From 9dfa26f24d9f03cec33a49cff429cbdfb9168a8a Mon Sep 17 00:00:00 2001 From: MohamedAfrash Date: Thu, 24 Sep 2026 03:36:29 +0100 Subject: [PATCH] fix(antigravity): route global workflows to config dir and quote bridgeScript on windows --- docs/ANTIGRAVITY-GUIDE.md | 19 ++++++++++--------- docs/releases/2.2.0/release-notes.md | 2 +- scripts/lib/antigravity-hooks.js | 2 +- scripts/lib/install-lifecycle.js | 13 ++++++++++--- scripts/lib/install-manifests.js | 1 + .../lib/install-targets/antigravity-home.js | 13 ++++++++++++- scripts/lib/install-targets/helpers.js | 7 +++++++ scripts/lib/install-targets/registry.js | 4 ++++ scripts/lib/install/apply.js | 14 ++++++++++++-- scripts/lib/install/plan.js | 1 + scripts/lib/multi-harness-setup.js | 8 ++++++-- tests/lib/antigravity-tier1.test.js | 4 +++- 12 files changed, 68 insertions(+), 20 deletions(-) diff --git a/docs/ANTIGRAVITY-GUIDE.md b/docs/ANTIGRAVITY-GUIDE.md index 2637f1acd..b498492e7 100644 --- a/docs/ANTIGRAVITY-GUIDE.md +++ b/docs/ANTIGRAVITY-GUIDE.md @@ -155,7 +155,7 @@ node "$EccRoot\scripts\uninstall.js" --target antigravity --dry-run Antigravity supports global plugins located in `~/.gemini/config/plugins//`. Installing ECC as a native Antigravity plugin enables: 1. **Global Scope**: ECC rules, skills, agents, workflows, and memory MCP are active across all projects automatically, without requiring a `.agents/` folder in every repository. -2. **Lifecycle Hooks (`hooks.json`)**: Full support for `PreToolUse` (command security gates, file modification guards) `PostToolUse` edit tracking, and `Stop` formatting and diagnostics using Antigravity's protojson protocol (`{ decision, reason }`). +2. **Lifecycle Hooks (`hooks.json`)**: Full support for `PreToolUse` (command security gates, file modification guards), `PostToolUse` edit tracking, and `Stop` formatting and diagnostics using Antigravity's protojson protocol (`{ decision, reason }`). 3. **Shared Memory Vault (`mcp_config.json`)**: Direct integration with `ecc-memory-mcp` across all Antigravity sessions. 4. **Native Plugin Manifest (`plugin.json`)**: Declares the ECC plugin metadata. @@ -182,15 +182,16 @@ with `--target antigravity`. Use `--no-hooks` to omit automatic hooks. ### Global Plugin Structure ```text -~/.gemini/config/plugins/ecc/ -├── plugin.json # Antigravity plugin manifest -├── hooks.json # PreToolUse, PostToolUse, and Stop hooks -├── mcp_config.json # Shared ECC Memory Vault MCP server -├── rules/ # Rules applied to all workspaces +~/.gemini/config/ ├── workflows/ # Global slash workflows -├── skills/ # Global Agent Skills -├── scripts/ # Hook bridge and memory runtime -└── node_modules/ # Memory server dependencies +└── plugins/ecc/ + ├── plugin.json # Antigravity plugin manifest + ├── hooks.json # PreToolUse, PostToolUse, and Stop hooks + ├── mcp_config.json # Shared ECC Memory Vault MCP server + ├── rules/ # Rules applied to all workspaces + ├── skills/ # Global Agent Skills + ├── scripts/ # Hook bridge and memory runtime + └── node_modules/ # Memory server dependencies ``` ## Official Antigravity references diff --git a/docs/releases/2.2.0/release-notes.md b/docs/releases/2.2.0/release-notes.md index 6aa336ddf..447cd6379 100644 --- a/docs/releases/2.2.0/release-notes.md +++ b/docs/releases/2.2.0/release-notes.md @@ -32,7 +32,7 @@ Install or update the published package, then run the same ECC install command y ```bash npm install -g ecc-universal@2.2.0 -ecc install --target antigravity --profile full +ecc install --target antigravity --profile full --enable-hooks ``` Use `ecc doctor --target ` after installation. For Antigravity, start a new conversation and verify workspace skills under Settings > Customizations. diff --git a/scripts/lib/antigravity-hooks.js b/scripts/lib/antigravity-hooks.js index 9b301b6b9..cc496665c 100644 --- a/scripts/lib/antigravity-hooks.js +++ b/scripts/lib/antigravity-hooks.js @@ -22,7 +22,7 @@ function buildAntigravityHooksConfig(options = {}) { if (/[%"!$`\r\n]/.test(bridgeScript)) { throw new Error('bridgeScript contains unsafe shell expansion characters'); } - quotedBridgeScript = bridgeScript.includes(' ') ? `"${bridgeScript}"` : bridgeScript; + quotedBridgeScript = `"${bridgeScript}"`; } else { quotedBridgeScript = shellQuote(bridgeScript); } diff --git a/scripts/lib/install-lifecycle.js b/scripts/lib/install-lifecycle.js index 7da0ae78a..f54809513 100644 --- a/scripts/lib/install-lifecycle.js +++ b/scripts/lib/install-lifecycle.js @@ -7,7 +7,7 @@ const { isDeepStrictEqual } = require('util'); const { loadInstallManifests } = require('./install-manifests'); const { readInstallState, validateInstallState } = require('./install-state'); -const { assertWithinTrustedRoot } = require('./path-safety'); +const { assertWithinTrustedRoot, isWithinRoot } = require('./path-safety'); const { createInstallPlanFromRequest } = require('./install/runtime'); const { assertNoNewUserOwnedFile, prepareUserOwnedFileGuard } = require('./install/ownership-guard'); const { isCodexUserConfig } = require('./install/codex-user-config'); @@ -2364,8 +2364,14 @@ function uninstallInstalledStates(options = {}) { ); } + const adapter = record.adapter && getInstallTargetAdapter(record.adapter.id || record.adapter.target); + const trustedRoots = adapter && typeof adapter.resolveTrustedRoots === 'function' + ? adapter.resolveTrustedRoots({ homeDir: options.homeDir, projectRoot: options.projectRoot }) + : [record.targetRoot]; + for (const operation of operations) { - const outcome = executeUninstallOperation(operation, record.targetRoot, { + const matchingRoot = trustedRoots.find(root => isWithinRoot(operation.destinationPath, root)) || record.targetRoot; + const outcome = executeUninstallOperation(operation, matchingRoot, { preserveDriftedCopies: true, target: record.adapter.target, settingsLockHeld: Boolean(releaseSettingsLock), @@ -2389,7 +2395,8 @@ function uninstallInstalledStates(options = {}) { } for (const cleanupTarget of cleanupTargets) { - cleanupEmptyParentDirs(cleanupTarget, record.targetRoot); + const matchingRoot = trustedRoots.find(root => isWithinRoot(cleanupTarget, root)) || record.targetRoot; + cleanupEmptyParentDirs(cleanupTarget, matchingRoot); } return { diff --git a/scripts/lib/install-manifests.js b/scripts/lib/install-manifests.js index 926948f34..f77a476d5 100644 --- a/scripts/lib/install-manifests.js +++ b/scripts/lib/install-manifests.js @@ -741,6 +741,7 @@ function resolveInstallPlan(options = {}) { targetAdapterId: scaffoldPlan ? scaffoldPlan.adapter.id : null, homeDir: targetPlanningInput ? targetPlanningInput.homeDir : null, targetRoot: scaffoldPlan ? scaffoldPlan.targetRoot : null, + trustedRoots: scaffoldPlan ? scaffoldPlan.trustedRoots : (scaffoldPlan?.targetRoot ? [scaffoldPlan.targetRoot] : []), installStatePath: scaffoldPlan ? scaffoldPlan.installStatePath : null, operations: scaffoldPlan ? scaffoldPlan.operations : [], }; diff --git a/scripts/lib/install-targets/antigravity-home.js b/scripts/lib/install-targets/antigravity-home.js index 5e362718d..2be18d0d9 100644 --- a/scripts/lib/install-targets/antigravity-home.js +++ b/scripts/lib/install-targets/antigravity-home.js @@ -39,6 +39,13 @@ module.exports = createInstallTargetAdapter({ installStatePathSegments: ['ecc-install-state.json'], nativeRootRelativePath: '.gemini', excludedSourcePaths: HOME_INSTALL_EXCLUDED_SOURCE_PATHS, + resolveTrustedRoots(input, targetRoot) { + const workflowsRoot = path.join( + path.dirname(path.dirname(targetRoot)), + 'workflows' + ); + return [targetRoot, workflowsRoot]; + }, planOperations(input, adapter) { const modules = Array.isArray(input.modules) ? input.modules @@ -81,11 +88,15 @@ module.exports = createInstallTargetAdapter({ const commandRelativePath = normalizedSourcePath === 'commands' ? '' : normalizedSourcePath.slice('commands/'.length); + const workflowsRoot = path.join( + path.dirname(path.dirname(targetRoot)), + 'workflows' + ); return [ createManagedScaffoldOperation( module.id, normalizedSourcePath, - path.join(targetRoot, 'workflows', commandRelativePath), + path.join(workflowsRoot, commandRelativePath), 'preserve-relative-path' ), ]; diff --git a/scripts/lib/install-targets/helpers.js b/scripts/lib/install-targets/helpers.js index 5df5ae1c4..dca6b4481 100644 --- a/scripts/lib/install-targets/helpers.js +++ b/scripts/lib/install-targets/helpers.js @@ -329,6 +329,13 @@ function createInstallTargetAdapter(config) { } return path.join(baseRoot, ...config.rootSegments); }, + resolveTrustedRoots(input = {}) { + const root = adapter.resolveRoot(input); + if (typeof config.resolveTrustedRoots === 'function') { + return config.resolveTrustedRoots(input, root); + } + return [root]; + }, getInstallStatePath(input = {}) { const root = adapter.resolveRoot(input); return path.join(root, ...config.installStatePathSegments); diff --git a/scripts/lib/install-targets/registry.js b/scripts/lib/install-targets/registry.js index 864a91a22..f50d973db 100644 --- a/scripts/lib/install-targets/registry.js +++ b/scripts/lib/install-targets/registry.js @@ -68,6 +68,9 @@ function planInstallTargetScaffold(options = {}) { } const targetRoot = adapter.resolveRoot(planningInput); const installStatePath = adapter.getInstallStatePath(planningInput); + const trustedRoots = typeof adapter.resolveTrustedRoots === 'function' + ? adapter.resolveTrustedRoots(planningInput) + : [targetRoot]; const operations = adapter.planOperations({ ...planningInput, modules, @@ -80,6 +83,7 @@ function planInstallTargetScaffold(options = {}) { kind: adapter.kind, }, targetRoot, + trustedRoots, installStatePath, validationIssues, operations, diff --git a/scripts/lib/install/apply.js b/scripts/lib/install/apply.js index 1776cb6ca..f08b7f7eb 100644 --- a/scripts/lib/install/apply.js +++ b/scripts/lib/install/apply.js @@ -21,7 +21,7 @@ const { validateRecordedManagedHooks, } = require('./claude-settings'); const { filterMcpConfig, parseDisabledMcpServers } = require('../mcp-config'); -const { assertWithinTrustedRoot } = require('../path-safety'); +const { assertWithinTrustedRoot, isWithinRoot } = require('../path-safety'); const { assertSafeClaudeSkillOperation, prepareClaudeSkillMigration, @@ -248,12 +248,22 @@ function isMcpConfigPath(filePath) { return basename === '.mcp.json' || basename === 'mcp.json'; } +function getTrustedRootsForPlan(plan) { + if (!plan) return []; + if (Array.isArray(plan.trustedRoots) && plan.trustedRoots.length > 0) { + return plan.trustedRoots; + } + return plan.targetRoot ? [plan.targetRoot] : []; +} + function assertSafeInstallOperation(plan, operation) { if (!operation || typeof operation.destinationPath !== 'string') { throw new Error('Refusing to apply install operation: missing destination path.'); } - const targetRoot = plan && plan.targetRoot; + const trustedRoots = getTrustedRootsForPlan(plan); + const matchingRoot = trustedRoots.find(root => isWithinRoot(operation.destinationPath, root)); + const targetRoot = matchingRoot || (plan && plan.targetRoot); assertWithinTrustedRoot(operation.destinationPath, targetRoot, 'install ECC file'); const resolvedRoot = path.resolve(targetRoot); diff --git a/scripts/lib/install/plan.js b/scripts/lib/install/plan.js index 91774b6e0..64d376ddd 100644 --- a/scripts/lib/install/plan.js +++ b/scripts/lib/install/plan.js @@ -328,6 +328,7 @@ function createManifestInstallPlan(options = {}) { }, homeDir: plan.homeDir, targetRoot: plan.targetRoot, + trustedRoots: plan.trustedRoots || (plan.targetRoot ? [plan.targetRoot] : []), installRoot: plan.targetRoot, installStatePath: plan.installStatePath, warnings: Array.isArray(options.warnings) ? [...options.warnings] : [], diff --git a/scripts/lib/multi-harness-setup.js b/scripts/lib/multi-harness-setup.js index 141eb4206..2367ac838 100644 --- a/scripts/lib/multi-harness-setup.js +++ b/scripts/lib/multi-harness-setup.js @@ -6,7 +6,7 @@ const os = require('os'); const path = require('path'); const { assertSafeInstallOperation } = require('./install/apply'); -const { assertWithinTrustedRoot, realpathNearestExisting } = require('./path-safety'); +const { assertWithinTrustedRoot, isWithinRoot, realpathNearestExisting } = require('./path-safety'); const VALID_CLAUDE_SCOPES = new Set(['user', 'project', 'local']); const VALID_CLAUDE_HOOKS = new Set(['off', 'minimal', 'standard', 'strict']); @@ -208,7 +208,11 @@ function readOwnedDestinations(plan, dependencies) { ); } const destinationPath = operation.destinationPath; - assertWithinTrustedRoot(destinationPath, plan.targetRoot, 'trust install-state ownership'); + const trustedRoots = Array.isArray(plan.trustedRoots) && plan.trustedRoots.length > 0 + ? plan.trustedRoots + : [plan.targetRoot]; + const matchingRoot = trustedRoots.find(root => isWithinRoot(destinationPath, root)) || plan.targetRoot; + assertWithinTrustedRoot(destinationPath, matchingRoot, 'trust install-state ownership'); const canonicalDestination = canonicalPath(destinationPath); const plannedOperation = plannedByDestination.get(canonicalDestination); if (!plannedOperation) continue; diff --git a/tests/lib/antigravity-tier1.test.js b/tests/lib/antigravity-tier1.test.js index e8e8fa98a..c274f513b 100644 --- a/tests/lib/antigravity-tier1.test.js +++ b/tests/lib/antigravity-tier1.test.js @@ -153,6 +153,7 @@ function runTests() { }); test('hook commands preserve shell metacharacters in the installed path', () => { + if (process.platform === 'win32') return; const dir = createTempDir("ecc space ' $HOME `echo x` "); try { const script = path.join(dir, 'bridge.js'); @@ -353,7 +354,7 @@ function runTests() { // Check workflows assert.ok( plan.operations.some(op => ( - op.destinationPath.startsWith(path.join(targetRoot, 'workflows')) + op.destinationPath.startsWith(path.join(homeDir, '.gemini', 'config', 'workflows')) )), 'Should plan workflows' ); @@ -522,6 +523,7 @@ function runTests() { assert.ok(fs.existsSync(path.join(pluginDir, 'rules', 'common-coding-style.md')), 'rules should exist'); assert.ok(fs.existsSync(path.join(pluginDir, 'skills', 'tdd-workflow', 'SKILL.md')), 'skills should exist'); assert.ok(fs.existsSync(path.join(pluginDir, 'scripts', 'hooks', 'antigravity-hook-bridge.js')), 'hook bridge should exist'); + assert.ok(fs.existsSync(path.join(homeDir, '.gemini', 'config', 'workflows', 'plan.md')), 'workflow plan.md should exist in global workflows dir'); const pluginJson = JSON.parse(fs.readFileSync(path.join(pluginDir, 'plugin.json'), 'utf8')); assert.strictEqual(pluginJson.name, 'ecc');