@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.
- package/CHANGELOG.md +68 -2
- package/dist/types/cli/classify-install-target.d.ts +5 -1
- package/dist/types/cli/dry-balance-cli.d.ts +104 -0
- package/dist/types/commands/dry-balance.d.ts +31 -0
- package/dist/types/config/model-registry.d.ts +2 -0
- package/dist/types/config/models-config-schema.d.ts +3 -0
- package/dist/types/config/settings-schema.d.ts +13 -4
- package/dist/types/config/settings.d.ts +11 -0
- package/dist/types/discovery/helpers.d.ts +1 -0
- package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +2 -3
- package/dist/types/hindsight/bank.d.ts +17 -9
- package/dist/types/hindsight/mental-models.d.ts +1 -1
- package/dist/types/hindsight/state.d.ts +9 -3
- package/dist/types/mcp/manager.d.ts +1 -1
- package/dist/types/modes/components/assistant-message.d.ts +11 -0
- package/dist/types/modes/components/custom-editor.d.ts +3 -1
- package/dist/types/modes/components/error-banner.d.ts +11 -0
- package/dist/types/modes/components/tool-execution.d.ts +15 -0
- package/dist/types/modes/components/transcript-container.d.ts +4 -2
- package/dist/types/modes/components/user-message.d.ts +1 -1
- package/dist/types/modes/image-references.d.ts +17 -0
- package/dist/types/modes/interactive-mode.d.ts +7 -0
- package/dist/types/modes/types.d.ts +7 -0
- package/dist/types/modes/utils/ui-helpers.d.ts +1 -0
- package/dist/types/session/agent-session.d.ts +9 -0
- package/dist/types/session/auth-storage.d.ts +2 -2
- package/dist/types/session/blob-store.d.ts +12 -11
- package/dist/types/session/session-manager.d.ts +5 -3
- package/dist/types/system-prompt.d.ts +2 -0
- package/dist/types/task/types.d.ts +2 -0
- package/dist/types/tiny/title-client.d.ts +16 -1
- package/dist/types/tool-discovery/mode.d.ts +8 -0
- package/dist/types/tools/archive-reader.d.ts +5 -1
- package/dist/types/tools/index.d.ts +16 -0
- package/dist/types/tools/path-utils.d.ts +11 -0
- package/dist/types/tui/hyperlink.d.ts +12 -0
- package/dist/types/web/search/render.d.ts +1 -2
- package/package.json +9 -9
- package/src/cli/classify-install-target.ts +31 -5
- package/src/cli/dry-balance-cli.ts +823 -0
- package/src/cli/plugin-cli.ts +45 -0
- package/src/cli/web-search-cli.ts +0 -1
- package/src/cli-commands.ts +1 -0
- package/src/commands/dry-balance.ts +43 -0
- package/src/config/model-registry.ts +60 -4
- package/src/config/models-config-schema.ts +2 -0
- package/src/config/settings-schema.ts +14 -4
- package/src/config/settings.ts +38 -0
- package/src/discovery/builtin-rules/ts-no-tiny-functions.md +1 -0
- package/src/discovery/github.ts +37 -1
- package/src/discovery/helpers.ts +3 -1
- package/src/eval/__tests__/agent-bridge.test.ts +72 -0
- package/src/eval/py/tool-bridge.ts +43 -5
- package/src/extensibility/custom-commands/bundled/ci-green/index.ts +31 -2
- package/src/extensibility/plugins/legacy-pi-compat.ts +245 -25
- package/src/hindsight/backend.ts +184 -35
- package/src/hindsight/bank.ts +32 -22
- package/src/hindsight/mental-models.ts +1 -1
- package/src/hindsight/state.ts +21 -7
- package/src/internal-urls/docs-index.generated.ts +6 -6
- package/src/internal-urls/omp-protocol.ts +8 -2
- package/src/main.ts +7 -1
- package/src/mcp/manager.ts +40 -21
- package/src/modes/components/assistant-message.ts +22 -0
- package/src/modes/components/custom-editor.ts +14 -2
- package/src/modes/components/error-banner.ts +33 -0
- package/src/modes/components/tool-execution.ts +44 -0
- package/src/modes/components/transcript-container.ts +102 -30
- package/src/modes/components/tree-selector.ts +29 -2
- package/src/modes/components/user-message.ts +9 -2
- package/src/modes/controllers/event-controller.ts +42 -3
- package/src/modes/controllers/input-controller.ts +41 -3
- package/src/modes/image-references.ts +111 -0
- package/src/modes/interactive-mode.ts +48 -13
- package/src/modes/setup-wizard/scenes/sign-in.ts +27 -7
- package/src/modes/types.ts +10 -1
- package/src/modes/utils/ui-helpers.ts +23 -2
- package/src/prompts/agents/explore.md +1 -0
- package/src/prompts/agents/librarian.md +1 -0
- package/src/prompts/ci-green-request.md +5 -3
- package/src/prompts/dry-balance-bench.md +8 -0
- package/src/prompts/system/project-prompt.md +1 -0
- package/src/sdk.ts +99 -18
- package/src/session/agent-session.ts +103 -19
- package/src/session/auth-storage.ts +4 -0
- package/src/session/blob-store.ts +96 -9
- package/src/session/session-manager.ts +19 -10
- package/src/system-prompt.ts +4 -0
- package/src/task/executor.ts +6 -2
- package/src/task/index.ts +8 -7
- package/src/task/types.ts +2 -0
- package/src/tiny/title-client.ts +7 -1
- package/src/tool-discovery/mode.ts +24 -0
- package/src/tools/archive-reader.ts +339 -31
- package/src/tools/bash.ts +3 -4
- package/src/tools/fetch.ts +29 -9
- package/src/tools/gh.ts +65 -11
- package/src/tools/index.ts +22 -8
- package/src/tools/job.ts +3 -3
- package/src/tools/memory-reflect.ts +2 -2
- package/src/tools/path-utils.ts +21 -0
- package/src/tools/read.ts +58 -12
- package/src/tools/search-tool-bm25.ts +4 -6
- package/src/tools/search.ts +78 -12
- package/src/tui/hyperlink.ts +42 -7
- package/src/utils/file-mentions.ts +7 -107
- package/src/utils/title-generator.ts +58 -37
- package/src/web/search/index.ts +2 -2
- package/src/web/search/render.ts +20 -52
package/src/hindsight/state.ts
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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.
|
|
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
|
|
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
|
|