repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

feat(open): open mentioned files beside Pi

ce496d6ddff10911590dfa1202dfbff1aefda571

Oliver Krylow <o.krylow@isp-insoft.de> ·

SSH signature · not checked

Browse filesCompare with HEAD

Changed files (7)

+835 / −0 text lines

Diff layout

README.md

Modified

+1 / −0 text lines

8484| `neko` | Tiny animated editor cat for Pi. Pointless. Correct. | [README](extensions/neko/README.md) |
8585| `notes` | Session-backed pending prompt notes for Pi. | [README](extensions/notes/README.md) |
8686| `nu-bang` | Nushell bang-command bridge for Pi. | [README](extensions/nu-bang/README.md) |
87| `open` | Open mentioned files in Neovim beside Pi. | [README](extensions/open/README.md) |
8788| `prompt-autopsy` | System-prompt autopsy command for Pi. | [README](extensions/prompt-autopsy/README.md) |
8889| `pulse` | Living documentation sync for Pi. | [README](extensions/pulse/README.md) |
8990| `quota` | Subscription quota dashboard for Pi providers. | [README](extensions/quota/README.md) |

extensions/open/README.md

Added
new file mode 100644

+36 / −0 text lines

1# open
2
3Open mentioned files in Neovim beside Pi.
4
5## Install / load
6
7Loaded through the root `pi-ext` package.
8See [root README](../../README.md).
9
10## Commands / tools / settings
12Commands:
14- `/open PATH` opens an existing file directly.
15- `/open` opens the sole recent file or a fuzzy picker for multiple files.
17Tools:
18none.
20Hooks:
22- `session_start` reports missing WezTerm, `$EDITOR`, or pane context.
24Settings:
25none.
27## Behavior
29`/open` reads the current session branch when invoked.
30It ranks existing file mentions by source: user, assistant, edit, then write.
31Paths are deduplicated and limited to 20.
32The picker keeps paths prominent and shows the source as its description.
34The selected file opens through `$EDITOR` in a new right-hand WezTerm split using 69 percent of Pi's pane.
35The editor starts in the project root and receives an absolute file path.
36Launch is asynchronous; the pane closes when the editor exits.

extensions/open/__tests__/harness.test.ts

Added
new file mode 100644

+287 / −0 text lines

