feat(cli): improve tigris init and add npx tigris alias - #230
Conversation
Greptile SummaryThis PR improves CLI detection and agent setup instructions while adding an unscoped
Confidence Score: 4/5The PR should not merge until The newly advertised npx path inherits a temporary Files Needing Attention: packages/cli/src/lib/init/index.ts and packages/cli/src/lib/init/shared.ts Important Files Changed
Reviews (1): Last reviewed commit: "feat(cli): skip CLI install in init when..." | Re-trigger Greptile |
e579f48 to
810ad19
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 810ad19. Configure here.
`tigris init` advertised and ran a CLI install step even when `tigris` was already on PATH. It now installs only when the CLI is missing and updates it otherwise, and the CLI is reachable unscoped as `npx tigris`. - Move the PATH check ahead of the mode prompt so the "Defaults" hint drops `CLI - Global` when the CLI is already installed. - Replace the bespoke registry fetch with a delegation to `tigris update`, which runs its own version check and picks the upgrade path matching how the CLI was installed (npm / Homebrew / standalone binary). Removes `fetchLatestVersionCapped` and its ref'd-timer handling. - Ignore package-runner bin directories when looking for an installed CLI. `npx`, `pnpm dlx`, `yarn dlx` and `bunx` all unpack into a throwaway tree and put its `.bin` on PATH for one run, so an unfiltered probe finds a copy that vanishes when the runner exits — and init would tell the agent to update a CLI that was never installed. The directory is derived from this process's own location rather than from each manager's cache layout, and is stripped for the whole command so the update and handoff paths can't reach it either. - Fall back to `npx` for the agent handoff when an update fails and leaves a CLI predating `init --agent` (< 3.5.0), probed rather than version-matched. - Build the `--agent` recipe from a step list so it opens with a single CLI step chosen from what `init` detected — install when missing, update when present — instead of two steps behind `if tigris isn't on $PATH` conditions. - Add `packages/tigris`: an unscoped alias whose bin imports `@tigrisdata/cli`, so argv, stdio, signals and exit codes pass through unchanged. Held to the CLI's version by a Changesets `fixed` group so the alias can't drift. - Add tests for the recipe, the defaults hint, and the PATH filtering; init had none. Assisted-by: Claude Opus 5 via Claude Code Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
810ad19 to
c49efff
Compare

Summary
Two changes to
tigris init, plus the package that makesnpx tigris initwork.initno longer offers to install a CLI you already haveThe wizard advertised
CLI - Globalin its "Defaults" hint and ran a CLI step on every run, regardless of whethertigriswas already on PATH. Now:The PATH check moved ahead of the mode prompt, so the hint reflects reality:
tigrison PATHMCP - Global, Skills - ProjectCLI - Global, MCP - Global, Skills - ProjectAn existing install is updated rather than reinstalled, by delegating to
tigris update. That command runs its own registry check andgetUpdateCommand()picks the path matching how the CLI was installed —npm install -g,brew upgrade tigris, or the curl/PowerShell installer for standalone binaries. Forcingnpm install -gfrominitcould fail or leave a second copy on PATH. It's a no-op when current, so nothing needs checking before calling it — which let the bespokefetchLatestVersionCappedhelper and its ref'd-timer handling go away entirely.If that update fails (offline, no write permission), it can leave a CLI predating
init --agentin place. Handing such an agenttigris init --agentjust errors, so the handoff degrades tonpx. Detected by probing (--agentonly writes to stdout, captured and discarded) rather than comparing against a hardcoded3.5.0, so it stays correct as the recipe moves.init --agentpicks the CLI step instead of delegating the decisionThe recipe used to print both branches and let the agent evaluate them:
initalready knows which applies, so it now emits one unambiguous step and renumbers the rest:New
tigrispackageAn unscoped alias so the CLI is reachable without the scope:
bin.jsis one line —import '@tigrisdata/cli'— which runs the CLI in-process, so argv, stdio, signals and exit codes all pass through unchanged, and--version/help still report the real CLI (Commander takes its program name fromspecs.yaml, not the filename). Every command works, not justinit..changeset/config.jsongains"fixed": [["@tigrisdata/cli", "tigris"]]so the alias can never drift from the CLI it wraps.Testing
pnpm test— 811 pass, 214 skipped. Addedtest/lib/init/{plan,shared}.test.ts(10 tests);inithad none before.pnpm lint,tsc --noEmit, and the binarytsconfig.binary.jsontypecheck all clean.publintclean on both packages.tigrison PATH.init --agentshipped in 3.5.0: 3.4.3 and older exit 1 withunknown option '--agent', which is what the handoff probe keys on.tigrisandt3bins work, including throughnpx.changeset versionand reverted: both packages land on3.7.0.npm trusted publishing must be configured for the
tigrispackage name. The release workflow publishes via OIDC with noNODE_AUTH_TOKEN, andtigriscurrently exists on npm as a0.0.0placeholder that predates this repo. If the trusted publisher isn't set up,@tigrisdata/cli@3.7.0will publish andtigriswill fail — leavingnpx tigrisresolving to the placeholder, which the wizard's fallback handoff now points users at.Follow-up (not in this PR)
initisn't in the generated CLI README at all — #203 added the command without runningpnpm updatedocs. Regenerating produces a large unrelated diff, so I left it out; happy to do it separately.🤖 Generated with Claude Code
Note
Medium Risk
Onboarding and global npm publish path change; mistaken PATH handling could mis-detect installs, and the new tigris package must publish correctly or npx handoffs break.
Overview
tigris initnow treats an on-PATH CLI as already installed: the Defaults hint omits CLI - Global, existing installs are refreshed viatigris update(not forcednpm install -g), and the agent handoff usesnpx tigris init --agentwhen update fails or the CLI is too old forinit --agent.When run via
npx/pnpm dlx,PATHis scrubbed of throwaway runner.bindirs so init does not mistake the ephemeral binary for a real install.tigris init --agentprints one resolved first step (install or update) viabuildAgentSetup, instead of both PATH branches for the agent to interpret.Adds the unscoped
tigrispackage (re-exports@tigrisdata/cli) sonpx tigrisworks; changesets fixed@tigrisdata/cliandtigristogether. New tests cover the agent recipe and PATH helpers.Reviewed by Cursor Bugbot for commit c49efff. Bugbot is set up for automated code reviews on this repo. Configure here.