@ftrdotdev/pi-tracker 0.6.0 → 0.7.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/README.md +109 -60
- package/package.json +8 -3
- package/src/compaction/candidate.test.ts +9 -6
- package/src/compaction/candidate.ts +32 -2
- package/src/compaction/classifier.test.ts +67 -60
- package/src/compaction/classifier.ts +24 -22
- package/src/compaction/completion.test.ts +127 -49
- package/src/compaction/completion.ts +1 -3
- package/src/compaction/decision-record.test.ts +91 -0
- package/src/compaction/decision-record.ts +101 -0
- package/src/compaction/digest.test.ts +104 -9
- package/src/compaction/digest.ts +96 -9
- package/src/compaction/footprint.test.ts +135 -0
- package/src/compaction/footprint.ts +387 -0
- package/src/compaction/observations.test.ts +199 -0
- package/src/compaction/observations.ts +348 -0
- package/src/compaction/rules.test.ts +253 -0
- package/src/compaction/rules.ts +188 -0
- package/src/compaction/settings.test.ts +105 -49
- package/src/compaction/settings.ts +53 -31
- package/src/compaction/settle.test.ts +370 -0
- package/src/compaction/settle.ts +109 -53
- package/src/core/deps.test.ts +1 -1
- package/src/core/domain.test.ts +42 -9
- package/src/core/domain.ts +73 -8
- package/src/core/persistence.test.ts +7 -7
- package/src/core/store.test.ts +116 -50
- package/src/core/store.ts +92 -31
- package/src/index.test.ts +172 -68
- package/src/index.ts +148 -46
- package/src/presentation/tool-metadata.test.ts +263 -48
- package/src/presentation/tool-metadata.ts +325 -102
- package/src/presentation/ui.test.ts +60 -6
- package/src/presentation/ui.ts +33 -15
|
@@ -33,14 +33,14 @@ const twoListState = (): TrackerState =>
|
|
|
33
33
|
id: 1,
|
|
34
34
|
name: "Work",
|
|
35
35
|
items: [
|
|
36
|
-
new TodoItem({
|
|
37
|
-
new TodoItem({
|
|
36
|
+
new TodoItem({ title: "write plan", done: true }),
|
|
37
|
+
new TodoItem({ title: "implement tracker", done: false }),
|
|
38
38
|
],
|
|
39
39
|
}),
|
|
40
40
|
new TodoList({
|
|
41
41
|
id: 2,
|
|
42
42
|
name: "Home",
|
|
43
|
-
items: [new TodoItem({
|
|
43
|
+
items: [new TodoItem({ title: "water plants", done: false })],
|
|
44
44
|
}),
|
|
45
45
|
],
|
|
46
46
|
activeListId: 1,
|
|
@@ -93,6 +93,25 @@ const flushAsync = (): Promise<void> => new Promise((resolve) => setTimeout(reso
|
|
|
93
93
|
// Interactive overlay: items pane follows the focused list
|
|
94
94
|
// --------------------------------------------------------------------------
|
|
95
95
|
|
|
96
|
+
it("overlay renders a multi-line description as separate lines", () => {
|
|
97
|
+
const list = new TodoList({
|
|
98
|
+
id: 1,
|
|
99
|
+
name: "Work",
|
|
100
|
+
items: [
|
|
101
|
+
new TodoItem({ id: 1, title: "multi", description: "first line\nsecond line", done: false }),
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
const h = makeOverlay(new TrackerState({ lists: [list], activeListId: 1, nextListId: 2 }));
|
|
105
|
+
const lines = h.overlay.render(80);
|
|
106
|
+
assert.equal(
|
|
107
|
+
lines.some((line) => line.includes("\n")),
|
|
108
|
+
false,
|
|
109
|
+
);
|
|
110
|
+
const text = lines.join("\n");
|
|
111
|
+
assert.include(text, "first line");
|
|
112
|
+
assert.include(text, "second line");
|
|
113
|
+
});
|
|
114
|
+
|
|
96
115
|
it("previews the focused list's items while navigating the lists pane", () => {
|
|
97
116
|
const h = makeOverlay(twoListState());
|
|
98
117
|
const text = () => h.overlay.render(80).join("\n");
|
|
@@ -192,6 +211,41 @@ it("widget renders nothing when no list is active (bridge hides it)", () => {
|
|
|
192
211
|
assert.deepStrictEqual(renderTrackerWidget(state, identityTheme, 40), []);
|
|
193
212
|
});
|
|
194
213
|
|
|
214
|
+
it("widget shows a dimmed description line truncated to the width", () => {
|
|
215
|
+
const description = "x".repeat(120);
|
|
216
|
+
const list = new TodoList({
|
|
217
|
+
id: 1,
|
|
218
|
+
name: "Work",
|
|
219
|
+
items: [new TodoItem({ id: 1, title: "long item", description, done: false })],
|
|
220
|
+
});
|
|
221
|
+
const state = new TrackerState({ lists: [list], activeListId: 1, nextListId: 2 });
|
|
222
|
+
const width = 40;
|
|
223
|
+
const lines = renderTrackerWidget(state, identityTheme, width);
|
|
224
|
+
const text = lines.join("\n");
|
|
225
|
+
assert.include(text, "long item");
|
|
226
|
+
notContain(text, description);
|
|
227
|
+
const descriptionLine = lines.find((line) => line.includes("x"));
|
|
228
|
+
assert.isDefined(descriptionLine);
|
|
229
|
+
assert.isAtMost(visibleWidth(descriptionLine!), width);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("widget collapses a multi-line description into one line", () => {
|
|
233
|
+
const list = new TodoList({
|
|
234
|
+
id: 1,
|
|
235
|
+
name: "Work",
|
|
236
|
+
items: [
|
|
237
|
+
new TodoItem({ id: 1, title: "multi", description: "first line\nsecond line", done: false }),
|
|
238
|
+
],
|
|
239
|
+
});
|
|
240
|
+
const state = new TrackerState({ lists: [list], activeListId: 1, nextListId: 2 });
|
|
241
|
+
const lines = renderTrackerWidget(state, identityTheme, 60);
|
|
242
|
+
assert.equal(
|
|
243
|
+
lines.some((line) => line.includes("\n")),
|
|
244
|
+
false,
|
|
245
|
+
);
|
|
246
|
+
assert.include(lines.join("\n"), "first line second line");
|
|
247
|
+
});
|
|
248
|
+
|
|
195
249
|
it("widget survives the setWidget bridge wrapper (render/invalidate handed off by reference)", () => {
|
|
196
250
|
// Mirrors the tracker bridge: `return { render: widget.render, invalidate: widget.invalidate }`.
|
|
197
251
|
// pi calls render as a method of the wrapper; closure components carry no
|
|
@@ -220,7 +274,7 @@ const listOfCount = (count: number, done: number): TodoList =>
|
|
|
220
274
|
nextItemId: count + 1,
|
|
221
275
|
items: Array.from(
|
|
222
276
|
{ length: count },
|
|
223
|
-
(_, index) => new TodoItem({ id: index + 1,
|
|
277
|
+
(_, index) => new TodoItem({ id: index + 1, title: `item ${index + 1}`, done: index < done }),
|
|
224
278
|
),
|
|
225
279
|
});
|
|
226
280
|
|
|
@@ -240,7 +294,7 @@ const listWithDeps = (
|
|
|
240
294
|
(itemDeps, index) =>
|
|
241
295
|
new TodoItem({
|
|
242
296
|
id: index + 1,
|
|
243
|
-
|
|
297
|
+
title: `item ${index + 1}`,
|
|
244
298
|
done: done.includes(index),
|
|
245
299
|
deps: itemDeps,
|
|
246
300
|
}),
|
|
@@ -431,7 +485,7 @@ it("planner anchors on the first ready item, not the first open item", () => {
|
|
|
431
485
|
(_, index) =>
|
|
432
486
|
new TodoItem({
|
|
433
487
|
id: index + 1,
|
|
434
|
-
|
|
488
|
+
title: `item ${index + 1}`,
|
|
435
489
|
done: index === 0,
|
|
436
490
|
deps: index === 1 ? ["Work:30"] : [],
|
|
437
491
|
}),
|
package/src/presentation/ui.ts
CHANGED
|
@@ -202,10 +202,21 @@ const widgetRows =
|
|
|
202
202
|
const item = view.list.items[row.index]!;
|
|
203
203
|
const blocked = (view.ready[row.index]?.blockers.length ?? 0) > 0;
|
|
204
204
|
const marker = itemMarker(item, blocked, row.index === current, theme);
|
|
205
|
-
const
|
|
206
|
-
? theme.style(item.
|
|
207
|
-
: item.
|
|
208
|
-
rows.push(` ${marker}${
|
|
205
|
+
const title = item.done
|
|
206
|
+
? theme.style(item.title, { fg: "muted", strikethrough: true })
|
|
207
|
+
: item.title;
|
|
208
|
+
rows.push(` ${marker}${title}`);
|
|
209
|
+
if (item.description.length > 0) {
|
|
210
|
+
// The widget row is one line, so a multi-line description collapses
|
|
211
|
+
// to single spaces before it is truncated.
|
|
212
|
+
const description = item.description.replace(/\s+/g, " ").trim();
|
|
213
|
+
rows.push(
|
|
214
|
+
truncateToWidth(
|
|
215
|
+
`${" ".repeat(2 + MARKER_WIDTH)}${theme.fg("dim", description)}`,
|
|
216
|
+
Math.max(0, _width),
|
|
217
|
+
),
|
|
218
|
+
);
|
|
219
|
+
}
|
|
209
220
|
}
|
|
210
221
|
return rows;
|
|
211
222
|
};
|
|
@@ -251,7 +262,7 @@ export type TrackerUiAction =
|
|
|
251
262
|
| { readonly type: "createList"; readonly name: string }
|
|
252
263
|
| { readonly type: "deleteList"; readonly listId: number }
|
|
253
264
|
| { readonly type: "setActive"; readonly listId: number | null }
|
|
254
|
-
| { readonly type: "addItem"; readonly listId: number; readonly
|
|
265
|
+
| { readonly type: "addItem"; readonly listId: number; readonly title: string }
|
|
255
266
|
| { readonly type: "updateItem"; readonly itemId: string; readonly patch: UpdateItemPatch }
|
|
256
267
|
| { readonly type: "removeItem"; readonly itemId: string };
|
|
257
268
|
|
|
@@ -444,11 +455,18 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
444
455
|
const prefix = selected ? theme.fg("accent", "→ ") : " ";
|
|
445
456
|
const blocker = readinessSuffix(item.done, view.ready[index]?.blockers ?? []);
|
|
446
457
|
const check = itemMarker(item, blocker !== "", false, theme);
|
|
447
|
-
const
|
|
448
|
-
? theme.style(item.
|
|
449
|
-
: item.
|
|
450
|
-
const row = truncateToWidth(`${prefix}${check}${
|
|
458
|
+
const title = item.done
|
|
459
|
+
? theme.style(item.title, { fg: "muted", strikethrough: true })
|
|
460
|
+
: item.title;
|
|
461
|
+
const row = truncateToWidth(`${prefix}${check}${title}${blocker}`, width);
|
|
451
462
|
lines.push(selected ? theme.style(row, { bg: "selectedBg" }) : row);
|
|
463
|
+
if (item.description.length > 0) {
|
|
464
|
+
// The overlay shows the full description; each source line becomes
|
|
465
|
+
// its own row so no embedded newline reaches the renderer.
|
|
466
|
+
for (const descriptionLine of item.description.split("\n")) {
|
|
467
|
+
lines.push(truncateToWidth(` ${theme.fg("dim", descriptionLine)}`, width));
|
|
468
|
+
}
|
|
469
|
+
}
|
|
452
470
|
}
|
|
453
471
|
if (activeListFor.items.length > MAX_ITEMS) {
|
|
454
472
|
lines.push(
|
|
@@ -467,8 +485,8 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
467
485
|
input.kind === "newList"
|
|
468
486
|
? "New list name"
|
|
469
487
|
: input.kind === "addItem"
|
|
470
|
-
? "Item
|
|
471
|
-
: "Edit item
|
|
488
|
+
? "Item title"
|
|
489
|
+
: "Edit item title";
|
|
472
490
|
lines.push(truncateToWidth(` ${theme.fg("accent", `${prompt}:`)} ${input.buffer}▌`, width));
|
|
473
491
|
lines.push(truncateToWidth(` ${theme.fg("dim", "enter confirm · esc cancel")}`, width));
|
|
474
492
|
} else if (error) {
|
|
@@ -624,7 +642,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
624
642
|
input = {
|
|
625
643
|
kind: "editItem",
|
|
626
644
|
itemId: `${list.name}:${item.id}`,
|
|
627
|
-
buffer: item.
|
|
645
|
+
buffer: item.title,
|
|
628
646
|
};
|
|
629
647
|
return true;
|
|
630
648
|
}
|
|
@@ -641,7 +659,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
641
659
|
if (data === "c") {
|
|
642
660
|
const item = items[itemIndex];
|
|
643
661
|
if (!item) return true;
|
|
644
|
-
copyText(`${list.name}:${item.id} ${item.
|
|
662
|
+
copyText(`${list.name}:${item.id} ${item.title}`, `item "${item.title}"`);
|
|
645
663
|
return true;
|
|
646
664
|
}
|
|
647
665
|
return false;
|
|
@@ -659,11 +677,11 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
659
677
|
current.kind === "newList"
|
|
660
678
|
? { type: "createList", name: current.buffer }
|
|
661
679
|
: current.kind === "addItem"
|
|
662
|
-
? { type: "addItem", listId: current.listId,
|
|
680
|
+
? { type: "addItem", listId: current.listId, title: current.buffer }
|
|
663
681
|
: {
|
|
664
682
|
type: "updateItem",
|
|
665
683
|
itemId: current.itemId,
|
|
666
|
-
patch: {
|
|
684
|
+
patch: { title: current.buffer },
|
|
667
685
|
};
|
|
668
686
|
void runAction(action);
|
|
669
687
|
} else if (matchesKey(data, Key.backspace)) {
|