@litfamily/litcodex 1.0.37 → 1.0.38

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 (67) hide show
  1. package/README-Ko-KR.md +9 -9
  2. package/README.md +9 -9
  3. package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +1 -1
  4. package/marketplace/plugins/litcodex/components/auto-update/package.json +1 -1
  5. package/marketplace/plugins/litcodex/components/comment-checker/package.json +1 -1
  6. package/marketplace/plugins/litcodex/components/git-bash/package.json +1 -1
  7. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-adhd.md +32 -13
  8. package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.js +2 -1
  9. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-board.d.ts +192 -0
  10. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-board.js +437 -0
  11. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-cli.js +17 -3
  12. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-go.d.ts +3 -2
  13. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind-go.js +6 -4
  14. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind.d.ts +9 -2
  15. package/marketplace/plugins/litcodex/components/lit-loop/dist/rewind.js +245 -30
  16. package/marketplace/plugins/litcodex/components/lit-loop/dist/route-heads.js +3 -3
  17. package/marketplace/plugins/litcodex/components/lit-loop/dist/state-types.d.ts +1 -1
  18. package/marketplace/plugins/litcodex/components/lit-loop/dist/state-types.js +2 -0
  19. package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.js +5 -1
  20. package/marketplace/plugins/litcodex/components/lit-loop/package.json +1 -1
  21. package/marketplace/plugins/litcodex/components/lsp/package.json +1 -1
  22. package/marketplace/plugins/litcodex/components/rules/package.json +1 -1
  23. package/marketplace/plugins/litcodex/components/start-work-continuation/directive.md +5 -5
  24. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/cli.js +30 -5
  25. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/codex-hook.d.ts +6 -5
  26. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/codex-hook.js +184 -62
  27. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/host-reads.d.ts +7 -0
  28. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/host-reads.js +30 -0
  29. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/index.d.ts +9 -4
  30. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/index.js +5 -2
  31. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/lifecycle-root.d.ts +9 -0
  32. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/lifecycle-root.js +117 -0
  33. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/lifecycle-store.d.ts +72 -1
  34. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/lifecycle-store.js +525 -103
  35. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/pre-tool-hook.d.ts +8 -0
  36. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/pre-tool-hook.js +131 -0
  37. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/protected-paths.d.ts +13 -0
  38. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/protected-paths.js +103 -0
  39. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/work-state-reader.d.ts +14 -2
  40. package/marketplace/plugins/litcodex/components/start-work-continuation/dist/work-state-reader.js +14 -4
  41. package/marketplace/plugins/litcodex/components/start-work-continuation/package.json +1 -1
  42. package/marketplace/plugins/litcodex/components/telemetry/package.json +1 -1
  43. package/marketplace/plugins/litcodex/components/wikify-knowledge/package.json +1 -1
  44. package/marketplace/plugins/litcodex/hooks/hooks.json +11 -0
  45. package/marketplace/plugins/litcodex/skills/lit-adhd/SKILL.md +43 -21
  46. package/marketplace/plugins/litcodex/skills/lit-adhd/agents/openai.yaml +1 -1
  47. package/marketplace/plugins/litcodex/skills/lit-adhd/references/card-examples.md +103 -3
  48. package/marketplace/plugins/litcodex/skills/lit-adhd/references/status-taxonomy.md +19 -1
  49. package/marketplace/plugins/litcodex/skills/start-work/SKILL.md +18 -4
  50. package/node_modules/@litcodex/lit-loop/directives/lit-adhd.md +32 -13
  51. package/node_modules/@litcodex/lit-loop/dist/hook-cli.js +2 -1
  52. package/node_modules/@litcodex/lit-loop/dist/rewind-board.d.ts +192 -0
  53. package/node_modules/@litcodex/lit-loop/dist/rewind-board.js +437 -0
  54. package/node_modules/@litcodex/lit-loop/dist/rewind-cli.js +17 -3
  55. package/node_modules/@litcodex/lit-loop/dist/rewind-go.d.ts +3 -2
  56. package/node_modules/@litcodex/lit-loop/dist/rewind-go.js +6 -4
  57. package/node_modules/@litcodex/lit-loop/dist/rewind.d.ts +9 -2
  58. package/node_modules/@litcodex/lit-loop/dist/rewind.js +245 -30
  59. package/node_modules/@litcodex/lit-loop/dist/route-heads.js +3 -3
  60. package/node_modules/@litcodex/lit-loop/dist/state-types.d.ts +1 -1
  61. package/node_modules/@litcodex/lit-loop/dist/state-types.js +2 -0
  62. package/node_modules/@litcodex/lit-loop/dist/workflow-map.js +5 -1
  63. package/node_modules/@litcodex/lit-loop/package.json +1 -1
  64. package/node_modules/@litcodex/lit-loop/skills/lit-adhd/SKILL.md +43 -21
  65. package/node_modules/@litcodex/lit-loop/skills/start-work/SKILL.md +18 -4
  66. package/package.json +2 -2
  67. package/readme-assets/badge-version.svg +1 -1
