pull/810/head
f 2 weeks ago
parent bc8d21f521
commit 29ac367fcb

@ -144,6 +144,8 @@ jobs:
return `Act as ${title}`; return `Act as ${title}`;
}; };
// First try to find prompts in README
let foundInReadme = false;
for (const file of files) { for (const file of files) {
console.log(`Processing file: ${file.filename}`); console.log(`Processing file: ${file.filename}`);
if (file.filename === 'README.md') { if (file.filename === 'README.md') {
@ -166,24 +168,30 @@ jobs:
prompts.set(actName.toLowerCase(), { actName, promptText, contributorInfo }); prompts.set(actName.toLowerCase(), { actName, promptText, contributorInfo });
console.log(`Found prompt in README: "${actName}"`); console.log(`Found prompt in README: "${actName}"`);
foundInReadme = true;
} }
} else if (file.filename === 'prompts.csv') { }
const patch = file.patch || ''; }
const addedLines = patch.split('\n')
.filter(line => line.startsWith('+')) // Only look in CSV if we didn't find anything in README
.map(line => line.substring(1)) if (!foundInReadme) {
.filter(line => line.trim()); // Remove empty lines console.log('No prompts found in README, checking CSV...');
for (const file of files) {
console.log('Attempting to extract prompts from CSV changes...'); if (file.filename === 'prompts.csv') {
for (const line of addedLines) { const patch = file.patch || '';
// Parse CSV line considering escaped quotes const addedLines = patch.split('\n')
const matches = [...line.matchAll(/"([^"]*(?:""[^"]*)*)"/g)]; .filter(line => line.startsWith('+'))
if (matches.length >= 2) { .map(line => line.substring(1))
const actName = normalizeTitle(matches[0][1].replace(/""/g, '"').trim()); .filter(line => line.trim()); // Remove empty lines
const promptText = matches[1][1].replace(/""/g, '"').trim();
console.log('Attempting to extract prompts from CSV changes...');
// Only add if not already found in README for (const line of addedLines) {
if (!prompts.has(actName.toLowerCase())) { // Parse CSV line considering escaped quotes
const matches = [...line.matchAll(/"([^"]*(?:""[^"]*)*)"/g)];
if (matches.length >= 2) {
const actName = normalizeTitle(matches[0][1].replace(/""/g, '"').trim());
const promptText = matches[1][1].replace(/""/g, '"').trim();
const contributorInfo = `Contributed by: [@${pr.user.login}](https://github.com/${pr.user.login})`; const contributorInfo = `Contributed by: [@${pr.user.login}](https://github.com/${pr.user.login})`;
prompts.set(actName.toLowerCase(), { actName, promptText, contributorInfo }); prompts.set(actName.toLowerCase(), { actName, promptText, contributorInfo });
console.log(`Found prompt in CSV: "${actName}"`); console.log(`Found prompt in CSV: "${actName}"`);

Loading…
Cancel
Save