Full compaction slices the raw history, which can exclude a delayed tool result and leave its tool_use open in the compacted prefix, triggering the same strict-provider 400 on the summary request. Synthesize a placeholder tool_result for such calls when projecting the compacted prefix.
Also sync the micro_compaction default to false in the en/zh configuration and env-var docs.
* feat: add workspace add-dir support
Add multi-directory /add-dir management with session-only or project-remembered persistence, directory completion, confirmation UI, and runtime workspace/permission wiring.
* fix: honor --add-dir for resumed sessions
Pass CLI additional directories through shell and prompt resume paths, resolve caller-relative dirs against workDir, and add regression coverage.
* fix: keep additional dirs AGENTS.md out of default context
Load only user-level and cwd AGENTS.md by default, while preserving additional directory listings in the prompt context.
* feat: append /add-dir result as user message
Add a session appendUserMessage RPC and use it after /add-dir so the command result is recorded as a normal user message and surfaced in the transcript.
* docs: add add-dir research and follow-up todos
Document the add-dir / local-command-stdout research findings and the follow-up tasks for stdout wrapping, slash file completion, and hints.
* feat: wrap /add-dir output as local-command-stdout
Insert the /add-dir result as a user-role <local-command-stdout> record with an injection origin directly inside Session.addAdditionalDir. It enters the model context on the next turn but does not start a turn, and stays out of the live and resumed transcript; the transient status toast is kept for immediate feedback. --add-dir is unaffected since it bypasses addAdditionalDir.
Remove the now-unused appendUserMessage RPC and SDK method.
* feat: reopen /add-dir completion after accepting a directory
Generalize the slash-argument completion reopen so it fires whenever the text before the cursor ends with '/', not only when the literal '/' key is typed. After Tab-accepting a directory (or auto-applying a single-child dir), the next level's completion list reappears automatically, so repeated Tab keeps drilling down into subdirectories. '@' file mention is unaffected.
* feat: reopen file mention completion after accepting a directory
Extend the path completion reopen so it also fires for '@' file mentions. After Tab-accepting a directory in an '@' mention, the next level's completion list reappears automatically, matching the '/add-dir' continuous-Tab behavior.
* feat: show inline argument hints for slash commands
Render a dim ghost-text argument hint inside the input box after a slash command that takes arguments, replacing the popup-only hint that was easy to miss. The hint appears once the command is typed and disappears as soon as an argument is entered, and is truncated to fit the box width. Add argument hints for /compact, /swarm, /goal and /title; /add-dir already had one.
* test: remove stale additional-dirs AGENTS.md assertion
The subagent-host test still asserted that an additional directory's AGENTS.md content appears in the agent system prompt, but additional-dirs AGENTS.md has been intentionally excluded from the default context since an earlier commit (covered by context.test.ts). Drop the stale assertion.
* fix: resolve /add-dir paths against workdir and persist via kaos
Resolve user-supplied /add-dir paths against the current workdir instead of the project root, so launching from a subdirectory behaves like the CLI --add-dir flag. Also route the local.toml read/write through the kaos abstraction instead of host fs, so the remember path works for non-local sessions.
* fix: expand ~ in /add-dir paths before resolving
The /add-dir completer emits ~/... values, but the core treated ~/foo as a relative path because pathe isAbsolute('~/foo') is false, producing <workDir>/~/foo. Expand ~ and ~/ to the home directory (via kaos.gethome()) before resolving.
* chore: remove add-dir dev docs from the branch
These were working notes (research and follow-up todos) that don't belong in the PR.
* chore: clarify add-dir changeset for users
* docs: document /add-dir, --add-dir, and local.toml
* test: flush records before reading wire in add-dir runtime tests
FileSystemAgentRecordPersistence.append buffers records and flushes asynchronously, so readMainWire can read the wire before the local-command-stdout record lands. Flush the main agent's records explicitly in the two add-dir runtime tests to make them deterministic.
* fix: clean up background tasks on session exit
* Stop background tasks on session close
Change versioning for agent-core and kimi-code to patch.
Signed-off-by: 7Sageer <12210216@mail.sustech.edu.cn>
---------
Signed-off-by: 7Sageer <12210216@mail.sustech.edu.cn>
* Refactor theme
* custom theme support
* docs: add custom themes guide
Document the custom theme file location, the color token reference, selecting a theme via /theme and tui.toml, and fallback behavior. Link it from the customization sidebar and the tui.toml theme field.
* feat(skill): add built-in custom-theme skill
Guides the model (or a manual /custom-theme run) to author a theme JSON in ~/.kimi-code/themes/: docs token reference, deliberate color choices, hex validation, and how to apply via /theme or /reload-tui. Note in the write-tui skill to keep the token set in sync across colors.ts, the schema, the docs, and this skill. Enrich the custom-theme changeset to cover all three usage paths.
* chore: remove theme research report
* fix(tui): resolve lint errors after main merge
Remove unused chalk/currentTheme/ResolvedTheme imports left by the theme refactor; break the theme <-> pi-tui-theme import cycle by dropping the markdown/editor theme getters from the Theme class (consumers call createMarkdownTheme directly); fix unused vars/params, a floating promise, and a redundant union type.
* fix(tui): address custom theme review feedback
- await applyTheme before refreshing terminal theme tracking, so
switching to "auto" installs the watcher against the new state
- invalidate the transcript on automatic (terminal-driven) theme
changes so already-rendered entries repaint
- rebuild UsagePanel bodies on invalidate (previously a no-op); /usage,
/status, /mcp and /plugins now repaint on a theme switch
- repaint the compaction header on invalidate
- validate a custom theme before applying it from the /theme picker
- hide reserved dark/light/auto names from the custom theme list
- escape the theme name when writing tui.toml
- stop the custom theme loader writing warnings to the raw terminal
- remove a stray hello.ts
* refactor(tui): polish custom theme feature
- footer and todo-panel read the currentTheme singleton directly at
render time instead of caching a palette copy; drop their setColors
methods and the manual setColors calls on every theme change
- support "base": "dark" | "light" in custom theme files so a partial
light theme inherits the light palette for unspecified tokens
- reconcile the docs and the custom-theme skill with the silent
invalid-color fallback (no terminal warning)
* refactor(tui): live-repaint the agent swarm progress panel
Read the currentTheme palette through a getter instead of caching it at
construction time, so the swarm progress panel recolors on a theme switch
like the rest of the transcript. Drops the now-unused `colors` option.
* chore: remove plan.md
* docs: update custom theme guide
* docs: document custom theme skill command
* fix(skill): make custom theme user-triggered only
* docs: fix code fence language and add cross-references (zh/en)
- slash-commands: add 'sh' language tag to /goal example code block
- config-files: link experimental section to env-vars#runtime-switches
- env-vars: link KIMI_CODE_EXPERIMENTAL_* rows to config-files#experimental
* docs: improve goals.md formatting and clarity (zh/en)
- Merge redundant opening paragraphs into one with concrete examples
- Use colons before code examples (not periods)
- Bold state names in lifecycle list (complete/paused/blocked)
- Replace prose keyboard shortcut description with table
- Remove draft product-background text from EN queue section
* docs: move goals after sessions in sidebar (zh/en)
Goal mode builds on multi-turn sessions, so it reads more naturally
after the sessions page in the guides navigation.
Inline, model-invocable skill to inspect and safely edit kimi-code's own config.toml and tui.toml (copy to a candidate, Edit, validate with kimi doctor, timestamped backup, then overwrite). Also documents tui.toml on the config files page (en + zh).
* feat: force adaptive thinking via KIMI_MODEL_ADAPTIVE_THINKING
Add the KIMI_MODEL_ADAPTIVE_THINKING env var and a matching
adaptive_thinking model-alias field that force adaptive thinking
(thinking: { type: 'adaptive' }) on or off, overriding the Anthropic
model-name version inference.
This lets custom-named staff endpoints that back an adaptive-capable
model opt in even when the model name does not encode a parseable Claude
version (which would otherwise fall back to budget-based thinking).
The kosong AnthropicChatProvider resolves the adaptive decision once in
withThinking() as `_adaptiveThinking ?? supportsAdaptiveThinking(model)`
and threads it through clampEffort/supportsEffortParam so forced adaptive
also unlocks the max effort level.
* fix: make adaptive_thinking imply the thinking capability
A model alias that sets adaptive_thinking=true (or env
KIMI_MODEL_ADAPTIVE_THINKING=true) without listing a thinking
capability previously resolved to thinking=false for custom-named
endpoints not in the capability catalog. The model picker then
classified the alias as "thinking unsupported" and forced thinking
off (persisting default_thinking=false).
Treat a forced adaptive flag as advertising the thinking capability
in resolveModelCapabilities, so the config.toml one-field opt-in
agrees with the KIMI_MODEL_* env path (which already defaults
capabilities to include thinking).
* fix: honor adaptiveThinking in the model picker, not the capability resolver
The earlier resolveModelCapabilities change had no observable effect:
modelCapabilities.thinking is consumed only for completion-budget and
media gating, never to decide whether thinking is dispatched or whether
the model picker offers a thinking toggle.
The mechanism that actually forced thinking off for an adaptive_thinking
alias is the TUI model picker, which reads ModelAlias.capabilities
directly (availableModels comes straight from config.models). Revert the
resolver change and instead make thinkingAvailability() treat
adaptiveThinking=true as a thinking toggle, so a custom-named config.toml
alias configured with only `adaptive_thinking = true` is no longer
classified "unsupported" (which forced thinking off and persisted
default_thinking=false on select). The KIMI_MODEL_* env path was already
covered by DEFAULT_CAPABILITIES.
* feat: define model via KIMI_MODEL_* environment variables
Add a KIMI_MODEL_* environment-variable channel that synthesizes a
provider (__kimi_env__) and model alias (__kimi_env_model__) in memory
and selects it as the default model, without editing config.toml.
Supports provider type (kimi/anthropic/openai), base URL, API key,
context size, capabilities, anthropic max_output_size, openai
reasoning_key, and full thinking settings.
Runtime config reads go through a new loadRuntimeConfig wrapper; the
config.toml write-back paths keep using readConfigFile so the
synthesized model is never persisted back to disk.
* feat: env-model defaults and friendly welcome model name
- KIMI_MODEL_MAX_CONTEXT_SIZE defaults to 262144 (256K) when unset
- KIMI_MODEL_CAPABILITIES defaults to image_in,thinking when unset
- TUI welcome banner shows the model display name / id instead of the
internal __kimi_env_model__ alias key
* fix: never persist env model to config.toml; validate default_thinking
- Strip the synthesized __kimi_env__ provider / __kimi_env_model__ model
(and a default_model pointing at it) in writeConfigFile, so the env model
and its shell API key cannot be persisted via a getConfig -> setConfig
patch round-trip (e.g. running /login or /connect in env-model mode).
- Reject a non-empty but unparseable KIMI_MODEL_DEFAULT_THINKING value
(fail-fast) instead of silently keeping config.toml's existing default.
* fix: preserve on-disk default_model when stripping env model; fix thinking docs
- stripEnvModelConfig restores config.toml's default_model from raw instead of
erasing it when the runtime default points at the env alias, so a real
default_model survives a getConfig -> setConfig round-trip.
- Correct KIMI_MODEL_DEFAULT_THINKING docs: unset follows the global default
(Thinking on), not Off.
* fix: restore env-injected fields to on-disk values in stripEnvModelConfig; update tests for thinking behavior
* fix(kosong): make OpenAI-compatible thinking work without reasoning_key
Reasoning field names (reasoning_content / reasoning_details / reasoning)
are protocol facts, not user preferences. Treating reasoning_key as a
required user-set field meant any path that didn't go through the catalog
— hand-written config.toml in particular — silently lost thinking content
and broke strict gateways like DeepSeek.
Demote reasoning_key to an internal protocol constant with an explicit
override:
- Inbound (stream + non-stream): scan reasoning_content,
reasoning_details, reasoning in order; first string value wins. An
explicit reasoning_key restricts the scan to that one field.
- Outbound: serialize ThinkPart back as reasoning_content by default.
An explicit reasoning_key writes to that field instead.
- reasoning_effort auto-injection no longer requires reasoning_key;
presence of ThinkPart in history is enough.
Catalog plumbing is unchanged — explicit values from the catalog still
win, the default just stops being undefined.
Manually verified end-to-end against the real DeepSeek API with a
hand-written config.toml that does not set reasoning_key: thinking
content renders, no 400, multi-turn conversations work.
* fix(kosong): normalize blank reasoning_key to unset
ModelAliasSchema accepts `reasoning_key = ""` (z.string().optional()).
A blank value used to disable the default field scan and route both
inbound reads and outbound writes through an empty property name.
Trim and treat empty as undefined at the provider boundary so the
default protocol behavior applies.
* fix(kosong): preserve caller-pinned reasoning_effort during auto-inject
When the history contains ThinkPart, generate() injects
reasoning_effort='medium' and then assigns it onto createParams,
which used to silently overwrite a value the caller set via
withGenerationKwargs({ reasoning_effort: 'high' }). Skip auto-inject
when an explicit reasoning_effort already lives in kwargs.