[codex] persist CLI backend mode and bump to 1.3.0 - #64
Conversation
WalkthroughIntroduces a Zod-validated persisted JSON configuration file (resolved via XDG/platform paths) that replaces environment-variable-only mode selection. Adds a ChangesPersisted config system with per-call backend source selection
Sequence DiagramsequenceDiagram
participant User
participant CLI_MCP_Tool as CLI / MCP Tool
participant modeForSource
participant createSolutionBackend
participant resolveConfig
participant writePersistedConfig
rect rgba(70, 130, 180, 0.5)
Note over User,writePersistedConfig: Setup: persist mode to config file
User->>CLI_MCP_Tool: clanker setup --mode local
CLI_MCP_Tool->>resolveConfig: env, ConfigPathOptions
resolveConfig-->>CLI_MCP_Tool: ServerConfig (configPath, hasPersistedConfig)
CLI_MCP_Tool->>writePersistedConfig: PersistedConfig {mode: "local", ...}
writePersistedConfig-->>CLI_MCP_Tool: configPath
end
rect rgba(60, 179, 113, 0.5)
Note over User,createSolutionBackend: Runtime: per-call source override
User->>CLI_MCP_Tool: clanker search "query" --source remote
CLI_MCP_Tool->>resolveConfig: env (reads persisted local config)
resolveConfig-->>CLI_MCP_Tool: ServerConfig {mode: "local"}
CLI_MCP_Tool->>modeForSource: config, "remote"
modeForSource-->>CLI_MCP_Tool: effectiveMode = "remote"
CLI_MCP_Tool->>createSolutionBackend: config, "remote"
createSolutionBackend-->>CLI_MCP_Tool: RemoteBackend
CLI_MCP_Tool-->>User: Source: remote\n[results] (log still goes local)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
README.md (1)
127-133: ⚡ Quick winClarify backend override scope to prevent confusion.
Lines 127–132 document
--source remotefor search and upvote, but the broader behavior should clarify that this applies to search, upvote, and downvote only;logdoes not support a source override (as stated at line 204). Consider adding a parenthetical to line 127 for completeness:Search or vote against a different backend without changing where new solutions are logged (log command always uses persisted mode):This prevents someone scanning the section from assuming all operations respect
--source.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@README.md` around lines 127 - 133, The documentation at line 127 describes using `--source remote` for search and upvote operations but does not clarify that the `log` command does not support this override and always uses persisted mode. Update the text at line 127 to include a parenthetical clarification that explicitly states the log command always uses persisted mode, making it clear to readers that the `--source` override applies only to search, upvote, and downvote operations and not to all operations mentioned in the section.packages/cli/src/index.ts (1)
88-93: 💤 Low valueConsider aligning error handling with existing CLI patterns.
parseBackendSourcethrows anErrorwhereas the adjacentparseSearchModeuses theconsole.error(pc.red(...)) + process.exit(1)pattern. This causes inconsistent error styling when users provide invalid values. Not a functional issue, but worth unifying for consistent UX.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/cli/src/index.ts` around lines 88 - 93, Update the parseBackendSource function to use the same error handling pattern as the adjacent parseSearchMode function instead of throwing a raw Error. Replace the throw statement with a console.error call using pc.red() for the error message, followed by process.exit(1) to maintain consistent error styling and CLI behavior when users provide invalid backend source values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/cli/src/index.ts`:
- Around line 88-93: Update the parseBackendSource function to use the same
error handling pattern as the adjacent parseSearchMode function instead of
throwing a raw Error. Replace the throw statement with a console.error call
using pc.red() for the error message, followed by process.exit(1) to maintain
consistent error styling and CLI behavior when users provide invalid backend
source values.
In `@README.md`:
- Around line 127-133: The documentation at line 127 describes using `--source
remote` for search and upvote operations but does not clarify that the `log`
command does not support this override and always uses persisted mode. Update
the text at line 127 to include a parenthetical clarification that explicitly
states the log command always uses persisted mode, making it clear to readers
that the `--source` override applies only to search, upvote, and downvote
operations and not to all operations mentioned in the section.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 71bdd650-7161-49af-ae1b-f57958e56e15
📒 Files selected for processing (18)
README.mdpackages/cli/.claude-plugin/plugin.jsonpackages/cli/.codex-plugin/plugin.jsonpackages/cli/e2e/local-mode.mjspackages/cli/openclaw.plugin.jsonpackages/cli/package.jsonpackages/cli/skills/clankeroverflow-cli/SKILL.mdpackages/cli/skills/clankeroverflow-mcp/SKILL.mdpackages/cli/src/index.test.tspackages/cli/src/index.tspackages/cli/src/mcp/config.test.tspackages/cli/src/mcp/config.tspackages/cli/src/mcp/create-backend.tspackages/cli/src/mcp/local-semantic.tspackages/cli/src/mcp/server.test.tspackages/cli/src/mcp/server.tspackages/cli/src/setup.test.tspackages/cli/src/setup.ts
What changed
clanker config show|path|setand expose matching MCP source controls@clankeroverflow/clifrom 1.2.1 to 1.3.0 and stamp all plugin descriptorsWhy
Previously, local mode was persisted only inside individual agent MCP environment entries. Direct CLI commands, packaged plugins, or regenerated agent configuration could fall back to the hosted backend. The shared config makes the user's logging destination authoritative and fails closed when that config is invalid.
User impact
Users can choose private local storage once during setup and both CLI and MCP will honor it. Search and voting can still explicitly target another backend without changing where new solutions are logged. Existing installations without a config retain the legacy
CLANKER_MODEand remote fallback behavior.Validation
pnpm --filter @clankeroverflow/cli test(86 tests)pnpm --filter @clankeroverflow/cli check-typespnpm --filter @clankeroverflow/cli buildpnpm run lint(passes with pre-existing warnings outside this change)pnpm run formatpnpm test:e2e:local(Node 22 and Node 24)git diff --checkSummary by CodeRabbit
Release Notes
New Features
--sourceflag to search and voting commands to select backend without changing where solutions are logged.configcommand withshow,set, andpathsubcommands for managing persisted configuration.--modeoption to setup command to explicitly choose local or remote backend mode.Documentation