Skip to content

[codex] persist CLI backend mode and bump to 1.3.0 - #64

Merged
bernoussama merged 1 commit into
masterfrom
codex/persist-cli-mode-config
Jun 21, 2026
Merged

[codex] persist CLI backend mode and bump to 1.3.0#64
bernoussama merged 1 commit into
masterfrom
codex/persist-cli-mode-config

Conversation

@bernoussama

@bernoussama bernoussama commented Jun 21, 2026

Copy link
Copy Markdown
Owner

What changed

  • add a versioned, platform-aware ClankerOverflow config file shared by CLI and MCP
  • persist local or remote mode during setup, with interactive setup defaulting to local
  • keep solution logging locked to the persisted mode while allowing explicit search and vote source overrides
  • add clanker config show|path|set and expose matching MCP source controls
  • update bundled skills, documentation, and isolated local-mode coverage
  • bump @clankeroverflow/cli from 1.2.1 to 1.3.0 and stamp all plugin descriptors

Why

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_MODE and remote fallback behavior.

Validation

  • pnpm --filter @clankeroverflow/cli test (86 tests)
  • pnpm --filter @clankeroverflow/cli check-types
  • pnpm --filter @clankeroverflow/cli build
  • pnpm run lint (passes with pre-existing warnings outside this change)
  • pnpm run format
  • pnpm test:e2e:local (Node 22 and Node 24)
  • git diff --check

Summary by CodeRabbit

Release Notes

  • New Features

    • Added --source flag to search and voting commands to select backend without changing where solutions are logged.
    • Added config command with show, set, and path subcommands for managing persisted configuration.
    • Added --mode option to setup command to explicitly choose local or remote backend mode.
    • Configuration is now persisted to disk and reused across CLI and MCP sessions.
  • Documentation

    • Updated guides for private local mode and backend behavior configuration.

@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Introduces a Zod-validated persisted JSON configuration file (resolved via XDG/platform paths) that replaces environment-variable-only mode selection. Adds a --source configured|local|remote flag to CLI search, upvote, and downvote commands and the equivalent source input to the MCP tools search_solutions, upvote_solution, and downvote_solution. Adds a new clanker config show|path|set command. The setup command gains --mode local|remote and writes the selected mode to the persisted config. All plugin manifests are bumped to 1.3.0.

Changes

Persisted config system with per-call backend source selection

Layer / File(s) Summary
Persisted config schema, path resolution, and I/O helpers
packages/cli/src/mcp/config.ts, packages/cli/src/mcp/config.test.ts, packages/cli/src/mcp/local-semantic.ts
Defines persistedConfigSchema/PersistedConfig, ConfigPathOptions, and extends ServerConfig with configPath/hasPersistedConfig. Adds getConfigPath, readPersistedConfig, toPersistedConfig, writePersistedConfig, and modeForSource. resolveConfig merges persisted file with env/defaults. Tests cover path resolution per platform, read/write round-trips, precedence, legacy fallback, semantic toggle, and fail-closed validation.
Backend mode parameter and per-source routing helper
packages/cli/src/mcp/create-backend.ts, packages/cli/src/mcp/server.ts
createSolutionBackend gains explicit mode parameter. createMcpServer gains optional ServerConfig param and a backendForSource(source) closure that calls modeForSource + createSolutionBackend per invocation.
MCP tool source input and status config path
packages/cli/src/mcp/server.ts, packages/cli/src/mcp/server.test.ts
search_solutions, upvote_solution, and downvote_solution gain an optional source: configured|local|remote input routed through backendForSource; success messages include the selected mode. clanker_status adds configPath to text and structured content. Tests assert source default, updated success message format, and remote source calls while in local mode.
CLI --source flag, config command, and setup --mode
packages/cli/src/index.ts, packages/cli/src/index.test.ts
Adds parseBackendSource, parseBooleanSetting, setConfigValue helpers. search, upvote, downvote gain --source with modeForSource effective-mode computation. New config show [--json]|path|set command. setup gains --mode. Tests cover invalid config fail-closed, remote source with local env, config persistence, and config show --json output.
Setup mode resolution and persisted config write
packages/cli/src/setup.ts, packages/cli/src/setup.test.ts
SetupOptions gains mode?: ClankerMode. resolveSetupMode validates mode flag, handles interactive/non-interactive cases. createMcpEnv returns {} for local and only CLANKER_API_KEY for remote. setupAgents builds configEnv, resolves config, and writes finalized persisted config. Tests updated with mode: "remote" throughout; new tests for interactive default and non-interactive mode requirement.
Documentation, version bumps, and E2E config file setup
README.md, packages/cli/skills/clankeroverflow-cli/SKILL.md, packages/cli/skills/clankeroverflow-mcp/SKILL.md, packages/cli/e2e/local-mode.mjs, packages/cli/package.json, packages/cli/*.plugin.json, packages/cli/openclaw.plugin.json
README and SKILL docs updated to describe persisted local mode, clanker config commands, --source remote usage, and CLANKER_MODE demoted to legacy fallback. All manifests bumped to 1.3.0. E2E test writes an explicit config.json into temp XDG_CONFIG_HOME instead of relying on CLANKER_MODE env.

Sequence Diagram

sequenceDiagram
  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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐇 Hop, hop, the config now lives on disk,
No more envs, that was a risk!
--source remote to peek at the cloud,
While local mode stays quiet and proud.
clanker config set seals the deal —
Persisted JSON, what a bunny meal! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: persisting CLI backend mode and bumping the version to 1.3.0, which are the core changes across the CLI package, config system, and plugin manifests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/persist-cli-mode-config

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@bernoussama
bernoussama marked this pull request as ready for review June 21, 2026 18:02

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
README.md (1)

127-133: ⚡ Quick win

Clarify backend override scope to prevent confusion.

Lines 127–132 document --source remote for search and upvote, but the broader behavior should clarify that this applies to search, upvote, and downvote only; log does 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 value

Consider aligning error handling with existing CLI patterns.

parseBackendSource throws an Error whereas the adjacent parseSearchMode uses the console.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

📥 Commits

Reviewing files that changed from the base of the PR and between c87a2f1 and 22713b3.

📒 Files selected for processing (18)
  • README.md
  • packages/cli/.claude-plugin/plugin.json
  • packages/cli/.codex-plugin/plugin.json
  • packages/cli/e2e/local-mode.mjs
  • packages/cli/openclaw.plugin.json
  • packages/cli/package.json
  • packages/cli/skills/clankeroverflow-cli/SKILL.md
  • packages/cli/skills/clankeroverflow-mcp/SKILL.md
  • packages/cli/src/index.test.ts
  • packages/cli/src/index.ts
  • packages/cli/src/mcp/config.test.ts
  • packages/cli/src/mcp/config.ts
  • packages/cli/src/mcp/create-backend.ts
  • packages/cli/src/mcp/local-semantic.ts
  • packages/cli/src/mcp/server.test.ts
  • packages/cli/src/mcp/server.ts
  • packages/cli/src/setup.test.ts
  • packages/cli/src/setup.ts

@bernoussama
bernoussama merged commit 36f30f4 into master Jun 21, 2026
2 checks passed
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