feat(config): TOML config and state, token resolution, host selection #25

Merged
deadstyle merged 3 commits from feature/5-config into develop 2026-10-02 12:13:31 -05:00
Owner

Summary

The config layer for #5: lazyforge can load, check and save its settings (config.toml) and remembered values (state.toml), get a sign-in token, and pick which host to connect to. The onboarding, Settings and host-picker screens moved to #24.

Changes

  • New internal/config package (ADR 0004):
    • load, validate (errors name the field) and atomically save config and state, at XDG / macOS paths
    • a pasted token requires a 0600 file, and the file is always written 0600
  • token_cmd runs through sh -c with a 10s timeout. The token and the command's output never appear in errors.
  • "Only merge when CI is green": require_green_ci per host, plus a per-repo override under [hosts.<name>.repos."owner/name"]. Off by default (PM decision, #13).
  • Host selection works in this order: --host, the only host, default_host, otherwise the picker (#24).
  • cmd/lazyforge has --config and --host flags, and prints the selected host until the UI exists.
  • The docs/architecture.md config example now shows the CI setting.

Test plan

  • Tests for acceptance criteria 1–9 and paths, written from the scope before the code existed.
  • Mutation check: 43 one-at-a-time mutations, each turned a test red on its assertion, and every test function was killed at least once.
  • make check exit 0: format, lint (0 issues), go test -race, govulncheck ("No vulnerabilities found"), build.

Rulings

  • Scope came from ADR 0004 and the architecture doc, without a planner.
  • The file is always written 0600, not only when it holds a token.
  • The 10s timeout value itself has no test. The timeout and cancel behavior is tested.

Closes #5

🤖 Generated with Claude Code

## Summary The config layer for #5: lazyforge can load, check and save its settings (`config.toml`) and remembered values (`state.toml`), get a sign-in token, and pick which host to connect to. The onboarding, Settings and host-picker screens moved to #24. ## Changes - New `internal/config` package (ADR 0004): - load, validate (errors name the field) and atomically save config and state, at XDG / macOS paths - a pasted token requires a 0600 file, and the file is always written 0600 - `token_cmd` runs through `sh -c` with a 10s timeout. The token and the command's output never appear in errors. - "Only merge when CI is green": `require_green_ci` per host, plus a per-repo override under `[hosts.<name>.repos."owner/name"]`. Off by default (PM decision, #13). - Host selection works in this order: `--host`, the only host, `default_host`, otherwise the picker (#24). - `cmd/lazyforge` has `--config` and `--host` flags, and prints the selected host until the UI exists. - The `docs/architecture.md` config example now shows the CI setting. ## Test plan - Tests for acceptance criteria 1–9 and paths, written from the scope before the code existed. - Mutation check: 43 one-at-a-time mutations, each turned a test red on its assertion, and every test function was killed at least once. - `make check` exit 0: format, lint (0 issues), `go test -race`, govulncheck ("No vulnerabilities found"), build. ## Rulings - Scope came from ADR 0004 and the architecture doc, without a planner. - The file is always written 0600, not only when it holds a token. - The 10s timeout value itself has no test. The timeout and cancel behavior is tested. Closes #5 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Adds internal/config (TOML config + state, atomic 0600 writes, host
selection, token resolution) and the --config/--host flags.

#5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Red-first tests for #5; the config package does not exist yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix(config): bound token_cmd wait after kill, inline tomlEncode
All checks were successful
ci / check (pull_request) Successful in 55s
5d89140fcb
Refs #5. Without WaitDelay a grandchild holding stdout open stalls
ResolveToken past the timeout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
deadstyle merged commit e4bec915da into develop 2026-10-02 12:13:31 -05:00
deadstyle deleted branch feature/5-config 2026-10-02 12:13:32 -05:00
Sign in to join this conversation.
No description provided.