Skip to content

fix(code): bridge config key into env + lazy subagent client#703

Merged
esengine merged 1 commit into
mainfrom
fix/code-cmd-key-bridge
May 12, 2026
Merged

fix(code): bridge config key into env + lazy subagent client#703
esengine merged 1 commit into
mainfrom
fix/code-cmd-key-bridge

Conversation

@esengine

Copy link
Copy Markdown
Owner

Summary

reasonix code (and npx tsx src/cli/index.ts code in dev) crashed at boot with DEEPSEEK_API_KEY is not set even when the user had a key saved in ~/.reasonix/config.json via reasonix setup. Two bugs stacked:

  1. code.tsx never bridged config → env. chat.tsx, desktop.ts, and run.ts all do loadDotenv() + process.env.DEEPSEEK_API_KEY = loadApiKey() at the top of their command. code.tsx skipped this entirely, relying on the shell env to already have it.

  2. Subagent client constructed eagerly. buildCodeToolset in src/code/setup.ts builds a DeepSeekClient for the skill-subagent runner at boot. With no env key the constructor throws — before chatCommand (called later in codeCommand) can mount the wizard that would prompt for one. So even fixing (1) wouldn't recover the wizard path for a brand-new user.

Fix

  • code.tsx: call loadDotenv() + bridge loadApiKey() into env at the very top of codeCommand, mirroring chatCommand
  • setup.ts: defer the subagent client to first dispatch (lazy let subagentClient: DeepSeekClient | null = null). Construction error now surfaces at the call site (user invokes a skill) instead of at boot, which preserves the wizard path

Test plan

  • New tests/code-setup-lazy-subagent.test.ts deletes DEEPSEEK_API_KEY and asserts buildCodeToolset succeeds
  • Full suite: 2690 / 2690
  • Manually re-ran npx tsx src/cli/index.ts code --help — boots cleanly with no env key

`reasonix code` crashed at boot with "DEEPSEEK_API_KEY is not set" for
two reasons stacked:

1. code.tsx never bridged ~/.reasonix/config.json → process.env the way
   chat.tsx / desktop.ts / run.ts do. A key the user stored via
   `reasonix setup` was invisible to `code`.

2. buildCodeToolset eagerly constructed a DeepSeekClient for the
   subagent runner. With no env key, the constructor throws — before
   chatCommand mounts the wizard that would prompt for one.

- code.tsx now calls loadDotenv() + bridges loadApiKey() into env at
  the top of codeCommand, mirroring chatCommand's setup
- setup.ts defers the subagent DeepSeekClient to first dispatch so
  toolset construction succeeds even when no key is configured yet
- new tests/code-setup-lazy-subagent.test.ts pins the invariant
@esengine esengine merged commit 0ca2c6b into main May 12, 2026
2 checks passed
@esengine esengine deleted the fix/code-cmd-key-bridge branch May 12, 2026 11:05
esengine added a commit that referenced this pull request May 12, 2026
…il, CardStream fix (#705)

npm-only release. The Tauri desktop source is in the repo and the CLI
subcommand works, but installer bundles for macOS / Windows / Linux
don't ship this round (separate release once signing's settled).

Highlights:
- Tauri desktop client with multi-tab concurrent runtimes (#689)
  plus a near-full polish pass: wallet balance, version chip, active-
  plan rail, abortable pause-gates, edit-gate pill, en + zh-CN i18n,
  shared pause-policy module dedup'd with the CLI TUI (#701)
- checkpoint API + git-changes panel in the embedded dashboard (#682)
- outside-sandbox file access approval modal (#696)
- MCP loading pill + readiness gate on tool dispatch (#687)
- escalate-after flag for flash → pro threshold (#699)

Fixes:
- CardStream Maximum-update-depth crash, quantize window so boundary
  cards stop oscillating (#700, #702)
- `reasonix code` bridges config key to env + lazy subagent client so
  fresh installs can reach the setup wizard (#703)
- pinned-mode scroll shrinks coalesced (#666), generic CSI key decode
  (#692), shell-confirm preview clamp (#691), frontmatter BOM/folded
  lines (#690), MCP error classification (#688), and more
ChasLui pushed a commit to ChasLui/DeepSeek-Reasonix that referenced this pull request May 23, 2026
…e#703)

`reasonix code` crashed at boot with "DEEPSEEK_API_KEY is not set" for
two reasons stacked:

1. code.tsx never bridged ~/.reasonix/config.json → process.env the way
   chat.tsx / desktop.ts / run.ts do. A key the user stored via
   `reasonix setup` was invisible to `code`.

2. buildCodeToolset eagerly constructed a DeepSeekClient for the
   subagent runner. With no env key, the constructor throws — before
   chatCommand mounts the wizard that would prompt for one.

- code.tsx now calls loadDotenv() + bridges loadApiKey() into env at
  the top of codeCommand, mirroring chatCommand's setup
- setup.ts defers the subagent DeepSeekClient to first dispatch so
  toolset construction succeeds even when no key is configured yet
- new tests/code-setup-lazy-subagent.test.ts pins the invariant
ChasLui pushed a commit to ChasLui/DeepSeek-Reasonix that referenced this pull request May 23, 2026
…il, CardStream fix (esengine#705)

npm-only release. The Tauri desktop source is in the repo and the CLI
subcommand works, but installer bundles for macOS / Windows / Linux
don't ship this round (separate release once signing's settled).

Highlights:
- Tauri desktop client with multi-tab concurrent runtimes (esengine#689)
  plus a near-full polish pass: wallet balance, version chip, active-
  plan rail, abortable pause-gates, edit-gate pill, en + zh-CN i18n,
  shared pause-policy module dedup'd with the CLI TUI (esengine#701)
- checkpoint API + git-changes panel in the embedded dashboard (esengine#682)
- outside-sandbox file access approval modal (esengine#696)
- MCP loading pill + readiness gate on tool dispatch (esengine#687)
- escalate-after flag for flash → pro threshold (esengine#699)

Fixes:
- CardStream Maximum-update-depth crash, quantize window so boundary
  cards stop oscillating (esengine#700, esengine#702)
- `reasonix code` bridges config key to env + lazy subagent client so
  fresh installs can reach the setup wizard (esengine#703)
- pinned-mode scroll shrinks coalesced (esengine#666), generic CSI key decode
  (esengine#692), shell-confirm preview clamp (esengine#691), frontmatter BOM/folded
  lines (esengine#690), MCP error classification (esengine#688), and more
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