Skip to content

feat: disableCommands to turn off the mcp and plugin built-ins (#200) - #202

Merged
garretpremo merged 3 commits into
devfrom
issues/200-disable-commands
Nov 5, 2026
Merged

garretpremo merged 3 commits into
devfrom
issues/200-disable-commands

Conversation

@garretpremo

Copy link
Copy Markdown
Contributor

Closes #200

Summary

A CLI can now turn off the optional mcp and plugin built-ins with disableCommands, set in .apijack/settings.json or passed to createCli. After an update, plugin install is re-run only when it still applies.

What changes

disableCommands

  • New ProjectSettings.disableCommands / CliOptions.disableCommands (DisableableCommand = 'mcp' | 'plugin', exported).
  • Allowed values are mcp and plugin. Unknown entries and non-arrays are dropped with the standard settings warning.
  • commandGates() (src/command-gates.ts) is the one place that decides what's on. Turning off mcp also turns off plugin.
  • A turned-off command isn't registered.
  • Help now tells built-ins apart by their Commander Command instances instead of by name. With a built-in off, an API group that shares its name (e.g. a mcp tag) is listed as an API command and goes through the first-run setup like any other.

Updates

  • src/post-update.ts: shouldReinstallPlugin() and refreshAfterUpdate() replace the two inline plugin install re-runs in upgrade and src/updater.ts.
  • plugin install is re-run only when mcp and plugin are on and the plugin was installed before (its marketplace directory exists). Previously it ran unconditionally, including for users who had never installed it.
  • bin/apijack.ts now checks for updates after loading project settings, so it can apply the same rule.

Docs

  • "Turning off built-in commands" section in CLAUDE.md, AGENTS.md and GEMINI.md. The wiki is updated at release time.

Acceptance criteria

  • { "disableCommands": ["mcp"] } removes mcp and plugin from --help; plugins stays
  • ["plugin"] removes only plugin
  • Unknown entries and non-arrays are dropped with a warning
  • Updates don't re-run plugin install when it's off or was never installed
  • Documented in the agent guides

Test plan

  • bun test: 1343 pass, 0 fail
  • bun run lint: 0 errors
  • bunx tsc --noEmit -p .: no new errors (same 9 pre-existing files as dev)
  • New tests: tests/settings.test.ts (validation), tests/cli-builder.test.ts (disableCommands: help, unknown command, same-named API group in help and first-run setup), tests/post-update.test.ts, tests/command-gates.test.ts, tests/bin-apijack.integration.test.ts (settings.json reaches createCli end to end)

A CLI can now leave out the optional `mcp` and `plugin` commands via
`.apijack/settings.json` `disableCommands` or `createCli({ disableCommands })`.
Turning off `mcp` also turns off `plugin`. Unknown entries are dropped with
the standard settings warning.

Updates (`upgrade` and the startup update prompt) now re-run
`plugin install` only when both commands are enabled and the plugin was
installed before. The shared binary checks for updates after loading
project settings so it can apply that rule.
…ps as built-ins

`commandGates()` is now the one place that decides whether `mcp` and
`plugin` are on; createCli and the shared binary both use it.

With a built-in turned off, an API group that shares its name (e.g. a
`mcp` tag) was still listed under the core commands and skipped the
first-run setup prompt. Help now tells built-ins apart by their Command
instances, and `mcp` / `plugin` skip auth only while the built-in exists.
@github-actions github-actions Bot added the needs review Open PR awaiting review label Nov 5, 2026
@garretpremo garretpremo added review in progress Review is actively underway and removed needs review Open PR awaiting review labels Nov 5, 2026

@garretpremo garretpremo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Automated review by claude — generated by the review-issue skill. Treat as advisory; a human still owns the merge decision.

All five acceptance criteria from #200 are met. disableCommands is validated in settings.ts, gated in one place (commandGates()), carried from settings.json through bin/apijack.ts into createCli, and documented in CLAUDE.md, AGENTS.md and GEMINI.md. Updates re-run plugin install only when it's on and was installed before, which works because uninstallPlugin removes the marketplace dir. Help now picks out built-ins by their Command instances, so a same-named API group is listed and authed as an API command. I checked out the branch locally: bun test gave 1343 pass / 0 fail, lint had 0 errors, there are no new type errors in the changed files, and CI is green on b979993.

Non-blocking observations
  • The update check now runs later in bin/apijack.ts. It used to be the first thing the binary did. Now it runs after .env loading, loadProjectAuth(), getActiveEnvConfig() and new URL(env.url). So if .apijack/auth.ts throws on import, or a saved config URL is malformed, the update prompt never appears. Before, it did, which gave a user a way to update out of a broken release. That's unlikely to matter much, and it's the price of reading settings.json first. One side effect is good: APIJACK_SKIP_UPDATE set in a project .env is now honored.
  • The "running it is an unknown-command error" docs line has a TTY exception. With mcp off, mcp drops out of skipAuthCommands. So in a TTY with no saved environment, <cli> mcp hits the first-run setup prompt before Commander reports the unknown command. Any typo'd command already behaves this way, so this isn't a regression. It's just slightly different from what the docs promise.
  • The update-path wiring has no test. shouldReinstallPlugin() and refreshAfterUpdate() have unit tests. Nothing tests that registerUpgradeCommand(..., { reinstallPlugin }) and checkForUpdate(..., { reinstallPlugin }) actually pass the flag on, for example that upgrade with disableCommands: ['plugin'] spawns nothing. The wiring is a one-liner, so the risk is low.
  • The shipped skills/write-routine/SKILL.md table doesn't mention disableCommands. Its .apijack/settings.json row (around line 317) still lists only customCommands.defaults.requiresAuth. The criterion only asks for the agent guides, and those are covered.
Nitpicks
  • bin/apijack.ts: with the old // 2. Check for updates block gone, the step comments jump from // 1. to // 3., and the moved check is labeled // 8b..

@garretpremo garretpremo added first pass reviewed Review passed with no blocking issues and removed review in progress Review is actively underway labels Nov 5, 2026

@garretpremo garretpremo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Final review by claude — generated by the final-review skill. CI is green, no blockers, soak window elapsed. Marking approved and merging.

Approved.

Outstanding observations from first-pass review

  • The update check now runs later in bin/apijack.ts. It used to be the first thing the binary did. Now it runs after .env loading, loadProjectAuth(), getActiveEnvConfig() and new URL(env.url). So if .apijack/auth.ts throws on import, or a saved config URL is malformed, the update prompt never appears. Before, it did, which gave a user a way to update out of a broken release. That's unlikely to matter much, and it's the price of reading settings.json first. One side effect is good: APIJACK_SKIP_UPDATE set in a project .env is now honored.
  • The "running it is an unknown-command error" docs line has a TTY exception. With mcp off, mcp drops out of skipAuthCommands. So in a TTY with no saved environment, <cli> mcp hits the first-run setup prompt before Commander reports the unknown command. Any typo'd command already behaves this way, so this isn't a regression. It's just slightly different from what the docs promise.
  • The update-path wiring has no test. shouldReinstallPlugin() and refreshAfterUpdate() have unit tests. Nothing tests that registerUpgradeCommand(..., { reinstallPlugin }) and checkForUpdate(..., { reinstallPlugin }) actually pass the flag on, for example that upgrade with disableCommands: ['plugin'] spawns nothing. The wiring is a one-liner, so the risk is low.
  • The shipped skills/write-routine/SKILL.md table doesn't mention disableCommands. Its .apijack/settings.json row (around line 317) still lists only customCommands.defaults.requiresAuth. The criterion only asks for the agent guides, and those are covered.

@garretpremo
garretpremo merged commit 0a6c3a4 into dev Nov 5, 2026
12 checks passed
@garretpremo garretpremo added approved PR has been fully approved and is ready to merge and removed first pass reviewed Review passed with no blocking issues labels Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved PR has been fully approved and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant