Skip to content

Commit 0b64492

Browse files
committed
fix(pi-plugin): retrospective provider uses correct pi-coding-agent API (#201)
loadDefaultPiSessionDeps() looked for SessionManager.listSessions and a public loadEntriesFromFile export, neither of which pi-coding-agent provides: the class exports the static listAll() (verified in session-manager.ts), and loadEntriesFromFile is internal (not re-exported from the package index). So the retrospective dream task threw "Pi session APIs unavailable" and silently reported "Skipped (no work)". Use SessionManager.listAll, and derive entry loading from the public parseSessionEntries + readFileSync when loadEntriesFromFile is absent (kept as an optional path so a future public export still works). Extracted from @kachook's PR #201 (the two real-code changes only; the PR branch predated the v0.30.2 WebSocket migration and carried a stale revert + version churn). Co-authored-by: kachook <kachook@users.noreply.github.com>
1 parent 952be13 commit 0b64492

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

packages/pi-plugin/src/dreamer/retrospective-raw-provider-pi.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { readFileSync } from "node:fs";
12
import { resolve } from "node:path";
23

34
import type {
@@ -191,20 +192,27 @@ async function loadDefaultPiSessionDeps(): Promise<
191192
> {
192193
const mod = (await import(/* @vite-ignore */ PI_CODING_AGENT_MODULE)) as {
193194
SessionManager?: {
194-
listSessions?: (sessionDir?: string) => unknown[] | Promise<unknown[]>;
195+
listAll?: (sessionDir?: string) => unknown[] | Promise<unknown[]>;
195196
};
196197
loadEntriesFromFile?: (filePath: string) => unknown[] | Promise<unknown[]>;
198+
parseSessionEntries?: (content: string) => unknown[];
197199
};
198-
const listSessions = mod.SessionManager?.listSessions;
199-
const loadEntriesFromFile = mod.loadEntriesFromFile;
200-
if (
201-
typeof listSessions !== "function" ||
202-
typeof loadEntriesFromFile !== "function"
203-
) {
200+
const listSessions = mod.SessionManager?.listAll;
201+
if (typeof listSessions !== "function") {
204202
throw new Error(
205-
"Pi session APIs unavailable: expected SessionManager.listSessions and loadEntriesFromFile",
203+
"Pi session APIs unavailable: expected SessionManager.listAll on pi-coding-agent",
206204
);
207205
}
206+
// loadEntriesFromFile is NOT part of pi-coding-agent's public API —
207+
// fall back to readFileSync + parseSessionEntries (both exported).
208+
const loadEntriesFromFile: (
209+
filePath: string,
210+
) => unknown[] | Promise<unknown[]> =
211+
mod.loadEntriesFromFile ??
212+
((filePath: string) => {
213+
const content = readFileSync(filePath, "utf8");
214+
return mod.parseSessionEntries?.(content) ?? [];
215+
});
208216
return {
209217
listSessions: listSessions.bind(mod.SessionManager),
210218
loadEntriesFromFile,

0 commit comments

Comments
 (0)