@cortexkit/magic-context 0.27.0 → 0.27.1

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 +53 -45
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7806,8 +7806,10 @@ var require_src2 = __commonJS((exports, module) => {
7806
7806
  });
7807
7807
 
7808
7808
  // src/lib/atomic-write.ts
7809
- import { chmodSync, renameSync, statSync, writeFileSync } from "node:fs";
7809
+ import { chmodSync, mkdirSync, renameSync, statSync, writeFileSync } from "node:fs";
7810
+ import { dirname } from "node:path";
7810
7811
  function writeFileAtomic(targetPath, data) {
7812
+ mkdirSync(dirname(targetPath), { recursive: true });
7811
7813
  const tmpPath = `${targetPath}.tmp`;
7812
7814
  writeFileSync(tmpPath, data, { encoding: "utf-8" });
7813
7815
  try {
@@ -7881,7 +7883,7 @@ var init_opencode_install = __esm(() => {
7881
7883
  import {
7882
7884
  closeSync,
7883
7885
  existsSync as existsSync3,
7884
- mkdirSync,
7886
+ mkdirSync as mkdirSync2,
7885
7887
  openSync,
7886
7888
  readFileSync,
7887
7889
  renameSync as renameSync2,
@@ -7891,7 +7893,7 @@ import {
7891
7893
  writeFileSync as writeFileSync2
7892
7894
  } from "node:fs";
7893
7895
  import { homedir as homedir2 } from "node:os";
7894
- import { basename, dirname, isAbsolute, join as join3 } from "node:path";
7896
+ import { basename, dirname as dirname2, isAbsolute, join as join3 } from "node:path";
7895
7897
  function homeDir() {
7896
7898
  if (process.platform === "win32") {
7897
7899
  return process.env.USERPROFILE || process.env.HOME || homedir2();
@@ -8046,7 +8048,7 @@ function fileSemanticsMatch(a, b) {
8046
8048
  function acquireConfigMigrationLock(lockDir) {
8047
8049
  for (let attempt = 0;attempt < 2; attempt++) {
8048
8050
  try {
8049
- mkdirSync(lockDir, { recursive: false });
8051
+ mkdirSync2(lockDir, { recursive: false });
8050
8052
  return () => {
8051
8053
  try {
8052
8054
  rmSync(lockDir, { recursive: true, force: true });
@@ -8071,8 +8073,8 @@ function acquireConfigMigrationLock(lockDir) {
8071
8073
  return null;
8072
8074
  }
8073
8075
  function atomicCopyConfigFile(sourcePath, targetPath) {
8074
- mkdirSync(dirname(targetPath), { recursive: true });
8075
- const tmpPath = join3(dirname(targetPath), `.${basename(targetPath)}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`);
8076
+ mkdirSync2(dirname2(targetPath), { recursive: true });
8077
+ const tmpPath = join3(dirname2(targetPath), `.${basename(targetPath)}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`);
8076
8078
  let fd = null;
8077
8079
  try {
8078
8080
  fd = openSync(tmpPath, "wx", 384);
@@ -8093,8 +8095,8 @@ function atomicCopyConfigFile(sourcePath, targetPath) {
8093
8095
  }
8094
8096
  }
8095
8097
  function atomicWriteConfigFile(targetPath, content) {
8096
- mkdirSync(dirname(targetPath), { recursive: true });
8097
- const tmpPath = join3(dirname(targetPath), `.${basename(targetPath)}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`);
8098
+ mkdirSync2(dirname2(targetPath), { recursive: true });
8099
+ const tmpPath = join3(dirname2(targetPath), `.${basename(targetPath)}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`);
8098
8100
  let fd = null;
8099
8101
  try {
8100
8102
  fd = openSync(tmpPath, "wx", 384);
@@ -8166,7 +8168,7 @@ function migrateConfigFile(opts) {
8166
8168
  if (existingSources.length === 0) {
8167
8169
  return { migrated: false, conflict: false, targetPath: opts.targetPath, warnings };
8168
8170
  }
8169
- mkdirSync(dirname(opts.targetPath), { recursive: true });
8171
+ mkdirSync2(dirname2(opts.targetPath), { recursive: true });
8170
8172
  const release = acquireConfigMigrationLock(`${opts.targetPath}.lock`);
8171
8173
  if (!release) {
8172
8174
  warnings.push(`Config migration for ${opts.scope} skipped this run (another instance is migrating); will retry on next start.`);
@@ -8415,7 +8417,7 @@ var init_paths = __esm(() => {
8415
8417
 
8416
8418
  // src/adapters/opencode.ts
8417
8419
  import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
8418
- import { dirname as dirname2 } from "node:path";
8420
+ import { dirname as dirname3 } from "node:path";
8419
8421
 
8420
8422
  class OpenCodeAdapter {
8421
8423
  kind = "opencode";
@@ -8641,10 +8643,10 @@ function matchesPluginEntry(entry, pkgName) {
8641
8643
  return head === pkgName;
8642
8644
  }
8643
8645
  function ensureDir(filePath) {
8644
- const dir = dirname2(filePath);
8646
+ const dir = dirname3(filePath);
8645
8647
  if (!existsSync5(dir)) {
8646
- const { mkdirSync: mkdirSync2 } = __require("node:fs");
8647
- mkdirSync2(dir, { recursive: true });
8648
+ const { mkdirSync: mkdirSync3 } = __require("node:fs");
8649
+ mkdirSync3(dir, { recursive: true });
8648
8650
  }
8649
8651
  }
8650
8652
  var import_comment_json, PLUGIN_NAME = "@cortexkit/opencode-magic-context", PLUGIN_ENTRY;
@@ -8746,7 +8748,7 @@ var init_pi_helpers = __esm(() => {
8746
8748
  // src/adapters/pi.ts
8747
8749
  import { execFileSync as execFileSync2 } from "node:child_process";
8748
8750
  import { existsSync as existsSync7, readFileSync as readFileSync3 } from "node:fs";
8749
- import { dirname as dirname3 } from "node:path";
8751
+ import { dirname as dirname4 } from "node:path";
8750
8752
 
8751
8753
  class PiAdapter {
8752
8754
  kind = "pi";
@@ -8903,10 +8905,10 @@ function matchesPiPackage(entry) {
8903
8905
  return false;
8904
8906
  }
8905
8907
  function ensureDir2(filePath) {
8906
- const dir = dirname3(filePath);
8908
+ const dir = dirname4(filePath);
8907
8909
  if (!existsSync7(dir)) {
8908
- const { mkdirSync: mkdirSync2 } = __require("node:fs");
8909
- mkdirSync2(dir, { recursive: true });
8910
+ const { mkdirSync: mkdirSync3 } = __require("node:fs");
8911
+ mkdirSync3(dir, { recursive: true });
8910
8912
  }
8911
8913
  }
8912
8914
  var import_comment_json2, PLUGIN_NAME2 = "@cortexkit/pi-magic-context";
@@ -11484,11 +11486,11 @@ var init_opencode_helpers = __esm(() => {
11484
11486
  });
11485
11487
 
11486
11488
  // src/commands/setup-opencode.ts
11487
- import { existsSync as existsSync10, mkdirSync as mkdirSync2, readFileSync as readFileSync6 } from "node:fs";
11488
- import { dirname as dirname4 } from "node:path";
11489
+ import { existsSync as existsSync10, mkdirSync as mkdirSync3, readFileSync as readFileSync6 } from "node:fs";
11490
+ import { dirname as dirname5 } from "node:path";
11489
11491
  function ensureDir3(dir) {
11490
11492
  if (!existsSync10(dir)) {
11491
- mkdirSync2(dir, { recursive: true });
11493
+ mkdirSync3(dir, { recursive: true });
11492
11494
  }
11493
11495
  }
11494
11496
  function readJsonc(path2) {
@@ -11501,7 +11503,7 @@ function readJsonc(path2) {
11501
11503
  }
11502
11504
  }
11503
11505
  function addPluginToOpenCodeConfig(configPath, format) {
11504
- ensureDir3(dirname4(configPath));
11506
+ ensureDir3(dirname5(configPath));
11505
11507
  if (format === "none") {
11506
11508
  const config = {
11507
11509
  plugin: [PLUGIN_ENTRY2],
@@ -11531,7 +11533,7 @@ function addPluginToOpenCodeConfig(configPath, format) {
11531
11533
  `);
11532
11534
  }
11533
11535
  function addPluginToTuiConfig(configPath, format) {
11534
- ensureDir3(dirname4(configPath));
11536
+ ensureDir3(dirname5(configPath));
11535
11537
  if (format === "none") {
11536
11538
  writeFileAtomic(configPath, `${import_comment_json4.stringify({ plugin: [PLUGIN_ENTRY2] }, null, 2)}
11537
11539
  `);
@@ -11872,11 +11874,11 @@ var init_pi_package_entry = __esm(() => {
11872
11874
  });
11873
11875
 
11874
11876
  // src/commands/setup-pi.ts
11875
- import { existsSync as existsSync11, mkdirSync as mkdirSync3, readFileSync as readFileSync7 } from "node:fs";
11876
- import { dirname as dirname5 } from "node:path";
11877
+ import { existsSync as existsSync11, mkdirSync as mkdirSync4, readFileSync as readFileSync7 } from "node:fs";
11878
+ import { dirname as dirname6 } from "node:path";
11877
11879
  function ensureDir4(path2) {
11878
11880
  if (!existsSync11(path2))
11879
- mkdirSync3(path2, { recursive: true });
11881
+ mkdirSync4(path2, { recursive: true });
11880
11882
  }
11881
11883
  async function getDefaultPrompts() {
11882
11884
  const { promptIO: promptIO2 } = await Promise.resolve().then(() => (init_prompts(), exports_prompts));
@@ -11916,7 +11918,7 @@ function comparePiVersion(a, b2) {
11916
11918
  return 0;
11917
11919
  }
11918
11920
  function writePiSettingsPackage(settingsPath, packageSource = PI_PACKAGE_SOURCE) {
11919
- ensureDir4(dirname5(settingsPath));
11921
+ ensureDir4(dirname6(settingsPath));
11920
11922
  const settings = existsSync11(settingsPath) ? readJsonc2(settingsPath) ?? {} : {};
11921
11923
  const packages = Array.isArray(settings.packages) ? settings.packages : [];
11922
11924
  const hasPackage = hasPiMagicContextPackage(packages);
@@ -11928,7 +11930,7 @@ function writePiSettingsPackage(settingsPath, packageSource = PI_PACKAGE_SOURCE)
11928
11930
  return !hasPackage;
11929
11931
  }
11930
11932
  function writeMagicContextConfig2(configPath, options) {
11931
- ensureDir4(dirname5(configPath));
11933
+ ensureDir4(dirname6(configPath));
11932
11934
  const config = existsSync11(configPath) ? readJsonc2(configPath) ?? {} : {};
11933
11935
  if (!config.$schema) {
11934
11936
  config.$schema = "https://raw.githubusercontent.com/cortexkit/magic-context/master/assets/magic-context.schema.json";
@@ -12262,7 +12264,7 @@ __export(exports_migrate, {
12262
12264
  formatPiFilenameTimestamp: () => formatPiFilenameTimestamp
12263
12265
  });
12264
12266
  import { randomBytes } from "node:crypto";
12265
- import { existsSync as existsSync12, mkdirSync as mkdirSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync4 } from "node:fs";
12267
+ import { existsSync as existsSync12, mkdirSync as mkdirSync5, unlinkSync as unlinkSync2, writeFileSync as writeFileSync4 } from "node:fs";
12266
12268
  import { homedir as homedir7 } from "node:os";
12267
12269
  import { join as join10 } from "node:path";
12268
12270
  function defaultOpenCodeDbPath() {
@@ -12275,7 +12277,7 @@ function defaultPiSessionsRoot() {
12275
12277
  return join10(homedir7(), ".pi", "agent", "sessions");
12276
12278
  }
12277
12279
  function defaultFs() {
12278
- return { existsSync: existsSync12, mkdirSync: mkdirSync4, writeFileSync: writeFileSync4, unlinkSync: unlinkSync2 };
12280
+ return { existsSync: existsSync12, mkdirSync: mkdirSync5, writeFileSync: writeFileSync4, unlinkSync: unlinkSync2 };
12279
12281
  }
12280
12282
  function stmt(db, sql) {
12281
12283
  return db.prepare(sql);
@@ -146500,10 +146502,10 @@ var init_tool_owner_backfill = __esm(() => {
146500
146502
  });
146501
146503
 
146502
146504
  // ../plugin/src/features/magic-context/storage-db.ts
146503
- import { chmodSync as chmodSync2, copyFileSync as copyFileSync2, cpSync, existsSync as existsSync15, mkdirSync as mkdirSync6, mkdtempSync } from "node:fs";
146504
- import { dirname as dirname7, join as join13 } from "node:path";
146505
+ import { chmodSync as chmodSync2, copyFileSync as copyFileSync2, cpSync, existsSync as existsSync15, mkdirSync as mkdirSync7, mkdtempSync } from "node:fs";
146506
+ import { dirname as dirname8, join as join13 } from "node:path";
146505
146507
  function ensureSecureStorageDir(dir) {
146506
- mkdirSync6(dir, { recursive: true, mode: 448 });
146508
+ mkdirSync7(dir, { recursive: true, mode: 448 });
146507
146509
  if (!PERMISSIONS_ENFORCEABLE)
146508
146510
  return;
146509
146511
  try {
@@ -146528,7 +146530,7 @@ function restrictDatabaseFilePermissions(dbPath) {
146528
146530
  }
146529
146531
  function resolveDatabasePath(dbPathOverride) {
146530
146532
  if (dbPathOverride) {
146531
- return { dbDir: dirname7(dbPathOverride), dbPath: dbPathOverride };
146533
+ return { dbDir: dirname8(dbPathOverride), dbPath: dbPathOverride };
146532
146534
  }
146533
146535
  const testDataDir = process.env.MAGIC_CONTEXT_TEST_DATA_DIR;
146534
146536
  if (testDataDir && !process.env.XDG_DATA_HOME) {
@@ -164931,7 +164933,7 @@ var init_magic_context = __esm(() => {
164931
164933
  // ../plugin/src/config/variable.ts
164932
164934
  import { existsSync as existsSync16, readFileSync as readFileSync8 } from "node:fs";
164933
164935
  import { homedir as homedir9 } from "node:os";
164934
- import { dirname as dirname8, isAbsolute as isAbsolute2, resolve as resolve2 } from "node:path";
164936
+ import { dirname as dirname9, isAbsolute as isAbsolute2, resolve as resolve2 } from "node:path";
164935
164937
  function sensitiveFilePathReason(resolvedPath) {
164936
164938
  const home = homedir9();
164937
164939
  const sensitiveDirs = [
@@ -164978,7 +164980,7 @@ function substituteConfigVariables(input) {
164978
164980
  if (fileMatches.length === 0) {
164979
164981
  return { text: text2, warnings };
164980
164982
  }
164981
- const configDir = input.configPath ? dirname8(input.configPath) : process.cwd();
164983
+ const configDir = input.configPath ? dirname9(input.configPath) : process.cwd();
164982
164984
  let output = "";
164983
164985
  let cursor = 0;
164984
164986
  for (const match of fileMatches) {
@@ -165442,13 +165444,13 @@ var DEFAULT_TIMEOUT_MS = 1e4, MAX_PREVIEW_CHARS = 240;
165442
165444
  import {
165443
165445
  chmodSync as chmodSync3,
165444
165446
  existsSync as existsSync18,
165445
- mkdirSync as mkdirSync7,
165447
+ mkdirSync as mkdirSync8,
165446
165448
  readFileSync as readFileSync10,
165447
165449
  renameSync as renameSync3,
165448
165450
  statSync as statSync6,
165449
165451
  writeFileSync as writeFileSync5
165450
165452
  } from "node:fs";
165451
- import { dirname as dirname9, join as join14 } from "node:path";
165453
+ import { dirname as dirname10, join as join14 } from "node:path";
165452
165454
  function pluginEntryId(entry) {
165453
165455
  if (typeof entry === "string")
165454
165456
  return entry;
@@ -165536,7 +165538,7 @@ function ensureTuiPluginEntry() {
165536
165538
  }
165537
165539
  }
165538
165540
  config2.plugin = plugins;
165539
- mkdirSync7(dirname9(configPath), { recursive: true });
165541
+ mkdirSync8(dirname10(configPath), { recursive: true });
165540
165542
  writeTuiConfigAtomic(configPath, config2);
165541
165543
  log2(`[magic-context] updated TUI plugin entry in ${configPath}`);
165542
165544
  return true;
@@ -165721,6 +165723,12 @@ function redactionTypeForKey(key) {
165721
165723
  const suffix = normalized.split(".").filter(Boolean).at(-1) ?? normalized;
165722
165724
  return suffix || "secret";
165723
165725
  }
165726
+ function isNonSecretScalarValue(value) {
165727
+ const v2 = value.trim();
165728
+ if (v2 === "true" || v2 === "false" || v2 === "null" || v2 === "undefined")
165729
+ return true;
165730
+ return /^[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(v2);
165731
+ }
165724
165732
  function isSecretKey(key) {
165725
165733
  const segments = key.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase().split(/[._-]+/).filter(Boolean);
165726
165734
  if (segments.length === 0)
@@ -165880,11 +165888,11 @@ var init_redaction = __esm(() => {
165880
165888
  },
165881
165889
  {
165882
165890
  pattern: /(["'])([^"']*(?:key|token|secret|password|auth|bearer|credential)[^"']*)\1(\s*:\s*)(["'])([^"']*)\4/gi,
165883
- replacement: (_full, quote, key, separator, valueQuote) => `${quote}${key}${quote}${separator}${valueQuote}<REDACTED:${redactionTypeForKey(key)}>${valueQuote}`
165891
+ replacement: (full, quote, key, separator, valueQuote, value) => isNonSecretScalarValue(value) ? full : `${quote}${key}${quote}${separator}${valueQuote}<REDACTED:${redactionTypeForKey(key)}>${valueQuote}`
165884
165892
  },
165885
165893
  {
165886
165894
  pattern: /\b([A-Za-z0-9_.-]*(?:key|token|secret|password|auth|bearer|credential)[A-Za-z0-9_.-]*)\s*=\s*([^\s'"`]+)/gi,
165887
- replacement: (_full, key) => `${key}=<REDACTED:${redactionTypeForKey(key)}>`
165895
+ replacement: (full, key, value) => isNonSecretScalarValue(value) ? full : `${key}=<REDACTED:${redactionTypeForKey(key)}>`
165888
165896
  }
165889
165897
  ];
165890
165898
  });
@@ -166382,7 +166390,7 @@ var init_diagnostics_opencode = __esm(() => {
166382
166390
  // src/lib/embedding-runtime.ts
166383
166391
  import { existsSync as existsSync20 } from "node:fs";
166384
166392
  import { createRequire as createRequire3 } from "node:module";
166385
- import { dirname as dirname10, join as join16, sep } from "node:path";
166393
+ import { dirname as dirname11, join as join16, sep } from "node:path";
166386
166394
  function expectedBinaryRelPath(platform, arch) {
166387
166395
  const supportedPlatform = platform === "linux" || platform === "darwin" || platform === "win32";
166388
166396
  const supportedArch = arch === "x64" || arch === "arm64";
@@ -166426,7 +166434,7 @@ function checkLocalEmbeddingRuntime(installRoots, platform = process.platform, a
166426
166434
  function packageDirFromResolved(resolvedPath, packageName) {
166427
166435
  const marker = `node_modules${sep}${packageName.split("/").join(sep)}`;
166428
166436
  const idx = resolvedPath.indexOf(marker);
166429
- return idx >= 0 ? resolvedPath.slice(0, idx + marker.length) : dirname10(resolvedPath);
166437
+ return idx >= 0 ? resolvedPath.slice(0, idx + marker.length) : dirname11(resolvedPath);
166430
166438
  }
166431
166439
  function checkLocalEmbeddingRuntimeByResolution(pluginDir, platform = process.platform, arch = process.arch) {
166432
166440
  if (!existsSync20(join16(pluginDir, "package.json"))) {
@@ -168454,10 +168462,10 @@ var init_logs_pi = __esm(() => {
168454
168462
 
168455
168463
  // src/commands/doctor-pi.ts
168456
168464
  import { execFileSync as execFileSync4, spawnSync as spawnSync3 } from "node:child_process";
168457
- import { existsSync as existsSync24, mkdirSync as mkdirSync8, readdirSync as readdirSync4, readFileSync as readFileSync17, rmSync as rmSync3, statSync as statSync10 } from "node:fs";
168465
+ import { existsSync as existsSync24, mkdirSync as mkdirSync9, readdirSync as readdirSync4, readFileSync as readFileSync17, rmSync as rmSync3, statSync as statSync10 } from "node:fs";
168458
168466
  import { createRequire as createRequire6 } from "node:module";
168459
168467
  import { homedir as homedir15 } from "node:os";
168460
- import { dirname as dirname11, isAbsolute as isAbsolute3, join as join21 } from "node:path";
168468
+ import { dirname as dirname12, isAbsolute as isAbsolute3, join as join21 } from "node:path";
168461
168469
  function depsFrom(options) {
168462
168470
  return {
168463
168471
  ...DEFAULT_DEPS,
@@ -168930,7 +168938,7 @@ async function runHealthChecks(options) {
168930
168938
  return { results, repairPlan, ...summarize(results) };
168931
168939
  }
168932
168940
  function writeDefaultMagicContextConfig(path6) {
168933
- mkdirSync8(dirname11(path6), { recursive: true });
168941
+ mkdirSync9(dirname12(path6), { recursive: true });
168934
168942
  const config2 = {
168935
168943
  $schema: "https://raw.githubusercontent.com/cortexkit/magic-context/master/assets/magic-context.schema.json",
168936
168944
  ...MagicContextConfigSchema.parse({})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/magic-context",
3
- "version": "0.27.0",
3
+ "version": "0.27.1",
4
4
  "description": "Unified CLI for Magic Context — setup, doctor, and migration across OpenCode and Pi",
5
5
  "keywords": [
6
6
  "opencode",