Skip to content

feat(cli): add --plan flag and default_plan_mode config#1665

Open
leonidlouis wants to merge 4 commits intoMoonshotAI:mainfrom
leonidlouis:add-plan-flag
Open

feat(cli): add --plan flag and default_plan_mode config#1665
leonidlouis wants to merge 4 commits intoMoonshotAI:mainfrom
leonidlouis:add-plan-flag

Conversation

@leonidlouis
Copy link
Copy Markdown

@leonidlouis leonidlouis commented Mar 30, 2026

Summary

Add ability to start Kimi CLI in plan mode via CLI flag and config option.

Motivation

Currently, plan mode can only be triggered interactively via:

  • Keyboard shortcut: +Shift-Tab+
  • Slash command: /plan+
  • LLM tool: EnterPlanMode (requires user approval)

There was no way to start a session directly in plan mode, unlike --yolo which has both CLI flag and config option.

Changes

New Features

  • CLI flag: +--plan+ - Start a new session in plan mode
  • Config option: +default_plan_mode = true/false+ in ~/.kimi/config.toml

Behavior

Scenario Result
New session with +--plan+ Enters plan mode
New session with +default_plan_mode = true+ Enters plan mode
Resumed session with +--plan+ Forces plan mode on (override)
Resumed session (no flag) Session state preserved, config ignored

Files Changed

  • +src/kimi_cli/config.py+: Add +default_plan_mode+ field
  • +src/kimi_cli/cli/init.py+: Add +--plan+ CLI flag
  • +src/kimi_cli/app.py+: Handle plan mode activation with proper side effects
  • +tests/core/test_config.py+: Update snapshot test

Testing

  • Config field serialization verified
  • Session state persistence tested
  • Precedence logic validated for all scenarios
  • Type checking (pyright) and linting (ruff) passed

Checklist

  • Code follows project style guidelines
  • Type checking passes
  • Linting passes
  • Tests updated and passing
  • Feature is properly documented via help text

Open with Devin

Add ability to start Kimi CLI in plan mode via:
- CLI flag: --plan (similar to --yolo)
- Config option: default_plan_mode = true/false in ~/.kimi/config.toml

Behavior:
- For new sessions: CLI flag > config > default (false)
- For resumed sessions: session state preserved, config not applied
- Full activation with _set_plan_mode() for proper side effects

Files changed:
- config.py: add default_plan_mode field
- cli/__init__.py: add --plan flag
- app.py: handle plan mode activation logic
- tests/core/test_config.py: update snapshot
chatgpt-codex-connector[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

Address PR review feedback:

1. Fix resumed flag in CLI (cli/__init__.py):
   - Track actual session restoration vs creation
   - resumed=True only when session was actually found
   - Fixes --session NEW_ID being treated as resumed

2. Add resumed=True to ACP server (acp/server.py):
   - ACP always loads/resumes existing sessions
   - Prevents config.default_plan_mode from overriding persisted state

3. Add resumed=True to web worker (web/runner/worker.py):
   - Web worker loads existing sessions by ID
   - Prevents config.default_plan_mode from overriding persisted state
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Add missing resumed=True to the _setup_session method in ACP server.
This method is used by load_session() and resume_session() to load
existing sessions, so it should pass resumed=True to preserve the
session's persisted plan_mode state.

This corrects the previous commit which mistakenly added resumed=True
to new_session instead of _setup_session.
devin-ai-integration[bot]

This comment was marked as resolved.

new_session() creates a brand-new session via Session.create(), so it
should NOT pass resumed=True. Doing so caused config.default_plan_mode
to be skipped for ACP new sessions.

resumed=True is correctly kept in _setup_session() which loads existing
sessions via Session.find().
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