@cortexkit/pi-magic-context 0.27.1 → 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"]
@@ -177523,21 +177543,21 @@ function isSecretDeniedPath(repoRelativePath) {
177523
177543
  const segments = normalized.split("/");
177524
177544
  if (segments.includes(".git") || segments.includes("secrets"))
177525
177545
  return true;
177526
- const basename2 = segments.at(-1) ?? "";
177527
- if (basename2 === ".npmrc" || basename2.startsWith(".env"))
177546
+ const basename3 = segments.at(-1) ?? "";
177547
+ if (basename3 === ".npmrc" || basename3.startsWith(".env"))
177528
177548
  return true;
177529
- if (basename2 === ".pgpass" || basename2 === ".netrc")
177549
+ if (basename3 === ".pgpass" || basename3 === ".netrc")
177530
177550
  return true;
177531
- if (SECRET_KEY_EXTENSIONS.some((extension) => basename2.endsWith(extension)))
177551
+ if (SECRET_KEY_EXTENSIONS.some((extension) => basename3.endsWith(extension)))
177532
177552
  return true;
177533
- 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_")) {
177534
177554
  return true;
177535
177555
  }
177536
- if (segments.includes(".aws") && basename2 === "credentials")
177556
+ if (segments.includes(".aws") && basename3 === "credentials")
177537
177557
  return true;
177538
- if (basename2.endsWith(".json")) {
177539
- const serviceAccountJson = basename2.includes("service-account") || basename2.includes("service_account");
177540
- 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"));
177541
177561
  if (serviceAccountJson || gcloudCredentialJson)
177542
177562
  return true;
177543
177563
  }
@@ -199300,7 +199320,7 @@ function formatThresholdPercent(value) {
199300
199320
  // package.json
199301
199321
  var package_default = {
199302
199322
  name: "@cortexkit/pi-magic-context",
199303
- version: "0.27.1",
199323
+ version: "0.27.2",
199304
199324
  type: "module",
199305
199325
  description: "Pi coding agent extension for Magic Context — cross-session memory and context management",
199306
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.1",
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",