diff --git a/packages/pi-plugin/package.json b/packages/pi-plugin/package.json index 62fb676d..71dd390d 100644 --- a/packages/pi-plugin/package.json +++ b/packages/pi-plugin/package.json @@ -1,71 +1,71 @@ { - "name": "@cortexkit/pi-magic-context", - "version": "0.30.1", - "type": "module", - "description": "Pi coding agent extension for Magic Context — cross-session memory and context management", - "main": "dist/index.js", - "license": "MIT", - "author": "ualtinok", - "keywords": [ - "pi", - "pi-coding-agent", - "extension", - "context", - "memory", - "magic-context", - "ai", - "llm" - ], - "repository": { - "type": "git", - "url": "https://github.com/cortexkit/magic-context", - "directory": "packages/pi-plugin" - }, - "files": [ - "dist", - "README.md" - ], - "scripts": { - "build": "bun build src/index.ts src/subagent-entry.ts --outdir dist --target node --format esm --external @earendil-works/pi-coding-agent --external @earendil-works/pi-tui --external @huggingface/transformers --external node:sqlite", - "typecheck": "tsc --noEmit", - "test": "bun test", - "lint": "biome check src", - "lint:fix": "biome check --write src", - "format": "biome format --write src", - "format:check": "biome format src", - "clean": "rm -rf dist", - "prepublishOnly": "bun run build" - }, - "dependencies": { - "@huggingface/transformers": "^4.1.0", - "@jitl/quickjs-singlefile-cjs-release-asyncify": "0.32.0", - "ai-tokenizer": "^1.0.6", - "comment-json": "^5.0.0", - "quickjs-emscripten": "^0.32.0", - "typebox": "^1.3.1", - "zod": "^4.1.8" - }, - "devDependencies": { - "@biomejs/biome": "^2.5.1", - "@earendil-works/pi-coding-agent": "^0.80.2", - "@earendil-works/pi-tui": "^0.80.2", - "@types/better-sqlite3": "^7.6.13", - "@types/bun": "^1.3.10", - "@types/node": "^22.20.0", - "typescript": "^5.8.0" - }, - "peerDependencies": { - "@earendil-works/pi-coding-agent": "^0.80.2", - "@earendil-works/pi-tui": "^0.80.2" - }, - "exports": { - ".": { - "import": "./dist/index.js" - } - }, - "pi": { - "extensions": [ - "./dist/index.js" - ] - } -} + "name": "@cortexkit/pi-magic-context", + "version": "0.30.2", + "type": "module", + "description": "Pi coding agent extension for Magic Context \u2014 cross-session memory and context management", + "main": "dist/index.js", + "license": "MIT", + "author": "ualtinok", + "keywords": [ + "pi", + "pi-coding-agent", + "extension", + "context", + "memory", + "magic-context", + "ai", + "llm" + ], + "repository": { + "type": "git", + "url": "https://github.com/cortexkit/magic-context", + "directory": "packages/pi-plugin" + }, + "files": [ + "dist", + "README.md" + ], + "scripts": { + "build": "bun build src/index.ts src/subagent-entry.ts --outdir dist --target node --format esm --external @earendil-works/pi-coding-agent --external @earendil-works/pi-tui --external @huggingface/transformers --external node:sqlite", + "typecheck": "tsc --noEmit", + "test": "bun test", + "lint": "biome check src", + "lint:fix": "biome check --write src", + "format": "biome format --write src", + "format:check": "biome format src", + "clean": "rm -rf dist", + "prepublishOnly": "bun run build" + }, + "dependencies": { + "@huggingface/transformers": "^4.1.0", + "@jitl/quickjs-singlefile-cjs-release-asyncify": "0.32.0", + "ai-tokenizer": "^1.0.6", + "comment-json": "^5.0.0", + "quickjs-emscripten": "^0.32.0", + "typebox": "^1.3.1", + "zod": "^4.1.8" + }, + "devDependencies": { + "@biomejs/biome": "^2.5.1", + "@earendil-works/pi-coding-agent": "^0.80.2", + "@earendil-works/pi-tui": "^0.80.2", + "@types/better-sqlite3": "^7.6.13", + "@types/bun": "^1.3.10", + "@types/node": "^22.20.0", + "typescript": "^5.8.0" + }, + "peerDependencies": { + "@earendil-works/pi-coding-agent": "^0.80.2", + "@earendil-works/pi-tui": "^0.80.2" + }, + "exports": { + ".": { + "import": "./dist/index.js" + } + }, + "pi": { + "extensions": [ + "./dist/index.js" + ] + } +} \ No newline at end of file diff --git a/packages/pi-plugin/src/dreamer/retrospective-raw-provider-pi.ts b/packages/pi-plugin/src/dreamer/retrospective-raw-provider-pi.ts index ff977915..f46a3de8 100644 --- a/packages/pi-plugin/src/dreamer/retrospective-raw-provider-pi.ts +++ b/packages/pi-plugin/src/dreamer/retrospective-raw-provider-pi.ts @@ -1,3 +1,4 @@ +import { readFileSync } from "node:fs"; import { resolve } from "node:path"; import type { @@ -191,20 +192,27 @@ async function loadDefaultPiSessionDeps(): Promise< > { const mod = (await import(/* @vite-ignore */ PI_CODING_AGENT_MODULE)) as { SessionManager?: { - listSessions?: (sessionDir?: string) => unknown[] | Promise; + listAll?: (sessionDir?: string) => unknown[] | Promise; }; loadEntriesFromFile?: (filePath: string) => unknown[] | Promise; + parseSessionEntries?: (content: string) => unknown[]; }; - const listSessions = mod.SessionManager?.listSessions; - const loadEntriesFromFile = mod.loadEntriesFromFile; - if ( - typeof listSessions !== "function" || - typeof loadEntriesFromFile !== "function" - ) { + const listSessions = mod.SessionManager?.listAll; + if (typeof listSessions !== "function") { throw new Error( - "Pi session APIs unavailable: expected SessionManager.listSessions and loadEntriesFromFile", + "Pi session APIs unavailable: expected SessionManager.listAll on pi-coding-agent", ); } + // loadEntriesFromFile is NOT part of pi-coding-agent's public API — + // fall back to readFileSync + parseSessionEntries (both exported). + const loadEntriesFromFile: ( + filePath: string, + ) => unknown[] | Promise = + mod.loadEntriesFromFile ?? + ((filePath: string) => { + const content = readFileSync(filePath, "utf8"); + return mod.parseSessionEntries?.(content) ?? []; + }); return { listSessions: listSessions.bind(mod.SessionManager), loadEntriesFromFile,