Files
ECC/scripts/lib/antigravity-hooks.js
T
MohamedAfrash 7e7ca11f21 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
2026-09-23 09:55:46 +01:00

80 lines
1.9 KiB
JavaScript

'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,
};