Net-new EoS/pi installable runtime — purely additive (no prior runtime==='pi'
branches). pi is a bun-runtime programmatic-CLI whose /gsd command is registered
by a native ExtensionAPI extension and dispatches through the embedded engine.
Stage 1 (install plumbing):
- capabilities/pi/capability.json: full hostIntegration descriptor (imperative /
slash-programmatic / active-model / native-extension / bun) + hostBehaviors
{nativePlugin, pluginOnlyInstall}.
- --pi flag + interactive-menu renumber (All 17->18); pi added to RUNTIME_FLAG_IDS,
RUNTIME_LABELS, RUNTIME_META, allRuntimes/runtimeMap, model-catalog defaults.
- Install mirrors OpenCode: pi installs the gsd.cjs extension + the shared engine
payload (gsd-core + scripts + config markers) + the shared hooks bundle (spawned
by the extension at lifecycle events, like OpenCode's plugin). pluginOnlyInstall
EXCLUDES declarative command/agent/skill markdown, which pi has no host-read
surface for (its /gsd is programmatic). _installNativePluginIfDeclared (extracted
from the opencode-family path) copies pi/gsd.cjs -> ~/.pi/agent/extensions/gsd.cjs
(global) / .pi/extensions/ (local). pi added to package.json files.
- Golden: new pi.json (320 files: extension + engine + 27-file hooks bundle, no
markdown); the 16 other fixtures + claude-local change only by the shared
model-catalog hash line.
Stage 2 (real dispatch + upgrades):
- Shared dispatchGsdCommand() (shell-command-projection): bounded, no-throw
subprocess-shim to gsd-tools.cjs (the only full-surface dispatch path; no
in-process full-hub factory exists). Fixes pi/gsd.cjs's createHub()-no-args bug
(every dispatch was UnknownCommand) AND the identical bug in mcp-server.cts's
gsd_invoke_command, which a vacuous unknown-family-only test had masked (now has
a real dispatch regression test).
- pi/gsd.cjs: /gsd handler now (args, ctx) - tokenizes (quote-aware, via the
shipped hooks/lib/git-cmd.js) + dispatches real family/subcommand (not hardcoded
query/help); gsd_invoke gets a TypeBox (JSON-schema-fallback) parameters schema +
consumes params; getArgumentCompletions; before_provider_request active-model
steering (fail-open on null resolution); functional session_start /
before_agent_start / session_before_compact hook bridges (spawn the shipped GSD
hook scripts).
- EXTENSION_EVENT_SURFACES.pi expanded from ['tool_call'] to the full 30-event
vocabulary.
Docs (host-integration matrix + how-to) + changeset (Added).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
97 lines
4.4 KiB
JavaScript
97 lines
4.4 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'",
|
|
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).
|
|
const SPECIAL_CASED = new Set(['claude', 'antigravity']);
|
|
|
|
test('getGlobalConfigHomeFragment: golden map matches for all 13 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(', ')}`);
|
|
});
|