fix(antigravity): route global workflows to config dir and quote bridgeScript on windows

This commit is contained in:
MohamedAfrash committed 2026-09-24 03:36:29 +01:00
1 parent aa457babfc
commit 9dfa26f24d
12 files changed
+68 -20

No files matched your search

+1 -1
View File
@@ -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);
}
+10 -3
View File
@@ -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 {
+1
View File
@@ -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 : [],
};
@@ -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'
),
];
+7
View File
@@ -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);
+4
View File
@@ -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,
+12 -2
View File
@@ -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);
+1
View File
@@ -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] : [],
+6 -2
View File
@@ -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;