Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ scratch/
AGENTS.md
GEMINI.md
.cch/

# Debug / scratch artifacts (never commit)
patch.diff
fix-await.ps1
fix_tests.py
35 changes: 35 additions & 0 deletions src/adapters/antigravity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { NormalizedHookInput } from './index';

export function fromAntigravity(raw: any): NormalizedHookInput {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocker, and it's about scope rather than code quality: we deliberately don't wire Antigravity capture yet. See isAntigravityMigrated in detect.ts and the gemini-antigravity-migration FAQ entry: because Google relocated hooks into a format it hasn't finalized publicly, we intentionally hold off on capture "rather than register hooks that quietly never run." This adapter guesses the payload shape (toolCall.arguments, write_file, etc.) against a spec that doesn't exist yet, so we can't verify it's correct. Could you drop fromAntigravity (and its entries in ALLOWED_ADAPTERS/HOOK_ADAPTERS/supported.ts) from this PR? When Google publishes the format we'll add it properly with a real payload fixture and the full install/detect wiring.

const toolCall = (raw.toolCall ?? {}) as Record<string, any>;
const toolInput = (toolCall.arguments ?? {}) as Record<string, any>;

const toolName = String(toolCall.name ?? '');
const sessionId = String(raw.session_id ?? raw.sessionId ?? '');
const rawFilePath = String(toolInput.file_path ?? toolInput.path ?? toolInput.filePath ?? '');

const oldContent = toolInput.old_string !== undefined ? String(toolInput.old_string) : (toolInput.oldContent !== undefined ? String(toolInput.oldContent) : undefined);
const newContent = toolInput.new_string !== undefined ? String(toolInput.new_string) : (toolInput.newContent !== undefined ? String(toolInput.newContent) : (toolInput.content !== undefined ? String(toolInput.content) : undefined));
const diff = raw.diff !== undefined ? String(raw.diff) : undefined;

const edits = Array.isArray(toolInput.edits)
? toolInput.edits.map((raw: any) => {
const e = (raw && typeof raw === 'object') ? raw : {};
return {
old_string: e.old_string !== undefined ? String(e.old_string) : undefined,
new_string: e.new_string !== undefined ? String(e.new_string) : undefined,
};
})
: undefined;

return {
toolName,
filePath: rawFilePath,
oldContent,
newContent,
diff,
sessionId,
source: 'antigravity',
edits
};
}
16 changes: 9 additions & 7 deletions src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { fromGemini } from './gemini';
import { fromCodex } from './codex';
import { fromCline } from './cline';
import { fromKimi } from './kimi';
import { fromAntigravity } from './antigravity';

export interface NormalizedHookInput {
toolName: string;
Expand All @@ -11,22 +12,23 @@ export interface NormalizedHookInput {
newContent?: string;
diff?: string;
sessionId: string;
source?: 'claude-code' | 'gemini' | 'codex' | 'cline' | 'kimi';
source?: 'claude-code' | 'gemini' | 'codex' | 'cline' | 'kimi' | 'antigravity';
edits?: Array<{ old_string?: string; new_string?: string }>;
}

export const ALLOWED_ADAPTERS = new Set(['claude-code', 'gemini', 'codex', 'cline', 'kimi']);
export const ALLOWED_ADAPTERS = new Set(['claude-code', 'gemini', 'codex', 'cline', 'kimi', 'antigravity']);

export function normalizeInput(raw: unknown, adapter: string): NormalizedHookInput {
if (!ALLOWED_ADAPTERS.has(adapter)) {
throw new Error(`Unsupported or invalid adapter: ${adapter}. Allowed adapters: ${[...ALLOWED_ADAPTERS].join(', ')}`);
}
const r = (raw ?? {}) as any;
switch (adapter) {
case 'gemini': return fromGemini(r);
case 'codex': return fromCodex(r);
case 'cline': return fromCline(r);
case 'kimi': return fromKimi(r);
default: return fromClaudeCode(r);
case 'gemini': return fromGemini(r);
case 'codex': return fromCodex(r);
case 'cline': return fromCline(r);
case 'kimi': return fromKimi(r);
case 'antigravity': return fromAntigravity(r);
default: return fromClaudeCode(r);
}
}
Loading
Loading