fix(antigravity): fix agent tools, sandbox permissions, and relocate global msd-core
Some checks failed
Tests / PR mergeability (push) Successful in 30s
Tests / Detect test scope (push) Successful in 21s
Tests / lint-tests (push) Failing after 3m39s
Tests / plugin-validate (push) Successful in 2m22s
Tests / test (inert CI) (push) Has been skipped
Tests / conformance test (macos-latest, 24) (push) Blocked by required conditions
Tests / conformance test (windows-latest, 24, shard 1/3) (push) Blocked by required conditions
Tests / conformance test (windows-latest, 24, shard 2/3) (push) Blocked by required conditions
Tests / Required tests (push) Blocked by required conditions
Tests / conformance test (windows-latest, 24, shard 3/3) (push) Blocked by required conditions
Tests / Base branch health (push) Successful in 12s
Tests / test (ubuntu-latest, 24, shard 1/3) (push) Failing after 20s
Tests / test (ubuntu-latest, 24, shard 2/3) (push) Failing after 19s
Tests / test (ubuntu-latest, 24, shard 3/3) (push) Failing after 19s
Tests / test (ubuntu-latest, 24) (push) Failing after 17s
Tests / QA loop walk (smell ratchet) (push) Failing after 20s
Tests / Coverage gate (merged shards) (push) Has been skipped
Tests / Publish emitted-baseline artifact (push) Has been skipped
Dismiss Unauthorized PR Approvals / dismiss-unauthorized-approval (push) Successful in 9s
Some checks failed
Tests / PR mergeability (push) Successful in 30s
Tests / Detect test scope (push) Successful in 21s
Tests / lint-tests (push) Failing after 3m39s
Tests / plugin-validate (push) Successful in 2m22s
Tests / test (inert CI) (push) Has been skipped
Tests / conformance test (macos-latest, 24) (push) Blocked by required conditions
Tests / conformance test (windows-latest, 24, shard 1/3) (push) Blocked by required conditions
Tests / conformance test (windows-latest, 24, shard 2/3) (push) Blocked by required conditions
Tests / Required tests (push) Blocked by required conditions
Tests / conformance test (windows-latest, 24, shard 3/3) (push) Blocked by required conditions
Tests / Base branch health (push) Successful in 12s
Tests / test (ubuntu-latest, 24, shard 1/3) (push) Failing after 20s
Tests / test (ubuntu-latest, 24, shard 2/3) (push) Failing after 19s
Tests / test (ubuntu-latest, 24, shard 3/3) (push) Failing after 19s
Tests / test (ubuntu-latest, 24) (push) Failing after 17s
Tests / QA loop walk (smell ratchet) (push) Failing after 20s
Tests / Coverage gate (merged shards) (push) Has been skipped
Tests / Publish emitted-baseline artifact (push) Has been skipped
Dismiss Unauthorized PR Approvals / dismiss-unauthorized-approval (push) Successful in 9s
- Map Glob, WebSearch, WebFetch to Antigravity-native tool names (find_by_name, search_web, read_url_content) and drop unmapped tools instead of lowercasing - Emit absolute, glob-free trailing-slash read_file() allow rules in settings.json and strip legacy globbed/tilde rules that crash the Antigravity terminal sandbox - Relocate global Antigravity msd-core/ and sibling scripts/ outside ~/.gemini/ to ~/.msd/antigravity/ (avoiding AGY CLI's hardcoded ~/.gemini/** protection boundary) - Update content rewriters, msd-run-resolver.md, update-context, and update.md to resolve ~/.msd/antigravity/msd-core/ and .agents/msd-core/ - Replace Discord invite link in installer banner with Golem15 Wavepath join URL
This commit is contained in:
353
bin/install.js
353
bin/install.js
@@ -31,6 +31,7 @@ const {
|
||||
} = require('../msd-core/bin/lib/command-roster.cjs');
|
||||
const {
|
||||
resolveAntigravityGlobalDir,
|
||||
resolveMsdCoreDir,
|
||||
getGlobalConfigDir,
|
||||
getGlobalSkillsBase,
|
||||
isRegisteredRuntimeId,
|
||||
@@ -1376,16 +1377,17 @@ const claudeToOpencodeTools = {
|
||||
// Tool name mapping from Claude Code to Antigravity
|
||||
// Antigravity uses Gemini's snake_case built-in tool names
|
||||
const claudeToAntigravityTools = {
|
||||
// #4705: Antigravity-NATIVE tool names (see src/runtime-artifact-conversion.cts)
|
||||
// #4705: Antigravity-NATIVE tool names (see src/runtime-artifact-conversion.cts).
|
||||
// Only names the Antigravity CLI tool registry resolves; TodoWrite has no
|
||||
// registered equivalent and is dropped by convertAntigravityToolName.
|
||||
Read: 'view_file',
|
||||
Write: 'write_file',
|
||||
Edit: 'replace_file_content',
|
||||
Bash: 'run_command',
|
||||
Glob: 'glob',
|
||||
Glob: 'find_by_name',
|
||||
Grep: 'grep_search',
|
||||
WebSearch: 'google_web_search',
|
||||
WebFetch: 'web_fetch',
|
||||
TodoWrite: 'write_todos',
|
||||
WebSearch: 'search_web',
|
||||
WebFetch: 'read_url_content',
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1435,12 +1437,13 @@ function convertAntigravityToolName(claudeTool) {
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
// Check for explicit mapping
|
||||
if (claudeToAntigravityTools[claudeTool]) {
|
||||
// Explicit mapping, or drop: Antigravity refuses to start an agent that
|
||||
// grants a name its tool registry does not know, so a lowercased guess is
|
||||
// worse than no grant (mirrors src/runtime-artifact-conversion.cts).
|
||||
if (Object.prototype.hasOwnProperty.call(claudeToAntigravityTools, claudeTool)) {
|
||||
return claudeToAntigravityTools[claudeTool];
|
||||
}
|
||||
// Default: lowercase
|
||||
return claudeTool.toLowerCase();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1522,11 +1525,75 @@ function convertClaudeCommandToClaudeSkill(content, skillName, _runtime = null,
|
||||
return `${fm}\n${normalizedBody}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Antigravity global configHome as it must be written into converted
|
||||
* content, in both spellings the sources use (`~/…` and `$HOME/…`).
|
||||
*
|
||||
* MSD's engine (msd-core/, hooks/, settings) installs into whichever of
|
||||
* ~/.gemini/antigravity{,-ide,-cli} the installer resolved. Content used to
|
||||
* hardcode `~/.gemini/antigravity/`, so on a machine that only has the CLI's
|
||||
* `antigravity-cli` dir every `@~/.gemini/antigravity/msd-core/…` reference
|
||||
* pointed at a directory that does not exist.
|
||||
*
|
||||
* An installer that knows its exact target (including an explicit
|
||||
* --config-dir) pins it with setAntigravityGlobalHomePrefix. Otherwise this
|
||||
* asks the same resolver the installer uses.
|
||||
*/
|
||||
let antigravityGlobalHomeOverride = null;
|
||||
|
||||
/** @param {string|null} pathPrefix e.g. '$HOME/.gemini/antigravity-cli/'; null clears the pin. */
|
||||
function setAntigravityGlobalHomePrefix(pathPrefix) {
|
||||
antigravityGlobalHomeOverride = typeof pathPrefix === 'string' && pathPrefix.trim()
|
||||
? pathPrefix.replace(/\/+$/, '')
|
||||
: null;
|
||||
}
|
||||
|
||||
function antigravityGlobalHomeRefs() {
|
||||
let prefix = antigravityGlobalHomeOverride;
|
||||
if (prefix === null) {
|
||||
const home = String(os.homedir()).replace(/\\/g, '/').replace(/\/+$/, '');
|
||||
const dir = String(resolveAntigravityGlobalDir()).replace(/\\/g, '/');
|
||||
prefix = dir.startsWith(`${home}/`) ? `$HOME${dir.slice(home.length)}` : dir;
|
||||
}
|
||||
if (prefix.startsWith('$HOME/')) return { tilde: `~${prefix.slice('$HOME'.length)}`, home: prefix };
|
||||
return { tilde: prefix, home: prefix };
|
||||
}
|
||||
|
||||
function antigravityGlobalMsdCoreRefs() {
|
||||
const refs = antigravityGlobalHomeRefs();
|
||||
const isInsideGemini =
|
||||
refs.home === '$HOME/.gemini' ||
|
||||
refs.home.startsWith('$HOME/.gemini/') ||
|
||||
refs.tilde === '~/.gemini' ||
|
||||
refs.tilde.startsWith('~/.gemini/');
|
||||
if (isInsideGemini) {
|
||||
const msdHomeEnv = process.env.MSD_HOME;
|
||||
const home = String(os.homedir()).replace(/\\/g, '/').replace(/\/+$/, '');
|
||||
if (typeof msdHomeEnv === 'string' && msdHomeEnv.trim() !== '') {
|
||||
const resolvedMsdHome = msdHomeEnv.replace(/\\/g, '/').replace(/\/+$/, '');
|
||||
if (resolvedMsdHome !== home) {
|
||||
const corePath = `${resolvedMsdHome}/.msd/antigravity/msd-core`;
|
||||
return { tilde: corePath, home: corePath };
|
||||
}
|
||||
}
|
||||
return {
|
||||
tilde: '~/.msd/antigravity/msd-core',
|
||||
home: '$HOME/.msd/antigravity/msd-core',
|
||||
};
|
||||
}
|
||||
return {
|
||||
tilde: `${refs.tilde}/msd-core`,
|
||||
home: `${refs.home}/msd-core`,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply Antigravity-specific content conversion — path replacement + command name conversion.
|
||||
* Path mappings depend on install mode:
|
||||
* Global: ~/.claude/skills/ → ~/.gemini/config/skills/ (#3738),
|
||||
* ~/.claude/ → ~/.gemini/antigravity/, ./.claude/ → ./.agents/
|
||||
* ~/.claude/msd-core/ → ~/.msd/antigravity/msd-core/ (outside ~/.gemini/ protection boundary),
|
||||
* ~/.claude/ → the resolved configHome (~/.gemini/antigravity{,-ide,-cli}),
|
||||
* ./.claude/ → ./.agents/
|
||||
* Local: ~/.claude/ → .agents/, ./.claude/ → ./.agents/
|
||||
* Applied to ALL Antigravity content (skills, agents, engine files).
|
||||
* @param {string} content - Source content to convert
|
||||
@@ -1537,10 +1604,8 @@ function convertClaudeToAntigravityContent(content, isGlobal = false) {
|
||||
if (isGlobal) {
|
||||
// #3738: global skills install under ~/.gemini/config/skills (the dir AGY
|
||||
// scans for global discovery), so skills-path references must divert there
|
||||
// — BEFORE the configHome rewrite below, which is correct for msd-core
|
||||
// runtime-file references (settings, workflows, VERSION) but wrong for the
|
||||
// skills dir itself. Mirrors src/runtime-artifact-conversion.cts (ADR-1508
|
||||
// keeps bin/install.js hand-authored; the two copies must stay in sync).
|
||||
// — BEFORE the configHome rewrite below. Mirrors src/runtime-artifact-conversion.cts
|
||||
// (ADR-1508 keeps bin/install.js hand-authored; the two copies must stay in sync).
|
||||
c = c.replace(/\$HOME\/\.claude\/skills\//g, '$HOME/.gemini/config/skills/');
|
||||
c = c.replace(/~\/\.claude\/skills\//g, '~/.gemini/config/skills/');
|
||||
// Bare skills form (no trailing slash) — must also precede the generic
|
||||
@@ -1548,11 +1613,21 @@ function convertClaudeToAntigravityContent(content, isGlobal = false) {
|
||||
// path ($HOME/.gemini/antigravity/skills).
|
||||
c = c.replace(/\$HOME\/\.claude\/skills\b/g, '$HOME/.gemini/config/skills');
|
||||
c = c.replace(/~\/\.claude\/skills\b/g, '~/.gemini/config/skills');
|
||||
c = c.replace(/\$HOME\/\.claude\//g, '$HOME/.gemini/antigravity/');
|
||||
c = c.replace(/~\/\.claude\//g, '~/.gemini/antigravity/');
|
||||
// Global Antigravity msd-core/ lives outside ~/.gemini/ (~/.msd/antigravity/msd-core)
|
||||
// because Antigravity CLI enforces a hardcoded protection boundary on ~/.gemini/**
|
||||
// that blocks read_file even when permissions.allow permits it.
|
||||
const coreRefs = antigravityGlobalMsdCoreRefs();
|
||||
c = c.replace(/\$HOME\/\.claude\/msd-core\//g, () => `${coreRefs.home}/`);
|
||||
c = c.replace(/~\/\.claude\/msd-core\//g, () => `${coreRefs.tilde}/`);
|
||||
c = c.replace(/\$HOME\/\.claude\/msd-core\b/g, () => coreRefs.home);
|
||||
c = c.replace(/~\/\.claude\/msd-core\b/g, () => coreRefs.tilde);
|
||||
// Remaining ~/.claude/ references (settings.json, hooks/, etc.) go to configHome.
|
||||
const refs = antigravityGlobalHomeRefs();
|
||||
c = c.replace(/\$HOME\/\.claude\//g, () => `${refs.home}/`);
|
||||
c = c.replace(/~\/\.claude\//g, () => `${refs.tilde}/`);
|
||||
// Bare form (no trailing slash) — must come after slash form to avoid double-replace
|
||||
c = c.replace(/\$HOME\/\.claude\b/g, '$HOME/.gemini/antigravity');
|
||||
c = c.replace(/~\/\.claude\b/g, '~/.gemini/antigravity');
|
||||
c = c.replace(/\$HOME\/\.claude\b/g, () => refs.home);
|
||||
c = c.replace(/~\/\.claude\b/g, () => refs.tilde);
|
||||
} else {
|
||||
c = c.replace(/\$HOME\/\.claude\//g, '.agents/');
|
||||
c = c.replace(/~\/\.claude\//g, '.agents/');
|
||||
@@ -5832,7 +5907,8 @@ function uninstall(isGlobal, runtime = DEFAULT_RUNTIME) {
|
||||
}
|
||||
|
||||
// 2. Remove msd-core directory
|
||||
const msdDir = path.join(targetDir, 'msd-core');
|
||||
const msdDir = resolveMsdCoreDir(targetDir, runtime, isGlobal);
|
||||
const legacyMsdDir = path.join(targetDir, 'msd-core');
|
||||
if (fs.existsSync(msdDir)) {
|
||||
// Stage user-generated files DURABLY to disk before wipe (#1423; #2875 /
|
||||
// #1874-F19 "site 5" — this block open-coded its own preserve/restore
|
||||
@@ -5880,6 +5956,13 @@ function uninstall(isGlobal, runtime = DEFAULT_RUNTIME) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// If msd-core/ lives outside targetDir (e.g. Antigravity global at
|
||||
// ~/.msd/antigravity/msd-core), also remove any legacy copy left under targetDir.
|
||||
if (path.resolve(legacyMsdDir) !== path.resolve(msdDir) && fs.existsSync(legacyMsdDir)) {
|
||||
fs.rmSync(legacyMsdDir, { recursive: true, force: true });
|
||||
removedCount++;
|
||||
console.log(` ${green}✓${reset} Removed legacy msd-core/ from config dir`);
|
||||
}
|
||||
|
||||
// 3. Remove MSD agents (msd-*.md files only)
|
||||
const agentsDir = path.join(targetDir, 'agents');
|
||||
@@ -6011,47 +6094,53 @@ function uninstall(isGlobal, runtime = DEFAULT_RUNTIME) {
|
||||
// non-empty (user has custom helpers) it stays; otherwise it goes cleanly.
|
||||
// MSD_CHANGESET_FILES / MSD_SCRIPTS_LIB_FILES are module-scoped (#3184) so
|
||||
// tests can assert their parity against the real directory contents.
|
||||
const changesetUninstallDir = path.join(targetDir, 'scripts', 'changeset');
|
||||
if (fs.existsSync(changesetUninstallDir)) {
|
||||
let removedChangeset = 0;
|
||||
for (const file of MSD_CHANGESET_FILES) {
|
||||
const fp = path.join(changesetUninstallDir, file);
|
||||
try { fs.unlinkSync(fp); removedChangeset++; } catch (_) { /* best-effort */ }
|
||||
}
|
||||
// Remove directory if empty after our cleanup
|
||||
try { fs.rmdirSync(changesetUninstallDir); } catch (_) { /* Not empty — user content present */ }
|
||||
if (removedChangeset > 0) {
|
||||
removedCount++;
|
||||
console.log(` ${green}✓${reset} Removed scripts/changeset/ MSD files`);
|
||||
}
|
||||
const scriptsRoots = [path.dirname(msdDir)];
|
||||
if (path.resolve(targetDir) !== path.resolve(path.dirname(msdDir))) {
|
||||
scriptsRoots.push(targetDir);
|
||||
}
|
||||
const scriptsLibUninstallDir = path.join(targetDir, 'scripts', 'lib');
|
||||
if (fs.existsSync(scriptsLibUninstallDir)) {
|
||||
let removedScriptsLib = 0;
|
||||
for (const file of MSD_SCRIPTS_LIB_FILES) {
|
||||
const fp = path.join(scriptsLibUninstallDir, file);
|
||||
try { fs.unlinkSync(fp); removedScriptsLib++; } catch (_) { /* best-effort */ }
|
||||
for (const scriptsRoot of scriptsRoots) {
|
||||
const changesetUninstallDir = path.join(scriptsRoot, 'scripts', 'changeset');
|
||||
if (fs.existsSync(changesetUninstallDir)) {
|
||||
let removedChangeset = 0;
|
||||
for (const file of MSD_CHANGESET_FILES) {
|
||||
const fp = path.join(changesetUninstallDir, file);
|
||||
try { fs.unlinkSync(fp); removedChangeset++; } catch (_) { /* best-effort */ }
|
||||
}
|
||||
// Remove directory if empty after our cleanup
|
||||
try { fs.rmdirSync(changesetUninstallDir); } catch (_) { /* Not empty — user content present */ }
|
||||
if (removedChangeset > 0) {
|
||||
removedCount++;
|
||||
console.log(` ${green}✓${reset} Removed scripts/changeset/ MSD files`);
|
||||
}
|
||||
}
|
||||
// Remove directory if empty after our cleanup
|
||||
try { fs.rmdirSync(scriptsLibUninstallDir); } catch (_) { /* Not empty — user content present */ }
|
||||
if (removedScriptsLib > 0) {
|
||||
removedCount++;
|
||||
console.log(` ${green}✓${reset} Removed scripts/lib/ MSD files`);
|
||||
const scriptsLibUninstallDir = path.join(scriptsRoot, 'scripts', 'lib');
|
||||
if (fs.existsSync(scriptsLibUninstallDir)) {
|
||||
let removedScriptsLib = 0;
|
||||
for (const file of MSD_SCRIPTS_LIB_FILES) {
|
||||
const fp = path.join(scriptsLibUninstallDir, file);
|
||||
try { fs.unlinkSync(fp); removedScriptsLib++; } catch (_) { /* best-effort */ }
|
||||
}
|
||||
// Remove directory if empty after our cleanup
|
||||
try { fs.rmdirSync(scriptsLibUninstallDir); } catch (_) { /* Not empty — user content present */ }
|
||||
if (removedScriptsLib > 0) {
|
||||
removedCount++;
|
||||
console.log(` ${green}✓${reset} Removed scripts/lib/ MSD files`);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove scripts/fix-slash-commands.cjs (#1223) — must come before the scripts/ rmdir
|
||||
const fixSlashUninstallPath = path.join(targetDir, 'scripts', 'fix-slash-commands.cjs');
|
||||
try { fs.unlinkSync(fixSlashUninstallPath); } catch (_) { /* best-effort */ }
|
||||
// Remove scripts/fix-slash-commands.cjs (#1223) — must come before the scripts/ rmdir
|
||||
const fixSlashUninstallPath = path.join(scriptsRoot, 'scripts', 'fix-slash-commands.cjs');
|
||||
try { fs.unlinkSync(fixSlashUninstallPath); } catch (_) { /* best-effort */ }
|
||||
|
||||
// Remove the capability registry generator scripts (#1920) — before the scripts/ rmdir
|
||||
for (const gen of ['gen-capability-registry.cjs', 'gen-loop-host-contract.cjs']) {
|
||||
try { fs.unlinkSync(path.join(targetDir, 'scripts', gen)); } catch (_) { /* best-effort */ }
|
||||
}
|
||||
// Remove the capability registry generator scripts (#1920) — before the scripts/ rmdir
|
||||
for (const gen of ['gen-capability-registry.cjs', 'gen-loop-host-contract.cjs']) {
|
||||
try { fs.unlinkSync(path.join(scriptsRoot, 'scripts', gen)); } catch (_) { /* best-effort */ }
|
||||
}
|
||||
|
||||
// If scripts/ dir is now empty, remove it too
|
||||
const scriptsUninstallDir = path.join(targetDir, 'scripts');
|
||||
if (fs.existsSync(scriptsUninstallDir)) {
|
||||
try { fs.rmdirSync(scriptsUninstallDir); } catch (_) { /* Not empty — leave it */ }
|
||||
// If scripts/ dir is now empty, remove it too
|
||||
const scriptsUninstallDir = path.join(scriptsRoot, 'scripts');
|
||||
if (fs.existsSync(scriptsUninstallDir)) {
|
||||
try { fs.rmdirSync(scriptsUninstallDir); } catch (_) { /* Not empty — leave it */ }
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Remove MSD package.json (CommonJS mode marker)
|
||||
@@ -6177,9 +6266,12 @@ function uninstall(isGlobal, runtime = DEFAULT_RUNTIME) {
|
||||
if (resolveInstallPlan(runtime).finishPermissionWriter === 'antigravity' && settings.permissions) {
|
||||
let antigravityPermissionsModified = false;
|
||||
if (Array.isArray(settings.permissions.allow)) {
|
||||
const msdRules = new Set(buildAntigravityAllowRules(targetDir));
|
||||
const msdCoreDir = resolveMsdCoreDir(targetDir, runtime, isGlobal);
|
||||
const msdRules = new Set(buildAntigravityAllowRules(targetDir, msdCoreDir));
|
||||
const before = settings.permissions.allow.length;
|
||||
settings.permissions.allow = settings.permissions.allow.filter((e) => !msdRules.has(e));
|
||||
settings.permissions.allow = settings.permissions.allow.filter(
|
||||
(e) => !msdRules.has(e) && !isLegacyAntigravityAllowRule(e, targetDir),
|
||||
);
|
||||
if (settings.permissions.allow.length !== before) {
|
||||
antigravityPermissionsModified = true;
|
||||
}
|
||||
@@ -6466,17 +6558,60 @@ function toTildePosixPath(absPath) {
|
||||
* strings in permissions.{allow,deny,ask}, evaluated deny > ask > allow. MSD
|
||||
* only ever contributes to `allow` — never deny/ask (those are user-owned risk
|
||||
* decisions this installer has no business making).
|
||||
*
|
||||
* IMPORTANT: Antigravity's terminal sandbox converts `read_file(...)` allow
|
||||
* rules into `readonly` bind mounts and rejects BOTH `*` globs (`globs not
|
||||
* supported`) AND `~`-prefixed paths (`non-absolute file path`). Directory
|
||||
* rules MUST use an absolute POSIX path with a trailing slash and no glob
|
||||
* (`read_file(/abs/path/to/dir/)`). Skills and agents under
|
||||
* `~/.gemini/config/{skills,agents}` (global) or `./.agents/` (local) are
|
||||
* already readable natively without rules.
|
||||
*/
|
||||
function buildAntigravityAllowRules(configDir) {
|
||||
function buildAntigravityAllowRules(configDir, msdCoreDir = null) {
|
||||
const absConfig = path.resolve(configDir).replace(/\\/g, '/').replace(/\/+$/, '');
|
||||
const resolvedCore = path.resolve(msdCoreDir || path.join(configDir, 'msd-core'));
|
||||
const defaultCore = path.resolve(path.join(configDir, 'msd-core'));
|
||||
// When msd-core/ is relocated outside configDir (global Antigravity at
|
||||
// ~/.msd/antigravity/msd-core), grant read_file on the engine root
|
||||
// (~/.msd/antigravity/) so both msd-core/ and its sibling scripts/ tree
|
||||
// (fix-slash-commands.cjs, gen-capability-registry.cjs, changeset/) are
|
||||
// mounted read-only in the terminal sandbox.
|
||||
const readRoot = resolvedCore !== defaultCore ? path.dirname(resolvedCore) : resolvedCore;
|
||||
const absReadRoot = readRoot.replace(/\\/g, '/').replace(/\/+$/, '');
|
||||
return [
|
||||
`read_file(${absReadRoot}/)`,
|
||||
`command(node ${absConfig}/hooks/)`,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy globbed or tilde-prefixed Antigravity allow rules emitted by earlier
|
||||
* MSD releases. Globs (`msd-core/*`, `agents/msd-*`, `skills/msd-*`) and
|
||||
* tilde-prefixed `read_file(~/...)` rules break Antigravity's terminal sandbox
|
||||
* (`globs not supported` / `non-absolute file path`), so reinstall/upgrade and
|
||||
* uninstall strip them automatically.
|
||||
*/
|
||||
function buildLegacyAntigravityAllowRules(configDir) {
|
||||
const msdPath = toTildePosixPath(configDir);
|
||||
return [
|
||||
`read_file(${msdPath}/msd-core/*)`,
|
||||
`read_file(${msdPath}/agents/msd-*)`,
|
||||
`read_file(${msdPath}/skills/msd-*)`,
|
||||
`command(node ${msdPath}/hooks/*)`,
|
||||
`read_file(${msdPath}/msd-core/)`,
|
||||
`command(node ${msdPath}/hooks/)`,
|
||||
];
|
||||
}
|
||||
|
||||
const LEGACY_ANTIGRAVITY_GEMINI_GLOB_RULE_RE =
|
||||
/^(?:read_file\(~\/\.gemini\/antigravity(?:-ide|-cli)?\/(?:msd-core\/\*|agents\/msd-\*|skills\/msd-\*)\)|read_file\(~\/\.msd\/antigravity\/msd-core\/\)|command\(node ~\/\.gemini\/antigravity(?:-ide|-cli)?\/hooks\/\*?\))$/;
|
||||
|
||||
function isLegacyAntigravityAllowRule(rule, configDir) {
|
||||
if (typeof rule !== 'string') return false;
|
||||
if (buildLegacyAntigravityAllowRules(configDir).includes(rule)) return true;
|
||||
return LEGACY_ANTIGRAVITY_GEMINI_GLOB_RULE_RE.test(rule);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure Antigravity permissions to allow reading/executing MSD's installed
|
||||
* tree without per-call approval prompts (#2096 Phase B Upgrade 1 — mirrors
|
||||
@@ -6488,7 +6623,8 @@ function buildAntigravityAllowRules(configDir) {
|
||||
* (installSurface: 'settings-json', writesSharedSettings: true) — unlike
|
||||
* OpenCode, which writes a separate native config file. This function
|
||||
* re-reads the file (already containing MSD's hooks by the time finishInstall
|
||||
* reaches this call) and only appends to permissions.allow.
|
||||
* reaches this call), strips any legacy globbed rules that break the terminal
|
||||
* sandbox, and appends the valid trailing-slash rules to permissions.allow.
|
||||
*
|
||||
* Non-destructive + idempotent: only `permissions.allow` is touched; an
|
||||
* existing user permissions block (including any deny/ask entries, or
|
||||
@@ -6525,7 +6661,16 @@ function configureAntigravityPermissions(isGlobal = true, configDir = null) {
|
||||
}
|
||||
|
||||
let modified = false;
|
||||
for (const rule of buildAntigravityAllowRules(antigravityConfigDir)) {
|
||||
const beforeLen = config.permissions.allow.length;
|
||||
config.permissions.allow = config.permissions.allow.filter(
|
||||
(rule) => !isLegacyAntigravityAllowRule(rule, antigravityConfigDir),
|
||||
);
|
||||
if (config.permissions.allow.length !== beforeLen) {
|
||||
modified = true;
|
||||
}
|
||||
|
||||
const msdCoreDir = resolveMsdCoreDir(antigravityConfigDir, 'antigravity', isGlobal);
|
||||
for (const rule of buildAntigravityAllowRules(antigravityConfigDir, msdCoreDir)) {
|
||||
if (!config.permissions.allow.includes(rule)) {
|
||||
config.permissions.allow.push(rule);
|
||||
modified = true;
|
||||
@@ -6721,7 +6866,6 @@ function resolveInstallRelativePath(baseDir, relPath) {
|
||||
*/
|
||||
function writeManifest(configDir, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
const { isOpencode, isCodex, isCursor } = runtimeFlags(runtime);
|
||||
const msdDir = path.join(configDir, 'msd-core');
|
||||
// #1367: Claude local now writes flat msd-*.md files at commands/ (not commands/msd/).
|
||||
// Claude local uses flatCommandsDir instead for manifest recording.
|
||||
const flatCommandsDir = path.join(configDir, 'commands');
|
||||
@@ -6735,6 +6879,7 @@ function writeManifest(configDir, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
// scope RECORDED in the manifest are one value, resolved once. Two reads of
|
||||
// `options.scope` could drift; one cannot.
|
||||
const resolvedScope = options.scope === 'local' ? 'local' : 'global';
|
||||
const msdDir = resolveMsdCoreDir(configDir, runtime, resolvedScope === 'global');
|
||||
const codexSkillsDir = _resolveSkillsRootDir(runtime, configDir, resolvedScope);
|
||||
// #3738: resolve the ACTUAL agents-install dir honoring an agents-kind `home`
|
||||
// override (antigravity global → $HOME/.gemini/config/agents), mirroring
|
||||
@@ -6859,7 +7004,8 @@ function writeManifest(configDir, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
}
|
||||
|
||||
// Track scripts/changeset/ and scripts/lib/ so saveLocalPatches() can detect drift
|
||||
const changesetInstallDir = path.join(configDir, 'scripts', 'changeset');
|
||||
const scriptsBaseDir = path.dirname(msdDir);
|
||||
const changesetInstallDir = path.join(scriptsBaseDir, 'scripts', 'changeset');
|
||||
if (fs.existsSync(changesetInstallDir)) {
|
||||
for (const file of fs.readdirSync(changesetInstallDir)) {
|
||||
if (file.endsWith('.cjs')) {
|
||||
@@ -6867,7 +7013,7 @@ function writeManifest(configDir, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
}
|
||||
}
|
||||
}
|
||||
const scriptsLibInstallDir = path.join(configDir, 'scripts', 'lib');
|
||||
const scriptsLibInstallDir = path.join(scriptsBaseDir, 'scripts', 'lib');
|
||||
if (fs.existsSync(scriptsLibInstallDir)) {
|
||||
for (const file of fs.readdirSync(scriptsLibInstallDir)) {
|
||||
if (file.endsWith('.cjs')) {
|
||||
@@ -6877,7 +7023,7 @@ function writeManifest(configDir, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
}
|
||||
|
||||
// Track scripts/fix-slash-commands.cjs (top-level scripts/ file, not covered by changeset/lib loops)
|
||||
const fixSlashInstallPath = path.join(configDir, 'scripts', 'fix-slash-commands.cjs');
|
||||
const fixSlashInstallPath = path.join(scriptsBaseDir, 'scripts', 'fix-slash-commands.cjs');
|
||||
if (fs.existsSync(fixSlashInstallPath)) {
|
||||
manifest.files['scripts/fix-slash-commands.cjs'] = fileHash(fixSlashInstallPath);
|
||||
}
|
||||
@@ -6885,7 +7031,7 @@ function writeManifest(configDir, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
// Track the capability registry generator scripts (#1920) — top-level scripts/ files
|
||||
// not covered by the changeset/lib loops.
|
||||
for (const gen of ['gen-capability-registry.cjs', 'gen-loop-host-contract.cjs']) {
|
||||
const genInstallPath = path.join(configDir, 'scripts', gen);
|
||||
const genInstallPath = path.join(scriptsBaseDir, 'scripts', gen);
|
||||
if (fs.existsSync(genInstallPath)) {
|
||||
manifest.files['scripts/' + gen] = fileHash(genInstallPath);
|
||||
}
|
||||
@@ -7116,6 +7262,7 @@ function saveLocalPatches(configDir, pristineCtx) {
|
||||
const patchRuntime = (pristineCtx && pristineCtx.runtime) || manifest.runtime || null;
|
||||
const patchScope = manifest.scope === 'local' ? 'local' : 'global';
|
||||
let skillsRedirect = null;
|
||||
let msdCoreRedirect = null;
|
||||
if (patchRuntime) {
|
||||
const skillsRoot = _resolveSkillsRootDir(patchRuntime, configDir, patchScope);
|
||||
const resolvedConfig = path.resolve(configDir);
|
||||
@@ -7126,6 +7273,13 @@ function saveLocalPatches(configDir, pristineCtx) {
|
||||
) {
|
||||
skillsRedirect = { root: skillsRoot, prefix: 'skills/' };
|
||||
}
|
||||
const msdCoreRoot = path.resolve(resolveMsdCoreDir(configDir, patchRuntime, patchScope === 'global'));
|
||||
if (
|
||||
msdCoreRoot !== resolvedConfig &&
|
||||
!msdCoreRoot.startsWith(resolvedConfig + path.sep)
|
||||
) {
|
||||
msdCoreRedirect = { root: msdCoreRoot, prefix: 'msd-core/' };
|
||||
}
|
||||
}
|
||||
|
||||
for (const [relPath, originalHash] of Object.entries(manifest.files || {})) {
|
||||
@@ -7142,6 +7296,15 @@ function saveLocalPatches(configDir, pristineCtx) {
|
||||
installedPath = altRef.fullPath;
|
||||
}
|
||||
}
|
||||
if (!fs.existsSync(installedPath) && msdCoreRedirect && safeRelPath.startsWith(msdCoreRedirect.prefix)) {
|
||||
const altRef = resolveInstallRelativePath(
|
||||
msdCoreRedirect.root,
|
||||
safeRelPath.slice(msdCoreRedirect.prefix.length)
|
||||
);
|
||||
if (altRef && fs.existsSync(altRef.fullPath)) {
|
||||
installedPath = altRef.fullPath;
|
||||
}
|
||||
}
|
||||
if (!fs.existsSync(installedPath)) continue;
|
||||
const currentHash = fileHash(installedPath);
|
||||
if (currentHash !== originalHash) {
|
||||
@@ -7555,6 +7718,15 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
// handle re-applied surfaces, not the first install.
|
||||
localDirName: getDirName(runtime),
|
||||
});
|
||||
// Antigravity content is converted by its own converter (noPathRewrite), which
|
||||
// never sees pathPrefix. Pin the exact target — including an explicit
|
||||
// --config-dir — on both converter twins so every emitted reference names the
|
||||
// directory this install writes msd-core/ into.
|
||||
if (_hostBehaviors(runtime).globalDirResolver === 'antigravity') {
|
||||
const pin = isGlobal ? pathPrefix : null;
|
||||
setAntigravityGlobalHomePrefix(pin);
|
||||
runtimeArtifactConversion.setAntigravityGlobalHomePrefix(pin);
|
||||
}
|
||||
|
||||
// runtimeLabel is now the single-source getRuntimeLabel lookup (ADR-1239
|
||||
// Phase B / #1679) — collapses the prior 16-line assignment chain.
|
||||
@@ -8105,14 +8277,34 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
// exactly once into this final tree instead of having that corpus overwritten
|
||||
// by a later whole-tree copy and needing a second provisioning pass.
|
||||
const skillSrc = path.join(src, 'msd-core');
|
||||
const skillDest = path.join(targetDir, 'msd-core');
|
||||
const skillDest = resolveMsdCoreDir(targetDir, runtime, isGlobal);
|
||||
const legacySkillDest = path.join(targetDir, 'msd-core');
|
||||
// When relocating msd-core/ outside targetDir (e.g. Antigravity global at
|
||||
// ~/.msd/antigravity/msd-core), migrate any user-owned artifacts from the
|
||||
// legacy targetDir/msd-core copy and remove the inaccessible legacy tree.
|
||||
if (path.resolve(skillDest) !== path.resolve(legacySkillDest) && fs.existsSync(legacySkillDest)) {
|
||||
for (const artifact of USER_OWNED_ARTIFACTS) {
|
||||
const oldArtifact = path.join(legacySkillDest, artifact);
|
||||
const newArtifact = path.join(skillDest, artifact);
|
||||
if (fs.existsSync(oldArtifact) && !fs.existsSync(newArtifact)) {
|
||||
fs.mkdirSync(path.dirname(newArtifact), { recursive: true });
|
||||
fs.copyFileSync(oldArtifact, newArtifact);
|
||||
}
|
||||
}
|
||||
fs.rmSync(legacySkillDest, { recursive: true, force: true });
|
||||
}
|
||||
fs.mkdirSync(path.dirname(skillDest), { recursive: true });
|
||||
const skillConfinementRoot =
|
||||
path.resolve(skillDest) === path.resolve(legacySkillDest)
|
||||
? targetDir
|
||||
: path.dirname(skillDest);
|
||||
const _msdArtifactsStagingRoot = _tryResolveUserArtifactStagingRoot(targetDir);
|
||||
if (_msdArtifactsStagingRoot === null) {
|
||||
console.warn(` ${yellow}!${reset} Skipping msd-core/${USER_OWNED_ARTIFACTS.join(', msd-core/')} preservation (staging unavailable) — it will be lost if present.`);
|
||||
copyWithPathReplacement(skillSrc, skillDest, pathPrefix, runtime, false, isGlobal, targetDir);
|
||||
copyWithPathReplacement(skillSrc, skillDest, pathPrefix, runtime, false, isGlobal, skillConfinementRoot);
|
||||
} else {
|
||||
const stagedMsdArtifacts = stageUserArtifacts(skillDest, USER_OWNED_ARTIFACTS, _msdArtifactsStagingRoot);
|
||||
copyWithPathReplacement(skillSrc, skillDest, pathPrefix, runtime, false, isGlobal, targetDir);
|
||||
copyWithPathReplacement(skillSrc, skillDest, pathPrefix, runtime, false, isGlobal, skillConfinementRoot);
|
||||
restoreStagedUserArtifacts(skillDest, stagedMsdArtifacts);
|
||||
discardStagedUserArtifacts(stagedMsdArtifacts);
|
||||
}
|
||||
@@ -8449,7 +8641,7 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
|
||||
// Copy CHANGELOG.md
|
||||
const changelogSrc = path.join(src, 'CHANGELOG.md');
|
||||
const changelogDest = path.join(targetDir, 'msd-core', 'CHANGELOG.md');
|
||||
const changelogDest = path.join(skillDest, 'CHANGELOG.md');
|
||||
if (fs.existsSync(changelogSrc)) {
|
||||
fs.copyFileSync(changelogSrc, changelogDest);
|
||||
if (verifyFileInstalled(changelogDest, 'CHANGELOG.md')) {
|
||||
@@ -8460,7 +8652,7 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
}
|
||||
|
||||
// Write VERSION file
|
||||
const versionDest = path.join(targetDir, 'msd-core', 'VERSION');
|
||||
const versionDest = path.join(skillDest, 'VERSION');
|
||||
fs.writeFileSync(versionDest, pkg.version);
|
||||
if (verifyFileInstalled(versionDest, 'VERSION')) {
|
||||
console.log(` ${green}✓${reset} Wrote VERSION (${pkg.version})`);
|
||||
@@ -8476,7 +8668,7 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
// applies ONLY when a non-alias runtime is actually resolving — a Claude session
|
||||
// reads its own marker and keeps its tier aliases instead of inheriting another
|
||||
// runtime's install-order-dependent "omit". See src/model-resolver.cts.
|
||||
const runtimeMarkerDest = path.join(targetDir, 'msd-core', '.msd-runtime');
|
||||
const runtimeMarkerDest = path.join(skillDest, '.msd-runtime');
|
||||
fs.writeFileSync(runtimeMarkerDest, `${runtime}\n`);
|
||||
if (verifyFileInstalled(runtimeMarkerDest, '.msd-runtime')) {
|
||||
console.log(` ${green}✓${reset} Wrote runtime marker (.msd-runtime: ${runtime})`);
|
||||
@@ -8683,6 +8875,10 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
//
|
||||
// All runtimes that use the update workflow need this, so we copy unconditionally
|
||||
// (same scope as msd-core/ itself — every runtime that installs workflows gets it).
|
||||
// scripts/ MUST be a sibling of msd-core/ (engineRoot = path.dirname(skillDest))
|
||||
// because msd-core/bin/lib/{command-roster,capability-loader}.cjs resolve
|
||||
// require('../../../scripts/...') relative to msd-core/bin/lib/.
|
||||
const engineRoot = path.dirname(skillDest);
|
||||
const changesetSrc = path.join(src, 'scripts', 'changeset');
|
||||
const scriptsLibSrc = path.join(src, 'scripts', 'lib');
|
||||
if (!fs.existsSync(changesetSrc)) {
|
||||
@@ -8690,8 +8886,8 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
// so the user knows the changelog preview will not work rather than silently degrading.
|
||||
failures.push('scripts/changeset/ (source missing from package — reinstall from npm)');
|
||||
} else {
|
||||
const changesetDest = path.join(targetDir, 'scripts', 'changeset');
|
||||
const scriptsLibDest = path.join(targetDir, 'scripts', 'lib');
|
||||
const changesetDest = path.join(engineRoot, 'scripts', 'changeset');
|
||||
const scriptsLibDest = path.join(engineRoot, 'scripts', 'lib');
|
||||
fs.mkdirSync(changesetDest, { recursive: true });
|
||||
fs.mkdirSync(scriptsLibDest, { recursive: true });
|
||||
// Copy scripts/changeset/ — all .cjs and .md files
|
||||
@@ -8731,8 +8927,8 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
// changeset CLI source is absent.
|
||||
{
|
||||
const fixSlashSrc = path.join(src, 'scripts', 'fix-slash-commands.cjs');
|
||||
const fixSlashDest = path.join(targetDir, 'scripts', 'fix-slash-commands.cjs');
|
||||
fs.mkdirSync(path.join(targetDir, 'scripts'), { recursive: true });
|
||||
const fixSlashDest = path.join(engineRoot, 'scripts', 'fix-slash-commands.cjs');
|
||||
fs.mkdirSync(path.join(engineRoot, 'scripts'), { recursive: true });
|
||||
if (!fs.existsSync(fixSlashSrc)) {
|
||||
failures.push('scripts/fix-slash-commands.cjs (source missing from package — reinstall from npm)');
|
||||
} else {
|
||||
@@ -8752,7 +8948,7 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
// gap as #1223 (fix-slash-commands.cjs) and copied unconditionally for the same reason:
|
||||
// any runtime that installs msd-core/ needs the capability system to compose.
|
||||
{
|
||||
const capGenDestDir = path.join(targetDir, 'scripts');
|
||||
const capGenDestDir = path.join(engineRoot, 'scripts');
|
||||
fs.mkdirSync(capGenDestDir, { recursive: true });
|
||||
for (const gen of ['gen-capability-registry.cjs', 'gen-loop-host-contract.cjs']) {
|
||||
const genSrc = path.join(src, 'scripts', gen);
|
||||
@@ -10020,7 +10216,7 @@ function finishInstall(settingsPath, settings, statuslineCommand, shouldInstallS
|
||||
console.log(`
|
||||
${green}Done!${reset} Restart ${program}, then in any directory either type ${cyan}${command}${reset} or ask Claude to run the ${cyan}msd-new-project${reset} skill.
|
||||
|
||||
${cyan}Join the community:${reset} https://discord.gg/mYgfVNfA2r
|
||||
${cyan}Join Golem15 on Wavepath:${reset} https://www.wavepath.org/join/0y3bklmu
|
||||
`);
|
||||
return;
|
||||
}
|
||||
@@ -10028,7 +10224,7 @@ function finishInstall(settingsPath, settings, statuslineCommand, shouldInstallS
|
||||
console.log(`
|
||||
${green}Done!${reset} Open a blank directory in ${program} and run ${cyan}${command}${reset}.
|
||||
|
||||
${cyan}Join the community:${reset} https://discord.gg/mYgfVNfA2r
|
||||
${cyan}Join Golem15 on Wavepath:${reset} https://www.wavepath.org/join/0y3bklmu
|
||||
`);
|
||||
}
|
||||
|
||||
@@ -10969,6 +11165,7 @@ module.exports = {
|
||||
configureAntigravityPermissions,
|
||||
configureAntigravityMcpConfig,
|
||||
convertClaudeToAntigravityContent,
|
||||
setAntigravityGlobalHomePrefix,
|
||||
convertClaudeCommandToAntigravitySkill,
|
||||
convertClaudeAgentToAntigravityAgent,
|
||||
convertClaudeCommandToClaudeSkill,
|
||||
|
||||
Reference in New Issue
Block a user