@cortexkit/magic-context 0.49.80 → 0.49.82
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 +342 -122
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39642,6 +39642,7 @@ function getOpenCodeConfigDirs() {
|
|
|
39642
39642
|
var init_opencode_config_dir = () => {};
|
|
39643
39643
|
|
|
39644
39644
|
// ../plugin/src/shared/conflict-detector.ts
|
|
39645
|
+
import { readFileSync as readFileSync17 } from "node:fs";
|
|
39645
39646
|
import { homedir as homedir14 } from "node:os";
|
|
39646
39647
|
import { join as join18 } from "node:path";
|
|
39647
39648
|
function detectConflicts(directory, options) {
|
|
@@ -39739,17 +39740,19 @@ function openCodeConfigFileChain(directory, hostGeneration) {
|
|
|
39739
39740
|
];
|
|
39740
39741
|
return [...new Set(files)];
|
|
39741
39742
|
}
|
|
39742
|
-
function readCompactionFromConfigFiles(directory, hostGeneration) {
|
|
39743
|
+
function readCompactionFromConfigFiles(directory, hostGeneration, readConfig = readJsoncFile) {
|
|
39743
39744
|
const merged = {};
|
|
39744
39745
|
for (const filePath of openCodeConfigFileChain(directory, hostGeneration)) {
|
|
39745
39746
|
let block;
|
|
39746
39747
|
try {
|
|
39747
|
-
block =
|
|
39748
|
+
block = readConfig(filePath)?.compaction;
|
|
39748
39749
|
} catch {}
|
|
39749
39750
|
if (!block || typeof block !== "object")
|
|
39750
39751
|
continue;
|
|
39751
39752
|
if (block.auto !== undefined)
|
|
39752
39753
|
merged.auto = block.auto;
|
|
39754
|
+
if (block.background !== undefined)
|
|
39755
|
+
merged.background = block.background;
|
|
39753
39756
|
if (block.prune !== undefined)
|
|
39754
39757
|
merged.prune = block.prune;
|
|
39755
39758
|
if (block.buffer !== undefined)
|
|
@@ -39759,6 +39762,31 @@ function readCompactionFromConfigFiles(directory, hostGeneration) {
|
|
|
39759
39762
|
}
|
|
39760
39763
|
return merged;
|
|
39761
39764
|
}
|
|
39765
|
+
function readOpenCode2BackgroundCompaction(directory) {
|
|
39766
|
+
let backgroundSource;
|
|
39767
|
+
const unreadable = [];
|
|
39768
|
+
const compaction = readCompactionFromConfigFiles(directory, "v2", (path) => {
|
|
39769
|
+
try {
|
|
39770
|
+
const text = readFileSync17(path, "utf-8").replace(/^\uFEFF/, "");
|
|
39771
|
+
const config = parseJsonc(text);
|
|
39772
|
+
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
39773
|
+
throw new Error("Expected an OpenCode config object");
|
|
39774
|
+
}
|
|
39775
|
+
if (config.compaction?.background !== undefined)
|
|
39776
|
+
backgroundSource = path;
|
|
39777
|
+
return config;
|
|
39778
|
+
} catch (error) {
|
|
39779
|
+
if (error.code !== "ENOENT")
|
|
39780
|
+
unreadable.push(path);
|
|
39781
|
+
return null;
|
|
39782
|
+
}
|
|
39783
|
+
});
|
|
39784
|
+
return {
|
|
39785
|
+
enabled: compaction.auto !== false && compaction.background !== false,
|
|
39786
|
+
backgroundSource,
|
|
39787
|
+
unreadable
|
|
39788
|
+
};
|
|
39789
|
+
}
|
|
39762
39790
|
function isRelevantCompactionBlock(block, hostGeneration) {
|
|
39763
39791
|
if (block.auto !== undefined)
|
|
39764
39792
|
return true;
|
|
@@ -39903,7 +39931,7 @@ var init_conflict_detector = __esm(() => {
|
|
|
39903
39931
|
});
|
|
39904
39932
|
|
|
39905
39933
|
// ../plugin/src/shared/conflict-fixer.ts
|
|
39906
|
-
import { existsSync as existsSync24, readFileSync as
|
|
39934
|
+
import { existsSync as existsSync24, readFileSync as readFileSync18, writeFileSync as writeFileSync6 } from "node:fs";
|
|
39907
39935
|
import { homedir as homedir15 } from "node:os";
|
|
39908
39936
|
import { join as join19 } from "node:path";
|
|
39909
39937
|
function isRecord3(value) {
|
|
@@ -39917,7 +39945,7 @@ function readConfig(filePath) {
|
|
|
39917
39945
|
return null;
|
|
39918
39946
|
}
|
|
39919
39947
|
try {
|
|
39920
|
-
const text =
|
|
39948
|
+
const text = readFileSync18(filePath, "utf-8");
|
|
39921
39949
|
const parsed = import_comment_json5.parse(text);
|
|
39922
39950
|
return isRecord3(parsed) ? { config: parsed, text } : null;
|
|
39923
39951
|
} catch {
|
|
@@ -39933,18 +39961,21 @@ function resolveUserOpenCodeConfigPath() {
|
|
|
39933
39961
|
return paths.configJsonc;
|
|
39934
39962
|
return paths.configJson;
|
|
39935
39963
|
}
|
|
39964
|
+
function projectOpenCodeConfigPaths(directory) {
|
|
39965
|
+
return [
|
|
39966
|
+
join19(directory, ".opencode", "opencode.jsonc"),
|
|
39967
|
+
join19(directory, ".opencode", "opencode.json"),
|
|
39968
|
+
join19(directory, "opencode.jsonc"),
|
|
39969
|
+
join19(directory, "opencode.json")
|
|
39970
|
+
];
|
|
39971
|
+
}
|
|
39936
39972
|
function collectOpenCodeConfigPaths(directory) {
|
|
39937
39973
|
const paths = new Set;
|
|
39938
39974
|
const userConfig = resolveUserOpenCodeConfigPath();
|
|
39939
39975
|
if (existsSync24(userConfig)) {
|
|
39940
39976
|
paths.add(userConfig);
|
|
39941
39977
|
}
|
|
39942
|
-
for (const filePath of
|
|
39943
|
-
join19(directory, ".opencode", "opencode.jsonc"),
|
|
39944
|
-
join19(directory, ".opencode", "opencode.json"),
|
|
39945
|
-
join19(directory, "opencode.jsonc"),
|
|
39946
|
-
join19(directory, "opencode.json")
|
|
39947
|
-
]) {
|
|
39978
|
+
for (const filePath of projectOpenCodeConfigPaths(directory)) {
|
|
39948
39979
|
if (existsSync24(filePath)) {
|
|
39949
39980
|
paths.add(filePath);
|
|
39950
39981
|
}
|
|
@@ -40118,12 +40149,17 @@ function isPlainObject5(value) {
|
|
|
40118
40149
|
}
|
|
40119
40150
|
function planOpenCodeConfigUpdate(configPath, removeDcp = false, compactionEnabled = true, hostGeneration = "v1") {
|
|
40120
40151
|
const registrationKey = pluginConfigKeyFor(hostGeneration);
|
|
40152
|
+
const compactionDefaults = {
|
|
40153
|
+
auto: false,
|
|
40154
|
+
prune: false,
|
|
40155
|
+
...hostGeneration === "v2" ? { background: false } : {}
|
|
40156
|
+
};
|
|
40121
40157
|
const existsAtCommit = existsSync25(configPath);
|
|
40122
40158
|
const existing = existsAtCommit ? readJsoncConfigForUpdate(configPath) : {};
|
|
40123
40159
|
if (!existsAtCommit) {
|
|
40124
40160
|
const created = { [registrationKey]: [OPENCODE_PLUGIN_ENTRY_WITH_VERSION] };
|
|
40125
40161
|
if (compactionEnabled) {
|
|
40126
|
-
created.compaction =
|
|
40162
|
+
created.compaction = compactionDefaults;
|
|
40127
40163
|
}
|
|
40128
40164
|
return `${import_comment_json6.stringify(created, null, 2)}
|
|
40129
40165
|
`;
|
|
@@ -40157,16 +40193,14 @@ function planOpenCodeConfigUpdate(configPath, removeDcp = false, compactionEnabl
|
|
|
40157
40193
|
const compaction = existing.compaction;
|
|
40158
40194
|
const hasCompactionObject = typeof compaction === "object" && compaction !== null && !Array.isArray(compaction);
|
|
40159
40195
|
if (!hasCompactionObject) {
|
|
40160
|
-
text = setJsoncValue(text, ["compaction"],
|
|
40196
|
+
text = setJsoncValue(text, ["compaction"], compactionDefaults);
|
|
40161
40197
|
changed = true;
|
|
40162
40198
|
} else {
|
|
40163
40199
|
const fields = compaction;
|
|
40164
|
-
|
|
40165
|
-
|
|
40166
|
-
|
|
40167
|
-
|
|
40168
|
-
if (fields.prune !== false) {
|
|
40169
|
-
text = setJsoncValue(text, ["compaction", "prune"], false);
|
|
40200
|
+
for (const key of Object.keys(compactionDefaults)) {
|
|
40201
|
+
if (fields[key] === false)
|
|
40202
|
+
continue;
|
|
40203
|
+
text = setJsoncValue(text, ["compaction", key], false);
|
|
40170
40204
|
changed = true;
|
|
40171
40205
|
}
|
|
40172
40206
|
}
|
|
@@ -40660,7 +40694,7 @@ import {
|
|
|
40660
40694
|
accessSync as accessSync3,
|
|
40661
40695
|
existsSync as existsSync27,
|
|
40662
40696
|
constants as fsConstants,
|
|
40663
|
-
readFileSync as
|
|
40697
|
+
readFileSync as readFileSync19,
|
|
40664
40698
|
renameSync as renameSync5,
|
|
40665
40699
|
statSync as statSync15,
|
|
40666
40700
|
writeFileSync as writeFileSync7
|
|
@@ -40714,7 +40748,7 @@ function getWinningConfig(directory, surface) {
|
|
|
40714
40748
|
try {
|
|
40715
40749
|
if (!existsSync27(path))
|
|
40716
40750
|
continue;
|
|
40717
|
-
const parsed = parseJsonConfig(
|
|
40751
|
+
const parsed = parseJsonConfig(readFileSync19(path, "utf-8"));
|
|
40718
40752
|
const entries = getPluginEntries(parsed);
|
|
40719
40753
|
if (entries.some((entry) => entry === PACKAGE_NAME || entry.startsWith(`${PACKAGE_NAME}@`))) {
|
|
40720
40754
|
if (winner) {
|
|
@@ -40751,14 +40785,14 @@ var init_checker = __esm(async () => {
|
|
|
40751
40785
|
});
|
|
40752
40786
|
|
|
40753
40787
|
// src/lib/opencode-plugin-schema-fence.ts
|
|
40754
|
-
import { existsSync as existsSync28, readdirSync as readdirSync6, readFileSync as
|
|
40788
|
+
import { existsSync as existsSync28, readdirSync as readdirSync6, readFileSync as readFileSync20 } from "node:fs";
|
|
40755
40789
|
import { join as join22 } from "node:path";
|
|
40756
40790
|
import { gunzipSync as gunzipSync2 } from "node:zlib";
|
|
40757
40791
|
function readPackageVersion(packageJsonPath) {
|
|
40758
40792
|
try {
|
|
40759
40793
|
if (!existsSync28(packageJsonPath))
|
|
40760
40794
|
return null;
|
|
40761
|
-
const packageJson = JSON.parse(
|
|
40795
|
+
const packageJson = JSON.parse(readFileSync20(packageJsonPath, "utf-8"));
|
|
40762
40796
|
if (packageJson.name !== OPENCODE_PLUGIN_NAME || typeof packageJson.version !== "string") {
|
|
40763
40797
|
return null;
|
|
40764
40798
|
}
|
|
@@ -40795,7 +40829,7 @@ function readFenceFromDist(packageDirectory) {
|
|
|
40795
40829
|
}
|
|
40796
40830
|
if (!entry.isFile() || !/\.(?:[cm]?js|ts)$/.test(entry.name))
|
|
40797
40831
|
continue;
|
|
40798
|
-
const fence = readFenceValue(
|
|
40832
|
+
const fence = readFenceValue(readFileSync20(path, "utf-8"));
|
|
40799
40833
|
if (fence !== null)
|
|
40800
40834
|
fenceValues.add(fence);
|
|
40801
40835
|
}
|
|
@@ -40964,13 +40998,13 @@ var init_opencode_plugin_schema_fence = __esm(async () => {
|
|
|
40964
40998
|
});
|
|
40965
40999
|
|
|
40966
41000
|
// src/commands/doctor-opencode-cache.ts
|
|
40967
|
-
import { existsSync as existsSync29, readFileSync as
|
|
41001
|
+
import { existsSync as existsSync29, readFileSync as readFileSync21, rmSync as rmSync7 } from "node:fs";
|
|
40968
41002
|
function readCachedPluginVersion(pluginCacheDir) {
|
|
40969
41003
|
try {
|
|
40970
41004
|
const installedPkgPath = getOpenCodePluginPackageJsonPath(pluginCacheDir);
|
|
40971
41005
|
if (!existsSync29(installedPkgPath))
|
|
40972
41006
|
return;
|
|
40973
|
-
const pkg = JSON.parse(
|
|
41007
|
+
const pkg = JSON.parse(readFileSync21(installedPkgPath, "utf-8"));
|
|
40974
41008
|
return typeof pkg.version === "string" ? pkg.version : undefined;
|
|
40975
41009
|
} catch {
|
|
40976
41010
|
return;
|
|
@@ -41334,7 +41368,7 @@ var init_doctor_prune_discovery = __esm(async () => {
|
|
|
41334
41368
|
|
|
41335
41369
|
// src/commands/doctor-storage-holders.ts
|
|
41336
41370
|
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
41337
|
-
import { readFileSync as
|
|
41371
|
+
import { readFileSync as readFileSync22, realpathSync as realpathSync7 } from "node:fs";
|
|
41338
41372
|
import { join as join23, resolve as resolve12 } from "node:path";
|
|
41339
41373
|
function canonicalStoragePath(path) {
|
|
41340
41374
|
try {
|
|
@@ -41362,7 +41396,7 @@ function processReferencesStorage(pid, storageDir) {
|
|
|
41362
41396
|
if (process.platform === "linux") {
|
|
41363
41397
|
for (const name of ["cmdline", "environ"]) {
|
|
41364
41398
|
try {
|
|
41365
|
-
texts.push(
|
|
41399
|
+
texts.push(readFileSync22(`/proc/${pid}/${name}`, "utf8"));
|
|
41366
41400
|
} catch {}
|
|
41367
41401
|
}
|
|
41368
41402
|
} else {
|
|
@@ -42724,11 +42758,22 @@ var init_storage_identity_merge = __esm(() => {
|
|
|
42724
42758
|
];
|
|
42725
42759
|
});
|
|
42726
42760
|
|
|
42761
|
+
// ../plugin/src/features/magic-context/memory/identity-merge-command.ts
|
|
42762
|
+
function shellArg(value, platform) {
|
|
42763
|
+
if (/^[\w.:/-]+$/.test(value))
|
|
42764
|
+
return value;
|
|
42765
|
+
return platform === "win32" ? `"${value}"` : `'${value.replaceAll("'", "'\\''")}'`;
|
|
42766
|
+
}
|
|
42767
|
+
function identityMergeCommand(from, to, platform = process.platform) {
|
|
42768
|
+
return `${IDENTITY_MERGE_COMMAND} --from ${shellArg(from, platform)} --to ${to ? shellArg(to, platform) : '"DESTINATION_IDENTITY"'}`;
|
|
42769
|
+
}
|
|
42770
|
+
var IDENTITY_MERGE_COMMAND = "npx @cortexkit/magic-context@latest doctor merge-identities", IDENTITY_MERGE_PREVIEW_HINT = "It shows what would move. Add --apply to move them.";
|
|
42771
|
+
|
|
42727
42772
|
// src/commands/doctor-identity-splits.ts
|
|
42728
42773
|
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
42729
42774
|
import { createHash as createHash6 } from "node:crypto";
|
|
42730
42775
|
import { existsSync as existsSync34, readdirSync as readdirSync7, realpathSync as realpathSync9, statSync as statSync19 } from "node:fs";
|
|
42731
|
-
import { dirname as dirname21, join as join27, resolve as resolve15 } from "node:path";
|
|
42776
|
+
import { dirname as dirname21, isAbsolute as isAbsolute9, join as join27, resolve as resolve15 } from "node:path";
|
|
42732
42777
|
function tableExists5(db, table) {
|
|
42733
42778
|
return !!db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table);
|
|
42734
42779
|
}
|
|
@@ -42756,6 +42801,39 @@ function orphanedPathReason(directory) {
|
|
|
42756
42801
|
return;
|
|
42757
42802
|
return "directory is empty and has no git metadata";
|
|
42758
42803
|
}
|
|
42804
|
+
function resolveReadOnly(directory) {
|
|
42805
|
+
if (!existsSync34(directory))
|
|
42806
|
+
return;
|
|
42807
|
+
try {
|
|
42808
|
+
const roots = execFileSync6("git", ["rev-list", "--max-parents=0", "HEAD"], {
|
|
42809
|
+
cwd: directory,
|
|
42810
|
+
windowsHide: true,
|
|
42811
|
+
encoding: "utf8",
|
|
42812
|
+
timeout: 5000,
|
|
42813
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
42814
|
+
}).trim().split(/\s+/).filter((root) => /^[0-9a-f]{40,64}$/.test(root)).sort();
|
|
42815
|
+
if (roots[0])
|
|
42816
|
+
return `git:${roots[0]}`;
|
|
42817
|
+
} catch {}
|
|
42818
|
+
try {
|
|
42819
|
+
const result = execFileSync6("git", ["rev-parse", "--is-inside-work-tree"], {
|
|
42820
|
+
cwd: directory,
|
|
42821
|
+
windowsHide: true,
|
|
42822
|
+
encoding: "utf8",
|
|
42823
|
+
timeout: 5000,
|
|
42824
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
42825
|
+
});
|
|
42826
|
+
if (result.trim() === "true")
|
|
42827
|
+
return;
|
|
42828
|
+
} catch (error) {
|
|
42829
|
+
if (String(error.stderr).includes("not a git repository"))
|
|
42830
|
+
return `dir:${createHash6("md5").update(projectDirectoryKey(directory)).digest("hex").slice(0, 12)}`;
|
|
42831
|
+
}
|
|
42832
|
+
return;
|
|
42833
|
+
}
|
|
42834
|
+
function canonicalIdentity(directory, storageDir) {
|
|
42835
|
+
return readRememberedGitIdentity(directory, storageDir) ?? (orphanedPathReason(directory) ? undefined : resolveReadOnly(directory));
|
|
42836
|
+
}
|
|
42759
42837
|
function findIdentitySplits(db, host, includeSingles = false) {
|
|
42760
42838
|
if (!tableExists5(db, "session_projects"))
|
|
42761
42839
|
return [];
|
|
@@ -42821,7 +42899,7 @@ function findIdentitySplits(db, host, includeSingles = false) {
|
|
|
42821
42899
|
const gitIdentities = new Map;
|
|
42822
42900
|
for (const [directoryKey, spellings] of directorySpellings) {
|
|
42823
42901
|
for (const directory of spellings) {
|
|
42824
|
-
const dirIdentity =
|
|
42902
|
+
const dirIdentity = directoryFallback(directory);
|
|
42825
42903
|
const hasData = [
|
|
42826
42904
|
"memories",
|
|
42827
42905
|
"notes",
|
|
@@ -42881,7 +42959,7 @@ function formatIdentitySplits(splits) {
|
|
|
42881
42959
|
...identityLines(split)
|
|
42882
42960
|
] : [
|
|
42883
42961
|
`Project identity split: ${split.directory} (read-only; no merge performed)`,
|
|
42884
|
-
|
|
42962
|
+
` Review with ${IDENTITY_MERGE_COMMAND} before choosing which identity to keep.`,
|
|
42885
42963
|
...identityLines(split)
|
|
42886
42964
|
];
|
|
42887
42965
|
});
|
|
@@ -42889,8 +42967,82 @@ function formatIdentitySplits(splits) {
|
|
|
42889
42967
|
function identityLines(split) {
|
|
42890
42968
|
return split.identities.map((row) => ` ${row.identity}: ${row.sessions} sessions, ${row.memories} memories, ${row.notes} notes, ${row.dreamer} dreamer rows (identity-wide counts)`);
|
|
42891
42969
|
}
|
|
42970
|
+
function eventDirectory(data, sessionId) {
|
|
42971
|
+
try {
|
|
42972
|
+
const event = JSON.parse(data);
|
|
42973
|
+
const directory = event?.location?.directory;
|
|
42974
|
+
if (event?.sessionID === sessionId && typeof directory === "string" && isAbsolute9(directory))
|
|
42975
|
+
return directory;
|
|
42976
|
+
} catch {}
|
|
42977
|
+
}
|
|
42978
|
+
function readSessionMoves(host) {
|
|
42979
|
+
if (!host || !tableExists5(host, "session_v2") || !tableExists5(host, "event"))
|
|
42980
|
+
return [];
|
|
42981
|
+
try {
|
|
42982
|
+
return host.prepare(`SELECT s.id, s.directory, c.data AS initial, m.data AS latest
|
|
42983
|
+
FROM session_v2 AS s
|
|
42984
|
+
JOIN event AS c ON c.aggregate_id = s.id AND c.seq = 0 AND c.type = 'session.created.1'
|
|
42985
|
+
JOIN event AS m ON m.aggregate_id = s.id AND m.seq = (
|
|
42986
|
+
SELECT MAX(seq) FROM event WHERE aggregate_id = s.id AND type GLOB 'session.moved.*'
|
|
42987
|
+
) AND m.type = 'session.moved.1' AND m.seq > c.seq`).all();
|
|
42988
|
+
} catch {
|
|
42989
|
+
return [];
|
|
42990
|
+
}
|
|
42991
|
+
}
|
|
42992
|
+
function formatStrandedDirectoryMemories(db, host, storageDir, splits) {
|
|
42993
|
+
if (!tableExists5(db, "memories") || !tableExists5(db, "session_projects"))
|
|
42994
|
+
return [];
|
|
42995
|
+
const seen = new Set(splits.flatMap(({ identities }) => identities.map(({ identity }) => identity)));
|
|
42996
|
+
const stranded = db.prepare(`SELECT m.project_path AS identity, COUNT(*) AS memories,
|
|
42997
|
+
MAX(MAX(m.last_seen_at, COALESCE(m.last_retrieved_at, 0))) AS lastUse
|
|
42998
|
+
FROM memories AS m WHERE m.project_path GLOB 'dir:*'
|
|
42999
|
+
AND NOT EXISTS (SELECT 1 FROM session_projects AS sp WHERE sp.project_path = m.project_path)
|
|
43000
|
+
GROUP BY m.project_path ORDER BY m.project_path`).all().filter(({ identity }) => !seen.has(identity));
|
|
43001
|
+
if (stranded.length === 0)
|
|
43002
|
+
return [];
|
|
43003
|
+
const keys = new Set(stranded.map(({ identity }) => identity));
|
|
43004
|
+
const binding = db.prepare("SELECT project_path FROM session_projects WHERE session_id = ? AND harness = 'opencode2'");
|
|
43005
|
+
const canonicalKeys = new Map;
|
|
43006
|
+
const sourceFolders = new Map;
|
|
43007
|
+
const destinations = new Map;
|
|
43008
|
+
for (const row of readSessionMoves(host)) {
|
|
43009
|
+
const source = eventDirectory(row.initial, row.id);
|
|
43010
|
+
if (!source)
|
|
43011
|
+
continue;
|
|
43012
|
+
const from = directoryFallback(source);
|
|
43013
|
+
if (!keys.has(from))
|
|
43014
|
+
continue;
|
|
43015
|
+
const latest = eventDirectory(row.latest, row.id);
|
|
43016
|
+
if (source === row.directory)
|
|
43017
|
+
continue;
|
|
43018
|
+
sourceFolders.set(from, source);
|
|
43019
|
+
const current = binding.get(row.id);
|
|
43020
|
+
if (latest === row.directory && current && !canonicalKeys.has(row.directory)) {
|
|
43021
|
+
canonicalKeys.set(row.directory, canonicalIdentity(row.directory, storageDir));
|
|
43022
|
+
}
|
|
43023
|
+
const resolved = canonicalKeys.get(row.directory);
|
|
43024
|
+
const target = latest === row.directory && current?.project_path === resolved ? resolved : undefined;
|
|
43025
|
+
const choices = destinations.get(from) ?? new Set;
|
|
43026
|
+
choices.add(target);
|
|
43027
|
+
destinations.set(from, choices);
|
|
43028
|
+
}
|
|
43029
|
+
return stranded.flatMap(({ identity, memories, lastUse }) => {
|
|
43030
|
+
const time = new Date(lastUse);
|
|
43031
|
+
const when = lastUse > 0 && Number.isFinite(time.getTime()) ? time.toISOString() : "unknown";
|
|
43032
|
+
const choices = destinations.get(identity);
|
|
43033
|
+
const target = choices?.size === 1 ? [...choices][0] : undefined;
|
|
43034
|
+
const from = sourceFolders.get(identity) ?? identity;
|
|
43035
|
+
return [
|
|
43036
|
+
`Memories left under folder key ${identity}: ${memories} ${memories === 1 ? "memory" : "memories"}; last used ${when}. No session is currently recorded for this key.`,
|
|
43037
|
+
target ? " Review a merge into the session's current project:" : " The destination can't be determined. If you choose one, replace DESTINATION_IDENTITY in:",
|
|
43038
|
+
` ${identityMergeCommand(from, target)}`,
|
|
43039
|
+
` ${IDENTITY_MERGE_PREVIEW_HINT}`
|
|
43040
|
+
];
|
|
43041
|
+
});
|
|
43042
|
+
}
|
|
42892
43043
|
function diagnoseIdentitySplits() {
|
|
42893
|
-
const
|
|
43044
|
+
const storageDir = getMagicContextStorageDir();
|
|
43045
|
+
const db = openExistingContextDatabase(join27(storageDir, "context.db"), {
|
|
42894
43046
|
readonly: true
|
|
42895
43047
|
});
|
|
42896
43048
|
if (!db)
|
|
@@ -42898,15 +43050,18 @@ function diagnoseIdentitySplits() {
|
|
|
42898
43050
|
let host = null;
|
|
42899
43051
|
try {
|
|
42900
43052
|
host = openExistingDatabase(resolveOpenCodeDbPath().path, { readonly: true });
|
|
42901
|
-
|
|
42902
|
-
|
|
42903
|
-
|
|
43053
|
+
const splits = host ? findIdentitySplits(db, host) : [];
|
|
43054
|
+
return [
|
|
43055
|
+
...host ? formatIdentitySplits(splits) : ["Identity split check skipped: OpenCode session directories unavailable."],
|
|
43056
|
+
...formatStrandedDirectoryMemories(db, host, storageDir, splits)
|
|
43057
|
+
];
|
|
42904
43058
|
} finally {
|
|
42905
43059
|
host?.close();
|
|
42906
43060
|
db.close();
|
|
42907
43061
|
}
|
|
42908
43062
|
}
|
|
42909
43063
|
var init_doctor_identity_splits = __esm(async () => {
|
|
43064
|
+
init_project_identity();
|
|
42910
43065
|
init_project_identity_cache();
|
|
42911
43066
|
init_data_path();
|
|
42912
43067
|
init_opencode_db_path();
|
|
@@ -42914,9 +43069,8 @@ var init_doctor_identity_splits = __esm(async () => {
|
|
|
42914
43069
|
});
|
|
42915
43070
|
|
|
42916
43071
|
// src/commands/doctor-merge-identity.ts
|
|
42917
|
-
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
42918
43072
|
import { createHash as createHash7 } from "node:crypto";
|
|
42919
|
-
import { existsSync as existsSync35, mkdtempSync as mkdtempSync2, readdirSync as readdirSync8, readFileSync as
|
|
43073
|
+
import { existsSync as existsSync35, mkdtempSync as mkdtempSync2, readdirSync as readdirSync8, readFileSync as readFileSync23, statSync as statSync20 } from "node:fs";
|
|
42920
43074
|
import { dirname as dirname22, join as join28, resolve as resolve16 } from "node:path";
|
|
42921
43075
|
function parseMergeIdentityArgs(args) {
|
|
42922
43076
|
const values = {};
|
|
@@ -42966,39 +43120,6 @@ function printReport(report) {
|
|
|
42966
43120
|
if (report.dryRun)
|
|
42967
43121
|
console.log(" No writes. Review this preview, then repeat with --apply to confirm.");
|
|
42968
43122
|
}
|
|
42969
|
-
function resolveReadOnly(directory) {
|
|
42970
|
-
if (!existsSync35(directory))
|
|
42971
|
-
return;
|
|
42972
|
-
try {
|
|
42973
|
-
const roots = execFileSync7("git", ["rev-list", "--max-parents=0", "HEAD"], {
|
|
42974
|
-
cwd: directory,
|
|
42975
|
-
windowsHide: true,
|
|
42976
|
-
encoding: "utf8",
|
|
42977
|
-
timeout: 5000,
|
|
42978
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
42979
|
-
}).trim().split(/\s+/).filter((root) => /^[0-9a-f]{40,64}$/.test(root)).sort();
|
|
42980
|
-
if (roots[0])
|
|
42981
|
-
return `git:${roots[0]}`;
|
|
42982
|
-
} catch {}
|
|
42983
|
-
try {
|
|
42984
|
-
const result = execFileSync7("git", ["rev-parse", "--is-inside-work-tree"], {
|
|
42985
|
-
cwd: directory,
|
|
42986
|
-
windowsHide: true,
|
|
42987
|
-
encoding: "utf8",
|
|
42988
|
-
timeout: 5000,
|
|
42989
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
42990
|
-
});
|
|
42991
|
-
if (result.trim() === "true")
|
|
42992
|
-
return;
|
|
42993
|
-
} catch (error) {
|
|
42994
|
-
if (String(error.stderr).includes("not a git repository"))
|
|
42995
|
-
return `dir:${createHash7("md5").update(projectDirectoryKey(directory)).digest("hex").slice(0, 12)}`;
|
|
42996
|
-
}
|
|
42997
|
-
return;
|
|
42998
|
-
}
|
|
42999
|
-
function canonicalIdentity(directory, storageDir) {
|
|
43000
|
-
return readRememberedGitIdentity(directory, storageDir) ?? (orphanedPathReason(directory) ? undefined : resolveReadOnly(directory));
|
|
43001
|
-
}
|
|
43002
43123
|
function directoryDoesNotExist(directory) {
|
|
43003
43124
|
try {
|
|
43004
43125
|
statSync20(directory);
|
|
@@ -43129,7 +43250,7 @@ function observations(db, hostPath, storageDir) {
|
|
|
43129
43250
|
if (!file.endsWith(".json"))
|
|
43130
43251
|
continue;
|
|
43131
43252
|
try {
|
|
43132
|
-
const record = JSON.parse(
|
|
43253
|
+
const record = JSON.parse(readFileSync23(join28(sidecars, file), "utf8"));
|
|
43133
43254
|
if (typeof record.directory === "string" && typeof record.identity === "string")
|
|
43134
43255
|
add(record.directory, record.identity);
|
|
43135
43256
|
} catch {}
|
|
@@ -43140,6 +43261,9 @@ function observations(db, hostPath, storageDir) {
|
|
|
43140
43261
|
}
|
|
43141
43262
|
function runMergeIdentityCli(args, deps = {}) {
|
|
43142
43263
|
const options = parseMergeIdentityArgs(args);
|
|
43264
|
+
if (options.from && !/^(git|dir):/.test(options.from)) {
|
|
43265
|
+
options.from = directoryFallback(options.from);
|
|
43266
|
+
}
|
|
43143
43267
|
const dbPath = options.dbPath ?? join28(getMagicContextStorageDir(), "context.db");
|
|
43144
43268
|
const storageDir = dirname22(dbPath);
|
|
43145
43269
|
const hostPath = options.hostPath ?? (options.dbPath ? join28(storageDir, "host.db") : resolveOpenCodeDbPath().path);
|
|
@@ -43210,7 +43334,7 @@ function runMergeIdentityCli(args, deps = {}) {
|
|
|
43210
43334
|
ensureStorageDirectorySync(sidecarBackup, true);
|
|
43211
43335
|
let backupBytes = 0;
|
|
43212
43336
|
for (const entry of sidecarEntries) {
|
|
43213
|
-
const content =
|
|
43337
|
+
const content = readFileSync23(join28(sidecarRoot, entry));
|
|
43214
43338
|
writeStorageFileAtomicSync(join28(sidecarBackup, entry), content, true);
|
|
43215
43339
|
backupBytes += content.byteLength;
|
|
43216
43340
|
}
|
|
@@ -46182,6 +46306,11 @@ var init_user_facing_codes = __esm(() => {
|
|
|
46182
46306
|
sentence: "History compression is paused because this session's saved summaries no longer line up with its messages.",
|
|
46183
46307
|
action: "Run /ctx-recomp to rebuild them."
|
|
46184
46308
|
},
|
|
46309
|
+
fork_history_gap: {
|
|
46310
|
+
code: "MC-H09",
|
|
46311
|
+
sentence: "This fork's saved history has a gap.",
|
|
46312
|
+
action: "Run /ctx-recomp to rebuild its history."
|
|
46313
|
+
},
|
|
46185
46314
|
history_boundary_unresolved: {
|
|
46186
46315
|
code: "MC-H04",
|
|
46187
46316
|
sentence: "This request was not sent: it is larger than the model's context window, and Magic Context could not cut the already-summarized history out of it.",
|
|
@@ -48322,7 +48451,7 @@ var DATABASE_REPAIR_COMMAND = "bunx @cortexkit/magic-context@latest doctor repai
|
|
|
48322
48451
|
|
|
48323
48452
|
// src/lib/github-issue.ts
|
|
48324
48453
|
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
48325
|
-
import { readFileSync as
|
|
48454
|
+
import { readFileSync as readFileSync24 } from "node:fs";
|
|
48326
48455
|
function runGhCommand(args) {
|
|
48327
48456
|
try {
|
|
48328
48457
|
const result = spawnSync7("gh", args, {
|
|
@@ -48349,7 +48478,7 @@ function failed(result) {
|
|
|
48349
48478
|
function submitGithubIssue(title, bodyPath, runner = runGhCommand) {
|
|
48350
48479
|
let body;
|
|
48351
48480
|
try {
|
|
48352
|
-
body =
|
|
48481
|
+
body = readFileSync24(bodyPath, "utf-8");
|
|
48353
48482
|
} catch (error) {
|
|
48354
48483
|
return {
|
|
48355
48484
|
ok: false,
|
|
@@ -49224,6 +49353,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49224
49353
|
"ERROR [tail-hygiene-last-writer-check-failed]: structural production guard failed open: \x01",
|
|
49225
49354
|
"historian: refreshed stale protected-tail snapshot at run time (was: \x01) — eligible head \x01-\x01",
|
|
49226
49355
|
"mc-module: historian firing for \x01: await_timeout_ms=\x01 attempt_budget_ms=\x01 firing_budget_ms=\x01\x020s",
|
|
49356
|
+
"This session changed projects. \x01 memories stayed with the old project (\x01); nothing moved. \x01\x021p",
|
|
49227
49357
|
"v2 context omitted a content part the host would reject: type=<missing> message=\x01 reason=\x01",
|
|
49228
49358
|
"v2 refusal: interrupting the turn before the provider request arm=compaction-fold cause=\x01",
|
|
49229
49359
|
"[magic-context] host overflow check: using isContextOverflow from @earendil-works/pi-ai",
|
|
@@ -49250,6 +49380,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49250
49380
|
"compaction-marker drain: retryable failure; preserving deferred history refresh signal \x01",
|
|
49251
49381
|
"LKG SNAPSHOT PREPARATION FAILED; forcing synchronous capture on the next applied pass: \x01",
|
|
49252
49382
|
"mc-module: execute_threshold channel=\x01 model=\x01 configured=\x01 provenance=\x01 effective=\x01 source=\x01",
|
|
49383
|
+
"This session changed projects. \x01 memories stayed with the old folder (\x01); nothing moved. \x01\x021p",
|
|
49253
49384
|
"compaction-marker drain: retryable failure; preserving deferred history refresh signal",
|
|
49254
49385
|
"event message.removed: cleared compaction marker (boundary or summary message removed)",
|
|
49255
49386
|
"LKG SNAPSHOT PREPARATION FAILED; forcing synchronous capture on the next applied pass:",
|
|
@@ -49270,6 +49401,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49270
49401
|
"[magic-context] host stall profiler: \x01ms main-thread stall, \x01 samples, top owner none → \x01\x022p",
|
|
49271
49402
|
"historian publish stage: stage=post-publish-drops status=started elapsed=0.0ms range=\x01-\x01",
|
|
49272
49403
|
"mc-request-byte-cap refused bytes=\x01 cap=\x01 method=\x01 kind=\x01 session=\x01 page_index=\x01 page_total=\x01",
|
|
49404
|
+
"This session changed projects. \x01 memory stayed with the old project (\x01); nothing moved. \x01\x021p",
|
|
49273
49405
|
"latest-turn thinking recovery: refused locally (the recovery state could not be read)",
|
|
49274
49406
|
"rust compaction-marker drain: candidate preparation deferred; pending target retained",
|
|
49275
49407
|
"served check: record dropped reason=session_cleared; the next request is not compared",
|
|
@@ -49286,6 +49418,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49286
49418
|
"[magic-context] tool-owner backfill failed (continuing with lazy adoption fallback): \x01",
|
|
49287
49419
|
"historian publish stage: stage=post-publish-drops status=completed elapsed=\x01ms range=\x01-\x01",
|
|
49288
49420
|
"raw_fallback_over_context_limit estimated=\x01 trusted=\x01 proxy_bytes=\x01 proxy_tokens=\x01 limit=\x01",
|
|
49421
|
+
"This session changed projects. \x01 memory stayed with the old folder (\x01); nothing moved. \x01\x021p",
|
|
49289
49422
|
"transform refused degraded pass site=host-instruction-retention-persistence-failure: \x01",
|
|
49290
49423
|
"transform: emergency fail-closed abort failed; refusing to return a sendable prompt: \x01",
|
|
49291
49424
|
"v2 refusal: interrupting the turn before the provider request arm=storage-busy cause=\x01",
|
|
@@ -49473,6 +49606,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49473
49606
|
"pass permission report failed after the request was decided; serving the pass:",
|
|
49474
49607
|
"system-prompt-hash skipped (OpenCode internal agent: title/summary/compaction)",
|
|
49475
49608
|
"thinking binding recovery: persistence failed; leaving the bound blocks intact",
|
|
49609
|
+
"v2 compaction hook: fired answered=true source=typescript_fallback row=running",
|
|
49476
49610
|
"v2 refusal: interrupting the turn before the provider request arm=storage-busy",
|
|
49477
49611
|
"WARN: [auto-update-checker] Failed to fetch latest version for channel: latest",
|
|
49478
49612
|
'Pi subagent agent "\x01" has no strict tool allow-list; forcing an empty tool list',
|
|
@@ -49557,6 +49691,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49557
49691
|
"Pi publication commit_failed reason=capture_failed; serving managed context",
|
|
49558
49692
|
"transform refused degraded pass site=reasoning-removal-persistence-failure:",
|
|
49559
49693
|
"transform: historian unavailable; clearing stale compartmentInProgress flag",
|
|
49694
|
+
"v2 compaction hook: fired answered=true source=typescript_fallback row=none",
|
|
49560
49695
|
"mc-module: finished \x01 pending context.db write(s) left by an earlier process",
|
|
49561
49696
|
"prompt_surface.guidance_override_path (\x01) is empty; using built-in guidance.\x020p",
|
|
49562
49697
|
"request tools changed (kind=\x01, model=\x01, schemas \x01→\x01): releasing signed thinking\x021m",
|
|
@@ -49769,6 +49904,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49769
49904
|
"transform refused degraded pass site=compaction-marker-drain-failure:",
|
|
49770
49905
|
"transform refused degraded pass site=store-generation-rebase-failure:",
|
|
49771
49906
|
"transform: recovery chain stops: the next historian run did not start",
|
|
49907
|
+
"v2 compaction hook: fired answered=true source=typescript row=running",
|
|
49772
49908
|
"v95 temporal metadata: malformed JSON skipped; original blob retained",
|
|
49773
49909
|
"v95 temporal metadata: non-array JSON skipped; original blob retained",
|
|
49774
49910
|
"prompt_surface.tool_descriptions.\x01 is empty; the override was ignored.",
|
|
@@ -49865,7 +50001,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49865
50001
|
"historian no-op: waiting for new history after no forward progress",
|
|
49866
50002
|
"transform refused degraded pass site=stale-reduce-strip-exception:",
|
|
49867
50003
|
"transform: recovery chain stops: the request could not be counted:",
|
|
49868
|
-
"v2 compaction hook: fired answered=true source=
|
|
50004
|
+
"v2 compaction hook: fired answered=true source=typescript row=none",
|
|
49869
50005
|
"v2 response ownership unavailable; keeping system identity pending",
|
|
49870
50006
|
"[git-commits] sweep parked for \x01: directory identity has no commits",
|
|
49871
50007
|
"[dreamer] domain lease lost (memory:\x01) — stopping remaining task(s)",
|
|
@@ -49901,6 +50037,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49901
50037
|
"transform refused degraded pass site=m0-m1-injection-degradation:",
|
|
49902
50038
|
"transform refused degraded pass site=overflow-state-read-failure:",
|
|
49903
50039
|
"transform refused degraded pass site=tagging-persistence-failure:",
|
|
50040
|
+
"v2 compaction hook: fired answered=true source=module row=running",
|
|
49904
50041
|
"heartbeat for \x01 refused: malformed_response; abandoning this claim",
|
|
49905
50042
|
"injected \x01 facts + \x01 memories into message[0] (no compartments yet)",
|
|
49906
50043
|
"v2 fork inheritance: fork of \x01 already has state; not copied again\x020s",
|
|
@@ -49916,6 +50053,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49916
50053
|
"[mc-module][\x01] historian oversize admission refused before spawn: \x01",
|
|
49917
50054
|
"compaction-marker drain: applied at ordinal \x01, boundary user msg \x01 \x01\x021i",
|
|
49918
50055
|
"mc_rust_emergency_refusal frozen_over_proven_limit module=\x01 limit=\x01",
|
|
50056
|
+
"project binding changed harness=\x01 cwd=\x01 old=\x01 new=\x01 memories=\x01 notice=\x01\x021p",
|
|
49919
50057
|
"recovery projection: case=conversation_only released=\x01 normalized=\x01",
|
|
49920
50058
|
"rust input coverage: oc_input=\x01 marker_at=\x01 covered=\x01 first_ordinal=\x01",
|
|
49921
50059
|
"rust parked health probe failed; refusing without a full request \x01",
|
|
@@ -49989,6 +50127,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49989
50127
|
"mc-module: lineage descent pending build-skew for target \x01 edge \x01",
|
|
49990
50128
|
"native reasoning activation failed; retaining previous replay: \x01",
|
|
49991
50129
|
"placeholder strip: removed=\x01 discovered=\x01 pruned=\x01 keptToolOwners=\x01",
|
|
50130
|
+
"project binding write failed harness=opencode cwd=\x01 attempted=\x01: \x01\x021p",
|
|
49992
50131
|
"project binding write failed harness=opencode cwd=\x01 attempted=\x01: \x01",
|
|
49993
50132
|
"project binding write recovered harness=opencode cwd=\x01 identity=\x01",
|
|
49994
50133
|
"Subagent temperature omitted for \x01: host model metadata says no \x01\x020m",
|
|
@@ -50006,6 +50145,8 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
50006
50145
|
"system delivery acknowledgement failed (keeping pending work):",
|
|
50007
50146
|
"transform: cannot force-start compartment agent without client",
|
|
50008
50147
|
"transform: injected memories/facts block (no compartments yet)",
|
|
50148
|
+
"v2 compaction hook: fired answered=true source=module row=none",
|
|
50149
|
+
"v2 fork saved history has a gap; /ctx-recomp repairs this fork",
|
|
50009
50150
|
'invalid cache_ttl "\x01" in ctx-status; falling back to default 5m',
|
|
50010
50151
|
"v2 boundary trim: dropped \x01 messages before the module boundary",
|
|
50011
50152
|
"Subagent temperature sent for \x01: no host or models.dev metadata\x020m",
|
|
@@ -50183,7 +50324,6 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
50183
50324
|
"recomp skipped: compartment lease held by another process",
|
|
50184
50325
|
"rust transform wire invariant failed; LKG replay required",
|
|
50185
50326
|
"transform: compartmentInProgress flag set, starting agent",
|
|
50186
|
-
"v2 compaction hook: fired answered=true source=typescript",
|
|
50187
50327
|
"wrapup: timed out waiting for the compartment-state lease",
|
|
50188
50328
|
"[migrations] v12 cleaned \x01 orphan memory_embeddings row(s)",
|
|
50189
50329
|
"\x01: prompt unsettled — session \x01 left to the age-gated sweep\x021s",
|
|
@@ -50205,6 +50345,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
50205
50345
|
"models-dev-cache: output reserve capped at 25% for \x01/\x01: \x01 → \x01\x020m,1m",
|
|
50206
50346
|
"native tag replay unavailable; retaining native history: \x01",
|
|
50207
50347
|
"post-transform snapshot failed; using independent reads: \x01",
|
|
50348
|
+
"project binding changed harness=\x01 cwd=\x01 old=\x01 new=\x01 memories=\x01\x021p",
|
|
50208
50349
|
"system prompt date refresh failed (keeping frozen date): \x01",
|
|
50209
50350
|
"system prompt token estimate failed (using prior count): \x01",
|
|
50210
50351
|
"transform tag persistence failed; not serving this pass: \x01",
|
|
@@ -50278,7 +50419,6 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
50278
50419
|
"event message.removed: pruned auto-search decision for \x01\x020i",
|
|
50279
50420
|
"event session.compacted pending-marker cleanup failed: \x01",
|
|
50280
50421
|
"mc-module: native reasoning replay proof not recorded: \x01",
|
|
50281
|
-
"project binding changed harness=opencode cwd=\x01 old=\x01 new=\x01\x021p,2p",
|
|
50282
50422
|
"reasoning cleanup: cleared=\x01 inlineStripped=\x01 watermark=\x01→\x01",
|
|
50283
50423
|
"WARN: message_end: synthetic todowrite capture failed: \x01",
|
|
50284
50424
|
"[dreamer] retrospective: no reply-following user lines",
|
|
@@ -50335,7 +50475,6 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
50335
50475
|
"LKG snapshot slices failed verification; slot cleared",
|
|
50336
50476
|
"protected-tail migration seed fell back to ordinal 1:",
|
|
50337
50477
|
"registered context handler (tagging + drops + nudges)",
|
|
50338
|
-
"v2 compaction hook: fired answered=true source=module",
|
|
50339
50478
|
"WARN: message_end: persist session_meta usage failed:",
|
|
50340
50479
|
"[\x01] primary: model not found, retrying with suggestion",
|
|
50341
50480
|
"injected \x01 facts into message[0] (no compartments yet)",
|
|
@@ -51099,6 +51238,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
51099
51238
|
"lkg_frozen_replay_released reason=\x01",
|
|
51100
51239
|
"reasoning replay: cleared=\x01 inline=\x01",
|
|
51101
51240
|
"subagent token accounting failed: \x01",
|
|
51241
|
+
"v2 fork skipped compartment \x01 (\x01-\x01): \x01",
|
|
51102
51242
|
"v2 model-limit cache warm failed: \x01",
|
|
51103
51243
|
"wrapup no-op: boundaryDiagnostics=\x01",
|
|
51104
51244
|
"current-compaction-id-unavailable",
|
|
@@ -51332,6 +51472,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
51332
51472
|
"pp.setupAndOperations",
|
|
51333
51473
|
"pp.todoPermissionRead",
|
|
51334
51474
|
"preemptive-compaction",
|
|
51475
|
+
"projectBindingWarning",
|
|
51335
51476
|
"refusal notice failed",
|
|
51336
51477
|
"served check skipped:",
|
|
51337
51478
|
"stableIdSchemePersist",
|
|
@@ -51571,7 +51712,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
51571
51712
|
});
|
|
51572
51713
|
|
|
51573
51714
|
// src/lib/log-lines.ts
|
|
51574
|
-
import { existsSync as existsSync40, readFileSync as
|
|
51715
|
+
import { existsSync as existsSync40, readFileSync as readFileSync25, statSync as statSync22 } from "node:fs";
|
|
51575
51716
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
51576
51717
|
import { join as join33 } from "node:path";
|
|
51577
51718
|
function tokenize(input, limit = Number.POSITIVE_INFINITY) {
|
|
@@ -51872,7 +52013,7 @@ function inspectLogFile(path) {
|
|
|
51872
52013
|
return { path, exists: false, sizeKb: 0, lineCount: 0, grammar: "unknown" };
|
|
51873
52014
|
}
|
|
51874
52015
|
try {
|
|
51875
|
-
const content =
|
|
52016
|
+
const content = readFileSync25(path, "utf8");
|
|
51876
52017
|
const lines = content.split(/\r?\n/).filter((line) => line.length > 0);
|
|
51877
52018
|
const grammars = new Set(lines.flatMap((line) => {
|
|
51878
52019
|
const parsed = parseLogLine(line);
|
|
@@ -51899,7 +52040,7 @@ function readLogLines(files) {
|
|
|
51899
52040
|
return [];
|
|
51900
52041
|
try {
|
|
51901
52042
|
let precedingTimestamp = "";
|
|
51902
|
-
return
|
|
52043
|
+
return readFileSync25(file.path, "utf8").split(/\r?\n/).filter((line) => line.length > 0).map((line, lineIndex) => {
|
|
51903
52044
|
precedingTimestamp = parseLogLine(line)?.ts ?? precedingTimestamp;
|
|
51904
52045
|
return { line, timestamp: precedingTimestamp, fileIndex, lineIndex };
|
|
51905
52046
|
});
|
|
@@ -52508,7 +52649,7 @@ var init_issue_body = __esm(() => {
|
|
|
52508
52649
|
});
|
|
52509
52650
|
|
|
52510
52651
|
// src/lib/omp-hide-secrets.ts
|
|
52511
|
-
import { existsSync as existsSync41, readdirSync as readdirSync9, readFileSync as
|
|
52652
|
+
import { existsSync as existsSync41, readdirSync as readdirSync9, readFileSync as readFileSync26, statSync as statSync23 } from "node:fs";
|
|
52512
52653
|
import { join as join34, resolve as resolve18 } from "node:path";
|
|
52513
52654
|
function stripYamlComment(line) {
|
|
52514
52655
|
let quote = null;
|
|
@@ -52632,7 +52773,7 @@ function readHideSecretsFromJson(text) {
|
|
|
52632
52773
|
function readSource(layer, path, format) {
|
|
52633
52774
|
let text;
|
|
52634
52775
|
try {
|
|
52635
|
-
text =
|
|
52776
|
+
text = readFileSync26(path, "utf-8");
|
|
52636
52777
|
} catch (error) {
|
|
52637
52778
|
const code = error.code;
|
|
52638
52779
|
return {
|
|
@@ -52732,10 +52873,10 @@ var init_omp_hide_secrets = __esm(() => {
|
|
|
52732
52873
|
});
|
|
52733
52874
|
|
|
52734
52875
|
// src/commands/doctor-omp.ts
|
|
52735
|
-
import { execFileSync as
|
|
52736
|
-
import { existsSync as existsSync42, readFileSync as
|
|
52876
|
+
import { execFileSync as execFileSync7, spawnSync as spawnSync8 } from "node:child_process";
|
|
52877
|
+
import { existsSync as existsSync42, readFileSync as readFileSync27 } from "node:fs";
|
|
52737
52878
|
import { createRequire as createRequire3 } from "node:module";
|
|
52738
|
-
import { isAbsolute as
|
|
52879
|
+
import { isAbsolute as isAbsolute10, join as join35, resolve as resolve19 } from "node:path";
|
|
52739
52880
|
function parseSemver(value) {
|
|
52740
52881
|
const match = value?.match(/(\d+)\.(\d+)\.(\d+)/);
|
|
52741
52882
|
return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
|
|
@@ -52780,7 +52921,7 @@ function readConfig2(path) {
|
|
|
52780
52921
|
if (!existsSync42(path))
|
|
52781
52922
|
return {};
|
|
52782
52923
|
try {
|
|
52783
|
-
const parsed = import_comment_json8.parse(
|
|
52924
|
+
const parsed = import_comment_json8.parse(readFileSync27(path, "utf-8"));
|
|
52784
52925
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? {} : { error: "top level is not an object" };
|
|
52785
52926
|
} catch (error) {
|
|
52786
52927
|
return { error: error instanceof Error ? error.message : String(error) };
|
|
@@ -52790,7 +52931,7 @@ function pluginDeclaresOmp(path) {
|
|
|
52790
52931
|
if (!path)
|
|
52791
52932
|
return null;
|
|
52792
52933
|
try {
|
|
52793
|
-
const pkg = JSON.parse(
|
|
52934
|
+
const pkg = JSON.parse(readFileSync27(join35(path, "package.json"), "utf-8"));
|
|
52794
52935
|
return Array.isArray(pkg.omp?.extensions) || Array.isArray(pkg.pi?.extensions);
|
|
52795
52936
|
} catch {
|
|
52796
52937
|
return null;
|
|
@@ -53079,7 +53220,7 @@ function runGhCommandWithDeps(deps, args) {
|
|
|
53079
53220
|
async function runIssueFlow(options) {
|
|
53080
53221
|
if (options.reportPath) {
|
|
53081
53222
|
const report = await runHealthChecks({ ...options, quiet: true });
|
|
53082
|
-
const path =
|
|
53223
|
+
const path = isAbsolute10(options.reportPath) ? options.reportPath : join35(options.cwd, options.reportPath);
|
|
53083
53224
|
const bundle = writeOmpIssueReport(path, ompIssueBody("Generated non-interactively by `doctor --issue --report`.", report, readLogLines(report.logFiles), null, options.cwd));
|
|
53084
53225
|
options.prompts.log.success(bundle.fullPath ? `Sanitized report written to ${bundle.path}; full report at ${bundle.fullPath}` : `Sanitized report written to ${bundle.path}`);
|
|
53085
53226
|
return 0;
|
|
@@ -53182,7 +53323,7 @@ var init_doctor_omp = __esm(async () => {
|
|
|
53182
53323
|
openExistingContextDatabase,
|
|
53183
53324
|
now: () => new Date,
|
|
53184
53325
|
inspectMagicContextLogs,
|
|
53185
|
-
execFileSync:
|
|
53326
|
+
execFileSync: execFileSync7,
|
|
53186
53327
|
spawnSync: spawnSync8
|
|
53187
53328
|
};
|
|
53188
53329
|
});
|
|
@@ -54092,12 +54233,12 @@ function listShadowBackfillStalls(db, projectIdentity) {
|
|
|
54092
54233
|
var SHADOW_BACKFILL_PROVENANCE_KEY = "_magicContextShadowBackfill";
|
|
54093
54234
|
|
|
54094
54235
|
// ../plugin/src/shared/auto-update-provenance.ts
|
|
54095
|
-
import { existsSync as existsSync43, readFileSync as
|
|
54236
|
+
import { existsSync as existsSync43, readFileSync as readFileSync28 } from "node:fs";
|
|
54096
54237
|
function readAutoUpdateCheckState(path) {
|
|
54097
54238
|
if (!existsSync43(path))
|
|
54098
54239
|
return null;
|
|
54099
54240
|
try {
|
|
54100
|
-
const value = JSON.parse(
|
|
54241
|
+
const value = JSON.parse(readFileSync28(path, "utf-8"));
|
|
54101
54242
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
54102
54243
|
return null;
|
|
54103
54244
|
const raw = value;
|
|
@@ -54127,7 +54268,7 @@ import {
|
|
|
54127
54268
|
chmodSync as chmodSync4,
|
|
54128
54269
|
existsSync as existsSync44,
|
|
54129
54270
|
mkdirSync as mkdirSync8,
|
|
54130
|
-
readFileSync as
|
|
54271
|
+
readFileSync as readFileSync29,
|
|
54131
54272
|
renameSync as renameSync8,
|
|
54132
54273
|
statSync as statSync24,
|
|
54133
54274
|
writeFileSync as writeFileSync8
|
|
@@ -54186,7 +54327,7 @@ function ensureTuiPluginEntry(options = {}) {
|
|
|
54186
54327
|
const configPath = resolveTuiConfigPath(options.configDir);
|
|
54187
54328
|
let config = {};
|
|
54188
54329
|
if (existsSync44(configPath)) {
|
|
54189
|
-
const raw =
|
|
54330
|
+
const raw = readFileSync29(configPath, "utf-8");
|
|
54190
54331
|
config = import_comment_json9.parse(raw) ?? {};
|
|
54191
54332
|
}
|
|
54192
54333
|
const plugins = Array.isArray(config.plugin) ? [...config.plugin] : [];
|
|
@@ -54273,7 +54414,7 @@ function scanHistorianSessionDumpDirs(root) {
|
|
|
54273
54414
|
var init_historian_dump_dirs = () => {};
|
|
54274
54415
|
|
|
54275
54416
|
// src/lib/diagnostics-opencode.ts
|
|
54276
|
-
import { existsSync as existsSync46, readFileSync as
|
|
54417
|
+
import { existsSync as existsSync46, readFileSync as readFileSync30, statSync as statSync26 } from "node:fs";
|
|
54277
54418
|
import { createRequire as createRequire4 } from "node:module";
|
|
54278
54419
|
import { join as join38 } from "node:path";
|
|
54279
54420
|
function getSelfVersion() {
|
|
@@ -54290,7 +54431,7 @@ function getSelfVersion() {
|
|
|
54290
54431
|
}
|
|
54291
54432
|
function readLegacyCachedVersion(root) {
|
|
54292
54433
|
try {
|
|
54293
|
-
const pkg = JSON.parse(
|
|
54434
|
+
const pkg = JSON.parse(readFileSync30(getOpenCodePluginPackageJsonPath(root), "utf-8"));
|
|
54294
54435
|
return typeof pkg.version === "string" ? pkg.version : undefined;
|
|
54295
54436
|
} catch {
|
|
54296
54437
|
return;
|
|
@@ -54362,7 +54503,7 @@ function readConfig3(path) {
|
|
|
54362
54503
|
if (!existsSync46(path))
|
|
54363
54504
|
return { value: null };
|
|
54364
54505
|
try {
|
|
54365
|
-
const raw =
|
|
54506
|
+
const raw = readFileSync30(path, "utf-8");
|
|
54366
54507
|
const value = import_comment_json10.parse(raw);
|
|
54367
54508
|
return { value };
|
|
54368
54509
|
} catch (error) {
|
|
@@ -54387,7 +54528,7 @@ function configHasPluginEntry(config) {
|
|
|
54387
54528
|
}
|
|
54388
54529
|
function parseHistorianDumpMeta(path) {
|
|
54389
54530
|
try {
|
|
54390
|
-
const xml =
|
|
54531
|
+
const xml = readFileSync30(path, "utf-8");
|
|
54391
54532
|
const parsed = parseCompartmentOutput(xml);
|
|
54392
54533
|
const factCountByCategory = {};
|
|
54393
54534
|
for (const fact of parsed.facts) {
|
|
@@ -54964,7 +55105,7 @@ var init_embedding_local = __esm(async () => {
|
|
|
54964
55105
|
|
|
54965
55106
|
// src/lib/embedding-runtime.ts
|
|
54966
55107
|
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
54967
|
-
import { existsSync as existsSync47, readFileSync as
|
|
55108
|
+
import { existsSync as existsSync47, readFileSync as readFileSync31 } from "node:fs";
|
|
54968
55109
|
import { createRequire as createRequire5 } from "node:module";
|
|
54969
55110
|
import { dirname as dirname25, join as join39, sep as sep3 } from "node:path";
|
|
54970
55111
|
function describeError(error) {
|
|
@@ -55112,7 +55253,7 @@ function expectedBinaryRelPath(platform, arch) {
|
|
|
55112
55253
|
}
|
|
55113
55254
|
function onnxRuntimeNodeVersion(packageDir) {
|
|
55114
55255
|
try {
|
|
55115
|
-
const parsed = JSON.parse(
|
|
55256
|
+
const parsed = JSON.parse(readFileSync31(join39(packageDir, "package.json"), "utf8"));
|
|
55116
55257
|
return typeof parsed.version === "string" ? parsed.version : undefined;
|
|
55117
55258
|
} catch {
|
|
55118
55259
|
return;
|
|
@@ -56005,6 +56146,76 @@ var init_doctor_harness_relabel = __esm(async () => {
|
|
|
56005
56146
|
await init_opencode2_relabel();
|
|
56006
56147
|
});
|
|
56007
56148
|
|
|
56149
|
+
// src/commands/doctor-opencode-background-compaction.ts
|
|
56150
|
+
function checkOpenCodeBackgroundCompaction(directory, hostVersion, options, sink) {
|
|
56151
|
+
if (!options.compactionEnabled || !hostVersion)
|
|
56152
|
+
return;
|
|
56153
|
+
const comparison = compareSemverPrecedence(hostVersion, "2.3.1");
|
|
56154
|
+
if (comparison === null || comparison < 0)
|
|
56155
|
+
return;
|
|
56156
|
+
const before = readOpenCode2BackgroundCompaction(directory);
|
|
56157
|
+
if (!before.enabled)
|
|
56158
|
+
return;
|
|
56159
|
+
sink.warn("OpenCode prepares compactions before you ask for them (compaction.background). If /compact uses a prepared answer, Magic Context does not shrink the next request. Run doctor --fix to turn off background compaction.");
|
|
56160
|
+
if (!options.fix)
|
|
56161
|
+
return;
|
|
56162
|
+
const userPath = detectConfigPaths().opencodeConfig;
|
|
56163
|
+
for (const path of new Set([userPath, ...projectOpenCodeConfigPaths(directory)])) {
|
|
56164
|
+
try {
|
|
56165
|
+
const config = readJsoncConfig(path);
|
|
56166
|
+
if (config.kind === "parse-error")
|
|
56167
|
+
throw config.error;
|
|
56168
|
+
if (config.kind === "missing") {
|
|
56169
|
+
if (path !== userPath)
|
|
56170
|
+
continue;
|
|
56171
|
+
writeFileAtomic(path, `{
|
|
56172
|
+
"compaction": {
|
|
56173
|
+
"background": false
|
|
56174
|
+
}
|
|
56175
|
+
}
|
|
56176
|
+
`);
|
|
56177
|
+
} else {
|
|
56178
|
+
const block = config.value.compaction;
|
|
56179
|
+
const fields = block && typeof block === "object" && !Array.isArray(block) ? block : undefined;
|
|
56180
|
+
if (fields?.background === false)
|
|
56181
|
+
continue;
|
|
56182
|
+
if (path !== userPath && fields?.background === undefined)
|
|
56183
|
+
continue;
|
|
56184
|
+
const { bom, text } = readJsoncTextForEdit(path);
|
|
56185
|
+
const next = fields ? setJsoncValue(text, ["compaction", "background"], false) : setJsoncValue(text, ["compaction"], { background: false });
|
|
56186
|
+
writeFileAtomic(path, bom + next);
|
|
56187
|
+
}
|
|
56188
|
+
sink.wrote(`Set compaction.background: false in ${path}`);
|
|
56189
|
+
} catch (error) {
|
|
56190
|
+
sink.warn(`Could not set compaction.background in ${path}: ${String(error)}`);
|
|
56191
|
+
}
|
|
56192
|
+
}
|
|
56193
|
+
const after = readOpenCode2BackgroundCompaction(directory);
|
|
56194
|
+
const unchecked = [
|
|
56195
|
+
...after.unreadable,
|
|
56196
|
+
...process.env.OPENCODE_CONFIG_CONTENT ? ["the OPENCODE_CONFIG_CONTENT layer"] : []
|
|
56197
|
+
];
|
|
56198
|
+
if (after.enabled || unchecked.length) {
|
|
56199
|
+
const sources = [
|
|
56200
|
+
...after.enabled ? [after.backgroundSource ?? "OpenCode's default"] : [],
|
|
56201
|
+
...unchecked
|
|
56202
|
+
];
|
|
56203
|
+
sink.warn(`Background compaction may still be enabled. Check compaction.background in: ${[...new Set(sources)].join(", ")}.`);
|
|
56204
|
+
} else {
|
|
56205
|
+
sink.info("Background compaction is disabled in the config files doctor could check. Remote, organization, or managed OpenCode settings may override them.");
|
|
56206
|
+
}
|
|
56207
|
+
sink.info("No OpenCode restart is needed for changes to compaction.background.");
|
|
56208
|
+
}
|
|
56209
|
+
var init_doctor_opencode_background_compaction = __esm(async () => {
|
|
56210
|
+
init_conflict_detector();
|
|
56211
|
+
init_conflict_fixer();
|
|
56212
|
+
init_jsonc_edit();
|
|
56213
|
+
init_atomic_write();
|
|
56214
|
+
init_jsonc_config();
|
|
56215
|
+
init_paths();
|
|
56216
|
+
await init_doctor_opencode2_cache();
|
|
56217
|
+
});
|
|
56218
|
+
|
|
56008
56219
|
// src/commands/doctor-opencode-plugin-duplicates.ts
|
|
56009
56220
|
import { isDeepStrictEqual } from "node:util";
|
|
56010
56221
|
function entryOptions(entry) {
|
|
@@ -56249,7 +56460,7 @@ function removeDeprecatedReasoningAge(config) {
|
|
|
56249
56460
|
|
|
56250
56461
|
// src/commands/doctor-opencode.ts
|
|
56251
56462
|
import { spawnSync as spawnSync10 } from "node:child_process";
|
|
56252
|
-
import { existsSync as existsSync48, mkdtempSync as mkdtempSync4, readFileSync as
|
|
56463
|
+
import { existsSync as existsSync48, mkdtempSync as mkdtempSync4, readFileSync as readFileSync32, rmSync as rmSync9 } from "node:fs";
|
|
56253
56464
|
import { createRequire as createRequire6 } from "node:module";
|
|
56254
56465
|
import { homedir as homedir21, tmpdir as tmpdir4 } from "node:os";
|
|
56255
56466
|
import { dirname as dirname27, join as join41, resolve as resolve20 } from "node:path";
|
|
@@ -56516,7 +56727,7 @@ function collectNpmReleaseAgeWarnings() {
|
|
|
56516
56727
|
if (!existsSync48(npmrcPath))
|
|
56517
56728
|
return ageWarnings;
|
|
56518
56729
|
try {
|
|
56519
|
-
const npmrc =
|
|
56730
|
+
const npmrc = readFileSync32(npmrcPath, "utf-8");
|
|
56520
56731
|
for (const line of npmrc.split(`
|
|
56521
56732
|
`)) {
|
|
56522
56733
|
const trimmed = line.trim();
|
|
@@ -56560,7 +56771,7 @@ async function checkPluginFreshnessForIssue(deps = {}) {
|
|
|
56560
56771
|
return { npmVersions: {} };
|
|
56561
56772
|
let config;
|
|
56562
56773
|
try {
|
|
56563
|
-
config = import_comment_json11.parse(
|
|
56774
|
+
config = import_comment_json11.parse(readFileSync32(paths.opencodeConfig, "utf-8"));
|
|
56564
56775
|
} catch {}
|
|
56565
56776
|
const configDir = dirname27(paths.opencodeConfig);
|
|
56566
56777
|
if (config && !isOpenCodePluginRegistered(config, configDir))
|
|
@@ -56961,7 +57172,7 @@ async function runDoctor2(options = {}) {
|
|
|
56961
57172
|
let magicContextStatusKnown = paths.opencodeConfigFormat === "none";
|
|
56962
57173
|
if (!magicContextStatusKnown) {
|
|
56963
57174
|
try {
|
|
56964
|
-
const config = import_comment_json11.parse(
|
|
57175
|
+
const config = import_comment_json11.parse(readFileSync32(paths.opencodeConfig, "utf-8"));
|
|
56965
57176
|
magicContextInstalled = isOpenCodePluginRegistered(config, dirname27(paths.opencodeConfig));
|
|
56966
57177
|
magicContextStatusKnown = true;
|
|
56967
57178
|
} catch {}
|
|
@@ -57275,7 +57486,7 @@ async function runDoctor2(options = {}) {
|
|
|
57275
57486
|
};
|
|
57276
57487
|
if (paths.opencodeConfigFormat !== "none") {
|
|
57277
57488
|
try {
|
|
57278
|
-
const raw =
|
|
57489
|
+
const raw = readFileSync32(paths.opencodeConfig, "utf-8");
|
|
57279
57490
|
const config = import_comment_json11.parse(raw);
|
|
57280
57491
|
const configName = paths.opencodeConfigFormat === "jsonc" ? "opencode.jsonc" : "opencode.json";
|
|
57281
57492
|
const configDir = dirname27(paths.opencodeConfig);
|
|
@@ -57336,6 +57547,14 @@ async function runDoctor2(options = {}) {
|
|
|
57336
57547
|
const compactionEnabled = resolveCompactionEnabledForDoctor();
|
|
57337
57548
|
const conflictResult = detectConflicts(cwd, { compactionEnabled });
|
|
57338
57549
|
log3.info("Compaction check: file-based; the running server's resolved config may differ — `opencode debug config` is authoritative");
|
|
57550
|
+
checkOpenCodeBackgroundCompaction(cwd, activeInstallation.version, { compactionEnabled, fix: options.fix }, {
|
|
57551
|
+
warn,
|
|
57552
|
+
info: (message) => log3.info(message),
|
|
57553
|
+
wrote: (message) => {
|
|
57554
|
+
pass(message);
|
|
57555
|
+
fixed++;
|
|
57556
|
+
}
|
|
57557
|
+
});
|
|
57339
57558
|
if (conflictResult.hasConflict) {
|
|
57340
57559
|
for (const reason of conflictResult.reasons) {
|
|
57341
57560
|
fail(`Conflict: ${reason}`);
|
|
@@ -57370,7 +57589,7 @@ async function runDoctor2(options = {}) {
|
|
|
57370
57589
|
fixed++;
|
|
57371
57590
|
} else if (existsSync48(paths.tuiConfig)) {
|
|
57372
57591
|
try {
|
|
57373
|
-
const tuiRaw =
|
|
57592
|
+
const tuiRaw = readFileSync32(paths.tuiConfig, "utf-8");
|
|
57374
57593
|
const tuiConfig = import_comment_json11.parse(tuiRaw);
|
|
57375
57594
|
const tuiConfigDir = dirname27(paths.tuiConfig);
|
|
57376
57595
|
const tuiRawPlugins = Array.isArray(tuiConfig?.plugin) ? tuiConfig.plugin : [];
|
|
@@ -57425,7 +57644,7 @@ async function runDoctor2(options = {}) {
|
|
|
57425
57644
|
let embeddingHostConfig = null;
|
|
57426
57645
|
try {
|
|
57427
57646
|
if (paths.opencodeConfigFormat !== "none")
|
|
57428
|
-
embeddingHostConfig = import_comment_json11.parse(
|
|
57647
|
+
embeddingHostConfig = import_comment_json11.parse(readFileSync32(paths.opencodeConfig, "utf-8"));
|
|
57429
57648
|
} catch {}
|
|
57430
57649
|
const embeddingInstalls = getOpenCodeLoadedPluginInstallRoots(hostGeneration, embeddingHostConfig);
|
|
57431
57650
|
const unusedInstalls = embeddingInstalls.others.filter((root) => existsSync48(root));
|
|
@@ -57525,7 +57744,7 @@ ${formatDatabaseRepairGuidance(dbPath)}`);
|
|
|
57525
57744
|
let pluginConfigUse;
|
|
57526
57745
|
if (paths.opencodeConfigFormat !== "none") {
|
|
57527
57746
|
try {
|
|
57528
|
-
pluginConfigUse = readOpenCodePluginConfigUse(import_comment_json11.parse(
|
|
57747
|
+
pluginConfigUse = readOpenCodePluginConfigUse(import_comment_json11.parse(readFileSync32(paths.opencodeConfig, "utf-8")), dirname27(paths.opencodeConfig));
|
|
57529
57748
|
} catch {}
|
|
57530
57749
|
}
|
|
57531
57750
|
const cacheResult = await clearPluginCache({
|
|
@@ -57579,7 +57798,7 @@ ${formatDatabaseRepairGuidance(dbPath)}`);
|
|
|
57579
57798
|
let v2DistTag;
|
|
57580
57799
|
if (paths.opencodeConfigFormat !== "none") {
|
|
57581
57800
|
try {
|
|
57582
|
-
v2DistTag = configuredOpenCodeV2DistTag(import_comment_json11.parse(
|
|
57801
|
+
v2DistTag = configuredOpenCodeV2DistTag(import_comment_json11.parse(readFileSync32(paths.opencodeConfig, "utf-8")));
|
|
57583
57802
|
} catch {}
|
|
57584
57803
|
}
|
|
57585
57804
|
const v2Cache = reportOpenCodeV2PluginCache(checkOpenCodeV2PluginCache({
|
|
@@ -57729,6 +57948,7 @@ var init_doctor_opencode = __esm(async () => {
|
|
|
57729
57948
|
init_v22_backfill_commands(),
|
|
57730
57949
|
init_doctor_cached_plugin_fence(),
|
|
57731
57950
|
init_doctor_harness_relabel(),
|
|
57951
|
+
init_doctor_opencode_background_compaction(),
|
|
57732
57952
|
init_doctor_opencode_cache(),
|
|
57733
57953
|
init_doctor_opencode_plugin_duplicates(),
|
|
57734
57954
|
init_doctor_opencode_plugin_entry(),
|
|
@@ -57999,7 +58219,7 @@ var init_model_chain_health = __esm(() => {
|
|
|
57999
58219
|
});
|
|
58000
58220
|
|
|
58001
58221
|
// src/lib/diagnostics-pi.ts
|
|
58002
|
-
import { existsSync as existsSync49, readdirSync as readdirSync11, readFileSync as
|
|
58222
|
+
import { existsSync as existsSync49, readdirSync as readdirSync11, readFileSync as readFileSync33, statSync as statSync27 } from "node:fs";
|
|
58003
58223
|
import { createRequire as createRequire7 } from "node:module";
|
|
58004
58224
|
import { join as join42 } from "node:path";
|
|
58005
58225
|
function getSelfVersion3() {
|
|
@@ -58032,7 +58252,7 @@ function readJsonc(path) {
|
|
|
58032
58252
|
return { value: {} };
|
|
58033
58253
|
try {
|
|
58034
58254
|
return {
|
|
58035
|
-
value: import_comment_json12.parse(
|
|
58255
|
+
value: import_comment_json12.parse(readFileSync33(path, "utf-8"))
|
|
58036
58256
|
};
|
|
58037
58257
|
} catch (error) {
|
|
58038
58258
|
return {
|
|
@@ -58102,7 +58322,7 @@ function collectPiRecentSessions() {
|
|
|
58102
58322
|
}
|
|
58103
58323
|
function parseHistorianDumpMeta2(path) {
|
|
58104
58324
|
try {
|
|
58105
|
-
const xml =
|
|
58325
|
+
const xml = readFileSync33(path, "utf-8");
|
|
58106
58326
|
const parsed = parseCompartmentOutput(xml);
|
|
58107
58327
|
const factCountByCategory = {};
|
|
58108
58328
|
for (const fact of parsed.facts) {
|
|
@@ -58425,11 +58645,11 @@ var init_logs_pi = __esm(() => {
|
|
|
58425
58645
|
});
|
|
58426
58646
|
|
|
58427
58647
|
// src/commands/doctor-pi.ts
|
|
58428
|
-
import { execFileSync as
|
|
58429
|
-
import { existsSync as existsSync50, lstatSync as lstatSync6, readdirSync as readdirSync12, readFileSync as
|
|
58648
|
+
import { execFileSync as execFileSync8, spawnSync as spawnSync11 } from "node:child_process";
|
|
58649
|
+
import { existsSync as existsSync50, lstatSync as lstatSync6, readdirSync as readdirSync12, readFileSync as readFileSync34, rmSync as rmSync10 } from "node:fs";
|
|
58430
58650
|
import { createRequire as createRequire8 } from "node:module";
|
|
58431
58651
|
import { homedir as homedir22 } from "node:os";
|
|
58432
|
-
import { basename as basename7, isAbsolute as
|
|
58652
|
+
import { basename as basename7, isAbsolute as isAbsolute11, join as join44 } from "node:path";
|
|
58433
58653
|
function depsFrom(options) {
|
|
58434
58654
|
return {
|
|
58435
58655
|
...DEFAULT_DEPS5,
|
|
@@ -58467,7 +58687,7 @@ function selfVersion2() {
|
|
|
58467
58687
|
}
|
|
58468
58688
|
function getLatestNpmVersion(packageName) {
|
|
58469
58689
|
try {
|
|
58470
|
-
return
|
|
58690
|
+
return execFileSync8("npm", ["view", packageName, "version"], {
|
|
58471
58691
|
windowsHide: true,
|
|
58472
58692
|
encoding: "utf-8",
|
|
58473
58693
|
stdio: ["ignore", "pipe", "ignore"],
|
|
@@ -58522,7 +58742,7 @@ function summarize(results) {
|
|
|
58522
58742
|
function readJsonc2(path) {
|
|
58523
58743
|
try {
|
|
58524
58744
|
return {
|
|
58525
|
-
value: import_comment_json13.parse(
|
|
58745
|
+
value: import_comment_json13.parse(readFileSync34(path, "utf-8"))
|
|
58526
58746
|
};
|
|
58527
58747
|
} catch (error) {
|
|
58528
58748
|
return {
|
|
@@ -58705,7 +58925,7 @@ function findPiMagicContextCacheDirs(cwd, expectedVersion, force = false) {
|
|
|
58705
58925
|
const packageJson = join44(path, "package.json");
|
|
58706
58926
|
if (existsSync50(packageJson)) {
|
|
58707
58927
|
try {
|
|
58708
|
-
const pkg = JSON.parse(
|
|
58928
|
+
const pkg = JSON.parse(readFileSync34(packageJson, "utf-8"));
|
|
58709
58929
|
const name = typeof pkg.name === "string" ? pkg.name : "";
|
|
58710
58930
|
const version = typeof pkg.version === "string" ? pkg.version : undefined;
|
|
58711
58931
|
if (name === PACKAGE_NAME2) {
|
|
@@ -59174,7 +59394,7 @@ function piCacheClearBlocker(paths, deps) {
|
|
|
59174
59394
|
function repair2(plan, prompts, deps) {
|
|
59175
59395
|
let fixed = 0;
|
|
59176
59396
|
for (const path of plan.reasoningAgeConfigPaths) {
|
|
59177
|
-
const content =
|
|
59397
|
+
const content = readFileSync34(path, "utf8");
|
|
59178
59398
|
const parsed = readJsonc2(path);
|
|
59179
59399
|
if (parsed.error)
|
|
59180
59400
|
continue;
|
|
@@ -59266,7 +59486,7 @@ async function runIssueFlow3(options) {
|
|
|
59266
59486
|
if (options.reportPath) {
|
|
59267
59487
|
try {
|
|
59268
59488
|
const report = await options.deps.collectDiagnostics(options.cwd);
|
|
59269
|
-
const outputPath =
|
|
59489
|
+
const outputPath = isAbsolute11(options.reportPath) ? options.reportPath : join44(options.cwd, options.reportPath);
|
|
59270
59490
|
const bundled = await bundleIssueReport2(report, "Generated non-interactively by `doctor --issue --report`.", "Magic Context diagnostic report", { cwd: options.cwd, now: options.deps.now(), outputPath });
|
|
59271
59491
|
options.prompts.log.info(`Report written to ${bundled.path}`);
|
|
59272
59492
|
return 0;
|
|
@@ -59471,7 +59691,7 @@ var init_doctor_pi = __esm(async () => {
|
|
|
59471
59691
|
probeCacheUse: probeHostProcessesUsing,
|
|
59472
59692
|
readProcessCommand,
|
|
59473
59693
|
now: () => new Date,
|
|
59474
|
-
execFileSync:
|
|
59694
|
+
execFileSync: execFileSync8,
|
|
59475
59695
|
spawnSync: spawnSync11
|
|
59476
59696
|
};
|
|
59477
59697
|
});
|
|
@@ -59769,12 +59989,12 @@ var SINGLE_STORE_HELP = [
|
|
|
59769
59989
|
`);
|
|
59770
59990
|
var MERGE_IDENTITY_HELP = [
|
|
59771
59991
|
"",
|
|
59772
|
-
" Usage: magic-context doctor merge-identities [--from <identity> --to <identity>] [--apply] [--force] [--verbose] [--db <path>] [--backup-root <dir>]",
|
|
59992
|
+
" Usage: magic-context doctor merge-identities [--from <identity-or-folder> --to <identity>] [--apply] [--force] [--verbose] [--db <path>] [--backup-root <dir>]",
|
|
59773
59993
|
"",
|
|
59774
59994
|
" Merge every project-scoped row from one project identity into another.",
|
|
59775
59995
|
"",
|
|
59776
59996
|
" Options:",
|
|
59777
|
-
" --from <identity>
|
|
59997
|
+
" --from <identity-or-folder> Source key, or a folder path naming its old dir: key",
|
|
59778
59998
|
" --to <identity> Identity that receives them",
|
|
59779
59999
|
" (no flags) List splits; --from/--to previews without writing",
|
|
59780
60000
|
" --apply Confirm the reviewed preview; hosts must be closed",
|