@litfamily/litclaude 1.0.53 → 1.0.55
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 +68 -0
- package/README.md +15 -9
- package/README_ko-KR.md +15 -9
- package/bin/litclaude-ai.js +1 -1
- package/docs/assets/readme/badge-version.svg +1 -1
- package/docs/assets/skills/ultra-brainstorm.webp +0 -0
- package/docs/hooks.md +42 -23
- package/docs/migration.md +8 -8
- package/package.json +1 -1
- package/plugins/litclaude/.claude-plugin/plugin.json +1 -1
- package/plugins/litclaude/bin/litclaude-hook.js +190 -35
- package/plugins/litclaude/bin/litclaude-hud.js +4 -1
- package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
- package/plugins/litclaude/commands/lit-adhd.md +13 -15
- package/plugins/litclaude/commands/lit-comprehend.md +1 -1
- package/plugins/litclaude/commands/lit-loop.md +3 -5
- package/plugins/litclaude/commands/lit-plan.md +5 -4
- package/plugins/litclaude/commands/lit-recap.md +17 -30
- package/plugins/litclaude/commands/lit-rewind.md +13 -15
- package/plugins/litclaude/commands/litgoal.md +3 -5
- package/plugins/litclaude/commands/start-work.md +2 -2
- package/plugins/litclaude/commands/ultra-brainstorm.md +96 -0
- package/plugins/litclaude/commands/wikify.md +1 -1
- package/plugins/litclaude/hooks/lit-mod.mjs +76 -3
- package/plugins/litclaude/lib/canonical-runtime-commitments.mjs +6 -6
- package/plugins/litclaude/lib/canonical-skill-catalog.mjs +1 -1
- package/plugins/litclaude/lib/canonical-skill-resources.mjs +18 -14
- package/plugins/litclaude/lib/goal-pipeline.mjs +112 -0
- package/plugins/litclaude/lib/hud-ignition.mjs +3 -1
- package/plugins/litclaude/lib/mod/frame.mjs +32 -7
- package/plugins/litclaude/lib/mod/goal.mjs +92 -0
- package/plugins/litclaude/lib/mod/motion.mjs +24 -3
- package/plugins/litclaude/lib/mod/skills.mjs +1 -1
- package/plugins/litclaude/lib/mod/state.mjs +2 -1
- package/plugins/litclaude/lib/mod/timeline.mjs +38 -1
- package/plugins/litclaude/lib/mod/view.mjs +18 -7
- package/plugins/litclaude/lib/mod/workflow.mjs +1 -0
- package/plugins/litclaude/lib/native-goal-binding.mjs +1 -1
- package/plugins/litclaude/lib/rewind/collect.mjs +100 -13
- package/plugins/litclaude/lib/rewind/verdict.mjs +268 -0
- package/plugins/litclaude/lib/skill-plan.mjs +234 -0
- package/plugins/litclaude/lib/start-work-lifecycle.mjs +2 -1
- package/plugins/litclaude/lib/workflow-check.mjs +1 -1
- package/plugins/litclaude/lib/workflow-stack.mjs +8 -1
- package/plugins/litclaude/scripts/goal-propose.mjs +57 -0
- package/plugins/litclaude/scripts/scaffold-plan.mjs +4 -0
- package/plugins/litclaude/skills/autoconference/SKILL.md +1 -1
- package/plugins/litclaude/skills/browser-drive/SKILL.md +4 -0
- package/plugins/litclaude/skills/browser-drive/scripts/capability-probe.mjs +189 -42
- package/plugins/litclaude/skills/frontend-ui-ux/scripts/interface-probe-page.mjs +3 -1
- package/plugins/litclaude/skills/frontend-ui-ux/scripts/interface-probe.mjs +5 -2
- package/plugins/litclaude/skills/lit-adhd/SKILL.md +47 -16
- package/plugins/litclaude/skills/lit-brainstorm/SKILL.md +1 -0
- package/plugins/litclaude/skills/lit-code/SKILL.md +3 -3
- package/plugins/litclaude/skills/lit-comprehend/SKILL.md +3 -2
- package/plugins/litclaude/skills/lit-handoff/SKILL.md +1 -0
- package/plugins/litclaude/skills/lit-loop/SKILL.md +2 -5
- package/plugins/litclaude/skills/lit-plan/SKILL.md +16 -8
- package/plugins/litclaude/skills/lit-team/SKILL.md +94 -56
- package/plugins/litclaude/skills/litgoal/SKILL.md +3 -8
- package/plugins/litclaude/skills/litresearch/SKILL.md +1 -0
- package/plugins/litclaude/skills/litwork/SKILL.md +1 -4
- package/plugins/litclaude/skills/review-work/SKILL.md +3 -2
- package/plugins/litclaude/skills/start-work/SKILL.md +7 -9
- package/plugins/litclaude/skills/ultra-brainstorm/SKILL.md +180 -0
- package/plugins/litclaude/skills/ultra-brainstorm/references/lenses.md +38 -0
- package/plugins/litclaude/skills/ultra-brainstorm/references/workflow-script.md +78 -0
- package/plugins/litclaude/skills/ultra-brainstorm/scripts/estimate.mjs +39 -0
- package/plugins/litclaude/skills/wikify/SKILL.md +3 -3
- package/docs/assets/skills/lit-recap.webp +0 -0
- package/plugins/litclaude/skills/lit-recap/SKILL.md +0 -175
|
@@ -5,14 +5,16 @@
|
|
|
5
5
|
// is inferred. It writes one file only: this session's next-step record for `go`.
|
|
6
6
|
|
|
7
7
|
import { execFileSync } from "node:child_process";
|
|
8
|
-
import {
|
|
8
|
+
import { createHash } from "node:crypto";
|
|
9
|
+
import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, writeFileSync } from "node:fs";
|
|
9
10
|
import { homedir } from "node:os";
|
|
10
|
-
import { basename, join, resolve, sep } from "node:path";
|
|
11
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
11
12
|
|
|
12
13
|
import { parsePlanTaskRows } from "../plan-task-rows.mjs";
|
|
13
14
|
import { resolveProjectStateRoot } from "../project-state-root.mjs";
|
|
14
15
|
import { buildBoard, renderBoard, STALE_PLAN_DAYS } from "./board.mjs";
|
|
15
16
|
import { renderBrief } from "./brief.mjs";
|
|
17
|
+
import { nextCursor, renderVerdict } from "./verdict.mjs";
|
|
16
18
|
import { aggregateProgress, clipToWidth, displayWidth, progressOf } from "./gauge.mjs";
|
|
17
19
|
import { chooseNextStep, writeNextStep } from "./next-step.mjs";
|
|
18
20
|
import { makeRedactor } from "./redact.mjs";
|
|
@@ -258,13 +260,29 @@ const stacksOf = (root, budget, redact) => {
|
|
|
258
260
|
});
|
|
259
261
|
};
|
|
260
262
|
|
|
263
|
+
// The recorded absolute plan path as a `/`-separated path inside `root`, or null when it is missing,
|
|
264
|
+
// outside the folder, or not a markdown file.
|
|
265
|
+
const exactPlanOf = (root, plan) => {
|
|
266
|
+
if (typeof plan !== "string" || !isAbsolute(plan) || !plan.endsWith(".md")) return null;
|
|
267
|
+
let base = root;
|
|
268
|
+
try {
|
|
269
|
+
base = realpathSync(root);
|
|
270
|
+
} catch {
|
|
271
|
+
// An unreadable root keeps its own spelling.
|
|
272
|
+
}
|
|
273
|
+
const rel = relative(base, plan);
|
|
274
|
+
return rel && !rel.startsWith("..") && !isAbsolute(rel) ? rel.split(sep).join("/") : null;
|
|
275
|
+
};
|
|
276
|
+
|
|
261
277
|
const startWorkOf = (root, budget, redact) => {
|
|
262
278
|
const state = readJson(join(root, ".litclaude", "boulder.json"), budget);
|
|
263
279
|
if (!state || typeof state.works !== "object" || state.works === null) return null;
|
|
264
280
|
const work = state.active_work_id ? state.works[state.active_work_id] : null;
|
|
265
281
|
if (!work) return [];
|
|
266
|
-
// The plan's own checkboxes are current; the stored snapshot only moves at a Stop.
|
|
267
|
-
|
|
282
|
+
// The plan's own checkboxes are current; the stored snapshot only moves at a Stop. The run records
|
|
283
|
+
// the exact plan it started (`active_plan`); only a record without one is guessed as plans/<name>.
|
|
284
|
+
const planRel = exactPlanOf(root, work.active_plan) ?? (typeof work.plan_name === "string" && /^[A-Za-z0-9._-]+\.md$/u.test(work.plan_name) ? `plans/${work.plan_name}` : null);
|
|
285
|
+
const planText = planRel ? readSmallFile(join(root, planRel), budget) : null;
|
|
268
286
|
const rows = planText === null ? [] : parsePlanTaskRows(planText);
|
|
269
287
|
const open = rows.filter((row) => !row.checked);
|
|
270
288
|
const progress = rows.length
|
|
@@ -276,14 +294,16 @@ const startWorkOf = (root, budget, redact) => {
|
|
|
276
294
|
const legacy = work.status === "paused" ? work.pending_boundary : null;
|
|
277
295
|
const allBlocked = rows.length ? open.length > 0 && open.every((row) => row.blocked) : !work.progress?.next_task && work.progress?.unchecked > 0;
|
|
278
296
|
const waiting = legacy ?? (parked.length && allBlocked ? parked[0] : null);
|
|
297
|
+
// Every row of the run's own plan ticked: the run is finished, whatever its last Stop stored (R4).
|
|
298
|
+
const finished = rows.length > 0 && open.length === 0 && ["active", "paused"].includes(work.status);
|
|
279
299
|
return [{
|
|
280
300
|
worktree: redact(root),
|
|
281
301
|
workId: work.work_id,
|
|
282
|
-
plan: typeof work.plan_name === "string" ? `plans/${work.plan_name}` : "unknown",
|
|
283
|
-
status: waiting ? "paused" : work.status === "paused" ? "active" : work.status,
|
|
302
|
+
plan: planRel ?? (typeof work.plan_name === "string" ? `plans/${work.plan_name}` : "unknown"),
|
|
303
|
+
status: finished ? "finished" : waiting ? "paused" : work.status === "paused" ? "active" : work.status,
|
|
284
304
|
sessionId: work.root_session_id ?? null,
|
|
285
305
|
id8: typeof work.root_session_id === "string" ? work.root_session_id.slice(0, 8) : "unknown",
|
|
286
|
-
...(waiting ? { pendingBoundary: { action: waiting.action, root: redact(waiting.root) } } : {}),
|
|
306
|
+
...(waiting && !finished ? { pendingBoundary: { action: waiting.action, root: redact(waiting.root) } } : {}),
|
|
287
307
|
...(parked.length ? { parked: parked.length } : {}),
|
|
288
308
|
progress,
|
|
289
309
|
}];
|
|
@@ -320,8 +340,9 @@ const livenessOf = (root, budget) => {
|
|
|
320
340
|
});
|
|
321
341
|
};
|
|
322
342
|
|
|
323
|
-
// `herdr agent list` answers one JSON document. Only agents
|
|
324
|
-
//
|
|
343
|
+
// `herdr agent list` answers one JSON document. Only agents whose cwd is inside the folders read
|
|
344
|
+
// (and this session's own pane) are kept, so a lane the brief can see is one that could race this
|
|
345
|
+
// project's `go`. A herdr workspace spans other repos, so sharing it proves nothing.
|
|
325
346
|
const herdrOf = (env, exec, redact, roots) => {
|
|
326
347
|
if (env.HERDR_ENV !== "1") return { status: "unknown", agents: [] };
|
|
327
348
|
try {
|
|
@@ -329,7 +350,7 @@ const herdrOf = (env, exec, redact, roots) => {
|
|
|
329
350
|
if (!Array.isArray(listed)) return { status: "unknown", agents: [] };
|
|
330
351
|
const inside = (path) => typeof path === "string" && roots.some((root) => path === root || path.startsWith(`${root}${sep}`));
|
|
331
352
|
const agents = listed
|
|
332
|
-
.filter((agent) => (env.
|
|
353
|
+
.filter((agent) => (Boolean(env.HERDR_PANE_ID) && agent?.pane_id === env.HERDR_PANE_ID) || inside(agent?.foreground_cwd) || inside(agent?.cwd))
|
|
333
354
|
.slice(0, 20)
|
|
334
355
|
.map((agent) => ({
|
|
335
356
|
agent: clipToWidth(redact(String(agent.agent ?? "unknown")), 20),
|
|
@@ -417,9 +438,26 @@ export const collectRewind = ({
|
|
|
417
438
|
const rootSet = new Set(roots.map((root) => resolve(root).normalize("NFC")));
|
|
418
439
|
const transcripts = findTranscripts(env.CLAUDE_CONFIG_DIR || join(home, ".claude"), roots);
|
|
419
440
|
const sessions = [];
|
|
441
|
+
// What the verdict card's coverage line reports: transcripts inside the window this run did not read.
|
|
442
|
+
const notRead = { budget: 0, limit: 0, unreadable: 0 };
|
|
420
443
|
for (const file of transcripts.files) {
|
|
421
|
-
|
|
444
|
+
let changed = null;
|
|
445
|
+
try {
|
|
446
|
+
changed = lstatSync(file).mtimeMs;
|
|
447
|
+
} catch {
|
|
448
|
+
changed = null;
|
|
449
|
+
}
|
|
450
|
+
if (changed !== null && now - changed > sinceMs) break;
|
|
451
|
+
if (sessions.length >= limit) {
|
|
452
|
+
notRead.limit += 1;
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
if (budget.exhausted) {
|
|
456
|
+
notRead.budget += 1;
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
422
459
|
const lines = readTranscriptLines(file, budget);
|
|
460
|
+
if (!lines) notRead.unreadable += 1;
|
|
423
461
|
const session = lines ? sessionRecord(lines, { redact, now }) : null;
|
|
424
462
|
if (!session || (session.lastMs !== null && now - session.lastMs > sinceMs)) continue;
|
|
425
463
|
// Claude's folder slug maps every non-alphanumeric to `-`, so `client_a` and `client-a` share one
|
|
@@ -502,6 +540,7 @@ export const collectRewind = ({
|
|
|
502
540
|
herdr: herdr.status,
|
|
503
541
|
},
|
|
504
542
|
budget: { bytesRead: budget.used, limit: budget.limit, exhausted: budget.exhausted },
|
|
543
|
+
coverage: { notRead },
|
|
505
544
|
summary: {
|
|
506
545
|
sessions: sessions.length,
|
|
507
546
|
waitingOnUser: sessions.filter((session) => session.status === "waiting-on-user").length,
|
|
@@ -591,6 +630,34 @@ export const renderRewind = (data, width = 100) => {
|
|
|
591
630
|
return `${out.join("\n")}\n`;
|
|
592
631
|
};
|
|
593
632
|
|
|
633
|
+
// The verdict card's "since your last look" cursor: one small file per project in LitClaude's own home
|
|
634
|
+
// (LITCLAUDE_HOME, else ~/.litclaude), outside every repository. It moves only after a card was printed.
|
|
635
|
+
export const adhdCursorPath = (env, cwd) => {
|
|
636
|
+
const home = env.LITCLAUDE_HOME || join(env.HOME || homedir(), ".litclaude");
|
|
637
|
+
const key = createHash("sha256").update(resolveProjectStateRoot(resolve(cwd))).digest("hex").slice(0, 16);
|
|
638
|
+
return join(home, "adhd", `cursor-${key}.json`);
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
const readCursor = (path) => {
|
|
642
|
+
try {
|
|
643
|
+
const cursor = JSON.parse(readFileSync(path, "utf8"));
|
|
644
|
+
return cursor && typeof cursor === "object" && typeof cursor.at === "string" ? cursor : null;
|
|
645
|
+
} catch {
|
|
646
|
+
return null;
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
|
|
650
|
+
const writeCursor = (path, cursor) => {
|
|
651
|
+
try {
|
|
652
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
653
|
+
const staging = `${path}.${process.pid}.tmp`;
|
|
654
|
+
writeFileSync(staging, `${JSON.stringify(cursor)}\n`);
|
|
655
|
+
renameSync(staging, path);
|
|
656
|
+
} catch {
|
|
657
|
+
// A cursor that cannot be written only means the next card shows the same baseline.
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
|
|
594
661
|
/**
|
|
595
662
|
* `litclaude-ai rewind [--brief [--detail] [--lang ko|en] | --json] [--here] [--since 7d] [--max 12] [--session <id>] [--width N]`.
|
|
596
663
|
* `--brief` prints the KPI board the lit-adhd skill copies, `--detail` adds the per-session brief
|
|
@@ -601,9 +668,11 @@ export const runRewindCli = (args, cwd = process.cwd(), { env = process.env, std
|
|
|
601
668
|
let json = false;
|
|
602
669
|
let brief = false;
|
|
603
670
|
let detail = false;
|
|
604
|
-
let
|
|
671
|
+
let verdict = false;
|
|
672
|
+
let recap = null;
|
|
673
|
+
let lang = null;
|
|
605
674
|
let width = Number(stdout.columns) || 100;
|
|
606
|
-
const usage = "Usage: litclaude-ai rewind [--brief [--detail] [--lang ko|en] | --json] [--here] [--since 7d] [--max 12] [--session <id>] [--width N]";
|
|
675
|
+
const usage = "Usage: litclaude-ai rewind [--verdict [--lang ko|en] | --brief [--detail] [--lang ko|en] | --recap [<session>] | --json] [--here] [--since 7d] [--max 12] [--session <id>] [--width N]";
|
|
607
676
|
if (args.some((arg) => arg === "--help" || arg === "-h")) {
|
|
608
677
|
stdout.write(`${usage}\n`);
|
|
609
678
|
return 0;
|
|
@@ -613,7 +682,10 @@ export const runRewindCli = (args, cwd = process.cwd(), { env = process.env, std
|
|
|
613
682
|
if (arg === "--json") json = true;
|
|
614
683
|
else if (arg === "--brief") brief = true;
|
|
615
684
|
else if (arg === "--detail") detail = true;
|
|
685
|
+
else if (arg === "--verdict") verdict = true;
|
|
686
|
+
else if (arg === "--recap") recap = /^[A-Za-z0-9._:-]{1,160}$/u.test(args[index + 1] ?? "") && !args[index + 1].startsWith("--") ? args[++index] : "";
|
|
616
687
|
else if (arg === "--lang" && ["ko", "en"].includes(args[index + 1])) lang = args[++index];
|
|
688
|
+
else if (arg === "--en") lang = "en";
|
|
617
689
|
else if (arg === "--here") options.here = true;
|
|
618
690
|
else if (arg === "--since" && parseSince(args[index + 1])) options.since = args[++index];
|
|
619
691
|
else if (arg === "--max" && /^\d{1,2}$/u.test(args[index + 1] ?? "")) options.max = Number(args[++index]);
|
|
@@ -625,7 +697,22 @@ export const runRewindCli = (args, cwd = process.cwd(), { env = process.env, std
|
|
|
625
697
|
}
|
|
626
698
|
}
|
|
627
699
|
const data = collectRewind(options);
|
|
700
|
+
if (!verdict) lang ??= "en";
|
|
628
701
|
const board = () => renderBoard(data, { lang });
|
|
702
|
+
if (verdict) {
|
|
703
|
+
const cursorPath = adhdCursorPath(env, cwd);
|
|
704
|
+
// The card is Korean unless English was asked for; the older views keep their English default.
|
|
705
|
+
const card = renderVerdict(data, { lang: lang ?? "ko", cursor: readCursor(cursorPath) });
|
|
706
|
+
stdout.write(card.text);
|
|
707
|
+
writeCursor(cursorPath, nextCursor(card.verdict, Date.parse(data.generatedAt)));
|
|
708
|
+
return 0;
|
|
709
|
+
}
|
|
710
|
+
if (recap !== null) {
|
|
711
|
+
// `lit adhd recap [session]`: the per-session cards, of one session when its id (or its first characters) is given.
|
|
712
|
+
const sessions = recap ? data.sessions.filter((session) => session.id8.startsWith(recap.slice(0, 8))) : data.sessions;
|
|
713
|
+
stdout.write(renderBrief({ ...data, sessions }, { lang }));
|
|
714
|
+
return 0;
|
|
715
|
+
}
|
|
629
716
|
stdout.write(json ? `${JSON.stringify(data, null, 2)}\n` : brief ? (detail ? `${board()}\n---\n\n${renderBrief(data, { lang })}` : board()) : renderRewind(data, width));
|
|
630
717
|
return 0;
|
|
631
718
|
};
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
// The lit-adhd verdict card (S5): about six lines that answer "so what do I do now?" from the collected
|
|
2
|
+
// record alone. A versioned rule table picks ONE verdict, top rule first; the model only prints it.
|
|
3
|
+
//
|
|
4
|
+
// 1 delta since the user's last look `18:02 이후: 2개 끝남, 1개가 너를 기다림`
|
|
5
|
+
// 2 the one action and where `지금 할 일: <where> 에서 <action>`
|
|
6
|
+
// 3 the exact text to type `입력: \`lit approve\``
|
|
7
|
+
// 4 why, and what happens if not `이유: … · 안 하면: …`
|
|
8
|
+
// 5 the decision queue, at most two `다음 대기: …`
|
|
9
|
+
// 6 coverage `읽음 6/7 세션 — 못 읽음: …`
|
|
10
|
+
//
|
|
11
|
+
// Inputs are evidence-gated: a finished start-work run, a plan with every row ticked and a commit are
|
|
12
|
+
// proven; a session that only says it is done is a claim and never counts as done. Every action carries
|
|
13
|
+
// a fingerprint of the records it rests on and a precondition; an irreversible step (push, publish, a
|
|
14
|
+
// release) is never an action, only `네 확인 필요: <question>`. `지금 할 일 없음` appears only when every
|
|
15
|
+
// source was read. Pure: the cursor file is read and written by the CLI, never here.
|
|
16
|
+
import { createHash } from "node:crypto";
|
|
17
|
+
import { basename } from "node:path";
|
|
18
|
+
|
|
19
|
+
import { clipToWidth } from "./gauge.mjs";
|
|
20
|
+
|
|
21
|
+
export const VERDICT_RULES_VERSION = "adhd-verdict.v1";
|
|
22
|
+
const TEXT_MAX = 64;
|
|
23
|
+
|
|
24
|
+
const LABELS = {
|
|
25
|
+
ko: {
|
|
26
|
+
since: (hhmm) => `${hhmm} 이후`,
|
|
27
|
+
firstLook: "처음 봄 — 기준 없음",
|
|
28
|
+
delta: (done, waiting) => [`${done}개 끝남`, `${waiting}개가 너를 기다림`],
|
|
29
|
+
nothingChanged: "바뀐 것 없음",
|
|
30
|
+
withdrawn: (fp) => `지난 할 일 #${fp} 철회 — 상태가 바뀜`,
|
|
31
|
+
doNow: "지금 할 일",
|
|
32
|
+
at: (where, action) => (where ? `${where} 에서 ${action}` : action),
|
|
33
|
+
type: "입력",
|
|
34
|
+
noType: (where) => `없음 — ${where ?? "그 창"}에서 직접`,
|
|
35
|
+
waitType: "없음 — 끝날 때까지 기다리기",
|
|
36
|
+
why: "이유",
|
|
37
|
+
ifNot: "안 하면",
|
|
38
|
+
queue: "다음 대기",
|
|
39
|
+
confirm: "네 확인 필요",
|
|
40
|
+
read: (read, found) => `읽음 ${read}/${found} 세션`,
|
|
41
|
+
missing: "못 읽음",
|
|
42
|
+
nothing: (count) => `지금 할 일 없음 — 확인한 기록 ${count}개`,
|
|
43
|
+
unknown: "판단 보류 — 못 읽은 기록이 있음",
|
|
44
|
+
reasons: { budget: "읽기 예산 초과", limit: "최대 개수 초과", unreadable: "읽을 수 없음", transcripts: "Claude 기록 폴더 없음", git: "git 상태" },
|
|
45
|
+
actions: {
|
|
46
|
+
approve: (plan) => `${plan}의 멈춘 단계 승인 또는 취소`,
|
|
47
|
+
answer: (q) => (q ? `질문에 답하기: ${q}` : "질문에 답하기"),
|
|
48
|
+
resume: (skill) => `멈춘 ${skill} 이어가기`,
|
|
49
|
+
continue: (plan) => `${plan} 이어서 진행`,
|
|
50
|
+
startPlan: (plan) => `${plan} 실행 시작`,
|
|
51
|
+
planItem: (item) => `다음 항목: ${item}`,
|
|
52
|
+
dirty: (count) => `바뀐 파일 ${count}개 확인`,
|
|
53
|
+
wait: (lanes) => `기다리기 — 다른 세션 ${lanes}개 작업 중`,
|
|
54
|
+
},
|
|
55
|
+
why_: {
|
|
56
|
+
approve: (n) => `작업이 승인을 기다림 (멈춘 단계 ${n}개)`,
|
|
57
|
+
answer: "그 세션이 네 답을 기다림",
|
|
58
|
+
resume: "이 세션의 작업이 멈춰 있음",
|
|
59
|
+
continue: "이 세션의 start-work가 진행 중",
|
|
60
|
+
startPlan: "열린 계획이 하나뿐이고 아무것도 안 돌고 있음",
|
|
61
|
+
planItem: "계획에 체크 안 된 항목이 남음",
|
|
62
|
+
dirty: "커밋 안 된 변경이 있음",
|
|
63
|
+
wait: "다른 세션이 같은 곳에서 일하는 중",
|
|
64
|
+
},
|
|
65
|
+
ifNot_: {
|
|
66
|
+
approve: "그 작업이 계속 멈춰 있음, 잃는 것 없음",
|
|
67
|
+
answer: "그 세션이 계속 기다림",
|
|
68
|
+
resume: "멈춘 그대로 남음",
|
|
69
|
+
continue: "남은 항목이 그대로 남음",
|
|
70
|
+
startPlan: "계획이 그대로 남음",
|
|
71
|
+
planItem: "계획이 그대로 남음",
|
|
72
|
+
dirty: "변경이 커밋 안 된 채 남음",
|
|
73
|
+
wait: "없음",
|
|
74
|
+
},
|
|
75
|
+
push: (where, count) => `${where}의 커밋 ${count}개를 push 할까?`,
|
|
76
|
+
stale: (name, days) => `${name} 계획이 ${days}일째 그대로 — 계속할지 닫을지`,
|
|
77
|
+
waitingAt: (where) => `${where} 세션이 답을 기다림`,
|
|
78
|
+
more: (n) => `(+${n})`,
|
|
79
|
+
},
|
|
80
|
+
en: {
|
|
81
|
+
since: (hhmm) => `Since ${hhmm}`,
|
|
82
|
+
firstLook: "First look — no baseline",
|
|
83
|
+
delta: (done, waiting) => [`${done} finished`, `${waiting} waiting on you`],
|
|
84
|
+
nothingChanged: "nothing changed",
|
|
85
|
+
withdrawn: (fp) => `last action #${fp} withdrawn — the state moved`,
|
|
86
|
+
doNow: "Do now",
|
|
87
|
+
at: (where, action) => (where ? `in ${where}: ${action}` : action),
|
|
88
|
+
type: "Type",
|
|
89
|
+
noType: (where) => `nothing — answer in ${where ?? "that window"}`,
|
|
90
|
+
waitType: "nothing — wait for them to finish",
|
|
91
|
+
why: "Why",
|
|
92
|
+
ifNot: "If not",
|
|
93
|
+
queue: "Next waiting",
|
|
94
|
+
confirm: "Your call",
|
|
95
|
+
read: (read, found) => `Read ${read}/${found} sessions`,
|
|
96
|
+
missing: "not read",
|
|
97
|
+
nothing: (count) => `Nothing to do now — ${count} records checked`,
|
|
98
|
+
unknown: "No verdict — some records were not read",
|
|
99
|
+
reasons: { budget: "read budget spent", limit: "over the session cap", unreadable: "unreadable", transcripts: "no Claude transcript folder", git: "git state" },
|
|
100
|
+
actions: {
|
|
101
|
+
approve: (plan) => `approve or cancel the parked step of ${plan}`,
|
|
102
|
+
answer: (q) => (q ? `answer: ${q}` : "answer its question"),
|
|
103
|
+
resume: (skill) => `resume the paused ${skill}`,
|
|
104
|
+
continue: (plan) => `continue ${plan}`,
|
|
105
|
+
startPlan: (plan) => `start ${plan}`,
|
|
106
|
+
planItem: (item) => `next item: ${item}`,
|
|
107
|
+
dirty: (count) => `review ${count} changed file(s)`,
|
|
108
|
+
wait: (lanes) => `wait — ${lanes} other session(s) at work`,
|
|
109
|
+
},
|
|
110
|
+
why_: {
|
|
111
|
+
approve: (n) => `the run waits for approval (${n} parked step(s))`,
|
|
112
|
+
answer: "that session waits for your answer",
|
|
113
|
+
resume: "this session's work is paused",
|
|
114
|
+
continue: "this session's start-work is running",
|
|
115
|
+
startPlan: "one open plan and nothing running",
|
|
116
|
+
planItem: "the plan has unticked rows",
|
|
117
|
+
dirty: "uncommitted changes",
|
|
118
|
+
wait: "another session works here",
|
|
119
|
+
},
|
|
120
|
+
ifNot_: {
|
|
121
|
+
approve: "the run stays parked, nothing lost",
|
|
122
|
+
answer: "that session keeps waiting",
|
|
123
|
+
resume: "it stays paused",
|
|
124
|
+
continue: "the open rows stay open",
|
|
125
|
+
startPlan: "the plan stays as it is",
|
|
126
|
+
planItem: "the plan stays as it is",
|
|
127
|
+
dirty: "the changes stay uncommitted",
|
|
128
|
+
wait: "nothing",
|
|
129
|
+
},
|
|
130
|
+
push: (where, count) => `push ${count} commit(s) in ${where}?`,
|
|
131
|
+
stale: (name, days) => `${name} untouched for ${days} days — keep or close?`,
|
|
132
|
+
waitingAt: (where) => `the session in ${where} waits for an answer`,
|
|
133
|
+
more: (n) => `(+${n})`,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const placeOf = (worktree) => (worktree && worktree !== "unknown" ? basename(String(worktree)) : null);
|
|
138
|
+
const short = (text) => clipToWidth(String(text ?? "").replace(/[`*_]/gu, "").replace(/\s+/gu, " ").trim(), TEXT_MAX);
|
|
139
|
+
const planLabel = (path) => short(basename(String(path ?? "plan")).replace(/\.md$/u, "").replace(/^\d{4}-\d{2}-\d{2}-/u, ""));
|
|
140
|
+
const lastQuestion = (result) => {
|
|
141
|
+
const text = String(result ?? "");
|
|
142
|
+
const question = text.split(/(?<=[.!??。])\s+|\n+/u).filter((part) => /[??]\s*$/u.test(part)).at(-1);
|
|
143
|
+
return question ? short(question) : null;
|
|
144
|
+
};
|
|
145
|
+
export const fingerprint = (parts) => createHash("sha256").update(JSON.stringify(parts)).digest("hex").slice(0, 6);
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Proven finished items: completed start-work runs, plans with every row ticked, and commits. A session
|
|
149
|
+
* that reads `done` from its transcript alone is a claim and is not counted.
|
|
150
|
+
*/
|
|
151
|
+
export const provenDone = (data) => [
|
|
152
|
+
...(data.finished?.runs ?? []).map((run) => ({ id: `run:${run.plan}:${run.at}`, at: Date.parse(run.at) })),
|
|
153
|
+
...(data.finished?.plans ?? []).filter((plan) => plan.progress?.total > 0 && plan.progress.done === plan.progress.total).map((plan) => ({ id: `plan:${plan.plan}`, at: plan.changedMs ?? null })),
|
|
154
|
+
...(data.commits ?? []).map((commit) => ({ id: `commit:${commit.hash}`, at: Date.parse(commit.at) })),
|
|
155
|
+
];
|
|
156
|
+
|
|
157
|
+
const waitingSessions = (data) => (data.sessions ?? []).filter((session) => !session.self && session.status === "waiting-on-user" && session.waitingReason !== "paused workflow");
|
|
158
|
+
|
|
159
|
+
/** Who could not be read. Herdr counts only when it was asked for. */
|
|
160
|
+
export const coverageOf = (data) => {
|
|
161
|
+
const notRead = data.coverage?.notRead ?? {};
|
|
162
|
+
const missing = [];
|
|
163
|
+
for (const reason of ["budget", "limit", "unreadable"]) if (notRead[reason] > 0) missing.push({ reason, count: notRead[reason] });
|
|
164
|
+
if (data.sources?.transcripts !== "ok") missing.push({ reason: "transcripts", count: null });
|
|
165
|
+
// A repository with no commit yet has no log, but its working-tree state was still read.
|
|
166
|
+
if (data.sources?.git !== "ok" && !(data.git ?? []).length) missing.push({ reason: "git", count: null });
|
|
167
|
+
const read = (data.sessions ?? []).length;
|
|
168
|
+
const skipped = missing.reduce((sum, item) => sum + (item.count ?? 0), 0);
|
|
169
|
+
return { read, found: read + skipped, missing, full: missing.length === 0 };
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* The rule table, top first. Each rule returns null or `{ code, kind, where, action, type, why, ifNot, fp, pre }`.
|
|
174
|
+
* Versioned: a change of order or meaning bumps VERDICT_RULES_VERSION and its golden fixtures.
|
|
175
|
+
*/
|
|
176
|
+
export const RULES = Object.freeze([
|
|
177
|
+
["approve-boundary", (data) => {
|
|
178
|
+
const work = (data.startWork ?? []).find((item) => item.status === "paused" && item.pendingBoundary);
|
|
179
|
+
return work ? { code: "NEEDS_YOU", kind: "approve", where: placeOf(work.worktree), plan: planLabel(work.plan), type: "lit approve", parked: work.parked ?? 1, fp: fingerprint(["approve", work.workId, work.pendingBoundary]), pre: "a parked start-work step is open" } : null;
|
|
180
|
+
}],
|
|
181
|
+
["answer-session", (data) => {
|
|
182
|
+
const session = waitingSessions(data)[0];
|
|
183
|
+
return session ? { code: "NEEDS_YOU", kind: "answer", where: placeOf(session.worktree), question: lastQuestion(session.result), type: null, fp: fingerprint(["answer", session.id8, session.last]), pre: "that session's last turn asked the user" } : null;
|
|
184
|
+
}],
|
|
185
|
+
["resume-own-frame", (data) => (data.next?.kind === "resume-frame" ? { code: "ONE_ACTION", kind: "resume", where: null, skill: data.next.target?.skill ?? "work", type: "lit continue", fp: fingerprint(["resume", data.next.target]), pre: "this session's frame is paused" } : null)],
|
|
186
|
+
["continue-own-work", (data) => (data.next?.kind === "continue-work" ? { code: "ONE_ACTION", kind: "continue", where: null, plan: planLabel(data.next.target?.plan), type: "go", fp: fingerprint(["continue", data.next.target]), pre: "this session's start-work is active" } : null)],
|
|
187
|
+
["other-lanes-at-work", (data) => (data.next?.wait?.lanes ? { code: "WAIT", kind: "wait", where: null, lanes: data.next.wait.lanes, type: null, fp: fingerprint(["wait", data.next.wait.lanes]), pre: "another session is active here" } : null)],
|
|
188
|
+
["start-single-plan", (data) => (data.next?.kind === "start-plan" ? { code: "ONE_ACTION", kind: "startPlan", where: null, plan: planLabel(data.next.target?.plan), type: "go", fp: fingerprint(["start", data.next.target]), pre: "one open plan, nothing running" } : null)],
|
|
189
|
+
["uncommitted-work", (data) => {
|
|
190
|
+
const tree = (data.git ?? []).find((item) => item.dirty > 0);
|
|
191
|
+
return tree ? { code: "ONE_ACTION", kind: "dirty", where: tree.name, count: tree.dirty, type: "git status", fp: fingerprint(["dirty", tree.name, tree.dirty]), pre: "the worktree has uncommitted changes" } : null;
|
|
192
|
+
}],
|
|
193
|
+
["next-plan-row", (data) => {
|
|
194
|
+
const plan = (data.roadmap?.plans ?? []).find((item) => item.local && item.current) ?? (data.roadmap?.plans ?? []).find((item) => item.current);
|
|
195
|
+
return plan ? { code: "ONE_ACTION", kind: "planItem", where: plan.local ? null : placeOf(plan.worktree), item: short(plan.current), type: plan.local ? `/litclaude:start-work ${plan.plan}` : null, fp: fingerprint(["row", plan.plan, plan.current]), pre: "that row is still unticked" } : null;
|
|
196
|
+
}],
|
|
197
|
+
]);
|
|
198
|
+
|
|
199
|
+
/** The decision queue: what else waits on the user, irreversible steps as questions. */
|
|
200
|
+
const queueOf = (data, chosen, labels) => {
|
|
201
|
+
const items = [];
|
|
202
|
+
for (const session of waitingSessions(data)) {
|
|
203
|
+
if (chosen?.kind === "answer" && chosen.fp === fingerprint(["answer", session.id8, session.last])) continue;
|
|
204
|
+
items.push(labels.waitingAt(placeOf(session.worktree) ?? session.id8));
|
|
205
|
+
}
|
|
206
|
+
for (const tree of data.git ?? []) if (tree.ahead > 0) items.push(`${labels.confirm}: ${labels.push(tree.name, tree.ahead)}`);
|
|
207
|
+
for (const plan of [...(data.stalePlans ?? [])].sort((a, b) => b.days - a.days)) items.push(labels.stale(planLabel(plan.plan), plan.days));
|
|
208
|
+
return items;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
/** The structured verdict: delta, the one action (or nothing / unknown), queue and coverage. */
|
|
212
|
+
export const decideVerdict = (data, { cursor = null } = {}) => {
|
|
213
|
+
const done = provenDone(data);
|
|
214
|
+
const since = cursor && Number.isFinite(Date.parse(cursor.at)) ? Date.parse(cursor.at) : null;
|
|
215
|
+
const seen = new Set(Array.isArray(cursor?.seen) ? cursor.seen : []);
|
|
216
|
+
const newlyDone = since === null ? null : done.filter((item) => !seen.has(item.id)).length;
|
|
217
|
+
const waiting = waitingSessions(data).length + ((data.startWork ?? []).some((item) => item.status === "paused") ? 1 : 0);
|
|
218
|
+
let chosen = null;
|
|
219
|
+
let rule = null;
|
|
220
|
+
for (const [name, test] of RULES) {
|
|
221
|
+
chosen = test(data);
|
|
222
|
+
if (chosen) {
|
|
223
|
+
rule = name;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
const coverage = coverageOf(data);
|
|
228
|
+
const code = chosen?.code ?? (coverage.full ? "ALL_CLEAR" : "UNKNOWN");
|
|
229
|
+
const checked = done.length + (data.sessions ?? []).length + (data.roadmap?.plans ?? []).length + (data.git ?? []).length;
|
|
230
|
+
return { version: VERDICT_RULES_VERSION, code, rule, action: chosen, since, newlyDone, waiting, coverage, checked, done: done.map(({ id }) => id) };
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const hhmm = (ms) => {
|
|
234
|
+
const date = new Date(ms);
|
|
235
|
+
return `${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/** The card as text lines. `lang` is ko (default) or en. */
|
|
239
|
+
export const renderVerdict = (data, { lang = "ko", cursor = null } = {}) => {
|
|
240
|
+
const labels = LABELS[lang] ?? LABELS.ko;
|
|
241
|
+
const verdict = decideVerdict(data, { cursor });
|
|
242
|
+
const lines = [];
|
|
243
|
+
if (verdict.since === null) lines.push(labels.firstLook);
|
|
244
|
+
else {
|
|
245
|
+
const [doneText, waitText] = labels.delta(verdict.newlyDone, verdict.waiting);
|
|
246
|
+
// The last card's action rested on records that changed: say it is withdrawn, never repeat it silently.
|
|
247
|
+
const withdrawn = typeof cursor?.fp === "string" && /^[0-9a-f]{6}$/u.test(cursor.fp) && cursor.fp !== (verdict.action?.fp ?? null) ? ` · ${labels.withdrawn(cursor.fp)}` : "";
|
|
248
|
+
lines.push(`${labels.since(hhmm(verdict.since))}: ${verdict.newlyDone === 0 && verdict.waiting === 0 ? labels.nothingChanged : `${doneText}, ${waitText}`}${withdrawn}`);
|
|
249
|
+
}
|
|
250
|
+
const action = verdict.action;
|
|
251
|
+
if (action) {
|
|
252
|
+
const text = labels.actions[action.kind](action.plan ?? action.question ?? action.skill ?? action.item ?? action.count ?? action.lanes);
|
|
253
|
+
lines.push(`${labels.doNow}: ${labels.at(action.where, text)} #${action.fp}`);
|
|
254
|
+
lines.push(`${labels.type}: ${action.type ? `\`${action.type}\`` : action.kind === "wait" ? labels.waitType : labels.noType(action.where)}`);
|
|
255
|
+
const why = typeof labels.why_[action.kind] === "function" ? labels.why_[action.kind](action.parked) : labels.why_[action.kind];
|
|
256
|
+
lines.push(`${labels.why}: ${why} · ${labels.ifNot}: ${labels.ifNot_[action.kind]}`);
|
|
257
|
+
} else {
|
|
258
|
+
lines.push(verdict.code === "ALL_CLEAR" ? labels.nothing(verdict.checked) : labels.unknown);
|
|
259
|
+
}
|
|
260
|
+
const queue = queueOf(data, action, labels);
|
|
261
|
+
if (queue.length) lines.push(`${labels.queue}: ${queue.slice(0, 2).join(" · ")}${queue.length > 2 ? ` ${labels.more(queue.length - 2)}` : ""}`);
|
|
262
|
+
const { read, found, missing } = verdict.coverage;
|
|
263
|
+
lines.push(`${labels.read(read, found)}${missing.length ? ` — ${labels.missing}: ${missing.map((item) => `${labels.reasons[item.reason]}${item.count ? ` ${item.count}` : ""}`).join(", ")}` : ""}`);
|
|
264
|
+
return { text: `${lines.join("\n")}\n`, verdict };
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
/** The next cursor: when the user looked, and which proven items they have now seen. */
|
|
268
|
+
export const nextCursor = (verdict, now) => ({ version: 1, at: new Date(now).toISOString(), seen: verdict.done.slice(0, 500), fp: verdict.action?.fp ?? null });
|