// 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. 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"; import path from "node:path"; import { fileURLToPath } from "node:url"; // Case-sensitive on purpose: "glob" and "grep" in lower case are ordinary words // and command names, "Glob" and "Grep" as tool names are what this catches. export const BANNED = [ "AskUserQuestion", "Glob", "Grep", "TodoWrite", "WebFetch", "WebSearch", "NotebookEdit", "Read tool", "Write tool", "Edit tool", "Bash tool", "ask_user_question", ]; const PATTERN = new RegExp(`(? { const m = PATTERN.exec(text); if (m) hits.push({ file: path.relative(dir, file).split(path.sep).join("/"), line: i + 1, name: m[1] }); }); } 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"); if (!fs.existsSync(dir)) { console.error(` FAIL ${dir} does not exist. Run: node install.js --build-skills`); 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\")."); } else { 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); }