@oh-my-pi/pi-coding-agent 15.9.1 → 15.9.5

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 (109) hide show
  1. package/CHANGELOG.md +68 -2
  2. package/dist/types/cli/classify-install-target.d.ts +5 -1
  3. package/dist/types/cli/dry-balance-cli.d.ts +104 -0
  4. package/dist/types/commands/dry-balance.d.ts +31 -0
  5. package/dist/types/config/model-registry.d.ts +2 -0
  6. package/dist/types/config/models-config-schema.d.ts +3 -0
  7. package/dist/types/config/settings-schema.d.ts +13 -4
  8. package/dist/types/config/settings.d.ts +11 -0
  9. package/dist/types/discovery/helpers.d.ts +1 -0
  10. package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +2 -3
  11. package/dist/types/hindsight/bank.d.ts +17 -9
  12. package/dist/types/hindsight/mental-models.d.ts +1 -1
  13. package/dist/types/hindsight/state.d.ts +9 -3
  14. package/dist/types/mcp/manager.d.ts +1 -1
  15. package/dist/types/modes/components/assistant-message.d.ts +11 -0
  16. package/dist/types/modes/components/custom-editor.d.ts +3 -1
  17. package/dist/types/modes/components/error-banner.d.ts +11 -0
  18. package/dist/types/modes/components/tool-execution.d.ts +15 -0
  19. package/dist/types/modes/components/transcript-container.d.ts +4 -2
  20. package/dist/types/modes/components/user-message.d.ts +1 -1
  21. package/dist/types/modes/image-references.d.ts +17 -0
  22. package/dist/types/modes/interactive-mode.d.ts +7 -0
  23. package/dist/types/modes/types.d.ts +7 -0
  24. package/dist/types/modes/utils/ui-helpers.d.ts +1 -0
  25. package/dist/types/session/agent-session.d.ts +9 -0
  26. package/dist/types/session/auth-storage.d.ts +2 -2
  27. package/dist/types/session/blob-store.d.ts +12 -11
  28. package/dist/types/session/session-manager.d.ts +5 -3
  29. package/dist/types/system-prompt.d.ts +2 -0
  30. package/dist/types/task/types.d.ts +2 -0
  31. package/dist/types/tiny/title-client.d.ts +16 -1
  32. package/dist/types/tool-discovery/mode.d.ts +8 -0
  33. package/dist/types/tools/archive-reader.d.ts +5 -1
  34. package/dist/types/tools/index.d.ts +16 -0
  35. package/dist/types/tools/path-utils.d.ts +11 -0
  36. package/dist/types/tui/hyperlink.d.ts +12 -0
  37. package/dist/types/web/search/render.d.ts +1 -2
  38. package/package.json +9 -9
  39. package/src/cli/classify-install-target.ts +31 -5
  40. package/src/cli/dry-balance-cli.ts +823 -0
  41. package/src/cli/plugin-cli.ts +45 -0
  42. package/src/cli/web-search-cli.ts +0 -1
  43. package/src/cli-commands.ts +1 -0
  44. package/src/commands/dry-balance.ts +43 -0
  45. package/src/config/model-registry.ts +60 -4
  46. package/src/config/models-config-schema.ts +2 -0
  47. package/src/config/settings-schema.ts +14 -4
  48. package/src/config/settings.ts +38 -0
  49. package/src/discovery/builtin-rules/ts-no-tiny-functions.md +1 -0
  50. package/src/discovery/github.ts +37 -1
  51. package/src/discovery/helpers.ts +3 -1
  52. package/src/eval/__tests__/agent-bridge.test.ts +72 -0
  53. package/src/eval/py/tool-bridge.ts +43 -5
  54. package/src/extensibility/custom-commands/bundled/ci-green/index.ts +31 -2
  55. package/src/extensibility/plugins/legacy-pi-compat.ts +245 -25
  56. package/src/hindsight/backend.ts +184 -35
  57. package/src/hindsight/bank.ts +32 -22
  58. package/src/hindsight/mental-models.ts +1 -1
  59. package/src/hindsight/state.ts +21 -7
  60. package/src/internal-urls/docs-index.generated.ts +6 -6
  61. package/src/internal-urls/omp-protocol.ts +8 -2
  62. package/src/main.ts +7 -1
  63. package/src/mcp/manager.ts +40 -21
  64. package/src/modes/components/assistant-message.ts +22 -0
  65. package/src/modes/components/custom-editor.ts +14 -2
  66. package/src/modes/components/error-banner.ts +33 -0
  67. package/src/modes/components/tool-execution.ts +44 -0
  68. package/src/modes/components/transcript-container.ts +102 -30
  69. package/src/modes/components/tree-selector.ts +29 -2
  70. package/src/modes/components/user-message.ts +9 -2
  71. package/src/modes/controllers/event-controller.ts +42 -3
  72. package/src/modes/controllers/input-controller.ts +41 -3
  73. package/src/modes/image-references.ts +111 -0
  74. package/src/modes/interactive-mode.ts +48 -13
  75. package/src/modes/setup-wizard/scenes/sign-in.ts +27 -7
  76. package/src/modes/types.ts +10 -1
  77. package/src/modes/utils/ui-helpers.ts +23 -2
  78. package/src/prompts/agents/explore.md +1 -0
  79. package/src/prompts/agents/librarian.md +1 -0
  80. package/src/prompts/ci-green-request.md +5 -3
  81. package/src/prompts/dry-balance-bench.md +8 -0
  82. package/src/prompts/system/project-prompt.md +1 -0
  83. package/src/sdk.ts +99 -18
  84. package/src/session/agent-session.ts +103 -19
  85. package/src/session/auth-storage.ts +4 -0
  86. package/src/session/blob-store.ts +96 -9
  87. package/src/session/session-manager.ts +19 -10
  88. package/src/system-prompt.ts +4 -0
  89. package/src/task/executor.ts +6 -2
  90. package/src/task/index.ts +8 -7
  91. package/src/task/types.ts +2 -0
  92. package/src/tiny/title-client.ts +7 -1
  93. package/src/tool-discovery/mode.ts +24 -0
  94. package/src/tools/archive-reader.ts +339 -31
  95. package/src/tools/bash.ts +3 -4
  96. package/src/tools/fetch.ts +29 -9
  97. package/src/tools/gh.ts +65 -11
  98. package/src/tools/index.ts +22 -8
  99. package/src/tools/job.ts +3 -3
  100. package/src/tools/memory-reflect.ts +2 -2
  101. package/src/tools/path-utils.ts +21 -0
  102. package/src/tools/read.ts +58 -12
  103. package/src/tools/search-tool-bm25.ts +4 -6
  104. package/src/tools/search.ts +78 -12
  105. package/src/tui/hyperlink.ts +42 -7
  106. package/src/utils/file-mentions.ts +7 -107
  107. package/src/utils/title-generator.ts +58 -37
  108. package/src/web/search/index.ts +2 -2
  109. package/src/web/search/render.ts +20 -52
