@cortexkit/pi-magic-context 0.30.3 → 0.30.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +59 -44
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -147,7 +147,7 @@ This package is part of the [magic-context monorepo](https://github.com/cortexki
|
|
|
147
147
|
| Pi-specific module | Responsibility |
|
|
148
148
|
|---|---|
|
|
149
149
|
| `context-handler.ts` | Pi `pi.on("context", ...)` adapter — tags, drops, runs nudges and auto-search |
|
|
150
|
-
| `subagent-runner.ts` | Spawns `pi --print --mode json --no-
|
|
150
|
+
| `subagent-runner.ts` | Spawns `pi --print --mode json --no-session ...` for historian/sidekick/dreamer subagents, keeps extension discovery on for provider/AFT extensions, sets `MAGIC_CONTEXT_PI_SUBAGENT=1` so the full Magic Context entry no-ops, and applies a per-agent `--tools`/`--no-tools` allow-list plus a 2-second terminal drain |
|
|
151
151
|
| `tools/` | Pi `pi.registerTool` wrappers around the shared tool implementations |
|
|
152
152
|
| `commands/` | Pi `pi.registerCommand` wrappers for the five `/ctx-*` slash commands |
|
|
153
153
|
| `dreamer/` | Pi-side adapter for the shared dreamer scheduler |
|
package/dist/index.js
CHANGED
|
@@ -156487,9 +156487,11 @@ function compareSemverCore(a, b) {
|
|
|
156487
156487
|
|
|
156488
156488
|
// ../plugin/src/shared/announcement.ts
|
|
156489
156489
|
init_data_path();
|
|
156490
|
-
var ANNOUNCEMENT_VERSION = "0.30.
|
|
156490
|
+
var ANNOUNCEMENT_VERSION = "0.30.4";
|
|
156491
156491
|
var ANNOUNCEMENT_FEATURES = [
|
|
156492
|
-
"
|
|
156492
|
+
"Pi: fixed historian and dreamer failing when your model comes from a provider extension (Antigravity, Anthropic OAuth, etc.). Subagents now load your extensions.",
|
|
156493
|
+
"Pi: fixed the retrospective and refresh-primers dreamer tasks reading sessions through the wrong API.",
|
|
156494
|
+
"OpenCode: the plugin no longer re-adds its TUI sidebar entry on startup, so removing it from tui.jsonc now sticks."
|
|
156493
156495
|
];
|
|
156494
156496
|
var ANNOUNCEMENT_FOOTER = "Join us on Discord: https://discord.gg/F2uWxjGnU";
|
|
156495
156497
|
var STATE_FILENAME = "last_announced_version";
|
|
@@ -156833,6 +156835,10 @@ function resolveSubagentEntryPath() {
|
|
|
156833
156835
|
}
|
|
156834
156836
|
var SUBAGENT_ENTRY_PATH = resolveSubagentEntryPath();
|
|
156835
156837
|
var TERMINAL_DRAIN_GRACE_MS = 2000;
|
|
156838
|
+
var MAGIC_CONTEXT_PI_SUBAGENT_ENV = "MAGIC_CONTEXT_PI_SUBAGENT";
|
|
156839
|
+
var PI_READ_ONLY_BUILTINS = ["read", "grep", "find", "ls"];
|
|
156840
|
+
var PI_AFT_READ_TOOLS = ["aft_outline", "aft_zoom", "aft_search"];
|
|
156841
|
+
var PI_HISTORIAN_TOOLS = [...PI_READ_ONLY_BUILTINS, "aft_search"];
|
|
156836
156842
|
var DREAMER_ACTION_AGENTS = new Set([
|
|
156837
156843
|
"dreamer",
|
|
156838
156844
|
"magic-context-dreamer"
|
|
@@ -156842,17 +156848,29 @@ var SEARCH_ONLY_SUBAGENT_TOOL_AGENTS = new Set([
|
|
|
156842
156848
|
"dreamer-retrospective",
|
|
156843
156849
|
"dreamer-primer-investigator"
|
|
156844
156850
|
]);
|
|
156845
|
-
var
|
|
156851
|
+
var STRICT_TOOL_ALLOWLIST_ENTRIES = [
|
|
156846
156852
|
["dreamer-retrospective", ["ctx_search"]],
|
|
156847
156853
|
["smart-note-compiler", []],
|
|
156854
|
+
["magic-context-historian", PI_HISTORIAN_TOOLS],
|
|
156855
|
+
["historian", PI_HISTORIAN_TOOLS],
|
|
156856
|
+
["historian-recomp", PI_HISTORIAN_TOOLS],
|
|
156857
|
+
["historian-editor", PI_HISTORIAN_TOOLS],
|
|
156858
|
+
["sidekick", [...PI_READ_ONLY_BUILTINS, "ctx_search"]],
|
|
156848
156859
|
["dreamer-classifier", []],
|
|
156849
156860
|
["dreamer-reviewer", []],
|
|
156850
|
-
[
|
|
156851
|
-
|
|
156852
|
-
|
|
156861
|
+
[
|
|
156862
|
+
"dreamer-primer-investigator",
|
|
156863
|
+
[...PI_READ_ONLY_BUILTINS, ...PI_AFT_READ_TOOLS, "ctx_search"]
|
|
156864
|
+
],
|
|
156865
|
+
["dreamer-memory-mapper", [...PI_READ_ONLY_BUILTINS, ...PI_AFT_READ_TOOLS]],
|
|
156866
|
+
[
|
|
156867
|
+
"dreamer-docs",
|
|
156868
|
+
[...PI_READ_ONLY_BUILTINS, "bash", "write", "edit", ...PI_AFT_READ_TOOLS]
|
|
156869
|
+
],
|
|
156853
156870
|
["dreamer", ["ctx_memory"]],
|
|
156854
156871
|
["magic-context-dreamer", ["ctx_memory"]]
|
|
156855
|
-
]
|
|
156872
|
+
];
|
|
156873
|
+
var STRICT_TOOL_ALLOWLIST = new Map(STRICT_TOOL_ALLOWLIST_ENTRIES);
|
|
156856
156874
|
function inferAccountingSubagent(agent) {
|
|
156857
156875
|
if (agent.includes("sidekick"))
|
|
156858
156876
|
return "sidekick";
|
|
@@ -156962,7 +156980,10 @@ class PiSubagentRunner {
|
|
|
156962
156980
|
try {
|
|
156963
156981
|
child = this.spawnImpl(this.invocation.command, [...this.invocation.prefixArgs, ...args], {
|
|
156964
156982
|
cwd: options.cwd,
|
|
156965
|
-
env:
|
|
156983
|
+
env: {
|
|
156984
|
+
...process.env,
|
|
156985
|
+
[MAGIC_CONTEXT_PI_SUBAGENT_ENV]: "1"
|
|
156986
|
+
},
|
|
156966
156987
|
stdio: [deliverViaStdin ? "pipe" : "ignore", "pipe", "pipe"]
|
|
156967
156988
|
});
|
|
156968
156989
|
} catch (error) {
|
|
@@ -157258,7 +157279,6 @@ function buildArgs(options, opts) {
|
|
|
157258
157279
|
"--mode",
|
|
157259
157280
|
"json",
|
|
157260
157281
|
"--no-session",
|
|
157261
|
-
"--no-extensions",
|
|
157262
157282
|
"--no-skills",
|
|
157263
157283
|
"--no-prompt-templates"
|
|
157264
157284
|
];
|
|
@@ -157270,7 +157290,10 @@ function buildArgs(options, opts) {
|
|
|
157270
157290
|
}
|
|
157271
157291
|
}
|
|
157272
157292
|
const strictTools = STRICT_TOOL_ALLOWLIST.get(options.agent);
|
|
157273
|
-
if (strictTools) {
|
|
157293
|
+
if (strictTools === undefined) {
|
|
157294
|
+
sessionLog(options.accountingSessionId ?? "pi-subagent", `Pi subagent agent "${options.agent}" has no strict tool allow-list; forcing --no-tools`);
|
|
157295
|
+
args.push("--no-tools");
|
|
157296
|
+
} else {
|
|
157274
157297
|
if (strictTools.length > 0) {
|
|
157275
157298
|
args.push("--tools", strictTools.join(","));
|
|
157276
157299
|
} else {
|
|
@@ -183682,8 +183705,26 @@ function synthesizeToolResultParts(msg) {
|
|
|
183682
183705
|
];
|
|
183683
183706
|
}
|
|
183684
183707
|
|
|
183685
|
-
// src/dreamer/
|
|
183708
|
+
// src/dreamer/pi-session-api.ts
|
|
183709
|
+
import { readFileSync as readFileSync9 } from "node:fs";
|
|
183686
183710
|
var PI_CODING_AGENT_MODULE = "@earendil-works/pi-coding-agent";
|
|
183711
|
+
async function loadDefaultPiSessionApi() {
|
|
183712
|
+
const mod = await import(PI_CODING_AGENT_MODULE);
|
|
183713
|
+
const listSessions = mod.SessionManager?.listAll;
|
|
183714
|
+
if (typeof listSessions !== "function") {
|
|
183715
|
+
throw new Error("Pi session APIs unavailable: expected SessionManager.listAll on pi-coding-agent");
|
|
183716
|
+
}
|
|
183717
|
+
const loadEntriesFromFile = mod.loadEntriesFromFile ?? ((filePath) => {
|
|
183718
|
+
const content = readFileSync9(filePath, "utf8");
|
|
183719
|
+
return mod.parseSessionEntries?.(content) ?? [];
|
|
183720
|
+
});
|
|
183721
|
+
return {
|
|
183722
|
+
listSessions: listSessions.bind(mod.SessionManager),
|
|
183723
|
+
loadEntriesFromFile
|
|
183724
|
+
};
|
|
183725
|
+
}
|
|
183726
|
+
|
|
183727
|
+
// src/dreamer/primer-raw-provider-pi.ts
|
|
183687
183728
|
function createPiPrimerRawProviderFactory(deps = {}) {
|
|
183688
183729
|
let resolved = null;
|
|
183689
183730
|
const resolveDeps = async () => {
|
|
@@ -183693,7 +183734,7 @@ function createPiPrimerRawProviderFactory(deps = {}) {
|
|
|
183693
183734
|
loadEntriesFromFile: deps.loadEntriesFromFile
|
|
183694
183735
|
};
|
|
183695
183736
|
}
|
|
183696
|
-
resolved ??=
|
|
183737
|
+
resolved ??= loadDefaultPiSessionApi();
|
|
183697
183738
|
return resolved;
|
|
183698
183739
|
};
|
|
183699
183740
|
return async (sessionId) => {
|
|
@@ -183720,24 +183761,9 @@ function createPiPrimerRawProviderFactory(deps = {}) {
|
|
|
183720
183761
|
}
|
|
183721
183762
|
};
|
|
183722
183763
|
}
|
|
183723
|
-
async function loadDefaultPiSessionDeps() {
|
|
183724
|
-
const mod = await import(PI_CODING_AGENT_MODULE);
|
|
183725
|
-
const listSessions = mod.SessionManager?.listSessions;
|
|
183726
|
-
const loadEntriesFromFile = mod.loadEntriesFromFile;
|
|
183727
|
-
if (typeof listSessions !== "function" || typeof loadEntriesFromFile !== "function") {
|
|
183728
|
-
throw new Error("Pi session APIs unavailable: expected SessionManager.listSessions and loadEntriesFromFile");
|
|
183729
|
-
}
|
|
183730
|
-
return {
|
|
183731
|
-
listSessions: listSessions.bind(mod.SessionManager),
|
|
183732
|
-
loadEntriesFromFile
|
|
183733
|
-
};
|
|
183734
|
-
}
|
|
183735
183764
|
|
|
183736
183765
|
// src/dreamer/retrospective-raw-provider-pi.ts
|
|
183737
|
-
import { readFileSync as readFileSync9 } from "node:fs";
|
|
183738
183766
|
import { resolve as resolve2 } from "node:path";
|
|
183739
|
-
var PI_CODING_AGENT_MODULE2 = "@earendil-works/pi-coding-agent";
|
|
183740
|
-
|
|
183741
183767
|
class PiRetrospectiveRawProvider {
|
|
183742
183768
|
deps;
|
|
183743
183769
|
sessionPathById = new Map;
|
|
@@ -183803,7 +183829,7 @@ class PiRetrospectiveRawProvider {
|
|
|
183803
183829
|
loadEntriesFromFile: this.deps.loadEntriesFromFile
|
|
183804
183830
|
};
|
|
183805
183831
|
}
|
|
183806
|
-
this.resolvedDefaultDeps ??=
|
|
183832
|
+
this.resolvedDefaultDeps ??= loadDefaultPiSessionApi();
|
|
183807
183833
|
return this.resolvedDefaultDeps;
|
|
183808
183834
|
}
|
|
183809
183835
|
}
|
|
@@ -183840,21 +183866,6 @@ function extractPiTextContent(content) {
|
|
|
183840
183866
|
}).join(`
|
|
183841
183867
|
`);
|
|
183842
183868
|
}
|
|
183843
|
-
async function loadDefaultPiSessionDeps2() {
|
|
183844
|
-
const mod = await import(PI_CODING_AGENT_MODULE2);
|
|
183845
|
-
const listSessions = mod.SessionManager?.listAll;
|
|
183846
|
-
if (typeof listSessions !== "function") {
|
|
183847
|
-
throw new Error("Pi session APIs unavailable: expected SessionManager.listAll on pi-coding-agent");
|
|
183848
|
-
}
|
|
183849
|
-
const loadEntriesFromFile = mod.loadEntriesFromFile ?? ((filePath) => {
|
|
183850
|
-
const content = readFileSync9(filePath, "utf8");
|
|
183851
|
-
return mod.parseSessionEntries?.(content) ?? [];
|
|
183852
|
-
});
|
|
183853
|
-
return {
|
|
183854
|
-
listSessions: listSessions.bind(mod.SessionManager),
|
|
183855
|
-
loadEntriesFromFile
|
|
183856
|
-
};
|
|
183857
|
-
}
|
|
183858
183869
|
|
|
183859
183870
|
// src/dreamer/index.ts
|
|
183860
183871
|
var registeredProjects2 = new Map;
|
|
@@ -200001,7 +200012,7 @@ function formatThresholdPercent(value) {
|
|
|
200001
200012
|
// package.json
|
|
200002
200013
|
var package_default = {
|
|
200003
200014
|
name: "@cortexkit/pi-magic-context",
|
|
200004
|
-
version: "0.30.
|
|
200015
|
+
version: "0.30.4",
|
|
200005
200016
|
type: "module",
|
|
200006
200017
|
description: "Pi coding agent extension for Magic Context — cross-session memory and context management",
|
|
200007
200018
|
main: "dist/index.js",
|
|
@@ -206350,6 +206361,10 @@ function resolveDreamerFromConfig(config2) {
|
|
|
206350
206361
|
return config2.dreamer?.disable === true ? undefined : config2.dreamer;
|
|
206351
206362
|
}
|
|
206352
206363
|
async function src_default2(pi) {
|
|
206364
|
+
if (process.env[MAGIC_CONTEXT_PI_SUBAGENT_ENV] === "1") {
|
|
206365
|
+
log(`${PREFIX} subagent child detected (${MAGIC_CONTEXT_PI_SUBAGENT_ENV}=1); skipping full extension registration`);
|
|
206366
|
+
return;
|
|
206367
|
+
}
|
|
206353
206368
|
const storageDir = getMagicContextStorageDir();
|
|
206354
206369
|
const dbPath = join13(storageDir, "context.db");
|
|
206355
206370
|
let db;
|
package/package.json
CHANGED