coding-agent-adapters 0.4.2 → 0.5.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/README.md CHANGED
@@ -103,7 +103,7 @@ Each adapter implements `detectTaskComplete(output)` to recognize when the CLI h
103
103
  | Claude | Turn duration (`Cooked for 3m 12s`, custom verb) + `❯` prompt (tolerates trailing status bar) | `claude_completed_turn_duration` |
104
104
  | Gemini | `◇ Ready` window title, `Type your message` composer | `gemini_ready_title` |
105
105
  | Codex | `Worked for 1m 05s` separator + `›` prompt | `codex_completed_worked_for_separator`, `codex_ready_prompt` |
106
- | Aider | `Aider is waiting for your input`, mode prompts with edit/cost markers | `aider_completed_llm_response_ready` |
106
+ | Aider | `Aider is waiting for your input`, mode prompts (including plain `>`) with edit/cost markers | `aider_completed_llm_response_ready` |
107
107
 
108
108
  ```typescript
109
109
  const claude = new ClaudeAdapter();
package/dist/index.cjs CHANGED
@@ -395,14 +395,17 @@ var BaseCodingAdapter = class extends ptyManager.BaseCLIAdapter {
395
395
  return adapterConfig?.interactive === true;
396
396
  }
397
397
  /**
398
- * Override stripAnsi to handle TUI cursor-forward codes.
399
- * TUI CLIs (Claude Code, Gemini CLI) use \x1b[<n>C (cursor forward)
400
- * instead of literal spaces for word positioning. Replace with spaces
401
- * before stripping other ANSI codes so regex patterns can match.
398
+ * Override stripAnsi to handle TUI cursor movement codes.
399
+ * TUI CLIs (Claude Code, Gemini CLI, Codex) use cursor positioning
400
+ * sequences instead of literal spaces. Replace ALL cursor movement
401
+ * codes with spaces before stripping other ANSI codes so regex
402
+ * patterns can match the visible text.
402
403
  */
403
404
  stripAnsi(str) {
404
- const withSpaces = str.replace(/\x1b\[\d*C/g, " ");
405
- return super.stripAnsi(withSpaces);
405
+ let result = str.replace(/\x1b\[\d*[CDABGdEF]/g, " ");
406
+ result = result.replace(/\x1b\[\d*(?:;\d+)?[Hf]/g, " ");
407
+ result = result.replace(/\x1b\[\d*[JK]/g, " ");
408
+ return super.stripAnsi(result);
406
409
  }
407
410
  /**
408
411
  * Override detectExit to include installation instructions
@@ -548,7 +551,7 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
548
551
  */
549
552
  autoResponseRules = [
550
553
  {
551
- pattern: /trust.*folder|safety.?check|project.you.created/i,
554
+ pattern: /trust.*(?:folder|directory)|safety.?check|project.you.created|(?:Yes|Allow).*(?:No|Deny).*(?:Enter|Return)/i,
552
555
  type: "permission",
553
556
  response: "",
554
557
  responseType: "keys",
@@ -982,6 +985,15 @@ var GeminiAdapter = class extends BaseCodingAdapter {
982
985
  instructions: "Gemini is asking to apply a change (file write, shell command, etc.)"
983
986
  };
984
987
  }
988
+ if (/Interactive\s+shell\s+awaiting\s+input/i.test(stripped)) {
989
+ return {
990
+ detected: true,
991
+ type: "tool_wait",
992
+ prompt: "Gemini interactive shell needs user focus",
993
+ canAutoRespond: false,
994
+ instructions: "Press Tab to focus the interactive shell, or wait for it to complete"
995
+ };
996
+ }
985
997
  const loginDetection = this.detectLogin(output);
986
998
  if (loginDetection.required) {
987
999
  return {
@@ -1103,6 +1115,12 @@ var GeminiAdapter = class extends BaseCodingAdapter {
1103
1115
  code: 0
1104
1116
  };
1105
1117
  }
1118
+ if (/Agent\s+powering\s+down/i.test(stripped)) {
1119
+ return {
1120
+ exited: true,
1121
+ code: 0
1122
+ };
1123
+ }
1106
1124
  return super.detectExit(output);
1107
1125
  }
1108
1126
  getPromptPattern() {
@@ -1806,7 +1824,7 @@ var AiderAdapter = class extends BaseCodingAdapter {
1806
1824
  if (/Aider\s+is\s+waiting\s+for\s+your\s+input/.test(stripped)) {
1807
1825
  return true;
1808
1826
  }
1809
- const hasPrompt = /(?:ask|code|architect)(?:\s+multi)?>\s*$/m.test(stripped);
1827
+ const hasPrompt = /(?:(?:ask|code|architect)(?:\s+multi)?)?>\s*$/m.test(stripped);
1810
1828
  if (hasPrompt) {
1811
1829
  const hasEditMarkers = /Applied edit to|Commit [a-f0-9]+|wrote to|Updated/i.test(stripped);
1812
1830
  const hasTokenUsage = /Tokens:|Cost:/i.test(stripped);
@@ -1900,6 +1918,15 @@ var BASELINE_PATTERNS = {
1900
1918
  "update available",
1901
1919
  "[y/n]"
1902
1920
  ],
1921
+ loading: [
1922
+ "Reading X files\u2026"
1923
+ ],
1924
+ turnComplete: [
1925
+ "Cooked for 1m 6s",
1926
+ "<CustomVerb> for 4m 39s"
1927
+ ],
1928
+ toolWait: [],
1929
+ exit: [],
1903
1930
  source: "baseline"
1904
1931
  },
1905
1932
  gemini: {
@@ -1921,6 +1948,20 @@ var BASELINE_PATTERNS = {
1921
1948
  "update available",
1922
1949
  "[y/n]"
1923
1950
  ],
1951
+ loading: [
1952
+ "<phrase> (esc to cancel, 25s)",
1953
+ "Waiting for user confirmation...",
1954
+ "Generating witty retort\u2026",
1955
+ "Reticulating splines",
1956
+ "Warming up the AI hamsters"
1957
+ ],
1958
+ turnComplete: [],
1959
+ toolWait: [
1960
+ "Interactive shell awaiting input... press tab to focus shell"
1961
+ ],
1962
+ exit: [
1963
+ "Agent powering down. Goodbye!"
1964
+ ],
1924
1965
  source: "baseline"
1925
1966
  },
1926
1967
  codex: {
@@ -1939,6 +1980,18 @@ var BASELINE_PATTERNS = {
1939
1980
  "update available",
1940
1981
  "[y/n]"
1941
1982
  ],
1983
+ loading: [
1984
+ "\u2022 Working (0s \u2022 esc to interrupt)",
1985
+ "Booting MCP server: alpha"
1986
+ ],
1987
+ turnComplete: [
1988
+ "Worked for 1m 05s"
1989
+ ],
1990
+ toolWait: [
1991
+ "Waiting for background terminal \xB7 <command>",
1992
+ "Searching the web"
1993
+ ],
1994
+ exit: [],
1942
1995
  source: "baseline"
1943
1996
  },
1944
1997
  aider: {
@@ -1957,6 +2010,16 @@ var BASELINE_PATTERNS = {
1957
2010
  "(Y)es/(N)o",
1958
2011
  "[y/n]"
1959
2012
  ],
2013
+ loading: [
2014
+ "Waiting for <model>",
2015
+ "Waiting for LLM",
2016
+ "Generating commit message with <model>"
2017
+ ],
2018
+ turnComplete: [
2019
+ "Aider is waiting for your input"
2020
+ ],
2021
+ toolWait: [],
2022
+ exit: [],
1960
2023
  source: "baseline"
1961
2024
  }
1962
2025
  };
@@ -1974,6 +2037,10 @@ async function tryLoadFromMonitor(adapter, version) {
1974
2037
  ready: patterns.readyPatterns || [],
1975
2038
  auth: patterns.authPatterns || [],
1976
2039
  blocking: patterns.blockingPatterns || [],
2040
+ loading: patterns.loadingPatterns || [],
2041
+ turnComplete: patterns.turnCompletePatterns || [],
2042
+ toolWait: patterns.toolWaitPatterns || [],
2043
+ exit: patterns.exitPatterns || [],
1977
2044
  source: "snapshot",
1978
2045
  version: patterns.version
1979
2046
  };