1import {
2 chmodSync,
3 copyFileSync,
4 mkdirSync,
5 mkdtempSync,
6 readFileSync,
7 rmSync,
8 writeFileSync,
9} from "node:fs";
10import { tmpdir } from "node:os";
11import { delimiter, join } from "node:path";
12import { afterEach, describe, expect, it } from "vitest";
13import { createTestSession, type TestSession } from "../../../test/harness";
14import openExtension, { __test, type FileCandidate } from "../index.ts";
16const roots: string[] = [];
17let session: TestSession | undefined;
19function tempRoot(): string {
20 const root = mkdtempSync(join(tmpdir(), "pi-open-test-"));
21 roots.push(root);
22 return root;
23}
25function file(root: string, path: string): string {
26 const absolute = join(root, path);
27 mkdirSync(join(absolute, ".."), { recursive: true });
28 writeFileSync(absolute, path);
29 return absolute;
30}
32function entry(message: unknown): unknown {
33 return { type: "message", message };
34}
36function fakeExecutable(bin: string, name: string): string {
37 const path = join(bin, process.platform === "win32" ? `${name}.exe` : name);
38 copyFileSync(process.execPath, path);
39 if (process.platform !== "win32") chmodSync(path, 0o700);
40 return path;
41}
43async function linesEventually(path: string, count: number): Promise<string[]> {
44 for (let attempt = 0; attempt < 100; attempt++) {
45 try {
46 const lines = readFileSync(path, "utf8").trim().split("\n");
47 if (lines.length >= count) return lines;
48 } catch {}
49 await new Promise((resolveWait) => setTimeout(resolveWait, 10));
50 }
51 throw new Error(`Timed out waiting for ${path}`);
52}
54afterEach(() => {
55 session?.dispose();
56 session = undefined;
57 for (const root of roots.splice(0))
58 rmSync(root, {
59 recursive: true,
60 force: true,
61 maxRetries: 10,
62 retryDelay: 20,
63 });
64});
66describe("open candidates", () => {
67 it("extracts existing path forms", () => {
68 const root = tempRoot();
69 const markdown = file(root, "docs/with space.md");
70 const backtick = file(root, "src/backtick.ts");
71 const atPath = file(root, "TODO.md");
72 const plain = file(root, "plain.json");
74 expect(
75 __test.extractTextPaths(
76 "plain.json then `src/backtick.ts`, @TODO.md, and [docs](docs/with space.md); missing.ts",
77 root,
78 ),
79 ).toEqual([plain, backtick, atPath, markdown]);
80 });
82 it("ranks source first, recency second, and deduplicates paths", () => {
83 const root = tempRoot();
84 const userOld = file(root, "user-old.ts");
85 const userNew = file(root, "user-new.ts");
86 const assistant = file(root, "assistant.ts");
87 const edited = file(root, "edited.ts");
88 const written = file(root, "written.ts");
89 const entries = [
90 entry({ role: "user", content: "@user-old.ts" }),
91 entry({
92 role: "assistant",
93 content: [
94 { type: "text", text: "`assistant.ts` and `user-new.ts`" },
95 {
96 type: "toolCall",
97 name: "write",
98 arguments: { path: "written.ts" },
99 },
100 { type: "toolCall", name: "edit", arguments: { path: "edited.ts" } },
101 ],
102 }),
103 entry({ role: "user", content: "Use @user-new.ts" }),
104 ];
106 expect(__test.collectCandidates(entries, root)).toEqual([
107 { path: userNew, displayPath: "user-new.ts", source: "user" },
108 { path: userOld, displayPath: "user-old.ts", source: "user" },
109 { path: assistant, displayPath: "assistant.ts", source: "assistant" },
110 { path: edited, displayPath: "edited.ts", source: "edit" },
111 { path: written, displayPath: "written.ts", source: "write" },
112 ]);
113 });
115 it("limits scanning to the 20 newest existing files", () => {
116 const root = tempRoot();
117 const entries = Array.from({ length: 25 }, (_, index) => {
118 const name = `file-${index}.ts`;
119 file(root, name);
120 return entry({ role: "user", content: `@${name}` });
121 });
123 const candidates = __test.collectCandidates(entries, root);
124 expect(candidates).toHaveLength(20);
125 expect(candidates[0]?.displayPath).toBe("file-24.ts");
126 expect(candidates.at(-1)?.displayPath).toBe("file-5.ts");
127 });
129 it("fuzzy-picks by path while keeping the path prominent", async () => {
130 const candidates: FileCandidate[] = [
131 { path: "/a/other.ts", displayPath: "src/other.ts", source: "user" },
132 {
133 path: "/a/about-this.ts",
134 displayPath: "src/about-this.ts",
135 source: "assistant",
136 },
137 ];
138 let rows: string[] = [];
139 const selected = await __test.chooseCandidate(candidates, {
140 mode: "tui",
141 ui: {
142 custom: async (factory: any) => {
143 let result: string | undefined;
144 const component = await factory(
145 { requestRender() {} },
146 { fg: (_color: string, text: string) => text },
147 {
148 matches: (data: string, action: string) =>
149 action === "tui.select.confirm" && data === "\r",
150 },
151 (value: string | undefined) => {
152 result = value;
153 },
154 );
155 for (const key of ["a", "b", "t"]) component.handleInput(key);
156 rows = component.render(120);
157 component.handleInput("\r");
158 return result;
159 },
160 },
161 } as any);
163 expect(selected).toEqual(candidates[1]);
164 expect(rows.join("\n")).toContain("src/about-this.ts");
165 });
167 it("uses the standard selector outside TUI mode", async () => {
168 const candidates: FileCandidate[] = [
169 { path: "/a/one.ts", displayPath: "one.ts", source: "user" },
170 { path: "/a/two.ts", displayPath: "two.ts", source: "assistant" },
171 ];
172 const selected = await __test.chooseCandidate(candidates, {
173 mode: "rpc",
174 ui: { select: async () => "two.ts" },
175 } as any);
177 expect(selected).toEqual(candidates[1]);
178 });
179});
181describe("open extension", () => {
182 it("launches explicit and sole-mentioned files through a detached WezTerm split", async () => {
183 const root = tempRoot();
184 const bin = join(root, "bin");
185 mkdirSync(bin);
186 const wezterm = fakeExecutable(bin, "wezterm");
187 const editor = fakeExecutable(bin, "nvim");
188 const marker = join(root, "launches.jsonl");
189 const preload = join(root, "record.cjs");
190 writeFileSync(
191 preload,
192 `require("node:fs").appendFileSync(${JSON.stringify(marker)}, JSON.stringify(process.argv.slice(1)) + "\\n"); process.exit(0);\n`,
193 );
194 const explicit = file(root, "explicit file.ts");
195 const mentioned = file(root, "mentioned.ts");
196 session = await createTestSession({
197 cwd: root,
198 extensionFactories: [openExtension],
199 env: {
200 PATH: `${bin}${delimiter}${process.env.PATH ?? ""}`,
201 EDITOR: "nvim",
202 WEZTERM_PANE: "7",
203 NODE_OPTIONS: `--require=${preload}`,
204 },
205 });
206 const extension = session.session.extensionRunner.extensions[0];
207 const command = extension.commands.get("open");
208 const context = session.session.extensionRunner.createCommandContext();
209 expect(command).toBeDefined();
211 await command.handler('"explicit file.ts"', context);
212 session.session.sessionManager.appendMessage({
213 role: "user",
214 content: "Check @mentioned.ts",
215 timestamp: Date.now(),
216 });
217 await command.handler("", context);
219 const launches = (await linesEventually(marker, 2)).map((line) =>
220 JSON.parse(line),
221 );
222 const prefix = [
223 join(root, "cli"),
224 "split-pane",
225 "--pane-id",
226 "7",
227 "--right",
228 "--percent",
229 "69",
230 "--cwd",
231 root,
232 "--",
233 editor,
234 ];
235 expect(launches).toEqual([
236 [...prefix, explicit],
237 [...prefix, mentioned],
238 ]);
239 expect(wezterm).toContain("wezterm");
240 });
242 it("warns when its required host context is unavailable", async () => {
243 const root = tempRoot();
244 session = await createTestSession({
245 cwd: root,
246 extensionFactories: [openExtension],
247 env: { PATH: "", EDITOR: undefined, WEZTERM_PANE: undefined },
248 });
250 expect(
251 session.events.uiCallsFor("notify").map((call) => call.args),
252 ).toEqual([
253 ["/open: wezterm is not on PATH", "warning"],
254 ["/open: EDITOR is not set", "warning"],
255 ["/open: WEZTERM_PANE is not set", "warning"],
256 ]);
257 });
259 it("reports missing files without launching", async () => {
260 const root = tempRoot();
261 const bin = join(root, "bin");
262 mkdirSync(bin);
263 fakeExecutable(bin, "wezterm");
264 fakeExecutable(bin, "nvim");
265 session = await createTestSession({
266 cwd: root,
267 extensionFactories: [openExtension],
268 env: {
269 PATH: bin,
270 EDITOR: "nvim",
271 WEZTERM_PANE: "7",
272 },
273 });
274 const extension = session.session.extensionRunner.extensions[0];
275 await extension.commands
276 .get("open")
277 .handler(
278 "missing.ts",
279 session.session.extensionRunner.createCommandContext(),
280 );
282 expect(session.events.uiCallsFor("notify").at(-1)?.args).toEqual([
283 "Not a file: missing.ts",
284 "error",
285 ]);
286 });
287});

