Skip to content

feat: add --config to reconfigure credentials without running the agent#24

Closed
Miller (bath-tub) wants to merge 1 commit into
langchain-ai:mainfrom
bath-tub:feat/config-command
Closed

feat: add --config to reconfigure credentials without running the agent#24
Miller (bath-tub) wants to merge 1 commit into
langchain-ai:mainfrom
bath-tub:feat/config-command

Conversation

@bath-tub

@bath-tub Miller (bath-tub) commented Jul 1, 2026

Copy link
Copy Markdown

Description

Adds openwiki --config, a settings-only entry point for changing the provider, API key, model, or LangSmith key.

Today, once ~/.openwiki/.env holds a complete set of credentials there is no way to change them from the CLI:

  • --init maps to a documentation run (shouldStart: true), so it invokes the agent on mount. A user whose key is dead (expired trial, exhausted quota, wrong tier) just gets an error on boot with no path to switch keys.
  • needsCredentialSetup() is only true when a value is missing, so InitSetup is never reached when the file is complete.
  • Interactive chat has no key command — /provider only writes the provider + default model and prints "ensure KEY is set".

This fixes #23

What changed

  • --config flag (commands.ts): new { kind: "config" } command. It errors if combined with --init/--update/--print/a message, and requires a TTY.
  • reconfigure mode in InitSetup (credentials.tsx): walks every step (provider → key → model → LangSmith) even when values already exist.
  • Non-destructive by design: on the API key and LangSmith prompts, an empty entry means keep the current valuecompleteSetup only writes non-null fields, so untouched secrets are never cleared. A saved custom model that isn't one of the provider presets is surfaced as a selectable "current" option so pressing Enter keeps it instead of silently falling back to the first preset.
  • Never runs the agent (cli.tsx): the config flow renders the outcome and exits; the agent-run effect is gated on command.kind === "run". Env is now loaded for --config too so existing values are detected.
  • Docs + help updated.

Testing

pnpm build, pnpm lint:check, pnpm format:check all pass. Drove the interactive flow through a PTY against an isolated HOME with a complete .env:

  • Keep all (Enter through every step): every value preserved, no network call.
  • Change key (type a new key, keep the rest): key replaced; provider, model, and LangSmith key preserved.
  • Custom model + keep all: a non-preset OPENWIKI_MODEL_ID is preserved rather than overwritten.

Follow-ups (not in this PR)

  • A /key (or /login) slash command for the in-session case.
  • A hint on 429/insufficient_quota errors pointing at --config.
  • Warn when the key being saved is shadowed by an exported shell var (loadOpenWikiEnv only fills process.env when unset, so an exported key wins over ~/.openwiki/.env on the next shell).

Made with Claude Code

…gent

Once `~/.openwiki/.env` holds a full set of credentials there is no way to
change them from the CLI: `--init` skips setup and immediately runs the agent
(so a dead/exhausted key just errors on boot), and interactive chat has no
command to re-enter an API key.

Add `openwiki --config`, a settings-only entry point that renders the setup
flow in a new `reconfigure` mode and exits without ever invoking the agent.
Reconfigure walks every step even when values already exist, but treats empty
input on the API key / LangSmith prompts as "keep current" so untouched
secrets are never overwritten. A saved custom model (not in the provider
presets) is surfaced as a selectable option so pressing Enter keeps it.

Closes langchain-ai#23

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@colifran

Copy link
Copy Markdown
Contributor

Thanks for PR! This will be superseded by: #374 which makes init idempotent so re-running allows updating config.

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.

No way to reconfigure API key once credentials exist; --init immediately calls the API

3 participants