@ftrdotdev/pi-tracker 0.8.0 → 0.9.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 +369 -0
- package/README.md +5 -0
- package/package.json +20 -16
- package/src/compaction/candidate.test.ts +66 -125
- package/src/compaction/classifier.test.ts +22 -2
- package/src/compaction/classifier.ts +35 -22
- package/src/compaction/completion.test.ts +24 -16
- package/src/compaction/completion.ts +1 -1
- package/src/compaction/decision-record.test.ts +1 -1
- package/src/compaction/decision-record.ts +1 -1
- package/src/compaction/digest.test.ts +34 -34
- package/src/compaction/footprint.ts +2 -4
- package/src/compaction/settings.test.ts +5 -1
- package/src/compaction/settings.ts +1 -1
- package/src/compaction/settle.test.ts +50 -10
- package/src/compaction/settle.ts +1 -1
- package/src/core/deps.test.ts +128 -109
- package/src/core/deps.ts +3 -2
- package/src/core/domain.test.ts +99 -68
- package/src/core/domain.ts +16 -10
- package/src/core/persistence.test.ts +18 -19
- package/src/core/persistence.ts +4 -3
- package/src/core/store.test.ts +129 -167
- package/src/core/store.ts +77 -57
- package/src/harness-collection.test.ts +75 -0
- package/src/index.test.ts +35 -30
- package/src/index.ts +45 -66
- package/src/layers.test.ts +101 -0
- package/src/layers.ts +46 -0
- package/src/presentation/tool-metadata.test.ts +36 -38
- package/src/presentation/tool-metadata.ts +127 -130
- package/src/presentation/ui.test.ts +67 -67
- package/src/presentation/ui.ts +22 -19
- package/src/presentation/vim-settings.test.ts +3 -0
- package/src/presentation/vim-settings.ts +1 -1
package/src/presentation/ui.ts
CHANGED
|
@@ -232,7 +232,7 @@ const widgetRows =
|
|
|
232
232
|
*/
|
|
233
233
|
export const makeTrackerWidget = (state: TrackerState, theme: Theme): Component => {
|
|
234
234
|
const list = activeList(state);
|
|
235
|
-
if (
|
|
235
|
+
if (list === undefined) {
|
|
236
236
|
// No list is active: render nothing. The bridge hides the widget in this
|
|
237
237
|
// case; an empty component keeps the seam safe regardless.
|
|
238
238
|
return { render: () => [], invalidate: () => {} };
|
|
@@ -250,8 +250,11 @@ export const makeTrackerWidget = (state: TrackerState, theme: Theme): Component
|
|
|
250
250
|
* Lines for the widget pane, or an empty array when no list is active — the
|
|
251
251
|
* bridge hides the widget in that case. Kept as a convenience for tests.
|
|
252
252
|
*/
|
|
253
|
-
export const renderTrackerWidget = (
|
|
254
|
-
|
|
253
|
+
export const renderTrackerWidget = (
|
|
254
|
+
state: TrackerState,
|
|
255
|
+
theme: Theme,
|
|
256
|
+
width: number,
|
|
257
|
+
): readonly string[] => makeTrackerWidget(state, theme).render(Math.max(4, width));
|
|
255
258
|
|
|
256
259
|
// --------------------------------------------------------------------------
|
|
257
260
|
// Interactive overlay (/tracker command)
|
|
@@ -330,7 +333,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
330
333
|
let cachedSignature: string | undefined;
|
|
331
334
|
|
|
332
335
|
const handleInput = (data: string): void => {
|
|
333
|
-
if (input) {
|
|
336
|
+
if (input !== null) {
|
|
334
337
|
handleInputMode(data);
|
|
335
338
|
return;
|
|
336
339
|
}
|
|
@@ -366,7 +369,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
366
369
|
const handleMouse = (event: TuiMouseEvent): { handled: boolean } | undefined => {
|
|
367
370
|
if (event.type !== "wheel") return undefined;
|
|
368
371
|
const delta = event.wheelDelta ?? 0;
|
|
369
|
-
if (delta === 0 || input) return { handled: delta !== 0 };
|
|
372
|
+
if (delta === 0 || input !== null) return { handled: delta !== 0 };
|
|
370
373
|
// pi normalizes wheel events to logical lines (the renderer applies
|
|
371
374
|
// `WheelScrollAccelerator`), so the delta is the step count directly.
|
|
372
375
|
const step = Math.abs(delta);
|
|
@@ -377,7 +380,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
377
380
|
if (count > 0) listIndex = wrap(listIndex + direction, count);
|
|
378
381
|
} else {
|
|
379
382
|
const list = activeList(state);
|
|
380
|
-
const count = list ? orderedItems(list).length : 0;
|
|
383
|
+
const count = list !== undefined ? orderedItems(list).length : 0;
|
|
381
384
|
if (count > 0) itemIndex = wrap(itemIndex + direction, count);
|
|
382
385
|
}
|
|
383
386
|
options.requestRender();
|
|
@@ -453,7 +456,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
453
456
|
});
|
|
454
457
|
lines.push(truncateToWidth(` ${itemsHeader}`, width));
|
|
455
458
|
|
|
456
|
-
if (
|
|
459
|
+
if (activeListFor === undefined) {
|
|
457
460
|
const hint =
|
|
458
461
|
state.lists.length === 0
|
|
459
462
|
? "No lists yet — press n to create one"
|
|
@@ -492,7 +495,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
492
495
|
}
|
|
493
496
|
|
|
494
497
|
// Input prompt / error line
|
|
495
|
-
if (input) {
|
|
498
|
+
if (input !== null) {
|
|
496
499
|
lines.push("");
|
|
497
500
|
const prompt =
|
|
498
501
|
input.kind === "newList"
|
|
@@ -502,17 +505,17 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
502
505
|
: "Edit item title";
|
|
503
506
|
lines.push(truncateToWidth(` ${theme.fg("accent", `${prompt}:`)} ${input.buffer}▌`, width));
|
|
504
507
|
lines.push(truncateToWidth(` ${theme.fg("dim", "enter confirm · esc cancel")}`, width));
|
|
505
|
-
} else if (error) {
|
|
508
|
+
} else if (error !== null && error !== "") {
|
|
506
509
|
lines.push("");
|
|
507
510
|
lines.push(truncateToWidth(` ${theme.fg("warning", `! ${error}`)}`, width));
|
|
508
|
-
} else if (notice) {
|
|
511
|
+
} else if (notice !== null && notice !== "") {
|
|
509
512
|
lines.push("");
|
|
510
513
|
lines.push(truncateToWidth(` ${theme.fg("success", `✓ ${notice}`)}`, width));
|
|
511
514
|
}
|
|
512
515
|
|
|
513
516
|
// Help
|
|
514
517
|
lines.push("");
|
|
515
|
-
const move = options.vim?.enabled ? "[↑↓←→/hjkl] move" : "[↑↓←→] move";
|
|
518
|
+
const move = (options.vim?.enabled ?? false) ? "[↑↓←→/hjkl] move" : "[↑↓←→] move";
|
|
516
519
|
const help =
|
|
517
520
|
mode === "lists"
|
|
518
521
|
? `[tab] items · [n] new · [d] delete · [c] copy · [space] toggle · ${move} · [enter] active · [esc] close`
|
|
@@ -578,7 +581,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
578
581
|
if (count > 0) listIndex = wrap(listIndex + step, count);
|
|
579
582
|
} else {
|
|
580
583
|
const list = activeList(state);
|
|
581
|
-
const count = list ? orderedItems(list).length : 0;
|
|
584
|
+
const count = list !== undefined ? orderedItems(list).length : 0;
|
|
582
585
|
if (count > 0) itemIndex = wrap(itemIndex + step, count);
|
|
583
586
|
}
|
|
584
587
|
return;
|
|
@@ -644,7 +647,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
644
647
|
|
|
645
648
|
const handleItemsKey = (data: string, state: TrackerState): boolean => {
|
|
646
649
|
const list = activeList(state);
|
|
647
|
-
if (
|
|
650
|
+
if (list === undefined) {
|
|
648
651
|
if (data === "n") {
|
|
649
652
|
input = { kind: "newList", buffer: "" };
|
|
650
653
|
return true;
|
|
@@ -669,7 +672,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
669
672
|
}
|
|
670
673
|
if (matchesKey(data, Key.enter) || data === "x") {
|
|
671
674
|
const item = items[itemIndex];
|
|
672
|
-
if (
|
|
675
|
+
if (item === undefined) return true;
|
|
673
676
|
void runAction({
|
|
674
677
|
type: "updateItem",
|
|
675
678
|
itemId: `${list.name}:${item.id}`,
|
|
@@ -683,7 +686,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
683
686
|
}
|
|
684
687
|
if (data === "e") {
|
|
685
688
|
const item = items[itemIndex];
|
|
686
|
-
if (
|
|
689
|
+
if (item === undefined) return true;
|
|
687
690
|
input = {
|
|
688
691
|
kind: "editItem",
|
|
689
692
|
itemId: `${list.name}:${item.id}`,
|
|
@@ -693,7 +696,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
693
696
|
}
|
|
694
697
|
if (data === "r") {
|
|
695
698
|
const item = items[itemIndex];
|
|
696
|
-
if (
|
|
699
|
+
if (item === undefined) return true;
|
|
697
700
|
void runAction({ type: "removeItem", itemId: `${list.name}:${item.id}` });
|
|
698
701
|
return true;
|
|
699
702
|
}
|
|
@@ -703,7 +706,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
703
706
|
}
|
|
704
707
|
if (data === "c") {
|
|
705
708
|
const item = items[itemIndex];
|
|
706
|
-
if (
|
|
709
|
+
if (item === undefined) return true;
|
|
707
710
|
copyText(`${list.name}:${item.id} ${item.title}`, `item "${item.title}"`);
|
|
708
711
|
return true;
|
|
709
712
|
}
|
|
@@ -712,7 +715,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
712
715
|
|
|
713
716
|
const handleInputMode = (data: string): void => {
|
|
714
717
|
const current = input;
|
|
715
|
-
if (
|
|
718
|
+
if (current === null) return;
|
|
716
719
|
if (matchesKey(data, Key.escape)) {
|
|
717
720
|
input = null;
|
|
718
721
|
error = null;
|
|
@@ -740,7 +743,7 @@ export const makeTrackerOverlay = (options: TrackerOverlayOptions): TrackerOverl
|
|
|
740
743
|
|
|
741
744
|
const runAction = async (action: TrackerUiAction, afterSuccess?: () => void): Promise<void> => {
|
|
742
745
|
const actionError = await options.onAction(action);
|
|
743
|
-
if (actionError) {
|
|
746
|
+
if (actionError !== null && actionError !== "") {
|
|
744
747
|
error = actionError;
|
|
745
748
|
} else {
|
|
746
749
|
error = null;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Each test is its own entry point: it builds a fresh layer for one scenario and
|
|
2
|
+
// runs its effects inside it, so providing there is the pattern the rule allows.
|
|
3
|
+
/* oxlint-disable effecttsgo/strict-effect-provide */
|
|
1
4
|
import { assert, it } from "@effect/vitest";
|
|
2
5
|
import { Effect, PlatformError } from "effect";
|
|
3
6
|
import * as FileSystem from "effect/FileSystem";
|
|
@@ -30,7 +30,7 @@ export class VimSettingsService extends Context.Service<
|
|
|
30
30
|
/** Never fails: every read, parse, or shape problem yields `false` (off). */
|
|
31
31
|
readonly load: Effect.Effect<boolean>;
|
|
32
32
|
}
|
|
33
|
-
>()("tracker/
|
|
33
|
+
>()("@ftrdotdev/pi-tracker/presentation/vim-settings/VimSettingsService") {
|
|
34
34
|
static make(path: string): Layer.Layer<VimSettingsService, never, FileSystem.FileSystem> {
|
|
35
35
|
return Layer.effect(
|
|
36
36
|
VimSettingsService,
|