mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-24 00:35:31 +00:00
feat(antigravity): elevate Google Antigravity to Tier 1 native plugin and lifecycle hooks
- Add antigravity-home target adapter installing directly into ~/.gemini/config/plugins/ecc/
- Support full Antigravity lifecycle hooks (PreToolUse, Stop) adhering to the protojson contract ({ decision, reason }) via scripts/hooks/antigravity-hook-bridge.js
- Generate native Antigravity plugin manifest (plugin.json) and shared ECC memory vault MCP config (mcp_config.json)
- Support dual scope (user and project) with full harness capability integration
- Update install schemas and manifests to recognize antigravity-home
- Fix upstream regressions in plan.js scaffoldOnly, plan-canvas child_process spawn, codex-hooks pre-push test, and claude-plugin-setup hook arguments
- Add comprehensive Tier 1 test suite (13 passing tests) with 100% pass across all 4919 repository tests
This commit is contained in:
1 parent
bf70150eb2
commit
7e7ca11f21
23 files changed
+1094
-28
No files matched your search
@@ -0,0 +1,162 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Antigravity Lifecycle Hook Bridge
|
||||
*
|
||||
* Bridges Google Antigravity's protojson hook contract (stdin/stdout JSON with
|
||||
* camelCase keys and { decision, reason } responses) to ECC's internal hook
|
||||
* runtime (exit-code/stderr based).
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
const { runPreBash } = require('./bash-hook-dispatcher');
|
||||
const { run: runGateGuard } = require('./gateguard-fact-force');
|
||||
const { run: runDocFileWarning } = require('./doc-file-warning');
|
||||
const { run: runStopFormatTypecheck } = require('./stop-format-typecheck');
|
||||
const { readStdinRaw, resolveMaxStdin } = require('./hook-input');
|
||||
|
||||
function parseArgs(argv) {
|
||||
const options = {
|
||||
mode: 'pre-tool-use',
|
||||
hook: null,
|
||||
};
|
||||
|
||||
for (let i = 2; i < argv.length; i += 1) {
|
||||
if (argv[i] === '--mode') {
|
||||
options.mode = argv[i + 1] || options.mode;
|
||||
i += 1;
|
||||
} else if (argv[i] === '--hook') {
|
||||
options.hook = argv[i + 1] || options.hook;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
function adaptAntigravityInputToEcc(antigravityData) {
|
||||
if (!antigravityData || typeof antigravityData !== 'object') {
|
||||
return { tool_name: '', tool_input: {} };
|
||||
}
|
||||
|
||||
const toolCall = antigravityData.toolCall || {};
|
||||
const toolName = toolCall.name || antigravityData.tool_name || '';
|
||||
const args = toolCall.args || antigravityData.tool_input || {};
|
||||
|
||||
// Normalize Antigravity tools to ECC tool conventions
|
||||
const toolInput = {
|
||||
...args,
|
||||
command: args.CommandLine || args.command || '',
|
||||
file_path: args.TargetFile || args.file_path || args.path || '',
|
||||
};
|
||||
|
||||
return {
|
||||
tool_name: toolName,
|
||||
tool_input: toolInput,
|
||||
conversation_id: antigravityData.conversationId || '',
|
||||
workspace_paths: antigravityData.workspacePaths || [],
|
||||
};
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const options = parseArgs(process.argv);
|
||||
const maxStdin = resolveMaxStdin(process.env.ECC_HOOK_INPUT_MAX_BYTES);
|
||||
|
||||
let raw = '';
|
||||
try {
|
||||
const inputResult = await readStdinRaw(process.stdin, { maxStdin });
|
||||
raw = inputResult.raw;
|
||||
} catch (_err) {
|
||||
// If stdin read fails, fail open safely
|
||||
process.stdout.write(JSON.stringify({ decision: 'allow' }));
|
||||
return;
|
||||
}
|
||||
|
||||
let antigravityPayload = {};
|
||||
try {
|
||||
antigravityPayload = raw.trim() ? JSON.parse(raw) : {};
|
||||
} catch (_parseErr) {
|
||||
// Malformed JSON on stdin
|
||||
process.stdout.write(JSON.stringify({ decision: 'allow' }));
|
||||
return;
|
||||
}
|
||||
|
||||
const eccPayload = adaptAntigravityInputToEcc(antigravityPayload);
|
||||
const eccJsonString = JSON.stringify(eccPayload);
|
||||
|
||||
if (options.mode === 'pre-tool-use') {
|
||||
let result = { exitCode: 0, stderr: '' };
|
||||
|
||||
if (options.hook === 'pre:bash:dispatcher') {
|
||||
result = runPreBash(eccJsonString);
|
||||
} else if (options.hook === 'pre:edit-write:gateguard-fact-force') {
|
||||
result = runGateGuard(eccJsonString);
|
||||
} else if (options.hook === 'pre:config-protection') {
|
||||
const child = spawnSync(process.execPath, [path.join(__dirname, 'config-protection.js')], {
|
||||
input: eccJsonString,
|
||||
encoding: 'utf8',
|
||||
});
|
||||
result = {
|
||||
exitCode: child.status || 0,
|
||||
stderr: child.stderr || '',
|
||||
};
|
||||
} else if (options.hook === 'pre:write:doc-file-warning') {
|
||||
result = runDocFileWarning(eccJsonString);
|
||||
}
|
||||
|
||||
if (result && (result.exitCode === 2 || result.denied || result.blocked)) {
|
||||
const reason = result.stderr || result.reason || 'Blocked by ECC safety hook';
|
||||
process.stdout.write(JSON.stringify({
|
||||
decision: 'deny',
|
||||
reason: reason.replace(/\r?\n/g, ' ').trim(),
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
process.stdout.write(JSON.stringify({ decision: 'allow' }));
|
||||
return;
|
||||
}
|
||||
|
||||
if (options.mode === 'stop') {
|
||||
let stopResult = { exitCode: 0, stderr: '' };
|
||||
|
||||
if (options.hook === 'stop:format-typecheck') {
|
||||
stopResult = runStopFormatTypecheck(eccJsonString);
|
||||
} else if (options.hook === 'stop:check-console-log') {
|
||||
const child = spawnSync(process.execPath, [path.join(__dirname, 'check-console-log.js')], {
|
||||
input: eccJsonString,
|
||||
encoding: 'utf8',
|
||||
});
|
||||
stopResult = {
|
||||
exitCode: child.status || 0,
|
||||
stderr: child.stderr || '',
|
||||
};
|
||||
}
|
||||
|
||||
if (stopResult && stopResult.exitCode !== 0 && stopResult.stderr) {
|
||||
process.stdout.write(JSON.stringify({
|
||||
decision: 'continue',
|
||||
reason: stopResult.stderr.replace(/\r?\n/g, ' ').trim(),
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
process.stdout.write(JSON.stringify({}));
|
||||
return;
|
||||
}
|
||||
|
||||
// Default passthrough
|
||||
process.stdout.write(JSON.stringify({ decision: 'allow' }));
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
main().catch(() => {
|
||||
process.stdout.write(JSON.stringify({ decision: 'allow' }));
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
adaptAntigravityInputToEcc,
|
||||
};
|
||||
@@ -0,0 +1,79 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Antigravity Hooks Generator
|
||||
*
|
||||
* Generates valid Antigravity hooks.json configuration matching Antigravity's
|
||||
* lifecycle schema (PreToolUse, PostToolUse, Stop) and pointing to the ECC
|
||||
* hook bridge.
|
||||
*/
|
||||
|
||||
function buildAntigravityHooksConfig(options = {}) {
|
||||
const profile = options.profile || 'standard';
|
||||
const bridgeScript = options.bridgeScript || 'scripts/hooks/antigravity-hook-bridge.js';
|
||||
|
||||
const preToolUseHandlers = [
|
||||
{
|
||||
matcher: 'run_command',
|
||||
hooks: [
|
||||
{
|
||||
type: 'command',
|
||||
command: `node ${bridgeScript} --mode pre-tool-use --hook pre:bash:dispatcher`,
|
||||
timeout: 15,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
matcher: 'write_to_file|replace_file_content',
|
||||
hooks: [
|
||||
{
|
||||
type: 'command',
|
||||
command: `node ${bridgeScript} --mode pre-tool-use --hook pre:edit-write:gateguard-fact-force`,
|
||||
timeout: 10,
|
||||
},
|
||||
{
|
||||
type: 'command',
|
||||
command: `node ${bridgeScript} --mode pre-tool-use --hook pre:config-protection`,
|
||||
timeout: 5,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
if (profile === 'standard' || profile === 'strict') {
|
||||
preToolUseHandlers.push({
|
||||
matcher: 'write_to_file',
|
||||
hooks: [
|
||||
{
|
||||
type: 'command',
|
||||
command: `node ${bridgeScript} --mode pre-tool-use --hook pre:write:doc-file-warning`,
|
||||
timeout: 5,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
const stopHandlers = [
|
||||
{
|
||||
type: 'command',
|
||||
command: `node ${bridgeScript} --mode stop --hook stop:format-typecheck`,
|
||||
timeout: 120,
|
||||
},
|
||||
{
|
||||
type: 'command',
|
||||
command: `node ${bridgeScript} --mode stop --hook stop:check-console-log`,
|
||||
timeout: 30,
|
||||
},
|
||||
];
|
||||
|
||||
return {
|
||||
'ecc-guard': {
|
||||
PreToolUse: preToolUseHandlers,
|
||||
Stop: stopHandlers,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
buildAntigravityHooksConfig,
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Antigravity MCP Configuration Generator
|
||||
*
|
||||
* Generates valid Antigravity mcp_config.json containing the ECC Memory Vault
|
||||
* stdio server so that Antigravity agents have native access to .ecc/memory/.
|
||||
*/
|
||||
|
||||
function buildAntigravityMcpConfig(options = {}) {
|
||||
const memoryScript = options.memoryScript || 'scripts/memory-mcp.mjs';
|
||||
|
||||
return {
|
||||
mcpServers: {
|
||||
'ecc-memory': {
|
||||
command: 'node',
|
||||
args: [memoryScript],
|
||||
env: {
|
||||
ECC_MEMORY_HARNESS: 'antigravity',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
buildAntigravityMcpConfig,
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Antigravity Plugin Manifest Generator
|
||||
*
|
||||
* Generates valid Antigravity plugin.json declaring the ECC plugin.
|
||||
*/
|
||||
|
||||
function buildAntigravityPluginManifest(options = {}) {
|
||||
const version = options.version || '2.2.2';
|
||||
return {
|
||||
name: 'ecc',
|
||||
description: 'ECC - The Agent Harness Operating System for Antigravity',
|
||||
version,
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
buildAntigravityPluginManifest,
|
||||
};
|
||||
@@ -570,6 +570,7 @@ function verifyPluginAtScope(options) {
|
||||
|
||||
function ensurePluginAtScope(options) {
|
||||
const run = options.run || runClaude;
|
||||
const configuredHooks = options.hookConfiguration;
|
||||
if (options.installed) {
|
||||
run(
|
||||
['plugin', 'update', CURRENT_PLUGIN_ID, '--scope', options.scope],
|
||||
@@ -577,13 +578,17 @@ function ensurePluginAtScope(options) {
|
||||
);
|
||||
return 'updated';
|
||||
}
|
||||
run(
|
||||
[
|
||||
'plugin', 'install', CURRENT_PLUGIN_ID,
|
||||
'--scope', options.scope,
|
||||
],
|
||||
{ cwd: options.projectRoot, phase: 'plugin-install' }
|
||||
);
|
||||
const installArgs = [
|
||||
'plugin', 'install', CURRENT_PLUGIN_ID,
|
||||
'--scope', options.scope,
|
||||
];
|
||||
if (configuredHooks) {
|
||||
installArgs.push(
|
||||
'--config', `hooks_enabled=${configuredHooks.hooks_enabled}`,
|
||||
'--config', `hook_profile=${configuredHooks.hook_profile}`
|
||||
);
|
||||
}
|
||||
run(installArgs, { cwd: options.projectRoot, phase: 'plugin-install' });
|
||||
return 'installed';
|
||||
}
|
||||
|
||||
|
||||
@@ -103,16 +103,23 @@ const HARNESS_CAPABILITIES = deepFreeze([
|
||||
},
|
||||
{
|
||||
id: 'antigravity',
|
||||
label: 'Antigravity',
|
||||
targetIds: ['antigravity'],
|
||||
channel: 'managed-project',
|
||||
installMode: 'managed-project',
|
||||
label: 'Google Antigravity',
|
||||
targetIds: ['antigravity-home', 'antigravity'],
|
||||
channel: 'native-plugin',
|
||||
installMode: 'native-plugin',
|
||||
guidedReady: false,
|
||||
availability: 'advanced',
|
||||
destination: './.agents',
|
||||
scopes: [scope('project', 'antigravity', './.agents')],
|
||||
hooks: hooks('not-configured', false, 'ECC hooks are not configured by this adapter.'),
|
||||
aliases: ['google-antigravity'],
|
||||
destination: 'Selected Antigravity scope: ~/.gemini/config/plugins/ecc or ./.agents',
|
||||
scopes: [
|
||||
scope('user', 'antigravity-home', '~/.gemini/config/plugins/ecc'),
|
||||
scope('project', 'antigravity', './.agents'),
|
||||
],
|
||||
hooks: hooks(
|
||||
'profile-selection',
|
||||
true,
|
||||
'ECC hooks are configured through Antigravity PreToolUse and Stop lifecycle hooks.'
|
||||
),
|
||||
aliases: ['google-antigravity', 'gemini-antigravity', 'agy'],
|
||||
},
|
||||
{
|
||||
id: 'gemini',
|
||||
|
||||
@@ -5,7 +5,7 @@ const { getInstallTargetAdapter, planInstallTargetScaffold } = require('./instal
|
||||
const { resolveInvocationEnvironment } = require('./invocation-environment');
|
||||
|
||||
const DEFAULT_REPO_ROOT = path.join(__dirname, '../..');
|
||||
const SUPPORTED_INSTALL_TARGETS = ['claude', 'claude-project', 'cursor', 'antigravity', 'codex', 'gemini', 'opencode', 'codebuddy', 'joycode', 'qwen', 'zed', 'hermes', 'openclaw', 'kimi', 'adal'];
|
||||
const SUPPORTED_INSTALL_TARGETS = ['claude', 'claude-project', 'cursor', 'antigravity', 'antigravity-home', 'codex', 'gemini', 'opencode', 'codebuddy', 'joycode', 'qwen', 'zed', 'hermes', 'openclaw', 'kimi', 'adal'];
|
||||
const COMPONENT_FAMILY_PREFIXES = {
|
||||
baseline: 'baseline:',
|
||||
language: 'lang:',
|
||||
@@ -71,6 +71,14 @@ const LEGACY_COMPAT_BASE_MODULE_IDS_BY_TARGET = Object.freeze({
|
||||
'skill-unified-memory',
|
||||
'workflow-quality',
|
||||
],
|
||||
'antigravity-home': [
|
||||
'rules-core',
|
||||
'agents-core',
|
||||
'commands-core',
|
||||
'hooks-runtime',
|
||||
'platform-configs',
|
||||
'workflow-quality',
|
||||
],
|
||||
zed: [
|
||||
'rules-core',
|
||||
'agents-core',
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const {
|
||||
HOME_INSTALL_EXCLUDED_SOURCE_PATHS,
|
||||
createFlatRuleOperations,
|
||||
createInstallTargetAdapter,
|
||||
createManagedOperation,
|
||||
createManagedScaffoldOperation,
|
||||
isForeignPlatformPath,
|
||||
normalizeRelativePath,
|
||||
} = require('./helpers');
|
||||
const { buildAntigravityHooksConfig } = require('../antigravity-hooks');
|
||||
const { buildAntigravityMcpConfig } = require('../antigravity-mcp');
|
||||
const { buildAntigravityPluginManifest } = require('../antigravity-plugin');
|
||||
|
||||
function readJsonObject(filePath, label) {
|
||||
let parsed;
|
||||
try {
|
||||
parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to parse ${label} at ${filePath}: ${error.message}`);
|
||||
}
|
||||
|
||||
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
||||
throw new Error(`Invalid ${label} at ${filePath}: expected a JSON object`);
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
module.exports = createInstallTargetAdapter({
|
||||
id: 'antigravity-home',
|
||||
target: 'antigravity-home',
|
||||
kind: 'home',
|
||||
rootSegments: ['.gemini', 'config', 'plugins', 'ecc'],
|
||||
installStatePathSegments: ['ecc-install-state.json'],
|
||||
nativeRootRelativePath: '.gemini',
|
||||
excludedSourcePaths: HOME_INSTALL_EXCLUDED_SOURCE_PATHS,
|
||||
planOperations(input, adapter) {
|
||||
const modules = Array.isArray(input.modules)
|
||||
? input.modules
|
||||
: (input.module ? [input.module] : []);
|
||||
const {
|
||||
repoRoot,
|
||||
projectRoot,
|
||||
homeDir,
|
||||
} = input;
|
||||
const planningInput = {
|
||||
repoRoot,
|
||||
projectRoot,
|
||||
homeDir,
|
||||
};
|
||||
const targetRoot = adapter.resolveRoot(planningInput);
|
||||
|
||||
return modules.flatMap(module => {
|
||||
const paths = Array.isArray(module.paths) ? module.paths : [];
|
||||
return paths
|
||||
.filter(p => !isForeignPlatformPath(p, 'antigravity') && !adapter.excludesSourcePath(p))
|
||||
.flatMap(sourceRelativePath => {
|
||||
const normalizedSourcePath = normalizeRelativePath(sourceRelativePath);
|
||||
|
||||
if (
|
||||
normalizedSourcePath === 'rules'
|
||||
|| normalizedSourcePath.startsWith('rules/')
|
||||
) {
|
||||
return createFlatRuleOperations({
|
||||
moduleId: module.id,
|
||||
repoRoot,
|
||||
sourceRelativePath: normalizedSourcePath,
|
||||
destinationDir: path.join(targetRoot, 'rules'),
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
normalizedSourcePath === 'commands'
|
||||
|| normalizedSourcePath.startsWith('commands/')
|
||||
) {
|
||||
const commandRelativePath = normalizedSourcePath === 'commands'
|
||||
? ''
|
||||
: normalizedSourcePath.slice('commands/'.length);
|
||||
return [
|
||||
createManagedScaffoldOperation(
|
||||
module.id,
|
||||
normalizedSourcePath,
|
||||
path.join(targetRoot, 'workflows', commandRelativePath),
|
||||
'preserve-relative-path'
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
if (
|
||||
normalizedSourcePath === 'agents'
|
||||
|| normalizedSourcePath.startsWith('agents/')
|
||||
) {
|
||||
const agentRelativePath = normalizedSourcePath === 'agents'
|
||||
? ''
|
||||
: normalizedSourcePath.slice('agents/'.length);
|
||||
return [
|
||||
createManagedOperation({
|
||||
moduleId: module.id,
|
||||
sourceRelativePath: normalizedSourcePath,
|
||||
destinationPath: path.join(targetRoot, 'agents', agentRelativePath),
|
||||
strategy: 'preserve-relative-path',
|
||||
contentTransform: 'antigravity-agent-frontmatter',
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
if (
|
||||
normalizedSourcePath === 'skills'
|
||||
|| normalizedSourcePath.startsWith('skills/')
|
||||
) {
|
||||
const skillRelativePath = normalizedSourcePath === 'skills'
|
||||
? ''
|
||||
: normalizedSourcePath.slice('skills/'.length);
|
||||
return [
|
||||
createManagedScaffoldOperation(
|
||||
module.id,
|
||||
normalizedSourcePath,
|
||||
path.join(targetRoot, 'skills', skillRelativePath),
|
||||
'preserve-relative-path'
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
if (
|
||||
module.id === 'hooks-runtime'
|
||||
&& normalizedSourcePath === 'hooks'
|
||||
) {
|
||||
return [
|
||||
createManagedOperation({
|
||||
kind: 'merge-json',
|
||||
moduleId: module.id,
|
||||
sourceRelativePath: 'hooks/hooks.json',
|
||||
destinationPath: path.join(targetRoot, 'hooks.json'),
|
||||
strategy: 'merge-json',
|
||||
ownership: 'managed',
|
||||
scaffoldOnly: false,
|
||||
mergePayload: buildAntigravityHooksConfig({
|
||||
profile: input.hookProfile || 'standard',
|
||||
}),
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
if (
|
||||
module.id === 'platform-configs'
|
||||
&& (normalizedSourcePath === 'mcp-configs' || normalizedSourcePath === '.mcp.json')
|
||||
) {
|
||||
const baseMcp = (repoRoot && fs.existsSync(path.join(repoRoot, '.mcp.json')))
|
||||
? readJsonObject(path.join(repoRoot, '.mcp.json'), '.mcp.json')
|
||||
: { mcpServers: {} };
|
||||
const antigravityMcp = buildAntigravityMcpConfig();
|
||||
const mergedMcp = {
|
||||
mcpServers: {
|
||||
...(baseMcp.mcpServers || {}),
|
||||
...(antigravityMcp.mcpServers || {}),
|
||||
},
|
||||
};
|
||||
|
||||
const operations = [
|
||||
createManagedOperation({
|
||||
kind: 'merge-json',
|
||||
moduleId: module.id,
|
||||
sourceRelativePath: '.mcp.json',
|
||||
destinationPath: path.join(targetRoot, 'mcp_config.json'),
|
||||
strategy: 'merge-json',
|
||||
ownership: 'managed',
|
||||
scaffoldOnly: false,
|
||||
mergePayload: mergedMcp,
|
||||
}),
|
||||
createManagedOperation({
|
||||
kind: 'merge-json',
|
||||
moduleId: module.id,
|
||||
sourceRelativePath: 'plugin.json',
|
||||
destinationPath: path.join(targetRoot, 'plugin.json'),
|
||||
strategy: 'merge-json',
|
||||
ownership: 'managed',
|
||||
scaffoldOnly: false,
|
||||
mergePayload: buildAntigravityPluginManifest(),
|
||||
}),
|
||||
];
|
||||
|
||||
if (repoRoot && fs.existsSync(path.join(repoRoot, 'scripts', 'memory-mcp.mjs'))) {
|
||||
operations.push(
|
||||
createManagedScaffoldOperation(
|
||||
module.id,
|
||||
'scripts/memory-mcp.mjs',
|
||||
path.join(targetRoot, 'scripts', 'memory-mcp.mjs'),
|
||||
'preserve-relative-path'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return operations;
|
||||
}
|
||||
|
||||
if (normalizedSourcePath === 'scripts/hooks' || normalizedSourcePath === 'scripts/lib') {
|
||||
return [adapter.createScaffoldOperation(module.id, normalizedSourcePath, planningInput)];
|
||||
}
|
||||
|
||||
return [];
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -1,3 +1,4 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const {
|
||||
@@ -7,8 +8,21 @@ const {
|
||||
createManagedScaffoldOperation,
|
||||
normalizeRelativePath,
|
||||
} = require('./helpers');
|
||||
const { buildAntigravityHooksConfig } = require('../antigravity-hooks');
|
||||
const { buildAntigravityMcpConfig } = require('../antigravity-mcp');
|
||||
const { buildAntigravityPluginManifest } = require('../antigravity-plugin');
|
||||
|
||||
const SUPPORTED_SOURCE_PREFIXES = ['rules', 'commands', 'agents', 'skills'];
|
||||
const SUPPORTED_SOURCE_PREFIXES = [
|
||||
'rules',
|
||||
'commands',
|
||||
'agents',
|
||||
'skills',
|
||||
'hooks',
|
||||
'scripts/hooks',
|
||||
'scripts/lib',
|
||||
'mcp-configs',
|
||||
'.mcp.json',
|
||||
];
|
||||
|
||||
function supportsAntigravitySourcePath(sourceRelativePath) {
|
||||
const normalizedPath = normalizeRelativePath(sourceRelativePath);
|
||||
@@ -17,12 +31,28 @@ function supportsAntigravitySourcePath(sourceRelativePath) {
|
||||
));
|
||||
}
|
||||
|
||||
function readJsonObject(filePath, label) {
|
||||
let parsed;
|
||||
try {
|
||||
parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to parse ${label} at ${filePath}: ${error.message}`);
|
||||
}
|
||||
|
||||
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
||||
throw new Error(`Invalid ${label} at ${filePath}: expected a JSON object`);
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
module.exports = createInstallTargetAdapter({
|
||||
id: 'antigravity-project',
|
||||
target: 'antigravity',
|
||||
kind: 'project',
|
||||
rootSegments: ['.agents'],
|
||||
installStatePathSegments: ['ecc-install-state.json'],
|
||||
nativeRootRelativePath: '.agents',
|
||||
supportsModule(module) {
|
||||
const paths = Array.isArray(module && module.paths) ? module.paths : [];
|
||||
return paths.length > 0;
|
||||
@@ -114,6 +144,82 @@ module.exports = createInstallTargetAdapter({
|
||||
];
|
||||
}
|
||||
|
||||
if (
|
||||
module.id === 'hooks-runtime'
|
||||
&& normalizedSourcePath === 'hooks'
|
||||
) {
|
||||
return [
|
||||
createManagedOperation({
|
||||
kind: 'merge-json',
|
||||
moduleId: module.id,
|
||||
sourceRelativePath: 'hooks/hooks.json',
|
||||
destinationPath: path.join(targetRoot, 'hooks.json'),
|
||||
strategy: 'merge-json',
|
||||
ownership: 'managed',
|
||||
scaffoldOnly: false,
|
||||
mergePayload: buildAntigravityHooksConfig({
|
||||
profile: input.hookProfile || 'standard',
|
||||
}),
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
if (
|
||||
module.id === 'platform-configs'
|
||||
&& (normalizedSourcePath === 'mcp-configs' || normalizedSourcePath === '.mcp.json')
|
||||
) {
|
||||
const baseMcp = (repoRoot && fs.existsSync(path.join(repoRoot, '.mcp.json')))
|
||||
? readJsonObject(path.join(repoRoot, '.mcp.json'), '.mcp.json')
|
||||
: { mcpServers: {} };
|
||||
const antigravityMcp = buildAntigravityMcpConfig();
|
||||
const mergedMcp = {
|
||||
mcpServers: {
|
||||
...(baseMcp.mcpServers || {}),
|
||||
...(antigravityMcp.mcpServers || {}),
|
||||
},
|
||||
};
|
||||
|
||||
const operations = [
|
||||
createManagedOperation({
|
||||
kind: 'merge-json',
|
||||
moduleId: module.id,
|
||||
sourceRelativePath: '.mcp.json',
|
||||
destinationPath: path.join(targetRoot, 'mcp_config.json'),
|
||||
strategy: 'merge-json',
|
||||
ownership: 'managed',
|
||||
scaffoldOnly: false,
|
||||
mergePayload: mergedMcp,
|
||||
}),
|
||||
createManagedOperation({
|
||||
kind: 'merge-json',
|
||||
moduleId: module.id,
|
||||
sourceRelativePath: 'plugin.json',
|
||||
destinationPath: path.join(targetRoot, 'plugins', 'ecc', 'plugin.json'),
|
||||
strategy: 'merge-json',
|
||||
ownership: 'managed',
|
||||
scaffoldOnly: false,
|
||||
mergePayload: buildAntigravityPluginManifest(),
|
||||
}),
|
||||
];
|
||||
|
||||
if (repoRoot && fs.existsSync(path.join(repoRoot, 'scripts', 'memory-mcp.mjs'))) {
|
||||
operations.push(
|
||||
createManagedScaffoldOperation(
|
||||
module.id,
|
||||
'scripts/memory-mcp.mjs',
|
||||
path.join(targetRoot, 'scripts', 'memory-mcp.mjs'),
|
||||
'preserve-relative-path'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return operations;
|
||||
}
|
||||
|
||||
if (normalizedSourcePath === 'scripts/hooks' || normalizedSourcePath === 'scripts/lib') {
|
||||
return [adapter.createScaffoldOperation(module.id, normalizedSourcePath, planningInput)];
|
||||
}
|
||||
|
||||
return [];
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const adalProject = require('./adal-project');
|
||||
const antigravityHome = require('./antigravity-home');
|
||||
const antigravityProject = require('./antigravity-project');
|
||||
const claudeHome = require('./claude-home');
|
||||
const claudeProject = require('./claude-project');
|
||||
@@ -19,6 +20,7 @@ const ADAPTERS = Object.freeze([
|
||||
claudeHome,
|
||||
claudeProject,
|
||||
cursorProject,
|
||||
antigravityHome,
|
||||
antigravityProject,
|
||||
codexHome,
|
||||
geminiProject,
|
||||
|
||||
@@ -6,7 +6,7 @@ const path = require('path');
|
||||
const { assertWithinTrustedRoot } = require('../path-safety');
|
||||
|
||||
function isCodexUserConfig(plan, operation) {
|
||||
if (plan.adapter.id !== 'codex-home' || operation.kind !== 'copy-file') {
|
||||
if (plan?.adapter?.id !== 'codex-home' || operation?.kind !== 'copy-file') {
|
||||
return false;
|
||||
}
|
||||
const relativePath = path.relative(plan.targetRoot, operation.destinationPath);
|
||||
|
||||
@@ -60,6 +60,7 @@ function isHookRuntimeOperation(operation = {}) {
|
||||
|| source.startsWith('.cursor/hooks/')
|
||||
|| source === '.cursor/hooks.json'
|
||||
|| destination.endsWith('/hooks/hooks.json')
|
||||
|| destination.endsWith('/hooks.json')
|
||||
|| destination.endsWith('/.cursor/hooks.json')
|
||||
|| destination.includes('/.cursor/hooks/')
|
||||
);
|
||||
|
||||
@@ -167,8 +167,10 @@ function materializeScaffoldOperation(sourceRoot, operation) {
|
||||
destinationPath: operation.destinationPath,
|
||||
strategy: operation.strategy || 'merge-json',
|
||||
ownership: operation.ownership || 'managed',
|
||||
scaffoldOnly: Object.hasOwn(operation, 'scaffoldOnly') ? operation.scaffoldOnly : false,
|
||||
mergePayload: readJsonObject(path.join(sourceRoot, operation.sourceRelativePath), operation.sourceRelativePath)
|
||||
scaffoldOnly: typeof operation.scaffoldOnly === 'boolean' ? operation.scaffoldOnly : false,
|
||||
mergePayload: operation.mergePayload !== undefined
|
||||
? JSON.parse(JSON.stringify(operation.mergePayload))
|
||||
: readJsonObject(path.join(sourceRoot, operation.sourceRelativePath), operation.sourceRelativePath)
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ const DEFAULT_SKILL_PROBE = path.join('skills', 'continuous-learning-v2');
|
||||
function resolveEccRoot(options = {}) {
|
||||
const envRoot = options.envRoot !== undefined
|
||||
? options.envRoot
|
||||
: (process.env.CLAUDE_PLUGIN_ROOT || '');
|
||||
: (process.env.CLAUDE_PLUGIN_ROOT || process.env.ANTIGRAVITY_PLUGIN_ROOT || process.env.GEMINI_PLUGIN_ROOT || '');
|
||||
|
||||
if (envRoot && envRoot.trim()) {
|
||||
return envRoot.trim();
|
||||
@@ -80,6 +80,12 @@ function resolveEccRoot(options = {}) {
|
||||
return claudeDir;
|
||||
}
|
||||
|
||||
// Antigravity global plugin install — ~/.gemini/config/plugins/ecc
|
||||
const antigravityPluginDir = path.join(homeDir, '.gemini', 'config', 'plugins', 'ecc');
|
||||
if (isRoot(antigravityPluginDir)) {
|
||||
return antigravityPluginDir;
|
||||
}
|
||||
|
||||
// Exact legacy plugin install locations. These preserve backwards
|
||||
// compatibility without scanning arbitrary plugin trees.
|
||||
const legacyPluginRoots = PLUGIN_ROOT_SEGMENTS.map((segments) =>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* so stdout stays parseable.
|
||||
*/
|
||||
|
||||
const { spawn } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const http = require('http');
|
||||
const path = require('path');
|
||||
|
||||
Reference in new issue
Block a user