@cortexkit/magic-context 0.49.26 → 0.49.27

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 +167 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -25303,18 +25303,95 @@ var init_opencode_plugin_cache = __esm(() => {
25303
25303
 
25304
25304
  // src/commands/doctor-windows-holders.ts
25305
25305
  import { existsSync as existsSync14 } from "node:fs";
25306
+ function fileName(path) {
25307
+ return path.toLowerCase().replaceAll("\\", "/").split("/").at(-1) ?? "";
25308
+ }
25309
+ function commandTokens2(command) {
25310
+ const tokens = [];
25311
+ let token = "";
25312
+ let quoted = false;
25313
+ let started = false;
25314
+ for (let index = 0;index < command.length; index += 1) {
25315
+ const char = command[index];
25316
+ if (char === "\\") {
25317
+ started = true;
25318
+ let end = index;
25319
+ while (command[end] === "\\")
25320
+ end += 1;
25321
+ const count = end - index;
25322
+ if (command[end] === '"') {
25323
+ token += "\\".repeat(Math.floor(count / 2));
25324
+ if (count % 2)
25325
+ token += '"';
25326
+ else
25327
+ quoted = !quoted;
25328
+ index = end;
25329
+ } else {
25330
+ token += "\\".repeat(count);
25331
+ index = end - 1;
25332
+ }
25333
+ } else if (char === '"') {
25334
+ started = true;
25335
+ quoted = !quoted;
25336
+ } else if (/\s/.test(char) && !quoted) {
25337
+ if (started)
25338
+ tokens.push(token);
25339
+ token = "";
25340
+ started = false;
25341
+ } else {
25342
+ started = true;
25343
+ token += char;
25344
+ }
25345
+ }
25346
+ if (started)
25347
+ tokens.push(token);
25348
+ return tokens;
25349
+ }
25350
+ function runtimeScript(runtime, tokens) {
25351
+ let allowRun = runtime !== "node";
25352
+ for (let index = 1;index < tokens.length; index += 1) {
25353
+ const token = tokens[index];
25354
+ if (token === "--")
25355
+ return tokens[index + 1];
25356
+ if (/^(?:--eval|--print)(?:=|$)|^-[ep]/.test(token))
25357
+ return;
25358
+ if (token.startsWith("-")) {
25359
+ if (runtimeValueOptions[runtime].has(token))
25360
+ index += 1;
25361
+ continue;
25362
+ }
25363
+ if (allowRun && token === "run") {
25364
+ allowRun = false;
25365
+ continue;
25366
+ }
25367
+ return token;
25368
+ }
25369
+ return;
25370
+ }
25371
+ function isHostScript(script) {
25372
+ const path = script.toLowerCase().replaceAll("\\", "/");
25373
+ return /^(?:ck-mc|opencode2?)(?:\.exe|\.js|\.mjs)?$/.test(fileName(path)) || piHarnessKindFromExecutable(path.replace(/\.(?:js|mjs|cjs)$/, "")) !== undefined || /(?:^|\/)(?:pi-coding-agent|@?oh-my-pi)(?:\/|$)/.test(path) || /(?:^|\/)(?:cljs\/dist|dist\/bundle\/cli)(?:[/.]|$)/.test(path);
25374
+ }
25375
+ function isHostProcess(imageName, commandLine) {
25376
+ const tokens = commandTokens2(commandLine ?? "");
25377
+ const image = fileName(imageName ?? tokens[0] ?? "");
25378
+ if (/^(?:opencode|opencode2|ck-mc)(?:\.exe)?$/.test(image) || piHarnessKindFromExecutable(image) !== undefined) {
25379
+ return true;
25380
+ }
25381
+ if (!runtimes.test(image))
25382
+ return false;
25383
+ const script = runtimeScript(image.replace(/\.exe$/, ""), tokens);
25384
+ return script !== undefined && isHostScript(script);
25385
+ }
25306
25386
  function assertWindowsStoresClosed(paths, processes) {
25307
- if (processes.pi.state !== "known" || processes.pi.processIds.length > 0 || (processes.pi.inconclusivePids?.length ?? 0) > 0 || processes.processSnapshot?.source !== "cim") {
25308
- throw new Error(`Windows process probe could not rule out OpenCode, Pi or ck-mc holders${processes.pi.processIds.length || processes.pi.inconclusivePids?.length ? ` (PID ${[...processes.pi.processIds, ...processes.pi.inconclusivePids ?? []].join(", ")})` : ""}`);
25387
+ if (processes.processSnapshot?.source !== "cim") {
25388
+ throw new Error("Windows process probe could not rule out OpenCode, Pi or ck-mc holders");
25309
25389
  }
25310
25390
  const facts = processes.processSnapshot.facts.filter(({ pid }) => pid !== process.pid);
25311
- const unknown = facts.filter(({ imageName, commandLine }) => !imageName && !commandLine || /^(?:bun|node|deno)(?:\.exe)?$/i.test(imageName ?? "") && !commandLine);
25391
+ const unknown = facts.filter(({ imageName, commandLine }) => !imageName && !commandLine || runtimes.test(fileName(imageName ?? "")) && !commandLine?.trim());
25312
25392
  if (unknown.length)
25313
25393
  throw new Error(`Windows process identity is unavailable (PID ${unknown.map(({ pid }) => pid).join(", ")})`);
25314
- const blockers = facts.filter(({ imageName, commandLine }) => {
25315
- const image = (imageName ?? "").toLowerCase().replaceAll("\\", "/").split("/").at(-1) ?? "";
25316
- return /^(?:opencode|opencode2|pi|omp|ck-mc)(?:\.exe)?$/.test(image) || /(?:^|[\\/\s"'])(?:ck-mc|opencode2?)(?:\.exe|\.js|\.mjs)?(?:$|[\s"'])/i.test(commandLine ?? "");
25317
- });
25394
+ const blockers = facts.filter(({ imageName, commandLine }) => isHostProcess(imageName, commandLine));
25318
25395
  if (blockers.length)
25319
25396
  throw new Error(`OpenCode, Pi or ck-mc process is running (${blockers.map(({ pid, imageName, commandLine }) => `${imageName ?? commandLine} PID ${pid}`).join(", ")})`);
25320
25397
  for (const path of [...new Set(paths)]) {
@@ -25336,8 +25413,91 @@ function assertWindowsStoresClosed(paths, processes) {
25336
25413
  }
25337
25414
  }
25338
25415
  }
25416
+ var runtimes, runtimeValueOptions;
25339
25417
  var init_doctor_windows_holders = __esm(async () => {
25418
+ init_pi_executable();
25340
25419
  await init_sqlite();
25420
+ runtimes = /^(?:bun|node|deno)(?:\.exe)?$/;
25421
+ runtimeValueOptions = {
25422
+ node: new Set([
25423
+ "-r",
25424
+ "--require",
25425
+ "--import",
25426
+ "--loader",
25427
+ "--experimental-loader",
25428
+ "-C",
25429
+ "--conditions",
25430
+ "--title",
25431
+ "--env-file",
25432
+ "--env-file-if-exists",
25433
+ "--icu-data-dir",
25434
+ "--openssl-config",
25435
+ "--redirect-warnings",
25436
+ "--diagnostic-dir",
25437
+ "--snapshot-blob",
25438
+ "--inspect-port",
25439
+ "--experimental-config-file",
25440
+ "--experimental-policy",
25441
+ "--experimental-sea-config",
25442
+ "--input-type",
25443
+ "--run",
25444
+ "--cpu-prof-dir",
25445
+ "--cpu-prof-name",
25446
+ "--heap-prof-dir",
25447
+ "--heap-prof-name",
25448
+ "--report-dir",
25449
+ "--report-directory",
25450
+ "--report-filename",
25451
+ "--heapsnapshot-signal",
25452
+ "--trace-event-categories",
25453
+ "--trace-event-file-pattern",
25454
+ "--watch-path",
25455
+ "--watch-kill-signal",
25456
+ "--test-name-pattern",
25457
+ "--test-skip-pattern",
25458
+ "--test-reporter",
25459
+ "--test-reporter-destination",
25460
+ "--test-global-setup"
25461
+ ]),
25462
+ bun: new Set([
25463
+ "-r",
25464
+ "--require",
25465
+ "--preload",
25466
+ "--cwd",
25467
+ "--env-file",
25468
+ "-c",
25469
+ "--config",
25470
+ "--tsconfig-override",
25471
+ "--define",
25472
+ "--loader",
25473
+ "--origin",
25474
+ "--port",
25475
+ "--conditions",
25476
+ "--external",
25477
+ "--use",
25478
+ "-F",
25479
+ "--filter",
25480
+ "--shell",
25481
+ "--main-fields",
25482
+ "--extension-order",
25483
+ "--jsx-factory",
25484
+ "--jsx-fragment",
25485
+ "--jsx-import-source"
25486
+ ]),
25487
+ deno: new Set([
25488
+ "-c",
25489
+ "--config",
25490
+ "--import-map",
25491
+ "--cert",
25492
+ "--location",
25493
+ "--lock",
25494
+ "--seed",
25495
+ "--v8-flags",
25496
+ "--preload",
25497
+ "--watch-exclude",
25498
+ "--strace-ops"
25499
+ ])
25500
+ };
25341
25501
  });
25342
25502
 
25343
25503
  // src/commands/doctor-opencode2-cache.ts
@@ -28061,8 +28221,6 @@ function runSessionWarmupWorker(input, options) {
28061
28221
  finish({ delta: reply.delta });
28062
28222
  else if (reply.kind === "indexed")
28063
28223
  finish({ inserted: reply.inserted, measurements: reply.measurements });
28064
- else if (reply.kind === "orphan-sweep")
28065
- finish({ orphanSweep: reply.result });
28066
28224
  else if (reply.kind === "exact-ordinal-ids")
28067
28225
  finish({ exactOrdinalIds: reply.ids });
28068
28226
  else if (reply.kind === "search-archive")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/magic-context",
3
- "version": "0.49.26",
3
+ "version": "0.49.27",
4
4
  "description": "Unified CLI for Magic Context — setup, doctor, and migration across OpenCode, Pi, and OMP",
5
5
  "keywords": [
6
6
  "opencode",