feat(#2099): drive GitHub Copilot through the EoS descriptor + multi-event hook bus (ADR-1239)
Fold Copilot's residual runtime-literal branches onto descriptor-driven hostBehaviors. Several issue premises were inaccurate (verified via research) and deliberately NOT followed: writesSharedSettings/"legacy exclusion list" (per-runtime descriptor data, copilot's false is correct); RUNTIME_CONTENT_DISPATCH.copilot + installSurface==='copilot-instructions' (already descriptor-driven); extendedHookEvents (closed Claude/Gemini enum — hooks extended in code instead); reapply ternary (already folded, kimi #2095). Real folds (all byte-parity — golden byte-identical for every runtime): - src/install-engine.cts + src/surface.cts: the two `.agent.md` filename cutovers (_copyStaged + _syncGsdDir) unified onto hostBehaviors.agentFileExtension via a new exported agentFileExtensionFor() accessor (kills the two-mechanism divergence). - src/runtime-artifact-conversion.cts: applyAgentPathRewrites' copilot skip → hostBehaviors.noPathRewrite:true (antigravity #2096 precedent). - bin/install.js uninstall: the two isCopilot cleanup branches → installSurface=== 'copilot-instructions' gate (symmetric with install-time). - bin/install.js: `!isCopilot` in the two skipSharedHooksInstall checks → hostBehaviors.skipSharedHooksInstall:true (copilot has no shared gsd-*.js hooks). - bin/install.js: three dead legacy inline-agent-loop isCopilot refs removed (copilot ∈ _DESCRIPTOR_AGENTS_RUNTIMES → unreachable; byte-parity proven by clean golden + real reachable-runtime install diffs). isCopilot dropped from 4 destructures. Zero live `runtime==='copilot'`/`isCopilot` branches remain in bin/install.js, install-engine.cts, surface.cts, or runtime-artifact-conversion.cts (AC2 guard scans all four). UPGRADE 1 (multi-event hook bus): buildCopilotHookConfig() now emits preToolUse/ postToolUse/userPromptSubmitted/sessionEnd advisory handlers alongside sessionStart (static inline bash/powershell — deterministic, golden-trackable). Only copilot.json's gsd-session.json hash changes. UPGRADE 2 (background dispatch): surfaced via the negotiated contract only — dispatch.background:true exceeds the declarative-cli baseline and survives negotiation with no downgrade warning. NO .agent.md frontmatter field (copilot has none). MCP companion out of scope (AC4 names only 2 upgrades). Tests: declarative-reference-copilot (adapter/axes/fail-closed + AC2 4-file source-grep guard) + copilot-upgrades (live 5-event hook wiring; dispatch.background negotiation). Matrix EoS note + how-to; changeset (Changed). capability-registry regenerated. Incidental flaky-test RE-ARCHITECTURE (no-defer, maintainer-directed): tests/opencode-review-reconstruction.property.test.cjs spawned ~600 synchronous execFileSync('jq') subprocesses (numRuns:200 × 3 fast-check properties, one jq per generated stream); a single jq freezing on a contended macos-22 CI runner hung the whole unit-test chunk to its 600s kill (this PR's CI). --test-force-exit can't interrupt a synchronous execFileSync, so the cure is to stop spawning per case, not just time-bound it. Re-architected to run the SHIPPED jq program over the whole fast-check corpus in ONE jq process: each generated stream is one compact-JSON array per line in a temp file, `jq -c <PROGRAM>` (no -s) applies PROGRAM to each array (`.` == the array, exactly what production's `jq -rs <file>` sees after slurping) and emits one result per line — empirically byte-identical to the per-stream form across embedded-newline/empty/quote/ unicode/null-drop cases, and file-input (like production) so there's no stdin pipe to deadlock on large I/O. ~600 spawns → 6; coverage unchanged (200-case corpus per property, deterministic seeds) plus explicit boundary/diagnostic example batches. Still property- tests the real shipped jq (no JS reimplementation). Per-call jq timeout retained as a belt-and-suspenders bound. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -83,6 +83,21 @@ function _hostBehaviors(runtime: string): Record<string, unknown> {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Public accessor for the `hostBehaviors.agentFileExtension` descriptor field
|
||||
* (ADR-1239 / #2099 / #2103). Returns the runtime's declared agent-file
|
||||
* destination-suffix rename target (e.g. copilot's `.agent.md`), or
|
||||
* `undefined` when the runtime declares none (the generic no-rename
|
||||
* default). Exported so callers outside this module (surface.cts's
|
||||
* `_syncGsdDir`) can derive the SAME rename decision as
|
||||
* install-engine.cts's staged-copy loop from ONE descriptor read, instead of
|
||||
* duplicating a hardcoded `runtime === 'copilot'` check (#2103 fold).
|
||||
*/
|
||||
function agentFileExtensionFor(runtime: string): string | undefined {
|
||||
const ext = _hostBehaviors(runtime).agentFileExtension;
|
||||
return typeof ext === 'string' ? ext : undefined;
|
||||
}
|
||||
|
||||
|
||||
const colorNameToHex = {
|
||||
cyan: '#00FFFF',
|
||||
@@ -2756,10 +2771,12 @@ function normalizeAgentBodyForRuntime(content: string, runtime: string, cmdNames
|
||||
* ~/\.claude\b → normalizedPathPrefix
|
||||
* $HOME/\.claude\b → normalizedPathPrefix
|
||||
*
|
||||
* Skipped for copilot (hardcoded — #2099 will fold it) and for any runtime
|
||||
* that declares `hostBehaviors.noPathRewrite` (descriptor-driven, ADR-1239 /
|
||||
* #2096 — folds the prior hardcoded `runtime === 'antigravity'` literal;
|
||||
* Antigravity does NOT do path rewrites in the inline loop). NO stamp
|
||||
* Skipped for any runtime that declares `hostBehaviors.noPathRewrite`
|
||||
* (descriptor-driven, ADR-1239 / #2096 — folds the prior hardcoded
|
||||
* `runtime === 'antigravity'` literal; Antigravity does NOT do path rewrites
|
||||
* in the inline loop / #2103 — folds the prior hardcoded
|
||||
* `runtime === 'copilot'` literal onto the same descriptor field, since
|
||||
* copilot also skips these rewrites). NO stamp
|
||||
* (_stampNonClaudeRuntimeDefaults) — agents are NOT stamped in the inline loop.
|
||||
*
|
||||
* ADR-1235 §1: pre-converter cross-cutting for descriptor-driven agent pipeline.
|
||||
@@ -2769,10 +2786,10 @@ function normalizeAgentBodyForRuntime(content: string, runtime: string, cmdNames
|
||||
* @param content raw agent file content
|
||||
* @param runtime canonical runtime ID
|
||||
* @param pathPrefix trailing-slash path prefix (e.g. '$HOME/.cursor/')
|
||||
* @returns content with path-prefix rewrites applied (or unchanged for copilot / noPathRewrite runtimes)
|
||||
* @returns content with path-prefix rewrites applied (or unchanged for noPathRewrite runtimes, e.g. copilot)
|
||||
*/
|
||||
function applyAgentPathRewrites(content: string, runtime: string, pathPrefix: string): string {
|
||||
if (runtime === 'copilot' || _hostBehaviors(runtime).noPathRewrite === true) return content;
|
||||
if (_hostBehaviors(runtime).noPathRewrite === true) return content;
|
||||
const normalizedPathPrefix = pathPrefix.replace(/\/$/, '');
|
||||
content = content.replace(/~\/\.claude\//g, pathPrefix);
|
||||
content = content.replace(/\$HOME\/\.claude\//g, pathPrefix);
|
||||
@@ -2813,6 +2830,11 @@ function processAttribution(
|
||||
|
||||
export = {
|
||||
processAttribution,
|
||||
// #2103: public accessor for hostBehaviors.agentFileExtension, exported so
|
||||
// surface.cts's _syncGsdDir can derive the .agent.md rename from the SAME
|
||||
// descriptor read as install-engine.cts (folds a duplicated hardcoded
|
||||
// `runtime === 'copilot'` literal).
|
||||
agentFileExtensionFor,
|
||||
yamlIdentifier,
|
||||
yamlQuote,
|
||||
toSingleLine,
|
||||
|
||||
Reference in New Issue
Block a user