Merge pull request #3110 from patrickclery/fix/3100-search-dirs-colon-leaks

fix: replace stale /gsd: references in agents/, sdk/src/, and .clinerules
This commit is contained in:
Tom Boucher
2026-05-06 20:52:43 -04:00
committed by GitHub
9 changed files with 75 additions and 22 deletions

View File

@@ -18,8 +18,22 @@ const SEARCH_DIRS = [
path.join(__dirname, '..', 'get-shit-done', 'templates'),
path.join(__dirname, '..', 'get-shit-done', 'contexts'),
path.join(__dirname, '..', 'commands', 'gsd'),
path.join(__dirname, '..', 'agents'),
path.join(__dirname, '..', 'sdk', 'src'),
];
const EXTENSIONS = new Set(['.md', '.cjs', '.js']);
const TOP_LEVEL_FILES = [
path.join(__dirname, '..', '.clinerules'),
];
const SKIP_DIRS = new Set(['node_modules', 'dist', '.turbo']);
const EXTENSIONS = new Set(['.md', '.cjs', '.js', '.ts', '.tsx']);
// Test files contain intentional fixture strings (e.g. inputs the sanitizer
// is expected to strip). Rewriting them changes test semantics.
function isTestFile(name) {
return /\.test\.(c?js|tsx?)$/.test(name);
}
function buildPattern(cmdNames) {
// Empty input would compile `/gsd:()(?=[^a-zA-Z0-9_-]|$)/g`, which the regex
@@ -49,6 +63,19 @@ function readCmdNames() {
.map(f => f.replace(/\.md$/, ''));
}
function processFile(file, cmdNames) {
const pattern = buildPattern(cmdNames);
if (!pattern) return;
let src;
try { src = fs.readFileSync(file, 'utf-8'); } catch { return; }
const replaced = transformContent(src, cmdNames);
if (replaced !== src) {
fs.writeFileSync(file, replaced, 'utf-8');
const count = (src.match(pattern) || []).length;
console.log(` ${count} replacements: ${path.relative(path.join(__dirname, '..'), file)}`);
}
}
function processDir(dir, cmdNames) {
const pattern = buildPattern(cmdNames);
if (!pattern) return;
@@ -57,15 +84,10 @@ function processDir(dir, cmdNames) {
for (const e of entries) {
const full = path.join(dir, e.name);
if (e.isDirectory()) {
if (SKIP_DIRS.has(e.name)) continue;
processDir(full, cmdNames);
} else if (EXTENSIONS.has(path.extname(e.name))) {
const src = fs.readFileSync(full, 'utf-8');
const replaced = transformContent(src, cmdNames);
if (replaced !== src) {
fs.writeFileSync(full, replaced, 'utf-8');
const count = (src.match(pattern) || []).length;
console.log(` ${count} replacements: ${path.relative(path.join(__dirname, '..'), full)}`);
}
} else if (EXTENSIONS.has(path.extname(e.name)) && !isTestFile(e.name)) {
processFile(full, cmdNames);
}
}
}
@@ -75,7 +97,10 @@ if (require.main === module) {
for (const dir of SEARCH_DIRS) {
processDir(dir, cmdNames);
}
for (const file of TOP_LEVEL_FILES) {
processFile(file, cmdNames);
}
console.log('Done.');
}
module.exports = { transformContent, buildPattern };
module.exports = { transformContent, buildPattern, SKIP_DIRS };