Merge remote-tracking branch 'origin/thedotmack/npx-gemini-cli' into thedotmack/npx-gemini-cli

Resolve merge conflicts in adapter index, gemini-cli adapter, and rebuilt CJS artifacts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alex Newman
2026-04-03 13:47:49 -07:00
53 changed files with 5248 additions and 5626 deletions
+3 -1
View File
@@ -3,6 +3,7 @@ import { claudeCodeAdapter } from './claude-code.js';
import { cursorAdapter } from './cursor.js';
import { geminiCliAdapter } from './gemini-cli.js';
import { rawAdapter } from './raw.js';
import { windsurfAdapter } from './windsurf.js';
export function getPlatformAdapter(platform: string): PlatformAdapter {
switch (platform) {
@@ -10,10 +11,11 @@ export function getPlatformAdapter(platform: string): PlatformAdapter {
case 'cursor': return cursorAdapter;
case 'gemini':
case 'gemini-cli': return geminiCliAdapter;
case 'windsurf': return windsurfAdapter;
case 'raw': return rawAdapter;
// Codex CLI and other compatible platforms use the raw adapter (accepts both camelCase and snake_case fields)
default: return rawAdapter;
}
}
export { claudeCodeAdapter, cursorAdapter, geminiCliAdapter, rawAdapter };
export { claudeCodeAdapter, cursorAdapter, geminiCliAdapter, rawAdapter, windsurfAdapter };
+79
View File
@@ -0,0 +1,79 @@
import type { PlatformAdapter, NormalizedHookInput, HookResult } from '../types.js';
// Maps Windsurf stdin format — JSON envelope with agent_action_name + tool_info payload
//
// Common envelope (all hooks):
// { agent_action_name, trajectory_id, execution_id, timestamp, tool_info: { ... } }
//
// Event-specific tool_info payloads:
// pre_user_prompt: { user_prompt: string }
// post_write_code: { file_path, edits: [{ old_string, new_string }] }
// post_run_command: { command_line, cwd }
// post_mcp_tool_use: { mcp_server_name, mcp_tool_name, mcp_tool_arguments, mcp_result }
// post_cascade_response: { response }
export const windsurfAdapter: PlatformAdapter = {
normalizeInput(raw) {
const r = (raw ?? {}) as any;
const toolInfo = r.tool_info ?? {};
const actionName: string = r.agent_action_name ?? '';
const base: NormalizedHookInput = {
sessionId: r.trajectory_id ?? r.execution_id,
cwd: toolInfo.cwd ?? process.cwd(),
platform: 'windsurf',
};
switch (actionName) {
case 'pre_user_prompt':
return {
...base,
prompt: toolInfo.user_prompt,
};
case 'post_write_code':
return {
...base,
toolName: 'Write',
filePath: toolInfo.file_path,
edits: toolInfo.edits,
toolInput: {
file_path: toolInfo.file_path,
edits: toolInfo.edits,
},
};
case 'post_run_command':
return {
...base,
cwd: toolInfo.cwd ?? base.cwd,
toolName: 'Bash',
toolInput: { command: toolInfo.command_line },
};
case 'post_mcp_tool_use':
return {
...base,
toolName: toolInfo.mcp_tool_name ?? 'mcp_tool',
toolInput: toolInfo.mcp_tool_arguments,
toolResponse: toolInfo.mcp_result,
};
case 'post_cascade_response':
return {
...base,
toolName: 'cascade_response',
toolResponse: toolInfo.response,
};
default:
// Unknown action — pass through what we can
return base;
}
},
formatOutput(result) {
// Windsurf exit codes: 0 = success, 2 = block (pre-hooks only)
// The CLI layer handles exit codes; here we just return a simple continue flag
return { continue: result.continue ?? true };
},
};
+1 -1
View File
@@ -39,7 +39,7 @@ export const contextHandler: EventHandler = {
// Pass all projects (parent + worktree if applicable) for unified timeline
const projectsParam = context.allProjects.join(',');
const apiPath = `/api/context/inject?projects=${encodeURIComponent(projectsParam)}`;
const colorApiPath = `${apiPath}&colors=true`;
const colorApiPath = input.platform === 'claude-code' ? `${apiPath}&colors=true` : apiPath;
// Note: Removed AbortSignal.timeout due to Windows Bun cleanup issue (libuv assertion)
// Worker service has its own timeouts, so client-side timeout is redundant
+3 -1
View File
@@ -23,9 +23,11 @@ export const userMessageHandler: EventHandler = {
const project = basename(input.cwd ?? process.cwd());
// Fetch formatted context directly from worker API
// Only request ANSI colors for platforms that render them (claude-code)
const colorsParam = input.platform === 'claude-code' ? '&colors=true' : '';
try {
const response = await workerHttpRequest(
`/api/context/inject?project=${encodeURIComponent(project)}&colors=true`
`/api/context/inject?project=${encodeURIComponent(project)}${colorsParam}`
);
if (!response.ok) {
+3 -1
View File
@@ -1,7 +1,7 @@
export interface NormalizedHookInput {
sessionId: string;
cwd: string;
platform?: string; // 'claude-code' or 'cursor'
platform?: string; // 'claude-code', 'cursor', 'gemini-cli', etc.
prompt?: string;
toolName?: string;
toolInput?: unknown;
@@ -10,6 +10,8 @@ export interface NormalizedHookInput {
// Cursor-specific fields
filePath?: string; // afterFileEdit
edits?: unknown[]; // afterFileEdit
// Platform-specific metadata (source, reason, trigger, mcp_context, etc.)
metadata?: Record<string, unknown>;
}
export interface HookResult {