Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix: keep option-bearing npm gates opaque [S1,A1,A2]

Corey Olsonb8d50ccbb4f4
diff --git a/src/rule-proof-counts.js b/src/rule-proof-counts.js
index d0df7521..cfcbddf4 100644
--- a/src/rule-proof-counts.js
+++ b/src/rule-proof-counts.js
@@ -46,10 +46,17 @@ function selectedFiles(args, tracked, canonical) {
return files;
}
+/** Recognize only option-free npm test and npm run script commands; options leave the gate opaque. */
+function npmScriptName(words) {
+ if (words?.[0] !== 'npm') return null;
+ if (words[1] === 'test' && words.length === 2) return 'test';
+ return words[1] === 'run' && words.length === 3 && words[2] && !words[2].startsWith('-') ? words[2] : null;
+}
+
/** Known external tools leave the parent shell's directory/environment intact; shell builtins do not. */
function keepsShellContext(words) {
return words && (words[0] === 'node' || words[0] === process.execPath
- || words[0] === 'npm' && (words[1] === 'test' && words.length === 2 || words[1] === 'run' && words.length === 3));
+ || npmScriptName(words) !== null);
}
/** Resolve supported configured test commands at the receipt's committed source; opaque commands prove no file. */
@@ -62,12 +69,12 @@ function includedFiles(root, commit, command, tracked, depth = 0) {
return parts.length > 1 && parts.every(part => keepsShellContext(literalShellWords(part)))
? parts.flatMap(part => includedFiles(root, commit, part, tracked, depth + 1)) : [];
}
- if (words[0] === 'npm' && (words[1] === 'test' && words.length === 2 || words[1] === 'run' && words.length === 3)) {
+ if (npmScriptName(words) !== null) {
try {
const source = tryGit(root, ['show', `${commit}:package.json`]);
const manifest = JSON.parse(source.stdout);
if (Object.hasOwn(manifest, 'workspaces') || tracked.has('.npmrc')) return [];
- const script = manifest.scripts?.[words[1] === 'test' ? 'test' : words[2]];
+ const script = manifest.scripts?.[npmScriptName(words)];
return typeof script === 'string' ? includedFiles(root, commit, script, tracked, depth + 1) : [];
} catch { return []; }
}