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 8s
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 8s
- 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:
5
.changeset/fierce-mice-roar.md
Normal file
5
.changeset/fierce-mice-roar.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
type: Fixed
|
||||
pr: 4
|
||||
---
|
||||
**Antigravity agents, workflows, and terminal sandbox work cleanly** — fixed four blockers on Antigravity CLI: (1) converted agents mapped `Glob`, `WebSearch` and `WebFetch` to names not in Antigravity's tool registry; they now map to `find_by_name`, `search_web` and `read_url_content`, and unmapped tools are dropped instead of lowercased; (2) `buildAntigravityAllowRules` emitted globbed `read_file(.../*)` / `msd-*` rules into `settings.json`, which Antigravity's terminal sandbox rejects (`globs not supported`), breaking every sandboxed command — rules now use glob-free trailing-slash directory paths (`read_file(<dir>/)`) and reinstall/uninstall strips legacy globbed rules automatically; (3) Antigravity CLI enforces a hardcoded system protection boundary across `~/.gemini/**` that blocks `read_file` on `~/.gemini/antigravity-cli/msd-core/` even when allowed in `settings.json` — global Antigravity `msd-core/` now installs outside `~/.gemini/` at `~/.msd/antigravity/msd-core/` (respecting `MSD_HOME`), with `read_file(~/.msd/antigravity/msd-core/)` in `settings.json` and matching `@~/.msd/antigravity/msd-core/...` rewrites; (4) `msd_run` and `/msd-update` now probe `~/.msd/antigravity/msd-core/` and `.agents/msd-core/`. Re-run the installer (`npx @golem15/msd-core --antigravity --global`) to heal `settings.json` and relocate `msd-core/`.
|
||||
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,
|
||||
|
||||
@@ -4,5 +4,5 @@ Use this bootstrap block when a workflow must call `msd-tools` from the active w
|
||||
Keep this resolver centralized; workflows should reference this file instead of copying the shell probe.
|
||||
|
||||
```bash
|
||||
_MSD_SHIM_NAME="msd-tools.cjs"; _MSD_RUNTIME_ROOT="${RUNTIME_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"; MSD_TOOLS="${_MSD_RUNTIME_ROOT}/msd-core/bin/${_MSD_SHIM_NAME}"; _msd_at() { for _p; do if [ -f "$_p" ]; then MSD_TOOLS="$_p"; return 0; fi; done; return 1; }; _msd_id_ok() { case "$("$1" runtime-identity --raw 2>/dev/null || true)" in '{"packageName":"@golem15/msd-core"'*'}') return 0;; *) return 1;; esac; }; _msd_homes() { _msd_at "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/msd-core/bin/${_MSD_SHIM_NAME}" "${CURSOR_CONFIG_DIR:-$HOME/.cursor}/msd-core/bin/${_MSD_SHIM_NAME}" "${CODEX_HOME:-$HOME/.codex}/msd-core/bin/${_MSD_SHIM_NAME}" "${GEMINI_CONFIG_DIR:-$HOME/.gemini}/msd-core/bin/${_MSD_SHIM_NAME}" "${GROK_AGENTS_HOME:-$HOME/.agents}/msd-core/bin/${_MSD_SHIM_NAME}" "${ANTIGRAVITY_CONFIG_DIR:-$HOME/.gemini/antigravity}/msd-core/bin/${_MSD_SHIM_NAME}" "${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/msd-core/bin/${_MSD_SHIM_NAME}"; }; if _msd_at "${_MSD_RUNTIME_ROOT}/msd-core/bin/${_MSD_SHIM_NAME}" "${_MSD_RUNTIME_ROOT}/.claude/msd-core/bin/${_MSD_SHIM_NAME}" "${_MSD_RUNTIME_ROOT}/.codex/msd-core/bin/${_MSD_SHIM_NAME}"; then msd_run() { node "$MSD_TOOLS" "$@"; }; elif _msd_homes; then msd_run() { node "$MSD_TOOLS" "$@"; }; elif unset -f msd_run; _G="$(command -v msd_run)"; [ -n "$_G" ] && _msd_id_ok "$_G"; then MSD_TOOLS="$_G"; msd_run() { "$MSD_TOOLS" "$@"; }; else echo "ERROR: msd-tools.cjs not found at $MSD_TOOLS and no identity-proving msd_run is on PATH. Run: npx -y @golem15/msd-core@latest --claude --local" >&2; exit 1; fi; MSD_IDENTITY_STATUS=unverified; _msd_id_ok msd_run && MSD_IDENTITY_STATUS=ok; export MSD_IDENTITY_STATUS; [ "$MSD_IDENTITY_STATUS" = ok ] || echo "WARNING: \"$MSD_TOOLS\" did not prove it is @golem15/msd-core - it is either a different package or an @golem15/msd-core older than the runtime-identity verb. See docs/how-to/diagnose-a-foreign-msd-tools.md" >&2; if [ -n "${CLAUDE_ENV_FILE:-}" ] && [ -n "${MSD_TOOLS:-}" ]; then printf "export PATH='%s':\"\$PATH\"\n" "${MSD_TOOLS%/*}" >> "$CLAUDE_ENV_FILE" 2>/dev/null || true; fi
|
||||
_MSD_SHIM_NAME="msd-tools.cjs"; _MSD_RUNTIME_ROOT="${RUNTIME_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"; MSD_TOOLS="${_MSD_RUNTIME_ROOT}/msd-core/bin/${_MSD_SHIM_NAME}"; _msd_at() { for _p; do if [ -f "$_p" ]; then MSD_TOOLS="$_p"; return 0; fi; done; return 1; }; _msd_id_ok() { case "$("$1" runtime-identity --raw 2>/dev/null || true)" in '{"packageName":"@golem15/msd-core"'*'}') return 0;; *) return 1;; esac; }; _msd_homes() { _msd_at "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/msd-core/bin/${_MSD_SHIM_NAME}" "${CURSOR_CONFIG_DIR:-$HOME/.cursor}/msd-core/bin/${_MSD_SHIM_NAME}" "${CODEX_HOME:-$HOME/.codex}/msd-core/bin/${_MSD_SHIM_NAME}" "${GEMINI_CONFIG_DIR:-$HOME/.gemini}/msd-core/bin/${_MSD_SHIM_NAME}" "${GROK_AGENTS_HOME:-$HOME/.agents}/msd-core/bin/${_MSD_SHIM_NAME}" "${MSD_HOME:-$HOME}/.msd/antigravity/msd-core/bin/${_MSD_SHIM_NAME}" "${ANTIGRAVITY_CONFIG_DIR:-$HOME/.gemini/antigravity-cli}/msd-core/bin/${_MSD_SHIM_NAME}" "${ANTIGRAVITY_CONFIG_DIR:-$HOME/.gemini/antigravity}/msd-core/bin/${_MSD_SHIM_NAME}" "${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/msd-core/bin/${_MSD_SHIM_NAME}"; }; if _msd_at "${_MSD_RUNTIME_ROOT}/msd-core/bin/${_MSD_SHIM_NAME}" "${_MSD_RUNTIME_ROOT}/.claude/msd-core/bin/${_MSD_SHIM_NAME}" "${_MSD_RUNTIME_ROOT}/.codex/msd-core/bin/${_MSD_SHIM_NAME}" "${_MSD_RUNTIME_ROOT}/.agents/msd-core/bin/${_MSD_SHIM_NAME}"; then msd_run() { node "$MSD_TOOLS" "$@"; }; elif _msd_homes; then msd_run() { node "$MSD_TOOLS" "$@"; }; elif unset -f msd_run; _G="$(command -v msd_run)"; [ -n "$_G" ] && _msd_id_ok "$_G"; then MSD_TOOLS="$_G"; msd_run() { "$MSD_TOOLS" "$@"; }; else echo "ERROR: msd-tools.cjs not found at $MSD_TOOLS and no identity-proving msd_run is on PATH. Run: npx -y @golem15/msd-core@latest --claude --local" >&2; exit 1; fi; MSD_IDENTITY_STATUS=unverified; _msd_id_ok msd_run && MSD_IDENTITY_STATUS=ok; export MSD_IDENTITY_STATUS; [ "$MSD_IDENTITY_STATUS" = ok ] || echo "WARNING: \"$MSD_TOOLS\" did not prove it is @golem15/msd-core - it is either a different package or an @golem15/msd-core older than the runtime-identity verb. See docs/how-to/diagnose-a-foreign-msd-tools.md" >&2; if [ -n "${CLAUDE_ENV_FILE:-}" ] && [ -n "${MSD_TOOLS:-}" ]; then printf "export PATH='%s':\"\$PATH\"\n" "${MSD_TOOLS%/*}" >> "$CLAUDE_ENV_FILE" 2>/dev/null || true; fi
|
||||
```
|
||||
|
||||
@@ -14,7 +14,7 @@ Detect the installed MSD version, scope, runtime, and config dir.
|
||||
|
||||
First, derive `PREFERRED_CONFIG_DIR` and `PREFERRED_RUNTIME` from the invoking prompt's `execution_context` path — this is the one input only the workflow knows:
|
||||
- If the path contains `/msd-core/workflows/update.md`, strip that suffix and store the remainder as `PREFERRED_CONFIG_DIR`.
|
||||
- Infer `PREFERRED_RUNTIME` from the path: `/.claude/` -> `claude`; `/.codex/` -> `codex`; `/.gemini/antigravity-ide/`, `/.gemini/antigravity-cli/`, `/.gemini/antigravity/`, `/.agents/` or `/.agent/` -> `antigravity` (`.agents` is the canonical local Antigravity install dir (#791); `.agent` is the legacy form (#503); see bin/install.js `getDirName('antigravity')`); `/.config/opencode/` or `/.opencode/` -> `opencode`; otherwise leave it empty.
|
||||
- Infer `PREFERRED_RUNTIME` from the path: `/.claude/` -> `claude`; `/.codex/` -> `codex`; `/.msd/antigravity/`, `/.gemini/antigravity-ide/`, `/.gemini/antigravity-cli/`, `/.gemini/antigravity/`, `/.agents/` or `/.agent/` -> `antigravity` (`.agents` is the canonical local Antigravity install dir (#791); `.agent` is the legacy form (#503); see bin/install.js `getDirName('antigravity')`); `/.config/opencode/` or `/.opencode/` -> `opencode`; otherwise leave it empty.
|
||||
|
||||
Then resolve the install context via the deterministic projection (#498). **Do NOT re-derive scope, runtime, or version by hand** — `update-context` owns that cascade in tested code (`msd-core/bin/lib/update-context.cjs`), the same way `check-latest-version` owns the package name (#2992):
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import { tryWithinRootLexical } from './security.cjs';
|
||||
import runtimeArtifactLayout = require('./runtime-artifact-layout.cjs');
|
||||
import runtimeArtifactInstallPlan = require('./runtime-artifact-install-plan.cjs');
|
||||
import runtimeNamePolicy = require('./runtime-name-policy.cjs');
|
||||
import runtimeHomes = require('./runtime-homes.cjs');
|
||||
import installProfiles = require('./install-profiles.cjs');
|
||||
import installerMigrations = require('./installer-migrations.cjs');
|
||||
import retiredArtifactCleanup = require('./retired-artifact-cleanup.cjs');
|
||||
@@ -140,10 +141,16 @@ function pruneEmptyCorpusParents(start: string, stop: string): void {
|
||||
}
|
||||
}
|
||||
|
||||
function syncRuntimeSurfaceCorpus(source: string, destination: string, configDir: string, manifestPrefix: string): void {
|
||||
if (hasExistingSymlinkBetween(path.resolve(configDir), destination, { allowOptInFollow: isSymlinkedDestOptIn() })) {
|
||||
function syncRuntimeSurfaceCorpus(
|
||||
source: string,
|
||||
destination: string,
|
||||
configDir: string,
|
||||
manifestPrefix: string,
|
||||
symlinkBase: string = configDir,
|
||||
): void {
|
||||
if (hasExistingSymlinkBetween(path.resolve(symlinkBase), destination, { allowOptInFollow: isSymlinkedDestOptIn() })) {
|
||||
throw new Error(
|
||||
`syncRuntimeSurfaceCorpus: destination "${destination}" contains a symlink the install root "${configDir}" does not trust — refusing to write.`,
|
||||
`syncRuntimeSurfaceCorpus: destination "${destination}" contains a symlink the install root "${symlinkBase}" does not trust — refusing to write.`,
|
||||
);
|
||||
}
|
||||
assertCorpusTreeHasNoSymlinks(destination);
|
||||
@@ -196,16 +203,25 @@ function provisionRuntimeSurfaceCorpus(
|
||||
}
|
||||
if (required.size === 0) return;
|
||||
|
||||
const corpusRoot = path.join(configDir, 'msd-core');
|
||||
const corpusRoot = runtimeHomes.resolveMsdCoreDir(
|
||||
configDir,
|
||||
layout.runtime,
|
||||
isGlobalScope(scope as InstallScope),
|
||||
);
|
||||
const resolvedConfigDir = path.resolve(configDir);
|
||||
const resolvedCorpusRoot = path.resolve(corpusRoot);
|
||||
const relCorpus = path.relative(resolvedConfigDir, resolvedCorpusRoot);
|
||||
const corpusInsideConfig = relCorpus === '' || (!relCorpus.startsWith('..') && !path.isAbsolute(relCorpus));
|
||||
const symlinkBase = corpusInsideConfig ? configDir : path.dirname(corpusRoot);
|
||||
if (required.has('commands')) {
|
||||
const source = runtimeArtifactLayout.findInstallSourceRoot();
|
||||
const destination = path.join(corpusRoot, 'commands', 'msd');
|
||||
syncRuntimeSurfaceCorpus(source, destination, configDir, 'msd-core/commands/msd/');
|
||||
syncRuntimeSurfaceCorpus(source, destination, configDir, 'msd-core/commands/msd/', symlinkBase);
|
||||
}
|
||||
if (required.has('agents')) {
|
||||
const source = path.join(executingPackageRoot(), 'agents');
|
||||
const destination = path.join(corpusRoot, 'agents');
|
||||
syncRuntimeSurfaceCorpus(source, destination, configDir, 'msd-core/agents/');
|
||||
syncRuntimeSurfaceCorpus(source, destination, configDir, 'msd-core/agents/', symlinkBase);
|
||||
}
|
||||
|
||||
const markerFile = _hostBehaviors(layout.runtime).sourceMarkerFile;
|
||||
|
||||
@@ -34,6 +34,8 @@ const { getDirName } = runtimeNamePolicy;
|
||||
import capabilityRegistry = require('./capability-registry.cjs');
|
||||
import hostIntegration = require('./host-integration.cjs');
|
||||
import { posixNormalize } from './shell-command-projection.cjs';
|
||||
// runtime-homes.cjs is leaf-tier (node builtins only) — no cycle.
|
||||
import { resolveAntigravityGlobalDir } from './runtime-homes.cjs';
|
||||
import frontmatterModule = require('./frontmatter.cjs');
|
||||
import { escapeRegex as escapeRegExp } from './pattern.cjs';
|
||||
import { scanFencedBlocks } from './markdown-sectionizer.cjs';
|
||||
@@ -395,11 +397,75 @@ function appendAgentTools(content: string, grants: string[]): string {
|
||||
return lines.join(eol);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = posixNormalize(os.homedir()).replace(/\/+$/, '');
|
||||
const dir = posixNormalize(resolveAntigravityGlobalDir());
|
||||
prefix = dir.startsWith(`${home}/`) ? `$HOME${dir.slice(home.length)}` : dir; // allow-handrolled-containment: display spelling only — picks the $HOME-relative form of an already-resolved path, no access decision
|
||||
}
|
||||
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 = posixNormalize(os.homedir()).replace(/\/+$/, '');
|
||||
if (typeof msdHomeEnv === 'string' && msdHomeEnv.trim() !== '') {
|
||||
const resolvedMsdHome = posixNormalize(msdHomeEnv).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
|
||||
@@ -410,9 +476,7 @@ 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.
|
||||
// — BEFORE the configHome rewrite below.
|
||||
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
|
||||
@@ -420,11 +484,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/');
|
||||
@@ -1012,21 +1086,24 @@ function convertClaudeToOpencodeFrontmatter(content, { isAgent = false, modelOve
|
||||
// Antigravity uses Gemini's snake_case built-in tool names
|
||||
// #4705: values are Antigravity-NATIVE tool names per the documented subagent
|
||||
// contract (antigravity.google/docs/subagents: view_file, replace_file_content,
|
||||
// grep_search, run_command are the documented examples; the catalog is
|
||||
// non-exhaustive, so unmapped entries keep their best-known grant rather than
|
||||
// being dropped — dropping would silently remove a restriction). The old
|
||||
// values were Gemini CLI dialect names, which Antigravity's tool validation
|
||||
// does not document and may hang the subagent on.
|
||||
// grep_search, run_command are the documented examples). The old values were
|
||||
// Gemini CLI dialect names, which Antigravity's tool validation does not
|
||||
// document and may hang the subagent on.
|
||||
// Every value here was checked against the Antigravity CLI 1.5.20 tool
|
||||
// registry by starting an agent that grants it. `glob`, `google_web_search`,
|
||||
// `web_fetch` and `write_todos` (the previous Glob/WebSearch/WebFetch/
|
||||
// TodoWrite values) are NOT registered there, and one unknown name stops the
|
||||
// whole agent from starting. TodoWrite has no registered equivalent, so it is
|
||||
// left unmapped and dropped by convertAntigravityToolName.
|
||||
const claudeToAntigravityTools = {
|
||||
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',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1058,12 +1135,14 @@ function convertAntigravityToolName(claudeTool) {
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
// Check for explicit mapping
|
||||
if (claudeToAntigravityTools[claudeTool]) {
|
||||
// Explicit mapping, or drop. Antigravity resolves every `tools:` entry
|
||||
// against a strict registry and refuses to start the agent on the first
|
||||
// unknown name ("unknown component: tool \"x\" not found in registry"), so a
|
||||
// lowercased guess for an unmapped tool is worse than no grant at all.
|
||||
if (Object.prototype.hasOwnProperty.call(claudeToAntigravityTools, claudeTool)) {
|
||||
return claudeToAntigravityTools[claudeTool];
|
||||
}
|
||||
// Default: lowercase
|
||||
return claudeTool.toLowerCase();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2243,6 +2322,7 @@ export = {
|
||||
extractFrontmatterField,
|
||||
skillFrontmatterName,
|
||||
convertClaudeToAntigravityContent,
|
||||
setAntigravityGlobalHomePrefix,
|
||||
convertClaudeCommandToAntigravitySkill,
|
||||
convertClaudeCommandToClaudeSkill,
|
||||
// #2873 (4b): pure, scope-free transform — applied by the one call site
|
||||
|
||||
@@ -141,6 +141,9 @@ interface RuntimeDescriptor {
|
||||
artifactLayout?: {
|
||||
global?: RuntimeArtifactKindDescriptor[];
|
||||
};
|
||||
hostBehaviors?: {
|
||||
globalDirResolver?: string;
|
||||
};
|
||||
}
|
||||
|
||||
function resolveDescriptorWithOptions(configHome: ConfigHomeDescriptor): string {
|
||||
@@ -533,3 +536,44 @@ export function getGlobalSkillDisplayPath(runtime: string, skillName: string): s
|
||||
const home = os.homedir();
|
||||
return dir.startsWith(home) ? '~' + dir.slice(home.length) : dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the directory where `msd-core/` (workflows, references, templates,
|
||||
* `bin/msd-tools.cjs`, `VERSION`, `CHANGELOG.md`, `.msd-runtime`) is installed.
|
||||
*
|
||||
* For Antigravity global installs whose `configDir` sits under `~/.gemini/`
|
||||
* (`~/.gemini/antigravity{,-ide,-cli}`), Antigravity CLI enforces a hardcoded
|
||||
* system protection boundary across `~/.gemini/**` that blocks `read_file`
|
||||
* even when `permissions.allow` permits it. Relocating `msd-core/` outside
|
||||
* `~/.gemini/` to `$MSD_HOME/.msd/antigravity/msd-core` (default
|
||||
* `~/.msd/antigravity/msd-core`) keeps workflow/reference files readable and
|
||||
* mountable read-only in the terminal sandbox via `read_file(~/.msd/antigravity/msd-core/)`.
|
||||
*
|
||||
* Local installs (`./.agents/msd-core`) and explicit `--config-dir` targets
|
||||
* outside `~/.gemini/` keep `msd-core/` inside `configDir`.
|
||||
*/
|
||||
export function resolveMsdCoreDir(
|
||||
configDir: string,
|
||||
runtime: string,
|
||||
isGlobal: boolean,
|
||||
opts: { env?: Record<string, string | undefined>; home?: string } = {},
|
||||
): string {
|
||||
const runtimeEntry = getRegistry().runtimes[runtime];
|
||||
const isAntigravity = runtimeEntry?.runtime?.hostBehaviors?.globalDirResolver === 'antigravity';
|
||||
if (isAntigravity && isGlobal) {
|
||||
const env = opts.env ?? process.env;
|
||||
const home = opts.home ?? os.homedir();
|
||||
const resolvedTarget = path.resolve(configDir);
|
||||
const geminiRoot = path.resolve(home, '.gemini');
|
||||
const rel = path.relative(geminiRoot, resolvedTarget);
|
||||
const isInsideGemini = rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
|
||||
if (isInsideGemini) {
|
||||
const msdHomeVal = env['MSD_HOME'];
|
||||
const msdHome = hasNonBlankOverride(msdHomeVal)
|
||||
? expandTilde(msdHomeVal, home)
|
||||
: home;
|
||||
return path.join(msdHome, '.msd', 'antigravity', 'msd-core');
|
||||
}
|
||||
}
|
||||
return path.join(configDir, 'msd-core');
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ export const RUNTIME_DIRS: RuntimeDirEntry[] = [
|
||||
['claude', '.claude'],
|
||||
['opencode', '.config/opencode'],
|
||||
['opencode', '.opencode'],
|
||||
['antigravity', '.msd/antigravity'],
|
||||
['antigravity', '.gemini/antigravity-ide'],
|
||||
['antigravity', '.gemini/antigravity-cli'],
|
||||
['antigravity', '.gemini/antigravity'],
|
||||
|
||||
@@ -74,13 +74,22 @@ test('toTildePosixPath leaves a non-homedir path as an absolute posix path', ()
|
||||
assert.equal(toTildePosixPath('/var/tmp/some-config-dir'), '/var/tmp/some-config-dir');
|
||||
});
|
||||
|
||||
test('buildAntigravityAllowRules emits the 4 documented "action(target)" rule strings', () => {
|
||||
test('buildAntigravityAllowRules emits glob-free trailing-slash "action(target)" rule strings', () => {
|
||||
const rules = buildAntigravityAllowRules('/tmp/ag-config');
|
||||
assert.deepEqual(rules, [
|
||||
'read_file(/tmp/ag-config/msd-core/*)',
|
||||
'read_file(/tmp/ag-config/agents/msd-*)',
|
||||
'read_file(/tmp/ag-config/skills/msd-*)',
|
||||
'command(node /tmp/ag-config/hooks/*)',
|
||||
'read_file(/tmp/ag-config/msd-core/)',
|
||||
'command(node /tmp/ag-config/hooks/)',
|
||||
]);
|
||||
for (const rule of rules) {
|
||||
assert.ok(!rule.includes('*'), `Antigravity allow rule must not contain globs (breaks terminal sandbox): ${rule}`);
|
||||
}
|
||||
});
|
||||
|
||||
test('buildAntigravityAllowRules accepts a relocated msdCoreDir outside ~/.gemini/ and grants the engine root', () => {
|
||||
const rules = buildAntigravityAllowRules('/home/u/.gemini/antigravity-cli', '/home/u/.msd/antigravity/msd-core');
|
||||
assert.deepEqual(rules, [
|
||||
'read_file(/home/u/.msd/antigravity/)',
|
||||
'command(node /home/u/.gemini/antigravity-cli/hooks/)',
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -89,7 +98,7 @@ test('buildAntigravityAllowRules emits the 4 documented "action(target)" rule st
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
for (const scope of ['global', 'local']) {
|
||||
test(`antigravity --${scope}: settings.json permissions.allow contains MSD's rules (UPGRADE 1)`, (t) => {
|
||||
test(`antigravity --${scope}: settings.json permissions.allow contains MSD's glob-free rules (UPGRADE 1)`, (t) => {
|
||||
const { configDir, root } = runMinimalInstall({ runtime: 'antigravity', scope });
|
||||
t.after(() => cleanup(root));
|
||||
|
||||
@@ -99,32 +108,69 @@ for (const scope of ['global', 'local']) {
|
||||
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
||||
assert.ok(settings.permissions && Array.isArray(settings.permissions.allow), 'permissions.allow must be an array');
|
||||
|
||||
// Asserting on the exact rule strings here would require reproducing
|
||||
// toTildePosixPath's os.homedir()-relative substitution from OUTSIDE the
|
||||
// spawned installer subprocess: runMinimalInstall overrides that
|
||||
// subprocess's HOME to `root`, so for --global (configDir === root ===
|
||||
// that subprocess's HOME) every rule collapses to the bare `~/...` form,
|
||||
// while THIS test process's own (unrelated, real) os.homedir() would
|
||||
// reconstruct full absolute paths instead — a guaranteed mismatch that
|
||||
// has nothing to do with correctness. Assert on the documented rule
|
||||
// SHAPE (action + path suffix) instead, which holds regardless of
|
||||
// whether the prefix collapsed to `~` or stayed a full absolute path.
|
||||
const expectedShapes = [
|
||||
{ action: 'read_file(', suffix: '/msd-core/*)' },
|
||||
{ action: 'read_file(', suffix: '/agents/msd-*)' },
|
||||
{ action: 'read_file(', suffix: '/skills/msd-*)' },
|
||||
{ action: 'command(node ', suffix: '/hooks/*)' },
|
||||
{ action: 'read_file(', suffix: scope === 'global' ? '/.msd/antigravity/)' : '/msd-core/)' },
|
||||
{ action: 'command(node ', suffix: '/hooks/)' },
|
||||
];
|
||||
for (const { action, suffix } of expectedShapes) {
|
||||
const found = settings.permissions.allow.some((rule) => rule.startsWith(action) && rule.endsWith(suffix));
|
||||
assert.ok(found, `permissions.allow must include a rule shaped like "${action}...${suffix}" — got ${JSON.stringify(settings.permissions.allow)}`);
|
||||
}
|
||||
// Terminal sandbox rejects both globs and ~-prefixed paths in readonly (read_file) allow rules.
|
||||
for (const rule of settings.permissions.allow) {
|
||||
assert.ok(!rule.includes('*'), `permissions.allow must never emit globbed rules — got ${rule}`);
|
||||
if (rule.startsWith('read_file(')) {
|
||||
assert.ok(!rule.startsWith('read_file(~'), `read_file() allow rule must be absolute (sandbox rejects ~): ${rule}`);
|
||||
}
|
||||
}
|
||||
// Priority-scoping (deny/ask) is a user-owned decision — MSD never writes it.
|
||||
assert.equal(settings.permissions.deny, undefined, 'MSD must never write permissions.deny');
|
||||
assert.equal(settings.permissions.ask, undefined, 'MSD must never write permissions.ask');
|
||||
|
||||
// Installed msd-tools.cjs must boot cleanly (sibling scripts/fix-slash-commands.cjs must land beside msd-core/).
|
||||
const msdToolsPath = scope === 'global'
|
||||
? path.join(root, '.msd', 'antigravity', 'msd-core', 'bin', 'msd-tools.cjs')
|
||||
: path.join(configDir, 'msd-core', 'bin', 'msd-tools.cjs');
|
||||
const idRes = spawnSync(process.execPath, [msdToolsPath, 'runtime-identity', '--raw'], {
|
||||
encoding: 'utf-8',
|
||||
timeout: PROBE_TIMEOUT_MS,
|
||||
});
|
||||
assert.strictEqual(idRes.status, 0, `installed msd-tools.cjs must run cleanly; stderr: ${idRes.stderr}`);
|
||||
assert.ok(idRes.stdout.includes(PACKAGE_NAME), `runtime-identity must report ${PACKAGE_NAME}, got: ${idRes.stdout}`);
|
||||
});
|
||||
}
|
||||
|
||||
test('configureAntigravityPermissions strips legacy globbed and tilde-prefixed rules that break the terminal sandbox', (t) => {
|
||||
const root = fs.mkdtempSync(path.join(require('node:os').tmpdir(), 'msd-ag-perm-legacy-'));
|
||||
t.after(() => cleanup(root));
|
||||
|
||||
fs.writeFileSync(path.join(root, 'settings.json'), JSON.stringify({
|
||||
permissions: {
|
||||
allow: [
|
||||
'command(git)',
|
||||
'read_file(~/.gemini/antigravity-cli/msd-core/*)',
|
||||
'read_file(~/.gemini/antigravity-cli/agents/msd-*)',
|
||||
'read_file(~/.gemini/antigravity-cli/skills/msd-*)',
|
||||
'command(node ~/.gemini/antigravity-cli/hooks/*)',
|
||||
'read_file(~/.msd/antigravity/msd-core/)',
|
||||
'command(node ~/.gemini/antigravity-cli/hooks/)',
|
||||
`read_file(${root}/msd-core/*)`,
|
||||
],
|
||||
},
|
||||
}, null, 2));
|
||||
|
||||
configureAntigravityPermissions(true, root);
|
||||
|
||||
const settings = JSON.parse(fs.readFileSync(path.join(root, 'settings.json'), 'utf8'));
|
||||
assert.ok(settings.permissions.allow.includes('command(git)'), 'unrelated user rule preserved');
|
||||
for (const rule of settings.permissions.allow) {
|
||||
assert.ok(!rule.includes('*'), `legacy glob rule must be stripped: ${rule}`);
|
||||
assert.ok(!rule.includes('~/'), `legacy tilde rule must be stripped: ${rule}`);
|
||||
}
|
||||
assert.ok(settings.permissions.allow.includes(`read_file(${root}/msd-core/)`));
|
||||
assert.ok(settings.permissions.allow.includes(`command(node ${root}/hooks/)`));
|
||||
});
|
||||
|
||||
test('configureAntigravityPermissions is idempotent — a second call adds no duplicate rules', (t) => {
|
||||
const root = fs.mkdtempSync(path.join(require('node:os').tmpdir(), 'msd-ag-perm-idem-'));
|
||||
t.after(() => cleanup(root));
|
||||
|
||||
@@ -223,7 +223,7 @@ describe('#1928 Antigravity preserved (shared surface with the removed gemini ru
|
||||
const toolsBlock = result.slice(result.indexOf('tools:')).split('\n').filter((l) => l.startsWith('- '));
|
||||
assert.ok(toolsBlock.includes('- view_file'), 'Read → view_file (native name, #4705)');
|
||||
assert.ok(toolsBlock.includes('- write_file'), 'Write → write_file');
|
||||
assert.ok(toolsBlock.includes('- web_fetch'), 'WebFetch → web_fetch');
|
||||
assert.ok(toolsBlock.includes('- read_url_content'), 'WebFetch → read_url_content');
|
||||
assert.ok(!toolsBlock.some((l) => /\bskill\b/.test(l)), 'Skill is still excluded (would be an invalid backend tool name)');
|
||||
});
|
||||
|
||||
@@ -251,8 +251,10 @@ describe('#1928 Antigravity preserved (shared surface with the removed gemini ru
|
||||
'the retired gemini-named function must not still be exported — a surviving alias means the rename never finished',
|
||||
);
|
||||
|
||||
// The #4727 rename remains a pure identifier change: same KEYS, same shape
|
||||
// (an added OR removed key still fails). The VALUES moved from the Gemini
|
||||
// The #4727 rename remains a pure identifier change (an added OR removed
|
||||
// key still fails). TodoWrite left the map on purpose: Antigravity has no
|
||||
// registered equivalent, and its old `write_todos` value stopped agents
|
||||
// from starting. The VALUES moved from the Gemini
|
||||
// CLI dialect to Antigravity-native names in #4705 — Antigravity's own
|
||||
// documented subagent contract (antigravity.google/docs/subagents) names
|
||||
// view_file / replace_file_content / grep_search / run_command as native,
|
||||
@@ -264,12 +266,11 @@ describe('#1928 Antigravity preserved (shared surface with the removed gemini ru
|
||||
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',
|
||||
}, 'the tool map keys are the #4727 rename surface (add/remove still fails); the VALUES are the #4705 Antigravity-native vocabulary');
|
||||
WebSearch: 'search_web',
|
||||
WebFetch: 'read_url_content',
|
||||
}, 'the tool map keys are the #4727 rename surface (add/remove still fails); the VALUES are names the Antigravity tool registry resolves');
|
||||
|
||||
// In-set / out-of-set boundary pair: the excluded ids still return null individually...
|
||||
for (const excluded of ['mcp__anything', 'Task', 'Agent', 'AskUserQuestion', 'ask_user', 'Skill', 'SlashCommand']) {
|
||||
@@ -279,12 +280,16 @@ describe('#1928 Antigravity preserved (shared surface with the removed gemini ru
|
||||
`${excluded} must still be excluded from the Antigravity tool dialect after the rename`,
|
||||
);
|
||||
}
|
||||
// ...and an unmapped name still falls through to the lowercase default.
|
||||
assert.strictEqual(
|
||||
mod.convertAntigravityToolName('SomeOtherTool'),
|
||||
'someothertool',
|
||||
'an unmapped tool name must still lowercase-fallback after the rename',
|
||||
);
|
||||
// ...and an unmapped name is dropped too: Antigravity refuses to start an
|
||||
// agent that grants a name its registry does not know, so a lowercased
|
||||
// guess would break the agent.
|
||||
for (const unmapped of ['SomeOtherTool', 'TodoWrite', 'constructor']) {
|
||||
assert.strictEqual(
|
||||
mod.convertAntigravityToolName(unmapped),
|
||||
null,
|
||||
`${unmapped} has no registered Antigravity tool and must be dropped`,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1166,10 +1166,41 @@ process.env.MSD_TEST_MODE = '1';
|
||||
const { describe, test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
const { convertClaudeToAntigravityContent } = require('../bin/install.js');
|
||||
const { convertClaudeToAntigravityContent, setAntigravityGlobalHomePrefix } = require('../bin/install.js');
|
||||
|
||||
describe('convertClaudeToAntigravityContent bare path replacement (#2418)', () => {
|
||||
describe('global install', () => {
|
||||
// The converter writes the configHome the installer resolved. Pin it so
|
||||
// these assertions do not depend on which ~/.gemini/antigravity* dirs the
|
||||
// machine running the tests happens to have.
|
||||
const { beforeEach, afterEach } = require('node:test');
|
||||
beforeEach(() => setAntigravityGlobalHomePrefix('$HOME/.gemini/antigravity/'));
|
||||
afterEach(() => setAntigravityGlobalHomePrefix(null));
|
||||
|
||||
test('routes msd-core outside ~/.gemini/ and keeps non-msd-core configHome refs pinned', () => {
|
||||
setAntigravityGlobalHomePrefix('$HOME/.gemini/antigravity-cli/');
|
||||
const result = convertClaudeToAntigravityContent(
|
||||
'@~/.claude/msd-core/workflows/ui-phase.md\nnode "$HOME/.claude/msd-core/bin/msd-tools.cjs"\ndir = ~/.claude',
|
||||
true,
|
||||
);
|
||||
assert.strictEqual(
|
||||
result,
|
||||
'@~/.msd/antigravity/msd-core/workflows/ui-phase.md\nnode "$HOME/.msd/antigravity/msd-core/bin/msd-tools.cjs"\ndir = ~/.gemini/antigravity-cli',
|
||||
);
|
||||
});
|
||||
|
||||
test('an explicit config dir outside the home directory is written as an absolute path', () => {
|
||||
setAntigravityGlobalHomePrefix('/opt/agy-work/');
|
||||
const result = convertClaudeToAntigravityContent('@~/.claude/msd-core/x.md and $HOME/.claude/msd-core/y.md', true);
|
||||
assert.strictEqual(result, '@/opt/agy-work/msd-core/x.md and /opt/agy-work/msd-core/y.md');
|
||||
});
|
||||
|
||||
test('the pin does not move the skills dir or affect local installs', () => {
|
||||
setAntigravityGlobalHomePrefix('$HOME/.gemini/antigravity-cli/');
|
||||
assert.strictEqual(convertClaudeToAntigravityContent('ls ~/.claude/skills/', true), 'ls ~/.gemini/config/skills/');
|
||||
assert.strictEqual(convertClaudeToAntigravityContent('See ~/.claude/msd-core/', false), 'See .agents/msd-core/');
|
||||
});
|
||||
|
||||
test('replaces ~/.claude (bare, no trailing slash) with ~/.gemini/antigravity', () => {
|
||||
const input = 'configDir = ~/.claude';
|
||||
const result = convertClaudeToAntigravityContent(input, true);
|
||||
@@ -1209,7 +1240,7 @@ describe('convertClaudeToAntigravityContent bare path replacement (#2418)', () =
|
||||
const input = 'See ~/.claude/msd-core/workflows/';
|
||||
const result = convertClaudeToAntigravityContent(input, true);
|
||||
assert.ok(
|
||||
result.includes('~/.gemini/antigravity/msd-core/workflows/'),
|
||||
result.includes('~/.msd/antigravity/msd-core/workflows/'),
|
||||
`Expected path with trailing slash to be replaced, got: ${result}`
|
||||
);
|
||||
assert.ok(!result.includes('~/.claude/'), `Expected ~/ .claude/ to be fully replaced, got: ${result}`);
|
||||
@@ -1219,7 +1250,7 @@ describe('convertClaudeToAntigravityContent bare path replacement (#2418)', () =
|
||||
const input = 'See ~/.claude/msd-core/';
|
||||
const result = convertClaudeToAntigravityContent(input, true);
|
||||
// Result should contain exactly one occurrence of the replacement path
|
||||
const count = (result.match(/~\/.gemini\/antigravity\//g) || []).length;
|
||||
const count = (result.match(/~\/\.msd\/antigravity\/msd-core\//g) || []).length;
|
||||
assert.strictEqual(count, 1, `Expected exactly 1 replacement, got ${count} in: ${result}`);
|
||||
});
|
||||
|
||||
@@ -1262,12 +1293,12 @@ describe('convertClaudeToAntigravityContent bare path replacement (#2418)', () =
|
||||
);
|
||||
});
|
||||
|
||||
test('keeps msd-core references under ~/.gemini/antigravity when a skills ref is present (#3738)', () => {
|
||||
test('routes msd-core references to ~/.msd/antigravity/msd-core when a skills ref is present (#3738)', () => {
|
||||
const input = 'Read ~/.claude/msd-core/workflows/x.md then list ~/.claude/skills/.';
|
||||
const result = convertClaudeToAntigravityContent(input, true);
|
||||
assert.ok(
|
||||
result.includes('~/.gemini/antigravity/msd-core/workflows/x.md'),
|
||||
`msd-core ref must stay under configHome, got: ${result}`
|
||||
result.includes('~/.msd/antigravity/msd-core/workflows/x.md'),
|
||||
`msd-core ref must live outside ~/.gemini/, got: ${result}`
|
||||
);
|
||||
assert.ok(
|
||||
result.includes('~/.gemini/config/skills/'),
|
||||
@@ -5909,6 +5940,49 @@ describe('#3738: antigravity global artifacts install under ~/.gemini/config', (
|
||||
'no agents dir may be created under the CLI configHome — agy never reads it (#3747 silent drop)'
|
||||
);
|
||||
});
|
||||
|
||||
// The engine (msd-core/workflows, references, bin) installs into the resolved
|
||||
// Skill and agent bodies must reference ~/.msd/antigravity/msd-core/ (outside
|
||||
// ~/.gemini/, which Antigravity CLI protects with a hardcoded boundary rule)
|
||||
// and must never point at ~/.gemini/antigravity{,-ide,-cli}/msd-core/.
|
||||
test('CLI-only install: skill and agent bodies reference ~/.msd/antigravity/msd-core/, not ~/.gemini/antigravity*', (t) => {
|
||||
const { resolveAntigravityGlobalDir } = require('../msd-core/bin/lib/runtime-homes.cjs');
|
||||
const home = createTempDir('msd-antigravity-cli-refs-');
|
||||
t.after(() => cleanup(home));
|
||||
sandboxHome(t, home);
|
||||
|
||||
const cliConfigHome = path.join(home, '.gemini', 'antigravity-cli');
|
||||
fs.mkdirSync(cliConfigHome, { recursive: true });
|
||||
const resolved = resolveAntigravityGlobalDir({ home, env: {}, existsSync: fs.existsSync });
|
||||
assert.strictEqual(resolved, cliConfigHome, 'test premise: configHome resolves to the CLI dir');
|
||||
|
||||
installRuntimeArtifacts('antigravity', resolved, 'global', RESOLVED_CORE);
|
||||
|
||||
const discoveryHome = path.join(home, '.gemini', 'config');
|
||||
const bodies = [];
|
||||
for (const dir of fs.readdirSync(path.join(discoveryHome, 'skills'))) {
|
||||
bodies.push(path.join(discoveryHome, 'skills', dir, 'SKILL.md'));
|
||||
}
|
||||
for (const file of fs.readdirSync(path.join(discoveryHome, 'agents'))) {
|
||||
bodies.push(path.join(discoveryHome, 'agents', file));
|
||||
}
|
||||
// allow-test-rule: source-text-is-the-product — installed prompt bodies are the emitted artifact.
|
||||
const validEngineRef = /(?:~|\$HOME)\/\.msd\/antigravity\/msd-core\//g;
|
||||
const blockedGeminiRef = /(?:~|\$HOME)\/\.gemini\/antigravity(?:-ide|-cli)?\/msd-core\//g;
|
||||
const wrong = [];
|
||||
let total = 0;
|
||||
for (const file of bodies.filter((f) => fs.existsSync(f))) {
|
||||
const text = fs.readFileSync(file, 'utf8');
|
||||
for (const _match of text.matchAll(validEngineRef)) {
|
||||
total += 1;
|
||||
}
|
||||
for (const match of text.matchAll(blockedGeminiRef)) {
|
||||
wrong.push(`${path.relative(discoveryHome, file)}: ${match[0]}`);
|
||||
}
|
||||
}
|
||||
assert.ok(total > 0, 'test premise: installed bodies reference the msd-core engine at ~/.msd/antigravity/msd-core/');
|
||||
assert.deepStrictEqual(wrong, [], 'no engine reference may point inside ~/.gemini/antigravity* (blocked by AGY protection boundary)');
|
||||
});
|
||||
});
|
||||
|
||||
// ── #4667 — codex installs must not keep @~/.claude includes ──────────────────
|
||||
|
||||
@@ -300,7 +300,7 @@ tools: Read, Write, Bash, Skill, WebFetch, SlashCommand
|
||||
const toolsItems = result.split('\n').filter(l => l.startsWith('- ')).map(l => l.slice(2));
|
||||
|
||||
assert.ok(toolsItems.includes('view_file'), 'maps Read -> view_file (#4705 native name)');
|
||||
assert.ok(toolsItems.includes('web_fetch'), 'maps WebFetch -> web_fetch');
|
||||
assert.ok(toolsItems.includes('read_url_content'), 'maps WebFetch -> read_url_content');
|
||||
assert.ok(!toolsItems.some(t => /\bskill\b/.test(t)), 'no invalid skill tool in Antigravity frontmatter');
|
||||
assert.ok(!toolsItems.some(t => /\bslashcommand\b/.test(t)), 'no invalid slashcommand tool in Antigravity frontmatter');
|
||||
});
|
||||
@@ -2455,10 +2455,42 @@ Inspect source files.`;
|
||||
assert.ok(!/- replace\b/.test(result), 'the Gemini CLI name replace must not survive');
|
||||
});
|
||||
|
||||
test('unmapped tools keep their lowercase grant (no silent restriction drop) (#4705)', () => {
|
||||
// Antigravity CLI resolves every `tools:` entry against a strict registry and
|
||||
// refuses to start the agent on the first unknown name ("unknown component:
|
||||
// tool \"glob\" not found in registry"). glob / google_web_search / web_fetch
|
||||
// were Gemini CLI names that registry does not carry.
|
||||
const toolItems = (result) => result.split('\n').filter((l) => l.startsWith('- ')).map((l) => l.slice(2));
|
||||
|
||||
test('Glob, WebSearch and WebFetch map to names the Antigravity registry resolves', () => {
|
||||
const result = convertClaudeAgentToAntigravityAgent(
|
||||
`---\nname: e\ndescription: d\ntools: Glob, WebFetch\n---\n\nbody`);
|
||||
assert.match(result, /- glob/, 'undocumented tools keep their mapped/lowercase grant');
|
||||
assert.match(result, /- web_fetch/, 'WebFetch stays granted');
|
||||
`---\nname: e\ndescription: d\ntools: Glob, WebSearch, WebFetch\n---\n\nbody`);
|
||||
assert.deepStrictEqual(toolItems(result), ['find_by_name', 'search_web', 'read_url_content']);
|
||||
});
|
||||
|
||||
test('a tool with no registered Antigravity equivalent is dropped, not lowercased', () => {
|
||||
const result = convertClaudeAgentToAntigravityAgent(
|
||||
`---\nname: e\ndescription: d\ntools: Read, TodoWrite, NotebookEdit\n---\n\nbody`);
|
||||
assert.deepStrictEqual(toolItems(result), ['view_file'],
|
||||
'an unknown name in tools: stops the whole agent from starting, so unmapped tools must not be emitted');
|
||||
});
|
||||
|
||||
test('every shipped MSD agent converts to registered Antigravity tool names only', () => {
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const agentsDir = path.join(__dirname, '..', 'agents');
|
||||
// Names confirmed against the Antigravity CLI tool registry.
|
||||
const registered = new Set([
|
||||
'view_file', 'write_file', 'replace_file_content', 'run_command',
|
||||
'grep_search', 'find_by_name', 'search_web', 'read_url_content',
|
||||
]);
|
||||
const offenders = [];
|
||||
for (const file of fs.readdirSync(agentsDir).filter((f) => f.endsWith('.md'))) {
|
||||
const converted = convertClaudeAgentToAntigravityAgent(fs.readFileSync(path.join(agentsDir, file), 'utf8'), true);
|
||||
const frontmatter = converted.slice(0, converted.indexOf('\n---', 4));
|
||||
for (const tool of toolItems(frontmatter)) {
|
||||
if (!registered.has(tool)) offenders.push(`${file}: ${tool}`);
|
||||
}
|
||||
}
|
||||
assert.deepStrictEqual(offenders, []);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user