Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

fix(cli): reject unknown options and extra positionals in render (#303)

tt-a1i5769acefcc2e
diff --git a/archify.zip b/archify.zip
index abbbc111..e64f6fa9 100644
Binary files a/archify.zip and b/archify.zip differ
diff --git a/archify/bin/archify.mjs b/archify/bin/archify.mjs
index 2b8cc7a7..034342ea 100755
--- a/archify/bin/archify.mjs
+++ b/archify/bin/archify.mjs
@@ -696,8 +696,15 @@ async function commandCompare(args) {
function commandRender(args) {
const qualityArgs = extractQualityArgs(args);
const repoArgs = extractRepoRootArgs(qualityArgs.rest);
+ // render takes no options of its own once --quality and --repo-root are
+ // stripped, so anything left starting with -- is a typo. Without this a
+ // mistyped flag was taken as the output path: `render architecture spec.json
+ // --json out.html` wrote a file literally named `--json` and never wrote
+ // out.html, exiting 0. Every sibling subcommand already guards this.
+ const unknown = repoArgs.rest.filter((arg) => arg.startsWith('--'));
+ if (unknown.length) fail(`Unknown render option "${unknown[0]}".`);
const [type, input, output] = repoArgs.rest;
- if (!type || !input) fail(usage());
+ if (!type || !input || repoArgs.rest.length > 3) fail(usage());
assertEvidenceType(type, repoArgs.repoRoot);
const result = runNode([rendererPath(type), input, ...(output ? [output] : [])], {
env: rendererEnv(qualityArgs.quality, repoArgs.repoRoot),
diff --git a/archify/test/cli.test.mjs b/archify/test/cli.test.mjs
index 8cf6198e..56d48fb2 100644
--- a/archify/test/cli.test.mjs
+++ b/archify/test/cli.test.mjs
@@ -807,3 +807,28 @@ test('cli: validate rejects an unknown type without leaking a temp directory', (
});
process.on('exit', () => fs.rmSync(tmp, { recursive: true, force: true }));
+
+test('render rejects a mistyped option instead of writing a file named after it', () => {
+ const dir = fs.mkdtempSync(path.join(tmp, 'render-guard-'));
+ const spec = path.join(dir, 'spec.json');
+ fs.copyFileSync(path.join(skillRoot, '../examples/archify-repo.architecture.json'), spec);
+
+ // Without the guard this wrote a 600KB file literally named `--json` and
+ // never wrote out.html, exiting 0.
+ const result = run(['render', 'architecture', spec, '--json', 'out.html'], { cwd: dir });
+
+ assert.notEqual(result.status, 0);
+ assert.match(result.stderr, /Unknown render option/);
+ assert.deepEqual(fs.readdirSync(dir), ['spec.json']);
+});
+
+test('render rejects an extra positional argument', () => {
+ const dir = fs.mkdtempSync(path.join(tmp, 'render-arity-'));
+ const spec = path.join(dir, 'spec.json');
+ fs.copyFileSync(path.join(skillRoot, '../examples/archify-repo.architecture.json'), spec);
+
+ const result = run(['render', 'architecture', spec, 'out.html', 'extra.html'], { cwd: dir });
+
+ assert.notEqual(result.status, 0);
+ assert.deepEqual(fs.readdirSync(dir), ['spec.json']);
+});