mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-30 23:59:20 -08:00
Remember the terminal or web console choice, refresh the launcher model menus (v3.2.2)
AI Assisted
This commit is contained in:
1 parent
f1d087ba47
commit
ccf82c4eb7
60 files changed
+477
-317
No files matched your search
@@ -1,10 +1,12 @@
|
||||
// Fails when a built prompt names an agent product's tool by its product name.
|
||||
// Fails when a built prompt names an agent product's tool by its product name,
|
||||
// or bakes --web into a skill command.
|
||||
//
|
||||
// Prompts are read by many agents, and each one calls the same tool something
|
||||
// else. Prompt text says what to do ("ask with the question tool", "list the
|
||||
// folder") and never what one product's tool is called. This reads every
|
||||
// Markdown file in the built skills/ tree, so run it after
|
||||
// `node install.js --build-skills`.
|
||||
// folder") and never what one product's tool is called. Skill commands are
|
||||
// printed bare so the person's saved terminal or web console default decides;
|
||||
// a baked --web overrides it. This reads every Markdown file in the built
|
||||
// skills/ tree, so run it after `node install.js --build-skills`.
|
||||
// Usage: node scripts/check-prompt-wording.mjs [skillsDir] (defaults to ./skills)
|
||||
|
||||
import fs from "node:fs";
|
||||
@@ -29,6 +31,7 @@ export const BANNED = [
|
||||
];
|
||||
|
||||
const PATTERN = new RegExp(`(?<![A-Za-z0-9_])(${BANNED.join("|")})(?![A-Za-z0-9_])`);
|
||||
const BAKED_WEB_PATTERN = /`[^`\n]*\/plan2code[\w-]*[^`\n]*--web\b[^`\n]*`/g;
|
||||
|
||||
function* markdownFiles(dir) {
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
@@ -52,6 +55,21 @@ export function findBanned(dir) {
|
||||
return hits;
|
||||
}
|
||||
|
||||
// Returns [{ file, line, text }] for every skill command with --web baked in.
|
||||
export function findBakedWeb(dir) {
|
||||
const hits = [];
|
||||
for (const file of markdownFiles(dir)) {
|
||||
fs.readFileSync(file, "utf8")
|
||||
.split("\n")
|
||||
.forEach((lineText, i) => {
|
||||
for (const m of lineText.matchAll(BAKED_WEB_PATTERN)) {
|
||||
hits.push({ file: path.relative(dir, file).split(path.sep).join("/"), line: i + 1, text: m[0] });
|
||||
}
|
||||
});
|
||||
}
|
||||
return hits;
|
||||
}
|
||||
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
const root = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
||||
const dir = process.argv[2] ? path.resolve(process.argv[2]) : path.join(root, "skills");
|
||||
@@ -60,10 +78,18 @@ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.me
|
||||
process.exit(1);
|
||||
}
|
||||
const hits = findBanned(dir);
|
||||
const baked = findBakedWeb(dir);
|
||||
if (hits.length) {
|
||||
for (const h of hits) console.error(` FAIL ${h.file}:${h.line} names a product tool: ${h.name}`);
|
||||
console.error(" Say what to do in neutral words (\"the question tool\", \"list the folder\").");
|
||||
process.exit(1);
|
||||
} else {
|
||||
console.log("Built prompts name no product tool.");
|
||||
}
|
||||
console.log("Built prompts name no product tool.");
|
||||
if (baked.length) {
|
||||
for (const h of baked) console.error(` FAIL ${h.file}:${h.line} bakes --web into a skill command: ${h.text}`);
|
||||
console.error(" Write the command bare and add \"(add `--web` for the web console)\" after it: a baked flag overrides the person's saved terminal or web console default.");
|
||||
} else {
|
||||
console.log("Built prompts bake no --web into skill commands.");
|
||||
}
|
||||
if (hits.length || baked.length) process.exit(1);
|
||||
}
|
||||
Reference in new issue
Block a user