@hcflabs/pi-herdr-tools 0.0.0-stage → 1.6.7

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.
@@ -0,0 +1,196 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="1280" height="720" viewBox="0 0 1280 720" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="done-flow-title done-flow-desc" id="done-flow-root">
3
+ <title id="done-flow-title">Safe worktree completion</title>
4
+ <desc id="done-flow-desc">Normal /done asks for confirmation before waiting for Pi to become idle, then checks cross-workspace checkout use and removes the worktree before tab cleanup and a conditional parent update; explicit force skips confirmation and the cross-workspace checkout-use check, but still validates this tab's workspace and closes sibling tabs.</desc>
5
+ <defs>
6
+ <style>@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&amp;family=Geist:wght@400;500;600&amp;family=Geist+Mono:wght@400;500;600&amp;family=Noto+Serif:ital@0;1&amp;family=Noto+Sans+KR:wght@400;500;600&amp;family=Noto+Serif+KR:wght@400&amp;family=Noto+Sans+TC:wght@400;500;600&amp;family=Noto+Serif+TC:wght@400&amp;display=swap');
7
+ #done-flow-root { --paper: #f0eee9;
8
+ --ink: #101828;
9
+ --muted: #4c5665;
10
+ --accent: #1d4ed8;
11
+ --sans: 'Geist', system-ui, sans-serif;
12
+ --serif: 'Instrument Serif', serif;
13
+ --mono: 'Geist Mono', ui-monospace, monospace; }
14
+ #done-flow-root { color: var(--ink); font-family: var(--sans); }
15
+ #done-flow-root .diagram-container { overflow-x: auto; }
16
+ #done-flow-root .lifeline { stroke: rgba(16,24,40,.20); stroke-width: 1; stroke-dasharray: 4 4; }
17
+ #done-flow-root .activation { fill: rgba(16,24,40,.06); stroke: #4c5665; stroke-width: .8; }
18
+ #done-flow-root .fragment { fill: rgba(16,24,40,.02); stroke: rgba(16,24,40,.24); stroke-width: 1; }
19
+ #done-flow-root .fragment-tab { fill: #f0eee9; stroke: rgba(16,24,40,.24); stroke-width: 1; }
20
+ #done-flow-root .fragment-label { fill: #4c5665; font: 500 8px 'Geist Mono', monospace; text-anchor: middle; letter-spacing: .12em; }
21
+ #done-flow-root .guard { fill: #4c5665; font: 400 8px 'Geist Mono', monospace; letter-spacing: .04em; }
22
+ #done-flow-root .gate-badge { fill: rgba(29,78,216,.08); stroke: #1d4ed8; stroke-width: 1; }
23
+ #done-flow-root .gate-label { fill: #1d4ed8; font: 500 8px 'Geist Mono', monospace; text-anchor: middle; letter-spacing: .08em; }
24
+ #done-flow-root .message { fill: none; stroke: #4c5665; stroke-width: 1.2; marker-end: url(#done-flow-done-flow-arrow); }
25
+ #done-flow-root .message-return { fill: none; stroke: #4c5665; stroke-width: 1.2; stroke-dasharray: 4 4; marker-end: url(#done-flow-done-flow-arrow); }
26
+ #done-flow-root .message-accent { fill: none; stroke: #1d4ed8; stroke-width: 1.4; marker-end: url(#done-flow-done-flow-arrow-accent); }
27
+ #done-flow-root .label-mask { fill: #f0eee9; }
28
+ #done-flow-root .message-label { fill: #4c5665; font: 400 8px 'Geist Mono', monospace; text-anchor: middle; letter-spacing: .04em; }
29
+ #done-flow-root .message-label-accent { fill: #1d4ed8; font: 500 8px 'Geist Mono', monospace; text-anchor: middle; letter-spacing: .04em; }
30
+ #done-flow-root .actor { fill: #fff; stroke: #101828; stroke-width: 1; }
31
+ #done-flow-root .actor-input { fill: rgba(76,86,101,.10); stroke: #6a7282; stroke-width: 1; }
32
+ #done-flow-root .actor-state { fill: rgba(16,24,40,.05); stroke: #4c5665; stroke-width: 1; }
33
+ #done-flow-root .actor-name { fill: #101828; font: 600 12px 'Geist', sans-serif; text-anchor: middle; }
34
+ #done-flow-root .actor-sub { fill: #4c5665; font: 400 9px 'Geist Mono', monospace; text-anchor: middle; letter-spacing: .04em; }
35
+ #done-flow-root .boundary { stroke: rgba(16,24,40,.24); stroke-width: 1; stroke-dasharray: 4 4; }
36
+ #done-flow-root .boundary-label { fill: #4c5665; font: 500 8px 'Geist Mono', monospace; text-anchor: middle; letter-spacing: .08em; }
37
+ #done-flow-root .legend-label { fill: #4c5665; font: 400 8px 'Geist', sans-serif; }
38
+ #done-flow-root .legend-title { fill: #6a7282; font: 500 8px 'Geist Mono', monospace; letter-spacing: .16em; }</style>
39
+ <style>
40
+ .lifeline { stroke: rgba(16,24,40,.20); stroke-width: 1; stroke-dasharray: 4 4; }
41
+ .activation { fill: rgba(16,24,40,.06); stroke: #4c5665; stroke-width: .8; }
42
+ .fragment { fill: rgba(16,24,40,.02); stroke: rgba(16,24,40,.24); stroke-width: 1; }
43
+ .fragment-tab { fill: #f0eee9; stroke: rgba(16,24,40,.24); stroke-width: 1; }
44
+ .fragment-label { fill: #4c5665; font: 500 8px 'Geist Mono', monospace; text-anchor: middle; letter-spacing: .12em; }
45
+ .guard { fill: #4c5665; font: 400 8px 'Geist Mono', monospace; letter-spacing: .04em; }
46
+ .gate-badge { fill: rgba(29,78,216,.08); stroke: #1d4ed8; stroke-width: 1; }
47
+ .gate-label { fill: #1d4ed8; font: 500 8px 'Geist Mono', monospace; text-anchor: middle; letter-spacing: .08em; }
48
+ .message { fill: none; stroke: #4c5665; stroke-width: 1.2; marker-end: url(#done-flow-done-flow-arrow); }
49
+ .message-return { fill: none; stroke: #4c5665; stroke-width: 1.2; stroke-dasharray: 4 4; marker-end: url(#done-flow-done-flow-arrow); }
50
+ .message-accent { fill: none; stroke: #1d4ed8; stroke-width: 1.4; marker-end: url(#done-flow-done-flow-arrow-accent); }
51
+ .label-mask { fill: #f0eee9; }
52
+ .message-label { fill: #4c5665; font: 400 8px 'Geist Mono', monospace; text-anchor: middle; letter-spacing: .04em; }
53
+ .message-label-accent { fill: #1d4ed8; font: 500 8px 'Geist Mono', monospace; text-anchor: middle; letter-spacing: .04em; }
54
+ .actor { fill: #fff; stroke: #101828; stroke-width: 1; }
55
+ .actor-input { fill: rgba(76,86,101,.10); stroke: #6a7282; stroke-width: 1; }
56
+ .actor-state { fill: rgba(16,24,40,.05); stroke: #4c5665; stroke-width: 1; }
57
+ .actor-name { fill: #101828; font: 600 12px 'Geist', sans-serif; text-anchor: middle; }
58
+ .actor-sub { fill: #4c5665; font: 400 9px 'Geist Mono', monospace; text-anchor: middle; letter-spacing: .04em; }
59
+ .boundary { stroke: rgba(16,24,40,.24); stroke-width: 1; stroke-dasharray: 4 4; }
60
+ .boundary-label { fill: #4c5665; font: 500 8px 'Geist Mono', monospace; text-anchor: middle; letter-spacing: .08em; }
61
+ .legend-label { fill: #4c5665; font: 400 8px 'Geist', sans-serif; }
62
+ .legend-title { fill: #6a7282; font: 500 8px 'Geist Mono', monospace; letter-spacing: .16em; }
63
+ </style>
64
+ <marker id="done-flow-done-flow-arrow" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto">
65
+ <polygon points="0 0,8 3,0 6" fill="#4c5665"/>
66
+ </marker>
67
+ <marker id="done-flow-done-flow-arrow-accent" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto">
68
+ <polygon points="0 0,8 3,0 6" fill="#1d4ed8"/>
69
+ </marker>
70
+ <marker id="done-flow-done-flow-arrow-link" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto">
71
+ <polygon points="0 0,8 3,0 6" fill="#1d4ed8"/>
72
+ </marker>
73
+ </defs>
74
+
75
+ <rect width="1280" height="720" fill="#f0eee9"/>
76
+
77
+ <!-- Optional normal-mode gates; both modes wait before cleanup. -->
78
+ <rect class="fragment" x="120" y="144" width="364" height="144" rx="4"/>
79
+ <rect class="fragment" x="388" y="352" width="292" height="92" rx="4"/>
80
+
81
+ <!-- Lifelines and activation bars -->
82
+ <line class="lifeline" x1="136" y1="96" x2="136" y2="624"/>
83
+ <line class="lifeline" x1="404" y1="96" x2="404" y2="624"/>
84
+ <line class="lifeline" x1="652" y1="96" x2="652" y2="624"/>
85
+ <line class="lifeline" x1="1124" y1="96" x2="1124" y2="624"/>
86
+ <rect class="activation" x="400" y="124" width="8" height="476"/>
87
+ <rect class="activation" x="648" y="396" width="8" height="28"/>
88
+ <rect class="activation" x="648" y="456" width="8" height="16"/>
89
+ <rect class="activation" x="1120" y="544" width="8" height="24"/>
90
+
91
+ <rect class="fragment-tab" x="120" y="144" width="40" height="16" rx="4"/>
92
+ <text class="fragment-label" x="140" y="156">OPT</text>
93
+ <rect class="label-mask" x="128" y="164" width="344" height="16"/>
94
+ <text class="guard" x="132" y="176">[normal /done; --force skips confirmation]</text>
95
+ <rect class="fragment-tab" x="388" y="352" width="40" height="16" rx="4"/>
96
+ <text class="fragment-label" x="408" y="364">OPT</text>
97
+ <text class="guard" x="440" y="364">[normal /done]</text>
98
+
99
+ <!-- Messages: time flows downward -->
100
+ <line class="message" x1="136" y1="124" x2="400" y2="124"/>
101
+ <rect class="label-mask" x="224" y="104" width="88" height="12" rx="4"/>
102
+ <text class="message-label" x="268" y="112">RUN /DONE</text>
103
+
104
+ <line class="message" x1="400" y1="208" x2="136" y2="208"/>
105
+ <rect class="label-mask" x="224" y="188" width="88" height="12" rx="4"/>
106
+ <text class="message-label" x="268" y="196">CONFIRM?</text>
107
+ <line class="message-return" x1="136" y1="244" x2="400" y2="244"/>
108
+ <rect class="label-mask" x="224" y="224" width="88" height="12" rx="4"/>
109
+ <text class="message-label" x="268" y="232">YES / STOP</text>
110
+
111
+ <path class="message" d="M408 308 H452 Q460 308 460 316 V332 Q460 340 452 340 H412"/>
112
+ <rect class="label-mask" x="468" y="316" width="112" height="12" rx="4"/>
113
+ <text class="message-label" x="524" y="324">WAIT FOR IDLE</text>
114
+
115
+ <line class="message" x1="408" y1="396" x2="648" y2="396"/>
116
+ <rect class="label-mask" x="432" y="376" width="192" height="12" rx="4"/>
117
+ <text class="message-label" x="528" y="384">CHECK CROSS-WORKSPACE CHECKOUT USE</text>
118
+ <line class="message-return" x1="648" y1="424" x2="408" y2="424"/>
119
+ <rect class="label-mask" x="484" y="404" width="88" height="12" rx="4"/>
120
+ <text class="message-label" x="528" y="412">CLEAR / REFUSE</text>
121
+
122
+ <!-- Safety details apply to the current flow, not a proposed flow. -->
123
+ <text class="guard" x="744" y="180">Decline: stop without waiting or changing the checkout.</text>
124
+ <text class="guard" x="744" y="204">Both modes wait for Pi to become idle before cleanup.</text>
125
+ <text class="guard" x="744" y="372">Normal: another workspace using this checkout blocks removal.</text>
126
+ <text class="guard" x="744" y="396">Git refuses dirty worktrees unless --force is set.</text>
127
+ <text class="guard" x="744" y="420">--force skips the cross-workspace checkout-use check; data loss is irreversible.</text>
128
+ <text class="guard" x="744" y="444">Locks serialize worktree removal and primary-checkout updates.</text>
129
+
130
+ <line class="message-accent" x1="408" y1="464" x2="648" y2="464"/>
131
+ <rect class="label-mask" x="448" y="436" width="160" height="20" rx="4"/>
132
+ <text class="message-label-accent" x="528" y="444">CLEAN / FORCE</text>
133
+ <text class="message-label-accent" x="528" y="452">REMOVE WORKTREE</text>
134
+
135
+ <!-- Successful removal is the partial-success boundary -->
136
+ <line class="boundary" x1="40" y1="488" x2="392" y2="488"/>
137
+ <line class="boundary" x1="888" y1="488" x2="1240" y2="488"/>
138
+ <text class="boundary-label" x="640" y="492">PARTIAL-SUCCESS BOUNDARY · WORKTREE REMOVED</text>
139
+
140
+ <line class="message" x1="400" y1="516" x2="136" y2="516"/>
141
+ <rect class="label-mask" x="180" y="496" width="176" height="12" rx="4"/>
142
+ <text class="message-label" x="268" y="504">CLOSE SIBLINGS</text>
143
+
144
+ <line class="message" x1="408" y1="544" x2="1120" y2="544"/>
145
+ <rect class="label-mask" x="684" y="516" width="160" height="20" rx="4"/>
146
+ <text class="message-label" x="764" y="524">LINKED PRIMARY</text>
147
+ <text class="message-label" x="764" y="532">PULL --FF-ONLY</text>
148
+
149
+ <line class="message-return" x1="1120" y1="568" x2="408" y2="568"/>
150
+ <rect class="label-mask" x="696" y="548" width="136" height="12" rx="4"/>
151
+ <text class="message-label" x="764" y="556">DONE / FAILED</text>
152
+
153
+ <line class="message" x1="400" y1="600" x2="136" y2="600"/>
154
+ <rect class="label-mask" x="184" y="580" width="168" height="12" rx="4"/>
155
+ <text class="message-label" x="268" y="588">CLOSE THIS TAB</text>
156
+
157
+ <!-- Actors are drawn after messages -->
158
+ <rect x="56" y="40" width="160" height="56" rx="6" fill="#f0eee9"/>
159
+ <rect class="actor-input" x="56" y="40" width="160" height="56" rx="6"/>
160
+ <text class="actor-name" x="136" y="68">Herdr workspace</text>
161
+ <text class="actor-sub" x="136" y="84">THIS WORKSPACE</text>
162
+
163
+ <rect x="324" y="40" width="160" height="56" rx="6" fill="#f0eee9"/>
164
+ <rect class="actor" x="324" y="40" width="160" height="56" rx="6"/>
165
+ <text class="actor-name" x="404" y="68">Pi /done</text>
166
+ <text class="actor-sub" x="404" y="84">IDLE BEFORE CLEANUP</text>
167
+
168
+ <rect x="572" y="40" width="160" height="56" rx="6" fill="#f0eee9"/>
169
+ <rect class="actor-state" x="572" y="40" width="160" height="56" rx="6"/>
170
+ <text class="actor-name" x="652" y="68">Removal gate</text>
171
+ <text class="actor-sub" x="652" y="84">WORKTREE + TAB USE</text>
172
+
173
+ <rect x="1044" y="40" width="160" height="56" rx="6" fill="#f0eee9"/>
174
+ <rect class="actor" x="1044" y="40" width="160" height="56" rx="6"/>
175
+ <text class="actor-name" x="1124" y="68">Parent checkout</text>
176
+ <text class="actor-sub" x="1124" y="84">LINKED + NON-BARE</text>
177
+
178
+ <text class="guard" x="744" y="604">Close this tab last, even if sibling cleanup or pull fails.</text>
179
+
180
+ <!-- Legend strip -->
181
+ <line x1="40" y1="640" x2="1240" y2="640" stroke="#101828" stroke-width=".8" stroke-opacity=".141"/>
182
+ <text class="legend-title" x="40" y="668">LEGEND</text>
183
+
184
+ <line class="message" x1="128" y1="664" x2="164" y2="664"/>
185
+ <text class="legend-label" x="176" y="668">Action</text>
186
+
187
+ <line class="message-return" x1="264" y1="664" x2="300" y2="664"/>
188
+ <text class="legend-label" x="312" y="668">Return or result</text>
189
+
190
+ <rect class="fragment" x="448" y="656" width="32" height="16" rx="4"/>
191
+ <text class="fragment-label" x="464" y="668">OPT</text>
192
+ <text class="legend-label" x="492" y="668">Normal-mode gate</text>
193
+
194
+ <line class="message-accent" x1="624" y1="664" x2="660" y2="664"/>
195
+ <text class="legend-label" x="672" y="668">Successful removal</text>
196
+ </svg>
@@ -0,0 +1,40 @@
1
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import registerBtwExtension, { BTW_TASK } from "../internal/btw.ts";
3
+ import herdrCloneExtension from "../internal/clone-tab.ts";
4
+ import herdrDoneExtension from "../internal/done.ts";
5
+ import herdrHandoffExtension from "../internal/handoff.ts";
6
+ import idleRecapExtension, { RECAP_TASK } from "../internal/recap.ts";
7
+ import herdrRenameExtension, { RENAME_TASK } from "../internal/rename.ts";
8
+ import { registerTaskModelsWarning } from "../internal/task-models.ts";
9
+
10
+ export default async function herdrToolsExtension(pi: ExtensionAPI): Promise<void> {
11
+ registerTaskModelsWarning(pi, [RENAME_TASK, BTW_TASK, RECAP_TASK]);
12
+ herdrRenameExtension(pi);
13
+ idleRecapExtension(pi);
14
+ await registerBtwExtension(pi);
15
+ herdrCloneExtension(pi);
16
+ herdrDoneExtension(pi);
17
+ herdrHandoffExtension(pi);
18
+ registerDialogStatus(pi);
19
+ }
20
+
21
+ /** Report open TUI dialogs through Herdr's blocked-status event, contributing at most one block. */
22
+ function registerDialogStatus(pi: ExtensionAPI): void {
23
+ // An earlier async ui_prompt_start handler can delay this start until after its end,
24
+ // so a signed balance returns to zero instead of leaving a stale block.
25
+ let balance = 0;
26
+ let closed = false;
27
+ const track = (delta: 1 | -1) => (_event: unknown, ctx: ExtensionContext) => {
28
+ if (closed || ctx.mode !== "tui") return;
29
+ const wasBlocked = balance > 0;
30
+ balance += delta;
31
+ if ((balance > 0) === wasBlocked) return;
32
+ pi.events.emit("herdr:blocked", wasBlocked ? { active: false } : { active: true, label: "Input required" });
33
+ };
34
+ pi.on("ui_prompt_start", track(1));
35
+ pi.on("ui_prompt_end", track(-1));
36
+ pi.on("session_shutdown", () => {
37
+ closed = true;
38
+ if (balance > 0) pi.events.emit("herdr:blocked", { active: false });
39
+ });
40
+ }