@@ -0,0 +1,437 @@
1
+ // src/rewind-board.ts — the lit-adhd KPI board: the one thing to do now, what is done, what is left, and what not
2
+ // to forget, computed from the collector's records and drawn as Markdown the Codex terminal shows well.
3
+ //
4
+ // `buildBoard` turns the facts `collectRewind` already read (plan rows, goals, the next step, sessions waiting on
5
+ // the person, uncommitted and unpushed work, other lanes, stale plans, the handoff's next item) into buckets, counts,
6
+ // bars, percentages and reminders. `renderBoard` writes that structure in English or Korean. Both are pure: the
7
+ // same records give the same board, and nothing here reads a file or runs a command. The board never shows a raw
8
+ // status code, a session id, a commit hash or an internal path; record text is escaped so it stays inert.
9
+ import { cleanLines } from "./control-chars.js";
10
+ import { fit } from "./hud.js";
11
+ /** Ten cells on every bar. */
12
+ export const BAR_CELLS = 10;
13
+ export const DONE_SHOWN = 5;
14
+ export const REMAINING_SHOWN = 7;
15
+ export const REMINDERS_SHOWN = 5;
16
+ export const MILESTONES_SHOWN = 4;
17
+ /** A plan nobody touched for this long is named as stopped. */
18
+ export const STALE_MS = 7 * 24 * 60 * 60 * 1000;
19
+ /** Ten cells of `█` and `░`; a partly done total never draws as full or as empty. */
20
+ export function boardBar(done, total) {
21
+ if (total <= 0)
22
+ return "░".repeat(BAR_CELLS);
23
+ let filled = Math.round((Math.min(done, total) / total) * BAR_CELLS);
24
+ if (done > 0 && filled === 0)
25
+ filled = 1;
26
+ if (done < total && filled === BAR_CELLS)
27
+ filled = BAR_CELLS - 1;
28
+ return "█".repeat(filled) + "░".repeat(BAR_CELLS - filled);
29
+ }
30
+ export function boardPercent(done, total) {
31
+ return total <= 0 ? 0 : Math.floor((Math.min(done, total) / total) * 100);
32
+ }
33
+ const STEP_KINDS_GO = new Set(["resume", "continue", "start"]);
34
+ function takeOf(now) {
35
+ if (STEP_KINDS_GO.has(now.kind))
36
+ return "go";
37
+ if (now.kind === "approve")
38
+ return "approve";
39
+ if (now.kind === "wait-lanes")
40
+ return "wait";
41
+ return "do";
42
+ }
43
+ /** The plan the person is on: the start-work run's plan, else the plan the step names, else the newest open one. */
44
+ function currentPlan(trees, step) {
45
+ for (const tree of trees)
46
+ if (tree.work !== null)
47
+ return `${tree.name}/${tree.work.file}`;
48
+ if (step.kind === "start" || step.kind === "continue" || step.kind === "plan-item") {
49
+ for (const tree of trees)
50
+ for (const plan of tree.plans)
51
+ if (plan.title === step.title)
52
+ return `${tree.name}/${plan.file}`;
53
+ }
54
+ return null;
55
+ }
56
+ export function buildBoard(input) {
57
+ const several = input.trees.length > 1;
58
+ const named = (title, tree) => (several ? `${title} (${tree.name})` : title);
59
+ const current = currentPlan(input.trees, input.step);
60
+ const milestones = [];
61
+ for (const tree of input.trees) {
62
+ for (const plan of tree.plans) {
63
+ const done = plan.rows.filter((row) => row.done).length;
64
+ const total = plan.rows.length;
65
+ const ofWork = tree.work !== null && tree.work.file === plan.file;
66
+ // A run with parked steps is still running: parked steps never make it a waiting milestone.
67
+ const state = done >= total ? "done" : ofWork || done > 0 ? "doing" : "todo";
68
+ milestones.push({
69
+ key: `${tree.name}/${plan.file}`,
70
+ title: named(plan.title, tree),
71
+ state,
72
+ done,
73
+ total,
74
+ bar: boardBar(done, total),
75
+ lastMs: plan.changedMs,
76
+ rows: plan.rows,
77
+ });
78
+ }
79
+ if (tree.goals !== null && tree.goals.total > 0) {
80
+ const { done, total } = tree.goals;
81
+ milestones.push({
82
+ key: `${tree.name}/goals`,
83
+ title: named("lit-loop goals", tree),
84
+ state: done >= total ? "done" : "doing",
85
+ done,
86
+ total,
87
+ bar: boardBar(done, total),
88
+ lastMs: null,
89
+ rows: [],
90
+ });
91
+ }
92
+ }
93
+ // The plan the person is on comes first, then the rest by when they last changed.
94
+ const ordered = [...milestones].sort((a, b) => {
95
+ const lead = Number(b.key === current) - Number(a.key === current);
96
+ if (lead !== 0)
97
+ return lead;
98
+ const open = Number(a.state === "done") - Number(b.state === "done");
99
+ return open !== 0 ? open : (b.lastMs ?? 0) - (a.lastMs ?? 0);
100
+ });
101
+ const done = ordered.reduce((sum, item) => sum + item.done, 0);
102
+ const doingRows = ordered.filter((item) => item.state === "doing").length;
103
+ const waitingRows = ordered.filter((item) => item.state === "waiting").length;
104
+ const openRows = ordered.reduce((sum, item) => sum + (item.total - item.done), 0);
105
+ const waiting = waitingRows + input.waiting.length;
106
+ const todo = Math.max(0, openRows - doingRows - waitingRows);
107
+ const total = done + doingRows + waiting + todo;
108
+ const newest = [...ordered].sort((a, b) => (b.lastMs ?? 0) - (a.lastMs ?? 0));
109
+ const doneLately = newest
110
+ .flatMap((item) => item.rows
111
+ .filter((row) => row.done)
112
+ .map((row) => row.label)
113
+ .reverse())
114
+ .slice(0, DONE_SHOWN);
115
+ const left = ordered.flatMap((item) => item.rows.filter((row) => !row.done).map((row) => row.label));
116
+ const reminders = [];
117
+ for (const session of input.waiting)
118
+ reminders.push({ kind: "waiting", ...session });
119
+ for (const tree of input.trees)
120
+ if (tree.parked > 0)
121
+ reminders.push({ kind: "parked", place: tree.name, count: tree.parked });
122
+ for (const tree of input.trees)
123
+ if (tree.uncommitted !== null && tree.uncommitted > 0)
124
+ reminders.push({ kind: "uncommitted", place: tree.name, count: tree.uncommitted });
125
+ for (const tree of input.trees)
126
+ if (tree.unpushed !== null && tree.unpushed > 0)
127
+ reminders.push({ kind: "unpushed", place: tree.name, count: tree.unpushed });
128
+ if (input.working > 0)
129
+ reminders.push({ kind: "lanes", count: input.working });
130
+ for (const tree of input.trees)
131
+ for (const plan of tree.stale)
132
+ reminders.push({
133
+ kind: "stale",
134
+ title: named(plan.title, tree),
135
+ days: Math.floor((input.now - plan.changedMs) / 86_400_000),
136
+ });
137
+ for (const tree of input.trees)
138
+ if (tree.handoffNext !== null)
139
+ reminders.push({ kind: "handoff", item: tree.handoffNext });
140
+ return {
141
+ at: input.now,
142
+ now: input.step,
143
+ take: takeOf(input.step),
144
+ counts: {
145
+ done,
146
+ doing: doingRows,
147
+ waiting,
148
+ todo,
149
+ total,
150
+ percent: boardPercent(done, total),
151
+ bar: boardBar(done, total),
152
+ },
153
+ milestones: ordered.map(({ key: _key, rows: _rows, ...item }) => item),
154
+ doneLately,
155
+ remaining: left.slice(0, REMAINING_SHOWN),
156
+ remainingMore: Math.max(0, left.length - REMAINING_SHOWN),
157
+ reminders: reminders.slice(0, REMINDERS_SHOWN),
158
+ unknown: input.unknown,
159
+ };
160
+ }
161
+ // ── Words ────────────────────────────────────────────────────────────────────
162
+ /** Record text as inert Markdown on one line: no markup, no table break, no code span. */
163
+ function md(text, width = 90) {
164
+ return fit(text.replace(/\s+/gu, " ").trim(), width)
165
+ .replace(/[<>`]/gu, (char) => (char === "<" ? "‹" : char === ">" ? "›" : "'"))
166
+ .replace(/[*|[\]\\]|(?<![\p{L}\p{N}])_|_(?![\p{L}\p{N}])/gu, (char) => `\\${char}`);
167
+ }
168
+ const LABELS = {
169
+ en: {
170
+ now: "🎯 Do this now",
171
+ glance: "📊 At a glance",
172
+ overall: "Overall",
173
+ milestones: "🏁 Milestones",
174
+ doneLately: "✅ Done lately",
175
+ left: "⬜ Still to do",
176
+ remember: "🔔 Don't forget",
177
+ type: "👉 Type:",
178
+ wait: "👉 Wait:",
179
+ act: "👉 Do:",
180
+ buckets: { done: "✅ done", doing: "🔄 in progress", waiting: "⏳ waiting on you", todo: "⬜ left" },
181
+ header: "| Milestone | State | Progress | Last |",
182
+ noMilestones: "No milestones yet",
183
+ noDone: "Nothing finished yet",
184
+ noLeft: "Nothing left",
185
+ noReminders: "Nothing to remember",
186
+ noTotal: "nothing tracked yet",
187
+ more: (n) => `…and ${n} more`,
188
+ ofShown: (shown, all) => ` (${shown} of ${all})`,
189
+ unknown: (names) => `*could not read: ${names}*`,
190
+ },
191
+ ko: {
192
+ now: "🎯 지금 할 일",
193
+ glance: "📊 한눈에 보기",
194
+ overall: "전체 진행",
195
+ milestones: "🏁 마일스톤",
196
+ doneLately: "✅ 최근 끝낸 일",
197
+ left: "⬜ 남은 일",
198
+ remember: "🔔 잊지 말 것",
199
+ type: "👉 입력:",
200
+ wait: "👉 기다리기:",
201
+ act: "👉 할 일:",
202
+ buckets: { done: "✅ 끝남", doing: "🔄 진행 중", waiting: "⏳ 나를 기다림", todo: "⬜ 남음" },
203
+ header: "| 마일스톤 | 상태 | 진행 | 최근 |",
204
+ noMilestones: "아직 마일스톤이 없어요",
205
+ noDone: "아직 끝낸 일이 없어요",
206
+ noLeft: "남은 일이 없어요",
207
+ noReminders: "잊을 만한 일이 없어요",
208
+ noTotal: "아직 기록된 일이 없어요",
209
+ more: (n) => `…외 ${n}개`,
210
+ ofShown: (shown, all) => ` (${all}개 중 ${shown}개)`,
211
+ unknown: (names) => `*읽지 못함: ${names}*`,
212
+ },
213
+ };
214
+ function agoWords(from, at, lang) {
215
+ if (from === null)
216
+ return "·";
217
+ const minutes = Math.max(0, Math.round((at - from) / 60_000));
218
+ if (lang === "ko") {
219
+ if (minutes < 1)
220
+ return "방금";
221
+ if (minutes < 60)
222
+ return `${minutes}분 전`;
223
+ if (minutes < 48 * 60)
224
+ return `${Math.round(minutes / 60)}시간 전`;
225
+ return `${Math.round(minutes / 1440)}일 전`;
226
+ }
227
+ if (minutes < 1)
228
+ return "just now";
229
+ if (minutes < 60)
230
+ return `${minutes}m ago`;
231
+ if (minutes < 48 * 60)
232
+ return `${Math.round(minutes / 60)}h ago`;
233
+ return `${Math.round(minutes / 1440)}d ago`;
234
+ }
235
+ /** The step in plain words: what to do, and why, one line each. */
236
+ function nowWords(now, lang) {
237
+ const ko = lang === "ko";
238
+ const tally = (done, total) => done === null || total === null ? "" : ko ? `${total}개 중 ${done}개 끝남` : `${done} of ${total} done`;
239
+ switch (now.kind) {
240
+ case "resume": {
241
+ const what = `${md(now.skill, 30)}${now.stage === null ? "" : ` (${md(now.stage, 20)})`}`;
242
+ return ko
243
+ ? { action: `멈춘 ${what} 이어 하기`, why: "이 세션에서 하다가 멈췄어요" }
244
+ : { action: `Resume the paused ${what}`, why: "it stopped part-way in this session" };
245
+ }
246
+ case "approve":
247
+ return ko
248
+ ? {
249
+ action: "보류된 start-work 단계 정리하기 (선택)",
250
+ why: `${md(now.place, 30)}의 작업은 계속 진행되고, 보류된 단계만 내 결정을 기다려요`,
251
+ }
252
+ : {
253
+ action: "Settle the parked start-work steps (optional)",
254
+ why: `the run in ${md(now.place, 30)} keeps going; only its parked steps wait for you`,
255
+ };
256
+ case "continue":
257
+ return ko
258
+ ? { action: `${md(now.title, 50)} 계속하기`, why: tally(now.done, now.total) || "진행 중인 작업이에요" }
259
+ : { action: `Keep going on ${md(now.title, 50)}`, why: tally(now.done, now.total) || "it is under way" };
260
+ case "start":
261
+ return ko
262
+ ? {
263
+ action: `${md(now.title, 50)} 시작하기`,
264
+ why: `여기 열린 계획은 이것 하나예요 (${tally(now.done, now.total)})`,
265
+ }
266
+ : {
267
+ action: `Start ${md(now.title, 50)}`,
268
+ why: `it is the only open plan here (${tally(now.done, now.total)})`,
269
+ };
270
+ case "elsewhere":
271
+ return ko
272
+ ? { action: "그 작업은 원래 세션에서 이어 하기", why: "다른 세션이 돌리던 start-work예요" }
273
+ : { action: "Continue that run in its own session", why: "another session owns this start-work run" };
274
+ case "answer-lane":
275
+ return ko
276
+ ? {
277
+ action: `${md(now.place, 30)}에서 기다리는 질문에 답하기`,
278
+ why: now.more > 0 ? `다른 레인 ${now.more}개도 아직 일하는 중이에요` : "그 레인이 내 답을 기다려요",
279
+ }
280
+ : {
281
+ action: `Answer the session in ${md(now.place, 30)}`,
282
+ why: now.more > 0 ? `${now.more} more lane(s) still at work` : "that lane waits on you",
283
+ };
284
+ case "wait-lanes":
285
+ return ko
286
+ ? { action: "다른 레인이 끝날 때까지 기다리기", why: `아직 일하는 레인이 ${now.count}개 있어요` }
287
+ : { action: "Wait for the other lanes to finish", why: `${now.count} lane(s) still at work` };
288
+ case "handoff":
289
+ return ko
290
+ ? { action: `handoff의 다음 항목 정하기: ${md(now.item, 60)}`, why: "`go`로는 실행되지 않아요" }
291
+ : { action: `Decide on the handoff's next item: ${md(now.item, 60)}`, why: "`go` does not run it" };
292
+ case "answer":
293
+ return ko
294
+ ? {
295
+ action: `${md(now.place, 30)}의 세션에 답하기`,
296
+ why: now.question === null ? "내 답을 기다리고 있어요" : `물어본 것: “${md(now.question, 70)}”`,
297
+ }
298
+ : {
299
+ action: `Answer the session in ${md(now.place, 30)}`,
300
+ why: now.question === null ? "it waits on your answer" : `it asked: “${md(now.question, 70)}”`,
301
+ };
302
+ case "review":
303
+ return ko
304
+ ? { action: `${md(now.place, 30)}에서 끝난 일 확인하기`, why: md(now.title, 60) }
305
+ : { action: `Review what finished in ${md(now.place, 30)}`, why: md(now.title, 60) };
306
+ case "resume-other":
307
+ return ko
308
+ ? { action: `멈춘 ${md(now.label, 40)} 이어 하기`, why: `${md(now.place, 30)}에서 멈춰 있어요` }
309
+ : { action: `Resume the paused ${md(now.label, 40)}`, why: `it is paused in ${md(now.place, 30)}` };
310
+ case "plan-item":
311
+ return ko
312
+ ? { action: md(now.item, 70), why: `${md(now.title, 40)}의 다음 항목이에요` }
313
+ : { action: md(now.item, 70), why: `the next item of ${md(now.title, 40)}` };
314
+ case "check":
315
+ return ko
316
+ ? { action: `${md(now.place, 30)}의 세션 살펴보기`, why: md(now.title, 60) }
317
+ : { action: `Check on the session in ${md(now.place, 30)}`, why: md(now.title, 60) };
318
+ case "pick-up":
319
+ return ko
320
+ ? { action: `${md(now.place, 30)}의 일 다시 잡기`, why: md(now.title, 60) }
321
+ : { action: `Pick up the work in ${md(now.place, 30)}`, why: md(now.title, 60) };
322
+ case "nothing":
323
+ return ko
324
+ ? { action: "무엇을 시작할지 말하기", why: "이 기간에는 세션도 계획도 없어요" }
325
+ : { action: "Say what to start", why: "no session or plan in this window" };
326
+ }
327
+ }
328
+ /** The line that says how to take the step. */
329
+ function takeLine(board, lang) {
330
+ const l = LABELS[lang];
331
+ const ko = lang === "ko";
332
+ const now = board.now;
333
+ if (board.take === "go")
334
+ return `${l.type} \`go\``;
335
+ if (board.take === "approve")
336
+ return `${l.type} \`lit approve\` ${ko ? "(선택) 또는" : "(optional) or"} \`lit cancel\``;
337
+ if (board.take === "wait" && now.kind === "wait-lanes")
338
+ return `${l.wait} ${md(now.place, 30)}${ko ? " 끝날 때까지 (그 전에는 `go` 치지 않기)" : " finishes (do not type `go` before then)"}`;
339
+ const how = {
340
+ elsewhere: [
341
+ "switch to that session; `go` here does not run it",
342
+ "그 세션으로 가기 (여기서 `go`는 실행되지 않아요)",
343
+ ],
344
+ "answer-lane": [
345
+ "open that session and answer it; do not type `go` here yet",
346
+ "그 세션을 열어 답하기 (여기서는 아직 `go` 치지 않기)",
347
+ ],
348
+ answer: ["open that session and answer it", "그 세션을 열어 답하기"],
349
+ review: ["open that session and look over the result", "그 세션을 열어 결과 보기"],
350
+ "resume-other": ["open that session and type `lit continue`", "그 세션을 열고 `lit continue` 입력"],
351
+ };
352
+ const words = how[now.kind];
353
+ if (words !== undefined)
354
+ return `${l.act} ${ko ? words[1] : words[0]}`;
355
+ return `${l.act} ${ko ? "할 일을 직접 말해 주세요" : "say what to do"}`;
356
+ }
357
+ function reminderLine(item, lang) {
358
+ const ko = lang === "ko";
359
+ switch (item.kind) {
360
+ case "waiting":
361
+ return ko
362
+ ? `- ⏳ ${md(item.place, 30)}의 세션이 답을 기다려요${item.question === null ? "" : `: “${md(item.question, 60)}”`} → 그 세션을 열어 답하기`
363
+ : `- ⏳ The session in ${md(item.place, 30)} waits on you${item.question === null ? "" : `: “${md(item.question, 60)}”`} → open it and answer`;
364
+ case "parked":
365
+ return ko
366
+ ? `- 🅿️ ${md(item.place, 30)}의 start-work는 계속 진행 중이고 보류된 단계가 ${item.count}개 있어요 → 허용하려면 \`lit approve\` (선택), 멈추려면 \`lit cancel\``
367
+ : `- 🅿️ start-work in ${md(item.place, 30)} keeps going with ${item.count} parked step(s) → \`lit approve\` to allow them (optional), \`lit cancel\` to end the run`;
368
+ case "uncommitted":
369
+ return ko
370
+ ? `- 💾 커밋 안 된 변경 ${item.count}개 (${md(item.place, 30)}) → 확인하고 커밋하거나, 일부러 남겨 두기`
371
+ : `- 💾 ${item.count} uncommitted change(s) (${md(item.place, 30)}) → review and commit, or keep them on purpose`;
372
+ case "unpushed":
373
+ return ko
374
+ ? `- 📤 푸시 안 된 커밋 ${item.count}개 (${md(item.place, 30)}) → 준비되면 푸시하기`
375
+ : `- 📤 ${item.count} commit(s) not pushed (${md(item.place, 30)}) → push when ready`;
376
+ case "lanes":
377
+ return ko
378
+ ? `- 🏃 아직 일하는 레인 ${item.count}개 → 끝날 때까지 \`go\` 치지 않기`
379
+ : `- 🏃 ${item.count} lane(s) still working → do not type \`go\` until they finish`;
380
+ case "stale":
381
+ return ko
382
+ ? `- 🕰️ ${item.days}일째 멈춘 계획: ${md(item.title, 50)} → 이어 할지, 접을지 정하기`
383
+ : `- 🕰️ Plan stopped ${item.days} days ago: ${md(item.title, 50)} → decide to continue or drop it`;
384
+ case "handoff":
385
+ return ko
386
+ ? `- 📝 handoff의 다음 항목: ${md(item.item, 60)} → 지금 할지 정하기`
387
+ : `- 📝 Handoff's next item: ${md(item.item, 60)} → decide whether to do it now`;
388
+ }
389
+ }
390
+ /**
391
+ * The board as Markdown the Codex terminal draws: bold section lines (it prints `#` heading marks literally),
392
+ * emoji, two tables and lists. Fixed order: do this now, at a glance, milestones, done lately, still to do,
393
+ * don't forget. About forty lines at most; every empty section says so in one line.
394
+ */
395
+ export function renderBoard(board, lang = "en") {
396
+ const l = LABELS[lang];
397
+ const said = nowWords(board.now, lang);
398
+ const c = board.counts;
399
+ const lines = [`**${l.now}**`, `**${said.action}** — ${said.why}`, takeLine(board, lang), ""];
400
+ const overall = c.total === 0 ? l.noTotal : `${c.bar} ${c.done}/${c.total} (${c.percent}%)`;
401
+ lines.push(`**${l.glance}** · ${l.overall} ${overall}`, `| ${l.buckets.done} | ${l.buckets.doing} | ${l.buckets.waiting} | ${l.buckets.todo} |`, "|:--:|:--:|:--:|:--:|", `| ${c.done} | ${c.doing} | ${c.waiting} | ${c.todo} |`, "");
402
+ const shown = board.milestones.slice(0, MILESTONES_SHOWN);
403
+ const of = board.milestones.length > shown.length ? l.ofShown(shown.length, board.milestones.length) : "";
404
+ lines.push(`**${l.milestones}**${of}`);
405
+ if (shown.length === 0)
406
+ lines.push(l.noMilestones);
407
+ else {
408
+ lines.push(l.header, "|---|---|---|---|");
409
+ for (const item of shown)
410
+ lines.push(`| ${md(item.title, 44)} | ${l.buckets[item.state]} | ${item.bar} ${item.done}/${item.total} | ${agoWords(item.lastMs, board.at, lang)} |`);
411
+ }
412
+ lines.push("", `**${l.doneLately}**`);
413
+ if (board.doneLately.length === 0)
414
+ lines.push(l.noDone);
415
+ else
416
+ for (const item of board.doneLately)
417
+ lines.push(`- ${md(item)}`);
418
+ lines.push("", `**${l.left}**`);
419
+ if (board.remaining.length === 0)
420
+ lines.push(l.noLeft);
421
+ else {
422
+ board.remaining.forEach((item, index) => {
423
+ lines.push(`${index + 1}. ${md(item)}`);
424
+ });
425
+ if (board.remainingMore > 0)
426
+ lines.push(l.more(board.remainingMore));
427
+ }
428
+ lines.push("", `**${l.remember}**`);
429
+ if (board.reminders.length === 0)
430
+ lines.push(l.noReminders);
431
+ else
432
+ for (const item of board.reminders)
433
+ lines.push(reminderLine(item, lang));
434
+ if (board.unknown.length > 0)
435
+ lines.push("", l.unknown(board.unknown.join(", ")));
436
+ return cleanLines(lines.join("\n"));
437
+ }
@@ -1,7 +1,9 @@
1
1
  // src/rewind-cli.ts — `cli.js rewind` and `cli.js stage`, the two commands the lit-adhd skill and a running
2
- // loop call. `rewind` prints the cross-session brief data (JSON for the model, text for a person) and writes
2
+ // loop call. `rewind` prints the KPI board (`--lang en|ko`; the per-session detail list under it on `--detail`;
3
+ // JSON with the ready board text and its structured fields on `--json`) and writes
3
4
  // the next-step note and the session's rewind look; `stage` records the stage and k/n of the work on top of the session's stack.
4
5
  import { collectRewind, DEFAULT_MAX, DEFAULT_SINCE_MS, parseSince, renderBrief } from "./rewind.js";
6
+ import { renderBoard } from "./rewind-board.js";
5
7
  import { markRewindLook } from "./rewind-look.js";
6
8
  import { resolveLoopScope } from "./state-paths.js";
7
9
  import { frameLabel, normalizeStage, recordStackEvent } from "./workflow-stack.js";
@@ -26,6 +28,11 @@ export function rewindCommand(argv, io) {
26
28
  io.stderr.write("[lit-adhd] --since takes a number and d, h or m, for example 7d\n");
27
29
  return 2;
28
30
  }
31
+ const lang = flagValue(argv, "--lang") ?? "en";
32
+ if (lang !== "en" && lang !== "ko") {
33
+ io.stderr.write("[lit-adhd] --lang takes en or ko\n");
34
+ return 2;
35
+ }
29
36
  const max = intFlag(argv, "--max") ?? DEFAULT_MAX;
30
37
  const width = intFlag(argv, "--width") ?? 96;
31
38
  const sessionId = resolveLoopScope({ argv, env })?.sessionId ?? null;
@@ -41,8 +48,15 @@ export function rewindCommand(argv, io) {
41
48
  // Whichever route ran the brief, the session that ran it gets the rewind look.
42
49
  if (sessionId !== null)
43
50
  markRewindLook(cwd, sessionId, env, io.now);
44
- const brief = renderBrief(result, width);
45
- io.stdout.write(argv.includes("--json") ? `${JSON.stringify({ ok: true, ...result, brief })}\n` : `${brief}\n`);
51
+ // The KPI board is the default; the per-session detail list appears under it only on `--detail`.
52
+ const board = renderBoard(result.kpi, lang);
53
+ const detail = argv.includes("--detail") ? renderBrief(result, width) : null;
54
+ if (argv.includes("--json")) {
55
+ io.stdout.write(`${JSON.stringify({ ok: true, ...result, board, ...(detail === null ? {} : { detail }) })}\n`);
56
+ }
57
+ else {
58
+ io.stdout.write(detail === null ? `${board}\n` : `${board}\n\n${detail}\n`);
59
+ }
46
60
  return 0;
47
61
  }
48
62
  /** Record the stage and counts of the top frame: `stage --family loop --stage RED --n 2 --total 5`. */
@@ -14,7 +14,8 @@ export type GoDecision = {
14
14
  */
15
15
  export declare function takeGo(cwd: string, sessionId: string, now: number): GoDecision | null;
16
16
  /**
17
- * True for the whole prompt `lit approve`, `lit deny`, `lit 승인` or `lit 거절`. The start-work lifecycle hook
18
- * owns these words; this hook stays silent for them so a bare `lit` never starts a loop on top of an answer.
17
+ * True for the whole prompt `lit approve`, `lit deny`, `lit cancel`, `lit 승인`, `lit 거절` or `lit 취소`. The
18
+ * start-work lifecycle hook owns these words; this hook stays silent for them so a bare `lit` never starts a loop
19
+ * on top of an answer or a cancel.
19
20
  */
20
21
  export declare function isBoundaryAnswer(prompt: string): boolean;
@@ -60,7 +60,8 @@ function readNote(cwd, sessionId) {
60
60
  }
61
61
  const EXPIRED = "The user said `go`, but the briefed next step is older than 30 minutes, so nothing was started. Tell the user that in one sentence and offer `lit adhd` for a fresh brief; start no other work.";
62
62
  const STALE = "The user said `go`, but the briefed next step no longer holds, so nothing was started. Tell the user that in one sentence and offer `lit adhd` for a fresh brief; start no other work.";
63
- const BOUNDARY = "The user said `go`, but the briefed step is a start-work boundary waiting for an answer. `go` never approves it: tell the user in one sentence to answer `lit approve` or `lit deny` themselves; start nothing.";
63
+ // Kept so a note an older version wrote inside its 30-minute window still answers.
64
+ const BOUNDARY = "The user said `go`, but the briefed step was a start-work waiting on parked steps, and `go` never approves them. Tell the user in one sentence that `lit approve` (optional) allows the parked steps and `lit cancel` ends the run; start nothing.";
64
65
  const LANES = "The user said `go`, but the brief offered no step for `go`: other lanes in this repository were still working, so nothing was started. Tell the user that in one sentence: wait for those lanes (or answer the one that waits on them), then ask for a fresh `lit adhd`; start no other work.";
65
66
  const ELSEWHERE = "The user said `go`, but the briefed run belongs to another session, so nothing was started. Tell the user in one sentence to continue it in that session; start no other work.";
66
67
  /**
@@ -101,10 +102,11 @@ export function takeGo(cwd, sessionId, now) {
101
102
  }
102
103
  return { kind: "run", prompt: "lit continue", note: `go: ${fresh.text}` };
103
104
  }
104
- const BOUNDARY_ANSWER = /^lit[ \t]+(?:approve|승인|deny|거절)$/u;
105
+ const BOUNDARY_ANSWER = /^lit[ \t]+(?:approve|승인|deny|거절|cancel|취소)$/u;
105
106
  /**
106
- * True for the whole prompt `lit approve`, `lit deny`, `lit 승인` or `lit 거절`. The start-work lifecycle hook
107
- * owns these words; this hook stays silent for them so a bare `lit` never starts a loop on top of an answer.
107
+ * True for the whole prompt `lit approve`, `lit deny`, `lit cancel`, `lit 승인`, `lit 거절` or `lit 취소`. The
108
+ * start-work lifecycle hook owns these words; this hook stays silent for them so a bare `lit` never starts a loop
109
+ * on top of an answer or a cancel.
108
110
  */
109
111
  export function isBoundaryAnswer(prompt) {
110
112
  return prompt.length <= 512 && BOUNDARY_ANSWER.test(prompt.trim());
@@ -1,4 +1,5 @@
1
1
  import { type HerdrRunner } from "./herdr-agents.js";
2
+ import { type RewindBoard } from "./rewind-board.js";
2
3
  export declare const ADHD_DIR = ".litcodex/adhd";
3
4
  /** A session written to in the last quarter hour is still running. */
4
5
  export declare const ACTIVE_MS: number;
@@ -31,6 +32,8 @@ export interface RewindLanes {
31
32
  /** Lanes that wait on the user: a session asking something, or a blocked agent. */
32
33
  readonly waiting: number;
33
34
  readonly labels: readonly string[];
35
+ /** The folder each labelled lane works in, in the same order, for words that name no session id. */
36
+ readonly places: readonly string[];
34
37
  readonly herdr: "off" | "ok" | "unknown";
35
38
  }
36
39
  export interface RewindSession {
@@ -109,6 +112,8 @@ export interface RewindResult {
109
112
  * paused workflow, an open plan item, the latest active session, the latest ended one. Shown, never recorded.
110
113
  */
111
114
  readonly suggestion: string;
115
+ /** The KPI board's buckets, counts, bars, milestones and reminders; `renderBoard` writes it in words. */
116
+ readonly kpi: RewindBoard;
112
117
  /** The window read, so the brief can say how far back it looked. */
113
118
  readonly scope: {
114
119
  readonly sinceMs: number;
@@ -157,11 +162,13 @@ export interface OpenPlan {
157
162
  /** When the plan file last changed; null when that cannot be read. */
158
163
  readonly changedMs: number | null;
159
164
  }
165
+ /** A plan's first `#` heading, else its file name without the date prefix and extension, in words. */
166
+ export declare function planTitle(text: string, file: string): string;
160
167
  /** The open plan `name` (a file under `.litcodex/plans`), or null when it is finished, a scaffold or missing. */
161
168
  export declare function openPlanNamed(cwd: string, name: string): OpenPlan | null;
162
169
  /**
163
- * The one step worth taking next, in priority order: the paused frame of this session's stack, then a boundary
164
- * waiting for an answer (shown, never started), then work already under way, then the single open plan.
170
+ * The one step worth taking next, in priority order: the paused frame of this session's stack, then work already
171
+ * under way (with its parked steps counted, never waited on), then the single open plan.
165
172
  */
166
173
  export declare function chooseNext(cwd: string, sessionId: string | null): NextStep;
167
174
  /** Save the briefed step for `go`, or remove a stale one when there is nothing to run. Never throws. */