Skip to content

Move config-file creation and email prompt into code-trace setup - #12

Closed
winjer wants to merge 1 commit into
setup-subcommand-hook-registrationfrom
setup-subcommand-write-config
Closed

Move config-file creation and email prompt into code-trace setup#12
winjer wants to merge 1 commit into
setup-subcommand-hook-registrationfrom
setup-subcommand-write-config

Conversation

@winjer

@winjer winjer commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Stacked on #11 (base is the #11 branch). Merge #11 first; GitHub will then retarget this to main.

Second slice of the installer-slimming direction: config-file creation and the Langfuse user-id email prompt move out of install.sh into the binary as code-trace setup --write-config.

What changed

  • src/setup.rs — pure, unit-tested helpers:
    • config_has_user_id — reuses the runtime config parser (config::parse_config_str), so a commented # LANGFUSE_USER_ID=… placeholder correctly does not count as configured.
    • decide_write / fresh_config / with_appended_user_id — the latter inserts a missing trailing newline so a hand-edited config is never concatenated (fixes the latent nit flagged back in Attach optional LANGFUSE_USER_ID to traces #8).
    • a write_config IO layer + terminal prompt. New flags: --write-config, --config-file, --user-email, --no-prompt.
  • Prompt moved into the binary. Because the prompt now runs in a separate process reading /dev/tty, it can no longer consume the piped curl | bash script — the whole class of stdin-consumption bug we fixed in Read installer email prompt from /dev/tty so piped installs ask #9/Route OpenCode/Pi install prompts through /dev/tty too #10 is gone by construction.
  • install.shcreate_config shrinks to a setup --write-config call plus the closing message. The OpenCode/Pi prompts remain in bash for now (next slice), so TTY_IN/resolve_tty_in stay.
  • Tests — 10 new unit tests on the pure helpers + 5 integration tests driving the real binary (fresh+email, fresh placeholder, append, already-configured left untouched, existing no-op).

Verification

  • cargo test (103 lib incl. 24 setup + 12 integration) and cargo clippy --all-targets clean.
  • Verified end to end through a piped curl | bash simulation with OpenCode installed (real pipe for stdin, pty for /dev/tty): the binary prompts for and writes the email — the exact scenario reported broken earlier.

Next slice, when you want it: OpenCode/Pi plugin install (which would also let plugin install work under curl | bash, by embedding the plugin sources in the binary — today it only works from a local checkout).

🤖 Generated with Claude Code

Second slice of shrinking install.sh: config-file creation and the
Langfuse user-id email prompt move from install.sh into the binary as
`code-trace setup --write-config`.

- src/setup.rs: pure, unit-tested helpers — config_has_user_id (reuses
  the runtime config parser so a commented placeholder does not count),
  decide_write, fresh_config, with_appended_user_id (inserts a missing
  trailing newline so a hand-edited file is never concatenated) — plus a
  write_config IO layer and terminal prompt. Flags: --write-config,
  --config-file, --user-email, --no-prompt.
- Because the prompt now runs in the binary (a separate process reading
  /dev/tty), it can no longer consume the piped curl | bash script — the
  class of stdin-consumption bug fixed in #9/#10 is gone by construction.
- install.sh create_config shrinks to a `setup --write-config` call plus
  the closing message. The OpenCode/Pi prompts stay in bash for now, so
  TTY_IN/resolve_tty_in remain.
- Tests: 10 new unit tests on the pure helpers + 5 integration tests
  driving the real binary (fresh+email, fresh placeholder, append,
  already-configured left untouched, existing no-op).

Verified end to end through a piped curl | bash simulation with OpenCode
present: the binary prompts for and writes the email correctly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@winjer
winjer deleted the branch setup-subcommand-hook-registration July 20, 2026 15:46
@winjer winjer closed this Jul 20, 2026
@winjer
winjer deleted the setup-subcommand-write-config branch July 20, 2026 15:47
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