mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-23 00:05:27 +00:00
fix(antigravity): route global workflows to config dir and quote bridgeScript on windows
This commit is contained in:
1 parent
aa457babfc
commit
9dfa26f24d
12 files changed
+68
-20
No files matched your search
@@ -155,7 +155,7 @@ node "$EccRoot\scripts\uninstall.js" --target antigravity --dry-run
|
||||
Antigravity supports global plugins located in `~/.gemini/config/plugins/<name>/`. 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
|
||||
|
||||
@@ -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 <target>` after installation. For Antigravity, start a new conversation and verify workspace skills under Settings > Customizations.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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'
|
||||
),
|
||||
];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,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;
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in new issue
Block a user