@qduc/term2 0.1.2 → 0.1.3

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 (235) hide show
  1. package/dist/agent.lite-mode.test.d.ts +2 -0
  2. package/dist/agent.lite-mode.test.d.ts.map +1 -0
  3. package/dist/agent.lite-mode.test.js +39 -0
  4. package/dist/agent.lite-mode.test.js.map +1 -0
  5. package/dist/app.d.ts.map +1 -1
  6. package/dist/app.js +3 -1
  7. package/dist/app.js.map +1 -1
  8. package/dist/components/ApprovalPrompt.d.ts.map +1 -1
  9. package/dist/components/ApprovalPrompt.js +20 -0
  10. package/dist/components/ApprovalPrompt.js.map +1 -1
  11. package/dist/components/InputBox.d.ts.map +1 -1
  12. package/dist/components/InputBox.js +2 -7
  13. package/dist/components/InputBox.js.map +1 -1
  14. package/dist/components/TextInput.d.ts.map +1 -1
  15. package/dist/components/TextInput.js +2 -1
  16. package/dist/components/TextInput.js.map +1 -1
  17. package/dist/components/TextInput.test.js.map +1 -1
  18. package/dist/debug_ask_mentor.d.ts +2 -0
  19. package/dist/debug_ask_mentor.d.ts.map +1 -0
  20. package/dist/debug_ask_mentor.js +73 -0
  21. package/dist/debug_ask_mentor.js.map +1 -0
  22. package/dist/hooks/use-model-selection.d.ts.map +1 -1
  23. package/dist/hooks/use-model-selection.js +7 -3
  24. package/dist/hooks/use-model-selection.js.map +1 -1
  25. package/dist/hooks/use-settings-completion.d.ts.map +1 -1
  26. package/dist/hooks/use-settings-completion.js +3 -0
  27. package/dist/hooks/use-settings-completion.js.map +1 -1
  28. package/dist/hooks/use-settings-completion.test.js +6 -0
  29. package/dist/hooks/use-settings-completion.test.js.map +1 -1
  30. package/dist/lib/openai-agent-client.d.ts.map +1 -1
  31. package/dist/lib/openai-agent-client.js +35 -15
  32. package/dist/lib/openai-agent-client.js.map +1 -1
  33. package/dist/lib/tool-invoke.test.js +1 -1
  34. package/dist/lib/tool-invoke.test.js.map +1 -1
  35. package/dist/modes/companion/command-index.d.ts +26 -0
  36. package/dist/modes/companion/command-index.d.ts.map +1 -0
  37. package/dist/modes/companion/command-index.js +50 -0
  38. package/dist/modes/companion/command-index.js.map +1 -0
  39. package/dist/modes/companion/command-index.test.d.ts +2 -0
  40. package/dist/modes/companion/command-index.test.d.ts.map +1 -0
  41. package/dist/modes/companion/command-index.test.js +86 -0
  42. package/dist/modes/companion/command-index.test.js.map +1 -0
  43. package/dist/modes/companion/companion-app.d.ts +12 -0
  44. package/dist/modes/companion/companion-app.d.ts.map +1 -0
  45. package/dist/modes/companion/companion-app.js +297 -0
  46. package/dist/modes/companion/companion-app.js.map +1 -0
  47. package/dist/modes/companion/companion-session.d.ts +63 -0
  48. package/dist/modes/companion/companion-session.d.ts.map +1 -0
  49. package/dist/modes/companion/companion-session.js +146 -0
  50. package/dist/modes/companion/companion-session.js.map +1 -0
  51. package/dist/modes/companion/companion-session.test.d.ts +2 -0
  52. package/dist/modes/companion/companion-session.test.d.ts.map +1 -0
  53. package/dist/modes/companion/companion-session.test.js +28 -0
  54. package/dist/modes/companion/companion-session.test.js.map +1 -0
  55. package/dist/modes/companion/components/status-bar.d.ts +13 -0
  56. package/dist/modes/companion/components/status-bar.d.ts.map +1 -0
  57. package/dist/modes/companion/components/status-bar.js +26 -0
  58. package/dist/modes/companion/components/status-bar.js.map +1 -0
  59. package/dist/modes/companion/context-buffer.d.ts +65 -0
  60. package/dist/modes/companion/context-buffer.d.ts.map +1 -0
  61. package/dist/modes/companion/context-buffer.js +156 -0
  62. package/dist/modes/companion/context-buffer.js.map +1 -0
  63. package/dist/modes/companion/context-buffer.test.d.ts +2 -0
  64. package/dist/modes/companion/context-buffer.test.d.ts.map +1 -0
  65. package/dist/modes/companion/context-buffer.test.js +154 -0
  66. package/dist/modes/companion/context-buffer.test.js.map +1 -0
  67. package/dist/modes/companion/event-detector.d.ts +46 -0
  68. package/dist/modes/companion/event-detector.d.ts.map +1 -0
  69. package/dist/modes/companion/event-detector.js +169 -0
  70. package/dist/modes/companion/event-detector.js.map +1 -0
  71. package/dist/modes/companion/event-detector.test.d.ts +2 -0
  72. package/dist/modes/companion/event-detector.test.d.ts.map +1 -0
  73. package/dist/modes/companion/event-detector.test.js +121 -0
  74. package/dist/modes/companion/event-detector.test.js.map +1 -0
  75. package/dist/modes/companion/index.d.ts +33 -0
  76. package/dist/modes/companion/index.d.ts.map +1 -0
  77. package/dist/modes/companion/index.js +21 -0
  78. package/dist/modes/companion/index.js.map +1 -0
  79. package/dist/modes/companion/input-key-mapper.d.ts +3 -0
  80. package/dist/modes/companion/input-key-mapper.d.ts.map +1 -0
  81. package/dist/modes/companion/input-key-mapper.js +31 -0
  82. package/dist/modes/companion/input-key-mapper.js.map +1 -0
  83. package/dist/modes/companion/input-key-mapper.test.d.ts +2 -0
  84. package/dist/modes/companion/input-key-mapper.test.d.ts.map +1 -0
  85. package/dist/modes/companion/input-key-mapper.test.js +26 -0
  86. package/dist/modes/companion/input-key-mapper.test.js.map +1 -0
  87. package/dist/modes/companion/input-parser.d.ts +53 -0
  88. package/dist/modes/companion/input-parser.d.ts.map +1 -0
  89. package/dist/modes/companion/input-parser.js +114 -0
  90. package/dist/modes/companion/input-parser.js.map +1 -0
  91. package/dist/modes/companion/input-parser.test.d.ts +2 -0
  92. package/dist/modes/companion/input-parser.test.d.ts.map +1 -0
  93. package/dist/modes/companion/input-parser.test.js +123 -0
  94. package/dist/modes/companion/input-parser.test.js.map +1 -0
  95. package/dist/modes/companion/mode-manager.d.ts +41 -0
  96. package/dist/modes/companion/mode-manager.d.ts.map +1 -0
  97. package/dist/modes/companion/mode-manager.js +56 -0
  98. package/dist/modes/companion/mode-manager.js.map +1 -0
  99. package/dist/modes/companion/mode-manager.test.d.ts +2 -0
  100. package/dist/modes/companion/mode-manager.test.d.ts.map +1 -0
  101. package/dist/modes/companion/mode-manager.test.js +65 -0
  102. package/dist/modes/companion/mode-manager.test.js.map +1 -0
  103. package/dist/modes/companion/output-classifier.d.ts +15 -0
  104. package/dist/modes/companion/output-classifier.d.ts.map +1 -0
  105. package/dist/modes/companion/output-classifier.js +77 -0
  106. package/dist/modes/companion/output-classifier.js.map +1 -0
  107. package/dist/modes/companion/output-classifier.test.d.ts +2 -0
  108. package/dist/modes/companion/output-classifier.test.d.ts.map +1 -0
  109. package/dist/modes/companion/output-classifier.test.js +133 -0
  110. package/dist/modes/companion/output-classifier.test.js.map +1 -0
  111. package/dist/modes/companion/pty-wrapper.d.ts +46 -0
  112. package/dist/modes/companion/pty-wrapper.d.ts.map +1 -0
  113. package/dist/modes/companion/pty-wrapper.js +143 -0
  114. package/dist/modes/companion/pty-wrapper.js.map +1 -0
  115. package/dist/modes/companion/safety-classifier.d.ts +31 -0
  116. package/dist/modes/companion/safety-classifier.d.ts.map +1 -0
  117. package/dist/modes/companion/safety-classifier.js +140 -0
  118. package/dist/modes/companion/safety-classifier.js.map +1 -0
  119. package/dist/modes/companion/safety-classifier.test.d.ts +2 -0
  120. package/dist/modes/companion/safety-classifier.test.d.ts.map +1 -0
  121. package/dist/modes/companion/safety-classifier.test.js +151 -0
  122. package/dist/modes/companion/safety-classifier.test.js.map +1 -0
  123. package/dist/modes/companion/summarizer.d.ts +24 -0
  124. package/dist/modes/companion/summarizer.d.ts.map +1 -0
  125. package/dist/modes/companion/summarizer.js +132 -0
  126. package/dist/modes/companion/summarizer.js.map +1 -0
  127. package/dist/modes/companion/terminal-history.d.ts +27 -0
  128. package/dist/modes/companion/terminal-history.d.ts.map +1 -0
  129. package/dist/modes/companion/terminal-history.js +142 -0
  130. package/dist/modes/companion/terminal-history.js.map +1 -0
  131. package/dist/prompts/simple-mentor.md +8 -0
  132. package/dist/providers/openai-compatible/model.d.ts.map +1 -1
  133. package/dist/providers/openai-compatible/model.js +13 -2
  134. package/dist/providers/openai-compatible/model.js.map +1 -1
  135. package/dist/providers/openai-compatible/reasoning-content.test.js +2 -2
  136. package/dist/providers/openai-compatible/reasoning-content.test.js.map +1 -1
  137. package/dist/providers/openrouter/reasoning-content.test.js +2 -2
  138. package/dist/providers/openrouter/reasoning-content.test.js.map +1 -1
  139. package/dist/providers/openrouter.test.js +30 -21
  140. package/dist/providers/openrouter.test.js.map +1 -1
  141. package/dist/services/check_mock.d.ts +2 -0
  142. package/dist/services/check_mock.d.ts.map +1 -0
  143. package/dist/services/check_mock.js +22 -0
  144. package/dist/services/check_mock.js.map +1 -0
  145. package/dist/services/conversation-service.test.d.ts +2 -0
  146. package/dist/services/conversation-service.test.d.ts.map +1 -0
  147. package/dist/services/conversation-service.test.js +149 -183
  148. package/dist/services/conversation-service.test.js.map +1 -0
  149. package/dist/services/conversation-store.test.js +12 -11
  150. package/dist/services/conversation-store.test.js.map +1 -1
  151. package/dist/services/settings-service.d.ts +5 -2
  152. package/dist/services/settings-service.d.ts.map +1 -1
  153. package/dist/services/settings-service.js +12 -0
  154. package/dist/services/settings-service.js.map +1 -1
  155. package/dist/tools/ask-mentor.d.ts +1 -1
  156. package/dist/tools/ask-mentor.d.ts.map +1 -1
  157. package/dist/tools/ask-mentor.js +1 -0
  158. package/dist/tools/ask-mentor.js.map +1 -1
  159. package/dist/tools/find-files.d.ts +2 -2
  160. package/dist/tools/find-files.d.ts.map +1 -1
  161. package/dist/tools/find-files.js +2 -0
  162. package/dist/tools/find-files.js.map +1 -1
  163. package/dist/tools/grep.d.ts +1 -1
  164. package/dist/tools/grep.d.ts.map +1 -1
  165. package/dist/tools/grep.js +1 -0
  166. package/dist/tools/grep.js.map +1 -1
  167. package/dist/tools/read-file.d.ts.map +1 -1
  168. package/dist/tools/read-file.js +10 -9
  169. package/dist/tools/read-file.js.map +1 -1
  170. package/dist/tools/read-file.test.js +24 -19
  171. package/dist/tools/read-file.test.js.map +1 -1
  172. package/dist/tools/search-replace.d.ts +1 -1
  173. package/dist/tools/search-replace.d.ts.map +1 -1
  174. package/dist/tools/search-replace.js +129 -1
  175. package/dist/tools/search-replace.js.map +1 -1
  176. package/dist/tools/search-replace.test.js +18 -0
  177. package/dist/tools/search-replace.test.js.map +1 -1
  178. package/dist/tools/search.d.ts +4 -4
  179. package/dist/tools/search.d.ts.map +1 -1
  180. package/dist/tools/search.js +4 -0
  181. package/dist/tools/search.js.map +1 -1
  182. package/dist/tools/shell.d.ts +2 -2
  183. package/dist/tools/shell.d.ts.map +1 -1
  184. package/dist/tools/shell.js +2 -0
  185. package/dist/tools/shell.js.map +1 -1
  186. package/dist/tools/types.d.ts +2 -2
  187. package/dist/tools/types.d.ts.map +1 -1
  188. package/dist/utils/command-safety.d.ts.map +1 -1
  189. package/dist/utils/command-safety.devnull.test.d.ts +2 -0
  190. package/dist/utils/command-safety.devnull.test.d.ts.map +1 -0
  191. package/dist/utils/command-safety.devnull.test.js +13 -0
  192. package/dist/utils/command-safety.devnull.test.js.map +1 -0
  193. package/dist/utils/command-safety.js +10 -364
  194. package/dist/utils/command-safety.js.map +1 -1
  195. package/dist/utils/extract-command-messages.test.d.ts +2 -0
  196. package/dist/utils/extract-command-messages.test.d.ts.map +1 -0
  197. package/dist/utils/extract-command-messages.test.js +58 -51
  198. package/dist/utils/extract-command-messages.test.js.map +1 -0
  199. package/dist/utils/settings-command.d.ts.map +1 -1
  200. package/dist/utils/settings-command.js +13 -4
  201. package/dist/utils/settings-command.js.map +1 -1
  202. package/package.json +2 -2
  203. package/dist/app.model-command-feedback.test.d.ts +0 -2
  204. package/dist/app.model-command-feedback.test.d.ts.map +0 -1
  205. package/dist/app.model-command-feedback.test.js +0 -19
  206. package/dist/app.model-command-feedback.test.js.map +0 -1
  207. package/dist/components/MentorMode.test.d.ts +0 -2
  208. package/dist/components/MentorMode.test.d.ts.map +0 -1
  209. package/dist/components/MentorMode.test.js.map +0 -1
  210. package/dist/debug-schema.d.ts +0 -2
  211. package/dist/debug-schema.d.ts.map +0 -1
  212. package/dist/debug-schema.js +0 -22
  213. package/dist/debug-schema.js.map +0 -1
  214. package/dist/hooks/use-model-selection.test.d.ts +0 -2
  215. package/dist/hooks/use-model-selection.test.d.ts.map +0 -1
  216. package/dist/hooks/use-model-selection.test.js +0 -28
  217. package/dist/hooks/use-model-selection.test.js.map +0 -1
  218. package/dist/hooks/use-path-completion.test.d.ts +0 -2
  219. package/dist/hooks/use-path-completion.test.d.ts.map +0 -1
  220. package/dist/hooks/use-path-completion.test.js +0 -29
  221. package/dist/hooks/use-path-completion.test.js.map +0 -1
  222. package/dist/prompts/default.md.bak +0 -77
  223. package/dist/providers/openrouter.history.test.d.ts +0 -2
  224. package/dist/providers/openrouter.history.test.d.ts.map +0 -1
  225. package/dist/providers/openrouter.history.test.js +0 -533
  226. package/dist/providers/openrouter.history.test.js.map +0 -1
  227. package/dist/test-search-tool.d.ts +0 -2
  228. package/dist/test-search-tool.d.ts.map +0 -1
  229. package/dist/test-search-tool.js +0 -36
  230. package/dist/test-search-tool.js.map +0 -1
  231. package/dist/utils/extract-command-messages.repro.test.d.ts +0 -2
  232. package/dist/utils/extract-command-messages.repro.test.d.ts.map +0 -1
  233. package/dist/utils/extract-command-messages.repro.test.js +0 -31
  234. package/dist/utils/extract-command-messages.repro.test.js.map +0 -1
  235. /package/{README.md → readme.md} +0 -0
