@cortexkit/magic-context 0.49.56 → 0.49.59
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 +282 -183
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1756,9 +1756,6 @@ function getMagicContextHistorianDir(harness = getHarness()) {
|
|
|
1756
1756
|
function getProjectMagicContextDir(directory) {
|
|
1757
1757
|
return path.join(directory, ".cortexkit", "magic-context");
|
|
1758
1758
|
}
|
|
1759
|
-
function getProjectMagicContextHistorianDir(directory) {
|
|
1760
|
-
return path.join(getProjectMagicContextDir(directory), "historian");
|
|
1761
|
-
}
|
|
1762
1759
|
function getOpenCodeStorageDir() {
|
|
1763
1760
|
return path.join(getDataDir(), "opencode", "storage");
|
|
1764
1761
|
}
|
|
@@ -16005,6 +16002,9 @@ function getMagicContextLogPath2(harness) {
|
|
|
16005
16002
|
function getMagicContextHistorianDir2(harness) {
|
|
16006
16003
|
return getMagicContextHistorianDir(harness);
|
|
16007
16004
|
}
|
|
16005
|
+
function getProjectHistorianDumpDir(directory) {
|
|
16006
|
+
return join7(getProjectMagicContextDir(directory), "historian");
|
|
16007
|
+
}
|
|
16008
16008
|
function getOpenCodePluginCacheDir() {
|
|
16009
16009
|
const xdg = process.env.XDG_CACHE_HOME || join7(homedir7(), ".cache");
|
|
16010
16010
|
return join7(xdg, "opencode", "packages");
|
|
@@ -48320,6 +48320,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
48320
48320
|
"[magic-context] storage warning: continuing migration for \x01; the Pi/OMP process-list probe could not run, which commonly means an OS sandbox denied ps. No live Pi harness was confirmed.\x020p",
|
|
48321
48321
|
"native-attachment-cache oversized_core_store session=\x01 stored_byte_charge=\x01 total_budget=\x01 over_budget_by=\x01 consequence=single_session_exceeds_native_cache_budget delta_core_preserved=true\x020s",
|
|
48322
48322
|
"compartment trigger: cheap-skip at \x01% (below proactive floor \x01%) — live-tail upper bound \x01 (persisted=\x01, untagged-memory≤\x01) < triggerBudget \x01; no size trigger possible, skipped full raw read",
|
|
48323
|
+
"OMP auto-learn capture refused for session=\x01: it sends the raw conversation, which Magic Context does not manage; auto-learn capture stays off while Magic Context manages this session",
|
|
48323
48324
|
"ERROR: compaction marker read-back failed harness=pi compactionId=<missing> expectedFirstKept=\x01; further writes disabled for this session manager until restart; leaving marker pending",
|
|
48324
48325
|
"[shadow] backfill scope \x01 for \x01 retired without progress — the chunk writer produced no canonical windows; \x01+ items remain and automatic registration will not retry unchanged candidates",
|
|
48325
48326
|
"transform: unknown provider usage; using wire estimate for priced pass inputTokens=\x01 percentage=\x01 trusted=\x01 wireTokens=\x01 pressureTokens=\x01 grewPastSavedReading=\x01 sizedPlan=clears_reasoning",
|
|
@@ -48370,6 +48371,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
48370
48371
|
"OMP structural comparison skipped: Cursor history blob IDs do not expose prepared turn structure; stale prepared requests are not detected on this pass; session=\x01",
|
|
48371
48372
|
"provider_usage_not_single_request: transform input \x01 exceeds pressure evidence bound \x01; ignoring possible turn-aggregate billing usage and using request estimates",
|
|
48372
48373
|
"transform: unknown provider usage; using saved provider reading for priced pass inputTokens=\x01 percentage=\x01 countPercentage=\x01 sizedPlan=keeps_reasoning+covered_rows",
|
|
48374
|
+
"[mural] skipped for \x01: only \x01/\x01 active memories have current cues the mural font can draw (\x01 more use characters it has no glyph for) (requires \x01 cues or \x01% coverage)",
|
|
48373
48375
|
"OMP dispatch fence disabled for session \x01: verified ephemeral context; session-wide abort cannot distinguish provider operations (side_contexts=\x01 context_passes=\x01)",
|
|
48374
48376
|
'historian failure: source=no-progress reason="historian returned compartments that did not advance past raw message \x01" newCompartmentCount=\x01 lastNewEnd=\x01 priorEnd=\x01',
|
|
48375
48377
|
"transform: unknown provider usage; using wire estimate for priced pass inputTokens=\x01 percentage=\x01 trusted=\x01 wireTokens=\x01 pressureTokens=\x01 sizedPlan=clears_reasoning",
|
|
@@ -48468,6 +48470,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
48468
48470
|
"[magic-context] sqlite writer site=compaction-marker-replace db=opencode acquire_ms=\x01 hold_ms=\x01 work_ms=\x01 end_ms=\x01 outcome=not_acquired",
|
|
48469
48471
|
"system prompt hash changed: \x01 → \x01 (len=\x01), adopting on the request whose messages are already final; presetChanged=unknown elements=[\x01]",
|
|
48470
48472
|
"[magic-context] host stall profiler enabled: threshold \x01ms, sample interval \x01ms, clock calibration unavailable, setup \x01ms, reports in \x01",
|
|
48473
|
+
"prefix trim: boundary \x01; pass=priced; no in-pass trim applied (Refusing a prompt that names more than one Magic Context hidden run)",
|
|
48471
48474
|
"compaction-marker drain: refusing ordinal \x01 because prefix trim through \x01 was not proven; preserving deferred history refresh signal\x021i",
|
|
48472
48475
|
"[magic-context] conflict-detector: resolved v2 config carried no explicit compaction.auto (\x01); falling back to file-based detection",
|
|
48473
48476
|
"[magic-context] sqlite writer site=compaction-marker-inject db=opencode acquire_ms=\x01 hold_ms=\x01 work_ms=\x01 end_ms=\x01 outcome=not_acquired",
|
|
@@ -48475,6 +48478,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
48475
48478
|
"auto-search: decision outcome=timeout reason=worker-busy lanes=\x01 nearMisses=\x01 threshold=\x01 pool=\x01 rows=\x01 workerStarted=\x01 peek=\x01 elapsedMs=\x01",
|
|
48476
48479
|
"history boundary repair: the cached prefix boundary \x01 is not in the host store; rebuilding it on this pass against compartment end \x01\x021i",
|
|
48477
48480
|
"rust compaction-marker admission deferred: reason=output_fit fit=\x01 estimated=\x01 trusted=\x01 proxy_tokens=unavailable proxy_bytes=\x01 limit=\x01",
|
|
48481
|
+
"prefix trim: boundary \x01; pass=defer; no in-pass trim applied (Refusing a prompt that names more than one Magic Context hidden run)",
|
|
48478
48482
|
"prefix trim: boundary \x01; pass=priced; no in-pass trim applied (Hidden child history does not contain this run's registered marker)",
|
|
48479
48483
|
"[magic-context] boot phase 'hooks' exceeded the whole-server \x01ms budget; host startup will continue with Magic Context fail-closed",
|
|
48480
48484
|
"prefix trim: boundary \x01; pass=defer; no in-pass trim applied (Hidden child history does not contain this run's registered marker)",
|
|
@@ -48515,6 +48519,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
48515
48519
|
"auto-search: decision outcome=\x01 reason=worker-error lanes=\x01 nearMisses=\x01 threshold=\x01 pool=\x01 rows=\x01 workerStarted=\x01 peek=\x01 elapsedMs=\x01",
|
|
48516
48520
|
"mc-module: render identity session=\x01 changed=\x01 observed=\x01 coordinator=\x01 transition=\x01 tool_present=\x01 profile=\x01 effective=\x01 persisted=\x01",
|
|
48517
48521
|
"latest-turn thinking recovery: restore no longer possible (missing-thinking-original); removing the turn's thinking instead",
|
|
48522
|
+
"[mural] rendered for \x01: \x01 cues drawn, \x01 left out for space, \x01 left out because the mural font has no glyph for their characters",
|
|
48518
48523
|
"rust compaction-marker admission deferred: reason=capture_inputs fit=\x01 estimated=\x01 trusted=\x01 proxy_tokens=\x01 proxy_bytes=\x01 limit=\x01",
|
|
48519
48524
|
"tag identity recurred after its one repair: serving without a second rebuild (one cache change) session=\x01 identity=\x01 numbers=\x01\x020s",
|
|
48520
48525
|
"[magic-context] fail-closed blocking armed (\x01); primary sessions will error until storage recovers or the build is upgraded",
|
|
@@ -48573,8 +48578,6 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
48573
48578
|
"[dreamer] curate safety refusal: session_id=\x01 memory_id=\x01 verdict=\x01 reason=\x01 original_chars=\x01 replacement_chars=\x01 refused=\x01\x020s,6s",
|
|
48574
48579
|
"[dreamer] retrospective: child rejected \x01-token estimated prompt for size; retrying watermark=\x01 with usable input \x01 -> \x01\x022m",
|
|
48575
48580
|
"[dreamer] retrospective: child rejected \x01-token estimated prompt for size; retrying watermark=\x01 with usable input \x01 -> \x01",
|
|
48576
|
-
"transform: historian did not complete within \x01 s: \x01; finalEstimate=\x01 estimateTrusted=\x01 contextLimit=\x01 emergencyReclaimed=\x01\x024m",
|
|
48577
|
-
"transform: historian did not complete within \x01 s: \x01; finalEstimate=\x01 estimateTrusted=\x01 contextLimit=\x01 emergencyReclaimed=\x01",
|
|
48578
48581
|
"transform: proceeding after bounded historian join; trusted final-wire \x01 fits context limit \x01 after emergency reclaim=\x01\x021m",
|
|
48579
48582
|
"transform: proceeding after bounded historian join; trusted final-wire \x01 fits context limit \x01 after emergency reclaim=\x01",
|
|
48580
48583
|
"compaction-off transition could not verify complete marker cleanup; durable cleanup retry will run on the next pass",
|
|
@@ -48625,6 +48628,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
48625
48628
|
"[magic-context] WARNING: \x01 configured \x01, but OpenCode does not know that model; provider gave no model suggestion\x021m",
|
|
48626
48629
|
"[shadow] skipped duplicate chunk batch for \x01; the same content was submitted within the one-hour provider budget",
|
|
48627
48630
|
"[magic-context] compaction-marker: schema probe failed: \x01. Marker injection disabled until next process restart.",
|
|
48631
|
+
"[mural] skipped for \x01: none of the \x01 overflow cues can be drawn (\x01 use characters the mural font has no glyph for)",
|
|
48628
48632
|
"[magic-context] embedding endpoint blocked: embedding endpoint host \x01 is the AWS IPv6 metadata service (blocked)",
|
|
48629
48633
|
"[magic-context] message_end: detected limit \x01 invalidated by a successful \x01-token request; using Pi contextWindow",
|
|
48630
48634
|
"v2 usage: inputTokens=\x01 contextLimit=\x01 percentage=\x01 responseModel=\x01 draftContextLimit=\x01 pressure=stale-model-ignored\x023m",
|
|
@@ -48722,6 +48726,8 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
48722
48726
|
"raw_fallback_over_context_limit estimated=\x01 trusted=\x01 proxy_bytes=\x01 proxy_tokens=\x01 limit=\x01 early_abort=true",
|
|
48723
48727
|
"TRANSIENT STORAGE FAILURE SQLITE_BUSY_OR_LOCKED: LKG unavailable (\x01); refusing unreduced \x01-message input",
|
|
48724
48728
|
"pending ops WILL APPLY — reason=force_materialization, pendingOps=not loaded (deferred pass) context=\x01%",
|
|
48729
|
+
"transform: historian join refusal: \x01; finalEstimate=\x01 estimateTrusted=\x01 contextLimit=\x01 emergencyReclaimed=\x01\x023m",
|
|
48730
|
+
"transform: historian join refusal: \x01; finalEstimate=\x01 estimateTrusted=\x01 contextLimit=\x01 emergencyReclaimed=\x01",
|
|
48725
48731
|
"EMERGENCY: disarming recovery — no eligible pre-tail history to compact (would otherwise loop at 95%)",
|
|
48726
48732
|
"m[0]/m[1] frozen: session directory unresolved; replaying the frozen prefix and deferring any rebuild",
|
|
48727
48733
|
"variant changed (\x01 -> \x01) on \x01/\x01 without a proven natural cache bust; deferring flush to next natural bust\x020s,2m,3m",
|
|
@@ -48803,6 +48809,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
48803
48809
|
"historian publish stage: stage=dangling-boundary-check status=started elapsed=0.0ms compartments=\x01",
|
|
48804
48810
|
"Pi compaction-marker clear: reason=active-branch-retired endMessageId=\x01 ordinal=\x01 firstKeptEntryId=\x01\x020i",
|
|
48805
48811
|
"v2 refusal: interrupting the turn before the provider request arm=blocking-transform-error cause=\x01",
|
|
48812
|
+
"Oh My Pi spawned session (agent kind sub) has compartments from its source session: kept primary",
|
|
48806
48813
|
"[dreamer] verify safety refusal: memory_id=\x01 verdict=archive reason=directive-shaped-project-rule",
|
|
48807
48814
|
"[dreamer] map-memories: all \x01 path(s) for memory \x01 were rejected; recording host_rejected_fallback",
|
|
48808
48815
|
"transform: model switch \x01 -> \x01/\x01 reset — percentage=\x01% tokens=\x01 — clearing stale model-specific state\x020s,1m,2m",
|
|
@@ -48822,6 +48829,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
48822
48829
|
"[dreamer] verify safety refusal: memory_id=\x01 verdict=update reason=directive-shaped-project-rule",
|
|
48823
48830
|
"transform: model switch \x01 -> \x01 reset — percentage=\x01% tokens=\x01 — clearing stale model-specific state\x020s",
|
|
48824
48831
|
"rust fold published compartments through ordinal \x01 (previously \x01); arming the deferred-note nudge",
|
|
48832
|
+
"v2 usage: detected limit \x01 invalidated by a successful \x01-token request on \x01; using catalog/default\x022m",
|
|
48825
48833
|
"TRANSIENT STORAGE FAILURE \x01: LKG unavailable (compaction_off); refusing unreduced \x01-message input",
|
|
48826
48834
|
"[magic-context] compaction-marker: flip-off cleanup for \x01 removed \x01 lineage(s) (\x01 rows), retained \x01\x020s",
|
|
48827
48835
|
"[magic-context] WARN: invalid workspace share_categories; sharing no foreign memory categories \x01",
|
|
@@ -48927,6 +48935,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
48927
48935
|
"mc-module: trailing-blank-heal session=\x01 mid=\x01 reason=source_without_trailing_blank pass_row=\x01",
|
|
48928
48936
|
"recomp prompt fit: chunkTokens=\x01 sessionReferences=\x01 memories=\x01/\x01 seeds=\x01/\x01 requestedChunkTokens=\x01",
|
|
48929
48937
|
"rust compaction-marker drain: retryable failure after module row \x01; pending target retained \x01",
|
|
48938
|
+
"transform: clearing detected limit \x01 and overflow recovery recorded for \x01; outgoing model is \x01\x021m",
|
|
48930
48939
|
"ctx_reduce permission is denied by OpenCode; frozen guidance remains until session restart",
|
|
48931
48940
|
"disabled by historian.host_runner.enabled=false; queued runs are left for another claimant",
|
|
48932
48941
|
"v2 refusal: interrupting the turn before the provider request arm=blocking-transform-error",
|
|
@@ -49158,9 +49167,12 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49158
49167
|
"historian publish stage: stage=validate status=completed elapsed=\x01ms compartments=\x01",
|
|
49159
49168
|
"mc-pass-stage session=\x01 stage=historian_inline_wait event=end outcome=\x01 elapsed_ms=\x01\x020s",
|
|
49160
49169
|
"transform: over-window first-pass check could not estimate the incoming history: \x01",
|
|
49170
|
+
"ctx_reduce served record failed after the request was decided; serving the pass:",
|
|
49161
49171
|
"final wire usage capture failed after the request was decided; serving the pass:",
|
|
49162
49172
|
"Pi publication commit_failed reason=envelope_unreadable; serving managed context",
|
|
49163
49173
|
"Pi publication commit_failed reason=number_write_failed; serving managed context",
|
|
49174
|
+
"request tool list changed: ctx_reduce added; tag prefixes return on this rebuild",
|
|
49175
|
+
"request tool list changed: ctx_reduce removed; tag prefixes stop on this rebuild",
|
|
49164
49176
|
"transform refused degraded pass site=merged-reasoning-strip-persistence-failure:",
|
|
49165
49177
|
"model changed (\x01/\x01 -> \x01/\x01), clearing historian failure state and reasoning watermark\x020m,1m,2m,3m",
|
|
49166
49178
|
"prompt_surface.guidance_override_path (\x01) is not a file; using built-in guidance.\x020p",
|
|
@@ -49255,8 +49267,6 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49255
49267
|
"historian no-op: chunk empty after filtering (messageCount=\x01, textLen=\x01) range=\x01-\x01",
|
|
49256
49268
|
"historian publish stage: stage=validate status=failed elapsed=\x01ms compartments=\x01",
|
|
49257
49269
|
"tag identity fold guard could not be written; serving the duplicate unmerged: \x01",
|
|
49258
|
-
"transform: \x01; finalEstimate=\x01 estimateTrusted=\x01 contextLimit=\x01 emergencyReclaimed=\x01\x023m",
|
|
49259
|
-
"transform: \x01; finalEstimate=\x01 estimateTrusted=\x01 contextLimit=\x01 emergencyReclaimed=\x01",
|
|
49260
49270
|
"[magic-context] event message.updated: no assistant info extracted from event",
|
|
49261
49271
|
"auto-embed scheduling failed after the request was decided; serving the pass:",
|
|
49262
49272
|
"compartment injection cache in degraded mode (null boundary), forcing rebuild",
|
|
@@ -49654,6 +49664,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49654
49664
|
"channel2 terminal-run intent clear failed; leaving lease to heal:",
|
|
49655
49665
|
"compaction-off render changed the head: stripping signed thinking",
|
|
49656
49666
|
"historian publish stage: stage=parse status=started elapsed=0.0ms",
|
|
49667
|
+
"Oh My Pi spawned session (agent kind sub): recorded as a subagent",
|
|
49657
49668
|
"transform refused degraded pass site=m0-m1-injection-degradation:",
|
|
49658
49669
|
"transform refused degraded pass site=overflow-state-read-failure:",
|
|
49659
49670
|
"transform refused degraded pass site=tagging-persistence-failure:",
|
|
@@ -49917,6 +49928,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
49917
49928
|
"[magic-context] timer-triggered maintenance check failed: \x01",
|
|
49918
49929
|
"[magic-context] v2 event handler failed (type=\x01, session=\x01) \x01\x021s",
|
|
49919
49930
|
"event message.removed: auto-search decision unchanged for \x01\x020i",
|
|
49931
|
+
"historian join refusal could not read the failure record: \x01",
|
|
49920
49932
|
"historian: prompt refused before opening a child session: \x01",
|
|
49921
49933
|
"historian[\x01] terminal @\x01ms stopReason=\x01 textLen=\x01 hasToolCall=\x01",
|
|
49922
49934
|
"mc-module: classify attempt=1 model=\x01 session=host outcome=\x01",
|
|
@@ -50362,6 +50374,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
50362
50374
|
"compartment agent: queued \x01 drops for messages \x01-\x01",
|
|
50363
50375
|
"compartment agent: recomp unhandled rejection: \x01",
|
|
50364
50376
|
"event session.compacted marker cleanup failed: \x01",
|
|
50377
|
+
"historian repeated-failure warning sent: count=\x01",
|
|
50365
50378
|
"historian trigger eval: getContextUsage threw: \x01",
|
|
50366
50379
|
"single-store embedding drain failed (ignored): \x01",
|
|
50367
50380
|
"system prompt meta persist failed (fail-open): \x01",
|
|
@@ -50529,6 +50542,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
50529
50542
|
"event completion clock persistence failed: \x01",
|
|
50530
50543
|
"heuristic cleanup stage: stage=\x01 elapsed=\x01ms \x01",
|
|
50531
50544
|
"historian failure: subagent run failed (\x01): \x01",
|
|
50545
|
+
"historian repeated-failure warning failed: \x01",
|
|
50532
50546
|
"lkg wrapper replay emergency check failed: \x01",
|
|
50533
50547
|
"lkg_fit_basis=host_metadata measured_input=\x01",
|
|
50534
50548
|
"mc-module: [\x01] signed thinking reset reason=\x01",
|
|
@@ -50547,6 +50561,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
50547
50561
|
"dreamer classify output hit the length cap",
|
|
50548
50562
|
"event completion clock persistence failed:",
|
|
50549
50563
|
"generate replay capture skipped: no-anchor",
|
|
50564
|
+
"historian repeated-failure warning failed:",
|
|
50550
50565
|
"lkg wrapper replay emergency check failed:",
|
|
50551
50566
|
"project registration after publish failed:",
|
|
50552
50567
|
"reasoning removal: drop mode write failed:",
|
|
@@ -50576,6 +50591,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
50576
50591
|
"event session.created persistence failed: \x01",
|
|
50577
50592
|
"event session.deleted persistence failed: \x01",
|
|
50578
50593
|
"frozen_fit_unproven module=unproven limit=\x01",
|
|
50594
|
+
"historian repeated-failure warning failed \x01",
|
|
50579
50595
|
"historian: clearEmergencyRecovery failed: \x01",
|
|
50580
50596
|
"project identity warning delivery failed: \x01",
|
|
50581
50597
|
"rust host runner launch failed (ignored): \x01",
|
|
@@ -50588,6 +50604,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
50588
50604
|
"event session.created persistence failed:",
|
|
50589
50605
|
"event session.deleted persistence failed:",
|
|
50590
50606
|
"heuristics WILL NOT RUN — reason=disabled",
|
|
50607
|
+
"historian repeated-failure warning failed",
|
|
50591
50608
|
"raw_fallback_refused completeness=partial",
|
|
50592
50609
|
"recomp skipped: /ctx-wrapup became active",
|
|
50593
50610
|
"rust host runner launch failed (ignored):",
|
|
@@ -50753,6 +50770,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
50753
50770
|
"[migrations] migration worker ready: \x01\x020p",
|
|
50754
50771
|
"collectMessageEntryIdsStrict failed: \x01",
|
|
50755
50772
|
"compartment agent: finalizer failed: \x01",
|
|
50773
|
+
"ctx_reduce served record unreadable: \x01",
|
|
50756
50774
|
"dreamer token budget: finalize fired \x01",
|
|
50757
50775
|
"event session.error handling failed: \x01",
|
|
50758
50776
|
"host checkpoint head: changed=\x01 proof=\x01",
|
|
@@ -50769,6 +50787,8 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
50769
50787
|
"WARN: shutdown: dreamer drain threw: \x01",
|
|
50770
50788
|
"[dreamer] scheduled task run failed:",
|
|
50771
50789
|
"compartment agent: finalizer failed:",
|
|
50790
|
+
"ctx_reduce served record not written",
|
|
50791
|
+
"ctx_reduce served record unreadable:",
|
|
50772
50792
|
"dreamer token budget: finalize fired",
|
|
50773
50793
|
"event session.error handling failed:",
|
|
50774
50794
|
"lkg wrapper replay fit check failed:",
|
|
@@ -51272,6 +51292,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
51272
51292
|
"memory",
|
|
51273
51293
|
"recomp",
|
|
51274
51294
|
"pct|\x01|\x01|\x01\x020s,1m",
|
|
51295
|
+
"toolu_\x01",
|
|
51275
51296
|
"WARN \x01 \x01",
|
|
51276
51297
|
"WARN: \x01\x020m",
|
|
51277
51298
|
"WARN: \x01",
|
|
@@ -51280,6 +51301,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
51280
51301
|
"error",
|
|
51281
51302
|
"stale",
|
|
51282
51303
|
"\x01:file\x01",
|
|
51304
|
+
"call_\x01",
|
|
51283
51305
|
"note:\x01",
|
|
51284
51306
|
"rust.\x01",
|
|
51285
51307
|
"WARN \x01",
|
|
@@ -51299,7 +51321,7 @@ var init_issue_log_templates_generated = __esm(() => {
|
|
|
51299
51321
|
}
|
|
51300
51322
|
return { parts, slots };
|
|
51301
51323
|
});
|
|
51302
|
-
ISSUE_LOG_IDENTIFIERS = "abort,aborted,above_cap,accepted,acquire,adopted,agent,agent-drops-applied,aligned,already-current,already-present,already_ran_this_turn,ambiguous,ambiguous-rewrite,anchor-missing,anchors-disagree,anthropic-continue,appended,applied,archive,assistant,attachment,attempt_mismatch,audio,auth_failed,auto_search_hint,backoff,band-crossing,band-deescalation,baseline-reset,baseline-unavailable,baseline-unevaluable,batch,batch-timeout,behind,below-emergency-band,below-threshold,boot_recovery,boundary,boundary_repair,busy,bytes,cache_hit,cache_invalid,cached_m1_missing,cadence-growth,cadence-refire,candidate-preparation,candidate_conflict,candidate_loss,candidate_rows_changed,candidates,capture_failed,cas-exhausted,cas-exhaustion,catalog,category,ceiling-threshold-met,changes-request,channel-2-ceiling-nudge,checkpoint,chunk_empty_canonical_text,chunk_fts_mapping_incomplete,chunk_partial_vector_set,chunk_window_contract_mismatch,cleared_reasoning_through_tag,close,closed-book,commit_clusters,committed,compaction,compartment-removed,compartment_render_epoch,compiled-check,compressed,compressor,config-re-read,conflict,content,content-loss,context_boundary,cooldown_active,count,coverage_fold,ctx_search_hint,custom_tool_call,darwin,data,date-cwd,deadline,defer,deferred,deferred_materialization,deferred_publication,definitely-no-cut,degraded,destination-not-empty,diagnostics,dimensions_mismatch,directive-shaped-project-rule,directory,disabled,discarded_last,divergent,document,done,drained,dreamer,dreamer-task,drift,drop_seed,duplicate_submission_budget,embed,embedded,empty,empty-session,empty_output,end_block_index,endpoint_unsupported,entry,entry-removed,envelope_unreadable,epoch_change,error,error_content,error_text,evaluate-smart-notes,exact-ordinal-ids,exception,excluded,execute,exited,expired,explicit_flush,failed,fallback,fatal,fenced_path,file,file_contains,first_render,fit_retry,flush,fold,force,force_band,force_materialization,found,frozen_slot,fts-rowid-backfill,full,function_call,generation-invalidated,git_commit_after,git_identity_unavailable,git_tag_matching,has-state,heavy_reasoning,historian,historian-editor,historian_editor,hold,home_directory,host,host-checkpoint,host_compaction,host_cut_before_watermark,host_history_change,host_rerender,http_error,identity_paused,image,images,incremental,indexed,injector,input,input_text,intact,invalid-pid,invalid_prompt,invalid_scheme,invocation,io,latest_turn_thinking_removed,leaked-id,lease_active,legacy,length,limit,live-geometry,lkg_anthropic_reasoning_run_invalid,lkg_content_mismatch,lkg_invalidated_reshape,lkg_miss,lkg_model_mismatch,lkg_output_mapping_unavailable,lkg_recovery_input_rebuild,lkg_recovery_unproven,lkg_restart_head_changed,lkg_restart_rebuild,lkg_seam_invalid,lkg_system_state_mismatch,lkg_unsafe_seam,m1_delta,magic-context-host-stall,maintain-docs,malformed,management_surface,manual-full-recomp,manual-wrapup-empty,max_mutation_id,memory,memory_hash_guard_rejected,merged-reasoning-strip-exception,merged-reasoning-strip-persistence-failure,message,messages,migrated,migration_guard,migration_required,mismatch,missing,missing-active-same-category-successor,missing_tool_messages,model_change,model_failed,model_or_limit_changed,mtime_after,mutation_drift,native,network_error,newer_schema,no-anchor,no-file,no-output,no-result,no_assistant,no_head,no_originating_cache_bust,no_recent_heavy_reasoning,non-finite-input,non_zero_exit,none,not-a-fork,not-accepted,not-ready,not-text-user,not_a_repo,not_certified,not_found,not_owned,not_tracked,note,note_nudge_anchor,object,ok,omp,opaque,open-tool-arc,openai-codex-responses,openai-responses,opencode,opencode2,orphan_tool_message,other,output_text,overflow,oversized,ownership_lost,pair_commit_failed,parent-missing,parse,parse-invalid,parse_failed,partial,partial-message-boundary,partial-recomp,parts,pass,pass-cap,patch,path_exists,pending_agent_drop,pending_materialization,pi,placeholder,polarity-missing-mechanism,populated,post-reduce-band-escalation,post-reduce-baseline-pending,post-reduce-compliance-grace,post-reduce-regrowth-reached,prepared-row,pressure_refold,prewarm,primary,probe_required,proceed,process,processed_image,profile_transition,prohibition-missing-marker,project,project_change,project_memory_epoch,projected_headroom,provider-overflow-abort,provider_error,provider_returned_no_vectors,publication-failed,query,range,ratio-below-ceiling,ratio-below-gentle,raw,read-outstanding,read_error,ready,reason,reasoning,reasoning-removal-persistence-failure,reasoning-removal-read-failure,recent-reduce-refresh,reclaimable-below-floor,recomp,reconnect,recovery-request-over-limit,recovery_prefix_released,recovery_tail_normalized,redacted_reasoning,redacted_thinking,refresh,refusal-grade-final-wire-over-limit,registration_retired_during_embed,release,reminder-strip,renew,repaired,replace,replay,resolved,response,restore,result,retry,retryable-failure,rpc_error,run,scan,scheduler_defer,schema_fence,seam-temporal-strip,search-archive,search-failure,search-limit,seeded,server_tool_use,session-content,shifted,size-walk,skip,skipped,snapshot,source,source-revision,source_changed,source_removed,spawn-failed,spawn_failed,stacked,stale,stale-skip,stale_reduce,stale_snapshot,stalled,stalled_no_progress,start,start-failed,start_block_index,steer,step-finish,step-start,step_limit,sticky-turn-floor,stop,stopped,storage,storage-busy,storage_failure,store_not_found,store_schema_unknown,store_unreadable,string,strip,strip_seed,structural,subtask,summary,summary_message,superpowers-bootstrap,superseded,synthetic-boundary-merged,synthetic-kept-entry,system,system_hash,system_injected,tag,tag-delta,tag-identity-rebuild-failed,tag-identity-recurring,tag-identity-repair-once,tag-identity-repair-pending,tag-summary,tag_identity_repair,tag_prefix,tail-below-minimum,tail_size,target-superseded,test-legacy,text,thinking,thinking_binding,thinking_hold,timeout,timeout-circuit-breaker,token-budget,token_budget,too-short,tool,tool-pair,tool-result,tool_call,tool_definitions,tool_provider,tool_result,tool_search_tool_result,tool_use,transform,transient,truncated,trusted-final-wire-disarm,ttl_expiry,ttl_idle,turn,type,unanchored,unavailable,unbalanced-parens,uncaptured_replay,uncertain,unknown,unknown_write_rejection,unmatched_tool_call_id,unplaceable,unreadable-branch,unregistered,unresolved,update,upgrade,upgrade_state,url,usage,user,user-memories,user-profile-is-not-project-memory,user_flush,user_memory_review,v1,v2,v2-archive-read,v2-archive-ready,v2-archive-result,validated,validation-failed,variant_change,verbose,verified,verify,video,view_error,waiting,waiting-for-entry,weak_lookahead_final_compartment,web_search_tool_result,whole-session-smaller-than-tail,worker-busy,worker-error,worker-failed,wrapup,x64".split(",");
|
|
51324
|
+
ISSUE_LOG_IDENTIFIERS = "abort,aborted,above_cap,accepted,acquire,adopted,agent,agent-drops-applied,aligned,already-current,already-present,already_ran_this_turn,ambiguous,ambiguous-rewrite,anchor-missing,anchors-disagree,anthropic-continue,appended,applied,archive,assistant,assistant-message,attachment,attempt_mismatch,audio,auth_failed,auto_search_hint,backoff,band-crossing,band-deescalation,baseline-reset,baseline-unavailable,baseline-unevaluable,batch,batch-timeout,behind,below-emergency-band,below-threshold,boot_recovery,boundary,boundary_repair,busy,bytes,cache_hit,cache_invalid,cached_m1_missing,cadence-growth,cadence-refire,call,candidate-preparation,candidate_conflict,candidate_loss,candidate_rows_changed,candidates,capture_failed,cas-exhausted,cas-exhaustion,catalog,category,ceiling-threshold-met,changes-request,channel-2-ceiling-nudge,checkpoint,chunk_empty_canonical_text,chunk_fts_mapping_incomplete,chunk_partial_vector_set,chunk_window_contract_mismatch,cleared_reasoning_through_tag,close,closed-book,commit_clusters,committed,compaction,compartment-removed,compartment_render_epoch,compiled-check,compressed,compressor,config-re-read,conflict,content,content-loss,context_boundary,cooldown_active,count,coverage_fold,ctx_search_hint,custom_tool_call,darwin,data,date-cwd,deadline,defer,deferred,deferred_materialization,deferred_publication,definitely-no-cut,degraded,destination-not-empty,diagnostics,dimensions_mismatch,directive-shaped-project-rule,directory,disabled,discarded_last,divergent,document,done,drained,dreamer,dreamer-task,drift,drop_seed,duplicate_submission_budget,embed,embedded,empty,empty-session,empty_output,end_block_index,endpoint_unsupported,entry,entry-removed,envelope_unreadable,epoch_change,error,error_content,error_text,evaluate-smart-notes,exact-ordinal-ids,exception,excluded,execute,exited,expired,explicit_flush,failed,fallback,fatal,fenced_path,file,file_contains,first_render,fit_retry,flush,fold,force,force_band,force_materialization,found,frozen_slot,fts-rowid-backfill,full,function_call,generation-invalidated,git_commit_after,git_identity_unavailable,git_tag_matching,has-state,heavy_reasoning,historian,historian-editor,historian_editor,hold,home_directory,host,host-checkpoint,host_compaction,host_cut_before_watermark,host_history_change,host_rerender,http_error,identity_paused,image,images,incremental,indexed,injector,input,input_text,intact,invalid-pid,invalid_prompt,invalid_scheme,invocation,io,latest_turn_thinking_removed,leaked-id,lease_active,legacy,length,limit,live-geometry,lkg_anthropic_reasoning_run_invalid,lkg_content_mismatch,lkg_invalidated_reshape,lkg_miss,lkg_model_mismatch,lkg_output_mapping_unavailable,lkg_recovery_input_rebuild,lkg_recovery_unproven,lkg_restart_head_changed,lkg_restart_rebuild,lkg_seam_invalid,lkg_system_state_mismatch,lkg_unsafe_seam,m1_delta,magic-context-host-stall,maintain-docs,malformed,management_surface,manual-full-recomp,manual-wrapup-empty,max_mutation_id,memory,memory_hash_guard_rejected,merged-reasoning-strip-exception,merged-reasoning-strip-persistence-failure,message,messages,migrated,migration_guard,migration_required,mismatch,missing,missing-active-same-category-successor,missing_tool_messages,model_change,model_failed,model_or_limit_changed,mtime_after,mutation_drift,native,network_error,newer_schema,no-anchor,no-file,no-output,no-result,no_assistant,no_head,no_originating_cache_bust,no_recent_heavy_reasoning,non-finite-input,non_zero_exit,none,not-a-fork,not-accepted,not-ready,not-text-user,not_a_repo,not_certified,not_found,not_owned,not_tracked,note,note_nudge_anchor,object,ok,omp,opaque,open-tool-arc,openai-codex-responses,openai-responses,opencode,opencode2,orphan_tool_message,other,output,output_text,overflow,oversized,ownership_lost,pair_commit_failed,parent-missing,parse,parse-invalid,parse_failed,partial,partial-message-boundary,partial-recomp,parts,pass,pass-cap,patch,path_exists,pending_agent_drop,pending_materialization,pi,placeholder,polarity-missing-mechanism,populated,post-reduce-band-escalation,post-reduce-baseline-pending,post-reduce-compliance-grace,post-reduce-regrowth-reached,prepared-row,pressure_refold,prewarm,primary,probe_required,proceed,process,processed_image,profile_transition,prohibition-missing-marker,project,project_change,project_memory_epoch,projected_headroom,provider-overflow-abort,provider_error,provider_returned_no_vectors,publication-failed,query,range,ratio-below-ceiling,ratio-below-gentle,raw,read-outstanding,read_error,ready,reason,reasoning,reasoning-removal-persistence-failure,reasoning-removal-read-failure,recent-reduce-refresh,reclaimable-below-floor,recomp,reconnect,recovery-request-over-limit,recovery_prefix_released,recovery_tail_normalized,redacted_reasoning,redacted_thinking,refresh,refusal-grade-final-wire-over-limit,registration_retired_during_embed,release,reminder-strip,renew,repaired,replace,replay,resolved,response,restore,result,retry,retryable-failure,rpc_error,run,scan,scheduler_defer,schema_fence,seam-temporal-strip,search-archive,search-failure,search-limit,seeded,server_tool_use,session-content,shifted,size-walk,skip,skipped,snapshot,source,source-revision,source_changed,source_removed,spawn-failed,spawn_failed,stacked,stale,stale-skip,stale_reduce,stale_snapshot,stalled,stalled_no_progress,start,start-failed,start_block_index,steer,step-finish,step-start,step_limit,sticky-turn-floor,stop,stopped,storage,storage-busy,storage_failure,store_not_found,store_schema_unknown,store_unreadable,string,strip,strip_seed,structural,subtask,summary,summary_message,superpowers-bootstrap,superseded,synthetic-boundary-merged,synthetic-kept-entry,system,system_hash,system_injected,tag,tag-delta,tag-identity-rebuild-failed,tag-identity-recurring,tag-identity-repair-once,tag-identity-repair-pending,tag-summary,tag_identity_repair,tag_prefix,tail-below-minimum,tail_size,target-superseded,test-legacy,text,thinking,thinking_binding,thinking_hold,timeout,timeout-circuit-breaker,token-budget,token_budget,too-short,tool,tool-pair,tool-result,tool_call,tool_definitions,tool_provider,tool_result,tool_search_tool_result,tool_use,transform,transient,truncated,trusted-final-wire-disarm,ttl_expiry,ttl_idle,turn,type,unanchored,unavailable,unbalanced-parens,uncaptured_replay,uncertain,unknown,unknown_write_rejection,unmatched_tool_call_id,unplaceable,unreadable-branch,unregistered,unresolved,update,upgrade,upgrade_state,url,usage,user,user-memories,user-profile-is-not-project-memory,user_flush,user_memory_review,v1,v2,v2-archive-read,v2-archive-ready,v2-archive-result,validated,validation-failed,variant_change,verbose,verified,verify,video,view_error,waiting,waiting-for-entry,weak_lookahead_final_compartment,web_search_tool_result,whole-session-smaller-than-tail,worker-busy,worker-error,worker-failed,wrapup,x64".split(",");
|
|
51303
51325
|
});
|
|
51304
51326
|
|
|
51305
51327
|
// src/lib/log-lines.ts
|
|
@@ -53963,10 +53985,45 @@ var init_tui_config = __esm(() => {
|
|
|
53963
53985
|
PLUGIN_ENTRY = `${PLUGIN_NAME2}@latest`;
|
|
53964
53986
|
});
|
|
53965
53987
|
|
|
53988
|
+
// src/lib/historian-dump-dirs.ts
|
|
53989
|
+
import { existsSync as existsSync46, readdirSync as readdirSync10, statSync as statSync25 } from "node:fs";
|
|
53990
|
+
import { join as join36 } from "node:path";
|
|
53991
|
+
function scanHistorianDumpFiles(dir) {
|
|
53992
|
+
if (!existsSync46(dir))
|
|
53993
|
+
return [];
|
|
53994
|
+
try {
|
|
53995
|
+
return readdirSync10(dir).filter((name) => name.endsWith(".xml")).map((name) => {
|
|
53996
|
+
const stat = statSync25(join36(dir, name));
|
|
53997
|
+
return { name, mtime: stat.mtimeMs, sizeKb: Math.round(stat.size / 1024) };
|
|
53998
|
+
}).sort((a, b) => b.mtime - a.mtime);
|
|
53999
|
+
} catch {
|
|
54000
|
+
return [];
|
|
54001
|
+
}
|
|
54002
|
+
}
|
|
54003
|
+
function scanHistorianSessionDumpDirs(root) {
|
|
54004
|
+
if (!existsSync46(root))
|
|
54005
|
+
return [];
|
|
54006
|
+
const sessions = [];
|
|
54007
|
+
try {
|
|
54008
|
+
for (const entry of readdirSync10(root, { withFileTypes: true })) {
|
|
54009
|
+
if (!entry.isDirectory())
|
|
54010
|
+
continue;
|
|
54011
|
+
const dir = join36(root, entry.name);
|
|
54012
|
+
const files = scanHistorianDumpFiles(dir);
|
|
54013
|
+
if (files.length > 0)
|
|
54014
|
+
sessions.push({ sessionId: entry.name, dir, files });
|
|
54015
|
+
}
|
|
54016
|
+
} catch {
|
|
54017
|
+
return [];
|
|
54018
|
+
}
|
|
54019
|
+
return sessions.sort((a, b) => (b.files[0]?.mtime ?? 0) - (a.files[0]?.mtime ?? 0));
|
|
54020
|
+
}
|
|
54021
|
+
var init_historian_dump_dirs = () => {};
|
|
54022
|
+
|
|
53966
54023
|
// src/lib/diagnostics-opencode.ts
|
|
53967
|
-
import { existsSync as
|
|
54024
|
+
import { existsSync as existsSync47, readFileSync as readFileSync29, statSync as statSync26 } from "node:fs";
|
|
53968
54025
|
import { createRequire as createRequire4 } from "node:module";
|
|
53969
|
-
import { join as
|
|
54026
|
+
import { join as join37 } from "node:path";
|
|
53970
54027
|
function getSelfVersion() {
|
|
53971
54028
|
const require2 = createRequire4(import.meta.url);
|
|
53972
54029
|
for (const relPath of ["../../package.json", "../package.json"]) {
|
|
@@ -53990,7 +54047,7 @@ function readLegacyCachedVersion(root) {
|
|
|
53990
54047
|
function collectOpenCodePluginCacheReport(hostGeneration, opencodeConfig, npmVersions = {}) {
|
|
53991
54048
|
const installs = [];
|
|
53992
54049
|
for (const root of getOpenCodePluginCacheRoots()) {
|
|
53993
|
-
if (!
|
|
54050
|
+
if (!existsSync47(root))
|
|
53994
54051
|
continue;
|
|
53995
54052
|
const spec = root.endsWith("@latest") ? "latest" : "(bare)";
|
|
53996
54053
|
installs.push({
|
|
@@ -54038,7 +54095,7 @@ function getStorageResolution() {
|
|
|
54038
54095
|
}
|
|
54039
54096
|
function fileSize(path) {
|
|
54040
54097
|
try {
|
|
54041
|
-
return
|
|
54098
|
+
return existsSync47(path) ? statSync26(path).size : 0;
|
|
54042
54099
|
} catch {
|
|
54043
54100
|
return 0;
|
|
54044
54101
|
}
|
|
@@ -54050,7 +54107,7 @@ function sanitizeValue(value) {
|
|
|
54050
54107
|
return sanitizeConfigValue(value);
|
|
54051
54108
|
}
|
|
54052
54109
|
function readConfig3(path) {
|
|
54053
|
-
if (!
|
|
54110
|
+
if (!existsSync47(path))
|
|
54054
54111
|
return { value: null };
|
|
54055
54112
|
try {
|
|
54056
54113
|
const raw = readFileSync29(path, "utf-8");
|
|
@@ -54110,46 +54167,36 @@ function parseHistorianDumpMeta(path) {
|
|
|
54110
54167
|
return { error: error instanceof Error ? error.message : String(error) };
|
|
54111
54168
|
}
|
|
54112
54169
|
}
|
|
54170
|
+
function summarizeDumps(dir, files, limit) {
|
|
54171
|
+
const now = Date.now();
|
|
54172
|
+
return files.slice(0, limit).map((entry) => {
|
|
54173
|
+
const meta = parseHistorianDumpMeta(join37(dir, entry.name));
|
|
54174
|
+
const summary = {
|
|
54175
|
+
name: entry.name,
|
|
54176
|
+
ageMinutes: Math.round((now - entry.mtime) / 60000),
|
|
54177
|
+
sizeKb: entry.sizeKb
|
|
54178
|
+
};
|
|
54179
|
+
if ("error" in meta) {
|
|
54180
|
+
summary.parseError = meta.error;
|
|
54181
|
+
} else {
|
|
54182
|
+
summary.meta = meta;
|
|
54183
|
+
}
|
|
54184
|
+
return summary;
|
|
54185
|
+
});
|
|
54186
|
+
}
|
|
54113
54187
|
function listDumpsInDir(dir, limit) {
|
|
54114
|
-
|
|
54115
|
-
|
|
54116
|
-
try {
|
|
54117
|
-
const entries = readdirSync10(dir).filter((name) => name.endsWith(".xml")).map((name) => {
|
|
54118
|
-
const stat = statSync25(join36(dir, name));
|
|
54119
|
-
return {
|
|
54120
|
-
name,
|
|
54121
|
-
mtime: stat.mtimeMs,
|
|
54122
|
-
sizeKb: Math.round(stat.size / 1024)
|
|
54123
|
-
};
|
|
54124
|
-
}).sort((a, b) => b.mtime - a.mtime);
|
|
54125
|
-
const now = Date.now();
|
|
54126
|
-
const recent = entries.slice(0, limit).map((entry) => {
|
|
54127
|
-
const meta = parseHistorianDumpMeta(join36(dir, entry.name));
|
|
54128
|
-
const summary = {
|
|
54129
|
-
name: entry.name,
|
|
54130
|
-
ageMinutes: Math.round((now - entry.mtime) / 60000),
|
|
54131
|
-
sizeKb: entry.sizeKb
|
|
54132
|
-
};
|
|
54133
|
-
if ("error" in meta) {
|
|
54134
|
-
summary.parseError = meta.error;
|
|
54135
|
-
} else {
|
|
54136
|
-
summary.meta = meta;
|
|
54137
|
-
}
|
|
54138
|
-
return summary;
|
|
54139
|
-
});
|
|
54140
|
-
return { count: entries.length, recent };
|
|
54141
|
-
} catch {
|
|
54142
|
-
return { count: 0, recent: [] };
|
|
54143
|
-
}
|
|
54188
|
+
const files = scanHistorianDumpFiles(dir);
|
|
54189
|
+
return { count: files.length, recent: summarizeDumps(dir, files, limit) };
|
|
54144
54190
|
}
|
|
54145
|
-
function collectHistorianDumps(recentSessions) {
|
|
54191
|
+
function collectHistorianDumps(recentSessions, historianRoot = getMagicContextHistorianDir2("opencode")) {
|
|
54192
|
+
const sessionDirs = scanHistorianSessionDumpDirs(historianRoot);
|
|
54146
54193
|
const buckets = new Map;
|
|
54147
54194
|
for (const session of recentSessions) {
|
|
54148
54195
|
const dir = session.directory;
|
|
54149
54196
|
if (!dir)
|
|
54150
54197
|
continue;
|
|
54151
|
-
const projectHistorianDir =
|
|
54152
|
-
const listing = listDumpsInDir(projectHistorianDir,
|
|
54198
|
+
const projectHistorianDir = getProjectHistorianDumpDir(dir);
|
|
54199
|
+
const listing = listDumpsInDir(projectHistorianDir, DUMPS_PER_BUCKET_LIMIT);
|
|
54153
54200
|
const existing = buckets.get(dir);
|
|
54154
54201
|
if (existing) {
|
|
54155
54202
|
if (!existing.sessionIds.includes(session.sessionId)) {
|
|
@@ -54167,12 +54214,21 @@ function collectHistorianDumps(recentSessions) {
|
|
|
54167
54214
|
recent: listing.recent
|
|
54168
54215
|
});
|
|
54169
54216
|
}
|
|
54170
|
-
const
|
|
54171
|
-
const legacyListing = listDumpsInDir(legacyDir, 5);
|
|
54217
|
+
const legacyListing = listDumpsInDir(historianRoot, DUMPS_PER_BUCKET_LIMIT);
|
|
54172
54218
|
return {
|
|
54219
|
+
sessionDumps: {
|
|
54220
|
+
dir: historianRoot,
|
|
54221
|
+
count: sessionDirs.reduce((sum, session) => sum + session.files.length, 0),
|
|
54222
|
+
sessionCount: sessionDirs.length,
|
|
54223
|
+
sessions: sessionDirs.slice(0, SESSION_DUMP_BUCKET_LIMIT).map((session) => ({
|
|
54224
|
+
sessionId: session.sessionId,
|
|
54225
|
+
count: session.files.length,
|
|
54226
|
+
recent: summarizeDumps(session.dir, session.files, DUMPS_PER_BUCKET_LIMIT)
|
|
54227
|
+
}))
|
|
54228
|
+
},
|
|
54173
54229
|
byProject: [...buckets.values()],
|
|
54174
54230
|
legacyDumps: {
|
|
54175
|
-
dir:
|
|
54231
|
+
dir: historianRoot,
|
|
54176
54232
|
count: legacyListing.count,
|
|
54177
54233
|
recent: legacyListing.recent
|
|
54178
54234
|
}
|
|
@@ -54235,7 +54291,7 @@ function collectRecentSessionsFromDatabase(database) {
|
|
|
54235
54291
|
});
|
|
54236
54292
|
}
|
|
54237
54293
|
async function collectDatabaseRows(path, read) {
|
|
54238
|
-
if (!
|
|
54294
|
+
if (!existsSync47(path))
|
|
54239
54295
|
return { available: false, reason: "path missing" };
|
|
54240
54296
|
let backend;
|
|
54241
54297
|
try {
|
|
@@ -54267,7 +54323,7 @@ async function collectRecentSessions(resolution, hostGeneration) {
|
|
|
54267
54323
|
});
|
|
54268
54324
|
}
|
|
54269
54325
|
async function collectHistorianFailures(storageDirPath) {
|
|
54270
|
-
return collectDatabaseRows(
|
|
54326
|
+
return collectDatabaseRows(join37(storageDirPath, "context.db"), (db) => {
|
|
54271
54327
|
const rows = db.prepare("SELECT session_id, historian_failure_count, historian_last_error, historian_last_failure_at FROM session_meta WHERE historian_failure_count > 0 ORDER BY historian_last_failure_at DESC LIMIT 10").all();
|
|
54272
54328
|
return rows.map((row) => {
|
|
54273
54329
|
const sessionId = typeof row.session_id === "string" ? row.session_id : "<unknown>";
|
|
@@ -54280,7 +54336,7 @@ async function collectHistorianFailures(storageDirPath) {
|
|
|
54280
54336
|
});
|
|
54281
54337
|
}
|
|
54282
54338
|
async function collectHistorianRuns(storageDirPath) {
|
|
54283
|
-
return collectDatabaseRows(
|
|
54339
|
+
return collectDatabaseRows(join37(storageDirPath, "context.db"), (db) => {
|
|
54284
54340
|
const aggRows = db.prepare(`SELECT session_id,
|
|
54285
54341
|
COUNT(*) AS total,
|
|
54286
54342
|
SUM(CASE WHEN status='success' THEN 1 ELSE 0 END) AS success,
|
|
@@ -54335,7 +54391,7 @@ async function collectDiagnostics(options = {}) {
|
|
|
54335
54391
|
const magicContextConfig = readConfig3(configPaths.magicContextConfig);
|
|
54336
54392
|
const storageResolution = getStorageResolution();
|
|
54337
54393
|
const storageDirPath = storageResolution.path;
|
|
54338
|
-
const contextDbPath =
|
|
54394
|
+
const contextDbPath = join37(storageDirPath, "context.db");
|
|
54339
54395
|
let compactionEnabled = false;
|
|
54340
54396
|
try {
|
|
54341
54397
|
compactionEnabled = isCompactionEnabled(loadPluginConfig(process.cwd()));
|
|
@@ -54367,7 +54423,7 @@ async function collectDiagnostics(options = {}) {
|
|
|
54367
54423
|
opencodeConfigHasPlugin: configHasPluginEntry(opencodeConfig.value),
|
|
54368
54424
|
tuiConfigHasPlugin: configHasPluginEntry(tuiConfig.value),
|
|
54369
54425
|
magicContextConfig: {
|
|
54370
|
-
exists:
|
|
54426
|
+
exists: existsSync47(configPaths.magicContextConfig),
|
|
54371
54427
|
...magicContextConfig.error ? { parseError: magicContextConfig.error } : {},
|
|
54372
54428
|
flags: sanitizeValue(magicContextConfig.value ?? {}) ?? {}
|
|
54373
54429
|
},
|
|
@@ -54375,7 +54431,7 @@ async function collectDiagnostics(options = {}) {
|
|
|
54375
54431
|
storageDir: {
|
|
54376
54432
|
path: storageDirPath,
|
|
54377
54433
|
source: storageResolution.source,
|
|
54378
|
-
exists:
|
|
54434
|
+
exists: existsSync47(storageDirPath),
|
|
54379
54435
|
contextDbSizeBytes: fileSize(contextDbPath)
|
|
54380
54436
|
},
|
|
54381
54437
|
openCodeDatabase: {
|
|
@@ -54446,6 +54502,12 @@ function renderDiagnosticsMarkdown(report) {
|
|
|
54446
54502
|
...openCodeInstallations.map((installation) => `| ${installation.active ? "[active]" : ""} | \`${sanitizeString(installation.path)}\` | ${installation.version} | ${installation.source} |`)
|
|
54447
54503
|
] : [];
|
|
54448
54504
|
const historianDumps = {
|
|
54505
|
+
sessionDumps: {
|
|
54506
|
+
dir: sanitizeString(report.historianDumps.sessionDumps.dir),
|
|
54507
|
+
count: report.historianDumps.sessionDumps.count,
|
|
54508
|
+
sessionCount: report.historianDumps.sessionDumps.sessionCount,
|
|
54509
|
+
sessions: report.historianDumps.sessionDumps.sessions
|
|
54510
|
+
},
|
|
54449
54511
|
byProject: report.historianDumps.byProject.map((bucket) => ({
|
|
54450
54512
|
directory: sanitizeString(bucket.directory),
|
|
54451
54513
|
primarySessionId: bucket.primarySessionId,
|
|
@@ -54510,7 +54572,7 @@ function renderDiagnosticsMarkdown(report) {
|
|
|
54510
54572
|
"",
|
|
54511
54573
|
"### Historian dumps",
|
|
54512
54574
|
"(Metadata only — XML content is not included in this report.)",
|
|
54513
|
-
"
|
|
54575
|
+
"`sessionDumps` lists the per-session directories under `<temp dir>/opencode/magic-context/historian/` that current plugins write to. `byProject` lists dumps that plugins up to 0.49.57 wrote under `<project>/.cortexkit/magic-context/historian/`, and `legacyDumps` those from plugins before 0.18.",
|
|
54514
54576
|
"```json",
|
|
54515
54577
|
JSON.stringify(historianDumps, null, 2),
|
|
54516
54578
|
"```",
|
|
@@ -54538,7 +54600,7 @@ function renderDiagnosticsMarkdown(report) {
|
|
|
54538
54600
|
].join(`
|
|
54539
54601
|
`);
|
|
54540
54602
|
}
|
|
54541
|
-
var import_comment_json10, RECENT_SESSION_GROUP_LIMIT = 5, CHILD_SESSIONS_PER_PARENT_LIMIT = 3;
|
|
54603
|
+
var import_comment_json10, SESSION_DUMP_BUCKET_LIMIT = 10, DUMPS_PER_BUCKET_LIMIT = 5, RECENT_SESSION_GROUP_LIMIT = 5, CHILD_SESSIONS_PER_PARENT_LIMIT = 3;
|
|
54542
54604
|
var init_diagnostics_opencode = __esm(async () => {
|
|
54543
54605
|
init_config();
|
|
54544
54606
|
init_agent_disable();
|
|
@@ -54546,6 +54608,7 @@ var init_diagnostics_opencode = __esm(async () => {
|
|
|
54546
54608
|
init_conflict_detector();
|
|
54547
54609
|
init_data_path();
|
|
54548
54610
|
init_opencode_db_path();
|
|
54611
|
+
init_historian_dump_dirs();
|
|
54549
54612
|
init_log_lines();
|
|
54550
54613
|
init_opencode_detect();
|
|
54551
54614
|
init_opencode_helpers();
|
|
@@ -54649,9 +54712,9 @@ var init_embedding_local = __esm(async () => {
|
|
|
54649
54712
|
|
|
54650
54713
|
// src/lib/embedding-runtime.ts
|
|
54651
54714
|
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
54652
|
-
import { existsSync as
|
|
54715
|
+
import { existsSync as existsSync48, readFileSync as readFileSync30 } from "node:fs";
|
|
54653
54716
|
import { createRequire as createRequire5 } from "node:module";
|
|
54654
|
-
import { dirname as dirname25, join as
|
|
54717
|
+
import { dirname as dirname25, join as join38, sep as sep2 } from "node:path";
|
|
54655
54718
|
function describeError(error) {
|
|
54656
54719
|
const message = error instanceof Error ? error.message : String(error ?? "unknown error");
|
|
54657
54720
|
const code = error?.code;
|
|
@@ -54793,11 +54856,11 @@ function expectedBinaryRelPath(platform, arch) {
|
|
|
54793
54856
|
const supportedArch = arch === "x64" || arch === "arm64";
|
|
54794
54857
|
if (!supportedPlatform || !supportedArch)
|
|
54795
54858
|
return null;
|
|
54796
|
-
return
|
|
54859
|
+
return join38("bin", "napi-v6", platform, arch, "onnxruntime_binding.node");
|
|
54797
54860
|
}
|
|
54798
54861
|
function onnxRuntimeNodeVersion(packageDir) {
|
|
54799
54862
|
try {
|
|
54800
|
-
const parsed = JSON.parse(readFileSync30(
|
|
54863
|
+
const parsed = JSON.parse(readFileSync30(join38(packageDir, "package.json"), "utf8"));
|
|
54801
54864
|
return typeof parsed.version === "string" ? parsed.version : undefined;
|
|
54802
54865
|
} catch {
|
|
54803
54866
|
return;
|
|
@@ -54846,7 +54909,7 @@ function formatLocalEmbeddingRuntimeWasmSelected(status) {
|
|
|
54846
54909
|
function requireNodeWasmBundle(probe, candidates) {
|
|
54847
54910
|
if (probe.state === "failed")
|
|
54848
54911
|
return probe;
|
|
54849
|
-
const bundlePath = candidates.find((candidate) =>
|
|
54912
|
+
const bundlePath = candidates.find((candidate) => existsSync48(candidate));
|
|
54850
54913
|
return bundlePath ? probe : {
|
|
54851
54914
|
state: "failed",
|
|
54852
54915
|
reason: `functional Node WASM Transformers bundle is missing (checked ${candidates.join(", ")})`
|
|
@@ -54854,13 +54917,13 @@ function requireNodeWasmBundle(probe, candidates) {
|
|
|
54854
54917
|
}
|
|
54855
54918
|
function nodeWasmBundleCandidates(installRoot) {
|
|
54856
54919
|
return [
|
|
54857
|
-
|
|
54858
|
-
|
|
54859
|
-
|
|
54920
|
+
join38(installRoot, "dist", "transformers-node-wasm.js"),
|
|
54921
|
+
join38(installRoot, "node_modules", "@cortexkit", "opencode-magic-context", "dist", "transformers-node-wasm.js"),
|
|
54922
|
+
join38(installRoot, "node_modules", "@cortexkit", "pi-magic-context", "dist", "transformers-node-wasm.js")
|
|
54860
54923
|
];
|
|
54861
54924
|
}
|
|
54862
54925
|
function probeWasmRuntimeAt(installRoot) {
|
|
54863
|
-
const requireFn = createRequire5(
|
|
54926
|
+
const requireFn = createRequire5(join38(installRoot, "package.json"));
|
|
54864
54927
|
return requireNodeWasmBundle(probeWasmRuntimeFromRequire(requireFn), nodeWasmBundleCandidates(installRoot));
|
|
54865
54928
|
}
|
|
54866
54929
|
function checkLocalEmbeddingRuntimeAt(installRoot, platform = process.platform, arch = process.arch, runtimePreference = "auto", host) {
|
|
@@ -54869,9 +54932,9 @@ function checkLocalEmbeddingRuntimeAt(installRoot, platform = process.platform,
|
|
|
54869
54932
|
const wasm = probeWasmRuntimeAt(installRoot);
|
|
54870
54933
|
return wasm.state === "ok" ? { state: "wasm-selected", wasmPath: wasm.wasmPath } : { state: "wasm-broken", wasmReason: wasm.reason };
|
|
54871
54934
|
}
|
|
54872
|
-
const packageDir =
|
|
54935
|
+
const packageDir = join38(installRoot, "node_modules", "onnxruntime-node");
|
|
54873
54936
|
let native;
|
|
54874
|
-
if (!
|
|
54937
|
+
if (!existsSync48(join38(packageDir, "package.json"))) {
|
|
54875
54938
|
native = { state: "package-missing", packageDir };
|
|
54876
54939
|
} else {
|
|
54877
54940
|
const rel = expectedBinaryRelPath(platform, arch);
|
|
@@ -54881,8 +54944,8 @@ function checkLocalEmbeddingRuntimeAt(installRoot, platform = process.platform,
|
|
|
54881
54944
|
binaryPath: packageDir
|
|
54882
54945
|
};
|
|
54883
54946
|
} else {
|
|
54884
|
-
const binaryPath =
|
|
54885
|
-
native =
|
|
54947
|
+
const binaryPath = join38(packageDir, rel);
|
|
54948
|
+
native = existsSync48(binaryPath) ? probeOnnxRuntimeNodeLoad(packageDir) ?? { state: "ok", binaryPath } : {
|
|
54886
54949
|
state: "binary-missing",
|
|
54887
54950
|
packageDir,
|
|
54888
54951
|
expectedBinary: binaryPath,
|
|
@@ -54893,7 +54956,7 @@ function checkLocalEmbeddingRuntimeAt(installRoot, platform = process.platform,
|
|
|
54893
54956
|
return withWasmFallback(native, () => probeWasmRuntimeAt(installRoot));
|
|
54894
54957
|
}
|
|
54895
54958
|
function checkLocalEmbeddingRuntime(installRoots, platform = process.platform, arch = process.arch, runtimePreference = "auto", host) {
|
|
54896
|
-
const existing = installRoots.filter((root) =>
|
|
54959
|
+
const existing = installRoots.filter((root) => existsSync48(root));
|
|
54897
54960
|
if (existing.length === 0) {
|
|
54898
54961
|
return {
|
|
54899
54962
|
state: "unknown",
|
|
@@ -54923,15 +54986,15 @@ function packageDirFromResolved(resolvedPath, packageName) {
|
|
|
54923
54986
|
}
|
|
54924
54987
|
function probeWasmRuntimeByResolution(pluginDir) {
|
|
54925
54988
|
try {
|
|
54926
|
-
const reqPlugin = createRequire5(
|
|
54989
|
+
const reqPlugin = createRequire5(join38(pluginDir, "package.json"));
|
|
54927
54990
|
const direct = probeWasmRuntimeFromRequire(reqPlugin);
|
|
54928
54991
|
let probe = direct;
|
|
54929
54992
|
if (direct.state === "failed" && direct.reason.startsWith("onnxruntime-web is not resolvable")) {
|
|
54930
54993
|
const tfResolved = reqPlugin.resolve("@huggingface/transformers");
|
|
54931
54994
|
const tfDir = packageDirFromResolved(tfResolved, "@huggingface/transformers");
|
|
54932
|
-
probe = probeWasmRuntimeFromRequire(createRequire5(
|
|
54995
|
+
probe = probeWasmRuntimeFromRequire(createRequire5(join38(tfDir, "package.json")));
|
|
54933
54996
|
}
|
|
54934
|
-
return requireNodeWasmBundle(probe, [
|
|
54997
|
+
return requireNodeWasmBundle(probe, [join38(pluginDir, "dist", "transformers-node-wasm.js")]);
|
|
54935
54998
|
} catch (error) {
|
|
54936
54999
|
return {
|
|
54937
55000
|
state: "failed",
|
|
@@ -54940,7 +55003,7 @@ function probeWasmRuntimeByResolution(pluginDir) {
|
|
|
54940
55003
|
}
|
|
54941
55004
|
}
|
|
54942
55005
|
function checkLocalEmbeddingRuntimeByResolution(pluginDir, platform = process.platform, arch = process.arch, runtimePreference = "auto", host) {
|
|
54943
|
-
if (!
|
|
55006
|
+
if (!existsSync48(join38(pluginDir, "package.json"))) {
|
|
54944
55007
|
return { state: "unknown", reason: "plugin package dir not found" };
|
|
54945
55008
|
}
|
|
54946
55009
|
const selectedRuntime = resolveLocalEmbeddingWorkerRuntime(runtimePreference, host);
|
|
@@ -54951,13 +55014,13 @@ function checkLocalEmbeddingRuntimeByResolution(pluginDir, platform = process.pl
|
|
|
54951
55014
|
let onnxDir = null;
|
|
54952
55015
|
let resolveError;
|
|
54953
55016
|
try {
|
|
54954
|
-
const reqPlugin = createRequire5(
|
|
55017
|
+
const reqPlugin = createRequire5(join38(pluginDir, "package.json"));
|
|
54955
55018
|
try {
|
|
54956
55019
|
onnxDir = packageDirFromResolved(reqPlugin.resolve("onnxruntime-node"), "onnxruntime-node");
|
|
54957
55020
|
} catch {
|
|
54958
55021
|
const tfResolved = reqPlugin.resolve("@huggingface/transformers");
|
|
54959
55022
|
const tfDir = packageDirFromResolved(tfResolved, "@huggingface/transformers");
|
|
54960
|
-
const reqTf = createRequire5(
|
|
55023
|
+
const reqTf = createRequire5(join38(tfDir, "package.json"));
|
|
54961
55024
|
onnxDir = packageDirFromResolved(reqTf.resolve("onnxruntime-node"), "onnxruntime-node");
|
|
54962
55025
|
}
|
|
54963
55026
|
} catch (error) {
|
|
@@ -54965,7 +55028,7 @@ function checkLocalEmbeddingRuntimeByResolution(pluginDir, platform = process.pl
|
|
|
54965
55028
|
if (resolveError === "ERR_MODULE_NOT_FOUND" || resolveError === "MODULE_NOT_FOUND") {
|
|
54966
55029
|
return withWasmFallback({
|
|
54967
55030
|
state: "package-missing",
|
|
54968
|
-
packageDir:
|
|
55031
|
+
packageDir: join38(pluginDir, "node_modules", "onnxruntime-node")
|
|
54969
55032
|
}, () => probeWasmRuntimeByResolution(pluginDir));
|
|
54970
55033
|
}
|
|
54971
55034
|
return {
|
|
@@ -54981,8 +55044,8 @@ function checkLocalEmbeddingRuntimeByResolution(pluginDir, platform = process.pl
|
|
|
54981
55044
|
if (rel === null) {
|
|
54982
55045
|
native = probeOnnxRuntimeNodeLoad(onnxDir) ?? { state: "ok", binaryPath: onnxDir };
|
|
54983
55046
|
} else {
|
|
54984
|
-
const binaryPath =
|
|
54985
|
-
native =
|
|
55047
|
+
const binaryPath = join38(onnxDir, rel);
|
|
55048
|
+
native = existsSync48(binaryPath) ? probeOnnxRuntimeNodeLoad(onnxDir) ?? { state: "ok", binaryPath } : {
|
|
54986
55049
|
state: "binary-missing",
|
|
54987
55050
|
packageDir: onnxDir,
|
|
54988
55051
|
expectedBinary: binaryPath,
|
|
@@ -55018,7 +55081,7 @@ var init_embedding_runtime = __esm(async () => {
|
|
|
55018
55081
|
|
|
55019
55082
|
// src/lib/logs-opencode.ts
|
|
55020
55083
|
import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync9 } from "node:fs";
|
|
55021
|
-
import { dirname as dirname26, join as
|
|
55084
|
+
import { dirname as dirname26, join as join39 } from "node:path";
|
|
55022
55085
|
function formatTimestamp(date) {
|
|
55023
55086
|
const pad = (value) => String(value).padStart(2, "0");
|
|
55024
55087
|
return [
|
|
@@ -55109,11 +55172,11 @@ async function bundleIssueReport(report, description, title, sessionFilter = nul
|
|
|
55109
55172
|
const bodyMarkdown = capBodyToGithubLimit(rawBodyMarkdown);
|
|
55110
55173
|
const truncated = bodyMarkdown !== rawBodyMarkdown;
|
|
55111
55174
|
const timestamp = formatTimestamp(new Date);
|
|
55112
|
-
const path = options.outputPath ??
|
|
55175
|
+
const path = options.outputPath ?? join39(process.cwd(), `magic-context-issue-${timestamp}.md`);
|
|
55113
55176
|
mkdirSync9(dirname26(path), { recursive: true });
|
|
55114
55177
|
writeFileSync9(path, `${bodyMarkdown}
|
|
55115
55178
|
`);
|
|
55116
|
-
const fullPath = truncated ? options.outputPath ? `${options.outputPath}.full.md` :
|
|
55179
|
+
const fullPath = truncated ? options.outputPath ? `${options.outputPath}.full.md` : join39(process.cwd(), `magic-context-issue-${timestamp}-full.md`) : undefined;
|
|
55117
55180
|
if (fullPath)
|
|
55118
55181
|
writeFileSync9(fullPath, `${rawBodyMarkdown}
|
|
55119
55182
|
`);
|
|
@@ -55934,10 +55997,10 @@ function removeDeprecatedReasoningAge(config) {
|
|
|
55934
55997
|
|
|
55935
55998
|
// src/commands/doctor-opencode.ts
|
|
55936
55999
|
import { spawnSync as spawnSync10 } from "node:child_process";
|
|
55937
|
-
import { existsSync as
|
|
56000
|
+
import { existsSync as existsSync49, mkdtempSync as mkdtempSync4, readFileSync as readFileSync31, rmSync as rmSync9 } from "node:fs";
|
|
55938
56001
|
import { createRequire as createRequire6 } from "node:module";
|
|
55939
56002
|
import { homedir as homedir21, tmpdir as tmpdir4 } from "node:os";
|
|
55940
|
-
import { dirname as dirname27, join as
|
|
56003
|
+
import { dirname as dirname27, join as join40, resolve as resolve19 } from "node:path";
|
|
55941
56004
|
function formatSharedDbRowCounts(db) {
|
|
55942
56005
|
return SHARED_DB_ROW_COUNT_TABLES.map((table) => {
|
|
55943
56006
|
try {
|
|
@@ -56008,7 +56071,7 @@ function checkConfiguredVariantCatalog(config, hostGeneration, warn, run = (args
|
|
|
56008
56071
|
}
|
|
56009
56072
|
if (models.length === 0)
|
|
56010
56073
|
return;
|
|
56011
|
-
const tempRoot = mkdtempSync4(
|
|
56074
|
+
const tempRoot = mkdtempSync4(join40(tmpdir4(), "magic-context-opencode-catalog-"));
|
|
56012
56075
|
try {
|
|
56013
56076
|
const command = hostGeneration === "v2" ? ["api", "model.list", "--param", `directory=${projectDir}`] : ["models", "--verbose"];
|
|
56014
56077
|
const guidance = `opencode ${command.join(" ")}`;
|
|
@@ -56184,7 +56247,7 @@ function getSelfVersion2() {
|
|
|
56184
56247
|
function describeAutoUpdateStall(specifier, autoUpdateEnabled, storageDir = getMagicContextStorageDir()) {
|
|
56185
56248
|
if (!autoUpdateEnabled || !isPinnedOpenCodePluginSpecifier(specifier))
|
|
56186
56249
|
return null;
|
|
56187
|
-
const state = readAutoUpdateCheckState(
|
|
56250
|
+
const state = readAutoUpdateCheckState(join40(storageDir, AUTO_UPDATE_CHECK_STATE_FILENAME));
|
|
56188
56251
|
const owner = isUpdaterPinnedSpec(state, specifier) ? "updater" : "you";
|
|
56189
56252
|
return `auto-update: stalled — config pinned to ${specifier} (by ${owner})`;
|
|
56190
56253
|
}
|
|
@@ -56193,12 +56256,12 @@ function getUserNpmrcPath() {
|
|
|
56193
56256
|
if (custom)
|
|
56194
56257
|
return custom;
|
|
56195
56258
|
const home = process.env.HOME?.trim();
|
|
56196
|
-
return
|
|
56259
|
+
return join40(home || homedir21(), ".npmrc");
|
|
56197
56260
|
}
|
|
56198
56261
|
function collectNpmReleaseAgeWarnings() {
|
|
56199
56262
|
const ageWarnings = [];
|
|
56200
56263
|
const npmrcPath = getUserNpmrcPath();
|
|
56201
|
-
if (!
|
|
56264
|
+
if (!existsSync49(npmrcPath))
|
|
56202
56265
|
return ageWarnings;
|
|
56203
56266
|
try {
|
|
56204
56267
|
const npmrc = readFileSync31(npmrcPath, "utf-8");
|
|
@@ -56390,7 +56453,7 @@ function checkLocalEmbeddingRuntimeForDoctor(installRoots, runtimePreference = "
|
|
|
56390
56453
|
return { issues: 0 };
|
|
56391
56454
|
}
|
|
56392
56455
|
async function checkEmbeddingConfig(magicContextConfigPath, installRoots) {
|
|
56393
|
-
if (!
|
|
56456
|
+
if (!existsSync49(magicContextConfigPath)) {
|
|
56394
56457
|
return checkLocalEmbeddingRuntimeForDoctor(installRoots);
|
|
56395
56458
|
}
|
|
56396
56459
|
let rawText;
|
|
@@ -56571,7 +56634,7 @@ async function runDoctor2(options = {}) {
|
|
|
56571
56634
|
const v22Result = await runV22BackfillCommands({
|
|
56572
56635
|
name: "OpenCode",
|
|
56573
56636
|
openDatabase: (readonly = true) => {
|
|
56574
|
-
const dbPath =
|
|
56637
|
+
const dbPath = join40(getMagicContextStorageDir(), "context.db");
|
|
56575
56638
|
v22Db = readonly ? openExistingContextDatabase(dbPath, { readonly: true }) : openExistingContextDatabaseForMutation(dbPath);
|
|
56576
56639
|
return v22Db;
|
|
56577
56640
|
},
|
|
@@ -56607,7 +56670,7 @@ async function runDoctor2(options = {}) {
|
|
|
56607
56670
|
if (isMagicContextStorageOutsideEngram(storageDir)) {
|
|
56608
56671
|
warn(`Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
|
|
56609
56672
|
}
|
|
56610
|
-
const authorityDbPath =
|
|
56673
|
+
const authorityDbPath = join40(getMagicContextStorageDir(), "context.db");
|
|
56611
56674
|
let authorityDb = null;
|
|
56612
56675
|
try {
|
|
56613
56676
|
authorityDb = openExistingContextDatabase(authorityDbPath, { readonly: true });
|
|
@@ -56782,7 +56845,7 @@ async function runDoctor2(options = {}) {
|
|
|
56782
56845
|
pass(`OpenCode config: ${paths.opencodeConfig}`);
|
|
56783
56846
|
}
|
|
56784
56847
|
let autoUpdateEnabled = true;
|
|
56785
|
-
if (
|
|
56848
|
+
if (existsSync49(paths.magicContextConfig)) {
|
|
56786
56849
|
pass(`Magic Context config: ${paths.magicContextConfig}`);
|
|
56787
56850
|
try {
|
|
56788
56851
|
const raw = loadRawConfigFile({ configPath: paths.magicContextConfig, tier: "user" });
|
|
@@ -56820,7 +56883,7 @@ async function runDoctor2(options = {}) {
|
|
|
56820
56883
|
log3.info(rerankConfigSummary());
|
|
56821
56884
|
log3.info(" Run 'setup' to create one with model recommendations");
|
|
56822
56885
|
}
|
|
56823
|
-
if (
|
|
56886
|
+
if (existsSync49(paths.magicContextConfig)) {
|
|
56824
56887
|
try {
|
|
56825
56888
|
const raw = loadRawConfigFile({ configPath: paths.magicContextConfig, tier: "user" });
|
|
56826
56889
|
if (!raw)
|
|
@@ -57053,7 +57116,7 @@ async function runDoctor2(options = {}) {
|
|
|
57053
57116
|
pass("Added TUI sidebar plugin to tui.json");
|
|
57054
57117
|
warn("Restart OpenCode to see the sidebar");
|
|
57055
57118
|
fixed++;
|
|
57056
|
-
} else if (
|
|
57119
|
+
} else if (existsSync49(paths.tuiConfig)) {
|
|
57057
57120
|
try {
|
|
57058
57121
|
const tuiRaw = readFileSync31(paths.tuiConfig, "utf-8");
|
|
57059
57122
|
const tuiConfig = import_comment_json11.parse(tuiRaw);
|
|
@@ -57094,7 +57157,7 @@ async function runDoctor2(options = {}) {
|
|
|
57094
57157
|
fail("Could not create or verify the TUI sidebar config");
|
|
57095
57158
|
}
|
|
57096
57159
|
}
|
|
57097
|
-
if (
|
|
57160
|
+
if (existsSync49(paths.magicContextConfig)) {
|
|
57098
57161
|
try {
|
|
57099
57162
|
const raw = loadRawConfigFile({ configPath: paths.magicContextConfig, tier: "user" });
|
|
57100
57163
|
if (!raw)
|
|
@@ -57113,7 +57176,7 @@ async function runDoctor2(options = {}) {
|
|
|
57113
57176
|
embeddingHostConfig = import_comment_json11.parse(readFileSync31(paths.opencodeConfig, "utf-8"));
|
|
57114
57177
|
} catch {}
|
|
57115
57178
|
const embeddingInstalls = getOpenCodeLoadedPluginInstallRoots(hostGeneration, embeddingHostConfig);
|
|
57116
|
-
const unusedInstalls = embeddingInstalls.others.filter((root) =>
|
|
57179
|
+
const unusedInstalls = embeddingInstalls.others.filter((root) => existsSync49(root));
|
|
57117
57180
|
if (unusedInstalls.length > 0)
|
|
57118
57181
|
log3.info(`Local embedding runtime: checked only the copy ${hostGeneration === "v2" ? "OpenCode 2" : "OpenCode 1"} loads; other installed copies (not loaded, not checked): ${unusedInstalls.join(", ")}`);
|
|
57119
57182
|
const embeddingCheck = await checkEmbeddingConfig(paths.magicContextConfig, embeddingInstalls.loaded);
|
|
@@ -57125,9 +57188,9 @@ async function runDoctor2(options = {}) {
|
|
|
57125
57188
|
else
|
|
57126
57189
|
passCount++;
|
|
57127
57190
|
const storage = getMagicContextStorageResolution();
|
|
57128
|
-
const dbPath =
|
|
57191
|
+
const dbPath = join40(storage.path, "context.db");
|
|
57129
57192
|
log3.info(`Shared storage: ${storage.path} (source: ${storage.source})`);
|
|
57130
|
-
if (!
|
|
57193
|
+
if (!existsSync49(dbPath)) {
|
|
57131
57194
|
log3.info(`Shared context DB not yet created at ${dbPath} (will be created on first run)`);
|
|
57132
57195
|
} else {
|
|
57133
57196
|
log3.info(`Shared context DB exists at ${dbPath}`);
|
|
@@ -57315,11 +57378,29 @@ ${formatDatabaseRepairGuidance(dbPath)}`);
|
|
|
57315
57378
|
}
|
|
57316
57379
|
}
|
|
57317
57380
|
const diagnostics = await collectDiagnostics();
|
|
57381
|
+
const sessionDumps = diagnostics.historianDumps.sessionDumps;
|
|
57382
|
+
if (sessionDumps.count > 0) {
|
|
57383
|
+
warn(`Historian debug dumps: ${sessionDumps.count} file(s) across ${sessionDumps.sessionCount} session(s) in ${sessionDumps.dir}`);
|
|
57384
|
+
for (const session of sessionDumps.sessions) {
|
|
57385
|
+
log3.info(` [${session.sessionId}] ${session.count} file(s)`);
|
|
57386
|
+
for (const dump of session.recent.slice(0, 3)) {
|
|
57387
|
+
const age = dump.ageMinutes;
|
|
57388
|
+
const ageStr = age < 60 ? `${age}m ago` : `${Math.round(age / 60)}h ago`;
|
|
57389
|
+
log3.info(` ${dump.name} (${ageStr})`);
|
|
57390
|
+
}
|
|
57391
|
+
if (session.count > 3) {
|
|
57392
|
+
log3.info(` ... and ${session.count - 3} more`);
|
|
57393
|
+
}
|
|
57394
|
+
}
|
|
57395
|
+
if (sessionDumps.sessionCount > sessionDumps.sessions.length) {
|
|
57396
|
+
log3.info(` ... and ${sessionDumps.sessionCount - sessionDumps.sessions.length} more session(s)`);
|
|
57397
|
+
}
|
|
57398
|
+
}
|
|
57318
57399
|
const dumpBuckets = diagnostics.historianDumps.byProject;
|
|
57319
57400
|
if (dumpBuckets.length > 0) {
|
|
57320
57401
|
const totalCount = dumpBuckets.reduce((sum, b) => sum + b.count, 0);
|
|
57321
57402
|
const sessionCount = dumpBuckets.length;
|
|
57322
|
-
warn(`Historian debug dumps: ${totalCount} file(s) across ${sessionCount} project(s)`);
|
|
57403
|
+
warn(`Historian debug dumps from older plugins in project directories: ${totalCount} file(s) across ${sessionCount} project(s)`);
|
|
57323
57404
|
for (const bucket of dumpBuckets) {
|
|
57324
57405
|
log3.info(` [${bucket.directory}] ${bucket.count} file(s)`);
|
|
57325
57406
|
for (const dump of bucket.recent.slice(0, 3)) {
|
|
@@ -57664,9 +57745,9 @@ var init_model_chain_health = __esm(() => {
|
|
|
57664
57745
|
});
|
|
57665
57746
|
|
|
57666
57747
|
// src/lib/diagnostics-pi.ts
|
|
57667
|
-
import { existsSync as
|
|
57748
|
+
import { existsSync as existsSync50, readdirSync as readdirSync11, readFileSync as readFileSync32, statSync as statSync27 } from "node:fs";
|
|
57668
57749
|
import { createRequire as createRequire7 } from "node:module";
|
|
57669
|
-
import { join as
|
|
57750
|
+
import { join as join41 } from "node:path";
|
|
57670
57751
|
function getSelfVersion3() {
|
|
57671
57752
|
const req = createRequire7(import.meta.url);
|
|
57672
57753
|
for (const relPath of ["../../package.json", "../package.json"]) {
|
|
@@ -57681,7 +57762,7 @@ function getSelfVersion3() {
|
|
|
57681
57762
|
}
|
|
57682
57763
|
function fileSize2(path) {
|
|
57683
57764
|
try {
|
|
57684
|
-
return
|
|
57765
|
+
return existsSync50(path) ? statSync27(path).size : 0;
|
|
57685
57766
|
} catch {
|
|
57686
57767
|
return 0;
|
|
57687
57768
|
}
|
|
@@ -57693,7 +57774,7 @@ function sanitizeValue2(value) {
|
|
|
57693
57774
|
return sanitizeConfigValue(value);
|
|
57694
57775
|
}
|
|
57695
57776
|
function readJsonc(path) {
|
|
57696
|
-
if (!
|
|
57777
|
+
if (!existsSync50(path))
|
|
57697
57778
|
return { value: {} };
|
|
57698
57779
|
try {
|
|
57699
57780
|
return {
|
|
@@ -57713,7 +57794,7 @@ function readConfigDiagnostic(path) {
|
|
|
57713
57794
|
const parsed = readJsonc(path);
|
|
57714
57795
|
return {
|
|
57715
57796
|
path,
|
|
57716
|
-
exists:
|
|
57797
|
+
exists: existsSync50(path),
|
|
57717
57798
|
...parsed.parseError ? { parseError: parsed.parseError } : {},
|
|
57718
57799
|
flags: sanitizeValue2(parsed.value)
|
|
57719
57800
|
};
|
|
@@ -57731,7 +57812,7 @@ function reverseSlugToDirectory(slug) {
|
|
|
57731
57812
|
}
|
|
57732
57813
|
function collectPiRecentSessions() {
|
|
57733
57814
|
const sessionsRoot = getPiSessionsRoot();
|
|
57734
|
-
if (!
|
|
57815
|
+
if (!existsSync50(sessionsRoot))
|
|
57735
57816
|
return [];
|
|
57736
57817
|
try {
|
|
57737
57818
|
const slugs = readdirSync11(sessionsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
@@ -57740,7 +57821,7 @@ function collectPiRecentSessions() {
|
|
|
57740
57821
|
const directory = reverseSlugToDirectory(slug);
|
|
57741
57822
|
if (!directory)
|
|
57742
57823
|
continue;
|
|
57743
|
-
const slugDir =
|
|
57824
|
+
const slugDir = join41(sessionsRoot, slug);
|
|
57744
57825
|
let files;
|
|
57745
57826
|
try {
|
|
57746
57827
|
files = readdirSync11(slugDir).filter((name) => name.endsWith(".jsonl"));
|
|
@@ -57749,7 +57830,7 @@ function collectPiRecentSessions() {
|
|
|
57749
57830
|
}
|
|
57750
57831
|
for (const file of files) {
|
|
57751
57832
|
try {
|
|
57752
|
-
const mtime =
|
|
57833
|
+
const mtime = statSync27(join41(slugDir, file)).mtimeMs;
|
|
57753
57834
|
const sessionId = file.replace(/\.jsonl$/, "");
|
|
57754
57835
|
candidates.push({ sessionId, directory, mtime });
|
|
57755
57836
|
} catch {}
|
|
@@ -57799,46 +57880,36 @@ function parseHistorianDumpMeta2(path) {
|
|
|
57799
57880
|
return { error: error instanceof Error ? error.message : String(error) };
|
|
57800
57881
|
}
|
|
57801
57882
|
}
|
|
57883
|
+
function summarizeDumps2(dir, files, limit) {
|
|
57884
|
+
const now = Date.now();
|
|
57885
|
+
return files.slice(0, limit).map((entry) => {
|
|
57886
|
+
const meta = parseHistorianDumpMeta2(join41(dir, entry.name));
|
|
57887
|
+
const summary = {
|
|
57888
|
+
name: entry.name,
|
|
57889
|
+
ageMinutes: Math.round((now - entry.mtime) / 60000),
|
|
57890
|
+
sizeKb: entry.sizeKb
|
|
57891
|
+
};
|
|
57892
|
+
if ("error" in meta) {
|
|
57893
|
+
summary.parseError = meta.error;
|
|
57894
|
+
} else {
|
|
57895
|
+
summary.meta = meta;
|
|
57896
|
+
}
|
|
57897
|
+
return summary;
|
|
57898
|
+
});
|
|
57899
|
+
}
|
|
57802
57900
|
function listDumpsInDir2(dir, limit) {
|
|
57803
|
-
|
|
57804
|
-
|
|
57805
|
-
try {
|
|
57806
|
-
const entries = readdirSync11(dir).filter((name) => name.endsWith(".xml")).map((name) => {
|
|
57807
|
-
const stat = statSync26(join40(dir, name));
|
|
57808
|
-
return {
|
|
57809
|
-
name,
|
|
57810
|
-
mtime: stat.mtimeMs,
|
|
57811
|
-
sizeKb: Math.round(stat.size / 1024)
|
|
57812
|
-
};
|
|
57813
|
-
}).sort((a, b) => b.mtime - a.mtime);
|
|
57814
|
-
const now = Date.now();
|
|
57815
|
-
const recent = entries.slice(0, limit).map((entry) => {
|
|
57816
|
-
const meta = parseHistorianDumpMeta2(join40(dir, entry.name));
|
|
57817
|
-
const summary = {
|
|
57818
|
-
name: entry.name,
|
|
57819
|
-
ageMinutes: Math.round((now - entry.mtime) / 60000),
|
|
57820
|
-
sizeKb: entry.sizeKb
|
|
57821
|
-
};
|
|
57822
|
-
if ("error" in meta) {
|
|
57823
|
-
summary.parseError = meta.error;
|
|
57824
|
-
} else {
|
|
57825
|
-
summary.meta = meta;
|
|
57826
|
-
}
|
|
57827
|
-
return summary;
|
|
57828
|
-
});
|
|
57829
|
-
return { count: entries.length, recent };
|
|
57830
|
-
} catch {
|
|
57831
|
-
return { count: 0, recent: [] };
|
|
57832
|
-
}
|
|
57901
|
+
const files = scanHistorianDumpFiles(dir);
|
|
57902
|
+
return { count: files.length, recent: summarizeDumps2(dir, files, limit) };
|
|
57833
57903
|
}
|
|
57834
|
-
function collectPiHistorianDumps(recentSessions) {
|
|
57904
|
+
function collectPiHistorianDumps(recentSessions, historianRoot = getMagicContextHistorianDir2("pi")) {
|
|
57905
|
+
const sessionDirs = scanHistorianSessionDumpDirs(historianRoot);
|
|
57835
57906
|
const buckets = new Map;
|
|
57836
57907
|
for (const session of recentSessions) {
|
|
57837
57908
|
const dir = session.directory;
|
|
57838
57909
|
if (!dir)
|
|
57839
57910
|
continue;
|
|
57840
|
-
const projectHistorianDir =
|
|
57841
|
-
const listing = listDumpsInDir2(projectHistorianDir,
|
|
57911
|
+
const projectHistorianDir = getProjectHistorianDumpDir(dir);
|
|
57912
|
+
const listing = listDumpsInDir2(projectHistorianDir, DUMPS_PER_BUCKET_LIMIT2);
|
|
57842
57913
|
const existing = buckets.get(dir);
|
|
57843
57914
|
if (existing) {
|
|
57844
57915
|
if (!existing.sessionIds.includes(session.sessionId)) {
|
|
@@ -57856,12 +57927,21 @@ function collectPiHistorianDumps(recentSessions) {
|
|
|
57856
57927
|
recent: listing.recent
|
|
57857
57928
|
});
|
|
57858
57929
|
}
|
|
57859
|
-
const
|
|
57860
|
-
const legacyListing = listDumpsInDir2(legacyDir, 5);
|
|
57930
|
+
const legacyListing = listDumpsInDir2(historianRoot, DUMPS_PER_BUCKET_LIMIT2);
|
|
57861
57931
|
return {
|
|
57932
|
+
sessionDumps: {
|
|
57933
|
+
dir: historianRoot,
|
|
57934
|
+
count: sessionDirs.reduce((sum, session) => sum + session.files.length, 0),
|
|
57935
|
+
sessionCount: sessionDirs.length,
|
|
57936
|
+
sessions: sessionDirs.slice(0, SESSION_DUMP_BUCKET_LIMIT2).map((session) => ({
|
|
57937
|
+
sessionId: session.sessionId,
|
|
57938
|
+
count: session.files.length,
|
|
57939
|
+
recent: summarizeDumps2(session.dir, session.files, DUMPS_PER_BUCKET_LIMIT2)
|
|
57940
|
+
}))
|
|
57941
|
+
},
|
|
57862
57942
|
byProject: [...buckets.values()],
|
|
57863
57943
|
legacyDumps: {
|
|
57864
|
-
dir:
|
|
57944
|
+
dir: historianRoot,
|
|
57865
57945
|
count: legacyListing.count,
|
|
57866
57946
|
recent: legacyListing.recent
|
|
57867
57947
|
}
|
|
@@ -57877,7 +57957,7 @@ async function collectDiagnostics2(cwd = process.cwd()) {
|
|
|
57877
57957
|
const loaded = loadPiConfig({ cwd });
|
|
57878
57958
|
const storageResolution = getMagicContextStorageResolution();
|
|
57879
57959
|
const storageDirPath = storageResolution.path;
|
|
57880
|
-
const dbPath =
|
|
57960
|
+
const dbPath = join41(storageDirPath, "context.db");
|
|
57881
57961
|
const logFiles = inspectMagicContextLogs("pi");
|
|
57882
57962
|
const primaryLog = logFiles.find((file) => file.exists) ?? logFiles[0];
|
|
57883
57963
|
const otherPiExtensions = packages.filter((entry) => !isPiMagicContextPackageEntry(entry)).map(describePiPackageEntry);
|
|
@@ -57894,7 +57974,7 @@ async function collectDiagnostics2(cwd = process.cwd()) {
|
|
|
57894
57974
|
piVersion: pi ? getPiVersion(pi.path) : null,
|
|
57895
57975
|
settings: {
|
|
57896
57976
|
path: settingsPath,
|
|
57897
|
-
exists:
|
|
57977
|
+
exists: existsSync50(settingsPath),
|
|
57898
57978
|
...settingsParsed.parseError ? { parseError: settingsParsed.parseError } : {},
|
|
57899
57979
|
hasMagicContextPackage: hasPiMagicContextPackage(packages),
|
|
57900
57980
|
packages: sanitizeValue2(packages)
|
|
@@ -57911,7 +57991,7 @@ async function collectDiagnostics2(cwd = process.cwd()) {
|
|
|
57911
57991
|
storageDir: {
|
|
57912
57992
|
path: storageDirPath,
|
|
57913
57993
|
source: storageResolution.source,
|
|
57914
|
-
exists:
|
|
57994
|
+
exists: existsSync50(storageDirPath),
|
|
57915
57995
|
contextDbSizeBytes: fileSize2(dbPath)
|
|
57916
57996
|
},
|
|
57917
57997
|
conflicts: {
|
|
@@ -58003,12 +58083,13 @@ function renderDiagnosticsMarkdown2(report) {
|
|
|
58003
58083
|
].join(`
|
|
58004
58084
|
`);
|
|
58005
58085
|
}
|
|
58006
|
-
var import_comment_json12;
|
|
58086
|
+
var import_comment_json12, SESSION_DUMP_BUCKET_LIMIT2 = 10, DUMPS_PER_BUCKET_LIMIT2 = 5;
|
|
58007
58087
|
var init_diagnostics_pi = __esm(() => {
|
|
58008
58088
|
init_migrate_config_location();
|
|
58009
58089
|
init_compartment_parser();
|
|
58010
58090
|
init_data_path();
|
|
58011
58091
|
init_config2();
|
|
58092
|
+
init_historian_dump_dirs();
|
|
58012
58093
|
init_log_lines();
|
|
58013
58094
|
init_paths();
|
|
58014
58095
|
init_pi_helpers();
|
|
@@ -58019,7 +58100,7 @@ var init_diagnostics_pi = __esm(() => {
|
|
|
58019
58100
|
|
|
58020
58101
|
// src/lib/logs-pi.ts
|
|
58021
58102
|
import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync10 } from "node:fs";
|
|
58022
|
-
import { dirname as dirname28, join as
|
|
58103
|
+
import { dirname as dirname28, join as join42 } from "node:path";
|
|
58023
58104
|
function formatTimestamp2(date) {
|
|
58024
58105
|
const pad = (value) => String(value).padStart(2, "0");
|
|
58025
58106
|
return [
|
|
@@ -58073,11 +58154,11 @@ async function bundleIssueReport2(report, description, title, options = {}) {
|
|
|
58073
58154
|
const truncated = bodyMarkdown !== rawBodyMarkdown;
|
|
58074
58155
|
const cwd = options.cwd ?? process.cwd();
|
|
58075
58156
|
const timestamp = formatTimestamp2(options.now ?? new Date);
|
|
58076
|
-
const path = options.outputPath ??
|
|
58157
|
+
const path = options.outputPath ?? join42(cwd, `magic-context-pi-issue-${timestamp}.md`);
|
|
58077
58158
|
mkdirSync10(dirname28(path), { recursive: true });
|
|
58078
58159
|
writeFileSync10(path, `${bodyMarkdown}
|
|
58079
58160
|
`);
|
|
58080
|
-
const fullPath = truncated ? options.outputPath ? `${options.outputPath}.full.md` :
|
|
58161
|
+
const fullPath = truncated ? options.outputPath ? `${options.outputPath}.full.md` : join42(cwd, `magic-context-pi-issue-${timestamp}-full.md`) : undefined;
|
|
58081
58162
|
if (fullPath)
|
|
58082
58163
|
writeFileSync10(fullPath, `${rawBodyMarkdown}
|
|
58083
58164
|
`);
|
|
@@ -58091,10 +58172,10 @@ var init_logs_pi = __esm(() => {
|
|
|
58091
58172
|
|
|
58092
58173
|
// src/commands/doctor-pi.ts
|
|
58093
58174
|
import { execFileSync as execFileSync9, spawnSync as spawnSync11 } from "node:child_process";
|
|
58094
|
-
import { existsSync as
|
|
58175
|
+
import { existsSync as existsSync51, readdirSync as readdirSync12, readFileSync as readFileSync33, rmSync as rmSync10, statSync as statSync28 } from "node:fs";
|
|
58095
58176
|
import { createRequire as createRequire8 } from "node:module";
|
|
58096
58177
|
import { homedir as homedir22 } from "node:os";
|
|
58097
|
-
import { isAbsolute as isAbsolute9, join as
|
|
58178
|
+
import { isAbsolute as isAbsolute9, join as join43 } from "node:path";
|
|
58098
58179
|
function depsFrom(options) {
|
|
58099
58180
|
return {
|
|
58100
58181
|
...DEFAULT_DEPS5,
|
|
@@ -58236,15 +58317,15 @@ function piPluginDirCandidates(packages, cwd) {
|
|
|
58236
58317
|
if (resolved)
|
|
58237
58318
|
dirs.push(resolved);
|
|
58238
58319
|
}
|
|
58239
|
-
dirs.push(
|
|
58240
|
-
dirs.push(
|
|
58241
|
-
return dirs.filter((dir) =>
|
|
58320
|
+
dirs.push(join43(agentDir, "npm", "node_modules", PACKAGE_NAME2));
|
|
58321
|
+
dirs.push(join43(cwd, ".pi", "npm", "node_modules", PACKAGE_NAME2));
|
|
58322
|
+
return dirs.filter((dir) => existsSync51(join43(dir, "package.json")));
|
|
58242
58323
|
}
|
|
58243
58324
|
function projectConfigPath(cwd) {
|
|
58244
58325
|
return resolveCortexKitProjectConfigPath(cwd);
|
|
58245
58326
|
}
|
|
58246
58327
|
function readConfigForEmbedding(path, isProjectConfig) {
|
|
58247
|
-
if (!
|
|
58328
|
+
if (!existsSync51(path))
|
|
58248
58329
|
return null;
|
|
58249
58330
|
try {
|
|
58250
58331
|
const raw = loadRawConfigFile({
|
|
@@ -58335,33 +58416,33 @@ function pinnedVersionFromPackageSpecifier(specifier) {
|
|
|
58335
58416
|
}
|
|
58336
58417
|
function cacheRoots(cwd) {
|
|
58337
58418
|
const home = process.env.HOME?.trim();
|
|
58338
|
-
const cacheHome = process.env.XDG_CACHE_HOME ||
|
|
58419
|
+
const cacheHome = process.env.XDG_CACHE_HOME || join43(home || homedir22(), ".cache");
|
|
58339
58420
|
const piCacheRoot = getPiCacheRoot();
|
|
58340
58421
|
return [
|
|
58341
|
-
|
|
58342
|
-
|
|
58343
|
-
|
|
58344
|
-
|
|
58345
|
-
|
|
58346
|
-
|
|
58347
|
-
|
|
58422
|
+
join43(piCacheRoot, "extensions"),
|
|
58423
|
+
join43(piCacheRoot, "packages"),
|
|
58424
|
+
join43(cacheHome, "pi", "extensions"),
|
|
58425
|
+
join43(cacheHome, "pi", "packages"),
|
|
58426
|
+
join43(getPiAgentConfigDir(), "cache", "extensions"),
|
|
58427
|
+
join43(getPiAgentConfigDir(), "npm", "node_modules", PACKAGE_NAME2),
|
|
58428
|
+
join43(cwd, ".pi", "npm", "node_modules", PACKAGE_NAME2)
|
|
58348
58429
|
];
|
|
58349
58430
|
}
|
|
58350
58431
|
function findPiMagicContextCacheDirs(cwd, expectedVersion, force = false) {
|
|
58351
58432
|
const found = new Map;
|
|
58352
58433
|
const visit = (path, depth) => {
|
|
58353
|
-
if (depth < 0 || !
|
|
58434
|
+
if (depth < 0 || !existsSync51(path))
|
|
58354
58435
|
return;
|
|
58355
58436
|
let stat;
|
|
58356
58437
|
try {
|
|
58357
|
-
stat =
|
|
58438
|
+
stat = statSync28(path);
|
|
58358
58439
|
} catch {
|
|
58359
58440
|
return;
|
|
58360
58441
|
}
|
|
58361
58442
|
if (!stat.isDirectory())
|
|
58362
58443
|
return;
|
|
58363
|
-
const packageJson =
|
|
58364
|
-
if (
|
|
58444
|
+
const packageJson = join43(path, "package.json");
|
|
58445
|
+
if (existsSync51(packageJson)) {
|
|
58365
58446
|
try {
|
|
58366
58447
|
const pkg = JSON.parse(readFileSync33(packageJson, "utf-8"));
|
|
58367
58448
|
const name = typeof pkg.name === "string" ? pkg.name : "";
|
|
@@ -58383,7 +58464,7 @@ function findPiMagicContextCacheDirs(cwd, expectedVersion, force = false) {
|
|
|
58383
58464
|
return;
|
|
58384
58465
|
}
|
|
58385
58466
|
for (const entry of entries)
|
|
58386
|
-
visit(
|
|
58467
|
+
visit(join43(path, entry), depth - 1);
|
|
58387
58468
|
};
|
|
58388
58469
|
for (const root of cacheRoots(cwd))
|
|
58389
58470
|
visit(root, 5);
|
|
@@ -58444,7 +58525,7 @@ async function runHealthChecks2(options) {
|
|
|
58444
58525
|
const settingsPath = getPiUserExtensionsPath();
|
|
58445
58526
|
let packages = [];
|
|
58446
58527
|
let piPluginInstalled = false;
|
|
58447
|
-
if (!
|
|
58528
|
+
if (!existsSync51(settingsPath)) {
|
|
58448
58529
|
if (pi) {
|
|
58449
58530
|
add2(results, "info", `${piVersion ? `Pi ${piVersion}` : "Pi"} found; Magic Context is not installed there (run setup to add it)`);
|
|
58450
58531
|
}
|
|
@@ -58486,7 +58567,7 @@ async function runHealthChecks2(options) {
|
|
|
58486
58567
|
["user", userConfigPath, true],
|
|
58487
58568
|
["project", projectPath, false]
|
|
58488
58569
|
]) {
|
|
58489
|
-
if (!
|
|
58570
|
+
if (!existsSync51(path)) {
|
|
58490
58571
|
if (required) {
|
|
58491
58572
|
add2(results, "warn", `No ${label} magic-context.jsonc found at ${path}`);
|
|
58492
58573
|
if (userConfigMigrationRefused) {
|
|
@@ -58533,12 +58614,12 @@ async function runHealthChecks2(options) {
|
|
|
58533
58614
|
checkPiModelChains(results, pi, loadedConfig.config, options.deps);
|
|
58534
58615
|
const storage = getMagicContextStorageResolution();
|
|
58535
58616
|
const storageDir = storage.path;
|
|
58536
|
-
const dbPath =
|
|
58617
|
+
const dbPath = join43(storageDir, "context.db");
|
|
58537
58618
|
if (isMagicContextStorageOutsideEngram(storageDir)) {
|
|
58538
58619
|
add2(results, "warn", `Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
|
|
58539
58620
|
}
|
|
58540
58621
|
add2(results, "info", `Shared storage: ${storageDir} (source: ${storage.source})`);
|
|
58541
|
-
const existedBeforeOpen =
|
|
58622
|
+
const existedBeforeOpen = existsSync51(dbPath);
|
|
58542
58623
|
if (existedBeforeOpen)
|
|
58543
58624
|
add2(results, "pass", `Shared context DB exists at ${dbPath}`);
|
|
58544
58625
|
else
|
|
@@ -58733,10 +58814,28 @@ ${formatDatabaseRepairGuidance(dbPath)}`);
|
|
|
58733
58814
|
}
|
|
58734
58815
|
}
|
|
58735
58816
|
const diagnosticsForDumps = await collectDiagnostics2(options.cwd);
|
|
58817
|
+
const sessionDumps = diagnosticsForDumps.historianDumps.sessionDumps;
|
|
58818
|
+
if (sessionDumps.count > 0) {
|
|
58819
|
+
add2(results, "warn", `Historian debug dumps: ${sessionDumps.count} file(s) across ${sessionDumps.sessionCount} session(s) in ${sessionDumps.dir}`);
|
|
58820
|
+
for (const session of sessionDumps.sessions) {
|
|
58821
|
+
add2(results, "info", ` [${session.sessionId}] ${session.count} file(s)`);
|
|
58822
|
+
for (const dump of session.recent.slice(0, 3)) {
|
|
58823
|
+
const age = dump.ageMinutes;
|
|
58824
|
+
const ageStr = age < 60 ? `${age}m ago` : `${Math.round(age / 60)}h ago`;
|
|
58825
|
+
add2(results, "info", ` ${dump.name} (${ageStr})`);
|
|
58826
|
+
}
|
|
58827
|
+
if (session.count > 3) {
|
|
58828
|
+
add2(results, "info", ` ... and ${session.count - 3} more`);
|
|
58829
|
+
}
|
|
58830
|
+
}
|
|
58831
|
+
if (sessionDumps.sessionCount > sessionDumps.sessions.length) {
|
|
58832
|
+
add2(results, "info", ` ... and ${sessionDumps.sessionCount - sessionDumps.sessions.length} more session(s)`);
|
|
58833
|
+
}
|
|
58834
|
+
}
|
|
58736
58835
|
const dumpBuckets = diagnosticsForDumps.historianDumps.byProject;
|
|
58737
58836
|
if (dumpBuckets.length > 0) {
|
|
58738
58837
|
const totalCount = dumpBuckets.reduce((sum, b) => sum + b.count, 0);
|
|
58739
|
-
add2(results, "warn", `Historian debug dumps: ${totalCount} file(s) across ${dumpBuckets.length} project(s)`);
|
|
58838
|
+
add2(results, "warn", `Historian debug dumps from older plugins in project directories: ${totalCount} file(s) across ${dumpBuckets.length} project(s)`);
|
|
58740
58839
|
for (const bucket of dumpBuckets) {
|
|
58741
58840
|
add2(results, "info", ` [${bucket.directory}] ${bucket.count} file(s)`);
|
|
58742
58841
|
for (const dump of bucket.recent.slice(0, 3)) {
|
|
@@ -58795,7 +58894,7 @@ function repair2(plan, prompts) {
|
|
|
58795
58894
|
}
|
|
58796
58895
|
if (plan.writeUserConfig) {
|
|
58797
58896
|
const configPath = getPiUserConfigPath();
|
|
58798
|
-
if (!
|
|
58897
|
+
if (!existsSync51(configPath)) {
|
|
58799
58898
|
try {
|
|
58800
58899
|
writeDefaultMagicContextConfig(configPath);
|
|
58801
58900
|
prompts.log.success(`Wrote default Magic Context config to ${configPath}`);
|
|
@@ -58849,7 +58948,7 @@ async function runIssueFlow3(options) {
|
|
|
58849
58948
|
if (options.reportPath) {
|
|
58850
58949
|
try {
|
|
58851
58950
|
const report = await options.deps.collectDiagnostics(options.cwd);
|
|
58852
|
-
const outputPath = isAbsolute9(options.reportPath) ? options.reportPath :
|
|
58951
|
+
const outputPath = isAbsolute9(options.reportPath) ? options.reportPath : join43(options.cwd, options.reportPath);
|
|
58853
58952
|
const bundled = await bundleIssueReport2(report, "Generated non-interactively by `doctor --issue --report`.", "Magic Context diagnostic report", { cwd: options.cwd, now: options.deps.now(), outputPath });
|
|
58854
58953
|
options.prompts.log.info(`Report written to ${bundled.path}`);
|
|
58855
58954
|
return 0;
|
|
@@ -58933,7 +59032,7 @@ async function runDoctor3(options = {}) {
|
|
|
58933
59032
|
const v22Result = await runV22BackfillCommands({
|
|
58934
59033
|
name: "Pi",
|
|
58935
59034
|
openDatabase: (readonly = true) => {
|
|
58936
|
-
const dbPath =
|
|
59035
|
+
const dbPath = join43(getMagicContextStorageDir(), "context.db");
|
|
58937
59036
|
v22Db = readonly ? openExistingContextDatabase(dbPath, { readonly: true }) : openExistingContextDatabaseForMutation(dbPath);
|
|
58938
59037
|
return v22Db;
|
|
58939
59038
|
},
|
|
@@ -59051,8 +59150,8 @@ var init_doctor_pi = __esm(async () => {
|
|
|
59051
59150
|
});
|
|
59052
59151
|
|
|
59053
59152
|
// src/commands/doctor.ts
|
|
59054
|
-
import { existsSync as
|
|
59055
|
-
import { join as
|
|
59153
|
+
import { existsSync as existsSync52, rmSync as rmSync11 } from "node:fs";
|
|
59154
|
+
import { join as join44 } from "node:path";
|
|
59056
59155
|
async function runDoctor4(options) {
|
|
59057
59156
|
if (options.clear)
|
|
59058
59157
|
return runClear();
|
|
@@ -59070,7 +59169,7 @@ async function runDoctor4(options) {
|
|
|
59070
59169
|
const result = await runV22BackfillCommands({
|
|
59071
59170
|
name: "Magic Context",
|
|
59072
59171
|
openDatabase: (readonly = true) => {
|
|
59073
|
-
const dbPath =
|
|
59172
|
+
const dbPath = join44(getMagicContextStorageDir(), "context.db");
|
|
59074
59173
|
v22Db = readonly ? openExistingContextDatabase(dbPath, { readonly: true }) : openExistingContextDatabaseForMutation(dbPath);
|
|
59075
59174
|
return v22Db;
|
|
59076
59175
|
},
|
|
@@ -59090,7 +59189,7 @@ async function runDoctor4(options) {
|
|
|
59090
59189
|
log3.warn(`Identity split check unavailable: ${error instanceof Error ? error.message : String(error)}`);
|
|
59091
59190
|
}
|
|
59092
59191
|
await init_migrate();
|
|
59093
|
-
const sweepDbPath =
|
|
59192
|
+
const sweepDbPath = join44(getMagicContextStorageDir(), "context.db");
|
|
59094
59193
|
let sweepDb = null;
|
|
59095
59194
|
try {
|
|
59096
59195
|
sweepDb = openExistingContextDatabaseForMutation(sweepDbPath);
|
|
@@ -59207,7 +59306,7 @@ async function runClear() {
|
|
|
59207
59306
|
failed += 1;
|
|
59208
59307
|
continue;
|
|
59209
59308
|
}
|
|
59210
|
-
} else if (
|
|
59309
|
+
} else if (existsSync52(item.path)) {
|
|
59211
59310
|
rmSync11(item.path, { recursive: true, force: true });
|
|
59212
59311
|
}
|
|
59213
59312
|
s.stop(`Cleared ${item.path}`);
|