duplicate
This commit is contained in:
parent
ed3854aa26
commit
bc8d21f521
|
@ -135,6 +135,15 @@ jobs:
|
|||
console.log('Analyzing changes to extract prompt information...');
|
||||
const prompts = new Map(); // Use Map to deduplicate prompts by title
|
||||
|
||||
// Helper function to normalize prompt titles
|
||||
const normalizeTitle = (title) => {
|
||||
title = title.trim();
|
||||
// Remove "Act as" or "Act as a" or "Act as an" from start if present
|
||||
title = title.replace(/^Act as (?:a |an )?/i, '');
|
||||
// Add "Act as" prefix
|
||||
return `Act as ${title}`;
|
||||
};
|
||||
|
||||
for (const file of files) {
|
||||
console.log(`Processing file: ${file.filename}`);
|
||||
if (file.filename === 'README.md') {
|
||||
|
@ -145,17 +154,17 @@ jobs:
|
|||
.join('\n');
|
||||
|
||||
console.log('Attempting to extract prompts from README changes...');
|
||||
const promptMatches = [...addedLines.matchAll(/## Act as (?:a |an )?([^\n]+)\n(?:Contributed by:[^\n]*\n)?(?:> )?([^#]+?)(?=\n##|\n\n##|$)/ig)];
|
||||
const promptMatches = [...addedLines.matchAll(/## (?:Act as (?:a |an )?)?([^\n]+)\n(?:Contributed by:[^\n]*\n)?(?:> )?([^#]+?)(?=\n##|\n\n##|$)/ig)];
|
||||
|
||||
for (const match of promptMatches) {
|
||||
const actName = `Act as ${match[1].trim()}`;
|
||||
const actName = normalizeTitle(match[1]);
|
||||
const promptText = match[2].trim();
|
||||
const contributorLine = addedLines.match(/Contributed by: \[@([^\]]+)\]\(https:\/\/github\.com\/([^\)]+)\)/);
|
||||
const contributorInfo = contributorLine
|
||||
? `Contributed by: [@${contributorLine[1]}](https://github.com/${contributorLine[2]})`
|
||||
: `Contributed by: [@${pr.user.login}](https://github.com/${pr.user.login})`;
|
||||
|
||||
prompts.set(actName, { actName, promptText, contributorInfo });
|
||||
prompts.set(actName.toLowerCase(), { actName, promptText, contributorInfo });
|
||||
console.log(`Found prompt in README: "${actName}"`);
|
||||
}
|
||||
} else if (file.filename === 'prompts.csv') {
|
||||
|
@ -170,13 +179,13 @@ jobs:
|
|||
// Parse CSV line considering escaped quotes
|
||||
const matches = [...line.matchAll(/"([^"]*(?:""[^"]*)*)"/g)];
|
||||
if (matches.length >= 2) {
|
||||
const actName = matches[0][1].replace(/""/g, '"').trim();
|
||||
const actName = normalizeTitle(matches[0][1].replace(/""/g, '"').trim());
|
||||
const promptText = matches[1][1].replace(/""/g, '"').trim();
|
||||
|
||||
// Only add if not already found in README
|
||||
if (!prompts.has(actName)) {
|
||||
if (!prompts.has(actName.toLowerCase())) {
|
||||
const contributorInfo = `Contributed by: [@${pr.user.login}](https://github.com/${pr.user.login})`;
|
||||
prompts.set(actName, { actName, promptText, contributorInfo });
|
||||
prompts.set(actName.toLowerCase(), { actName, promptText, contributorInfo });
|
||||
console.log(`Found prompt in CSV: "${actName}"`);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue