@cortexkit/magic-context 0.49.80 → 0.49.81
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 +185 -69
- 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 {
|
|
@@ -42916,7 +42950,7 @@ var init_doctor_identity_splits = __esm(async () => {
|
|
|
42916
42950
|
// src/commands/doctor-merge-identity.ts
|
|
42917
42951
|
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
42918
42952
|
import { createHash as createHash7 } from "node:crypto";
|
|
42919
|
-
import { existsSync as existsSync35, mkdtempSync as mkdtempSync2, readdirSync as readdirSync8, readFileSync as
|
|
42953
|
+
import { existsSync as existsSync35, mkdtempSync as mkdtempSync2, readdirSync as readdirSync8, readFileSync as readFileSync23, statSync as statSync20 } from "node:fs";
|
|
42920
42954
|
import { dirname as dirname22, join as join28, resolve as resolve16 } from "node:path";
|
|
42921
42955
|
function parseMergeIdentityArgs(args) {
|
|
42922
42956
|
const values = {};
|
|
@@ -43129,7 +43163,7 @@ function observations(db, hostPath, storageDir) {
|
|
|
43129
43163
|
if (!file.endsWith(".json"))
|
|
43130
43164
|
continue;
|
|
43131
43165
|
try {
|
|
43132
|
-
const record = JSON.parse(
|
|
43166
|
+
const record = JSON.parse(readFileSync23(join28(sidecars, file), "utf8"));
|
|
43133
43167
|
if (typeof record.directory === "string" && typeof record.identity === "string")
|
|
43134
43168
|
add(record.directory, record.identity);
|
|
43135
43169
|
} catch {}
|
|
@@ -43210,7 +43244,7 @@ function runMergeIdentityCli(args, deps = {}) {
|
|
|
43210
43244
|
ensureStorageDirectorySync(sidecarBackup, true);
|
|
43211
43245
|
let backupBytes = 0;
|
|
43212
43246
|
for (const entry of sidecarEntries) {
|
|
43213
|
-
const content =
|
|
43247
|
+
const content = readFileSync23(join28(sidecarRoot, entry));
|
|
43214
43248
|
writeStorageFileAtomicSync(join28(sidecarBackup, entry), content, true);
|
|
43215
43249
|
backupBytes += content.byteLength;
|
|
43216
43250
|
}
|
|
@@ -48322,7 +48356,7 @@ var DATABASE_REPAIR_COMMAND = "bunx @cortexkit/magic-context@latest doctor repai
|
|
|
48322
48356
|
|
|
48323
48357
|
// src/lib/github-issue.ts
|
|
48324
48358
|
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
48325
|
-
import { readFileSync as
|
|
48359
|
+
import { readFileSync as readFileSync24 } from "node:fs";
|
|
48326
48360
|
function runGhCommand(args) {
|
|
48327
48361
|
try {
|
|
48328
48362
|
const result = spawnSync7("gh", args, {
|
|
@@ -48349,7 +48383,7 @@ function failed(result) {
|
|
|
48349
48383
|
function submitGithubIssue(title, bodyPath, runner = runGhCommand) {
|
|
48350
48384
|
let body;
|
|
48351
48385
|
try {
|
|
48352
|
-
body =
|
|
48386
|
+
body = readFileSync24(bodyPath, "utf-8");
|
|
48353
48387
|
} catch (error) {
|
|
48354
48388
|
return {
|
|
48355
48389
|
ok: false,
|
|
@@ -49473,6 +49507,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49473
49507
|
"pass permission report failed after the request was decided; serving the pass:",
|
|
49474
49508
|
"system-prompt-hash skipped (OpenCode internal agent: title/summary/compaction)",
|
|
49475
49509
|
"thinking binding recovery: persistence failed; leaving the bound blocks intact",
|
|
49510
|
+
"v2 compaction hook: fired answered=true source=typescript_fallback row=running",
|
|
49476
49511
|
"v2 refusal: interrupting the turn before the provider request arm=storage-busy",
|
|
49477
49512
|
"WARN: [auto-update-checker] Failed to fetch latest version for channel: latest",
|
|
49478
49513
|
'Pi subagent agent "\x01" has no strict tool allow-list; forcing an empty tool list',
|
|
@@ -49557,6 +49592,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49557
49592
|
"Pi publication commit_failed reason=capture_failed; serving managed context",
|
|
49558
49593
|
"transform refused degraded pass site=reasoning-removal-persistence-failure:",
|
|
49559
49594
|
"transform: historian unavailable; clearing stale compartmentInProgress flag",
|
|
49595
|
+
"v2 compaction hook: fired answered=true source=typescript_fallback row=none",
|
|
49560
49596
|
"mc-module: finished \x01 pending context.db write(s) left by an earlier process",
|
|
49561
49597
|
"prompt_surface.guidance_override_path (\x01) is empty; using built-in guidance.\x020p",
|
|
49562
49598
|
"request tools changed (kind=\x01, model=\x01, schemas \x01→\x01): releasing signed thinking\x021m",
|
|
@@ -49769,6 +49805,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49769
49805
|
"transform refused degraded pass site=compaction-marker-drain-failure:",
|
|
49770
49806
|
"transform refused degraded pass site=store-generation-rebase-failure:",
|
|
49771
49807
|
"transform: recovery chain stops: the next historian run did not start",
|
|
49808
|
+
"v2 compaction hook: fired answered=true source=typescript row=running",
|
|
49772
49809
|
"v95 temporal metadata: malformed JSON skipped; original blob retained",
|
|
49773
49810
|
"v95 temporal metadata: non-array JSON skipped; original blob retained",
|
|
49774
49811
|
"prompt_surface.tool_descriptions.\x01 is empty; the override was ignored.",
|
|
@@ -49865,7 +49902,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49865
49902
|
"historian no-op: waiting for new history after no forward progress",
|
|
49866
49903
|
"transform refused degraded pass site=stale-reduce-strip-exception:",
|
|
49867
49904
|
"transform: recovery chain stops: the request could not be counted:",
|
|
49868
|
-
"v2 compaction hook: fired answered=true source=
|
|
49905
|
+
"v2 compaction hook: fired answered=true source=typescript row=none",
|
|
49869
49906
|
"v2 response ownership unavailable; keeping system identity pending",
|
|
49870
49907
|
"[git-commits] sweep parked for \x01: directory identity has no commits",
|
|
49871
49908
|
"[dreamer] domain lease lost (memory:\x01) — stopping remaining task(s)",
|
|
@@ -49901,6 +49938,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49901
49938
|
"transform refused degraded pass site=m0-m1-injection-degradation:",
|
|
49902
49939
|
"transform refused degraded pass site=overflow-state-read-failure:",
|
|
49903
49940
|
"transform refused degraded pass site=tagging-persistence-failure:",
|
|
49941
|
+
"v2 compaction hook: fired answered=true source=module row=running",
|
|
49904
49942
|
"heartbeat for \x01 refused: malformed_response; abandoning this claim",
|
|
49905
49943
|
"injected \x01 facts + \x01 memories into message[0] (no compartments yet)",
|
|
49906
49944
|
"v2 fork inheritance: fork of \x01 already has state; not copied again\x020s",
|
|
@@ -50006,6 +50044,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
50006
50044
|
"system delivery acknowledgement failed (keeping pending work):",
|
|
50007
50045
|
"transform: cannot force-start compartment agent without client",
|
|
50008
50046
|
"transform: injected memories/facts block (no compartments yet)",
|
|
50047
|
+
"v2 compaction hook: fired answered=true source=module row=none",
|
|
50009
50048
|
'invalid cache_ttl "\x01" in ctx-status; falling back to default 5m',
|
|
50010
50049
|
"v2 boundary trim: dropped \x01 messages before the module boundary",
|
|
50011
50050
|
"Subagent temperature sent for \x01: no host or models.dev metadata\x020m",
|
|
@@ -50183,7 +50222,6 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
50183
50222
|
"recomp skipped: compartment lease held by another process",
|
|
50184
50223
|
"rust transform wire invariant failed; LKG replay required",
|
|
50185
50224
|
"transform: compartmentInProgress flag set, starting agent",
|
|
50186
|
-
"v2 compaction hook: fired answered=true source=typescript",
|
|
50187
50225
|
"wrapup: timed out waiting for the compartment-state lease",
|
|
50188
50226
|
"[migrations] v12 cleaned \x01 orphan memory_embeddings row(s)",
|
|
50189
50227
|
"\x01: prompt unsettled — session \x01 left to the age-gated sweep\x021s",
|
|
@@ -50335,7 +50373,6 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
50335
50373
|
"LKG snapshot slices failed verification; slot cleared",
|
|
50336
50374
|
"protected-tail migration seed fell back to ordinal 1:",
|
|
50337
50375
|
"registered context handler (tagging + drops + nudges)",
|
|
50338
|
-
"v2 compaction hook: fired answered=true source=module",
|
|
50339
50376
|
"WARN: message_end: persist session_meta usage failed:",
|
|
50340
50377
|
"[\x01] primary: model not found, retrying with suggestion",
|
|
50341
50378
|
"injected \x01 facts into message[0] (no compartments yet)",
|
|
@@ -51571,7 +51608,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
51571
51608
|
});
|
|
51572
51609
|
|
|
51573
51610
|
// src/lib/log-lines.ts
|
|
51574
|
-
import { existsSync as existsSync40, readFileSync as
|
|
51611
|
+
import { existsSync as existsSync40, readFileSync as readFileSync25, statSync as statSync22 } from "node:fs";
|
|
51575
51612
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
51576
51613
|
import { join as join33 } from "node:path";
|
|
51577
51614
|
function tokenize(input, limit = Number.POSITIVE_INFINITY) {
|
|
@@ -51872,7 +51909,7 @@ function inspectLogFile(path) {
|
|
|
51872
51909
|
return { path, exists: false, sizeKb: 0, lineCount: 0, grammar: "unknown" };
|
|
51873
51910
|
}
|
|
51874
51911
|
try {
|
|
51875
|
-
const content =
|
|
51912
|
+
const content = readFileSync25(path, "utf8");
|
|
51876
51913
|
const lines = content.split(/\r?\n/).filter((line) => line.length > 0);
|
|
51877
51914
|
const grammars = new Set(lines.flatMap((line) => {
|
|
51878
51915
|
const parsed = parseLogLine(line);
|
|
@@ -51899,7 +51936,7 @@ function readLogLines(files) {
|
|
|
51899
51936
|
return [];
|
|
51900
51937
|
try {
|
|
51901
51938
|
let precedingTimestamp = "";
|
|
51902
|
-
return
|
|
51939
|
+
return readFileSync25(file.path, "utf8").split(/\r?\n/).filter((line) => line.length > 0).map((line, lineIndex) => {
|
|
51903
51940
|
precedingTimestamp = parseLogLine(line)?.ts ?? precedingTimestamp;
|
|
51904
51941
|
return { line, timestamp: precedingTimestamp, fileIndex, lineIndex };
|
|
51905
51942
|
});
|
|
@@ -52508,7 +52545,7 @@ var init_issue_body = __esm(() => {
|
|
|
52508
52545
|
});
|
|
52509
52546
|
|
|
52510
52547
|
// src/lib/omp-hide-secrets.ts
|
|
52511
|
-
import { existsSync as existsSync41, readdirSync as readdirSync9, readFileSync as
|
|
52548
|
+
import { existsSync as existsSync41, readdirSync as readdirSync9, readFileSync as readFileSync26, statSync as statSync23 } from "node:fs";
|
|
52512
52549
|
import { join as join34, resolve as resolve18 } from "node:path";
|
|
52513
52550
|
function stripYamlComment(line) {
|
|
52514
52551
|
let quote = null;
|
|
@@ -52632,7 +52669,7 @@ function readHideSecretsFromJson(text) {
|
|
|
52632
52669
|
function readSource(layer, path, format) {
|
|
52633
52670
|
let text;
|
|
52634
52671
|
try {
|
|
52635
|
-
text =
|
|
52672
|
+
text = readFileSync26(path, "utf-8");
|
|
52636
52673
|
} catch (error) {
|
|
52637
52674
|
const code = error.code;
|
|
52638
52675
|
return {
|
|
@@ -52733,7 +52770,7 @@ var init_omp_hide_secrets = __esm(() => {
|
|
|
52733
52770
|
|
|
52734
52771
|
// src/commands/doctor-omp.ts
|
|
52735
52772
|
import { execFileSync as execFileSync8, spawnSync as spawnSync8 } from "node:child_process";
|
|
52736
|
-
import { existsSync as existsSync42, readFileSync as
|
|
52773
|
+
import { existsSync as existsSync42, readFileSync as readFileSync27 } from "node:fs";
|
|
52737
52774
|
import { createRequire as createRequire3 } from "node:module";
|
|
52738
52775
|
import { isAbsolute as isAbsolute9, join as join35, resolve as resolve19 } from "node:path";
|
|
52739
52776
|
function parseSemver(value) {
|
|
@@ -52780,7 +52817,7 @@ function readConfig2(path) {
|
|
|
52780
52817
|
if (!existsSync42(path))
|
|
52781
52818
|
return {};
|
|
52782
52819
|
try {
|
|
52783
|
-
const parsed = import_comment_json8.parse(
|
|
52820
|
+
const parsed = import_comment_json8.parse(readFileSync27(path, "utf-8"));
|
|
52784
52821
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? {} : { error: "top level is not an object" };
|
|
52785
52822
|
} catch (error) {
|
|
52786
52823
|
return { error: error instanceof Error ? error.message : String(error) };
|
|
@@ -52790,7 +52827,7 @@ function pluginDeclaresOmp(path) {
|
|
|
52790
52827
|
if (!path)
|
|
52791
52828
|
return null;
|
|
52792
52829
|
try {
|
|
52793
|
-
const pkg = JSON.parse(
|
|
52830
|
+
const pkg = JSON.parse(readFileSync27(join35(path, "package.json"), "utf-8"));
|
|
52794
52831
|
return Array.isArray(pkg.omp?.extensions) || Array.isArray(pkg.pi?.extensions);
|
|
52795
52832
|
} catch {
|
|
52796
52833
|
return null;
|
|
@@ -54092,12 +54129,12 @@ function listShadowBackfillStalls(db, projectIdentity) {
|
|
|
54092
54129
|
var SHADOW_BACKFILL_PROVENANCE_KEY = "_magicContextShadowBackfill";
|
|
54093
54130
|
|
|
54094
54131
|
// ../plugin/src/shared/auto-update-provenance.ts
|
|
54095
|
-
import { existsSync as existsSync43, readFileSync as
|
|
54132
|
+
import { existsSync as existsSync43, readFileSync as readFileSync28 } from "node:fs";
|
|
54096
54133
|
function readAutoUpdateCheckState(path) {
|
|
54097
54134
|
if (!existsSync43(path))
|
|
54098
54135
|
return null;
|
|
54099
54136
|
try {
|
|
54100
|
-
const value = JSON.parse(
|
|
54137
|
+
const value = JSON.parse(readFileSync28(path, "utf-8"));
|
|
54101
54138
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
54102
54139
|
return null;
|
|
54103
54140
|
const raw = value;
|
|
@@ -54127,7 +54164,7 @@ import {
|
|
|
54127
54164
|
chmodSync as chmodSync4,
|
|
54128
54165
|
existsSync as existsSync44,
|
|
54129
54166
|
mkdirSync as mkdirSync8,
|
|
54130
|
-
readFileSync as
|
|
54167
|
+
readFileSync as readFileSync29,
|
|
54131
54168
|
renameSync as renameSync8,
|
|
54132
54169
|
statSync as statSync24,
|
|
54133
54170
|
writeFileSync as writeFileSync8
|
|
@@ -54186,7 +54223,7 @@ function ensureTuiPluginEntry(options = {}) {
|
|
|
54186
54223
|
const configPath = resolveTuiConfigPath(options.configDir);
|
|
54187
54224
|
let config = {};
|
|
54188
54225
|
if (existsSync44(configPath)) {
|
|
54189
|
-
const raw =
|
|
54226
|
+
const raw = readFileSync29(configPath, "utf-8");
|
|
54190
54227
|
config = import_comment_json9.parse(raw) ?? {};
|
|
54191
54228
|
}
|
|
54192
54229
|
const plugins = Array.isArray(config.plugin) ? [...config.plugin] : [];
|
|
@@ -54273,7 +54310,7 @@ function scanHistorianSessionDumpDirs(root) {
|
|
|
54273
54310
|
var init_historian_dump_dirs = () => {};
|
|
54274
54311
|
|
|
54275
54312
|
// src/lib/diagnostics-opencode.ts
|
|
54276
|
-
import { existsSync as existsSync46, readFileSync as
|
|
54313
|
+
import { existsSync as existsSync46, readFileSync as readFileSync30, statSync as statSync26 } from "node:fs";
|
|
54277
54314
|
import { createRequire as createRequire4 } from "node:module";
|
|
54278
54315
|
import { join as join38 } from "node:path";
|
|
54279
54316
|
function getSelfVersion() {
|
|
@@ -54290,7 +54327,7 @@ function getSelfVersion() {
|
|
|
54290
54327
|
}
|
|
54291
54328
|
function readLegacyCachedVersion(root) {
|
|
54292
54329
|
try {
|
|
54293
|
-
const pkg = JSON.parse(
|
|
54330
|
+
const pkg = JSON.parse(readFileSync30(getOpenCodePluginPackageJsonPath(root), "utf-8"));
|
|
54294
54331
|
return typeof pkg.version === "string" ? pkg.version : undefined;
|
|
54295
54332
|
} catch {
|
|
54296
54333
|
return;
|
|
@@ -54362,7 +54399,7 @@ function readConfig3(path) {
|
|
|
54362
54399
|
if (!existsSync46(path))
|
|
54363
54400
|
return { value: null };
|
|
54364
54401
|
try {
|
|
54365
|
-
const raw =
|
|
54402
|
+
const raw = readFileSync30(path, "utf-8");
|
|
54366
54403
|
const value = import_comment_json10.parse(raw);
|
|
54367
54404
|
return { value };
|
|
54368
54405
|
} catch (error) {
|
|
@@ -54387,7 +54424,7 @@ function configHasPluginEntry(config) {
|
|
|
54387
54424
|
}
|
|
54388
54425
|
function parseHistorianDumpMeta(path) {
|
|
54389
54426
|
try {
|
|
54390
|
-
const xml =
|
|
54427
|
+
const xml = readFileSync30(path, "utf-8");
|
|
54391
54428
|
const parsed = parseCompartmentOutput(xml);
|
|
54392
54429
|
const factCountByCategory = {};
|
|
54393
54430
|
for (const fact of parsed.facts) {
|
|
@@ -54964,7 +55001,7 @@ var init_embedding_local = __esm(async () => {
|
|
|
54964
55001
|
|
|
54965
55002
|
// src/lib/embedding-runtime.ts
|
|
54966
55003
|
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
54967
|
-
import { existsSync as existsSync47, readFileSync as
|
|
55004
|
+
import { existsSync as existsSync47, readFileSync as readFileSync31 } from "node:fs";
|
|
54968
55005
|
import { createRequire as createRequire5 } from "node:module";
|
|
54969
55006
|
import { dirname as dirname25, join as join39, sep as sep3 } from "node:path";
|
|
54970
55007
|
function describeError(error) {
|
|
@@ -55112,7 +55149,7 @@ function expectedBinaryRelPath(platform, arch) {
|
|
|
55112
55149
|
}
|
|
55113
55150
|
function onnxRuntimeNodeVersion(packageDir) {
|
|
55114
55151
|
try {
|
|
55115
|
-
const parsed = JSON.parse(
|
|
55152
|
+
const parsed = JSON.parse(readFileSync31(join39(packageDir, "package.json"), "utf8"));
|
|
55116
55153
|
return typeof parsed.version === "string" ? parsed.version : undefined;
|
|
55117
55154
|
} catch {
|
|
55118
55155
|
return;
|
|
@@ -56005,6 +56042,76 @@ var init_doctor_harness_relabel = __esm(async () => {
|
|
|
56005
56042
|
await init_opencode2_relabel();
|
|
56006
56043
|
});
|
|
56007
56044
|
|
|
56045
|
+
// src/commands/doctor-opencode-background-compaction.ts
|
|
56046
|
+
function checkOpenCodeBackgroundCompaction(directory, hostVersion, options, sink) {
|
|
56047
|
+
if (!options.compactionEnabled || !hostVersion)
|
|
56048
|
+
return;
|
|
56049
|
+
const comparison = compareSemverPrecedence(hostVersion, "2.3.1");
|
|
56050
|
+
if (comparison === null || comparison < 0)
|
|
56051
|
+
return;
|
|
56052
|
+
const before = readOpenCode2BackgroundCompaction(directory);
|
|
56053
|
+
if (!before.enabled)
|
|
56054
|
+
return;
|
|
56055
|
+
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.");
|
|
56056
|
+
if (!options.fix)
|
|
56057
|
+
return;
|
|
56058
|
+
const userPath = detectConfigPaths().opencodeConfig;
|
|
56059
|
+
for (const path of new Set([userPath, ...projectOpenCodeConfigPaths(directory)])) {
|
|
56060
|
+
try {
|
|
56061
|
+
const config = readJsoncConfig(path);
|
|
56062
|
+
if (config.kind === "parse-error")
|
|
56063
|
+
throw config.error;
|
|
56064
|
+
if (config.kind === "missing") {
|
|
56065
|
+
if (path !== userPath)
|
|
56066
|
+
continue;
|
|
56067
|
+
writeFileAtomic(path, `{
|
|
56068
|
+
"compaction": {
|
|
56069
|
+
"background": false
|
|
56070
|
+
}
|
|
56071
|
+
}
|
|
56072
|
+
`);
|
|
56073
|
+
} else {
|
|
56074
|
+
const block = config.value.compaction;
|
|
56075
|
+
const fields = block && typeof block === "object" && !Array.isArray(block) ? block : undefined;
|
|
56076
|
+
if (fields?.background === false)
|
|
56077
|
+
continue;
|
|
56078
|
+
if (path !== userPath && fields?.background === undefined)
|
|
56079
|
+
continue;
|
|
56080
|
+
const { bom, text } = readJsoncTextForEdit(path);
|
|
56081
|
+
const next = fields ? setJsoncValue(text, ["compaction", "background"], false) : setJsoncValue(text, ["compaction"], { background: false });
|
|
56082
|
+
writeFileAtomic(path, bom + next);
|
|
56083
|
+
}
|
|
56084
|
+
sink.wrote(`Set compaction.background: false in ${path}`);
|
|
56085
|
+
} catch (error) {
|
|
56086
|
+
sink.warn(`Could not set compaction.background in ${path}: ${String(error)}`);
|
|
56087
|
+
}
|
|
56088
|
+
}
|
|
56089
|
+
const after = readOpenCode2BackgroundCompaction(directory);
|
|
56090
|
+
const unchecked = [
|
|
56091
|
+
...after.unreadable,
|
|
56092
|
+
...process.env.OPENCODE_CONFIG_CONTENT ? ["the OPENCODE_CONFIG_CONTENT layer"] : []
|
|
56093
|
+
];
|
|
56094
|
+
if (after.enabled || unchecked.length) {
|
|
56095
|
+
const sources = [
|
|
56096
|
+
...after.enabled ? [after.backgroundSource ?? "OpenCode's default"] : [],
|
|
56097
|
+
...unchecked
|
|
56098
|
+
];
|
|
56099
|
+
sink.warn(`Background compaction may still be enabled. Check compaction.background in: ${[...new Set(sources)].join(", ")}.`);
|
|
56100
|
+
} else {
|
|
56101
|
+
sink.info("Background compaction is disabled in the config files doctor could check. Remote, organization, or managed OpenCode settings may override them.");
|
|
56102
|
+
}
|
|
56103
|
+
sink.info("No OpenCode restart is needed for changes to compaction.background.");
|
|
56104
|
+
}
|
|
56105
|
+
var init_doctor_opencode_background_compaction = __esm(async () => {
|
|
56106
|
+
init_conflict_detector();
|
|
56107
|
+
init_conflict_fixer();
|
|
56108
|
+
init_jsonc_edit();
|
|
56109
|
+
init_atomic_write();
|
|
56110
|
+
init_jsonc_config();
|
|
56111
|
+
init_paths();
|
|
56112
|
+
await init_doctor_opencode2_cache();
|
|
56113
|
+
});
|
|
56114
|
+
|
|
56008
56115
|
// src/commands/doctor-opencode-plugin-duplicates.ts
|
|
56009
56116
|
import { isDeepStrictEqual } from "node:util";
|
|
56010
56117
|
function entryOptions(entry) {
|
|
@@ -56249,7 +56356,7 @@ function removeDeprecatedReasoningAge(config) {
|
|
|
56249
56356
|
|
|
56250
56357
|
// src/commands/doctor-opencode.ts
|
|
56251
56358
|
import { spawnSync as spawnSync10 } from "node:child_process";
|
|
56252
|
-
import { existsSync as existsSync48, mkdtempSync as mkdtempSync4, readFileSync as
|
|
56359
|
+
import { existsSync as existsSync48, mkdtempSync as mkdtempSync4, readFileSync as readFileSync32, rmSync as rmSync9 } from "node:fs";
|
|
56253
56360
|
import { createRequire as createRequire6 } from "node:module";
|
|
56254
56361
|
import { homedir as homedir21, tmpdir as tmpdir4 } from "node:os";
|
|
56255
56362
|
import { dirname as dirname27, join as join41, resolve as resolve20 } from "node:path";
|
|
@@ -56516,7 +56623,7 @@ function collectNpmReleaseAgeWarnings() {
|
|
|
56516
56623
|
if (!existsSync48(npmrcPath))
|
|
56517
56624
|
return ageWarnings;
|
|
56518
56625
|
try {
|
|
56519
|
-
const npmrc =
|
|
56626
|
+
const npmrc = readFileSync32(npmrcPath, "utf-8");
|
|
56520
56627
|
for (const line of npmrc.split(`
|
|
56521
56628
|
`)) {
|
|
56522
56629
|
const trimmed = line.trim();
|
|
@@ -56560,7 +56667,7 @@ async function checkPluginFreshnessForIssue(deps = {}) {
|
|
|
56560
56667
|
return { npmVersions: {} };
|
|
56561
56668
|
let config;
|
|
56562
56669
|
try {
|
|
56563
|
-
config = import_comment_json11.parse(
|
|
56670
|
+
config = import_comment_json11.parse(readFileSync32(paths.opencodeConfig, "utf-8"));
|
|
56564
56671
|
} catch {}
|
|
56565
56672
|
const configDir = dirname27(paths.opencodeConfig);
|
|
56566
56673
|
if (config && !isOpenCodePluginRegistered(config, configDir))
|
|
@@ -56961,7 +57068,7 @@ async function runDoctor2(options = {}) {
|
|
|
56961
57068
|
let magicContextStatusKnown = paths.opencodeConfigFormat === "none";
|
|
56962
57069
|
if (!magicContextStatusKnown) {
|
|
56963
57070
|
try {
|
|
56964
|
-
const config = import_comment_json11.parse(
|
|
57071
|
+
const config = import_comment_json11.parse(readFileSync32(paths.opencodeConfig, "utf-8"));
|
|
56965
57072
|
magicContextInstalled = isOpenCodePluginRegistered(config, dirname27(paths.opencodeConfig));
|
|
56966
57073
|
magicContextStatusKnown = true;
|
|
56967
57074
|
} catch {}
|
|
@@ -57275,7 +57382,7 @@ async function runDoctor2(options = {}) {
|
|
|
57275
57382
|
};
|
|
57276
57383
|
if (paths.opencodeConfigFormat !== "none") {
|
|
57277
57384
|
try {
|
|
57278
|
-
const raw =
|
|
57385
|
+
const raw = readFileSync32(paths.opencodeConfig, "utf-8");
|
|
57279
57386
|
const config = import_comment_json11.parse(raw);
|
|
57280
57387
|
const configName = paths.opencodeConfigFormat === "jsonc" ? "opencode.jsonc" : "opencode.json";
|
|
57281
57388
|
const configDir = dirname27(paths.opencodeConfig);
|
|
@@ -57336,6 +57443,14 @@ async function runDoctor2(options = {}) {
|
|
|
57336
57443
|
const compactionEnabled = resolveCompactionEnabledForDoctor();
|
|
57337
57444
|
const conflictResult = detectConflicts(cwd, { compactionEnabled });
|
|
57338
57445
|
log3.info("Compaction check: file-based; the running server's resolved config may differ — `opencode debug config` is authoritative");
|
|
57446
|
+
checkOpenCodeBackgroundCompaction(cwd, activeInstallation.version, { compactionEnabled, fix: options.fix }, {
|
|
57447
|
+
warn,
|
|
57448
|
+
info: (message) => log3.info(message),
|
|
57449
|
+
wrote: (message) => {
|
|
57450
|
+
pass(message);
|
|
57451
|
+
fixed++;
|
|
57452
|
+
}
|
|
57453
|
+
});
|
|
57339
57454
|
if (conflictResult.hasConflict) {
|
|
57340
57455
|
for (const reason of conflictResult.reasons) {
|
|
57341
57456
|
fail(`Conflict: ${reason}`);
|
|
@@ -57370,7 +57485,7 @@ async function runDoctor2(options = {}) {
|
|
|
57370
57485
|
fixed++;
|
|
57371
57486
|
} else if (existsSync48(paths.tuiConfig)) {
|
|
57372
57487
|
try {
|
|
57373
|
-
const tuiRaw =
|
|
57488
|
+
const tuiRaw = readFileSync32(paths.tuiConfig, "utf-8");
|
|
57374
57489
|
const tuiConfig = import_comment_json11.parse(tuiRaw);
|
|
57375
57490
|
const tuiConfigDir = dirname27(paths.tuiConfig);
|
|
57376
57491
|
const tuiRawPlugins = Array.isArray(tuiConfig?.plugin) ? tuiConfig.plugin : [];
|
|
@@ -57425,7 +57540,7 @@ async function runDoctor2(options = {}) {
|
|
|
57425
57540
|
let embeddingHostConfig = null;
|
|
57426
57541
|
try {
|
|
57427
57542
|
if (paths.opencodeConfigFormat !== "none")
|
|
57428
|
-
embeddingHostConfig = import_comment_json11.parse(
|
|
57543
|
+
embeddingHostConfig = import_comment_json11.parse(readFileSync32(paths.opencodeConfig, "utf-8"));
|
|
57429
57544
|
} catch {}
|
|
57430
57545
|
const embeddingInstalls = getOpenCodeLoadedPluginInstallRoots(hostGeneration, embeddingHostConfig);
|
|
57431
57546
|
const unusedInstalls = embeddingInstalls.others.filter((root) => existsSync48(root));
|
|
@@ -57525,7 +57640,7 @@ ${formatDatabaseRepairGuidance(dbPath)}`);
|
|
|
57525
57640
|
let pluginConfigUse;
|
|
57526
57641
|
if (paths.opencodeConfigFormat !== "none") {
|
|
57527
57642
|
try {
|
|
57528
|
-
pluginConfigUse = readOpenCodePluginConfigUse(import_comment_json11.parse(
|
|
57643
|
+
pluginConfigUse = readOpenCodePluginConfigUse(import_comment_json11.parse(readFileSync32(paths.opencodeConfig, "utf-8")), dirname27(paths.opencodeConfig));
|
|
57529
57644
|
} catch {}
|
|
57530
57645
|
}
|
|
57531
57646
|
const cacheResult = await clearPluginCache({
|
|
@@ -57579,7 +57694,7 @@ ${formatDatabaseRepairGuidance(dbPath)}`);
|
|
|
57579
57694
|
let v2DistTag;
|
|
57580
57695
|
if (paths.opencodeConfigFormat !== "none") {
|
|
57581
57696
|
try {
|
|
57582
|
-
v2DistTag = configuredOpenCodeV2DistTag(import_comment_json11.parse(
|
|
57697
|
+
v2DistTag = configuredOpenCodeV2DistTag(import_comment_json11.parse(readFileSync32(paths.opencodeConfig, "utf-8")));
|
|
57583
57698
|
} catch {}
|
|
57584
57699
|
}
|
|
57585
57700
|
const v2Cache = reportOpenCodeV2PluginCache(checkOpenCodeV2PluginCache({
|
|
@@ -57729,6 +57844,7 @@ var init_doctor_opencode = __esm(async () => {
|
|
|
57729
57844
|
init_v22_backfill_commands(),
|
|
57730
57845
|
init_doctor_cached_plugin_fence(),
|
|
57731
57846
|
init_doctor_harness_relabel(),
|
|
57847
|
+
init_doctor_opencode_background_compaction(),
|
|
57732
57848
|
init_doctor_opencode_cache(),
|
|
57733
57849
|
init_doctor_opencode_plugin_duplicates(),
|
|
57734
57850
|
init_doctor_opencode_plugin_entry(),
|
|
@@ -57999,7 +58115,7 @@ var init_model_chain_health = __esm(() => {
|
|
|
57999
58115
|
});
|
|
58000
58116
|
|
|
58001
58117
|
// src/lib/diagnostics-pi.ts
|
|
58002
|
-
import { existsSync as existsSync49, readdirSync as readdirSync11, readFileSync as
|
|
58118
|
+
import { existsSync as existsSync49, readdirSync as readdirSync11, readFileSync as readFileSync33, statSync as statSync27 } from "node:fs";
|
|
58003
58119
|
import { createRequire as createRequire7 } from "node:module";
|
|
58004
58120
|
import { join as join42 } from "node:path";
|
|
58005
58121
|
function getSelfVersion3() {
|
|
@@ -58032,7 +58148,7 @@ function readJsonc(path) {
|
|
|
58032
58148
|
return { value: {} };
|
|
58033
58149
|
try {
|
|
58034
58150
|
return {
|
|
58035
|
-
value: import_comment_json12.parse(
|
|
58151
|
+
value: import_comment_json12.parse(readFileSync33(path, "utf-8"))
|
|
58036
58152
|
};
|
|
58037
58153
|
} catch (error) {
|
|
58038
58154
|
return {
|
|
@@ -58102,7 +58218,7 @@ function collectPiRecentSessions() {
|
|
|
58102
58218
|
}
|
|
58103
58219
|
function parseHistorianDumpMeta2(path) {
|
|
58104
58220
|
try {
|
|
58105
|
-
const xml =
|
|
58221
|
+
const xml = readFileSync33(path, "utf-8");
|
|
58106
58222
|
const parsed = parseCompartmentOutput(xml);
|
|
58107
58223
|
const factCountByCategory = {};
|
|
58108
58224
|
for (const fact of parsed.facts) {
|
|
@@ -58426,7 +58542,7 @@ var init_logs_pi = __esm(() => {
|
|
|
58426
58542
|
|
|
58427
58543
|
// src/commands/doctor-pi.ts
|
|
58428
58544
|
import { execFileSync as execFileSync9, spawnSync as spawnSync11 } from "node:child_process";
|
|
58429
|
-
import { existsSync as existsSync50, lstatSync as lstatSync6, readdirSync as readdirSync12, readFileSync as
|
|
58545
|
+
import { existsSync as existsSync50, lstatSync as lstatSync6, readdirSync as readdirSync12, readFileSync as readFileSync34, rmSync as rmSync10 } from "node:fs";
|
|
58430
58546
|
import { createRequire as createRequire8 } from "node:module";
|
|
58431
58547
|
import { homedir as homedir22 } from "node:os";
|
|
58432
58548
|
import { basename as basename7, isAbsolute as isAbsolute10, join as join44 } from "node:path";
|
|
@@ -58522,7 +58638,7 @@ function summarize(results) {
|
|
|
58522
58638
|
function readJsonc2(path) {
|
|
58523
58639
|
try {
|
|
58524
58640
|
return {
|
|
58525
|
-
value: import_comment_json13.parse(
|
|
58641
|
+
value: import_comment_json13.parse(readFileSync34(path, "utf-8"))
|
|
58526
58642
|
};
|
|
58527
58643
|
} catch (error) {
|
|
58528
58644
|
return {
|
|
@@ -58705,7 +58821,7 @@ function findPiMagicContextCacheDirs(cwd, expectedVersion, force = false) {
|
|
|
58705
58821
|
const packageJson = join44(path, "package.json");
|
|
58706
58822
|
if (existsSync50(packageJson)) {
|
|
58707
58823
|
try {
|
|
58708
|
-
const pkg = JSON.parse(
|
|
58824
|
+
const pkg = JSON.parse(readFileSync34(packageJson, "utf-8"));
|
|
58709
58825
|
const name = typeof pkg.name === "string" ? pkg.name : "";
|
|
58710
58826
|
const version = typeof pkg.version === "string" ? pkg.version : undefined;
|
|
58711
58827
|
if (name === PACKAGE_NAME2) {
|
|
@@ -59174,7 +59290,7 @@ function piCacheClearBlocker(paths, deps) {
|
|
|
59174
59290
|
function repair2(plan, prompts, deps) {
|
|
59175
59291
|
let fixed = 0;
|
|
59176
59292
|
for (const path of plan.reasoningAgeConfigPaths) {
|
|
59177
|
-
const content =
|
|
59293
|
+
const content = readFileSync34(path, "utf8");
|
|
59178
59294
|
const parsed = readJsonc2(path);
|
|
59179
59295
|
if (parsed.error)
|
|
59180
59296
|
continue;
|