extensions/open/index.ts

Added
new file mode 100644

+444 / −0 text lines

1import { spawn } from "node:child_process";
2import { accessSync, constants, statSync } from "node:fs";
3import {
4 delimiter,
5 extname,
6 isAbsolute,
7 join,
8 relative,
9 resolve,
10 sep,
11} from "node:path";
12import type {
13 ExtensionAPI,
14 ExtensionContext,
15 SessionEntry,
16} from "@earendil-works/pi-coding-agent";
17import {
18 Container,
19 fuzzyFilter,
20 Input,
21 SelectList,
22} from "@earendil-works/pi-tui";
24const MAX_CANDIDATES = 20;
25const SOURCE_ORDER = ["user", "assistant", "edit", "write"] as const;
26const SPLIT_PERCENT = "69";
28type CandidateSource = (typeof SOURCE_ORDER)[number];
30export interface FileCandidate {
31 path: string;
32 displayPath: string;
33 source: CandidateSource;
34}
36function envValue(
37 env: NodeJS.ProcessEnv,
38 key: string,
39 platform: NodeJS.Platform,
40): string | undefined {
41 if (platform !== "win32") return env[key];
42 const actual = Object.keys(env).find(
43 (candidate) => candidate.toLowerCase() === key.toLowerCase(),
44 );
45 return actual ? env[actual] : undefined;
46}
48function executableNames(command: string, platform: NodeJS.Platform): string[] {
49 if (platform !== "win32" || extname(command)) return [command];
50 return [command, `${command}.exe`, `${command}.com`];
51}
53function executableOnPath(
54 command: string,
55 env: NodeJS.ProcessEnv = process.env,
56 platform: NodeJS.Platform = process.platform,
57): string | undefined {
58 const pathValue = envValue(env, "PATH", platform);
59 const directories =
60 command.includes("/") || command.includes("\\")
61 ? [""]
62 : (pathValue ?? "").split(delimiter).filter(Boolean);
63 for (const directory of directories) {
64 for (const name of executableNames(command, platform)) {
65 const candidate = directory
66 ? join(directory.replace(/^"|"$/gu, ""), name)
67 : resolve(name);
68 try {
69 accessSync(
70 candidate,
71 platform === "win32" ? constants.F_OK : constants.X_OK,
72 );
73 if (statSync(candidate).isFile()) return candidate;
74 } catch {
75 // Keep searching PATH.
76 }
77 }
78 }
79 return undefined;
80}
82function existingFile(rawPath: string, cwd: string): string | undefined {
83 const trimmed = rawPath.trim().replace(/^(["'])(.*)\1$/u, "$2");
84 if (!trimmed) return undefined;
85 const path = resolve(cwd, trimmed);
86 try {
87 return statSync(path).isFile() ? path : undefined;
88 } catch {
89 return undefined;
90 }
91}
93function displayPath(path: string, cwd: string): string {
94 const local = relative(cwd, path);
95 return local && !local.startsWith(`..${sep}`) && !isAbsolute(local)
96 ? local
97 : path;
98}
100function pathLike(token: string): boolean {
101 return (
102 token.includes("/") ||
103 token.includes("\\") ||
104 token.startsWith(".") ||
105 /^[^\s.][^/\\\s]*\.[A-Za-z0-9_-]+$/u.test(token)
106 );
107}
109function trimToken(token: string): string {
110 return token
111 .trim()
112 .replace(/^[@`'"<([{]+/u, "")
113 .replace(/[`'">)\]},;!?]+$/u, "")
114 .replace(/[.:]+$/u, "");
115}
117function extractTextPaths(text: string, cwd: string): string[] {
118 const raw: Array<{ value: string; structured: boolean; index: number }> = [];
119 for (const match of text.matchAll(/\]\(([^)\n]+)\)/gu)) {
120 raw.push({ value: match[1], structured: true, index: match.index });
121 }
122 for (const match of text.matchAll(/`([^`\n]+)`/gu)) {
123 raw.push({ value: match[1], structured: true, index: match.index });
124 }
125 for (const match of text.matchAll(/\S+/gu)) {
126 raw.push({ value: match[0], structured: false, index: match.index });
127 }
128 raw.sort(
129 (left, right) =>
130 left.index - right.index ||
131 Number(right.structured) - Number(left.structured),
132 );
134 const paths: string[] = [];
135 const seen = new Set<string>();
136 for (const item of raw) {
137 const token = trimToken(item.value);
138 if (!token || (!item.structured && !pathLike(token))) continue;
139 const path = existingFile(token, cwd);
140 if (!path || seen.has(path)) continue;
141 seen.add(path);
142 paths.push(path);
143 }
144 return paths;
145}
147function textFromContent(content: unknown): string[] {
148 if (typeof content === "string") return [content];
149 if (!Array.isArray(content)) return [];
150 return content.flatMap((part) =>
151 part &&
152 typeof part === "object" &&
153 "type" in part &&
154 part.type === "text" &&
155 "text" in part &&
156 typeof part.text === "string"
157 ? [part.text]
158 : [],
159 );
160}
162function toolPath(
163 block: unknown,
164): { source: "edit" | "write"; path: string } | undefined {
165 if (!block || typeof block !== "object" || !("type" in block))
166 return undefined;
167 if (block.type !== "toolCall" || !("name" in block)) return undefined;
168 if (block.name !== "edit" && block.name !== "write") return undefined;
169 if (
170 !("arguments" in block) ||
171 !block.arguments ||
172 typeof block.arguments !== "object"
173 )
174 return undefined;
175 if (!("path" in block.arguments) || typeof block.arguments.path !== "string")
176 return undefined;
177 return { source: block.name, path: block.arguments.path };
178}
180function collectCandidates(
181 entries: readonly SessionEntry[] | readonly unknown[],
182 cwd: string,
183): FileCandidate[] {
184 const buckets = new Map(
185 SOURCE_ORDER.map((source) => [source, new Map<string, FileCandidate>()]),
186 );
187 const found = new Set<string>();
188 const add = (path: string, source: CandidateSource): void => {
189 const bucket = buckets.get(source);
190 if (!bucket || bucket.has(path)) return;
191 bucket.set(path, { path, displayPath: displayPath(path, cwd), source });
192 found.add(path);
193 };
195 for (let index = entries.length - 1; index >= 0; index--) {
196 const entry = entries[index];
197 if (!entry || typeof entry !== "object" || !("type" in entry)) continue;
198 if (entry.type !== "message" || !("message" in entry)) continue;
199 const message = entry.message;
200 if (!message || typeof message !== "object" || !("role" in message))
201 continue;
202 if (message.role === "user" && "content" in message) {
203 for (const text of textFromContent(message.content).toReversed()) {
204 for (const path of extractTextPaths(text, cwd).toReversed())
205 add(path, "user");
206 }
207 if (found.size >= MAX_CANDIDATES) break;
208 continue;
209 }
210 if (message.role !== "assistant" || !("content" in message)) continue;
211 for (const block of Array.isArray(message.content)
212 ? message.content.toReversed()
213 : []) {
214 const touched = toolPath(block);
215 if (touched) {
216 const path = existingFile(touched.path, cwd);
217 if (path) add(path, touched.source);
218 continue;
219 }
220 for (const text of textFromContent([block])) {
221 for (const path of extractTextPaths(text, cwd).toReversed())
222 add(path, "assistant");
223 }
224 }
225 if (found.size >= MAX_CANDIDATES) break;
226 }
228 const candidates: FileCandidate[] = [];
229 const seen = new Set<string>();
230 for (const source of SOURCE_ORDER) {
231 for (const candidate of buckets.get(source)?.values() ?? []) {
232 if (seen.has(candidate.path)) continue;
233 seen.add(candidate.path);
234 candidates.push(candidate);
235 if (candidates.length === MAX_CANDIDATES) return candidates;
236 }
237 }
238 return candidates;
239}
241function fuzzyCandidates(
242 candidates: readonly FileCandidate[],
243 query: string,
244): FileCandidate[] {
245 return fuzzyFilter(
246 [...candidates],
247 query,
248 (candidate) => candidate.displayPath,
249 );
250}
252async function chooseCandidate(
253 candidates: readonly FileCandidate[],
254 ctx: Pick<ExtensionContext, "mode" | "ui">,
255): Promise<FileCandidate | undefined> {
256 if (ctx.mode !== "tui") {
257 const selected = await ctx.ui.select(
258 "Open",
259 candidates.map((candidate) => candidate.displayPath),
260 );
261 return candidates.find((candidate) => candidate.displayPath === selected);
262 }
263 const selectedPath = await ctx.ui.custom<string | undefined>(
264 (tui, theme, keybindings, done) => {
265 const container = new Container();
266 const input = new Input();
267 input.focused = true;
268 let list: SelectList;
270 function rebuild(): void {
271 const filtered = fuzzyCandidates(candidates, input.getValue());
272 list = new SelectList(
273 filtered.map((candidate) => ({
274 value: candidate.path,
275 label: candidate.displayPath,
276 description: candidate.source,
277 })),
278 Math.min(Math.max(filtered.length, 1), 8),
279 {
280 selectedPrefix: (text) => theme.fg("accent", text),
281 selectedText: (text) => theme.fg("accent", text),
282 description: (text) => theme.fg("dim", text),
283 scrollInfo: (text) => theme.fg("dim", text),
284 noMatch: (text) => theme.fg("warning", text),
285 },
286 );
287 list.onSelect = (item) => done(item.value);
288 list.onCancel = () => done(undefined);
289 container.clear();
290 container.addChild(input);
291 container.addChild(list);
292 }
294 rebuild();
295 let focused = true;
296 return {
297 get focused() {
298 return focused;
299 },
300 set focused(value: boolean) {
301 focused = value;
302 input.focused = value;
303 },
304 render: (width: number) => container.render(width),
305 invalidate: () => container.invalidate(),
306 handleInput(data: string) {
307 if (
308 keybindings.matches(data, "tui.select.up") ||
309 keybindings.matches(data, "tui.select.down")
310 ) {
311 list.handleInput(data);
312 tui.requestRender();
313 return;
314 }
315 if (keybindings.matches(data, "tui.select.confirm")) {
316 const selected = list.getSelectedItem();
317 if (selected) done(selected.value);
318 return;
319 }
320 if (keybindings.matches(data, "tui.select.cancel")) {
321 done(undefined);
322 return;
323 }
324 const previous = input.getValue();
325 input.handleInput(data);
326 if (input.getValue() !== previous) rebuild();
327 tui.requestRender();
328 },
329 };
330 },
331 );
332 return candidates.find((candidate) => candidate.path === selectedPath);
333}
335function splitArguments(
336 paneId: string,
337 cwd: string,
338 editor: string,
339 path: string,
340): string[] {
341 return [
342 "cli",
343 "split-pane",
344 "--pane-id",
345 paneId,
346 "--right",
347 "--percent",
348 SPLIT_PERCENT,
349 "--cwd",
350 cwd,
351 "--",
352 editor,
353 path,
354 ];
355}
357async function launchInSplit(
358 wezterm: string,
359 editor: string,
360 paneId: string,
361 cwd: string,
362 path: string,
363): Promise<void> {
364 await new Promise<void>((resolveLaunch, reject) => {
365 const child = spawn(wezterm, splitArguments(paneId, cwd, editor, path), {
366 cwd,
367 detached: true,
368 stdio: "ignore",
369 windowsHide: true,
370 });
371 child.once("error", reject);
372 child.once("spawn", () => {
373 child.unref();
374 resolveLaunch();
375 });
376 });
377}
379export default function openExtension(pi: ExtensionAPI): void {
380 const wezterm = executableOnPath("wezterm");
381 const editorName = process.env.EDITOR?.trim();
382 const editor = editorName ? executableOnPath(editorName) : undefined;
384 pi.on("session_start", (_event, ctx) => {
385 if (!wezterm) ctx.ui.notify("/open: wezterm is not on PATH", "warning");
386 if (!editorName) ctx.ui.notify("/open: EDITOR is not set", "warning");
387 else if (!editor)
388 ctx.ui.notify(`/open: EDITOR '${editorName}' is not on PATH`, "warning");
389 if (!process.env.WEZTERM_PANE)
390 ctx.ui.notify("/open: WEZTERM_PANE is not set", "warning");
391 });
393 pi.registerCommand("open", {
394 description: "Open a file in a Neovim WezTerm split",
395 async handler(args, ctx) {
396 const paneId = process.env.WEZTERM_PANE;
397 if (!wezterm || !editor || !paneId) {
398 ctx.ui.notify("/open unavailable; see startup warnings", "error");
399 return;
400 }
402 let path: string | undefined;
403 if (args.trim()) {
404 path = existingFile(args, ctx.cwd);
405 if (!path) {
406 ctx.ui.notify(`Not a file: ${args.trim()}`, "error");
407 return;
408 }
409 } else {
410 const candidates = collectCandidates(
411 ctx.sessionManager.getBranch(),
412 ctx.cwd,
413 );
414 if (candidates.length === 0) {
415 ctx.ui.notify("No mentioned files", "info");
416 return;
417 }
418 path =
419 candidates.length === 1
420 ? candidates[0].path
421 : (await chooseCandidate(candidates, ctx))?.path;
422 }
423 if (!path) return;
425 try {
426 await launchInSplit(wezterm, editor, paneId, ctx.cwd, path);
427 } catch (error) {
428 ctx.ui.notify(
429 `/open failed: ${error instanceof Error ? error.message : String(error)}`,
430 "error",
431 );
432 }
433 },
434 });
435}
437export const __test = {
438 chooseCandidate,
439 collectCandidates,
440 executableOnPath,
441 extractTextPaths,
442 fuzzyCandidates,
443 splitArguments,
444};

extensions/open/mise.toml

Added
new file mode 100644

+31 / −0 text lines

1[tasks.fmt]
2description = "Format open extension"
3depends = ["//:install"]
4run = [
5 "biome check --write .",
6 "rumdl fmt README.md",
7 "taplo format mise.toml",
8]
9
10[tasks.lint]
11description = "Lint open extension"
12depends = ["//:install"]
13run = [
14 "biome ci --config-path ../.. .",
15 "rumdl check --config ../../.rumdl.toml .",
16 "taplo format --check --config ../../.taplo.toml mise.toml",
17]
19[tasks.test]
20description = "Test open extension"
21depends = ["//:install"]
22run = [
23 { task = "//:test", args = ["extensions/open"] },
24]
26[tasks.check]
27description = "Check open extension"
28depends = ["//:install"]
29run = [
30 { task = "//:build", args = ["open"] },
31]

extensions/open/package.json

Added
new file mode 100644

+20 / −0 text lines

1{
2 "name": "@bugabinga/pi-ext-open",
3 "type": "module",
4 "main": "index.ts",
5 "peerDependencies": {
6 "@earendil-works/pi-coding-agent": "*",
7 "@earendil-works/pi-tui": "*"
8 },
9 "license": "MIT",
10 "description": "Open mentioned files in Neovim beside Pi.",
11 "keywords": [
12 "pi",
13 "pi-extension"
14 ],
15 "devDependencies": {
16 "@marcfargas/pi-test-harness": "^0.6.1",
17 "vitest": "^4.1.9"
18 },
19 "private": true
20}

package-lock.json

Modified

+16 / −0 text lines

329329 "@earendil-works/pi-tui": "*"
330330 }
331331 },
332 "extensions/open": {
333 "name": "@bugabinga/pi-ext-open",
334 "license": "MIT",
335 "devDependencies": {
336 "@marcfargas/pi-test-harness": "^0.6.1",
337 "vitest": "^4.1.9"
338 },
339 "peerDependencies": {
340 "@earendil-works/pi-coding-agent": "*",
341 "@earendil-works/pi-tui": "*"
342 }
343 },
332344 "extensions/os-notifier": {
333345 "name": "@bugabinga/pi-ext-os-notifier",
334346 "license": "MIT",
14861498 "resolved": "extensions/nu-bang",
14871499 "link": true
14881500 },
1501 "node_modules/@bugabinga/pi-ext-open": {
1502 "resolved": "extensions/open",
1503 "link": true
1504 },
14891505 "node_modules/@bugabinga/pi-ext-os-notifier": {
14901506 "resolved": "extensions/os-notifier",
14911507 "link": true