@cortexkit/magic-context 0.49.81 → 0.49.83

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 +161 -53
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -42758,11 +42758,22 @@ var init_storage_identity_merge = __esm(() => {
42758
42758
  ];
42759
42759
  });
42760
42760
 
42761
+ // ../plugin/src/features/magic-context/memory/identity-merge-command.ts
42762
+ function shellArg(value, platform) {
42763
+ if (/^[\w.:/-]+$/.test(value))
42764
+ return value;
42765
+ return platform === "win32" ? `"${value}"` : `'${value.replaceAll("'", "'\\''")}'`;
42766
+ }
42767
+ function identityMergeCommand(from, to, platform = process.platform) {
42768
+ return `${IDENTITY_MERGE_COMMAND} --from ${shellArg(from, platform)} --to ${to ? shellArg(to, platform) : '"DESTINATION_IDENTITY"'}`;
42769
+ }
42770
+ var IDENTITY_MERGE_COMMAND = "npx @cortexkit/magic-context@latest doctor merge-identities", IDENTITY_MERGE_PREVIEW_HINT = "It shows what would move. Add --apply to move them.";
42771
+
42761
42772
  // src/commands/doctor-identity-splits.ts
42762
42773
  import { execFileSync as execFileSync6 } from "node:child_process";
42763
42774
  import { createHash as createHash6 } from "node:crypto";
42764
42775
  import { existsSync as existsSync34, readdirSync as readdirSync7, realpathSync as realpathSync9, statSync as statSync19 } from "node:fs";
42765
- import { dirname as dirname21, join as join27, resolve as resolve15 } from "node:path";
42776
+ import { dirname as dirname21, isAbsolute as isAbsolute9, join as join27, resolve as resolve15 } from "node:path";
42766
42777
  function tableExists5(db, table) {
42767
42778
  return !!db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table);
42768
42779
  }
@@ -42790,6 +42801,39 @@ function orphanedPathReason(directory) {
42790
42801
  return;
42791
42802
  return "directory is empty and has no git metadata";
42792
42803
  }
