feat(antigravity): add hybrid Antigravity 2.0 and agy CLI adapter support

This commit is contained in:
woffluon committed 2026-11-05 23:12:48 +03:00
1 parent b38be6a7f6
commit eac38dd481
12 files changed
+474 -19

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
{
"name": "ecc",
"version": "2.2.3",
"description": "Cross-harness operating system for Antigravity 2.0 and agy CLI - skills, rules, hooks, and agents",
"author": {
"name": "Affaan Mustafa",
"url": "https://x.com/affaanmustafa"
},
"homepage": "https://ecc.tools",
"repository": "https://github.com/affaan-m/ECC",
"license": "MIT",
"keywords": [
"antigravity",
"agy",
"agents",
"skills",
"hooks",
"rules",
"tdd",
"code-review",
"security"
],
"skills": "./skills/",
"mcpServers": "./.mcp.json",
"hooks": "./hooks/antigravity-hooks.json"
}
+2 -1
View File
@@ -1333,7 +1333,8 @@ Treat `stable`, `beta`, `experimental`, and `instruction-only` below as capabili
| OpenCode | Beta built plugin | Build plugin, then selective installer | ECC ships a subset of the catalog; connect a provider and select a model in OpenCode ([#2617](https://github.com/affaan-m/ECC/issues/2617)). |
| GitHub Copilot Chat | Instruction-only | Checked-in instructions and prompt files | ECC hooks are not adapted. |
| GitHub Copilot CLI | Beta project adapter | `--target copilot` places skills, adapted agents, and converted rules in `.github/` | ECC hooks and command shims are not installed by this target. |
| Gemini, Zed, Antigravity, Qwen, Hermes, OpenClaw, Kimi, CodeBuddy, JoyCode | Experimental/minimal adapters | Harness-specific selective target | File placement and instruction portability are tested; full Claude feature parity is not claimed. |
| Antigravity 2.0 | Supported adapter & plugin | Native plugin (`.antigravity-plugin/` or `plugins/ecc/`) or `./install.sh --target antigravity` into `.agents/` | Subagents map to native tools (`read_file`, `edit_file`, `write_file`, `run_command`, `search_web`); hooks bridge via `scripts/antigravity/hook-bridge.js`. |
| Gemini, Zed, Qwen, Hermes, OpenClaw, Kimi, CodeBuddy, JoyCode | Experimental/minimal adapters | Harness-specific selective target | File placement and instruction portability are tested; full Claude feature parity is not claimed. |
<details>
<summary><strong>Package manager detection</strong></summary>
@@ -41,6 +41,7 @@ The matrix below is rendered from
| OpenCode | Adapter-backed | OpenCode package/plugin metadata; shared skills; MCP config; event adapter patterns | Event names, plugin packaging, and command dispatch differ from Claude Code | OpenCode package or plugin surface from this repo | `node tests/scripts/build-opencode.test.js`; `npm run harness:audit -- --format json` | Keep hook logic in shared scripts and adapt only event shape at the edge. |
| Pi | Adapter-backed | Pi package manifest; canonical ECC skills (skills/); canonical ECC commands as prompt templates (commands/); canonical ECC engineering rules (rules/common/) injected into the system prompt; session lifecycle hook adapter; /ecc-doctor diagnostics command; canonical ECC agents (agents/) portable via scripts/agent-convert.js (claude -> pi) | Agent chains, approval prompts, and persistent todos require companion Pi packages and are not part of this adapter (individual agent definitions are portable via scripts/agent-convert.js); Pi core has no MCP surface, though ECC MCP configs load verbatim through the community pi-mcp-adapter package, which ECC neither installs nor depends on | `pi install git:github.com/affaan-m/ECC`; `pi install /path/to/ECC` from a local checkout | `node tests/pi/pi-package-manifest.test.js`; `node tests/pi/pi-extension-adapter.test.js`; `node tests/pi/agent-convert.test.js`; `npm run harness:adapters -- --check` | Pi extensions execute with full user permissions, and hooks run without a shell and resolve from the installed package rather than the user project; Keep canonical skills and commands as the single source of truth, and never generate copies under .pi/ |
| Cursor | Adapter-backed | Cursor rules; project-local skills; hook adapter; shared scripts | Cursor hook events and rule loading differ from Claude Code | `./install.sh --profile minimal --target cursor` | `node tests/lib/install-targets.test.js`; `npm run harness:audit -- --format json` | Cursor adapters must preserve existing project rules and avoid silent overwrite. |
| Antigravity 2.0 | Adapter-backed | Antigravity plugin manifest; skills (skills/); agents (agents/); workflows (commands/); progressive disclosure rules (rules/); lifecycle hooks (hooks.json via hook-bridge); MCP configs | Subagent recursion depth and terminal permissions follow Antigravity sandbox settings | `./install.sh --profile minimal --target antigravity`; `./install.ps1 -Profile minimal -Target antigravity`; `agy plugin install <path-to-ecc>` | `node tests/lib/antigravity-install-target.test.js`; `node tests/lib/antigravity-hook-bridge.test.js`; `node tests/lib/antigravity-legacy-migration.test.js`; `node tests/lib/antigravity-rule.test.js`; `npm run harness:adapters -- --check` | Preserve the 20k token rules budget using model_decision and glob triggers rather than loading every rule as always_on. |
| Gemini | Instruction-backed | Gemini project-local instructions; shared skills; rules; compatibility docs | No full ECC hook parity; ecosystem ports must document drift from upstream ECC | `./install.sh --profile minimal --target gemini` | `node tests/lib/install-targets.test.js` | Treat Gemini ports as ecosystem adapters until validated end to end inside Gemini CLI. |
| Zed | Adapter-backed | Zed project settings; flattened project rules; shared skills; commands; agents | Zed external agents and native Agent Panel permissions are not Claude hooks | `./install.sh --profile minimal --target zed` | `node tests/lib/install-targets.test.js`; `npm run harness:audit -- --format json` | Keep project settings conservative and do not copy BYOK/OpenRouter secrets into `.zed/`. |
| dmux | Adapter-backed | session snapshots; tmux/worktree orchestration status; handoff exports | dmux is an orchestration runtime, not an install target for skills/rules | `node scripts/session-inspect.js --list-adapters`; dmux session target inspection | `node tests/lib/session-adapters.test.js` | Treat dmux events as session/runtime signals, not as a replacement for repo validation. |
+16
View File
@@ -0,0 +1,16 @@
{
"ecc-guardrails": {
"PreToolUse": [
{
"matcher": "run_command|write_file|edit_file",
"hooks": [
{
"type": "command",
"command": "node scripts/antigravity/hook-bridge.js --hook config-protection",
"timeout": 30
}
]
}
]
}
}
+2
View File
@@ -53,6 +53,7 @@
"files": [
".adal/",
".agents/",
".antigravity-plugin/",
".claude-plugin/",
".codex/",
".codex-plugin/",
@@ -111,6 +112,7 @@
"rules/",
"schemas/",
"scripts/agent-convert.js",
"scripts/antigravity/",
"scripts/catalog.js",
"scripts/ci/scan-supply-chain-iocs.js",
"scripts/ci/supply-chain-advisory-sources.js",
+12
View File
@@ -0,0 +1,12 @@
{
"name": "ecc",
"version": "2.2.3",
"description": "Cross-harness operating system for Antigravity 2.0 and agy CLI - skills, rules, hooks, and agents",
"author": {
"name": "Affaan Mustafa",
"url": "https://x.com/affaanmustafa"
},
"homepage": "https://ecc.tools",
"repository": "https://github.com/affaan-m/ECC",
"license": "MIT"
}
+197
View File
@@ -0,0 +1,197 @@
#!/usr/bin/env node
/**
* Antigravity 2.0 Hook Bridge for ECC
*
* Translates Antigravity 2.0 lifecycle hook payloads (camelCase protojson on stdin)
* to Claude Code / Hermes hook payloads (snake_case on stdin), executes the target
* ECC hook script, and translates the outcome back to Antigravity's expected JSON
* contract on stdout ({ "decision": "allow" | "deny" | "ask", "reason": "..." }).
*/
'use strict';
const fs = require('fs');
const path = require('path');
const { spawnSync } = require('child_process');
const REPO_ROOT = path.resolve(__dirname, '..', '..');
const KNOWN_HOOKS = Object.freeze({
'config-protection': path.join(REPO_ROOT, 'scripts', 'hooks', 'config-protection.js'),
'check-console-log': path.join(REPO_ROOT, 'scripts', 'hooks', 'check-console-log.js'),
'quality-gate': path.join(REPO_ROOT, 'scripts', 'hooks', 'quality-gate.js'),
'pre-bash-commit-quality': path.join(REPO_ROOT, 'scripts', 'hooks', 'pre-bash-commit-quality.js'),
'block-no-verify': path.join(REPO_ROOT, 'scripts', 'hooks', 'block-no-verify.js'),
});
function parseArgs(argv) {
const args = argv.slice(2);
let hookTarget = null;
for (let i = 0; i < args.length; i += 1) {
const arg = args[i];
if (arg === '--hook' && i + 1 < args.length) {
hookTarget = args[i + 1];
i += 1;
} else if (arg.startsWith('--hook=')) {
hookTarget = arg.slice('--hook='.length);
} else if (arg === '--script' && i + 1 < args.length) {
hookTarget = args[i + 1];
i += 1;
} else if (arg.startsWith('--script=')) {
hookTarget = arg.slice('--script='.length);
}
}
return { hookTarget };
}
function resolveHookScript(hookTarget) {
if (!hookTarget) return null;
if (Object.prototype.hasOwnProperty.call(KNOWN_HOOKS, hookTarget)) {
return KNOWN_HOOKS[hookTarget];
}
const resolved = path.isAbsolute(hookTarget) ? hookTarget : path.resolve(REPO_ROOT, hookTarget);
return fs.existsSync(resolved) ? resolved : null;
}
function normalizeAntigravityToClaude(payload) {
const toolCall = payload.toolCall || {};
const rawToolName = String(toolCall.name || '');
const args = toolCall.args || {};
let claudeToolName = rawToolName;
const claudeToolInput = { ...args };
if (rawToolName === 'edit_file' || rawToolName === 'replace_file_content') {
claudeToolName = 'Edit';
const filePath = args.Path || args.path || args.filePath || '';
claudeToolInput.file_path = filePath;
claudeToolInput.path = filePath;
claudeToolInput.file = filePath;
} else if (rawToolName === 'write_file' || rawToolName === 'write_to_file') {
claudeToolName = 'Write';
const filePath = args.Path || args.path || args.filePath || '';
claudeToolInput.file_path = filePath;
claudeToolInput.path = filePath;
claudeToolInput.file = filePath;
claudeToolInput.content = args.Content || args.content || '';
} else if (rawToolName === 'run_command') {
claudeToolName = 'Bash';
claudeToolInput.command = args.CommandLine || args.command || '';
} else if (rawToolName === 'read_file' || rawToolName === 'view_file') {
claudeToolName = 'Read';
const filePath = args.Path || args.path || args.filePath || '';
claudeToolInput.file_path = filePath;
claudeToolInput.path = filePath;
}
return {
hook_event_name: 'pre_tool_call',
session_id: payload.conversationId || '',
tool_name: claudeToolName,
tool_input: claudeToolInput,
transcript_path: payload.transcriptPath || '',
cwd: Array.isArray(payload.workspacePaths) && payload.workspacePaths.length > 0
? payload.workspacePaths[0]
: process.cwd(),
};
}
function emitAntigravityDecision(decision, reason) {
const result = { decision };
if (reason) {
result.reason = reason;
}
process.stdout.write(JSON.stringify(result) + '\n');
}
function main() {
const { hookTarget } = parseArgs(process.argv);
const hookScript = resolveHookScript(hookTarget);
let rawStdin = '';
try {
rawStdin = fs.readFileSync(0, 'utf8');
} catch (_e) {
rawStdin = '';
}
let antigravityPayload = {};
if (rawStdin && rawStdin.trim()) {
try {
antigravityPayload = JSON.parse(rawStdin);
} catch (_err) {
// Unparseable payload fails open per ECC hook contract
emitAntigravityDecision('allow');
process.exit(0);
}
}
if (!hookScript) {
// If no specific hook script was configured or found, allow
emitAntigravityDecision('allow');
process.exit(0);
}
const claudePayload = normalizeAntigravityToClaude(antigravityPayload);
const childStdin = JSON.stringify(claudePayload);
const isPython = hookScript.endsWith('.py');
const runner = isPython ? (process.platform === 'win32' ? 'python' : 'python3') : process.execPath;
const result = spawnSync(runner, [hookScript], {
input: childStdin,
encoding: 'utf8',
timeout: 30000,
cwd: claudePayload.cwd || process.cwd(),
});
if (result.error) {
// Execution failed, fail open with warning
process.stderr.write(`[antigravity-hook-bridge] Error invoking hook ${hookScript}: ${result.error.message}\n`);
emitAntigravityDecision('allow');
process.exit(0);
}
// Parse stdout from hook
const childStdout = (result.stdout || '').trim();
const childStderr = (result.stderr || '').trim();
let childDecision = null;
let childReason = null;
if (childStdout) {
try {
const parsedStdout = JSON.parse(childStdout);
if (parsedStdout && typeof parsedStdout === 'object') {
if (parsedStdout.decision === 'block' || parsedStdout.decision === 'deny') {
childDecision = 'deny';
childReason = parsedStdout.reason || childStderr || 'Operation blocked by ECC guardrail';
}
}
} catch (_ignore) {
// Not JSON stdout, check exit code
}
}
// If exit code is 2 (blocking) or non-zero and not explicitly allowed
if (result.status === 2 || childDecision === 'deny') {
emitAntigravityDecision('deny', childReason || childStderr || 'Operation blocked by ECC config-protection guardrail');
} else if (result.status !== 0 && result.status !== null) {
// Other error
emitAntigravityDecision('deny', childReason || childStderr || `Hook failed with exit code ${result.status}`);
} else {
emitAntigravityDecision('allow');
}
}
if (require.main === module) {
main();
}
module.exports = {
KNOWN_HOOKS,
normalizeAntigravityToClaude,
resolveHookScript,
};
+41
View File
@@ -185,6 +185,47 @@ const ADAPTER_RECORDS = Object.freeze([
'tests/lib/install-targets.test.js',
],
},
{
id: 'antigravity',
harness: 'Antigravity 2.0',
state: 'Adapter-backed',
supported_assets: [
'Antigravity plugin manifest',
'skills (skills/)',
'agents (agents/)',
'workflows (commands/)',
'progressive disclosure rules (rules/)',
'lifecycle hooks (hooks.json via hook-bridge)',
'MCP configs',
],
unsupported_surfaces: [
'Subagent recursion depth and terminal permissions follow Antigravity sandbox settings',
],
install_or_onramp: [
'`./install.sh --profile minimal --target antigravity`',
'`./install.ps1 -Profile minimal -Target antigravity`',
'`agy plugin install <path-to-ecc>`',
],
verification_commands: [
'`node tests/lib/antigravity-install-target.test.js`',
'`node tests/lib/antigravity-hook-bridge.test.js`',
'`node tests/lib/antigravity-legacy-migration.test.js`',
'`node tests/lib/antigravity-rule.test.js`',
'`npm run harness:adapters -- --check`',
],
risk_notes: [
'Preserve the 20k token rules budget using model_decision and glob triggers rather than loading every rule as always_on.',
],
last_verified_at: '2026-11-05',
owner: 'ECC maintainers',
source_docs: [
'.agents/',
'hooks/antigravity-hooks.json',
'scripts/lib/install-targets/antigravity-project.js',
'scripts/antigravity/hook-bridge.js',
'tests/lib/antigravity-install-target.test.js',
],
},
{
id: 'gemini',
harness: 'Gemini',
@@ -8,7 +8,7 @@ const {
normalizeRelativePath,
} = require('./helpers');
const SUPPORTED_SOURCE_PREFIXES = ['rules', 'commands', 'agents', 'skills'];
const SUPPORTED_SOURCE_PREFIXES = ['rules', 'commands', 'agents', 'skills', 'hooks'];
function supportsAntigravitySourcePath(sourceRelativePath) {
const normalizedPath = normalizeRelativePath(sourceRelativePath);
@@ -130,6 +130,21 @@ module.exports = createInstallTargetAdapter({
];
}
if (
normalizedSourcePath === 'hooks'
|| normalizedSourcePath.startsWith('hooks/')
) {
const antigravityHooksSource = path.join('hooks', 'antigravity-hooks.json');
return [
createManagedOperation({
moduleId: module.id,
sourceRelativePath: antigravityHooksSource,
destinationPath: path.join(targetRoot, 'hooks.json'),
strategy: 'copy-file',
}),
];
}
return [];
});
});
+10 -9
View File
@@ -3,17 +3,18 @@
const { normalizeAgentTools } = require('../agent-tools');
const TOOL_NAMES = Object.freeze({
Read: 'view_file',
ReadFile: 'view_file',
NotebookRead: 'view_file',
Write: 'write_to_file',
Edit: 'replace_file_content',
MultiEdit: 'replace_file_content',
Grep: 'grep_search',
Glob: 'find_by_name',
Read: 'read_file',
ReadFile: 'read_file',
NotebookRead: 'read_file',
Write: 'write_file',
Edit: 'edit_file',
MultiEdit: 'edit_file',
Grep: 'run_command',
Glob: 'run_command',
Bash: 'run_command',
WebSearch: 'search_web',
WebFetch: 'read_url_content',
WebFetch: 'search_web',
Task: 'invoke_subagent',
});
const MODEL_NAMES = Object.freeze({
+135
View File
@@ -0,0 +1,135 @@
/**
* Contract tests for the Antigravity 2.0 hook bridge.
*/
'use strict';
const assert = require('assert');
const path = require('path');
const { spawnSync } = require('child_process');
const REPO_ROOT = path.resolve(__dirname, '..', '..');
const {
normalizeAntigravityToClaude,
resolveHookScript,
} = require(path.join(REPO_ROOT, 'scripts', 'antigravity', 'hook-bridge'));
let passed = 0;
let failed = 0;
function test(name, fn) {
try {
fn();
console.log(` \u2713 ${name}`);
passed += 1;
} catch (error) {
console.log(` \u2717 ${name}`);
console.log(` Error: ${error.message}`);
failed += 1;
}
}
console.log('=== Testing Antigravity Hook Bridge ===\n');
test('resolves known hook aliases to absolute paths', () => {
const resolved = resolveHookScript('config-protection');
assert.ok(resolved, 'Expected config-protection to resolve');
assert.ok(resolved.endsWith('config-protection.js'));
});
test('translates Antigravity edit_file payload to Claude Edit tool shape', () => {
const agyPayload = {
conversationId: 'test-conv-123',
toolCall: {
name: 'edit_file',
args: {
Path: 'eslint.config.js',
Target: 'old',
Replacement: 'new',
},
},
workspacePaths: [REPO_ROOT],
};
const claudePayload = normalizeAntigravityToClaude(agyPayload);
assert.strictEqual(claudePayload.session_id, 'test-conv-123');
assert.strictEqual(claudePayload.tool_name, 'Edit');
assert.strictEqual(claudePayload.tool_input.file_path, 'eslint.config.js');
assert.strictEqual(claudePayload.tool_input.path, 'eslint.config.js');
});
test('translates Antigravity run_command payload to Claude Bash tool shape', () => {
const agyPayload = {
conversationId: 'test-conv-456',
toolCall: {
name: 'run_command',
args: {
CommandLine: 'npm test',
},
},
workspacePaths: [REPO_ROOT],
};
const claudePayload = normalizeAntigravityToClaude(agyPayload);
assert.strictEqual(claudePayload.session_id, 'test-conv-456');
assert.strictEqual(claudePayload.tool_name, 'Bash');
assert.strictEqual(claudePayload.tool_input.command, 'npm test');
});
test('hook bridge blocks modifications to protected files via config-protection hook', () => {
const bridgeScript = path.join(REPO_ROOT, 'scripts', 'antigravity', 'hook-bridge.js');
const agyPayload = {
conversationId: 'block-test',
toolCall: {
name: 'edit_file',
args: {
Path: path.join(REPO_ROOT, 'eslint.config.js'),
Target: 'a',
Replacement: 'b',
},
},
workspacePaths: [REPO_ROOT],
};
const result = spawnSync(process.execPath, [bridgeScript, '--hook', 'config-protection'], {
input: JSON.stringify(agyPayload),
encoding: 'utf8',
cwd: REPO_ROOT,
});
assert.strictEqual(result.status, 0, 'Bridge itself should exit 0 with JSON decision');
const decision = JSON.parse(result.stdout.trim());
assert.strictEqual(decision.decision, 'deny');
assert.ok(decision.reason && decision.reason.length > 0);
});
test('hook bridge allows modifications to unprotected files via config-protection hook', () => {
const bridgeScript = path.join(REPO_ROOT, 'scripts', 'antigravity', 'hook-bridge.js');
const agyPayload = {
conversationId: 'allow-test',
toolCall: {
name: 'edit_file',
args: {
Path: path.join(REPO_ROOT, 'some-regular-feature.js'),
Target: 'a',
Replacement: 'b',
},
},
workspacePaths: [REPO_ROOT],
};
const result = spawnSync(process.execPath, [bridgeScript, '--hook', 'config-protection'], {
input: JSON.stringify(agyPayload),
encoding: 'utf8',
cwd: REPO_ROOT,
});
assert.strictEqual(result.status, 0);
const decision = JSON.parse(result.stdout.trim());
assert.strictEqual(decision.decision, 'allow');
});
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);
if (failed > 0) {
process.exit(1);
}
+16 -8
View File
@@ -79,14 +79,12 @@ test('transform maps Claude tools (including MultiEdit/ReadFile/NotebookRead), m
assert.strictEqual(parsed.model, 'pro');
assert.strictEqual(Object.hasOwn(parsed, 'color'), false);
assert.deepStrictEqual(parsed.tools, [
'view_file',
'replace_file_content',
'write_to_file',
'grep_search',
'find_by_name',
'read_file',
'edit_file',
'write_file',
'run_command',
'search_web',
'read_url_content',
'invoke_subagent',
]);
assert.ok(adapted.includes('## Role'));
assert.ok(adapted.includes('You simplify complex code.'));
@@ -108,7 +106,7 @@ test('transform parses quoted tool scalars and maps haiku to flash', () => {
const adapted = adaptAntigravityAgent(source, 'agents/fast-helper.md');
const parsed = yaml.load(adapted.match(/^---\n([\s\S]*?)\n---\n/)[1]);
assert.strictEqual(parsed.model, 'flash');
assert.deepStrictEqual(parsed.tools, ['view_file', 'replace_file_content']);
assert.deepStrictEqual(parsed.tools, ['read_file', 'edit_file']);
});
test('transform preserves CRLF line endings consistently on Windows-saved agents', () => {
@@ -129,7 +127,7 @@ test('transform preserves CRLF line endings consistently on Windows-saved agents
assert.ok(adapted.includes('\r\n'), 'Expected CRLF line endings to be preserved');
assert.ok(!/[^\r]\n/.test(adapted), 'Expected no mixed bare LF line endings in CRLF output');
assert.ok(!adapted.includes('color:'));
assert.ok(adapted.includes('replace_file_content'));
assert.ok(adapted.includes('edit_file'));
});
test('transform preserves mixed body line endings verbatim without rewriting body LFs', () => {
@@ -167,6 +165,7 @@ test('every planned operation is contained within .agents', () => {
{ id: 'agents-core', paths: ['agents', '.agents', 'AGENTS.md'] },
{ id: 'commands-core', paths: ['commands'] },
{ id: 'framework-language', paths: ['skills/api-design'] },
{ id: 'hooks-core', paths: ['hooks'] },
]);
const root = path.join('/project', '.agents');
assert.ok(operations.length > 0);
@@ -179,6 +178,15 @@ test('every planned operation is contained within .agents', () => {
}
});
test('plans hook operation copying antigravity-hooks.json to .agents/hooks.json', () => {
const operations = planFor([
{ id: 'hooks-core', paths: ['hooks'] },
]);
assert.strictEqual(operations.length, 1);
assert.strictEqual(operations[0].destinationPath, path.join('/project', '.agents', 'hooks.json'));
assert.strictEqual(operations[0].strategy, 'copy-file');
});
test('Antigravity installs non-Markdown agent assets byte-for-byte while adapting Markdown agents', () => {
const { createManifestInstallPlan, applyInstallPlan } = require('../../scripts/lib/install-executor');
const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-antigravity-agent-assets-'));