Commit graph

883 commits

Author SHA1 Message Date
_Kerman
0d0bb736a8 fix: appendSystemReminder 2026-07-04 21:20:18 +08:00
_Kerman
bec0b085f2 Merge remote-tracking branch 'origin/kimi-code-v2' into xtr/context-ops-wire
# Conflicts:
#	packages/agent-core-v2/src/agent/contextMemory/contextMemory.ts
#	packages/agent-core-v2/src/agent/goal/goalService.ts
#	packages/agent-core-v2/src/agent/prompt/promptService.ts
#	packages/agent-core-v2/src/agent/systemReminder/systemReminder.ts
2026-07-04 18:14:31 +08:00
_Kerman
9a869d94ad style: normalize agent-core-v2 service interface layout
Align all DI service contracts on _serviceBrand first, a blank line, methods and properties, then hooks last when present.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-04 17:54:21 +08:00
_Kerman
14e3c769f3 refactor: objectify agent loop run options 2026-07-04 17:30:38 +08:00
_Kerman
0d9d91f584 fix: remove TurnStartedEvent.origin 2026-07-04 17:23:52 +08:00
_Kerman
c0c9f155da fix: restore prompt id in server-v2 snapshots 2026-07-04 17:14:50 +08:00
_Kerman
8705d502f0 refactor: remove PromptOrigin from IAgentTurnService.launch
Turn origin is tracked on context messages instead; drop it from the turn launch API and wire records.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-04 17:03:45 +08:00
_Kerman
3665c7da37 Merge remote-tracking branch 'origin/kimi-code-v2' into xtr/context-ops-wire
# Conflicts:
#	packages/agent-core-v2/src/agent/contextMemory/messageId.ts
#	packages/agent-core-v2/src/agent/goal/goalService.ts
2026-07-04 16:29:30 +08:00
_Kerman
0d8b9f96ef refactor: remove promptMessageId from turn lifecycle
Turn no longer carries or emits the triggering message id; prompt and goal
callers keep message identity in context memory instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-04 16:24:17 +08:00
_Kerman
7d44096be3 fix: route external hook context writes through context ops 2026-07-04 16:21:07 +08:00
_Kerman
c1debee32b refactor: remove systemReminderService 2026-07-04 16:15:35 +08:00
_Kerman
5471fc6bdb fix 2026-07-04 16:14:30 +08:00
_Kerman
0491b06339 refactor: route v2 context changes through context ops 2026-07-04 16:14:30 +08:00
_Kerman
b71b2d20c2 refactor: ExecutableToolResult 2026-07-04 15:53:37 +08:00
_Kerman
86a7db1b35 refactor: remove lastEndedReason 2026-07-04 15:43:26 +08:00
_Kerman
14b5d581d8 refactor: promptService 2026-07-04 15:36:05 +08:00
_Kerman
589c6b6cf0 fix: rework steer 2026-07-04 15:32:17 +08:00
_Kerman
2471ae088f feat: simplify turn service 2026-07-04 15:04:06 +08:00
_Kerman
95901922e4 refactor: simplify loop and turn 2026-07-04 14:15:06 +08:00
_Kerman
4c2c3956fe refactor: generalize loop error recovery hook 2026-07-04 13:49:22 +08:00
_Kerman
58516f4900 feat: allow multi-shot hook 2026-07-04 13:11:40 +08:00
_Kerman
cc53ae6dd7 refactor: unify turn continuation handling 2026-07-04 12:22:14 +08:00
haozhe.yang
f060872ffc Merge remote-tracking branch 'origin/kimi-code-v2' into kimi-code-v2 2026-07-04 09:08:14 +08:00
haozhe.yang
b3ac27e79a refactor(agent-core-v2): make todo session-shared and wire-only
- move todo from agent scope (`IAgentTodoListService`) to session scope
  (`ISessionTodoService`); the list is now shared across every agent in a
  session instead of per-agent.
- persist every change as a `todo.set` record on the main agent's wire, which
  is the single source of truth and a replayable timeline; drop the agent
  tool-store `'todo'` key and the atomic-doc persistence store.
