* feat(#2454): add kimi-code as an EoS capability (Node Kimi Code CLI) PR 1 of N for #2454. Establishes the EoS descriptor foundation for splitting GSD's kimi support into two distinct products per the user's directive: - kimi (existing): Moonshot's Python kimi-cli (~/.kimi, runtime: python) - kimi-code (new): Moonshot's Node Kimi Code CLI (~/.kimi-code, runtime: node, KIMI_CODE_HOME env) Per ADR-1239 EoS, runtime behavior is driven by capabilities/<id>/capability.json descriptors, not hardcoded branches in install.js. The new descriptor uses the existing primitives (dot-home configHome, skills artifactLayout, kimi-hooks-toml hooksSurface — same TOML [[hooks]] format Kimi Code reads per its docs). Critical Kimi Code constraint reflected in the descriptor: hostIntegration.dispatch.namedDispatch: false hostIntegration.dispatch.builtInSubagents: ['coder', 'explore', 'plan'] hostBehaviors.namedSubagentsSupported: false Kimi Code's official docs confirm only 3 built-in subagents with NO custom- subagent registration (the [subagent] table only has timeout_ms). The kimi-agents YAML layout (used by Python kimi-cli) is therefore NOT in kimi-code's artifactLayout. Schema adjustments: - subagentToolkit set to 'undocumented' (the existing escape hatch); the schema enum (full/read-only) lacks a 'limited'/'built-in-only' value. A follow-up PR can extend the schema enum to add 'built-in-only' as a first-class axis value reflecting Kimi Code's documented model. Registration: - capabilities/kimi-code/capability.json (new descriptor, modeled on codex) - bin/install.js: allRuntimes array + --all list + --kimi-code flag - gsd-core/bin/shared/runtime-aliases.manifest.json: kimi-code aliases (kimi-code, kimicode, kimi_code) - src/runtime-name-policy.cts: FALLBACK_ALIASES map - gsd-core/bin/lib/capability-registry.cjs: regenerated via scripts/gen-capability-registry.cjs --write Tests: - tests/multi-runtime-select.test.cjs updated for the new runtime count (18) + new --kimi-code flag test + 'All' shortcut renumbered 18 → 19. Out of scope for PR 1 (follow-up PRs in the sequence): - Install-time decision logic (kimi vs kimi-code detection / prompt) - agent-install-check semantics for kimi-code (verify Agent Skills presence) - cmdAgentSkills fallback returning subagent prompt content - Workflow template mapping (named agents → built-in coder/explore/plan) - Migration guidance for users currently on 'kimi' who are actually on Kimi Code - Schema enum extension for subagentToolkit: 'built-in-only' Refs #2454, #2095 (EoS/kimi migration epic), ADR-1239 (EoS). * fix(#2454): complete drift-guard registrations for kimi-code runtime The drift guards caught every surface that pins runtime enumeration. Each update is mechanical, driven by the guard's named failure mode: - src/runtime-name-policy.cts RUNTIME_LABELS: 'Kimi Code' label for kimi-code - src/runtime-name-policy.cts RUNTIME_FLAG_IDS: add kimi-code to the isKimiCode predicate generator - bin/install.js runtimeMap: option '11' → 'kimi-code', renumber downstream entries (11..17 → 12..18), ALL_RUNTIMES_OPTION 18 → 19 - gsd-core/bin/shared/model-catalog.json runtimeTierDefaults: kimi-code entry (null/null/null — same as kimi, no model tier defaults until configured) - docs/reference/capability-matrix.md: regenerated via scripts/gen-capability-matrix.cjs --write (kimi-code row added) - tests/global-config-home-fragment.test.cjs GOLDEN_FRAGMENT_MAP: kimi-code → '.kimi-code' - tests/fixtures/golden-install-parity/*.json: regenerated via npm run gen:golden (the runtime-aliases.manifest.json hash changed; all 17 runtime fixtures updated) The capability-registry is already regenerated from the prior commit. * test(#2454): update drift-guard tests for kimi-code runtime registration Multiple drift guards pin runtime enumeration counts and option numbering. Each update is mechanical, driven by the guard's named failure mode: - tests/runtime-flags.test.cjs: EXPECTED_FLAGS gains isKimiCode (16 → 17); 'all 16 flags' → 'all 17 flags' in test names + messages. - tests/multi-runtime-select.test.cjs: parseRuntimeInput option renumbering cascade — kilo moves 11→12, opencode 12→13, pi 13→14, qwen 14→15, trae 15→16, windsurf 16→17, zcode 17→18, All 18→19. New single-choice test for kimi-code (option 11). Prompt test updated for new numbering. - tests/host-integration-descriptors.test.cjs: EXPECTED_PROFILES gains kimi-code → 'programmatic-cli' (terminal CLI per Kimi Code docs); EXPECTED_FLATTEN gains kimi-code → false (backgroundDispatch:true per docs, same as Python kimi/opencode). - tests/global-config-home-fragment.test.cjs: table-count test renamed 13 → 14 table runtimes (kimi-code added to GOLDEN_FRAGMENT_MAP earlier). * fix(#2454): empty artifactLayout for kimi-code (PR 1 scope) The skills kind requires a converter (existing converters are per-runtime like convertClaudeCommandToKimiSkill). PR 1 of this multi-PR sequence only registers the descriptor; the actual Agent Skills converter (and a new 'convertClaudeCommandToKimiCodeSkill' function) lands in PR 2 alongside the install-time decision logic. Empty artifactLayout.global is valid and means 'nothing to install yet via the layout seam'. Also: added kimi-code to RUNTIME_META in tests/helpers/install-shared.cjs (localDir .kimi-code, globalSuffix .kimi-code), and added Kimi Code as option 11 in install.js's buildRuntimePromptText (renumbered downstream options 11..17 → 12..18, All 18 → 19). * fix(#2454): camelCase runtimeFlags for hyphenated ids (kimi-code → isKimiCode) The runtimeFlags generator previously produced 'isKimi-code' (hyphen preserved) for the new kimi-code runtime id. Property names with hyphens are awkward for consumers (flags['isKimi-code'] instead of flags.isKimiCode). The new runtimeIdToFlagName helper folds -[a-z] boundaries to uppercase, producing the conventional PascalCase flag name. The 16 prior single-word runtime ids are unaffected (the regex finds no hyphens). * fix(#2454): update remaining drift-guard tests + gen kimi-code fixtures - tests/runtime-flags.test.cjs drift guard: use proper kebab-case conversion (isKimiCode → kimi-code, not 'kimicode') so the registry comparison doesn't false-positive on hyphenated runtime ids. - tests/multi-runtime-select.test.cjs: fix kilo/opencode/pi/qwen/trae single-choice tests for the renumbered options (kilo 11→12, opencode 12→13, pi 13→14, qwen 14→15, trae 15→16). - tests/install.test.cjs: Kilo integration option 11→12, prompt test regex updated. - tests/fixtures/golden-install-parity/kimi-code.json + install-tree/ kimi-code.json: generated via UPDATE_GOLDEN=1 + UPDATE_INSTALL_TREE=1. The kimi-code install produces the standard GSD install layout (skills, contexts, references, etc.) — 436 paths, same shape as other runtimes that have no custom converter yet. * fix(#2454): add kimi-code install contract + global config home fragment - src/runtime-name-policy.cts GLOBAL_CONFIG_HOME_FRAGMENTS: add kimi-code → '.kimi-code' so getGlobalConfigHomeFragment returns the correct path instead of falling through to the default '.claude'. - tests/installer-migration-install.integration.test.cjs RUNTIME_INSTALL_CONTRACTS: kimi-code entry (same surface as kimi for PR 1; PR 2 will specialize once the Agent Skills converter lands). - tests/multi-runtime-select.test.cjs: fix space-separated-choices test for the renumbered kilo option (11 → 12). - tests/fixtures/golden-install-parity/kimi-code.json + install-tree/ kimi-code.json: regenerated after rebasing onto current next (new planner-reversibility.md from #2471 etc. now included). * test(#2454): skip kimi-code install contract until PR 2 ships install layout The end-to-end install test (tests/installer-migration-install.integration .test.cjs) asserts every allRuntimes entry installs a runtime-specific artifact surface. PR 1 of #2454 registers kimi-code in allRuntimes + the capability descriptor + flags + labels, but the install LAYOUT (Agent Skills converter + global AGENTS.md at $KIMI_CODE_HOME/AGENTS.md) lands in PR 2. The SKIP_INSTALL_CONTRACT set marks this exclusion explicit and self-removing — PR 2 removes the entry alongside adding the install surface, restoring the contract loop to full coverage. * fix(#2454): restore compact model-catalog.json format (M1 review) Per code-review M1: my prior 'fix(#2454): complete drift-guard registrations' commit used python json.dump(indent=2) which inflated the file from 165→607 lines (every nested entry got expanded) and lost the trailing newline. The semantic change was just a 3-line kimi-code entry. Restored the original hybrid format (top-level indent=2 + inner entries' one-line style) and added kimi-code in matching form. Regenerated golden install parity + install tree fixtures since the model-catalog.json hash changed. * fix(#2454): update CONTEXT.md allRuntimes glossary (17 → 18, add kimi-code) CI lint-tests job failed on the glossary drift guard (scripts/check-glossary-refs.cjs --check): ✗ CONTEXT.md's allRuntimes enum-count sentence claims 17 values but bin/install.js's allRuntimes array has 18. ✗ CONTEXT.md's allRuntimes member list has drifted from bin/install.js (missing from CONTEXT.md's list: kimi-code). Missed in the prior commits because gsd-test does not run the glossary check (it's a CI lint-tests-only check). Updating CONTEXT.md's two claims to 18 values + kimi-code in the member list. * chore(#2505): regen capability-registry + stamp kimi-code version 1.8.0 (#2511) * docs(changeset): Phase 1 kimi-code runtime Added (#2511) * test(#2511): regen kimi-code golden parity fixture after Phase 0 guard normalization lands * docs(changeset): backfill PR #2519 for Phase 1 (#2511)
100 lines
4.6 KiB
JavaScript
100 lines
4.6 KiB
JavaScript
'use strict';
|
|
/**
|
|
* Drift-guard + collapse: getGlobalConfigHomeFragment must be the SINGLE source
|
|
* of truth for the runtime → global config-home path-fragment mapping used by
|
|
* `getConfigDirFromHome` in bin/install.js for hook path.join() codegen.
|
|
*
|
|
* Collapses the prior branch `if (runtime === 'x') return "'...'"` chain
|
|
* (install.js ~514-543) into one table — ADR-1239 Phase B / #1679, AC2 slice 2.
|
|
*
|
|
* Invariants pinned here:
|
|
* 1. Each of the 13 table runtimes returns its exact verbatim source fragment
|
|
* (byte-identical to the prior chain — golden install parity asserts the
|
|
* generated hook output is unchanged).
|
|
* 2. claude + unknown + empty fall back to the default "'.claude'" fragment.
|
|
* 3. antigravity is intentionally NOT in the table (handled dynamically by the
|
|
* caller via resolveAntigravityGlobalDir).
|
|
* 4. Drift guard: every registry runtime EXCEPT {claude, antigravity} has a
|
|
* table entry — so adding a runtime forces a deliberate fragment decision
|
|
* here (the add-a-host tax this collapse removes).
|
|
*
|
|
* ADR-1239 Phase B (#1679). Behavioral tests only.
|
|
*/
|
|
|
|
const { test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const runtimeNamePolicy = require('../gsd-core/bin/lib/runtime-name-policy.cjs');
|
|
const registry = require('../gsd-core/bin/lib/capability-registry.cjs');
|
|
|
|
const { getGlobalConfigHomeFragment } = runtimeNamePolicy;
|
|
|
|
// Golden oracle: the exact source-string fragments the prior install.js chain
|
|
// emitted, preserved verbatim. These are path.join() arg-source snippets (the
|
|
// embedded quotes/commas are intentional — they get spliced into generated hook
|
|
// scripts). Pinned here as the test oracle.
|
|
const GOLDEN_FRAGMENT_MAP = {
|
|
copilot: "'.copilot'",
|
|
opencode: "'.config', 'opencode'",
|
|
kilo: "'.config', 'kilo'",
|
|
codex: "'.codex'",
|
|
cursor: "'.cursor'",
|
|
windsurf: "'.windsurf'",
|
|
augment: "'.augment'",
|
|
trae: "'.trae'",
|
|
qwen: "'.qwen'",
|
|
hermes: "'.hermes'",
|
|
codebuddy: "'.codebuddy'",
|
|
cline: "'.cline'",
|
|
kimi: "'.config', 'agents'",
|
|
'kimi-code': "'.kimi-code'",
|
|
zcode: "'.zcode'",
|
|
pi: "'.pi', 'agent'",
|
|
};
|
|
|
|
// Runtimes intentionally NOT in the table: claude is the default; antigravity is
|
|
// resolved dynamically by the caller (resolveAntigravityGlobalDir + path.relative);
|
|
// vscode (#2103) is extension-distributed with no file-projected config home at
|
|
// all — getGlobalConfigHomeFragment is never invoked for it (no install surface).
|
|
const SPECIAL_CASED = new Set(['claude', 'antigravity', 'vscode']);
|
|
|
|
test('getGlobalConfigHomeFragment: golden map matches for all 14 table runtimes', () => {
|
|
for (const [id, expected] of Object.entries(GOLDEN_FRAGMENT_MAP)) {
|
|
const actual = getGlobalConfigHomeFragment(id);
|
|
assert.strictEqual(
|
|
actual,
|
|
expected,
|
|
`getGlobalConfigHomeFragment('${id}') diverged from golden.\n` +
|
|
` actual: ${JSON.stringify(actual)}\n` +
|
|
` expected: ${JSON.stringify(expected)}`,
|
|
);
|
|
}
|
|
});
|
|
|
|
test('getGlobalConfigHomeFragment fallback: claude/unknown/empty return the default fragment', () => {
|
|
assert.strictEqual(getGlobalConfigHomeFragment('claude'), "'.claude'",
|
|
'claude must return the default fragment (it is special-cased as the default)');
|
|
assert.strictEqual(getGlobalConfigHomeFragment('unknown'), "'.claude'",
|
|
'unknown runtime must return the default fragment');
|
|
assert.strictEqual(getGlobalConfigHomeFragment(''), "'.claude'",
|
|
'empty input must return the default fragment');
|
|
});
|
|
|
|
test('drift guard: every registry runtime except {claude, antigravity} has a table entry (add-a-host tax removed)', () => {
|
|
// A newly-added registry runtime that is NOT claude/antigravity MUST get a
|
|
// deliberate fragment entry here — otherwise it silently falls through to the
|
|
// '.claude' default. claude (default) and antigravity (caller-dynamic) are the
|
|
// only legitimate absences.
|
|
const tableIds = new Set(Object.keys(GOLDEN_FRAGMENT_MAP));
|
|
const missing = Object.keys(registry.runtimes)
|
|
.filter((id) => !SPECIAL_CASED.has(id) && !tableIds.has(id));
|
|
assert.deepEqual(missing, [],
|
|
`registry runtimes missing a fragment table entry (add one to GOLDEN_FRAGMENT_MAP + the module table, or add to SPECIAL_CASED if caller-dynamic): ${missing.join(', ')}`);
|
|
});
|
|
|
|
test('drift guard: table keys are a subset of the registry (no stale entries)', () => {
|
|
const registryIds = new Set(Object.keys(registry.runtimes));
|
|
const stale = Object.keys(GOLDEN_FRAGMENT_MAP).filter((id) => !registryIds.has(id));
|
|
assert.deepEqual(stale, [],
|
|
`fragment table references runtimes not in the registry (stale entries): ${stale.join(', ')}`);
|
|
});
|