pi-mono-all 1.0.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.
- package/CHANGELOG.md +13 -0
- package/LICENCE.md +7 -0
- package/node_modules/pi-common/package.json +22 -0
- package/node_modules/pi-common/src/auth-config.ts +290 -0
- package/node_modules/pi-common/src/auth.ts +63 -0
- package/node_modules/pi-common/src/cache.ts +60 -0
- package/node_modules/pi-common/src/errors.ts +47 -0
- package/node_modules/pi-common/src/http-client.ts +118 -0
- package/node_modules/pi-common/src/index.ts +7 -0
- package/node_modules/pi-common/src/rate-limiter.ts +32 -0
- package/node_modules/pi-common/src/tool-result.ts +27 -0
- package/node_modules/pi-mono-ask-user-question/CHANGELOG.md +185 -0
- package/node_modules/pi-mono-ask-user-question/README.md +226 -0
- package/node_modules/pi-mono-ask-user-question/index.ts +923 -0
- package/node_modules/pi-mono-ask-user-question/package.json +29 -0
- package/node_modules/pi-mono-auto-fix/CHANGELOG.md +59 -0
- package/node_modules/pi-mono-auto-fix/README.md +77 -0
- package/node_modules/pi-mono-auto-fix/index.ts +488 -0
- package/node_modules/pi-mono-auto-fix/package.json +23 -0
- package/node_modules/pi-mono-btw/CHANGELOG.md +180 -0
- package/node_modules/pi-mono-btw/README.md +24 -0
- package/node_modules/pi-mono-btw/index.ts +499 -0
- package/node_modules/pi-mono-btw/package.json +29 -0
- package/node_modules/pi-mono-clear/CHANGELOG.md +180 -0
- package/node_modules/pi-mono-clear/README.md +40 -0
- package/node_modules/pi-mono-clear/index.ts +45 -0
- package/node_modules/pi-mono-clear/package.json +29 -0
- package/node_modules/pi-mono-context/CHANGELOG.md +12 -0
- package/node_modules/pi-mono-context/README.md +74 -0
- package/node_modules/pi-mono-context/index.ts +641 -0
- package/node_modules/pi-mono-context/package.json +29 -0
- package/node_modules/pi-mono-context-guard/CHANGELOG.md +195 -0
- package/node_modules/pi-mono-context-guard/README.md +81 -0
- package/node_modules/pi-mono-context-guard/index.ts +212 -0
- package/node_modules/pi-mono-context-guard/package.json +23 -0
- package/node_modules/pi-mono-figma/CHANGELOG.md +59 -0
- package/node_modules/pi-mono-figma/README.md +236 -0
- package/node_modules/pi-mono-figma/__tests__/code-connect.test.ts +32 -0
- package/node_modules/pi-mono-figma/__tests__/figma-assets.test.ts +38 -0
- package/node_modules/pi-mono-figma/__tests__/figma-component-hints.test.ts +23 -0
- package/node_modules/pi-mono-figma/__tests__/figma-implementation-layout.test.ts +47 -0
- package/node_modules/pi-mono-figma/__tests__/figma-search.test.ts +51 -0
- package/node_modules/pi-mono-figma/__tests__/figma-summarizer.test.ts +65 -0
- package/node_modules/pi-mono-figma/__tests__/fixtures/complex-auto-layout.json +115 -0
- package/node_modules/pi-mono-figma/__tests__/fixtures/component-instance.json +50 -0
- package/node_modules/pi-mono-figma/__tests__/fixtures/hidden-and-vectors.json +28 -0
- package/node_modules/pi-mono-figma/__tests__/fixtures/variables-and-styles.json +40 -0
- package/node_modules/pi-mono-figma/docs/live-selection-bridge.md +16 -0
- package/node_modules/pi-mono-figma/index.ts +6 -0
- package/node_modules/pi-mono-figma/package.json +33 -0
- package/node_modules/pi-mono-figma/skills/figma/SKILL.md +143 -0
- package/node_modules/pi-mono-figma/src/code-connect.ts +110 -0
- package/node_modules/pi-mono-figma/src/figma-assets.ts +146 -0
- package/node_modules/pi-mono-figma/src/figma-cache.ts +6 -0
- package/node_modules/pi-mono-figma/src/figma-client.ts +471 -0
- package/node_modules/pi-mono-figma/src/figma-component-hints.ts +87 -0
- package/node_modules/pi-mono-figma/src/figma-implementation.ts +264 -0
- package/node_modules/pi-mono-figma/src/figma-schemas.ts +139 -0
- package/node_modules/pi-mono-figma/src/figma-search.ts +195 -0
- package/node_modules/pi-mono-figma/src/figma-summarizer.ts +673 -0
- package/node_modules/pi-mono-figma/src/figma-tokens.ts +57 -0
- package/node_modules/pi-mono-figma/src/figma-tools.ts +352 -0
- package/node_modules/pi-mono-linear/CHANGELOG.md +44 -0
- package/node_modules/pi-mono-linear/README.md +159 -0
- package/node_modules/pi-mono-linear/index.ts +6 -0
- package/node_modules/pi-mono-linear/package.json +30 -0
- package/node_modules/pi-mono-linear/skills/linear/SKILL.md +107 -0
- package/node_modules/pi-mono-linear/src/linear-client.ts +339 -0
- package/node_modules/pi-mono-linear/src/linear-queries.ts +101 -0
- package/node_modules/pi-mono-linear/src/linear-schemas.ts +90 -0
- package/node_modules/pi-mono-linear/src/linear-tools.ts +362 -0
- package/node_modules/pi-mono-loop/CHANGELOG.md +163 -0
- package/node_modules/pi-mono-loop/README.md +54 -0
- package/node_modules/pi-mono-loop/index.ts +291 -0
- package/node_modules/pi-mono-loop/package.json +26 -0
- package/node_modules/pi-mono-multi-edit/CHANGELOG.md +232 -0
- package/node_modules/pi-mono-multi-edit/README.md +244 -0
- package/node_modules/pi-mono-multi-edit/__tests__/classic.test.ts +277 -0
- package/node_modules/pi-mono-multi-edit/__tests__/diff.test.ts +77 -0
- package/node_modules/pi-mono-multi-edit/__tests__/patch.test.ts +287 -0
- package/node_modules/pi-mono-multi-edit/benchmark-edits.ts +966 -0
- package/node_modules/pi-mono-multi-edit/classic.ts +435 -0
- package/node_modules/pi-mono-multi-edit/diff.ts +143 -0
- package/node_modules/pi-mono-multi-edit/index.ts +266 -0
- package/node_modules/pi-mono-multi-edit/package.json +37 -0
- package/node_modules/pi-mono-multi-edit/patch.ts +463 -0
- package/node_modules/pi-mono-multi-edit/types.ts +53 -0
- package/node_modules/pi-mono-multi-edit/workspace.ts +85 -0
- package/node_modules/pi-mono-review/CHANGELOG.md +190 -0
- package/node_modules/pi-mono-review/README.md +30 -0
- package/node_modules/pi-mono-review/common.ts +930 -0
- package/node_modules/pi-mono-review/index.ts +8 -0
- package/node_modules/pi-mono-review/package.json +29 -0
- package/node_modules/pi-mono-review/review-tui.ts +194 -0
- package/node_modules/pi-mono-review/review.ts +119 -0
- package/node_modules/pi-mono-review/reviewer.ts +339 -0
- package/node_modules/pi-mono-sentinel/CHANGELOG.md +158 -0
- package/node_modules/pi-mono-sentinel/README.md +87 -0
- package/node_modules/pi-mono-sentinel/__tests__/output-scanner.test.ts +109 -0
- package/node_modules/pi-mono-sentinel/__tests__/permissions.test.ts +202 -0
- package/node_modules/pi-mono-sentinel/__tests__/whitelist.test.ts +59 -0
- package/node_modules/pi-mono-sentinel/guards/execution-tracker.ts +281 -0
- package/node_modules/pi-mono-sentinel/guards/output-scanner.ts +232 -0
- package/node_modules/pi-mono-sentinel/guards/permission-gate.ts +170 -0
- package/node_modules/pi-mono-sentinel/index.ts +43 -0
- package/node_modules/pi-mono-sentinel/package.json +26 -0
- package/node_modules/pi-mono-sentinel/patterns/permissions.ts +175 -0
- package/node_modules/pi-mono-sentinel/patterns/read-targets.ts +104 -0
- package/node_modules/pi-mono-sentinel/patterns/secrets.ts +143 -0
- package/node_modules/pi-mono-sentinel/session.ts +95 -0
- package/node_modules/pi-mono-sentinel/specs/2026/04/sentinel/001-permission-gate.md +145 -0
- package/node_modules/pi-mono-sentinel/types.ts +39 -0
- package/node_modules/pi-mono-sentinel/whitelist.ts +86 -0
- package/node_modules/pi-mono-simplify/CHANGELOG.md +163 -0
- package/node_modules/pi-mono-simplify/README.md +56 -0
- package/node_modules/pi-mono-simplify/index.ts +78 -0
- package/node_modules/pi-mono-simplify/package.json +29 -0
- package/node_modules/pi-mono-status-line/CHANGELOG.md +180 -0
- package/node_modules/pi-mono-status-line/README.md +96 -0
- package/node_modules/pi-mono-status-line/basic.ts +89 -0
- package/node_modules/pi-mono-status-line/expert.ts +689 -0
- package/node_modules/pi-mono-status-line/index.ts +54 -0
- package/node_modules/pi-mono-status-line/package.json +29 -0
- package/node_modules/pi-mono-team-mode/CHANGELOG.md +278 -0
- package/node_modules/pi-mono-team-mode/README.md +246 -0
- package/node_modules/pi-mono-team-mode/__tests__/agent-manager-transient.test.ts +75 -0
- package/node_modules/pi-mono-team-mode/__tests__/delegation-manager.test.ts +118 -0
- package/node_modules/pi-mono-team-mode/__tests__/formatters.test.ts +104 -0
- package/node_modules/pi-mono-team-mode/__tests__/model-config.test.ts +272 -0
- package/node_modules/pi-mono-team-mode/__tests__/notification-box.test.ts +34 -0
- package/node_modules/pi-mono-team-mode/__tests__/parallel-utils.test.ts +32 -0
- package/node_modules/pi-mono-team-mode/__tests__/pi-stream-parser.test.ts +64 -0
- package/node_modules/pi-mono-team-mode/__tests__/prompts.test.ts +106 -0
- package/node_modules/pi-mono-team-mode/__tests__/store.test.ts +164 -0
- package/node_modules/pi-mono-team-mode/__tests__/tasks.test.ts +267 -0
- package/node_modules/pi-mono-team-mode/__tests__/teammate-specs.test.ts +114 -0
- package/node_modules/pi-mono-team-mode/__tests__/widget.test.ts +41 -0
- package/node_modules/pi-mono-team-mode/__tests__/worktree.test.ts +78 -0
- package/node_modules/pi-mono-team-mode/core/chain-utils.ts +90 -0
- package/node_modules/pi-mono-team-mode/core/fs-utils.ts +44 -0
- package/node_modules/pi-mono-team-mode/core/model-config.ts +432 -0
- package/node_modules/pi-mono-team-mode/core/parallel-utils.ts +48 -0
- package/node_modules/pi-mono-team-mode/core/prompts.ts +158 -0
- package/node_modules/pi-mono-team-mode/core/store.ts +156 -0
- package/node_modules/pi-mono-team-mode/core/tasks.ts +99 -0
- package/node_modules/pi-mono-team-mode/core/teammate-specs.ts +124 -0
- package/node_modules/pi-mono-team-mode/core/types.ts +160 -0
- package/node_modules/pi-mono-team-mode/index.ts +825 -0
- package/node_modules/pi-mono-team-mode/managers/agent-manager.ts +654 -0
- package/node_modules/pi-mono-team-mode/managers/delegation-manager.ts +211 -0
- package/node_modules/pi-mono-team-mode/managers/task-manager.ts +238 -0
- package/node_modules/pi-mono-team-mode/managers/team-manager.ts +59 -0
- package/node_modules/pi-mono-team-mode/package.json +33 -0
- package/node_modules/pi-mono-team-mode/runtime/pi-stream-parser.ts +194 -0
- package/node_modules/pi-mono-team-mode/runtime/subprocess.ts +183 -0
- package/node_modules/pi-mono-team-mode/runtime/transient-session.ts +196 -0
- package/node_modules/pi-mono-team-mode/runtime/worktree.ts +90 -0
- package/node_modules/pi-mono-team-mode/ui/formatters.ts +149 -0
- package/node_modules/pi-mono-team-mode/ui/notification-box.ts +55 -0
- package/node_modules/pi-mono-team-mode/ui/widget.ts +94 -0
- package/package.json +76 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loop — run a prompt or slash command on a recurring interval.
|
|
3
|
+
*
|
|
4
|
+
* Adapted from: https://github.com/emanuelcasco/claude-code/blob/main/src/skills/bundled/loop.ts
|
|
5
|
+
* Original uses Claude Code's Kairos cron system; this version uses JS timers
|
|
6
|
+
* + pi.sendUserMessage() instead.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* /loop [interval] <prompt>
|
|
10
|
+
*
|
|
11
|
+
* Intervals: Ns, Nm, Nh, Nd (e.g. 5m, 30m, 2h, 1d). Minimum is 10s.
|
|
12
|
+
* If no interval is specified, defaults to 10m.
|
|
13
|
+
*
|
|
14
|
+
* Examples:
|
|
15
|
+
* /loop 5m /review
|
|
16
|
+
* /loop 30m check the deploy
|
|
17
|
+
* /loop 1h run the tests and report failures
|
|
18
|
+
* /loop check the deploy (defaults to 10m)
|
|
19
|
+
* /loop check the deploy every 20m
|
|
20
|
+
* /loop stop (cancel all active loops)
|
|
21
|
+
* /loop stop <id> (cancel a specific loop)
|
|
22
|
+
* /loop list (show active loops)
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
26
|
+
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Constants
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
const DEFAULT_INTERVAL = "10m";
|
|
32
|
+
const MIN_INTERVAL_MS = 10_000; // 10 seconds
|
|
33
|
+
const MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000; // 7 days
|
|
34
|
+
|
|
35
|
+
const USAGE_MESSAGE = `Usage: /loop [interval] <prompt>
|
|
36
|
+
|
|
37
|
+
Run a prompt or slash command on a recurring interval.
|
|
38
|
+
|
|
39
|
+
Intervals: Ns, Nm, Nh, Nd (e.g. 5m, 30m, 2h, 1d). Minimum is 10s.
|
|
40
|
+
If no interval is specified, defaults to ${DEFAULT_INTERVAL}.
|
|
41
|
+
|
|
42
|
+
Subcommands:
|
|
43
|
+
/loop list — list active loops
|
|
44
|
+
/loop stop — cancel all active loops
|
|
45
|
+
/loop stop <id> — cancel a specific loop by ID
|
|
46
|
+
|
|
47
|
+
Examples:
|
|
48
|
+
/loop 5m /review
|
|
49
|
+
/loop 30m check the deploy
|
|
50
|
+
/loop 1h run the tests
|
|
51
|
+
/loop check the deploy (defaults to ${DEFAULT_INTERVAL})
|
|
52
|
+
/loop check the deploy every 20m`;
|
|
53
|
+
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
// Types
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
|
|
58
|
+
interface LoopEntry {
|
|
59
|
+
id: string;
|
|
60
|
+
prompt: string;
|
|
61
|
+
intervalMs: number;
|
|
62
|
+
intervalLabel: string;
|
|
63
|
+
createdAt: Date;
|
|
64
|
+
fireCount: number;
|
|
65
|
+
timer: ReturnType<typeof setInterval>;
|
|
66
|
+
expiryTimer: ReturnType<typeof setTimeout>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
// Interval parsing helpers
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
/** Parse a token like "5m", "2h", "30s", "1d" → milliseconds, or null. */
|
|
74
|
+
function parseIntervalToken(token: string): number | null {
|
|
75
|
+
const m = token.match(/^(\d+(?:\.\d+)?)(s|m|h|d)$/i);
|
|
76
|
+
if (!m) return null;
|
|
77
|
+
const n = parseFloat(m[1]!);
|
|
78
|
+
const unit = m[2]!.toLowerCase();
|
|
79
|
+
switch (unit) {
|
|
80
|
+
case "s":
|
|
81
|
+
return n * 1_000;
|
|
82
|
+
case "m":
|
|
83
|
+
return n * 60_000;
|
|
84
|
+
case "h":
|
|
85
|
+
return n * 3_600_000;
|
|
86
|
+
case "d":
|
|
87
|
+
return n * 86_400_000;
|
|
88
|
+
default:
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Human-readable label for an interval in ms. */
|
|
94
|
+
function formatInterval(ms: number): string {
|
|
95
|
+
if (ms < 60_000) return `${Math.round(ms / 1_000)}s`;
|
|
96
|
+
if (ms < 3_600_000) return `${Math.round(ms / 60_000)}m`;
|
|
97
|
+
if (ms < 86_400_000) return `${Math.round(ms / 3_600_000)}h`;
|
|
98
|
+
return `${Math.round(ms / 86_400_000)}d`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface ParseResult {
|
|
102
|
+
intervalMs: number;
|
|
103
|
+
intervalLabel: string;
|
|
104
|
+
prompt: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Parse `[interval] <prompt>` using the same priority rules as the original skill:
|
|
109
|
+
* 1. Leading token that matches \d+[smhd]
|
|
110
|
+
* 2. Trailing "every <N><unit>" clause
|
|
111
|
+
* 3. Default interval (DEFAULT_INTERVAL)
|
|
112
|
+
*/
|
|
113
|
+
function parseArgs(input: string): ParseResult | null {
|
|
114
|
+
const trimmed = input.trim();
|
|
115
|
+
if (!trimmed) return null;
|
|
116
|
+
|
|
117
|
+
// Rule 1 — leading token
|
|
118
|
+
const parts = trimmed.split(/\s+/);
|
|
119
|
+
const leading = parts[0]!;
|
|
120
|
+
const leadingMs = parseIntervalToken(leading);
|
|
121
|
+
if (leadingMs !== null) {
|
|
122
|
+
const prompt = parts.slice(1).join(" ").trim();
|
|
123
|
+
return { intervalMs: leadingMs, intervalLabel: leading.toLowerCase(), prompt };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Rule 2 — trailing "every <N><unit>" or "every <N> <unit-word>"
|
|
127
|
+
const trailingExact = trimmed.match(/^([\s\S]+?)\s+every\s+(\d+(?:\.\d+)?)(s|m|h|d|seconds?|minutes?|hours?|days?)$/i);
|
|
128
|
+
if (trailingExact) {
|
|
129
|
+
const rawUnit = trailingExact[3]!.toLowerCase();
|
|
130
|
+
const canonicalUnit = rawUnit.startsWith("s")
|
|
131
|
+
? "s"
|
|
132
|
+
: rawUnit.startsWith("m")
|
|
133
|
+
? "m"
|
|
134
|
+
: rawUnit.startsWith("h")
|
|
135
|
+
? "h"
|
|
136
|
+
: "d";
|
|
137
|
+
const token = `${trailingExact[2]}${canonicalUnit}`;
|
|
138
|
+
const ms = parseIntervalToken(token)!;
|
|
139
|
+
const prompt = trailingExact[1]!.trim();
|
|
140
|
+
return { intervalMs: ms, intervalLabel: token, prompt };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Rule 3 — default
|
|
144
|
+
const defaultMs = parseIntervalToken(DEFAULT_INTERVAL)!;
|
|
145
|
+
return { intervalMs: defaultMs, intervalLabel: DEFAULT_INTERVAL, prompt: trimmed };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ---------------------------------------------------------------------------
|
|
149
|
+
// Loop registry (in-memory, process-scoped)
|
|
150
|
+
// ---------------------------------------------------------------------------
|
|
151
|
+
|
|
152
|
+
const activeLoops = new Map<string, LoopEntry>();
|
|
153
|
+
let nextLoopId = 1;
|
|
154
|
+
|
|
155
|
+
function generateId(): string {
|
|
156
|
+
return `loop-${nextLoopId++}`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function cancelLoop(entry: LoopEntry): void {
|
|
160
|
+
clearInterval(entry.timer);
|
|
161
|
+
clearTimeout(entry.expiryTimer);
|
|
162
|
+
activeLoops.delete(entry.id);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function cancelAllLoops(): number {
|
|
166
|
+
const count = activeLoops.size;
|
|
167
|
+
for (const entry of activeLoops.values()) {
|
|
168
|
+
cancelLoop(entry);
|
|
169
|
+
}
|
|
170
|
+
return count;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
// Extension
|
|
175
|
+
// ---------------------------------------------------------------------------
|
|
176
|
+
|
|
177
|
+
export default function (pi: ExtensionAPI) {
|
|
178
|
+
pi.registerCommand("loop", {
|
|
179
|
+
description: `Run a prompt on a recurring interval. Usage: /loop [interval] <prompt> (default: ${DEFAULT_INTERVAL})`,
|
|
180
|
+
handler: async (args, ctx) => {
|
|
181
|
+
const trimmed = args.trim();
|
|
182
|
+
|
|
183
|
+
// ── Subcommands ──────────────────────────────────────────────────
|
|
184
|
+
if (!trimmed || trimmed === "help") {
|
|
185
|
+
ctx.ui.notify(USAGE_MESSAGE, "info");
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (trimmed === "list") {
|
|
190
|
+
if (activeLoops.size === 0) {
|
|
191
|
+
ctx.ui.notify("No active loops.", "info");
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const lines = [...activeLoops.values()].map(
|
|
195
|
+
(e) =>
|
|
196
|
+
`• ${e.id} every ${formatInterval(e.intervalMs)} fires: ${e.fireCount} prompt: "${e.prompt}"`,
|
|
197
|
+
);
|
|
198
|
+
ctx.ui.notify(`Active loops (${activeLoops.size}):\n${lines.join("\n")}`, "info");
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (trimmed === "stop") {
|
|
203
|
+
const count = cancelAllLoops();
|
|
204
|
+
ctx.ui.notify(count > 0 ? `Cancelled ${count} loop(s).` : "No active loops to cancel.", "info");
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (trimmed.startsWith("stop ")) {
|
|
209
|
+
const id = trimmed.slice(5).trim();
|
|
210
|
+
const entry = activeLoops.get(id);
|
|
211
|
+
if (!entry) {
|
|
212
|
+
ctx.ui.notify(`No loop found with ID "${id}". Use /loop list to see active loops.`, "warning");
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
cancelLoop(entry);
|
|
216
|
+
ctx.ui.notify(`Loop "${id}" cancelled.`, "info");
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// ── Schedule ─────────────────────────────────────────────────────
|
|
221
|
+
const parsed = parseArgs(trimmed);
|
|
222
|
+
if (!parsed || !parsed.prompt) {
|
|
223
|
+
ctx.ui.notify(USAGE_MESSAGE, "warning");
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const { prompt, intervalMs, intervalLabel } = parsed;
|
|
228
|
+
|
|
229
|
+
if (intervalMs < MIN_INTERVAL_MS) {
|
|
230
|
+
ctx.ui.notify(
|
|
231
|
+
`Interval "${intervalLabel}" is below the minimum (${formatInterval(MIN_INTERVAL_MS)}). Using ${formatInterval(MIN_INTERVAL_MS)} instead.`,
|
|
232
|
+
"warning",
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
const effectiveMs = Math.max(intervalMs, MIN_INTERVAL_MS);
|
|
236
|
+
|
|
237
|
+
const id = generateId();
|
|
238
|
+
|
|
239
|
+
const sendPrompt = () => {
|
|
240
|
+
const entry = activeLoops.get(id);
|
|
241
|
+
if (entry) entry.fireCount++;
|
|
242
|
+
// Wait for the agent to be idle before sending the next prompt
|
|
243
|
+
if (!ctx.isIdle()) {
|
|
244
|
+
pi.sendUserMessage(prompt, { deliverAs: "followUp" });
|
|
245
|
+
} else {
|
|
246
|
+
pi.sendUserMessage(prompt);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const timer = setInterval(sendPrompt, effectiveMs);
|
|
251
|
+
|
|
252
|
+
const expiryTimer = setTimeout(() => {
|
|
253
|
+
const entry = activeLoops.get(id);
|
|
254
|
+
if (entry) {
|
|
255
|
+
cancelLoop(entry);
|
|
256
|
+
ctx.ui.notify(`Loop "${id}" auto-expired after ${formatInterval(MAX_AGE_MS)}.`, "info");
|
|
257
|
+
}
|
|
258
|
+
}, MAX_AGE_MS);
|
|
259
|
+
|
|
260
|
+
const entry: LoopEntry = {
|
|
261
|
+
id,
|
|
262
|
+
prompt,
|
|
263
|
+
intervalMs: effectiveMs,
|
|
264
|
+
intervalLabel: formatInterval(effectiveMs),
|
|
265
|
+
createdAt: new Date(),
|
|
266
|
+
fireCount: 0,
|
|
267
|
+
timer,
|
|
268
|
+
expiryTimer,
|
|
269
|
+
};
|
|
270
|
+
activeLoops.set(id, entry);
|
|
271
|
+
|
|
272
|
+
ctx.ui.notify(
|
|
273
|
+
`Loop scheduled!\n` +
|
|
274
|
+
` ID: ${id}\n` +
|
|
275
|
+
` Prompt: "${prompt}"\n` +
|
|
276
|
+
` Interval: every ${formatInterval(effectiveMs)}\n` +
|
|
277
|
+
` Auto-expires: after ${formatInterval(MAX_AGE_MS)}\n` +
|
|
278
|
+
` Cancel with: /loop stop ${id}`,
|
|
279
|
+
"info",
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
// Run the prompt immediately on first invocation
|
|
283
|
+
pi.sendUserMessage(prompt);
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
// Clean up timers on shutdown to avoid leaks
|
|
288
|
+
pi.on("session_shutdown", () => {
|
|
289
|
+
cancelAllLoops();
|
|
290
|
+
});
|
|
291
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-mono-loop",
|
|
3
|
+
"version": "1.7.2",
|
|
4
|
+
"description": "Pi extension that runs a prompt or slash command on a recurring interval",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package",
|
|
7
|
+
"pi-extension"
|
|
8
|
+
],
|
|
9
|
+
"peerDependencies": {
|
|
10
|
+
"@mariozechner/pi-coding-agent": "*"
|
|
11
|
+
},
|
|
12
|
+
"pi": {
|
|
13
|
+
"extensions": [
|
|
14
|
+
"./index.ts"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/emanuelcasco/pi-mono-extensions.git",
|
|
20
|
+
"directory": "extensions/loop"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/emanuelcasco/pi-mono-extensions/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/emanuelcasco/pi-mono-extensions#readme"
|
|
26
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# pi-mono-multi-edit
|
|
2
|
+
|
|
3
|
+
## 1.7.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
### Fixed: ask-user-question
|
|
8
|
+
|
|
9
|
+
- Remove unused `StringEnum` import from `@mariozechner/pi-ai`.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## 1.7.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
### Fixed: team-mode
|
|
17
|
+
|
|
18
|
+
- Widget no longer mislabels blocked or approval-pending teams as "running smoothly" — blockers and pending approvals are now detected via team summaries.
|
|
19
|
+
- Preserve in-flight work on re-emitted `session_start` events instead of tearing the runtime down and SIGTERM-ing live teammates.
|
|
20
|
+
- Auto-relaunch leaders for `running` teams after a session reset; surface failures as both a team signal and a UI notification.
|
|
21
|
+
- `createTeam` now defaults `repoRoots` to `[process.cwd()]` when the caller passes an empty array.
|
|
22
|
+
- Archive `process.json` into `history/` before a new task reuses the same role slot, so the prior task's final state is no longer silently clobbered.
|
|
23
|
+
|
|
24
|
+
### Enhanced: team-mode
|
|
25
|
+
|
|
26
|
+
- Durable intent queue for subprocess handoff: `team_spawn_teammate` calls made from a teammate subprocess are written to disk and executed by the main session's `LeaderRuntime` instead of spawning orphaned grand-children.
|
|
27
|
+
- New tool `team_task_create_batch` lets the leader emit the full initial task DAG in one call, removing per-task LLM round-trips during bootstrap.
|
|
28
|
+
- `team_create` / `launchLeader` accept an `awaitBootstrap` option so the user sees the task graph before the tool returns; leader launch retries up to 3 times on transient failures.
|
|
29
|
+
- Persist per-turn debug artifacts (prompt, invocation, stderr, raw event stream) for both leader and teammate subprocesses, exposed via `TeammateSummary.debugArtifacts`.
|
|
30
|
+
- Track `exitCode`, `exitSignal`, `terminationReason`, `stderrTail`, `toolExecutions`, `model` and `modelProvider` on every `TeammateProcess` record.
|
|
31
|
+
- Provider detection now consults pi's `settings.json` and `auth.json` in addition to env vars; default model IDs aligned with the provider/model scheme.
|
|
32
|
+
- `collectPiOutput` supports `AbortSignal` cancellation.
|
|
33
|
+
|
|
34
|
+
### Tests
|
|
35
|
+
|
|
36
|
+
- New `intent-queue` and `model-config` suites; expanded coverage across `leader-runtime`, `team-manager`, `team-query-tool` and `formatters`.
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## 1.7.0
|
|
40
|
+
|
|
41
|
+
### Minor Changes
|
|
42
|
+
|
|
43
|
+
### Enhanced: status-line
|
|
44
|
+
|
|
45
|
+
- Improved progress rendering and colors in expert mode
|
|
46
|
+
|
|
47
|
+
### Enhanced: team-mode
|
|
48
|
+
|
|
49
|
+
- **LLM-driven leader** — replaced the hardcoded `research → synthesis → implementation → verification` state machine with a pi subprocess coordinator that authors the task graph via tool calls
|
|
50
|
+
- **New tool `team_task_create`** so the leader can author tasks at runtime
|
|
51
|
+
- **New tool `team_handoff`** for explicit teammate → teammate context handoffs (replaces regex-scraping of `Handoffs:` output sections)
|
|
52
|
+
- **File-based teammate specs** — drop `.claude/teammates/<role>.md` frontmatter files (`name`, `description`, `needsWorktree`, `hasMemory`, `modelTier`) to extend or override the seven built-in roles
|
|
53
|
+
- **Event-driven leader wakes** — mailbox messages addressed to the leader (or broadcast) trigger a debounced (~200ms) cycle instead of waiting for the 20s polling tick
|
|
54
|
+
- **Templates accept any string** — `fullstack` / `research` / `refactor` remain as built-ins, but unknown template keys are accepted and no-op gracefully
|
|
55
|
+
- **Provider config per team** — per-team model overrides via `/team models`
|
|
56
|
+
- Reduced leader overhead and parent-session token churn
|
|
57
|
+
- `spawnTeammate` now always appends the full runtime-built context (signals, mailbox, dependencies, team memory) so teammates get the richer snapshot even when the caller's `context` argument is brief
|
|
58
|
+
|
|
59
|
+
### Breaking changes: team-mode
|
|
60
|
+
|
|
61
|
+
- Removed `LeaderPhase` enum and `currentPhase` field from `TeamRecord` / `TeamSummary`
|
|
62
|
+
- Removed `parseExplicitHandoffs` export and the legacy `Handoffs:` output parser — peer handoffs must go through the `team_handoff` tool
|
|
63
|
+
- Removed the deterministic auto-spawn loop (`ensureBootstrapTasks`) — all task authoring and teammate spawning is now the LLM leader's responsibility
|
|
64
|
+
- Removed `StringEnum` gate on `team_create`'s `template` parameter (now plain string)
|
|
65
|
+
|
|
66
|
+
### Fixed: review
|
|
67
|
+
|
|
68
|
+
- Annotate diff lines so the model picks correct line numbers
|
|
69
|
+
- Fix slice chunk around lines for comments in the reviewer TUI
|
|
70
|
+
|
|
71
|
+
### Documentation
|
|
72
|
+
|
|
73
|
+
- Updated root README and sentinel extension README
|
|
74
|
+
- Documented the new file-based teammate spec format and event-driven leader wake in the team-mode README
|
|
75
|
+
|
|
76
|
+
## 1.6.0
|
|
77
|
+
|
|
78
|
+
### Minor Changes
|
|
79
|
+
|
|
80
|
+
### New Extension: sentinel
|
|
81
|
+
|
|
82
|
+
Replaced the `grep` extension with a new security-focused `sentinel` extension for monitoring and guarding sensitive operations.
|
|
83
|
+
|
|
84
|
+
### Enhanced: team-mode
|
|
85
|
+
|
|
86
|
+
- Added comprehensive test suite with integration tests
|
|
87
|
+
- New mock helpers for subprocess testing
|
|
88
|
+
- Improved signal manager with better error handling
|
|
89
|
+
- Leader runtime refactoring for stability
|
|
90
|
+
- Team query tool with dedicated tests
|
|
91
|
+
|
|
92
|
+
### Enhanced: status-line
|
|
93
|
+
|
|
94
|
+
- Added basic and expert mode displays
|
|
95
|
+
- Improved index.ts with better state management
|
|
96
|
+
|
|
97
|
+
### Enhanced: clear
|
|
98
|
+
|
|
99
|
+
- Updated keyboard shortcut to `Ctrl+Shift+L`
|
|
100
|
+
- Better busy-state handling for shortcuts
|
|
101
|
+
- Added warning/cancel handling and error notifications
|
|
102
|
+
|
|
103
|
+
### Enhanced: context-guard
|
|
104
|
+
|
|
105
|
+
- Improved read deduplication across sessions
|
|
106
|
+
- Added `context-guard:file-modified` event for cache eviction
|
|
107
|
+
|
|
108
|
+
### Documentation
|
|
109
|
+
|
|
110
|
+
- Added dedicated README for `clear` extension
|
|
111
|
+
- Added dedicated README for `context-guard` extension
|
|
112
|
+
- Updated main README with improved extension descriptions
|
|
113
|
+
|
|
114
|
+
## 1.5.0
|
|
115
|
+
|
|
116
|
+
### Minor Changes
|
|
117
|
+
|
|
118
|
+
- ### `multi-edit` — diverge from upstream fork
|
|
119
|
+
|
|
120
|
+
The extension was originally derived from [mitsuhiko/agent-stuff](https://github.com/mitsuhiko/agent-stuff)'s `pi-extensions/multi-edit.ts`. This release rewrites the largest unmodified subsystems so the implementation is structurally distinct from upstream while keeping the public contract intact.
|
|
121
|
+
|
|
122
|
+
- **Modularized layout** — the 953-line `index.ts` is split into purpose-scoped modules: `types.ts`, `workspace.ts`, `classic.ts`, `patch.ts`, `diff.ts`, and a slim `index.ts` (~180 lines of registration + dispatch wiring).
|
|
123
|
+
- **New patch engine** — `patch.ts` is now a recursive-descent parser over a `LineCursor` class with `indexOf`-based hunk anchoring. Hunks are stored as `{ oldBlock, newBlock }` raw strings (previously `{ oldLines[], newLines[] }` arrays), letting the applier splice content directly instead of reconstructing line arrays per apply.
|
|
124
|
+
- **Two-pass diff renderer** — `diff.ts` now walks `diffLines` parts into a typed `Entry[]` stream and makes all gutter / context-collapse decisions in a second pass, replacing the prior single-loop state-flag design.
|
|
125
|
+
- **Polished classic edits** — extracted `groupEditsByPath`, `sortGroupByPosition`, `applyGroupToContent`, and `rollbackSnapshots` helpers; formalized the quote-fallback as an ordered `MATCH_PASSES` array so new normalizers (dashes, NBSP, etc.) can be added by appending one entry.
|
|
126
|
+
- **First contract test suite** — 34 tests under `__tests__/` cover classic edits (positional reordering, redundant-pair skip, quote fallback, atomic rollback, read-only preflight), patch operations (Add/Delete/Update round-trips, move-rejection, multi-op batches), and diff rendering (line-number gutter, context collapse, add/remove-only cases). Runs via `npm test` (`tsx --test`).
|
|
127
|
+
- **Dropped Codex apply_patch edge cases** (documented in `README.md` → "Codex apply_patch compatibility"): `*** End of File` sentinel hunks, 4-pass fuzzy `seekSequence` matching, implicit first hunk without `@@`, whitespace-tolerant anchoring. Common paths (Add/Delete/Update-single-chunk, Update with multiple hunks, Add+Update+Delete batches) are fully tested and preserved.
|
|
128
|
+
- **README attribution** — new "Origins" section crediting `mitsuhiko/agent-stuff` as the original source.
|
|
129
|
+
|
|
130
|
+
## 1.4.0
|
|
131
|
+
|
|
132
|
+
### Minor Changes
|
|
133
|
+
|
|
134
|
+
- Add teammate progress heartbeats and widget refresh improvements to team mode.
|
|
135
|
+
|
|
136
|
+
## 1.3.0
|
|
137
|
+
|
|
138
|
+
### Patch Changes
|
|
139
|
+
|
|
140
|
+
- ### New Extensions
|
|
141
|
+
|
|
142
|
+
#### `loop`
|
|
143
|
+
|
|
144
|
+
New extension that runs a prompt or slash command on a recurring interval. Useful for periodic tasks, polling, and automated repeated actions within a pi session.
|
|
145
|
+
|
|
146
|
+
#### `simplify`
|
|
147
|
+
|
|
148
|
+
New extension that reviews changed code for reuse, quality, and efficiency, then automatically fixes any issues found. Integrates with `git diff` to scope the review to recent changes.
|
|
149
|
+
|
|
150
|
+
***
|
|
151
|
+
|
|
152
|
+
### Bug Fixes
|
|
153
|
+
|
|
154
|
+
#### `multi-edit`
|
|
155
|
+
|
|
156
|
+
- **Broader unicode normalization**: `findActualString` now handles the full range of Unicode single-quote variants (`‘’‚‛`) and double-quote variants (`“”„‟`) when falling back from exact match — fixes more curly-quote mismatch cases
|
|
157
|
+
- **Parallel write-access preflight**: `checkWriteAccess` calls are now issued concurrently via `Promise.all` instead of sequentially — faster batch preflight on large edit sets
|
|
158
|
+
- **Removed redundant `editOrder` array**: `Map` insertion order is now relied upon directly, simplifying the grouping loop
|
|
159
|
+
|
|
160
|
+
#### `team-mode`
|
|
161
|
+
|
|
162
|
+
- **Stall detection hardened**: introduced `STALL_BLOCKER_MARKER` / `STALL_BLOCKER_MESSAGE` constants so the marker used to detect and record abnormal process exits stays in sync — prevents duplicate stall reports
|
|
163
|
+
- **Leader cycle guard comment clarified**: `cycleRunning` guard comment now explicitly calls out the race between the poll interval and teammate-completion handlers
|
|
164
|
+
|
|
165
|
+
## 1.2.0
|
|
166
|
+
|
|
167
|
+
### Minor Changes
|
|
168
|
+
|
|
169
|
+
- ### `multi-edit` — robustness improvements
|
|
170
|
+
|
|
171
|
+
- **No-op write guard**: skip file write and `context-guard:file-modified` event when new content is identical to what was last read — prevents unnecessary watcher churn
|
|
172
|
+
- **Early write-access check**: virtual workspace `checkWriteAccess` now validates real-filesystem permissions during the preflight pass so read-only files fail fast before any real file is touched
|
|
173
|
+
- **Curly-quote normalization**: new `findActualString` helper falls back to normalized quote matching (`"` / `'` ↔ `"` / `'`) when exact `oldText` search fails — the most common class of preflight mismatch
|
|
174
|
+
- **Atomic batch rollback**: `applyClassicEdits` gains a `rollbackOnError` option that restores all successfully written files when a later edit in the same batch fails
|
|
175
|
+
|
|
176
|
+
### `ask-user-question` — UX fixes
|
|
177
|
+
|
|
178
|
+
- **Reliable text capture on submit**: answer is read directly from the editor before it clears itself, fixing a race where the stored value was always empty
|
|
179
|
+
- **Unified advance logic**: `advanceTab()` and `saveOtherModeText()` helpers replace scattered single-question fast-paths — behaviour is now consistent regardless of form length
|
|
180
|
+
- **Auto-advance on Enter / Tab**: pressing Enter or Tab in any question (text, radio with "Other", checkbox with "Other") advances to the next tab without requiring a separate click
|
|
181
|
+
|
|
182
|
+
### `team-mode` — stability fixes
|
|
183
|
+
|
|
184
|
+
- **Infinite retry loop eliminated**: subprocess guard (`PI_TEAM_SUBPROCESS=1`) prevents spawned pi subprocesses from launching a ghost `LeaderRuntime` that immediately marks in-progress tasks as stalled
|
|
185
|
+
- **Stall detection grace period**: tasks updated within the last 2 × `LEADER_POLL_MS` (10 s) are skipped by `detectStalledTasks` — eliminates false positives on the spawning cycle
|
|
186
|
+
- **Circuit breaker**: tasks that stall more than `MAX_TASK_RETRIES` (3) times are permanently cancelled with a clear error signal instead of being silently re-queued
|
|
187
|
+
- **Concurrent cycle guard**: `runLeaderCycle` returns early if a cycle is already in-flight for the same team, preventing overlapping read-modify-write from the poll interval and completion handlers
|
|
188
|
+
- **Widget cleanup**: cancelled and completed teams are no longer shown in the team widget — only `initializing | running | paused | failed` states are displayed
|
|
189
|
+
- **Shorter auto-generated names**: `objectiveToName` now splits on non-alphanumeric characters (handles path separators), filters stopwords and extreme-length tokens, and hard-caps at 32 characters
|
|
190
|
+
|
|
191
|
+
## 1.1.1
|
|
192
|
+
|
|
193
|
+
### Patch Changes
|
|
194
|
+
|
|
195
|
+
- chore: update all packages for consistency and include team-mode fixes
|
|
196
|
+
|
|
197
|
+
## 1.1.0
|
|
198
|
+
|
|
199
|
+
### Patch Changes
|
|
200
|
+
|
|
201
|
+
- Add context-guard and grep extensions; improve multi-edit with dedup
|
|
202
|
+
|
|
203
|
+
**New: `pi-mono-context-guard`**
|
|
204
|
+
Extension that keeps the LLM context window lean with three guards:
|
|
205
|
+
|
|
206
|
+
- `read` without `limit` → auto-injects `limit=120`
|
|
207
|
+
- Read dedup → mtime-based stub for unchanged files (~20 tokens vs full content re-send)
|
|
208
|
+
- `bash` with unbounded `rg` → appends `| head -60`
|
|
209
|
+
|
|
210
|
+
Listens to `context-guard:file-modified` events to invalidate the dedup cache after edits.
|
|
211
|
+
`/context-guard` command to inspect and toggle guards at runtime.
|
|
212
|
+
|
|
213
|
+
**New: `pi-mono-grep`**
|
|
214
|
+
Dedicated ripgrep wrapper tool. Replaces raw `rg` in bash with a structured tool that has
|
|
215
|
+
`head_limit=60` built into the schema, `output_mode` (files_with_matches / content / count),
|
|
216
|
+
pagination via `offset`, and automatic VCS directory exclusions.
|
|
217
|
+
Prompt guidelines instruct the model to always use `grep` instead of bash+rg.
|
|
218
|
+
|
|
219
|
+
**Updated: `pi-mono-multi-edit`**
|
|
220
|
+
|
|
221
|
+
- Per-call read cache in `createRealWorkspace` deduplicates disk reads within a single `execute()` invocation (preflight + real-apply)
|
|
222
|
+
- Emits `context-guard:file-modified` event after every real `writeText` and `deleteFile` so context-guard can evict stale dedup cache entries
|
|
223
|
+
|
|
224
|
+
## 1.0.0
|
|
225
|
+
|
|
226
|
+
### Major Changes
|
|
227
|
+
|
|
228
|
+
- 199c367: First version of the extensions to upload to GitHub
|
|
229
|
+
|
|
230
|
+
### Patch Changes
|
|
231
|
+
|
|
232
|
+
- Bump all packages to 0.1.1
|