@cortexkit/pi-magic-context 0.27.0 → 0.27.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.
package/dist/index.js CHANGED
@@ -15136,7 +15136,18 @@ function legacySourcesForBase(basePath, label) {
15136
15136
  { path: `${basePath}.json`, label: `${label} magic-context.json` }
15137
15137
  ];
15138
15138
  }
15139
+ function userScopeConfigPaths() {
15140
+ return new Set([
15141
+ `${cortexKitUserConfigBasePath()}.jsonc`,
15142
+ `${cortexKitUserConfigBasePath()}.json`,
15143
+ join(configHome(), "opencode", `${CONFIG_FILE_BASENAME}.jsonc`),
15144
+ join(configHome(), "opencode", `${CONFIG_FILE_BASENAME}.json`),
15145
+ join(homeDir(), ".pi", "agent", `${CONFIG_FILE_BASENAME}.jsonc`),
15146
+ join(homeDir(), ".pi", "agent", `${CONFIG_FILE_BASENAME}.json`)
15147
+ ]);
15148
+ }
15139
15149
  function resolveLegacyConfigSources(directory) {
15150
+ const userPaths = userScopeConfigPaths();
15140
15151
  return {
15141
15152
  user: [
15142
15153
  ...legacySourcesForBase(join(configHome(), "opencode", CONFIG_FILE_BASENAME), "OpenCode user"),
@@ -15146,7 +15157,7 @@ function resolveLegacyConfigSources(directory) {
15146
15157
  ...legacySourcesForBase(join(directory, CONFIG_FILE_BASENAME), "project root"),
15147
15158
  ...legacySourcesForBase(join(directory, ".opencode", CONFIG_FILE_BASENAME), "OpenCode project"),
15148
15159
  ...legacySourcesForBase(join(directory, ".pi", CONFIG_FILE_BASENAME), "Pi project")
15149
- ]
15160
+ ].filter((source) => !userPaths.has(source.path))
15150
15161
  };
15151
15162
  }
15152
15163
  function resolveLegacyConfigSourcesForHarness(directory, harness) {
@@ -156419,7 +156430,7 @@ init_logger();
156419
156430
  import * as childProcess from "node:child_process";
156420
156431
  import { existsSync as existsSync7 } from "node:fs";
156421
156432
  import { createRequire as createRequire2 } from "node:module";
156422
- import { dirname as dirname4, join as join8, resolve as resolvePath } from "node:path";
156433
+ import { basename as basename2, dirname as dirname4, join as join8, resolve as resolvePath } from "node:path";
156423
156434
  import { createInterface } from "node:readline";
156424
156435
  import { fileURLToPath } from "node:url";
156425
156436
 
@@ -156528,6 +156539,24 @@ function resolveBundledPiCli() {
156528
156539
  return null;
156529
156540
  }
156530
156541
  }
