@oh-my-pi/pi-coding-agent 16.3.0 → 16.3.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 (163) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/dist/cli.js +3855 -3798
  3. package/dist/types/cli/update-cli.d.ts +1 -0
  4. package/dist/types/cli/update-cli.test.d.ts +1 -0
  5. package/dist/types/commands/update.d.ts +5 -0
  6. package/dist/types/config/config-file.d.ts +1 -1
  7. package/dist/types/config/settings-schema.d.ts +20 -0
  8. package/dist/types/dap/client.d.ts +9 -1
  9. package/dist/types/discovery/helpers.d.ts +2 -0
  10. package/dist/types/edit/file-snapshot-store.d.ts +9 -1
  11. package/dist/types/edit/hashline/execute.d.ts +1 -1
  12. package/dist/types/edit/hashline/params.d.ts +3 -6
  13. package/dist/types/edit/renderer.d.ts +1 -0
  14. package/dist/types/extensibility/plugins/parser.d.ts +2 -1
  15. package/dist/types/hindsight/client.d.ts +15 -11
  16. package/dist/types/hindsight/client.test.d.ts +1 -0
  17. package/dist/types/irc/bus.d.ts +5 -4
  18. package/dist/types/mcp/smithery-registry.d.ts +1 -0
  19. package/dist/types/mcp/smithery-registry.test.d.ts +1 -0
  20. package/dist/types/modes/components/advisor-message.d.ts +4 -2
  21. package/dist/types/modes/components/tool-execution.d.ts +9 -6
  22. package/dist/types/modes/components/transcript-container.d.ts +1 -0
  23. package/dist/types/modes/theme/theme.d.ts +1 -1
  24. package/dist/types/session/agent-session.d.ts +13 -13
  25. package/dist/types/session/indexed-session-storage.d.ts +2 -2
  26. package/dist/types/session/session-storage.d.ts +31 -3
  27. package/dist/types/ssh/__tests__/connection-manager-timeout.test.d.ts +1 -0
  28. package/dist/types/ssh/__tests__/sshfs-mount.test.d.ts +1 -0
  29. package/dist/types/ssh/connection-manager.d.ts +19 -0
  30. package/dist/types/ssh/sshfs-mount.d.ts +10 -1
  31. package/dist/types/subprocess/worker-client.d.ts +20 -6
  32. package/dist/types/task/discovery.d.ts +5 -2
  33. package/dist/types/task/renderer.d.ts +1 -0
  34. package/dist/types/tools/ast-grep.d.ts +4 -2
  35. package/dist/types/tools/bash.d.ts +27 -0
  36. package/dist/types/tools/browser/render.d.ts +2 -0
  37. package/dist/types/tools/debug.d.ts +1 -0
  38. package/dist/types/tools/eval-render.d.ts +2 -0
  39. package/dist/types/tools/glob.d.ts +4 -2
  40. package/dist/types/tools/grep.d.ts +4 -3
  41. package/dist/types/tools/path-utils.d.ts +7 -0
  42. package/dist/types/tools/renderers.d.ts +24 -0
  43. package/dist/types/tools/ssh.d.ts +4 -1
  44. package/dist/types/tts/index.d.ts +2 -0
  45. package/dist/types/tts/speakable.d.ts +47 -0
  46. package/dist/types/tts/speech-enhancer.d.ts +46 -0
  47. package/dist/types/tts/streaming-player.d.ts +1 -2
  48. package/dist/types/tts/tts-client.d.ts +11 -10
  49. package/dist/types/tts/tts-protocol.d.ts +7 -0
  50. package/dist/types/tts/vocalizer.d.ts +15 -8
  51. package/dist/types/utils/fetch-timeout.d.ts +4 -0
  52. package/dist/types/utils/git.d.ts +2 -0
  53. package/dist/types/web/search/providers/base.d.ts +1 -0
  54. package/dist/types/web/search/providers/gemini.d.ts +1 -0
  55. package/package.json +12 -12
  56. package/scripts/generate-legacy-pi-bundled-registry.ts +8 -2
  57. package/src/advisor/__tests__/advisor.test.ts +1 -1
  58. package/src/cli/gallery-fixtures/fs.ts +2 -2
  59. package/src/cli/gallery-fixtures/search.ts +2 -2
  60. package/src/cli/models-cli.ts +19 -0
  61. package/src/cli/update-cli.test.ts +28 -0
  62. package/src/cli/update-cli.ts +35 -8
  63. package/src/cli.ts +27 -5
  64. package/src/commands/update.ts +8 -2
  65. package/src/config/config-file.ts +6 -6
  66. package/src/config/model-resolver.ts +31 -10
  67. package/src/config/settings-schema.ts +21 -0
  68. package/src/cursor.ts +1 -1
  69. package/src/dap/client.ts +134 -36
  70. package/src/discovery/helpers.ts +8 -0
  71. package/src/edit/file-snapshot-store.ts +12 -1
  72. package/src/edit/hashline/diff.ts +4 -13
  73. package/src/edit/hashline/execute.ts +1 -1
  74. package/src/edit/hashline/params.ts +5 -12
  75. package/src/edit/renderer.ts +4 -2
  76. package/src/edit/streaming.ts +15 -5
  77. package/src/export/html/tool-views.generated.js +34 -34
  78. package/src/extensibility/custom-tools/loader.ts +3 -3
  79. package/src/extensibility/extensions/loader.ts +10 -3
  80. package/src/extensibility/legacy-pi-coding-agent-shim.ts +2 -2
  81. package/src/extensibility/plugins/installer.ts +12 -3
  82. package/src/extensibility/plugins/legacy-pi-compat.ts +87 -11
  83. package/src/extensibility/plugins/loader.ts +30 -1
  84. package/src/extensibility/plugins/manager.ts +32 -8
  85. package/src/extensibility/plugins/parser.ts +7 -5
  86. package/src/extensibility/tool-event-input.ts +1 -1
  87. package/src/hindsight/client.test.ts +33 -0
  88. package/src/hindsight/client.ts +42 -22
  89. package/src/internal-urls/docs-index.generated.txt +1 -1
  90. package/src/irc/bus.ts +5 -4
  91. package/src/main.ts +7 -1
  92. package/src/mcp/oauth-flow.ts +93 -4
  93. package/src/mcp/smithery-auth.ts +3 -0
  94. package/src/mcp/smithery-connect.ts +9 -0
  95. package/src/mcp/smithery-registry.test.ts +51 -0
  96. package/src/mcp/smithery-registry.ts +27 -4
  97. package/src/modes/components/__tests__/move-overlay.test.ts +72 -1
  98. package/src/modes/components/advisor-message.ts +13 -10
  99. package/src/modes/components/assistant-message.ts +1 -1
  100. package/src/modes/components/move-overlay.ts +35 -23
  101. package/src/modes/components/status-line/component.ts +11 -4
  102. package/src/modes/components/tool-execution.ts +119 -20
  103. package/src/modes/components/transcript-container.ts +26 -0
  104. package/src/modes/components/tree-selector.ts +10 -3
  105. package/src/modes/controllers/event-controller.ts +23 -3
  106. package/src/modes/controllers/tool-args-reveal.ts +1 -1
  107. package/src/modes/interactive-mode.ts +1 -0
  108. package/src/modes/rpc/rpc-client.ts +29 -16
  109. package/src/modes/theme/shimmer.ts +49 -15
  110. package/src/modes/theme/theme.ts +7 -0
  111. package/src/prompts/goals/goal-mode-context.md +4 -0
  112. package/src/prompts/goals/goal-todo-context.md +10 -2
  113. package/src/prompts/system/speech-rewrite.md +15 -0
  114. package/src/prompts/system/tiny-title-system.md +1 -1
  115. package/src/prompts/system/title-system-marker.md +2 -1
  116. package/src/prompts/system/title-system.md +2 -1
  117. package/src/prompts/tools/ast-grep.md +3 -3
  118. package/src/prompts/tools/glob.md +1 -1
  119. package/src/prompts/tools/grep.md +1 -1
  120. package/src/sdk.ts +8 -5
  121. package/src/session/agent-session.ts +329 -79
  122. package/src/session/indexed-session-storage.ts +40 -3
  123. package/src/session/session-history-format.ts +6 -2
  124. package/src/session/session-manager.ts +83 -14
  125. package/src/session/session-storage.ts +112 -26
  126. package/src/slash-commands/helpers/usage-report.ts +6 -1
  127. package/src/ssh/__tests__/connection-manager-timeout.test.ts +61 -0
  128. package/src/ssh/__tests__/sshfs-mount.test.ts +13 -0
  129. package/src/ssh/connection-manager.ts +44 -11
  130. package/src/ssh/sshfs-mount.ts +27 -4
  131. package/src/subprocess/worker-client.ts +161 -10
  132. package/src/task/discovery.ts +25 -2
  133. package/src/task/executor.ts +24 -4
  134. package/src/task/render.ts +26 -12
  135. package/src/task/renderer.ts +1 -0
  136. package/src/task/worktree.ts +144 -16
  137. package/src/tiny/text.ts +109 -17
  138. package/src/tools/ast-grep.ts +20 -17
  139. package/src/tools/bash.ts +46 -9
  140. package/src/tools/browser/render.ts +2 -0
  141. package/src/tools/debug.ts +1 -0
  142. package/src/tools/eval-render.ts +5 -2
  143. package/src/tools/gh-renderer.ts +3 -0
  144. package/src/tools/glob.ts +24 -20
  145. package/src/tools/grep.ts +39 -37
  146. package/src/tools/path-utils.ts +55 -10
  147. package/src/tools/read.ts +23 -6
  148. package/src/tools/renderers.ts +24 -0
  149. package/src/tools/ssh.ts +25 -7
  150. package/src/tts/index.ts +2 -0
  151. package/src/tts/speakable.ts +382 -0
  152. package/src/tts/speech-enhancer.ts +204 -0
  153. package/src/tts/streaming-player.ts +71 -16
  154. package/src/tts/tts-client.ts +11 -10
  155. package/src/tts/tts-protocol.ts +14 -5
  156. package/src/tts/tts-worker.ts +52 -49
  157. package/src/tts/vocalizer.ts +277 -46
  158. package/src/utils/clipboard.ts +49 -12
  159. package/src/utils/fetch-timeout.ts +10 -0
  160. package/src/utils/git.ts +8 -0
  161. package/src/web/search/index.ts +8 -0
  162. package/src/web/search/providers/base.ts +1 -0
  163. package/src/web/search/providers/gemini.ts +23 -6
