@abhishek944/pi-tasks 0.15.0 → 0.17.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 (54) hide show
  1. package/README.md +63 -14
  2. package/dist/agents/delegation.d.ts +4 -0
  3. package/dist/agents/delegation.js +130 -0
  4. package/dist/agents/herdr.d.ts +10 -3
  5. package/dist/agents/herdr.js +39 -12
  6. package/dist/agents/links.d.ts +3 -3
  7. package/dist/agents/links.js +42 -19
  8. package/dist/auto-continue.js +409 -33
  9. package/dist/blocked.d.ts +29 -0
  10. package/dist/blocked.js +100 -0
  11. package/dist/command.d.ts +2 -2
  12. package/dist/command.js +7 -3
  13. package/dist/delegated-time.d.ts +12 -1
  14. package/dist/delegated-time.js +96 -15
  15. package/dist/dependency.d.ts +7 -0
  16. package/dist/dependency.js +13 -0
  17. package/dist/durable.d.ts +42 -0
  18. package/dist/durable.js +577 -0
  19. package/dist/herdr-header.d.ts +3 -0
  20. package/dist/herdr-header.js +100 -0
  21. package/dist/herdr-panel.d.ts +15 -0
  22. package/dist/herdr-panel.js +219 -0
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +125 -56
  25. package/dist/markdown.js +3 -1
  26. package/dist/panel-settings.d.ts +11 -0
  27. package/dist/panel-settings.js +30 -0
  28. package/dist/progress.js +1 -1
  29. package/dist/snapshot.d.ts +23 -0
  30. package/dist/snapshot.js +166 -0
  31. package/dist/state.d.ts +43 -18
  32. package/dist/state.js +581 -289
  33. package/dist/thoughts.d.ts +11 -0
  34. package/dist/thoughts.js +14 -0
  35. package/dist/timing.js +9 -2
  36. package/dist/tools.js +295 -34
  37. package/dist/tracking.js +25 -13
  38. package/dist/transition.d.ts +9 -0
  39. package/dist/transition.js +26 -0
  40. package/dist/types.d.ts +76 -3
  41. package/dist/ui/panel.js +38 -19
  42. package/dist/ui/task-view.d.ts +7 -0
  43. package/dist/ui/task-view.js +10 -0
  44. package/dist/ui/works-dashboard.js +37 -19
  45. package/docs/REFERENCE.md +85 -31
  46. package/docs/USAGE_GUIDE.md +129 -55
  47. package/herdr/pi-tasks/README.md +46 -0
  48. package/herdr/pi-tasks/header.js +212 -0
  49. package/herdr/pi-tasks/main.js +488 -0
  50. package/herdr/pi-tasks/mod.json +3 -0
  51. package/herdr/pi-tasks/spinner.svg +1 -0
  52. package/package.json +26 -1
  53. package/dist/agents/tools.d.ts +0 -3
  54. package/dist/agents/tools.js +0 -143
