From cd60a3d0e206358f209d28a1875b8d58a19b0e52 Mon Sep 17 00:00:00 2001 From: glorydavid03023 Date: Wed, 3 Jun 2026 01:04:08 -0500 Subject: [PATCH 1/2] feat(mcp): add version command and clearer unknown-command guidance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a `version` command (with `--version` and `-v` aliases) to the gittensory-mcp CLI. It prints the installed package version, the targeted API version, and the Node.js runtime version, with a `--json` form for tooling and bug reports. Previously the version constant existed in the binary but had no command surface — the conventional `--version` flag was missing. Also point the unknown-command error at `gittensory-mcp --help` so a mistyped command guides the user to the command list instead of a bare "Unknown command" message. Tests cover the plain output for all three aliases, the machine-readable `--json` payload, and the unknown-command guidance. Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/gittensory-mcp/README.md | 4 ++++ packages/gittensory-mcp/bin/gittensory-mcp.js | 13 +++++++++++- test/unit/mcp-cli.test.ts | 20 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/packages/gittensory-mcp/README.md b/packages/gittensory-mcp/README.md index b49e8d60c0..61abf135dc 100644 --- a/packages/gittensory-mcp/README.md +++ b/packages/gittensory-mcp/README.md @@ -27,6 +27,8 @@ npm link --workspace @jsonbored/gittensory-mcp ## Commands ```sh +gittensory-mcp version +gittensory-mcp version --json gittensory-mcp login gittensory-mcp logout gittensory-mcp whoami @@ -52,6 +54,8 @@ gittensory-mcp agent explain --json gittensory-mcp --stdio ``` +`gittensory-mcp version` (aliases `--version` and `-v`) prints the installed package version, the targeted API version, and the Node.js runtime version. Add `--json` for machine-readable output. + For near-term what-if scoreability, pass the situational assumptions explicitly: ```sh diff --git a/packages/gittensory-mcp/bin/gittensory-mcp.js b/packages/gittensory-mcp/bin/gittensory-mcp.js index 8aa9d61d98..be5d5a8f06 100755 --- a/packages/gittensory-mcp/bin/gittensory-mcp.js +++ b/packages/gittensory-mcp/bin/gittensory-mcp.js @@ -485,6 +485,7 @@ await server.connect(new StdioServerTransport()); async function runCli(args) { const command = args[0]; if (command === "--help" || command === "help") return printHelp(); + if (command === "--version" || command === "-v" || command === "version") return printVersion(parseOptions(args.slice(1))); if (command === "agent") return runAgentCli(args.slice(1)); if (command === "cache") return runCacheCli(args.slice(1)); const options = parseOptions(args.slice(1)); @@ -498,7 +499,7 @@ async function runCli(args) { if (command === "init-client") return initClient(options); if (command === "decision-pack") return decisionPackCli(options); if (command === "repo-decision") return repoDecisionCli(options); - if (command !== "analyze-branch" && command !== "preflight") throw new Error(`Unknown command: ${command}`); + if (command !== "analyze-branch" && command !== "preflight") throw new Error(`Unknown command: ${command}. Run \`gittensory-mcp --help\` to list commands.`); const contributorLogin = options.login ?? process.env.GITTENSORY_LOGIN ?? process.env.GITHUB_LOGIN; if (!contributorLogin) throw new Error("Pass --login or set GITTENSORY_LOGIN."); const result = await analyzeCurrentBranch({ @@ -719,9 +720,19 @@ function isUnsafePublicPacketText(value) { return /\b(reward\w*|score\w*|wallet|hotkey|coldkey|mnemonic|farming|payout|ranking|raw[-_\s]?trust|trust[-_\s]?score|private[-_\s]?reviewability|reviewability)\b|\/Users\/|\/home\/|\/tmp\/|[A-Z]:\\Users\\/i.test(value); } +function printVersion(options) { + const payload = { name: packageName, version: packageVersion, apiVersion: currentApiVersion, node: process.version }; + if (options.json) { + process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`); + return; + } + process.stdout.write(`${packageName}/${packageVersion} (node ${process.version})\n`); +} + function printHelp() { process.stdout.write(`Usage: gittensory-mcp --stdio + gittensory-mcp version [--json] gittensory-mcp login [--profile name] [--github-token ] [--json] gittensory-mcp logout [--profile name] [--all] [--json] gittensory-mcp whoami [--profile name] [--json] diff --git a/test/unit/mcp-cli.test.ts b/test/unit/mcp-cli.test.ts index f6aae2771a..b4db41ba1e 100644 --- a/test/unit/mcp-cli.test.ts +++ b/test/unit/mcp-cli.test.ts @@ -900,6 +900,26 @@ describe("gittensory-mcp CLI", () => { it("rejects unsupported client snippets", () => { expect(() => run(["init-client", "--print", "other"])).toThrow(/Unsupported client/); }); + + it("reports the package version via version, --version, and -v", () => { + const expected = "@jsonbored/gittensory-mcp/0.4.0"; + expect(run(["version"]).trim()).toContain(expected); + expect(run(["--version"]).trim()).toContain(expected); + expect(run(["-v"]).trim()).toContain(expected); + }); + + it("emits machine-readable version output with --json", () => { + const payload = JSON.parse(run(["version", "--json"])) as { name: string; version: string; apiVersion: string; node: string }; + expect(payload.name).toBe("@jsonbored/gittensory-mcp"); + expect(payload.version).toBe("0.4.0"); + expect(payload.apiVersion).toBe("0.1.0"); + expect(payload.node).toBe(process.version); + }); + + it("guides unknown commands to --help", () => { + expect(() => run(["bogus-command"])).toThrow(/Unknown command: bogus-command/); + expect(() => run(["bogus-command"])).toThrow(/gittensory-mcp --help/); + }); }); function run(args: string[], env: Record = {}) { From 184a4643ddff6211af1e80a2dd5ace907c5efffc Mon Sep 17 00:00:00 2001 From: glorydavid03023 Date: Wed, 3 Jun 2026 20:26:49 -0500 Subject: [PATCH 2/2] docs(mcp): align version output and README, assert all three fields Address review feedback on #333: - Include the targeted API version in the plain `version` output so it matches the README description (package version, API version, Node runtime). Output is now `name/version (api X, node vY)`. - Add concrete plain and --json output examples to the README. - Strengthen the test to assert the plain form reports all three fields. Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/gittensory-mcp/README.md | 17 ++++++++++++++++- packages/gittensory-mcp/bin/gittensory-mcp.js | 2 +- test/unit/mcp-cli.test.ts | 10 +++++++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/packages/gittensory-mcp/README.md b/packages/gittensory-mcp/README.md index 61abf135dc..2328674aeb 100644 --- a/packages/gittensory-mcp/README.md +++ b/packages/gittensory-mcp/README.md @@ -54,7 +54,22 @@ gittensory-mcp agent explain --json gittensory-mcp --stdio ``` -`gittensory-mcp version` (aliases `--version` and `-v`) prints the installed package version, the targeted API version, and the Node.js runtime version. Add `--json` for machine-readable output. +`gittensory-mcp version` (aliases `--version` and `-v`) prints the installed package version, the targeted API version, and the Node.js runtime version: + +```text +@jsonbored/gittensory-mcp/0.4.0 (api 0.1.0, node v22.12.0) +``` + +Add `--json` for machine-readable output: + +```json +{ + "name": "@jsonbored/gittensory-mcp", + "version": "0.4.0", + "apiVersion": "0.1.0", + "node": "v22.12.0" +} +``` For near-term what-if scoreability, pass the situational assumptions explicitly: diff --git a/packages/gittensory-mcp/bin/gittensory-mcp.js b/packages/gittensory-mcp/bin/gittensory-mcp.js index be5d5a8f06..3f370a6a2d 100755 --- a/packages/gittensory-mcp/bin/gittensory-mcp.js +++ b/packages/gittensory-mcp/bin/gittensory-mcp.js @@ -726,7 +726,7 @@ function printVersion(options) { process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`); return; } - process.stdout.write(`${packageName}/${packageVersion} (node ${process.version})\n`); + process.stdout.write(`${packageName}/${packageVersion} (api ${currentApiVersion}, node ${process.version})\n`); } function printHelp() { diff --git a/test/unit/mcp-cli.test.ts b/test/unit/mcp-cli.test.ts index b4db41ba1e..3418ea523c 100644 --- a/test/unit/mcp-cli.test.ts +++ b/test/unit/mcp-cli.test.ts @@ -903,9 +903,13 @@ describe("gittensory-mcp CLI", () => { it("reports the package version via version, --version, and -v", () => { const expected = "@jsonbored/gittensory-mcp/0.4.0"; - expect(run(["version"]).trim()).toContain(expected); - expect(run(["--version"]).trim()).toContain(expected); - expect(run(["-v"]).trim()).toContain(expected); + for (const flag of ["version", "--version", "-v"]) { + const plain = run([flag]).trim(); + expect(plain).toContain(expected); + // The plain form reports all three values the README documents. + expect(plain).toContain("api 0.1.0"); + expect(plain).toContain(`node ${process.version}`); + } }); it("emits machine-readable version output with --json", () => {