feat(#2097): migrate Augment onto EoS declarative adapter + settings.json MCP companion (ADR-1239)

Fold augment's runtime-literal conversion branches onto descriptor-driven
hostBehaviors and delete dead code:
- Site A (_applyRuntimeRewrites case 'augment'): the 4 ~/.augment dot-dir
  regexes now derive from getDirName('augment') via escapeRegExp (byte-
  identical; getDirName('augment')==='.augment') — no runtime literal.
- Site B (applyRuntimeContentRewritesForCommandsInPlace): the
  `if (runtime==='augment')` markdown-converter branch now reads
  runtime.hostBehaviors.commandBodyConverter and dispatches through a local
  COMMAND_BODY_CONVERTERS map (degrade-closed on unknown/absent name).
- Deleted dead `claudeToAugmentTools` map (zero refs; orphaned by ADR-1508
  single-sourcing) and the unreachable `else if (isAugment)` agent-conversion
  branch (augment ∈ _DESCRIPTOR_AGENTS_RUNTIMES → gated out upstream).
- Incidental orphan cleanup (no-defer): removed the equally-unreachable
  `else if (isTrae)` agent-conversion arm left behind by trae's already-merged
  migration #2094 (trae ∈ _DESCRIPTOR_AGENTS_RUNTIMES, same upstream gate).
  copilot/windsurf/codebuddy arms are removed by their own pending migrations.

UPGRADE 3 (transport:mcp): register the GSD companion MCP server in Augment's
settings.json under mcpServers.gsd (Augment hosts MCP in settings.json, not a
standalone file). mergeGsdMcpServerIntoSettings mutates the in-memory settings
object finishInstall already writes (gated on hostBehaviors.mcpCompanion===
'settings-json'); non-destructive + idempotent; symmetric uninstall removal.
settings.json is golden-excluded, so no golden change. UPGRADE 1 (named/
background dispatch) + UPGRADE 2 (settings-json hook bus, Claude dialect)
were already live in production — this adds tests exercising both.

Golden: byte-identical for all 16 runtimes (folds preserve regex behavior;
MCP lives in golden-excluded settings.json) — verified by a real double-install
tree diff. Tests: declarative-reference-augment (adapter/axes/fail-closed/
undocumented-sub-axes + source-grep guard scoped to conversion-logic branches)
+ augment-upgrades (dispatch negotiation, hook-bus live install, MCP add/
idempotent/preserve/uninstall). Matrix + connect-gsd-mcp-server + a stale
install-on-your-runtime hook-ownership claim corrected; changeset (Changed).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-07-11 04:04:48 -04:00
parent 41d544248b
commit 17aa35fba7
10 changed files with 564 additions and 21 deletions

View File

@@ -2606,14 +2606,6 @@ function convertClaudeAgentToWindsurfAgent(content) {
// Augment uses a tool set similar to Cursor/Windsurf.
// Config lives in .augment/ (local) and ~/.augment/ (global).
const claudeToAugmentTools = {
Bash: 'launch-process',
Edit: 'str-replace-editor',
AskUserQuestion: null,
SlashCommand: null,
TodoWrite: 'add_tasks',
};
// #1675 (ADR-1508): the augment converter family below was a byte-identical
// duplicate of runtime-artifact-conversion.cjs:
// convertSlashCommandsToAugmentSkillMentions, convertClaudeToAugmentMarkdown,
@@ -7546,6 +7538,21 @@ function uninstall(isGlobal, runtime = DEFAULT_RUNTIME) {
}
}
// #2097 UPGRADE 3 — Remove the MCP companion entry from settings.json for
// runtimes that host MCP there (Augment), symmetric to the mcp_config.json
// removal for Antigravity below. Only the GSD-owned mcpServers.gsd key is
// removed — any other user-configured MCP servers are preserved.
if (_hostBehaviors(runtime).mcpCompanion === 'settings-json' &&
settings.mcpServers && typeof settings.mcpServers === 'object' &&
settings.mcpServers.gsd !== undefined) {
delete settings.mcpServers.gsd;
if (Object.keys(settings.mcpServers).length === 0) {
delete settings.mcpServers;
}
settingsModified = true;
console.log(` ${green}✓${reset} Removed GSD MCP companion server from settings.json`);
}
if (settingsModified) {
writeSettings(settingsPath, settings);
removedCount++;
@@ -8078,6 +8085,27 @@ function configureAntigravityMcpConfig(isGlobal = true, configDir = null) {
console.log(` ${green}✓${reset} Configured Antigravity MCP companion server (gsd)`);
}
/**
* #2097 (ADR-1239 transport:mcp): register the GSD companion MCP server inside a
* runtime's settings.json (Augment hosts MCP in settings.json.mcpServers, unlike
* Antigravity's standalone mcp_config.json). Mutates the in-memory settings object
* that finishInstall already writes — non-destructive + idempotent: only sets
* mcpServers.gsd, preserving any user-defined servers (a user's own `gsd` override
* is respected — Hyrum's Law).
* @param {object} settings - the in-memory settings object finishInstall will write
*/
function mergeGsdMcpServerIntoSettings(settings) {
if (!settings.mcpServers || typeof settings.mcpServers !== 'object' || Array.isArray(settings.mcpServers)) {
settings.mcpServers = {};
}
if (settings.mcpServers.gsd === undefined) {
settings.mcpServers.gsd = {
command: 'npx',
args: ['-y', '-p', PACKAGE_NAME, 'gsd-mcp-server'],
};
}
}
/**
* Verify a directory exists and contains files
*/
@@ -9643,10 +9671,6 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
content = convertClaudeAgentToCopilotAgent(content, isGlobal);
} else if (isWindsurf) {
content = convertClaudeAgentToWindsurfAgent(content);
} else if (isAugment) {
content = convertClaudeAgentToAugmentAgent(content);
} else if (isTrae) {
content = convertClaudeAgentToTraeAgent(content);
} else if (isCodebuddy) {
content = convertClaudeAgentToCodebuddyAgent(content);
} else if (_hostBehaviors(runtime).frontmatterDialect === 'cline') {
@@ -10918,6 +10942,12 @@ function finishInstall(settingsPath, settings, statuslineCommand, shouldInstallS
mergeClaudePermissions(settings);
}
// #2097 UPGRADE 3 (transport:mcp): companion MCP server for runtimes that host
// MCP in settings.json (Augment). settings.json is golden-excluded, so no golden change.
if (_hostBehaviors(runtime).mcpCompanion === 'settings-json' && settings && plan.writesSharedSettings) {
mergeGsdMcpServerIntoSettings(settings);
}
// Write settings when runtime supports settings.json.
// #3002 CR: defense-in-depth — re-run validateHookFields right before
// serialization. The push-site guards above already skip null-command
@@ -11930,6 +11960,8 @@ module.exports = {
buildAntigravityAllowRules,
configureAntigravityPermissions,
configureAntigravityMcpConfig,
// #2097 UPGRADE 3 — Augment MCP companion (settings.json-hosted)
mergeGsdMcpServerIntoSettings,
claudeToCopilotTools,
convertCopilotToolName,
convertClaudeToCopilotContent,