@heyhuynhgiabuu/pi-pretty 0.6.10 → 0.6.12
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/CHANGELOG.md +24 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -73
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +87 -91
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.12] - 2026-06-21
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **Published install resume crash on Pi 0.79.9** — remove the nested runtime
|
|
8
|
+
`@earendil-works/pi-coding-agent` dependency from published installs and make
|
|
9
|
+
FFF startup independent from the optional SDK tool-factory import. Published
|
|
10
|
+
extensions should not load a second Pi host runtime inside the Pi process.
|
|
11
|
+
|
|
12
|
+
- **FFF native teardown during resume/session switching** — stop destroying the
|
|
13
|
+
native FFF finder in `session_shutdown`; Pi can emit shutdown/start while the
|
|
14
|
+
same process continues, and native teardown in that transition is too risky.
|
|
15
|
+
|
|
16
|
+
## [0.6.11] - 2026-06-21
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- **Pi resume crash with v0.6.10 on Pi 0.79.9** — `v0.6.10` promoted
|
|
21
|
+
`@earendil-works/pi-coding-agent` to a runtime dependency but kept the old
|
|
22
|
+
`^0.75.1` range. Published installs could therefore load a nested older Pi SDK
|
|
23
|
+
inside a Pi `0.79.9` host process during extension activation/resume.
|
|
24
|
+
|
|
25
|
+
Fix: align the runtime SDK dependency with Pi `0.79.9` and refresh the lockfile.
|
|
26
|
+
|
|
3
27
|
## [0.6.10] - 2026-06-21
|
|
4
28
|
|
|
5
29
|
### Fixed
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAA6C,MAAM,iCAAiC,CAAC;AAE/G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA6B/C,YAAY,EAAE,YAAY,EAAE,CAAC;AAE7B,wBAA8B,iBAAiB,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAqNpG"}
|
package/dist/index.js
CHANGED
|
@@ -39,77 +39,20 @@ async function piPrettyExtension(pi, deps) {
|
|
|
39
39
|
const isToolEnabled = (name) => !disabledTools.has(name.toLowerCase());
|
|
40
40
|
const cwd = process.cwd();
|
|
41
41
|
// ------------------------------------------------------------------
|
|
42
|
-
// Resolve SDK tools
|
|
43
|
-
// ------------------------------------------------------------------
|
|
44
|
-
let sdk;
|
|
45
|
-
let createReadTool;
|
|
46
|
-
let createBashTool;
|
|
47
|
-
let createLsTool;
|
|
48
|
-
let createFindTool;
|
|
49
|
-
let createGrepTool;
|
|
50
|
-
let getAgentDir;
|
|
51
|
-
if (deps) {
|
|
52
|
-
sdk = deps.sdk ?? {};
|
|
53
|
-
createReadTool = sdk.createReadTool ?? sdk.createReadToolDefinition;
|
|
54
|
-
createBashTool = sdk.createBashTool ?? sdk.createBashToolDefinition;
|
|
55
|
-
createLsTool = sdk.createLsTool ?? sdk.createLsToolDefinition;
|
|
56
|
-
createFindTool = sdk.createFindTool ?? sdk.createFindToolDefinition;
|
|
57
|
-
createGrepTool = sdk.createGrepTool ?? sdk.createGrepToolDefinition;
|
|
58
|
-
getAgentDir = sdk.getAgentDir;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
try {
|
|
62
|
-
// Dynamic import() uses ESM resolution (not CJS interop), so it
|
|
63
|
-
// correctly resolves subpath exports like @earendil-works/pi-ai/base
|
|
64
|
-
// which only have "import" conditions in their exports map.
|
|
65
|
-
const mod = await import("@earendil-works/pi-coding-agent");
|
|
66
|
-
sdk = mod;
|
|
67
|
-
createReadTool = sdk.createReadToolDefinition ?? sdk.createReadTool;
|
|
68
|
-
createBashTool = sdk.createBashToolDefinition ?? sdk.createBashTool;
|
|
69
|
-
createLsTool = sdk.createLsToolDefinition ?? sdk.createLsTool;
|
|
70
|
-
createFindTool = sdk.createFindToolDefinition ?? sdk.createFindTool;
|
|
71
|
-
createGrepTool = sdk.createGrepToolDefinition ?? sdk.createGrepTool;
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
return; // pi SDK not available
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if (!createReadTool)
|
|
78
|
-
return;
|
|
79
|
-
// ------------------------------------------------------------------
|
|
80
42
|
// FFF service init
|
|
81
43
|
// ------------------------------------------------------------------
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
44
|
+
// Keep FFF independent from the Pi SDK import. Published extension installs
|
|
45
|
+
// run in Pi's isolated npm root; importing a nested Pi SDK at activation time
|
|
46
|
+
// has proven crash-prone across host Pi versions. FFF commands and indexing
|
|
47
|
+
// should still work even when SDK tool factories are unavailable.
|
|
48
|
+
const maybeGetAgentDir = deps?.sdk?.getAgentDir;
|
|
49
|
+
const agentDir = typeof maybeGetAgentDir === "function" ? maybeGetAgentDir() : (0, config_js_1.getDefaultAgentDir)();
|
|
50
|
+
let fffService = new fff_js_1.FffService(deps?.fffModule, agentDir);
|
|
87
51
|
// Ripgrep fallback for multi_grep
|
|
88
52
|
const multiGrepFallback = deps?.multiGrepRipgrepFallback ?? multi_grep_fallback_js_1.runMultiGrepRipgrepFallback;
|
|
89
53
|
// Text component for custom rendering (DI-friendly)
|
|
90
54
|
const TextComp = deps?.TextComponent;
|
|
91
55
|
// ------------------------------------------------------------------
|
|
92
|
-
// Tool registration
|
|
93
|
-
// ------------------------------------------------------------------
|
|
94
|
-
if (isToolEnabled("read") && createReadTool) {
|
|
95
|
-
(0, read_js_1.registerReadTool)(pi, cwd, null, createReadTool(cwd), TextComp);
|
|
96
|
-
}
|
|
97
|
-
if (isToolEnabled("bash") && createBashTool) {
|
|
98
|
-
(0, bash_js_1.registerBashTool)(pi, cwd, null, createBashTool(cwd), TextComp);
|
|
99
|
-
}
|
|
100
|
-
if (isToolEnabled("ls") && createLsTool) {
|
|
101
|
-
(0, ls_js_1.registerLsTool)(pi, cwd, null, createLsTool(cwd), TextComp);
|
|
102
|
-
}
|
|
103
|
-
if (isToolEnabled("find") && createFindTool) {
|
|
104
|
-
(0, find_js_1.registerFindTool)(pi, cwd, fffService, createFindTool(cwd), TextComp);
|
|
105
|
-
}
|
|
106
|
-
if (isToolEnabled("grep") && createGrepTool) {
|
|
107
|
-
(0, grep_js_1.registerGrepTool)(pi, cwd, fffService, createGrepTool(cwd), TextComp);
|
|
108
|
-
}
|
|
109
|
-
if (isToolEnabled("multi_grep") && (fffService || createGrepTool)) {
|
|
110
|
-
(0, multi_grep_js_1.registerMultiGrepTool)(pi, cwd, fffService, createGrepTool ? createGrepTool(cwd) : undefined, multiGrepFallback, TextComp);
|
|
111
|
-
}
|
|
112
|
-
// ------------------------------------------------------------------
|
|
113
56
|
// FFF commands
|
|
114
57
|
// ------------------------------------------------------------------
|
|
115
58
|
if (fffService) {
|
|
@@ -176,13 +119,13 @@ async function piPrettyExtension(pi, deps) {
|
|
|
176
119
|
pi.on("session_start", async (_event, ctx) => {
|
|
177
120
|
if (!fffService)
|
|
178
121
|
return;
|
|
179
|
-
// Try dynamic import if sync require failed
|
|
180
|
-
if (!fffService.isModuleLoaded()) {
|
|
181
|
-
const loaded = await fffService.tryLoadModule();
|
|
182
|
-
if (!loaded)
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
122
|
try {
|
|
123
|
+
// Try dynamic import if sync require failed
|
|
124
|
+
if (!fffService.isModuleLoaded()) {
|
|
125
|
+
const loaded = await fffService.tryLoadModule();
|
|
126
|
+
if (!loaded)
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
186
129
|
await fffService.ensureFinder(ctx.cwd);
|
|
187
130
|
if (fffService.partialIndex) {
|
|
188
131
|
ctx.ui?.notify?.("FFF: scan timed out — using partial index. Run /fff-rescan when ready.", "warning");
|
|
@@ -192,16 +135,73 @@ async function piPrettyExtension(pi, deps) {
|
|
|
192
135
|
ui?.setStatus?.("fff", "FFF indexed");
|
|
193
136
|
setTimeout(() => ui?.setStatus?.("fff", undefined), 3000);
|
|
194
137
|
}
|
|
138
|
+
// Register FFF-backed @-mention autocomplete only after a finder exists.
|
|
139
|
+
ctx.ui?.addAutocompleteProvider?.((current) => (0, autocomplete_js_1.createFffAutocompleteProvider)(current, () => fffService?.getFinder() ?? null));
|
|
195
140
|
}
|
|
196
141
|
catch (error) {
|
|
197
142
|
ctx.ui?.notify?.(`FFF init failed: ${error instanceof Error ? error.message : String(error)}`, "error");
|
|
198
143
|
}
|
|
199
|
-
// Register FFF-backed @-mention autocomplete
|
|
200
|
-
ctx.ui?.addAutocompleteProvider?.((current) => (0, autocomplete_js_1.createFffAutocompleteProvider)(current, () => fffService?.getFinder() ?? null));
|
|
201
144
|
});
|
|
202
145
|
pi.on("session_shutdown", async () => {
|
|
203
|
-
|
|
146
|
+
// Intentionally do not destroy the native FFF finder on session shutdown.
|
|
147
|
+
// Pi can emit shutdown/start during resume or session switching while the
|
|
148
|
+
// process keeps running. Native teardown during that transition has caused
|
|
149
|
+
// hard process crashes in published installs; let process exit reclaim it.
|
|
150
|
+
fffService = null;
|
|
204
151
|
});
|
|
152
|
+
// ------------------------------------------------------------------
|
|
153
|
+
// Resolve SDK tools, if available
|
|
154
|
+
// ------------------------------------------------------------------
|
|
155
|
+
// The SDK import is optional. Do not return from the extension if it fails;
|
|
156
|
+
// FFF commands/indexing above must remain available in published npm installs.
|
|
157
|
+
let sdk = deps?.sdk ?? {};
|
|
158
|
+
let createReadTool = sdk.createReadTool ?? sdk.createReadToolDefinition;
|
|
159
|
+
let createBashTool = sdk.createBashTool ?? sdk.createBashToolDefinition;
|
|
160
|
+
let createLsTool = sdk.createLsTool ?? sdk.createLsToolDefinition;
|
|
161
|
+
let createFindTool = sdk.createFindTool ?? sdk.createFindToolDefinition;
|
|
162
|
+
let createGrepTool = sdk.createGrepTool ?? sdk.createGrepToolDefinition;
|
|
163
|
+
if (!deps) {
|
|
164
|
+
try {
|
|
165
|
+
// Dynamic import() uses ESM resolution (not CJS interop), so it
|
|
166
|
+
// correctly resolves subpath exports like @earendil-works/pi-ai/base
|
|
167
|
+
// which only have "import" conditions in their exports map.
|
|
168
|
+
const mod = await import("@earendil-works/pi-coding-agent");
|
|
169
|
+
sdk = mod;
|
|
170
|
+
createReadTool = sdk.createReadToolDefinition ?? sdk.createReadTool;
|
|
171
|
+
createBashTool = sdk.createBashToolDefinition ?? sdk.createBashTool;
|
|
172
|
+
createLsTool = sdk.createLsToolDefinition ?? sdk.createLsTool;
|
|
173
|
+
createFindTool = sdk.createFindToolDefinition ?? sdk.createFindTool;
|
|
174
|
+
createGrepTool = sdk.createGrepToolDefinition ?? sdk.createGrepTool;
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
createReadTool = undefined;
|
|
178
|
+
createBashTool = undefined;
|
|
179
|
+
createLsTool = undefined;
|
|
180
|
+
createFindTool = undefined;
|
|
181
|
+
createGrepTool = undefined;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// ------------------------------------------------------------------
|
|
185
|
+
// Tool registration
|
|
186
|
+
// ------------------------------------------------------------------
|
|
187
|
+
if (isToolEnabled("read") && createReadTool) {
|
|
188
|
+
(0, read_js_1.registerReadTool)(pi, cwd, null, createReadTool(cwd), TextComp);
|
|
189
|
+
}
|
|
190
|
+
if (isToolEnabled("bash") && createBashTool) {
|
|
191
|
+
(0, bash_js_1.registerBashTool)(pi, cwd, null, createBashTool(cwd), TextComp);
|
|
192
|
+
}
|
|
193
|
+
if (isToolEnabled("ls") && createLsTool) {
|
|
194
|
+
(0, ls_js_1.registerLsTool)(pi, cwd, null, createLsTool(cwd), TextComp);
|
|
195
|
+
}
|
|
196
|
+
if (isToolEnabled("find") && createFindTool) {
|
|
197
|
+
(0, find_js_1.registerFindTool)(pi, cwd, fffService, createFindTool(cwd), TextComp);
|
|
198
|
+
}
|
|
199
|
+
if (isToolEnabled("grep") && createGrepTool) {
|
|
200
|
+
(0, grep_js_1.registerGrepTool)(pi, cwd, fffService, createGrepTool(cwd), TextComp);
|
|
201
|
+
}
|
|
202
|
+
if (isToolEnabled("multi_grep") && (fffService || createGrepTool)) {
|
|
203
|
+
(0, multi_grep_js_1.registerMultiGrepTool)(pi, cwd, fffService, createGrepTool ? createGrepTool(cwd) : undefined, multiGrepFallback, TextComp);
|
|
204
|
+
}
|
|
205
205
|
// Fallback padding for SDK-rendered tool bodies. The SDK reads
|
|
206
206
|
// result.content[0].text and slices collapsed output to roughly the first
|
|
207
207
|
// 10 lines, so insert bottom padding inside that visible slice.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAsCH,oCAqNC;AAzPD,sBAAsB;AACtB,uCAA8C;AAArC,4GAAA,gBAAgB,OAAA;AAKzB,qCAAsC;AACtC,6CAAmD;AACnD,6CAAmD;AACnD,yCAA+C;AAC/C,6CAAmD;AACnD,6CAAmD;AACnD,yDAA8D;AAC9D,qEAAuE;AACvE,2CAAiD;AACjD,uDAAkE;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AC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,eAAe,GAAG,IAAI,EAAE,CAAC,CAAC;QAChF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAEzC,MAAM,QAAQ,GAAG,sBAAsB,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC7D,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;QAEvE,OAAO;YACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACvF,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heyhuynhgiabuu/pi-pretty",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.12",
|
|
4
4
|
"description": "Pretty terminal output for pi — syntax-highlighted file reads, colored bash output, tree-view directory listings, and more.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi",
|
|
@@ -36,20 +36,20 @@
|
|
|
36
36
|
"test:watch": "vitest --passWithNoTests"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@earendil-works/pi-coding-agent": "^0.75.1",
|
|
40
39
|
"@ff-labs/fff-node": "^0.9.4",
|
|
41
40
|
"@shikijs/cli": "^4.0.2",
|
|
42
41
|
"typebox": "1.1.38"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"@biomejs/biome": "^2.3.5",
|
|
45
|
+
"@earendil-works/pi-ai": "^0.79.9",
|
|
46
46
|
"@earendil-works/pi-tui": "*",
|
|
47
47
|
"@types/node": "^20.0.0",
|
|
48
48
|
"typescript": "^5.0.0",
|
|
49
|
-
"vitest": "^4.0.18"
|
|
49
|
+
"vitest": "^4.0.18",
|
|
50
|
+
"@earendil-works/pi-coding-agent": "^0.79.9"
|
|
50
51
|
},
|
|
51
52
|
"peerDependencies": {
|
|
52
|
-
"@earendil-works/pi-coding-agent": "*",
|
|
53
53
|
"@earendil-works/pi-tui": "*"
|
|
54
54
|
},
|
|
55
55
|
"pi": {
|
package/src/index.ts
CHANGED
|
@@ -12,9 +12,6 @@
|
|
|
12
12
|
// Re-export for tests
|
|
13
13
|
export { __imageInternals } from "./image.js";
|
|
14
14
|
|
|
15
|
-
import { mkdirSync } from "node:fs";
|
|
16
|
-
import { join } from "node:path";
|
|
17
|
-
|
|
18
15
|
import type { ExtensionAPI, ExtensionContext, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
19
16
|
|
|
20
17
|
import type { PiPrettyDeps } from "./types.js";
|
|
@@ -53,56 +50,17 @@ export default async function piPrettyExtension(pi: ExtensionAPI, deps?: PiPrett
|
|
|
53
50
|
const isToolEnabled = (name: string) => !disabledTools.has(name.toLowerCase());
|
|
54
51
|
const cwd = process.cwd();
|
|
55
52
|
|
|
56
|
-
// ------------------------------------------------------------------
|
|
57
|
-
// Resolve SDK tools
|
|
58
|
-
// ------------------------------------------------------------------
|
|
59
|
-
|
|
60
|
-
let sdk: any;
|
|
61
|
-
let createReadTool: any;
|
|
62
|
-
let createBashTool: any;
|
|
63
|
-
let createLsTool: any;
|
|
64
|
-
let createFindTool: any;
|
|
65
|
-
let createGrepTool: any;
|
|
66
|
-
let getAgentDir: (() => string) | undefined;
|
|
67
|
-
|
|
68
|
-
if (deps) {
|
|
69
|
-
sdk = deps.sdk ?? {};
|
|
70
|
-
createReadTool = sdk.createReadTool ?? sdk.createReadToolDefinition;
|
|
71
|
-
createBashTool = sdk.createBashTool ?? sdk.createBashToolDefinition;
|
|
72
|
-
createLsTool = sdk.createLsTool ?? sdk.createLsToolDefinition;
|
|
73
|
-
createFindTool = sdk.createFindTool ?? sdk.createFindToolDefinition;
|
|
74
|
-
createGrepTool = sdk.createGrepTool ?? sdk.createGrepToolDefinition;
|
|
75
|
-
getAgentDir = sdk.getAgentDir;
|
|
76
|
-
} else {
|
|
77
|
-
try {
|
|
78
|
-
// Dynamic import() uses ESM resolution (not CJS interop), so it
|
|
79
|
-
// correctly resolves subpath exports like @earendil-works/pi-ai/base
|
|
80
|
-
// which only have "import" conditions in their exports map.
|
|
81
|
-
const mod = await import("@earendil-works/pi-coding-agent");
|
|
82
|
-
sdk = mod;
|
|
83
|
-
createReadTool = sdk.createReadToolDefinition ?? sdk.createReadTool;
|
|
84
|
-
createBashTool = sdk.createBashToolDefinition ?? sdk.createBashTool;
|
|
85
|
-
createLsTool = sdk.createLsToolDefinition ?? sdk.createLsTool;
|
|
86
|
-
createFindTool = sdk.createFindToolDefinition ?? sdk.createFindTool;
|
|
87
|
-
createGrepTool = sdk.createGrepToolDefinition ?? sdk.createGrepTool;
|
|
88
|
-
} catch {
|
|
89
|
-
return; // pi SDK not available
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (!createReadTool) return;
|
|
94
|
-
|
|
95
53
|
// ------------------------------------------------------------------
|
|
96
54
|
// FFF service init
|
|
97
55
|
// ------------------------------------------------------------------
|
|
56
|
+
// Keep FFF independent from the Pi SDK import. Published extension installs
|
|
57
|
+
// run in Pi's isolated npm root; importing a nested Pi SDK at activation time
|
|
58
|
+
// has proven crash-prone across host Pi versions. FFF commands and indexing
|
|
59
|
+
// should still work even when SDK tool factories are unavailable.
|
|
98
60
|
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
let fffService: FffService | null = new FffService(
|
|
102
|
-
|
|
103
|
-
if (deps?.fffModule) {
|
|
104
|
-
fffService = new FffService(deps.fffModule, agentDir);
|
|
105
|
-
}
|
|
61
|
+
const maybeGetAgentDir = deps?.sdk?.getAgentDir;
|
|
62
|
+
const agentDir = typeof maybeGetAgentDir === "function" ? maybeGetAgentDir() : getDefaultAgentDir();
|
|
63
|
+
let fffService: FffService | null = new FffService(deps?.fffModule, agentDir);
|
|
106
64
|
|
|
107
65
|
// Ripgrep fallback for multi_grep
|
|
108
66
|
const multiGrepFallback = deps?.multiGrepRipgrepFallback ?? runMultiGrepRipgrepFallback;
|
|
@@ -110,36 +68,6 @@ export default async function piPrettyExtension(pi: ExtensionAPI, deps?: PiPrett
|
|
|
110
68
|
// Text component for custom rendering (DI-friendly)
|
|
111
69
|
const TextComp = deps?.TextComponent;
|
|
112
70
|
|
|
113
|
-
// ------------------------------------------------------------------
|
|
114
|
-
// Tool registration
|
|
115
|
-
// ------------------------------------------------------------------
|
|
116
|
-
|
|
117
|
-
if (isToolEnabled("read") && createReadTool) {
|
|
118
|
-
registerReadTool(pi, cwd, null, createReadTool(cwd), TextComp);
|
|
119
|
-
}
|
|
120
|
-
if (isToolEnabled("bash") && createBashTool) {
|
|
121
|
-
registerBashTool(pi, cwd, null, createBashTool(cwd), TextComp);
|
|
122
|
-
}
|
|
123
|
-
if (isToolEnabled("ls") && createLsTool) {
|
|
124
|
-
registerLsTool(pi, cwd, null, createLsTool(cwd), TextComp);
|
|
125
|
-
}
|
|
126
|
-
if (isToolEnabled("find") && createFindTool) {
|
|
127
|
-
registerFindTool(pi, cwd, fffService, createFindTool(cwd), TextComp);
|
|
128
|
-
}
|
|
129
|
-
if (isToolEnabled("grep") && createGrepTool) {
|
|
130
|
-
registerGrepTool(pi, cwd, fffService, createGrepTool(cwd), TextComp);
|
|
131
|
-
}
|
|
132
|
-
if (isToolEnabled("multi_grep") && (fffService || createGrepTool)) {
|
|
133
|
-
registerMultiGrepTool(
|
|
134
|
-
pi,
|
|
135
|
-
cwd,
|
|
136
|
-
fffService,
|
|
137
|
-
createGrepTool ? createGrepTool(cwd) : undefined,
|
|
138
|
-
multiGrepFallback,
|
|
139
|
-
TextComp,
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
71
|
// ------------------------------------------------------------------
|
|
144
72
|
// FFF commands
|
|
145
73
|
// ------------------------------------------------------------------
|
|
@@ -213,13 +141,13 @@ export default async function piPrettyExtension(pi: ExtensionAPI, deps?: PiPrett
|
|
|
213
141
|
pi.on("session_start", async (_event: unknown, ctx: ExtensionContext) => {
|
|
214
142
|
if (!fffService) return;
|
|
215
143
|
|
|
216
|
-
// Try dynamic import if sync require failed
|
|
217
|
-
if (!fffService.isModuleLoaded()) {
|
|
218
|
-
const loaded = await fffService.tryLoadModule();
|
|
219
|
-
if (!loaded) return;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
144
|
try {
|
|
145
|
+
// Try dynamic import if sync require failed
|
|
146
|
+
if (!fffService.isModuleLoaded()) {
|
|
147
|
+
const loaded = await fffService.tryLoadModule();
|
|
148
|
+
if (!loaded) return;
|
|
149
|
+
}
|
|
150
|
+
|
|
223
151
|
await fffService.ensureFinder(ctx.cwd);
|
|
224
152
|
if (fffService.partialIndex) {
|
|
225
153
|
ctx.ui?.notify?.("FFF: scan timed out — using partial index. Run /fff-rescan when ready.", "warning");
|
|
@@ -228,20 +156,88 @@ export default async function piPrettyExtension(pi: ExtensionAPI, deps?: PiPrett
|
|
|
228
156
|
ui?.setStatus?.("fff", "FFF indexed");
|
|
229
157
|
setTimeout(() => ui?.setStatus?.("fff", undefined), 3000);
|
|
230
158
|
}
|
|
159
|
+
|
|
160
|
+
// Register FFF-backed @-mention autocomplete only after a finder exists.
|
|
161
|
+
ctx.ui?.addAutocompleteProvider?.((current) =>
|
|
162
|
+
createFffAutocompleteProvider(current, () => fffService?.getFinder() ?? null),
|
|
163
|
+
);
|
|
231
164
|
} catch (error: unknown) {
|
|
232
165
|
ctx.ui?.notify?.(`FFF init failed: ${error instanceof Error ? error.message : String(error)}`, "error");
|
|
233
166
|
}
|
|
234
|
-
|
|
235
|
-
// Register FFF-backed @-mention autocomplete
|
|
236
|
-
ctx.ui?.addAutocompleteProvider?.((current) =>
|
|
237
|
-
createFffAutocompleteProvider(current, () => fffService?.getFinder() ?? null),
|
|
238
|
-
);
|
|
239
167
|
});
|
|
240
168
|
|
|
241
169
|
pi.on("session_shutdown", async () => {
|
|
242
|
-
|
|
170
|
+
// Intentionally do not destroy the native FFF finder on session shutdown.
|
|
171
|
+
// Pi can emit shutdown/start during resume or session switching while the
|
|
172
|
+
// process keeps running. Native teardown during that transition has caused
|
|
173
|
+
// hard process crashes in published installs; let process exit reclaim it.
|
|
174
|
+
fffService = null;
|
|
243
175
|
});
|
|
244
176
|
|
|
177
|
+
// ------------------------------------------------------------------
|
|
178
|
+
// Resolve SDK tools, if available
|
|
179
|
+
// ------------------------------------------------------------------
|
|
180
|
+
// The SDK import is optional. Do not return from the extension if it fails;
|
|
181
|
+
// FFF commands/indexing above must remain available in published npm installs.
|
|
182
|
+
|
|
183
|
+
let sdk: any = deps?.sdk ?? {};
|
|
184
|
+
let createReadTool: any = sdk.createReadTool ?? sdk.createReadToolDefinition;
|
|
185
|
+
let createBashTool: any = sdk.createBashTool ?? sdk.createBashToolDefinition;
|
|
186
|
+
let createLsTool: any = sdk.createLsTool ?? sdk.createLsToolDefinition;
|
|
187
|
+
let createFindTool: any = sdk.createFindTool ?? sdk.createFindToolDefinition;
|
|
188
|
+
let createGrepTool: any = sdk.createGrepTool ?? sdk.createGrepToolDefinition;
|
|
189
|
+
|
|
190
|
+
if (!deps) {
|
|
191
|
+
try {
|
|
192
|
+
// Dynamic import() uses ESM resolution (not CJS interop), so it
|
|
193
|
+
// correctly resolves subpath exports like @earendil-works/pi-ai/base
|
|
194
|
+
// which only have "import" conditions in their exports map.
|
|
195
|
+
const mod = await import("@earendil-works/pi-coding-agent");
|
|
196
|
+
sdk = mod;
|
|
197
|
+
createReadTool = sdk.createReadToolDefinition ?? sdk.createReadTool;
|
|
198
|
+
createBashTool = sdk.createBashToolDefinition ?? sdk.createBashTool;
|
|
199
|
+
createLsTool = sdk.createLsToolDefinition ?? sdk.createLsTool;
|
|
200
|
+
createFindTool = sdk.createFindToolDefinition ?? sdk.createFindTool;
|
|
201
|
+
createGrepTool = sdk.createGrepToolDefinition ?? sdk.createGrepTool;
|
|
202
|
+
} catch {
|
|
203
|
+
createReadTool = undefined;
|
|
204
|
+
createBashTool = undefined;
|
|
205
|
+
createLsTool = undefined;
|
|
206
|
+
createFindTool = undefined;
|
|
207
|
+
createGrepTool = undefined;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// ------------------------------------------------------------------
|
|
212
|
+
// Tool registration
|
|
213
|
+
// ------------------------------------------------------------------
|
|
214
|
+
|
|
215
|
+
if (isToolEnabled("read") && createReadTool) {
|
|
216
|
+
registerReadTool(pi, cwd, null, createReadTool(cwd), TextComp);
|
|
217
|
+
}
|
|
218
|
+
if (isToolEnabled("bash") && createBashTool) {
|
|
219
|
+
registerBashTool(pi, cwd, null, createBashTool(cwd), TextComp);
|
|
220
|
+
}
|
|
221
|
+
if (isToolEnabled("ls") && createLsTool) {
|
|
222
|
+
registerLsTool(pi, cwd, null, createLsTool(cwd), TextComp);
|
|
223
|
+
}
|
|
224
|
+
if (isToolEnabled("find") && createFindTool) {
|
|
225
|
+
registerFindTool(pi, cwd, fffService, createFindTool(cwd), TextComp);
|
|
226
|
+
}
|
|
227
|
+
if (isToolEnabled("grep") && createGrepTool) {
|
|
228
|
+
registerGrepTool(pi, cwd, fffService, createGrepTool(cwd), TextComp);
|
|
229
|
+
}
|
|
230
|
+
if (isToolEnabled("multi_grep") && (fffService || createGrepTool)) {
|
|
231
|
+
registerMultiGrepTool(
|
|
232
|
+
pi,
|
|
233
|
+
cwd,
|
|
234
|
+
fffService,
|
|
235
|
+
createGrepTool ? createGrepTool(cwd) : undefined,
|
|
236
|
+
multiGrepFallback,
|
|
237
|
+
TextComp,
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
245
241
|
// Fallback padding for SDK-rendered tool bodies. The SDK reads
|
|
246
242
|
// result.content[0].text and slices collapsed output to roughly the first
|
|
247
243
|
// 10 lines, so insert bottom padding inside that visible slice.
|