repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

pulse: cover timer trigger

d148426dcea0ba88eb1c007fb0e5f439e805999e

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (2)

+62 / −2 text lines

pi/agent/extensions/pulse/README.md

Modified

+28 / −2 text lines

2 2 # pulse
4 4 Living documentation sync for Pi.
6 -Tracks docs and applies validated model-proposed updates when project files change.
6 +Tracks docs and applies validated model-proposed updates after workspace changes or periodic checks.
8 -Apply modes: `auto` (default), `confirm`, `review` in `.pi/pulse.json`.
8 +## Setup
10 +Load extension, then run:
12 +- `/pulse init`
13 +- `/pulse add <file> [note]`
14 +- `/pulse add-dir <dir> <glob> [note]`
15 +- `/pulse add-glob <glob> [note]`
17 +## Config
19 +`.pi/pulse.json`:
21 +```json
23 + "documents": [{ "path": "README.md" }],
24 + "interval": 10,
25 + "apply": "auto"
27 +```
29 +`apply`: `auto` (default), `confirm`, `review`.
10 31 ## Commands
33 +- `/pulse list`
34 +- `/pulse status`
35 +- `/pulse force`
36 +- `/pulse pause` / `/pulse resume`
37 +- `/pulse config`
12 38 - `/pulse help`
14 40 ## Demo

pi/agent/extensions/pulse/__tests__/harness.test.ts

Modified

+34 / −0 text lines

145 145 await t.session.extensionRunner.emit({ type: "session_shutdown", reason: "quit" });
148 + it("runs periodic idle checks from the timer", async () => {
149 + const realSetInterval = globalThis.setInterval;
150 + const realClearInterval = globalThis.clearInterval;
151 + const realNow = Date.now;
152 + let tick: (() => void) | undefined;
153 + let now = 0;
154 + globalThis.setInterval = ((fn: () => void) => {
155 + tick = fn;
156 + return 1 as never;
157 + }) as never;
158 + globalThis.clearInterval = (() => {}) as never;
159 + Date.now = () => now;
161 + try {
162 + t = await createTestSession({ extensions: [pulsePath()] });
163 + writeFileSync(path.join(t.cwd, "README.md"), "old", "utf8");
164 + writeConfig({ interval: 1, documents: [{ path: "README.md" }] });
166 + await t.session.extensionRunner.emit({ type: "session_start", reason: "startup" });
167 + expect(tick).toBeDefined();
169 + now = 6 * 60 * 1000;
170 + tick!();
171 + await new Promise((resolve) => realSetInterval(resolve, 10));
173 + expect(notifyText().some((m) => m.startsWith("Pulse: missing auth"))).toBe(true);
174 + await t.session.extensionRunner.emit({ type: "session_shutdown", reason: "quit" });
175 + } finally {
176 + globalThis.setInterval = realSetInterval;
177 + globalThis.clearInterval = realClearInterval;
178 + Date.now = realNow;
180 + });