@cortexkit/magic-context 0.49.0 → 0.49.2

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.
Files changed (2) hide show
  1. package/dist/index.js +414 -213
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2327,6 +2327,7 @@ import {
2327
2327
  chmodSync as chmodSync2,
2328
2328
  closeSync as closeSync2,
2329
2329
  createWriteStream,
2330
+ fsyncSync,
2330
2331
  lstatSync,
2331
2332
  mkdirSync as mkdirSync2,
2332
2333
  openSync as openSync2,
@@ -2464,44 +2465,9 @@ var enforcePrivateStoragePermissions = true;
2464
2465
  var init_storage_permissions = () => {};
2465
2466
 
2466
2467
  // ../plugin/src/shared/window-geometry.ts
2467
- function setWindowOverlayPath(path) {
2468
- if (configuredOverlayPath === path)
2469
- return;
2470
- reloadWindowOverlay(path);
2471
- }
2472
- function reloadWindowOverlay(path) {
2473
- configuredOverlayPath = path;
2474
- loadedOverlayPath = undefined;
2475
- loadedOverlay = undefined;
2476
- }
2477
- var GRADES, UNITS, BOUNDARIES, UNKNOWN_REASONS, NUMERIC_FACT_KEYS, configuredOverlayPath, loadedOverlayPath, loadedOverlay, geometryClampLogSeen;
2468
+ var geometryClampLogSeen;
2478
2469
  var init_window_geometry = __esm(() => {
2479
- init_data_path();
2480
- init_harness_provider_map();
2481
2470
  init_logger();
2482
- GRADES = new Set([
2483
- "provider_asserted_runtime",
2484
- "measured",
2485
- "provider_asserted_doc",
2486
- "catalog",
2487
- "unknown"
2488
- ]);
2489
- UNITS = new Set(["provider", "estimate"]);
2490
- BOUNDARIES = new Set(["Observed", "Asserted", "Corrected"]);
2491
- UNKNOWN_REASONS = new Set([
2492
- "placeholder_output_equals_context",
2493
- "placeholder_zero",
2494
- "never_measured",
2495
- "not_single_valued_at_key",
2496
- "retracted"
2497
- ]);
2498
- NUMERIC_FACT_KEYS = new Set([
2499
- "window.advertised",
2500
- "window.enforced",
2501
- "output.advertised",
2502
- "output.enforced",
2503
- "output.default"
2504
- ]);
2505
2471
  geometryClampLogSeen = new Set;
2506
2472
  });
2507
2473
 
@@ -2565,6 +2531,21 @@ function migrateLegacyAgentEnabledInMemory(rawConfig, warnings) {
2565
2531
  }
2566
2532
  var init_agent_disable = () => {};
2567
2533
 
2534
+ // ../plugin/src/config/deprecated-config.ts
2535
+ function warnDeprecatedMuralModel(config, warnings) {
2536
+ const mural = config.mural;
2537
+ if (typeof mural === "object" && mural !== null && Object.hasOwn(mural, "model")) {
2538
+ warnings.push(MURAL_MODEL_DEPRECATION_WARNING);
2539
+ }
2540
+ }
2541
+ function warnDeprecatedWindowOverlayPath(config, warnings) {
2542
+ const models = config.models;
2543
+ if (typeof models === "object" && models !== null && Object.hasOwn(models, "window_overlay_path") && !warnings.includes(WINDOW_OVERLAY_PATH_DEPRECATION_WARNING)) {
2544
+ warnings.push(WINDOW_OVERLAY_PATH_DEPRECATION_WARNING);
2545
+ }
2546
+ }
2547
+ var MURAL_MODEL_DEPRECATION_WARNING = "mural.model is deprecated and ignored; compress-cues now uses the dreamer model for each harness, like every other dreamer task. To override it, set dreamer.opencode.tasks.compress-cues.model (or the pi/omp equivalent). This key no longer does anything; remove it.", WINDOW_OVERLAY_PATH_DEPRECATION_WARNING = "models.window_overlay_path is deprecated and ignored; Fusiform no longer publishes window-overlay data, so this setting no longer changes model window geometry. Remove this key.";
2548
+
2568
2549
  // ../plugin/src/shared/jsonc-edit.ts
2569
2550
  function parseDocument(text) {
2570
2551
  const errors = [];
@@ -3480,15 +3461,6 @@ function migrateLegacyExperimental(rawConfig, warnings) {
3480
3461
  return patched;
3481
3462
  }
3482
3463
 
3483
- // ../plugin/src/config/mural-model-deprecation.ts
3484
- function warnDeprecatedMuralModel(config, warnings) {
3485
- const mural = config.mural;
3486
- if (typeof mural === "object" && mural !== null && Object.hasOwn(mural, "model")) {
3487
- warnings.push(MURAL_MODEL_DEPRECATION_WARNING);
3488
- }
3489
- }
3490
- var MURAL_MODEL_DEPRECATION_WARNING = "mural.model is deprecated and ignored; compress-cues now uses the dreamer model for each harness, like every other dreamer task. To override it, set dreamer.opencode.tasks.compress-cues.model (or the pi/omp equivalent). This key no longer does anything; remove it.";
3491
-
3492
3464
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/core.js
3493
3465
  function $constructor(name, initializer, params) {
3494
3466
  function init(inst, def) {
@@ -9239,7 +9211,7 @@ var init_magic_context = __esm(() => {
9239
9211
  document_prefix: string2().optional().describe("OpenAI-compatible stored-document prefix override, prepended verbatim. Defaults to the model-family recipe (empty for Qwen3/gte/e5 instruct; 'search_document: ' for Nomic). Changing it changes stored vectors and triggers re-embedding. User-level only; project values are ignored."),
9240
9212
  truncate: string2().optional().describe("Optional truncate mode sent in the embedding request body (e.g. NVIDIA NIM accepts 'NONE' | 'START' | 'END'). Omitted from the request when unset."),
9241
9213
  max_input_tokens: number2().int().positive().optional().describe("Optional maximum input tokens for chunk embeddings. Defaults conservatively to 512 when omitted."),
9242
- local_runtime: _enum(["auto", "native", "wasm"]).default("auto").describe("Local provider only: ONNX runtime selection. 'auto' uses native under Node and uses WASM under Bun versions before 1.4.0, where Bun's NAPI teardown race can panic on quit; native is restored automatically on Bun 1.4.0+. Inference runs in a dedicated worker. On Bun before 1.4.0, even explicit 'native' uses WASM because native worker teardown can crash the process. Set 'wasm' to avoid loading the native addon on newer hosts too."),
9214
+ local_runtime: _enum(["auto", "native", "wasm"]).default("auto").describe("Local provider only: ONNX runtime selection. 'auto' uses native under Node and uses WASM under Bun versions before 1.4.0, where Bun's NAPI teardown race can panic on quit; native is restored automatically on Bun 1.4.0+. Inference runs in a dedicated worker after disabling POSIX telemetry in the native process environment. Compiled Bun hosts and hosts without a verified in-process opt-out use a subprocess instead. Windows native ONNX emits OS-controlled ETW diagnostics, not direct uploads. On Bun before 1.4.0, even explicit 'native' uses WASM because native worker teardown can crash the process. Set 'wasm' to avoid loading the native addon on newer hosts too."),
9243
9215
  local_dtype: _enum([
9244
9216
  "auto",
9245
9217
  "fp32",
@@ -9348,8 +9320,8 @@ var init_magic_context = __esm(() => {
9348
9320
  object({ default: number2().min(0) }).catchall(number2().min(0))
9349
9321
  ]).optional().describe('User-only output-token reservation override. Number or per-model object ({ default: 16384, "provider/model": 8192 }); 0 disables reservation. Takes precedence over every derived source: an explicit value here always wins against catalog output limits, provider window-geometry facts, and the 25%-of-context fallback (usable window = context window minus this reserve). When unset, Magic Context reserves the catalog output limit (capped at 25% of context) for shared-window providers and keeps proven separate-quota Google/Gemini windows unchanged.'),
9350
9322
  models: object({
9351
- window_overlay_path: string2().trim().min(1).optional()
9352
- }).optional().describe("User-only Fusiform window-overlay settings. The path defaults to <dataDir>/fusiform/window-overlay.json."),
9323
+ window_overlay_path: unknown().optional().describe("Deprecated: ignored. Fusiform no longer publishes window-overlay data, so this setting no longer changes model window geometry. Remove this key.").meta({ deprecated: true })
9324
+ }).optional().describe("Deprecated user-only Fusiform window-overlay settings; ignored."),
9353
9325
  toast_duration_ms: number2().min(0).max(60000).default(5000).describe("TUI toast lifetime in milliseconds for Magic Context notifications. Set to 0 to disable Magic Context toasts entirely (min: 0, max: 60000, default: 5000)"),
9354
9326
  execute_threshold_percentage: union([
9355
9327
  number2().min(20).max(90, EXECUTE_THRESHOLD_CAP_MESSAGE),
@@ -9750,7 +9722,7 @@ function stripUnsafeProjectConfigFields(projectRaw) {
9750
9722
  const models = projectRaw.models;
9751
9723
  if (isPlainObject2(models) && "window_overlay_path" in models) {
9752
9724
  delete models.window_overlay_path;
9753
- warnings.push("Ignoring models.window_overlay_path from project config (security: only user-level config may select model geometry metadata).");
9725
+ warnings.push("Ignoring models.window_overlay_path from project config (deprecated; this setting no longer changes model window geometry).");
9754
9726
  }
9755
9727
  if ("language" in projectRaw) {
9756
9728
  delete projectRaw.language;
@@ -10917,6 +10889,7 @@ function parsePluginConfig(rawConfig, recoveredTopLevelKeys = []) {
10917
10889
  preMigrationWarnings.push(...misplacedAgentModelWarnings(rawConfig));
10918
10890
  const migratedExperimental = migrateLegacyExperimental(configWithoutRemovedAgent, preMigrationWarnings);
10919
10891
  warnDeprecatedMuralModel(migratedExperimental, preMigrationWarnings);
10892
+ warnDeprecatedWindowOverlayPath(migratedExperimental, preMigrationWarnings);
10920
10893
  const migratedDreamer = migrateDreamerV2(migratedExperimental, preMigrationWarnings);
10921
10894
  const migrated = migrateLegacyAgentEnabledInMemory(migratedDreamer, preMigrationWarnings);
10922
10895
  const parsed = MagicContextConfigSchema.safeParse(migrated);
@@ -11168,7 +11141,6 @@ function loadPluginConfigDetailed(directory, applyRuntimeGlobals = true) {
11168
11141
  config.profile = profileResolution.activeProfile;
11169
11142
  if (applyRuntimeGlobals) {
11170
11143
  setOutputReserveConfig(config.output_reserve);
11171
- setWindowOverlayPath(config.models?.window_overlay_path);
11172
11144
  }
11173
11145
  const leafValidationWarnings = [...config.configWarnings ?? []];
11174
11146
  if (config.configWarnings?.length) {
@@ -11234,7 +11206,6 @@ var init_config = __esm(() => {
11234
11206
  init_jsonc_parser();
11235
11207
  init_logger();
11236
11208
  init_models_dev_cache();
11237
- init_window_geometry();
11238
11209
  init_agent_disable();
11239
11210
  init_migrate_config_location();
11240
11211
  init_migrate_dreamer_v2();
@@ -32076,15 +32047,111 @@ var init_edit_marker = __esm(() => {
32076
32047
  DIFF_KEYS = new Set(["oldString", "newString", "content", "old_string", "new_string"]);
32077
32048
  });
32078
32049
 
32079
- // ../plugin/src/hooks/magic-context/final-wire-token-estimate.ts
32080
- var wireTextTokens;
32081
- var init_final_wire_token_estimate = __esm(() => {
32082
- init_tool_definition_tokens();
32050
+ // ../plugin/src/features/magic-context/merged-reasoning-decisions.ts
32051
+ var decodedDecisions, MAX_DECODED_DECISION_BYTES;
32052
+ var init_merged_reasoning_decisions = __esm(() => {
32053
+ decodedDecisions = new Map;
32054
+ MAX_DECODED_DECISION_BYTES = 32 * 1024 * 1024;
32055
+ });
32056
+ // ../plugin/src/features/magic-context/session-decision-calibration.ts
32057
+ var init_session_decision_calibration = __esm(() => {
32083
32058
  init_decision_calibration();
32084
- init_image_token_estimate();
32085
- init_read_session_formatting();
32086
- init_tokenizer_calibration();
32087
- wireTextTokens = createTokenCountMemo(1e5, 128 * 1024 * 1024);
32059
+ init_harness_provider_map();
32060
+ });
32061
+
32062
+ // ../plugin/src/features/magic-context/protection-window.ts
32063
+ var init_protection_window = __esm(async () => {
32064
+ init_session_decision_calibration();
32065
+ await init_storage_tags();
32066
+ });
32067
+
32068
+ // ../plugin/src/features/magic-context/storage-meta-shared.ts
32069
+ var BOOLEAN_META_KEYS, NULL_BIND_META_KEYS, sessionMetaExistsStatements;
32070
+ var init_storage_meta_shared = __esm(async () => {
32071
+ init_harness_provider_map();
32072
+ await init_sqlite();
32073
+ BOOLEAN_META_KEYS = new Set(["isSubagent", "compartmentInProgress", "cacheAlertSent"]);
32074
+ NULL_BIND_META_KEYS = new Set([
32075
+ "cachedM0Bytes",
32076
+ "cachedM0MuralDataUrl",
32077
+ "cachedM0MuralHash",
32078
+ "cachedM1Bytes",
32079
+ "cachedM0ProjectMemoryEpoch",
32080
+ "cachedM0WorkspaceFingerprint",
32081
+ "cachedM0ProjectUserProfileVersion",
32082
+ "cachedM0MaxCompartmentSeq",
32083
+ "cachedM0MaxMemoryId",
32084
+ "cachedM0MaxMutationId",
32085
+ "cachedM0MaxMemoryMutationId",
32086
+ "cachedM0ProjectDocsHash",
32087
+ "cachedM0MaterializedAt",
32088
+ "cachedM0SessionFactsVersion",
32089
+ "cachedM0UpgradeState",
32090
+ "cachedM0ProjectIdentity",
32091
+ "lastObservedModelKey",
32092
+ "upgradeRemindedAt",
32093
+ "upgradeReminderLastSentAt",
32094
+ "piStableIdScheme"
32095
+ ]);
32096
+ sessionMetaExistsStatements = new WeakMap;
32097
+ });
32098
+
32099
+ // ../plugin/src/features/magic-context/storage-replay-document.ts
32100
+ var MISSING_REPLAY_DOCUMENT_COLUMN, decisionTablePresent, trailingBlankReadCache, TRAILING_BLANK_CACHE_MAX_CHARS, DECISION_CONFLICT;
32101
+ var init_storage_replay_document = __esm(async () => {
32102
+ init_logger();
32103
+ await init_storage_meta_shared();
32104
+ MISSING_REPLAY_DOCUMENT_COLUMN = Symbol("missing replay document column");
32105
+ decisionTablePresent = new WeakMap;
32106
+ trailingBlankReadCache = new WeakMap;
32107
+ TRAILING_BLANK_CACHE_MAX_CHARS = 4 * 1024 * 1024;
32108
+ DECISION_CONFLICT = Symbol("replay decision changed concurrently");
32109
+ });
32110
+
32111
+ // ../plugin/src/features/magic-context/storage-meta-persisted.ts
32112
+ var emergencyRecoveryArmedSessions, emergencyRecoveryArmedAtBySession, providerOverflowReconfirmedSessions, providerOverflowKnownLimitSessions, AUTO_SEARCH_NO_HINT_REASONS, DRAIN_WINDOW_MS, WRAPUP_IN_PROGRESS_TTL_MS, COMPACTION_MODE_RECORD_VALUES, EMERGENCY_DRAIN_MAX_LATCH_MS, pendingAutoSearchRetirements, COMPACTION_MARKER_PENDING_BUDGET_MS, preSnapshotSessions, warnedProtectedTokenTierOverrides;
32113
+ var init_storage_meta_persisted = __esm(async () => {
32114
+ init_magic_context();
32115
+ init_harness_provider_map();
32116
+ init_logger();
32117
+ init_write_transaction_timing();
32118
+ init_merged_reasoning_decisions();
32119
+ await __promiseAll([
32120
+ init_protection_window(),
32121
+ init_storage_meta_shared(),
32122
+ init_storage_replay_document()
32123
+ ]);
32124
+ emergencyRecoveryArmedSessions = new Set;
32125
+ emergencyRecoveryArmedAtBySession = new Map;
32126
+ providerOverflowReconfirmedSessions = new Set;
32127
+ providerOverflowKnownLimitSessions = new Set;
32128
+ AUTO_SEARCH_NO_HINT_REASONS = new Set([
32129
+ "below-threshold",
32130
+ "timeout",
32131
+ "empty",
32132
+ "error",
32133
+ "stacked",
32134
+ "too-short"
32135
+ ]);
32136
+ DRAIN_WINDOW_MS = 10 * 60 * 1000;
32137
+ WRAPUP_IN_PROGRESS_TTL_MS = 5 * 60 * 1000;
32138
+ COMPACTION_MODE_RECORD_VALUES = new Set([
32139
+ "on",
32140
+ "off",
32141
+ "on_notice_pending",
32142
+ "off_notice_pending",
32143
+ "off_cleanup_pending"
32144
+ ]);
32145
+ EMERGENCY_DRAIN_MAX_LATCH_MS = 30 * 60 * 1000;
32146
+ pendingAutoSearchRetirements = new WeakMap;
32147
+ COMPACTION_MARKER_PENDING_BUDGET_MS = 5 * 60000;
32148
+ preSnapshotSessions = new Map;
32149
+ warnedProtectedTokenTierOverrides = new WeakSet;
32150
+ });
32151
+
32152
+ // ../plugin/src/features/magic-context/storage-reasoning-removal.ts
32153
+ var init_storage_reasoning_removal = __esm(async () => {
32154
+ await init_storage_replay_document();
32088
32155
  });
32089
32156
 
32090
32157
  // ../plugin/src/features/magic-context/overflow-detection.ts
@@ -32108,6 +32175,74 @@ var init_sentinel = __esm(() => {
32108
32175
  NEUTRALIZED_ORIGINALS = new WeakMap;
32109
32176
  });
32110
32177
 
32178
+ // ../plugin/src/hooks/magic-context/active-anthropic-turn.ts
32179
+ var init_active_anthropic_turn = __esm(() => {
32180
+ init_sentinel();
32181
+ });
32182
+
32183
+ // ../plugin/src/hooks/magic-context/strip-content.ts
32184
+ var METADATA_PART_TYPES, CLEARED_REASONING_TYPES, REASONING_IGNORED_PART_TYPES, REASONING_PART_TYPES;
32185
+ var init_strip_content = __esm(() => {
32186
+ init_merged_reasoning_decisions();
32187
+ init_sentinel();
32188
+ init_tag_content_primitives();
32189
+ METADATA_PART_TYPES = new Set([
32190
+ "step-start",
32191
+ "step-finish",
32192
+ "snapshot",
32193
+ "patch",
32194
+ "agent",
32195
+ "retry",
32196
+ "subtask",
32197
+ "compaction"
32198
+ ]);
32199
+ CLEARED_REASONING_TYPES = new Set(["thinking", "reasoning"]);
32200
+ REASONING_IGNORED_PART_TYPES = new Set([
32201
+ "step-start",
32202
+ "step-finish",
32203
+ "snapshot",
32204
+ "patch",
32205
+ "agent",
32206
+ "retry",
32207
+ "subtask",
32208
+ "compaction"
32209
+ ]);
32210
+ REASONING_PART_TYPES = new Set(["reasoning", "thinking", "redacted_thinking"]);
32211
+ });
32212
+
32213
+ // ../plugin/src/hooks/magic-context/reasoning-budget.ts
32214
+ var init_reasoning_budget = __esm(async () => {
32215
+ init_merged_reasoning_decisions();
32216
+ init_prompt_surface();
32217
+ init_active_anthropic_turn();
32218
+ init_read_session_formatting();
32219
+ init_sentinel();
32220
+ init_strip_content();
32221
+ await __promiseAll([
32222
+ init_storage_meta_persisted(),
32223
+ init_storage_reasoning_removal(),
32224
+ init_storage_tags()
32225
+ ]);
32226
+ });
32227
+
32228
+ // ../plugin/src/hooks/magic-context/opaque-thinking.ts
32229
+ var init_opaque_thinking = __esm(async () => {
32230
+ await init_reasoning_budget();
32231
+ });
32232
+
32233
+ // ../plugin/src/hooks/magic-context/final-wire-token-estimate.ts
32234
+ var wireTextTokens;
32235
+ var init_final_wire_token_estimate = __esm(async () => {
32236
+ init_tool_definition_tokens();
32237
+ init_decision_calibration();
32238
+ init_image_token_estimate();
32239
+ init_read_session_formatting();
32240
+ init_tokenizer_calibration();
32241
+ init_logger();
32242
+ await init_opaque_thinking();
32243
+ wireTextTokens = createTokenCountMemo(1e5, 128 * 1024 * 1024);
32244
+ });
32245
+
32111
32246
  // ../plugin/src/hooks/magic-context/tool-input-size.ts
32112
32247
  var encoder2;
32113
32248
  var init_tool_input_size = __esm(() => {
@@ -32136,14 +32271,14 @@ function extractToolCallObservation(part) {
32136
32271
  return null;
32137
32272
  }
32138
32273
  var IGNORE_PART_TYPES;
32139
- var init_tool_drop_target = __esm(() => {
32274
+ var init_tool_drop_target = __esm(async () => {
32140
32275
  init_user_answer();
32141
32276
  init_dropped_input_guard();
32142
32277
  init_edit_marker();
32143
- init_final_wire_token_estimate();
32144
32278
  init_sentinel();
32145
32279
  init_tag_content_primitives();
32146
32280
  init_tool_input_size();
32281
+ await init_final_wire_token_estimate();
32147
32282
  IGNORE_PART_TYPES = new Set([
32148
32283
  "thinking",
32149
32284
  "reasoning",
@@ -33122,13 +33257,13 @@ var init_read_session_chunk = __esm(async () => {
33122
33257
  init_read_session_true_raw_tokens();
33123
33258
  init_system_injection_stripper();
33124
33259
  init_tag_part_guards();
33125
- init_tool_drop_target();
33126
33260
  init_read_session_formatting();
33127
33261
  await __promiseAll([
33128
33262
  init_storage_tags(),
33129
33263
  init_raw_ordinal_warmup(),
33130
33264
  init_read_session_db(),
33131
- init_read_session_raw()
33265
+ init_read_session_raw(),
33266
+ init_tool_drop_target()
33132
33267
  ]);
33133
33268
  blockTokenMemo = new Map;
33134
33269
  sessionProviders = new Map;
@@ -44228,6 +44363,7 @@ function parsePiConfig(rawConfig, recoveredTopLevelKeys = []) {
44228
44363
  const agentMigrated = migrateLegacyAgentEnabledInMemory(configToMigrate, preMigrationWarnings);
44229
44364
  const migratedExperimental = migrateLegacyExperimental(agentMigrated, preMigrationWarnings);
44230
44365
  warnDeprecatedMuralModel(migratedExperimental, preMigrationWarnings);
44366
+ warnDeprecatedWindowOverlayPath(migratedExperimental, preMigrationWarnings);
44231
44367
  const migrated = migrateDreamerV2(migratedExperimental, preMigrationWarnings);
44232
44368
  const parsed = MagicContextConfigSchema.safeParse(migrated);
44233
44369
  if (parsed.success) {
@@ -44470,7 +44606,6 @@ function loadPiConfigDetailed(opts = {}, applyRuntimeGlobals = true) {
44470
44606
  parsed.config.profile = profileResolution.activeProfile;
44471
44607
  if (applyRuntimeGlobals) {
44472
44608
  setOutputReserveConfig(parsed.config.output_reserve);
44473
- setWindowOverlayPath(parsed.config.models?.window_overlay_path);
44474
44609
  }
44475
44610
  warnings.push(...parsed.warnings.map((warning) => `[merged config] ${warning}`));
44476
44611
  const substitutionFailures = loadedFiles.flatMap(bindSubstitutionFailures2);
@@ -44520,7 +44655,6 @@ var init_config2 = __esm(() => {
44520
44655
  init_config_diagnostics();
44521
44656
  init_jsonc_parser();
44522
44657
  init_models_dev_cache();
44523
- init_window_geometry();
44524
44658
  });
44525
44659
 
44526
44660
  // src/lib/database-repair-guidance.ts
@@ -44970,6 +45104,151 @@ var init_log_lines = __esm(() => {
44970
45104
  LEVEL_DEFAULT = LEVEL_ORDER.INFO;
44971
45105
  });
44972
45106
 
45107
+ // src/lib/issue-body.ts
45108
+ function isErrorLogLine(line) {
45109
+ const parsed = parseLogLine(line);
45110
+ if (parsed?.level !== null && parsed?.level !== undefined) {
45111
+ return parsed.level === "ERROR" || parsed.level === "WARN";
45112
+ }
45113
+ if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(line))
45114
+ return false;
45115
+ const message = parsed?.message ?? line;
45116
+ return ERROR_LOG_PATTERNS.some((rx) => rx.test(message));
45117
+ }
45118
+ function extractRecentErrors(sanitized, limit = 20) {
45119
+ const matches = [];
45120
+ const lines = sanitized.split(/\r?\n/);
45121
+ for (let i = lines.length - 1;i >= 0 && matches.length < limit; i -= 1) {
45122
+ if (isErrorLogLine(lines[i])) {
45123
+ matches.push(lines[i]);
45124
+ }
45125
+ }
45126
+ return matches.reverse();
45127
+ }
45128
+ function filterLogLinesBySession(lines, sessionId) {
45129
+ if (!sessionId)
45130
+ return lines;
45131
+ const otherSessionPattern = /\bses_[A-Za-z0-9]{3,64}\b/g;
45132
+ return lines.filter((line) => {
45133
+ const parsed = parseLogLine(line);
45134
+ if (parsed?.session && parsed.session !== sessionId)
45135
+ return false;
45136
+ const matches = parsed?.message.match(otherSessionPattern) ?? line.match(otherSessionPattern);
45137
+ if (!matches)
45138
+ return true;
45139
+ return matches.every((id) => id === sessionId);
45140
+ });
45141
+ }
45142
+ function getLogSessionIds(lines) {
45143
+ const otherSessionPattern = /\bses_[A-Za-z0-9]{3,64}\b/g;
45144
+ const seen = new Set;
45145
+ const sessions = [];
45146
+ for (let index = lines.length - 1;index >= 0; index -= 1) {
45147
+ const line = lines[index];
45148
+ const parsed = parseLogLine(line);
45149
+ if (parsed?.session && !seen.has(parsed.session)) {
45150
+ seen.add(parsed.session);
45151
+ sessions.push(parsed.session);
45152
+ }
45153
+ const matches = parsed?.message.match(otherSessionPattern) ?? line.match(otherSessionPattern);
45154
+ for (const session of matches ?? []) {
45155
+ if (!seen.has(session)) {
45156
+ seen.add(session);
45157
+ sessions.push(session);
45158
+ }
45159
+ }
45160
+ }
45161
+ return sessions;
45162
+ }
45163
+ function capBodyToGithubLimit(body, maxBytes = MAX_GITHUB_BODY_BYTES) {
45164
+ if (Buffer.byteLength(body, "utf8") <= maxBytes)
45165
+ return body;
45166
+ let capped = body;
45167
+ const heading = "## Log (last";
45168
+ const headingIdx = body.indexOf(heading);
45169
+ if (headingIdx === -1) {
45170
+ const markerBytes = Buffer.byteLength(FALLBACK_TRUNCATION_MARKER, "utf8");
45171
+ capped = truncateToByteBudget(body, maxBytes - markerBytes) + FALLBACK_TRUNCATION_MARKER;
45172
+ return enforceFinalBodyLimit(capped, maxBytes);
45173
+ }
45174
+ const fenceOpenIdx = body.indexOf("\n```", headingIdx);
45175
+ if (fenceOpenIdx === -1)
45176
+ return enforceFinalBodyLimit(body, maxBytes);
45177
+ const logStart = fenceOpenIdx + "\n```\n".length;
45178
+ const fenceCloseIdx = body.indexOf("\n```", logStart);
45179
+ if (fenceCloseIdx === -1)
45180
+ return enforceFinalBodyLimit(body, maxBytes);
45181
+ const head = body.slice(0, logStart);
45182
+ const log = body.slice(logStart, fenceCloseIdx);
45183
+ const tail = body.slice(fenceCloseIdx);
45184
+ const overheadBytes = Buffer.byteLength(head, "utf8") + Buffer.byteLength(tail, "utf8");
45185
+ const markerBytes = Buffer.byteLength(LOG_TRUNCATION_MARKER, "utf8");
45186
+ const logBudget = maxBytes - overheadBytes - markerBytes;
45187
+ if (logBudget <= 0) {
45188
+ capped = `${head}${LOG_TRUNCATION_MARKER}${tail}`;
45189
+ return enforceFinalBodyLimit(capped, maxBytes);
45190
+ }
45191
+ const lines = log.split(`
45192
+ `);
45193
+ let keepLines = lines;
45194
+ let kept = keepLines.join(`
45195
+ `);
45196
+ while (Buffer.byteLength(kept, "utf8") > logBudget && keepLines.length > 1) {
45197
+ const dropCount = Math.max(1, Math.floor(keepLines.length * 0.05));
45198
+ keepLines = keepLines.slice(dropCount);
45199
+ kept = keepLines.join(`
45200
+ `);
45201
+ }
45202
+ if (Buffer.byteLength(kept, "utf8") > logBudget) {
45203
+ kept = truncateToByteBudget(kept, logBudget);
45204
+ }
45205
+ capped = `${head}${LOG_TRUNCATION_MARKER}${kept}${tail}`;
45206
+ return enforceFinalBodyLimit(capped, maxBytes);
45207
+ }
45208
+ function enforceFinalBodyLimit(body, maxBytes) {
45209
+ if (Buffer.byteLength(body, "utf8") <= maxBytes)
45210
+ return body;
45211
+ const markerBytes = Buffer.byteLength(FINAL_TRUNCATION_MARKER, "utf8");
45212
+ if (markerBytes >= maxBytes) {
45213
+ return truncateToByteBudget(FINAL_TRUNCATION_MARKER, maxBytes);
45214
+ }
45215
+ return truncateToByteBudget(body, maxBytes - markerBytes) + FINAL_TRUNCATION_MARKER;
45216
+ }
45217
+ function truncateToByteBudget(input, maxBytes) {
45218
+ if (maxBytes <= 0)
45219
+ return "";
45220
+ const buf = Buffer.from(input, "utf8");
45221
+ if (buf.length <= maxBytes)
45222
+ return input;
45223
+ let end = maxBytes;
45224
+ while (end > 0 && (buf[end] & 192) === 128) {
45225
+ end -= 1;
45226
+ }
45227
+ return buf.subarray(0, end).toString("utf8");
45228
+ }
45229
+ var MAX_GITHUB_BODY_BYTES = 60000, LOG_TRUNCATION_MARKER = `[truncated for GitHub 64KB limit — older log lines dropped]
45230
+ `, FINAL_TRUNCATION_MARKER = `
45231
+
45232
+ [truncated further to fit GitHub body limit]
45233
+ `, FALLBACK_TRUNCATION_MARKER = `
45234
+
45235
+ [truncated for GitHub 64KB limit]
45236
+ `, ERROR_LOG_PATTERNS;
45237
+ var init_issue_body = __esm(() => {
45238
+ init_log_lines();
45239
+ ERROR_LOG_PATTERNS = [
45240
+ /\bfailed:/i,
45241
+ /\b(?:[A-Z][a-zA-Z]*)?Error:\s/,
45242
+ /\bEMERGENCY\b/,
45243
+ /could not safely prepare this turn/i,
45244
+ /\bMC-H[A-Z0-9-]+\b/i,
45245
+ /\brefused\s*\(/i,
45246
+ /\bexception\b/i,
45247
+ /^\s+at\s+[\w.<>$]+\s+\(/,
45248
+ /^\s+at\s+(?:file:|node_modules\/|[^/\s]+:\d+)/
45249
+ ];
45250
+ });
45251
+
44973
45252
  // src/lib/redaction.ts
44974
45253
  function sanitizeDiagnosticEndpoint(value) {
44975
45254
  const trimmed = value.trim();
@@ -45059,6 +45338,8 @@ function pluginDeclaresOmp(path) {
45059
45338
  }
45060
45339
  async function runHealthChecks(options) {
45061
45340
  const results = [];
45341
+ let pluginVersion = null;
45342
+ let ompVersion = null;
45062
45343
  const repairPlan = {
45063
45344
  installPlugin: false,
45064
45345
  disableCompaction: false,
@@ -45070,11 +45351,13 @@ async function runHealthChecks(options) {
45070
45351
  add(results, "fail", "OMP binary not found on PATH or in standard user bin directories");
45071
45352
  } else {
45072
45353
  const version = options.deps.getOmpVersion(omp.path);
45354
+ ompVersion = version;
45073
45355
  const plugins = options.deps.listOmpPlugins(omp.path);
45074
45356
  if (!plugins) {
45075
45357
  add(results, "fail", "`omp plugin list --json` failed or returned invalid JSON");
45076
45358
  } else {
45077
45359
  const plugin = plugins.find((entry) => entry.name === OMP_PLUGIN_PACKAGE);
45360
+ pluginVersion = plugin?.version ?? null;
45078
45361
  if (!plugin) {
45079
45362
  add(results, "info", `${version ? `Oh My Pi ${version}` : "Oh My Pi"} found; Magic Context is not installed there (run setup to add it)`);
45080
45363
  repairPlan.installPlugin = true;
@@ -45201,6 +45484,9 @@ ${formatDatabaseRepairGuidance(dbPath)}`);
45201
45484
  return {
45202
45485
  results,
45203
45486
  repairPlan,
45487
+ pluginVersion,
45488
+ ompVersion,
45489
+ logFiles,
45204
45490
  pass: results.filter((result) => result.status === "pass").length,
45205
45491
  warn: results.filter((result) => result.status === "warn").length,
45206
45492
  fail: results.filter((result) => result.status === "fail").length
@@ -45254,17 +45540,51 @@ async function repair(plan, deps, prompts, cwd) {
45254
45540
  function timestamp2(date) {
45255
45541
  return date.toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "Z");
45256
45542
  }
45257
- function ompIssueBody(description, report) {
45543
+ function ompIssueBody(description, report, logLines, sessionFilter) {
45544
+ const LOG_TAIL_LINES = 400;
45545
+ const filteredLogLines = filterLogLinesBySession(logLines, sessionFilter);
45546
+ const recentLog = sanitizeDiagnosticText(filteredLogLines.slice(-LOG_TAIL_LINES).join(`
45547
+ `)).trim();
45548
+ const errorScanWindow = sanitizeDiagnosticText(filteredLogLines.slice(-4000).join(`
45549
+ `));
45550
+ const recentErrorLines = extractRecentErrors(errorScanWindow, 20);
45258
45551
  return [
45259
45552
  "## Description",
45260
45553
  sanitizeDiagnosticText(description),
45261
45554
  "",
45555
+ "## Environment",
45556
+ `- Magic Context plugin: ${report.pluginVersion ? `v${sanitizeDiagnosticText(report.pluginVersion)}` : "not installed"}`,
45557
+ `- Oh My Pi: ${report.ompVersion ? sanitizeDiagnosticText(report.ompVersion) : "not detected"}`,
45558
+ `- OS: ${process.platform} ${process.arch}`,
45559
+ `- Runtime: Node.js ${process.version}`,
45560
+ "",
45262
45561
  "## OMP diagnostics",
45263
- `- Magic Context CLI: ${selfVersion()}`,
45264
- ...report.results.map((result) => `- ${result.status.toUpperCase()}: ${sanitizeDiagnosticText(result.message)}`)
45562
+ `- Magic Context CLI: v${selfVersion()}`,
45563
+ ...report.results.map((result) => `- ${result.status.toUpperCase()}: ${sanitizeDiagnosticText(result.message)}`),
45564
+ "",
45565
+ "## Recent errors (last 20, sanitized)",
45566
+ recentErrorLines.length === 0 ? "_No error-shaped log lines found in recent history._" : ["```", recentErrorLines.join(`
45567
+ `), "```"].join(`
45568
+ `),
45569
+ "",
45570
+ `## Log (last ${LOG_TAIL_LINES} lines, sanitized)`,
45571
+ "```",
45572
+ recentLog || "<no log output>",
45573
+ "```"
45265
45574
  ].join(`
45266
45575
  `);
45267
45576
  }
45577
+ function writeOmpIssueReport(path, fullBodyMarkdown) {
45578
+ const bodyMarkdown = capBodyToGithubLimit(fullBodyMarkdown);
45579
+ const truncated = bodyMarkdown !== fullBodyMarkdown;
45580
+ writeFileAtomic(path, `${bodyMarkdown}
45581
+ `);
45582
+ const fullPath = truncated ? `${path}.full.md` : undefined;
45583
+ if (fullPath)
45584
+ writeFileAtomic(fullPath, `${fullBodyMarkdown}
45585
+ `);
45586
+ return { path, bodyMarkdown, ...fullPath ? { fullPath } : {}, truncated };
45587
+ }
45268
45588
  function runGhCommandWithDeps(deps, args) {
45269
45589
  if (args[0] === "issue") {
45270
45590
  const result = deps.spawnSync("gh", args, {
@@ -45298,9 +45618,8 @@ async function runIssueFlow(options) {
45298
45618
  if (options.reportPath) {
45299
45619
  const report = await runHealthChecks({ ...options, quiet: true });
45300
45620
  const path = isAbsolute8(options.reportPath) ? options.reportPath : join33(options.cwd, options.reportPath);
45301
- writeFileAtomic(path, `${ompIssueBody("Generated non-interactively by `doctor --issue --report`.", report)}
45302
- `);
45303
- options.prompts.log.success(`Sanitized report written to ${path}`);
45621
+ const bundle = writeOmpIssueReport(path, ompIssueBody("Generated non-interactively by `doctor --issue --report`.", report, readLogLines(report.logFiles), null));
45622
+ options.prompts.log.success(bundle.fullPath ? `Sanitized report written to ${bundle.path}; full report at ${bundle.fullPath}` : `Sanitized report written to ${bundle.path}`);
45304
45623
  return 0;
45305
45624
  }
45306
45625
  const title = await options.prompts.text("Issue title", {
@@ -45312,19 +45631,31 @@ async function runIssueFlow(options) {
45312
45631
  validate: (value) => value.trim() ? undefined : "Description is required"
45313
45632
  });
45314
45633
  const report = await runHealthChecks({ ...options, quiet: true });
45634
+ const logLines = readLogLines(report.logFiles);
45635
+ const sessionIds = getLogSessionIds(logLines);
45636
+ let sessionFilter = null;
45637
+ if (sessionIds.length > 1) {
45638
+ const choice = await options.prompts.selectOne("Which OMP session is this issue about? (filters log lines from other sessions)", [
45639
+ ...sessionIds.map((sessionId, index) => ({
45640
+ label: `${sessionId}${index === 0 ? " (most recent)" : ""}`,
45641
+ value: sessionId
45642
+ })),
45643
+ { label: "All sessions (no filtering)", value: "__all__" }
45644
+ ]);
45645
+ sessionFilter = choice === "__all__" ? null : choice;
45646
+ }
45315
45647
  const path = join33(options.cwd, `magic-context-omp-issue-${timestamp2(options.deps.now())}.md`);
45316
- writeFileAtomic(path, `${ompIssueBody(description, report)}
45317
- `);
45318
- options.prompts.log.success(`Sanitized report written to ${path}`);
45648
+ const bundle = writeOmpIssueReport(path, ompIssueBody(description, report, logLines, sessionFilter));
45649
+ options.prompts.log.success(bundle.fullPath ? `Sanitized report written to ${bundle.path}; full report at ${bundle.fullPath}` : `Sanitized report written to ${bundle.path}`);
45319
45650
  if (await options.prompts.confirm("Submit this issue on GitHub now?", false)) {
45320
- const result = submitGithubIssue(`[omp] ${title}`, path, (args) => runGhCommandWithDeps(options.deps, args));
45651
+ const result = submitGithubIssue(`[omp] ${title}`, bundle.path, (args) => runGhCommandWithDeps(options.deps, args));
45321
45652
  if (result.ok) {
45322
45653
  options.prompts.log.success(result.output);
45323
45654
  } else {
45324
- options.prompts.log.warn(formatGithubIssueFallback(result, path));
45655
+ options.prompts.log.warn(formatGithubIssueFallback(result, bundle.fullPath ?? bundle.path));
45325
45656
  }
45326
45657
  }
45327
- options.prompts.log.info(`Open https://github.com/cortexkit/magic-context/issues/new and drag ${path} into the issue`);
45658
+ options.prompts.log.info(`Open https://github.com/cortexkit/magic-context/issues/new and drag ${bundle.fullPath ?? bundle.path} into the issue`);
45328
45659
  return 0;
45329
45660
  }
45330
45661
  async function runDoctor(options = {}) {
@@ -45365,6 +45696,7 @@ var init_doctor_omp = __esm(async () => {
45365
45696
  init_atomic_write();
45366
45697
  init_config_location_migration();
45367
45698
  init_github_issue();
45699
+ init_issue_body();
45368
45700
  init_log_lines();
45369
45701
  init_omp_helpers();
45370
45702
  init_paths();
@@ -47017,9 +47349,13 @@ var init_embedding_identity = __esm(() => {
47017
47349
  init_normalize_hash();
47018
47350
  });
47019
47351
 
47352
+ // ../plugin/src/features/magic-context/memory/onnx-telemetry.ts
47353
+ var init_onnx_telemetry = () => {};
47354
+
47020
47355
  // ../plugin/src/features/magic-context/memory/embedding-worker-client.ts
47021
47356
  var init_embedding_worker_client = __esm(() => {
47022
47357
  init_logger();
47358
+ init_onnx_telemetry();
47023
47359
  });
47024
47360
  // ../plugin/src/features/magic-context/memory/embedding-local.ts
47025
47361
  function currentLocalEmbeddingHost() {
@@ -47438,113 +47774,6 @@ var init_embedding_runtime = __esm(() => {
47438
47774
  runOnnxRuntimeNodeLoadProbeChildForRuntime = runOnnxRuntimeNodeLoadProbeChild;
47439
47775
  });
47440
47776
 
47441
- // src/lib/issue-body.ts
47442
- function isErrorLogLine(line) {
47443
- const parsed = parseLogLine(line);
47444
- if (parsed?.level !== null && parsed?.level !== undefined) {
47445
- return parsed.level === "ERROR" || parsed.level === "WARN";
47446
- }
47447
- if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(line))
47448
- return false;
47449
- const message = parsed?.message ?? line;
47450
- return ERROR_LOG_PATTERNS.some((rx) => rx.test(message));
47451
- }
47452
- function extractRecentErrors(sanitized, limit = 20) {
47453
- const matches = [];
47454
- const lines = sanitized.split(/\r?\n/);
47455
- for (let i = lines.length - 1;i >= 0 && matches.length < limit; i -= 1) {
47456
- if (isErrorLogLine(lines[i])) {
47457
- matches.push(lines[i]);
47458
- }
47459
- }
47460
- return matches.reverse();
47461
- }
47462
- function capBodyToGithubLimit(body, maxBytes = MAX_GITHUB_BODY_BYTES) {
47463
- if (Buffer.byteLength(body, "utf8") <= maxBytes)
47464
- return body;
47465
- let capped = body;
47466
- const heading = "## Log (last";
47467
- const headingIdx = body.indexOf(heading);
47468
- if (headingIdx === -1) {
47469
- const markerBytes = Buffer.byteLength(FALLBACK_TRUNCATION_MARKER, "utf8");
47470
- capped = truncateToByteBudget(body, maxBytes - markerBytes) + FALLBACK_TRUNCATION_MARKER;
47471
- return enforceFinalBodyLimit(capped, maxBytes);
47472
- }
47473
- const fenceOpenIdx = body.indexOf("\n```", headingIdx);
47474
- if (fenceOpenIdx === -1)
47475
- return enforceFinalBodyLimit(body, maxBytes);
47476
- const logStart = fenceOpenIdx + "\n```\n".length;
47477
- const fenceCloseIdx = body.indexOf("\n```", logStart);
47478
- if (fenceCloseIdx === -1)
47479
- return enforceFinalBodyLimit(body, maxBytes);
47480
- const head = body.slice(0, logStart);
47481
- const log = body.slice(logStart, fenceCloseIdx);
47482
- const tail = body.slice(fenceCloseIdx);
47483
- const overheadBytes = Buffer.byteLength(head, "utf8") + Buffer.byteLength(tail, "utf8");
47484
- const markerBytes = Buffer.byteLength(LOG_TRUNCATION_MARKER, "utf8");
47485
- const logBudget = maxBytes - overheadBytes - markerBytes;
47486
- if (logBudget <= 0) {
47487
- capped = `${head}${LOG_TRUNCATION_MARKER}${tail}`;
47488
- return enforceFinalBodyLimit(capped, maxBytes);
47489
- }
47490
- const lines = log.split(`
47491
- `);
47492
- let keepLines = lines;
47493
- let kept = keepLines.join(`
47494
- `);
47495
- while (Buffer.byteLength(kept, "utf8") > logBudget && keepLines.length > 1) {
47496
- const dropCount = Math.max(1, Math.floor(keepLines.length * 0.05));
47497
- keepLines = keepLines.slice(dropCount);
47498
- kept = keepLines.join(`
47499
- `);
47500
- }
47501
- if (Buffer.byteLength(kept, "utf8") > logBudget) {
47502
- kept = truncateToByteBudget(kept, logBudget);
47503
- }
47504
- capped = `${head}${LOG_TRUNCATION_MARKER}${kept}${tail}`;
47505
- return enforceFinalBodyLimit(capped, maxBytes);
47506
- }
47507
- function enforceFinalBodyLimit(body, maxBytes) {
47508
- if (Buffer.byteLength(body, "utf8") <= maxBytes)
47509
- return body;
47510
- const markerBytes = Buffer.byteLength(FINAL_TRUNCATION_MARKER, "utf8");
47511
- if (markerBytes >= maxBytes) {
47512
- return truncateToByteBudget(FINAL_TRUNCATION_MARKER, maxBytes);
47513
- }
47514
- return truncateToByteBudget(body, maxBytes - markerBytes) + FINAL_TRUNCATION_MARKER;
47515
- }
47516
- function truncateToByteBudget(input, maxBytes) {
47517
- if (maxBytes <= 0)
47518
- return "";
47519
- const buf = Buffer.from(input, "utf8");
47520
- if (buf.length <= maxBytes)
47521
- return input;
47522
- let end = maxBytes;
47523
- while (end > 0 && (buf[end] & 192) === 128) {
47524
- end -= 1;
47525
- }
47526
- return buf.subarray(0, end).toString("utf8");
47527
- }
47528
- var MAX_GITHUB_BODY_BYTES = 60000, LOG_TRUNCATION_MARKER = `[truncated for GitHub 64KB limit — older log lines dropped]
47529
- `, FINAL_TRUNCATION_MARKER = `
47530
-
47531
- [truncated further to fit GitHub body limit]
47532
- `, FALLBACK_TRUNCATION_MARKER = `
47533
-
47534
- [truncated for GitHub 64KB limit]
47535
- `, ERROR_LOG_PATTERNS;
47536
- var init_issue_body = __esm(() => {
47537
- init_log_lines();
47538
- ERROR_LOG_PATTERNS = [
47539
- /\bfailed:/i,
47540
- /\b(?:[A-Z][a-zA-Z]*)?Error:\s/,
47541
- /\bEMERGENCY\b/,
47542
- /\bexception\b/i,
47543
- /^\s+at\s+[\w.<>$]+\s+\(/,
47544
- /^\s+at\s+(?:file:|node_modules\/|[^/\s]+:\d+)/
47545
- ];
47546
- });
47547
-
47548
47777
  // src/lib/logs-opencode.ts
47549
47778
  import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync7 } from "node:fs";
47550
47779
  import { dirname as dirname24, join as join37 } from "node:path";
@@ -47577,20 +47806,6 @@ function extractHistorianFailureLines(sanitized, limit = 30) {
47577
47806
  }
47578
47807
  return matches.reverse();
47579
47808
  }
47580
- function filterLogLinesBySession(lines, sessionId) {
47581
- if (!sessionId)
47582
- return lines;
47583
- const otherSessionPattern = /\bses_[A-Za-z0-9]{3,64}\b/g;
47584
- return lines.filter((line) => {
47585
- const parsed = parseLogLine(line);
47586
- if (parsed?.session && parsed.session !== sessionId)
47587
- return false;
47588
- const matches = parsed?.message.match(otherSessionPattern) ?? line.match(otherSessionPattern);
47589
- if (!matches)
47590
- return true;
47591
- return matches.every((id) => id === sessionId);
47592
- });
47593
- }
47594
47809
  async function bundleIssueReport(report, description, title, sessionFilter = null, options = {}) {
47595
47810
  const LOG_TAIL_LINES = 400;
47596
47811
  const allLogLines = readLogLines(report.logFiles ?? [report.logFile]);
@@ -50472,24 +50687,10 @@ function formatTimestamp2(date) {
50472
50687
  pad(date.getSeconds())
50473
50688
  ].join("");
50474
50689
  }
50475
- function filterLogLinesBySession2(lines, sessionId) {
50476
- if (!sessionId)
50477
- return lines;
50478
- const otherSessionPattern = /\bses_[A-Za-z0-9]{3,64}\b/g;
50479
- return lines.filter((line) => {
50480
- const parsed = parseLogLine(line);
50481
- if (parsed?.session && parsed.session !== sessionId)
50482
- return false;
50483
- const matches = parsed?.message.match(otherSessionPattern) ?? line.match(otherSessionPattern);
50484
- if (!matches)
50485
- return true;
50486
- return matches.every((id) => id === sessionId);
50487
- });
50488
- }
50489
50690
  async function bundleIssueReport2(report, description, title, options = {}) {
50490
50691
  const LOG_TAIL_LINES = 400;
50491
50692
  const allLogLines = readLogLines(report.logFiles ?? [report.logFile]);
50492
- const logLines = filterLogLinesBySession2(allLogLines, options.sessionFilter ?? null);
50693
+ const logLines = filterLogLinesBySession(allLogLines, options.sessionFilter ?? null);
50493
50694
  const recentLog = sanitizeLogContent2(logLines.slice(-LOG_TAIL_LINES).join(`
50494
50695
  `)).trim();
50495
50696
  const errorScanWindow = sanitizeLogContent2(logLines.slice(-4000).join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/magic-context",
3
- "version": "0.49.0",
3
+ "version": "0.49.2",
4
4
  "description": "Unified CLI for Magic Context — setup, doctor, and migration across OpenCode, Pi, and OMP",
5
5
  "keywords": [
6
6
  "opencode",