- bind `TodoListTool` and the stale reminder into every agent via
  `IAgentLifecycleService`, and register the `todo.set` resume resumer on the
  main agent.
- migrate `fullCompaction` to read `ISessionTodoService`; register the `todo`
  domain at L4 with a `todo>agentLifecycle` layer exception; refresh the DI
  scope/domain diagram.
2026-07-03 23:30:55 +08:00
_Kerman
483fc99696 Merge branch 'kimi-code-v2' of https://github.com/MoonshotAI/kimi-code into kimi-code-v2 2026-07-03 22:59:50 +08:00
_Kerman
0f77fa8a2e fix: full compaction 2026-07-03 22:59:42 +08:00
haozhe.yang
bcc9bc095f refactor(agent-core-v2): drop ISessionAgentFileSystem, use os layer
- remove the ISessionAgentFileSystem service and its node implementation
- extend IHostFileSystem with readText decode options and stat mtimeMs/ino
- route SessionFsService, profile context, media, and plan through IHostFileSystem
- drop the unused agentFs:* session REST endpoints from server-v2/server-e2e
2026-07-03 21:08:00 +08:00
haozhe.yang
80d65c7a85 refactor(agent-core-v2): split file tools and edit service
- route read/write/grep/glob through host fs and process services
- add TextModel/EditService with an os-backed FileEditService
- update file tool tests, exports, layer rules, and DI docs
2026-07-03 20:42:55 +08:00
_Kerman
5ccfe76546 fix: projector and ready promise 2026-07-03 20:11:54 +08:00
_Kerman
ec53d89739 fix: context injector and projector 2026-07-03 19:40:47 +08:00
_Kerman
87faa7897b Merge branch 'kimi-code-v2' of https://github.com/MoonshotAI/kimi-code into kimi-code-v2 2026-07-03 18:15:12 +08:00
_Kerman
b00027b912 fix: loop result 2026-07-03 18:15:06 +08:00
haozhe.yang
33fbbcb451 Merge remote-tracking branch 'origin/kimi-code-v2' into kimi-code-v2 2026-07-03 17:54:05 +08:00
_Kerman
6e4baf8dc2 Merge branch 'kimi-code-v2' of https://github.com/MoonshotAI/kimi-code into kimi-code-v2 2026-07-03 17:09:05 +08:00
_Kerman
030cf793d5 refactor: task instead of background task 2026-07-03 16:57:46 +08:00
haozhe.yang
b05c30e705 refactor(cron): consolidate cron domain into app/cron
- add app/cron barrel re-exporting the cron task record, persistence contract/service, and dependency-free algorithm lib (cron-expr, jitter, clock, format)
- move cronTask persistence files from app/cronPersistence into app/cron and drop the old cronPersistence barrel
- register the cron config section (KIMI_CRON_* env bindings) via configSection
- repoint cron tests from #/agent/cron and #/app/cronPersistence to #/app/cron
2026-07-03 16:53:54 +08:00
haozhe.yang
649ba03783 refactor(agent-core-v2): relocate builtin profile contributions
- move plan profile into plan domain profile/
- move agent/coder/explore profiles into agentLifecycle domain profile/
- add shared profile prompt helper and update barrel side-effect imports
2026-07-03 16:49:45 +08:00
_Kerman
0cc1329a25 Merge remote-tracking branch 'origin/main' into kimi-code-v2
# Conflicts:
#	package.json
#	packages/server/src/routes/prompts.ts
#	pnpm-lock.yaml
2026-07-03 15:48:13 +08:00
haozhe.yang
c7c4b50d8c refactor(agent-core-v2): flatten task module interface directory
- move task.ts from task/interface/ up to task/
- remove the task/interface/ barrel directory
- update imports in task barrel, taskService, and tests
2026-07-03 15:47:40 +08:00
haozhe.yang
b432d302d3 refactor(agent-core-v2): bind profile in spawn, drop compat barrels
- spawn now accepts `profile` and binds it, removing applyProfileToAgent
- delete app/storage, app/hostEnvironment, app/hostFs re-export barrels
- update consumers to import from persistence/interface and os/interface
- add AgentProfileService.bind tests
2026-07-03 15:43:17 +08:00
haozhe.yang
3701cf13fa refactor(file-tools): relocate built-in file tools to node-local backend
- move Read/Write/Edit/Grep/Glob tools and line-endings helper from agent/fileTools to os/backends/node-local/tools
- re-export tools from the node-local backend barrel
- drop the fileTools domain barrel and its domain-layer entry
- update test imports to the new paths
2026-07-03 15:43:17 +08:00
haozhe.yang
baf1dc304b refactor(agent-core-v2): move subagent orchestration into lifecycle service
- add runSubagent/resumeSubagent to IAgentLifecycleService
- move spawn/profile/prompt-prefix/record/telemetry/observe composition out of the Agent tool
- turn the Agent tool into a thin adapter over the lifecycle service
- stub the two methods in gateway and sessionActivity tests
2026-07-03 15:43:17 +08:00
haozhe.yang
c2e88c1846 refactor(agent-core-v2): implement git domain on os process service
- spawn git/gh via IHostProcessService instead of node:child_process
- probe path existence via IHostFileSystem instead of node:fs/promises
- normalize git porcelain paths without node:path
- resolve IGitService through the container in gitService.test.ts
2026-07-03 15:43:17 +08:00
haozhe.yang
3287b8fc0f refactor(agent-core-v2): move web to app, split WebSearch into auth
- Move the `web` domain from src/agent/web to src/app/web; it now owns only
  the auth-independent FetchURL (tool, UrlFetcher contract, and the local and
  Moonshot fetch providers).