@@ -0,0 +1,121 @@
1
+ import test from 'ava';
2
+ import { EventDetector } from './event-detector.js';
3
+ // Helper to create a test entry
4
+ function createEntry(command, exitCode = 0, output = '') {
5
+ return {
6
+ command,
7
+ output,
8
+ exitCode,
9
+ timestamp: Date.now(),
10
+ outputLines: output.split('\n').length,
11
+ };
12
+ }
13
+ test('does not trigger on first failure', t => {
14
+ const detector = new EventDetector({ errorCascadeThreshold: 3 });
15
+ const result = detector.processCommand(createEntry('cmd', 1));
16
+ t.is(result, null);
17
+ });
18
+ test('triggers error_cascade after threshold consecutive failures', t => {
19
+ const detector = new EventDetector({ errorCascadeThreshold: 3 });
20
+ detector.processCommand(createEntry('cmd1', 1));
21
+ detector.processCommand(createEntry('cmd2', 1));
22
+ const result = detector.processCommand(createEntry('cmd3', 1));
23
+ t.not(result, null);
24
+ t.is(result?.pattern, 'error_cascade');
25
+ t.truthy(result?.message);
26
+ });
27
+ test('error cascade resets after success', t => {
28
+ const detector = new EventDetector({ errorCascadeThreshold: 3 });
29
+ detector.processCommand(createEntry('cmd1', 1));
30
+ detector.processCommand(createEntry('cmd2', 1));
31
+ detector.processCommand(createEntry('success', 0)); // Reset
32
+ detector.processCommand(createEntry('cmd3', 1));
33
+ const result = detector.processCommand(createEntry('cmd4', 1));
34
+ t.is(result, null);
35
+ });
36
+ test('does not trigger retry_loop on first occurrence', t => {
37
+ const detector = new EventDetector({ retryLoopThreshold: 2 });
38
+ const result = detector.processCommand(createEntry('npm test'));
39
+ t.is(result, null);
40
+ });
41
+ test('triggers retry_loop when same command repeated', t => {
42
+ const detector = new EventDetector({ retryLoopThreshold: 2 });
43
+ detector.processCommand(createEntry('npm test'));
44
+ const result = detector.processCommand(createEntry('npm test'));
45
+ t.not(result, null);
46
+ t.is(result?.pattern, 'retry_loop');
47
+ t.truthy(result?.message);
48
+ });
49
+ test('retry loop resets with different command', t => {
50
+ const detector = new EventDetector({ retryLoopThreshold: 2 });
51
+ detector.processCommand(createEntry('npm test'));
52
+ detector.processCommand(createEntry('git status')); // Different
53
+ const result = detector.processCommand(createEntry('npm test'));
54
+ t.is(result, null);
55
+ });
56
+ test('markActivity resets activity timer', t => {
57
+ const detector = new EventDetector();
58
+ detector.markActivity();
59
+ t.true(detector.timeSinceLastActivity < 100); // Should be very recent
60
+ });
61
+ test('getOptions returns current options', t => {
62
+ const detector = new EventDetector({ errorCascadeThreshold: 5 });
63
+ const options = detector.getOptions();
64
+ t.is(options.errorCascadeThreshold, 5);
65
+ });
66
+ test('setOptions updates options', t => {
67
+ const detector = new EventDetector({ errorCascadeThreshold: 3 });
68
+ detector.setOptions({ errorCascadeThreshold: 5 });
69
+ t.is(detector.getOptions().errorCascadeThreshold, 5);
70
+ });
71
+ test('setOptions preserves unset options', t => {
72
+ const detector = new EventDetector({
73
+ errorCascadeThreshold: 3,
74
+ retryLoopThreshold: 2,
75
+ });
76
+ detector.setOptions({ errorCascadeThreshold: 5 });
77
+ t.is(detector.getOptions().retryLoopThreshold, 2);
78
+ });
79
+ test('clear resets all state', t => {
80
+ const detector = new EventDetector({ errorCascadeThreshold: 2 });
81
+ detector.processCommand(createEntry('cmd', 1));
82
+ detector.clear();
83
+ const result = detector.processCommand(createEntry('cmd', 1));
84
+ t.is(result, null); // Cascade count should be reset
85
+ });
86
+ test('emits hint event for long_pause', async (t) => {
87
+ const detector = new EventDetector({ pauseHintDelayMs: 50 });
88
+ const events = [];
89
+ detector.on('hint', (event) => {
90
+ events.push(event);
91
+ });
92
+ // Trigger an error
93
+ detector.processCommand(createEntry('cmd', 1));
94
+ // Wait for pause hint
95
+ await new Promise(resolve => setTimeout(resolve, 100));
96
+ t.is(events.length, 1);
97
+ t.is(events[0]?.pattern, 'long_pause');
98
+ });
99
+ test('pause hint is cancelled by new activity', async (t) => {
100
+ const detector = new EventDetector({ pauseHintDelayMs: 100 });
101
+ const events = [];
102
+ detector.on('hint', (event) => {
103
+ events.push(event);
104
+ });
105
+ // Trigger an error
106
+ detector.processCommand(createEntry('cmd', 1));
107
+ // Add activity before pause triggers
108
+ await new Promise(resolve => setTimeout(resolve, 50));
109
+ detector.markActivity();
110
+ // Wait past original pause time
111
+ await new Promise(resolve => setTimeout(resolve, 100));
112
+ t.is(events.length, 0);
113
+ });
114
+ test('uses default options when not provided', t => {
115
+ const detector = new EventDetector();
116
+ const options = detector.getOptions();
117
+ t.is(options.errorCascadeThreshold, 3);
118
+ t.is(options.retryLoopThreshold, 2);
119
+ t.is(options.pauseHintDelayMs, 30000);
120
+ });
121
+ //# sourceMappingURL=event-detector.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-detector.test.js","sourceRoot":"","sources":["../../../source/modes/companion/event-detector.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,KAAK,CAAC;AACvB,OAAO,EAAC,aAAa,EAAqB,MAAM,qBAAqB,CAAC;AAGtE,gCAAgC;AAChC,SA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IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAEvD,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,wCAAwC,EAAE,CAAC,CAAC,EAAE;IAC/C,MAAM,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,EAAE,CAAC;IAEtC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;IACpC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;AAC1C,CAAC,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Companion Mode - Terminal Companion that observes, learns, and assists.
3
+ *
4
+ * Instead of the AI being the primary interface, the user's normal terminal remains primary.
5
+ * The AI watches silently in the background, building context from commands and outputs.
6
+ * When the user gets stuck or explicitly asks, the AI can assist or temporarily take control.
7
+ */
8
+ export { CompanionApp } from './companion-app.js';
9
+ export type { CompanionAppProps } from './companion-app.js';
10
+ export { PTYWrapper } from './pty-wrapper.js';
11
+ export type { PTYWrapperOptions, PTYWrapperEvents } from './pty-wrapper.js';
12
+ export { ContextBuffer } from './context-buffer.js';
13
+ export type { CommandEntry, CommandIndexEntry, ContextBufferOptions, } from './context-buffer.js';
14
+ export { ModeManager } from './mode-manager.js';
15
+ export type { CompanionMode } from './mode-manager.js';
16
+ export { EventDetector } from './event-detector.js';
17
+ export type { EventPattern, EventDetectorOptions, DetectedEvent, } from './event-detector.js';
18
+ export { Summarizer } from './summarizer.js';
19
+ export type { SummarizerDeps } from './summarizer.js';
20
+ export { createTerminalHistoryToolDefinition } from './terminal-history.js';
21
+ export type { TerminalHistoryParams } from './terminal-history.js';
22
+ export { formatCommandIndex, generateCommandIndexPrompt, estimateTokens } from './command-index.js';
23
+ export { classifyOutputType, shouldSummarize, getSummarizationPrompt, } from './output-classifier.js';
24
+ export type { OutputType } from './output-classifier.js';
25
+ export { StatusBar } from './components/status-bar.js';
26
+ export type { StatusBarProps } from './components/status-bar.js';
27
+ export { parseCompanionInput, isShellPrompt, extractCommandFromPromptLine, CommandOutputBuffer, } from './input-parser.js';
28
+ export type { ParsedInput } from './input-parser.js';
29
+ export { CompanionSession } from './companion-session.js';
30
+ export type { CompanionSessionDeps, CompanionEvent } from './companion-session.js';
31
+ export { classifyCommandSafety, shouldAutoApprove, shouldBlock, getSafetyDescription, } from './safety-classifier.js';
32
+ export type { SafetyLevel, SafetyClassification } from './safety-classifier.js';
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/modes/companion/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAChD,YAAY,EAAC,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C,YAAY,EAAC,iBAAiB,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAE1E,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAClD,YAAY,EACR,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,GACvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,YAAY,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAClD,YAAY,EACR,YAAY,EACZ,oBAAoB,EACpB,aAAa,GAChB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC3C,YAAY,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAC,mCAAmC,EAAC,MAAM,uBAAuB,CAAC;AAC1E,YAAY,EAAC,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAC,kBAAkB,EAAE,0BAA0B,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAElG,OAAO,EACH,kBAAkB,EAClB,eAAe,EACf,sBAAsB,GACzB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAC,SAAS,EAAC,MAAM,4BAA4B,CAAC;AACrD,YAAY,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,4BAA4B,EAC5B,mBAAmB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AACxD,YAAY,EAAC,oBAAoB,EAAE,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAEjF,OAAO,EACH,qBAAqB,EACrB,iBAAiB,EACjB,WAAW,EACX,oBAAoB,GACvB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAC,WAAW,EAAE,oBAAoB,EAAC,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Companion Mode - Terminal Companion that observes, learns, and assists.
3
+ *
4
+ * Instead of the AI being the primary interface, the user's normal terminal remains primary.
5
+ * The AI watches silently in the background, building context from commands and outputs.
6
+ * When the user gets stuck or explicitly asks, the AI can assist or temporarily take control.
7
+ */
8
+ export { CompanionApp } from './companion-app.js';
9
+ export { PTYWrapper } from './pty-wrapper.js';
10
+ export { ContextBuffer } from './context-buffer.js';
11
+ export { ModeManager } from './mode-manager.js';
12
+ export { EventDetector } from './event-detector.js';
13
+ export { Summarizer } from './summarizer.js';
14
+ export { createTerminalHistoryToolDefinition } from './terminal-history.js';
15
+ export { formatCommandIndex, generateCommandIndexPrompt, estimateTokens } from './command-index.js';
16
+ export { classifyOutputType, shouldSummarize, getSummarizationPrompt, } from './output-classifier.js';
17
+ export { StatusBar } from './components/status-bar.js';
18
+ export { parseCompanionInput, isShellPrompt, extractCommandFromPromptLine, CommandOutputBuffer, } from './input-parser.js';
19
+ export { CompanionSession } from './companion-session.js';
20
+ export { classifyCommandSafety, shouldAutoApprove, shouldBlock, getSafetyDescription, } from './safety-classifier.js';
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/modes/companion/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAOlD,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAG9C,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAOlD,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAG3C,OAAO,EAAC,mCAAmC,EAAC,MAAM,uBAAuB,CAAC;AAG1E,OAAO,EAAC,kBAAkB,EAAE,0BAA0B,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAElG,OAAO,EACH,kBAAkB,EAClB,eAAe,EACf,sBAAsB,GACzB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAC,SAAS,EAAC,MAAM,4BAA4B,CAAC;AAGrD,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,4BAA4B,EAC5B,mBAAmB,GACtB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EACH,qBAAqB,EACrB,iBAAiB,EACjB,WAAW,EACX,oBAAoB,GACvB,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Key } from 'ink';
2
+ export declare function getPtyInputSequence(input: string, key: Key): string | null;
3
+ //# sourceMappingURL=input-key-mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-key-mapper.d.ts","sourceRoot":"","sources":["../../../source/modes/companion/input-key-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AAS7B,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CA8B1E"}
@@ -0,0 +1,31 @@
1
+ const BACKSPACE_SEQUENCE = '\x08';
2
+ const DELETE_SEQUENCE = '\x1b[3~';
3
+ const UP_ARROW_SEQUENCE = '\x1b[A';
4
+ const DOWN_ARROW_SEQUENCE = '\x1b[B';
5
+ const RIGHT_ARROW_SEQUENCE = '\x1b[C';
6
+ const LEFT_ARROW_SEQUENCE = '\x1b[D';
7
+ export function getPtyInputSequence(input, key) {
8
+ if (key.upArrow) {
9
+ return UP_ARROW_SEQUENCE;
10
+ }
11
+ if (key.downArrow) {
12
+ return DOWN_ARROW_SEQUENCE;
13
+ }
14
+ if (key.rightArrow) {
15
+ return RIGHT_ARROW_SEQUENCE;
16
+ }
17
+ if (key.leftArrow) {
18
+ return LEFT_ARROW_SEQUENCE;
19
+ }
20
+ if (key.delete) {
21
+ return DELETE_SEQUENCE;
22
+ }
23
+ if (key.backspace) {
24
+ return BACKSPACE_SEQUENCE;
25
+ }
26
+ if (input) {
27
+ return input;
28
+ }
29
+ return null;
30
+ }
31
+ //# sourceMappingURL=input-key-mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-key-mapper.js","sourceRoot":"","sources":["../../../source/modes/companion/input-key-mapper.ts"],"names":[],"mappings":"AAEA,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,eAAe,GAAG,SAAS,CAAC;AAClC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AACnC,MAAM,mBAAmB,GAAG,QAAQ,CAAC;AACrC,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AACtC,MAAM,mBAAmB,GAAG,QAAQ,CAAC;AAErC,MAAM,UAAU,mBAAmB,CAAC,KAAa,EAAE,GAAQ;IACvD,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QACd,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IAED,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;QAChB,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;QACjB,OAAO,oBAAoB,CAAC;IAChC,CAAC;IAED,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;QAChB,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QACb,OAAO,eAAe,CAAC;IAC3B,CAAC;IAED,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;QAChB,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED,IAAI,KAAK,EAAE,CAAC;QACR,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=input-key-mapper.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-key-mapper.test.d.ts","sourceRoot":"","sources":["../../../source/modes/companion/input-key-mapper.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import test from 'ava';
2
+ import { getPtyInputSequence } from './input-key-mapper.js';
3
+ function makeKey(overrides = {}) {
4
+ return overrides;
5
+ }
6
+ test('getPtyInputSequence returns input when provided', t => {
7
+ const key = makeKey({ upArrow: true });
8
+ t.is(getPtyInputSequence('a', key), 'a');
9
+ });
10
+ test('getPtyInputSequence prefers special key mappings over input', t => {
11
+ t.is(getPtyInputSequence('\b', makeKey({ backspace: true })), '\x08');
12
+ });
13
+ test('getPtyInputSequence maps arrow keys when input is empty', t => {
14
+ t.is(getPtyInputSequence('', makeKey({ upArrow: true })), '\x1b[A');
15
+ t.is(getPtyInputSequence('', makeKey({ downArrow: true })), '\x1b[B');
16
+ t.is(getPtyInputSequence('', makeKey({ rightArrow: true })), '\x1b[C');
17
+ t.is(getPtyInputSequence('', makeKey({ leftArrow: true })), '\x1b[D');
18
+ });
19
+ test('getPtyInputSequence maps delete and backspace when input is empty', t => {
20
+ t.is(getPtyInputSequence('', makeKey({ delete: true })), '\x1b[3~');
21
+ t.is(getPtyInputSequence('', makeKey({ backspace: true })), '\x08');
22
+ });
23
+ test('getPtyInputSequence returns null when no input or mapping', t => {
24
+ t.is(getPtyInputSequence('', makeKey()), null);
25
+ });
26
+ //# sourceMappingURL=input-key-mapper.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-key-mapper.test.js","sourceRoot":"","sources":["../../../source/modes/companion/input-key-mapper.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,KAAK,CAAC;AAEvB,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAE1D,SAAS,OAAO,CAAC,YAA0B,EAAE;IACzC,OAAO,SAAgB,CAAC;AAC5B,CAAC;AAED,IAAI,CAAC,iDAAiD,EAAE,CAAC,CAAC,EAAE;IACxD,MAAM,GAAG,GAAG,OAAO,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC,CAAC;IACrC,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,6DAA6D,EAAE,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AC,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Input parser for companion mode.
3
+ * Detects special commands like ?? and !auto in user input.
4
+ */
5
+ export interface ParsedInput {
6
+ type: 'query' | 'auto' | 'normal';
7
+ content: string;
8
+ }
9
+ /**
10
+ * Parse input line to detect ?? queries and !auto commands.
11
+ */
12
+ export declare function parseCompanionInput(input: string): ParsedInput;
13
+ /**
14
+ * Check if a line looks like a shell prompt.
15
+ * Used to detect when a command has completed.
16
+ */
17
+ export declare function isShellPrompt(line: string): boolean;
18
+ /**
19
+ * Extract command from prompt line.
20
+ * Tries to separate the prompt from the actual command.
21
+ */
22
+ export declare function extractCommandFromPromptLine(line: string): string | null;
23
+ /**
24
+ * Buffer for accumulating PTY output and detecting command boundaries.
25
+ */
26
+ export declare class CommandOutputBuffer {
27
+ #private;
28
+ /**
29
+ * Process incoming PTY data.
30
+ * Returns completed command+output when a command boundary is detected.
31
+ */
32
+ processData(data: string): {
33
+ command: string;
34
+ output: string;
35
+ } | null;
36
+ /**
37
+ * Mark start of a new command.
38
+ */
39
+ startCommand(command: string): void;
40
+ /**
41
+ * Get the current prompt line.
42
+ */
43
+ get promptLine(): string;
44
+ /**
45
+ * Check if currently waiting for command output.
46
+ */
47
+ get isWaitingForOutput(): boolean;
48
+ /**
49
+ * Clear the buffer.
50
+ */
51
+ clear(): void;
52
+ }
53
+ //# sourceMappingURL=input-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-parser.d.ts","sourceRoot":"","sources":["../../../source/modes/companion/input-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAiB9D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAanD;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYxE;AAED;;GAEG;AACH,qBAAa,mBAAmB;;IAK5B;;;OAGG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG;QACvB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAClB,GAAG,IAAI;IA0BR;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKnC;;OAEG;IACH,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED;;OAEG;IACH,IAAI,kBAAkB,IAAI,OAAO,CAEhC;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;CAKhB"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Input parser for companion mode.
3
+ * Detects special commands like ?? and !auto in user input.
4
+ */
5
+ /**
6
+ * Parse input line to detect ?? queries and !auto commands.
7
+ */
8
+ export function parseCompanionInput(input) {
9
+ const trimmed = input.trim();
10
+ // Detect ?? query
11
+ if (trimmed.startsWith('??')) {
12
+ const query = trimmed.slice(2).trim();
13
+ return { type: 'query', content: query };
14
+ }
15
+ // Detect !auto command
16
+ if (trimmed.startsWith('!auto')) {
17
+ const task = trimmed.slice(5).trim();
18
+ return { type: 'auto', content: task };
19
+ }
20
+ // Normal input
21
+ return { type: 'normal', content: trimmed };
22
+ }
23
+ /**
24
+ * Check if a line looks like a shell prompt.
25
+ * Used to detect when a command has completed.
26
+ */
27
+ export function isShellPrompt(line) {
28
+ // Common shell prompt patterns
29
+ const promptPatterns = [
30
+ /\$\s*$/, // bash/sh: ends with $
31
+ /%\s*$/, // zsh: ends with %
32
+ />\s*$/, // some shells: ends with >
33
+ /❯\s*$/, // oh-my-zsh/powerlevel: ends with ❯
34
+ /→\s*$/, // some prompts: ends with →
35
+ /^\[.+\]\s*[$%>❯→]\s*$/, // bracketed: [path]$
36
+ /^.+@.+:.+[$%>❯→]\s*$/, // user@host:path$
37
+ ];
38
+ return promptPatterns.some(pattern => pattern.test(line));
39
+ }
40
+ /**
41
+ * Extract command from prompt line.
42
+ * Tries to separate the prompt from the actual command.
43
+ */
44
+ export function extractCommandFromPromptLine(line) {
45
+ // Look for common prompt endings followed by command
46
+ const promptEndings = ['$ ', '% ', '> ', '❯ ', '→ '];
47
+ for (const ending of promptEndings) {
48
+ const idx = line.lastIndexOf(ending);
49
+ if (idx !== -1 && idx < line.length - 2) {
50
+ return line.slice(idx + ending.length).trim();
51
+ }
52
+ }
53
+ return null;
54
+ }
55
+ /**
56
+ * Buffer for accumulating PTY output and detecting command boundaries.
57
+ */
58
+ export class CommandOutputBuffer {
59
+ #currentCommand = null;
60
+ #outputBuffer = '';
61
+ #promptLine = '';
62
+ /**
63
+ * Process incoming PTY data.
64
+ * Returns completed command+output when a command boundary is detected.
65
+ */
66
+ processData(data) {
67
+ // Accumulate output
68
+ this.#outputBuffer += data;
69
+ // Check for command boundary (new prompt)
70
+ const lines = this.#outputBuffer.split('\n');
71
+ const lastLine = lines[lines.length - 1] ?? '';
72
+ if (isShellPrompt(lastLine) && this.#currentCommand) {
73
+ // Command completed
74
+ const result = {
75
+ command: this.#currentCommand,
76
+ output: this.#outputBuffer.slice(0, -lastLine.length).trim(),
77
+ };
78
+ // Reset for next command
79
+ this.#currentCommand = null;
80
+ this.#outputBuffer = lastLine;
81
+ this.#promptLine = lastLine;
82
+ return result;
83
+ }
84
+ return null;
85
+ }
86
+ /**
87
+ * Mark start of a new command.
88
+ */
89
+ startCommand(command) {
90
+ this.#currentCommand = command;
91
+ this.#outputBuffer = '';
92
+ }
93
+ /**
94
+ * Get the current prompt line.
95
+ */
96
+ get promptLine() {
97
+ return this.#promptLine;
98
+ }
99
+ /**
100
+ * Check if currently waiting for command output.
101
+ */
102
+ get isWaitingForOutput() {
103
+ return this.#currentCommand !== null;
104
+ }
105
+ /**
106
+ * Clear the buffer.
107
+ */
108
+ clear() {
109
+ this.#currentCommand = null;
110
+ this.#outputBuffer = '';
111
+ this.#promptLine = '';
112
+ }
113
+ }
114
+ //# sourceMappingURL=input-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-parser.js","sourceRoot":"","sources":["../../../source/modes/companion/input-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC7C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAE7B,kBAAkB;IAClB,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACtC,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAC,CAAC;IAC3C,CAAC;IAED,uBAAuB;IACvB,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACrC,OAAO,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;IACzC,CAAC;IAED,eAAe;IACf,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAC,CAAC;AAC9C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACtC,+BAA+B;IAC/B,MAAM,cAAc,GAAG;QACnB,QAAQ,EAAE,uBAAuB;QACjC,OAAO,EAAE,mBAAmB;QAC5B,OAAO,EAAE,2BAA2B;QACpC,OAAO,EAAE,oCAAoC;QAC7C,OAAO,EAAE,4BAA4B;QACrC,uBAAuB,EAAE,qBAAqB;QAC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,IAAI,CAAC,eAAe;gBAC7B,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE;aAC/D,CAAC;YAEF,yBAAyB;YACzB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;YAC5B,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC;YAC9B,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC;YAE5B,OAAO,MAAM,CAAC;QAClB,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,OAAe;QACxB,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAI,kBAAkB;QAClB,OAAO,IAAI,CAAC,eAAe,KAAK,IAAI,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,KAAK;QACD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IAC1B,CAAC;CACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=input-parser.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-parser.test.d.ts","sourceRoot":"","sources":["../../../source/modes/companion/input-parser.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,123 @@
1
+ import test from 'ava';
2
+ import { parseCompanionInput, isShellPrompt, extractCommandFromPromptLine, CommandOutputBuffer, } from './input-parser.js';
3
+ // parseCompanionInput tests
4
+ test('parseCompanionInput detects ?? query with content', t => {
5
+ const result = parseCompanionInput('?? why did this fail');
6
+ t.is(result.type, 'query');
7
+ t.is(result.content, 'why did this fail');
8
+ });
9
+ test('parseCompanionInput detects bare ?? query', t => {
10
+ const result = parseCompanionInput('??');
11
+ t.is(result.type, 'query');
12
+ t.is(result.content, '');
13
+ });
14
+ test('parseCompanionInput detects ?? with extra spaces', t => {
15
+ const result = parseCompanionInput('?? how do I fix this ');
16
+ t.is(result.type, 'query');
17
+ t.is(result.content, 'how do I fix this');
18
+ });
19
+ test('parseCompanionInput detects !auto command', t => {
20
+ const result = parseCompanionInput('!auto fix the tests');
21
+ t.is(result.type, 'auto');
22
+ t.is(result.content, 'fix the tests');
23
+ });
24
+ test('parseCompanionInput detects bare !auto', t => {
25
+ const result = parseCompanionInput('!auto');
26
+ t.is(result.type, 'auto');
27
+ t.is(result.content, '');
28
+ });
29
+ test('parseCompanionInput returns normal for regular input', t => {
30
+ const result = parseCompanionInput('npm test');
31
+ t.is(result.type, 'normal');
32
+ t.is(result.content, 'npm test');
33
+ });
34
+ test('parseCompanionInput handles whitespace-only input', t => {
35
+ const result = parseCompanionInput(' ');
36
+ t.is(result.type, 'normal');
37
+ t.is(result.content, '');
38
+ });
39
+ test('parseCompanionInput does not detect ?? in middle of string', t => {
40
+ const result = parseCompanionInput('echo "?? test"');
41
+ t.is(result.type, 'normal');
42
+ t.is(result.content, 'echo "?? test"');
43
+ });
44
+ // isShellPrompt tests
45
+ test('isShellPrompt detects bash prompt ending with $', t => {
46
+ t.true(isShellPrompt('user@host:~/project$ '));
47
+ t.true(isShellPrompt('$ '));
48
+ t.true(isShellPrompt('[~/project]$ '));
49
+ });
50
+ test('isShellPrompt detects zsh prompt ending with %', t => {
51
+ t.true(isShellPrompt('% '));
52
+ t.true(isShellPrompt('user@host % '));
53
+ });
54
+ test('isShellPrompt detects prompt ending with >', t => {
55
+ t.true(isShellPrompt('> '));
56
+ t.true(isShellPrompt('PS1> '));
57
+ });
58
+ test('isShellPrompt detects oh-my-zsh prompt', t => {
59
+ t.true(isShellPrompt('❯ '));
60
+ t.true(isShellPrompt('~/project ❯ '));
61
+ });
62
+ test('isShellPrompt returns false for regular output', t => {
63
+ t.false(isShellPrompt('npm test'));
64
+ t.false(isShellPrompt('error: file not found'));
65
+ t.false(isShellPrompt(''));
66
+ });
67
+ // extractCommandFromPromptLine tests
68
+ test('extractCommandFromPromptLine extracts command after $', t => {
69
+ const result = extractCommandFromPromptLine('user@host:~$ npm test');
70
+ t.is(result, 'npm test');
71
+ });
72
+ test('extractCommandFromPromptLine extracts command after %', t => {
73
+ const result = extractCommandFromPromptLine('% git status');
74
+ t.is(result, 'git status');
75
+ });
76
+ test('extractCommandFromPromptLine returns null for prompt only', t => {
77
+ const result = extractCommandFromPromptLine('user@host:~$ ');
78
+ t.is(result, null);
79
+ });
80
+ test('extractCommandFromPromptLine returns null for non-prompt line', t => {
81
+ const result = extractCommandFromPromptLine('npm test output');
82
+ t.is(result, null);
83
+ });
84
+ // CommandOutputBuffer tests
85
+ test('CommandOutputBuffer starts not waiting for output', t => {
86
+ const buffer = new CommandOutputBuffer();
87
+ t.false(buffer.isWaitingForOutput);
88
+ });
89
+ test('CommandOutputBuffer tracks current command', t => {
90
+ const buffer = new CommandOutputBuffer();
91
+ buffer.startCommand('npm test');
92
+ t.true(buffer.isWaitingForOutput);
93
+ });
94
+ test('CommandOutputBuffer returns null when no command boundary', t => {
95
+ const buffer = new CommandOutputBuffer();
96
+ buffer.startCommand('npm test');
97
+ const result = buffer.processData('test output\nmore output');
98
+ t.is(result, null);
99
+ });
100
+ test('CommandOutputBuffer detects command completion', t => {
101
+ const buffer = new CommandOutputBuffer();
102
+ buffer.startCommand('npm test');
103
+ buffer.processData('PASS test.js\n');
104
+ const result = buffer.processData('user@host:~$ ');
105
+ t.not(result, null);
106
+ t.is(result?.command, 'npm test');
107
+ t.true(result?.output.includes('PASS test.js'));
108
+ });
109
+ test('CommandOutputBuffer resets after command completion', t => {
110
+ const buffer = new CommandOutputBuffer();
111
+ buffer.startCommand('npm test');
112
+ buffer.processData('output\nuser@host:~$ ');
113
+ t.false(buffer.isWaitingForOutput);
114
+ });
115
+ test('CommandOutputBuffer.clear resets state', t => {
116
+ const buffer = new CommandOutputBuffer();
117
+ buffer.startCommand('npm test');
118
+ buffer.processData('output');
119
+ buffer.clear();
120
+ t.false(buffer.isWaitingForOutput);
121
+ t.is(buffer.promptLine, '');
122
+ });
123
+ //# sourceMappingURL=input-parser.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-parser.test.js","sourceRoot":"","sources":["../../../source/modes/companion/input-parser.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,KAAK,CAAC;AACvB,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,4BAA4B,EAC5B,mBAAmB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,4BAA4B;AAE5B,IAAI,CAAC,mDAAmD,EAAE,CAAC,CAAC,EAAE;IAC1D,MAAM,MAAM,GAAG,mBAAmB,CAAC,sBAAsB,CAAC,CAAC;IAE3D,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3B,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,2CAA2C,EAAE,CAAC,CAAC,EAAE;IAClD,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAEzC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3B,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,kDAAkD,EAAE,CAAC,CAAC,EAAE;IACzD,MAAM,MAAM,GAAG,mBAAmB,CAAC,2BAA2B,CAAC,CAAC;IAEhE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3B,CAAC,CAAC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