@blackbelt-technology/pi-dashboard-extension 0.3.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 (57) hide show
  1. package/.pi/skills/pi-dashboard/SKILL.md +134 -0
  2. package/.pi/skills/pi-dashboard/references/api-reference.md +470 -0
  3. package/.pi/skills/pi-dashboard/references/recipes.md +252 -0
  4. package/.pi/skills/pi-dashboard/scripts/dashboard-api.sh +75 -0
  5. package/package.json +38 -0
  6. package/src/__tests__/ask-user-tool.test.ts +432 -0
  7. package/src/__tests__/command-handler.test.ts +712 -0
  8. package/src/__tests__/connection.test.ts +344 -0
  9. package/src/__tests__/credentials-updated.test.ts +26 -0
  10. package/src/__tests__/dashboard-default-adapter.test.ts +77 -0
  11. package/src/__tests__/dev-build.test.ts +79 -0
  12. package/src/__tests__/enrich-model-metadata.test.ts +201 -0
  13. package/src/__tests__/event-forwarder.test.ts +89 -0
  14. package/src/__tests__/fork-entryid-timing.test.ts +100 -0
  15. package/src/__tests__/git-info.test.ts +124 -0
  16. package/src/__tests__/git-link-builder.test.ts +102 -0
  17. package/src/__tests__/openspec-activity-detector.test.ts +232 -0
  18. package/src/__tests__/openspec-poller.test.ts +124 -0
  19. package/src/__tests__/process-metrics.test.ts +47 -0
  20. package/src/__tests__/process-scanner-kill.test.ts +61 -0
  21. package/src/__tests__/process-scanner.test.ts +202 -0
  22. package/src/__tests__/prompt-bus-wiring.test.ts +791 -0
  23. package/src/__tests__/prompt-bus.test.ts +469 -0
  24. package/src/__tests__/prompt-expander.test.ts +54 -0
  25. package/src/__tests__/provider-register-reload.test.ts +394 -0
  26. package/src/__tests__/server-auto-start.test.ts +258 -0
  27. package/src/__tests__/server-launcher.test.ts +61 -0
  28. package/src/__tests__/server-probe.test.ts +25 -0
  29. package/src/__tests__/session-switch.test.ts +139 -0
  30. package/src/__tests__/session-sync.test.ts +55 -0
  31. package/src/__tests__/source-detector.test.ts +73 -0
  32. package/src/__tests__/stats-extractor.test.ts +92 -0
  33. package/src/__tests__/tui-prompt-adapter.test.ts +207 -0
  34. package/src/__tests__/watchdog.test.ts +161 -0
  35. package/src/ask-user-tool.ts +352 -0
  36. package/src/bridge-context.ts +64 -0
  37. package/src/bridge.ts +1182 -0
  38. package/src/command-handler.ts +533 -0
  39. package/src/connection.ts +204 -0
  40. package/src/dashboard-default-adapter.ts +37 -0
  41. package/src/dev-build.ts +39 -0
  42. package/src/event-forwarder.ts +40 -0
  43. package/src/flow-event-wiring.ts +85 -0
  44. package/src/git-info.ts +55 -0
  45. package/src/git-link-builder.ts +112 -0
  46. package/src/model-tracker.ts +56 -0
  47. package/src/pi-env.d.ts +37 -0
  48. package/src/process-metrics.ts +70 -0
  49. package/src/process-scanner.ts +430 -0
  50. package/src/prompt-bus.ts +240 -0
  51. package/src/prompt-expander.ts +108 -0
  52. package/src/provider-register.ts +564 -0
  53. package/src/server-auto-start.ts +113 -0
  54. package/src/server-launcher.ts +126 -0
  55. package/src/server-probe.ts +33 -0
  56. package/src/session-sync.ts +155 -0
  57. package/src/source-detector.ts +26 -0
