fix: require Pi 0.86 and test transcript context mapping

This commit is contained in:
Kashyab Ambarani
2026-09-22 15:05:44 -07:00
parent 2f94b72ee1
commit f42b776b8e
4 changed files with 61 additions and 6 deletions
+1
View File
@@ -4,3 +4,4 @@ package-lock.json
.DS_Store .DS_Store
*.log *.log
.env .env
.reference/
+7 -3
View File
@@ -16,9 +16,9 @@ Those models are available through the local Devin CLI. This package uses that C
## Requirements ## Requirements
- Pi Coding Agent 0.80+ - Pi Coding Agent 0.86+
- A signed-in [Devin CLI](https://docs.devin.ai/cli) (`devin auth status`) - A signed-in [Devin CLI](https://docs.devin.ai/cli) (`devin auth status`)
- Node 18+ - Node 22.19+ (required by Pi 0.86)
The CLI binary is resolved in this order: The CLI binary is resolved in this order:
@@ -35,12 +35,16 @@ From git:
pi install git:github.com/kashyab12/pi-devin pi install git:github.com/kashyab12/pi-devin
``` ```
After npm publish: From npm:
```bash ```bash
pi install npm:pi-devin pi install npm:pi-devin
``` ```
The published `pi-devin@0.1.2` predates Pi 0.86 support. For Pi 0.86+, use the git install above until a newer npm release is available.
`pi-devin-local` is a separate npm package maintained in the [mizorewww/pi-devin fork](https://github.com/mizorewww/pi-devin). Changes merged here do not update that package. Install only one: both packages register the `devin` provider, so their registrations can overwrite each other.
Local checkout: Local checkout:
```bash ```bash
+4 -3
View File
@@ -29,17 +29,18 @@
"LICENSE" "LICENSE"
], ],
"scripts": { "scripts": {
"test": "node --test test/*.test.mjs",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"peerDependencies": { "peerDependencies": {
"@earendil-works/pi-ai": "*", "@earendil-works/pi-ai": ">=0.86.0",
"@earendil-works/pi-coding-agent": "*" "@earendil-works/pi-coding-agent": ">=0.86.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^24.13.3", "@types/node": "^24.13.3",
"typescript": "^5.9.2" "typescript": "^5.9.2"
}, },
"engines": { "engines": {
"node": ">=18.0.0" "node": ">=22.19.0"
} }
} }
+49
View File
@@ -0,0 +1,49 @@
import assert from "node:assert/strict";
import test from "node:test";
import { normalizeContext } from "@earendil-works/pi-ai";
import { mapContextToChat } from "../src/context-map.ts";
const tool = (name) => ({
name,
description: name,
parameters: { type: "object", properties: {} },
});
// Regression for #7: Pi 0.86 moves prompt and tools into system messages.
test("preserves the prompt and tools from a normalized transcript", () => {
const read = tool("read");
const context = normalizeContext({
systemPrompt: "Inspect the repository.",
tools: [read],
messages: [{ role: "user", content: "Read README", timestamp: 1 }],
});
assert.deepEqual(mapContextToChat(context), {
messages: [
{ role: "system", content: "Inspect the repository." },
{ role: "user", content: "Read README" },
],
tools: [read],
});
});
test("applies later instruction, section, and tool changes", () => {
const bash = tool("bash");
const context = {
messages: [
{ role: "system", content: "Inspect the repository.", sections: { policy: "Old policy", obsolete: "Remove me" }, toolsAdded: [tool("read")], timestamp: 0 },
{ role: "user", content: "Continue", timestamp: 1 },
{ role: "system", content: "Use bash.", sections: { policy: "Do not edit.", obsolete: null }, toolsRemoved: [{ name: "read" }], toolsAdded: [bash], timestamp: 2 },
],
};
assert.deepEqual(mapContextToChat(context), {
messages: [
{ role: "system", content: "Inspect the repository.\n\nUse bash.\n\nDo not edit." },
{ role: "user", content: "Continue" },
],
tools: [bash],
});
});
test("accepts an empty transcript", () => {
assert.deepEqual(mapContextToChat(normalizeContext({ messages: [] })), { messages: [], tools: [] });
});