feat(cli): install --init and init --yes for a one-shot, non-interactive bootstrap (#1578) - #1595
Open
colbymchenry wants to merge 1 commit into
Open
feat(cli): install --init and init --yes for a one-shot, non-interactive bootstrap (#1578)#1595colbymchenry wants to merge 1 commit into
install --init and init --yes for a one-shot, non-interactive bootstrap (#1578)#1595colbymchenry wants to merge 1 commit into
Conversation
…ractive bootstrap (#1578) A fresh container or CI job had to run two commands — `codegraph install --yes` and then `codegraph init` — and the second could still stop on a prompt (the gitignored-child-repos offer, the watch-fallback offer). The installer deliberately never indexes on its own (a surprise index of $HOME is exactly what `init` refuses), so the missing piece was an explicit opt-in, not a behavior change. - `codegraph install -i/--init` runs the `init` flow in the current directory after the agents are wired — also when nothing was wired (`--target none`, no agents detected), since the installer returns normally there. It shares every guard with `codegraph init`: an unsafe root (home directory, filesystem root, a parent of home) is refused with exit code 1 and no implied `--force`; an already-initialized project just says so and exits 0. Ignored by `--print-config` / `--refresh`, which return before the install. - `codegraph init -y/--yes` makes every post-index offer non-interactive: the ignored-repos offer prints its one-line opt-in snippet instead of prompting (the non-TTY behavior), and the watch-fallback offer takes its `yes` default. - The `init` action body is now `runInit()`, shared by both commands; the plain `init` path is behavior-identical. - The post-install "Next: index a project" note mentions the flag; README gets the flag row + a `--yes --init` example. Tests (`__tests__/cli-install-init.test.ts`, against the built binary, stdin closed, `--target none` so no agent config is touched): `install --yes --target none --init` builds `.codegraph/codegraph.db`; the same on an already-initialized project reports it and exits 0; at the filesystem root it refuses with exit 1 and writes nothing; `init --yes` completes with stdin closed; both flags appear in `--help`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LxZj6W6Y1SHXwvpT3uwJpK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1578.
What was wrong
Bootstrapping CodeGraph in a fresh environment — the issue's case is a throwaway container per AI session — took two commands,
codegraph install --yesand thencodegraph init, and the second one could still stop on a prompt (the gitignored-child-repos offer, the watch-fallback offer on WSL//mnt). There was no way to wire agents and build the project's index in one non-interactive line.The installer's "never index implicitly" rule is deliberate (a surprise index of
$HOMEis exactly whatinitrefuses), so the gap is an explicit opt-in, not a change in default behavior.What this does
codegraph install -i, --init— after wiring the agents, runs theinitflow in the current directory. It also runs when nothing was wired (--target none, no agents detected), since the installer returns normally in that case. Everyinitguard applies: a home directory / filesystem root / parent of home is refused with exit code 1 (no implied--force), and an already-initialized project just reports that and exits 0.--print-configand--refreshreturn before the install, so--initis a no-op with them.codegraph init -y, --yes— non-interactive: the ignored-repos offer prints its one-lineincludeIgnoredopt-in snippet instead of prompting (the existing non-TTY behavior), and the watch-fallback offer takes itsyesdefault.install --initpasses--yesthrough, socodegraph install --yes --initis a fully unattended bootstrap.initaction body becomesrunInit(), shared by both commands. The plaininitpath is behavior-identical (same refusal, already-initialized notice, supervised index, telemetry, offers, outro).--init; README gets the flag row and a--yes --initexample.On the reporter's other observation —
install --yesskipping the "install the CLI on your PATH" step: that's by design for scripted use (it assumes the CLI is already present), and thebunx @colbymchenry/codegraph serve --mcpMCP entry they found is the self-contained alternative. Not changed here.Tests
__tests__/cli-install-init.test.ts— end-to-end against the built binary with stdin closed (a blocking prompt would fail), always--target noneso the suite never touches an agent config on the host:install --yes --target none --init→ exit 0, installer reports nothing to wire,Initialized in <tmp>,.codegraph/codegraph.dbexists;Already initialized, exit 0;Refusing to initialize, nothing written;init --yeswith stdin closed → exit 0, index built;init --helplists-y, --yes,install --helplists-i, --init.npx vitest run __tests__/installer-targets.test.ts __tests__/upgrade.test.ts→ 283 passed, 3 skipped. Fullnpm test→ see the checks on this PR / below.🤖 Generated with Claude Code
https://claude.ai/code/session_01LxZj6W6Y1SHXwvpT3uwJpK