Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 70 additions & 70 deletions packages/pi-plugin/package.json
Original file line number Diff line number Diff line change
@@ -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"
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Missing trailing newline at end of file. This will produce a noisy diff when the next change adds one, and most linters (including Biome, which this repo uses) flag it.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/pi-plugin/package.json, line 64:

<comment>Missing trailing newline at end of file. This will produce a noisy diff when the next change adds one, and most linters (including Biome, which this repo uses) flag it.</comment>

<file context>
@@ -1,71 +1,71 @@
+  "exports": {
+    ".": {
+      "import": "./dist/index.js"
+    }
+  },
+  "pi": {
</file context>

},
"pi": {
"extensions": [
"./dist/index.js"
]
}
}
Comment on lines +70 to +71

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The file is missing a trailing newline after the reformatting. Most linters and editors expect one, and it produces a noisy diff in future PRs.

Suggested change
}
}
}
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

24 changes: 16 additions & 8 deletions packages/pi-plugin/src/dreamer/retrospective-raw-provider-pi.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { readFileSync } from "node:fs";
import { resolve } from "node:path";

import type {
Expand Down Expand Up @@ -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<unknown[]>;
listAll?: (sessionDir?: string) => unknown[] | Promise<unknown[]>;
};
loadEntriesFromFile?: (filePath: string) => unknown[] | Promise<unknown[]>;
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<unknown[]> =
mod.loadEntriesFromFile ??
((filePath: string) => {
const content = readFileSync(filePath, "utf8");
return mod.parseSessionEntries?.(content) ?? [];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Silent failure when parseSessionEntries is unavailable. If the peer package stops exporting parseSessionEntries, mod.parseSessionEntries?.(content) evaluates to undefined, and ?? [] silently returns an empty array. The retrospective will report "Skipped (no work)" with no diagnostic — reproducing the exact same symptom this PR intends to fix. Consider throwing (or at least logging a warning) when neither loadEntriesFromFile nor parseSessionEntries is available.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/pi-plugin/src/dreamer/retrospective-raw-provider-pi.ts, line 214:

<comment>Silent failure when `parseSessionEntries` is unavailable. If the peer package stops exporting `parseSessionEntries`, `mod.parseSessionEntries?.(content)` evaluates to `undefined`, and `?? []` silently returns an empty array. The retrospective will report "Skipped (no work)" with no diagnostic — reproducing the exact same symptom this PR intends to fix. Consider throwing (or at least logging a warning) when neither `loadEntriesFromFile` nor `parseSessionEntries` is available.</comment>

<file context>
@@ -191,20 +192,27 @@ async function loadDefaultPiSessionDeps(): Promise<
+		mod.loadEntriesFromFile ??
+		((filePath: string) => {
+			const content = readFileSync(filePath, "utf8");
+			return mod.parseSessionEntries?.(content) ?? [];
+		});
 	return {
</file context>
Suggested change
return mod.parseSessionEntries?.(content) ?? [];
const entries = mod.parseSessionEntries?.(content);
if (entries === undefined) {
throw new Error(
"Pi session APIs unavailable: neither loadEntriesFromFile nor parseSessionEntries found on pi-coding-agent",
);
}
return entries;

});
Comment on lines +208 to +215

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Silent fallback when parseSessionEntries is also absent

The guard now only checks that SessionManager.listAll is present, but drops the check for any entry-loading API. If loadEntriesFromFile is not exported (the situation described in the PR) and parseSessionEntries is also not exported or is later removed, mod.parseSessionEntries?.(content) evaluates to undefined, undefined ?? [] returns [], and every call to loadEntriesFromFile silently produces zero entries — no exception is raised, and the retrospective task reports "Skipped (no work)" with no diagnostic error. This is the exact same symptom as the original bug, just without the helpful error message that would surface it.

return {
listSessions: listSessions.bind(mod.SessionManager),
loadEntriesFromFile,
Expand Down