- Move WebSearch (tool, WebSearchProvider contract, MoonshotWebSearchProvider)
  into the KimiOAuth auth domain under src/app/auth/webSearch, since it needs
  an authenticated backend.
- Replace the Agent-scope IAgentWebService registrar with registerTool
  contributions fed by new App-scope seams (IWebFetchService,
  IWebSearchProviderService), because the tool registry is Agent-scoped.
- Add documented auth>tool / auth>toolRegistry layer exceptions and update the
  DI scope-domain graph.
2026-07-03 15:43:17 +08:00
Kai
021786f5a2
fix(kaos): enrich PATH from the user's login shell at startup (#1339)
* feat(agent-core): strengthen the language-matching rule in the default system prompt

* chore: refine changeset wording

* fix(kaos): enrich PATH from the user's login shell at startup

When kimi-code is launched from a context that skipped the user's shell
profile (GUI launchers, non-login parent shells), process.env.PATH misses
entries like /opt/homebrew/bin, so commands spawned by the Bash tool
cannot find user-installed tools such as gh.

LocalKaos.create() now probes the user's login shell once
($SHELL -l -c env, 5s timeout, memoised) and appends the missing PATH
entries to process.env.PATH. Existing entries keep their order and
priority; probe failures silently leave PATH untouched. Windows is
skipped: the problem is specific to POSIX login-shell profiles.

* fix(kaos): fall back to the account login shell when $SHELL is unset

launchd/daemon launches can leave $SHELL unset or blank — the very
contexts whose PATH is impoverished — so the login-shell PATH probe
would give up exactly where it matters most. Resolve the shell from the
OS user database (os.userInfo().shell) before giving up; lookups that
throw (uid without a database entry) or yield nologin shells degrade
silently as before.

* fix(kaos): preserve empty PATH components when merging login-shell PATH

POSIX command lookup treats an empty PATH component (leading colon,
trailing colon, or double colon) as the current directory. The merge
previously filtered those out of the current PATH and rewrote the value
even when nothing was appended, silently dropping cwd lookup for users
who rely on it.

Keep the current PATH string verbatim as the prefix, append only the
missing login-shell entries, and skip the env write entirely when the
login shell contributes nothing — an unset PATH stays unset, a set PATH
is never rewritten. Empty login-shell components are still never
imported.

