@litfamily/litclaude 1.0.41 → 1.0.43
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 +50 -0
- package/README.md +8 -8
- package/README_ko-KR.md +8 -8
- package/TRADEMARK.md +12 -0
- package/bin/litclaude-ai.js +29 -3
- package/docs/assets/readme/badge-version.svg +1 -1
- package/docs/hooks.md +35 -6
- package/package.json +2 -1
- package/plugins/litclaude/.claude-plugin/plugin.json +7 -1
- package/plugins/litclaude/bin/litclaude-hook.js +52 -6
- package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
- package/plugins/litclaude/commands/lit-plan.md +5 -2
- package/plugins/litclaude/commands/start-work.md +8 -0
- package/plugins/litclaude/hooks/lit-band-client.mjs +9 -4
- package/plugins/litclaude/hooks/lit-mod.mjs +31 -1
- package/plugins/litclaude/lib/canonical-skill-resources.mjs +8 -8
- package/plugins/litclaude/lib/invite.mjs +131 -0
- package/plugins/litclaude/lib/lit-plan-persistence.mjs +15 -4
- package/plugins/litclaude/lib/mod/frame.mjs +97 -21
- package/plugins/litclaude/lib/mod/looks.mjs +13 -0
- package/plugins/litclaude/lib/mod/motion.mjs +5 -0
- package/plugins/litclaude/lib/mod/settings.mjs +5 -2
- package/plugins/litclaude/lib/mod/state.mjs +85 -5
- package/plugins/litclaude/lib/mod/svg-card.mjs +66 -16
- package/plugins/litclaude/lib/mod/timeline.mjs +32 -0
- package/plugins/litclaude/lib/mod/view.mjs +84 -12
- package/plugins/litclaude/lib/owner-lock.mjs +11 -1
- package/plugins/litclaude/lib/plan-scope-roots.mjs +76 -0
- package/plugins/litclaude/lib/plan-task-rows.mjs +17 -4
- package/plugins/litclaude/lib/rewind/brief.mjs +62 -8
- package/plugins/litclaude/lib/rewind/collect.mjs +114 -25
- package/plugins/litclaude/lib/session-liveness.mjs +36 -0
- package/plugins/litclaude/lib/start-work-lifecycle.mjs +200 -12
- package/plugins/litclaude/scripts/scaffold-plan.mjs +8 -2
- package/plugins/litclaude/skills/lit-adhd/SKILL.md +18 -11
- package/plugins/litclaude/skills/lit-adhd/references/card-examples.md +2 -2
- package/plugins/litclaude/skills/lit-adhd/references/status-taxonomy.md +8 -3
- package/plugins/litclaude/skills/lit-plan/SKILL.md +10 -3
- package/plugins/litclaude/skills/start-work/SKILL.md +5 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
2
|
+
import { homedir, tmpdir } from "node:os";
|
|
3
3
|
import {
|
|
4
4
|
appendFileSync,
|
|
5
5
|
closeSync,
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
21
21
|
import { fileURLToPath } from "node:url";
|
|
22
22
|
|
|
23
|
+
import { SCOPE_LINE } from "./plan-scope-roots.mjs";
|
|
23
24
|
import { parsePlanTaskRows } from "./plan-task-rows.mjs";
|
|
24
25
|
import { requireStateDir, STATE_APPEND_FLAG, STATE_WRITE_FLAG } from "./project-state-root.mjs";
|
|
25
26
|
import { pathIdentity, samePathIdentity } from "./secure-path-read.mjs";
|
|
@@ -461,7 +462,8 @@ const readCanonicalPlanText = (planPath) => {
|
|
|
461
462
|
|
|
462
463
|
export const readPlanProgress = (planPath) => {
|
|
463
464
|
const text = readCanonicalPlanText(planPath);
|
|
464
|
-
|
|
465
|
+
// `blocked` joins the fingerprint only when set, so a plan without BLOCKED: tasks keeps its hash.
|
|
466
|
+
const tasks = parsePlanTaskRows(text).map(({ checked, text: taskText, blocked }) => ({ checked, text: taskText, ...(blocked ? { blocked } : {}) }));
|
|
465
467
|
const fingerprint = hash(JSON.stringify(tasks));
|
|
466
468
|
const uncheckedTasks = tasks.filter(({ checked }) => !checked);
|
|
467
469
|
return {
|
|
@@ -469,7 +471,8 @@ export const readPlanProgress = (planPath) => {
|
|
|
469
471
|
total: tasks.length,
|
|
470
472
|
checked: tasks.length - uncheckedTasks.length,
|
|
471
473
|
unchecked: uncheckedTasks.length,
|
|
472
|
-
next_task: uncheckedTasks
|
|
474
|
+
next_task: uncheckedTasks.find(({ blocked }) => !blocked)?.text ?? null,
|
|
475
|
+
blocked_tasks: uncheckedTasks.filter(({ blocked }) => blocked).map(({ text: taskText }) => taskText),
|
|
473
476
|
};
|
|
474
477
|
};
|
|
475
478
|
|
|
@@ -852,7 +855,15 @@ export const startWorkStructuredContext = (root, sessionId, response = null) =>
|
|
|
852
855
|
return `<litclaude-start-work-context>\n${json}\n</litclaude-start-work-context>`;
|
|
853
856
|
};
|
|
854
857
|
|
|
855
|
-
const forbiddenShellPattern = /(?:\bgit\b[^\n;&|]*\b(?:commit|push|tag|reset|clean|config)\b|\b(?:npm|pnpm|yarn)\b[^\n;&|]*\
|
|
858
|
+
const forbiddenShellPattern = /(?:\bgit\b[^\n;&|]*\b(?:commit|push|tag|reset|clean|config)\b|\b(?:npm|pnpm|yarn)\b[^\n;&|]*\bpublish\b|\bgh\b[^\n;&|]*\brelease\s+create\b|\bdefaults\s+write\b)/iu;
|
|
859
|
+
// A package manager call that names `version` is a bump unless its subcommand only reads or runs a
|
|
860
|
+
// script (`npm view <pkg> version`, `npm run check:version`). That verb must be the word right after
|
|
861
|
+
// the manager: any flag in front of it (`--prefix run version patch`) leaves the subcommand unknown, refused.
|
|
862
|
+
// The lookahead keeps a nested call (`npm view x version $(npm version patch)`) its own match.
|
|
863
|
+
const PACKAGE_MANAGER_CALL = /\b(?:npm|pnpm|yarn)\b(?=([^\n;&|]*))/giu;
|
|
864
|
+
const VERSION_READ_VERB = /^[ \t]+(?:view|info|show|v|run|run-script)(?:[ \t]|$)/iu;
|
|
865
|
+
const forbiddenShellCommand = (command) => forbiddenShellPattern.test(command)
|
|
866
|
+
|| [...command.matchAll(PACKAGE_MANAGER_CALL)].some(([, rest]) => /\b(?:version|verison)\b/iu.test(rest) && !VERSION_READ_VERB.test(rest));
|
|
856
867
|
const shellRelocationPattern = /(?:^|\s)(?:--prefix|--cwd|--directory|--chdir)(?:=|\s|$)|(?:^|\s)-C(?:\s|$)/u;
|
|
857
868
|
// For grep and rg, `-C <n>` is the context-lines flag, not a change of directory.
|
|
858
869
|
const searchRelocationPattern = /(?:^|\s)(?:--prefix|--cwd|--directory|--chdir)(?:=|\s|$)/u;
|
|
@@ -1122,7 +1133,7 @@ const classifyBash = (command, cwd) => {
|
|
|
1122
1133
|
if (typeof command !== "string" || command.length === 0 || command.length > 32_768) {
|
|
1123
1134
|
return { denied: "unclassified mutating Bash command" };
|
|
1124
1135
|
}
|
|
1125
|
-
if (
|
|
1136
|
+
if (forbiddenShellCommand(command)) return { denied: "forbidden authority action in Bash command" };
|
|
1126
1137
|
const trimmed = command.trim();
|
|
1127
1138
|
const segments = trimmed.split(/[ \t]+&&[ \t]+/u);
|
|
1128
1139
|
if (segments.length === 1) return classifyBashSegment(trimmed, cwd);
|
|
@@ -1331,6 +1342,24 @@ const PLUGIN_ROOT = (() => {
|
|
|
1331
1342
|
const pluginSelfRead = (classified) => classified.action === "read" && PLUGIN_ROOT !== null
|
|
1332
1343
|
&& (classified.targetRoots ?? [classified.targetRoot]).every((target) => rootCovers(PLUGIN_ROOT, target));
|
|
1333
1344
|
|
|
1345
|
+
// Claude Code spills a long tool result to `<config>/projects/<project key>/<session id>/tool-results/`
|
|
1346
|
+
// and tells the session to read it there. The root session (and its subagents, which share its id) may
|
|
1347
|
+
// read its own folder; the key is the project path with every non-alphanumeric character as `-`.
|
|
1348
|
+
// Another session's folder, and any write, stay boundaries.
|
|
1349
|
+
const ownSpillRead = (classified, sessionId, projectDirs) => {
|
|
1350
|
+
if (classified.action !== "read" || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,159}$/u.test(sessionId)) return false;
|
|
1351
|
+
const projects = join(process.env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude"), "projects");
|
|
1352
|
+
const spills = projectDirs.filter((dir) => typeof dir === "string").flatMap((dir) => {
|
|
1353
|
+
const spill = join(projects, dir.replace(/[^A-Za-z0-9]/gu, "-"), sessionId, "tool-results");
|
|
1354
|
+
try {
|
|
1355
|
+
return [canonicalTarget(spill, "spill folder")];
|
|
1356
|
+
} catch {
|
|
1357
|
+
return [];
|
|
1358
|
+
}
|
|
1359
|
+
});
|
|
1360
|
+
return (classified.targetRoots ?? [classified.targetRoot]).every((target) => spills.some((spill) => rootCovers(spill, target)));
|
|
1361
|
+
};
|
|
1362
|
+
|
|
1334
1363
|
// What an approved boundary covers: a read reaches the target's folder, or the toplevel of another
|
|
1335
1364
|
// git checkout the target sits in; a write reaches the target's folder only. The next file beside
|
|
1336
1365
|
// the first then needs no second approval.
|
|
@@ -1378,9 +1407,156 @@ const planRoute = (root, work) => {
|
|
|
1378
1407
|
return path.startsWith("..") || isAbsolute(path) ? work.active_plan : path;
|
|
1379
1408
|
};
|
|
1380
1409
|
|
|
1410
|
+
// Words and operators of a command another session sends to watch the work. Single quotes hold
|
|
1411
|
+
// data verbatim. Outside them only path-like characters pass (`*` and `?` mark the word as a glob);
|
|
1412
|
+
// `|`, ` && ` and `2>&1` must stand alone between spaces. Anything else (`;`, `||`, `$`, a backtick,
|
|
1413
|
+
// a double quote, a backslash, a redirect, a newline) refuses the whole command.
|
|
1414
|
+
const OBSERVATION_CHAR = /[\p{L}\p{N}_.\/@+,:=%-]/u;
|
|
1415
|
+
const observationTokens = (command) => {
|
|
1416
|
+
const tokens = [];
|
|
1417
|
+
const chars = [...command];
|
|
1418
|
+
let word = null;
|
|
1419
|
+
const standalone = (index, text) => word === null && chars.slice(index, index + text.length).join("") === text
|
|
1420
|
+
&& (index + text.length === chars.length || /[ \t]/u.test(chars[index + text.length]));
|
|
1421
|
+
for (let index = 0; index < chars.length; index += 1) {
|
|
1422
|
+
const ch = chars[index];
|
|
1423
|
+
if (ch === " " || ch === "\t") {
|
|
1424
|
+
if (word) tokens.push(word);
|
|
1425
|
+
word = null;
|
|
1426
|
+
} else if (ch === "'") {
|
|
1427
|
+
const end = chars.indexOf("'", index + 1);
|
|
1428
|
+
if (end < 0) return null;
|
|
1429
|
+
word ??= { text: "", quoted: false, glob: false };
|
|
1430
|
+
word.text += chars.slice(index + 1, end).join("");
|
|
1431
|
+
word.quoted = true;
|
|
1432
|
+
index = end;
|
|
1433
|
+
} else if (standalone(index, "&&") || standalone(index, "2>&1")) {
|
|
1434
|
+
const op = standalone(index, "&&") ? "&&" : "2>&1";
|
|
1435
|
+
tokens.push({ op });
|
|
1436
|
+
index += op.length - 1;
|
|
1437
|
+
} else if (standalone(index, "|")) {
|
|
1438
|
+
tokens.push({ op: "|" });
|
|
1439
|
+
} else if (OBSERVATION_CHAR.test(ch) || ch === "*" || ch === "?") {
|
|
1440
|
+
word ??= { text: "", quoted: false, glob: false };
|
|
1441
|
+
word.text += ch;
|
|
1442
|
+
if (ch === "*" || ch === "?") word.glob = true;
|
|
1443
|
+
} else {
|
|
1444
|
+
return null;
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
if (word) tokens.push(word);
|
|
1448
|
+
return tokens;
|
|
1449
|
+
};
|
|
1450
|
+
|
|
1451
|
+
const plainWord = (word) => Boolean(word) && !word.op && !word.quoted && !word.glob;
|
|
1452
|
+
// A word starting with `-` is a flag only when bare; quoted, the tool would still read it as one.
|
|
1453
|
+
const flagWord = (word, pattern) => plainWord(word) && pattern.test(word.text);
|
|
1454
|
+
const dataWord = (word) => Boolean(word) && !word.op && !word.glob && !word.text.startsWith("-");
|
|
1455
|
+
|
|
1456
|
+
const HERDR_READS = Object.freeze({ agent: ["read", "get", "list"], pane: ["read", "list"], tab: ["list"] });
|
|
1457
|
+
// Only the flags a read needs: a flag herdr may add later (an output file, keys to send) is refused.
|
|
1458
|
+
const HERDR_READ_FLAG = /^--(?:source|lines|workspace|tab|json)(?:=[\w.:-]+)?$/u;
|
|
1459
|
+
const HERDR_ID = /^[A-Za-z0-9][\w.:-]*$/u;
|
|
1460
|
+
const observeHerdr = ([noun, verb, ...rest]) => plainWord(noun) && plainWord(verb)
|
|
1461
|
+
&& Object.hasOwn(HERDR_READS, noun.text) && HERDR_READS[noun.text].includes(verb.text)
|
|
1462
|
+
&& rest.every((word) => plainWord(word) && (HERDR_READ_FLAG.test(word.text) || HERDR_ID.test(word.text)));
|
|
1463
|
+
|
|
1464
|
+
// grep or rg over existing paths: bare flags from a closed set, the include/exclude globs, one
|
|
1465
|
+
// pattern, then plain path operands. Flags that read a pattern file or run a preprocessor are absent.
|
|
1466
|
+
const observeSearch = (args, cwd) => {
|
|
1467
|
+
let pattern = false;
|
|
1468
|
+
for (const word of args) {
|
|
1469
|
+
if (word.op) return false;
|
|
1470
|
+
if (word.text.startsWith("-")) {
|
|
1471
|
+
if (flagWord(word, /^-[rRlLnicvwxoEFHhsqZ]+$/u)) continue;
|
|
1472
|
+
if (!word.quoted && /^--(?:include|exclude|exclude-dir)=[\w.*?-]+$/u.test(word.text)) continue;
|
|
1473
|
+
return false;
|
|
1474
|
+
}
|
|
1475
|
+
if (word.glob) return false;
|
|
1476
|
+
if (!pattern) pattern = true;
|
|
1477
|
+
else if (word.quoted || !PLAIN_PATH_WORD.test(word.text) || !existsSync(resolve(cwd, word.text))) return false;
|
|
1478
|
+
}
|
|
1479
|
+
return pattern;
|
|
1480
|
+
};
|
|
1481
|
+
|
|
1482
|
+
const LIST_WORD = /^[\d,-]+$/u;
|
|
1483
|
+
const observeFilter = ([head, ...args]) => {
|
|
1484
|
+
if (!plainWord(head)) return false;
|
|
1485
|
+
switch (head.text) {
|
|
1486
|
+
case "grep":
|
|
1487
|
+
case "rg":
|
|
1488
|
+
return args.every((word) => flagWord(word, /^-[vinEFcwxoh]+$/u) || dataWord(word))
|
|
1489
|
+
&& args.filter((word) => !word.text.startsWith("-")).length === 1;
|
|
1490
|
+
case "head":
|
|
1491
|
+
case "tail":
|
|
1492
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
1493
|
+
if (flagWord(args[index], /^-n$/u) && flagWord(args[index + 1], /^\d+$/u)) index += 1;
|
|
1494
|
+
else if (!flagWord(args[index], /^-(?:\d+|q)$/u)) return false;
|
|
1495
|
+
}
|
|
1496
|
+
return true;
|
|
1497
|
+
case "cut":
|
|
1498
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
1499
|
+
if (flagWord(args[index], /^-c[\d,-]+$/u)) continue;
|
|
1500
|
+
if (flagWord(args[index], /^-[cf]$/u) && flagWord(args[index + 1], LIST_WORD)) index += 1;
|
|
1501
|
+
else if (flagWord(args[index], /^-d$/u) && args[index + 1] && !args[index + 1].op && !args[index + 1].glob && [...args[index + 1].text].length === 1) index += 1;
|
|
1502
|
+
else return false;
|
|
1503
|
+
}
|
|
1504
|
+
return true;
|
|
1505
|
+
case "wc":
|
|
1506
|
+
return args.every((word) => flagWord(word, /^-[lwcm]+$/u));
|
|
1507
|
+
case "sort":
|
|
1508
|
+
return args.every((word) => flagWord(word, /^-[unrbf]+$/u));
|
|
1509
|
+
case "uniq":
|
|
1510
|
+
return args.every((word) => flagWord(word, /^-[cdu]+$/u));
|
|
1511
|
+
default:
|
|
1512
|
+
return false;
|
|
1513
|
+
}
|
|
1514
|
+
};
|
|
1515
|
+
|
|
1516
|
+
// What another session may run to watch a running work without changing it: up to four segments
|
|
1517
|
+
// joined by ` && `, each a `cd <dir>`, a herdr read (agent read|get|list, pane read|list, tab list)
|
|
1518
|
+
// or a grep/rg read, each followed by up to four read-only pipe filters. Only otherSessionDecision
|
|
1519
|
+
// calls this; the owner's guard keeps classifyBash.
|
|
1520
|
+
export const classifyObservation = (command, cwd) => {
|
|
1521
|
+
if (typeof command !== "string" || command.length === 0 || command.length > 32_768) return false;
|
|
1522
|
+
if (forbiddenShellCommand(command)) return false;
|
|
1523
|
+
const tokens = observationTokens(command.trim());
|
|
1524
|
+
if (!tokens?.length) return false;
|
|
1525
|
+
const segments = [[]];
|
|
1526
|
+
for (const token of tokens) {
|
|
1527
|
+
if (token.op === "&&") segments.push([]);
|
|
1528
|
+
else if (token.op !== "2>&1") segments.at(-1).push(token);
|
|
1529
|
+
}
|
|
1530
|
+
if (segments.length > MAX_CHAIN_SEGMENTS) return false;
|
|
1531
|
+
let here = cwd;
|
|
1532
|
+
for (const segment of segments) {
|
|
1533
|
+
const parts = [[]];
|
|
1534
|
+
for (const token of segment) {
|
|
1535
|
+
if (token.op === "|") parts.push([]);
|
|
1536
|
+
else parts.at(-1).push(token);
|
|
1537
|
+
}
|
|
1538
|
+
const [[head, ...args], ...filters] = parts;
|
|
1539
|
+
if (!plainWord(head) || filters.length > 4 || filters.some((filter) => !observeFilter(filter))) return false;
|
|
1540
|
+
if (head.text === "cd") {
|
|
1541
|
+
if (filters.length || args.length !== 1 || !plainWord(args[0])) return false;
|
|
1542
|
+
const moved = classifyCd(`cd ${args[0].text}`, here);
|
|
1543
|
+
if (!moved || moved.denied) return false;
|
|
1544
|
+
here = moved.cd;
|
|
1545
|
+
} else if (head.text === "herdr") {
|
|
1546
|
+
if (!observeHerdr(args)) return false;
|
|
1547
|
+
} else if (head.text === "grep" || head.text === "rg") {
|
|
1548
|
+
if (!observeSearch(args, here)) return false;
|
|
1549
|
+
} else {
|
|
1550
|
+
return false;
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
return true;
|
|
1554
|
+
};
|
|
1555
|
+
|
|
1381
1556
|
// Another session in the project of a running work: reading, searching, read-only shell, loading a
|
|
1382
|
-
// skill, a read-type agent
|
|
1383
|
-
// refused with the work, its age and the ways out. The owner's work never
|
|
1557
|
+
// skill, a read-type agent, the status call and an observation command pass with a note; anything
|
|
1558
|
+
// that changes files is refused with the work, its age and the ways out. The owner's work never
|
|
1559
|
+
// pauses for it.
|
|
1384
1560
|
const STATUS_CALL = /^(?:litclaude-ai|litclaude)[ \t]+start-work[ \t]+status(?:[ \t]+--json)?$/u;
|
|
1385
1561
|
const READ_ACTIONS = new Set(["read", "vcs-read"]);
|
|
1386
1562
|
const otherSessionDecision = (root, work, input, now) => {
|
|
@@ -1397,6 +1573,14 @@ const otherSessionDecision = (root, work, input, now) => {
|
|
|
1397
1573
|
reads = false;
|
|
1398
1574
|
}
|
|
1399
1575
|
}
|
|
1576
|
+
if (!reads && toolName === "Bash") {
|
|
1577
|
+
try {
|
|
1578
|
+
const cwd = canonicalDirectory(typeof input.cwd === "string" ? input.cwd : root, "tool cwd");
|
|
1579
|
+
reads = classifyObservation(input?.tool_input?.command, cwd);
|
|
1580
|
+
} catch {
|
|
1581
|
+
reads = false;
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1400
1584
|
if (reads) {
|
|
1401
1585
|
return { decision: "allow-normal", action: "read", root, roots: [root], context: `Another session is running start-work ${work.work_id} here (last activity ${age} ago); you may read, not change files.` };
|
|
1402
1586
|
}
|
|
@@ -1466,6 +1650,9 @@ export const handleStartWorkPreToolUse = (root, input, { now = Date.now() } = {}
|
|
|
1466
1650
|
}
|
|
1467
1651
|
if (classified.control) return { decision: "allow-normal", action: "control", root: executionRoot, roots: [executionRoot] };
|
|
1468
1652
|
if (pluginSelfRead(classified)) return { decision: "allow-normal", action: "read", root: PLUGIN_ROOT, roots: [PLUGIN_ROOT] };
|
|
1653
|
+
if (!classified.chain && ownSpillRead(classified, input.session_id, [canonicalRoot, input.cwd])) {
|
|
1654
|
+
return { decision: "allow-normal", action: "read", root: classified.targetRoots?.[0] ?? classified.targetRoot, roots: classified.targetRoots ?? [classified.targetRoot] };
|
|
1655
|
+
}
|
|
1469
1656
|
if (classified.chain) {
|
|
1470
1657
|
const covered = classified.chain.every((link) => link.control
|
|
1471
1658
|
|| link.targetRoots.every((targetRoot) => work.authority.grants.some((grant) => grantCovers(grant, link.action, targetRoot))));
|
|
@@ -1621,9 +1808,13 @@ export const handleStartWorkStop = (root, input) => {
|
|
|
1621
1808
|
const next = progress.next_task
|
|
1622
1809
|
? `Continue work ${work.work_id} with next top-level task: ${progress.next_task}.`
|
|
1623
1810
|
: `Work ${work.work_id} has all top-level tasks checked; run final verification and cleanup, then complete it with \`litclaude-ai start-work complete --work-id ${work.work_id} --session-id ${input.session_id} --expected-revision ${work.revision} --idempotency-key complete-${work.work_id}-${work.revision}\`.`;
|
|
1811
|
+
// Every open task waits on the user (BLOCKED:): say so once and let the session stop. The
|
|
1812
|
+
// fingerprint below keeps the next Stop silent until the plan changes.
|
|
1813
|
+
const waiting = !progress.next_task && progress.unchecked > 0;
|
|
1624
1814
|
const output = {
|
|
1625
|
-
|
|
1626
|
-
|
|
1815
|
+
...(waiting
|
|
1816
|
+
? { systemMessage: `LitClaude start-work ${work.work_id} is waiting on you; every open task is BLOCKED: ${progress.blocked_tasks.slice(0, 5).map((task) => task.replace(/[\p{Cc}\p{Cf}]/gu, " ").slice(0, 120)).join("; ")}${progress.blocked_tasks.length > 5 ? ` (+${progress.blocked_tasks.length - 5} more)` : ""}. Remove BLOCKED: from a task or reply to carry on.` }
|
|
1817
|
+
: { decision: "block", reason: `LitClaude start-work continuation: ${next}` }),
|
|
1627
1818
|
work_id: work.work_id,
|
|
1628
1819
|
revision: work.revision,
|
|
1629
1820
|
continuation_id: `continuation-${shortHash(`${input.session_id}:${promptId}:${work.work_id}:${work.revision}:${progress.fingerprint}`)}`,
|
|
@@ -1683,9 +1874,6 @@ export const openPlans = (root) => {
|
|
|
1683
1874
|
}).map((name) => `plans/${name}`);
|
|
1684
1875
|
};
|
|
1685
1876
|
|
|
1686
|
-
// `Scope roots: <path> (<action>, <action>)` lines in the plan widen the grants it starts with.
|
|
1687
|
-
const SCOPE_LINE = /^Scope roots?:[ \t]*(\S+)[ \t]*\(([a-z, -]+)\)[ \t]*$/gmu;
|
|
1688
|
-
|
|
1689
1877
|
const derivedGrants = (root, plan, workId) => {
|
|
1690
1878
|
const grants = ["read", "write", "execute", "test", "package", "vcs-read"].map((action) => ({ action, root, issuedBy: "user-invocation" }));
|
|
1691
1879
|
if (!rootCovers(root, dirname(plan))) grants.push({ action: "read", root: dirname(plan), issuedBy: "user-invocation" });
|
|
@@ -29,6 +29,7 @@ import { realpathSync } from "node:fs";
|
|
|
29
29
|
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
30
30
|
import { fileURLToPath } from "node:url";
|
|
31
31
|
|
|
32
|
+
import { describeScopePath, uncoveredScopePaths } from "../lib/plan-scope-roots.mjs";
|
|
32
33
|
import { parsePlanTaskRows, planLinesOutsideFences } from "../lib/plan-task-rows.mjs";
|
|
33
34
|
import { ensureStateDirIgnored, resolveProjectStateRoot } from "../lib/project-state-root.mjs";
|
|
34
35
|
import { readRegularStable, samePathIdentity } from "../lib/secure-path-read.mjs";
|
|
@@ -950,7 +951,7 @@ export async function scaffold(cwd, { slug, intent, reset = false, force = false
|
|
|
950
951
|
* UNCHECKED at this point. `scripts/audit-plan-checkboxes.mjs` is the different,
|
|
951
952
|
* post-completion audit that requires them checked.
|
|
952
953
|
*/
|
|
953
|
-
export function checkPlanStructure(text) {
|
|
954
|
+
export function checkPlanStructure(text, projectRoot = null) {
|
|
954
955
|
const problems = [];
|
|
955
956
|
const lines = text.split(/\r?\n/u);
|
|
956
957
|
const visibleLines = planLinesOutsideFences(text);
|
|
@@ -1008,6 +1009,11 @@ export function checkPlanStructure(text) {
|
|
|
1008
1009
|
problems.push("unfilled <fill ...> placeholders remain — the plan is not decision-complete");
|
|
1009
1010
|
}
|
|
1010
1011
|
|
|
1012
|
+
// A folder outside the project that a todo names is granted up front, never asked for mid-run.
|
|
1013
|
+
if (projectRoot) {
|
|
1014
|
+
for (const entry of uncoveredScopePaths(text, projectRoot)) problems.push(describeScopePath(entry));
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1011
1017
|
return { ok: problems.length === 0, problems };
|
|
1012
1018
|
}
|
|
1013
1019
|
|
|
@@ -1019,7 +1025,7 @@ async function runCheck(checkPath, cwd) {
|
|
|
1019
1025
|
throw new Error(`refused: --check cannot safely read ${checkPath}: ${read.failure}`);
|
|
1020
1026
|
}
|
|
1021
1027
|
const text = read.bytes.toString("utf8");
|
|
1022
|
-
const { ok, problems } = checkPlanStructure(text);
|
|
1028
|
+
const { ok, problems } = checkPlanStructure(text, cwd);
|
|
1023
1029
|
if (ok) {
|
|
1024
1030
|
process.stdout.write(`PLAN_STRUCTURE_PASS: ${checkPath}\n`);
|
|
1025
1031
|
return 0;
|
|
@@ -46,18 +46,19 @@ verdicts: [PASS, FAIL, BLOCKED]
|
|
|
46
46
|
|
|
47
47
|
## #contract.outputs
|
|
48
48
|
|
|
49
|
-
The collector draws the brief in Markdown (`lib/rewind/brief.mjs`), so its shape is the same every time and a tired reader finds each part where it was last time. It has five parts, in this order:
|
|
49
|
+
The collector draws the brief in Markdown (`lib/rewind/brief.mjs`), so its shape is the same every time and a tired reader finds each part where it was last time. It opens with three lines, then has five parts, in this order:
|
|
50
50
|
|
|
51
|
+
0. **Three opening lines**, from records only: `Done so far:` this worktree's newest commits in the window (two at most), then its completed start-work runs (`<plan> (start-work complete)`) and its plans with every row ticked (`<plan> [▉▉] 2/2`), three items at most, else its finished litgoal objective, else "nothing finished in this window"; `Doing now:` this session's top workflow frame (skill, stage, gauge), else its running start-work plan, else the newest active session's title, else "nothing running"; `Next:` the recommended step with the word to type in brackets (`(type go)`). In Korean: `지금까지:`, `지금:`, `다음: … (go 입력)`.
|
|
51
52
|
1. **Headline.** One `## 🧭` line: sessions found, how many wait on the user, how many are active, and the next step in plain words: `세션 7개 · 나를 기다리는 것 1 · 진행 중 4 · 다음: 멈춘 lit-loop(verify) 이어가기` / `7 sessions · 1 waits on you · 4 active · next: Resume the paused lit-loop at verify`. A dim line under it gives the window and how many worktrees were read.
|
|
52
53
|
2. **Live session cards, grouped by worktree and branch.** Sessions that wait on the user or are active come first: a `### 🌿 branch · worktree` heading per group, then one quoted card per session:
|
|
53
|
-
- a coloured status badge (🟠 waiting on you, 🟢 active, ⚪ ended, ⚫ unknown; see `references/status-taxonomy.md`) with the reason it waits, its `id8`, how long ago it last moved, and `this session` / `이 세션` for the current one;
|
|
54
|
+
- a coloured status badge (🟠 waiting on you, 🟢 active, 💤 idle, ✅ done, ⚪ ended, ⚫ unknown; see `references/status-taxonomy.md`) with the reason it waits, its `id8`, how long ago it last moved, and `this session` / `이 세션` for the current one;
|
|
54
55
|
- the goal in bold, from the session's title, else its first ask;
|
|
55
56
|
- its progress: a gauge with the next remaining items when both numbers are recorded, otherwise the known facts after ⏳ (how long it ran and its last ask);
|
|
56
57
|
- ✅ what was done: edited files and commits, or, before any edit, the tools it used most;
|
|
57
|
-
- ▶ what is next for that session: answer the question it asked, resume its paused frame, approve its boundary, its plan's current item, or what it is doing now (its last tool call: `Bash “Run the gates
|
|
58
|
+
- ▶ what is next for that session: answer the question it asked, resume its paused frame, approve its boundary, its plan's current item, or what it is doing now (its last tool call: `Bash “Run the gates”`, for an active session only). A done session names the plan its run finished; an idle or done session's last tool call is never offered as its next step.
|
|
58
59
|
3. **Ended sessions, one table row each.** A `### ⚪ Ended · N` table (id, where, goal, ended, done), at most 8 rows and a count of the rest.
|
|
59
60
|
4. **Roadmap timeline.** A `### 🗺️` heading with this worktree's roadmap gauge, then ✓ finished commits with their dates and branch, ▶ the current item of each open plan of this worktree and of plans another worktree changed inside the window (with its worktree name) with its gauge, ○ the items after it, then litgoal objectives. Stale plans elsewhere, unfilled plan scaffolds and another worktree's finished objectives are left out.
|
|
60
|
-
5. **One recommended next step** in a box, from `next`, with the word to type (`go`, `lit continue` or `lit approve`), then one line: "Type `go` to continue." When nothing can run on `go`, the box still recommends a real step from the records
|
|
61
|
+
5. **One recommended next step** in a box, from `next`, with the word to type (`go`, `lit continue` or `lit approve`), then one line: "Type `go` to continue." When nothing can run on `go`, the box still recommends a real step from the records: first the first item under `## Next` or `## Next Steps` in this worktree's own `HANDOFF*.md`, then a session waiting on the user, a paused workflow, an open plan item, the latest active session, then the newest listed session that is not running (review what a done one finished, or pick up an idle or ended one). Only a window with no session and no plan says there is nothing to start. It says that nothing runs on its own, and a HANDOFF step never carries a word to type.
|
|
61
62
|
|
|
62
63
|
**Progress gauges (D9), required.** A gauge appears only when both numbers are real, in the form `[▉▉▉░░] 3/5` (filled `▉` done, light `░` remaining, then done/total). An unknown total has no gauge: the card states what is known in words instead. Never a question-mark gauge, never a guess, never an estimate, never a gauge of your own.
|
|
63
64
|
|
|
@@ -102,24 +103,27 @@ The collector (`plugins/litclaude/lib/rewind/collect.mjs`, served as `litclaude-
|
|
|
102
103
|
| Source | What it gives | Missing reads |
|
|
103
104
|
| --- | --- | --- |
|
|
104
105
|
| Claude Code transcripts, `<config>/projects/<slug>/*.jsonl` | per session: title (custom, then AI, then first prompt), first and last ask, tools used, files changed, last assistant text, status | `transcripts: unknown` |
|
|
105
|
-
| `plans/*.md` checkbox rows | open plans, current item, done/total, remaining names | `plans: unknown` |
|
|
106
|
+
| `plans/*.md` checkbox rows | open plans changed inside the window (this worktree's too), current item, done/total, remaining names | `plans: unknown` |
|
|
106
107
|
| `.litclaude/litgoal/goals.json` | objective and passed/total criteria | `litgoal: unknown` |
|
|
107
|
-
| `HANDOFF*.md` | headings from the first 40 lines only | `handoffs: unknown` |
|
|
108
|
+
| `HANDOFF*.md` | headings from the first 40 lines; for this worktree's own file only, the first item under `## Next` / `## Next Steps` | `handoffs: unknown` |
|
|
108
109
|
| `git log --since` | commits in the window, matched to sessions by time and branch | `git: unknown` |
|
|
109
110
|
| `.litclaude/workflow-stack/*.json` | running and paused disciplines with stage and k/n | `workflowStack: unknown` |
|
|
110
|
-
| `.litclaude/boulder.json` | active start-work, its plan progress and any boundary waiting for approval | `startWork: unknown` |
|
|
111
|
+
| `.litclaude/boulder.json` | active start-work, its plan progress and any boundary waiting for approval; completed runs from its history | `startWork: unknown` |
|
|
112
|
+
| `.litclaude/liveness/*.json` | each session's last hook event (`alive`, `idle`, `ended`), written by PostToolUse, Stop and SessionEnd | the transcript time alone decides |
|
|
111
113
|
| `herdr agent list` (only when `HERDR_ENV=1`) | agent panes | `herdr: unknown` |
|
|
112
114
|
|
|
113
|
-
Transcripts are read head (64 KiB) and tail (256 KiB) only, under one 8 MiB budget for the whole run, through descriptors opened without following links; subagent transcripts and sidechain lines are skipped. The slug is the session's absolute cwd with every character outside `[A-Za-z0-9]` turned into `-`; a folder whose slug is missing is found by the `cwd` its newest transcript records. Every string is redacted before it leaves the collector: credential shapes, `NAME=value` with a secret-like name, URI userinfo, any current environment value of eight or more characters, and the home directory (shown as `~`).
|
|
115
|
+
Plans, litgoal, handoffs, workflow stacks and start-work are read first, then transcripts, so a busy transcript folder never crowds out the plans; a plan met after the budget ran out is counted and the brief says how many were not read. Transcripts are read head (64 KiB) and tail (256 KiB) only, under one 8 MiB budget for the whole run, through descriptors opened without following links; subagent transcripts and sidechain lines are skipped. The slug is the session's absolute cwd with every character outside `[A-Za-z0-9]` turned into `-`; a folder whose slug is missing is found by the `cwd` its newest transcript records. Every string is redacted before it leaves the collector: credential shapes, `NAME=value` with a secret-like name, URI userinfo, any current environment value of eight or more characters, and the home directory (shown as `~`).
|
|
114
116
|
|
|
115
117
|
## Status taxonomy
|
|
116
118
|
|
|
117
119
|
- `waiting-on-user`: the session's last word was the assistant asking something, or it holds a paused workflow frame or a start-work boundary awaiting `lit approve`.
|
|
118
120
|
- `active`: written to within the last 15 minutes and not waiting.
|
|
119
|
-
- `
|
|
121
|
+
- `done`: its start-work run completed in the window and it has not moved since.
|
|
122
|
+
- `idle`: its last hook event was a Stop at least as new as its last transcript line (another session's only; this session is always active while it runs the brief).
|
|
123
|
+
- `ended`: quiet for longer than 15 minutes, or its last hook event was SessionEnd.
|
|
120
124
|
- `unknown`: the transcript held no timestamp.
|
|
121
125
|
|
|
122
|
-
Sessions waiting on the user come first, then active ones, newest first.
|
|
126
|
+
Sessions waiting on the user come first, then active ones, then idle and done ones, newest first.
|
|
123
127
|
|
|
124
128
|
## The next step
|
|
125
129
|
|
|
@@ -163,6 +167,9 @@ The colours move by hue at a steady lightness, so the card never flashes: at mos
|
|
|
163
167
|
| The brief says no session records were found | No `projects/` folder under the Claude config dir | Print it as drawn; plans and goals still show |
|
|
164
168
|
| The brief says older sessions were not read | The 8 MiB budget ran out | Print it as drawn |
|
|
165
169
|
| A card shows ⏳ facts and no gauge | No stack, plan or start-work records a total for that session | Print it as drawn; do not estimate |
|
|
166
|
-
| The box recommends a step with no word to type | `next.kind: none`; the step is drawn from the records | Print it as drawn; do not run it or invent another |
|
|
170
|
+
| The box recommends a step with no word to type | `next.kind: none`; the step is drawn from the records (this worktree's HANDOFF.md Next item first) | Print it as drawn; do not run it or invent another |
|
|
171
|
+
| The brief says N plans were not read | The read budget ran out before those plan files | Print it as drawn |
|
|
172
|
+
| A plan you expected is missing | It was last changed before the window (`--since`, 7 days by default) | Print it as drawn; a wider `--since` lists it |
|
|
173
|
+
| `Doing now: nothing running` | No frame, start-work or active session is on record | Print it as drawn |
|
|
167
174
|
|
|
168
175
|
See `references/card-examples.md` for complete briefs in English and Korean and `references/status-taxonomy.md` for the status wording in both languages.
|
|
@@ -57,7 +57,7 @@ with the language.
|
|
|
57
57
|
- ○ later · 12. go continues
|
|
58
58
|
- ○ later · 13. card
|
|
59
59
|
|
|
60
|
-
```
|
|
60
|
+
```
|
|
61
61
|
╭─ RECOMMENDED NEXT STEP ──────────────╮
|
|
62
62
|
│ Resume the paused lit-loop at verify │
|
|
63
63
|
│ type: lit continue │
|
|
@@ -104,7 +104,7 @@ Type **`lit continue`** to continue.
|
|
|
104
104
|
- ○ 이후 · 12. go continues
|
|
105
105
|
- ○ 이후 · 13. card
|
|
106
106
|
|
|
107
|
-
```
|
|
107
|
+
```
|
|
108
108
|
╭─ 추천하는 다음 단계 ───────────╮
|
|
109
109
|
│ 멈춘 lit-loop(verify) 이어가기 │
|
|
110
110
|
│ 입력: lit continue │
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
# lit-adhd status taxonomy
|
|
2
2
|
|
|
3
3
|
The collector assigns every session exactly one status. The brief renders it in the user's language
|
|
4
|
-
with the words below and never invents
|
|
4
|
+
with the words below and never invents another.
|
|
5
5
|
|
|
6
6
|
| Status | Set when | English | 한국어 |
|
|
7
7
|
| --- | --- | --- | --- |
|
|
8
8
|
| `waiting-on-user` | The last transcript entry is the assistant asking something (a closing `?`, `lit approve`, `확인해 주세요`, `할까요`…), or the session holds a paused workflow frame or a start-work boundary | waiting on you | 나를 기다림 |
|
|
9
9
|
| `active` | A transcript write within the last 15 minutes and not waiting | active | 진행 중 |
|
|
10
|
-
| `
|
|
10
|
+
| `done` | Its start-work run completed inside the window (boulder history) and its liveness record shows no activity after that | done | 완료 |
|
|
11
|
+
| `idle` | Another session whose newest liveness record is `idle`, at least as new as its last transcript line | idle | 쉬는 중 |
|
|
12
|
+
| `ended` | Quiet for longer than 15 minutes, or its newest liveness record is `ended` | ended | 끝남 |
|
|
11
13
|
| `unknown` | The transcript held no timestamp | unknown | 모름 |
|
|
12
14
|
|
|
15
|
+
The session running the brief is always `active`, and a `waiting-on-user` session keeps that status
|
|
16
|
+
whatever its liveness record says.
|
|
17
|
+
|
|
13
18
|
`waitingReason` says why a session waits: `asked the user`, `paused workflow` or
|
|
14
19
|
`start-work boundary`. Name it in the card's status cell when present: `waiting on you (paused
|
|
15
20
|
workflow)` / `나를 기다림 (멈춘 워크플로)`.
|
|
16
21
|
|
|
17
|
-
Order in the brief: waiting sessions first, then active, ended and unknown; newest first inside each group.
|
|
22
|
+
Order in the brief: waiting sessions first, then active, then idle and done, then ended and unknown; newest first inside each group.
|
|
18
23
|
|
|
19
24
|
## Sources
|
|
20
25
|
|
|
@@ -89,11 +89,18 @@ fresh Claude Code session execute without re-solving the architecture.
|
|
|
89
89
|
This skill is **planning-only**. You must not implement, must not edit files for
|
|
90
90
|
product changes, and must not run mutating commands. Do not call any start-work
|
|
91
91
|
tool from inside planning mode. Close the saved plan with one step: tell the
|
|
92
|
-
user to type `/litclaude:start-work plans/<slug>.md`;
|
|
93
|
-
so no second confirm reply and no `/goal` line is needed. The
|
|
92
|
+
user to type `go` within 30 minutes, or `/litclaude:start-work plans/<slug>.md`;
|
|
93
|
+
typing it approves this plan and runs it, so no second confirm reply and no `/goal` line is needed. The
|
|
94
|
+
Stop hook saves the plan as this session's next step once the plan file is written, which is
|
|
95
|
+
what lets the one word `go` start it. The hook starts the work
|
|
94
96
|
with grants derived from the project; a plan that needs more names it on a line
|
|
95
97
|
such as `Scope roots: <path> (read)`, and anything else outside the
|
|
96
|
-
project pauses until the user answers `lit approve` or `lit deny`.
|
|
98
|
+
project pauses until the user answers `lit approve` or `lit deny`. Every absolute
|
|
99
|
+
path a todo names outside the project must sit under such a line: `scaffold-plan.mjs
|
|
100
|
+
--check` and the Stop hook list each uncovered one with the exact line to paste
|
|
101
|
+
(`Scope roots: <existing folder> (read)`), and the Stop hook blocks until it is there.
|
|
102
|
+
Widen `(read)` by hand when a lane must write in that folder. A command quoted in
|
|
103
|
+
backticks is data and is not read for paths.
|
|
97
104
|
|
|
98
105
|
## Planning Contract
|
|
99
106
|
|
|
@@ -239,6 +239,11 @@ unavailable:
|
|
|
239
239
|
its last checkbox, so do not ask the user to set a goal before executing.
|
|
240
240
|
- Do not auto-type or send `/goal` text from a skill; if the user invokes `/goal`, respect it.
|
|
241
241
|
|
|
242
|
+
When a top-level task cannot move until the user acts, write `BLOCKED: <reason>` on its
|
|
243
|
+
line or as an indented body line under it. The Stop continuation skips such tasks; when
|
|
244
|
+
every open task is blocked it tells the user once and lets the session stop. Removing the
|
|
245
|
+
marker, or the user's reply, resumes the run.
|
|
246
|
+
|
|
242
247
|
If model-facing goal tools are absent (the case today), continue with Boulder/ledger discipline.
|
|
243
248
|
If goal tools are not exposed, do not print repeated fallback status; just keep
|
|
244
249
|
the plan ledger accurate and continue with verified evidence.
|