@stfade/pi-read-delegator 1.0.9 → 1.0.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stfade/pi-read-delegator",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Pi extension that delegates all read operations to a Reader subagent, blocking read tools from the main model",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -21,18 +21,9 @@ export declare class ReaderError extends Error {
21
21
  readonly originalError?: unknown | undefined;
22
22
  constructor(message: string, originalError?: unknown | undefined);
23
23
  }
24
- /**
25
- * Verify that pi-subagents is installed as a Pi extension.
26
- *
27
- * - Uses `require.resolve('pi-subagents')` to check installation.
28
- * - If not installed, prompts the user to install via `pi install pi-subagents`.
29
- * - If the user declines or installation fails, returns false (caller disables the extension).
30
- *
31
- * @returns true if installed or successfully installed; false otherwise
32
- */
33
24
  export declare function checkDependencies(prompt: (message: string) => Promise<string>): Promise<boolean>;
34
25
  /**
35
- * Quick synchronous check: can we resolve pi-subagents?
26
+ * Quick synchronous check: does pi-subagents exist on disk?
36
27
  */
37
28
  export declare function isSubagentsInstalled(): boolean;
38
29
  /**
package/reader-manager.js CHANGED
@@ -77,21 +77,24 @@ const READER_TEMPLATE_PATH = expandTilde("~/.pi/agent/agents/reader.md");
77
77
  /**
78
78
  * Verify that pi-subagents is installed as a Pi extension.
79
79
  *
80
- * - Uses `require.resolve('pi-subagents')` to check installation.
81
- * - If not installed, prompts the user to install via `pi install pi-subagents`.
80
+ * - Checks fs.existsSync for the pi-subagents directory (bypasses require.resolve
81
+ * caching issues after npm install within the same process).
82
+ * - If not installed, prompts the user to install via `npm install --prefix`.
82
83
  * - If the user declines or installation fails, returns false (caller disables the extension).
83
84
  *
84
85
  * @returns true if installed or successfully installed; false otherwise
85
86
  */
87
+ function piSubagentsDir() {
88
+ return path.join(os.homedir(), ".pi", "agent", "npm", "node_modules", "pi-subagents");
89
+ }
90
+ function piSubagentsPackageJson() {
91
+ return path.join(piSubagentsDir(), "package.json");
92
+ }
86
93
  async function checkDependencies(prompt) {
87
94
  // Already installed — nothing to do
88
- try {
89
- require.resolve("pi-subagents");
95
+ if (fs.existsSync(piSubagentsPackageJson())) {
90
96
  return true;
91
97
  }
92
- catch {
93
- // MODULE_NOT_FOUND — prompt the user
94
- }
95
98
  console.warn("[pi-read-delegator] ⚠️ pi-subagents is not installed.");
96
99
  const answer = await prompt("pi-subagents is not installed. Install it now? [Y/n]");
97
100
  const normalized = answer.trim().toLowerCase();
@@ -116,26 +119,19 @@ async function checkDependencies(prompt) {
116
119
  return false;
117
120
  }
118
121
  // Verify installation took effect
119
- try {
120
- require.resolve("pi-subagents");
122
+ if (fs.existsSync(piSubagentsPackageJson())) {
121
123
  return true;
122
124
  }
123
- catch {
124
- console.error("[pi-read-delegator] ❌ pi-subagents installed but cannot be found. Restart Pi and try again.");
125
- return false;
126
- }
125
+ console.error("[pi-read-delegator] ❌ pi-subagents installed but cannot be found at " +
126
+ piSubagentsDir() +
127
+ ". Restart Pi and try again.");
128
+ return false;
127
129
  }
128
130
  /**
129
- * Quick synchronous check: can we resolve pi-subagents?
131
+ * Quick synchronous check: does pi-subagents exist on disk?
130
132
  */
131
133
  function isSubagentsInstalled() {
132
- try {
133
- require.resolve("pi-subagents");
134
- return true;
135
- }
136
- catch {
137
- return false;
138
- }
134
+ return fs.existsSync(piSubagentsPackageJson());
139
135
  }
140
136
  // ---------------------------------------------------------------------------
141
137
  // 2. Reader template