@litfamily/litclaude 1.0.38 → 1.0.40
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 +41 -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 +11 -6
- package/package.json +1 -1
- package/plugins/litclaude/.claude-plugin/plugin.json +1 -1
- package/plugins/litclaude/bin/litclaude-hook.js +31 -13
- package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
- package/plugins/litclaude/commands/lit-adhd.md +12 -8
- package/plugins/litclaude/commands/lit-rewind.md +12 -8
- package/plugins/litclaude/lib/canonical-skill-resources.mjs +26 -25
- package/plugins/litclaude/lib/interface-probe-gate.mjs +4 -5
- package/plugins/litclaude/lib/lit-plan-persistence.mjs +4 -5
- package/plugins/litclaude/lib/litgoal/autoloop.mjs +4 -5
- package/plugins/litclaude/lib/litgoal/cli.mjs +4 -5
- package/plugins/litclaude/lib/litgoal/ledger.mjs +4 -5
- package/plugins/litclaude/lib/litgoal/state.mjs +4 -6
- package/plugins/litclaude/lib/mod/frame.mjs +87 -20
- package/plugins/litclaude/lib/mod/svg-card.mjs +64 -22
- package/plugins/litclaude/lib/mod/timeline.mjs +4 -3
- package/plugins/litclaude/lib/mod/view.mjs +53 -13
- package/plugins/litclaude/lib/motion-render-gate.mjs +4 -5
- package/plugins/litclaude/lib/project-state-root.mjs +44 -2
- package/plugins/litclaude/lib/rewind/brief.mjs +373 -0
- package/plugins/litclaude/lib/rewind/collect.mjs +55 -25
- package/plugins/litclaude/lib/rewind/gauge.mjs +28 -8
- package/plugins/litclaude/lib/rewind/next-step.mjs +4 -5
- package/plugins/litclaude/lib/rewind/redact.mjs +28 -8
- package/plugins/litclaude/lib/rewind/suggest.mjs +56 -0
- package/plugins/litclaude/lib/rewind/transcripts.mjs +18 -3
- package/plugins/litclaude/lib/start-work-lifecycle.mjs +6 -9
- package/plugins/litclaude/lib/workflow-stack.mjs +4 -5
- package/plugins/litclaude/skills/frontend-ui-ux/SKILL.md +8 -1
- package/plugins/litclaude/skills/frontend-ui-ux/references/production-interview.md +1 -1
- package/plugins/litclaude/skills/lit-adhd/SKILL.md +45 -28
- package/plugins/litclaude/skills/lit-adhd/references/card-examples.md +114 -58
- package/plugins/litclaude/skills/lit-adhd/scripts/rewind.mjs +1 -1
- package/plugins/litclaude/skills/lit-diagram-drawer/SKILL.md +12 -1
- package/plugins/litclaude/skills/lit-docx/SKILL.md +6 -1
- package/plugins/litclaude/skills/lit-docx/references/direction-step.md +8 -4
- package/plugins/litclaude/skills/lit-handoff/SKILL.md +1 -0
- package/plugins/litclaude/skills/lit-hijack/references/capture-and-provenance.md +7 -0
- package/plugins/litclaude/skills/lit-hijack/references/distil-and-licence.md +5 -0
- package/plugins/litclaude/skills/lit-hijack/scripts/hijack.mjs +87 -15
- package/plugins/litclaude/skills/lit-pptx/SKILL.md +6 -1
- package/plugins/litclaude/skills/lit-pptx/references/direction-step.md +4 -2
- package/plugins/litclaude/skills/lit-recap/SKILL.md +1 -0
- package/plugins/litclaude/skills/lit-schematic/SKILL.md +12 -1
- package/plugins/litclaude/skills/lit-typographic-motion/SKILL.md +10 -6
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/assets.mjs +80 -13
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-serve.mjs +13 -3
- package/plugins/litclaude/skills/lit-typographic-motion/references/treatment.md +9 -7
- package/plugins/litclaude/skills/readme-studio/SKILL.md +10 -0
- package/plugins/litclaude/skills/readme-studio/references/production-interview.md +2 -0
|
@@ -11,6 +11,7 @@ import { basename, join, resolve } from "node:path";
|
|
|
11
11
|
|
|
12
12
|
import { parsePlanTaskRows } from "../plan-task-rows.mjs";
|
|
13
13
|
import { resolveProjectStateRoot } from "../project-state-root.mjs";
|
|
14
|
+
import { renderBrief } from "./brief.mjs";
|
|
14
15
|
import { aggregateProgress, clipToWidth, displayWidth, progressOf } from "./gauge.mjs";
|
|
15
16
|
import { chooseNextStep, writeNextStep } from "./next-step.mjs";
|
|
16
17
|
import { makeRedactor } from "./redact.mjs";
|
|
@@ -78,6 +79,16 @@ const worktreesOf = (cwd, exec) => {
|
|
|
78
79
|
}
|
|
79
80
|
};
|
|
80
81
|
|
|
82
|
+
// A plan scaffold nobody filled in: a row that is still a `<placeholder>`, or every row the same.
|
|
83
|
+
const isTemplate = (rows) => rows.some((row) => /<[^<>]{1,40}>/u.test(row.text)) || (rows.length > 1 && new Set(rows.map((row) => row.text.trim())).size === 1);
|
|
84
|
+
const mtimeOf = (path) => {
|
|
85
|
+
try {
|
|
86
|
+
return lstatSync(path).mtimeMs;
|
|
87
|
+
} catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
81
92
|
const plansIn = (root, budget, redact, local) => {
|
|
82
93
|
const list = entries(join(root, "plans"));
|
|
83
94
|
if (!list) return null;
|
|
@@ -85,7 +96,7 @@ const plansIn = (root, budget, redact, local) => {
|
|
|
85
96
|
const text = readSmallFile(join(root, "plans", entry.name), budget);
|
|
86
97
|
if (text === null) return [];
|
|
87
98
|
const rows = parsePlanTaskRows(text);
|
|
88
|
-
if (!rows.length) return [];
|
|
99
|
+
if (!rows.length || isTemplate(rows)) return [];
|
|
89
100
|
const open = rows.filter((row) => !row.checked);
|
|
90
101
|
if (!open.length) return [];
|
|
91
102
|
const done = rows.length - open.length;
|
|
@@ -93,9 +104,10 @@ const plansIn = (root, budget, redact, local) => {
|
|
|
93
104
|
worktree: redact(root),
|
|
94
105
|
plan: `plans/${entry.name}`,
|
|
95
106
|
local,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
107
|
+
changedMs: mtimeOf(join(root, "plans", entry.name)),
|
|
108
|
+
rows: rows.map((row) => ({ checked: row.checked, title: clipToWidth(redact(row.text), NAME_MAX) })),
|
|
109
|
+
current: clipToWidth(redact(open[0].text), NAME_MAX),
|
|
110
|
+
progress: progressOf(done, rows.length, open.map((row) => clipToWidth(redact(row.text), NAME_MAX))),
|
|
99
111
|
}];
|
|
100
112
|
});
|
|
101
113
|
};
|
|
@@ -104,11 +116,11 @@ const litgoalOf = (root, budget, redact) => {
|
|
|
104
116
|
const goals = readJson(join(root, ".litclaude", "litgoal", "goals.json"), budget);
|
|
105
117
|
if (!goals || !Array.isArray(goals.criteria)) return null;
|
|
106
118
|
const passed = goals.criteria.filter((criterion) => criterion?.status === "passed");
|
|
107
|
-
const remaining = goals.criteria.filter((criterion) => criterion?.status !== "passed").map((criterion) => redact(
|
|
119
|
+
const remaining = goals.criteria.filter((criterion) => criterion?.status !== "passed").map((criterion) => clipToWidth(redact(String(criterion?.description ?? criterion?.id ?? "unknown")), NAME_MAX));
|
|
108
120
|
return {
|
|
109
121
|
worktree: redact(root),
|
|
110
122
|
status: typeof goals.status === "string" ? goals.status : "unknown",
|
|
111
|
-
objective: redact(
|
|
123
|
+
objective: clipToWidth(redact(String(goals.objective ?? "unknown").split("\n")[0]), 120),
|
|
112
124
|
progress: progressOf(passed.length, goals.criteria.length, remaining),
|
|
113
125
|
};
|
|
114
126
|
};
|
|
@@ -117,7 +129,7 @@ const handoffsOf = (root, budget, redact) => (entries(root) ?? [])
|
|
|
117
129
|
.filter((entry) => entry.isFile() && /^HANDOFF.*\.md$/u.test(entry.name))
|
|
118
130
|
.map((entry) => {
|
|
119
131
|
const text = readSmallFile(join(root, entry.name), budget) ?? "";
|
|
120
|
-
const headings = text.split("\n").slice(0, 40).filter((line) => /^#{1,3} /u.test(line)).map((line) => redact(
|
|
132
|
+
const headings = text.split("\n").slice(0, 40).filter((line) => /^#{1,3} /u.test(line)).map((line) => clipToWidth(redact(line), 100));
|
|
121
133
|
return { worktree: redact(root), file: entry.name, headings };
|
|
122
134
|
});
|
|
123
135
|
|
|
@@ -128,7 +140,7 @@ const commitsOf = (root, sinceMs, now, exec, redact) => {
|
|
|
128
140
|
const out = exec("git", ["log", `--since=${since}`, "--max-count=20", "--format=%H%x09%cI%x09%s"], { cwd: root, timeout: GIT_TIMEOUT_MS });
|
|
129
141
|
return out.split("\n").filter(Boolean).map((line) => {
|
|
130
142
|
const [hash, at, ...subject] = line.split("\t");
|
|
131
|
-
return { worktree: redact(root), branch: redact(branch), hash: hash.slice(0, 7), at, atMs: Date.parse(at), subject: redact(
|
|
143
|
+
return { worktree: redact(root), branch: redact(branch), hash: hash.slice(0, 7), at, atMs: Date.parse(at), subject: clipToWidth(redact(subject.join("\t")), 100) };
|
|
132
144
|
});
|
|
133
145
|
} catch {
|
|
134
146
|
return null;
|
|
@@ -151,7 +163,7 @@ const stacksOf = (root, budget, redact) => {
|
|
|
151
163
|
role: frame.role === "spine" ? "spine" : "side",
|
|
152
164
|
status: frame.status === "paused" ? "paused" : "active",
|
|
153
165
|
at: typeof frame.at === "string" ? frame.at : "unknown",
|
|
154
|
-
progress: progressOf(frame.n, frame.total, Array.isArray(frame.remaining) ? frame.remaining.map((name) => redact(
|
|
166
|
+
progress: progressOf(frame.n, frame.total, Array.isArray(frame.remaining) ? frame.remaining.map((name) => clipToWidth(redact(String(name)), NAME_MAX)) : undefined),
|
|
155
167
|
}));
|
|
156
168
|
});
|
|
157
169
|
};
|
|
@@ -166,8 +178,8 @@ const startWorkOf = (root, budget, redact) => {
|
|
|
166
178
|
const rows = planText === null ? [] : parsePlanTaskRows(planText);
|
|
167
179
|
const open = rows.filter((row) => !row.checked);
|
|
168
180
|
const progress = rows.length
|
|
169
|
-
? progressOf(rows.length - open.length, rows.length, open.map((row) => redact(
|
|
170
|
-
: progressOf(work.progress?.checked, work.progress?.total, work.progress?.next_task ? [redact(
|
|
181
|
+
? progressOf(rows.length - open.length, rows.length, open.map((row) => clipToWidth(redact(row.text), NAME_MAX)))
|
|
182
|
+
: progressOf(work.progress?.checked, work.progress?.total, work.progress?.next_task ? [clipToWidth(redact(work.progress.next_task), NAME_MAX)] : undefined);
|
|
171
183
|
return [{
|
|
172
184
|
worktree: redact(root),
|
|
173
185
|
workId: work.work_id,
|
|
@@ -184,7 +196,7 @@ const herdrOf = (env, exec, redact) => {
|
|
|
184
196
|
if (env.HERDR_ENV !== "1") return { status: "unknown", agents: [] };
|
|
185
197
|
try {
|
|
186
198
|
const out = exec("herdr", ["agent", "list"], { timeout: HERDR_TIMEOUT_MS });
|
|
187
|
-
return { status: "ok", agents: out.split("\n").filter((line) => line.trim()).slice(0, 20).map((line) => redact(
|
|
199
|
+
return { status: "ok", agents: out.split("\n").filter((line) => line.trim()).slice(0, 20).map((line) => clipToWidth(redact(line.trim()), 120)) };
|
|
188
200
|
} catch {
|
|
189
201
|
return { status: "unknown", agents: [] };
|
|
190
202
|
}
|
|
@@ -218,6 +230,7 @@ export const collectRewind = ({
|
|
|
218
230
|
const listed = here ? null : worktreesOf(start, exec);
|
|
219
231
|
const roots = [...new Set([start, ...(here ? [] : listed ?? [stateRoot])])];
|
|
220
232
|
|
|
233
|
+
const rootSet = new Set(roots.map((root) => resolve(root).normalize("NFC")));
|
|
221
234
|
const transcripts = findTranscripts(env.CLAUDE_CONFIG_DIR || join(home, ".claude"), roots);
|
|
222
235
|
const sessions = [];
|
|
223
236
|
for (const file of transcripts.files) {
|
|
@@ -225,7 +238,10 @@ export const collectRewind = ({
|
|
|
225
238
|
const lines = readTranscriptLines(file, budget);
|
|
226
239
|
const session = lines ? sessionRecord(lines, { redact, now }) : null;
|
|
227
240
|
if (!session || (session.lastMs !== null && now - session.lastMs > sinceMs)) continue;
|
|
228
|
-
|
|
241
|
+
// Claude's folder slug maps every non-alphanumeric to `-`, so `client_a` and `client-a` share one
|
|
242
|
+
// folder; a session counts only when the cwd it recorded is one of the folders asked about.
|
|
243
|
+
const recorded = session.cwd ? resolve(session.cwd).normalize("NFC") : null;
|
|
244
|
+
if (here ? recorded && recorded !== start.normalize("NFC") : !recorded || !rootSet.has(recorded)) continue;
|
|
229
245
|
sessions.push(session);
|
|
230
246
|
}
|
|
231
247
|
|
|
@@ -266,9 +282,12 @@ export const collectRewind = ({
|
|
|
266
282
|
}
|
|
267
283
|
sessions.sort((a, b) => statusRank[a.status] - statusRank[b.status] || (b.lastMs ?? 0) - (a.lastMs ?? 0));
|
|
268
284
|
|
|
269
|
-
//
|
|
270
|
-
//
|
|
271
|
-
|
|
285
|
+
// This worktree's open plans and the ones another worktree touched inside the window are listed,
|
|
286
|
+
// this one's first, then the most recently changed, up to a short cap; a stale plan elsewhere is
|
|
287
|
+
// left out entirely. The roadmap gauge counts this worktree only, since a sum over unrelated
|
|
288
|
+
// branches measures nothing.
|
|
289
|
+
const recent = (plan) => plan.local || (plan.changedMs !== null && now - plan.changedMs <= sinceMs);
|
|
290
|
+
const orderedPlans = (plans ?? []).filter(recent).sort((a, b) => Number(b.local) - Number(a.local) || (b.changedMs ?? 0) - (a.changedMs ?? 0));
|
|
272
291
|
const shownPlans = orderedPlans.slice(0, PLAN_LIMIT);
|
|
273
292
|
const localGoals = (litgoal ?? []).filter((goal) => goal.local);
|
|
274
293
|
const roadmapItems = [...orderedPlans.filter((plan) => plan.local).map((plan) => plan.progress), ...localGoals.map((goal) => goal.progress)];
|
|
@@ -296,7 +315,8 @@ export const collectRewind = ({
|
|
|
296
315
|
roadmap: {
|
|
297
316
|
plans: shownPlans,
|
|
298
317
|
plansOmitted: orderedPlans.length - shownPlans.length,
|
|
299
|
-
|
|
318
|
+
// Another worktree's finished objective is history, not roadmap.
|
|
319
|
+
litgoal: (litgoal ?? []).filter((goal) => goal.local || goal.status !== "complete"),
|
|
300
320
|
progress: roadmapItems.length ? aggregateProgress(roadmapItems) : progressOf(null, null),
|
|
301
321
|
},
|
|
302
322
|
workflows: (workflows ?? []).map((frame) => ({ ...frame, self: Boolean(sessionId) && frame.sessionId === sessionId })),
|
|
@@ -333,37 +353,45 @@ const remainingLine = (names, width) => {
|
|
|
333
353
|
return out;
|
|
334
354
|
};
|
|
335
355
|
|
|
356
|
+
// A gauge with its leading space, or nothing: an unknown total has no gauge to print.
|
|
357
|
+
const shown = (progress) => (progress?.gauge ? ` ${progress.gauge}` : "");
|
|
358
|
+
|
|
336
359
|
/** Plain-text rendering: every gauge with its remaining names under it, clipped to `width`. */
|
|
337
360
|
export const renderRewind = (data, width = 100) => {
|
|
338
361
|
const out = [];
|
|
339
362
|
const push = (text) => out.push(line(text, width));
|
|
340
363
|
push(`lit-adhd: ${data.summary.sessions} session(s), ${data.summary.waitingOnUser} waiting on you, ${data.summary.active} active`);
|
|
341
|
-
push(`roadmap here
|
|
364
|
+
push(`roadmap here${shown(data.roadmap.progress)}`);
|
|
342
365
|
for (const plan of data.roadmap.plans) {
|
|
343
|
-
push(` ${plan.local ? "" : `${basename(plan.worktree)}: `}${plan.plan}
|
|
366
|
+
push(` ${plan.local ? "" : `${basename(plan.worktree)}: `}${plan.plan}${shown(plan.progress)} now: ${plan.current}`);
|
|
344
367
|
const left = remainingLine(plan.progress.remaining, width);
|
|
345
368
|
if (left) push(` ${left}`);
|
|
346
369
|
}
|
|
347
370
|
if (data.roadmap.plansOmitted) push(` …(+${data.roadmap.plansOmitted} more open plans)`);
|
|
348
|
-
for (const goal of data.roadmap.litgoal) push(` litgoal
|
|
371
|
+
for (const goal of data.roadmap.litgoal) push(` litgoal${shown(goal.progress)} ${goal.objective}`);
|
|
349
372
|
for (const session of data.sessions) {
|
|
350
|
-
push(`${session.id8} ${session.status}
|
|
373
|
+
push(`${session.id8} ${session.status}${shown(session.progress)} ${session.title}`);
|
|
351
374
|
const left = remainingLine(session.progress.remaining, width);
|
|
352
375
|
if (left) push(left);
|
|
353
376
|
}
|
|
354
|
-
for (const frame of data.workflows) push(` ${frame.id8} ${frame.skill} ${frame.stage} ${frame.status}
|
|
377
|
+
for (const frame of data.workflows) push(` ${frame.id8} ${frame.skill} ${frame.stage} ${frame.status}${shown(frame.progress)}`);
|
|
355
378
|
push(`next: ${data.next.kind}${data.next.say ? ` (say "${data.next.say}")` : ""}`);
|
|
356
379
|
const unknown = Object.entries(data.sources).filter(([, status]) => status !== "ok").map(([name]) => name);
|
|
357
380
|
if (unknown.length) push(`unknown: ${unknown.join(", ")}`);
|
|
358
381
|
return `${out.join("\n")}\n`;
|
|
359
382
|
};
|
|
360
383
|
|
|
361
|
-
/**
|
|
384
|
+
/**
|
|
385
|
+
* `litclaude-ai rewind [--brief [--lang ko|en] | --json] [--here] [--since 7d] [--max 12] [--session <id>] [--width N]`.
|
|
386
|
+
* `--brief` prints the Markdown brief the lit-adhd skill copies; `--json` the data under it.
|
|
387
|
+
*/
|
|
362
388
|
export const runRewindCli = (args, cwd = process.cwd(), { env = process.env, stdout = process.stdout, stderr = process.stderr } = {}) => {
|
|
363
389
|
const options = { cwd, env, here: false, since: DEFAULT_SINCE, max: DEFAULT_MAX, sessionId: env.CLAUDE_CODE_SESSION_ID || null };
|
|
364
390
|
let json = false;
|
|
391
|
+
let brief = false;
|
|
392
|
+
let lang = "en";
|
|
365
393
|
let width = Number(stdout.columns) || 100;
|
|
366
|
-
const usage = "Usage: litclaude-ai rewind [--json] [--here] [--since 7d] [--max 12] [--session <id>] [--width N]";
|
|
394
|
+
const usage = "Usage: litclaude-ai rewind [--brief [--lang ko|en] | --json] [--here] [--since 7d] [--max 12] [--session <id>] [--width N]";
|
|
367
395
|
if (args.some((arg) => arg === "--help" || arg === "-h")) {
|
|
368
396
|
stdout.write(`${usage}\n`);
|
|
369
397
|
return 0;
|
|
@@ -371,6 +399,8 @@ export const runRewindCli = (args, cwd = process.cwd(), { env = process.env, std
|
|
|
371
399
|
for (let index = 0; index < args.length; index += 1) {
|
|
372
400
|
const arg = args[index];
|
|
373
401
|
if (arg === "--json") json = true;
|
|
402
|
+
else if (arg === "--brief") brief = true;
|
|
403
|
+
else if (arg === "--lang" && ["ko", "en"].includes(args[index + 1])) lang = args[++index];
|
|
374
404
|
else if (arg === "--here") options.here = true;
|
|
375
405
|
else if (arg === "--since" && parseSince(args[index + 1])) options.since = args[++index];
|
|
376
406
|
else if (arg === "--max" && /^\d{1,2}$/u.test(args[index + 1] ?? "")) options.max = Number(args[++index]);
|
|
@@ -382,6 +412,6 @@ export const runRewindCli = (args, cwd = process.cwd(), { env = process.env, std
|
|
|
382
412
|
}
|
|
383
413
|
}
|
|
384
414
|
const data = collectRewind(options);
|
|
385
|
-
stdout.write(json ? `${JSON.stringify(data, null, 2)}\n` : renderRewind(data, width));
|
|
415
|
+
stdout.write(json ? `${JSON.stringify(data, null, 2)}\n` : brief ? renderBrief(data, { lang }) : renderRewind(data, width));
|
|
386
416
|
return 0;
|
|
387
417
|
};
|
|
@@ -1,21 +1,41 @@
|
|
|
1
|
-
// Progress gauges for the lit-adhd brief (plans/lit-adhd.md D9). Code draws them so
|
|
2
|
-
// copies them and never invents its own: `[▉▉▉░░] 3/5`, one cell per item up to ten, scaled
|
|
3
|
-
// cells above that
|
|
1
|
+
// Progress gauges for the lit-adhd brief and the LIT card (plans/lit-adhd.md D9). Code draws them so
|
|
2
|
+
// the model copies them and never invents its own: `[▉▉▉░░] 3/5`, one cell per item up to ten, scaled
|
|
3
|
+
// to ten cells above that. A gauge needs two real numbers; with either missing there is no gauge, and
|
|
4
|
+
// the reader gets what is known in words instead (knownFacts).
|
|
4
5
|
|
|
5
6
|
const MAX_CELLS = 10;
|
|
6
7
|
const known = (value) => Number.isInteger(value) && value >= 0;
|
|
7
8
|
|
|
8
|
-
/** `[▉▉▉░░] 3/5
|
|
9
|
+
/** `[▉▉▉░░] 3/5`, or null unless both the count and a total above zero are known. */
|
|
9
10
|
export const gauge = (done, total) => {
|
|
10
|
-
if (!known(total)
|
|
11
|
-
const k =
|
|
11
|
+
if (!known(total) || total === 0 || !known(done)) return null;
|
|
12
|
+
const k = Math.min(done, total);
|
|
12
13
|
const cells = Math.min(total, MAX_CELLS);
|
|
13
14
|
let filled = k;
|
|
14
15
|
if (total > MAX_CELLS) filled = k === total ? MAX_CELLS : k === 0 ? 0 : Math.min(MAX_CELLS - 1, Math.max(1, Math.floor((k * MAX_CELLS) / total)));
|
|
15
16
|
return `[${"▉".repeat(filled)}${"░".repeat(cells - filled)}] ${k}/${total}`;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
const duration = (ms) => {
|
|
20
|
+
const seconds = Math.max(0, Math.round(ms / 1000));
|
|
21
|
+
if (seconds < 60) return `${seconds}s`;
|
|
22
|
+
const minutes = Math.floor(seconds / 60);
|
|
23
|
+
if (minutes < 60) return `${minutes}m`;
|
|
24
|
+
const hours = Math.floor(minutes / 60);
|
|
25
|
+
return minutes % 60 ? `${hours}h ${minutes % 60}m` : `${hours}h`;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* What is known of a thread whose total is not: `12 steps · 4m · last: Edit README.md`, or with no
|
|
30
|
+
* steps `running 4m` (`paused 4m`, …, by `state`), or the state word alone.
|
|
31
|
+
*/
|
|
32
|
+
export const knownFacts = ({ steps = null, elapsedMs = null, last = null, state = "running" } = {}) => {
|
|
33
|
+
const time = Number.isFinite(elapsedMs) && elapsedMs >= 0 ? duration(elapsedMs) : null;
|
|
34
|
+
if (!(known(steps) && steps > 0)) return time ? `${state} ${time}` : state;
|
|
35
|
+
return [`${steps} ${steps === 1 ? "step" : "steps"}`, time, last ? `last: ${last}` : null].filter(Boolean).join(" · ");
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** `{done, total, gauge, remaining}`; `gauge` is null without two real numbers, `remaining` as recorded or `["unknown"]`. */
|
|
19
39
|
export const progressOf = (done, total, remaining) => ({
|
|
20
40
|
done: known(done) ? done : null,
|
|
21
41
|
total: known(total) ? total : null,
|
|
@@ -23,7 +43,7 @@ export const progressOf = (done, total, remaining) => ({
|
|
|
23
43
|
remaining: Array.isArray(remaining) && remaining.length ? remaining : known(total) && known(done) && done >= total ? [] : ["unknown"],
|
|
24
44
|
});
|
|
25
45
|
|
|
26
|
-
/** One gauge over several: the sum of known totals, or
|
|
46
|
+
/** One gauge over several: the sum of known totals, or no gauge when any total is unknown. */
|
|
27
47
|
export const aggregateProgress = (items) => {
|
|
28
48
|
const done = items.reduce((sum, item) => sum + (known(item.done) ? item.done : 0), 0);
|
|
29
49
|
const total = items.every((item) => known(item.total)) ? items.reduce((sum, item) => sum + item.total, 0) : null;
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
// 4. a single open plan with no work running -> start-plan (`/litclaude:start-work <plan>`)
|
|
7
7
|
// 5. otherwise -> none
|
|
8
8
|
|
|
9
|
-
import { closeSync, constants, fstatSync,
|
|
9
|
+
import { closeSync, constants, fstatSync, openSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
10
10
|
import { dirname, join } from "node:path";
|
|
11
11
|
|
|
12
12
|
import { ignitionFileName } from "../mod/state.mjs";
|
|
13
|
-
import {
|
|
13
|
+
import { requireStateDir, STATE_WRITE_FLAG } from "../project-state-root.mjs";
|
|
14
14
|
|
|
15
15
|
export const chooseNextStep = (data, sessionId) => {
|
|
16
16
|
const ownStack = data.workflows.find((frame) => frame.sessionId === sessionId && frame.role === "spine" && frame.status === "paused");
|
|
@@ -36,10 +36,9 @@ export const nextStepPath = (stateRoot, sessionId) => join(stateRoot, ".litclaud
|
|
|
36
36
|
/** Writes `{kind, target, at}` for this session, whole, through a temporary file. */
|
|
37
37
|
export const writeNextStep = (stateRoot, sessionId, step, now = new Date()) => {
|
|
38
38
|
const path = nextStepPath(stateRoot, sessionId);
|
|
39
|
-
|
|
40
|
-
ensureStateDirIgnored(path);
|
|
39
|
+
requireStateDir(dirname(path));
|
|
41
40
|
const staging = `${path}.${process.pid}.tmp`;
|
|
42
|
-
writeFileSync(staging, `${JSON.stringify({ kind: step.kind, target: step.target, at: now.toISOString() })}\n
|
|
41
|
+
writeFileSync(staging, `${JSON.stringify({ kind: step.kind, target: step.target, at: now.toISOString() })}\n`, { flag: STATE_WRITE_FLAG });
|
|
43
42
|
renameSync(staging, path);
|
|
44
43
|
return path;
|
|
45
44
|
};
|
|
@@ -1,22 +1,40 @@
|
|
|
1
|
-
// Redaction for every string the lit-adhd collector emits.
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
1
|
+
// Redaction for every string the lit-adhd collector emits. Terminal escape sequences, control and
|
|
2
|
+
// format characters go first, so neither an OSC link in a commit subject nor a zero-width space
|
|
3
|
+
// inside a key survives. Credential shapes, webhook URLs and URI userinfo come next; `NAME=value`
|
|
4
|
+
// and JSON `"name": "value"` pairs with a secret-like name lose their value; any substring equal to
|
|
5
|
+
// a current environment value of 8+ characters is replaced (compared here, never printed); the home
|
|
6
|
+
// directory becomes `~`. Path-shaped and locale/terminal values are not credentials and stay, or
|
|
7
|
+
// every path in the brief would be blanked; a URL is kept only when it is a bare origin. Callers
|
|
8
|
+
// redact the whole text and clip afterwards, so a clip cannot cut a secret below its shape.
|
|
6
9
|
|
|
7
10
|
import { SECRET_SHAPE_PATTERNS, URI_USERINFO_PATTERN } from "../secret-shapes.mjs";
|
|
8
11
|
|
|
9
12
|
const MASK = "[redacted]";
|
|
10
|
-
const SECRET_NAME = /KEY|TOKEN|SECRET|PASS|AUTH|COOKIE/iu;
|
|
13
|
+
const SECRET_NAME = /KEY|TOKEN|SECRET|PASS|AUTH|COOKIE|WEBHOOK/iu;
|
|
11
14
|
const ASSIGNMENT = /\b([A-Za-z_][A-Za-z0-9_]*)=("[^"]*"|'[^']*'|[^\s"'`]+)/gu;
|
|
15
|
+
const JSON_PAIR = /"([A-Za-z_][A-Za-z0-9_-]*)"(\s*:\s*)"(?:[^"\\]|\\.)*"/gu;
|
|
16
|
+
const WEBHOOK = /\bhttps?:\/\/(?:hooks\.slack\.com\/(?:services|workflows|triggers)|(?:[a-z0-9-]+\.)?discord(?:app)?\.com\/api\/webhooks|[a-z0-9-]+\.webhook\.office\.com|outlook\.office\.com\/webhook)\/[^\s"'`<>]+/giu;
|
|
17
|
+
// CSI and OSC sequences whole, then any other C0/C1 control (tab and newline stay) and format character.
|
|
18
|
+
const TERMINAL_SEQUENCE = /\u001b\[[0-?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)?|\u009b[0-?]*[ -/]*[@-~]|\u009d[^\u0007\u001b]*(?:\u0007|\u001b\\)?|\u001b[@-_]?/gu;
|
|
19
|
+
const CONTROL = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f\p{Cf}]/gu;
|
|
20
|
+
export const stripControls = (text) => String(text).replace(TERMINAL_SEQUENCE, "").replace(CONTROL, "");
|
|
12
21
|
const PLAIN_ENV_NAMES = /^(?:PATH|HOME|PWD|OLDPWD|SHELL|USER|LOGNAME|LANG|LANGUAGE|TERM|TERM_PROGRAM|TERM_PROGRAM_VERSION|COLORTERM|EDITOR|VISUAL|PAGER|TMPDIR|SHLVL|LC_[A-Z]+|XPC_[A-Z_]+|__CF[A-Z_]*|COMMAND_MODE|_)$/u;
|
|
13
22
|
const globalOf = (pattern) => new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`);
|
|
14
23
|
const SHAPES = [...SECRET_SHAPE_PATTERNS.map(globalOf)];
|
|
15
24
|
const USERINFO = globalOf(URI_USERINFO_PATTERN);
|
|
16
25
|
|
|
26
|
+
// A URL-form value is a secret when it carries more than an origin: a webhook path, a query or userinfo.
|
|
27
|
+
const carriesUrlSecret = (value) => {
|
|
28
|
+
try {
|
|
29
|
+
const url = new URL(value);
|
|
30
|
+
return /^https?:$/u.test(url.protocol) && (url.pathname.length > 1 || url.search !== "" || url.username !== "");
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
17
35
|
const envSecrets = (env) => Object.entries(env ?? {})
|
|
18
36
|
.filter(([name, value]) => typeof value === "string" && value.length >= 8 && !PLAIN_ENV_NAMES.test(name)
|
|
19
|
-
&& !/^[~/]/u.test(value) && !value.includes(":/") && !/^(?:true|false|\d+)$/iu.test(value))
|
|
37
|
+
&& !/^[~/]/u.test(value) && (!value.includes(":/") || carriesUrlSecret(value)) && !/^(?:true|false|\d+)$/iu.test(value))
|
|
20
38
|
.map(([, value]) => value)
|
|
21
39
|
.sort((a, b) => b.length - a.length);
|
|
22
40
|
|
|
@@ -25,10 +43,12 @@ export const makeRedactor = ({ env = process.env, home = env?.HOME } = {}) => {
|
|
|
25
43
|
const values = envSecrets(env);
|
|
26
44
|
return (input) => {
|
|
27
45
|
if (typeof input !== "string" || input === "") return input;
|
|
28
|
-
let text = input;
|
|
46
|
+
let text = stripControls(input);
|
|
29
47
|
for (const value of values) if (text.includes(value)) text = text.split(value).join(MASK);
|
|
48
|
+
text = text.replace(WEBHOOK, MASK);
|
|
30
49
|
text = text.replace(USERINFO, (match) => match.replace(/\/\/[^/?#\s]+@/u, `//${MASK}@`));
|
|
31
50
|
text = text.replace(ASSIGNMENT, (match, name) => (SECRET_NAME.test(name) ? `${name}=${MASK}` : match));
|
|
51
|
+
text = text.replace(JSON_PAIR, (match, name, colon) => (SECRET_NAME.test(name) ? `"${name}"${colon}"${MASK}"` : match));
|
|
32
52
|
for (const pattern of SHAPES) text = text.replace(pattern, MASK);
|
|
33
53
|
if (typeof home === "string" && home.length > 1) text = text.split(home).join("~");
|
|
34
54
|
return text;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// The SessionStart nudge toward lit-adhd: when this folder has other Claude Code sessions from the
|
|
2
|
+
// last three days, say once a day that `lit adhd` briefs them all on one screen. It looks only at
|
|
3
|
+
// this folder's own transcript folder (no scan of other projects) and stats file times, never
|
|
4
|
+
// contents, so it stays cheap on every session start. A marker under `.litclaude/adhd/` keeps it
|
|
5
|
+
// to one nudge per calendar day per project. A symlinked `.litclaude`, folder or marker (a cloned
|
|
6
|
+
// repository can carry one) is never followed: the nudge is then skipped, not written elsewhere.
|
|
7
|
+
import { lstatSync, readFileSync, readdirSync, renameSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
|
|
10
|
+
import { prepareStateDir, STATE_WRITE_FLAG } from "../project-state-root.mjs";
|
|
11
|
+
import { projectSlug } from "./transcripts.mjs";
|
|
12
|
+
|
|
13
|
+
export const RECENT_MS = 3 * 24 * 60 * 60 * 1000;
|
|
14
|
+
const SCAN_LIMIT = 400;
|
|
15
|
+
|
|
16
|
+
const dayOf = (now) => new Date(now).toISOString().slice(0, 10);
|
|
17
|
+
|
|
18
|
+
const recentOthers = (folder, sessionId, now) => {
|
|
19
|
+
let names;
|
|
20
|
+
try {
|
|
21
|
+
names = readdirSync(folder).filter((name) => name.endsWith(".jsonl")).slice(0, SCAN_LIMIT);
|
|
22
|
+
} catch {
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
25
|
+
return names.filter((name) => {
|
|
26
|
+
if (name === `${sessionId}.jsonl`) return false;
|
|
27
|
+
try {
|
|
28
|
+
const stat = lstatSync(join(folder, name));
|
|
29
|
+
return stat.isFile() && now - stat.mtimeMs < RECENT_MS;
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}).length;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The one-line suggestion, or null when there is nothing to suggest or it was already made today.
|
|
38
|
+
* Making it records today's date in `<stateRoot>/.litclaude/adhd/suggested.json`.
|
|
39
|
+
*/
|
|
40
|
+
export const adhdSuggestion = ({ cwd, sessionId, configDir, stateRoot, now = Date.now() }) => {
|
|
41
|
+
const count = recentOthers(join(configDir, "projects", projectSlug(cwd)), sessionId, now);
|
|
42
|
+
if (count === 0) return null;
|
|
43
|
+
const dir = join(stateRoot, ".litclaude", "adhd");
|
|
44
|
+
const marker = join(dir, "suggested.json");
|
|
45
|
+
if (!prepareStateDir(dir)) return null;
|
|
46
|
+
try {
|
|
47
|
+
if (lstatSync(marker).isSymbolicLink()) return null;
|
|
48
|
+
if (JSON.parse(readFileSync(marker, "utf8")).day === dayOf(now)) return null;
|
|
49
|
+
} catch {
|
|
50
|
+
// No marker yet, or an unreadable one: suggest and rewrite it.
|
|
51
|
+
}
|
|
52
|
+
const staging = `${marker}.${process.pid}.tmp`;
|
|
53
|
+
writeFileSync(staging, `${JSON.stringify({ day: dayOf(now) })}\n`, { flag: STATE_WRITE_FLAG });
|
|
54
|
+
renameSync(staging, marker);
|
|
55
|
+
return `${count} other recent ${count === 1 ? "session" : "sessions"} here · type \`lit adhd\` for a one-screen brief of where each stands`;
|
|
56
|
+
};
|
|
@@ -163,6 +163,17 @@ const slashPrompt = (text) => {
|
|
|
163
163
|
return args ? `${name} ${args}` : name;
|
|
164
164
|
};
|
|
165
165
|
const FILE_TOOLS = new Set(["Write", "Edit", "MultiEdit", "NotebookEdit"]);
|
|
166
|
+
// What a tool call was about, in a few words: a file's base name, a shell call's own description,
|
|
167
|
+
// a search pattern, a subagent's or skill's name. Never a command line or file contents.
|
|
168
|
+
const actionTarget = (name, input) => {
|
|
169
|
+
const path = input?.file_path ?? input?.notebook_path ?? input?.path;
|
|
170
|
+
if (["Read", ...FILE_TOOLS].includes(name) && typeof path === "string") return path.split(/[\\/]/u).at(-1);
|
|
171
|
+
if (name === "Bash" && typeof input?.description === "string") return input.description;
|
|
172
|
+
if ((name === "Grep" || name === "Glob") && typeof input?.pattern === "string") return input.pattern;
|
|
173
|
+
if ((name === "Agent" || name === "Task") && typeof input?.description === "string") return input.description;
|
|
174
|
+
if (name === "Skill" && typeof input?.skill === "string") return input.skill;
|
|
175
|
+
return null;
|
|
176
|
+
};
|
|
166
177
|
const WAITING_TEXT = /[??]\s*$|`?lit approve`?|`?lit deny`?|승인해\s*주|확인해\s*주|괜찮을까요|할까요/iu;
|
|
167
178
|
|
|
168
179
|
/**
|
|
@@ -184,6 +195,7 @@ export const sessionRecord = (lines, { redact = (text) => text, now = Date.now()
|
|
|
184
195
|
const tools = {};
|
|
185
196
|
const files = [];
|
|
186
197
|
let result = null;
|
|
198
|
+
let lastAction = null;
|
|
187
199
|
for (const line of main) {
|
|
188
200
|
if (line.type === "custom-title" && typeof line.customTitle === "string") customTitle = line.customTitle;
|
|
189
201
|
if (line.type === "ai-title" && typeof line.aiTitle === "string") aiTitle = line.aiTitle;
|
|
@@ -207,6 +219,8 @@ export const sessionRecord = (lines, { redact = (text) => text, now = Date.now()
|
|
|
207
219
|
tools[part.name] = (tools[part.name] ?? 0) + 1;
|
|
208
220
|
const path = part.input?.file_path ?? part.input?.notebook_path;
|
|
209
221
|
if (FILE_TOOLS.has(part.name) && typeof path === "string") files.push(path);
|
|
222
|
+
const target = actionTarget(part.name, part.input);
|
|
223
|
+
lastAction = { tool: part.name, ...(target ? { target } : {}) };
|
|
210
224
|
lastEntry = { role: "tool" };
|
|
211
225
|
}
|
|
212
226
|
}
|
|
@@ -222,7 +236,7 @@ export const sessionRecord = (lines, { redact = (text) => text, now = Date.now()
|
|
|
222
236
|
return inside && !inside.startsWith("..") ? inside : path;
|
|
223
237
|
};
|
|
224
238
|
const changed = [...new Set(files.reverse())].slice(0, 5).map((path) => redact(relativeFile(path)));
|
|
225
|
-
const asked = [...new Set([prompts[0], prompts.at(-1)].filter(Boolean))].slice(0, 2).map((text) => redact(
|
|
239
|
+
const asked = [...new Set([prompts[0], prompts.at(-1)].filter(Boolean))].slice(0, 2).map((text) => clip(redact(text), 160));
|
|
226
240
|
const waiting = lastEntry?.role === "assistant" && WAITING_TEXT.test(lastEntry.text.slice(-400));
|
|
227
241
|
const status = last === null ? "unknown" : waiting ? "waiting-on-user" : now - last < ACTIVE_MS ? "active" : "ended";
|
|
228
242
|
return {
|
|
@@ -234,10 +248,11 @@ export const sessionRecord = (lines, { redact = (text) => text, now = Date.now()
|
|
|
234
248
|
started: started === null ? "unknown" : new Date(started).toISOString(),
|
|
235
249
|
last: last === null ? "unknown" : new Date(last).toISOString(),
|
|
236
250
|
lastMs: last,
|
|
237
|
-
title: redact(
|
|
251
|
+
title: clip(redact(customTitle ?? aiTitle ?? prompts[0] ?? "unknown"), 80),
|
|
238
252
|
asked: asked.length ? asked : ["unknown"],
|
|
239
253
|
done: { tools, files: changed, commits: [] },
|
|
240
|
-
|
|
254
|
+
lastAction: lastAction ? { tool: lastAction.tool, ...(lastAction.target ? { target: clip(redact(lastAction.target), 60) } : {}) } : null,
|
|
255
|
+
result: result ? clip(redact(result), 240) : "unknown",
|
|
241
256
|
status,
|
|
242
257
|
...(waiting ? { waitingReason: "asked the user" } : {}),
|
|
243
258
|
};
|
|
@@ -21,7 +21,7 @@ import { basename, dirname, isAbsolute, join, relative, resolve } from "node:pat
|
|
|
21
21
|
import { fileURLToPath } from "node:url";
|
|
22
22
|
|
|
23
23
|
import { parsePlanTaskRows } from "./plan-task-rows.mjs";
|
|
24
|
-
import {
|
|
24
|
+
import { requireStateDir, STATE_APPEND_FLAG, STATE_WRITE_FLAG } from "./project-state-root.mjs";
|
|
25
25
|
import { pathIdentity, samePathIdentity } from "./secure-path-read.mjs";
|
|
26
26
|
|
|
27
27
|
const SCHEMA_VERSION = 3;
|
|
@@ -67,10 +67,9 @@ export const startWorkLockDir = (root) => join(startWorkStateDir(root), ".lock")
|
|
|
67
67
|
const startWorkLockOwnerPath = (root) => join(startWorkLockDir(root), "owner.json");
|
|
68
68
|
|
|
69
69
|
const atomicWriteJson = (path, value) => {
|
|
70
|
-
|
|
71
|
-
ensureStateDirIgnored(path);
|
|
70
|
+
requireStateDir(dirname(path));
|
|
72
71
|
const temporary = `${path}.${process.pid}.${Date.now()}.tmp`;
|
|
73
|
-
writeFileSync(temporary, `${JSON.stringify(value, null, 2)}\n`, { mode: 0o600 });
|
|
72
|
+
writeFileSync(temporary, `${JSON.stringify(value, null, 2)}\n`, { mode: 0o600, flag: STATE_WRITE_FLAG });
|
|
74
73
|
const fd = openSync(temporary, "r");
|
|
75
74
|
fsyncSync(fd);
|
|
76
75
|
closeSync(fd);
|
|
@@ -107,8 +106,7 @@ const readLockOwner = (root) => {
|
|
|
107
106
|
|
|
108
107
|
export const acquireStartWorkLock = (root, options = {}) => {
|
|
109
108
|
const lockDir = startWorkLockDir(root);
|
|
110
|
-
|
|
111
|
-
ensureStateDirIgnored(lockDir);
|
|
109
|
+
requireStateDir(dirname(lockDir));
|
|
112
110
|
const configured = Number.parseInt(process.env.LITCLAUDE_START_WORK_LOCK_TIMEOUT_MS ?? "5000", 10);
|
|
113
111
|
const timeout = Number.isFinite(options.timeoutMs)
|
|
114
112
|
? Math.max(0, options.timeoutMs)
|
|
@@ -319,14 +317,13 @@ const assertLedgerCompatible = (existing, stateEvents) => {
|
|
|
319
317
|
|
|
320
318
|
const reconcileLedger = (root, state) => {
|
|
321
319
|
const path = startWorkLedgerPath(root);
|
|
322
|
-
|
|
323
|
-
ensureStateDirIgnored(path);
|
|
320
|
+
requireStateDir(dirname(path));
|
|
324
321
|
const existing = ledgerRecords(root);
|
|
325
322
|
assertLedgerCompatible(existing, state.events);
|
|
326
323
|
const ids = new Set(existing.map(({ event_id: eventId }) => eventId).filter(Boolean));
|
|
327
324
|
for (const event of state.events) {
|
|
328
325
|
if (ids.has(event.event_id)) continue;
|
|
329
|
-
appendFileSync(path, `${JSON.stringify(event)}\n`, { mode: 0o600 });
|
|
326
|
+
appendFileSync(path, `${JSON.stringify(event)}\n`, { mode: 0o600, flag: STATE_APPEND_FLAG });
|
|
330
327
|
ids.add(event.event_id);
|
|
331
328
|
}
|
|
332
329
|
if (existsSync(path)) {
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
// card reads it back through its own guarded read. Frames keep skills, stages and counts only;
|
|
11
11
|
// never a prompt, a command or a path other than a project-relative plan name.
|
|
12
12
|
|
|
13
|
-
import { closeSync, constants, fstatSync, lstatSync,
|
|
13
|
+
import { closeSync, constants, fstatSync, lstatSync, openSync, readSync, renameSync, writeFileSync } from "node:fs";
|
|
14
14
|
import { dirname, join } from "node:path";
|
|
15
15
|
|
|
16
16
|
import { ignitionFileName } from "./mod/state.mjs";
|
|
17
17
|
import { DISCIPLINE_ENTRY, REVIEW_LANES, STAGE_UNITS, VERDICT_STATES, normalizeStage } from "./mod/workflow.mjs";
|
|
18
|
-
import {
|
|
18
|
+
import { requireStateDir, resolveProjectStateRoot, STATE_WRITE_FLAG } from "./project-state-root.mjs";
|
|
19
19
|
|
|
20
20
|
export const MAX_FRAMES = 3;
|
|
21
21
|
export const MAX_HISTORY = 20;
|
|
@@ -234,10 +234,9 @@ export const readStack = (cwd, sessionId) => {
|
|
|
234
234
|
/** Writes the whole stack through a temporary file; a link at the destination is replaced, never followed. */
|
|
235
235
|
export const writeStack = (cwd, sessionId, stack) => {
|
|
236
236
|
const path = stackPath(cwd, sessionId);
|
|
237
|
-
|
|
238
|
-
ensureStateDirIgnored(path);
|
|
237
|
+
requireStateDir(dirname(path));
|
|
239
238
|
const staging = `${path}.${process.pid}.tmp`;
|
|
240
|
-
writeFileSync(staging, `${JSON.stringify(stack)}\n`, { flag:
|
|
239
|
+
writeFileSync(staging, `${JSON.stringify(stack)}\n`, { flag: STATE_WRITE_FLAG });
|
|
241
240
|
renameSync(staging, path);
|
|
242
241
|
return stack;
|
|
243
242
|
};
|
|
@@ -43,6 +43,13 @@ only), `harden` (stress axes); `audit` is a read-only probe run whose table is e
|
|
|
43
43
|
|
|
44
44
|
1. Inspect the target and choose the lane. A sufficient build/design brief authorizes scoped implementation. A bare invocation may identify an unambiguous frontend, but a skill name or keyword-only request does not itself authorize a build. Ask a question only for a material unresolved choice; incidental mentions and review, plan, or keyword-only requests remain read-only.
|
|
45
45
|
2. Capture a compact direction and finite inventory. Follow `references/production-interview.md` for material ambiguity and retain each answer across turns. When the brief names competing visual directions and leaves them undecided, ask before selecting a direction or implementing it; a recommendation in the alternatives question does not resolve the choice. Existing brand constraints take precedence.
|
|
46
|
+
**Choose the design first.** For a new page or screen the user picks the look; the user has the right to choose. Before `design-lock.mjs init` or any markup, call the `AskUserQuestion` tool once with up to three questions, and pass the answers to `init` as `--style`, `--family` and `--density`:
|
|
47
|
+
1. `Style` ("Which house style?"): the style the brief's register points to as `<style> (Recommended)` (`field-notes` for a read-once page, `graphite` for a screen worked in), then up to three of `meadow` (warm, consumer), `computational-brutalism` (instrument, terminal), `neo-brutalism` (loud, outlined), `graphite` or `field-notes`, picked by their `use_when` lines. Each description is the register in a line; each `preview` is a small ASCII of the signature, for example `neo-brutalism` as a thick-outlined card with a hard offset shadow, `computational-brutalism` as a ruled mono panel on a plotting grid, `field-notes` as a dotted-paper hero with a large title.
|
|
48
|
+
2. `Family` ("What is being built?"): `landing`, `workspace` or `settings`, the one the brief implies first with `(Recommended)`; the preview is the starter's wireframe (site bar and split hero; app shell with side nav and panels; section index and one form column).
|
|
49
|
+
3. `Density` ("How full should it be?"): `Rich (Recommended)` (the lock default: section rhythm, texture, second accent, bands) or `Calm` (broad flat page, one accent).
|
|
50
|
+
|
|
51
|
+
The tool adds "Other" itself, so no Other option is written; a typed style id from `design-lock.mjs list` or brand tokens go to `--style` or `--from`. Skip a question when the prompt already names its answer (a style keyword, a family, an existing brand or token file, a brownfield or redesign lane that keeps the product's identity) or the user hands the choice over ("알아서", "you choose", "just make it good"); then apply the family defaults below and say which style was used. When `AskUserQuestion` is unavailable (a non-interactive `claude -p` run), take the Recommended option of each question, say so in one line ("Non-interactive run: building with graphite, the recommended option"), and continue. Review, plan and keyword-only requests stay read-only and ask nothing.
|
|
52
|
+
|
|
46
53
|
For a new page or screen, lock the look before writing markup, then read `references/house-styles.md` for the class catalogue:
|
|
47
54
|
|
|
48
55
|
```bash
|
|
@@ -50,7 +57,7 @@ only), `harden` (stress axes); `audit` is a read-only probe run whose table is e
|
|
|
50
57
|
node "$FRONTEND_UIUX_SKILL_ROOT/scripts/design-lock.mjs" init --family <landing|workspace|settings> [--style <field-notes|graphite|meadow|computational-brutalism|neo-brutalism>] [--brief "<the request>"] [--density calm] --moment <kind> --moment-note "<what it is>" --dir "<project>" --scaffold
|
|
51
58
|
```
|
|
52
59
|
|
|
53
|
-
|
|
60
|
+
Once that question is skipped or handed over, when a new brief supplies no visual direction, apply `references/default-editorial-pixel.json` without asking: a read-once page (landing, docs, report) locks `field-notes`, which is that profile made complete. For a screen people work in rather than read once, apply its `work_surfaces` rules: the working content comes first, and dashboards, settings, forms and admin or data-dense screens lock `graphite`. Omitting `--style` applies exactly these family defaults unless the request passed as `--brief` names a register by a style keyword: brutalist, brutalism, retro-futurist or 레트로퓨처 lock `computational-brutalism`, neo-brutalism or 네오브루탈리즘 locks `neo-brutalism` (`design-lock.mjs match "<request>"` shows the pick, `list` prints every keyword, signature and forbidden pattern). A register named only in other words picks a style by its `use_when` line; `meadow`, `computational-brutalism` and `neo-brutalism` are opt-in only, never defaults. Brand tokens are locked with `--from <style.json>` instead. The lock is rich by default: a tighter section rhythm, the style's texture, a second accent family, colour bands, a two-accent wash and an atmosphere glow, with up to four accent hue families per view; it locks `density: calm` (broad flat page, one accent) only when the request asks for a minimal, calm, quiet or restrained page or passes `--density calm`. Never strip a page toward minimal on your own; the safety floors are the same in both. Build with the kit's `ui-*` classes and `var(--…)` tokens only, starting from the scaffolded family layout; a literal colour, font or off-scale size is drift the probe reports. Every page also carries one signature moment chosen for its content (house-styles.md section 6): bold on a read-once page and in its first screen (`hero-composition`, `type-set-piece`, `data-moment`, `diagram`, `motion-detail`, `interactive-object`), small on a work surface (`chart`, `empty-state`, `header-detail`). Record it in the lock, mark that element `data-ui-moment="<kind>"`, and never make it a centred headline over a gradient; DS-008 fails a page without it.
|
|
54
61
|
3. Build the declared interactions and states with repository-native components. Evolve the `litfamily.design-contract/v1beta2` artifact with implementation; validate canonical JSON below 1 MiB before acceptance. A full schema is not a prerequisite to starting an already authorized build. Do not request routine approval again or stop at contract-only delivery.
|
|
55
62
|
Use the shipped validator from the exact selected skill directory, not a handwritten schema checker or an inferred lookalike contract:
|
|
56
63
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Choose the output mode from the user's actual request. A critique or plan is read-only. A build with a clear target proceeds to source changes and inspection. A bare skill name with several frontends needs a target choice; naming a skill does not settle scope. PostToolUse guidance is a reminder to inspect the changed UI, never permission to redesign unrelated screens.
|
|
4
4
|
|
|
5
|
-
Before implementation, record a short direction and the finite routes, controls and states that matter. Read current components, brand tokens and dirty files. Preserve established identity in brownfield work. For new work with no visual direction in the brief, apply the authored default pixel profile without asking; absence of direction is not an unresolved choice. The profile is not a mandate to recolor an existing product.
|
|
5
|
+
Before implementation, record a short direction and the finite routes, controls and states that matter. Read current components, brand tokens and dirty files. Preserve established identity in brownfield work. For new work, SKILL.md's "Choose the design first" step asks the user to pick the house style, family and density with one `AskUserQuestion` call. Once that step is skipped or handed over ("you choose", "알아서", a named style, a non-interactive run), with no visual direction in the brief, apply the authored default pixel profile without asking; absence of direction is then not an unresolved choice. The profile is not a mandate to recolor an existing product.
|
|
6
6
|
|
|
7
7
|
There is no mandatory interview. Ask only when two plausible answers would materially change scope, architecture, permissions, accessibility, or visual direction. Resolve a known conflict before installing tooling or producing a baseline capture; a capture is not needed to ask the question. Ask one high-impact question at a time, present concrete alternatives and their consequences, then wait for the answer before choosing the next unresolved material decision. Continue for as many rounds as materially necessary; there is no fixed question count.
|
|
8
8
|
|