cyrus-gemini-runner 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +411 -0
  3. package/dist/GeminiRunner.d.ts +136 -0
  4. package/dist/GeminiRunner.d.ts.map +1 -0
  5. package/dist/GeminiRunner.js +683 -0
  6. package/dist/GeminiRunner.js.map +1 -0
  7. package/dist/SimpleGeminiRunner.d.ts +27 -0
  8. package/dist/SimpleGeminiRunner.d.ts.map +1 -0
  9. package/dist/SimpleGeminiRunner.js +149 -0
  10. package/dist/SimpleGeminiRunner.js.map +1 -0
  11. package/dist/adapters.d.ts +37 -0
  12. package/dist/adapters.d.ts.map +1 -0
  13. package/dist/adapters.js +317 -0
  14. package/dist/adapters.js.map +1 -0
  15. package/dist/formatter.d.ts +40 -0
  16. package/dist/formatter.d.ts.map +1 -0
  17. package/dist/formatter.js +363 -0
  18. package/dist/formatter.js.map +1 -0
  19. package/dist/index.d.ts +36 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +56 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/prompts/system.md +108 -0
  24. package/dist/schemas.d.ts +1472 -0
  25. package/dist/schemas.d.ts.map +1 -0
  26. package/dist/schemas.js +678 -0
  27. package/dist/schemas.js.map +1 -0
  28. package/dist/settingsGenerator.d.ts +72 -0
  29. package/dist/settingsGenerator.d.ts.map +1 -0
  30. package/dist/settingsGenerator.js +255 -0
  31. package/dist/settingsGenerator.js.map +1 -0
  32. package/dist/systemPromptManager.d.ts +27 -0
  33. package/dist/systemPromptManager.d.ts.map +1 -0
  34. package/dist/systemPromptManager.js +65 -0
  35. package/dist/systemPromptManager.js.map +1 -0
  36. package/dist/types.d.ts +113 -0
  37. package/dist/types.d.ts.map +1 -0
  38. package/dist/types.js +23 -0
  39. package/dist/types.js.map +1 -0
  40. package/package.json +37 -0
