Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.
TypeScript ai-agentsanthropicclaude-codeclicode-graphcodexcontext-engineeringcursordeveloper-toolsgeminiknowledge-graphllmmcpmcp-serveropen-sourceopenaitree-sitter
fix(viz): judge --tabs before the repo, not after (#223)
anirudhkumar-nanonets780ef7396c82
diff --git a/src/cli.ts b/src/cli.tsindex 43103619..fc83c6e7 100644--- a/src/cli.ts+++ b/src/cli.ts@@ -615,6 +615,10 @@ program.option("--title <text>", "subtitle shown beside the repo name in an exported page (e.g. \"PR #151\")").option("--tabs <list>", "tabs the exported page offers, comma separated: context,code,outline (default: all three)").action(async (dirArg: string | undefined, opts: { port: string; open: boolean; export?: string; title?: string; tabs?: string }) => {+ // Flags are checked before the repository is: a typo'd `--tabs` is a mistake+ // in the command the caller just typed, and telling them to go build an index+ // first sends them off to fix the wrong thing.+ const tabs = parseTabs(opts.tabs);const dir = noteQuery(queryRoot(dirArg));const { existsSync } = await import("node:fs");const { resolve, basename } = await import("node:path");@@ -640,7 +644,7 @@ programoutDir: resolve(opts.export),repoName: basename(root),subtitle: opts.title,- tabs: parseTabs(opts.tabs),+ tabs,});const kb = Math.round(out.bytes / 1024);console.log(diff --git a/test/viz-export.test.ts b/test/viz-export.test.tsindex f7f1b9fc..fe6b58ed 100644--- a/test/viz-export.test.ts+++ b/test/viz-export.test.ts@@ -193,8 +193,14 @@ test("viz --tabs: a bad tab name fails loudly rather than exporting a page missi}};- const bad = run(["viz", ".", "--export", out(), "--tabs", "context,graph"]);+ // Deliberately run where there is NO graft index — CI is such a checkout, and+ // the first version of this test only passed on a machine that happened to have+ // one, so it broke main the day it merged.+ const bare = out();+ const bad = run(["viz", bare, "--export", out(), "--tabs", "context,graph"]);assert.equal(bad.status, 1);assert.match(bad.stderr, /--tabs takes a comma-separated subset of context, code, outline — got "graph"/);- assert.equal(run(["viz", ".", "--export", out(), "--tabs", ""]).status, 1, "an empty list is a mistake too");+ assert.equal(run(["viz", bare, "--export", out(), "--tabs", ""]).status, 1, "an empty list is a mistake too");+ // …and the flag is judged on its own: an unbuilt repo is a different complaint.+ assert.match(run(["viz", bare, "--export", out()]).stderr, /no context graph/);});