pi-tui-footer 1.2.8 → 1.2.9
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 +2 -2
- package/extensions/rounded-tools.ts +14 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,9 +45,9 @@ pi update --extensions
|
|
|
45
45
|
|
|
46
46
|
### 圆角工具框与第三方工具
|
|
47
47
|
|
|
48
|
-
`roundedTools`
|
|
48
|
+
`roundedTools` 会为 Pi 内置工具(read、write、edit、bash、powershell、grep、find、ls)添加圆角边框。第三方扩展注册的自定义工具不会自动添加圆角边框。
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
若第三方扩展会覆盖同名内置工具,请在 `~/.pi/agent/settings.json` 的 `packages` 中将 `pi-tui-footer` 放在该扩展之后。Pi 按扩展加载顺序处理同名工具,先注册的定义生效;此顺序可保留第三方工具的执行实现:
|
|
51
51
|
|
|
52
52
|
```json
|
|
53
53
|
{
|
|
@@ -47,6 +47,7 @@ export class RoundedFrame implements Component {
|
|
|
47
47
|
private inner: Component,
|
|
48
48
|
private border: (text: string) => string,
|
|
49
49
|
private mode: FrameMode = "closed",
|
|
50
|
+
private colorKey: string = "border",
|
|
50
51
|
) {}
|
|
51
52
|
|
|
52
53
|
getInner(): Component {
|
|
@@ -64,10 +65,16 @@ export class RoundedFrame implements Component {
|
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
update(
|
|
68
|
-
|
|
68
|
+
update(
|
|
69
|
+
inner: Component,
|
|
70
|
+
border: (text: string) => string,
|
|
71
|
+
mode: FrameMode,
|
|
72
|
+
colorKey: string,
|
|
73
|
+
): this {
|
|
74
|
+
if (this.inner !== inner || this.mode !== mode || this.colorKey !== colorKey) {
|
|
69
75
|
this.inner = inner;
|
|
70
76
|
this.mode = mode;
|
|
77
|
+
this.colorKey = colorKey;
|
|
71
78
|
this.invalidate();
|
|
72
79
|
}
|
|
73
80
|
this.border = border;
|
|
@@ -169,7 +176,7 @@ const frame = (
|
|
|
169
176
|
theme: { fg: (color: string, text: string) => string },
|
|
170
177
|
mode: FrameMode = "closed",
|
|
171
178
|
colorKey: string = "border",
|
|
172
|
-
): RoundedFrame => new RoundedFrame(inner, (t) => theme.fg(colorKey, t), mode);
|
|
179
|
+
): RoundedFrame => new RoundedFrame(inner, (t) => theme.fg(colorKey, t), mode, colorKey);
|
|
173
180
|
|
|
174
181
|
function borderColorFor(
|
|
175
182
|
context: { isPartial?: boolean; isError?: boolean } | undefined,
|
|
@@ -215,7 +222,7 @@ export function wrapBuiltin(def: ToolDef): ToolDef {
|
|
|
215
222
|
|
|
216
223
|
let callFrame: RoundedFrame;
|
|
217
224
|
if (context?.lastComponent instanceof RoundedFrame) {
|
|
218
|
-
callFrame = context.lastComponent.update(inner, borderFn, mode);
|
|
225
|
+
callFrame = context.lastComponent.update(inner, borderFn, mode, borderColorFor(context));
|
|
219
226
|
} else {
|
|
220
227
|
callFrame = frame(inner, theme, mode, borderColorFor(context));
|
|
221
228
|
}
|
|
@@ -242,7 +249,7 @@ export function wrapBuiltin(def: ToolDef): ToolDef {
|
|
|
242
249
|
const borderFn = (t: string) => theme.fg(borderColorFor(context), t);
|
|
243
250
|
|
|
244
251
|
if (context?.lastComponent instanceof RoundedFrame) {
|
|
245
|
-
return context.lastComponent.update(inner, borderFn, "open-top");
|
|
252
|
+
return context.lastComponent.update(inner, borderFn, "open-top", borderColorFor(context));
|
|
246
253
|
}
|
|
247
254
|
return frame(inner, theme, "open-top", borderColorFor(context));
|
|
248
255
|
},
|
|
@@ -273,7 +280,7 @@ export function registerRoundedTools(
|
|
|
273
280
|
if (typeof target !== "function" && target.getActiveTools) {
|
|
274
281
|
try {
|
|
275
282
|
const active = target.getActiveTools();
|
|
276
|
-
if (Array.isArray(active)
|
|
283
|
+
if (Array.isArray(active)) {
|
|
277
284
|
activeToolNames = new Set(active);
|
|
278
285
|
}
|
|
279
286
|
} catch {
|
|
@@ -287,7 +294,7 @@ export function registerRoundedTools(
|
|
|
287
294
|
write: () => createWriteToolDefinition(cwd),
|
|
288
295
|
edit: () => createEditToolDefinition(cwd),
|
|
289
296
|
bash: () => createBashToolDefinition(cwd, { commandPrefix: shellCommandPrefix, shellPath }),
|
|
290
|
-
powershell: () => createPowerShellToolDefinition(cwd
|
|
297
|
+
powershell: () => createPowerShellToolDefinition(cwd),
|
|
291
298
|
ls: () => createLsToolDefinition(cwd),
|
|
292
299
|
grep: () => createGrepToolDefinition(cwd),
|
|
293
300
|
find: () => createFindToolDefinition(cwd),
|