@xynogen/pix-find 0.2.1 → 0.2.3
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 +2 -2
- package/src/find.test.ts +14 -9
- package/src/find.ts +8 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xynogen/pix-find",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Pi tool — glob file search",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@xynogen/pix-pretty": "^1.
|
|
41
|
+
"@xynogen/pix-pretty": "^1.19.0",
|
|
42
42
|
"@xynogen/pix-runtime": "^0.8.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
package/src/find.test.ts
CHANGED
|
@@ -33,6 +33,10 @@ class MockTextComponent {
|
|
|
33
33
|
getText() {
|
|
34
34
|
return this.text;
|
|
35
35
|
}
|
|
36
|
+
render(_width?: number) {
|
|
37
|
+
return this.text.split("\n");
|
|
38
|
+
}
|
|
39
|
+
invalidate() {}
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
describe("applyFindDefaults", () => {
|
|
@@ -233,17 +237,18 @@ describe("registerFindTool", () => {
|
|
|
233
237
|
matchCount: 0,
|
|
234
238
|
},
|
|
235
239
|
};
|
|
236
|
-
const render = (state: Record<string, unknown>, expanded = false) =>
|
|
237
|
-
registered
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
240
|
+
const render = (state: Record<string, unknown>, expanded = false) => {
|
|
241
|
+
const component = registered.renderResult?.(result, { isPartial: false }, theme, {
|
|
242
|
+
expanded,
|
|
243
|
+
isError: true,
|
|
244
|
+
invalidate: () => {},
|
|
245
|
+
state,
|
|
246
|
+
} as unknown as RenderContextLike);
|
|
247
|
+
return component?.render(120).join("\n") ?? "";
|
|
248
|
+
};
|
|
245
249
|
|
|
246
250
|
expect(render({ timer: 1 })).toContain(diagnostic);
|
|
251
|
+
expect(render({ timer: 1 })).toContain("─");
|
|
247
252
|
expect(render({ collapsed: true })).toContain("✗ find [ in src · failed");
|
|
248
253
|
expect(render({ collapsed: true }, true)).toContain(diagnostic);
|
|
249
254
|
});
|
package/src/find.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
import {
|
|
18
18
|
appendNotices,
|
|
19
19
|
fillToolBackground,
|
|
20
|
+
frameToolResult,
|
|
20
21
|
getTextContent,
|
|
21
22
|
hideCollapsedToolCall,
|
|
22
23
|
makeTextResult,
|
|
@@ -25,6 +26,7 @@ import {
|
|
|
25
26
|
renderDimPreview,
|
|
26
27
|
renderToolError,
|
|
27
28
|
setResultDetails,
|
|
29
|
+
unframeToolResult,
|
|
28
30
|
} from "@xynogen/pix-pretty/utils";
|
|
29
31
|
import { type CollapseState, tickCollapse } from "@xynogen/pix-runtime/collapse";
|
|
30
32
|
|
|
@@ -157,7 +159,7 @@ export function registerFindTool(
|
|
|
157
159
|
return text;
|
|
158
160
|
text.setText(
|
|
159
161
|
fillToolBackground(
|
|
160
|
-
`${theme.fg("toolTitle", theme.bold("find"))} ${theme.fg("
|
|
162
|
+
`${theme.fg("toolTitle", theme.bold("find"))} ${theme.fg("dim", pattern)}${path}`,
|
|
161
163
|
),
|
|
162
164
|
);
|
|
163
165
|
return text;
|
|
@@ -170,14 +172,15 @@ export function registerFindTool(
|
|
|
170
172
|
renderCtx: RenderContextLike,
|
|
171
173
|
) {
|
|
172
174
|
resolveBaseBackground(theme);
|
|
173
|
-
const text = renderCtx.lastComponent ?? new TextComponent("", 0, 0);
|
|
175
|
+
const text = unframeToolResult(renderCtx.lastComponent ?? new TextComponent("", 0, 0));
|
|
174
176
|
const d = result.details;
|
|
175
177
|
const isPartial = _opt?.isPartial === true;
|
|
178
|
+
const completed = () => frameToolResult(text, theme, renderCtx.isError);
|
|
176
179
|
const structuredError = renderCtx.isError && d?._type === "findResult";
|
|
177
180
|
|
|
178
181
|
if (renderCtx.isError && (!structuredError || isPartial)) {
|
|
179
182
|
text.setText(renderToolError(getTextContent(result) || "Error", theme));
|
|
180
|
-
return text;
|
|
183
|
+
return isPartial ? text : completed();
|
|
181
184
|
}
|
|
182
185
|
|
|
183
186
|
// Auto-collapse: show summary line after delay
|
|
@@ -203,14 +206,14 @@ export function registerFindTool(
|
|
|
203
206
|
|
|
204
207
|
if (renderCtx.isError) {
|
|
205
208
|
text.setText(renderToolError(getTextContent(result) || "Error", theme));
|
|
206
|
-
return
|
|
209
|
+
return completed();
|
|
207
210
|
}
|
|
208
211
|
|
|
209
212
|
const output = getTextContent(result) || "found";
|
|
210
213
|
// One framed shape; rules follow status color. Count lives in the collapsed row.
|
|
211
214
|
text.setText(
|
|
212
215
|
renderDimPreview(output, theme, {
|
|
213
|
-
frame:
|
|
216
|
+
frame: !isPartial,
|
|
214
217
|
paint: (s: string) => theme.fg(renderCtx.isError ? "error" : "success", s),
|
|
215
218
|
highlight: d?._type === "findResult" ? globHighlight(d.pattern) : undefined,
|
|
216
219
|
}),
|