@litfamily/litclaude 1.0.40 → 1.0.42
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 +47 -0
- package/README.md +8 -8
- package/README_ko-KR.md +8 -8
- package/docs/assets/readme/badge-version.svg +1 -1
- package/docs/hooks.md +35 -8
- package/package.json +1 -1
- package/plugins/litclaude/.claude-plugin/plugin.json +1 -1
- package/plugins/litclaude/bin/litclaude-hook.js +49 -8
- 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 +1 -1
- package/plugins/litclaude/hooks/lit-mod.mjs +89 -9
- package/plugins/litclaude/lib/canonical-skill-resources.mjs +10 -10
- package/plugins/litclaude/lib/lit-plan-persistence.mjs +15 -4
- package/plugins/litclaude/lib/mod/frame.mjs +55 -29
- package/plugins/litclaude/lib/mod/looks.mjs +36 -0
- package/plugins/litclaude/lib/mod/motion.mjs +2 -3
- package/plugins/litclaude/lib/mod/state.mjs +72 -7
- package/plugins/litclaude/lib/mod/svg-card.mjs +13 -5
- package/plugins/litclaude/lib/mod/timeline.mjs +3 -3
- package/plugins/litclaude/lib/mod/view.mjs +155 -19
- package/plugins/litclaude/lib/mod/workflow.mjs +2 -0
- package/plugins/litclaude/lib/plan-scope-roots.mjs +76 -0
- 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 +158 -5
- package/plugins/litclaude/lib/workflow-stage.mjs +104 -22
- 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-hijack/references/capture-and-provenance.md +2 -1
- package/plugins/litclaude/skills/lit-hijack/scripts/hijack.mjs +40 -12
- package/plugins/litclaude/skills/lit-plan/SKILL.md +10 -3
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/assets.mjs +45 -17
- package/plugins/litclaude/skills/lit-typographic-motion/references/treatment.md +2 -1
|
@@ -215,6 +215,8 @@ export const parseBoulder = (state, sessionId) => {
|
|
|
215
215
|
nextTask: str(progress.next_task, 400),
|
|
216
216
|
lanes: laneList(active.lanes),
|
|
217
217
|
lastEvent: str(Array.isArray(active.events) ? active.events.at(-1)?.event : null, 60),
|
|
218
|
+
// A paused work waits at a typed boundary (start-work-lifecycle) until the user answers it.
|
|
219
|
+
awaiting: active.status === "paused" ? str(active.pending_boundary?.boundary_id, 120) : null,
|
|
218
220
|
},
|
|
219
221
|
completed,
|
|
220
222
|
};
|
|
@@ -382,19 +384,27 @@ export const countPlanTasks = (text) => {
|
|
|
382
384
|
return rows.length ? { done: rows.filter(({ checked }) => checked).length, total: rows.length } : null;
|
|
383
385
|
};
|
|
384
386
|
|
|
385
|
-
// Each frame that names a plan gets that plan's checkbox counts, read once per plan under the cap
|
|
387
|
+
// Each frame that names a plan gets that plan's checkbox counts, read once per plan under the cap,
|
|
388
|
+
// and `planAt`, the plan file's last change (when a finished plan's row was checked off).
|
|
386
389
|
const withPlanCounts = async (io, stateRoot, frames) => {
|
|
387
390
|
const refs = [...new Set(frames.map(({ planRef }) => planRef).filter(Boolean))];
|
|
388
|
-
const
|
|
389
|
-
|
|
391
|
+
const read = new Map(await Promise.all(refs.map(async (ref) => [ref, {
|
|
392
|
+
counts: countPlanTasks(await readGuarded(io, stateRoot, ref, STATE_CAPS.goals)),
|
|
393
|
+
at: num((await statOf(io, joinPath(stateRoot, ref)))?.mtimeMs),
|
|
394
|
+
}])));
|
|
395
|
+
for (const frame of frames) {
|
|
396
|
+
frame.plan = frame.planRef ? read.get(frame.planRef)?.counts ?? null : null;
|
|
397
|
+
frame.planAt = frame.planRef ? read.get(frame.planRef)?.at ?? null : null;
|
|
398
|
+
}
|
|
390
399
|
return frames;
|
|
391
400
|
};
|
|
392
401
|
|
|
393
402
|
const OTHER_STACKS = 6;
|
|
394
403
|
|
|
395
404
|
// The stacks other sessions of this project keep beside this one's, newest first and at most
|
|
396
|
-
// OTHER_STACKS: `{ id8, at, frames }` each, `at` being the file's mtime
|
|
397
|
-
// file and the unknown-session file are skipped;
|
|
405
|
+
// OTHER_STACKS: `{ id8, at, ended, frames }` each, `at` being the file's mtime and `ended` set once
|
|
406
|
+
// SessionEnd marked it. Links, this session's own file and the unknown-session file are skipped;
|
|
407
|
+
// whether one is still live is the view's call.
|
|
398
408
|
const readOtherStacks = async (io, stateRoot, sessionId) => {
|
|
399
409
|
const own = new Set([ignitionFileName(sessionId), ignitionFileName(null)]);
|
|
400
410
|
const files = (await listOf(io, joinPath(stateRoot, ".litclaude", "workflow-stack")))
|
|
@@ -406,11 +416,32 @@ const readOtherStacks = async (io, stateRoot, sessionId) => {
|
|
|
406
416
|
const id = typeof raw?.sessionId === "string" ? raw.sessionId : null;
|
|
407
417
|
const parsed = id ? parseWorkflowStack(raw, id) : null;
|
|
408
418
|
if (parsed) await withPlanCounts(io, stateRoot, parsed.frames.slice(-1));
|
|
409
|
-
return parsed ? { id8: id.replace(/[^A-Za-z0-9]/gu, "").slice(0, 8), at: entry.mtimeMs, frames: parsed.frames } : null;
|
|
419
|
+
return parsed ? { sessionId: id, id8: id.replace(/[^A-Za-z0-9]/gu, "").slice(0, 8), at: entry.mtimeMs, ended: typeof raw.endedAt === "string", frames: parsed.frames } : null;
|
|
410
420
|
}));
|
|
411
421
|
return read.filter(Boolean);
|
|
412
422
|
};
|
|
413
423
|
|
|
424
|
+
const LIVENESS_FILES = 12;
|
|
425
|
+
const LIVENESS_STATES = new Set(["alive", "idle", "ended"]);
|
|
426
|
+
|
|
427
|
+
// The newest liveness records the hooks wrote (session-liveness.mjs), keyed by full session id:
|
|
428
|
+
// `{ state, at, herdrPane }`. Links and malformed records are skipped.
|
|
429
|
+
const readLiveness = async (io, stateRoot) => {
|
|
430
|
+
const files = (await listOf(io, joinPath(stateRoot, ".litclaude", "liveness")))
|
|
431
|
+
.filter((entry) => entry?.kind === "file" && !entry.isLink && /^[A-Za-z0-9._-]+\.json$/u.test(entry.name))
|
|
432
|
+
.sort((a, b) => b.mtimeMs - a.mtimeMs)
|
|
433
|
+
.slice(0, LIVENESS_FILES);
|
|
434
|
+
const records = await Promise.all(files.map((entry) => readGuardedJson(io, stateRoot, joinPath(".litclaude", "liveness", entry.name), STATE_CAPS.small)));
|
|
435
|
+
const liveness = {};
|
|
436
|
+
for (const record of records) {
|
|
437
|
+
const id = str(record?.sessionId, 160);
|
|
438
|
+
if (!id || !LIVENESS_STATES.has(record.state) || time(record.at) === null || Object.hasOwn(liveness, id)) continue;
|
|
439
|
+
const pane = typeof record.herdrPane === "string" && /^[A-Za-z0-9:_-]{1,32}$/u.test(record.herdrPane) ? record.herdrPane : null;
|
|
440
|
+
liveness[id] = { state: record.state, at: time(record.at), herdrPane: pane };
|
|
441
|
+
}
|
|
442
|
+
return liveness;
|
|
443
|
+
};
|
|
444
|
+
|
|
414
445
|
const readWorkflowSources = async (io, stateRoot, sessionId) => {
|
|
415
446
|
const dir = (name) => joinPath(stateRoot, ".litclaude", name);
|
|
416
447
|
const [interviews, drafts, researches, ownStack, unknownStack] = await Promise.all([
|
|
@@ -425,7 +456,8 @@ const readWorkflowSources = async (io, stateRoot, sessionId) => {
|
|
|
425
456
|
await withPlanCounts(io, stateRoot, stack.frames);
|
|
426
457
|
if (stack.record) stack.record.plan = stack.frames[stack.owner].plan;
|
|
427
458
|
}
|
|
428
|
-
const
|
|
459
|
+
const [stacks, liveness] = await Promise.all([readOtherStacks(io, stateRoot, sessionId), readLiveness(io, stateRoot)]);
|
|
460
|
+
const others = stacks.map((other) => ({ ...other, liveness: liveness[other.sessionId] ?? null }));
|
|
429
461
|
// A record written before the stack existed, read only while this session has no stack.
|
|
430
462
|
const legacy = stack ? null : await readGuardedJson(io, stateRoot, ".litclaude/workflow-stage.json", STATE_CAPS.small);
|
|
431
463
|
const interviewFile = newestFile(interviews, /^[A-Za-z0-9._-]+-state\.json$/u);
|
|
@@ -445,6 +477,8 @@ const readWorkflowSources = async (io, stateRoot, sessionId) => {
|
|
|
445
477
|
record: stack?.record ?? parseStageRecord(legacy, sessionId),
|
|
446
478
|
stack,
|
|
447
479
|
others,
|
|
480
|
+
liveness,
|
|
481
|
+
sessionId: typeof sessionId === "string" ? sessionId : null,
|
|
448
482
|
interview: interview ? parseInterviewState(interview, interviewFile.mtimeMs) : null,
|
|
449
483
|
draft: draft === null ? null : parseDraftStatus(draft, draftFile.name.replace(/\.md$/u, ""), draftFile.mtimeMs),
|
|
450
484
|
research,
|
|
@@ -485,6 +519,37 @@ export const readLitSnapshot = async (io, { cwd, sessionId, env = {} }) => {
|
|
|
485
519
|
};
|
|
486
520
|
};
|
|
487
521
|
|
|
522
|
+
/**
|
|
523
|
+
* The LitClaude version Claude Code installed, from its `installed_plugins.json` record: the
|
|
524
|
+
* `litclaude@…` entry, user scope first. Anything unreadable or malformed gives null.
|
|
525
|
+
*/
|
|
526
|
+
export const installedVersionOf = (record) => {
|
|
527
|
+
const plugins = record?.plugins;
|
|
528
|
+
if (!plugins || typeof plugins !== "object" || Array.isArray(plugins)) return null;
|
|
529
|
+
const entries = Object.entries(plugins)
|
|
530
|
+
.filter(([key, list]) => key.startsWith("litclaude@") && Array.isArray(list))
|
|
531
|
+
.flatMap(([, list]) => list)
|
|
532
|
+
.filter((entry) => entry && typeof entry === "object" && typeof entry.version === "string");
|
|
533
|
+
return str((entries.find(({ scope }) => scope === "user") ?? entries[0])?.version, 40);
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
const readJsonAt = async (io, path, cap) => {
|
|
537
|
+
if (typeof path !== "string" || !path) return null;
|
|
538
|
+
try {
|
|
539
|
+
const text = await readSmall(io, path, cap);
|
|
540
|
+
const value = text === null ? null : JSON.parse(text);
|
|
541
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
542
|
+
} catch {
|
|
543
|
+
return null;
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
/** `{ loaded, installed }`: this plugin's own manifest version and the one installed, or null each. */
|
|
548
|
+
export const readPluginVersions = async (io, { pluginJson, installedFile }) => {
|
|
549
|
+
const [plugin, installed] = await Promise.all([readJsonAt(io, pluginJson, STATE_CAPS.small), readJsonAt(io, installedFile, STATE_CAPS.goals)]);
|
|
550
|
+
return { loaded: str(plugin?.version, 40), installed: installedVersionOf(installed) };
|
|
551
|
+
};
|
|
552
|
+
|
|
488
553
|
const readSmall = async (io, path, cap) => {
|
|
489
554
|
const stat = await statOf(io, path);
|
|
490
555
|
if (!stat || stat.kind !== "file" || !(stat.size <= cap)) return null;
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
|
|
23
23
|
import { gauge, knownFacts } from "../rewind/gauge.mjs";
|
|
24
24
|
import { textWidth, truncateToWidth } from "./layout.mjs";
|
|
25
|
-
import {
|
|
25
|
+
import { LOOKS, lookOf } from "./looks.mjs";
|
|
26
|
+
import { TIMINGS, barCells, gradientAt, rainbowAt } from "./motion.mjs";
|
|
26
27
|
|
|
27
28
|
const C = Object.freeze({
|
|
28
29
|
bg: "#0d1117",
|
|
@@ -102,6 +103,8 @@ const pill = (x, y, label, { fill, ink, bold = true, sweep = false, breath = nul
|
|
|
102
103
|
|
|
103
104
|
const indicatorOf = (model, accent) => {
|
|
104
105
|
if (model.completion) return { label: "DONE ✓", fill: C.green };
|
|
106
|
+
if (model.look === "turn") return { label: LOOKS.turn.label, fill: C.amber };
|
|
107
|
+
if (model.look === "review") return { label: `${LOOKS.review.label} ${model.workflow.verdicts.filter(({ state }) => state === "pass" || state === "fail").length}/${model.workflow.verdicts.length}`, fill: accent };
|
|
105
108
|
if (model.idle) return { label: "idle", fill: C.dim, plain: true };
|
|
106
109
|
const flow = model.workflow;
|
|
107
110
|
if (flow?.paused && flow.current >= 0) return { label: `${flow.stages[flow.current].id.toUpperCase()} ||`, fill: C.dim };
|
|
@@ -121,8 +124,12 @@ const topRow = (model, accent, animate, rewind = false) => {
|
|
|
121
124
|
? pill(pad, y, "🔥 LIT", { fill: "url(#lit-rainbow)", ink: C.ink, veil: true })
|
|
122
125
|
: pill(pad, y, "🔥 LIT", { fill: C.pink, ink: C.ink, breath: animate.breath ? C.orange : null });
|
|
123
126
|
const indicator = rewind && !model.completion ? { label: "REWIND <<", fill: "url(#lit-rainbow)" } : indicatorOf(model, accent);
|
|
124
|
-
|
|
125
|
-
const
|
|
127
|
+
// A newer LitClaude installed than the one loaded: `restart to <version>` left of the indicator.
|
|
128
|
+
const chip = model.restart ? `restart to ${model.restart}` : null;
|
|
129
|
+
const chipEnd = width - pad - widthOf(indicator.label) - 16;
|
|
130
|
+
const right = text(width - pad, y, indicator.label, { fill: indicator.fill, bold: !indicator.plain, anchor: "end" })
|
|
131
|
+
+ (chip ? text(chipEnd, y, chip, { fill: C.amber, anchor: "end" }) : "");
|
|
132
|
+
const room = width - pad - widthOf(indicator.label) - 16 - (chip ? widthOf(chip) + 16 : 0) - brand.end - widthOf(" · ");
|
|
126
133
|
const name = truncateToWidth(model.title ?? "ready", Math.max(4, Math.floor(room / SVG_CARD.cell)));
|
|
127
134
|
const title = run(brand.end + 4, y, [[" · ", { fill: C.dim }], [name, model.idle && !rewind ? { fill: C.dim } : { fill: accent, bold: true }]]);
|
|
128
135
|
return brand.markup + title.markup + right;
|
|
@@ -420,7 +427,7 @@ const pulseSvg = (x, y, animate, fill) => {
|
|
|
420
427
|
*/
|
|
421
428
|
const threadRowsSvg = (model, { animate = false, rewind = false } = {}) => {
|
|
422
429
|
const { width, pad } = SVG_CARD;
|
|
423
|
-
const { chain, lanes, others, laneCount = 0, taskCount = 0, more } = model.threads;
|
|
430
|
+
const { chain, lanes, herdrLanes = [], others, laneCount = 0, taskCount = 0, more } = model.threads;
|
|
424
431
|
const lines = [];
|
|
425
432
|
chain.forEach((thread, index) => lines.push({ thread, lead: index === 0 ? "" : `${" ".repeat(index - 1)}└─ ` }));
|
|
426
433
|
const under = " ".repeat(Math.max(0, chain.length - 1));
|
|
@@ -431,6 +438,7 @@ const threadRowsSvg = (model, { animate = false, rewind = false } = {}) => {
|
|
|
431
438
|
} else {
|
|
432
439
|
lanes.forEach((thread) => lines.push({ thread, lead: chain.length ? `${under}└─ ` : "" }));
|
|
433
440
|
}
|
|
441
|
+
herdrLanes.forEach((thread) => lines.push({ thread, lead: "" }));
|
|
434
442
|
others.forEach((thread) => lines.push({ thread, lead: "" }));
|
|
435
443
|
const threads = lines.filter(({ thread }) => thread).map(({ thread }) => thread);
|
|
436
444
|
const nameCells = Math.min(28, Math.max(...threads.map(({ name }) => textWidth(name))));
|
|
@@ -515,7 +523,7 @@ export const svgCardAlt = (model) => {
|
|
|
515
523
|
parts.push(`phase ${LABELS[current]}`);
|
|
516
524
|
}
|
|
517
525
|
if (model.step) parts.push(`running ${model.step.name}`);
|
|
518
|
-
const threads = model.threads ? [...model.threads.chain, ...model.threads.lanes, ...model.threads.others] : [];
|
|
526
|
+
const threads = model.threads ? [...model.threads.chain, ...model.threads.lanes, ...(model.threads.herdrLanes ?? []), ...model.threads.others] : [];
|
|
519
527
|
if (threads.length) parts.push(`threads ${threads.map((thread) => `${thread.name} ${gauge(thread.done, thread.total) ? `${gauge(thread.done, thread.total)} ${thread.state}` : threadFacts(thread)}`).join(", ")}${model.threads.more ? `, ${model.threads.more} more` : ""}`);
|
|
520
528
|
if (model.skills.length) parts.push(`skills ${model.skills.map(({ id }) => id).join(", ")}`);
|
|
521
529
|
const { context, rates } = model.figures;
|
|
@@ -38,10 +38,10 @@ const chipsOf = (model, now, previous = null) => Object.fromEntries((model.skill
|
|
|
38
38
|
}));
|
|
39
39
|
|
|
40
40
|
// The ambient loop runs while the card shows LitClaude at work, so motion itself says "active",
|
|
41
|
-
//
|
|
42
|
-
// does not restart on every new model.
|
|
41
|
+
// while the rewind look lingers after a brief and while YOUR TURN breathes; `at` is when the current
|
|
42
|
+
// run began, so the loop does not restart on every new model.
|
|
43
43
|
const ambientOf = (model, now, profile, previous = null) => {
|
|
44
|
-
const on = Boolean(profile.ambient) && model.visible && (!model.idle || model.rewind === true);
|
|
44
|
+
const on = Boolean(profile.ambient) && model.visible && (!model.idle || model.rewind === true || model.look === "turn");
|
|
45
45
|
return { on, at: on && previous?.on ? previous.at : now };
|
|
46
46
|
};
|
|
47
47
|
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
// (skills.mjs) and what Claude Code reports live (subagents, context and rate-limit usage). Pure: the mod calls these on each refresh and hands the result to the
|
|
3
3
|
// band's surface module, which only draws and animates it.
|
|
4
4
|
|
|
5
|
-
import { lookOf } from "./
|
|
5
|
+
import { lookOf } from "./looks.mjs";
|
|
6
6
|
import { AUTOLOOP_LIMITS, GATE_LIMITS } from "./state.mjs";
|
|
7
|
-
import { buildWorkflow } from "./workflow.mjs";
|
|
7
|
+
import { REVIEW_LANES, buildWorkflow } from "./workflow.mjs";
|
|
8
8
|
|
|
9
9
|
export const STALL_MS = 10 * 60 * 1000;
|
|
10
10
|
// An agent the host does not list, quiet this long with no call in flight, no longer counts as
|
|
11
11
|
// running: a crashed loop or a lost report must not hold the card at work for the rest of the
|
|
12
|
-
// session. One the host lists as live stays, however quiet; it is marked stalled instead
|
|
12
|
+
// session. One the host lists as live stays, however quiet; it is marked stalled instead, unless
|
|
13
|
+
// the host lists it idle: a teammate that finished its turn and waits for a message is not stuck.
|
|
13
14
|
export const AGENT_STALE_MS = 30 * 60 * 1000;
|
|
14
15
|
// The context warning starts this many points before the auto-handoff percent.
|
|
15
16
|
export const CONTEXT_LEAD = 5;
|
|
@@ -22,6 +23,7 @@ export const REWIND_LINGER_MS = 15 * 60 * 1000;
|
|
|
22
23
|
export const BREAK_MS = 30 * 60 * 1000;
|
|
23
24
|
|
|
24
25
|
const LIVE_AGENT = new Set(["running", "pending", "waiting", "idle"]);
|
|
26
|
+
const STALLABLE_AGENT = new Set(["running", "pending", "waiting"]);
|
|
25
27
|
const ENDED_AGENT = new Set(["completed", "failed", "killed"]);
|
|
26
28
|
const NONTERMINAL_GOAL = new Set(["active", "blocked", "review_blocked", "needs_user_decision"]);
|
|
27
29
|
const WORK_DISCIPLINES = new Set(["lit-loop", "litwork", "litgoal", "start-work", "native-workflow"]);
|
|
@@ -89,7 +91,7 @@ export const mergeSpawned = (listed, spawned, now) => {
|
|
|
89
91
|
|
|
90
92
|
export const stalledLanes = (agents, activity, now, thresholdMs = STALL_MS) =>
|
|
91
93
|
agents
|
|
92
|
-
.filter((agent) =>
|
|
94
|
+
.filter((agent) => STALLABLE_AGENT.has(agent.status) && Number.isFinite(activity.last[agent.id]) && now - activity.last[agent.id] > thresholdMs)
|
|
93
95
|
.map((agent) => ({ id: agent.id, name: laneName(agent), quietMs: now - activity.last[agent.id] }));
|
|
94
96
|
|
|
95
97
|
export const laneName = (agent) => String(agent.name || agent.description || agent.type || "agent").slice(0, 40);
|
|
@@ -98,8 +100,12 @@ export const laneName = (agent) => String(agent.name || agent.description || age
|
|
|
98
100
|
// leaves PARALLEL_ROWS for the lanes and tasks under it.
|
|
99
101
|
export const THREAD_ROWS = 4;
|
|
100
102
|
const PARALLEL_ROWS = 3;
|
|
101
|
-
// Another session of this project counts as live while its stack was written this recently
|
|
103
|
+
// Another session of this project counts as live while its stack was written this recently and
|
|
104
|
+
// SessionEnd has not marked it ended.
|
|
102
105
|
export const OTHER_SESSION_MS = 15 * 60 * 1000;
|
|
106
|
+
// A finished start-work (or any thread marked done) keeps its check mark this long after it
|
|
107
|
+
// finished, then leaves the card.
|
|
108
|
+
export const DONE_LINGER_MS = 60_000;
|
|
103
109
|
|
|
104
110
|
const countOrNull = (value) => (Number.isInteger(value) && value >= 0 ? value : null);
|
|
105
111
|
|
|
@@ -238,22 +244,59 @@ const frameCount = (frame, snapshot, mainList) => {
|
|
|
238
244
|
|
|
239
245
|
// A thread with no total carries what is known instead: its finished steps, how long it has run
|
|
240
246
|
// and its last step (knownFacts in rewind/gauge.mjs words them).
|
|
247
|
+
// A frame is finished when its record says so, or when it is a start-work, not paused, whose plan has
|
|
248
|
+
// every row checked; a paused one at k/k still waits (for a review to hand back, say). `doneAt` is
|
|
249
|
+
// when: the plan file's last change, else the record's or the frame's time.
|
|
241
250
|
const frameThread = (frame, index, snapshot, active, mainList = null, now = null, mainEntry = null) => {
|
|
242
251
|
const { done, total } = frameCount(frame, snapshot, active ? mainList : null);
|
|
243
252
|
const started = Number.isFinite(frame.at) ? frame.at : frame.record?.at;
|
|
253
|
+
const finished = Boolean(frame.record?.done) || (frame.skill === "start-work" && frame.status !== "paused" && total > 0 && done === total);
|
|
254
|
+
const doneAt = [frame.planAt, frame.record?.at, started].find(Number.isFinite) ?? null;
|
|
244
255
|
return {
|
|
245
256
|
key: `frame-${index}`,
|
|
246
257
|
name: frame.skill ?? frame.record?.family ?? "work",
|
|
247
258
|
stage: frame.record?.step ?? frame.record?.stage ?? null,
|
|
248
259
|
done,
|
|
249
260
|
total,
|
|
250
|
-
state:
|
|
261
|
+
state: finished ? "done" : frame.status === "paused" ? "paused" : frame.skill === "start-work" && snapshot.work?.status === "paused" ? "blocked" : "running",
|
|
262
|
+
doneAt: finished ? doneAt : null,
|
|
251
263
|
active,
|
|
252
264
|
steps: active && mainEntry ? mainEntry.steps : null,
|
|
253
265
|
last: active && mainEntry ? mainEntry.last ?? null : null,
|
|
254
266
|
elapsedMs: Number.isFinite(now) && Number.isFinite(started) ? Math.max(0, now - started) : null,
|
|
255
267
|
};
|
|
256
268
|
};
|
|
269
|
+
const lingering = (thread, now) => thread.state !== "done" || !Number.isFinite(thread.doneAt) || now - thread.doneAt <= DONE_LINGER_MS;
|
|
270
|
+
|
|
271
|
+
// Another session's row: its liveness record says running (`alive`), `idle` or `ended` (hidden);
|
|
272
|
+
// without one, a stack written within OTHER_SESSION_MS and not marked ended counts as running.
|
|
273
|
+
// A stack that moved after the record (a resumed session's first tool call) outranks it.
|
|
274
|
+
const otherState = (thread, liveness) => (liveness?.state === "idle" && thread.state === "running" ? "idle" : thread.state);
|
|
275
|
+
const currentLiveness = (liveness, stackAt) => (liveness && !(Number.isFinite(stackAt) && stackAt > liveness.at) ? liveness : null);
|
|
276
|
+
const seenAt = (other) => Math.max(Number.isFinite(other.at) ? other.at : -Infinity, Number.isFinite(other.liveness?.at) ? other.liveness.at : -Infinity);
|
|
277
|
+
// Running first, then idle, then the rest (paused, done), each newest first.
|
|
278
|
+
const STATE_ORDER = { running: 0, idle: 1 };
|
|
279
|
+
const runningFirst = (a, b) => (STATE_ORDER[a.state] ?? 2) - (STATE_ORDER[b.state] ?? 2) || b.seenAt - a.seenAt;
|
|
280
|
+
|
|
281
|
+
// herdr lanes of this project: sessions whose hooks ran in a herdr pane (their liveness record keeps
|
|
282
|
+
// the pane id), drawn as lanes named `<top skill or claude> · <pane>`. This session, and any session
|
|
283
|
+
// in this session's own pane, are never listed.
|
|
284
|
+
const herdrLanesOf = (snapshot, others, now) => {
|
|
285
|
+
const liveness = snapshot.workflow?.liveness ?? {};
|
|
286
|
+
const self = snapshot.workflow?.sessionId ?? null;
|
|
287
|
+
const ownPane = self ? liveness[self]?.herdrPane ?? null : null;
|
|
288
|
+
return Object.entries(liveness)
|
|
289
|
+
.filter(([id, entry]) => id !== self && entry.herdrPane && entry.herdrPane !== ownPane)
|
|
290
|
+
.map(([id, entry]) => {
|
|
291
|
+
const other = others.find((candidate) => candidate.sessionId === id);
|
|
292
|
+
const live = currentLiveness(entry, other?.at);
|
|
293
|
+
if (live?.state === "ended" || (!live && other?.ended) || now - Math.max(entry.at, other?.at ?? -Infinity) > OTHER_SESSION_MS) return null;
|
|
294
|
+
const top = other?.frames?.length ? frameThread(other.frames.at(-1), 0, {}, false, null, now) : { name: "claude", stage: null, done: null, total: null, state: "running", doneAt: null, active: false, elapsedMs: null };
|
|
295
|
+
return { ...top, key: `herdr-${entry.herdrPane}`, sessionId: id, name: `${top.name} · ${entry.herdrPane}`, state: otherState(top, live), seenAt: Math.max(entry.at, other?.at ?? -Infinity) };
|
|
296
|
+
})
|
|
297
|
+
.filter((thread) => thread && lingering(thread, now))
|
|
298
|
+
.sort(runningFirst);
|
|
299
|
+
};
|
|
257
300
|
|
|
258
301
|
// A lane's k/n: its own todo or task list, then the tasks a loop gave it by name; else no total,
|
|
259
302
|
// with the steps it has finished and its last one.
|
|
@@ -271,7 +314,8 @@ const laneCount = (entry, lists, name) => listProgress(entry) ?? ownedProgress(l
|
|
|
271
314
|
const threadsOf = ({ snapshot, lanes, tasks, lists, now, threadReserve }) => {
|
|
272
315
|
const frames = snapshot.workflow?.stack?.frames ?? [];
|
|
273
316
|
const mainList = listProgress(lists.main);
|
|
274
|
-
const chain = frames.map((frame, index) => frameThread(frame, index, snapshot, index === frames.length - 1, mainList, now, lists.main))
|
|
317
|
+
const chain = frames.map((frame, index) => frameThread(frame, index, snapshot, index === frames.length - 1, mainList, now, lists.main))
|
|
318
|
+
.filter((thread) => lingering(thread, now));
|
|
275
319
|
const laneThreads = lanes.map((lane, index) => ({
|
|
276
320
|
key: `lane-${lane.id ?? index}`,
|
|
277
321
|
name: lane.name,
|
|
@@ -283,23 +327,36 @@ const threadsOf = ({ snapshot, lanes, tasks, lists, now, threadReserve }) => {
|
|
|
283
327
|
}));
|
|
284
328
|
const taskThreads = tasks.map((task) => ({ key: `task-${task.id}`, name: task.name, stage: task.kind, done: null, total: null, state: "running", active: false, task: task.kind, elapsedMs: Number.isFinite(task.at) ? Math.max(0, now - task.at) : null }));
|
|
285
329
|
const parallel = [...laneThreads, ...taskThreads];
|
|
330
|
+
const herdrLanes = herdrLanesOf(snapshot, snapshot.workflow?.others ?? [], now);
|
|
331
|
+
const inHerdr = new Set(herdrLanes.map(({ sessionId }) => sessionId));
|
|
286
332
|
const others = (snapshot.workflow?.others ?? [])
|
|
287
|
-
.filter((other) =>
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
333
|
+
.filter((other) => {
|
|
334
|
+
const live = currentLiveness(other.liveness, other.at);
|
|
335
|
+
return (live ? live.state !== "ended" : !other.ended) && !inHerdr.has(other.sessionId) && now - seenAt(other) <= OTHER_SESSION_MS && other.frames?.length;
|
|
336
|
+
})
|
|
337
|
+
.map((other) => {
|
|
338
|
+
const thread = frameThread(other.frames.at(-1), 0, {}, false, null, now);
|
|
339
|
+
return { ...thread, key: `session-${other.id8}`, session: other.id8, state: otherState(thread, currentLiveness(other.liveness, other.at)), seenAt: seenAt(other) };
|
|
340
|
+
})
|
|
341
|
+
.filter((thread) => lingering(thread, now))
|
|
342
|
+
.sort(runningFirst);
|
|
343
|
+
const total = chain.length + parallel.length + herdrLanes.length + others.length;
|
|
344
|
+
// A lone own thread keeps the plain card; a herdr lane or another session always gets its row.
|
|
345
|
+
if (total < 2 && herdrLanes.length + others.length === 0) return null;
|
|
291
346
|
const room = Math.max(PARALLEL_ROWS, THREAD_ROWS - chain.length);
|
|
292
347
|
const keptLanes = parallel.slice(0, room);
|
|
293
|
-
const
|
|
348
|
+
const keptHerdr = herdrLanes.slice(0, Math.max(0, room - keptLanes.length));
|
|
349
|
+
const keptOthers = others.slice(0, Math.max(0, room - keptLanes.length - keptHerdr.length));
|
|
294
350
|
const fork = parallel.length >= 2 ? 1 : 0;
|
|
295
|
-
const needed = chain.length + keptLanes.length + keptOthers.length + fork;
|
|
351
|
+
const needed = chain.length + keptLanes.length + keptHerdr.length + keptOthers.length + fork;
|
|
296
352
|
return {
|
|
297
353
|
chain,
|
|
298
354
|
lanes: keptLanes,
|
|
355
|
+
herdrLanes: keptHerdr,
|
|
299
356
|
others: keptOthers,
|
|
300
357
|
laneCount: laneThreads.length,
|
|
301
358
|
taskCount: taskThreads.length,
|
|
302
|
-
more: total - chain.length - keptLanes.length - keptOthers.length,
|
|
359
|
+
more: total - chain.length - keptLanes.length - keptHerdr.length - keptOthers.length,
|
|
303
360
|
reserve: Math.max(needed, Number.isInteger(threadReserve) ? threadReserve : 0),
|
|
304
361
|
};
|
|
305
362
|
};
|
|
@@ -388,9 +445,22 @@ export const stepName = (tool) => {
|
|
|
388
445
|
* lit (the idle title), `git` the branch and `step` the live step (`{ name, at }`, the tool the
|
|
389
446
|
* main loop runs and since when). `threadReserve` is the previous model's `threads.reserve`,
|
|
390
447
|
* `lists` the loops' todo and task counts (noteLoopCall) and `tasks` the background tasks
|
|
391
|
-
* (noteBackgroundTask).
|
|
448
|
+
* (noteBackgroundTask). `turnStartedAt` is when the main loop's current turn began, `waiting`
|
|
449
|
+
* what the session waits on the user for (`{ reason }`, null while it does not).
|
|
392
450
|
*/
|
|
393
|
-
|
|
451
|
+
const versionParts = (version) => {
|
|
452
|
+
const match = typeof version === "string" ? /^(\d+)\.(\d+)\.(\d+)/u.exec(version) : null;
|
|
453
|
+
return match ? match.slice(1, 4).map(Number) : null;
|
|
454
|
+
};
|
|
455
|
+
/** The installed version when it is newer than the loaded one by `major.minor.patch`, else null. */
|
|
456
|
+
export const restartVersion = ({ loaded = null, installed = null } = {}) => {
|
|
457
|
+
const [have, want] = [versionParts(loaded), versionParts(installed)];
|
|
458
|
+
if (!have || !want) return null;
|
|
459
|
+
const order = want.map((part, i) => part - have[i]).find((diff) => diff !== 0) ?? 0;
|
|
460
|
+
return order > 0 ? installed.slice(0, 40) : null;
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
export const buildBandModel = ({ snapshot, agents = [], activity = EMPTY_ACTIVITY, usage = null, now, band = "always", isWorking = false, notice = null, completion = null, skills = [], lastDiscipline = null, git = null, step = null, threadReserve = 0, lists = EMPTY_LISTS, tasks = EMPTY_TASKS, turnStartedAt = null, waiting = null, versions = null }) => {
|
|
394
464
|
const discipline = snapshot.ignition?.discipline ?? null;
|
|
395
465
|
const progress = progressOf(snapshot);
|
|
396
466
|
const completing = completion !== null;
|
|
@@ -404,7 +474,8 @@ export const buildBandModel = ({ snapshot, agents = [], activity = EMPTY_ACTIVIT
|
|
|
404
474
|
id: agent.id,
|
|
405
475
|
name: laneName(agent),
|
|
406
476
|
status: stalledIds.has(agent.id) ? "stalled" : agent.status,
|
|
407
|
-
|
|
477
|
+
// An idle teammate's clock would count time it spent waiting, so it shows none.
|
|
478
|
+
elapsedMs: agent.status !== "idle" && Number.isFinite(activity.first[agent.id]) ? now - activity.first[agent.id] : null,
|
|
408
479
|
}))
|
|
409
480
|
: boulderLanes.slice(0, 6).map((lane) => ({ name: lane.type, status: "running", elapsedMs: Number.isFinite(lane.startedAt) ? now - lane.startedAt : null }));
|
|
410
481
|
const goal = snapshot.goal;
|
|
@@ -419,12 +490,16 @@ export const buildBandModel = ({ snapshot, agents = [], activity = EMPTY_ACTIVIT
|
|
|
419
490
|
const lit = skills.some(({ state }) => state === "current");
|
|
420
491
|
const workflow = buildWorkflow({ snapshot, skills, completion, now });
|
|
421
492
|
const title = discipline ?? skills.find(({ state }) => state === "current")?.id ?? lastDiscipline;
|
|
422
|
-
const
|
|
423
|
-
const
|
|
493
|
+
const look = selectLook({ snapshot, discipline, skills, workflow, completion, waiting, now, turnStartedAt });
|
|
494
|
+
const rewind = look === "rewind";
|
|
495
|
+
const visible = band === "off" ? false : band === "always" || active || lit || look !== null || notice !== null || completion !== null || warnings.length > 0;
|
|
424
496
|
return {
|
|
425
497
|
visible,
|
|
426
498
|
idle: !active && !lit,
|
|
499
|
+
restart: restartVersion(versions ?? undefined),
|
|
500
|
+
look,
|
|
427
501
|
rewind,
|
|
502
|
+
waiting: waiting?.reason ?? null,
|
|
428
503
|
away: !active && !lit && !rewind && skills.length > 0 && now - Math.max(...skills.map(({ at }) => (Number.isFinite(at) ? at : now))) >= BREAK_MS,
|
|
429
504
|
discipline,
|
|
430
505
|
title: workflow?.paused ? crumbOf(workflow.paused) : title,
|
|
@@ -447,6 +522,24 @@ export const buildBandModel = ({ snapshot, agents = [], activity = EMPTY_ACTIVIT
|
|
|
447
522
|
};
|
|
448
523
|
};
|
|
449
524
|
|
|
525
|
+
// The card's look (looks.mjs): a finish, then the session waiting on the user, then the look of the
|
|
526
|
+
// newest look-bearing skill this request ran. A Skill tool load never reaches the prompt hook, so a
|
|
527
|
+
// firing in this turn counts as the ignited discipline does; the next turn's start ends the one, the
|
|
528
|
+
// next prompt's ignition the other. The review look draws only the lanes review-work has open, and
|
|
529
|
+
// holds while a lane is still running: background lanes report in the turns their notifications start.
|
|
530
|
+
const selectLook = ({ snapshot, discipline, skills, workflow, completion, waiting, now, turnStartedAt }) => {
|
|
531
|
+
if (completion) return "done";
|
|
532
|
+
if (waiting) return "turn";
|
|
533
|
+
const fired = Number.isFinite(turnStartedAt) ? skills.filter(({ id, at }) => lookOf(id) && at >= turnStartedAt) : [];
|
|
534
|
+
const ignited = lookOf(discipline) && Number.isFinite(snapshot.ignition?.at) ? [{ id: discipline, at: snapshot.ignition.at }] : [];
|
|
535
|
+
const newest = [...fired, ...ignited].filter(({ at }) => now - at < REWIND_LINGER_MS).sort((a, b) => b.at - a.at)[0];
|
|
536
|
+
const look = newest ? lookOf(newest.id) : null;
|
|
537
|
+
const lanesOpen = workflow?.current >= 0 && workflow.verdicts?.length === REVIEW_LANES.length;
|
|
538
|
+
if (look === "review") return lanesOpen ? "review" : null;
|
|
539
|
+
if (!look && lanesOpen && workflow.verdicts.some(({ state }) => state === "running")) return "review";
|
|
540
|
+
return look;
|
|
541
|
+
};
|
|
542
|
+
|
|
450
543
|
// `lit-loop || > lit-brainstorm`, or `lit-loop || > … > lit-brainstorm` with a side between them.
|
|
451
544
|
const crumbOf = ({ parent, child, chain }) => `${parent} || > ${chain.length > 1 ? "… > " : ""}${child}`;
|
|
452
545
|
|
|
@@ -511,6 +604,49 @@ export const detectCompletion = (previous, next) => {
|
|
|
511
604
|
return null;
|
|
512
605
|
};
|
|
513
606
|
|
|
607
|
+
// Fenced code is quoted material, not the answer's own words.
|
|
608
|
+
const FENCE = /^\s*(```|~~~)/u;
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Why a main-loop answer leaves the session waiting on the user: `blocked` when a line reports
|
|
612
|
+
* `BLOCKED:`, `question` when its last paragraph ends in a question mark, else null.
|
|
613
|
+
*/
|
|
614
|
+
export const waitingReason = (answer) => {
|
|
615
|
+
let fenced = false;
|
|
616
|
+
const lines = String(answer ?? "").split(/\r?\n/u).filter((line) => {
|
|
617
|
+
if (FENCE.test(line)) {
|
|
618
|
+
fenced = !fenced;
|
|
619
|
+
return false;
|
|
620
|
+
}
|
|
621
|
+
return !fenced;
|
|
622
|
+
});
|
|
623
|
+
if (lines.some((line) => /^\s*(?:[-*>]\s*)?\**BLOCKED\**:/u.test(line))) return "blocked";
|
|
624
|
+
const last = lines.join("\n").trim().split(/\n\s*\n/u).at(-1) ?? "";
|
|
625
|
+
return /[??]["')\]*_`]*$/u.test(last.trim()) ? "question" : null;
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* The review finishing, by comparing the previous model with this one: every lane had not passed and
|
|
630
|
+
* now the main map is done. Plan and goal finishes come from the durable state (detectCompletion).
|
|
631
|
+
*/
|
|
632
|
+
export const workflowFinish = (previous, next) => {
|
|
633
|
+
const before = previous?.workflow;
|
|
634
|
+
const after = next?.workflow;
|
|
635
|
+
if (!before || !after || before.family !== "main" || after.family !== "main") return null;
|
|
636
|
+
const open = before.verdicts ?? before.paused?.verdicts;
|
|
637
|
+
const lanes = open?.length === REVIEW_LANES.length ? open : null;
|
|
638
|
+
if (!lanes || before.current < 0 || lanes.every(({ state }) => state === "pass") || after.current !== -1) return null;
|
|
639
|
+
return { id: "review", detail: `review · ${REVIEW_LANES.length}/${REVIEW_LANES.length} lanes passed` };
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
/** A release the main loop published: a successful `npm publish` that was not a dry run. */
|
|
643
|
+
export const releaseFinish = (e, outcome) => {
|
|
644
|
+
if (typeof e?.agentId === "string" || e?.tool !== "Bash" || typeof e.command !== "string") return null;
|
|
645
|
+
if (!/^\s*npm\s+publish\b/u.test(e.command) || /(?:^|\s)--dry-run\b/u.test(e.command)) return null;
|
|
646
|
+
if (!outcome || outcome.isError || outcome.deny !== undefined) return null;
|
|
647
|
+
return { id: `release:${e.command.trim()}`, detail: "released" };
|
|
648
|
+
};
|
|
649
|
+
|
|
514
650
|
/** The evidence pane: goal criteria, blockers, the litgoal timeline, lanes and gates. */
|
|
515
651
|
export const buildEvidenceModel = ({ snapshot, ledger = [], agents = [], activity = EMPTY_ACTIVITY, now, icons = null }) => {
|
|
516
652
|
const goal = snapshot.goal;
|
|
@@ -258,6 +258,8 @@ export const buildWorkflow = ({ snapshot, skills = [], completion = null, now })
|
|
|
258
258
|
const count = family !== "main" && countOf ? ` ${countOf.done}/${countOf.total}` : "";
|
|
259
259
|
at.label = `|| ${at.label}${count}`;
|
|
260
260
|
paused.count = countOf;
|
|
261
|
+
// The lanes stay with the paused map, undrawn, so the review finishing under the side still bursts.
|
|
262
|
+
paused.verdicts = verdicts;
|
|
261
263
|
if (!next && goalIsOpen(snapshot.goal)) next = plainText(snapshot.goal.criteria.find(({ status }) => status !== "pass")?.description);
|
|
262
264
|
return { family, stages, current, count: null, items: [`↳ ${paused.child}`, "back: lit continue"], verdicts: null, next, paused };
|
|
263
265
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Outside folders a plan's todos name must be granted before the work starts, so a lane never stops
|
|
2
|
+
// to ask the user for them. start-work reads `Scope roots:` lines with SCOPE_LINE; lit-plan's checks
|
|
3
|
+
// use uncoveredScopePaths to name each todo path no such line covers, with the line to paste.
|
|
4
|
+
import { realpathSync, statSync } from "node:fs";
|
|
5
|
+
import { homedir } from "node:os";
|
|
6
|
+
import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
7
|
+
|
|
8
|
+
import { planLinesOutsideFences } from "./plan-task-rows.mjs";
|
|
9
|
+
|
|
10
|
+
// `Scope roots: <path> (<action>, <action>)` lines in the plan widen the grants it starts with.
|
|
11
|
+
// Global, for `matchAll` only: `.test()` or `.exec()` on this shared object would carry `lastIndex`.
|
|
12
|
+
export const SCOPE_LINE = /^Scope roots?:[ \t]*(\S+)[ \t]*\(([a-z, -]+)\)[ \t]*$/gmu;
|
|
13
|
+
|
|
14
|
+
// An absolute path of two or more segments. A command quoted in an inline code span (it holds a
|
|
15
|
+
// space) is data, not a folder the work reaches, so only spans that are one path count.
|
|
16
|
+
const PATH_TOKEN = /(?<![\w.~\/-])\/[\w.@+%,=~-]+(?:\/[\w.@+%,=~-]+)+\/?/gu;
|
|
17
|
+
const pathMentions = (line) => line.replace(/`([^`]*)`/gu, (_, span) => (/\s/u.test(span.trim()) ? " " : ` ${span.trim()} `)).match(PATH_TOKEN) ?? [];
|
|
18
|
+
|
|
19
|
+
const covers = (root, path) => {
|
|
20
|
+
const inside = relative(root, path);
|
|
21
|
+
return inside === "" || (!inside.startsWith("..") && !isAbsolute(inside));
|
|
22
|
+
};
|
|
23
|
+
const real = (path) => {
|
|
24
|
+
try {
|
|
25
|
+
return realpathSync(path);
|
|
26
|
+
} catch {
|
|
27
|
+
return path;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const nearestDirectory = (path) => {
|
|
31
|
+
for (let at = path; ; at = dirname(at)) {
|
|
32
|
+
try {
|
|
33
|
+
if (statSync(at).isDirectory()) return at;
|
|
34
|
+
} catch {
|
|
35
|
+
// Not there yet; climb.
|
|
36
|
+
}
|
|
37
|
+
if (dirname(at) === at) return at;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Each absolute path under `## Todos` (before `## Final verification wave`, outside fences) that
|
|
43
|
+
* lies outside the project and outside every `Scope roots:` line, as `{ path, suggestion }` with
|
|
44
|
+
* the line to paste, or `{ path, problem }` when the nearest existing folder is too broad to grant.
|
|
45
|
+
* One entry per folder.
|
|
46
|
+
*/
|
|
47
|
+
export const uncoveredScopePaths = (planText, projectRoot) => {
|
|
48
|
+
const project = real(resolve(projectRoot));
|
|
49
|
+
const scoped = [...planText.matchAll(SCOPE_LINE)].map(([, path]) => real(isAbsolute(path) ? path : resolve(project, path)));
|
|
50
|
+
let inTodos = false;
|
|
51
|
+
const found = new Map();
|
|
52
|
+
for (const { line } of planLinesOutsideFences(planText)) {
|
|
53
|
+
const heading = line.trimEnd();
|
|
54
|
+
if (heading === "## Todos") inTodos = true;
|
|
55
|
+
else if (heading === "## Final verification wave") inTodos = false;
|
|
56
|
+
if (!inTodos) continue;
|
|
57
|
+
for (const mention of pathMentions(line)) {
|
|
58
|
+
const path = mention.replace(/[.,:;)]+$/u, "");
|
|
59
|
+
const directory = real(nearestDirectory(path));
|
|
60
|
+
if ([path, directory].some((candidate) => covers(project, real(candidate)) || scoped.some((root) => covers(root, real(candidate))))) continue;
|
|
61
|
+
if (found.has(directory)) continue;
|
|
62
|
+
// The filesystem root, a top-level folder or the home folder itself is never suggested.
|
|
63
|
+
const parent = dirname(directory);
|
|
64
|
+
const tooBroad = parent === dirname(parent) || directory === real(homedir());
|
|
65
|
+
found.set(directory, tooBroad
|
|
66
|
+
? { path, problem: `${path} is outside the project; name a narrower existing folder on a Scope roots line` }
|
|
67
|
+
: { path, suggestion: `Scope roots: ${directory} (read)` });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return [...found.values()];
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const describeScopePath = (entry) => entry.suggestion
|
|
74
|
+
? `${entry.path} is outside the project and no Scope roots line covers it; add: ${entry.suggestion}`
|
|
75
|
+
: entry.problem;
|
|
76
|
+
|