* 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)
440 lines
19 KiB
JavaScript
440 lines
19 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* ADR-1239 Phase A: Descriptor tests — validate that all 16 role:runtime
|
|
* capability descriptors have correct hostIntegration axes, pass the validator,
|
|
* and negotiate correctly via the host-integration module.
|
|
*
|
|
* Expectations are derived from the generated capability registry and
|
|
* .host-cli-final.json (source of truth). Values are verbatim; 'undocumented'
|
|
* sentinels fail-closed in negotiation (safe documented default, never propagate).
|
|
*/
|
|
|
|
const { describe, test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const path = require('node:path');
|
|
|
|
const {
|
|
negotiateHostCapabilities,
|
|
profileOf,
|
|
shouldFlattenDispatch,
|
|
} = require(path.join(__dirname, '../gsd-core/bin/lib/host-integration.cjs'));
|
|
|
|
const registry = require(path.join(__dirname, '../gsd-core/bin/lib/capability-registry.cjs'));
|
|
|
|
const {
|
|
validateCapability,
|
|
} = require(path.join(__dirname, '../gsd-core/bin/lib/capability-validator.cjs'));
|
|
|
|
// All 8 scalar hostIntegration axis keys
|
|
const SCALAR_AXES = ['embeddingMode', 'commandSurface', 'modelMode', 'hookBus', 'stateIO', 'transport', 'runtime'];
|
|
// All 6 dispatch sub-keys (includes backgroundDispatch added in feat/1679-dispatch-flatten)
|
|
const DISPATCH_KEYS = ['namedDispatch', 'nested', 'maxDepth', 'background', 'subagentToolkit', 'backgroundDispatch'];
|
|
|
|
// Runtime ids are derived from the registry (the single source of truth) so the
|
|
// suite stays fluid when a runtime descriptor is added or removed. The profile
|
|
// and flatten maps below remain CURATED pins — they catch an accidental axis
|
|
// flip (e.g. a descriptor changing embeddingMode silently moves its profile).
|
|
const RUNTIME_IDS = Object.keys(registry.runtimes);
|
|
|
|
// Contract-pinned profile split (derived from .host-cli-final.json):
|
|
// programmatic-cli: claude, cline, cursor, hermes, kilo, kimi, kimi-code, opencode, pi, qwen, trae (11)
|
|
// declarative-cli: antigravity, augment, codebuddy, codex, copilot, windsurf, zcode (7)
|
|
// ide: vscode (1) — #2103, the first installed ide-profile host.
|
|
const EXPECTED_PROFILES = {
|
|
claude: 'programmatic-cli',
|
|
cline: 'programmatic-cli',
|
|
cursor: 'programmatic-cli',
|
|
hermes: 'programmatic-cli',
|
|
kilo: 'programmatic-cli',
|
|
kimi: 'programmatic-cli',
|
|
'kimi-code': 'programmatic-cli',
|
|
opencode: 'programmatic-cli',
|
|
pi: 'programmatic-cli',
|
|
qwen: 'programmatic-cli',
|
|
trae: 'programmatic-cli',
|
|
antigravity: 'declarative-cli',
|
|
augment: 'declarative-cli',
|
|
codebuddy: 'declarative-cli',
|
|
codex: 'declarative-cli',
|
|
copilot: 'declarative-cli',
|
|
windsurf: 'declarative-cli',
|
|
zcode: 'declarative-cli',
|
|
vscode: 'ide',
|
|
};
|
|
|
|
describe('ADR-1239 Phase A: hostIntegration descriptors', () => {
|
|
// ─── Registry shape ──────────────────────────────────────────────────────────
|
|
|
|
test('registry.runtimes exactly equals the curated RUNTIME_IDS set (count-agnostic)', () => {
|
|
// RUNTIME_IDS is derived from the registry above, so this asserts internal
|
|
// consistency: the curated profile/flatten maps cover every registry runtime
|
|
// exactly once, no matter how many exist.
|
|
for (const id of RUNTIME_IDS) {
|
|
assert.ok(
|
|
Object.prototype.hasOwnProperty.call(registry.runtimes, id),
|
|
'registry.runtimes must contain "' + id + '"',
|
|
);
|
|
}
|
|
assert.deepStrictEqual(
|
|
Object.keys(registry.runtimes).sort(),
|
|
[...RUNTIME_IDS].sort(),
|
|
'registry.runtimes key set must match RUNTIME_IDS',
|
|
);
|
|
});
|
|
|
|
// ─── Per-runtime assertions ───────────────────────────────────────────────────
|
|
|
|
for (const id of RUNTIME_IDS) {
|
|
describe('runtime: ' + id, () => {
|
|
const cap = registry.runtimes[id];
|
|
const hi = cap && cap.runtime && cap.runtime.hostIntegration;
|
|
|
|
// (i) Validator passes with zero errors
|
|
test('(i) validateCapability returns zero errors', () => {
|
|
const errors = validateCapability(cap, id);
|
|
assert.deepEqual(
|
|
errors,
|
|
[],
|
|
id + ': validateCapability must return no errors, got: ' + JSON.stringify(errors),
|
|
);
|
|
});
|
|
|
|
// (ii) hostIntegration object is present with all required keys
|
|
test('(ii) cap.runtime.hostIntegration is present with all 8 axis keys and 6 dispatch sub-keys', () => {
|
|
assert.ok(
|
|
hi !== undefined && hi !== null && typeof hi === 'object',
|
|
id + ': cap.runtime.hostIntegration must be a non-null object',
|
|
);
|
|
// All 8 scalar axes present
|
|
for (const axis of SCALAR_AXES) {
|
|
assert.ok(
|
|
Object.prototype.hasOwnProperty.call(hi, axis),
|
|
id + ': hostIntegration must have axis "' + axis + '"',
|
|
);
|
|
}
|
|
// dispatch is an object
|
|
assert.ok(
|
|
hi.dispatch !== null && typeof hi.dispatch === 'object',
|
|
id + ': hostIntegration.dispatch must be a non-null object',
|
|
);
|
|
// All 5 dispatch sub-keys present
|
|
for (const key of DISPATCH_KEYS) {
|
|
assert.ok(
|
|
Object.prototype.hasOwnProperty.call(hi.dispatch, key),
|
|
id + ': hostIntegration.dispatch must have key "' + key + '"',
|
|
);
|
|
}
|
|
});
|
|
|
|
// (iii) negotiateHostCapabilities does not throw and behaves correctly
|
|
test('(iii) negotiateHostCapabilities: documented scalars pass through; undocumented scalars degrade with warning', () => {
|
|
assert.ok(hi, id + ': hostIntegration must exist to negotiate');
|
|
let result;
|
|
assert.doesNotThrow(() => {
|
|
result = negotiateHostCapabilities(hi);
|
|
}, id + ': negotiateHostCapabilities must not throw');
|
|
|
|
const eff = result.effective;
|
|
|
|
// For each scalar axis: if declared !== 'undocumented', effective === declared
|
|
// If declared === 'undocumented', effective !== 'undocumented' (safe default) and
|
|
// warnings must mention that axis.
|
|
for (const axis of SCALAR_AXES) {
|
|
const declared = hi[axis];
|
|
if (declared !== 'undocumented') {
|
|
assert.strictEqual(
|
|
eff[axis],
|
|
declared,
|
|
id + ': effective.' + axis + ' must equal declared (' + JSON.stringify(declared) + '), got: ' + JSON.stringify(eff[axis]),
|
|
);
|
|
} else {
|
|
// fail-closed: effective must be a documented safe default, not 'undocumented'
|
|
assert.notStrictEqual(
|
|
eff[axis],
|
|
'undocumented',
|
|
id + ': effective.' + axis + ' must NOT be "undocumented" (fail-closed)',
|
|
);
|
|
// warnings must mention this axis
|
|
const mentionsAxis = result.warnings.some((w) => w.includes(axis));
|
|
assert.ok(
|
|
mentionsAxis,
|
|
id + ': result.warnings must mention axis "' + axis + '" when declared is undocumented, got: ' + JSON.stringify(result.warnings),
|
|
);
|
|
}
|
|
}
|
|
});
|
|
|
|
// (iii-b) dispatch negotiation for namedDispatch
|
|
test('(iii-b) dispatch.namedDispatch negotiation', () => {
|
|
assert.ok(hi, id + ': hostIntegration must exist to negotiate');
|
|
const result = negotiateHostCapabilities(hi);
|
|
|
|
const declaredND = hi.dispatch && hi.dispatch.namedDispatch;
|
|
|
|
if (declaredND === true) {
|
|
// documented as true → effective must be true
|
|
assert.strictEqual(
|
|
result.effective.dispatch.namedDispatch,
|
|
true,
|
|
id + ': effective.dispatch.namedDispatch must be true when declared is true',
|
|
);
|
|
} else if (declaredND === 'undocumented') {
|
|
// undocumented → fail-closed: effective namedDispatch must be false
|
|
assert.strictEqual(
|
|
result.effective.dispatch.namedDispatch,
|
|
false,
|
|
id + ': effective.dispatch.namedDispatch must be false when declared is "undocumented" (fail-closed)',
|
|
);
|
|
// dispatch.effectiveLevel must be 'absent' (no named dispatch)
|
|
assert.strictEqual(
|
|
result.points.dispatch.effectiveLevel,
|
|
'absent',
|
|
id + ': points.dispatch.effectiveLevel must be "absent" when namedDispatch is undocumented',
|
|
);
|
|
}
|
|
});
|
|
|
|
// (iv) profileOf returns expected profile
|
|
test('(iv) profileOf returns expected profile', () => {
|
|
assert.ok(hi, id + ': hostIntegration must exist to profile');
|
|
const profile = profileOf(hi);
|
|
assert.ok(
|
|
profile !== null,
|
|
id + ': profileOf must return a non-null profile',
|
|
);
|
|
assert.strictEqual(
|
|
profile,
|
|
EXPECTED_PROFILES[id],
|
|
id + ': profileOf must return "' + EXPECTED_PROFILES[id] + '" (got: "' + profile + '")',
|
|
);
|
|
});
|
|
});
|
|
}
|
|
|
|
// ─── Contract-pin profile split ───────────────────────────────────────────────
|
|
|
|
test('contract-pin: profile split is internally consistent with EXPECTED_PROFILES (count-agnostic)', () => {
|
|
// The counts are DERIVED from the curated EXPECTED_PROFILES map rather than
|
|
// hand-pinned, so adding a runtime + its profile entry updates the counts
|
|
// automatically. #2103: vscode is now the first installed ide-profile host,
|
|
// so 'ide' is no longer pinned at a hardcoded 0 — it is derived below like
|
|
// the other two profiles.
|
|
const counts = { 'programmatic-cli': 0, 'declarative-cli': 0, 'ide': 0 };
|
|
for (const id of RUNTIME_IDS) {
|
|
const cap = registry.runtimes[id];
|
|
const hi = cap && cap.runtime && cap.runtime.hostIntegration;
|
|
assert.ok(hi, id + ': hostIntegration must exist for profile count');
|
|
const profile = profileOf(hi);
|
|
assert.ok(profile !== null, id + ': profileOf must be non-null');
|
|
assert.strictEqual(profile, EXPECTED_PROFILES[id],
|
|
id + ': profileOf must match EXPECTED_PROFILES (an axis may have flipped)');
|
|
if (counts[profile] !== undefined) {
|
|
counts[profile]++;
|
|
}
|
|
}
|
|
// Derived expected counts from the curated map itself.
|
|
const expectedCounts = { 'programmatic-cli': 0, 'declarative-cli': 0, 'ide': 0 };
|
|
for (const p of Object.values(EXPECTED_PROFILES)) {
|
|
if (expectedCounts[p] !== undefined) expectedCounts[p]++;
|
|
}
|
|
assert.strictEqual(counts['programmatic-cli'], expectedCounts['programmatic-cli']);
|
|
assert.strictEqual(counts['declarative-cli'], expectedCounts['declarative-cli']);
|
|
assert.strictEqual(counts['ide'], expectedCounts['ide'],
|
|
'ide-profile count must match EXPECTED_PROFILES (#2103: vscode is the first ide-profile host)');
|
|
});
|
|
|
|
// ─── backgroundDispatch presence ─────────────────────────────────────────────
|
|
|
|
test('every runtime descriptor has dispatch.backgroundDispatch (boolean or "undocumented")', () => {
|
|
for (const id of RUNTIME_IDS) {
|
|
const cap = registry.runtimes[id];
|
|
const dispatch = cap && cap.runtime && cap.runtime.hostIntegration && cap.runtime.hostIntegration.dispatch;
|
|
assert.ok(
|
|
dispatch !== null && typeof dispatch === 'object',
|
|
id + ': hostIntegration.dispatch must be an object',
|
|
);
|
|
assert.ok(
|
|
Object.prototype.hasOwnProperty.call(dispatch, 'backgroundDispatch'),
|
|
id + ': dispatch must have a backgroundDispatch key',
|
|
);
|
|
const v = dispatch.backgroundDispatch;
|
|
assert.ok(
|
|
v === true || v === false || v === 'undocumented',
|
|
id + ': dispatch.backgroundDispatch must be true, false, or "undocumented", got: ' + JSON.stringify(v),
|
|
);
|
|
}
|
|
});
|
|
|
|
// ─── shouldFlattenDispatch per-host (#853 discriminator) ─────────────────────
|
|
|
|
// Expected: false (may background) for codex, cursor, kimi, and opencode;
|
|
// true (must inline) for the other 13.
|
|
const EXPECTED_FLATTEN = {
|
|
antigravity: true,
|
|
augment: true,
|
|
claude: true,
|
|
cline: true,
|
|
codebuddy: true,
|
|
codex: false,
|
|
copilot: true,
|
|
cursor: false,
|
|
hermes: true,
|
|
kilo: true,
|
|
// #2095: Kimi Upgrade 2 — Kimi's Agent tool takes a run_in_background
|
|
// call-time param (Context7 agents.html) → backgroundDispatch flipped to
|
|
// true → dispatch.background/backgroundDispatch both true → NOT
|
|
// force-flattened (mirrors the #2087 OpenCode precedent below).
|
|
kimi: false,
|
|
// #2454: Kimi Code (Node CLI) — same background-dispatch model as Python
|
|
// kimi-cli per Kimi Code docs (dispatch.background/backgroundDispatch both
|
|
// true) → NOT force-flattened.
|
|
'kimi-code': false,
|
|
// #2087: OpenCode background subagents (v1.15 param, v1.17 default-on) →
|
|
// dispatch.background/backgroundDispatch true → NOT force-flattened.
|
|
opencode: false,
|
|
// #2102: pi's dispatch.background/backgroundDispatch are both false
|
|
// (undocumented background-subagent primitive) → force-flattened.
|
|
pi: true,
|
|
qwen: true,
|
|
trae: true,
|
|
windsurf: true,
|
|
zcode: true,
|
|
// #2103: vscode's dispatch.backgroundDispatch is 'undocumented' (no
|
|
// documented background-subagent primitive) → fails closed to false →
|
|
// force-flattened, mirroring the pi (#2102) precedent above.
|
|
vscode: true,
|
|
};
|
|
|
|
for (const id of RUNTIME_IDS) {
|
|
test('shouldFlattenDispatch(' + id + ') === ' + EXPECTED_FLATTEN[id], () => {
|
|
const cap = registry.runtimes[id];
|
|
const dispatch = cap && cap.runtime && cap.runtime.hostIntegration && cap.runtime.hostIntegration.dispatch;
|
|
assert.ok(dispatch, id + ': dispatch must exist');
|
|
const result = shouldFlattenDispatch(dispatch);
|
|
assert.strictEqual(
|
|
result,
|
|
EXPECTED_FLATTEN[id],
|
|
id + ': shouldFlattenDispatch must return ' + EXPECTED_FLATTEN[id] + ' (got: ' + result + ')',
|
|
);
|
|
});
|
|
}
|
|
|
|
test('contract-pin: background-eligible set matches EXPECTED_FLATTEN (count-agnostic)', () => {
|
|
// The eligible set is DERIVED from the curated EXPECTED_FLATTEN map rather
|
|
// than hand-pinned to a fixed pair, so a runtime whose dispatch axes change
|
|
// updates the expectation automatically.
|
|
const expectedEligible = RUNTIME_IDS
|
|
.filter((id) => EXPECTED_FLATTEN[id] === false)
|
|
.sort();
|
|
const eligible = RUNTIME_IDS.filter((id) => {
|
|
const cap = registry.runtimes[id];
|
|
const dispatch = cap && cap.runtime && cap.runtime.hostIntegration && cap.runtime.hostIntegration.dispatch;
|
|
return dispatch && shouldFlattenDispatch(dispatch) === false;
|
|
}).sort();
|
|
assert.deepEqual(eligible, expectedEligible,
|
|
'background-eligible set must match EXPECTED_FLATTEN (a dispatch axis may have flipped)');
|
|
});
|
|
|
|
test('contract-pin: spot-check claude→programmatic-cli, codex→declarative-cli, opencode→programmatic-cli, windsurf→declarative-cli', () => {
|
|
const checks = [
|
|
['claude', 'programmatic-cli'],
|
|
['codex', 'declarative-cli'],
|
|
['opencode', 'programmatic-cli'],
|
|
['windsurf', 'declarative-cli'],
|
|
];
|
|
for (const [id, expectedProfile] of checks) {
|
|
const cap = registry.runtimes[id];
|
|
const hi = cap && cap.runtime && cap.runtime.hostIntegration;
|
|
assert.ok(hi, id + ': hostIntegration must exist');
|
|
const profile = profileOf(hi);
|
|
assert.strictEqual(
|
|
profile,
|
|
expectedProfile,
|
|
id + ': profileOf must return "' + expectedProfile + '" (got: "' + profile + '")',
|
|
);
|
|
}
|
|
});
|
|
|
|
// ─── NEGATIVE cases ───────────────────────────────────────────────────────────
|
|
|
|
describe('NEGATIVE: invalid hostIntegration.embeddingMode triggers validator error', () => {
|
|
test('embeddingMode "bogus" produces a validator error naming embeddingMode', () => {
|
|
const cap = {
|
|
id: 'test-neg',
|
|
role: 'runtime',
|
|
version: '1.0.0',
|
|
title: 'Test Negative',
|
|
description: 'Negative case for hostIntegration validation.',
|
|
tier: 'core',
|
|
requires: [],
|
|
runtime: {
|
|
configHome: { kind: 'dot-home', name: '.test-neg', env: [] },
|
|
configFormat: 'settings-json',
|
|
artifactLayout: { global: [], local: [] },
|
|
commandStyle: 'slash-hyphen',
|
|
hooksSurface: 'settings-json',
|
|
hookEvents: 'claude',
|
|
sandboxTier: 'none',
|
|
supportTier: 1,
|
|
installSurface: 'settings-json',
|
|
writesSharedSettings: true,
|
|
permissionWriter: null,
|
|
extendedHookEvents: [],
|
|
hostIntegration: {
|
|
embeddingMode: 'bogus',
|
|
commandSurface: 'slash-file',
|
|
dispatch: { namedDispatch: true, nested: false, maxDepth: 1, background: false, subagentToolkit: 'full', backgroundDispatch: false },
|
|
modelMode: 'passive',
|
|
hookBus: 'host',
|
|
stateIO: 'filesystem',
|
|
transport: 'mcp',
|
|
runtime: 'node',
|
|
},
|
|
},
|
|
};
|
|
const errors = validateCapability(cap, 'test-neg');
|
|
assert.ok(errors.length > 0, 'Expected validation errors for bogus embeddingMode');
|
|
assert.ok(
|
|
errors.some((e) => e.includes('embeddingMode')),
|
|
'At least one error must mention embeddingMode, got: ' + JSON.stringify(errors),
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('NEGATIVE: missing hostIntegration produces required-object error', () => {
|
|
test('runtime body without hostIntegration produces the required-object error', () => {
|
|
const cap = {
|
|
id: 'test-missing-hi',
|
|
role: 'runtime',
|
|
version: '1.0.0',
|
|
title: 'Test Missing HI',
|
|
description: 'Negative case for missing hostIntegration.',
|
|
tier: 'core',
|
|
requires: [],
|
|
runtime: {
|
|
configHome: { kind: 'dot-home', name: '.test-missing-hi', env: [] },
|
|
configFormat: 'settings-json',
|
|
artifactLayout: { global: [], local: [] },
|
|
commandStyle: 'slash-hyphen',
|
|
hooksSurface: 'settings-json',
|
|
hookEvents: 'claude',
|
|
sandboxTier: 'none',
|
|
supportTier: 1,
|
|
installSurface: 'settings-json',
|
|
writesSharedSettings: true,
|
|
permissionWriter: null,
|
|
extendedHookEvents: [],
|
|
// hostIntegration intentionally absent
|
|
},
|
|
};
|
|
const errors = validateCapability(cap, 'test-missing-hi');
|
|
assert.ok(errors.length > 0, 'Expected validation errors for missing hostIntegration');
|
|
assert.ok(
|
|
errors.some((e) => e.includes('hostIntegration') && e.includes('required')),
|
|
'At least one error must mention hostIntegration and required, got: ' + JSON.stringify(errors),
|
|
);
|
|
});
|
|
});
|
|
});
|