@@ -1,6 +1,6 @@
1
1
  import { logger } from "@oh-my-pi/pi-utils";
2
2
  import type { AgentSession } from "../session/agent-session";
3
- import { type BankScope, ensureBankMission } from "./bank";
3
+ import { type BankScope, ensureBankExists } from "./bank";
4
4
  import type { HindsightApi, MemoryItemInput } from "./client";
5
5
  import type { HindsightConfig } from "./config";
6
6
  import {
@@ -45,12 +45,12 @@ export interface HindsightSessionStateOptions {
45
45
  recallTagsMatch?: "any" | "all" | "any_strict" | "all_strict";
46
46
  config: HindsightConfig;
47
47
  session: AgentSession;
48
- missionsSet: Set<string>;
48
+ banksSet: Set<string>;
49
49
  lastRetainedTurn?: number;
50
50
  hasRecalledForFirstTurn?: boolean;
51
51
  /**
52
52
  * When set, this entry is a subagent alias that reuses the parent's bank,
53
- * scope, config, client, and missionsSet. Aliases skip auto-recall and
53
+ * scope, config, client, and banksSet. Aliases skip auto-recall and
54
54
  * auto-retain — those run on the parent only — but the recall/retain/reflect
55
55
  * tools resolve via the alias so they persist to the same bank as the parent.
56
56
  */
@@ -148,7 +148,7 @@ export class HindsightRetainQueue {
148
148
  }
149
149
 
150
150
  try {
151
- await ensureBankMission(state.client, state.bankId, state.config, state.missionsSet);
151
+ await ensureBankExists(state.client, state.bankId, state.config, state.banksSet);
152
152
  const batch: MemoryItemInput[] = items.map(item => ({
153
153
  content: item.content,
154
154
  context: item.context ?? state.config.retainContext,
@@ -198,7 +198,7 @@ export class HindsightSessionState {
198
198
  recallTagsMatch?: "any" | "all" | "any_strict" | "all_strict";
199
199
  config: HindsightConfig;
200
200
  session: AgentSession;
201
- missionsSet: Set<string>;
201
+ banksSet: Set<string>;
202
202
  lastRetainedTurn: number;
203
203
  hasRecalledForFirstTurn: boolean;
204
204
  lastRecallSnippet?: string;
@@ -213,6 +213,12 @@ export class HindsightSessionState {
213
213
  */
214
214
  mentalModelsLoadPromise?: Promise<void>;
215
215
  unsubscribe?: () => void;
216
+ /**
217
+ * Releases the `onHindsightScopeChanged` subscription that drives live
218
+ * rebuilds when `hindsight.bankId` / `bankIdPrefix` / `scoping` change.
219
+ * Only set on primary states; aliases inherit the parent's subscription.
220
+ */
221
+ unsubscribeScope?: () => void;
216
222
  /** Alias states delegate persistence config to a primary parent state. */
217
223
  aliasOf?: HindsightSessionState;
218
224
  readonly retainQueue: HindsightRetainQueue;
@@ -226,7 +232,7 @@ export class HindsightSessionState {
226
232
  this.recallTagsMatch = options.recallTagsMatch;
227
233
  this.config = options.config;
228
234
  this.session = options.session;
229
- this.missionsSet = options.missionsSet;
235
+ this.banksSet = options.banksSet;
230
236
  this.lastRetainedTurn = options.lastRetainedTurn ?? 0;
231
237
  this.hasRecalledForFirstTurn = options.hasRecalledForFirstTurn ?? false;
232
238
  this.aliasOf = options.aliasOf;
@@ -291,7 +297,7 @@ export class HindsightSessionState {
291
297
  const { transcript } = prepareRetentionTranscript(target, true);
292
298
  if (!transcript) return;
293
299
 
294
- await ensureBankMission(this.client, this.bankId, this.config, this.missionsSet);
300
+ await ensureBankExists(this.client, this.bankId, this.config, this.banksSet);
295
301
  await this.client.retain(this.bankId, transcript, {
296
302
  documentId,
297
303
  context: this.config.retainContext,
@@ -398,6 +404,12 @@ export class HindsightSessionState {
398
404
  async runMentalModelLoad(scope: BankScope): Promise<void> {
399
405
  if (!this.config.mentalModelsEnabled) return;
400
406
 
407
+ // Create/ensure the bank BEFORE the first mental-model POST so we don't
408
+ // land `createMentalModel` against a bank the server has never seen —
409
+ // that surfaces as a FK / 404 on Hindsight's side. `ensureBankExists`
410
+ // is idempotent (PUT) and skips after the first call via `banksSet`.
411
+ await ensureBankExists(this.client, this.bankId, this.config, this.banksSet);
412
+
401
413
  // Seeding is opt-in (`hindsight.mentalModelAutoSeed`). Default behaviour is
402
414
  // read-only: we surface whatever models the operator has curated on the
403
415
  // bank, but we do NOT POST to create new ones unless they explicitly
@@ -456,6 +468,8 @@ export class HindsightSessionState {
456
468
  dispose(): void {
457
469
  this.unsubscribe?.();
458
470
  this.unsubscribe = undefined;
471
+ this.unsubscribeScope?.();
472
+ this.unsubscribeScope = undefined;
459
473
  this.retainQueue.dispose();
460
474
  }
461
475