Skip to content

feat(cli): add qq init and mark config paths as present or missing (OB5) - #147

Merged
lg2m merged 1 commit into
feat/eng-882-first-session-guidancefrom
feat/eng-879-init
Sep 23, 2026
Merged

lg2m merged 1 commit into
feat/eng-882-first-session-guidancefrom
feat/eng-879-init

Conversation

@lg2m

@lg2m lg2m commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Stack: #146 (OB8) → #147 (OB5) → #148 (OB9). Merge in that order; each PR is based on the previous branch and shows only its own diff. After merging one, retarget the next to main (GitHub does this automatically when the base branch is deleted on merge).

Plan slice OB5 of docs/plans/onboarding-ux.md. Linear: ENG-879.

User-visible behavior

qq init writes a short, commented starter config.ron:

$ qq init --model openai/gpt-5.6
wrote /home/u/.config/qq/config.ron (model: openai/gpt-5.6)

next: qq auth login openai          # or export OPENAI_API_KEY
then: qq
  • --project writes <cwd>/.qq/config.ron instead, with a comment block about qq trust and gitignored config.d/*-local.ron fragments, and adds note: run qq trust so this project's model is loaded.
  • Without --model on a terminal, it lists the five built-in login providers with an example model each and accepts a number or a full PROVIDER/MODEL. Without a terminal it errors: no --model given and stdin is not a terminal; pass --model PROVIDER/MODEL.
  • Refuses to overwrite: <path> already exists; pass --force to overwrite.
  • The "next" line adapts: browser sign-in for openai-codex, AWS credential chain for bedrock/bedrock-mantle, "declare it under providers:" for anything else.

qq config paths now prints global config: <global>/config.ron and appends (exists) / (missing) to every path.

The quickstart's mkdir + heredoc + awk block is replaced by one qq init line (README too).

Design notes

  • Logic lives in src/init.rs with injected ConfigPaths, cwd, reader, and writer (the doctor pattern), so tests run against a temp tree; InitError is a thiserror enum with actionable variants.
  • The file is written with create_new unless --force, mode 0600 in a 0700 global dir on unix; a project .qq/ is repository content and keeps default modes.
  • After writing, the document is validated through the ordinary ConfigLoader::check so the file the user runs with is the one that was checked. TrustRequired is accepted (a project file that sets model is pending trust by design); any other ConfigError is reported with the path so the user can edit it.
  • The model string is RON-escaped: a quote or backslash in the route cannot change the document's meaning.
  • No change to qq-config: route parsing is split_once('/') in the binary; ModelRoute::parse stays private.

Docs

docs/guide/quickstart.md § 2, docs/guide/configuration.md, docs/guide/cli.md (new ## qq init, paths row), docs/guide/troubleshooting.md, README.md. Ledger: OB5 → In review; OB0 → Shipped (#128); OB6 → Shipped (#139).

Verification

  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace — 1790 passed
  • 16 new tests (cli::tests::parses_init…, init::tests::*): writes and validates, unix modes, --project + trust note, refuse-then---force, four bad routes, ModelRequired, escaping round-trip, unknown provider surfaced as Invalid, codex/bedrock/other "next" lines, chooser by number / route / invalid answer, CHOICES names equal LOGIN_PROVIDERS.
  • Manual: cargo run -- init --help, cargo run -- config paths, interactive chooser under a pty.

Performance / compatibility

Startup-neutral (new subcommand only). qq config paths output gains one row and a trailing marker per line; scripts that parsed it with awk '{print $2}' still get the path (the marker is a separate field), and the one such script in our docs was replaced.

Notes

  • Running qq init (global) from inside an untrusted project directory validates only up to TrustRequired, so an unknown provider in the global file is not caught in that one case. Acceptable for this slice; qq config check after qq trust reports it.

`qq init [--project] [--model PROVIDER/MODEL] [--force]` writes a short,
commented config.ron to the global directory (0700/0600) or to
<cwd>/.qq/config.ron, validates it through the ordinary loader, and
prints the path plus the next command (`qq auth login PROVIDER # or
export VAR`, the browser sign-in for openai-codex, AWS for bedrock). It
refuses to overwrite without --force. Without --model on a terminal it
offers a numbered list of the built-in providers; without a terminal it
errors. The model string is escaped so a quote cannot change the
document. `qq config paths` now prints `global config` and appends
(exists)/(missing) to every path.

The quickstart's mkdir/heredoc/awk block is replaced by `qq init`.

Closes ENG-879.
@lg2m
lg2m force-pushed the feat/eng-879-init branch from fc1bfa3 to 10a0bc5 Compare September 23, 2026 22:29
@lg2m
lg2m changed the base branch from main to feat/eng-882-first-session-guidance September 23, 2026 22:29
@lg2m
lg2m added this pull request to stack #149 September 23, 2026 22:37
@lg2m
lg2m merged commit a410915 into main Sep 23, 2026
8 checks passed
@lg2m
lg2m deleted the feat/eng-879-init branch September 23, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant