@andares/pi-toolkits 1.2.4 → 1.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.
@@ -0,0 +1 @@
1
+ :root{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--paper:#f4faf6;--paper-deep:#e8f3ec;--surface:#fffdfb;--line:#d8e7dd;--ink:#16281e;--muted:#5b7465;--leaf:#2e9b63;--leaf-deep:#1b7a4b;--leaf-soft:#dcf0e4;--warn:#a9741b;--danger:#c4483c;--shadow:0 10px 32px #163a2612;--font-display:"P052", "Palatino Linotype", Palatino, "Iowan Old Style", Georgia, "Noto Serif", "Songti SC", serif;--font-sans:"Ubuntu Sans", "Noto Sans", "Droid Sans Fallback", system-ui, sans-serif;--font-mono:"Noto Sans Mono", ui-monospace, SFMono-Regular, Menlo, monospace}*{box-sizing:border-box}body{background:var(--paper);color:var(--ink);font:14px/1.6 var(--font-sans);-webkit-font-smoothing:antialiased;margin:0}code{background:var(--paper-deep);font:.92em var(--font-mono);color:var(--leaf-deep);border-radius:6px;padding:.05rem .35rem}button{font:inherit;color:inherit;cursor:pointer}.mono{font-family:var(--font-mono)}.page{background:linear-gradient(180deg, var(--paper), var(--paper-deep));min-height:100vh;position:relative;overflow-x:hidden}.glow{filter:blur(130px);pointer-events:none;border-radius:50%;position:absolute}.glow-a{opacity:.5;background:#bfe7cd;width:660px;height:660px;top:-220px;left:-200px}.glow-b{opacity:.45;background:#e4f6c6;width:580px;height:580px;top:200px;right:-260px}.glow-c{opacity:.24;background:#cdeaf0;width:540px;height:540px;top:860px;left:120px}.shell{max-width:1160px;margin:0 auto;padding:52px 24px 96px;position:relative}.brand{align-items:center;gap:12px;display:flex}.mark{background:linear-gradient(135deg, var(--leaf), #7bc96f);border-radius:10px;place-items:center;width:32px;height:32px;display:grid}.mark svg{fill:none;stroke:#fff;stroke-width:2.4px;stroke-linecap:round;stroke-linejoin:round;width:16px;height:16px}.brand-label{letter-spacing:.14em;text-transform:uppercase;color:var(--muted);font-size:12px;font-weight:700}.head-row{justify-content:space-between;align-items:flex-start;gap:24px;margin-top:6px;display:flex}h1{font:400 40px/1.1 var(--font-display);letter-spacing:-.01em;margin:0}.meta{color:var(--muted);flex-wrap:wrap;align-items:center;gap:10px;margin:8px 0 0;font-size:12px;display:flex}.meta .dot{background:#c3d6c9;border-radius:50%;width:4px;height:4px}.meta-strong{color:var(--leaf-deep);font-weight:700}.head{border-bottom:1px solid var(--line);padding-bottom:28px}.ghost{border:1px solid var(--line);background:var(--surface);height:36px;color:var(--ink);border-radius:10px;align-items:center;gap:7px;padding:0 14px;font-size:12px;transition:border-color .12s,background .12s;display:inline-flex}.ghost:hover{border-color:var(--leaf);background:var(--leaf-soft)}.icon{fill:none;stroke:currentColor;stroke-width:1.8px;stroke-linecap:round;stroke-linejoin:round;flex:none;width:14px;height:14px}.icon.ok{color:var(--leaf-deep)}.link{color:var(--muted);background:0 0;border:0;padding:0;font-size:12px}.link:hover{color:var(--leaf-deep)}.banner{border:1px solid var(--line);background:var(--surface);border-radius:12px;margin:20px 0 0;padding:14px 18px;font-size:13px}.banner.error{border-color:var(--danger);color:var(--danger)}.banner.pending{border-color:color-mix(in srgb, var(--warn) 45%, var(--line));border-left:3px solid var(--warn);color:var(--ink)}.banner.pending p{margin:0}.banner.pending p+p{color:var(--muted);margin-top:6px}.progress{border:1px solid var(--line);background:var(--surface);box-shadow:var(--shadow);border-radius:16px;align-items:center;gap:36px;margin-top:32px;padding:24px 28px;display:flex}.score{flex-direction:column;min-width:128px;display:flex}.score-num{font:400 40px/1 var(--font-display);color:var(--leaf-deep)}.score-label{color:var(--muted);margin-top:4px;font-size:12px}.track-wrap{flex:1;min-width:0}.track{background:var(--paper-deep);border-radius:999px;height:10px;overflow:hidden}.track-fill{background:var(--leaf);border-radius:999px;height:100%;transition:width .24s}.legend{color:var(--muted);flex-wrap:wrap;gap:20px;margin-top:12px;font-size:12px;display:flex}.legend-item{align-items:center;gap:6px;display:inline-flex}.legend-dot{background:var(--muted);border-radius:50%;flex:none;width:6px;height:6px}.legend-dot.leaf{background:var(--leaf)}.legend-dot.amber{background:var(--warn)}.legend-ok{color:var(--leaf-deep);font-weight:700}.live{text-align:right;min-width:92px}.live-label{letter-spacing:.12em;color:var(--muted);font-size:12px;font-weight:700;display:block}.live-state{color:var(--leaf-deep);align-items:center;gap:5px;margin-top:4px;font-size:12px;font-weight:700;display:inline-flex}.live-state.down{color:var(--warn)}.layout{grid-template-columns:minmax(0,1fr) 344px;align-items:start;gap:32px;margin-top:28px;display:grid}.board{min-width:0}.list-head{justify-content:space-between;align-items:center;margin:4px 0 14px;display:flex}.kicker{letter-spacing:.14em;text-transform:uppercase;color:var(--muted);font-size:12px;font-weight:700;display:block}.kicker.inline{letter-spacing:.08em;display:inline}.list-count{color:var(--muted);font-size:12px}.empty{border:1px dashed var(--line);background:color-mix(in srgb, var(--surface) 60%, transparent);color:var(--muted);text-align:center;border-radius:16px;margin:0;padding:32px}.items{flex-direction:column;gap:16px;margin:0;padding:0;list-style:none;display:flex}.item{border:1px solid var(--line);background:var(--surface);box-shadow:var(--shadow);border-radius:16px;align-items:flex-start;gap:14px;padding:18px 22px;display:flex}.item.done{background:color-mix(in srgb, var(--surface) 70%, var(--paper-deep));box-shadow:none}.check{cursor:pointer;flex:none;margin-top:2px;position:relative}.check input{opacity:0;cursor:pointer;position:absolute;inset:0}.check-box{border:1.5px solid var(--line);background:var(--surface);border-radius:8px;place-items:center;width:22px;height:22px;transition:border-color .12s,background .12s;display:grid}.check:hover .check-box{border-color:var(--leaf)}.check input:focus-visible+.check-box{outline:2px solid var(--leaf);outline-offset:2px}.check-box.checked{border-color:var(--leaf);background:var(--leaf)}.check-box svg{fill:none;stroke:#fff;stroke-width:2.4px;stroke-linecap:round;stroke-linejoin:round;width:14px;height:14px}.item .body{flex:1;min-width:0}.item h2{font:400 20px/1.4 var(--font-display);margin:0}.row{justify-content:space-between;align-items:flex-start;gap:12px;display:flex}.badges{flex-wrap:wrap;flex:none;justify-content:flex-end;gap:6px;padding-top:2px;display:flex}.badge{background:var(--paper-deep);color:var(--muted);white-space:nowrap;border-radius:999px;padding:3px 9px;font-size:12px}.badge.area{background:var(--leaf-soft);color:var(--leaf-deep)}.badge.reopened{background:color-mix(in srgb, var(--warn) 16%, var(--surface));color:var(--warn)}.summary{color:var(--muted);margin:8px 0 0;font-size:14px;line-height:1.6}.more{color:var(--leaf-deep);background:0 0;border:0;margin-top:10px;padding:0;font-size:12px;font-weight:700}.more:hover{text-decoration:underline}.details{border-top:1px solid var(--line);margin-top:14px;padding-top:14px}.details .kicker+*{margin-top:8px}.details>*+*{margin-top:14px}.steps{counter-reset:step;margin:0;padding:0;list-style:none}.steps li{color:var(--ink);padding-left:26px;font-size:14px;line-height:1.55;position:relative}.steps li+li{margin-top:6px}.steps li:before{counter-increment:step;content:counter(step);font:12px/1.6 var(--font-mono);color:var(--leaf-deep);position:absolute;top:1px;left:0}.edge{margin:0;padding:0;list-style:none}.edge li{color:var(--muted);padding-left:16px;font-size:14px;line-height:1.55;position:relative}.edge li+li{margin-top:6px}.edge li:before{content:"";background:#c3d6c9;border-radius:50%;width:4px;height:4px;position:absolute;top:10px;left:0}.skip p{color:var(--muted);margin:6px 0 0;font-size:14px;line-height:1.55}.chips{flex-wrap:wrap;gap:6px;display:flex}.chip{background:var(--paper-deep);font:12px/1.33 var(--font-mono);color:var(--muted);border:0;border-radius:8px;padding:5px 9px}.chip:hover,.chip-more{background:var(--leaf-soft);color:var(--leaf-deep)}.stamp{color:var(--muted);margin:8px 0 0;font-size:12px}.accepted{border:1px solid var(--line);background:var(--paper);text-align:left;border-radius:12px;justify-content:space-between;align-items:center;gap:12px;width:100%;height:56px;margin-top:16px;padding:0 20px;display:flex}.accepted-left{align-items:center;gap:10px;font-size:14px;display:flex}.accepted .muted{color:var(--muted);font-size:12px}.accepted-list{margin-top:12px}.rail{flex-direction:column;gap:18px;min-width:0;display:flex}.card{border:1px solid var(--line);background:var(--surface);box-shadow:var(--shadow);border-radius:16px;padding:20px}.card.wash{background:var(--paper);box-shadow:none}.batch-id{color:var(--ink);margin-top:8px;font-size:12px;display:block}.rule{background:var(--line);height:1px;margin:10px 0}.kv{color:var(--muted);justify-content:space-between;align-items:center;font-size:12px;display:flex}.kv+.kv{margin-top:8px}.kv strong{color:var(--ink)}.note{color:var(--muted);margin:10px 0 0;font-size:12px;line-height:1.5}.bullets{margin:10px 0 0;padding:0;list-style:none}.bullets li{color:var(--muted);padding-left:15px;font-size:12px;line-height:1.5;position:relative}.bullets li+li{margin-top:8px}.bullets li:before{content:"";background:var(--leaf);border-radius:50%;width:5px;height:5px;position:absolute;top:7px;left:0}.commands{flex-wrap:wrap;gap:6px;margin-top:12px;display:flex}.commands code{background:var(--leaf-soft);color:var(--leaf-deep);padding:5px 9px;font-size:12px}.recents,.retired{margin:10px 0 0;padding:0;list-style:none}.recents li{color:var(--muted);align-items:flex-start;gap:8px;font-size:12px;display:flex}.recents li+li{margin-top:8px}.retired li{color:var(--muted);flex-wrap:wrap;align-items:baseline;gap:8px;font-size:12px;display:flex}.retired li+li{margin-top:8px}.retired .mono{font-size:11px}.retired-reason{background:var(--paper-deep);color:var(--warn);border-radius:999px;padding:1px 6px;font-size:11px}.card-toggle{text-align:left;background:0 0;border:0;justify-content:space-between;align-items:center;width:100%;padding:0;display:flex}.card-toggle .kicker{margin:0}.root{color:var(--muted);word-break:break-all;margin:4px 0 0;font-size:12px}.drawer{z-index:20;background:var(--surface);border-top:1px solid var(--line);border-radius:20px 20px 0 0;flex-direction:column;max-height:min(70vh,420px);animation:.16s slide-up;display:flex;position:fixed;inset:auto 0 0;box-shadow:0 -18px 48px #163a261f}@keyframes slide-up{0%{opacity:0;transform:translateY(12px)}}.drawer-inner{width:100%;max-width:1160px;margin:0 auto;padding:24px 24px 20px;overflow:auto}.drawer-head{border-bottom:1px solid var(--line);justify-content:space-between;align-items:center;gap:16px;padding-bottom:12px;display:flex}.drawer-title{color:var(--ink);align-items:center;gap:10px;font-size:12px;font-weight:700;display:inline-flex}.drawer pre{font:13px/1.65 var(--font-mono);color:var(--muted);white-space:pre-wrap;word-break:break-word;margin:16px 0 0}.drawer-note{color:var(--muted);margin:16px 0 0;font-size:12px}@media (max-width:1040px){.layout{grid-template-columns:minmax(0,1fr)}.rail{flex-flow:wrap}.rail>.card{flex:260px}}@media (max-width:680px){.shell{padding:32px 16px 80px}.head-row{flex-direction:column}.progress{flex-direction:column;align-items:flex-start;gap:18px}.live{text-align:left}.item{padding:16px}.row{flex-direction:column}.badges{justify-content:flex-start;padding-top:0}.rail{flex-direction:column}}
@@ -4,9 +4,9 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <meta name="robots" content="noindex" />
7
- <title>ask-uat — acceptance</title>
8
- <script type="module" crossorigin src="/index-DCBQCsli.js"></script>
9
- <link rel="stylesheet" crossorigin href="/index-D-W9zj0w.css">
7
+ <title>Acceptance — ask-uat</title>
8
+ <script type="module" crossorigin src="/index-CPTHXggT.js"></script>
9
+ <link rel="stylesheet" crossorigin href="/index-D9S_sCVr.css">
10
10
  </head>
11
11
  <body>
12
12
  <div id="root"></div>
@@ -123,6 +123,17 @@ function harness(): Harness {
123
123
  };
124
124
  }
