Commit graph

1575 commits

Author SHA1 Message Date
Haozhe
b4ae7f875d
fix(agent-core-v2): allow Bash cwd outside the workspace roots (#3444)
Some checks are pending
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
Release / Publish native release assets (push) Blocked by required conditions
Release / Release (push) Waiting to run
Release / Deploy docs (push) Blocked by required conditions
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
Release / Native release artifact (push) Blocked by required conditions
Publish VS Code extension / Publish VSIX to marketplaces (push) Waiting to run
- drop the built-in escape assertion from RuntimeWorkspaceView.resolve so it is a pure path mapping
- return the validated path from assertAllowed and compose it explicitly in terminalService
- add a bash test covering cwd outside the workspace roots
2026-09-02 09:04:25 +08:00
Grapedge
0fd89695f5
refactor(vscode): migrate the webview data layer from ahooks to TanStack Query (#3440)
Some checks are pending
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
Release / Release (push) Waiting to run
Release / Deploy docs (push) Blocked by required conditions
Release / Native release artifact (push) Blocked by required conditions
Release / Publish native release assets (push) Blocked by required conditions
Publish VS Code extension / Publish VSIX to marketplaces (push) Waiting to run
* fix(vscode): keep current and root work dirs visible in directory picker

* refactor(vscode): migrate the webview data layer from ahooks to TanStack Query
2026-09-02 01:42:43 +08:00
Haozhe
026e807cf8
refactor(vis): migrate vis from agent-core v1 to agent-core-v2 (#3438)
* refactor(vis): migrate vis from agent-core v1 to agent-core-v2

- swap vis-server engine deps to @moonshot-ai/agent-core-v2, drop kosong
- rebuild the wire record union from v2 durable payload types
- fold token_counting records into the context-window fill
- read cron state from wire records alongside legacy cron files
- read agent parent/swarm metadata from state.json labels
- align context projection and web rendering with the v2 wire vocabulary
- bundle agent-core-v2 into the vis-server build

* fix(vis): replay legacy compactions per engine rules, tolerate bad cron payloads

- treat every record without keptUserMessageCount (or with an explicit
  legacyTail flag) as a verbatim-tail compaction, matching the engine's
  readContextCompactionShapeInput instead of gating on compactedCount
- derive tokensAfter from the reconstructed shape when the record omits
  it, instead of keeping the stale pre-compaction fill
- skip malformed cron.delete / cron.cursor payloads instead of throwing
2026-09-02 00:00:29 +08:00
Haozhe
ae7a6dc6fb
refactor(acp): remove the legacy acp-adapter package (#3434) 2026-09-01 23:59:20 +08:00
Haozhe
ab565e0816
docs(transcript): rewrite SDK document against the current contract (#3437)
* docs(transcript): add SDK contract document

* docs(transcript): rewrite SDK document against the current contract
2026-09-01 23:03:04 +08:00
Haozhe
deed1e935c
docs(transcript): add SDK contract document (#3432) 2026-09-01 22:27:49 +08:00
Haozhe
742e1197a9
feat(agent-core-v2): persist step retry and interrupt events to the wire (#3428)
* feat(agent-core-v2): persist step retry and interrupt events to the wire

* feat(transcript): create the missing interrupted step in the cold fold
2026-09-01 21:56:28 +08:00
Haozhe
ceb51535ef
feat(cli): add the kimi session list subcommand (#3425)
* feat(cli): add the kimi session list subcommand

- add the session command group with list: cwd scope by default, --all/--cwd/--archived/--limit/--json
- pass includeArchived through the SDK listSessions options (v2 klient query, v1 includeArchive mapping)

* docs: condense the session list changeset to one sentence

* fix(cli): sanitize session list rows and tidy option types

- strip control characters and line breaks from user-controlled row fields
- declare cwd/limit as plain optional properties without undefined unions
2026-09-01 21:41:52 +08:00
Haozhe
442b56391b
fix(agent-core-v2): let experimental config override the master flag env (#3427) 2026-09-01 21:36:57 +08:00
Haozhe
33eee42601
fix(agent-core-v2): reproject a stale session index at startup (#3422)
- add mtime to the file system storage service (node-fs stat, memory write clock)
- record the source max mtime in the session index checkpoint at projection
- compare the cheap mtime signal before adopting a persisted manifest on prepare
- refresh the checkpoint mtime after reconcile so warm starts stay scan-free
2026-09-01 21:20:00 +08:00
Haozhe
55b422aaee
feat(kimi-code): allow overriding the remote control relay origin via env (#3424) 2026-09-01 20:58:18 +08:00
Haozhe
9c37feb473
perf(agent-core-v2): fork sessions without materializing the target (#3421)
* fix(agent-core-v2): persist plan.revision as agent-relative key

- replace the session-scoped `path` field in durable plan.revision records
  with an agent-relative `key`, resolved to a display path at read and
  projection time against the current agent/session scope
- migrate legacy `path` records during wire restore and rewrite the journal
  once migration succeeds, emitting low-cardinality
  `wire_plan_revision_migrated` telemetry
- tolerate journal truncation during the migration rebuild and keep the
  legacy `path` display in cold transcript folds for unmigrated records
- keep external transcript marker `path` and meta `reviewPath` projections
  unchanged

* perf(agent-core-v2): fork sessions without materializing the target

- copy session files byte-for-byte (wire.jsonl included, parallel file
  writes) and append the forked marker per agent instead of parsing and
  rewriting every wire journal
- write the forked session's state.json, agent registry, and session
  index entry directly without creating a live session or agent scopes;
  fork returns SessionMeta and SessionForkedEvent drops the scope handle
- keep turnIndex truncation on the per-record path
- kap-server fork/createChild routes, the klient facade and wire
  contract, and the node-sdk forkSession resume the forked session
  through the normal resume path when a live handle is needed
- stop healing truncated source wires during fork; the forked session
  repairs its own copy lazily on resume
- add the `kimi fork [--cwd] [-y]` CLI command
2026-09-01 19:46:35 +08:00
Grapedge
76c1a7a347
refactor(agent-core-v2): simplify the default system prompt (#3390)
Some checks are pending
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Publish VS Code extension / Publish VSIX to marketplaces (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
Release / Native release artifact (push) Blocked by required conditions
Release / Release (push) Waiting to run
Release / Deploy docs (push) Blocked by required conditions
Release / Publish native release assets (push) Blocked by required conditions
2026-09-01 18:16:59 +08:00
tpoisonooo
c3bf6f9d2d
feat(agent-core-v2): rework tower mode entry and surface worker deaths (#3399)
Tower mode is now entered only manually — /tower on, or /tower
<base-branch> to also pin the local branch missions merge back into. The
agent can no longer enter it on its own: TowerInit refuses while the mode
is off and points at the slash command.

/tower <base-branch> is deterministic end to end: a missing base branch is
created from the current checkout (uncommitted changes committed onto it
as a labeled WIP snapshot), the checkout switches to it, and the tower
workspace is initialized immediately instead of relying on the model to
apply the base. With an existing workspace the tower rebases onto the
requested base when no missions are open and refuses naming the blocking
missions otherwise. The base rides the tower_mode.enter event into the new
tower.base state key and TowerInit falls back to it.

Tower agent deaths (failed/timed_out/killed/lost) are recorded in the
tower protocol: TowerStatus marks dead roster entries and warns about
missions whose owner died, with a resume hint. The tower console prompt
now requires a per-worker deliverables summary before TowerTeardown.

The session profile REST surface accepts tower_base so web clients can
turn tower mode on with /tower <base-branch> instead of sending the
argument as a prompt.

Co-authored-by: konghuanjun <konghuanjun@moonshot.ai>
2026-09-01 18:03:13 +08:00
7Sageer
4d7f32e1aa
fix(agent-core-v2): drop compaction mechanics from the AGENTS.md discovery reminder (#3420)
* fix(agent-core-v2): drop compaction mechanics from the AGENTS.md discovery reminder

The re-injection trigger is harness mechanics the model cannot act on, and the unread-path condition never fires from the model's perspective. End the reminder at the actionable instruction.

* fix(agent-core-v2): reword the AGENTS.md discovery reminder lead

Lead with the files instead of the paths, and replace harness vocabulary (touched / covered by / injected instructions) with terms the model can place: apply to, your system prompt.
2026-09-01 17:22:05 +08:00
7Sageer
379241e008
feat(agent-core-v2): report enabled experimental flags in session_started telemetry (#3419)
* feat(agent-core-v2): report enabled experimental flags in session_started telemetry

Add a sorted, comma-separated experimental_flags property to the v2
session_started event so feature-gated metrics gain a session-granular
exposure denominator, and carry the post-apply enabled set on the TUI
experimental_features_apply event to bound mid-session flag flips.

* feat(node-sdk): carry experimental flags on the harness session_started row

The v2 in-process path emits session_started twice (engine-side from
SessionLifecycleService, harness-side from KimiHarness), and only the
engine row carried experimental_flags, so consumers could double-count
or miss the flag dimension. Merge a per-emission dynamic getter into the
harness row, wired to the in-process engine's flag service, so both
rows report the same enabled flag set.

* fix(node-sdk): keep experimental_flags canonical on session_started

A caller-supplied experimental_flags in per-call sessionStartedProperties
could overwrite the engine-owned dynamic value, breaking row-to-row flag
consistency. Merge the dynamic properties after the session-scoped ones
so engine-owned keys always win.

* fix(agent-core-v2): count tower as exposure only once assembled

The tower flag reacts live to mid-process flips, but TowerFeature's
tools and profiles are assembled at App scope construction, so a session
started after an in-process flip cannot actually use tower. Filter it
out of experimental_flags on both session_started producers unless
isTowerFeatureAssembled says the feature is assembled in this process,
keeping the exposure denominator honest.

* test: recalibrate fixtures for the added constructor param and drop timing-sensitive tower assertion

The WorkspaceInstanceManager test builds the service with positional
args; the new flags param shifted unitHostFactory one slot. The tower
inclusion assertion in the SDK integration test depended on feature
assembly winning the race against async config load, which slow CI
runners lose; tower assembled-state coverage stays with the tower
service tests.

* refactor(agent-core-v2): move flag exposure gating into the flag definition

Telemetry consumers hardcoded tower's assemble-at-startup semantics to
keep it out of experimental_flags until assembled. Push the gate into
FlagDefinitionInput as an optional isExposed predicate owned by the
flag's own domain, expose it as IFlagService.exposedIds(), and let both
session_started producers call it — no feature-specific knowledge leaks
into the SDK or the session lifecycle.
2026-09-01 17:14:35 +08:00
7Sageer
0b8808a2cd
fix(agent-core-v2): re-remind subdirectory AGENTS.md after context compaction (#3409)
* fix(agent-core-v2): re-remind subdirectory AGENTS.md after context compaction

Deliver the discovery reminder through the reminder runtime's register()
channel so it re-injects whenever the previous reminder leaves the context
(compaction, /clear, or undo), instead of firing a one-shot notify() that
compaction silently drops while the known-set survives.

Discovery bookkeeping splits into agentsMdReminder.pending (discovered, not
yet read) and agentsMdReminder.known (injected or read); the provider injects
only pending paths not covered by the last injection's disclosure. A newly
created AGENTS.md lands in pending until read; a modified one counts as
injected.

* fix(agent-core-v2): drop deleted AGENTS.md from reminder bookkeeping

A discovered-but-unread AGENTS.md that gets deleted stayed in
agentsMdReminder.pending, so the next re-injection after context loss
pointed the model at a file that no longer exists. Remove deleted paths
from both the pending and known sets on the watcher event.

* Delete .changeset/agents-md-reminder-compaction-reset.md

Signed-off-by: 7Sageer <sag77r@hotmail.com>

---------

Signed-off-by: 7Sageer <sag77r@hotmail.com>
2026-09-01 17:06:55 +08:00
Kexin Liu
a26fca784d
test: catch fixtures up with the model-validation removal (#3418)
#3411 dropped two positional constructor params from
WorkspaceInstanceManager, shifting the agent-profile stub the
Reflect.construct fixture pins by index, and turned the broken
subagent-pool session create from VALIDATION_FAILED into a success;
both suites fail on main since then.

Co-authored-by: user <user@userdeMacBook-Pro.local>
2026-09-01 15:53:22 +08:00
7Sageer
effa5b7d43
Delete GOAL.md (#3416)
Signed-off-by: 7Sageer <sag77r@hotmail.com>
2026-09-01 15:21:01 +08:00
Kimi Agent
82bf0a8dd2
fix(agent-core-v2): parse git status porcelain with -z for non-ASCII paths (#3415)
git status --porcelain=v1 without -z C-quotes non-ASCII paths under
git's default core.quotePath, and parsePorcelain consumed the quoted
form verbatim while the posix() helper turned each \3xx octal escape
into a fake path segment — the changes tree then split those segments
on '/' and rendered Chinese filenames as bogus directory chains, and
diff requests for such entries failed the same way.

Run porcelain with -z (NUL-separated, never quoted; rename records are
XY new\0old with the new path first) and drop the posix() helper —
porcelain already emits '/' separators on every platform. The v1 engine
shares the bug and is intentionally left unchanged for now.

Refs #3414

Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com>
Co-authored-by: liruifengv <liruifeng1024@gmail.com>
2026-09-01 15:06:39 +08:00
7Sageer
7bc5b2027c
refactor(agent-core-v2): deliver the subagent fork notice via reminder injection (#3412) 2026-09-01 14:02:01 +08:00
Haozhe
5e57618fc8
fix(agent-core-v2): allow sessions without valid models (#3411)
* fix(agent-core-v2): allow sessions without valid models

* fix(agent-core-v2): wait for model initialization

* fix(agent-core-v2): align session lifecycle dependencies
2026-09-01 12:38:55 +08:00
Kimi Agent
630a11db51
feat(cli): compress native update artifacts and decompress them while staging (#3405)
Some checks are pending
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
Release / Release (push) Waiting to run
Release / Deploy docs (push) Blocked by required conditions
Release / Native release artifact (push) Blocked by required conditions
Release / Publish native release assets (push) Blocked by required conditions
Publish VS Code extension / Publish VSIX to marketplaces (push) Waiting to run
* feat(cli): compress native update artifacts and decompress them while staging

Co-authored-by: qer <wbxl2000@outlook.com>

* fix(cli): generate compressed native artifacts in the publish job

The zip's checksum never pairs with the bare executable the updater
verifies after inflating, and artifacts produced in the matrix job never
leave the runner (the workflow's upload-artifact path lists only the
zip). Extract each zip in the publish job, hash the bare executable, and
emit the .zst/.tar.gz artifacts there so the manifest entry pairs
checksum with what compressed inflates to, and everything new reaches
the release via the existing upload glob — no workflow changes needed.

Co-authored-by: qer <wbxl2000@outlook.com>

* fix(cli): keep the .exe suffix in windows manifest filenames

The updater's bare-binary fallback downloads entry.filename, and the CDN
layout carries .exe on Windows — without it the fallback 404s. The .zst
and .tar.gz artifact names stay unchanged. Also fold the manifest
coverage into the pre-existing release-artifacts test (its fake-zip
fixture predates extraction) and pin the end-to-end chain there.

Co-authored-by: qer <wbxl2000@outlook.com>

---------

Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com>
Co-authored-by: qer <wbxl2000@outlook.com>
2026-09-01 01:00:14 +08:00
Haozhe
19413c2803
docs: rename permission modes to Always Ask, Ask When Needed, and Never Ask (#3406)
Follow-up to #3403 for the user docs: living pages (en + zh mirrors)
now use the new mode names and descriptions — slash-commands and
interaction references for /ask-when-needed (aliases /yolo, /yes) and
/never-ask (alias /auto), CLI flag and config glosses, guides,
customization pages, and the docs AGENTS.md terminology table. Wire
and config ids (manual/yolo/auto) are unchanged; release notes are
historical and untouched.
2026-08-31 23:02:07 +08:00
Haozhe
15bf58555b
refactor(agent-core-v2): replace agent runtime with agent-scoped DI services (#3402)
* refactor(agent-core-v2): migrate todo domain to agent-scoped DI service

* refactor(agent-core-v2): migrate skill domain to agent-scoped DI service

* refactor(agent-core-v2): migrate reminder domain to agent-scoped DI service

* refactor(agent-core-v2): migrate interaction domain to agent-scoped DI service

* refactor(agent-core-v2): migrate cron domain to agent-scoped DI service

* refactor(agent-core-v2): migrate dateChange domain to agent-scoped DI service

* refactor(agent-core-v2): migrate goal domain to agent-scoped DI service

* refactor(agent-core-v2): remove agent runtime infrastructure

* docs(agent-core-v2): rewrite agent domain standard as agent-scoped DI service

* fix(agent-core-v2): restore actor services on late feature re-provide and order agent-created events after metadata registration
2026-08-31 22:53:29 +08:00
Haozhe
08a2fb0031
feat(cli): rename permission modes to Always Ask, Ask When Needed, and Never Ask (#3403)
TUI copy for the three permission modes (manual/yolo/auto) now uses the
new display names and descriptions across the /permission selector,
footer badge, toggle notices, goal/swarm start prompts, session replay,
and /status. The /yolo and /auto commands are renamed to
/ask-when-needed and /never-ask, with the old names kept as aliases.
2026-08-31 22:23:51 +08:00
7Sageer
3b2fc06a91
feat(agent-core-v2): add P0 telemetry events for auth, execution, and degradation paths (#3394)
* feat(agent-core-v2): add P0 telemetry events for auth, execution, and degradation paths

* test(agent-core-v2): drop telemetry emission assertions from existing test suites
2026-08-31 20:36:58 +08:00
wenhua020201-arch
70e35f5f82
docs: add Remote Control guide (zh/en) (#3398) 2026-08-31 20:26:12 +08:00
Haozhe
4b9888b73d
feat(agent-core-v2): require approval for dangerous bash commands in all permission modes (#3290)
* feat(agent-core-v2): require approval for dangerous bash commands in all permission modes

* feat(agent-core-v2): deny dangerous commands in auto mode, unwrap command launchers, and skip the guard for non-interactive hosts

* feat(agent-core-v2): support disabling the dangerous-command guard via config

* test(node-sdk): project v2's env-materialized empty permission section in config parity
2026-08-31 20:24:53 +08:00
7Sageer
616d51045d
feat(agent-core-v2): preserve config.toml formatting on writeback (#3392)
* feat(agent-core-v2): preserve config.toml formatting on writeback

Config persistence previously re-serialized the whole document on every
write, destroying user comments, key order, and blank lines. Writes now go
through a raw-text channel on the TOML document store: the file is scanned
into top-level domain regions, changed domains are diffed at key level so
only edited statements are rewritten, and untouched regions keep their
original bytes (including CRLF). The effort max-to-high migration performs
a single-line text replacement instead of a full rewrite.

Ambiguous constructs (dotted keys, arrays of tables, unmapped files) fall
back to re-serializing the affected domain, and any scanner failure falls
back to the previous whole-document write. Byte-identical results skip the
write entirely.

* feat(agent-core-v2): support quoted table headers in config writeback

The region scanner parsed only bare-key table headers, so files using
quoted segments such as [models."acme/m1"] or ["x.y"] fell back to a
whole-document rewrite, dropping user comments for exactly the configs
with the most hand-written content. Header parsing now walks TOML key
paths segment by segment (bare, basic-quoted with escape decoding,
literal-quoted), so quoted regions participate in key-level preservation
and are edited or removed in place. Emission of new sub-table headers
already quotes non-bare segments through smol-toml. Unparseable headers
still decline to the whole-document fallback.
2026-08-31 19:04:06 +08:00
7Sageer
5f0aa7f6d6
fix(cli): default the workspace trust prompt to "Trust this folder" (#3391)
Some checks are pending
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
Release / Release (push) Waiting to run
Release / Deploy docs (push) Blocked by required conditions
Release / Native release artifact (push) Blocked by required conditions
Release / Publish native release assets (push) Blocked by required conditions
Publish VS Code extension / Publish VSIX to marketplaces (push) Waiting to run
2026-08-31 16:01:46 +08:00
7Sageer
971a8b24c1
feat(secondary-model): graduate the subagent model pool out of experimental (#3334)
* feat(secondary-model): enable the subagent model pool by default

* feat(secondary-model): graduate the subagent model pool out of experimental

* fix(secondary-model): honor the v2 default_model key on the legacy engine

* fix(secondary-model): enforce forced subagent pools on the legacy engine

* fix(tower): keep reviewers on primary model

* fix(secondary-model): live-apply picker saves and replace the legacy model key

* fix(secondary-model): accept default_model in the live-apply setter and clear on removal

* fix(secondary-model): revert the legacy v1 engine, keep the v2 pool opt-out

* feat(secondary-model): graduate pool with model source telemetry

* fix(secondary-model): keep legacy engine opt-in

* test(sdk): pin secondary-model engine divergence

* fix(tower): honor forced model for reviewers
2026-08-31 15:33:26 +08:00
Haozhe
8f2c60b328
feat(agent-core-v2): support openai_responses protocol for kimi provider (#3375) 2026-08-31 14:51:21 +08:00
tpoisonooo
9e881528a8
fix(agent-core-v2): persist prompt resolution events (#3371)
* fix(agent-core-v2): persist prompt resolution events so replays can reconcile queued prompts

* docs(changset): update prompt desc

---------

Co-authored-by: konghuanjun <konghuanjun@moonshot.ai>
2026-08-31 12:32:09 +08:00
tpoisonooo
ece96185e9
fix(agent-core-v2): spawn tower workers on dirty base (#3346)
* feat(agent-core-v2): spawn tower workers on a snapshot of base checkout WIP

Tower worktrees were created from the base branch tip, so a worker never
saw uncommitted changes sitting in the base checkout — it would start
building on a foundation that did not exist in its worktree.

When a mission branch is first created, the store now captures the base
checkout's dirty paths (staged, unstaged, and untracked per git status;
.tower/ and git's own ignore rules excluded; unmerged paths refuse the
spawn) into a synthetic snapshot commit built through a temporary index
(read-tree + add + write-tree + commit-tree), so the user's checkout,
index, and base branch are never touched. The mission branch starts at
that commit and the mission records it as spawnBase.

The merge gate diffs the branch from spawnBase instead of the base tip,
so snapshotted WIP is never mistaken for a worker scope violation, and
the reviewer briefing diffs from the same point. Alternatives
considered: applying the WIP as uncommitted changes inside the new
worktree (fragile — it mixes into the worker's first commit and can be
lost before that), and excluding the WIP file set inside the gate
(permanent holes in scope enforcement, hidden provenance). A snapshot
commit keeps the gate strict and makes the WIP an explicit, mergeable
part of the branch history.

TowerMerge now also refuses to merge while the main checkout holds
uncommitted changes in files the merge would overwrite (blocked reason
base-dirty) and tells the user to commit or stash them first; dirt that
does not intersect the merge no longer blocks it.

* fix(agent-core-v2): harden tower base-WIP snapshot edge cases

- fall back to the base branch as diff base once a rebase drops the
  snapshot commit (it is only used while still an ancestor), so scope
  checks, reviewer prompts, and conflict attribution stop blaming base
  changes on the worker
- run snapshot index commands from the worktree top-level and filter
  .tower by path segment, fixing dirty-base spawning from a repo
  subdirectory (porcelain paths are worktree-root relative)
- refuse to snapshot WIP collected from a checkout that is not the
  recorded base (or a detached HEAD) instead of mixing another
  branch's content into base history

* fix(agent-core-v2): let tower mode take over from a live but idle owner session

The tower-mode ownership check refused entry whenever the recorded
owner session was still materialized in the process. kap-server keeps
sessions materialized until explicit close, so a session that stopped
abnormally (closed tab, failed turn) owned the workspace tower forever
and no second session could enter tower mode.

Now the owner is only protected while actually occupied: entry is
refused when the owner session has an active turn or a pending
interaction; a live but idle owner is exited remotely (durable
TowerModeExit in its own event log) and the entering session takes
over.

* feat(agent-core-v2): keep tower mode active after tower teardown

* chore: add changeset for tower teardown staying active

* docs(tower): merge changeset

* docs(tower): merge changeset

* fix(agent-core-v2): make tower mode mutually exclusive with plan and swarm modes

* chore: add changeset for tower mode mutual exclusion

---------

Co-authored-by: konghuanjun <konghuanjun@moonshot.ai>
2026-08-31 12:31:57 +08:00
Luyu Cheng
58b74cfeab
fix(transcript): preserve turn prompt identity (#3377)
Some checks are pending
CI / lint (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
Release / Release (push) Waiting to run
Release / Deploy docs (push) Blocked by required conditions
Release / Native release artifact (push) Blocked by required conditions
Release / Publish native release assets (push) Blocked by required conditions
Publish VS Code extension / Publish VSIX to marketplaces (push) Waiting to run
* fix(transcript): preserve turn prompt identity

* fix(transcript): backfill active prompt identity

* fix(transcript): seed late-bound turn identity

* fix(transcript): persist turn prompt identity

* fix(transcript): skip undone prompt identities

* fix(transcript): hide undone continuation turns

* docs(agent-core): update wire manifest

* fix(transcript): match cold turns by prompt identity

* fix(transcript): match internal prompt turns by origin

* fix(transcript): align undo anchors with context

* fix(transcript): prioritize cold turn matches

* fix(transcript): retire unmatched turn boundaries

* style(transcript): align cold matcher
2026-08-31 06:41:56 +08:00
Luyu Cheng
cbe0a77f3d
fix(transcript): preserve steer provenance (#3374)
* fix(transcript): preserve bundled prompt origin

* refactor(transcript): narrow steer origin projection
2026-08-30 22:41:23 +08:00
Haozhe
56b5480ed0
fix(cli): validate config.toml against the v2 schema in kimi doctor (#3372)
Some checks are pending
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
Release / Release (push) Waiting to run
Release / Deploy docs (push) Blocked by required conditions
Release / Native release artifact (push) Blocked by required conditions
Release / Publish native release assets (push) Blocked by required conditions
Publish VS Code extension / Publish VSIX to marketplaces (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / build (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
2026-08-30 15:30:09 +08:00
Kimi Agent
961927739e
fix(cli): use the unicode ellipsis in user-facing interface text (#3366)
Some checks are pending
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
Release / Release (push) Waiting to run
Release / Deploy docs (push) Blocked by required conditions
Release / Native release artifact (push) Blocked by required conditions
Release / Publish native release assets (push) Blocked by required conditions
Publish VS Code extension / Publish VSIX to marketplaces (push) Waiting to run
Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com>
2026-08-29 18:53:33 +08:00
Kexin Liu
9d2304c23c
fix(persistence): guard file reads against torn writes from external editors (#3348)
Some checks are pending
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
Release / Native release artifact (push) Blocked by required conditions
Release / Release (push) Waiting to run
Release / Deploy docs (push) Blocked by required conditions
Release / Publish native release assets (push) Blocked by required conditions
Publish VS Code extension / Publish VSIX to marketplaces (push) Waiting to run
* fix(persistence): guard file reads against torn writes from external editors

A config.toml overwritten in place (truncate + write, the way plain
writeFile and some editors save) can be read mid-write by a concurrent
config reload -- the truncated head often parses as valid TOML, so the
reload silently adopts a config with the models/providers sections
missing and wipes the model table until the next watcher-driven reload.
Observed as the prompts.test.ts flake: ProviderDiscoveryService's
reload raced the test's writeFile and setModel then failed with
"Model stub is not configured".

FileStorageService.read now verifies the read against the file's size
after the read and retries briefly on mismatch, and prompts.test.ts
swaps its in-place config overwrites for atomic tmp+rename writes.

* fix(persistence): confirm hot files with a second stat, list the CLI package in the changeset

A size match alone is not proof of a stable snapshot: a writer that
truncates or writes a partial chunk and then pauses lets read and stat
observe the same transient length. When the file's mtime is within
100ms of now, the read is only accepted after a second stat 15ms later
reports the same size and mtime; settled files still return after one
stat. The changeset now lists @moonshot-ai/kimi-code per the changeset
rules for user-perceivable fixes shipped through the CLI.

* revert(persistence): drop the hot-file double-stat confirmation

The confirmation delayed every read of a recently written file by 15ms
(45ms for files being appended), which shifted server boot and reload
timing enough to break real tests in CI (config changedFields baseline,
fork parity). The simple size-verify guard covers the race that was
actually observed; a read-side guard cannot be airtight against an
in-place writer paused mid-write anyway -- atomic writes are the real
contract.

---------

Co-authored-by: user <user@userdeMacBook-Pro.local>
2026-08-29 01:39:42 +08:00
qer
44b40e6852
ci: add VS Code extension publish workflow (#3332)
* ci: add VS Code extension publish workflow

Publish VSIX to VS Marketplace and Open VSX on version-change pushes
to main, with online-version gates and workflow_dispatch fallback.

* ci(vscode): harden publish gate with before-SHA diff and per-platform checks

Address review on the auto-publish workflow:

- Version-change detection now compares against the push event's
  `before` SHA instead of `GITHUB_SHA~1`, so a single push carrying
  multiple commits cannot skip a version bump. An empty or all-zero
  `before` (e.g. first push of a branch) is treated as a version
  change — better an extra marketplace lookup than a missed release.
- Marketplace gates now verify all 6 targetPlatforms
  (darwin/linux/win32 x x64/arm64) instead of only the version number:
  Open VSX is checked per-platform via REST, VS Marketplace via the
  targetPlatform entries in `vsce show --json`. A partially published
  version now reruns the affected publish step, which backfills
  idempotently via --skip-duplicate / already-exists handling.
  Lookup failures stay fail-closed (treated as not published).

---------

Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com>
2026-08-28 19:59:38 +08:00
7Sageer
9fa1e77df5
refactor(agent-core-v2): remove the ${now} system prompt template variable (#3341)
Some checks are pending
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
Release / Publish native release assets (push) Blocked by required conditions
Release / Release (push) Waiting to run
Release / Deploy docs (push) Blocked by required conditions
Release / Native release artifact (push) Blocked by required conditions
2026-08-28 19:09:53 +08:00
Kimi Agent
0312baaf13
docs(changelog): sync 0.39.1 from apps/kimi-code/CHANGELOG.md (#3342) 2026-08-28 18:34:17 +08:00
github-actions[bot]
5efca0c311
ci: release packages (#3312)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-28 17:58:47 +08:00
Kimi Agent
8f43674b90
chore: sync web dist from code-app (#3333)
* chore: sync web dist from code-app

code-app: 2139742c91c097a1e26cec7044970067a7e3d736

* chore: clarify web sync changeset wording

Reword two synced changesets to describe the actual upstream code-app
changes (#420, #439). Release contents unchanged.

---------

Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com>
2026-08-28 17:50:08 +08:00
liruifengv
d8317d81e5
fix(agent-core-v2): cache workspace alias resolution across calls (#3325)
* fix(agent-core-v2): cache workspace alias resolution across calls

resolveAliasIds re-read the workspace catalog and the whole session
index from disk on every call, so the by_workspace grouping loop and
the per-workspace session counts paid repeated full-file reads per
workspace per request (~2.4s per 50-group page at 1.1k workspaces,
23 pages serially during a client startup drain).

Cache both files as precomputed snapshots (by-id map plus a
root-key -> alias ids index) invalidated by the storage watch events,
which cover atomic rewrites and cross-process writes; storage backends
without watch fall back to reading through. The first resolution primes
the workspace merge via IWorkspaceService.list() so the cached catalog
matches what WorkspaceService.get() would have returned.

* chore: drop the changeset; the user-facing entry ships with the app changelog

* fix(agent-core-v2): coalesce cold alias snapshot loads and guard publication

Concurrent cold resolveAliasIds callers (the /workspaces route fans out
per-workspace counts with Promise.all) all passed the cache check before
any caller finished loading, re-running the full catalog and session
index reads the cache exists to avoid; memoize the in-flight load
promise so a cold batch shares one read. Also capture the invalidation
generation before each read and publish the snapshot only when it is
unchanged, so a mid-read file replacement cannot leave a stale snapshot
installed over the watch invalidation.

* fix(agent-core-v2): publish catalog invalidation through the persistence owner

A debounced fs watch was the only invalidation channel for the alias
catalog snapshot, so an in-process catalog write stayed invisible to
resolveAliasIds for up to the watch debounce window while the previous
read-through code observed every completed write immediately.
IWorkspacePersistence now exposes onDidChange: FileWorkspacePersistence
fires it synchronously on save and re-fires the underlying document
watch (covering atomic rewrites and cross-process writers), and the
aliases service subscribes to it instead of watching raw storage keys.
The session index snapshot keeps the filesystem watch, matching the
read-side ownership of that file.

* fix(agent-core-v2): invalidate session alias snapshots on append-log writes

A flushed session_index.jsonl append was invisible to resolveAliasIds
for up to the fs-watch debounce window, so a sessions request issued
right after a session create could resolve the workspace's aliases from
the pre-append snapshot. IAppendLogStore now publishes onDidWrite after
each durable flush (append batches and rewrites), and the aliases
service drops its session-index snapshot through that event; the raw
filesystem watch stays as the channel for cross-process writers.

* fix(agent-core-v2): fire append-log write events only after actual writes

Once a key has a LogState, every global flush() (WireService flushes
after ordinary agent persistence) completed it successfully and fired
onDidWrite unconditionally, so idle agent activity kept dropping the
alias session-index snapshot and forced full re-reads of an unchanged
index. drain() now reports whether it appended anything and the write
event fires only when a flush actually persisted a batch or a rewrite.

* fix(agent-core-v2): retry shared snapshot loads that span a write

Callers joining an in-flight single-flight load after a completed write
still received the pre-write snapshot: the generation check only guarded
cache publication, not the value returned to awaiters. Each load now
carries the generation it started at, and catalog()/sessionIndex()
re-read (coalesced through the same single-flight) when the settled
load's generation is stale.

* fix(agent-core-v2): report partial progress when an append-log drain fails

A drain that persisted one batch and then failed the next threw without
recording the durable write, so onDidWrite never fired for records that
were in fact persisted (the alias session-index snapshot then missed
its synchronous invalidation). The write box now threads through the
whole owned flush: each successful batch marks it, and the event fires
before the failure propagates.

* fix(agent-core-v2): retry the whole alias resolution across a mid-write

The per-snapshot retry guarded each read on its own, so a write landing
between the catalog and session-index reads returned an alias set
assembled across two generations. resolveAliasIds now captures the
generation once, reads both snapshots together, and retries the whole
resolution when either input was invalidated mid-flight. The
spanned-write test is reworked to gate after the load (so the snapshot
content genuinely predates the write), and a new case covers the
cross-generation mix directly.

* fix(agent-core-v2): replace the session-index fs watch with a size check

A resident chokidar watcher per server on the shared home directory
degraded watch delivery for unrelated files under test-suite boot
volume (the prompts suite lost the config.toml reload race and the
catalog missed a just-written model). In-process appends were already
covered synchronously by the append-log write event; cross-process
writers now surface through a per-call size comparison on the
append-only file, which costs one stat per resolve and needs no
resident watcher.
2026-08-28 17:20:52 +08:00
Kimi Agent
dc6028dc6b
fix(kap-server): only fold user-origin steers by content in the cold transcript (#3328)
* fix(kap-server): only fold user-origin steers by content in the cold transcript

* fix(transcript): check marker-only origins before the steer content match

* fix(transcript): limit the steer bypass to marker-only skill triggers

* fix(transcript): consume the steer count for marker-only activations

* fix(transcript): pair steered contents with messages by origin kind

* refactor(kap-server): read the steer origin kind without nested casts

---------

Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com>
2026-08-28 17:05:59 +08:00
Haozhe
efce74e435
fix(cli): show the full remote control link in the startup output (#3331) 2026-08-28 15:54:19 +08:00
liruifengv
2bf7ed22d7
feat(auth): split model readiness from sign-in state in /api/v1/auth (#3293)
* feat(auth): split model readiness from sign-in state in /api/v1/auth

GET /api/v1/auth now reports models_ready (the default model resolves
against the configured catalog, providerless and env-injected models
included) instead of the compound ready flag, and no longer carries
default_model — config values are served by /config alone. The v1
summary schema follows.

OAuth managed-model refreshes now heal a lost default model: the
refresh snapshot includes defaultModel, so an unchanged catalog with
a missing default still lands the write-back branch and re-selects
one. The refresh also rebases onto a fresh config read after the
remote fetch, so a model or thinking change made during the fetch is
no longer overwritten. The shared discovery refresh path (scheduler,
POST /providers/{id}:refresh) heals the default the same way.

Config changes are now published to WS clients on every write path:
a debounced+trailing publisher bridges IConfigService section changes
to ConfigChanged with camelCase changedFields and a full config
projection, and the broadcaster forwards event.config.changed and
event.model_catalog.changed (both previously published but never
delivered). All three event types are registered in the event unions,
so session_event parsing and AsyncAPI describe them.

BREAKING CHANGE: GET /api/v1/auth drops the ready and default_model
fields in favor of models_ready; event.config.changed's changedFields
is now camelCase domain names instead of the raw snake_case request
keys (v1 summary schema follows).

* fix(kap-server): expose the session model in session list projections

GET /api/v1/sessions hardcoded agent_config.model to '' and the v2
projection had no model field at all, so clients could only learn a
session's model via the post-select /status read — which races the WS
replay and often never lands. SessionFacts now carries the live
session's model (same source as the snapshot route), toWireSession
emits it, and the v2 activity domain gains a nullable model field.

* fix(kap-server): gate prompt submission on the effective session model

The submit gate called ensureReady() with no override, so it only ever
validated config.default_model: a session with a bound model (or a
prompt carrying one) was rejected with 40113 whenever default_model was
missing or dangling. Pass the effective model (request model, then the
agent profile's bound model, falling back to default_model inside
ensureReady) on both the prompt submit and btw routes.

* fix(agent-core-v2): honor defaultProvider in model readiness resolution

resolveModelForReady stopped at the flat baseUrl fallback, so a model
that omits provider/providerId and relies on the configured
defaultProvider resolved at runtime (ModelCatalog.resolveProviderContext
falls back to it) while /api/v1/auth reported models_ready:false and the
send gate rejected the prompt. Mirror the runtime order (providerId ->
provider -> defaultProvider -> flat baseUrl) and pass the configured
default provider from both readiness callers.

* fix(kap-server): redact inline model credentials from config responses

toConfigResponse only redacted the providers section, so a model's
inline apiKey/oauth rode GET /config verbatim and, via the new
event.config.changed publisher, every WS connection plus the persistent
event journal. Project the models section the same way: strip
credential fields and report has_api_key.

* fix(agent-core-v2): honor defaultProvider in ensureReady credential checks

The readiness phase learned the defaultProvider fallback, but the
credential phase right after still derived the provider only from the
model's explicit fields: a model omitting provider/providerId passed
readiness yet missed the default provider's apiKey/OAuth material and
prompts failed with auth.token_missing. Mirror the same provider chain
(providerId -> provider -> defaultProvider) when resolving credentials.

* fix(kap-server): validate the model a profile bind will select at the prompt gate

The gate validated the session's current model even for a prompt that
switches profile without a model — but bind falls back to defaultModel
in that case, so a stale session model drew a misleading 40113 before
bind could run. Gate on bind's selection order instead: the request's
explicit model, then the default on a profile switch, then the session's
bound model.

* fix(kap-server): redact inline service credentials from config responses

The earlier redaction covered providers and models, but toConfigResponse
still passed the services section through verbatim: inline or
env-injected apiKey, oauth references, and credential-bearing
customHeaders rode GET /config and, via the event.config.changed
publisher, every WS connection plus the persistent event journal.
Project services the same way: strip apiKey/oauth into has_api_key and
report only the header names as custom_header_keys (the MCP
envKeys/headerKeys convention).

* fix(kap-server): keep unlisted config domains through event validation

The config.changed broadcaster returned the zod-parsed config, which
strips domains absent from configResponseSchema (mcp, identity,
model_catalog, image, tools, token_counting): changedFields named them
while the advertised full snapshot no longer matched GET /api/v1/config.
Make the response projection passthrough (defineRoute validates only
requests, so REST responses are unaffected).

* fix(agent-core-v2): use the exact configured key for model readiness lookups

resolveModelForReady trimmed the model id before the models-table lookup
while ModelCatalog and ensureReady use the configured string as an exact
record key: a whitespace-padded default_model was reported ready and then
crashed the submit gate with an internal error instead of 40113, and a
legitimate key containing spaces was reported dangling. Trim only rejects
blank values now; the lookup always uses the raw key.

* fix(protocol): keep unlisted config domains in the shared event projection

The shared configResponseSchema stripped domains it does not enumerate
(mcp, identity, model_catalog, image, tools, token_counting, subagent,
secondary_model), so event.config.changed parsed through agentEventSchema
named them in changedFields while omitting their values. Make the shared
projection passthrough like the kap-server-local one.

* fix(agent-core-v2): use the exact default_provider key in readiness checks

The defaultProvider fallback trimmed the configured value before the
providers-table lookup while ProviderService and ModelCatalog use the
configured string verbatim: a whitespace-padded default_provider could
build successfully yet report not-ready (40113), or report ready for a
provider runtime resolution cannot find. Trim only rejects blank values;
the lookup uses the raw key.

* chore: sync web dist from code-app

Rebuild the bundled web UI against this branch's /auth contract (models_ready, no ready/default_model): the previous bundle still read the old fields and stayed in the not-ready flow against this server.

code-app: 000d2594ff3e95b553be326126bab3f939b62944

* Revert "chore: sync web dist from code-app"

This reverts commit 9400a24a03863b3e8b780dda251540f824f02f3a.

* fix(oauth): rebase the default selection after the refresh fetch

A provider refresh snapshots the config before the remote catalog fetch;
when the user selects a default model while the fetch is in flight, the
stale snapshot's empty default made an otherwise unchanged catalog enter
the write path and the self-heal persisted the generated default over the
user's newer selection. Each branch now re-reads and rebases the
default/thinking selection after its fetch, before cloning, comparing,
or writing.

* style(kap-server): pass optional custom_header_keys without conditional spread
2026-08-28 15:53:56 +08:00
Kimi Agent
0310f223da
fix(cli): give the interactive update check a longer CDN timeout (#3307)
* fix(cli): give the interactive update check a longer CDN timeout

`kimi update` shared the 3-second CDN fetch budget sized for passive
background checks. Every CLI invocation is a fresh process paying full
DNS+TCP+TLS setup, so a slow connection to the CDN intermittently
aborted the interactive check with a raw "This operation was aborted".

Thread a per-request timeout through the CDN fetch helpers and
refreshUpdateCache; the interactive upgrade command now passes a 10
second budget (INTERACTIVE_UPDATE_CHECK_TIMEOUT_MS) while all
background refresh paths keep the 3-second default.

* refactor(cli): drop motivational comments and simplify the update-check changeset

* docs(cli): reword the update-check changeset

* docs(cli): English changeset for the update-check timeout

---------

Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com>
2026-08-28 12:21:57 +08:00