@@ -8,10 +8,12 @@
8
8
  * tests to spy on.
9
9
  */
10
10
 
11
+ import { isTimeoutError, withTimeoutSignal } from "../utils/fetch-timeout";
11
12
  import type { HindsightConfig } from "./config";
12
13
 
13
14
  const USER_AGENT = "oh-my-pi-coding-agent";
14
15
  const DEFAULT_USER_AGENT = USER_AGENT;
16
+ const HINDSIGHT_REQUEST_TIMEOUT_MS = 30_000;
15
17
 
16
18
  export type Budget = "low" | "mid" | "high" | string;
17
19
  export type TagsMatch = "any" | "all" | "any_strict" | "all_strict";
@@ -24,6 +26,11 @@ export interface HindsightApiOptions {
24
26
  userAgent?: string;
25
27
  }
26
28
 
29
+ /** Caller cancellation shared by Hindsight request option bags. */
30
+ export interface HindsightRequestOptions {
31
+ signal?: AbortSignal;
32
+ }
33
+
27
34
  export interface RecallResult {
28
35
  id?: string;
29
36
  text: string;
@@ -77,7 +84,7 @@ export interface MemoryItemInput {
77
84
  updateMode?: UpdateMode;
78
85
  }
79
86
 
80
- export interface RetainOptions {
87
+ export interface RetainOptions extends HindsightRequestOptions {
81
88
  timestamp?: Date | string;
82
89
  context?: string;
83
90
  metadata?: Record<string, string>;
@@ -87,7 +94,7 @@ export interface RetainOptions {
87
94
  updateMode?: UpdateMode;
88
95
  }
89
96
 
90
- export interface RetainBatchOptions {
97
+ export interface RetainBatchOptions extends HindsightRequestOptions {
91
98
  /** Document id applied to every item that doesn't carry its own. */
92
99
  documentId?: string;
93
100
  /** Tags attached to the resulting document(s), not individual items. */
@@ -95,7 +102,7 @@ export interface RetainBatchOptions {
95
102
  async?: boolean;
96
103
  }
97
104
 
98
- export interface RecallOptions {
105
+ export interface RecallOptions extends HindsightRequestOptions {
99
106
  types?: string[];
100
107
  maxTokens?: number;
101
108
  budget?: Budget;
@@ -103,19 +110,19 @@ export interface RecallOptions {
103
110
  tagsMatch?: TagsMatch;
104
111
  }
105
112
 
106
- export interface ReflectOptions {
113
+ export interface ReflectOptions extends HindsightRequestOptions {
107
114
  context?: string;
108
115
  budget?: Budget;
109
116
  tags?: string[];
110
117
  tagsMatch?: TagsMatch;
111
118
  }
112
119
 
113
- export interface CreateBankOptions {
120
+ export interface CreateBankOptions extends HindsightRequestOptions {
114
121
  reflectMission?: string;
115
122
  retainMission?: string;
116
123
  }
117
124
 
118
- export interface ListMemoriesOptions {
125
+ export interface ListMemoriesOptions extends HindsightRequestOptions {
119
126
  limit?: number;
120
127
  offset?: number;
121
128
  type?: string;
@@ -123,12 +130,12 @@ export interface ListMemoriesOptions {
123
130
  consolidationState?: ConsolidationState;
124
131
  }
125
132
 
126
- export interface ListDocumentsOptions {
133
+ export interface ListDocumentsOptions extends HindsightRequestOptions {
127
134
  limit?: number;
128
135
  offset?: number;
129
136
  }
130
137
 
131
- export interface UpdateDocumentOptions {
138
+ export interface UpdateDocumentOptions extends HindsightRequestOptions {
132
139
  tags?: string[];
133
140
  }
134
141
 
@@ -166,7 +173,7 @@ export interface MentalModelHistoryEntry {
166
173
  [key: string]: unknown;
167
174
  }
168
175
 
169
- export interface CreateMentalModelOptions {
176
+ export interface CreateMentalModelOptions extends HindsightRequestOptions {
170
177
  id?: string;
171
178
  tags?: string[];
172
179
  maxTokens?: number;
@@ -183,11 +190,11 @@ export interface RefreshMentalModelResponse {
183
190
  [key: string]: unknown;
184
191
  }
185
192
 
186
- export interface ListMentalModelsOptions {
193
+ export interface ListMentalModelsOptions extends HindsightRequestOptions {
187
194
  detail?: MentalModelDetail;
188
195
  }
189
196
 
190
- export interface GetMentalModelOptions {
197
+ export interface GetMentalModelOptions extends HindsightRequestOptions {
191
198
  detail?: MentalModelDetail;
192
199
  }
193
200
 
@@ -208,6 +215,7 @@ interface RequestOptions {
208
215
  query?: Record<string, unknown>;
209
216
  /** Return null instead of throwing on a 404 response. */
210
217
  allow404?: boolean;
218
+ signal?: AbortSignal;
211
219
  }
212
220
 
213
221
  export class HindsightApi {
@@ -240,7 +248,10 @@ export class HindsightApi {
240
248
  "POST",
241
249
  `/v1/default/banks/${encodeURIComponent(bankId)}/memories`,
242
250
  "retain",
243
- { body: { items: [item], async: options?.async } },
251
+ {
252
+ body: { items: [item], async: options?.async },
253
+ signal: options?.signal,
254
+ },
244
255
  );
245
256
  }
246
257
 
@@ -270,6 +281,7 @@ export class HindsightApi {
270
281
  document_tags: options?.documentTags,
271
282
  async: options?.async,
272
283
  },
284
+ signal: options?.signal,
273
285
  },
274
286
  );
275
287
  }
@@ -288,6 +300,7 @@ export class HindsightApi {
288
300
  tags: options?.tags,
289
301
  tags_match: options?.tagsMatch,
290
302
  },
303
+ signal: options?.signal,
291
304
  },
292
305
  );
293
306
  }
@@ -305,6 +318,7 @@ export class HindsightApi {
305
318
  tags: options?.tags,
306
319
  tags_match: options?.tagsMatch,
307
320
  },
321
+ signal: options?.signal,
308
322
  },
309
323
  );
310
324
  }
@@ -319,6 +333,7 @@ export class HindsightApi {
319
333
  reflect_mission: options.reflectMission,
320
334
  retain_mission: options.retainMission,
321
335
  },
336
+ signal: options.signal,
322
337
  },
323
338
  );
324
339
  }
@@ -340,6 +355,7 @@ export class HindsightApi {
340
355
  limit: options?.limit,
341
356
  offset: options?.offset,
342
357
  },
358
+ signal: options?.signal,
343
359
  },
344
360
  );
345
361
  }
@@ -350,7 +366,7 @@ export class HindsightApi {
350
366
  "GET",
351
367
  `/v1/default/banks/${encodeURIComponent(bankId)}/documents`,
352
368
  "listDocuments",
353
- { query: { limit: options?.limit, offset: options?.offset } },
369
+ { query: { limit: options?.limit, offset: options?.offset }, signal: options?.signal },
354
370
  );
355
371
  }
356
372
 
@@ -370,7 +386,7 @@ export class HindsightApi {
370
386
  "PATCH",
371
387
  `/v1/default/banks/${encodeURIComponent(bankId)}/documents/${encodeURIComponent(documentId)}`,
372
388
  "updateDocument",
373
- { body: { tags: options.tags } },
389
+ { body: { tags: options.tags }, signal: options.signal },
374
390
  );
375
391
  }
