@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 +1 -1
- package/reader-manager.d.ts +1 -10
- package/reader-manager.js +17 -21
package/package.json
CHANGED
package/reader-manager.d.ts
CHANGED
|
@@ -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:
|
|
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
|
-
* -
|
|
81
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
120
|
-
require.resolve("pi-subagents");
|
|
122
|
+
if (fs.existsSync(piSubagentsPackageJson())) {
|
|
121
123
|
return true;
|
|
122
124
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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:
|
|
131
|
+
* Quick synchronous check: does pi-subagents exist on disk?
|
|
130
132
|
*/
|
|
131
133
|
function isSubagentsInstalled() {
|
|
132
|
-
|
|
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
|