@tmustier/pi-files-widget 0.1.19 → 0.1.21
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 +13 -0
- package/README.md +2 -14
- package/browser.ts +2 -2
- package/demo.svg +1 -1
- package/file-viewer.ts +1 -1
- package/index.ts +3 -58
- package/input-utils.ts +1 -1
- package/package.json +7 -3
- package/viewer.ts +2 -2
package/file-viewer.ts
CHANGED
package/index.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pi Editor Extension
|
|
3
3
|
*
|
|
4
|
-
* Provides an in-terminal file browser
|
|
5
|
-
* Use /
|
|
4
|
+
* Provides an in-terminal file browser and viewer.
|
|
5
|
+
* Use /readfiles to open the file browser, navigate with j/k, Enter to view.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { ExtensionAPI } from "@
|
|
9
|
-
import { execSync, spawnSync } from "node:child_process";
|
|
8
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
10
9
|
import { join } from "node:path";
|
|
11
10
|
|
|
12
11
|
import { createFileBrowser } from "./browser";
|
|
@@ -70,60 +69,6 @@ export default function editorExtension(pi: ExtensionAPI): void {
|
|
|
70
69
|
},
|
|
71
70
|
});
|
|
72
71
|
|
|
73
|
-
pi.registerCommand("readfiles-review", {
|
|
74
|
-
description: "Open tuicr to review changes and send feedback to agent",
|
|
75
|
-
handler: async (_args, ctx) => {
|
|
76
|
-
if (!hasCommand("tuicr")) {
|
|
77
|
-
ctx.ui.notify("Install tuicr: brew install agavra/tap/tuicr", "error");
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
ctx.ui.notify("Opening tuicr... Press :wq or y to copy review", "info");
|
|
82
|
-
|
|
83
|
-
try {
|
|
84
|
-
spawnSync("tuicr", [], { cwd, stdio: "inherit" });
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
const clipboard = execSync(
|
|
88
|
-
process.platform === "darwin" ? "pbpaste" : "xclip -selection clipboard -o",
|
|
89
|
-
{ encoding: "utf-8", timeout: 5000 }
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
if (
|
|
93
|
-
clipboard.includes("## Review") ||
|
|
94
|
-
clipboard.includes("```") ||
|
|
95
|
-
clipboard.includes("[Issue]") ||
|
|
96
|
-
clipboard.includes("[Suggestion]")
|
|
97
|
-
) {
|
|
98
|
-
pi.sendUserMessage(clipboard, { deliverAs: "steer" });
|
|
99
|
-
ctx.ui.notify("Review sent to agent", "success");
|
|
100
|
-
}
|
|
101
|
-
} catch {}
|
|
102
|
-
} catch (e: any) {
|
|
103
|
-
ctx.ui.notify(`tuicr error: ${e.message}`, "error");
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
pi.registerCommand("readfiles-diff", {
|
|
109
|
-
description: "Open critique to view diffs",
|
|
110
|
-
handler: async (args, ctx) => {
|
|
111
|
-
if (!hasCommand("bun")) {
|
|
112
|
-
ctx.ui.notify("critique requires Bun: brew install oven-sh/bun/bun", "error");
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const critiqueArgs = args ? args.split(" ") : [];
|
|
117
|
-
ctx.ui.notify("Opening critique...", "info");
|
|
118
|
-
|
|
119
|
-
try {
|
|
120
|
-
spawnSync("bunx", ["critique", ...critiqueArgs], { cwd, stdio: "inherit" });
|
|
121
|
-
} catch (e: any) {
|
|
122
|
-
ctx.ui.notify(`critique error: ${e.message}`, "error");
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
|
|
127
72
|
pi.on("tool_result", async (event) => {
|
|
128
73
|
if (event.toolName === "write" || event.toolName === "edit") {
|
|
129
74
|
const filePath = event.input?.path as string | undefined;
|
package/input-utils.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmustier/pi-files-widget",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "In-terminal file browser and viewer for Pi.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Thomas Mustier",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"bugs": "https://github.com/tmustier/pi-extensions/issues",
|
|
16
16
|
"homepage": "https://github.com/tmustier/pi-extensions/tree/main/files-widget",
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@
|
|
19
|
-
"@
|
|
18
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
19
|
+
"@earendil-works/pi-tui": "*"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"postinstall": "node -e \"console.log('pi-files-widget: required deps: bat, delta, glow. Install with: brew install bat git-delta glow')\""
|
|
@@ -26,5 +26,9 @@
|
|
|
26
26
|
"index.ts"
|
|
27
27
|
],
|
|
28
28
|
"video": "https://raw.githubusercontent.com/tmustier/pi-extensions/main/files-widget/demo.mp4"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@earendil-works/pi-coding-agent": "^0.74.0",
|
|
32
|
+
"@earendil-works/pi-tui": "^0.74.0"
|
|
29
33
|
}
|
|
30
34
|
}
|
package/viewer.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Theme } from "@
|
|
2
|
-
import { Key, matchesKey, truncateToWidth, wrapTextWithAnsi } from "@
|
|
1
|
+
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { Key, matchesKey, truncateToWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
3
3
|
import { readFileSync, statSync } from "node:fs";
|
|
4
4
|
import { relative } from "node:path";
|
|
5
5
|
|