@cortexkit/pi-magic-context 0.27.1 → 0.27.3
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/dist/index.js +48 -27
- package/dist/subagent-entry.js +13 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15136,7 +15136,18 @@ function legacySourcesForBase(basePath, label) {
|
|
|
15136
15136
|
{ path: `${basePath}.json`, label: `${label} magic-context.json` }
|
|
15137
15137
|
];
|
|
15138
15138
|
}
|
|
15139
|
+
function userScopeConfigPaths() {
|
|
15140
|
+
return new Set([
|
|
15141
|
+
`${cortexKitUserConfigBasePath()}.jsonc`,
|
|
15142
|
+
`${cortexKitUserConfigBasePath()}.json`,
|
|
15143
|
+
join(configHome(), "opencode", `${CONFIG_FILE_BASENAME}.jsonc`),
|
|
15144
|
+
join(configHome(), "opencode", `${CONFIG_FILE_BASENAME}.json`),
|
|
15145
|
+
join(homeDir(), ".pi", "agent", `${CONFIG_FILE_BASENAME}.jsonc`),
|
|
15146
|
+
join(homeDir(), ".pi", "agent", `${CONFIG_FILE_BASENAME}.json`)
|
|
15147
|
+
]);
|
|
15148
|
+
}
|
|
15139
15149
|
function resolveLegacyConfigSources(directory) {
|
|
15150
|
+
const userPaths = userScopeConfigPaths();
|
|
15140
15151
|
return {
|
|
15141
15152
|
user: [
|
|
15142
15153
|
...legacySourcesForBase(join(configHome(), "opencode", CONFIG_FILE_BASENAME), "OpenCode user"),
|
|
@@ -15146,7 +15157,7 @@ function resolveLegacyConfigSources(directory) {
|
|
|
15146
15157
|
...legacySourcesForBase(join(directory, CONFIG_FILE_BASENAME), "project root"),
|
|
15147
15158
|
...legacySourcesForBase(join(directory, ".opencode", CONFIG_FILE_BASENAME), "OpenCode project"),
|
|
15148
15159
|
...legacySourcesForBase(join(directory, ".pi", CONFIG_FILE_BASENAME), "Pi project")
|
|
15149
|
-
]
|
|
15160
|
+
].filter((source) => !userPaths.has(source.path))
|
|
15150
15161
|
};
|
|
15151
15162
|
}
|
|
15152
15163
|
function resolveLegacyConfigSourcesForHarness(directory, harness) {
|
|
@@ -150523,7 +150534,7 @@ function enforceSchemaFence(db, dbPath, latestSupportedVersion) {
|
|
|
150523
150534
|
return true;
|
|
150524
150535
|
}
|
|
150525
150536
|
lastSchemaFenceRejection = { persistedVersion, supportedVersion: latestSupportedVersion };
|
|
150526
|
-
log(`[magic-context] storage fatal: refusing to open ${dbPath}; database schema v${persistedVersion} is newer than this binary supports (max v${latestSupportedVersion}).
|
|
150537
|
+
log(`[magic-context] storage fatal: refusing to open ${dbPath}; database schema v${persistedVersion} is newer than this binary supports (max v${latestSupportedVersion}). A pinned or stale plugin is likely sharing this database with a newer instance; update or unpin Magic Context with 'npx @cortexkit/magic-context@latest doctor --force', then restart.`);
|
|
150527
150538
|
return false;
|
|
150528
150539
|
}
|
|
150529
150540
|
var sqlitePragmaConfig = {
|
|
@@ -156419,7 +156430,7 @@ init_logger();
|
|
|
156419
156430
|
import * as childProcess from "node:child_process";
|
|
156420
156431
|
import { existsSync as existsSync7 } from "node:fs";
|
|
156421
156432
|
import { createRequire as createRequire2 } from "node:module";
|
|
156422
|
-
import { dirname as dirname4, join as join8, resolve as resolvePath } from "node:path";
|
|
156433
|
+
import { basename as basename2, dirname as dirname4, join as join8, resolve as resolvePath } from "node:path";
|
|
156423
156434
|
import { createInterface } from "node:readline";
|
|
156424
156435
|
import { fileURLToPath } from "node:url";
|
|
156425
156436
|
|
|
@@ -156528,6 +156539,24 @@ function resolveBundledPiCli() {
|
|
|
156528
156539
|
return null;
|
|
156529
156540
|
}
|
|
156530
156541
|
}
|
|
156542
|
+
function resolvePiInvocation() {
|
|
156543
|
+
const execPath = process.execPath;
|
|
156544
|
+
const currentScript = process.argv[1];
|
|
156545
|
+
const isBunVirtualScript = currentScript?.startsWith("/$bunfs/root/") ?? false;
|
|
156546
|
+
if (currentScript && !isBunVirtualScript && existsSync7(currentScript)) {
|
|
156547
|
+
return { command: execPath, prefixArgs: [currentScript] };
|
|
156548
|
+
}
|
|
156549
|
+
const execName = basename2(execPath).toLowerCase();
|
|
156550
|
+
const isGenericRuntime = /^(node|bun)(\.exe)?$/.test(execName);
|
|
156551
|
+
if (!isGenericRuntime) {
|
|
156552
|
+
return { command: execPath, prefixArgs: [] };
|
|
156553
|
+
}
|
|
156554
|
+
const bundled = resolveBundledPiCli();
|
|
156555
|
+
if (bundled) {
|
|
156556
|
+
return { command: execPath, prefixArgs: [bundled] };
|
|
156557
|
+
}
|
|
156558
|
+
return { command: "pi", prefixArgs: [] };
|
|
156559
|
+
}
|
|
156531
156560
|
function resolveSubagentEntryPath() {
|
|
156532
156561
|
try {
|
|
156533
156562
|
const here = dirname4(fileURLToPath(import.meta.url));
|
|
@@ -156577,19 +156606,10 @@ function inferAccountingSubagent(agent) {
|
|
|
156577
156606
|
|
|
156578
156607
|
class PiSubagentRunner {
|
|
156579
156608
|
harness = "pi";
|
|
156580
|
-
|
|
156609
|
+
invocation;
|
|
156581
156610
|
spawnImpl;
|
|
156582
156611
|
constructor(options = {}) {
|
|
156583
|
-
|
|
156584
|
-
this.piBinary = options.piBinary;
|
|
156585
|
-
} else {
|
|
156586
|
-
const bundled = resolveBundledPiCli();
|
|
156587
|
-
if (bundled) {
|
|
156588
|
-
this.piBinary = bundled;
|
|
156589
|
-
} else {
|
|
156590
|
-
this.piBinary = "pi";
|
|
156591
|
-
}
|
|
156592
|
-
}
|
|
156612
|
+
this.invocation = options.piBinary ? { command: options.piBinary, prefixArgs: [] } : resolvePiInvocation();
|
|
156593
156613
|
this.spawnImpl = options.spawnImpl ?? childProcess.spawn;
|
|
156594
156614
|
}
|
|
156595
156615
|
async run(options) {
|
|
@@ -156677,7 +156697,7 @@ class PiSubagentRunner {
|
|
|
156677
156697
|
};
|
|
156678
156698
|
let child;
|
|
156679
156699
|
try {
|
|
156680
|
-
child = this.spawnImpl(this.
|
|
156700
|
+
child = this.spawnImpl(this.invocation.command, [...this.invocation.prefixArgs, ...args], {
|
|
156681
156701
|
cwd: options.cwd,
|
|
156682
156702
|
env: process.env,
|
|
156683
156703
|
stdio: [deliverViaStdin ? "pipe" : "ignore", "pipe", "pipe"]
|
|
@@ -177523,21 +177543,21 @@ function isSecretDeniedPath(repoRelativePath) {
|
|
|
177523
177543
|
const segments = normalized.split("/");
|
|
177524
177544
|
if (segments.includes(".git") || segments.includes("secrets"))
|
|
177525
177545
|
return true;
|
|
177526
|
-
const
|
|
177527
|
-
if (
|
|
177546
|
+
const basename3 = segments.at(-1) ?? "";
|
|
177547
|
+
if (basename3 === ".npmrc" || basename3.startsWith(".env"))
|
|
177528
177548
|
return true;
|
|
177529
|
-
if (
|
|
177549
|
+
if (basename3 === ".pgpass" || basename3 === ".netrc")
|
|
177530
177550
|
return true;
|
|
177531
|
-
if (SECRET_KEY_EXTENSIONS.some((extension) =>
|
|
177551
|
+
if (SECRET_KEY_EXTENSIONS.some((extension) => basename3.endsWith(extension)))
|
|
177532
177552
|
return true;
|
|
177533
|
-
if (
|
|
177553
|
+
if (basename3 === "id_rsa" || basename3 === "id_dsa" || basename3 === "id_ecdsa" || basename3 === "id_ed25519" || basename3.startsWith("id_")) {
|
|
177534
177554
|
return true;
|
|
177535
177555
|
}
|
|
177536
|
-
if (segments.includes(".aws") &&
|
|
177556
|
+
if (segments.includes(".aws") && basename3 === "credentials")
|
|
177537
177557
|
return true;
|
|
177538
|
-
if (
|
|
177539
|
-
const serviceAccountJson =
|
|
177540
|
-
const gcloudCredentialJson = segments.includes("gcloud") && (
|
|
177558
|
+
if (basename3.endsWith(".json")) {
|
|
177559
|
+
const serviceAccountJson = basename3.includes("service-account") || basename3.includes("service_account");
|
|
177560
|
+
const gcloudCredentialJson = segments.includes("gcloud") && (basename3 === "application_default_credentials.json" || basename3.includes("credential") || segments.includes("legacy_credentials"));
|
|
177541
177561
|
if (serviceAccountJson || gcloudCredentialJson)
|
|
177542
177562
|
return true;
|
|
177543
177563
|
}
|
|
@@ -184317,6 +184337,7 @@ var pendingPiDecisionBySession = new Map;
|
|
|
184317
184337
|
var lastBoundMessageIdBySession = new Map;
|
|
184318
184338
|
var scheduledWriteTokensBySession = new Map;
|
|
184319
184339
|
var writerOverrideForTests = null;
|
|
184340
|
+
var retentionOverrideForTests = null;
|
|
184320
184341
|
function normalizeMaterializeReason(harness, reason, rematerialized) {
|
|
184321
184342
|
const raw = typeof reason === "string" ? reason.trim() : "";
|
|
184322
184343
|
if (raw.length > 0) {
|
|
@@ -184457,7 +184478,7 @@ function writeTransformDecisionRow(dbPath, row) {
|
|
|
184457
184478
|
WHERE session_id = ? AND harness = ?
|
|
184458
184479
|
ORDER BY ts_ms DESC, rowid DESC
|
|
184459
184480
|
LIMIT ?
|
|
184460
|
-
)`).run(row.sessionId, row.harness, row.sessionId, row.harness, TRANSFORM_DECISIONS_RETENTION);
|
|
184481
|
+
)`).run(row.sessionId, row.harness, row.sessionId, row.harness, retentionOverrideForTests ?? TRANSFORM_DECISIONS_RETENTION);
|
|
184461
184482
|
} finally {
|
|
184462
184483
|
closeQuietly(db);
|
|
184463
184484
|
}
|
|
@@ -199300,7 +199321,7 @@ function formatThresholdPercent(value) {
|
|
|
199300
199321
|
// package.json
|
|
199301
199322
|
var package_default = {
|
|
199302
199323
|
name: "@cortexkit/pi-magic-context",
|
|
199303
|
-
version: "0.27.
|
|
199324
|
+
version: "0.27.3",
|
|
199304
199325
|
type: "module",
|
|
199305
199326
|
description: "Pi coding agent extension for Magic Context — cross-session memory and context management",
|
|
199306
199327
|
main: "dist/index.js",
|
|
@@ -205511,7 +205532,7 @@ async function src_default2(pi) {
|
|
|
205511
205532
|
return;
|
|
205512
205533
|
}
|
|
205513
205534
|
if (!db) {
|
|
205514
|
-
warn(`Magic Context (pi) storage unavailable at ${dbPath} (cache schema is newer than this binary supports). ` + "Plugin will not register hooks;
|
|
205535
|
+
warn(`Magic Context (pi) storage unavailable at ${dbPath} (cache schema is newer than this binary supports). ` + "A pinned or stale plugin is likely sharing this database with a newer instance. " + "Plugin will not register hooks; run 'npx @cortexkit/magic-context@latest doctor --force' " + "(or update Pi/OpenCode) and restart to recover.");
|
|
205515
205536
|
return;
|
|
205516
205537
|
}
|
|
205517
205538
|
const database = db;
|
package/dist/subagent-entry.js
CHANGED
|
@@ -142942,7 +142942,7 @@ function enforceSchemaFence(db, dbPath, latestSupportedVersion) {
|
|
|
142942
142942
|
return true;
|
|
142943
142943
|
}
|
|
142944
142944
|
lastSchemaFenceRejection = { persistedVersion, supportedVersion: latestSupportedVersion };
|
|
142945
|
-
log(`[magic-context] storage fatal: refusing to open ${dbPath}; database schema v${persistedVersion} is newer than this binary supports (max v${latestSupportedVersion}).
|
|
142945
|
+
log(`[magic-context] storage fatal: refusing to open ${dbPath}; database schema v${persistedVersion} is newer than this binary supports (max v${latestSupportedVersion}). A pinned or stale plugin is likely sharing this database with a newer instance; update or unpin Magic Context with 'npx @cortexkit/magic-context@latest doctor --force', then restart.`);
|
|
142946
142946
|
return false;
|
|
142947
142947
|
}
|
|
142948
142948
|
var sqlitePragmaConfig = {
|
|
@@ -144113,7 +144113,18 @@ function legacySourcesForBase(basePath, label) {
|
|
|
144113
144113
|
{ path: `${basePath}.json`, label: `${label} magic-context.json` }
|
|
144114
144114
|
];
|
|
144115
144115
|
}
|
|
144116
|
+
function userScopeConfigPaths() {
|
|
144117
|
+
return new Set([
|
|
144118
|
+
`${cortexKitUserConfigBasePath()}.jsonc`,
|
|
144119
|
+
`${cortexKitUserConfigBasePath()}.json`,
|
|
144120
|
+
join4(configHome(), "opencode", `${CONFIG_FILE_BASENAME}.jsonc`),
|
|
144121
|
+
join4(configHome(), "opencode", `${CONFIG_FILE_BASENAME}.json`),
|
|
144122
|
+
join4(homeDir(), ".pi", "agent", `${CONFIG_FILE_BASENAME}.jsonc`),
|
|
144123
|
+
join4(homeDir(), ".pi", "agent", `${CONFIG_FILE_BASENAME}.json`)
|
|
144124
|
+
]);
|
|
144125
|
+
}
|
|
144116
144126
|
function resolveLegacyConfigSources(directory) {
|
|
144127
|
+
const userPaths = userScopeConfigPaths();
|
|
144117
144128
|
return {
|
|
144118
144129
|
user: [
|
|
144119
144130
|
...legacySourcesForBase(join4(configHome(), "opencode", CONFIG_FILE_BASENAME), "OpenCode user"),
|
|
@@ -144123,7 +144134,7 @@ function resolveLegacyConfigSources(directory) {
|
|
|
144123
144134
|
...legacySourcesForBase(join4(directory, CONFIG_FILE_BASENAME), "project root"),
|
|
144124
144135
|
...legacySourcesForBase(join4(directory, ".opencode", CONFIG_FILE_BASENAME), "OpenCode project"),
|
|
144125
144136
|
...legacySourcesForBase(join4(directory, ".pi", CONFIG_FILE_BASENAME), "Pi project")
|
|
144126
|
-
]
|
|
144137
|
+
].filter((source) => !userPaths.has(source.path))
|
|
144127
144138
|
};
|
|
144128
144139
|
}
|
|
144129
144140
|
function resolveLegacyConfigSourcesForHarness(directory, harness) {
|
package/package.json
CHANGED