@@ -0,0 +1,363 @@
1
+ /**
2
+ * Gemini Message Formatter
3
+ *
4
+ * Implements message formatting for Gemini CLI tool messages.
5
+ * This formatter understands Gemini's specific tool format and converts
6
+ * tool use/result messages into human-readable content for Linear.
7
+ *
8
+ * Gemini CLI tool names:
9
+ * - read_file: Read file contents
10
+ * - write_file: Write content to a file
11
+ * - list_directory: List directory contents
12
+ * - search_file_content: Search for patterns in files
13
+ * - run_shell_command: Execute shell commands
14
+ * - write_todos: Update task list
15
+ * - replace: Edit/replace content in files
16
+ */
17
+ /**
18
+ * Helper to safely get a string property from tool input
19
+ */
20
+ function getString(input, key) {
21
+ const value = input[key];
22
+ return typeof value === "string" ? value : undefined;
23
+ }
24
+ /**
25
+ * Helper to safely get a number property from tool input
26
+ */
27
+ function getNumber(input, key) {
28
+ const value = input[key];
29
+ return typeof value === "number" ? value : undefined;
30
+ }
31
+ /**
32
+ * Helper to check if a property exists and is truthy
33
+ */
34
+ function hasProperty(input, key) {
35
+ return key in input && input[key] !== undefined && input[key] !== null;
36
+ }
37
+ export class GeminiMessageFormatter {
38
+ /**
39
+ * Format TodoWrite tool parameter as a nice checklist
40
+ */
41
+ formatTodoWriteParameter(jsonContent) {
42
+ try {
43
+ const data = JSON.parse(jsonContent);
44
+ if (!data.todos || !Array.isArray(data.todos)) {
45
+ return jsonContent;
46
+ }
47
+ const todos = data.todos;
48
+ // Keep original order but add status indicators
49
+ let formatted = "\n";
50
+ todos.forEach((todo, index) => {
51
+ let statusEmoji = "";
52
+ if (todo.status === "completed") {
53
+ statusEmoji = "✅ ";
54
+ }
55
+ else if (todo.status === "in_progress") {
56
+ statusEmoji = "🔄 ";
57
+ }
58
+ else if (todo.status === "pending") {
59
+ statusEmoji = "⏳ ";
60
+ }
61
+ // Gemini uses 'description' instead of 'content' for todo items
62
+ const todoText = todo.description || todo.content || "";
63
+ formatted += `${statusEmoji}${todoText}`;
64
+ if (index < todos.length - 1) {
65
+ formatted += "\n";
66
+ }
67
+ });
68
+ return formatted;
69
+ }
70
+ catch (error) {
71
+ console.error("[GeminiMessageFormatter] Failed to format TodoWrite parameter:", error);
72
+ return jsonContent;
73
+ }
74
+ }
75
+ /**
76
+ * Format tool input for display in Linear agent activities
77
+ * Converts raw tool inputs into user-friendly parameter strings
78
+ */
79
+ formatToolParameter(toolName, toolInput) {
80
+ // If input is already a string, return it
81
+ if (typeof toolInput === "string") {
82
+ return toolInput;
83
+ }
84
+ try {
85
+ switch (toolName) {
86
+ // Gemini tool names
87
+ case "run_shell_command": {
88
+ // Show command only
89
+ const command = getString(toolInput, "command");
90
+ return command || JSON.stringify(toolInput);
91
+ }
92
+ case "read_file": {
93
+ const filePath = getString(toolInput, "file_path");
94
+ if (filePath) {
95
+ let param = filePath;
96
+ const offset = getNumber(toolInput, "offset");
97
+ const limit = getNumber(toolInput, "limit");
98
+ if (offset !== undefined || limit !== undefined) {
99
+ const start = offset || 0;
100
+ const end = limit ? start + limit : "end";
101
+ param += ` (lines ${start + 1}-${end})`;
102
+ }
103
+ return param;
104
+ }
105
+ break;
106
+ }
107
+ case "write_file": {
108
+ const filePath = getString(toolInput, "file_path");
109
+ if (filePath) {
110
+ return filePath;
111
+ }
112
+ break;
113
+ }
114
+ case "replace": {
115
+ // Gemini's replace tool has instruction and file_path
116
+ const filePath = getString(toolInput, "file_path");
117
+ if (filePath) {
118
+ let param = filePath;
119
+ const instruction = getString(toolInput, "instruction");
120
+ if (instruction) {
121
+ param += ` - ${instruction.substring(0, 50)}${instruction.length > 50 ? "..." : ""}`;
122
+ }
123
+ return param;
124
+ }
125
+ break;
126
+ }
127
+ case "search_file_content": {
128
+ const pattern = getString(toolInput, "pattern");
129
+ if (pattern) {
130
+ let param = `Pattern: \`${pattern}\``;
131
+ const path = getString(toolInput, "path");
132
+ if (path) {
133
+ param += ` in ${path}`;
134
+ }
135
+ const glob = getString(toolInput, "glob");
136
+ if (glob) {
137
+ param += ` (${glob})`;
138
+ }
139
+ return param;
140
+ }
141
+ break;
142
+ }
143
+ case "list_directory": {
144
+ const dirPath = getString(toolInput, "dir_path");
145
+ if (dirPath) {
146
+ return dirPath;
147
+ }
148
+ const path = getString(toolInput, "path");
149
+ if (path) {
150
+ return path;
151
+ }
152
+ return ".";
153
+ }
154
+ case "write_todos":
155
+ if (hasProperty(toolInput, "todos") &&
156
+ Array.isArray(toolInput.todos)) {
157
+ return this.formatTodoWriteParameter(JSON.stringify(toolInput));
158
+ }
159
+ break;
160
+ default:
161
+ // For MCP tools or other unknown tools, try to extract meaningful info
162
+ if (toolName.startsWith("mcp__")) {
163
+ // Extract key fields that are commonly meaningful
164
+ const meaningfulFields = [
165
+ "query",
166
+ "id",
167
+ "issueId",
168
+ "title",
169
+ "name",
170
+ "path",
171
+ "file",
172
+ ];
173
+ for (const field of meaningfulFields) {
174
+ const value = getString(toolInput, field);
175
+ if (value) {
176
+ return `${field}: ${value}`;
177
+ }
178
+ }
179
+ }
180
+ break;
181
+ }
182
+ // Fallback to JSON but make it compact
183
+ return JSON.stringify(toolInput);
184
+ }
185
+ catch (error) {
186
+ console.error("[GeminiMessageFormatter] Failed to format tool parameter:", error);
187
+ return JSON.stringify(toolInput);
188
+ }
189
+ }
190
+ /**
191
+ * Format tool action name with description for shell command tool
192
+ * Puts the description in round brackets after the tool name in the action field
193
+ */
194
+ formatToolActionName(toolName, toolInput, isError) {
195
+ // Handle run_shell_command tool with description
196
+ if (toolName === "run_shell_command") {
197
+ const description = getString(toolInput, "description");
198
+ if (description) {
199
+ const baseName = isError ? `${toolName} (Error)` : toolName;
200
+ return `${baseName} (${description})`;
201
+ }
202
+ }
203
+ // Default formatting for other tools
204
+ return isError ? `${toolName} (Error)` : toolName;
205
+ }
206
+ /**
207
+ * Format tool result for display in Linear agent activities
208
+ * Converts raw tool results into formatted Markdown
209
+ */
210
+ formatToolResult(toolName, toolInput, result, isError) {
211
+ // If there's an error, wrap in error formatting
212
+ if (isError) {
213
+ return `\`\`\`\n${result}\n\`\`\``;
214
+ }
215
+ try {
216
+ switch (toolName) {
217
+ // Gemini tool names
218
+ case "run_shell_command": {
219
+ let formatted = "";
220
+ const command = getString(toolInput, "command");
221
+ const description = getString(toolInput, "description");
222
+ if (command && !description) {
223
+ formatted += `\`\`\`bash\n${command}\n\`\`\`\n\n`;
224
+ }
225
+ if (result?.trim()) {
226
+ formatted += `\`\`\`\n${result}\n\`\`\``;
227
+ }
228
+ else {
229
+ formatted += "*No output*";
230
+ }
231
+ return formatted;
232
+ }
233
+ case "read_file": {
234
+ // Gemini CLI returns empty output on success - file content goes into model context
235
+ // Only show content if Gemini actually returns something (which it typically doesn't)
236
+ if (result?.trim()) {
237
+ // Clean up the result: remove line numbers and system-reminder tags
238
+ let cleanedResult = result;
239
+ // Remove line numbers (format: " 123→")
240
+ cleanedResult = cleanedResult.replace(/^\s*\d+→/gm, "");
241
+ // Remove system-reminder blocks
242
+ cleanedResult = cleanedResult.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g, "");
243
+ // Trim only blank lines (not horizontal whitespace) to preserve indentation
244
+ cleanedResult = cleanedResult
245
+ .replace(/^\n+/, "")
246
+ .replace(/\n+$/, "");
247
+ // Try to detect language from file extension
248
+ let lang = "";
249
+ const filePath = getString(toolInput, "file_path");
250
+ if (filePath) {
251
+ const ext = filePath.split(".").pop()?.toLowerCase();
252
+ const langMap = {
253
+ ts: "typescript",
254
+ tsx: "typescript",
255
+ js: "javascript",
256
+ jsx: "javascript",
257
+ py: "python",
258
+ rb: "ruby",
259
+ go: "go",
260
+ rs: "rust",
261
+ java: "java",
262
+ c: "c",
263
+ cpp: "cpp",
264
+ cs: "csharp",
265
+ php: "php",
266
+ swift: "swift",
267
+ kt: "kotlin",
268
+ scala: "scala",
269
+ sh: "bash",
270
+ bash: "bash",
271
+ zsh: "bash",
272
+ yml: "yaml",
273
+ yaml: "yaml",
274
+ json: "json",
275
+ xml: "xml",
276
+ html: "html",
277
+ css: "css",
278
+ scss: "scss",
279
+ md: "markdown",
280
+ sql: "sql",
281
+ };
282
+ lang = langMap[ext || ""] || "";
283
+ }
284
+ return `\`\`\`${lang}\n${cleanedResult}\n\`\`\``;
285
+ }
286
+ // Gemini returns empty output on success - this is normal, not an empty file
287
+ return "*File read successfully*";
288
+ }
289
+ case "write_file":
290
+ if (result?.trim()) {
291
+ return result;
292
+ }
293
+ return "*File written successfully*";
294
+ case "replace": {
295
+ // For replace/edit, show the instruction if available
296
+ const oldString = getString(toolInput, "old_string");
297
+ const newString = getString(toolInput, "new_string");
298
+ if (oldString && newString) {
299
+ // Format as a unified diff
300
+ const oldLines = oldString.split("\n");
301
+ const newLines = newString.split("\n");
302
+ let diff = "```diff\n";
303
+ for (const line of oldLines) {
304
+ diff += `-${line}\n`;
305
+ }
306
+ for (const line of newLines) {
307
+ diff += `+${line}\n`;
308
+ }
309
+ diff += "```";
310
+ return diff;
311
+ }
312
+ const instruction = getString(toolInput, "instruction");
313
+ if (instruction) {
314
+ return `*${instruction}*\n\n${result || "Edit completed"}`;
315
+ }
316
+ if (result?.trim()) {
317
+ return result;
318
+ }
319
+ return "*Edit completed*";
320
+ }
321
+ case "search_file_content": {
322
+ if (result?.trim()) {
323
+ const lines = result.split("\n");
324
+ if (lines.length > 0 &&
325
+ lines[0] &&
326
+ !lines[0].includes(":") &&
327
+ lines[0].trim().length > 0) {
328
+ return `Found ${lines.filter((l) => l.trim()).length} matching files:\n\`\`\`\n${result}\n\`\`\``;
329
+ }
330
+ return `\`\`\`\n${result}\n\`\`\``;
331
+ }
332
+ return "*No matches found*";
333
+ }
334
+ case "list_directory": {
335
+ if (result?.trim()) {
336
+ const lines = result.split("\n").filter((l) => l.trim());
337
+ return `Found ${lines.length} items:\n\`\`\`\n${result}\n\`\`\``;
338
+ }
339
+ return "*Empty directory*";
340
+ }
341
+ case "write_todos":
342
+ if (result?.trim()) {
343
+ return result;
344
+ }
345
+ return "*Todos updated*";
346
+ default:
347
+ // For unknown tools, use code block if result has multiple lines
348
+ if (result?.trim()) {
349
+ if (result.includes("\n") && result.length > 100) {
350
+ return `\`\`\`\n${result}\n\`\`\``;
351
+ }
352
+ return result;
353
+ }
354
+ return "*Completed*";
355
+ }
356
+ }
357
+ catch (error) {
358
+ console.error("[GeminiMessageFormatter] Failed to format tool result:", error);
359
+ return result || "";
360
+ }
361
+ }
362
+ }
363
+ //# sourceMappingURL=formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH;;GAEG;AACH,SAAS,SAAS,CAAC,KAAyB,EAAE,GAAW;IACxD,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAED;;GAEG;AACH,SAAS,SAAS,CAAC,KAAyB,EAAE,GAAW;IACxD,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,KAAyB,EAAE,GAAW;IAC1D,OAAO,GAAG,IAAI,KAAK,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;AACxE,CAAC;AAED,MAAM,OAAO,sBAAsB;IAClC;;OAEG;IACH,wBAAwB,CAAC,WAAmB;QAC3C,IAAI,CAAC;YACJ,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACrC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/C,OAAO,WAAW,CAAC;YACpB,CAAC;YAED,MAAM,KAAK,GAAG,IAAI,CAAC,K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oBACC,iEAAiE;oBACjE,IAAI,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;wBACpB,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;4BAClD,OAAO,WAAW,MAAM,UAAU,CAAC;wBACpC,CAAC;wBACD,OAAO,MAAM,CAAC;oBACf,CAAC;oBACD,OAAO,aAAa,CAAC;YACvB,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CACZ,wDAAwD,EACxD,KAAK,CACL,CAAC;YACF,OAAO,MAAM,IAAI,EAAE,CAAC;QACrB,CAAC;IACF,CAAC;CACD"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @module cyrus-gemini-runner
3
+ *
4
+ * Gemini CLI integration for Cyrus agent framework.
5
+ * Provides a provider-agnostic wrapper around the Gemini CLI that implements
6
+ * the IAgentRunner interface, allowing seamless switching between Claude and Gemini.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { GeminiRunner } from 'cyrus-gemini-runner';
11
+ *
12
+ * const runner = new GeminiRunner({
13
+ * cyrusHome: '/home/user/.cyrus',
14
+ * workingDirectory: '/path/to/repo',
15
+ * model: 'gemini-2.5-flash',
16
+ * autoApprove: true
17
+ * });
18
+ *
19
+ * // Start a session
20
+ * const session = await runner.start("Analyze this codebase");
21
+ * console.log(`Session ID: ${session.sessionId}`);
22
+ *
23
+ * // Get messages
24
+ * const messages = runner.getMessages();
25
+ * console.log(`Received ${messages.length} messages`);
26
+ * ```
27
+ */
28
+ export { createUserMessage, extractSessionId, geminiEventToSDKMessage, } from "./adapters.js";
29
+ export { GeminiMessageFormatter } from "./formatter.js";
30
+ export { GeminiRunner } from "./GeminiRunner.js";
31
+ export { SimpleGeminiRunner } from "./SimpleGeminiRunner.js";
32
+ export { extractToolNameFromId, GeminiErrorEventSchema, GeminiInitEventSchema, GeminiMessageEventSchema, GeminiResultEventSchema, GeminiStreamEventSchema, GeminiToolParametersSchema, GeminiToolResultEventSchema, GeminiToolUseEventSchema, isGeminiErrorEvent, isGeminiInitEvent, isGeminiMessageEvent, isGeminiResultEvent, isGeminiToolResultEvent, isGeminiToolUseEvent, isListDirectoryTool, isListDirectoryToolResult, isReadFileTool, isReadFileToolResult, isReplaceTool, isReplaceToolResult, isRunShellCommandTool, isRunShellCommandToolResult, isSearchFileContentTool, isSearchFileContentToolResult, isWriteFileTool, isWriteFileToolResult, isWriteTodosTool, isWriteTodosToolResult, ListDirectoryParametersSchema, ListDirectoryToolResultSchema, ListDirectoryToolUseEventSchema, parseAsListDirectoryTool, parseAsReadFileTool, parseAsReplaceTool, parseAsRunShellCommandTool, parseAsSearchFileContentTool, parseAsWriteFileTool, parseAsWriteTodosTool, parseGeminiStreamEvent, ReadFileParametersSchema, ReadFileToolResultSchema, ReadFileToolUseEventSchema, ReplaceParametersSchema, ReplaceToolResultSchema, ReplaceToolUseEventSchema, RunShellCommandParametersSchema, RunShellCommandToolResultSchema, RunShellCommandToolUseEventSchema, SearchFileContentParametersSchema, SearchFileContentToolResultSchema, SearchFileContentToolUseEventSchema, safeParseGeminiStreamEvent, TodoItemSchema, UnknownToolUseEventSchema, WriteFileParametersSchema, WriteFileToolResultSchema, WriteFileToolUseEventSchema, WriteTodosParametersSchema, WriteTodosToolResultSchema, WriteTodosToolUseEventSchema, } from "./schemas.js";
33
+ export { autoDetectMcpConfig, backupGeminiSettings, convertToGeminiMcpConfig, deleteGeminiSettings, type GeminiSettingsOptions, loadMcpConfigFromPaths, restoreGeminiSettings, setupGeminiSettings, writeGeminiSettings, } from "./settingsGenerator.js";
34
+ export { SystemPromptManager } from "./systemPromptManager.js";
35
+ export type { GeminiErrorEvent, GeminiInitEvent, GeminiMcpServerConfig, GeminiMessageEvent, GeminiResultEvent, GeminiRunnerConfig, GeminiRunnerEvents, GeminiSessionInfo, GeminiStreamEvent, GeminiToolParameters, GeminiToolResultEvent, GeminiToolUseEvent, ListDirectoryParameters, ListDirectoryToolResult, ListDirectoryToolUseEvent, McpServerConfig, ReadFileParameters, ReadFileToolResult, ReadFileToolUseEvent, ReplaceParameters, ReplaceToolResult, ReplaceToolUseEvent, RunShellCommandParameters, RunShellCommandToolResult, RunShellCommandToolUseEvent, SearchFileContentParameters, SearchFileContentToolResult, SearchFileContentToolUseEvent, TodoItem, UnknownToolUseEvent, WriteFileParameters, WriteFileToolResult, WriteFileToolUseEvent, WriteTodosParameters, WriteTodosToolResult, WriteTodosToolUseEvent, } from "./types.js";
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EACN,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,GACvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAEN,qBAAqB,EAErB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EAEvB,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EAExB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EAEpB,mBAAmB,EAEnB,yBAAyB,EACzB,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,uBAAuB,EACvB,6BAA6B,EAC7B,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,6BAA6B,EAE7B,6BAA6B,EAC7B,+BAA+B,EAC/B,wBAAwB,EACxB,mB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
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @module cyrus-gemini-runner
3
+ *
4
+ * Gemini CLI integration for Cyrus agent framework.
5
+ * Provides a provider-agnostic wrapper around the Gemini CLI that implements
6
+ * the IAgentRunner interface, allowing seamless switching between Claude and Gemini.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { GeminiRunner } from 'cyrus-gemini-runner';
11
+ *
12
+ * const runner = new GeminiRunner({
13
+ * cyrusHome: '/home/user/.cyrus',
14
+ * workingDirectory: '/path/to/repo',
15
+ * model: 'gemini-2.5-flash',
16
+ * autoApprove: true
17
+ * });
18
+ *
19
+ * // Start a session
20
+ * const session = await runner.start("Analyze this codebase");
21
+ * console.log(`Session ID: ${session.sessionId}`);
22
+ *
23
+ * // Get messages
24
+ * const messages = runner.getMessages();
25
+ * console.log(`Received ${messages.length} messages`);
26
+ * ```
27
+ */
28
+ // Adapter functions
29
+ export { createUserMessage, extractSessionId, geminiEventToSDKMessage, } from "./adapters.js";
30
+ // Formatter
31
+ export { GeminiMessageFormatter } from "./formatter.js";
32
+ // Main runner class
33
+ export { GeminiRunner } from "./GeminiRunner.js";
34
+ // Simple agent runner
35
+ export { SimpleGeminiRunner } from "./SimpleGeminiRunner.js";
36
+ // Zod schemas and validation utilities
37
+ export {
38
+ // Parsing utilities
39
+ extractToolNameFromId,
40
+ // Event schemas
41
+ GeminiErrorEventSchema, GeminiInitEventSchema, GeminiMessageEventSchema, GeminiResultEventSchema, GeminiStreamEventSchema,
42
+ // Tool parameter schemas
43
+ GeminiToolParametersSchema, GeminiToolResultEventSchema, GeminiToolUseEventSchema,
44
+ // Event type guards
45
+ isGeminiErrorEvent, isGeminiInitEvent, isGeminiMessageEvent, isGeminiResultEvent, isGeminiToolResultEvent, isGeminiToolUseEvent,
46
+ // Tool use type guards
47
+ isListDirectoryTool,
48
+ // Tool result type guards
49
+ isListDirectoryToolResult, isReadFileTool, isReadFileToolResult, isReplaceTool, isReplaceToolResult, isRunShellCommandTool, isRunShellCommandToolResult, isSearchFileContentTool, isSearchFileContentToolResult, isWriteFileTool, isWriteFileToolResult, isWriteTodosTool, isWriteTodosToolResult, ListDirectoryParametersSchema,
50
+ // Tool result schemas
51
+ ListDirectoryToolResultSchema, ListDirectoryToolUseEventSchema, parseAsListDirectoryTool, parseAsReadFileTool, parseAsReplaceTool, parseAsRunShellCommandTool, parseAsSearchFileContentTool, parseAsWriteFileTool, parseAsWriteTodosTool, parseGeminiStreamEvent, ReadFileParametersSchema, ReadFileToolResultSchema, ReadFileToolUseEventSchema, ReplaceParametersSchema, ReplaceToolResultSchema, ReplaceToolUseEventSchema, RunShellCommandParametersSchema, RunShellCommandToolResultSchema, RunShellCommandToolUseEventSchema, SearchFileContentParametersSchema, SearchFileContentToolResultSchema, SearchFileContentToolUseEventSchema, safeParseGeminiStreamEvent, TodoItemSchema, UnknownToolUseEventSchema, WriteFileParametersSchema, WriteFileToolResultSchema, WriteFileToolUseEventSchema, WriteTodosParametersSchema, WriteTodosToolResultSchema, WriteTodosToolUseEventSchema, } from "./schemas.js";
52
+ // Settings generator utilities (for MCP configuration)
53
+ export { autoDetectMcpConfig, backupGeminiSettings, convertToGeminiMcpConfig, deleteGeminiSettings, loadMcpConfigFromPaths, restoreGeminiSettings, setupGeminiSettings, writeGeminiSettings, } from "./settingsGenerator.js";
54
+ // System prompt manager
55
+ export { SystemPromptManager } from "./systemPromptManager.js";
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,oBAAoB;AACpB,OAAO,EACN,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,GACvB,MAAM,eAAe,CAAC;AACvB,YAAY;AACZ,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,oBAAoB;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,C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BAAmB,EACnB,mBAAmB,GACnB,MAAM,wBAAwB,CAAC;AAChC,wBAAwB;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,108 @@
1
+ You are an interactive CLI agent specializing in software engineering tasks. Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools.
2
+
3
+ # Core Mandates
4
+
5
+ - **Conventions:** Rigorously adhere to existing project conventions when reading or modifying code. Analyze surrounding code, tests, and configuration first.
6
+ - **Libraries/Frameworks:** NEVER assume a library/framework is available or appropriate. Verify its established usage within the project (check imports, configuration files like 'package.json', 'Cargo.toml', 'requirements.txt', 'build.gradle', etc., or observe neighboring files) before employing it.
7
+ - **Style & Structure:** Mimic the style (formatting, naming), structure, framework choices, typing, and architectural patterns of existing code in the project.
8
+ - **Idiomatic Changes:** When editing, understand the local context (imports, functions/classes) to ensure your changes integrate naturally and idiomatically.
9
+ - **Comments:** Add code comments sparingly. Focus on *why* something is done, especially for complex logic, rather than *what* is done. Only add high-value comments if necessary for clarity or if requested by the user. Do not edit comments that are separate from the code you are changing. *NEVER* talk to the user or describe your changes through comments.
10
+ - **Proactiveness:** Fulfill the user's request thoroughly. When adding features or fixing bugs, this includes adding tests to ensure quality. Consider all created files, especially tests, to be permanent artifacts unless the user says otherwise.
11
+ - **Confirm Ambiguity/Expansion:** Do not take significant actions beyond the clear scope of the request without confirming with the user. If asked *how* to do something, explain first, don't just do it.
12
+ - **Explaining Changes:** After completing a code modification or file operation *do not* provide summaries unless asked.
13
+ - **Do Not revert changes:** Do not revert changes to the codebase unless asked to do so by the user. Only revert changes made by you if they have resulted in an error or if the user has explicitly asked you to revert the changes.
14
+
15
+ # Primary Workflows
16
+
17
+ ## Software Engineering Tasks
18
+ When requested to perform tasks like fixing bugs, adding features, refactoring, or explaining code, follow this sequence:
19
+ 1. **Understand & Strategize:** Think about the user's request and the relevant codebase context. When the task involves **complex refactoring, codebase exploration or system-wide analysis**, your **first and primary tool** must be 'codebase_investigator'. Use it to build a comprehensive understanding of the code, its structure, and dependencies. For **simple, targeted searches** (like finding a specific function name, file path, or variable declaration), you should use 'search_file_content' or 'glob' directly.
20
+ 2. **Plan:** Build a coherent and grounded (based on the understanding in step 1) plan for how you intend to resolve the user's task. If 'codebase_investigator' was used, do not ignore the output of 'codebase_investigator', you must use it as the foundation of your plan. For complex tasks, break them down into smaller, manageable subtasks and use the `write_todos` tool to track your progress. Share an extremely concise yet clear plan with the user if it would help the user understand your thought process. As part of the plan, you should use an iterative development process that includes writing unit tests to verify your changes. Use output logs or debug statements as part of this process to arrive at a solution.
21
+ 3. **Implement:** Use the available tools (e.g., 'replace', 'write_file' 'run_shell_command' ...) to act on the plan, strictly adhering to the project's established conventions (detailed under 'Core
22
+ Mandates').
23
+ 4. **Verify (Tests):** If applicable and feasible, verify the changes using the project's testing procedures. Identify the correct test commands and frameworks by examining 'README' files, build/package configuration (e.g., 'package.json'), or existing test execution patterns. NEVER assume standard test commands.
24
+ 5. **Verify (Standards):** VERY IMPORTANT: After making code changes, execute the project-specific build, linting and type-checking commands (e.g., 'tsc', 'npm run lint', 'ruff check .') that you have identified for this project (or obtained from the user). This ensures code quality and adherence to standards. If unsure about these commands, you can ask the user if they'd like you to run them and if so how to.
25
+ 6. **Finalize:** After all verification passes, consider the task complete. Do not remove or revert any changes or created files (like tests). Await the user's next instruction.
26
+
27
+ ## New Applications
28
+
29
+ **Goal:** Autonomously implement and deliver a visually appealing, substantially complete, and functional prototype. Utilize all tools at your disposal to implement the application. Some tools you may especially find useful are 'write_file', 'replace' and 'run_shell_command'.
30
+
31
+ 1. **Understand Requirements:** Analyze the user's request to identify core features, desired user experience (UX), visual aesthetic, application type/platform (web, mobile, desktop, CLI, library, 2D or 3D game), and explicit constraints. If critical information for initial planning is missing or ambiguous, ask concise, targeted clarification questions.
32
+ 2. **Propose Plan:** Formulate an internal development plan. Present a clear, concise, high-level summary to the user. This summary must effectively convey the application's type and core purpose, key technologies to be used, main features and how users will interact with them, and the general approach to the visual design and user experience (UX) with the intention of delivering something beautiful, modern, and polished, especially for UI-based applications. For applications requiring visual assets (like games or rich UIs), briefly describe the strategy for sourcing or generating placeholders (e.g., simple geometric shapes, procedurally generated patterns, or open-source assets if feasible and licenses permit) to ensure a visually complete initial prototype. Ensure this information is presented in a structured and easily digestible manner.
33
+ - When key technologies aren't specified, prefer the following:
34
+ - **Websites (Frontend):** React (JavaScript/TypeScript) or Angular with Bootstrap CSS, incorporating Material Design principles for UI/UX.
35
+ - **Back-End APIs:** Node.js with Express.js (JavaScript/TypeScript) or Python with FastAPI.
36
+ - **Full-stack:** Next.js (React/Node.js) using Bootstrap CSS and Material Design principles for the frontend, or Python (Django/Flask) for the backend with a React/Vue.js/Angular frontend styled with Bootstrap CSS and Material Design principles.
37
+ - **CLIs:** Python or Go.
38
+ - **Mobile App:** Compose Multiplatform (Kotlin Multiplatform) or Flutter (Dart) using Material Design libraries and principles, when sharing code between Android and iOS. Jetpack Compose (Kotlin JVM) with Material Design principles or SwiftUI (Swift) for native apps targeted at either Android or iOS, respectively.
39
+ - **3d Games:** HTML/CSS/JavaScript with Three.js.
40
+ - **2d Games:** HTML/CSS/JavaScript.
41
+ 3. **User Approval:** Obtain user approval for the proposed plan.
42
+ 4. **Implementation:** Autonomously implement each feature and design element per the approved plan utilizing all available tools. When starting ensure you scaffold the application using 'run_shell_command' for commands like 'npm init', 'npx create-react-app'. Aim for full scope completion. Proactively create or source necessary placeholder assets (e.g., images, icons, game sprites, 3D models using basic primitives if complex assets are not generatable) to ensure the application is visually coherent and functional, minimizing reliance on the user to provide these. If the model can generate simple assets (e.g., a uniformly colored square sprite, a simple 3D cube), it should do so. Otherwise, it should clearly indicate what kind of placeholder has been used and, if absolutely necessary, what the user might replace it with. Use placeholders only when essential for progress, intending to replace them with more refined versions or instruct the user on replacement during polishing if generation is not feasible.
43
+ 5. **Verify:** Review work against the original request, the approved plan. Fix bugs, deviations, and all placeholders where feasible, or ensure placeholders are visually adequate for a prototype. Ensure styling, interactions, produce a high-quality, functional and beautiful prototype aligned with design goals. Finally, but MOST importantly, build the application and ensure there are no compile errors.
44
+ 6. **Solicit Feedback:** If still applicable, provide instructions on how to start the application and request user feedback on the prototype.
45
+
46
+ # Operational Guidelines
47
+
48
+ ## Shell tool output token efficiency:
49
+
50
+ IT IS CRITICAL TO FOLLOW THESE GUIDELINES TO AVOID EXCESSIVE TOKEN CONSUMPTION.
51
+
52
+ - Always prefer command flags that reduce output verbosity when using 'run_shell_command'.
53
+ - Aim to minimize tool output tokens while still capturing necessary information.
54
+ - If a command is expected to produce a lot of output, use quiet or silent flags where available and appropriate.
55
+ - Always consider the trade-off between output verbosity and the need for information. If a command's full output is essential for understanding the result, avoid overly aggressive quieting that might obscure important details.
56
+ - If a command does not have quiet/silent flags or for commands with potentially long output that may not be useful, redirect stdout and stderr to temp files in the project's temporary directory. For example: 'command > <temp_dir>/out.log 2> <temp_dir>/err.log'.
57
+ - After the command runs, inspect the temp files (e.g. '<temp_dir>/out.log' and '<temp_dir>/err.log') using commands like 'grep', 'tail', 'head', ... (or platform equivalents). Remove the temp files when done.
58
+
59
+
60
+ ## Tone and Style (CLI Interaction)
61
+ - **Concise & Direct:** Adopt a professional, direct, and concise tone suitable for a CLI environment.
62
+ - **Minimal Output:** Aim for fewer than 3 lines of text output (excluding tool use/code generation) per response whenever practical. Focus strictly on the user's query.
63
+ - **Clarity over Brevity (When Needed):** While conciseness is key, prioritize clarity for essential explanations or when seeking necessary clarification if a request is ambiguous.
64
+ - **No Chitchat:** Avoid conversational filler, preambles ("Okay, I will now..."), or postambles ("I have finished the changes..."). Get straight to the action or answer.
65
+ - **Formatting:** Use GitHub-flavored Markdown. Responses will be rendered in monospace.
66
+ - **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls or code blocks unless specifically part of the required code/command itself.
67
+ - **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly (1-2 sentences) without excessive justification. Offer alternatives if appropriate.
68
+
69
+ ## Security and Safety Rules
70
+ - **Explain Critical Commands:** Before executing commands with 'run_shell_command' that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this).
71
+ - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information.
72
+
73
+ ## Tool Usage
74
+ - **Parallelism:** Execute multiple independent tool calls in parallel when feasible (i.e. searching the codebase).
75
+ - **Command Execution:** Use the 'run_shell_command' tool for running shell commands, remembering the safety rule to explain modifying commands first.
76
+ - **Background Processes:** Use background processes (via `&`) for commands that are unlikely to stop on their own, e.g. `node server.js &`. If unsure, ask the user.
77
+ - **Interactive Commands:** Some commands are interactive, meaning they can accept user input during their execution (e.g. ssh, vim). Only execute non-interactive commands. Use non-interactive versions of commands (e.g. `npm init -y` instead of `npm init`) when available. Interactive shell commands are not supported and may cause hangs until canceled by the user.
78
+ - **Remembering Facts:** Use the 'save_memory' tool to remember specific, *user-related* facts or preferences when the user explicitly asks, or when they state a clear, concise piece of information that would help personalize or streamline *your future interactions with them* (e.g., preferred coding style, common project paths they use, personal tool aliases). This tool is for user-specific information that should persist across sessions. Do *not* use it for general project context or information. If unsure whether to save something, you can ask the user, "Should I remember that for you?"
79
+ - **Respect User Confirmations:** Most tool calls (also denoted as 'function calls') will first require confirmation from the user, where they will either approve or cancel the function call. If a user cancels a function call, respect their choice and do _not_ try to make the function call again. It is okay to request the tool call again _only_ if the user requests that same tool call on a subsequent prompt. When a user cancels a function call, assume best intentions from the user and consider inquiring if they prefer any alternative paths forward.
80
+
81
+ ## Interaction Details
82
+ - **Help Command:** The user can use '/help' to display help information.
83
+ - **Feedback:** To report a bug or provide feedback, please use the /bug command.
84
+
85
+
86
+ # Outside of Sandbox
87
+ You are running outside of a sandbox container, directly on the user's system. For critical commands that are particularly likely to modify the user's system outside of the project directory or system temp directory, as you explain the command to the user (per the Explain Critical Commands rule above), also remind the user to consider enabling sandboxing.
88
+
89
+
90
+
91
+ # Git Repository
92
+ - The current working (project) directory is being managed by a git repository.
93
+ - When asked to commit changes or prepare a commit, always start by gathering information using shell commands:
94
+ - `git status` to ensure that all relevant files are tracked and staged, using `git add ...` as needed.
95
+ - `git diff HEAD` to review all changes (including unstaged changes) to tracked files in work tree since last commit.
96
+ - `git diff --staged` to review only staged changes when a partial commit makes sense or was requested by the user.
97
+ - `git log -n 3` to review recent commit messages and match their style (verbosity, formatting, signature line, etc.)
98
+ - Combine shell commands whenever possible to save time/steps, e.g. `git status && git diff HEAD && git log -n 3`.
99
+ - Always propose a draft commit message. Never just ask the user to give you the full commit message.
100
+ - Prefer commit messages that are clear, concise, and focused more on "why" and less on "what".
101
+ - Keep the user informed and ask for clarification or confirmation where needed.
102
+ - After each commit, confirm that it was successful by running `git status`.
103
+ - If a commit fails, never attempt to work around the issues without being asked to do so.
104
+ - Never push changes to a remote repository without being asked explicitly by the user.
105
+
106
+
107
+ # Final Reminder
108
+ Your core function is efficient and safe assistance. Balance extreme conciseness with the crucial need for clarity, especially regarding safety and potential system modifications. Always prioritize user control and project conventions. Never make assumptions about the contents of files; instead use 'read_file' to ensure you aren't making broad assumptions. Finally, you are an agent - please keep going until the user's query is completely resolved.⏎