coding-agent-adapters 0.12.0 → 0.14.0

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.
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  var promises = require('fs/promises');
4
4
  var path = require('path');
5
- var ptyManager = require('pty-manager');
5
+ var adapterTypes = require('adapter-types');
6
6
 
7
7
  // src/base-coding-adapter.ts
8
8
 
@@ -375,7 +375,7 @@ function getPresetDefinition(preset) {
375
375
  }
376
376
 
377
377
  // src/base-coding-adapter.ts
378
- var BaseCodingAdapter = class extends ptyManager.BaseCLIAdapter {
378
+ var BaseCodingAdapter = class extends adapterTypes.BaseCLIAdapter {
379
379
  /**
380
380
  * Coding agent CLIs use TUI menus that require arrow-key navigation.
381
381
  */
@@ -589,6 +589,16 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
589
589
  * Explicit responseType: 'text' prevents the usesTuiMenus default from kicking in.
590
590
  */
591
591
  autoResponseRules = [
592
+ {
593
+ pattern: /choose\s+the\s+text\s+style\s+that\s+looks\s+best\s+with\s+your\s+terminal|syntax\s+theme:/i,
594
+ type: "config",
595
+ response: "",
596
+ responseType: "keys",
597
+ keys: ["enter"],
598
+ description: "Accept Claude first-run theme/style prompt",
599
+ safe: true,
600
+ once: true
601
+ },
592
602
  {
593
603
  pattern: /trust.*(?:folder|directory)|safety.?check|project.you.created|(?:Yes|Allow).*(?:No|Deny).*(?:Enter|Return)/i,
594
604
  type: "permission",
@@ -1095,7 +1105,8 @@ jq -nc --arg event "${"$"}EVENT" --arg notification_type "${"$"}NOTIFICATION
1095
1105
  const hasConversationalReadyText = stripped.includes("How can I help") || stripped.includes("What would you like");
1096
1106
  const hasLegacyPrompt = /claude>/i.test(tail);
1097
1107
  const hasShortcutsHint = stripped.includes("for shortcuts");
1098
- return hasConversationalReadyText || hasLegacyPrompt || hasShortcutsHint;
1108
+ const hasInteractivePromptBar = /❯\s+\S/.test(tail) && (/\/effort/i.test(stripped) || /Welcome back/i.test(stripped) || /Recent activity/i.test(stripped) || /What's new/i.test(stripped));
1109
+ return hasConversationalReadyText || hasLegacyPrompt || hasShortcutsHint || hasInteractivePromptBar;
1099
1110
  }
1100
1111
  parseOutput(output) {
1101
1112
  const withoutHookMarkers = this.stripHookMarkers(output);
@@ -1251,6 +1262,25 @@ var GeminiAdapter = class extends BaseCodingAdapter {
1251
1262
  return env;
1252
1263
  }
1253
1264
  getHookTelemetryProtocol(options) {
1265
+ if (options?.httpUrl) {
1266
+ const sessionHeader = options.sessionId ? ` -H 'X-Parallax-Session-Id: ${options.sessionId}'` : "";
1267
+ const curlCommand = `bash -c 'curl -sf -X POST "${options.httpUrl}" -H "Content-Type: application/json"${sessionHeader} -d @- --max-time 4 2>/dev/null || echo "{\\"continue\\":true}"'`;
1268
+ const hookEntry2 = [{ matcher: "", hooks: [{ type: "command", command: curlCommand, timeout: 5e3 }] }];
1269
+ const hookEntryNoMatcher = [{ hooks: [{ type: "command", command: curlCommand, timeout: 5e3 }] }];
1270
+ const settingsHooks2 = {
1271
+ BeforeTool: hookEntry2,
1272
+ AfterTool: hookEntry2,
1273
+ AfterAgent: hookEntryNoMatcher,
1274
+ SessionEnd: hookEntryNoMatcher,
1275
+ Notification: hookEntry2
1276
+ };
1277
+ return {
1278
+ markerPrefix: "",
1279
+ scriptPath: "",
1280
+ scriptContent: "",
1281
+ settingsHooks: settingsHooks2
1282
+ };
1283
+ }
1254
1284
  const markerPrefix = options?.markerPrefix || GEMINI_HOOK_MARKER_PREFIX;
1255
1285
  const scriptPath = options?.scriptPath || ".gemini/hooks/parallax-hook-telemetry.sh";
1256
1286
  const scriptCommand = `"${"$"}GEMINI_PROJECT_ROOT"/${scriptPath}`;
@@ -1928,12 +1958,20 @@ var CodexAdapter = class extends BaseCodingAdapter {
1928
1958
  return false;
1929
1959
  }
1930
1960
  detectReady(output) {
1961
+ const rawTail = output.slice(-2e3);
1962
+ const hasRawComposerSignals = /OpenAI\s+Codex/i.test(rawTail) && (/Explain\s+this\s+codebase/i.test(rawTail) || /Summarize\s+recent\s+commits/i.test(rawTail) || /Ask\s+Codex\s+to\s+do\s+anything/i.test(rawTail) || /\?\s+for\s+shortcuts/i.test(rawTail) || /context\s+left/i.test(rawTail));
1963
+ if (hasRawComposerSignals) {
1964
+ return true;
1965
+ }
1931
1966
  const stripped = this.stripAnsi(output);
1932
1967
  if (!stripped.trim()) return false;
1933
1968
  const tail = stripped.slice(-1200);
1934
1969
  const hasComposerPrompt = /^\s*›\s*(?!\d+\.)\S.*$/m.test(tail) || /›\s+Ask\s+Codex\s+to\s+do\s+anything/.test(tail);
1935
1970
  const hasComposerFooter = /\?\s+for\s+shortcuts/i.test(tail) || /context\s+left/i.test(tail) || /tab\s+to\s+queue\s+message/i.test(tail) || /shift\s*\+\s*enter\s+for\s+newline/i.test(tail);
1936
- if (hasComposerPrompt || hasComposerFooter) {
1971
+ const hasStartupComposerHints = /Summarize\s+recent\s+commits/i.test(tail) || /Explain\s+this\s+codebase/i.test(tail) || /Ask\s+Codex\s+to\s+do\s+anything/i.test(tail);
1972
+ const hasCodexHeader = /OpenAI\s+Codex/i.test(tail) && /directory:\s+~?\/?.+/i.test(tail);
1973
+ const hasInteractiveStatusBar = /gpt-[\w.-]+\s+(?:high|medium|low)/i.test(tail) && /left\b/i.test(tail);
1974
+ if (hasComposerPrompt || hasComposerFooter || hasStartupComposerHints || hasCodexHeader && hasInteractiveStatusBar) {
1937
1975
  return true;
1938
1976
  }
1939
1977
  if (/do.?you.?trust.?the.?contents/i.test(stripped) || /sign.?in.?with.?chatgpt/i.test(stripped) || /update.?available/i.test(stripped) || /enable.?full.?access/i.test(stripped) || /choose.?working.?directory/i.test(stripped)) {
@@ -2042,6 +2080,14 @@ var AiderAdapter = class extends BaseCodingAdapter {
2042
2080
  description: "Decline automatic bug report",
2043
2081
  safe: true
2044
2082
  },
2083
+ {
2084
+ pattern: /open documentation url for more info\?/i,
2085
+ type: "config",
2086
+ response: "n",
2087
+ responseType: "text",
2088
+ description: "Decline opening Aider documentation for model warnings",
2089
+ safe: true
2090
+ },
2045
2091
  // ── File / edit operations ──────────────────────────────────────────
2046
2092
  {
2047
2093
  pattern: /add .+ to the chat\?/i,
@@ -2215,8 +2261,9 @@ var AiderAdapter = class extends BaseCodingAdapter {
2215
2261
  }
2216
2262
  getArgs(config) {
2217
2263
  const args = [];
2218
- args.push("--auto-commits");
2219
- if (!this.isInteractive(config)) {
2264
+ const interactive = this.isInteractive(config);
2265
+ if (!interactive) {
2266
+ args.push("--auto-commits");
2220
2267
  args.push("--no-pretty");
2221
2268
  args.push("--no-show-diffs");
2222
2269
  }
@@ -2224,22 +2271,26 @@ var AiderAdapter = class extends BaseCodingAdapter {
2224
2271
  const credentials = this.getCredentials(config);
2225
2272
  if (config.env?.AIDER_MODEL) {
2226
2273
  args.push("--model", config.env.AIDER_MODEL);
2227
- } else if (provider === "anthropic") {
2274
+ } else if (interactive && (credentials.googleKey || process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY)) {
2275
+ args.push("--model", "gemini");
2276
+ } else if (!interactive && provider === "anthropic") {
2228
2277
  args.push("--model", "sonnet");
2229
- } else if (provider === "openai") {
2278
+ } else if (!interactive && provider === "openai") {
2230
2279
  args.push("--model", "4o");
2231
- } else if (provider === "google") {
2280
+ } else if (!interactive && provider === "google") {
2232
2281
  args.push("--model", "gemini");
2233
- } else if (credentials.anthropicKey) {
2282
+ } else if (!interactive && credentials.anthropicKey) {
2234
2283
  args.push("--model", "sonnet");
2235
- } else if (credentials.openaiKey) {
2284
+ } else if (!interactive && credentials.openaiKey) {
2236
2285
  args.push("--model", "4o");
2237
- } else if (credentials.googleKey) {
2286
+ } else if (!interactive && credentials.googleKey) {
2238
2287
  args.push("--model", "gemini");
2239
2288
  }
2240
- if (credentials.anthropicKey) args.push("--api-key", `anthropic=${credentials.anthropicKey}`);
2241
- if (credentials.openaiKey) args.push("--api-key", `openai=${credentials.openaiKey}`);
2242
- if (credentials.googleKey) args.push("--api-key", `gemini=${credentials.googleKey}`);
2289
+ if (!interactive) {
2290
+ if (credentials.anthropicKey) args.push("--api-key", `anthropic=${credentials.anthropicKey}`);
2291
+ if (credentials.openaiKey) args.push("--api-key", `openai=${credentials.openaiKey}`);
2292
+ if (credentials.googleKey) args.push("--api-key", `gemini=${credentials.googleKey}`);
2293
+ }
2243
2294
  const approvalConfig = this.getApprovalConfig(config);
2244
2295
  if (approvalConfig) {
2245
2296
  args.push(...approvalConfig.cliFlags);