@cortexkit/pi-magic-context 0.35.1 → 0.36.0
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 +46 -20
- package/dist/{index-gxftx2a4.js → index-9t7jhq83.js} +519 -31
- package/dist/{index-zmyx6nf5.js → index-npnqc564.js} +8 -1
- package/dist/index.js +161 -39
- package/dist/{safe-notification-target-ng8ygena.js → safe-notification-target-0s6j4m9f.js} +1 -1
- package/dist/subagent-entry.js +2 -2
- package/package.json +20 -4
|
@@ -13,7 +13,7 @@ function getHarness() {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
// ../plugin/src/shared/data-path.ts
|
|
16
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
16
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
|
17
17
|
import * as os from "node:os";
|
|
18
18
|
import * as path from "node:path";
|
|
19
19
|
function getDataDir() {
|
|
@@ -62,6 +62,13 @@ function getOpenCodeStorageDir() {
|
|
|
62
62
|
return path.join(getDataDir(), "opencode", "storage");
|
|
63
63
|
}
|
|
64
64
|
function getMagicContextStorageDir() {
|
|
65
|
+
if (!process.env.XDG_DATA_HOME) {
|
|
66
|
+
const testDataDir = process.env.MAGIC_CONTEXT_TEST_DATA_DIR;
|
|
67
|
+
if (testDataDir) {
|
|
68
|
+
return path.join(testDataDir, "cortexkit", "magic-context");
|
|
69
|
+
}
|
|
70
|
+
if (false) {}
|
|
71
|
+
}
|
|
65
72
|
return path.join(getDataDir(), "cortexkit", "magic-context");
|
|
66
73
|
}
|
|
67
74
|
function getLegacyOpenCodeMagicContextStorageDir() {
|
package/dist/index.js
CHANGED
|
@@ -246,6 +246,7 @@ import {
|
|
|
246
246
|
normalizeText,
|
|
247
247
|
normalizeTodoStateJson,
|
|
248
248
|
normalizeVerificationFiles,
|
|
249
|
+
ompModelRefToCanonical,
|
|
249
250
|
openDatabase,
|
|
250
251
|
openDatabaseAsync,
|
|
251
252
|
parkGitSweepNonIndexable,
|
|
@@ -309,6 +310,7 @@ import {
|
|
|
309
310
|
resolveGitTopLevel,
|
|
310
311
|
resolveLimit,
|
|
311
312
|
resolveModelConfigOrDefault,
|
|
313
|
+
resolveModelRefForOmp,
|
|
312
314
|
resolveModelRefForPi,
|
|
313
315
|
resolveMuralWire,
|
|
314
316
|
resolvePiStableId,
|
|
@@ -373,7 +375,7 @@ import {
|
|
|
373
375
|
withMigrationLanguageDirective,
|
|
374
376
|
withRawMessageProvider,
|
|
375
377
|
withRawSessionMessageCache
|
|
376
|
-
} from "./index-
|
|
378
|
+
} from "./index-9t7jhq83.js";
|
|
377
379
|
import {
|
|
378
380
|
pushNotification
|
|
379
381
|
} from "./index-hw34xmzk.js";
|
|
@@ -385,7 +387,7 @@ import {
|
|
|
385
387
|
log,
|
|
386
388
|
sessionLog,
|
|
387
389
|
setHarness
|
|
388
|
-
} from "./index-
|
|
390
|
+
} from "./index-npnqc564.js";
|
|
389
391
|
import {
|
|
390
392
|
__require,
|
|
391
393
|
__toESM
|
|
@@ -2064,7 +2066,13 @@ function isEmptySidekickResult(text) {
|
|
|
2064
2066
|
|
|
2065
2067
|
// src/subagent-runner.ts
|
|
2066
2068
|
import * as childProcess from "node:child_process";
|
|
2067
|
-
import {
|
|
2069
|
+
import {
|
|
2070
|
+
existsSync as existsSync3,
|
|
2071
|
+
mkdtempSync,
|
|
2072
|
+
readFileSync as readFileSync2,
|
|
2073
|
+
rmSync,
|
|
2074
|
+
writeFileSync as writeFileSync2
|
|
2075
|
+
} from "node:fs";
|
|
2068
2076
|
import { createRequire } from "node:module";
|
|
2069
2077
|
import { homedir, tmpdir } from "node:os";
|
|
2070
2078
|
import {
|
|
@@ -2263,7 +2271,61 @@ function resolveSubagentEntryPath() {
|
|
|
2263
2271
|
var SUBAGENT_ENTRY_PATH = resolveSubagentEntryPath();
|
|
2264
2272
|
var TERMINAL_DRAIN_GRACE_MS = 2000;
|
|
2265
2273
|
var MAGIC_CONTEXT_PI_SUBAGENT_ENV = "MAGIC_CONTEXT_PI_SUBAGENT";
|
|
2266
|
-
|
|
2274
|
+
function packageRootIsOmp(packageRoot) {
|
|
2275
|
+
try {
|
|
2276
|
+
const manifest = JSON.parse(readFileSync2(join2(packageRoot, "package.json"), "utf-8"));
|
|
2277
|
+
return manifest.name === "@oh-my-pi/pi-coding-agent";
|
|
2278
|
+
} catch {
|
|
2279
|
+
return false;
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
function expandHomePath(value) {
|
|
2283
|
+
if (value === "~")
|
|
2284
|
+
return homedir();
|
|
2285
|
+
if (value.startsWith("~/") || value.startsWith("~\\")) {
|
|
2286
|
+
return resolvePath(homedir(), value.slice(2));
|
|
2287
|
+
}
|
|
2288
|
+
return resolvePath(value);
|
|
2289
|
+
}
|
|
2290
|
+
function isOmpHostProcess() {
|
|
2291
|
+
const execName = basename(process.execPath).toLowerCase();
|
|
2292
|
+
if (/^omp(?:\.exe)?$/.test(execName))
|
|
2293
|
+
return true;
|
|
2294
|
+
const packageOverride = process.env.PI_PACKAGE_DIR?.trim();
|
|
2295
|
+
if (packageOverride && packageRootIsOmp(expandHomePath(packageOverride))) {
|
|
2296
|
+
return true;
|
|
2297
|
+
}
|
|
2298
|
+
let current = process.argv[1] ? dirname(resolvePath(process.argv[1])) : "";
|
|
2299
|
+
while (current) {
|
|
2300
|
+
if (packageRootIsOmp(current))
|
|
2301
|
+
return true;
|
|
2302
|
+
const parent = dirname(current);
|
|
2303
|
+
if (parent === current)
|
|
2304
|
+
break;
|
|
2305
|
+
current = parent;
|
|
2306
|
+
}
|
|
2307
|
+
return false;
|
|
2308
|
+
}
|
|
2309
|
+
function normalizedOmpProfile() {
|
|
2310
|
+
const raw = (process.env.OMP_PROFILE ?? process.env.PI_PROFILE)?.trim();
|
|
2311
|
+
return raw && raw !== "default" && /^[a-z0-9][a-z0-9._-]{0,63}$/.test(raw) ? raw : undefined;
|
|
2312
|
+
}
|
|
2313
|
+
function getHostAgentSettingsDir() {
|
|
2314
|
+
if (!isOmpHostProcess())
|
|
2315
|
+
return join2(homedir(), ".pi", "agent");
|
|
2316
|
+
const configRoot = join2(homedir(), process.env.PI_CONFIG_DIR?.trim() || ".omp");
|
|
2317
|
+
const profile = normalizedOmpProfile();
|
|
2318
|
+
if (profile)
|
|
2319
|
+
return join2(configRoot, "profiles", profile, "agent");
|
|
2320
|
+
const configured = process.env.PI_CODING_AGENT_DIR?.trim();
|
|
2321
|
+
return configured ? resolvePath(configured) : join2(configRoot, "agent");
|
|
2322
|
+
}
|
|
2323
|
+
function modelRefToCanonicalForHost(ref) {
|
|
2324
|
+
return isOmpHostProcess() ? ompModelRefToCanonical(ref) : piModelRefToCanonical(ref);
|
|
2325
|
+
}
|
|
2326
|
+
function resolveModelRefForHost(ref) {
|
|
2327
|
+
return isOmpHostProcess() ? resolveModelRefForOmp(ref) : resolveModelRefForPi(ref);
|
|
2328
|
+
}
|
|
2267
2329
|
var configuredSubagentExtensions;
|
|
2268
2330
|
function configurePiSubagentExtensions(extensions) {
|
|
2269
2331
|
configuredSubagentExtensions = extensions?.slice();
|
|
@@ -2271,7 +2333,7 @@ function configurePiSubagentExtensions(extensions) {
|
|
|
2271
2333
|
function resolveSubagentExtensionEntry(entry) {
|
|
2272
2334
|
const trimmed = entry.trim();
|
|
2273
2335
|
const isNpmSource = trimmed.startsWith("npm:");
|
|
2274
|
-
return !isNpmSource && !isAbsolute(trimmed) ? resolvePath(
|
|
2336
|
+
return !isNpmSource && !isAbsolute(trimmed) ? resolvePath(getHostAgentSettingsDir(), trimmed) : trimmed;
|
|
2275
2337
|
}
|
|
2276
2338
|
var PI_READ_ONLY_BUILTINS = ["read", "grep", "find", "ls"];
|
|
2277
2339
|
var PI_AFT_READ_TOOLS = ["aft_outline", "aft_zoom", "aft_search"];
|
|
@@ -2309,6 +2371,32 @@ var STRICT_TOOL_ALLOWLIST_ENTRIES = [
|
|
|
2309
2371
|
];
|
|
2310
2372
|
var STRICT_TOOL_ALLOWLIST = new Map(STRICT_TOOL_ALLOWLIST_ENTRIES);
|
|
2311
2373
|
var ZERO_TOOL_PROMPT_REQUIRED_AGENTS = new Set(STRICT_TOOL_ALLOWLIST_ENTRIES.filter(([, tools]) => tools.length === 0).map(([agent]) => agent));
|
|
2374
|
+
var OMP_TOOL_ALIASES = {
|
|
2375
|
+
find: "glob",
|
|
2376
|
+
ls: "glob"
|
|
2377
|
+
};
|
|
2378
|
+
var OMP_ALLOWLISTABLE_TOOLS = {
|
|
2379
|
+
read: true,
|
|
2380
|
+
grep: true,
|
|
2381
|
+
glob: true,
|
|
2382
|
+
bash: true,
|
|
2383
|
+
edit: true,
|
|
2384
|
+
write: true
|
|
2385
|
+
};
|
|
2386
|
+
function resolveHostToolAllowlist(tools, ompHost = isOmpHostProcess()) {
|
|
2387
|
+
if (!ompHost)
|
|
2388
|
+
return tools;
|
|
2389
|
+
const resolved = [];
|
|
2390
|
+
const seen = new Set;
|
|
2391
|
+
for (const tool of tools) {
|
|
2392
|
+
const mapped = OMP_TOOL_ALIASES[tool] ?? tool;
|
|
2393
|
+
if (OMP_ALLOWLISTABLE_TOOLS[mapped] !== true || seen.has(mapped))
|
|
2394
|
+
continue;
|
|
2395
|
+
seen.add(mapped);
|
|
2396
|
+
resolved.push(mapped);
|
|
2397
|
+
}
|
|
2398
|
+
return resolved;
|
|
2399
|
+
}
|
|
2312
2400
|
function inferAccountingSubagent(agent) {
|
|
2313
2401
|
if (agent.includes("sidekick"))
|
|
2314
2402
|
return "sidekick";
|
|
@@ -2882,11 +2970,11 @@ function replaceProviderPrefix(ref, provider) {
|
|
|
2882
2970
|
function resolveProviderModelAttempt(model) {
|
|
2883
2971
|
if (typeof model !== "string" || model.length === 0)
|
|
2884
2972
|
return;
|
|
2885
|
-
const canonicalRef =
|
|
2973
|
+
const canonicalRef = modelRefToCanonicalForHost(model);
|
|
2886
2974
|
const canonicalProvider = providerPrefix(canonicalRef);
|
|
2887
2975
|
if (!canonicalProvider)
|
|
2888
2976
|
return;
|
|
2889
|
-
const translatedRef =
|
|
2977
|
+
const translatedRef = resolveModelRefForHost(canonicalRef);
|
|
2890
2978
|
const translatedProvider = providerPrefix(translatedRef);
|
|
2891
2979
|
const cachedProvider = PI_PROVIDER_FORM_CACHE.get(canonicalProvider);
|
|
2892
2980
|
if (!translatedProvider || translatedProvider === canonicalProvider && cachedProvider === undefined) {
|
|
@@ -2906,14 +2994,14 @@ function isProviderCredentialFailure(result, attempt) {
|
|
|
2906
2994
|
}
|
|
2907
2995
|
var PROMPT_ARGV_MAX_BYTES = 96 * 1024;
|
|
2908
2996
|
function buildArgs(options, opts) {
|
|
2997
|
+
const ompHost = isOmpHostProcess();
|
|
2909
2998
|
const args = [
|
|
2910
2999
|
"--print",
|
|
2911
3000
|
"--mode",
|
|
2912
3001
|
"json",
|
|
2913
3002
|
"--no-session",
|
|
2914
3003
|
"--no-skills",
|
|
2915
|
-
"--no-prompt-templates",
|
|
2916
|
-
"--no-context-files"
|
|
3004
|
+
...ompHost ? ["--no-rules"] : ["--no-prompt-templates", "--no-context-files"]
|
|
2917
3005
|
];
|
|
2918
3006
|
if (opts?.disableDiscoveredExtensions || opts?.subagentExtensions !== undefined) {
|
|
2919
3007
|
args.push("--no-extensions");
|
|
@@ -2936,8 +3024,9 @@ function buildArgs(options, opts) {
|
|
|
2936
3024
|
sessionLog(options.accountingSessionId ?? "pi-subagent", `Pi subagent agent "${options.agent}" has no strict tool allow-list; forcing --no-tools`);
|
|
2937
3025
|
args.push("--no-tools");
|
|
2938
3026
|
} else {
|
|
2939
|
-
|
|
2940
|
-
|
|
3027
|
+
const hostTools = resolveHostToolAllowlist(strictTools, ompHost);
|
|
3028
|
+
if (hostTools.length > 0) {
|
|
3029
|
+
args.push("--tools", hostTools.join(","));
|
|
2941
3030
|
} else {
|
|
2942
3031
|
args.push("--no-tools");
|
|
2943
3032
|
}
|
|
@@ -2946,7 +3035,7 @@ function buildArgs(options, opts) {
|
|
|
2946
3035
|
args.push("--system-prompt", opts.systemPromptPath);
|
|
2947
3036
|
}
|
|
2948
3037
|
if (typeof options.model === "string" && options.model.length > 0) {
|
|
2949
|
-
args.push("--model", opts?.modelRef ??
|
|
3038
|
+
args.push("--model", opts?.modelRef ?? resolveModelRefForHost(options.model));
|
|
2950
3039
|
}
|
|
2951
3040
|
if (options.thinkingLevel) {
|
|
2952
3041
|
args.push("--thinking", options.thinkingLevel);
|
|
@@ -3206,16 +3295,16 @@ function claimExpectedState(db, expected) {
|
|
|
3206
3295
|
WHERE id = ? AND type = 'smart' AND status = 'pending'
|
|
3207
3296
|
AND content = ? AND surface_condition IS ? AND updated_at = ?${statusClause}`).run(...params).changes > 0;
|
|
3208
3297
|
}
|
|
3209
|
-
function getDueCompiledSmartNoteChecks(db, projectPath, now, limit) {
|
|
3210
|
-
return getPendingSmartNotes(db, projectPath).map(toSmartNote).filter((note) => note.checkStatus === "compiled" && note.compiledCheck !== null && note.policyVersion === SMART_NOTE_CHECK_POLICY_VERSION && (note.checkQuarantinedUntil === null || note.checkQuarantinedUntil <= now) && (note.checkNextDueAt === null || note.checkNextDueAt <= now)).sort((a, b) => (a.checkNextDueAt ?? 0) - (b.checkNextDueAt ?? 0) || a.id - b.id).slice(0, Math.max(1, limit));
|
|
3298
|
+
function getDueCompiledSmartNoteChecks(db, projectPath, now, limit, retinaHandoff = false) {
|
|
3299
|
+
return getPendingSmartNotes(db, projectPath).filter((note) => !retinaHandoff || note.compileStatus !== "compiled").map(toSmartNote).filter((note) => note.checkStatus === "compiled" && note.compiledCheck !== null && note.policyVersion === SMART_NOTE_CHECK_POLICY_VERSION && (note.checkQuarantinedUntil === null || note.checkQuarantinedUntil <= now) && (note.checkNextDueAt === null || note.checkNextDueAt <= now)).sort((a, b) => (a.checkNextDueAt ?? 0) - (b.checkNextDueAt ?? 0) || a.id - b.id).slice(0, Math.max(1, limit));
|
|
3211
3300
|
}
|
|
3212
|
-
function getSmartNotesNeedingCompilation(db, projectPath, now, limit) {
|
|
3213
|
-
return getPendingSmartNotes(db, projectPath).map(toSmartNote).filter((note) => (note.checkNextDueAt === null || note.checkNextDueAt <= now) && (note.checkStatus === "uncompiled" || note.checkStatus === "failing" || note.compiledCheck === null || note.policyVersion !== SMART_NOTE_CHECK_POLICY_VERSION)).sort((a, b) => a.createdAt - b.createdAt || a.id - b.id).slice(0, Math.max(1, limit));
|
|
3301
|
+
function getSmartNotesNeedingCompilation(db, projectPath, now, limit, retinaHandoff = false) {
|
|
3302
|
+
return getPendingSmartNotes(db, projectPath).filter((note) => !retinaHandoff || note.compileStatus !== "compiled").map(toSmartNote).filter((note) => (note.checkNextDueAt === null || note.checkNextDueAt <= now) && (note.checkStatus === "uncompiled" || note.checkStatus === "failing" || note.compiledCheck === null || note.policyVersion !== SMART_NOTE_CHECK_POLICY_VERSION)).sort((a, b) => a.createdAt - b.createdAt || a.id - b.id).slice(0, Math.max(1, limit));
|
|
3214
3303
|
}
|
|
3215
|
-
function getStaleCompiledSmartNotes(db, projectPath, now, limit) {
|
|
3304
|
+
function getStaleCompiledSmartNotes(db, projectPath, now, limit, retinaHandoff = false) {
|
|
3216
3305
|
const staleBefore = now - SMART_NOTE_CHECK_MAX_STALENESS_MS;
|
|
3217
3306
|
const livenessBefore = now - SMART_NOTE_CHECK_LIVENESS_RECHECK_MS;
|
|
3218
|
-
return getPendingSmartNotes(db, projectPath).map(toSmartNote).filter((note) => note.checkStatus === "compiled" && note.compiledCheck !== null && note.policyVersion === SMART_NOTE_CHECK_POLICY_VERSION && note.checkFalseSinceAt !== null && note.checkFalseSinceAt <= staleBefore && (note.checkLastLivenessAt === null || note.checkLastLivenessAt <= livenessBefore)).sort((a, b) => (a.checkFalseSinceAt ?? 0) - (b.checkFalseSinceAt ?? 0) || a.id - b.id).slice(0, Math.max(1, limit));
|
|
3307
|
+
return getPendingSmartNotes(db, projectPath).filter((note) => !retinaHandoff || note.compileStatus !== "compiled").map(toSmartNote).filter((note) => note.checkStatus === "compiled" && note.compiledCheck !== null && note.policyVersion === SMART_NOTE_CHECK_POLICY_VERSION && note.checkFalseSinceAt !== null && note.checkFalseSinceAt <= staleBefore && (note.checkLastLivenessAt === null || note.checkLastLivenessAt <= livenessBefore)).sort((a, b) => (a.checkFalseSinceAt ?? 0) - (b.checkFalseSinceAt ?? 0) || a.id - b.id).slice(0, Math.max(1, limit));
|
|
3219
3308
|
}
|
|
3220
3309
|
function storeCompiledSmartNoteCheck(db, args) {
|
|
3221
3310
|
db.prepare(`UPDATE notes
|
|
@@ -3666,7 +3755,7 @@ async function sendIgnoredMessageNow(client, sessionId, text, params, forcePersi
|
|
|
3666
3755
|
queueIgnoredNotification({ client, sessionId, text, params, forcePersist });
|
|
3667
3756
|
return "queued";
|
|
3668
3757
|
}
|
|
3669
|
-
const { waitForSafeNotificationTarget } = await import("./safe-notification-target-
|
|
3758
|
+
const { waitForSafeNotificationTarget } = await import("./safe-notification-target-0s6j4m9f.js");
|
|
3670
3759
|
if (await waitForSafeNotificationTarget(client, sessionId) === "skip") {
|
|
3671
3760
|
sessionLog(sessionId, "notification skipped (session not titled yet)");
|
|
3672
3761
|
return "skipped";
|
|
@@ -7055,7 +7144,7 @@ var MAX_FAILURES_BEFORE_REAUTHOR = 3;
|
|
|
7055
7144
|
async function runDueCompiledSmartNoteChecks(args) {
|
|
7056
7145
|
const startedAt = Date.now();
|
|
7057
7146
|
const now = args.now ?? startedAt;
|
|
7058
|
-
const due = getDueCompiledSmartNoteChecks(args.db, args.projectIdentity, now, args.maxChecks ?? DEFAULT_MAX_CHECKS);
|
|
7147
|
+
const due = getDueCompiledSmartNoteChecks(args.db, args.projectIdentity, now, args.maxChecks ?? DEFAULT_MAX_CHECKS, args.retinaHandoff);
|
|
7059
7148
|
let ran = 0;
|
|
7060
7149
|
let surfaced = 0;
|
|
7061
7150
|
let failed = 0;
|
|
@@ -7185,7 +7274,8 @@ async function evaluateSmartNotes(args) {
|
|
|
7185
7274
|
const projectRoot = args.sessionDirectory ?? args.projectIdentity;
|
|
7186
7275
|
const moduleBridge = getModuleNoteEvaluationBridge(args.projectIdentity);
|
|
7187
7276
|
await moduleBridge?.sync();
|
|
7188
|
-
const
|
|
7277
|
+
const pendingNotes = () => getPendingSmartNotes(args.db, args.projectIdentity).filter((note) => !args.retinaHandoff || note.compileStatus !== "compiled");
|
|
7278
|
+
const pendingAtStart = pendingNotes().length;
|
|
7189
7279
|
if (pendingAtStart === 0) {
|
|
7190
7280
|
log("[dreamer] smart notes: no pending notes");
|
|
7191
7281
|
return { surfaced: 0, pending: 0, ran: false };
|
|
@@ -7209,7 +7299,7 @@ async function evaluateSmartNotes(args) {
|
|
|
7209
7299
|
let didWork = false;
|
|
7210
7300
|
try {
|
|
7211
7301
|
if (moduleBridge) {
|
|
7212
|
-
const candidates2 =
|
|
7302
|
+
const candidates2 = pendingNotes().slice(0, MAX_COMPILE_PER_RUN);
|
|
7213
7303
|
for (const note of candidates2) {
|
|
7214
7304
|
if (Date.now() >= args.deadline)
|
|
7215
7305
|
break;
|
|
@@ -7230,7 +7320,7 @@ async function evaluateSmartNotes(args) {
|
|
|
7230
7320
|
surfaced += 1;
|
|
7231
7321
|
}
|
|
7232
7322
|
await moduleBridge.sync();
|
|
7233
|
-
const pending2 =
|
|
7323
|
+
const pending2 = pendingNotes().length;
|
|
7234
7324
|
return { surfaced, pending: pending2, ran: didWork };
|
|
7235
7325
|
}
|
|
7236
7326
|
const dueRun = await runDueCompiledSmartNoteChecks({
|
|
@@ -7240,11 +7330,12 @@ async function evaluateSmartNotes(args) {
|
|
|
7240
7330
|
maxChecks: 10,
|
|
7241
7331
|
sweepBudgetMs: 1e4,
|
|
7242
7332
|
leaseHeld,
|
|
7243
|
-
signal: leaseAbortController.signal
|
|
7333
|
+
signal: leaseAbortController.signal,
|
|
7334
|
+
retinaHandoff: args.retinaHandoff
|
|
7244
7335
|
});
|
|
7245
7336
|
surfaced += dueRun.surfaced;
|
|
7246
7337
|
didWork ||= dueRun.ran > 0;
|
|
7247
|
-
const candidates = getSmartNotesNeedingCompilation(args.db, args.projectIdentity, Date.now(), MAX_COMPILE_PER_RUN);
|
|
7338
|
+
const candidates = getSmartNotesNeedingCompilation(args.db, args.projectIdentity, Date.now(), MAX_COMPILE_PER_RUN, args.retinaHandoff);
|
|
7248
7339
|
for (const note of candidates) {
|
|
7249
7340
|
if (Date.now() >= args.deadline)
|
|
7250
7341
|
break;
|
|
@@ -7254,7 +7345,7 @@ async function evaluateSmartNotes(args) {
|
|
|
7254
7345
|
if (compiled)
|
|
7255
7346
|
surfaced += 1;
|
|
7256
7347
|
}
|
|
7257
|
-
const stale = getStaleCompiledSmartNotes(args.db, args.projectIdentity, Date.now(), MAX_FALLBACK_PER_RUN);
|
|
7348
|
+
const stale = getStaleCompiledSmartNotes(args.db, args.projectIdentity, Date.now(), MAX_FALLBACK_PER_RUN, args.retinaHandoff);
|
|
7258
7349
|
for (const note of stale) {
|
|
7259
7350
|
if (Date.now() >= args.deadline)
|
|
7260
7351
|
break;
|
|
@@ -7264,7 +7355,7 @@ async function evaluateSmartNotes(args) {
|
|
|
7264
7355
|
if (met)
|
|
7265
7356
|
surfaced += 1;
|
|
7266
7357
|
}
|
|
7267
|
-
const fallbackNotes =
|
|
7358
|
+
const fallbackNotes = pendingNotes().filter((note) => note.checkStatus === "fallback").slice(0, MAX_FALLBACK_PER_RUN);
|
|
7268
7359
|
for (const note of fallbackNotes) {
|
|
7269
7360
|
if (Date.now() >= args.deadline)
|
|
7270
7361
|
break;
|
|
@@ -7515,7 +7606,7 @@ Output exactly JSON: {"met": false}`;
|
|
|
7515
7606
|
}
|
|
7516
7607
|
|
|
7517
7608
|
// ../plugin/src/features/magic-context/dreamer/maintain-docs-protected-enforcement.ts
|
|
7518
|
-
import { existsSync as existsSync5, readFileSync as
|
|
7609
|
+
import { existsSync as existsSync5, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
7519
7610
|
import { join as join3 } from "node:path";
|
|
7520
7611
|
|
|
7521
7612
|
// ../plugin/src/features/magic-context/dreamer/protected-regions.ts
|
|
@@ -7620,7 +7711,7 @@ function snapshotMaintainDocsFiles(docsDir) {
|
|
|
7620
7711
|
const path4 = join3(docsDir, name);
|
|
7621
7712
|
try {
|
|
7622
7713
|
if (existsSync5(path4)) {
|
|
7623
|
-
snapshot.set(name,
|
|
7714
|
+
snapshot.set(name, readFileSync3(path4, "utf8"));
|
|
7624
7715
|
}
|
|
7625
7716
|
} catch {}
|
|
7626
7717
|
}
|
|
@@ -7630,7 +7721,7 @@ function enforceMaintainDocsProtectedRegions(args) {
|
|
|
7630
7721
|
for (const [fileName, original] of args.snapshot) {
|
|
7631
7722
|
const path4 = join3(args.docsDir, fileName);
|
|
7632
7723
|
try {
|
|
7633
|
-
const current =
|
|
7724
|
+
const current = readFileSync3(path4, "utf8");
|
|
7634
7725
|
const { text, violated } = enforceProtectedRegions(original, current);
|
|
7635
7726
|
if (!violated) {
|
|
7636
7727
|
continue;
|
|
@@ -9915,7 +10006,8 @@ function createDreamTaskExecutor(deps) {
|
|
|
9915
10006
|
leaseKey,
|
|
9916
10007
|
deadline,
|
|
9917
10008
|
model: config.model,
|
|
9918
|
-
fallbackModels: config.fallbackModels
|
|
10009
|
+
fallbackModels: config.fallbackModels,
|
|
10010
|
+
retinaHandoff: deps.retinaHandoff
|
|
9919
10011
|
});
|
|
9920
10012
|
recordRun("completed", null, {
|
|
9921
10013
|
smartNotesSurfaced: result.surfaced,
|
|
@@ -10873,6 +10965,7 @@ async function sweepProject(reg, origin, db, gitCommitEnabled) {
|
|
|
10873
10965
|
dreamerModel: dreamerConfig.model,
|
|
10874
10966
|
mural: reg.mural,
|
|
10875
10967
|
memoryInjectionBudgetTokens: reg.memoryInjectionBudgetTokens,
|
|
10968
|
+
retinaHandoff: reg.retinaHandoff,
|
|
10876
10969
|
transformMode: reg.transformMode,
|
|
10877
10970
|
moduleClient: reg.moduleClient,
|
|
10878
10971
|
onProgress: (progress, completedTask) => reg.onDreamerProgress?.(progress, completedTask)
|
|
@@ -10916,7 +11009,8 @@ async function runCompiledSmartNoteSweep(reg, db) {
|
|
|
10916
11009
|
const result = await runDueCompiledSmartNoteChecks({
|
|
10917
11010
|
db,
|
|
10918
11011
|
projectIdentity: reg.projectIdentity,
|
|
10919
|
-
projectRoot: reg.directory
|
|
11012
|
+
projectRoot: reg.directory,
|
|
11013
|
+
retinaHandoff: reg.retinaHandoff
|
|
10920
11014
|
});
|
|
10921
11015
|
if (result.ran > 0) {
|
|
10922
11016
|
log(`[dreamer] compiled smart-note sweep ${reg.projectIdentity}: ran=${result.ran} surfaced=${result.surfaced} logic_failed=${result.failed} network_failed=${result.networkFailed}`);
|
|
@@ -10991,7 +11085,7 @@ async function sweepGitCommits(args) {
|
|
|
10991
11085
|
}
|
|
10992
11086
|
|
|
10993
11087
|
// src/dreamer/pi-session-api.ts
|
|
10994
|
-
import { readFileSync as
|
|
11088
|
+
import { readFileSync as readFileSync4 } from "node:fs";
|
|
10995
11089
|
import { createRequire as createRequire2 } from "node:module";
|
|
10996
11090
|
import { pathToFileURL } from "node:url";
|
|
10997
11091
|
var PI_CODING_AGENT_MODULE = "@earendil-works/pi-coding-agent";
|
|
@@ -11047,7 +11141,7 @@ async function loadDefaultPiSessionApi(loaders) {
|
|
|
11047
11141
|
throw new Error("Pi session APIs unavailable: expected SessionManager.listAll on pi-coding-agent");
|
|
11048
11142
|
}
|
|
11049
11143
|
const loadEntriesFromFile = mod.loadEntriesFromFile ?? ((filePath) => {
|
|
11050
|
-
const content =
|
|
11144
|
+
const content = readFileSync4(filePath, "utf8");
|
|
11051
11145
|
return mod.parseSessionEntries?.(content) ?? [];
|
|
11052
11146
|
});
|
|
11053
11147
|
return {
|
|
@@ -11237,6 +11331,7 @@ function registerPiDreamerProject(opts) {
|
|
|
11237
11331
|
dreamerConfig: opts.config,
|
|
11238
11332
|
language: opts.language,
|
|
11239
11333
|
gitCommitIndexing: opts.gitCommitIndexing,
|
|
11334
|
+
retinaHandoff: opts.retinaHandoff,
|
|
11240
11335
|
ensureRegistered: ensureProjectRegisteredFromPiDirectory,
|
|
11241
11336
|
retrospectiveRawProvider: () => new PiRetrospectiveRawProvider({ projectCwd: opts.projectDir }),
|
|
11242
11337
|
primerRawProviderFactory: createPiPrimerRawProviderFactory()
|
|
@@ -11261,7 +11356,8 @@ function registerPiDreamerProject(opts) {
|
|
|
11261
11356
|
primerRawProviderFactory: createPiPrimerRawProviderFactory(),
|
|
11262
11357
|
userMemoryCollectionEnabled: userMemoryCollectionEnabled(opts.config),
|
|
11263
11358
|
ensureProjectRegistered: ensureProjectRegisteredFromPiDirectory,
|
|
11264
|
-
language: opts.language
|
|
11359
|
+
language: opts.language,
|
|
11360
|
+
retinaHandoff: opts.retinaHandoff
|
|
11265
11361
|
}),
|
|
11266
11362
|
task
|
|
11267
11363
|
});
|
|
@@ -26907,6 +27003,14 @@ var MIGRATION_SYSTEM_PROMPT = "You re-organize a software project's long-term me
|
|
|
26907
27003
|
var LKG_TOTAL_BYTES = 64 * 1024 * 1024;
|
|
26908
27004
|
var LKG_SINGLE_SLOT_BYTES = 24 * 1024 * 1024;
|
|
26909
27005
|
var slots = new Map;
|
|
27006
|
+
var LKG_SNAPSHOT_ARRAY = Symbol("array");
|
|
27007
|
+
var LKG_SNAPSHOT_OBJECT = Symbol("object");
|
|
27008
|
+
var LKG_SNAPSHOT_KEY = Symbol("key");
|
|
27009
|
+
var LKG_SNAPSHOT_STRING = Symbol("string");
|
|
27010
|
+
var LKG_SNAPSHOT_NUMBER = Symbol("number");
|
|
27011
|
+
var LKG_SNAPSHOT_BOOLEAN = Symbol("boolean");
|
|
27012
|
+
var LKG_SNAPSHOT_NULL = Symbol("null");
|
|
27013
|
+
var LKG_SNAPSHOT_UNDEFINED = Symbol("undefined");
|
|
26910
27014
|
|
|
26911
27015
|
// ../plugin/src/hooks/magic-context/recomp-orchestrator.ts
|
|
26912
27016
|
function isRecompFailure(message) {
|
|
@@ -27452,15 +27556,17 @@ ${c.content}
|
|
|
27452
27556
|
// package.json
|
|
27453
27557
|
var package_default = {
|
|
27454
27558
|
name: "@cortexkit/pi-magic-context",
|
|
27455
|
-
version: "0.
|
|
27559
|
+
version: "0.36.0",
|
|
27456
27560
|
type: "module",
|
|
27457
|
-
description: "Pi coding agent extension for Magic Context — cross-session memory and context management",
|
|
27561
|
+
description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
|
|
27458
27562
|
main: "dist/index.js",
|
|
27459
27563
|
license: "MIT",
|
|
27460
27564
|
author: "ualtinok",
|
|
27461
27565
|
keywords: [
|
|
27462
27566
|
"pi",
|
|
27463
27567
|
"pi-coding-agent",
|
|
27568
|
+
"omp",
|
|
27569
|
+
"oh-my-pi",
|
|
27464
27570
|
"extension",
|
|
27465
27571
|
"context",
|
|
27466
27572
|
"memory",
|
|
@@ -27478,8 +27584,9 @@ var package_default = {
|
|
|
27478
27584
|
"README.md"
|
|
27479
27585
|
],
|
|
27480
27586
|
scripts: {
|
|
27481
|
-
build: "rm -f dist/index.js dist/subagent-entry.js dist/*-*.js && bun build src/index.ts src/subagent-entry.ts --outdir dist --target node --format esm --splitting --external @earendil-works/pi-coding-agent --external @earendil-works/pi-tui --external @huggingface/transformers --external node:sqlite",
|
|
27482
|
-
|
|
27587
|
+
build: "tsc -p ../retina-local-fs/tsconfig.build.json && rm -f dist/index.js dist/subagent-entry.js dist/*-*.js && bun build src/index.ts src/subagent-entry.ts --outdir dist --target node --format esm --splitting --external @earendil-works/pi-coding-agent --external @earendil-works/pi-tui --external @huggingface/transformers --external node:sqlite",
|
|
27588
|
+
"build:e2e-argv": "bun build src/subagent-runner.ts --outfile ../../tests/docker/.generated/subagent-runner-e2e.mjs --target node --format esm --external node:sqlite",
|
|
27589
|
+
typecheck: "tsc -p ../retina-local-fs/tsconfig.build.json && tsc --noEmit",
|
|
27483
27590
|
test: "bun test",
|
|
27484
27591
|
lint: "biome check src",
|
|
27485
27592
|
"lint:fix": "biome check --write src",
|
|
@@ -27510,6 +27617,14 @@ var package_default = {
|
|
|
27510
27617
|
"@earendil-works/pi-coding-agent": "^0.80.2",
|
|
27511
27618
|
"@earendil-works/pi-tui": "^0.80.2"
|
|
27512
27619
|
},
|
|
27620
|
+
peerDependenciesMeta: {
|
|
27621
|
+
"@earendil-works/pi-coding-agent": {
|
|
27622
|
+
optional: true
|
|
27623
|
+
},
|
|
27624
|
+
"@earendil-works/pi-tui": {
|
|
27625
|
+
optional: true
|
|
27626
|
+
}
|
|
27627
|
+
},
|
|
27513
27628
|
exports: {
|
|
27514
27629
|
".": {
|
|
27515
27630
|
import: "./dist/index.js"
|
|
@@ -27519,6 +27634,11 @@ var package_default = {
|
|
|
27519
27634
|
extensions: [
|
|
27520
27635
|
"./dist/index.js"
|
|
27521
27636
|
]
|
|
27637
|
+
},
|
|
27638
|
+
omp: {
|
|
27639
|
+
extensions: [
|
|
27640
|
+
"./dist/index.js"
|
|
27641
|
+
]
|
|
27522
27642
|
}
|
|
27523
27643
|
};
|
|
27524
27644
|
|
|
@@ -29268,6 +29388,7 @@ async function startPiMagicContextRuntime(pi, database, dbPath) {
|
|
|
29268
29388
|
config: dreamerConfig,
|
|
29269
29389
|
embeddingConfig: bootProjectDeps.config.embedding,
|
|
29270
29390
|
memoryEnabled: bootProjectDeps.config.memory.enabled,
|
|
29391
|
+
retinaHandoff: bootProjectDeps.config.smart_notes.retina_handoff,
|
|
29271
29392
|
language: bootProjectDeps.config.language,
|
|
29272
29393
|
gitCommitIndexing: bootProjectDeps.config.memory.git_commit_indexing,
|
|
29273
29394
|
onAdjunctsRefreshNeeded: signalPiSystemPromptRefreshForProject
|
|
@@ -29312,6 +29433,7 @@ async function startPiMagicContextRuntime(pi, database, dbPath) {
|
|
|
29312
29433
|
config: effectiveDreamerConfig,
|
|
29313
29434
|
embeddingConfig: effectiveConfig.embedding,
|
|
29314
29435
|
memoryEnabled: effectiveConfig.memory.enabled,
|
|
29436
|
+
retinaHandoff: effectiveConfig.smart_notes.retina_handoff,
|
|
29315
29437
|
language: effectiveConfig.language,
|
|
29316
29438
|
gitCommitIndexing: effectiveConfig.memory.git_commit_indexing,
|
|
29317
29439
|
onAdjunctsRefreshNeeded: signalPiSystemPromptRefreshForProject
|
package/dist/subagent-entry.js
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
registerMagicContextTools,
|
|
6
6
|
resolveProjectIdentityForSession,
|
|
7
7
|
setStoragePrivatePermissionEnforcement
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-9t7jhq83.js";
|
|
9
9
|
import {
|
|
10
10
|
log,
|
|
11
11
|
setHarness
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-npnqc564.js";
|
|
13
13
|
import"./index-wckvcay0.js";
|
|
14
14
|
|
|
15
15
|
// src/subagent-entry.ts
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/pi-magic-context",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"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",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "ualtinok",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"pi",
|
|
11
11
|
"pi-coding-agent",
|
|
12
|
+
"omp",
|
|
13
|
+
"oh-my-pi",
|
|
12
14
|
"extension",
|
|
13
15
|
"context",
|
|
14
16
|
"memory",
|
|
@@ -26,8 +28,9 @@
|
|
|
26
28
|
"README.md"
|
|
27
29
|
],
|
|
28
30
|
"scripts": {
|
|
29
|
-
"build": "rm -f dist/index.js dist/subagent-entry.js dist/*-*.js && bun build src/index.ts src/subagent-entry.ts --outdir dist --target node --format esm --splitting --external @earendil-works/pi-coding-agent --external @earendil-works/pi-tui --external @huggingface/transformers --external node:sqlite",
|
|
30
|
-
"
|
|
31
|
+
"build": "tsc -p ../retina-local-fs/tsconfig.build.json && rm -f dist/index.js dist/subagent-entry.js dist/*-*.js && bun build src/index.ts src/subagent-entry.ts --outdir dist --target node --format esm --splitting --external @earendil-works/pi-coding-agent --external @earendil-works/pi-tui --external @huggingface/transformers --external node:sqlite",
|
|
32
|
+
"build:e2e-argv": "bun build src/subagent-runner.ts --outfile ../../tests/docker/.generated/subagent-runner-e2e.mjs --target node --format esm --external node:sqlite",
|
|
33
|
+
"typecheck": "tsc -p ../retina-local-fs/tsconfig.build.json && tsc --noEmit",
|
|
31
34
|
"test": "bun test",
|
|
32
35
|
"lint": "biome check src",
|
|
33
36
|
"lint:fix": "biome check --write src",
|
|
@@ -58,6 +61,14 @@
|
|
|
58
61
|
"@earendil-works/pi-coding-agent": "^0.80.2",
|
|
59
62
|
"@earendil-works/pi-tui": "^0.80.2"
|
|
60
63
|
},
|
|
64
|
+
"peerDependenciesMeta": {
|
|
65
|
+
"@earendil-works/pi-coding-agent": {
|
|
66
|
+
"optional": true
|
|
67
|
+
},
|
|
68
|
+
"@earendil-works/pi-tui": {
|
|
69
|
+
"optional": true
|
|
70
|
+
}
|
|
71
|
+
},
|
|
61
72
|
"exports": {
|
|
62
73
|
".": {
|
|
63
74
|
"import": "./dist/index.js"
|
|
@@ -67,5 +78,10 @@
|
|
|
67
78
|
"extensions": [
|
|
68
79
|
"./dist/index.js"
|
|
69
80
|
]
|
|
81
|
+
},
|
|
82
|
+
"omp": {
|
|
83
|
+
"extensions": [
|
|
84
|
+
"./dist/index.js"
|
|
85
|
+
]
|
|
70
86
|
}
|
|
71
87
|
}
|