* fix(kaos): only import absolute login-shell PATH entries

A `.` or relative component in the login-shell PATH is cwd-dependent
lookup with another spelling, and LocalKaos runs commands from arbitrary
workspace directories — importing one would let a command name resolve
from an untrusted project cwd. Tighten the merge's skip condition from
"empty" to "not absolute", which subsumes the empty-component check.

* fix(kaos): invoke the login-shell probe's env by absolute path

A bare `env` inside `$SHELL -l -c` resolves through the inherited PATH
from the workspace cwd. If that PATH carries a cwd-dependent component
(which the merge deliberately preserves), a repo-planted `env` binary
would run automatically at session startup and could feed the probe an
arbitrary PATH. /usr/bin/env is guaranteed on mainstream POSIX systems
and also bypasses profile function shadowing.
2026-07-03 15:20:38 +08:00
_Kerman
ab64d48154 refactor: onToolResult, LLMRequestSource 2026-07-03 15:11:20 +08:00
_Kerman
8ba75bbc02 Merge branch 'kimi-code-v2' of https://github.com/MoonshotAI/kimi-code into kimi-code-v2 2026-07-03 15:09:22 +08:00
Kai
e2fe62a5ef
fix(agent-core): harden tool_use/tool_result exchange integrity (#1340)
Some checks are pending
CI / lint (push) Waiting to run
CI / test (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / build (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 / Desktop release artifact (push) Blocked by required conditions
Release / Publish native release assets (push) Blocked by required conditions
* feat(agent-core): guide the model away from repeating denied or failed tool calls

- system.md: add a diagnose-before-retrying paragraph next to the existing
  permission-denial guidance, covering failed tool calls
- permission: when the user rejects an approval on the main agent, tell the
  model not to re-attempt the exact same call (sub agents already had an
  equivalent hint)

* fix(agent-core): close abandoned tool exchanges and dedupe duplicate tool_use ids

A turn that dies between a recorded tool.call and its paired tool.result
(e.g. a transcript write failure mid-batch) used to leave
pendingToolResultIds open forever: every later message was stranded in
deferredMessages and user input was silently swallowed.

- runOneTurn now defensively closes any dangling tool calls when a turn
  ends (completed, cancelled, or failed), synthesizing an error result
  that names the cause, with a warn log and a tool_exchange_abandoned
  telemetry event
- the projector drops assistant tool calls whose id already appeared
  earlier (first occurrence wins): a duplicate id is wire-invalid on
  strict providers and not repairable by the strict resend; reported via
  the existing projection-repair log and telemetry
- resume-side closePendingToolResults now logs what it closes (warn for
  a mid-history gap, info for the routine trailing interruption)

* chore: add changesets for tool exchange fixes

* fix(agent-core): scope duplicate tool_use id dedup to the strict resend

Unconditional dedup regressed providers that emit per-response counter
ids (e.g. call_0 in every step) and accept their own duplicates: later
tool exchanges silently vanished from the projected history, and a
duplicate call's own recorded result was left dangling.

- the dedupe pass is now opt-in via dedupeDuplicateToolCalls and enabled
  only in strictMessages, so the normal projection keeps the history the
  provider produced
- the pass also drops every tool result after the first for an id, so no
  dangling tool message survives; when the kept call has no result of
  its own, the surviving one is reattached by the adjacency repair
- kosong now classifies the Anthropic "tool_use ids must be unique" 400
  as a recoverable request-structure error so it triggers the strict
  resend
2026-07-03 14:26:57 +08:00
liruifengv
9091627257
fix(tui): avoid submitting rapid multi-line paste bursts (#1305)
* fix(tui): avoid submitting rapid multi-line paste bursts

* chore(tui): remove paste burst settings picker

* fix(tui): reset paste burst on DEL backspace
2026-07-03 14:21:02 +08:00
haozhe.yang
323639f1b8 Merge remote-tracking branch 'origin/kimi-code-v2' into kimi-code-v2 2026-07-03 14:04:20 +08:00