oira666_pi-watcher 0.0.5 → 0.0.6

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A persistent side-agent conversation for your running [Pi](https://pi.dev) agent.
4
4
 
5
- **Package:** `oira666_pi-watcher` · **Version:** `0.0.5` · **License:** MIT
5
+ **Package:** `oira666_pi-watcher` · **Version:** `0.0.6` · **License:** MIT
6
6
 
7
7
  ## Install
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oira666_pi-watcher",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "A persistent side-agent conversation for observing and steering your running Pi agent.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -103,6 +103,8 @@ export interface PiLocation {
103
103
  packageDir: string;
104
104
  /** Module exporting `main` and `DefaultPackageManager` (bundle index, else unbundled index). */
105
105
  entry: string;
106
+ /** Executable Pi CLI for extensions that spawn process.argv[1]. */
107
+ cliEntry: string;
106
108
  docsDir?: string;
107
109
  }
108
110
 
@@ -138,8 +140,16 @@ export function locatePi(options: { piPackageDir?: string; argv?: readonly strin
138
140
  existsSync(f),
139
141
  );
140
142
  if (!entry) continue;
143
+ const bin = readJson(join(packageDir, "package.json"))?.bin;
144
+ const piBin = typeof bin === "string" ? bin : (bin as Record<string, unknown> | undefined)?.pi;
145
+ const cliEntry = [
146
+ ...(typeof piBin === "string" ? [resolve(packageDir, piBin)] : []),
147
+ join(packageDir, "dist", "bundle", "cli.js"),
148
+ join(packageDir, "dist", "cli.js"),
149
+ ].find((f) => existsSync(f));
150
+ if (!cliEntry) continue;
141
151
  const docsDir = join(packageDir, "docs");
142
- return { packageDir, entry, docsDir: existsSync(docsDir) ? docsDir : undefined };
152
+ return { packageDir, entry, cliEntry, docsDir: existsSync(docsDir) ? docsDir : undefined };
143
153
  }
144
154
  throw new Error(
145
155
  `Cannot locate the ${PI_PACKAGE_NAME} package (tried: ${candidates.join(", ") || "none"}). Pass piPackageDir or set PI_PACKAGE_DIR.`,
@@ -42,6 +42,10 @@ async function run() {
42
42
  setTimeout(() => process.exit(0), 3000).unref();
43
43
  });
44
44
 
45
+ // Inherited extensions launch subagents using execPath + argv[1]. Expose the real
46
+ // CLI before importing Pi or loading extensions, not this IPC-only bootstrap.
47
+ process.argv[1] = config.piCliEntry;
48
+
45
49
  const pi = await import(pathToFileURL(config.piEntry).href);
46
50
  const { DefaultPackageManager, main } = pi;
47
51
  if (typeof main !== "function") throw new Error(`pi entry ${config.piEntry} does not export main()`);
@@ -26,6 +26,8 @@ export interface ChildConfig {
26
26
  version: 1;
27
27
  /** Absolute path of the pi module exporting `main` and `DefaultPackageManager` (bundle/index.js). */
28
28
  piEntry: string;
29
+ /** Executable Pi CLI exposed as process.argv[1] in the child. */
30
+ piCliEntry: string;
29
31
  cwd: string;
30
32
  mainSessionId: string;
31
33
  mainSessionFile: string;
package/src/runtime.ts CHANGED
@@ -403,6 +403,7 @@ interface Resolved {
403
403
  childEntry: string;
404
404
  piPackageDir: string;
405
405
  piEntry: string;
406
+ piCliEntry: string;
406
407
  piDocsDir?: string;
407
408
  nodePath: string;
408
409
  baseArgs: string[];
@@ -787,6 +788,7 @@ export class WatcherRuntime {
787
788
  childEntry,
788
789
  piPackageDir: pi.packageDir,
789
790
  piEntry: pi.entry,
791
+ piCliEntry: pi.cliEntry,
790
792
  piDocsDir: pi.docsDir,
791
793
  nodePath,
792
794
  baseArgs: ["--session-dir", sessionDir, "--session-id", sideSessionId, "--extension", bridgePath],
@@ -804,6 +806,7 @@ export class WatcherRuntime {
804
806
  const config: ChildConfig = {
805
807
  version: 1,
806
808
  piEntry: resolved.piEntry,
809
+ piCliEntry: resolved.piCliEntry,
807
810
  cwd: resolved.cwd,
808
811
  mainSessionId: options.mainSessionId,
809
812
  mainSessionFile: resolved.mainSessionFile,