Commit graph

14 commits

Author SHA1 Message Date
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
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
_Kerman
38c2c0f527 refactor(agent-core-v2): reverse external hooks dependency 2026-07-03 10:48:32 +08:00
haozhe.yang
b293d6f030 refactor(agent-core-v2): register built-in tools via DI
Make built-in tool registration DI-native:
- each tool is now a DI class whose dependencies are injected via @IX
  instead of hand-wired through a parent service constructor
- each domain registers its tools from an Eager Agent-scope *ToolsService
  that builds them with IInstantiationService.createInstance
- split tool registration out of domain services that the tools call back
  into (cron/background/goal/plan/swarm/skill) to avoid constructor cycles
- drop the manual force-pulls (rpc marker injections, the
  initializeBuiltinTools callback, runChildAgent ensureAgentTool) now that
  Eager registration runs at Agent scope creation
- defer IHostEnvironment reads in GlobTool/BashTool to getters so Eager
  construction does not require environment readiness

Media tools (ReadMediaFile) are left as-is pending a capability-gated
registration design.
2026-07-02 16:04:39 +08:00
haozhe.yang
3606488ea2 refactor(agent-core-v2): drop @moonshot-ai/kaos, split IKaos into atoms
Replace the god-object `IKaos` interface and the `@moonshot-ai/kaos`
package dependency with atomic services:

- `IHostEnvironment` (App scope) — memoised OS / shell / path-style /
  home probe; sync fields plus a `ready` promise the composition root
  awaits before seeding Session scopes.
- `IExecContext` (Session scope) — immutable cwd + env-layers seed
  value with `withCwd` / `withEnv` derivations; replaces
  `IKaos.cwd/withCwd/withEnv` and `IKaosFactory`.
- `ISessionAgentFileSystem` / `ISessionProcessRunner` — inline
  `node:fs/promises` and `child_process.spawn` directly; the
  `IKaos.backend` leak that let `profile/context.ts`, `fileTools/glob`
  and `agentFs/runRg` reach around the facades is gone.

Vendor the pure helpers into `src/_base/execEnv/` (`BufferedReadable`,
`decodeTextWithErrors`, `globPatternToRegex`, host-environment probe).
`src/app/kaos/` and `test/kaos/` are deleted; session-lifecycle awaits
`hostEnv.ready` and then seeds `IExecContext` into the child scope.

Rewrites every `@IKaos` consumer:
- `shellTools/bash`, `fileTools/{read,write,edit,glob,grep}`,
  `media/read-media`, `_base/tools/policies/path-access`
- `permissionPolicy/git-cwd-write-approve` and
  `permissionPolicy/git-control-path-access-ask`
- `agent/rpc`, `agent/agentTool`, `agent/profile/{context,profileService}`
- `session/{sessionWarning,workspaceContext}`
- `app/bootstrap` (drops `IBootstrapService.detect()`)
- `fileTools/glob` and `agentFs/runRg` now route rg through
  `ISessionProcessRunner.exec` with per-call `{ cwd }` overrides

`test/tools/fixtures/fake-kaos.ts` is replaced by `fake-exec.ts` with
per-atom factories (`createFakeHostEnvironment`, `createFakeExecContext`,
`createFakeAgentFs`, `createFakeProcessRunner`). Domain-layer registry,
PUML diagram, tsdown externals and `package.json` deps are updated
accordingly.

`packages/kaos/` stays in the workspace — v1, node-sdk and acp-adapter
still depend on it. Only `agent-core-v2` has been detached.
2026-07-01 21:40:46 +08:00
haozhe.yang
5fece98c91 refactor(agent-core-v2): group src domains by lifecycle scope
Move src/{domain}/* to src/{scope}/{domain}/* (app/session/agent) so the
directory layout mirrors the DI LifecycleScope tree. Split the three
multi-scope domains so no domain spans two scopes:

- log      -> app/log + session/sessionLog
- question -> session/question + agent/questionTools
- skill    -> app/globalSkillCatalog + session/sessionSkillCatalog + agent/skill

Rewrite every #/ and relative import, module augmentation, vi.mock, and
source-path read; update the package barrel, registerScopedService domain
labels, the domain-layer checker, the dep-graph script, file headers, and
the di-scope-domains map.
2026-07-01 15:11:49 +08:00
haozhe.yang
314e4ef2df Merge remote-tracking branch 'origin/kimi-code-v2' into kimi-code-v2
# Conflicts:
#	packages/agent-core-v2/src/shellTools/shellToolsService.ts
#	packages/agent-core-v2/src/userTool/userToolService.ts
#	packages/agent-core-v2/test/goal/injection.test.ts
#	packages/agent-core-v2/test/harness/agent.ts
#	packages/agent-core-v2/test/profile/config-state.test.ts
#	packages/agent-core-v2/test/session-lifecycle/sessionLifecycle.test.ts
#	packages/agent-core-v2/test/shellTools/shellToolsService.test.ts
#	packages/agent-core-v2/test/skill/plugin-session-start.test.ts
#	packages/agent-core-v2/test/snapshot/events.ts
#	packages/agent-core-v2/test/subagentHost/agent-tool.test.ts
#	packages/agent-core-v2/test/swarm/swarm.test.ts
#	packages/agent-core-v2/test/toolDedup/tool-dedup.test.ts
#	packages/agent-core-v2/test/turn/stubs.ts
#	packages/agent-core-v2/test/turn/turn.test.ts
2026-07-01 13:58:56 +08:00
haozhe.yang
e0f900803a feat(agent-core-v2): wire remaining v1 migration pieces
- add completion budget with 128k compaction output cap and max-output honor
- add config + /update-config hints to the max-steps-per-turn error
- log malformed tool-call JSON parse failures and cover parseToolCallArguments
- add modelCatalog config section (refresh interval / refresh-on-start)
- wire plugin skills + session-start reminders into skill catalog and prompt flow
- add error serialization helpers and error taxonomy coverage
- route messageLegacy cold-session loading through session-lifecycle resume
- add background task detachTimeoutMs option
2026-07-01 13:00:20 +08:00
_Kerman
9fed2af01c fix(agent-core-v2): fix tests 2026-07-01 10:54:13 +08:00
haozhe.yang
cd47ef4aff refactor(agent-core-v2): rename scoped services to encode scope
- rename service interfaces and implementations to carry the Session/Agent
  scope prefix and Service suffix (e.g. IApprovalService ->
  ISessionApprovalService, ApprovalService -> SessionApprovalService)
- rename LifecycleScope.Core to App in the DI base
- update DI createDecorator keys to match the new identifiers
- propagate the renames through server-v2 routes/transport, examples, docs,
  and the agent-core-dev skill
2026-07-01 01:05:53 +08:00
haozhe.yang
78320259a5 feat(agent-core-v2): add built-in file and shell tools
- add fileTools domain (Read/Write/Edit/Grep/Glob)
- add shellTools domain (Bash)
- wire registration through FileToolsService and ShellToolsService
- add readLines to IAgentFileSystem for the Read tool
2026-06-30 14:12:22 +08:00