@cortexkit/magic-context 0.34.0 → 0.34.1
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 +165 -62
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -11863,9 +11863,10 @@ function migrateLegacyExperimental(rawConfig, warnings) {
|
|
|
11863
11863
|
const exp = experimental;
|
|
11864
11864
|
const hasUM = "user_memories" in exp;
|
|
11865
11865
|
const hasPKF = "pin_key_files" in exp;
|
|
11866
|
+
const hasMural = "mural" in exp;
|
|
11866
11867
|
const TOP_LEVEL_GRADUATED = ["temporal_awareness", "caveman_text_compression"];
|
|
11867
11868
|
const MEMORY_GRADUATED = ["auto_search", "git_commit_indexing"];
|
|
11868
|
-
const hasGraduated = TOP_LEVEL_GRADUATED.some((k) => (k in exp)) || MEMORY_GRADUATED.some((k) => (k in exp));
|
|
11869
|
+
const hasGraduated = TOP_LEVEL_GRADUATED.some((k) => (k in exp)) || MEMORY_GRADUATED.some((k) => (k in exp)) || hasMural;
|
|
11869
11870
|
if (!hasUM && !hasPKF && !hasGraduated) {
|
|
11870
11871
|
return rawConfig;
|
|
11871
11872
|
}
|
|
@@ -11873,6 +11874,15 @@ function migrateLegacyExperimental(rawConfig, warnings) {
|
|
|
11873
11874
|
const dreamer = typeof patched.dreamer === "object" && patched.dreamer !== null ? { ...patched.dreamer } : {};
|
|
11874
11875
|
const memory = typeof patched.memory === "object" && patched.memory !== null ? { ...patched.memory } : {};
|
|
11875
11876
|
const newExperimental = { ...exp };
|
|
11877
|
+
const coerceToObject = (value) => {
|
|
11878
|
+
if (typeof value === "boolean") {
|
|
11879
|
+
return { enabled: value };
|
|
11880
|
+
}
|
|
11881
|
+
if (typeof value === "object" && value !== null) {
|
|
11882
|
+
return { ...value };
|
|
11883
|
+
}
|
|
11884
|
+
return;
|
|
11885
|
+
};
|
|
11876
11886
|
const relocate = (key, dest, destLabel) => {
|
|
11877
11887
|
if (!(key in exp))
|
|
11878
11888
|
return;
|
|
@@ -11893,15 +11903,20 @@ function migrateLegacyExperimental(rawConfig, warnings) {
|
|
|
11893
11903
|
relocate(key, patched, "");
|
|
11894
11904
|
for (const key of MEMORY_GRADUATED)
|
|
11895
11905
|
relocate(key, memory, "memory.");
|
|
11896
|
-
|
|
11897
|
-
|
|
11898
|
-
|
|
11899
|
-
|
|
11900
|
-
|
|
11901
|
-
|
|
11906
|
+
if (hasMural) {
|
|
11907
|
+
const oldMural = coerceToObject(exp.mural);
|
|
11908
|
+
const existingMural = patched.mural;
|
|
11909
|
+
if (existingMural === undefined) {
|
|
11910
|
+
patched.mural = oldMural ?? exp.mural;
|
|
11911
|
+
warnings.push('Deprecated "experimental.mural"; use top-level "mural" instead (migrated in memory; run `doctor` to persist).');
|
|
11912
|
+
} else if (oldMural !== undefined && typeof existingMural === "object" && existingMural !== null && !Array.isArray(existingMural)) {
|
|
11913
|
+
patched.mural = {
|
|
11914
|
+
...oldMural,
|
|
11915
|
+
...existingMural
|
|
11916
|
+
};
|
|
11902
11917
|
}
|
|
11903
|
-
|
|
11904
|
-
}
|
|
11918
|
+
delete newExperimental.mural;
|
|
11919
|
+
}
|
|
11905
11920
|
if (hasUM) {
|
|
11906
11921
|
const oldUM = coerceToObject(exp.user_memories);
|
|
11907
11922
|
if (oldUM !== undefined) {
|
|
@@ -26915,12 +26930,10 @@ var init_magic_context = __esm(() => {
|
|
|
26915
26930
|
MagicContextConfigSchema = exports_external.object({
|
|
26916
26931
|
enabled: exports_external.boolean().default(true).describe("Enable magic context (default: true)"),
|
|
26917
26932
|
allow_home_project: exports_external.boolean().default(false).describe("Allow Magic Context sessions launched from the exact canonical home directory. The home session uses its deterministic dir: identity so pre-gate memories reconnect. USER-LEVEL ONLY: project config is ignored. The home identity is excluded from registry seed exports, never resolves descendants by containment, and cannot join a workspace."),
|
|
26918
|
-
|
|
26919
|
-
|
|
26920
|
-
|
|
26921
|
-
|
|
26922
|
-
}).default({ enabled: false }).describe("Experimental mural: a single deterministically-rendered image of project memories that did not fit the context budget. Cues are compressed per-memory by the compress-cues dreamer task.")
|
|
26923
|
-
}).default({ mural: { enabled: false } }).describe("Experimental feature switches. User and project configuration are both accepted."),
|
|
26933
|
+
mural: exports_external.object({
|
|
26934
|
+
enabled: exports_external.boolean().default(false),
|
|
26935
|
+
model: exports_external.string().trim().min(1).optional().describe("Model for the compress-cues task that compresses each memory into a mural cue. The mural image itself is rendered deterministically (no author model).")
|
|
26936
|
+
}).default({ enabled: false }).describe("Experimental mural: a single deterministically-rendered image of project memories that did not fit the context budget. Cues are compressed per-memory by the compress-cues dreamer task."),
|
|
26924
26937
|
transform_mode: exports_external.enum(["ts", "rust"]).default("ts").describe('Experimental: routes the entire Magic Context runtime for the project through the ck-mc Rust module over subc (requires user-level `subc` config); "ts" is the current TypeScript pipeline.'),
|
|
26925
26938
|
auto_update: exports_external.boolean().optional().describe("Enable automatic npm self-update checks for the OpenCode plugin. Security: USER-only in config loader, so hostile project configs cannot suppress updates."),
|
|
26926
26939
|
language: exports_external.string().trim().toLowerCase().refine((s) => isValidLanguageCode(s), 'language must be a 2-letter ISO 639-1 code (e.g. "tr", "es", "de")').optional().describe("Output language for Magic Context's generated content and guidance, as a " + '2-letter ISO 639-1 code (e.g. "tr", "es", "de", "ja", "pt"). When set, the ' + "historian, dreamer, sidekick, and the agent-guidance block instruct the model to " + "write its PROSE in this language while keeping all structural tokens (XML tags, " + "the five memory category names, code identifiers, file paths) in English. " + "USER-LEVEL ONLY (ignored in project config for security). Unset = today's " + "behavior (model mirrors the conversation; English scaffolding). Changing it " + "triggers one cache re-materialization; existing compartments/memories keep their " + "original language until naturally rewritten."),
|
|
@@ -27187,6 +27200,17 @@ function stripUnsafeProjectConfigFields(projectRaw) {
|
|
|
27187
27200
|
warnings.push(`Ignoring historian.${removed.join("/")} from project config ` + "(security: historian model selection is user-level only; a repository cannot force extra compaction cost).");
|
|
27188
27201
|
}
|
|
27189
27202
|
}
|
|
27203
|
+
const mural = projectRaw.mural;
|
|
27204
|
+
if (isPlainObject2(mural) && "model" in mural) {
|
|
27205
|
+
delete mural.model;
|
|
27206
|
+
warnings.push("Ignoring mural.model from project config (security: the mural cue-compressor model is a user-level setting; a repository cannot choose where project memory is sent).");
|
|
27207
|
+
}
|
|
27208
|
+
const experimental = projectRaw.experimental;
|
|
27209
|
+
const legacyMural = isPlainObject2(experimental) ? experimental.mural : undefined;
|
|
27210
|
+
if (isPlainObject2(legacyMural) && "model" in legacyMural) {
|
|
27211
|
+
delete legacyMural.model;
|
|
27212
|
+
warnings.push("Ignoring experimental.mural.model from project config (security: the mural cue-compressor model is a user-level setting; use user-level mural.model).");
|
|
27213
|
+
}
|
|
27190
27214
|
for (const agentKey of HIDDEN_AGENT_KEYS) {
|
|
27191
27215
|
const block2 = projectRaw[agentKey];
|
|
27192
27216
|
if (!isPlainObject2(block2))
|
|
@@ -32996,6 +33020,8 @@ var init_module_transport = __esm(() => {
|
|
|
32996
33020
|
init_data_path();
|
|
32997
33021
|
});
|
|
32998
33022
|
// ../plugin/src/shared/rpc-utils.ts
|
|
33023
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
33024
|
+
import { readFileSync as readFileSync9 } from "node:fs";
|
|
32999
33025
|
function isPidAlive(pid) {
|
|
33000
33026
|
if (!Number.isInteger(pid) || pid <= 0)
|
|
33001
33027
|
return false;
|
|
@@ -33006,6 +33032,76 @@ function isPidAlive(pid) {
|
|
|
33006
33032
|
return err.code === "EPERM";
|
|
33007
33033
|
}
|
|
33008
33034
|
}
|
|
33035
|
+
function parseLinuxProcessStartTime(statContent, uptimeContent) {
|
|
33036
|
+
const closingCommandName = statContent.lastIndexOf(")");
|
|
33037
|
+
if (closingCommandName < 0)
|
|
33038
|
+
return null;
|
|
33039
|
+
const statFields = statContent.slice(closingCommandName + 1).trim().split(/\s+/);
|
|
33040
|
+
const startTimeTicks = Number(statFields[19]);
|
|
33041
|
+
const uptimeSeconds = Number(uptimeContent.trim().split(/\s+/)[0]);
|
|
33042
|
+
if (!Number.isFinite(startTimeTicks) || startTimeTicks < 0 || !Number.isFinite(uptimeSeconds) || uptimeSeconds < 0) {
|
|
33043
|
+
return null;
|
|
33044
|
+
}
|
|
33045
|
+
const processStartTime = rpcIdentityNowMs() - uptimeSeconds * 1000 + startTimeTicks / LINUX_CLOCK_TICKS_PER_SECOND * 1000;
|
|
33046
|
+
return Number.isFinite(processStartTime) ? processStartTime : null;
|
|
33047
|
+
}
|
|
33048
|
+
function readLinuxProcessStartTime(pid) {
|
|
33049
|
+
try {
|
|
33050
|
+
const statContent = String(rpcIdentityReadFileSync(`/proc/${pid}/stat`, "utf8"));
|
|
33051
|
+
const uptimeContent = String(rpcIdentityReadFileSync("/proc/uptime", "utf8"));
|
|
33052
|
+
return parseLinuxProcessStartTime(statContent, uptimeContent);
|
|
33053
|
+
} catch {
|
|
33054
|
+
return null;
|
|
33055
|
+
}
|
|
33056
|
+
}
|
|
33057
|
+
function readPsProcessStartTime(pid) {
|
|
33058
|
+
try {
|
|
33059
|
+
const output = rpcIdentityExecFileSync("ps", ["-p", String(pid), "-o", "lstart="], {
|
|
33060
|
+
encoding: "utf8",
|
|
33061
|
+
timeout: PS_PROBE_TIMEOUT_MS
|
|
33062
|
+
});
|
|
33063
|
+
const processStartTime = Date.parse(String(output).trim());
|
|
33064
|
+
return Number.isFinite(processStartTime) ? processStartTime : null;
|
|
33065
|
+
} catch {
|
|
33066
|
+
return null;
|
|
33067
|
+
}
|
|
33068
|
+
}
|
|
33069
|
+
function readLinuxProcessCommand(pid) {
|
|
33070
|
+
try {
|
|
33071
|
+
return String(rpcIdentityReadFileSync(`/proc/${pid}/cmdline`, "utf8"));
|
|
33072
|
+
} catch {
|
|
33073
|
+
return null;
|
|
33074
|
+
}
|
|
33075
|
+
}
|
|
33076
|
+
function readPsProcessCommand(pid) {
|
|
33077
|
+
try {
|
|
33078
|
+
const output = rpcIdentityExecFileSync("ps", ["-p", String(pid), "-o", "command="], {
|
|
33079
|
+
encoding: "utf8",
|
|
33080
|
+
timeout: PS_PROBE_TIMEOUT_MS
|
|
33081
|
+
});
|
|
33082
|
+
return String(output);
|
|
33083
|
+
} catch {
|
|
33084
|
+
return null;
|
|
33085
|
+
}
|
|
33086
|
+
}
|
|
33087
|
+
function commandLooksLikeOpenCode(command) {
|
|
33088
|
+
const normalized = command.toLowerCase();
|
|
33089
|
+
return OPEN_CODE_COMMAND_MARKERS.some((marker) => normalized.includes(marker));
|
|
33090
|
+
}
|
|
33091
|
+
function isPidIdentityPlausible(record2) {
|
|
33092
|
+
if (!Number.isInteger(record2.pid) || record2.pid <= 0)
|
|
33093
|
+
return false;
|
|
33094
|
+
if (Number.isFinite(record2.started_at) && record2.started_at > 0) {
|
|
33095
|
+
const processStartTime = rpcIdentityPlatform === "linux" ? readLinuxProcessStartTime(record2.pid) : readPsProcessStartTime(record2.pid);
|
|
33096
|
+
if (processStartTime === null)
|
|
33097
|
+
return true;
|
|
33098
|
+
return processStartTime <= record2.started_at + RPC_IDENTITY_SKEW_TOLERANCE_MS;
|
|
33099
|
+
}
|
|
33100
|
+
const command = rpcIdentityPlatform === "linux" ? readLinuxProcessCommand(record2.pid) : readPsProcessCommand(record2.pid);
|
|
33101
|
+
if (command === null)
|
|
33102
|
+
return true;
|
|
33103
|
+
return commandLooksLikeOpenCode(command);
|
|
33104
|
+
}
|
|
33009
33105
|
function parseRpcPortFile(content, fallbackPid = 0) {
|
|
33010
33106
|
const trimmed = content.trim();
|
|
33011
33107
|
if (!trimmed)
|
|
@@ -33037,7 +33133,13 @@ function parseRpcPortFile(content, fallbackPid = 0) {
|
|
|
33037
33133
|
function isValidPort(port) {
|
|
33038
33134
|
return Number.isInteger(port) && port > 0 && port <= 65535;
|
|
33039
33135
|
}
|
|
33040
|
-
var
|
|
33136
|
+
var RPC_IDENTITY_SKEW_TOLERANCE_MS = 120000, LINUX_CLOCK_TICKS_PER_SECOND = 100, PS_PROBE_TIMEOUT_MS = 1000, OPEN_CODE_COMMAND_MARKERS, rpcIdentityReadFileSync, rpcIdentityExecFileSync, rpcIdentityPlatform, rpcIdentityNowMs = () => Date.now();
|
|
33137
|
+
var init_rpc_utils = __esm(() => {
|
|
33138
|
+
OPEN_CODE_COMMAND_MARKERS = ["opencode", "node", "bun", "electron"];
|
|
33139
|
+
rpcIdentityReadFileSync = readFileSync9;
|
|
33140
|
+
rpcIdentityExecFileSync = execFileSync4;
|
|
33141
|
+
rpcIdentityPlatform = process.platform;
|
|
33142
|
+
});
|
|
33041
33143
|
// ../plugin/src/hooks/magic-context/compartment-parser.ts
|
|
33042
33144
|
function makeTierOpenRegex(n2) {
|
|
33043
33145
|
return new RegExp(`<p${n2}\\s*(/?)>`);
|
|
@@ -33498,7 +33600,7 @@ function installLatestAuthorityTriggers(db) {
|
|
|
33498
33600
|
`);
|
|
33499
33601
|
}
|
|
33500
33602
|
}
|
|
33501
|
-
var MIGRATIONS, LATEST_MIGRATION_VERSION;
|
|
33603
|
+
var FORK_MIGRATION_VERSION_FLOOR = 1e4, MIGRATIONS, LATEST_MIGRATION_VERSION;
|
|
33502
33604
|
var init_migrations = __esm(() => {
|
|
33503
33605
|
init_compartment_parser();
|
|
33504
33606
|
init_logger();
|
|
@@ -167912,7 +168014,7 @@ import {
|
|
|
167912
168014
|
mkdirSync as mkdirSync7,
|
|
167913
168015
|
mkdtempSync,
|
|
167914
168016
|
readdirSync as readdirSync2,
|
|
167915
|
-
readFileSync as
|
|
168017
|
+
readFileSync as readFileSync10,
|
|
167916
168018
|
unlinkSync as unlinkSync2
|
|
167917
168019
|
} from "node:fs";
|
|
167918
168020
|
import { basename as basename3, dirname as dirname10, join as join12 } from "node:path";
|
|
@@ -167921,7 +168023,7 @@ function getPersistedSchemaVersion(db) {
|
|
|
167921
168023
|
if (!hasMigrationsTable) {
|
|
167922
168024
|
return 0;
|
|
167923
168025
|
}
|
|
167924
|
-
const row = db.prepare("SELECT MAX(version) AS version FROM schema_migrations").get();
|
|
168026
|
+
const row = db.prepare("SELECT COALESCE(MAX(version), 0) AS version FROM schema_migrations WHERE version < ?").get(FORK_MIGRATION_VERSION_FLOOR);
|
|
167925
168027
|
return row?.version ?? 0;
|
|
167926
168028
|
}
|
|
167927
168029
|
function unreadableDiscovery(path4) {
|
|
@@ -167968,7 +168070,7 @@ function inspectRpcServerDiscovery(storageDir) {
|
|
|
167968
168070
|
for (const portFile of portFiles) {
|
|
167969
168071
|
let raw;
|
|
167970
168072
|
try {
|
|
167971
|
-
raw =
|
|
168073
|
+
raw = readFileSync10(portFile, "utf8");
|
|
167972
168074
|
} catch {
|
|
167973
168075
|
return unreadableDiscovery(portFile);
|
|
167974
168076
|
}
|
|
@@ -167978,15 +168080,11 @@ function inspectRpcServerDiscovery(storageDir) {
|
|
|
167978
168080
|
if (!record2 || !Number.isInteger(record2.pid) || record2.pid <= 0) {
|
|
167979
168081
|
return unreadableDiscovery(portFile);
|
|
167980
168082
|
}
|
|
167981
|
-
if (isPidAlive(record2.pid))
|
|
168083
|
+
if (isPidAlive(record2.pid) && isPidIdentityPlausible(record2))
|
|
167982
168084
|
pids.add(record2.pid);
|
|
167983
168085
|
else
|
|
167984
168086
|
staleFiles.push(portFile);
|
|
167985
168087
|
}
|
|
167986
|
-
const serverPids = [...pids].sort((a3, b2) => a3 - b2);
|
|
167987
|
-
if (serverPids.length > 0) {
|
|
167988
|
-
return { state: "live", serverPids, staleFiles };
|
|
167989
|
-
}
|
|
167990
168088
|
for (const staleFile of staleFiles) {
|
|
167991
168089
|
try {
|
|
167992
168090
|
unlinkSync2(staleFile);
|
|
@@ -167994,6 +168092,10 @@ function inspectRpcServerDiscovery(storageDir) {
|
|
|
167994
168092
|
return unreadableDiscovery(staleFile);
|
|
167995
168093
|
}
|
|
167996
168094
|
}
|
|
168095
|
+
const serverPids = [...pids].sort((a3, b2) => a3 - b2);
|
|
168096
|
+
if (serverPids.length > 0) {
|
|
168097
|
+
return { state: "live", serverPids, staleFiles };
|
|
168098
|
+
}
|
|
167997
168099
|
return { state: "stale", serverPids: [], staleFiles };
|
|
167998
168100
|
}
|
|
167999
168101
|
function getLiveMigrationBlockingProcesses(storageDir) {
|
|
@@ -170037,7 +170139,7 @@ import {
|
|
|
170037
170139
|
chmodSync as chmodSync3,
|
|
170038
170140
|
existsSync as existsSync19,
|
|
170039
170141
|
mkdirSync as mkdirSync8,
|
|
170040
|
-
readFileSync as
|
|
170142
|
+
readFileSync as readFileSync11,
|
|
170041
170143
|
renameSync as renameSync3,
|
|
170042
170144
|
statSync as statSync7,
|
|
170043
170145
|
writeFileSync as writeFileSync6
|
|
@@ -170096,7 +170198,7 @@ function ensureTuiPluginEntry(options = {}) {
|
|
|
170096
170198
|
const configPath = resolveTuiConfigPath(options.configDir);
|
|
170097
170199
|
let config2 = {};
|
|
170098
170200
|
if (existsSync19(configPath)) {
|
|
170099
|
-
const raw =
|
|
170201
|
+
const raw = readFileSync11(configPath, "utf-8");
|
|
170100
170202
|
config2 = import_comment_json7.parse(raw) ?? {};
|
|
170101
170203
|
}
|
|
170102
170204
|
const plugins = Array.isArray(config2.plugin) ? [...config2.plugin] : [];
|
|
@@ -170356,7 +170458,7 @@ var init_redaction2 = __esm(() => {
|
|
|
170356
170458
|
});
|
|
170357
170459
|
|
|
170358
170460
|
// src/lib/diagnostics-opencode.ts
|
|
170359
|
-
import { existsSync as existsSync20, readdirSync as readdirSync3, readFileSync as
|
|
170461
|
+
import { existsSync as existsSync20, readdirSync as readdirSync3, readFileSync as readFileSync12, statSync as statSync8 } from "node:fs";
|
|
170360
170462
|
import { createRequire as createRequire2 } from "node:module";
|
|
170361
170463
|
import { homedir as homedir14 } from "node:os";
|
|
170362
170464
|
import { join as join18 } from "node:path";
|
|
@@ -170378,7 +170480,7 @@ function getPluginCacheInfo() {
|
|
|
170378
170480
|
for (const installedPkgPath of getOpenCodePluginPackageJsonPaths()) {
|
|
170379
170481
|
try {
|
|
170380
170482
|
if (existsSync20(installedPkgPath)) {
|
|
170381
|
-
const pkg = JSON.parse(
|
|
170483
|
+
const pkg = JSON.parse(readFileSync12(installedPkgPath, "utf-8"));
|
|
170382
170484
|
cached2 = typeof pkg.version === "string" ? pkg.version : undefined;
|
|
170383
170485
|
if (cached2)
|
|
170384
170486
|
break;
|
|
@@ -170410,7 +170512,7 @@ function readConfig2(path6) {
|
|
|
170410
170512
|
if (!existsSync20(path6))
|
|
170411
170513
|
return { value: null };
|
|
170412
170514
|
try {
|
|
170413
|
-
const raw =
|
|
170515
|
+
const raw = readFileSync12(path6, "utf-8");
|
|
170414
170516
|
const value = import_comment_json8.parse(raw);
|
|
170415
170517
|
return { value };
|
|
170416
170518
|
} catch (error51) {
|
|
@@ -170435,7 +170537,7 @@ function configHasPluginEntry(config2) {
|
|
|
170435
170537
|
}
|
|
170436
170538
|
function parseHistorianDumpMeta(path6) {
|
|
170437
170539
|
try {
|
|
170438
|
-
const xml =
|
|
170540
|
+
const xml = readFileSync12(path6, "utf-8");
|
|
170439
170541
|
const parsed = parseCompartmentOutput(xml);
|
|
170440
170542
|
const factCountByCategory = {};
|
|
170441
170543
|
for (const fact of parsed.facts) {
|
|
@@ -171194,7 +171296,7 @@ var init_issue_body = __esm(() => {
|
|
|
171194
171296
|
});
|
|
171195
171297
|
|
|
171196
171298
|
// src/lib/logs-opencode.ts
|
|
171197
|
-
import { readFileSync as
|
|
171299
|
+
import { readFileSync as readFileSync13, writeFileSync as writeFileSync7 } from "node:fs";
|
|
171198
171300
|
import { join as join20 } from "node:path";
|
|
171199
171301
|
function sanitizeLogContent(content) {
|
|
171200
171302
|
return sanitizeDiagnosticText(content);
|
|
@@ -171237,7 +171339,7 @@ function filterLogLinesBySession(lines, sessionId) {
|
|
|
171237
171339
|
}
|
|
171238
171340
|
async function bundleIssueReport(report, description, title, sessionFilter = null) {
|
|
171239
171341
|
const LOG_TAIL_LINES = 400;
|
|
171240
|
-
const allLogLines = report.logFile.exists ?
|
|
171342
|
+
const allLogLines = report.logFile.exists ? readFileSync13(report.logFile.path, "utf-8").split(/\r?\n/) : [];
|
|
171241
171343
|
const logLines = filterLogLinesBySession(allLogLines, sessionFilter);
|
|
171242
171344
|
const recentLog = sanitizeLogContent(logLines.slice(-LOG_TAIL_LINES).join(`
|
|
171243
171345
|
`)).trim();
|
|
@@ -171585,7 +171687,7 @@ function formatFailClosedBlockingMessage(reason) {
|
|
|
171585
171687
|
}
|
|
171586
171688
|
if (reason.kind === "schema_fence") {
|
|
171587
171689
|
return [
|
|
171588
|
-
`Magic Context cannot operate: this Magic Context build is older than the database; upgrade/restart this harness (
|
|
171690
|
+
`Magic Context cannot operate: this Magic Context build is older than the database; upgrade/restart this harness (upstream migration lane v${reason.persistedVersion}, build supports through v${reason.supportedVersion}).`,
|
|
171589
171691
|
`Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
|
|
171590
171692
|
].join(" ");
|
|
171591
171693
|
}
|
|
@@ -171610,7 +171712,7 @@ function checkStorageVersionFence(versions2, options = {}) {
|
|
|
171610
171712
|
if (databaseVersion > supportedVersion) {
|
|
171611
171713
|
return {
|
|
171612
171714
|
alarm: true,
|
|
171613
|
-
message: `
|
|
171715
|
+
message: `Upstream migration fence alarm: context.db is v${databaseVersion}, but this build supports through v${supportedVersion}. ` + `${STALE_BUILD_RESTART_INSTRUCTION}.`
|
|
171614
171716
|
};
|
|
171615
171717
|
}
|
|
171616
171718
|
if (databaseVersion < supportedVersion) {
|
|
@@ -171627,12 +171729,12 @@ function checkStorageVersionFence(versions2, options = {}) {
|
|
|
171627
171729
|
}
|
|
171628
171730
|
return {
|
|
171629
171731
|
alarm: false,
|
|
171630
|
-
message: `
|
|
171732
|
+
message: `Upstream migrations pending: context.db is v${databaseVersion}; this build supports through v${supportedVersion}.`
|
|
171631
171733
|
};
|
|
171632
171734
|
}
|
|
171633
171735
|
return {
|
|
171634
171736
|
alarm: false,
|
|
171635
|
-
message: `
|
|
171737
|
+
message: `Upstream migration fence: context.db and this build are both v${supportedVersion}.`
|
|
171636
171738
|
};
|
|
171637
171739
|
}
|
|
171638
171740
|
function readStorageVersions(db) {
|
|
@@ -171651,13 +171753,13 @@ var init_storage_versions = __esm(async () => {
|
|
|
171651
171753
|
});
|
|
171652
171754
|
|
|
171653
171755
|
// src/commands/doctor-opencode-cache.ts
|
|
171654
|
-
import { existsSync as existsSync22, readFileSync as
|
|
171756
|
+
import { existsSync as existsSync22, readFileSync as readFileSync14, rmSync as rmSync2 } from "node:fs";
|
|
171655
171757
|
function readCachedPluginVersion(pluginCacheDir) {
|
|
171656
171758
|
try {
|
|
171657
171759
|
const installedPkgPath = getOpenCodePluginPackageJsonPath(pluginCacheDir);
|
|
171658
171760
|
if (!existsSync22(installedPkgPath))
|
|
171659
171761
|
return;
|
|
171660
|
-
const pkg = JSON.parse(
|
|
171762
|
+
const pkg = JSON.parse(readFileSync14(installedPkgPath, "utf-8"));
|
|
171661
171763
|
return typeof pkg.version === "string" ? pkg.version : undefined;
|
|
171662
171764
|
} catch {
|
|
171663
171765
|
return;
|
|
@@ -171734,7 +171836,7 @@ var init_doctor_opencode_cache = __esm(() => {
|
|
|
171734
171836
|
|
|
171735
171837
|
// src/commands/doctor-opencode.ts
|
|
171736
171838
|
import { execSync as execSync2, spawnSync as spawnSync3 } from "node:child_process";
|
|
171737
|
-
import { existsSync as existsSync23, readFileSync as
|
|
171839
|
+
import { existsSync as existsSync23, readFileSync as readFileSync15, statSync as statSync9 } from "node:fs";
|
|
171738
171840
|
import { createRequire as createRequire4 } from "node:module";
|
|
171739
171841
|
import { homedir as homedir15 } from "node:os";
|
|
171740
171842
|
import { join as join21 } from "node:path";
|
|
@@ -171844,7 +171946,7 @@ function collectNpmReleaseAgeWarnings() {
|
|
|
171844
171946
|
if (!existsSync23(npmrcPath))
|
|
171845
171947
|
return ageWarnings;
|
|
171846
171948
|
try {
|
|
171847
|
-
const npmrc =
|
|
171949
|
+
const npmrc = readFileSync15(npmrcPath, "utf-8");
|
|
171848
171950
|
for (const line of npmrc.split(`
|
|
171849
171951
|
`)) {
|
|
171850
171952
|
const trimmed = line.trim();
|
|
@@ -171988,7 +172090,7 @@ async function checkEmbeddingConfig(magicContextConfigPath) {
|
|
|
171988
172090
|
}
|
|
171989
172091
|
let rawText;
|
|
171990
172092
|
try {
|
|
171991
|
-
rawText =
|
|
172093
|
+
rawText = readFileSync15(magicContextConfigPath, "utf-8");
|
|
171992
172094
|
} catch {
|
|
171993
172095
|
log2.warn("Could not read magic-context.jsonc for embedding check");
|
|
171994
172096
|
return { issues: 1 };
|
|
@@ -172197,7 +172299,7 @@ async function runDoctor(options = {}) {
|
|
|
172197
172299
|
if (existsSync23(paths.magicContextConfig)) {
|
|
172198
172300
|
pass(`Magic Context config: ${paths.magicContextConfig}`);
|
|
172199
172301
|
try {
|
|
172200
|
-
const raw =
|
|
172302
|
+
const raw = readFileSync15(paths.magicContextConfig, "utf-8");
|
|
172201
172303
|
const substituted = substituteConfigVariables({
|
|
172202
172304
|
text: raw,
|
|
172203
172305
|
configPath: paths.magicContextConfig
|
|
@@ -172224,7 +172326,7 @@ async function runDoctor(options = {}) {
|
|
|
172224
172326
|
}
|
|
172225
172327
|
if (existsSync23(paths.magicContextConfig)) {
|
|
172226
172328
|
try {
|
|
172227
|
-
const mcRaw =
|
|
172329
|
+
const mcRaw = readFileSync15(paths.magicContextConfig, "utf-8");
|
|
172228
172330
|
const mcConfig = import_comment_json9.parse(mcRaw);
|
|
172229
172331
|
let mcChanged = false;
|
|
172230
172332
|
const experimental = mcConfig.experimental;
|
|
@@ -172309,6 +172411,7 @@ async function runDoctor(options = {}) {
|
|
|
172309
172411
|
if (experimental) {
|
|
172310
172412
|
relocateGraduated("temporal_awareness", mcConfig, "");
|
|
172311
172413
|
relocateGraduated("caveman_text_compression", mcConfig, "");
|
|
172414
|
+
relocateGraduated("mural", mcConfig, "");
|
|
172312
172415
|
const memoryDest = mcConfig.memory ?? {};
|
|
172313
172416
|
relocateGraduated("auto_search", memoryDest, "memory.");
|
|
172314
172417
|
relocateGraduated("git_commit_indexing", memoryDest, "memory.");
|
|
@@ -172341,7 +172444,7 @@ async function runDoctor(options = {}) {
|
|
|
172341
172444
|
}
|
|
172342
172445
|
if (paths.opencodeConfigFormat !== "none") {
|
|
172343
172446
|
try {
|
|
172344
|
-
const raw =
|
|
172447
|
+
const raw = readFileSync15(paths.opencodeConfig, "utf-8");
|
|
172345
172448
|
const config2 = import_comment_json9.parse(raw);
|
|
172346
172449
|
const rawPlugins = Array.isArray(config2?.plugin) ? config2.plugin : [];
|
|
172347
172450
|
const existingIdx = rawPlugins.findIndex((entry) => matchesPluginEntry(entry, OPENCODE_PLUGIN_NAME) || isDevPathPluginEntry(entry));
|
|
@@ -172427,7 +172530,7 @@ async function runDoctor(options = {}) {
|
|
|
172427
172530
|
fixed++;
|
|
172428
172531
|
} else if (existsSync23(paths.tuiConfig)) {
|
|
172429
172532
|
try {
|
|
172430
|
-
const tuiRaw =
|
|
172533
|
+
const tuiRaw = readFileSync15(paths.tuiConfig, "utf-8");
|
|
172431
172534
|
const tuiConfig = import_comment_json9.parse(tuiRaw);
|
|
172432
172535
|
const tuiRawPlugins = Array.isArray(tuiConfig?.plugin) ? tuiConfig.plugin : [];
|
|
172433
172536
|
const tuiIdx = tuiRawPlugins.findIndex((entry) => matchesPluginEntry(entry, OPENCODE_PLUGIN_NAME) || isDevPathPluginEntry(entry));
|
|
@@ -172478,7 +172581,7 @@ async function runDoctor(options = {}) {
|
|
|
172478
172581
|
}
|
|
172479
172582
|
if (existsSync23(paths.magicContextConfig)) {
|
|
172480
172583
|
try {
|
|
172481
|
-
const mcRaw =
|
|
172584
|
+
const mcRaw = readFileSync15(paths.magicContextConfig, "utf-8");
|
|
172482
172585
|
const mcConfig = import_comment_json9.parse(mcRaw);
|
|
172483
172586
|
const warning = checkUserMemoriesDreamerCompatibility(mcConfig);
|
|
172484
172587
|
if (warning) {
|
|
@@ -172680,7 +172783,7 @@ var init_doctor_opencode = __esm(async () => {
|
|
|
172680
172783
|
});
|
|
172681
172784
|
|
|
172682
172785
|
// ../pi-plugin/src/config/index.ts
|
|
172683
|
-
import { existsSync as existsSync24, readFileSync as
|
|
172786
|
+
import { existsSync as existsSync24, readFileSync as readFileSync16 } from "node:fs";
|
|
172684
172787
|
function getProjectConfigPaths(cwd) {
|
|
172685
172788
|
const basePath = cortexKitProjectConfigBasePath(cwd);
|
|
172686
172789
|
return [`${basePath}.jsonc`, `${basePath}.json`];
|
|
@@ -172697,7 +172800,7 @@ function resolvePiLegacyFallback(sources) {
|
|
|
172697
172800
|
}
|
|
172698
172801
|
function loadConfigFile(path6, scope) {
|
|
172699
172802
|
try {
|
|
172700
|
-
const rawText =
|
|
172803
|
+
const rawText = readFileSync16(path6, "utf-8");
|
|
172701
172804
|
const substituted = substituteConfigVariables({
|
|
172702
172805
|
text: rawText,
|
|
172703
172806
|
configPath: path6,
|
|
@@ -172904,7 +173007,7 @@ var init_config2 = __esm(() => {
|
|
|
172904
173007
|
|
|
172905
173008
|
// src/lib/diagnostics-pi.ts
|
|
172906
173009
|
import { createHash as createHash4 } from "node:crypto";
|
|
172907
|
-
import { existsSync as existsSync25, readdirSync as readdirSync4, readFileSync as
|
|
173010
|
+
import { existsSync as existsSync25, readdirSync as readdirSync4, readFileSync as readFileSync17, statSync as statSync10 } from "node:fs";
|
|
172908
173011
|
import { createRequire as createRequire5 } from "node:module";
|
|
172909
173012
|
import { homedir as homedir16, userInfo as userInfo2 } from "node:os";
|
|
172910
173013
|
import { join as join22 } from "node:path";
|
|
@@ -172978,7 +173081,7 @@ function readJsonc(path6) {
|
|
|
172978
173081
|
return { value: {} };
|
|
172979
173082
|
try {
|
|
172980
173083
|
return {
|
|
172981
|
-
value: import_comment_json11.parse(
|
|
173084
|
+
value: import_comment_json11.parse(readFileSync17(path6, "utf-8"))
|
|
172982
173085
|
};
|
|
172983
173086
|
} catch (error51) {
|
|
172984
173087
|
return {
|
|
@@ -173048,7 +173151,7 @@ function collectPiRecentSessions() {
|
|
|
173048
173151
|
}
|
|
173049
173152
|
function parseHistorianDumpMeta2(path6) {
|
|
173050
173153
|
try {
|
|
173051
|
-
const xml =
|
|
173154
|
+
const xml = readFileSync17(path6, "utf-8");
|
|
173052
173155
|
const parsed = parseCompartmentOutput(xml);
|
|
173053
173156
|
const factCountByCategory = {};
|
|
173054
173157
|
for (const fact of parsed.facts) {
|
|
@@ -173293,7 +173396,7 @@ var init_diagnostics_pi = __esm(() => {
|
|
|
173293
173396
|
});
|
|
173294
173397
|
|
|
173295
173398
|
// src/lib/logs-pi.ts
|
|
173296
|
-
import { readFileSync as
|
|
173399
|
+
import { readFileSync as readFileSync18, writeFileSync as writeFileSync8 } from "node:fs";
|
|
173297
173400
|
import { join as join23 } from "node:path";
|
|
173298
173401
|
function sanitizeLogContent2(content) {
|
|
173299
173402
|
return sanitizeString2(content);
|
|
@@ -173323,7 +173426,7 @@ function filterLogLinesBySession2(lines, sessionId) {
|
|
|
173323
173426
|
}
|
|
173324
173427
|
async function bundleIssueReport2(report, description, title, options = {}) {
|
|
173325
173428
|
const LOG_TAIL_LINES = 400;
|
|
173326
|
-
const allLogLines = report.logFile.exists ?
|
|
173429
|
+
const allLogLines = report.logFile.exists ? readFileSync18(report.logFile.path, "utf-8").split(/\r?\n/) : [];
|
|
173327
173430
|
const logLines = filterLogLinesBySession2(allLogLines, options.sessionFilter ?? null);
|
|
173328
173431
|
const recentLog = sanitizeLogContent2(logLines.slice(-LOG_TAIL_LINES).join(`
|
|
173329
173432
|
`)).trim();
|
|
@@ -173370,8 +173473,8 @@ var init_logs_pi = __esm(() => {
|
|
|
173370
173473
|
});
|
|
173371
173474
|
|
|
173372
173475
|
// src/commands/doctor-pi.ts
|
|
173373
|
-
import { execFileSync as
|
|
173374
|
-
import { existsSync as existsSync26, mkdirSync as mkdirSync9, readdirSync as readdirSync5, readFileSync as
|
|
173476
|
+
import { execFileSync as execFileSync5, spawnSync as spawnSync4 } from "node:child_process";
|
|
173477
|
+
import { existsSync as existsSync26, mkdirSync as mkdirSync9, readdirSync as readdirSync5, readFileSync as readFileSync19, rmSync as rmSync3, statSync as statSync11 } from "node:fs";
|
|
173375
173478
|
import { createRequire as createRequire6 } from "node:module";
|
|
173376
173479
|
import { homedir as homedir17 } from "node:os";
|
|
173377
173480
|
import { dirname as dirname13, isAbsolute as isAbsolute4, join as join24 } from "node:path";
|
|
@@ -173410,7 +173513,7 @@ function selfVersion() {
|
|
|
173410
173513
|
}
|
|
173411
173514
|
function getLatestNpmVersion(packageName) {
|
|
173412
173515
|
try {
|
|
173413
|
-
return
|
|
173516
|
+
return execFileSync5("npm", ["view", packageName, "version"], {
|
|
173414
173517
|
encoding: "utf-8",
|
|
173415
173518
|
stdio: ["ignore", "pipe", "ignore"],
|
|
173416
173519
|
timeout: 1e4
|
|
@@ -173464,7 +173567,7 @@ function summarize(results) {
|
|
|
173464
173567
|
function readJsonc2(path6) {
|
|
173465
173568
|
try {
|
|
173466
173569
|
return {
|
|
173467
|
-
value: import_comment_json12.parse(
|
|
173570
|
+
value: import_comment_json12.parse(readFileSync19(path6, "utf-8"))
|
|
173468
173571
|
};
|
|
173469
173572
|
} catch (error51) {
|
|
173470
173573
|
return {
|
|
@@ -173497,7 +173600,7 @@ function readConfigForEmbedding(path6, isProjectConfig) {
|
|
|
173497
173600
|
if (!existsSync26(path6))
|
|
173498
173601
|
return null;
|
|
173499
173602
|
try {
|
|
173500
|
-
const rawText =
|
|
173603
|
+
const rawText = readFileSync19(path6, "utf-8");
|
|
173501
173604
|
const substituted = substituteConfigVariables({
|
|
173502
173605
|
text: rawText,
|
|
173503
173606
|
configPath: path6,
|
|
@@ -173596,7 +173699,7 @@ function findPiMagicContextCacheDirs(cwd, expectedVersion, force = false) {
|
|
|
173596
173699
|
const packageJson = join24(path6, "package.json");
|
|
173597
173700
|
if (existsSync26(packageJson)) {
|
|
173598
173701
|
try {
|
|
173599
|
-
const pkg = JSON.parse(
|
|
173702
|
+
const pkg = JSON.parse(readFileSync19(packageJson, "utf-8"));
|
|
173600
173703
|
const name2 = typeof pkg.name === "string" ? pkg.name : "";
|
|
173601
173704
|
const version2 = typeof pkg.version === "string" ? pkg.version : undefined;
|
|
173602
173705
|
if (name2 === PACKAGE_NAME) {
|
|
@@ -173852,7 +173955,7 @@ async function runHealthChecks(options) {
|
|
|
173852
173955
|
if (existsSync26(logPath)) {
|
|
173853
173956
|
const stat = statSync11(logPath);
|
|
173854
173957
|
const sizeKb = (stat.size / 1024).toFixed(0);
|
|
173855
|
-
const lines =
|
|
173958
|
+
const lines = readFileSync19(logPath, "utf-8").split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
173856
173959
|
add(results, "info", `Log file: ${logPath} (${sizeKb} KB)`);
|
|
173857
173960
|
const lastLine = lines.at(-1);
|
|
173858
173961
|
add(results, "info", `Last plugin log line: ${lastLine ? sanitizeDiagnosticText(lastLine) : "<empty log>"}`);
|
|
@@ -174130,7 +174233,7 @@ var init_doctor_pi = __esm(async () => {
|
|
|
174130
174233
|
probeEmbeddingEndpoint,
|
|
174131
174234
|
openExistingContextDatabase,
|
|
174132
174235
|
now: () => new Date,
|
|
174133
|
-
execFileSync:
|
|
174236
|
+
execFileSync: execFileSync5,
|
|
174134
174237
|
spawnSync: spawnSync4
|
|
174135
174238
|
};
|
|
174136
174239
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/magic-context",
|
|
3
|
-
"version": "0.34.
|
|
4
|
-
"description": "Unified CLI for Magic Context
|
|
3
|
+
"version": "0.34.1",
|
|
4
|
+
"description": "Unified CLI for Magic Context — setup, doctor, and migration across OpenCode and Pi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|
|
7
7
|
"opencode-plugin",
|