repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

pi(ext): remove pr-status, interactive, sticky-bottom

b1776356d9b503ce47987d685744a8e6d7493971

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (7)

pi/agent/bun.lock

Modified
61 61 "name": "@bugabinga/pi-ext-inline",
62 62 "version": "0.1.0",
64 - "extensions/interactive": {
65 - "name": "@bugabinga/pi-ext-interactive",
66 - "version": "0.1.0",
67 - },
68 64 "extensions/mux": {
69 65 "name": "@bugabinga/pi-ext-mux",
70 66 "version": "0.1.0",
77 73 "name": "@bugabinga/pi-ext-notify",
78 74 "version": "0.1.0",
80 - "extensions/pr-status": {
81 - "name": "@bugabinga/pi-ext-pr-status",
82 - "version": "0.1.0",
83 - },
84 76 "extensions/prune": {
85 77 "name": "prune",
86 78 "version": "0.1.0",
116 108 "name": "@bugabinga/pi-ext-session-rename",
117 109 "version": "0.1.0",
119 - "extensions/sticky-bottom": {
120 - "name": "@bugabinga/pi-ext-sticky-bottom",
121 - "version": "0.1.0",
122 - },
123 111 "extensions/terminal-signals": {
124 112 "name": "@bugabinga/pi-ext-terminal-signals",
125 113 "version": "0.1.0",
128 116 "name": "@bugabinga/pi-ext-thinking",
129 117 "version": "0.1.0",
131 - "extensions/thinking-label": {
132 - "name": "@bugabinga/pi-ext-thinking-label",
133 - "version": "0.1.0",
134 - },
135 119 "extensions/timing": {
136 120 "name": "@bugabinga/pi-ext-timing",
137 121 "version": "0.1.0",
261 245 "@bugabinga/pi-ext-inline": ["@bugabinga/pi-ext-inline@workspace:extensions/inline"],
263 - "@bugabinga/pi-ext-interactive": ["@bugabinga/pi-ext-interactive@workspace:extensions/interactive"],
265 247 "@bugabinga/pi-ext-mux": ["@bugabinga/pi-ext-mux@workspace:extensions/mux"],
267 249 "@bugabinga/pi-ext-neko": ["@bugabinga/pi-ext-neko@workspace:extensions/neko"],
269 251 "@bugabinga/pi-ext-notify": ["@bugabinga/pi-ext-notify@workspace:extensions/notify"],
271 - "@bugabinga/pi-ext-pr-status": ["@bugabinga/pi-ext-pr-status@workspace:extensions/pr-status"],
273 253 "@bugabinga/pi-ext-pulse": ["@bugabinga/pi-ext-pulse@workspace:extensions/pulse"],
275 255 "@bugabinga/pi-ext-quota": ["@bugabinga/pi-ext-quota@workspace:extensions/quota"],
283 263 "@bugabinga/pi-ext-session-rename": ["@bugabinga/pi-ext-session-rename@workspace:extensions/session-rename"],
285 - "@bugabinga/pi-ext-sticky-bottom": ["@bugabinga/pi-ext-sticky-bottom@workspace:extensions/sticky-bottom"],
287 265 "@bugabinga/pi-ext-terminal-signals": ["@bugabinga/pi-ext-terminal-signals@workspace:extensions/terminal-signals"],
289 267 "@bugabinga/pi-ext-thinking": ["@bugabinga/pi-ext-thinking@workspace:extensions/thinking"],
291 - "@bugabinga/pi-ext-thinking-label": ["@bugabinga/pi-ext-thinking-label@workspace:extensions/thinking-label"],
293 269 "@bugabinga/pi-ext-timing": ["@bugabinga/pi-ext-timing@workspace:extensions/timing"],
295 271 "@bugabinga/pi-ext-todo": ["@bugabinga/pi-ext-todo@workspace:extensions/todo"],

pi/agent/extensions/interactive/index.ts

Deleted
deleted file mode 100644
1 -/**
2 - * Interactive Shell Commands Extension
3 - *
4 - * Enables running interactive commands (vim, git rebase -i, htop, etc.)
5 - * with full terminal access. The TUI suspends while they run.
6 - *
7 - * Usage:
8 - * pi -e examples/extensions/interactive-shell.ts
9 - *
10 - * !vim file.txt # Auto-detected as interactive
11 - * !i any-command # Force interactive mode with !i prefix
12 - * !git rebase -i HEAD~3
13 - * !htop
14 - *
15 - * Configuration via environment variables:
16 - * INTERACTIVE_COMMANDS - Additional commands (comma-separated)
17 - * INTERACTIVE_EXCLUDE - Commands to exclude (comma-separated)
18 - *
19 - * Note: This only intercepts user `!` commands, not agent bash tool calls.
20 - * If the agent runs an interactive command, it will fail (which is fine).
21 - */
23 -import { spawnSync } from "node:child_process";
24 -import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
26 -// Default interactive commands - editors, pagers, git ops, TUIs
27 -const DEFAULT_INTERACTIVE_COMMANDS = [
28 - // Editors
29 - "vim",
30 - "nvim",
31 - "vi",
32 - "nano",
33 - "emacs",
34 - "pico",
35 - "micro",
36 - "helix",
37 - "hx",
38 - "kak",
39 - // Pagers
40 - "less",
41 - "more",
42 - "most",
43 - // Git interactive
44 - "git commit",
45 - "git rebase",
46 - "git merge",
47 - "git cherry-pick",
48 - "git revert",
49 - "git add -p",
50 - "git add --patch",
51 - "git add -i",
52 - "git add --interactive",
53 - "git stash -p",
54 - "git stash --patch",
55 - "git reset -p",
56 - "git reset --patch",
57 - "git checkout -p",
58 - "git checkout --patch",
59 - "git difftool",
60 - "git mergetool",
61 - // System monitors
62 - "htop",
63 - "top",
64 - "btop",
65 - "glances",
66 - // File managers
67 - "ranger",
68 - "nnn",
69 - "lf",
70 - "mc",
71 - "vifm",
72 - "yy",
73 - "yazi",
74 - // Git TUIs
75 - "tig",
76 - "lazygit",
77 - "gitui",
78 - "gitu",
79 - // Fuzzy finders
80 - "fzf",
81 - "sk",
82 - // Remote sessions
83 - "ssh",
84 - "telnet",
85 - "mosh",
86 - // Database clients
87 - "psql",
88 - "mysql",
89 - "sqlite3",
90 - "mongosh",
91 - "redis-cli",
92 - // Kubernetes/Docker
93 - "kubectl edit",
94 - "kubectl exec -it",
95 - "docker exec -it",
96 - "docker run -it",
97 - // Other
98 - "tmux",
99 - "screen",
100 - "ncdu",
101 -];
103 -function getInteractiveCommands(): string[] {
104 - const additional = process.env.INTERACTIVE_COMMANDS?.split(",")
105 - .map((s) => s.trim())
106 - .filter(Boolean) ?? [];
107 - const excluded = new Set(
108 - process.env.INTERACTIVE_EXCLUDE?.split(",").map((s) =>
109 - s.trim().toLowerCase()
110 - ) ?? [],
111 - );
112 - return [...DEFAULT_INTERACTIVE_COMMANDS, ...additional].filter((cmd) =>
113 - !excluded.has(cmd.toLowerCase())
114 - );
117 -function isInteractiveCommand(command: string): boolean {
118 - const trimmed = command.trim().toLowerCase();
119 - const commands = getInteractiveCommands();
121 - for (const cmd of commands) {
122 - const cmdLower = cmd.toLowerCase();
123 - // Match at start
124 - if (
125 - trimmed === cmdLower || trimmed.startsWith(`${cmdLower} `) ||
126 - trimmed.startsWith(`${cmdLower}\t`)
127 - ) {
128 - return true;
129 - }
130 - // Match after pipe: "cat file | less"
131 - const pipeIdx = trimmed.lastIndexOf("|");
132 - if (pipeIdx !== -1) {
133 - const afterPipe = trimmed.slice(pipeIdx + 1).trim();
134 - if (afterPipe === cmdLower || afterPipe.startsWith(`${cmdLower} `)) {
135 - return true;
136 - }
137 - }
138 - }
139 - return false;
142 -export default function (pi: ExtensionAPI) {
143 - pi.on("user_bash", async (event, ctx) => {
144 - let command = event.command;
145 - let forceInteractive = false;
147 - // Check for !i prefix (command comes without the leading !)
148 - // The prefix parsing happens before this event, so we check if command starts with "i "
149 - if (command.startsWith("i ") || command.startsWith("i\t")) {
150 - forceInteractive = true;
151 - command = command.slice(2).trim();
152 - }
154 - const shouldBeInteractive = forceInteractive ||
155 - isInteractiveCommand(command);
156 - if (!shouldBeInteractive) {
157 - return; // Let normal handling proceed
158 - }
160 - // No UI available (print mode, RPC, etc.)
161 - if (!ctx.hasUI) {
162 - return {
163 - result: {
164 - output: "(interactive commands require TUI)",
165 - exitCode: 1,
166 - cancelled: false,
167 - truncated: false,
168 - },
169 - };
170 - }
172 - // Use ctx.ui.custom() to get TUI access, then run the command
173 - const exitCode = await ctx.ui.custom<number | null>(
174 - (tui, _theme, _kb, done) => {
175 - // Stop TUI to release terminal
176 - tui.stop();
178 - // Clear screen
179 - process.stdout.write("\x1b[2J\x1b[H");
181 - // Run command with full terminal access
182 - const shell = process.env.SHELL || "/bin/sh";
183 - const result = spawnSync(shell, ["-c", command], {
184 - stdio: "inherit",
185 - env: process.env,
186 - });
188 - // Restart TUI
189 - tui.start();
190 - tui.requestRender(true);
192 - // Signal completion
193 - done(result.status);
195 - // Return empty component (immediately disposed since done() was called)
196 - return { render: () => [], invalidate: () => {} };
197 - },
198 - );
200 - // Return result to prevent default bash handling
201 - const output = exitCode === 0
202 - ? "(interactive command completed successfully)"
203 - : `(interactive command exited with code ${exitCode})`;
205 - return {
206 - result: {
207 - output,
208 - exitCode: exitCode ?? 1,
209 - cancelled: false,
210 - truncated: false,
211 - },
212 - };
213 - });

pi/agent/extensions/interactive/package.json

Deleted
deleted file mode 100644
1 -{
2 - "name": "@bugabinga/pi-ext-interactive",
3 - "version": "0.1.0",
4 - "private": true,
5 - "type": "module",
6 - "main": "index.ts"
7 -}

pi/agent/extensions/pr-status/index.ts

Deleted
deleted file mode 100644
1 -/**
2 - * PR/MR status footer segment producer.
3 - *
4 - * Detects open pull/merge requests for the current branch.
5 - * Forge-agnostic: tries gh (GitHub), glab (GitLab), bb (Bitbucket).
6 - * Falls back silently if no forge CLI is available.
7 - * Emits footer:segment with zone "workspace".
8 - */
10 -import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
11 -import { assertArray, assertString, assertHasKeys } from "@bugabinga/pi-lib";
13 -type ForgeResult = { id: string; url: string; state: string; isDraft?: boolean };
15 -async function execForge(pi: ExtensionAPI, args: string[], cwd: string, timeout = 3000): Promise<string | null> {
16 - try {
17 - const r = await pi.exec(args[0]!, args.slice(1), { cwd, timeout });
18 - return r.code === 0 ? r.stdout.trim() : null;
19 - } catch { return null; }
22 -async function tryGitHub(pi: ExtensionAPI, cwd: string, branch: string): Promise<ForgeResult | null> {
23 - const out = await execForge(pi, [
24 - "gh", "pr", "list", "--head", branch, "--state", "open",
25 - "--limit", "1", "--json", "number,url,state,isDraft",
26 - ], cwd);
27 - if (!out) return null;
28 - try {
29 - const raw = JSON.parse(out);
30 - assertArray(raw, "gh pr list should return array");
31 - if (raw.length === 0) return null;
32 - assertHasKeys(raw[0], ["number", "url", "state"], "gh pr entry shape");
33 - const pr = raw[0];
34 - return { id: `#${pr.number}`, url: pr.url, state: pr.state, isDraft: pr.isDraft };
35 - } catch { return null; }
38 -async function tryGitLab(pi: ExtensionAPI, cwd: string, branch: string): Promise<ForgeResult | null> {
39 - const out = await execForge(pi, [
40 - "glab", "mr", "list", "--source-branch", branch, "--state", "opened",
41 - "--per-page", "1", "--output", "json",
42 - ], cwd);
43 - if (!out) return null;
44 - try {
45 - const raw = JSON.parse(out);
46 - assertArray(raw, "glab mr list should return array");
47 - if (raw.length === 0) return null;
48 - assertHasKeys(raw[0], ["iid", "web_url", "state"], "glab mr entry shape");
49 - const mr = raw[0];
50 - return { id: `!${mr.iid}`, url: mr.web_url, state: mr.state };
51 - } catch { return null; }
54 -async function tryBitbucket(pi: ExtensionAPI, cwd: string, branch: string): Promise<ForgeResult | null> {
55 - const out = await execForge(pi, [
56 - "bb", "pr", "list", "--source-branch", branch, "--state", "OPEN",
57 - "--limit", "1", "--output", "json",
58 - ], cwd);
59 - if (!out) return null;
60 - try {
61 - const raw = JSON.parse(out);
62 - assertArray(raw, "bb pr list should return array");
63 - if (raw.length === 0) return null;
64 - const pr = raw[0];
65 - assertString(pr.id, "bb pr should have id");
66 - return { id: `#${pr.id}`, url: pr.links?.html?.href ?? "", state: pr.state };
67 - } catch { return null; }
70 -async function detectPR(pi: ExtensionAPI, cwd: string): Promise<ForgeResult | null> {
71 - // Get current branch
72 - const branch = await execForge(pi, ["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd, 1500);
73 - if (!branch || branch === "HEAD") return null;
75 - // Try each forge CLI in order
76 - return (
77 - await tryGitHub(pi, cwd, branch) ??
78 - await tryGitLab(pi, cwd, branch) ??
79 - await tryBitbucket(pi, cwd, branch)
80 - );
83 -export default function prStatusExtension(pi: ExtensionAPI) {
84 - let currentCwd = "";
85 - let hasUI = false;
86 - let refreshInFlight = false;
88 - const refresh = async () => {
89 - if (refreshInFlight) return;
90 - refreshInFlight = true;
91 - try {
92 - const pr = await detectPR(pi, currentCwd);
93 - if (pr) {
94 - const draft = pr.isDraft ? " (draft)" : "";
95 - pi.events.emit("footer:segment", {
96 - id: "pr-status",
97 - text: `${pr.id}${draft}`,
98 - icon: "",
99 - color: "accent",
100 - zone: "workspace",
101 - order: 2,
102 - });
103 - } else {
104 - pi.events.emit("footer:segment", { id: "pr-status", text: undefined });
105 - }
106 - } finally {
107 - refreshInFlight = false;
108 - }
109 - };
111 - pi.on("session_start", async (_e, ctx) => { hasUI = ctx.hasUI; currentCwd = ctx.cwd; refresh(); });
112 - pi.on("agent_end", async () => { if (hasUI) refresh(); });

pi/agent/extensions/pr-status/package.json

Deleted
deleted file mode 100644
1 -{
2 - "name": "@bugabinga/pi-ext-pr-status",
3 - "version": "0.1.0",
4 - "private": true,
5 - "type": "module",
6 - "main": "index.ts",
7 - "@bugabinga/pi-lib": "workspace:*"
8 -}

pi/agent/extensions/sticky-bottom/index.ts

Deleted
deleted file mode 100644
1 -import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
2 -import { TUI } from "@mariozechner/pi-tui";
4 -export default function (pi: ExtensionAPI) {
5 - pi.on("session_start", (_event, ctx) => {
6 - if (!ctx.hasUI) return;
8 - const proto = TUI.prototype as any;
9 - if (proto.__stickyBottom) return;
10 - proto.__stickyBottom = true;
12 - const orig = proto.render;
13 - proto.render = function (width: number): string[] {
14 - const lines: string[] = orig.call(this, width);
15 - const h = this.terminal?.rows;
17 - if (h && Array.isArray(lines) && lines.length < h && !this.overlayStack?.length) {
18 - const pad: string[] = [];
19 - pad.length = h - lines.length;
20 - pad.fill("");
21 - return pad.concat(lines);
22 - }
24 - return lines;
25 - };
26 - });
27 -}

pi/agent/extensions/sticky-bottom/package.json

Deleted
deleted file mode 100644
1 -{
2 - "name": "@bugabinga/pi-ext-sticky-bottom",
3 - "version": "0.1.0",
4 - "private": true,
5 - "type": "module",
6 - "main": "index.ts"
7 -}