42804
+ function resolveReadOnly(directory) {
42805
+ if (!existsSync34(directory))
42806
+ return;
42807
+ try {
42808
+ const roots = execFileSync6("git", ["rev-list", "--max-parents=0", "HEAD"], {
42809
+ cwd: directory,
42810
+ windowsHide: true,
42811
+ encoding: "utf8",
42812
+ timeout: 5000,
42813
+ stdio: ["ignore", "pipe", "pipe"]
42814
+ }).trim().split(/\s+/).filter((root) => /^[0-9a-f]{40,64}$/.test(root)).sort();
42815
+ if (roots[0])
42816
+ return `git:${roots[0]}`;
42817
+ } catch {}
42818
+ try {
42819
+ const result = execFileSync6("git", ["rev-parse", "--is-inside-work-tree"], {
42820
+ cwd: directory,
42821
+ windowsHide: true,
42822
+ encoding: "utf8",
42823
+ timeout: 5000,
42824
+ stdio: ["ignore", "pipe", "pipe"]
42825
+ });
42826
+ if (result.trim() === "true")
42827
+ return;
42828
+ } catch (error) {
42829
+ if (String(error.stderr).includes("not a git repository"))
42830
+ return `dir:${createHash6("md5").update(projectDirectoryKey(directory)).digest("hex").slice(0, 12)}`;
42831
+ }
42832
+ return;
42833
+ }
42834
+ function canonicalIdentity(directory, storageDir) {
42835
+ return readRememberedGitIdentity(directory, storageDir) ?? (orphanedPathReason(directory) ? undefined : resolveReadOnly(directory));
42836
+ }
42793
42837
  function findIdentitySplits(db, host, includeSingles = false) {
42794
42838
  if (!tableExists5(db, "session_projects"))
42795
42839
  return [];
@@ -42855,7 +42899,7 @@ function findIdentitySplits(db, host, includeSingles = false) {
42855
42899
  const gitIdentities = new Map;
42856
42900
  for (const [directoryKey, spellings] of directorySpellings) {
42857
42901
  for (const directory of spellings) {
42858
- const dirIdentity = `dir:${createHash6("md5").update(resolve15(directory), "utf8").digest("hex").slice(0, 12)}`;
42902
+ const dirIdentity = directoryFallback(directory);
42859
42903
  const hasData = [
42860
42904
  "memories",
42861
42905
  "notes",
@@ -42915,7 +42959,7 @@ function formatIdentitySplits(splits) {
42915
42959
  ...identityLines(split)
42916
42960
  ] : [
42917
42961
  `Project identity split: ${split.directory} (read-only; no merge performed)`,
42918
- " Review with doctor merge-identities before choosing which identity to keep.",
42962
+ ` Review with ${IDENTITY_MERGE_COMMAND} before choosing which identity to keep.`,
42919
42963
  ...identityLines(split)
42920
42964
  ];
42921
42965
  });
@@ -42923,8 +42967,82 @@ function formatIdentitySplits(splits) {
42923
42967
  function identityLines(split) {
42924
42968
  return split.identities.map((row) => ` ${row.identity}: ${row.sessions} sessions, ${row.memories} memories, ${row.notes} notes, ${row.dreamer} dreamer rows (identity-wide counts)`);
42925
42969
  }
42970
+ function eventDirectory(data, sessionId) {
42971
+ try {
42972
+ const event = JSON.parse(data);
42973
+ const directory = event?.location?.directory;
42974
+ if (event?.sessionID === sessionId && typeof directory === "string" && isAbsolute9(directory))
42975
+ return directory;
42976
+ } catch {}
42977
+ }
42978
+ function readSessionMoves(host) {
42979
+ if (!host || !tableExists5(host, "session_v2") || !tableExists5(host, "event"))
42980
+ return [];
42981
+ try {
42982
+ return host.prepare(`SELECT s.id, s.directory, c.data AS initial, m.data AS latest
42983
+ FROM session_v2 AS s
42984
+ JOIN event AS c ON c.aggregate_id = s.id AND c.seq = 0 AND c.type = 'session.created.1'
42985
+ JOIN event AS m ON m.aggregate_id = s.id AND m.seq = (
42986
+ SELECT MAX(seq) FROM event WHERE aggregate_id = s.id AND type GLOB 'session.moved.*'
42987
+ ) AND m.type = 'session.moved.1' AND m.seq > c.seq`).all();
42988
+ } catch {
42989
+ return [];
42990
+ }
42991
+ }
42992
+ function formatStrandedDirectoryMemories(db, host, storageDir, splits) {
42993
+ if (!tableExists5(db, "memories") || !tableExists5(db, "session_projects"))
42994
+ return [];
42995
+ const seen = new Set(splits.flatMap(({ identities }) => identities.map(({ identity }) => identity)));
42996
+ const stranded = db.prepare(`SELECT m.project_path AS identity, COUNT(*) AS memories,
42997
+ MAX(MAX(m.last_seen_at, COALESCE(m.last_retrieved_at, 0))) AS lastUse
42998
+ FROM memories AS m WHERE m.project_path GLOB 'dir:*'
42999
+ AND NOT EXISTS (SELECT 1 FROM session_projects AS sp WHERE sp.project_path = m.project_path)
43000
+ GROUP BY m.project_path ORDER BY m.project_path`).all().filter(({ identity }) => !seen.has(identity));
43001
+ if (stranded.length === 0)
43002
+ return [];
43003
+ const keys = new Set(stranded.map(({ identity }) => identity));
43004
+ const binding = db.prepare("SELECT project_path FROM session_projects WHERE session_id = ? AND harness = 'opencode2'");
43005
+ const canonicalKeys = new Map;
43006
+ const sourceFolders = new Map;
43007
+ const destinations = new Map;
43008
+ for (const row of readSessionMoves(host)) {
43009
+ const source = eventDirectory(row.initial, row.id);
43010
+ if (!source)
43011
+ continue;
43012
+ const from = directoryFallback(source);
43013
+ if (!keys.has(from))
43014
+ continue;
43015
+ const latest = eventDirectory(row.latest, row.id);
43016
+ if (source === row.directory)
43017
+ continue;
43018
+ sourceFolders.set(from, source);
43019
+ const current = binding.get(row.id);
43020
+ if (latest === row.directory && current && !canonicalKeys.has(row.directory)) {
43021
+ canonicalKeys.set(row.directory, canonicalIdentity(row.directory, storageDir));
43022
+ }
43023
+ const resolved = canonicalKeys.get(row.directory);
43024
+ const target = latest === row.directory && current?.project_path === resolved ? resolved : undefined;
43025
+ const choices = destinations.get(from) ?? new Set;
43026
+ choices.add(target);
43027
+ destinations.set(from, choices);
43028
+ }
43029
+ return stranded.flatMap(({ identity, memories, lastUse }) => {
43030
+ const time = new Date(lastUse);
43031
+ const when = lastUse > 0 && Number.isFinite(time.getTime()) ? time.toISOString() : "unknown";
43032
+ const choices = destinations.get(identity);
43033
+ const target = choices?.size === 1 ? [...choices][0] : undefined;
43034
+ const from = sourceFolders.get(identity) ?? identity;
43035
+ return [
43036
+ `Memories left under folder key ${identity}: ${memories} ${memories === 1 ? "memory" : "memories"}; last used ${when}. No session is currently recorded for this key.`,
43037
+ target ? " Review a merge into the session's current project:" : " The destination can't be determined. If you choose one, replace DESTINATION_IDENTITY in:",
43038
+ ` ${identityMergeCommand(from, target)}`,
43039
+ ` ${IDENTITY_MERGE_PREVIEW_HINT}`
43040
+ ];
43041
+ });
43042
+ }
42926
43043
  function diagnoseIdentitySplits() {
42927
- const db = openExistingContextDatabase(join27(getMagicContextStorageDir(), "context.db"), {
43044
+ const storageDir = getMagicContextStorageDir();
43045
+ const db = openExistingContextDatabase(join27(storageDir, "context.db"), {
42928
43046
  readonly: true
42929
43047
  });
42930
43048
  if (!db)
@@ -42932,15 +43050,18 @@ function diagnoseIdentitySplits() {
42932
43050
  let host = null;
42933
43051
  try {
42934
43052
  host = openExistingDatabase(resolveOpenCodeDbPath().path, { readonly: true });
42935
- if (!host)
42936
- return ["Identity split check skipped: OpenCode session directories unavailable."];
42937
- return formatIdentitySplits(findIdentitySplits(db, host));
43053
+ const splits = host ? findIdentitySplits(db, host) : [];
43054
+ return [
43055
+ ...host ? formatIdentitySplits(splits) : ["Identity split check skipped: OpenCode session directories unavailable."],
43056
+ ...formatStrandedDirectoryMemories(db, host, storageDir, splits)
43057
+ ];
42938
43058
  } finally {
42939
43059
  host?.close();
42940
43060
  db.close();
42941
43061
  }
42942
43062
  }
42943
43063
  var init_doctor_identity_splits = __esm(async () => {
43064
+ init_project_identity();
42944
43065
  init_project_identity_cache();
42945
43066
  init_data_path();
42946
43067
  init_opencode_db_path();
@@ -42948,7 +43069,6 @@ var init_doctor_identity_splits = __esm(async () => {
42948
43069
  });
42949
43070
 
42950
43071
  // src/commands/doctor-merge-identity.ts
42951
- import { execFileSync as execFileSync7 } from "node:child_process";
42952
43072
  import { createHash as createHash7 } from "node:crypto";
42953
43073
  import { existsSync as existsSync35, mkdtempSync as mkdtempSync2, readdirSync as readdirSync8, readFileSync as readFileSync23, statSync as statSync20 } from "node:fs";
42954
43074
  import { dirname as dirname22, join as join28, resolve as resolve16 } from "node:path";
@@ -43000,39 +43120,6 @@ function printReport(report) {
43000
43120
  if (report.dryRun)
43001
43121
  console.log(" No writes. Review this preview, then repeat with --apply to confirm.");
43002
43122
  }
43003
- function resolveReadOnly(directory) {
43004
- if (!existsSync35(directory))
43005
- return;
43006
- try {
43007
- const roots = execFileSync7("git", ["rev-list", "--max-parents=0", "HEAD"], {
43008
- cwd: directory,
43009
- windowsHide: true,
43010
- encoding: "utf8",
43011
- timeout: 5000,
43012
- stdio: ["ignore", "pipe", "pipe"]
43013
- }).trim().split(/\s+/).filter((root) => /^[0-9a-f]{40,64}$/.test(root)).sort();
43014
- if (roots[0])
43015
- return `git:${roots[0]}`;
43016
- } catch {}
43017
- try {
43018
- const result = execFileSync7("git", ["rev-parse", "--is-inside-work-tree"], {
43019
- cwd: directory,
43020
- windowsHide: true,
43021
- encoding: "utf8",
43022
- timeout: 5000,
43023
- stdio: ["ignore", "pipe", "pipe"]
43024
- });
43025
- if (result.trim() === "true")
43026
- return;
43027
- } catch (error) {
43028
- if (String(error.stderr).includes("not a git repository"))
43029
- return `dir:${createHash7("md5").update(projectDirectoryKey(directory)).digest("hex").slice(0, 12)}`;
43030
- }
43031
- return;
43032
- }
43033
- function canonicalIdentity(directory, storageDir) {
43034
- return readRememberedGitIdentity(directory, storageDir) ?? (orphanedPathReason(directory) ? undefined : resolveReadOnly(directory));
43035
- }
43036
43123
  function directoryDoesNotExist(directory) {
43037
43124
  try {
43038
43125
  statSync20(directory);
@@ -43174,6 +43261,9 @@ function observations(db, hostPath, storageDir) {
43174
43261
  }
43175
43262
  function runMergeIdentityCli(args, deps = {}) {
43176
43263
  const options = parseMergeIdentityArgs(args);
43264
+ if (options.from && !/^(git|dir):/.test(options.from)) {
43265
+ options.from = directoryFallback(options.from);
43266
+ }
43177
43267
  const dbPath = options.dbPath ?? join28(getMagicContextStorageDir(), "context.db");
43178
43268
  const storageDir = dirname22(dbPath);
43179
43269
  const hostPath = options.hostPath ?? (options.dbPath ? join28(storageDir, "host.db") : resolveOpenCodeDbPath().path);
@@ -46216,6 +46306,11 @@ var init_user_facing_codes = __esm(() => {
46216
46306
  sentence: "History compression is paused because this session's saved summaries no longer line up with its messages.",
46217
46307
  action: "Run /ctx-recomp to rebuild them."
46218
46308
  },
46309
+ fork_history_gap: {
46310
+ code: "MC-H09",
46311
+ sentence: "This fork's saved history has a gap.",
46312
+ action: "Run /ctx-recomp to rebuild its history."
46313
+ },
46219
46314
  history_boundary_unresolved: {
46220
46315
  code: "MC-H04",
46221
46316
  sentence: "This request was not sent: it is larger than the model's context window, and Magic Context could not cut the already-summarized history out of it.",
@@ -48768,6 +48863,7 @@ var init_issue_log_templates_generated = __esm(() => {
48768
48863
  "[magic-context] embedding endpoint blocked: embedding endpoint host \x01 (IPv4-mapped \x01) is link-local / cloud metadata (blocked)",
48769
48864
  "[magic-context] sqlite writer site=compaction-marker-inject db=opencode acquire_ms=\x01 hold_ms=\x01 work_ms=\x01 end_ms=\x01 outcome=failed",
48770
48865
  "system prompt hash changed: \x01 → \x01 (len=\x01), adopting on the request whose messages are already final; presetChanged=\x01 elements=[\x01]",
48866
+ "[dreamer] retrospective: watermark start=\x01 maxScannedTs=\x01 patch=\x01 stored=\x01 usableInputTokens=\x01 recencyCutoffMs=\x01 budgetTruncated=\x01 \x01",
48771
48867
  "[magic-context] partial recomp prompt fit session=\x01: chunkTokens=\x01 sessionReferences=\x01 memories=\x01/\x01 seeds=\x01/\x01 requestedChunkTokens=\x01\x020s",
48772
48868
  "[mc-module][\x01] historian oversize admission: range=\x01-\x01 rawChunkTokens=\x01 producerSourceTokens=\x01 historianChunkTokens=\x01 guardReason=\x01",
48773
48869
  "auto-search: decision outcome=\x01 reason=start-failed lanes=\x01 nearMisses=\x01 threshold=\x01 pool=\x01 rows=\x01 workerStarted=\x01 peek=\x01 elapsedMs=\x01",
@@ -48775,6 +48871,7 @@ var init_issue_log_templates_generated = __esm(() => {
48775
48871
  "mc-module: render identity session=\x01 changed=\x01 observed=\x01 coordinator=\x01 transition=\x01 tool_present=\x01 profile=\x01 effective=\x01 persisted=\x01",
48776
48872
  "latest-turn thinking recovery: restore no longer possible (missing-thinking-original); removing the turn's thinking instead",
48777
48873
  "[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",
48874
+ "[dreamer] retrospective: watermark start=\x01 maxScannedTs=\x01 patch=\x01 stored=\x01 usableInputTokens=\x01 recencyCutoffMs=\x01 budgetTruncated=\x01",
48778
48875
  "compartment trigger: force-firing at \x01% (projected post-drop \x01%) admittedBy=overflow_recovery trueRawTokens=\x01 formattedTokens=\x01",
48779
48876
  "rust compaction-marker admission deferred: reason=capture_inputs fit=\x01 estimated=\x01 trusted=\x01 proxy_tokens=\x01 proxy_bytes=\x01 limit=\x01",
48780
48877
  "tag identity recurred after its one repair: serving without a second rebuild (one cache change) session=\x01 identity=\x01 numbers=\x01\x020s",
@@ -49214,6 +49311,7 @@ var init_issue_log_templates_generated = __esm(() => {
49214
49311
  "latest-turn thinking recovery: armed for the provider's latest turn (first=\x01 last=\x01 model=\x01/\x01)\x023m",
49215
49312
  "transform: bumping percentage to 95% due to overflow recovery flag (was \x01%, detectedLimit=\x01)",
49216
49313
  "transform: skipping compartment start, no eligible history before protected tail (beyond \x01)",
49314
+ "[dreamer] retrospective: oversized timestamp cohort sessionIds=\x01 timestamp=\x01 skippedAtLeast=\x01\x020s",
49217
49315
  "[magic-context] WARNING: \x01 configured \x01, but Pi does not know that model; provider suggests \x01\x021m",
49218
49316
  "Pi compaction-marker clear: reason=clone-replaced endMessageId=\x01 ordinal=\x01 firstKeptEntryId=\x01\x020i",
49219
49317
  "v2 refusal: interrupting the turn before the provider request arm=usage-unavailable cause=\x01",
@@ -49258,6 +49356,7 @@ var init_issue_log_templates_generated = __esm(() => {
49258
49356
  "ERROR [tail-hygiene-last-writer-check-failed]: structural production guard failed open: \x01",
49259
49357
  "historian: refreshed stale protected-tail snapshot at run time (was: \x01) — eligible head \x01-\x01",
49260
49358
  "mc-module: historian firing for \x01: await_timeout_ms=\x01 attempt_budget_ms=\x01 firing_budget_ms=\x01\x020s",
49359
+ "This session changed projects. \x01 memories stayed with the old project (\x01); nothing moved. \x01\x021p",
49261
49360
  "v2 context omitted a content part the host would reject: type=<missing> message=\x01 reason=\x01",
49262
49361
  "v2 refusal: interrupting the turn before the provider request arm=compaction-fold cause=\x01",
49263
49362
  "[magic-context] host overflow check: using isContextOverflow from @earendil-works/pi-ai",
@@ -49284,6 +49383,7 @@ var init_issue_log_templates_generated = __esm(() => {
49284
49383
  "compaction-marker drain: retryable failure; preserving deferred history refresh signal \x01",
49285
49384
  "LKG SNAPSHOT PREPARATION FAILED; forcing synchronous capture on the next applied pass: \x01",
49286
49385
  "mc-module: execute_threshold channel=\x01 model=\x01 configured=\x01 provenance=\x01 effective=\x01 source=\x01",
49386
+ "This session changed projects. \x01 memories stayed with the old folder (\x01); nothing moved. \x01\x021p",
49287
49387
  "compaction-marker drain: retryable failure; preserving deferred history refresh signal",
49288
49388
  "event message.removed: cleared compaction marker (boundary or summary message removed)",
49289
49389
  "LKG SNAPSHOT PREPARATION FAILED; forcing synchronous capture on the next applied pass:",
@@ -49304,6 +49404,7 @@ var init_issue_log_templates_generated = __esm(() => {
49304
49404
  "[magic-context] host stall profiler: \x01ms main-thread stall, \x01 samples, top owner none → \x01\x022p",
49305
49405
  "historian publish stage: stage=post-publish-drops status=started elapsed=0.0ms range=\x01-\x01",
49306
49406
  "mc-request-byte-cap refused bytes=\x01 cap=\x01 method=\x01 kind=\x01 session=\x01 page_index=\x01 page_total=\x01",
49407
+ "This session changed projects. \x01 memory stayed with the old project (\x01); nothing moved. \x01\x021p",
49307
49408
  "latest-turn thinking recovery: refused locally (the recovery state could not be read)",
49308
49409
  "rust compaction-marker drain: candidate preparation deferred; pending target retained",
49309
49410
  "served check: record dropped reason=session_cleared; the next request is not compared",
@@ -49320,6 +49421,7 @@ var init_issue_log_templates_generated = __esm(() => {
49320
49421
  "[magic-context] tool-owner backfill failed (continuing with lazy adoption fallback): \x01",
49321
49422
  "historian publish stage: stage=post-publish-drops status=completed elapsed=\x01ms range=\x01-\x01",
49322
49423
  "raw_fallback_over_context_limit estimated=\x01 trusted=\x01 proxy_bytes=\x01 proxy_tokens=\x01 limit=\x01",
49424
+ "This session changed projects. \x01 memory stayed with the old folder (\x01); nothing moved. \x01\x021p",
49323
49425
  "transform refused degraded pass site=host-instruction-retention-persistence-failure: \x01",
49324
49426
  "transform: emergency fail-closed abort failed; refusing to return a sendable prompt: \x01",
49325
49427
  "v2 refusal: interrupting the turn before the provider request arm=storage-busy cause=\x01",
@@ -49366,6 +49468,7 @@ var init_issue_log_templates_generated = __esm(() => {
49366
49468
  'historian no-op: stored compartments still invalid ("invalid range \x01-\x01"); backing off',
49367
49469
  "DEGRADED PASS \x01: LKG unavailable (compaction_off); refusing unreduced \x01-message input",
49368
49470
  "channel2 ceiling nudge delivery skipped: claim no longer owned before send (state=\x01)",
49471
+ "[dreamer] retrospective: oversized timestamp cohort sessionIds=\x01 timestamp=\x01 skipped=\x01\x020s",
49369
49472
  "[magic-context] embedding endpoint blocked: embedding endpoint is not a valid URL: \x01",
49370
49473
  "[session-projects] failed to make backfill lease retryable after discovery failed: \x01",
49371
49474
  "compaction-marker: removal failed during session cleanup, cleared persisted state: \x01",
@@ -49954,6 +50057,7 @@ var init_issue_log_templates_generated = __esm(() => {
49954
50057
  "[mc-module][\x01] historian oversize admission refused before spawn: \x01",
49955
50058
  "compaction-marker drain: applied at ordinal \x01, boundary user msg \x01 \x01\x021i",
49956
50059
  "mc_rust_emergency_refusal frozen_over_proven_limit module=\x01 limit=\x01",
50060
+ "project binding changed harness=\x01 cwd=\x01 old=\x01 new=\x01 memories=\x01 notice=\x01\x021p",
49957
50061
  "recovery projection: case=conversation_only released=\x01 normalized=\x01",
49958
50062
  "rust input coverage: oc_input=\x01 marker_at=\x01 covered=\x01 first_ordinal=\x01",
49959
50063
  "rust parked health probe failed; refusing without a full request \x01",
@@ -50027,6 +50131,7 @@ var init_issue_log_templates_generated = __esm(() => {
50027
50131
  "mc-module: lineage descent pending build-skew for target \x01 edge \x01",
50028
50132
  "native reasoning activation failed; retaining previous replay: \x01",
50029
50133
  "placeholder strip: removed=\x01 discovered=\x01 pruned=\x01 keptToolOwners=\x01",
50134
+ "project binding write failed harness=opencode cwd=\x01 attempted=\x01: \x01\x021p",
50030
50135
  "project binding write failed harness=opencode cwd=\x01 attempted=\x01: \x01",
50031
50136
  "project binding write recovered harness=opencode cwd=\x01 identity=\x01",
50032
50137
  "Subagent temperature omitted for \x01: host model metadata says no \x01\x020m",
@@ -50045,6 +50150,7 @@ var init_issue_log_templates_generated = __esm(() => {
50045
50150
  "transform: cannot force-start compartment agent without client",
50046
50151
  "transform: injected memories/facts block (no compartments yet)",
50047
50152
  "v2 compaction hook: fired answered=true source=module row=none",
50153
+ "v2 fork saved history has a gap; /ctx-recomp repairs this fork",
50048
50154
  'invalid cache_ttl "\x01" in ctx-status; falling back to default 5m',
50049
50155
  "v2 boundary trim: dropped \x01 messages before the module boundary",
50050
50156
  "Subagent temperature sent for \x01: no host or models.dev metadata\x020m",
@@ -50243,6 +50349,7 @@ var init_issue_log_templates_generated = __esm(() => {
50243
50349
  "models-dev-cache: output reserve capped at 25% for \x01/\x01: \x01 → \x01\x020m,1m",
50244
50350
  "native tag replay unavailable; retaining native history: \x01",
50245
50351
  "post-transform snapshot failed; using independent reads: \x01",
50352
+ "project binding changed harness=\x01 cwd=\x01 old=\x01 new=\x01 memories=\x01\x021p",
50246
50353
  "system prompt date refresh failed (keeping frozen date): \x01",
50247
50354
  "system prompt token estimate failed (using prior count): \x01",
50248
50355
  "transform tag persistence failed; not serving this pass: \x01",
@@ -50316,7 +50423,6 @@ var init_issue_log_templates_generated = __esm(() => {
50316
50423
  "event message.removed: pruned auto-search decision for \x01\x020i",
50317
50424
  "event session.compacted pending-marker cleanup failed: \x01",
50318
50425
  "mc-module: native reasoning replay proof not recorded: \x01",
50319
- "project binding changed harness=opencode cwd=\x01 old=\x01 new=\x01\x021p,2p",
50320
50426
  "reasoning cleanup: cleared=\x01 inlineStripped=\x01 watermark=\x01→\x01",
50321
50427
  "WARN: message_end: synthetic todowrite capture failed: \x01",
50322
50428
  "[dreamer] retrospective: no reply-following user lines",
@@ -51136,6 +51242,7 @@ var init_issue_log_templates_generated = __esm(() => {
51136
51242
  "lkg_frozen_replay_released reason=\x01",
51137
51243
  "reasoning replay: cleared=\x01 inline=\x01",
51138
51244
  "subagent token accounting failed: \x01",
51245
+ "v2 fork skipped compartment \x01 (\x01-\x01): \x01",
51139
51246
  "v2 model-limit cache warm failed: \x01",
51140
51247
  "wrapup no-op: boundaryDiagnostics=\x01",
51141
51248
  "current-compaction-id-unavailable",
@@ -51369,6 +51476,7 @@ var init_issue_log_templates_generated = __esm(() => {
51369
51476
  "pp.setupAndOperations",
51370
51477
  "pp.todoPermissionRead",
51371
51478
  "preemptive-compaction",
51479
+ "projectBindingWarning",
51372
51480
  "refusal notice failed",
51373
51481
  "served check skipped:",
51374
51482
  "stableIdSchemePersist",
@@ -52769,10 +52877,10 @@ var init_omp_hide_secrets = __esm(() => {
52769
52877
  });
52770
52878
 
52771
52879
  // src/commands/doctor-omp.ts
52772
- import { execFileSync as execFileSync8, spawnSync as spawnSync8 } from "node:child_process";
52880
+ import { execFileSync as execFileSync7, spawnSync as spawnSync8 } from "node:child_process";
52773
52881
  import { existsSync as existsSync42, readFileSync as readFileSync27 } from "node:fs";
52774
52882
  import { createRequire as createRequire3 } from "node:module";
52775
- import { isAbsolute as isAbsolute9, join as join35, resolve as resolve19 } from "node:path";
52883
+ import { isAbsolute as isAbsolute10, join as join35, resolve as resolve19 } from "node:path";
52776
52884
  function parseSemver(value) {
52777
52885
  const match = value?.match(/(\d+)\.(\d+)\.(\d+)/);
52778
52886
  return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
@@ -53116,7 +53224,7 @@ function runGhCommandWithDeps(deps, args) {
53116
53224
  async function runIssueFlow(options) {
53117
53225
  if (options.reportPath) {
53118
53226
  const report = await runHealthChecks({ ...options, quiet: true });
53119
- const path = isAbsolute9(options.reportPath) ? options.reportPath : join35(options.cwd, options.reportPath);
53227
+ const path = isAbsolute10(options.reportPath) ? options.reportPath : join35(options.cwd, options.reportPath);
53120
53228
  const bundle = writeOmpIssueReport(path, ompIssueBody("Generated non-interactively by `doctor --issue --report`.", report, readLogLines(report.logFiles), null, options.cwd));
53121
53229
  options.prompts.log.success(bundle.fullPath ? `Sanitized report written to ${bundle.path}; full report at ${bundle.fullPath}` : `Sanitized report written to ${bundle.path}`);
53122
53230
  return 0;
@@ -53219,7 +53327,7 @@ var init_doctor_omp = __esm(async () => {
53219
53327
  openExistingContextDatabase,
53220
53328
  now: () => new Date,
53221
53329
  inspectMagicContextLogs,
53222
- execFileSync: execFileSync8,
53330
+ execFileSync: execFileSync7,
53223
53331
  spawnSync: spawnSync8
53224
53332
  };
53225
53333
  });
@@ -58541,11 +58649,11 @@ var init_logs_pi = __esm(() => {
58541
58649
  });
58542
58650
 
58543
58651
  // src/commands/doctor-pi.ts
58544
- import { execFileSync as execFileSync9, spawnSync as spawnSync11 } from "node:child_process";
58652
+ import { execFileSync as execFileSync8, spawnSync as spawnSync11 } from "node:child_process";
58545
58653
  import { existsSync as existsSync50, lstatSync as lstatSync6, readdirSync as readdirSync12, readFileSync as readFileSync34, rmSync as rmSync10 } from "node:fs";
58546
58654
  import { createRequire as createRequire8 } from "node:module";
58547
58655
  import { homedir as homedir22 } from "node:os";
58548
- import { basename as basename7, isAbsolute as isAbsolute10, join as join44 } from "node:path";
58656
+ import { basename as basename7, isAbsolute as isAbsolute11, join as join44 } from "node:path";
58549
58657
  function depsFrom(options) {
58550
58658
  return {
58551
58659
  ...DEFAULT_DEPS5,
@@ -58583,7 +58691,7 @@ function selfVersion2() {
58583
58691
  }
58584
58692
  function getLatestNpmVersion(packageName) {
58585
58693
  try {
58586
- return execFileSync9("npm", ["view", packageName, "version"], {
58694
+ return execFileSync8("npm", ["view", packageName, "version"], {
58587
58695
  windowsHide: true,
58588
58696
  encoding: "utf-8",
58589
58697
  stdio: ["ignore", "pipe", "ignore"],
@@ -59382,7 +59490,7 @@ async function runIssueFlow3(options) {
59382
59490
  if (options.reportPath) {
59383
59491
  try {
59384
59492
  const report = await options.deps.collectDiagnostics(options.cwd);
59385
- const outputPath = isAbsolute10(options.reportPath) ? options.reportPath : join44(options.cwd, options.reportPath);
59493
+ const outputPath = isAbsolute11(options.reportPath) ? options.reportPath : join44(options.cwd, options.reportPath);
59386
59494
  const bundled = await bundleIssueReport2(report, "Generated non-interactively by `doctor --issue --report`.", "Magic Context diagnostic report", { cwd: options.cwd, now: options.deps.now(), outputPath });
59387
59495
  options.prompts.log.info(`Report written to ${bundled.path}`);
59388
59496
  return 0;
@@ -59587,7 +59695,7 @@ var init_doctor_pi = __esm(async () => {
59587
59695
  probeCacheUse: probeHostProcessesUsing,
59588
59696
  readProcessCommand,
59589
59697
  now: () => new Date,
59590
- execFileSync: execFileSync9,
59698
+ execFileSync: execFileSync8,
59591
59699
  spawnSync: spawnSync11
59592
59700
  };
59593
59701
  });
@@ -59885,12 +59993,12 @@ var SINGLE_STORE_HELP = [
59885
59993
  `);
59886
59994
  var MERGE_IDENTITY_HELP = [
59887
59995
  "",
59888
- " Usage: magic-context doctor merge-identities [--from <identity> --to <identity>] [--apply] [--force] [--verbose] [--db <path>] [--backup-root <dir>]",
59996
+ " Usage: magic-context doctor merge-identities [--from <identity-or-folder> --to <identity>] [--apply] [--force] [--verbose] [--db <path>] [--backup-root <dir>]",
59889
59997
  "",
59890
59998
  " Merge every project-scoped row from one project identity into another.",
59891
59999
  "",
59892
60000
  " Options:",
59893
- " --from <identity> Identity whose rows are moved",
60001
+ " --from <identity-or-folder> Source key, or a folder path naming its old dir: key",
59894
60002
  " --to <identity> Identity that receives them",
59895
60003
  " (no flags) List splits; --from/--to previews without writing",
59896
60004
  " --apply Confirm the reviewed preview; hosts must be closed",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/magic-context",
3
- "version": "0.49.81",
3
+ "version": "0.49.83",
4
4
  "description": "Unified CLI for Magic Context — setup, doctor, and migration across OpenCode, Pi, and OMP",
5
5
  "keywords": [
6
6
  "opencode",