Skip to content

Commit 3f4a69d

Browse files
LynricsyWineFoxDev
andcommitted
feat(pi): 🧩 support OMP-compatible runtime
Co-authored-by: Wine Fox <fox@ling.plus>
1 parent 113f3e4 commit 3f4a69d

3 files changed

Lines changed: 48 additions & 9 deletions

File tree

packages/pi-plugin/package.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
"name": "@cortexkit/pi-magic-context",
33
"version": "0.33.0",
44
"type": "module",
5-
"description": "Pi coding agent extension for Magic Context — cross-session memory and context management",
5+
"description": "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
66
"main": "dist/index.js",
77
"license": "MIT",
88
"author": "ualtinok",
99
"keywords": [
1010
"pi",
1111
"pi-coding-agent",
12+
"omp",
13+
"oh-my-pi",
1214
"extension",
1315
"context",
1416
"memory",
@@ -58,6 +60,14 @@
5860
"@earendil-works/pi-coding-agent": "^0.80.2",
5961
"@earendil-works/pi-tui": "^0.80.2"
6062
},
63+
"peerDependenciesMeta": {
64+
"@earendil-works/pi-coding-agent": {
65+
"optional": true
66+
},
67+
"@earendil-works/pi-tui": {
68+
"optional": true
69+
}
70+
},
6171
"exports": {
6272
".": {
6373
"import": "./dist/index.js"
@@ -67,5 +77,10 @@
6777
"extensions": [
6878
"./dist/index.js"
6979
]
80+
},
81+
"omp": {
82+
"extensions": [
83+
"./dist/index.js"
84+
]
7085
}
7186
}

packages/pi-plugin/src/subagent-runner.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,29 @@ describe("subagent-runner pure helpers", () => {
286286
expect(args).toContain("--no-extensions");
287287
});
288288

289+
it("resolves relative allowlist entries from the active host agent dir", () => {
290+
const previous = process.env.PI_CODING_AGENT_DIR;
291+
process.env.PI_CODING_AGENT_DIR = "/tmp/omp-profile/agent";
292+
try {
293+
const args = buildArgsForTest(
294+
{ ...baseOptions, model: "anthropic/claude-sonnet" },
295+
{
296+
subagentExtensions: ["provider-package", "./extensions/provider.ts"],
297+
},
298+
);
299+
const firstExtension = args.indexOf("--extension");
300+
expect(args.slice(firstExtension, firstExtension + 4)).toEqual([
301+
"--extension",
302+
"/tmp/omp-profile/agent/provider-package",
303+
"--extension",
304+
"/tmp/omp-profile/agent/extensions/provider.ts",
305+
]);
306+
} finally {
307+
if (previous === undefined) delete process.env.PI_CODING_AGENT_DIR;
308+
else process.env.PI_CODING_AGENT_DIR = previous;
309+
}
310+
});
311+
289312
it("keeps the current all-extension argv shape when no allowlist is configured", () => {
290313
const args = buildArgsForTest({
291314
...baseOptions,

packages/pi-plugin/src/subagent-runner.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,14 @@ const TERMINAL_DRAIN_GRACE_MS = 2_000;
175175

176176
export const MAGIC_CONTEXT_PI_SUBAGENT_ENV = "MAGIC_CONTEXT_PI_SUBAGENT";
177177

178-
// Pi resolves local entries in its user settings package list from the
179-
// settings directory, not from the spawned child's project cwd. Keep the same
180-
// base for explicit --extension entries; the installed Pi package is not
181-
// available in every development worktree to import its resolver directly.
182-
// Pi's current resolver treats bare names as local paths too; npm packages
183-
// should use the explicit `npm:` source form.
184-
const PI_AGENT_SETTINGS_DIR = join(homedir(), ".pi", "agent");
178+
// Pi and OMP both expose their active agent directory through
179+
// PI_CODING_AGENT_DIR. OMP sets it for named profiles too. Resolve it at argv
180+
// construction time so profile switches and test seams cannot freeze a stale
181+
// user root; upstream Pi falls back to its stock ~/.pi/agent directory.
182+
function getHostAgentSettingsDir(): string {
183+
const configured = process.env.PI_CODING_AGENT_DIR?.trim();
184+
return configured ? resolvePath(configured) : join(homedir(), ".pi", "agent");
185+
}
185186
let configuredSubagentExtensions: readonly string[] | undefined;
186187

187188
/** Configure the user-tier extension allowlist used by new Pi child runners. */
@@ -195,7 +196,7 @@ function resolveSubagentExtensionEntry(entry: string): string {
195196
const trimmed = entry.trim();
196197
const isNpmSource = trimmed.startsWith("npm:");
197198
return !isNpmSource && !isAbsolute(trimmed)
198-
? resolvePath(PI_AGENT_SETTINGS_DIR, trimmed)
199+
? resolvePath(getHostAgentSettingsDir(), trimmed)
199200
: trimmed;
200201
}
201202

0 commit comments

Comments
 (0)