@@ -0,0 +1,469 @@
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
+ import { PromptBus, type PromptAdapter, type PromptRequest, type PromptResponse } from "../prompt-bus.js";
3
+
4
+ function createMockAdapter(name: string, claim: any = {}) {
5
+ return {
6
+ name,
7
+ onRequest: vi.fn().mockReturnValue(claim) as any,
8
+ onResponse: vi.fn() as any,
9
+ onCancel: vi.fn() as any,
10
+ } satisfies PromptAdapter;
11
+ }
12
+
13
+ describe("PromptBus", () => {
14
+ let bus: PromptBus;
15
+ let onDashboardRequest: any;
16
+ let onDashboardDismiss: any;
17
+ let onDashboardCancel: any;
18
+
19
+ beforeEach(() => {
20
+ vi.useFakeTimers();
21
+ onDashboardRequest = vi.fn() as any;
22
+ onDashboardDismiss = vi.fn() as any;
23
+ onDashboardCancel = vi.fn() as any;
24
+ bus = new PromptBus({
25
+ timeoutMs: 5000,
26
+ onDashboardRequest,
27
+ onDashboardDismiss,
28
+ onDashboardCancel,
29
+ });
30
+ });
31
+
32
+ afterEach(() => {
33
+ vi.useRealTimers();
34
+ });
35
+
36
+ describe("adapter registration", () => {
37
+ it("should register an adapter", () => {
38
+ const adapter = createMockAdapter("test");
39
+ bus.registerAdapter(adapter);
40
+ expect(bus.adapterNames).toEqual(["test"]);
41
+ });
42
+
43
+ it("should replace adapter with same name on re-registration", () => {
44
+ const adapter1 = createMockAdapter("test");
45
+ const adapter2 = createMockAdapter("test");
46
+ bus.registerAdapter(adapter1);
47
+ bus.registerAdapter(adapter2);
48
+ expect(bus.adapterNames).toEqual(["test"]);
49
+
50
+ // Verify new adapter is used
51
+ bus.request({ pipeline: "command", type: "select", question: "Pick:", options: ["A"] });
52
+ expect(adapter2.onRequest).toHaveBeenCalled();
53
+ expect(adapter1.onRequest).not.toHaveBeenCalled();
54
+ });
55
+
56
+ it("should unregister adapter via returned function", () => {
57
+ const adapter = createMockAdapter("test");
58
+ const unsub = bus.registerAdapter(adapter);
59
+ expect(bus.adapterNames).toEqual(["test"]);
60
+ unsub();
61
+ expect(bus.adapterNames).toEqual([]);
62
+ });
63
+
64
+ it("should support multiple adapters", () => {
65
+ bus.registerAdapter(createMockAdapter("a"));
66
+ bus.registerAdapter(createMockAdapter("b"));
67
+ expect(bus.adapterNames).toEqual(["a", "b"]);
68
+ });
69
+ });
70
+
71
+ describe("request distribution", () => {
72
+ it("should call onRequest on all registered adapters", () => {
73
+ const a = createMockAdapter("a");
74
+ const b = createMockAdapter("b");
75
+ bus.registerAdapter(a);
76
+ bus.registerAdapter(b);
77
+
78
+ bus.request({ pipeline: "command", type: "select", question: "Pick:", options: ["A", "B"] });
79
+
80
+ expect(a.onRequest).toHaveBeenCalledWith(expect.objectContaining({
81
+ pipeline: "command",
82
+ type: "select",
83
+ question: "Pick:",
84
+ options: ["A", "B"],
85
+ }));
86
+ expect(b.onRequest).toHaveBeenCalledWith(expect.objectContaining({
87
+ pipeline: "command",
88
+ }));
89
+ });
90
+
91
+ it("should generate a unique id for each request", () => {
92
+ const adapter = createMockAdapter("a");
93
+ bus.registerAdapter(adapter);
94
+
95
+ bus.request({ pipeline: "command", type: "select", question: "Q1", options: ["A"] });
96
+ bus.request({ pipeline: "command", type: "select", question: "Q2", options: ["B"] });
97
+
98
+ const id1 = (adapter.onRequest.mock.calls[0][0] as PromptRequest).id;
99
+ const id2 = (adapter.onRequest.mock.calls[1][0] as PromptRequest).id;
100
+ expect(id1).not.toBe(id2);
101
+ });
102
+
103
+ it("should send prompt_request to dashboard with custom component if claimed", () => {
104
+ const adapter = createMockAdapter("arch", {
105
+ component: { type: "architect-prompt", props: { foo: 1 } },
106
+ placement: "widget-bar",
107
+ });
108
+ bus.registerAdapter(adapter);
109
+
110
+ bus.request({ pipeline: "architect-new", type: "select", question: "Save?", options: ["Save", "Cancel"] });
111
+
112
+ expect(onDashboardRequest).toHaveBeenCalledWith(
113
+ expect.objectContaining({ question: "Save?" }),
114
+ { type: "architect-prompt", props: { foo: 1 } },
115
+ "widget-bar",
116
+ );
117
+ });
118
+
119
+ it("should fall back to generic-dialog when no adapter claims with component", () => {
120
+ const adapter = createMockAdapter("tui", {}); // no component
121
+ bus.registerAdapter(adapter);
122
+
123
+ bus.request({ pipeline: "command", type: "select", question: "Pick:", options: ["A"] });
124
+
125
+ expect(onDashboardRequest).toHaveBeenCalledWith(
126
+ expect.objectContaining({ question: "Pick:" }),
127
+ expect.objectContaining({ type: "generic-dialog" }),
128
+ "inline",
129
+ );
130
+ });
131
+
132
+ it("should use first adapter's component when multiple claim", () => {
133
+ const a = createMockAdapter("a", {
134
+ component: { type: "custom-a", props: {} },
135
+ placement: "widget-bar",
136
+ });
137
+ const b = createMockAdapter("b", {
138
+ component: { type: "custom-b", props: {} },
139
+ placement: "inline",
140
+ });
141
+ bus.registerAdapter(a);
142
+ bus.registerAdapter(b);
143
+
144
+ bus.request({ pipeline: "test", type: "select", question: "Q", options: [] });
145
+
146
+ expect(onDashboardRequest).toHaveBeenCalledWith(
147
+ expect.anything(),
148
+ expect.objectContaining({ type: "custom-a" }),
149
+ "widget-bar",
150
+ );
151
+ });
152
+
153
+ it("should skip adapters that return null", () => {
154
+ const a = createMockAdapter("a");
155
+ a.onRequest.mockReturnValue(null);
156
+ const b = createMockAdapter("b", {});
157
+ bus.registerAdapter(a);
158
+ bus.registerAdapter(b);
159
+
160
+ bus.request({ pipeline: "command", type: "select", question: "Q", options: [] });
161
+
162
+ // Should still send to dashboard (generic fallback since b has no component)
163
+ expect(onDashboardRequest).toHaveBeenCalled();
164
+ });
165
+
166
+ it("should handle adapter onRequest throwing without breaking", () => {
167
+ const bad = createMockAdapter("bad");
168
+ bad.onRequest.mockImplementation(() => { throw new Error("boom"); });
169
+ const good = createMockAdapter("good", {});
170
+ bus.registerAdapter(bad);
171
+ bus.registerAdapter(good);
172
+
173
+ bus.request({ pipeline: "command", type: "select", question: "Q", options: [] });
174
+
175
+ expect(good.onRequest).toHaveBeenCalled();
176
+ });
177
+ });
178
+
179
+ describe("first-response-wins", () => {
180
+ it("should resolve with first response", async () => {
181
+ const adapter = createMockAdapter("a");
182
+ bus.registerAdapter(adapter);
183
+
184
+ const promise = bus.request({ pipeline: "command", type: "select", question: "Q", options: ["A"] });
185
+ const id = (adapter.onRequest.mock.calls[0][0] as PromptRequest).id;
186
+
187
+ bus.respond({ id, answer: "A", source: "a" });
188
+
189
+ const result = await promise;
190
+ expect(result).toEqual({ id, answer: "A", source: "a" });
191
+ });
192
+
193
+ it("should ignore second response for same prompt", async () => {
194
+ const adapter = createMockAdapter("a");
195
+ bus.registerAdapter(adapter);
196
+
197
+ const promise = bus.request({ pipeline: "command", type: "select", question: "Q", options: ["A", "B"] });
198
+ const id = (adapter.onRequest.mock.calls[0][0] as PromptRequest).id;
199
+
200
+ bus.respond({ id, answer: "A", source: "tui" });
201
+ bus.respond({ id, answer: "B", source: "dashboard" }); // late, ignored
202
+
203
+ const result = await promise;
204
+ expect(result.answer).toBe("A");
205
+ expect(result.source).toBe("tui");
206
+ });
207
+
208
+ it("should remove from pending after response", async () => {
209
+ const adapter = createMockAdapter("a");
210
+ bus.registerAdapter(adapter);
211
+
212
+ const promise = bus.request({ pipeline: "command", type: "select", question: "Q", options: [] });
213
+ expect(bus.pendingCount).toBe(1);
214
+
215
+ const id = (adapter.onRequest.mock.calls[0][0] as PromptRequest).id;
216
+ bus.respond({ id, answer: "A", source: "a" });
217
+ await promise;
218
+
219
+ expect(bus.pendingCount).toBe(0);
220
+ });
221
+ });
222
+
223
+ describe("cross-adapter dismissal", () => {
224
+ it("should call onResponse on all adapters when one responds", async () => {
225
+ const a = createMockAdapter("a");
226
+ const b = createMockAdapter("b");
227
+ bus.registerAdapter(a);
228
+ bus.registerAdapter(b);
229
+
230
+ const promise = bus.request({ pipeline: "command", type: "select", question: "Q", options: [] });
231
+ const id = (a.onRequest.mock.calls[0][0] as PromptRequest).id;
232
+
233
+ bus.respond({ id, answer: "X", source: "a" });
234
+ await promise;
235
+
236
+ expect(a.onResponse).toHaveBeenCalledWith({ id, answer: "X", source: "a" });
237
+ expect(b.onResponse).toHaveBeenCalledWith({ id, answer: "X", source: "a" });
238
+ });
239
+
240
+ it("should send dashboard dismiss on response", async () => {
241
+ const adapter = createMockAdapter("a");
242
+ bus.registerAdapter(adapter);
243
+
244
+ const promise = bus.request({ pipeline: "command", type: "select", question: "Q", options: [] });
245
+ const id = (adapter.onRequest.mock.calls[0][0] as PromptRequest).id;
246
+
247
+ bus.respond({ id, answer: "A", source: "tui" });
248
+ await promise;
249
+
250
+ expect(onDashboardDismiss).toHaveBeenCalledWith(id);
251
+ });
252
+ });
253
+
254
+ describe("cancellation", () => {
255
+ it("should resolve with cancelled when cancel is called", async () => {
256
+ const adapter = createMockAdapter("a");
257
+ bus.registerAdapter(adapter);
258
+
259
+ const promise = bus.request({ pipeline: "command", type: "select", question: "Q", options: [] });
260
+ const id = (adapter.onRequest.mock.calls[0][0] as PromptRequest).id;
261
+
262
+ bus.cancel(id);
263
+
264
+ const result = await promise;
265
+ expect(result.cancelled).toBe(true);
266
+ });
267
+
268
+ it("should call onCancel on all adapters", async () => {
269
+ const a = createMockAdapter("a");
270
+ const b = createMockAdapter("b");
271
+ bus.registerAdapter(a);
272
+ bus.registerAdapter(b);
273
+
274
+ const promise = bus.request({ pipeline: "command", type: "select", question: "Q", options: [] });
275
+ const id = (a.onRequest.mock.calls[0][0] as PromptRequest).id;
276
+
277
+ bus.cancel(id);
278
+ await promise;
279
+
280
+ expect(a.onCancel).toHaveBeenCalledWith(id);
281
+ expect(b.onCancel).toHaveBeenCalledWith(id);
282
+ });
283
+
284
+ it("should send dashboard cancel on cancel", async () => {
285
+ const adapter = createMockAdapter("a");
286
+ bus.registerAdapter(adapter);
287
+
288
+ const promise = bus.request({ pipeline: "command", type: "select", question: "Q", options: [] });
289
+ const id = (adapter.onRequest.mock.calls[0][0] as PromptRequest).id;
290
+
291
+ bus.cancel(id);
292
+ await promise;
293
+
294
+ expect(onDashboardCancel).toHaveBeenCalledWith(id);
295
+ });
296
+
297
+ it("should be a no-op when cancelling already-resolved prompt", () => {
298
+ const adapter = createMockAdapter("a");
299
+ bus.registerAdapter(adapter);
300
+
301
+ bus.request({ pipeline: "command", type: "select", question: "Q", options: [] });
302
+ const id = (adapter.onRequest.mock.calls[0][0] as PromptRequest).id;
303
+
304
+ bus.respond({ id, answer: "A", source: "a" });
305
+ bus.cancel(id); // no-op, no error
306
+
307
+ expect(adapter.onCancel).not.toHaveBeenCalled();
308
+ });
309
+ });
310
+
311
+ describe("timeout", () => {
312
+ it("should cancel prompt after timeout", async () => {
313
+ const adapter = createMockAdapter("a");
314
+ bus.registerAdapter(adapter);
315
+
316
+ const promise = bus.request({ pipeline: "command", type: "select", question: "Q", options: [] });
317
+
318
+ vi.advanceTimersByTime(5000);
319
+
320
+ const result = await promise;
321
+ expect(result.cancelled).toBe(true);
322
+ expect(adapter.onCancel).toHaveBeenCalled();
323
+ });
324
+
325
+ it("should not timeout if answered before deadline", async () => {
326
+ const adapter = createMockAdapter("a");
327
+ bus.registerAdapter(adapter);
328
+
329
+ const promise = bus.request({ pipeline: "command", type: "select", question: "Q", options: [] });
330
+ const id = (adapter.onRequest.mock.calls[0][0] as PromptRequest).id;
331
+
332
+ vi.advanceTimersByTime(2000);
333
+ bus.respond({ id, answer: "A", source: "a" });
334
+
335
+ const result = await promise;
336
+ expect(result.answer).toBe("A");
337
+ expect(result.cancelled).toBeUndefined();
338
+
339
+ // Advance past timeout — should be no-op
340
+ vi.advanceTimersByTime(5000);
341
+ expect(adapter.onCancel).not.toHaveBeenCalled();
342
+ });
343
+ });
344
+
345
+ describe("concurrent prompts", () => {
346
+ it("should handle multiple pending prompts independently", async () => {
347
+ const adapter = createMockAdapter("a");
348
+ bus.registerAdapter(adapter);
349
+
350
+ const promise1 = bus.request({ pipeline: "command", type: "select", question: "Q1", options: ["A"] });
351
+ const promise2 = bus.request({ pipeline: "architect-new", type: "input", question: "Q2" });
352
+
353
+ expect(bus.pendingCount).toBe(2);
354
+
355
+ const id1 = (adapter.onRequest.mock.calls[0][0] as PromptRequest).id;
356
+ const id2 = (adapter.onRequest.mock.calls[1][0] as PromptRequest).id;
357
+
358
+ bus.respond({ id: id1, answer: "A", source: "tui" });
359
+
360
+ const result1 = await promise1;
361
+ expect(result1.answer).toBe("A");
362
+ expect(bus.pendingCount).toBe(1);
363
+
364
+ bus.respond({ id: id2, answer: "guidance", source: "dashboard" });
365
+
366
+ const result2 = await promise2;
367
+ expect(result2.answer).toBe("guidance");
368
+ expect(bus.pendingCount).toBe(0);
369
+ });
370
+
371
+ it("should not dismiss other prompts when one is answered", async () => {
372
+ const adapter = createMockAdapter("a");
373
+ bus.registerAdapter(adapter);
374
+
375
+ bus.request({ pipeline: "command", type: "select", question: "Q1", options: [] });
376
+ bus.request({ pipeline: "command", type: "select", question: "Q2", options: [] });
377
+
378
+ const id1 = (adapter.onRequest.mock.calls[0][0] as PromptRequest).id;
379
+
380
+ bus.respond({ id: id1, answer: "A", source: "tui" });
381
+
382
+ // Second prompt should still be pending
383
+ expect(bus.pendingCount).toBe(1);
384
+ });
385
+ });
386
+
387
+ describe("respond with unknown id", () => {
388
+ it("should silently ignore response for unknown prompt id", () => {
389
+ bus.respond({ id: "nonexistent", answer: "A", source: "tui" });
390
+ // No error
391
+ });
392
+ });
393
+
394
+ describe("getPendingRequests", () => {
395
+ it("should return empty array when no prompts are pending", () => {
396
+ expect(bus.getPendingRequests()).toEqual([]);
397
+ });
398
+
399
+ it("should return pending prompt with resolved component", () => {
400
+ const adapter = createMockAdapter("a", {
401
+ component: { type: "custom-ui", props: { x: 1 } },
402
+ placement: "widget-bar",
403
+ });
404
+ bus.registerAdapter(adapter);
405
+
406
+ bus.request({ pipeline: "command", type: "select", question: "Pick:", options: ["A"] });
407
+
408
+ const pending = bus.getPendingRequests();
409
+ expect(pending).toHaveLength(1);
410
+ expect(pending[0].request).toEqual(expect.objectContaining({
411
+ pipeline: "command",
412
+ type: "select",
413
+ question: "Pick:",
414
+ }));
415
+ expect(pending[0].component).toEqual({ type: "custom-ui", props: { x: 1 } });
416
+ expect(pending[0].placement).toBe("widget-bar");
417
+ });
418
+
419
+ it("should return generic-dialog component when no adapter claims with component", () => {
420
+ const adapter = createMockAdapter("tui", {}); // no component
421
+ bus.registerAdapter(adapter);
422
+
423
+ bus.request({ pipeline: "command", type: "select", question: "Pick:", options: ["A"] });
424
+
425
+ const pending = bus.getPendingRequests();
426
+ expect(pending).toHaveLength(1);
427
+ expect(pending[0].component.type).toBe("generic-dialog");
428
+ expect(pending[0].placement).toBe("inline");
429
+ });
430
+
431
+ it("should omit resolved prompts", async () => {
432
+ const adapter = createMockAdapter("a");
433
+ bus.registerAdapter(adapter);
434
+
435
+ const promise = bus.request({ pipeline: "command", type: "select", question: "Q", options: [] });
436
+ expect(bus.getPendingRequests()).toHaveLength(1);
437
+
438
+ const id = (adapter.onRequest.mock.calls[0][0] as PromptRequest).id;
439
+ bus.respond({ id, answer: "A", source: "a" });
440
+ await promise;
441
+
442
+ expect(bus.getPendingRequests()).toEqual([]);
443
+ });
444
+
445
+ it("should omit cancelled prompts", async () => {
446
+ const adapter = createMockAdapter("a");
447
+ bus.registerAdapter(adapter);
448
+
449
+ const promise = bus.request({ pipeline: "command", type: "select", question: "Q", options: [] });
450
+ expect(bus.getPendingRequests()).toHaveLength(1);
451
+
452
+ const id = (adapter.onRequest.mock.calls[0][0] as PromptRequest).id;
453
+ bus.cancel(id);
454
+ await promise;
455
+
456
+ expect(bus.getPendingRequests()).toEqual([]);
457
+ });
458
+
459
+ it("should return multiple pending prompts", () => {
460
+ const adapter = createMockAdapter("a");
461
+ bus.registerAdapter(adapter);
462
+
463
+ bus.request({ pipeline: "command", type: "select", question: "Q1", options: ["A"] });
464
+ bus.request({ pipeline: "command", type: "input", question: "Q2" });
465
+
466
+ expect(bus.getPendingRequests()).toHaveLength(2);
467
+ });
468
+ });
469
+ });
@@ -0,0 +1,54 @@
1
+ import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
+ import { mkdirSync, writeFileSync, rmSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import { expandPromptTemplateFromDisk } from "../prompt-expander.js";
5
+
6
+ const tmpDir = join(import.meta.dirname ?? __dirname, "__tmp_prompt_test__");
7
+ const promptsDir = join(tmpDir, ".pi", "prompts");
8
+
9
+ beforeEach(() => {
10
+ mkdirSync(promptsDir, { recursive: true });
11
+ writeFileSync(join(promptsDir, "opsx-continue.md"), "---\ndescription: continue\n---\nContinue the change");
12
+ writeFileSync(join(promptsDir, "opsx-apply.md"), "Apply the change");
13
+ writeFileSync(join(promptsDir, "hello.md"), "Hello world");
14
+ });
15
+
16
+ afterEach(() => {
17
+ rmSync(tmpDir, { recursive: true, force: true });
18
+ });
19
+
20
+ describe("expandPromptTemplateFromDisk", () => {
21
+ it("expands hyphen form /opsx-continue", () => {
22
+ const result = expandPromptTemplateFromDisk("/opsx-continue my-change", tmpDir);
23
+ expect(result).toContain("Continue the change");
24
+ expect(result).toContain("my-change");
25
+ });
26
+
27
+ it("expands colon form /opsx:continue as alias for /opsx-continue", () => {
28
+ const result = expandPromptTemplateFromDisk("/opsx:continue my-change", tmpDir);
29
+ expect(result).toContain("Continue the change");
30
+ expect(result).toContain("my-change");
31
+ });
32
+
33
+ it("expands colon form /opsx:apply without args", () => {
34
+ const result = expandPromptTemplateFromDisk("/opsx:apply", tmpDir);
35
+ expect(result).toBe("Apply the change");
36
+ });
37
+
38
+ it("does not affect non-opsx colon commands", () => {
39
+ // /hello has no colon, should work as before
40
+ const result = expandPromptTemplateFromDisk("/hello", tmpDir);
41
+ expect(result).toBe("Hello world");
42
+ });
43
+
44
+ it("returns original text when no template found", () => {
45
+ const result = expandPromptTemplateFromDisk("/nonexistent", tmpDir);
46
+ expect(result).toBe("/nonexistent");
47
+ });
48
+
49
+ it("strips YAML frontmatter from colon form too", () => {
50
+ const result = expandPromptTemplateFromDisk("/opsx:continue", tmpDir);
51
+ expect(result).toBe("Continue the change");
52
+ expect(result).not.toContain("---");
53
+ });
54
+ });