125
125
 
126
+ async function recordChange(h: Harness, title: string, behavior: string): Promise<string> {
127
+ const result = await h.tools.get(RECORD_CHANGE_TOOL)!.execute(
128
+ "t",
129
+ { title, body: "body", behavior },
130
+ undefined,
131
+ undefined,
132
+ h.ctx,
133
+ );
134
+ return (result.details as { id: string }).id;
135
+ }
136
+
126
137
  /** POST JSON the way the page does. */
127
138
  async function post(url: string, path: string, body: unknown): Promise<{ status: number; body: any }> {
128
139
  const parsed = new URL(url);
@@ -202,8 +213,8 @@ describe("ask-uat command", () => {
202
213
  });
203
214
 
204
215
  it("opens the page and dispatches clustering only when records are pending", async () => {
205
- createRecord(root, { title: "alpha change", body: "body", now: new Date(2026, 10, 12, 9, 0) });
206
216
  const h = harness();
217
+ await recordChange(h, "alpha change", "The operator sees alpha.");
207
218
  await h.commands.get(UAT_COMMAND)!.handler("", h.ctx);
208
219
 
209
220
  expect(h.openBrowser).toHaveBeenCalledTimes(1);
@@ -222,7 +233,7 @@ describe("ask-uat command", () => {
222
233
  await h.commands.get(UAT_COMMAND)!.handler("", h.ctx);
223
234
  expect(h.openBrowser).toHaveBeenCalledTimes(1);
224
235
  expect(h.sendUserMessage).not.toHaveBeenCalled();
225
- expect(h.notify).toHaveBeenCalledWith(expect.stringContaining("0 pending"), "info");
236
+ expect(h.notify).toHaveBeenCalledWith(expect.stringContaining("0 new"), "info");
226
237
  await h.commands.get(UAT_COMMAND)!.handler("off", h.ctx);
227
238
  h.shutdown();
228
239
  });
@@ -240,13 +251,39 @@ describe("ask-uat command", () => {
240
251
  const h = harness();
241
252
  await h.commands.get(UAT_COMMAND)!.handler("", h.ctx);
242
253
  expect(h.sendUserMessage).not.toHaveBeenCalled();
243
- createRecord(root, { title: "later change", body: "body", now: new Date(2026, 10, 13, 20, 0) });
254
+ await recordChange(h, "later change", "The operator sees the later thing.");
244
255
  await h.commands.get(UAT_COMMAND)!.handler("", h.ctx);
245
256
  expect(h.sendUserMessage).toHaveBeenCalledWith(expect.stringContaining("later change"));
246
257
  await h.commands.get(UAT_COMMAND)!.handler("off", h.ctx);
247
258
  h.shutdown();
248
259
  });
249
260
 
261
+ it("leaves records without a behaviour line out of a default run and points at legacy", async () => {
262
+ const h = harness();
263
+ await recordChange(h, "new change", "The operator sees the new thing.");
264
+ createRecord(root, { title: "old file", body: "body", now: new Date(2026, 10, 1, 9, 0) });
265
+ await h.commands.get(UAT_COMMAND)!.handler("", h.ctx);
266
+ const kickoff = h.sendUserMessage.mock.calls[0][0] as string;
267
+ expect(kickoff).toContain("new change");
268
+ expect(kickoff).not.toContain("old file");
269
+ expect(kickoff).toContain("/ask-uat legacy");
270
+ await h.commands.get(UAT_COMMAND)!.handler("off", h.ctx);
271
+ h.shutdown();
272
+ });
273
+
274
+ it("/ask-uat legacy puts records without a behaviour line into the work order", async () => {
275
+ const h = harness();
276
+ createRecord(root, { title: "old file", body: "body", now: new Date(2026, 10, 1, 9, 0) });
277
+ await h.commands.get(UAT_COMMAND)!.handler("legacy", h.ctx);
278
+ expect(h.sendUserMessage).toHaveBeenCalledTimes(1);
279
+ const kickoff = h.sendUserMessage.mock.calls[0][0] as string;
280
+ expect(kickoff).toContain("old file");
281
+ expect(kickoff).toContain("read the record");
282
+ expect(kickoff).toContain("Open each file before you cluster it");
283
+ await h.commands.get(UAT_COMMAND)!.handler("off", h.ctx);
284
+ h.shutdown();
285
+ });
286
+
250
287
  it("removes phase tools on a session switch", async () => {
251
288
  const h = harness();
252
289
  await h.commands.get(UAT_COMMAND)!.handler("", h.ctx);
@@ -338,6 +375,62 @@ describe("record_change", () => {
338
375
  });
339
376
  });
340
377
 
378
+ describe("uat_item drop", () => {
379
+ it("retires records by id without creating an item", async () => {
380
+ const first = createRecord(root, { title: "docs only", body: "body", now: new Date(2026, 10, 12, 9, 0) });
381
+ const h = harness();
382
+ await h.commands.get(UAT_COMMAND)!.handler("", h.ctx);
383
+ const result = await h.tools.get(UAT_ITEM_TOOL)!.execute(
384
+ "t",
385
+ { op: "drop", reports: [first.entry.id], reason: "documentation only" },
386
+ undefined,
387
+ undefined,
388
+ h.ctx,
389
+ );
390
+ expect(result.isError).toBeFalsy();
391
+ expect(result.content[0].text).toContain("Retired 1 record");
392
+ const state = uatSummary(root);
393
+ expect(state.items).toEqual([]);
394
+ expect(state.pending).toEqual([]);
395
+ expect(state.counts.retired).toBe(1);
396
+ expect(state.retired[0]).toMatchObject({ id: first.entry.id, reason: "dropped" });
397
+ await h.commands.get(UAT_COMMAND)!.handler("off", h.ctx);
398
+ h.shutdown();
399
+ });
400
+
401
+ it("rejects a drop that names nothing", async () => {
402
+ const h = harness();
403
+ await h.commands.get(UAT_COMMAND)!.handler("", h.ctx);
404
+ const result = await h.tools.get(UAT_ITEM_TOOL)!.execute(
405
+ "t",
406
+ { op: "drop" },
407
+ undefined,
408
+ undefined,
409
+ h.ctx,
410
+ );
411
+ expect(result.isError).toBe(true);
412
+ expect(result.content[0].text).toContain("needs `item` or `reports`");
413
+ await h.commands.get(UAT_COMMAND)!.handler("off", h.ctx);
414
+ h.shutdown();
415
+ });
416
+
417
+ it("rejects a drop naming an unknown record", async () => {
418
+ const h = harness();
419
+ await h.commands.get(UAT_COMMAND)!.handler("", h.ctx);
420
+ const result = await h.tools.get(UAT_ITEM_TOOL)!.execute(
421
+ "t",
422
+ { op: "drop", reports: ["2099-01-01_0000_ghost"] },
423
+ undefined,
424
+ undefined,
425
+ h.ctx,
426
+ );
427
+ expect(result.isError).toBe(true);
428
+ expect(result.content[0].text).toContain("Unknown change record");
429
+ await h.commands.get(UAT_COMMAND)!.handler("off", h.ctx);
430
+ h.shutdown();
431
+ });
432
+ });
433
+
341
434
  describe("page round-trip", () => {
342
435
  it("clusters an item, then accepts it through the API", async () => {
343
436
  const first = createRecord(root, {
@@ -30,7 +30,14 @@ import {
30
30
  UAT_ITEM_TOOL,
31
31
  } from "./constants.js";
32
32
  import { registerUatItemTool } from "./item-tool.js";
33
- import { deriveState, ledgerPath, readEvents, appendEvent, newEventId } from "./ledger.js";
33
+ import {
34
+ deriveState,
35
+ ledgerPath,
36
+ readEvents,
37
+ appendEvent,
38
+ newEventId,
39
+ type PendingCandidate,
40
+ } from "./ledger.js";
34
41
  import { listRecords } from "./records.js";
35
42
  import { buildUatKickoff, describeCounts, UAT_MODE_BANNER } from "./prompt.js";
36
43
  import { registerRecordTool } from "./record-tool.js";
@@ -169,23 +176,43 @@ export function registerUat(pi: ExtensionAPI, options: UatOptions = {}): void {
169
176
  }
170
177
 
171
178
  /** Dispatch one clustering turn; the open page streams the resulting items. */
172
- function dispatchClustering(): void {
179
+ function planCandidates(
180
+ pending: readonly PendingCandidate[],
181
+ includeLegacy: boolean,
182
+ limit: number,
183
+ ): { picked: PendingCandidate[]; legacyRemaining: number } {
184
+ const fresh = pending.filter((entry) => entry.hasBehavior);
185
+ const historical = pending.filter((entry) => !entry.hasBehavior);
186
+ // New records first: they are cheap to cluster and carry the operator's
187
+ // actual behaviour sentence. Historical files only fill what is left.
188
+ const picked = fresh.slice(0, limit);
189
+ if (includeLegacy) {
190
+ picked.push(...historical.slice(0, Math.max(0, limit - picked.length)));
191
+ }
192
+ const included = picked.filter((entry) => !entry.hasBehavior).length;
193
+ return { picked, legacyRemaining: historical.length - included };
194
+ }
195
+
196
+ function dispatchClustering(includeLegacy = false): void {
173
197
  if (!root) return;
174
198
  const state = loadSnapshot(root).state;
175
- if (state.pending.length === 0) return;
176
- batch = openBatch(state.pending.length);
199
+ const planned = planCandidates(state.pending, includeLegacy, maxCandidates);
200
+ if (planned.picked.length === 0) return;
201
+ batch = openBatch(planned.picked.length);
177
202
  const fresh = loadSnapshot(root).state;
178
203
  pi.sendUserMessage(
179
204
  buildUatKickoff({
180
- pending: fresh.pending,
205
+ pending: planned.picked,
181
206
  openItems: fresh.open,
182
207
  maxCandidates,
183
208
  maxItems,
209
+ legacy: includeLegacy,
210
+ legacyRemaining: planned.legacyRemaining,
184
211
  }),
185
212
  );
186
213
  }
187
214
 
188
- async function start(ctx: ExtensionContext): Promise<void> {
215
+ async function start(ctx: ExtensionContext, includeLegacy = false): Promise<void> {
189
216
  const projectRoot = rootOf(ctx.cwd || process.cwd());
190
217
  if (!frameworkInstalled(projectRoot)) {
191
218
  const missing = frameworkMissing(projectRoot);
@@ -209,7 +236,7 @@ export function registerUat(pi: ExtensionAPI, options: UatOptions = {}): void {
209
236
  ctx.ui.notify(`ask-uat: page reopened — ${describeCounts(state)}.`, "info");
210
237
  // A second /ask-uat is the explicit "cluster what arrived since then"
211
238
  // action; merely reopening must not leave new records stuck forever.
212
- if (state.pending.length > 0 && ctx.isIdle()) dispatchClustering();
239
+ if (state.pending.length > 0 && ctx.isIdle()) dispatchClustering(includeLegacy);
213
240
  return;
214
241
  }
215
242
 
@@ -254,12 +281,12 @@ export function registerUat(pi: ExtensionAPI, options: UatOptions = {}): void {
254
281
  }
255
282
 
256
283
  if (pending.length === 0) return;
257
- dispatchClustering();
284
+ dispatchClustering(includeLegacy);
258
285
  }
259
286
 
260
287
  pi.registerCommand(UAT_COMMAND, {
261
288
  description:
262
- "Acceptance: cluster unaccepted change records into user-facing items, then open the page. `open` reopens it, `off` closes it.",
289
+ "Acceptance: cluster unaccepted change records into user-facing items, then open the page. `legacy` also includes records without a behaviour line, `open` reopens it, `off` closes it.",
263
290
  handler: async (args: string, ctx: ExtensionContext) => {
264
291
  const arg = args.trim();
265
292
  ctxRef = ctx;
@@ -280,11 +307,14 @@ export function registerUat(pi: ExtensionAPI, options: UatOptions = {}): void {
280
307
  ctx.ui.notify(`ask-uat: ${server.url}`, "info");
281
308
  return;
282
309
  }
283
- if (arg !== "") {
284
- ctx.ui.notify("ask-uat: usage — /ask-uat | /ask-uat open | /ask-uat off", "warning");
310
+ if (arg !== "" && arg !== "legacy") {
311
+ ctx.ui.notify(
312
+ "ask-uat: usage — /ask-uat | /ask-uat legacy | /ask-uat open | /ask-uat off",
313
+ "warning",
314
+ );
285
315
  return;
286
316
  }
287
- await start(ctx);
317
+ await start(ctx, arg === "legacy");
288
318
  },
289
319
  });
290
320
 
@@ -41,7 +41,8 @@ const PARAMS = Type.Object({
41
41
  ),
42
42
  item: Type.Optional(
43
43
  Type.String({
44
- description: "Target item id (link/amend/merge/drop). Omit for create — the id is generated.",
44
+ description:
45
+ "Target item id (link/amend/merge/drop). Omit for create — the id is generated. On drop it may be omitted when `reports` names the records to retire.",
45
46
  }),
46
47
  ),
47
48
  title: Type.Optional(Type.String({ description: "Short user-facing title (create/amend)." })),
@@ -69,7 +70,8 @@ const PARAMS = Type.Object({
69
70
  area: Type.Optional(Type.String({ description: "Short area label used for grouping." })),
70
71
  reports: Type.Optional(
71
72
  Type.Array(Type.String({ description: "Change-record id, e.g. 2026-11-13_2107_ask-uat." }), {
72
- description: "Change records that are evidence for this item (create/link).",
73
+ description:
74
+ "Change records that are evidence for this item (create/link). On drop, records to retire without creating an item.",
73
75
  }),
74
76
  ),
75
77
  sources: Type.Optional(
@@ -92,6 +94,7 @@ const GUIDELINES = [
92
94
  "Write `summary` in 2-3 sentences from the operator's point of view; never mention file names or functions there.",
93
95
  "Use op=\"link\" when the new evidence belongs to an already-open item; create a new item only for a distinct behaviour.",
94
96
  "Use op=\"drop\" with a reason for work that shipped but never became user-visible, or that was abandoned.",
97
+ "To retire records that should never be tested, pass op=\"drop\" with `reports` (and no item) instead of creating an item just to drop it.",
95
98
  ];
96
99
 
97
100
  function errorResult(text: string) {
@@ -210,7 +213,7 @@ export function registerUatItemTool(pi: ExtensionAPI, options: UatItemToolOption
210
213
  content: [
211
214
  {
212
215
  type: "text" as const,
213
- text: `Linked ${fresh.length} record${fresh.length === 1 ? "" : "s"} to ${summarize(item)}. If it was accepted, the page now shows it as reopened.`,
216
+ text: `Linked ${fresh.length} record${fresh.length === 1 ? "" : "s"} to ${summarize(item)}. The page updates immediately; only evidence newer than the last tick reopens an accepted item.`,
214
217
  },
215
218
  ],
216
219
  details: { item: item.id },
@@ -259,17 +262,42 @@ export function registerUatItemTool(pi: ExtensionAPI, options: UatItemToolOption
259
262
  };
260
263
  }
261
264
  case "drop": {
262
- const item = findItem((params.item ?? "").trim());
263
- if (!item) return errorResult("uat_item: `item` must be an existing open item id.");
265
+ const itemId = (params.item ?? "").trim();
266
+ const requested = (params.reports ?? []).map((value) => value.trim()).filter(Boolean);
267
+ if (itemId === "" && requested.length === 0) {
268
+ return errorResult("uat_item: drop needs `item` or `reports`.");
269
+ }
270
+ let reports: string[] = [];
271
+ if (requested.length > 0) {
272
+ const checked = checkReports(requested);
273
+ if (typeof checked === "string") return errorResult(`uat_item: ${checked}`);
274
+ reports = checked;
275
+ }
276
+ if (itemId !== "") {
277
+ const item = findItem(itemId);
278
+ if (!item) return errorResult("uat_item: `item` must be an existing open item id.");
279
+ }
264
280
  append({
265
281
  ...base,
266
282
  type: "drop",
267
- item: item.id,
283
+ ...(itemId !== "" ? { item: itemId } : {}),
284
+ ...(reports.length > 0 ? { reports } : {}),
268
285
  reason: params.reason?.trim() || undefined,
269
286
  });
287
+ const counts = [
288
+ itemId !== "" ? `item ${itemId}` : "",
289
+ reports.length > 0
290
+ ? `${reports.length} record${reports.length === 1 ? "" : "s"}`
291
+ : "",
292
+ ].filter(Boolean);
270
293
  return {
271
- content: [{ type: "text" as const, text: `Dropped ${item.id}.` }],
272
- details: { item: item.id },
294
+ content: [
295
+ {
296
+ type: "text" as const,
297
+ text: `Retired ${counts.join(" and ")}. Retired records leave the pending queue; nothing was deleted.`,
298
+ },
299
+ ],
300
+ details: { item: itemId !== "" ? itemId : undefined, reports },
273
301
  };
274
302
  }
275
303
  default:
@@ -27,9 +27,28 @@ afterEach(() => {
27
27
  });
28
28
 
29
29
  let counter = 0;
30
+
31
+ /**
32
+ * Local ISO timestamp with seconds and the machine's own offset.
33
+ *
34
+ * Tests must not hardcode `+08:00`: records are written in local time, and a
35
+ * fixed offset silently shifts every comparison by the machine's timezone.
36
+ */
37
+ function isoSeconds(date: Date): string {
38
+ const pad = (value: number): string => String(value).padStart(2, "0");
39
+ const offset = -date.getTimezoneOffset();
40
+ const sign = offset >= 0 ? "+" : "-";
41
+ const absolute = Math.abs(offset);
42
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(
43
+ date.getHours(),
44
+ )}:${pad(date.getMinutes())}:${pad(date.getSeconds())}${sign}${pad(
45
+ Math.floor(absolute / 60),
46
+ )}:${pad(absolute % 60)}`;
47
+ }
48
+
30
49
  function event<T extends Omit<UatEvent, "v" | "id" | "ts">>(
31
50
  body: T,
32
- ts = "2026-11-13T21:00+08:00",
51
+ ts = isoSeconds(new Date(2026, 10, 13, 21, 0)),
33
52
  ): UatEvent {
34
53
  counter += 1;
35
54
  return { v: 1, id: `e-test-${counter}`, ts, ...body } as unknown as UatEvent;
@@ -43,7 +62,11 @@ function candidate(report: string, behavior = "operator sees it"): CandidateEven
43
62
  return event({ type: "candidate", report, title: report, behavior }) as CandidateEvent;
44
63
  }
45
64
 
46
- function item(id: string, reports: string[], ts = "2026-11-13T21:00+08:00"): ItemEvent {
65
+ function item(
66
+ id: string,
67
+ reports: string[],
68
+ ts = isoSeconds(new Date(2026, 10, 13, 21, 0)),
69
+ ): ItemEvent {
47
70
  return event(
48
71
  { type: "item", item: id, title: id, summary: "summary", reports },
49
72
  ts,
@@ -140,13 +163,16 @@ describe("derivation", () => {
140
163
  const state = deriveState(
141
164
  [a, b],
142
165
  [
143
- item("U-1", [a.id], "2026-11-13T20:00+08:00"),
144
- check("U-1", "2026-11-13T21:00+08:00"),
145
- event({ type: "link", item: "U-1", reports: [b.id] }, "2026-11-14T10:00+08:00"),
166
+ item("U-1", [a.id], isoSeconds(new Date(2026, 10, 13, 20, 0))),
167
+ check("U-1", isoSeconds(new Date(2026, 10, 13, 21, 0))),
168
+ event(
169
+ { type: "link", item: "U-1", reports: [b.id] },
170
+ isoSeconds(new Date(2026, 10, 14, 10, 0)),
171
+ ),
146
172
  ],
147
173
  );
148
174
  const entry = state.items.find((candidateItem) => candidateItem.id === "U-1");
149
- expect(entry?.checkedAt).toBe("2026-11-13T21:00+08:00");
175
+ expect(entry?.checkedAt).toBe(isoSeconds(new Date(2026, 10, 13, 21, 0)));
150
176
  expect(entry?.reopened).toBe(true);
151
177
  expect(state.open.map((candidateItem) => candidateItem.id)).toEqual(["U-1"]);
152
178
  expect(state.checked).toEqual([]);
@@ -158,11 +184,11 @@ describe("derivation", () => {
158
184
  const state = deriveState(
159
185
  [a, b],
160
186
  [
161
- item("U-1", [a.id], "2026-11-13T21:06:00+08:00"),
162
- check("U-1", "2026-11-13T21:07:10+08:00"),
187
+ item("U-1", [a.id], isoSeconds(new Date(2026, 10, 13, 21, 6, 0))),
188
+ check("U-1", isoSeconds(new Date(2026, 10, 13, 21, 7, 10))),
163
189
  event(
164
190
  { type: "link", item: "U-1", reports: [b.id] },
165
- "2026-11-13T21:07:50+08:00",
191
+ isoSeconds(new Date(2026, 10, 13, 21, 7, 50)),
166
192
  ),
167
193
  ],
168
194
  );
@@ -172,7 +198,13 @@ describe("derivation", () => {
172
198
 
173
199
  it("keeps a checked item checked when no newer evidence exists", () => {
174
200
  const a = record("alpha", new Date(2026, 10, 13, 9, 0));
175
- const state = deriveState([a], [item("U-1", [a.id], "2026-11-13T20:00+08:00"), check("U-1", "2026-11-13T21:00+08:00")]);
201
+ const state = deriveState(
202
+ [a],
203
+ [
204
+ item("U-1", [a.id], isoSeconds(new Date(2026, 10, 13, 20, 0))),
205
+ check("U-1", isoSeconds(new Date(2026, 10, 13, 21, 0))),
206
+ ],
207
+ );
176
208
  expect(state.checked.map((entry) => entry.id)).toEqual(["U-1"]);
177
209
  expect(state.open).toEqual([]);
178
210
  });
@@ -221,10 +253,13 @@ describe("derivation", () => {
221
253
  const state = deriveState(
222
254
  [a, b],
223
255
  [
224
- item("U-target", [a.id], "2026-11-13T10:00+08:00"),
225
- item("U-source", [b.id], "2026-11-12T10:00+08:00"),
226
- check("U-target", "2026-11-13T11:00+08:00"),
227
- event({ type: "merge", item: "U-target", sources: ["U-source"] }, "2026-11-13T12:00+08:00"),
256
+ item("U-target", [a.id], isoSeconds(new Date(2026, 10, 13, 10, 0))),
257
+ item("U-source", [b.id], isoSeconds(new Date(2026, 10, 12, 10, 0))),
258
+ check("U-target", isoSeconds(new Date(2026, 10, 13, 11, 0))),
259
+ event(
260
+ { type: "merge", item: "U-target", sources: ["U-source"] },
261
+ isoSeconds(new Date(2026, 10, 13, 12, 0)),
262
+ ),
228
263
  ],
229
264
  );
230
265
  expect(state.open.map((entry) => entry.id)).toEqual(["U-target"]);
@@ -246,4 +281,125 @@ describe("derivation", () => {
246
281
  const state = deriveState([], [item("U-1", ["gone"])]);
247
282
  expect(state.items[0]?.missingReports).toEqual(["gone"]);
248
283
  });
284
+
285
+ it("keeps a none: hint record out of the queue and counts it as retired", () => {
286
+ const a = record("alpha", new Date(2026, 10, 13, 9, 0));
287
+ const b = record("beta", new Date(2026, 10, 13, 10, 0));
288
+ const state = deriveState(
289
+ [a, b],
290
+ [
291
+ candidate(a.id, "alpha behaviour"),
292
+ event({
293
+ type: "candidate",
294
+ report: b.id,
295
+ title: b.id,
296
+ behavior: "docs only",
297
+ hint: " None:internal docs, nothing to test ",
298
+ }),
299
+ ],
300
+ );
301
+ expect(state.pending.map((entry) => entry.id)).toEqual([a.id]);
302
+ expect(state.counts.retired).toBe(1);
303
+ expect(state.retired[0]).toMatchObject({ id: b.id, reason: "none" });
304
+ });
305
+
306
+ it("does not treat a hint that merely mentions none as a retirement", () => {
307
+ const a = record("alpha", new Date(2026, 10, 13, 9, 0));
308
+ const state = deriveState(
309
+ [a],
310
+ [
311
+ event({
312
+ type: "candidate",
313
+ report: a.id,
314
+ title: a.id,
315
+ behavior: "operator sees it",
316
+ hint: "open the list, nothing none-ish about it",
317
+ }),
318
+ ],
319
+ );
320
+ expect(state.pending.map((entry) => entry.id)).toEqual([a.id]);
321
+ expect(state.counts.retired).toBe(0);
322
+ });
323
+
324
+ it("splits pending into new records and legacy files", () => {
325
+ const fresh = record("fresh", new Date(2026, 10, 13, 9, 0));
326
+ const legacy = record("legacy", new Date(2026, 10, 12, 9, 0));
327
+ const state = deriveState([fresh, legacy], [candidate(fresh.id, "fresh behaviour")]);
328
+ const byId = new Map(state.pending.map((entry) => [entry.id, entry]));
329
+ expect(byId.get(fresh.id)?.hasBehavior).toBe(true);
330
+ expect(byId.get(legacy.id)?.hasBehavior).toBe(false);
331
+ expect(state.counts.pendingNew).toBe(1);
332
+ expect(state.counts.pendingLegacy).toBe(1);
333
+ expect(state.counts.pending).toBe(2);
334
+ });
335
+
336
+ it("retires records by drop even when no item exists", () => {
337
+ const a = record("alpha", new Date(2026, 10, 13, 9, 0));
338
+ const state = deriveState(
339
+ [a],
340
+ [
341
+ event(
342
+ { type: "drop", reports: [a.id], reason: "absorbed by a later item" },
343
+ "2026-11-13T22:00+08:00",
344
+ ),
345
+ ],
346
+ );
347
+ expect(state.items).toEqual([]);
348
+ expect(state.pending).toEqual([]);
349
+ expect(state.counts.retired).toBe(1);
350
+ expect(state.retired[0]).toMatchObject({ id: a.id, reason: "dropped" });
351
+ });
352
+
353
+ it("keeps an accepted item accepted when an older record is attached", () => {
354
+ const recent = record("recent", new Date(2026, 10, 10, 9, 0));
355
+ const old = record("old", new Date(2026, 10, 5, 9, 0));
356
+ const state = deriveState(
357
+ [recent, old],
358
+ [
359
+ item("U-1", [recent.id], isoSeconds(new Date(2026, 10, 10, 20, 0))),
360
+ check("U-1", isoSeconds(new Date(2026, 10, 12, 21, 0))),
361
+ event(
362
+ { type: "link", item: "U-1", reports: [old.id] },
363
+ isoSeconds(new Date(2026, 10, 13, 9, 0)),
364
+ ),
365
+ ],
366
+ );
367
+ expect(state.checked.map((entry) => entry.id)).toEqual(["U-1"]);
368
+ expect(state.items[0]?.reopened).toBe(false);
369
+ });
370
+
371
+ it("does not reopen when the attached record predates the check's minute", () => {
372
+ const recent = record("recent", new Date(2026, 10, 13, 21, 5));
373
+ const earlier = record("earlier", new Date(2026, 10, 13, 21, 6));
374
+ const state = deriveState(
375
+ [recent, earlier],
376
+ [
377
+ item("U-1", [recent.id], isoSeconds(new Date(2026, 10, 13, 21, 5, 30))),
378
+ check("U-1", isoSeconds(new Date(2026, 10, 13, 21, 7, 40))),
379
+ event(
380
+ { type: "link", item: "U-1", reports: [earlier.id] },
381
+ isoSeconds(new Date(2026, 10, 13, 23, 0)),
382
+ ),
383
+ ],
384
+ );
385
+ expect(state.checked.map((entry) => entry.id)).toEqual(["U-1"]);
386
+ });
387
+
388
+ it("reopens when a record newer than the check lands later", () => {
389
+ const recent = record("recent", new Date(2026, 10, 13, 21, 5));
390
+ const newer = record("newer", new Date(2026, 10, 14, 8, 0));
391
+ const state = deriveState(
392
+ [recent, newer],
393
+ [
394
+ item("U-1", [recent.id], isoSeconds(new Date(2026, 10, 13, 21, 5, 30))),
395
+ check("U-1", isoSeconds(new Date(2026, 10, 13, 21, 7, 40))),
396
+ event(
397
+ { type: "link", item: "U-1", reports: [newer.id] },
398
+ isoSeconds(new Date(2026, 10, 14, 10, 0)),
399
+ ),
400
+ ],
401
+ );
402
+ expect(state.open.map((entry) => entry.id)).toEqual(["U-1"]);
403
+ expect(state.items[0]?.reopened).toBe(true);
404
+ });
249
405
  });