tuiboard 0.8.5 → 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 +45 -0
- package/README.md +37 -1
- package/bin/tuiboard.ts +4 -0
- package/package.json +3 -1
- package/src/app.tsx +36 -17
- package/src/boards/config-writer.ts +191 -0
- package/src/boards/create.ts +57 -0
- package/src/boards/scan.ts +95 -0
- package/src/boards/suggest.ts +34 -0
- package/src/cli/args.ts +2 -2
- package/src/cli/board.ts +151 -0
- package/src/config/loader.ts +37 -13
- package/src/input/handleKey.ts +58 -1
- package/src/io/watcher.ts +11 -0
- package/src/parser/markdown.ts +10 -0
- package/src/store/index.ts +379 -12
- package/src/ui/BoardView.tsx +8 -6
- package/src/ui/Chrome.tsx +65 -9
- package/src/ui/Modal.tsx +128 -0
- package/src/ui/PlannerPanel.tsx +1 -1
- package/src/ui/pane-ring.ts +73 -0
- package/src/views/BoardOnly.tsx +3 -2
- package/src/views/Dashboard.tsx +1 -1
- package/src/cli/args.test.ts +0 -40
- package/src/cli/headless.test.ts +0 -202
- package/src/scripts/agents-check.ts +0 -24
- package/src/scripts/parse-check.ts +0 -124
- package/src/scripts/roundtrip-check.ts +0 -79
- package/src/store/agents.test.ts +0 -181
- package/src/store/index.test.ts +0 -225
- package/src/store/parsers.test.ts +0 -64
- package/src/store/timeline.test.ts +0 -332
- package/src/ui/board-scroll.test.ts +0 -63
- package/src/ui/glyphs.test.ts +0 -31
package/src/ui/Modal.tsx
CHANGED
|
@@ -55,6 +55,7 @@ function ModalRouter(props: { store: TuiStore; modal: NonNullable<TuiStore["stat
|
|
|
55
55
|
case "event-edit": return <EventEditModal store={props.store} />;
|
|
56
56
|
case "confirm-delete-event": return <ConfirmDeleteEventModal store={props.store} />;
|
|
57
57
|
case "search": return <SearchModal store={props.store} />;
|
|
58
|
+
case "board-new": return <BoardNewModal store={props.store} />;
|
|
58
59
|
case "help": return <HelpModal store={props.store} />;
|
|
59
60
|
}
|
|
60
61
|
}
|
|
@@ -68,6 +69,131 @@ interface DialogShellProps {
|
|
|
68
69
|
width?: number;
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
// ─── New board ───────────────────────────────────────────────────────────────
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Onboarding and the `+` button are the same screen, differing only in title
|
|
76
|
+
* and in whether Escape works: on first run there is nothing behind it.
|
|
77
|
+
*
|
|
78
|
+
* Deliberately thin. Every step that touches the disk calls into
|
|
79
|
+
* `src/boards/`, which is also what `tuiboard board add` calls, so the two
|
|
80
|
+
* entry points cannot drift apart.
|
|
81
|
+
*/
|
|
82
|
+
function BoardNewModal(props: { store: TuiStore }) {
|
|
83
|
+
const w = createMemo(() => props.store.state.ui.boardNew);
|
|
84
|
+
|
|
85
|
+
const title = createMemo(() =>
|
|
86
|
+
w()?.mandatory ? "Welcome to tuiboard" : "New board",
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const hint = createMemo(() => {
|
|
90
|
+
const b = w();
|
|
91
|
+
if (!b) return "";
|
|
92
|
+
if (b.step === "mode") return "j/k choose · Enter confirm" + (b.mandatory ? "" : " · Esc cancel");
|
|
93
|
+
if (b.step === "pick") return "j/k move · Space tick · Enter adopt · Esc back";
|
|
94
|
+
return "Enter confirm" + (b.mandatory ? "" : " · Esc cancel");
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<DialogShell title={title()} hint={hint()} width={MODAL_WIDTH}>
|
|
99
|
+
<Show when={w()}>
|
|
100
|
+
{(b: () => NonNullable<ReturnType<typeof w>>) => (
|
|
101
|
+
<box style={{ flexDirection: "column" }}>
|
|
102
|
+
<Show when={b().mandatory && b().step === "mode"}>
|
|
103
|
+
<text>
|
|
104
|
+
<span style={{ fg: T.textDim }}>
|
|
105
|
+
No boards configured yet. Boards are plain markdown files.
|
|
106
|
+
</span>
|
|
107
|
+
</text>
|
|
108
|
+
<text> </text>
|
|
109
|
+
</Show>
|
|
110
|
+
|
|
111
|
+
{/* Step 1 — which way through */}
|
|
112
|
+
<Show when={b().step === "mode"}>
|
|
113
|
+
<For each={[
|
|
114
|
+
{ key: "create", label: "Create a new board", desc: "a new markdown file" },
|
|
115
|
+
{ key: "adopt", label: "Use files I already have", desc: "scan a folder" },
|
|
116
|
+
]}>
|
|
117
|
+
{(opt, i) => (
|
|
118
|
+
<text>
|
|
119
|
+
<span style={{ fg: b().sel === i() ? T.accent : T.text }}>
|
|
120
|
+
{b().sel === i() ? "▶ " : " "}{opt.label}
|
|
121
|
+
</span>
|
|
122
|
+
<span style={{ fg: T.textDim }}>{" — " + opt.desc}</span>
|
|
123
|
+
</text>
|
|
124
|
+
)}
|
|
125
|
+
</For>
|
|
126
|
+
</Show>
|
|
127
|
+
|
|
128
|
+
{/* Step 2a — name, then columns */}
|
|
129
|
+
<Show when={b().step === "name"}>
|
|
130
|
+
<text><span style={{ fg: T.textDim }}>Board name</span></text>
|
|
131
|
+
<input
|
|
132
|
+
focused
|
|
133
|
+
value=""
|
|
134
|
+
onSubmit={((v: string) => props.store.boardNewSubmitText(v)) as any}
|
|
135
|
+
/>
|
|
136
|
+
<text>
|
|
137
|
+
<span style={{ fg: T.textDim }}>{"It will live in " + b().dir}</span>
|
|
138
|
+
</text>
|
|
139
|
+
</Show>
|
|
140
|
+
|
|
141
|
+
<Show when={b().step === "columns"}>
|
|
142
|
+
<text><span style={{ fg: T.textDim }}>Columns, comma separated</span></text>
|
|
143
|
+
<input
|
|
144
|
+
focused
|
|
145
|
+
value={b().columns}
|
|
146
|
+
onSubmit={((v: string) => props.store.boardNewSubmitText(v)) as any}
|
|
147
|
+
/>
|
|
148
|
+
<text>
|
|
149
|
+
<span style={{ fg: T.textDim }}>{"Creating " + b().name + ".md"}</span>
|
|
150
|
+
</text>
|
|
151
|
+
</Show>
|
|
152
|
+
|
|
153
|
+
{/* Step 2b — a folder, then what was found in it */}
|
|
154
|
+
<Show when={b().step === "dir"}>
|
|
155
|
+
<text><span style={{ fg: T.textDim }}>Folder to scan</span></text>
|
|
156
|
+
<input
|
|
157
|
+
focused
|
|
158
|
+
value={b().dir}
|
|
159
|
+
onSubmit={((v: string) => props.store.boardNewSubmitText(v)) as any}
|
|
160
|
+
/>
|
|
161
|
+
</Show>
|
|
162
|
+
|
|
163
|
+
<Show when={b().step === "pick"}>
|
|
164
|
+
<text>
|
|
165
|
+
<span style={{ fg: T.textDim }}>
|
|
166
|
+
{b().candidates.length + " board file(s) in " + b().dir}
|
|
167
|
+
</span>
|
|
168
|
+
</text>
|
|
169
|
+
<For each={b().candidates}>
|
|
170
|
+
{(c, i) => (
|
|
171
|
+
<text>
|
|
172
|
+
<span style={{ fg: b().sel === i() ? T.accent : T.text }}>
|
|
173
|
+
{b().sel === i() ? "▶ " : " "}
|
|
174
|
+
{c.alreadyInConfig ? "· " : b().ticked.includes(i()) ? "✓ " : " "}
|
|
175
|
+
{c.suggestedName}
|
|
176
|
+
</span>
|
|
177
|
+
<span style={{ fg: T.textDim }}>
|
|
178
|
+
{" " + c.taskCount + (c.taskCount === 1 ? " task" : " tasks")
|
|
179
|
+
+ (c.alreadyInConfig ? " · already open" : "")}
|
|
180
|
+
</span>
|
|
181
|
+
</text>
|
|
182
|
+
)}
|
|
183
|
+
</For>
|
|
184
|
+
</Show>
|
|
185
|
+
|
|
186
|
+
<Show when={b().error}>
|
|
187
|
+
<text> </text>
|
|
188
|
+
<text><span style={{ fg: T.overdue }}>{b().error}</span></text>
|
|
189
|
+
</Show>
|
|
190
|
+
</box>
|
|
191
|
+
)}
|
|
192
|
+
</Show>
|
|
193
|
+
</DialogShell>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
71
197
|
function DialogShell(props: DialogShellProps) {
|
|
72
198
|
void props.width;
|
|
73
199
|
return (
|
|
@@ -805,6 +931,8 @@ function HelpModal(props: { store: TuiStore }) {
|
|
|
805
931
|
<span style={{ fg: T.textDim }}>{"Navigation\n"}</span>
|
|
806
932
|
<span style={{ fg: T.text }}>{" h j k l ←↑↓→ Move cursor inside the active zone\n"}</span>
|
|
807
933
|
<span style={{ fg: T.text }}>{" Tab Next board (kanban zone)\n"}</span>
|
|
934
|
+
<span style={{ fg: T.text }}>{" + New board — create one, or adopt files you have\n"}</span>
|
|
935
|
+
<span style={{ fg: T.text }}>{" z Focus one pane (automatic below 100 columns)\n"}</span>
|
|
808
936
|
<span style={{ fg: T.text }}>{" 1..9 Jump to board N\n"}</span>
|
|
809
937
|
<span style={{ fg: T.text }}>{" v Toggle Today/Tomorrow planner panel focus\n"}</span>
|
|
810
938
|
<span style={{ fg: T.text }}>{" Shift-Tab Cycle active zone (planner → board → timeline → agents)\n"}</span>
|
package/src/ui/PlannerPanel.tsx
CHANGED
|
@@ -40,7 +40,7 @@ export function PlannerPanel(props: { store: TuiStore }) {
|
|
|
40
40
|
const groups = createMemo(() => groupPlannerItems(items()));
|
|
41
41
|
const isActive = createMemo(() => props.store.state.ui.activeZone === "planner");
|
|
42
42
|
const isZoomed = createMemo(
|
|
43
|
-
() => props.store.
|
|
43
|
+
() => props.store.singlePane() && props.store.state.ui.activeZone === "planner",
|
|
44
44
|
);
|
|
45
45
|
const cursorRow = createMemo(() => props.store.state.ui.row);
|
|
46
46
|
let scrollBoxRef: ScrollBoxLike | undefined;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single-pane ring.
|
|
3
|
+
*
|
|
4
|
+
* When only one pane fits on screen, the zones stop being a layout — left and
|
|
5
|
+
* right no longer mean anything geometric — and become a sequence. This module
|
|
6
|
+
* builds that sequence and steps through it.
|
|
7
|
+
*
|
|
8
|
+
* The board is not one stop but many: in single-pane it renders a single
|
|
9
|
+
* column at full width, so each drawn column is its own pane. The result reads
|
|
10
|
+
* planner → column → column → … → agenda → agents, and closes into a ring.
|
|
11
|
+
*
|
|
12
|
+
* Pure: no store, no renderer, no terminal. The caller decides which zones are
|
|
13
|
+
* enabled and which columns are drawn — this only decides what comes next.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export type RingZone = "planner" | "timeline" | "agents";
|
|
17
|
+
|
|
18
|
+
export type Pane =
|
|
19
|
+
| { kind: "zone"; zone: RingZone }
|
|
20
|
+
| { kind: "column"; index: number };
|
|
21
|
+
|
|
22
|
+
export interface RingInput {
|
|
23
|
+
/** Which zones the config enables. `board` is implied by renderedColumns. */
|
|
24
|
+
enabledZones: Record<"planner" | "board" | "timeline" | "agents", boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Board column indexes actually drawn, in order. Hidden columns (Done,
|
|
27
|
+
* Archive) must already be filtered out by the caller: a pane you cannot
|
|
28
|
+
* see is a dead end to step onto.
|
|
29
|
+
*/
|
|
30
|
+
renderedColumns: readonly number[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function buildRing({ enabledZones, renderedColumns }: RingInput): Pane[] {
|
|
34
|
+
const ring: Pane[] = [];
|
|
35
|
+
if (enabledZones.planner) ring.push({ kind: "zone", zone: "planner" });
|
|
36
|
+
if (enabledZones.board) {
|
|
37
|
+
for (const index of renderedColumns) ring.push({ kind: "column", index });
|
|
38
|
+
}
|
|
39
|
+
if (enabledZones.timeline) ring.push({ kind: "zone", zone: "timeline" });
|
|
40
|
+
if (enabledZones.agents) ring.push({ kind: "zone", zone: "agents" });
|
|
41
|
+
return ring;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The next pane in `delta`'s direction, wrapping at both ends.
|
|
46
|
+
*
|
|
47
|
+
* A ring of one returns itself: stepping should feel like nothing happened,
|
|
48
|
+
* not like a wrap. If `current` is no longer in the ring — a column removed by
|
|
49
|
+
* a filter change or an external edit — the first pane is returned rather than
|
|
50
|
+
* something unrenderable.
|
|
51
|
+
*/
|
|
52
|
+
export function stepRing(ring: readonly Pane[], current: Pane, delta: 1 | -1): Pane {
|
|
53
|
+
if (ring.length === 0) return current;
|
|
54
|
+
if (ring.length === 1) return ring[0]!;
|
|
55
|
+
|
|
56
|
+
const at = ring.findIndex((p) => samePane(p, current));
|
|
57
|
+
if (at < 0) return ring[0]!;
|
|
58
|
+
|
|
59
|
+
const next = (at + delta + ring.length) % ring.length;
|
|
60
|
+
return ring[next]!;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function samePane(a: Pane, b: Pane): boolean {
|
|
64
|
+
if (a.kind === "zone" && b.kind === "zone") return a.zone === b.zone;
|
|
65
|
+
if (a.kind === "column" && b.kind === "column") return a.index === b.index;
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Where the current pane sits in the ring, for the position indicator. */
|
|
70
|
+
export function ringPosition(ring: readonly Pane[], current: Pane): { at: number; of: number } {
|
|
71
|
+
const at = ring.findIndex((p) => samePane(p, current));
|
|
72
|
+
return { at: at < 0 ? 0 : at, of: ring.length };
|
|
73
|
+
}
|
package/src/views/BoardOnly.tsx
CHANGED
|
@@ -18,16 +18,17 @@ import type { TuiStore } from "~/store/index";
|
|
|
18
18
|
|
|
19
19
|
export function BoardOnly(props: { store: TuiStore }) {
|
|
20
20
|
const ui = () => props.store.state.ui;
|
|
21
|
+
const singlePane = () => props.store.singlePane();
|
|
21
22
|
const activeBoard = createMemo(
|
|
22
23
|
() => props.store.state.boards[ui().activeBoardIndex]?.board,
|
|
23
24
|
);
|
|
24
25
|
|
|
25
26
|
return (
|
|
26
27
|
<box style={{ flexDirection: "row", flexGrow: 1 }}>
|
|
27
|
-
<Show when={!
|
|
28
|
+
<Show when={!singlePane() || ui().activeZone === "planner"}>
|
|
28
29
|
<PlannerPanel store={props.store} />
|
|
29
30
|
</Show>
|
|
30
|
-
<Show when={(!
|
|
31
|
+
<Show when={(!singlePane() || ui().activeZone !== "planner") && activeBoard()}>
|
|
31
32
|
<BoardView store={props.store} board={activeBoard()!} />
|
|
32
33
|
</Show>
|
|
33
34
|
</box>
|
package/src/views/Dashboard.tsx
CHANGED
package/src/cli/args.test.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "bun:test";
|
|
2
|
-
import { parseArgs, type ViewKind } from "./args";
|
|
3
|
-
|
|
4
|
-
describe("parseArgs", () => {
|
|
5
|
-
it("returns view=undefined when no flag is present", () => {
|
|
6
|
-
expect(parseArgs([])).toEqual({ view: undefined });
|
|
7
|
-
expect(parseArgs(["bun", "src/app.tsx"])).toEqual({ view: undefined });
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("parses --view=board", () => {
|
|
11
|
-
expect(parseArgs(["--view=board"])).toEqual({ view: "board" });
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("parses --view=timeline", () => {
|
|
15
|
-
expect(parseArgs(["--view=timeline"])).toEqual({ view: "timeline" });
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("parses --view=agents", () => {
|
|
19
|
-
expect(parseArgs(["--view=agents"])).toEqual({ view: "agents" });
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("parses --view <value> with space separator", () => {
|
|
23
|
-
expect(parseArgs(["--view", "board"])).toEqual({ view: "board" });
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("returns view=undefined for unknown view value (with warning to stderr)", () => {
|
|
27
|
-
const result = parseArgs(["--view=garbage"]);
|
|
28
|
-
expect(result.view).toBeUndefined();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("ignores other flags", () => {
|
|
32
|
-
expect(parseArgs(["--debug", "--view=board", "--something-else"])).toEqual({
|
|
33
|
-
view: "board",
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Type-level assertion: ensure ViewKind covers exactly the four expected values.
|
|
39
|
-
const _viewKinds: ViewKind[] = ["board", "timeline", "agents"];
|
|
40
|
-
void _viewKinds;
|
package/src/cli/headless.test.ts
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The headless CLI — `tuiboard task` and `tuiboard summary`.
|
|
3
|
-
*
|
|
4
|
-
* These are the only commands that write to the user's real board files from
|
|
5
|
-
* outside the TUI (a bar widget, a cron job), so they are tested against a
|
|
6
|
-
* real board on disk rather than a parsed fixture: the round trip through
|
|
7
|
-
* parse → mutate → serialize → write is exactly what can lose data.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
|
|
11
|
-
import { mkdtempSync, readFileSync, rmSync, utimesSync, writeFileSync } from "node:fs";
|
|
12
|
-
import { tmpdir } from "node:os";
|
|
13
|
-
import { join } from "node:path";
|
|
14
|
-
|
|
15
|
-
import { ConflictError, statMtime, writeBoardFile } from "~/io/writer";
|
|
16
|
-
import { buildSummary } from "./summary";
|
|
17
|
-
import { runTask } from "./task";
|
|
18
|
-
|
|
19
|
-
const BOARD = `---
|
|
20
|
-
|
|
21
|
-
kanban-plugin: board
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## Home
|
|
26
|
-
- [ ] Bollette ⏳ 2026-08-31
|
|
27
|
-
- [x] Spesa ⏳ 2026-08-31 ✅ 2026-08-31
|
|
28
|
-
- [ ] Chiamare idraulico 📅 2026-08-31
|
|
29
|
-
- [ ] Cambiare gomme
|
|
30
|
-
- [ ] Ambiguo uno
|
|
31
|
-
- [ ] Ambiguo due
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
let dir: string;
|
|
35
|
-
let boardPath: string;
|
|
36
|
-
let configPath: string;
|
|
37
|
-
let previousConfig: string | undefined;
|
|
38
|
-
|
|
39
|
-
/** Days from today as YYYY-MM-DD, in local time — matches the CLI's own clock. */
|
|
40
|
-
function iso(offsetDays: number): string {
|
|
41
|
-
const d = new Date();
|
|
42
|
-
d.setDate(d.getDate() + offsetDays);
|
|
43
|
-
const p = (n: number) => String(n).padStart(2, "0");
|
|
44
|
-
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function board(): string {
|
|
48
|
-
return readFileSync(boardPath, "utf-8");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function line(title: string): string {
|
|
52
|
-
const hit = board()
|
|
53
|
-
.split("\n")
|
|
54
|
-
.find((l) => l.includes(title));
|
|
55
|
-
if (!hit) throw new Error(`no line matching "${title}" in board`);
|
|
56
|
-
return hit;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
beforeEach(() => {
|
|
60
|
-
dir = mkdtempSync(join(tmpdir(), "tuiboard-cli-"));
|
|
61
|
-
boardPath = join(dir, "Board.md");
|
|
62
|
-
configPath = join(dir, "config.yaml");
|
|
63
|
-
writeFileSync(boardPath, BOARD, "utf-8");
|
|
64
|
-
writeFileSync(configPath, `boards:\n - path: ${boardPath}\n name: Test\n`, "utf-8");
|
|
65
|
-
previousConfig = process.env.TUIBOARD_CONFIG;
|
|
66
|
-
process.env.TUIBOARD_CONFIG = configPath;
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
afterEach(() => {
|
|
70
|
-
if (previousConfig === undefined) delete process.env.TUIBOARD_CONFIG;
|
|
71
|
-
else process.env.TUIBOARD_CONFIG = previousConfig;
|
|
72
|
-
rmSync(dir, { recursive: true, force: true });
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const args = (...rest: string[]) => ["--board", "Test", "--column", "Home", ...rest];
|
|
76
|
-
|
|
77
|
-
describe("tuiboard task done", () => {
|
|
78
|
-
it("ticks the task and stamps today's completion date", async () => {
|
|
79
|
-
expect(await runTask(["done", ...args("--match", "Bollette")])).toBe(0);
|
|
80
|
-
expect(line("Bollette")).toBe(`- [x] Bollette ⏳ 2026-08-31 ✅ ${iso(0)}`);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("leaves an already-done task untouched", async () => {
|
|
84
|
-
const before = line("Spesa");
|
|
85
|
-
expect(await runTask(["done", ...args("--match", "Spesa")])).toBe(0);
|
|
86
|
-
expect(line("Spesa")).toBe(before);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
describe("tuiboard task undone", () => {
|
|
91
|
-
it("reopens a completed task and drops the completion date with it", async () => {
|
|
92
|
-
expect(await runTask(["undone", ...args("--match", "Spesa")])).toBe(0);
|
|
93
|
-
expect(line("Spesa")).toBe("- [ ] Spesa ⏳ 2026-08-31");
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("is the exact inverse of done — round trip restores the line", async () => {
|
|
97
|
-
const before = line("Bollette");
|
|
98
|
-
expect(await runTask(["done", ...args("--match", "Bollette")])).toBe(0);
|
|
99
|
-
expect(await runTask(["undone", ...args("--match", "Bollette")])).toBe(0);
|
|
100
|
-
expect(line("Bollette")).toBe(before);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("leaves an already-open task untouched", async () => {
|
|
104
|
-
const before = line("Bollette");
|
|
105
|
-
expect(await runTask(["undone", ...args("--match", "Bollette")])).toBe(0);
|
|
106
|
-
expect(line("Bollette")).toBe(before);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
describe("tuiboard task defer", () => {
|
|
111
|
-
it("moves `scheduled` when the task has one", async () => {
|
|
112
|
-
expect(await runTask(["defer", ...args("--match", "Bollette")])).toBe(0);
|
|
113
|
-
expect(line("Bollette")).toBe(`- [ ] Bollette ⏳ ${iso(1)}`);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("moves `due` when that is the only date — the field the planner reads", async () => {
|
|
117
|
-
expect(await runTask(["defer", ...args("--match", "idraulico")])).toBe(0);
|
|
118
|
-
expect(line("idraulico")).toBe(`- [ ] Chiamare idraulico 📅 ${iso(1)}`);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it("schedules an undated task, which is what puts it on the agenda", async () => {
|
|
122
|
-
expect(await runTask(["defer", ...args("--match", "gomme")])).toBe(0);
|
|
123
|
-
expect(line("gomme")).toBe(`- [ ] Cambiare gomme ⏳ ${iso(1)}`);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it("--days 0 pulls a task back to today", async () => {
|
|
127
|
-
expect(await runTask(["defer", ...args("--match", "Bollette", "--days", "0")])).toBe(0);
|
|
128
|
-
expect(line("Bollette")).toBe(`- [ ] Bollette ⏳ ${iso(0)}`);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it("--to takes an explicit date", async () => {
|
|
132
|
-
expect(await runTask(["defer", ...args("--match", "Bollette", "--to", "2027-01-15")])).toBe(0);
|
|
133
|
-
expect(line("Bollette")).toBe("- [ ] Bollette ⏳ 2027-01-15");
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it("rejects a malformed --to without touching the board", async () => {
|
|
137
|
-
const before = board();
|
|
138
|
-
expect(await runTask(["defer", ...args("--match", "Bollette", "--to", "15/01/2027")])).toBe(2);
|
|
139
|
-
expect(board()).toBe(before);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
describe("tuiboard task — refusing to guess", () => {
|
|
144
|
-
it("writes nothing when the match is ambiguous", async () => {
|
|
145
|
-
const before = board();
|
|
146
|
-
expect(await runTask(["done", ...args("--match", "Ambiguo")])).toBe(1);
|
|
147
|
-
expect(board()).toBe(before);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it("writes nothing when nothing matches", async () => {
|
|
151
|
-
const before = board();
|
|
152
|
-
expect(await runTask(["done", ...args("--match", "inesistente")])).toBe(1);
|
|
153
|
-
expect(board()).toBe(before);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it("--dry-run reports success and leaves the file alone", async () => {
|
|
157
|
-
const before = board();
|
|
158
|
-
expect(await runTask(["done", ...args("--match", "Bollette", "--dry-run")])).toBe(0);
|
|
159
|
-
expect(board()).toBe(before);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it("refuses the write when the board moved on since it was read", () => {
|
|
163
|
-
// What `runTask` maps to exit 3. Driven through the writer directly: the
|
|
164
|
-
// race it guards against — the file changing between the read and the
|
|
165
|
-
// write — cannot be staged from outside the function that spans it.
|
|
166
|
-
const stale = statMtime(boardPath);
|
|
167
|
-
const past = new Date(Date.now() - 60_000);
|
|
168
|
-
utimesSync(boardPath, past, past);
|
|
169
|
-
const before = board();
|
|
170
|
-
expect(() => writeBoardFile(boardPath, "clobbered", { expectedMtimeMs: stale }))
|
|
171
|
-
.toThrow(ConflictError);
|
|
172
|
-
expect(board()).toBe(before);
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
describe("tuiboard summary — planner entries", () => {
|
|
177
|
-
it("reports whether a Today entry is already ticked", async () => {
|
|
178
|
-
// The board's dates are fixed, so the summary is asked for that same day.
|
|
179
|
-
const s = buildSummary({ next: 0, today: "2026-08-31" });
|
|
180
|
-
const today = s.planner.today;
|
|
181
|
-
const bollette = today.find((e) => e.title === "Bollette");
|
|
182
|
-
const spesa = today.find((e) => e.title === "Spesa");
|
|
183
|
-
|
|
184
|
-
expect(bollette?.done).toBe(false);
|
|
185
|
-
expect(bollette?.doneDate).toBeUndefined();
|
|
186
|
-
expect(spesa?.done).toBe(true);
|
|
187
|
-
expect(spesa?.doneDate).toBe("2026-08-31");
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("follows a task through done and back", async () => {
|
|
191
|
-
await runTask(["done", ...args("--match", "Bollette")]);
|
|
192
|
-
const done = buildSummary({ next: 0, today: "2026-08-31" })
|
|
193
|
-
.planner.today.find((e) => e.title === "Bollette");
|
|
194
|
-
expect(done?.done).toBe(true);
|
|
195
|
-
|
|
196
|
-
await runTask(["undone", ...args("--match", "Bollette")]);
|
|
197
|
-
const reopened = buildSummary({ next: 0, today: "2026-08-31" })
|
|
198
|
-
.planner.today.find((e) => e.title === "Bollette");
|
|
199
|
-
expect(reopened?.done).toBe(false);
|
|
200
|
-
expect(reopened?.doneDate).toBeUndefined();
|
|
201
|
-
});
|
|
202
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Smoke check for the agents store. Lists the first 10 sessions
|
|
3
|
-
* discovered on this machine with status, display name, and short cwd.
|
|
4
|
-
*
|
|
5
|
-
* Usage: bun run agents:check
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { createAgentsStore } from "~/store/agents";
|
|
9
|
-
|
|
10
|
-
const store = createAgentsStore();
|
|
11
|
-
const all = store.sessions();
|
|
12
|
-
const live = all.filter(
|
|
13
|
-
(s) => s.status === "live-busy" || s.status === "live-idle",
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
console.log(`Found ${all.length} sessions, ${live.length} live`);
|
|
17
|
-
console.log("");
|
|
18
|
-
for (const s of all.slice(0, 10)) {
|
|
19
|
-
console.log(
|
|
20
|
-
` ${s.status.padEnd(10)} ${s.displayName.padEnd(40)} ${s.cwdShort}`,
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
await store.dispose();
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI smoke-test for the markdown parser.
|
|
3
|
-
*
|
|
4
|
-
* Usage:
|
|
5
|
-
* bun run src/scripts/parse-check.ts # uses config-discovered boards
|
|
6
|
-
* bun run src/scripts/parse-check.ts <file.md>... # parses specific files
|
|
7
|
-
*
|
|
8
|
-
* Prints per-board summary: columns, task counts, metadata coverage,
|
|
9
|
-
* diagnostics, and a sample of parsed tasks so we can eyeball correctness.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { readFileSync } from "node:fs";
|
|
13
|
-
import { loadConfig } from "~/config/loader";
|
|
14
|
-
import { isTask, parseBoard } from "~/parser/markdown";
|
|
15
|
-
import type { Task } from "~/types";
|
|
16
|
-
|
|
17
|
-
const args = process.argv.slice(2);
|
|
18
|
-
const files: string[] = [];
|
|
19
|
-
|
|
20
|
-
if (args.length > 0) {
|
|
21
|
-
files.push(...args);
|
|
22
|
-
} else {
|
|
23
|
-
const cfg = loadConfig();
|
|
24
|
-
if (!cfg.loaded) {
|
|
25
|
-
console.error(
|
|
26
|
-
`No .tuiboard/config.yaml found from ${cfg.root}. Using fallback scan of cwd.`,
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
if (cfg.boards.length === 0) {
|
|
30
|
-
console.error("No boards configured and none found via fallback scan.");
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
files.push(...cfg.boards.map((b) => b.path));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let totalTasks = 0;
|
|
37
|
-
let totalDone = 0;
|
|
38
|
-
let totalWithSched = 0;
|
|
39
|
-
let totalWithTimeBlock = 0;
|
|
40
|
-
let totalLegacyTimeBlock = 0;
|
|
41
|
-
let totalWithPriority = 0;
|
|
42
|
-
let totalDiagnostics = 0;
|
|
43
|
-
|
|
44
|
-
for (const file of files) {
|
|
45
|
-
let content: string;
|
|
46
|
-
try {
|
|
47
|
-
content = readFileSync(file, "utf-8");
|
|
48
|
-
} catch (e) {
|
|
49
|
-
console.error(`✗ Cannot read ${file}: ${(e as Error).message}`);
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const { board, diagnostics } = parseBoard(content, { filepath: file });
|
|
54
|
-
const tasks: Task[] = [];
|
|
55
|
-
for (const col of board.columns) {
|
|
56
|
-
for (const child of col.children) {
|
|
57
|
-
if (isTask(child)) tasks.push(child);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const done = tasks.filter((t) => t.done).length;
|
|
61
|
-
const withSched = tasks.filter((t) => t.scheduled).length;
|
|
62
|
-
const withTime = tasks.filter((t) => t.timeBlock).length;
|
|
63
|
-
const legacyTime = tasks.filter((t) => t.timeBlockSource === "legacy-prefix").length;
|
|
64
|
-
const withPrio = tasks.filter((t) => t.priority !== "none").length;
|
|
65
|
-
|
|
66
|
-
totalTasks += tasks.length;
|
|
67
|
-
totalDone += done;
|
|
68
|
-
totalWithSched += withSched;
|
|
69
|
-
totalWithTimeBlock += withTime;
|
|
70
|
-
totalLegacyTimeBlock += legacyTime;
|
|
71
|
-
totalWithPriority += withPrio;
|
|
72
|
-
totalDiagnostics += diagnostics.length;
|
|
73
|
-
|
|
74
|
-
console.log(`\n━━━ ${board.name} ━━━`);
|
|
75
|
-
console.log(` file: ${file}`);
|
|
76
|
-
console.log(` frontmatter: ${board.frontmatter ? "yes" : "no"}`);
|
|
77
|
-
console.log(` trailer: ${board.trailer ? "yes" : "no"}`);
|
|
78
|
-
console.log(` columns: ${board.columns.length} — ${board.columns.map((c) => c.name).join(" │ ")}`);
|
|
79
|
-
console.log(` tasks total: ${tasks.length} (${done} done, ${tasks.length - done} open)`);
|
|
80
|
-
console.log(` scheduled: ${withSched}`);
|
|
81
|
-
console.log(` time blocks: ${withTime} (${legacyTime} legacy prefix, ${withTime - legacyTime} ⌚)`);
|
|
82
|
-
console.log(` priority: ${withPrio}`);
|
|
83
|
-
console.log(` diagnostics: ${diagnostics.length}`);
|
|
84
|
-
|
|
85
|
-
// Show first 3 diagnostics
|
|
86
|
-
for (const d of diagnostics.slice(0, 3)) {
|
|
87
|
-
console.log(` [L${d.line}] ${d.level}: ${d.message}`);
|
|
88
|
-
}
|
|
89
|
-
if (diagnostics.length > 3) console.log(` … and ${diagnostics.length - 3} more`);
|
|
90
|
-
|
|
91
|
-
// Show first 5 parsed open tasks for eyeballing
|
|
92
|
-
const sample = tasks.filter((t) => !t.done).slice(0, 5);
|
|
93
|
-
if (sample.length > 0) {
|
|
94
|
-
console.log("\n sample tasks:");
|
|
95
|
-
for (const t of sample) {
|
|
96
|
-
const tb = t.timeBlock
|
|
97
|
-
? ` ⌚${fmtMin(t.timeBlock.startMin)}-${fmtMin(t.timeBlock.endMin)}`
|
|
98
|
-
: "";
|
|
99
|
-
const sched = t.scheduled ? ` ⏳${t.scheduled}` : "";
|
|
100
|
-
const prio = t.priority !== "none" ? ` [${t.priority}]` : "";
|
|
101
|
-
const assignee = t.assignee ? ` @${t.assignee}` : "";
|
|
102
|
-
const tags = t.tags.length ? ` ${t.tags.map((x) => "#" + x).join(" ")}` : "";
|
|
103
|
-
console.log(` • ${truncate(t.displayTitle, 60)}${prio}${assignee}${sched}${tb}${tags}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
console.log("\n━━━ TOTALS ━━━");
|
|
109
|
-
console.log(` files: ${files.length}`);
|
|
110
|
-
console.log(` tasks: ${totalTasks} (${totalDone} done)`);
|
|
111
|
-
console.log(` scheduled: ${totalWithSched}`);
|
|
112
|
-
console.log(` time blocks: ${totalWithTimeBlock} (${totalLegacyTimeBlock} legacy, ${totalWithTimeBlock - totalLegacyTimeBlock} ⌚)`);
|
|
113
|
-
console.log(` priority: ${totalWithPriority}`);
|
|
114
|
-
console.log(` diagnostics: ${totalDiagnostics}`);
|
|
115
|
-
|
|
116
|
-
function fmtMin(m: number): string {
|
|
117
|
-
const h = Math.floor(m / 60).toString().padStart(2, "0");
|
|
118
|
-
const mm = (m % 60).toString().padStart(2, "0");
|
|
119
|
-
return `${h}:${mm}`;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function truncate(s: string, n: number): string {
|
|
123
|
-
return s.length <= n ? s : s.slice(0, n - 1) + "…";
|
|
124
|
-
}
|