@@ -0,0 +1,212 @@
1
+ // Installed as the entry point of a personal clone of the current pane header.
2
+ // base.js and its assets come from Herdr's official mod.clone, never a shipped-file edit.
3
+ import BaseHeader from "./base.js";
4
+ import { div } from "gpui-kit";
5
+ import { Button, h_flex, Popup, Select, v_flex } from "gpui-base";
6
+ import { panes, props, run, setShared, shared, theme } from "herdr";
7
+
8
+ // Stored task statuses only; "Running" is derived from an active task with a live source, so it
9
+ // belongs to Active. Works have no status and are never filtered by value.
10
+ const STATUSES = [
11
+ { value: "all", label: "All statuses" },
12
+ { value: "active", label: "Active" },
13
+ { value: "blocked", label: "Blocked (all)" },
14
+ { value: "blocked-user", label: "Blocked on you" },
15
+ { value: "blocked-agent", label: "Waiting on agents" },
16
+ { value: "completed", label: "Completed" },
17
+ { value: "cancelled", label: "Cancelled" },
18
+ ];
19
+
20
+ const DECISION_STATUSES = [
21
+ { value: "all", label: "All" },
22
+ { value: "pending", label: "Pending" },
23
+ { value: "expired", label: "Expired" },
24
+ { value: "answered", label: "Answered" },
25
+ { value: "failed", label: "Failed" },
26
+ { value: "invalid", label: "Invalid" },
27
+ ];
28
+
29
+ export default class TasksHeader extends BaseHeader {
30
+ init(props, cx) {
31
+ super.init?.(props, cx);
32
+ this.activityFocus = [cx.focus_handle(), cx.focus_handle()];
33
+ this.statusIndex = 0;
34
+ this.statusTrigger = cx.focus_handle();
35
+ this.statusContent = cx.focus_handle();
36
+ }
37
+
38
+ activityHeader(id) {
39
+ const t = theme();
40
+ const key = "pi-activity-section:" + id;
41
+ const selected = shared(key) === "monitors" ? "monitors" : "loops";
42
+ const sections = ["loops", "monitors"];
43
+ const select = (index) => {
44
+ const target = panes().find((item) => item.pane === id);
45
+ if (target?.mod !== "pi-loop-monitor" || target.terminal !== null) return;
46
+ run("pane.focus", { pane: id });
47
+ setShared(key, sections[index]);
48
+ this.activityFocus[index].focus();
49
+ };
50
+ return h_flex().id("activity-header-" + id).size_full().px(10).gap(12).items_center()
51
+ .bg(t.background).border_b(1).border_color(t.border).text_size(12)
52
+ .child(h_flex().h_full().gap(12).role("tab_list").accessibility_label("Loops and Monitors sections")
53
+ .children(sections.map((section, index) => Button.new("activity-tab-" + id + section)
54
+ .h_full().px(4).role("tab").selected(selected === section).set_position(index + 1, 2)
55
+ .track_focus(this.activityFocus[index]).tab_stop(selected === section)
56
+ .text_color(selected === section ? t.foreground : t.dim)
57
+ .when(selected === section, (style) => style.font_semibold().border_b(2).border_color(t.accent))
58
+ .hover((style) => style.bg(t.hover)).focus((style) => style.bg(t.selected))
59
+ .accessibility_label(section === "loops" ? "Loops" : "Monitors")
60
+ .on_mouse_down("left", (_event, cx) => cx.stop_propagation())
61
+ .on_click((_event, cx) => { cx.stop_propagation(); select(index); })
62
+ .on_key_down((event, cx) => {
63
+ if (!["left", "right", "home", "end"].includes(event.key)) return;
64
+ cx.stop_propagation();
65
+ const next = event.key === "home" ? 0 : event.key === "end" ? 1 : 1 - index;
66
+ select(next);
67
+ }).child(section === "loops" ? "Loops" : "Monitors"))))
68
+ .child(div().flex_1())
69
+ .child(Button.new("activity-close-" + id).size(30).flex_none().rounded(4).cursor_pointer()
70
+ .text_size(22).text_color(t.muted).hover((style) => style.bg(t.hover).text_color(t.foreground))
71
+ .focus((style) => style.bg(t.selected).text_color(t.accent)).tab_stop(true)
72
+ .accessibility_label("Close Loops and Monitors view").tooltip("Close only this view; Tasks, Pi, loops and monitors continue")
73
+ .on_mouse_down("left", (_event, cx) => cx.stop_propagation())
74
+ .on_click((_event, cx) => {
75
+ cx.stop_propagation();
76
+ const target = panes().find((item) => item.pane === id);
77
+ if (target?.mod === "pi-loop-monitor" && target.terminal === null) run("pane.close", { pane: id });
78
+ }).child("×"));
79
+ }
80
+
81
+ // The content copy cannot name its own pane, so this pane's header publishes the selected status
82
+ // under a pane-scoped key; the Tasks view reads the same key through the pane id it is given.
83
+ statusKey(id, kind) {
84
+ return "pi-" + kind + "-status:" + id;
85
+ }
86
+
87
+ statusValue(id, kind, statuses) {
88
+ const value = shared(this.statusKey(id, kind));
89
+ return statuses.some((item) => item.value === value) ? value : kind === "decisions" ? "pending" : "all";
90
+ }
91
+
92
+ // Open state is shared with this pane's view, which closes the menu when the pointer goes down
93
+ // anywhere in the task list: Herdr's Select owns Escape and its own dismissal, but a click
94
+ // outside this mod never reaches it.
95
+ statusOpenKey(id, kind) {
96
+ return "pi-" + kind + "-status-open:" + id;
97
+ }
98
+
99
+ statusOpen(id, kind) {
100
+ return shared(this.statusOpenKey(id, kind)) === true;
101
+ }
102
+
103
+ setStatusOpen(id, kind, open) {
104
+ setShared(this.statusOpenKey(id, kind), open);
105
+ }
106
+
107
+ statusControl(id, t, counts, kind, statuses) {
108
+ const noun = kind === "tasks" ? "Task" : "Decision";
109
+ const label = (entry) => counts ? `${entry.label} (${counts[entry.value]})` : entry.label;
110
+ const value = this.statusValue(id, kind, statuses);
111
+ const current = statuses.find((item) => item.value === value) ?? statuses[0];
112
+ const open = this.statusOpen(id, kind);
113
+ const choose = (entry, cx) => {
114
+ setShared(this.statusKey(id, kind), entry.value);
115
+ this.setStatusOpen(id, kind, false);
116
+ this.statusIndex = Math.max(0, statuses.findIndex((item) => item.value === entry.value));
117
+ this.statusTrigger.focus();
118
+ cx.notify();
119
+ };
120
+ const close = (cx) => {
121
+ this.setStatusOpen(id, kind, false);
122
+ this.statusTrigger.focus();
123
+ cx.notify();
124
+ };
125
+ const trigger = h_flex().id("tasks-status-trigger-" + id).h(26).w(120).flex_none().min_w(0).px(8).gap(4).items_center()
126
+ .bg(t.background).rounded(6).border(1).border_color(t.input)
127
+ .track_focus(this.statusTrigger).tab_index(0).cursor_pointer()
128
+ .accessibility_label(noun + " status: " + label(current)).tooltip("Show only " + kind + " with one status")
129
+ .focus((style) => style.border_color(t.accent))
130
+ .on_mouse_down("left", (_event, cx) => cx.stop_propagation())
131
+ .on_click((_event, cx) => {
132
+ cx.stop_propagation();
133
+ const next = !open;
134
+ this.setStatusOpen(id, kind, next);
135
+ if (next) this.statusIndex = Math.max(0, statuses.findIndex((item) => item.value === value));
136
+ (next ? this.statusContent : this.statusTrigger).focus();
137
+ cx.notify();
138
+ })
139
+ .child(div().flex_1().min_w(0).truncate().text_size(12).text_color(t.foreground).child(label(current)))
140
+ .child(div().flex_none().text_size(11).text_color(t.muted).child("⌄"));
141
+ // Anchoring to the trigger and growing down-right is the one placement this 32px pane header
142
+ // supports: an anchor above the trigger would land outside the window.
143
+ const menu = v_flex().id("tasks-status-menu-" + id).w(190).min_w(0).p(5).gap(1).rounded(6)
144
+ .border(1).border_color(t.input).bg(t.popover).text_color(t.foreground)
145
+ .track_focus(this.statusContent).role("list_box").accessibility_label(noun + " status")
146
+ // GPUI observes presses outside the painted menu across the window, including other mods.
147
+ .on_mouse_down_out((_event, cx) => { this.setStatusOpen(id, kind, false); cx.notify(); })
148
+ .on_key_down((event, cx) => {
149
+ if (event.key === "up" || event.key === "down") {
150
+ const step = event.key === "down" ? 1 : -1;
151
+ this.statusIndex = (this.statusIndex + step + statuses.length) % statuses.length;
152
+ cx.stop_propagation(); cx.notify();
153
+ } else if (event.key === "enter" || event.key === "return") {
154
+ choose(statuses[this.statusIndex], cx); cx.stop_propagation();
155
+ } else if (event.key === "escape") {
156
+ close(cx); cx.stop_propagation();
157
+ }
158
+ })
159
+ .children(statuses.map((entry, index) => h_flex().id("tasks-status-option-" + id + entry.value).h(30).flex_none().min_w(0).px(6).gap(6).items_center()
160
+ .rounded(4).role("list_box_option").accessibility_label(label(entry)).selected(entry.value === value)
161
+ .when(index === this.statusIndex, (row) => row.aria_active_descendant())
162
+ .bg(index === this.statusIndex ? t.selected : t.popover).hover((style) => style.bg(t.hover))
163
+ .cursor_pointer()
164
+ .on_mouse_down("left", (_event, cx) => cx.stop_propagation())
165
+ .on_click((_event, cx) => { cx.stop_propagation(); choose(entry, cx); })
166
+ .child(div().w(12).flex_none().text_size(12).text_color(t.foreground).child(entry.value === value ? "✓" : ""))
167
+ .child(div().flex_1().min_w(0).truncate().text_size(12).child(label(entry)))));
168
+ const select = Select.new("tasks-status-" + id).accessibility_label(noun + " status").open(open)
169
+ .track_focus(this.statusTrigger).content_focus_handle(this.statusContent)
170
+ .on_open_change((next, cx) => {
171
+ this.setStatusOpen(id, kind, next);
172
+ if (next) this.statusIndex = Math.max(0, statuses.findIndex((item) => item.value === value));
173
+ cx.notify();
174
+ })
175
+ .on_confirm((_event, cx) => choose(statuses[this.statusIndex], cx))
176
+ .on_dismiss((_event, cx) => close(cx))
177
+ .child(Popup.new("tasks-status-popup-" + id, trigger).anchor("bottom_right")
178
+ .when(open, (el) => el.content(menu)));
179
+ return select;
180
+ }
181
+
182
+ render(cx) {
183
+ const id = props()?.pane;
184
+ const pane = panes().find((item) => item.pane === id);
185
+ if (pane?.mod === "pi-loop-monitor" && pane.terminal === null) return this.activityHeader(id);
186
+ if ((pane?.mod !== "pi-tasks" && pane?.mod !== "pi-decisions") || pane.terminal !== null) return super.render(cx);
187
+ const kind = pane.mod === "pi-tasks" ? "tasks" : "decisions";
188
+ const title = kind === "tasks" ? "Tasks" : "Decisions";
189
+ const t = theme();
190
+ const counts = shared("pi-" + kind + "-counts:" + id);
191
+ const statuses = kind === "tasks" ? STATUSES : DECISION_STATUSES;
192
+ const validCounts = counts && statuses.every(({ value }) => Number.isSafeInteger(counts[value]) && counts[value] >= 0) ? counts : null;
193
+ return h_flex().id("tasks-header-" + id).size_full().px(10).items_center().gap(8)
194
+ .bg(t.background).border_b(1).border_color(t.border).text_size(12)
195
+ .on_click(() => {
196
+ if (this.statusOpen(id, kind)) this.setStatusOpen(id, kind, false);
197
+ run("pane.focus", { pane: id });
198
+ })
199
+ .child(div().flex_1().min_w(0).truncate().text_color(t.muted).child(validCounts ? `${title} (${validCounts.all})` : title))
200
+ .child(this.statusControl(id, t, validCounts, kind, statuses))
201
+ .child(Button.new("tasks-close-" + id).size(32).flex_none().rounded(4).cursor_pointer()
202
+ .text_size(22).text_color(t.muted).hover((style) => style.bg(t.hover).text_color(t.foreground))
203
+ .focus((style) => style.bg(t.selected).text_color(t.accent))
204
+ .accessibility_label("Close " + title + " view").tooltip(kind === "tasks" ? "Close Tasks only; Pi, agents and tracking continue" : "Close Decisions only; Pi and agents continue").tab_stop(true)
205
+ .on_mouse_down("left", (_event, cx) => cx.stop_propagation())
206
+ .on_click((_event, cx) => {
207
+ cx.stop_propagation();
208
+ const target = panes().find((item) => item.pane === id);
209
+ if (target?.mod === "pi-" + kind && target.terminal === null) run("pane.close", { pane: id });
210
+ }).child("×"));
211
+ }
212
+ }