feat(#2095): migrate Kimi CLI onto EoS imperative adapter + native hook-bus + background dispatch (ADR-1239)
Fold all runtime==='kimi'/isKimi logic branches into descriptor-driven hostBehaviors (localInstallDeferred, verificationStyle, agentManifestStyle, reapplyCommand, doneBannerStyle) + add 'kimi' to _DESCRIPTOR_AGENTS_RUNTIMES. Kimi's skills/kimi-agents dispatch was already descriptor-driven (converter-by- name + kimi-agents kind). Zero isKimi/runtime==='kimi' branches remain. UPGRADE 1 (native hook bus): new hooksSurface 'kimi-hooks-toml' + a marker- delimited config.toml [[hooks]] emitter (buildKimiHooksTomlBlock/writeKimiHooksToml in runtime-hooks-surface.cts; resolveKimiHooksTomlDir in runtime-homes.cts). GSD's lifecycle hooks now wire into Kimi's native ~/.kimi/config.toml (Context7- confirmed path) at SessionStart/PreToolUse/Stop/PreCompact/SubagentStart/ SubagentStop — kimi becomes a hooks/ consumer (the 3 && !isKimi exclusion guards removed). config.toml holds absolute install paths so it's golden-excluded via an exact relative-path (.kimi/config.toml), not a basename (which would blind Codex's config.toml). New hooksSurface value added to the closed enum in capability-validator + runtime-config-adapter-registry. UPGRADE 2 (background dispatch): flip dispatch.backgroundDispatch true (Kimi's Agent tool takes run_in_background; root agent already gets the Agent tool), so negotiation no longer flattens dispatch. subagentToolkit stays 'undocumented' per AC (coder/explore/plan have distinct tool policies). MCP transport explicitly deferred (no installer-driven MCP for any runtime). Golden: only kimi.json changes (hooks/ scripts now installed); all 15 others + claude-local byte-identical (kilo/zcode keep their own exclusions). Tests: kimi-imperative-reference (adapter/axes/fail-closed/hostBehaviors + source-grep guard) + kimi-upgrades (config.toml [[hooks]] SessionStart + marker idempotency + backgroundDispatch negotiation). CONTEXT.md glossary + matrix + how-to updated; changeset (Added). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -369,6 +369,31 @@ export function resolveKimiGlobalDir(opts: ResolveKimiOpts = {}): string {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the directory holding Kimi CLI's OWN native config.toml (the file
|
||||
* Kimi itself reads for providers/models/hooks/etc — see
|
||||
* moonshotai.github.io/kimi-cli/en/configuration/data-locations.html and
|
||||
* .../reference/kimi-command.html). Default `~/.kimi`, overridden by
|
||||
* `KIMI_SHARE_DIR` per Kimi's own upstream env-var (NOT `KIMI_CONFIG_DIR`,
|
||||
* which is a GSD-installer write-location override for the unrelated generic
|
||||
* Agent-Skills root resolved by resolveKimiGlobalDir above).
|
||||
*
|
||||
* This is deliberately a SEPARATE directory from GSD's kimi configHome
|
||||
* (~/.config/agents): Kimi's own docs confirm the Agent-Skills search path is
|
||||
* independent of KIMI_SHARE_DIR ("This variable does not affect Agent Skills
|
||||
* search paths, which are handled separately"). #2095 Upgrade 1 writes GSD's
|
||||
* native [[hooks]] entries into `<this dir>/config.toml`, never into the
|
||||
* skills configDir.
|
||||
*/
|
||||
export function resolveKimiHooksTomlDir(opts: ResolveKimiOpts = {}): string {
|
||||
const env: Record<string, string | undefined> = opts.env ?? process.env;
|
||||
const home = opts.home ?? os.homedir();
|
||||
return resolveConfigHomeFromDescriptor(
|
||||
{ kind: 'dot-home', name: '.kimi', env: ['KIMI_SHARE_DIR'] },
|
||||
{ env, home },
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the global config base directory for the given runtime.
|
||||
* Respects the same env-var overrides as bin/install.js getGlobalDir().
|
||||
|
||||
Reference in New Issue
Block a user