376
392
 
@@ -399,7 +415,7 @@ export class HindsightApi {
399
415
  "GET",
400
416
  `/v1/default/banks/${encodeURIComponent(bankId)}/mental-models`,
401
417
  "listMentalModels",
402
- { query: { detail: options?.detail ?? "content" } },
418
+ { query: { detail: options?.detail ?? "content" }, signal: options?.signal },
403
419
  );
404
420
  }
405
421
 
@@ -413,7 +429,7 @@ export class HindsightApi {
413
429
  "GET",
414
430
  `/v1/default/banks/${encodeURIComponent(bankId)}/mental-models/${encodeURIComponent(mentalModelId)}`,
415
431
  "getMentalModel",
416
- { query: { detail: options?.detail ?? "content" }, allow404: true },
432
+ { query: { detail: options?.detail ?? "content" }, allow404: true, signal: options?.signal },
417
433
  );
418
434
  }
419
435
 
@@ -441,6 +457,7 @@ export class HindsightApi {
441
457
  max_tokens: options?.maxTokens,
442
458
  trigger: options?.trigger,
443
459
  },
460
+ signal: options?.signal,
444
461
  },
445
462
  );
446
463
  }
@@ -489,7 +506,11 @@ export class HindsightApi {
489
506
  if (qs) url += `?${qs}`;
490
507
  }
491
508
 
492
- const init: RequestInit = { method, headers: this.#headers };
509
+ const init: RequestInit = {
510
+ method,
511
+ headers: this.#headers,
512
+ signal: withTimeoutSignal(HINDSIGHT_REQUEST_TIMEOUT_MS, opts?.signal),
513
+ };
493
514
  if (opts?.body !== undefined) {
494
515
  init.body = JSON.stringify(pruneUndefined(opts.body));
495
516
  }
@@ -498,11 +519,10 @@ export class HindsightApi {
498
519
  try {
499
520
  response = await fetch(url, init);
500
521
  } catch (err) {
501
- throw new HindsightError(
502
- `${operation} request failed: ${err instanceof Error ? err.message : String(err)}`,
503
- undefined,
504
- err,
505
- );
522
+ const message = isTimeoutError(err)
523
+ ? `${operation} request timed out after 30s`
524
+ : `${operation} request failed: ${err instanceof Error ? err.message : String(err)}`;
525
+ throw new HindsightError(message, undefined, err);
506
526
  }
507
527
 
508
528
  if (opts?.allow404 && response.status === 404) {