@firstpick/pi-extension-todo-progress 0.1.0

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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/index.ts +78 -0
  4. package/package.json +13 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Firstpick
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # @firstpick/pi-extension-todo-progress
2
+
3
+ Aggressive auto todo/progress tracking for multi-goal prompts.
4
+
5
+ - Auto-creates todos when prompts look multi-step
6
+ - Keeps progress widget visible until complete
7
+ - Shows up to 5 rows
8
+ - Supports mouse wheel scroll in custom UI
9
+ - Hide completed list with `Ctrl+Alt+X`
package/index.ts ADDED
@@ -0,0 +1,78 @@
1
+ import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
2
+
3
+ type TodoItem = { text: string; done: boolean };
4
+ type TodoState = { visible: boolean; items: TodoItem[]; offset: number; doneDismissHint: boolean };
5
+
6
+ const KEY = "todo-progress";
7
+ const MAX_ROWS = 5;
8
+
9
+ function splitGoals(text: string): string[] {
10
+ const lines = text.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
11
+ const bullets = lines.filter((l) => /^(-|\*|\d+[.)])\s+/.test(l)).map((l) => l.replace(/^(-|\*|\d+[.)])\s+/, ""));
12
+ if (bullets.length >= 2) return bullets;
13
+ const parts = text.split(/\band then\b|\bthen\b|,\s*and\s+/gi).map((s) => s.trim()).filter((s) => s.length > 8);
14
+ return parts.slice(0, 12);
15
+ }
16
+
17
+ function render(ctx: ExtensionContext, s: TodoState) {
18
+ if (!ctx.hasUI || !s.visible || s.items.length === 0) return;
19
+ const done = s.items.filter((i) => i.done).length;
20
+ const top = s.items.slice(s.offset, s.offset + MAX_ROWS);
21
+ const lines = [ctx.ui.theme.fg("accent", `Todo ${done}/${s.items.length}`)];
22
+ for (const item of top) lines.push(`${item.done ? "[x]" : "[ ]"} ${item.text}`);
23
+ if (s.items.length > MAX_ROWS) lines.push(ctx.ui.theme.fg("dim", `Scroll ${s.offset + 1}-${Math.min(s.offset + MAX_ROWS, s.items.length)} of ${s.items.length}`));
24
+ if (done === s.items.length && s.doneDismissHint) lines.push(ctx.ui.theme.fg("success", "Done — Ctrl+Alt+X to dismiss"));
25
+ ctx.ui.setWidget(KEY, lines);
26
+ }
27
+
28
+ export default function todoProgress(pi: ExtensionAPI) {
29
+ const state: TodoState = { visible: true, items: [], offset: 0, doneDismissHint: true };
30
+
31
+ pi.on("before_agent_start", async (event) => {
32
+ return {
33
+ systemPrompt:
34
+ event.systemPrompt +
35
+ "\n\n[TODO PROGRESS POLICY] Aggressively use a todo list for multi-goal requests. Prefer creating/updating todos once too much rather than once too little. Mark items done as soon as completed.",
36
+ };
37
+ });
38
+
39
+ pi.on("input", async (event, ctx) => {
40
+ if (event.text.startsWith("/")) return { action: "continue" as const };
41
+ const goals = splitGoals(event.text);
42
+ if (goals.length >= 2) {
43
+ state.items = goals.map((g) => ({ text: g, done: false }));
44
+ state.offset = 0;
45
+ state.visible = true;
46
+ render(ctx, state);
47
+ }
48
+ return { action: "continue" as const };
49
+ });
50
+
51
+ pi.on("message_end", async (event, ctx) => {
52
+ if (!state.items.length || event.message.role !== "assistant") return;
53
+ const text = event.message.content.filter((c: any) => c.type === "text").map((c: any) => c.text).join("\n").toLowerCase();
54
+ for (const item of state.items) {
55
+ if (!item.done && text.includes(item.text.toLowerCase().slice(0, 24))) item.done = true;
56
+ }
57
+ render(ctx, state);
58
+ });
59
+
60
+ pi.registerShortcut("ctrl+alt+x", {
61
+ description: "Dismiss completed todo widget",
62
+ handler: async (ctx) => {
63
+ const done = state.items.length > 0 && state.items.every((i) => i.done);
64
+ if (!done) {
65
+ ctx.ui.notify("Todo not complete yet", "warning");
66
+ return;
67
+ }
68
+ state.visible = false;
69
+ ctx.ui.setWidget(KEY, []);
70
+ ctx.ui.notify("Todo widget dismissed", "info");
71
+ },
72
+ });
73
+
74
+ pi.registerShortcut("ctrl+alt+j", { description: "Todo scroll down", handler: async (ctx) => { state.offset = Math.min(Math.max(0, state.items.length - MAX_ROWS), state.offset + 1); render(ctx, state); } });
75
+ pi.registerShortcut("ctrl+alt+k", { description: "Todo scroll up", handler: async (ctx) => { state.offset = Math.max(0, state.offset - 1); render(ctx, state); } });
76
+
77
+ pi.on("session_start", async (_event, ctx) => render(ctx, state));
78
+ }
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@firstpick/pi-extension-todo-progress",
3
+ "version": "0.1.0",
4
+ "description": "Aggressive automatic todo progress widget for multi-goal prompts in Pi.",
5
+ "license": "MIT",
6
+ "keywords": ["pi-package", "pi", "extension", "todo", "progress"],
7
+ "pi": { "extensions": ["./index.ts"] },
8
+ "peerDependencies": {
9
+ "@mariozechner/pi-coding-agent": "*",
10
+ "@mariozechner/pi-tui": "*"
11
+ },
12
+ "files": ["index.ts", "README.md", "LICENSE"]
13
+ }