156542
+ function resolvePiInvocation() {
156543
+ const execPath = process.execPath;
156544
+ const currentScript = process.argv[1];
156545
+ const isBunVirtualScript = currentScript?.startsWith("/$bunfs/root/") ?? false;
156546
+ if (currentScript && !isBunVirtualScript && existsSync7(currentScript)) {
156547
+ return { command: execPath, prefixArgs: [currentScript] };
156548
+ }
156549
+ const execName = basename2(execPath).toLowerCase();
156550
+ const isGenericRuntime = /^(node|bun)(\.exe)?$/.test(execName);
156551
+ if (!isGenericRuntime) {
156552
+ return { command: execPath, prefixArgs: [] };
156553
+ }
156554
+ const bundled = resolveBundledPiCli();
156555
+ if (bundled) {
156556
+ return { command: execPath, prefixArgs: [bundled] };
156557
+ }
156558
+ return { command: "pi", prefixArgs: [] };
156559
+ }
156531
156560
  function resolveSubagentEntryPath() {
156532
156561
  try {
156533
156562
  const here = dirname4(fileURLToPath(import.meta.url));
@@ -156577,19 +156606,10 @@ function inferAccountingSubagent(agent) {
156577
156606
 
156578
156607
  class PiSubagentRunner {
156579
156608
  harness = "pi";
156580
- piBinary;
156609
+ invocation;
156581
156610
  spawnImpl;
156582
156611
  constructor(options = {}) {
156583
- if (options.piBinary) {
156584
- this.piBinary = options.piBinary;
156585
- } else {
156586
- const bundled = resolveBundledPiCli();
156587
- if (bundled) {
156588
- this.piBinary = bundled;
156589
- } else {
156590
- this.piBinary = "pi";
156591
- }
156592
- }
156612
+ this.invocation = options.piBinary ? { command: options.piBinary, prefixArgs: [] } : resolvePiInvocation();
156593
156613
  this.spawnImpl = options.spawnImpl ?? childProcess.spawn;
156594
156614
  }
156595
156615
  async run(options) {
@@ -156677,7 +156697,7 @@ class PiSubagentRunner {
156677
156697
  };
156678
156698
  let child;
156679
156699
  try {
156680
- child = this.spawnImpl(this.piBinary, args, {
156700
+ child = this.spawnImpl(this.invocation.command, [...this.invocation.prefixArgs, ...args], {
156681
156701
  cwd: options.cwd,
156682
156702
  env: process.env,
156683
156703
  stdio: [deliverViaStdin ? "pipe" : "ignore", "pipe", "pipe"]
@@ -176728,6 +176748,12 @@ function redactionTypeForKey(key) {
176728
176748
  const suffix = normalized.split(".").filter(Boolean).at(-1) ?? normalized;
176729
176749
  return suffix || "secret";
176730
176750
  }
176751
+ function isNonSecretScalarValue(value) {
176752
+ const v = value.trim();
176753
+ if (v === "true" || v === "false" || v === "null" || v === "undefined")
176754
+ return true;
176755
+ return /^[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(v);
176756
+ }
176731
176757
  var SECRET_QUALIFIERS = new Set([
176732
176758
  "api",
176733
176759
  "access",
@@ -176807,11 +176833,11 @@ var SECRET_TEXT_PATTERNS = [
176807
176833
  },
176808
176834
  {
176809
176835
  pattern: /(["'])([^"']*(?:key|token|secret|password|auth|bearer|credential)[^"']*)\1(\s*:\s*)(["'])([^"']*)\4/gi,
176810
- replacement: (_full, quote, key, separator, valueQuote) => `${quote}${key}${quote}${separator}${valueQuote}<REDACTED:${redactionTypeForKey(key)}>${valueQuote}`
176836
+ replacement: (full, quote, key, separator, valueQuote, value) => isNonSecretScalarValue(value) ? full : `${quote}${key}${quote}${separator}${valueQuote}<REDACTED:${redactionTypeForKey(key)}>${valueQuote}`
176811
176837
  },
176812
176838
  {
176813
176839
  pattern: /\b([A-Za-z0-9_.-]*(?:key|token|secret|password|auth|bearer|credential)[A-Za-z0-9_.-]*)\s*=\s*([^\s'"`]+)/gi,
176814
- replacement: (_full, key) => `${key}=<REDACTED:${redactionTypeForKey(key)}>`
176840
+ replacement: (full, key, value) => isNonSecretScalarValue(value) ? full : `${key}=<REDACTED:${redactionTypeForKey(key)}>`
176815
176841
  }
176816
176842
  ];
176817
176843
  function redactSecretText(value) {
@@ -177517,21 +177543,21 @@ function isSecretDeniedPath(repoRelativePath) {
177517
177543
  const segments = normalized.split("/");
177518
177544
  if (segments.includes(".git") || segments.includes("secrets"))
177519
177545
  return true;
177520
- const basename2 = segments.at(-1) ?? "";
177521
- if (basename2 === ".npmrc" || basename2.startsWith(".env"))
177546
+ const basename3 = segments.at(-1) ?? "";
177547
+ if (basename3 === ".npmrc" || basename3.startsWith(".env"))
177522
177548
  return true;
177523
- if (basename2 === ".pgpass" || basename2 === ".netrc")
177549
+ if (basename3 === ".pgpass" || basename3 === ".netrc")
177524
177550
  return true;
177525
- if (SECRET_KEY_EXTENSIONS.some((extension) => basename2.endsWith(extension)))
177551
+ if (SECRET_KEY_EXTENSIONS.some((extension) => basename3.endsWith(extension)))
177526
177552
  return true;
177527
- if (basename2 === "id_rsa" || basename2 === "id_dsa" || basename2 === "id_ecdsa" || basename2 === "id_ed25519" || basename2.startsWith("id_")) {
177553
+ if (basename3 === "id_rsa" || basename3 === "id_dsa" || basename3 === "id_ecdsa" || basename3 === "id_ed25519" || basename3.startsWith("id_")) {
177528
177554
  return true;
177529
177555
  }
177530
- if (segments.includes(".aws") && basename2 === "credentials")
177556
+ if (segments.includes(".aws") && basename3 === "credentials")
177531
177557
  return true;
177532
- if (basename2.endsWith(".json")) {
177533
- const serviceAccountJson = basename2.includes("service-account") || basename2.includes("service_account");
177534
- const gcloudCredentialJson = segments.includes("gcloud") && (basename2 === "application_default_credentials.json" || basename2.includes("credential") || segments.includes("legacy_credentials"));
177558
+ if (basename3.endsWith(".json")) {
177559
+ const serviceAccountJson = basename3.includes("service-account") || basename3.includes("service_account");
177560
+ const gcloudCredentialJson = segments.includes("gcloud") && (basename3 === "application_default_credentials.json" || basename3.includes("credential") || segments.includes("legacy_credentials"));
177535
177561
  if (serviceAccountJson || gcloudCredentialJson)
177536
177562
  return true;
177537
177563
  }
@@ -199294,7 +199320,7 @@ function formatThresholdPercent(value) {
199294
199320
  // package.json
199295
199321
  var package_default = {
199296
199322
  name: "@cortexkit/pi-magic-context",
199297
- version: "0.27.0",
199323
+ version: "0.27.2",
199298
199324
  type: "module",
199299
199325
  description: "Pi coding agent extension for Magic Context — cross-session memory and context management",
199300
199326
  main: "dist/index.js",
@@ -144113,7 +144113,18 @@ function legacySourcesForBase(basePath, label) {
144113
144113
  { path: `${basePath}.json`, label: `${label} magic-context.json` }
144114
144114
  ];
144115
144115
  }
144116
+ function userScopeConfigPaths() {
144117
+ return new Set([
144118
+ `${cortexKitUserConfigBasePath()}.jsonc`,
144119
+ `${cortexKitUserConfigBasePath()}.json`,
144120
+ join4(configHome(), "opencode", `${CONFIG_FILE_BASENAME}.jsonc`),
144121
+ join4(configHome(), "opencode", `${CONFIG_FILE_BASENAME}.json`),
144122
+ join4(homeDir(), ".pi", "agent", `${CONFIG_FILE_BASENAME}.jsonc`),
144123
+ join4(homeDir(), ".pi", "agent", `${CONFIG_FILE_BASENAME}.json`)
144124
+ ]);
144125
+ }
144116
144126
  function resolveLegacyConfigSources(directory) {
144127
+ const userPaths = userScopeConfigPaths();
144117
144128
  return {
144118
144129
  user: [
144119
144130
  ...legacySourcesForBase(join4(configHome(), "opencode", CONFIG_FILE_BASENAME), "OpenCode user"),
@@ -144123,7 +144134,7 @@ function resolveLegacyConfigSources(directory) {
144123
144134
  ...legacySourcesForBase(join4(directory, CONFIG_FILE_BASENAME), "project root"),
144124
144135
  ...legacySourcesForBase(join4(directory, ".opencode", CONFIG_FILE_BASENAME), "OpenCode project"),
144125
144136
  ...legacySourcesForBase(join4(directory, ".pi", CONFIG_FILE_BASENAME), "Pi project")
144126
- ]
144137
+ ].filter((source) => !userPaths.has(source.path))
144127
144138
  };
144128
144139
  }
144129
144140
  function resolveLegacyConfigSourcesForHarness(directory, harness) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/pi-magic-context",
3
- "version": "0.27.0",
3
+ "version": "0.27.2",
4
4
  "type": "module",
5
5
  "description": "Pi coding agent extension for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",