@litfamily/litclaude 1.0.42 → 1.0.44
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 +67 -0
- package/README.md +8 -8
- package/README_ko-KR.md +8 -8
- package/TRADEMARK.md +12 -0
- package/bin/litclaude-ai.js +58 -5
- 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/agents/korean-prose-editor.md +2 -0
- package/plugins/litclaude/agents/korean-style-analyzer.md +2 -0
- package/plugins/litclaude/agents/librarian-researcher.md +2 -0
- package/plugins/litclaude/agents/lit-executor.md +2 -0
- package/plugins/litclaude/agents/lit-planner.md +2 -0
- package/plugins/litclaude/agents/lit-verifier.md +2 -0
- package/plugins/litclaude/agents/meaning-preservation-auditor.md +2 -0
- package/plugins/litclaude/agents/native-flow-reviewer.md +2 -0
- package/plugins/litclaude/agents/polish-orchestrator.md +2 -0
- package/plugins/litclaude/agents/qa-runner.md +2 -0
- package/plugins/litclaude/agents/quality-reviewer.md +2 -0
- package/plugins/litclaude/bin/litclaude-hook.js +24 -5
- package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
- package/plugins/litclaude/commands/litgoal.md +3 -1
- package/plugins/litclaude/hooks/lit-band-client.mjs +9 -4
- package/plugins/litclaude/hooks/lit-mod.mjs +9 -1
- package/plugins/litclaude/lib/canonical-runtime-commitments.mjs +6 -6
- package/plugins/litclaude/lib/canonical-skill-resources.mjs +49 -46
- package/plugins/litclaude/lib/invite.mjs +131 -0
- package/plugins/litclaude/lib/litgoal/autoloop.mjs +57 -8
- package/plugins/litclaude/lib/litgoal/cli.mjs +62 -1
- package/plugins/litclaude/lib/litgoal/freshness.mjs +55 -0
- package/plugins/litclaude/lib/litgoal/ledger.mjs +1 -1
- package/plugins/litclaude/lib/litgoal/state.mjs +1 -1
- package/plugins/litclaude/lib/litgoal/unknowns.mjs +44 -0
- package/plugins/litclaude/lib/mark-logo.png +0 -0
- package/plugins/litclaude/lib/mark.mjs +375 -0
- package/plugins/litclaude/lib/mod/frame.mjs +88 -19
- 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 +18 -0
- package/plugins/litclaude/lib/mod/svg-card.mjs +61 -16
- package/plugins/litclaude/lib/mod/timeline.mjs +32 -0
- package/plugins/litclaude/lib/mod/view.mjs +8 -3
- package/plugins/litclaude/lib/official-build.mjs +22 -0
- package/plugins/litclaude/lib/output_mark.py +132 -0
- package/plugins/litclaude/lib/owner-lock.mjs +11 -1
- package/plugins/litclaude/lib/plan-task-rows.mjs +17 -4
- package/plugins/litclaude/lib/render_pages.py +16 -0
- package/plugins/litclaude/lib/rewind/collect.mjs +58 -5
- package/plugins/litclaude/lib/start-work-lifecycle.mjs +45 -10
- package/plugins/litclaude/skills/autoconference/SKILL.md +2 -0
- package/plugins/litclaude/skills/autoresearch/SKILL.md +2 -0
- package/plugins/litclaude/skills/browser-drive/SKILL.md +2 -0
- package/plugins/litclaude/skills/comment-checker/SKILL.md +2 -0
- package/plugins/litclaude/skills/debugging/SKILL.md +2 -0
- package/plugins/litclaude/skills/deep-interview/SKILL.md +2 -0
- package/plugins/litclaude/skills/frontend-ui-ux/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-adhd/SKILL.md +3 -0
- package/plugins/litclaude/skills/lit-brainstorm/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-burnoff/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-burnoff-file/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-code/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-commit/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-comprehend/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-crucible/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-diagram-drawer/SKILL.md +3 -1
- package/plugins/litclaude/skills/lit-diagram-drawer/scripts/export.mjs +35 -1
- package/plugins/litclaude/skills/lit-docx/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-docx/scripts/convert_md_to_docx.py +4 -1
- package/plugins/litclaude/skills/lit-docx/scripts/convert_md_to_pdf.py +2 -0
- package/plugins/litclaude/skills/lit-handoff/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-hijack/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-humanizer/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-init/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-loop/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-plan/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-pptx/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-pptx/scripts/lib/render-adapter-pptx.js +6 -1
- package/plugins/litclaude/skills/lit-recap/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-schematic/SKILL.md +3 -1
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/sheet.mjs +10 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/lib/svg.mjs +4 -0
- package/plugins/litclaude/skills/lit-schematic/scripts/motion.mjs +5 -2
- package/plugins/litclaude/skills/lit-schematic/scripts/render.mjs +20 -2
- package/plugins/litclaude/skills/lit-scientific-visualization/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-team/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-typographic-motion/SKILL.md +2 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/chrome.mjs +23 -2
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-capture.mjs +14 -1
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover.mjs +48 -2
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/encode.mjs +8 -1
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/end-card.mjs +128 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/pipeline.mjs +59 -14
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-gate.mjs +7 -4
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage.mjs +29 -7
- package/plugins/litclaude/skills/lit-typographic-motion/references/studio.md +11 -0
- package/plugins/litclaude/skills/litgoal/SKILL.md +53 -1
- package/plugins/litclaude/skills/litresearch/SKILL.md +2 -0
- package/plugins/litclaude/skills/litwork/SKILL.md +2 -0
- package/plugins/litclaude/skills/lsp/SKILL.md +2 -0
- package/plugins/litclaude/skills/lsp-setup/SKILL.md +2 -0
- package/plugins/litclaude/skills/readme-studio/SKILL.md +3 -1
- package/plugins/litclaude/skills/readme-studio/templates/cover-source.json +1 -0
- package/plugins/litclaude/skills/readme-studio/templates/hyperframes-cover/index.html +3 -2
- package/plugins/litclaude/skills/readme-studio/templates/remotion-cover/package-lock.json +3 -3
- package/plugins/litclaude/skills/readme-studio/templates/remotion-cover/package.json +2 -1
- package/plugins/litclaude/skills/readme-studio/templates/remotion-cover/src/index.tsx +4 -3
- package/plugins/litclaude/skills/refactor/SKILL.md +2 -0
- package/plugins/litclaude/skills/review-work/SKILL.md +2 -0
- package/plugins/litclaude/skills/rules/SKILL.md +2 -0
- package/plugins/litclaude/skills/start-work/SKILL.md +7 -0
- package/plugins/litclaude/skills/structural-search/SKILL.md +2 -0
- package/plugins/litclaude/skills/visual-qa/SKILL.md +2 -0
- package/plugins/litclaude/skills/wikify/SKILL.md +2 -0
- package/scripts/doctor.mjs +3 -1
- package/scripts/prepublish-test-gate.mjs +75 -22
|
@@ -8,7 +8,9 @@ import { join } from "node:path";
|
|
|
8
8
|
import { requireStateDir, STATE_WRITE_FLAG } from "../project-state-root.mjs";
|
|
9
9
|
import { appendLitgoalLedger } from "./ledger.mjs";
|
|
10
10
|
import { litgoalGoalsPath, litgoalLedgerPath, litgoalLockDir, litgoalStateDir } from "./paths.mjs";
|
|
11
|
+
import { reopenStaleCriteria } from "./freshness.mjs";
|
|
11
12
|
import { readLitgoalState, withLitgoalLock, writeLitgoalState } from "./state.mjs";
|
|
13
|
+
import { openCriticalUnknowns } from "./unknowns.mjs";
|
|
12
14
|
|
|
13
15
|
export const litgoalAutoloopPath = (cwd = process.cwd()) => join(litgoalStateDir(cwd), "autoloop.json");
|
|
14
16
|
|
|
@@ -62,7 +64,8 @@ export const completeAutoloopGoal = (cwd = process.cwd()) =>
|
|
|
62
64
|
const canComplete = state.status === "active"
|
|
63
65
|
&& state.autoloop === true
|
|
64
66
|
&& criteria.length > 0
|
|
65
|
-
&& criteria.every((criterion) => criterion?.status === "pass")
|
|
67
|
+
&& criteria.every((criterion) => criterion?.status === "pass")
|
|
68
|
+
&& openCriticalUnknowns(state).length === 0;
|
|
66
69
|
if (!checkpoint && !canComplete) return { completed: false };
|
|
67
70
|
|
|
68
71
|
if (!checkpoint) {
|
|
@@ -96,11 +99,42 @@ export const completeAutoloopGoal = (cwd = process.cwd()) =>
|
|
|
96
99
|
return { completed: true, checkpoint };
|
|
97
100
|
});
|
|
98
101
|
|
|
102
|
+
// Before the Stop hook decides, reopen any pass whose recorded inputs changed or vanished, so a stale pass is
|
|
103
|
+
// never completed. Returns the (possibly updated) state.
|
|
104
|
+
export const refreshAutoloopState = (cwd = process.cwd()) =>
|
|
105
|
+
withLitgoalLock(litgoalLockDir(cwd), () => {
|
|
106
|
+
const state = readLitgoalState(litgoalGoalsPath(cwd), null);
|
|
107
|
+
if (!state) return state;
|
|
108
|
+
const reopened = reopenStaleCriteria(state);
|
|
109
|
+
if (reopened.length) {
|
|
110
|
+
state.updatedAt = new Date().toISOString();
|
|
111
|
+
writeLitgoalState(litgoalGoalsPath(cwd), state);
|
|
112
|
+
for (const entry of reopened) appendLitgoalLedger(litgoalLedgerPath(cwd), entry);
|
|
113
|
+
}
|
|
114
|
+
return state;
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// When only questions the user can answer remain, looping cannot help: the goal moves to needs_user_decision
|
|
118
|
+
// and the session stops with the questions, instead of completing.
|
|
119
|
+
export const handAutoloopToUser = (cwd, stopReason) =>
|
|
120
|
+
withLitgoalLock(litgoalLockDir(cwd), () => {
|
|
121
|
+
const state = readLitgoalState(litgoalGoalsPath(cwd), null);
|
|
122
|
+
if (!state || state.status !== "active") return { handedOff: false };
|
|
123
|
+
const checkpoint = { status: "needs_user_decision", note: stopReason, createdAt: new Date().toISOString(), generatedBy: "stop-hook-autoloop-handoff" };
|
|
124
|
+
state.status = "needs_user_decision";
|
|
125
|
+
state.checkpoints = [...(state.checkpoints ?? []), checkpoint];
|
|
126
|
+
state.updatedAt = checkpoint.createdAt;
|
|
127
|
+
writeLitgoalState(litgoalGoalsPath(cwd), state);
|
|
128
|
+
appendLitgoalLedger(litgoalLedgerPath(cwd), { event: "checkpoint.recorded", ...checkpoint });
|
|
129
|
+
return { handedOff: true, checkpoint };
|
|
130
|
+
});
|
|
131
|
+
|
|
99
132
|
// Pure decision function for the Stop hook — kept side-effect-free so it is unit
|
|
100
133
|
// testable without touching the filesystem or the process. Returns one of:
|
|
101
134
|
// { action: "allow" } -> let the session stop
|
|
102
135
|
// { action: "cap", stopReason } -> hard stop (continue:false)
|
|
103
136
|
// { action: "block", reason, nextCount } -> block stopping; caller persists nextCount
|
|
137
|
+
// { action: "handoff", stopReason } -> stop and hand the open UK questions to the user
|
|
104
138
|
export const evaluateAutoloop = ({ env = {}, state, autoloopState, now = Date.now() } = {}) => {
|
|
105
139
|
if (env.LITCLAUDE_GOAL_OFF === "1") return { action: "allow", why: "kill-switch" };
|
|
106
140
|
if (!state || state.status !== "active" || state.autoloop !== true) {
|
|
@@ -110,7 +144,19 @@ export const evaluateAutoloop = ({ env = {}, state, autoloopState, now = Date.no
|
|
|
110
144
|
const remaining = criteria.length === 0
|
|
111
145
|
? [{ id: "criteria-required", status: "missing", description: "no success criteria are defined" }]
|
|
112
146
|
: criteria.filter((c) => !c || c.status !== "pass");
|
|
113
|
-
|
|
147
|
+
const critical = openCriticalUnknowns(state);
|
|
148
|
+
if (criteria.length > 0 && remaining.length === 0) {
|
|
149
|
+
if (critical.length === 0) return { action: "allow", why: "all-criteria-pass" };
|
|
150
|
+
if (critical.every(({ kind }) => kind === "UK")) {
|
|
151
|
+
return {
|
|
152
|
+
action: "handoff",
|
|
153
|
+
stopReason:
|
|
154
|
+
`LitClaude litgoal "${state.objective}" needs your answer before it can finish:\n` +
|
|
155
|
+
`${critical.map(({ id, text }) => ` - ${id}: ${text}`).join("\n")}\n` +
|
|
156
|
+
`Answer in chat; the goal waits as needs_user_decision.`,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
114
160
|
|
|
115
161
|
const auto = autoloopState && typeof autoloopState === "object"
|
|
116
162
|
? autoloopState
|
|
@@ -129,14 +175,17 @@ export const evaluateAutoloop = ({ env = {}, state, autoloopState, now = Date.no
|
|
|
129
175
|
}
|
|
130
176
|
|
|
131
177
|
const nextCount = blockCount + 1;
|
|
132
|
-
const list =
|
|
133
|
-
.map((c) => c
|
|
178
|
+
const list = [
|
|
179
|
+
...remaining.map((c) => c
|
|
134
180
|
? ` - ${c.id} [${c.status}]: ${c.description ?? c.scenario ?? ""}`
|
|
135
|
-
: " - criterion-invalid [missing]: invalid criterion")
|
|
136
|
-
.
|
|
181
|
+
: " - criterion-invalid [missing]: invalid criterion"),
|
|
182
|
+
...critical.map(({ id, kind, text, probe }) => ` - ${id} [open ${kind}, critical]: ${text} (probe: ${probe ?? "none"})`),
|
|
183
|
+
].join("\n");
|
|
137
184
|
const reason =
|
|
138
|
-
`LitClaude litgoal still active: "${state.objective}". ${remaining.length} criterion(s) not yet pass
|
|
139
|
-
|
|
185
|
+
`LitClaude litgoal still active: "${state.objective}". ${remaining.length} criterion(s) not yet pass, ` +
|
|
186
|
+
`${critical.length} critical unknown(s) open:\n${list}\n` +
|
|
187
|
+
`Advance each: litclaude-ai litgoal record-evidence --criterion <id> --status pass --json '{"artifact":"..."}', ` +
|
|
188
|
+
`or close an unknown with litclaude-ai litgoal unknown resolve --id <id> --evidence "...". ` +
|
|
140
189
|
`Autoloop block ${nextCount}/${AUTOLOOP_MAX_BLOCKS}. Escape: litclaude-ai litgoal checkpoint --status blocked, or LITCLAUDE_GOAL_OFF=1.`;
|
|
141
190
|
return { action: "block", reason, nextCount, firstBlockAt };
|
|
142
191
|
};
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
import { readLitgoalState, LitgoalStateError, withLitgoalLock, writeLitgoalState } from "./state.mjs";
|
|
13
13
|
import { resetAutoloopState } from "./autoloop.mjs";
|
|
14
14
|
import { NativeWorkerError, runNativeWorker } from "./native-worker.mjs";
|
|
15
|
+
import { fingerprintInputs, reopenStaleCriteria } from "./freshness.mjs";
|
|
16
|
+
import { addUnknown, openCriticalUnknowns, resolveUnknown } from "./unknowns.mjs";
|
|
15
17
|
|
|
16
18
|
const subcommands = [
|
|
17
19
|
["create-goals", "Create durable goal records; use --replace for a fresh cycle."],
|
|
@@ -21,6 +23,7 @@ const subcommands = [
|
|
|
21
23
|
["checkpoint", "Write a continuation checkpoint."],
|
|
22
24
|
["steer", "Record a steering decision."],
|
|
23
25
|
["record-review-blockers", "Record review blockers."],
|
|
26
|
+
["unknown", "Add, resolve or list unknowns (KK, KU, UK, UU)."],
|
|
24
27
|
["native-worker", "Launch a separate native /goal worker (dry-run by default)."],
|
|
25
28
|
];
|
|
26
29
|
|
|
@@ -55,6 +58,7 @@ const reservedEvidenceKeys = new Set([
|
|
|
55
58
|
"goalId",
|
|
56
59
|
"sessionId",
|
|
57
60
|
"event",
|
|
61
|
+
"inputs",
|
|
58
62
|
]);
|
|
59
63
|
|
|
60
64
|
const hasFlag = (args, flag) => args.includes(flag);
|
|
@@ -67,6 +71,12 @@ const optionValue = (args, flag) => {
|
|
|
67
71
|
return value;
|
|
68
72
|
};
|
|
69
73
|
|
|
74
|
+
// Every value given for a repeatable flag, comma lists split: `--inputs a,b --inputs c` -> [a, b, c].
|
|
75
|
+
const optionValues = (args, flag) =>
|
|
76
|
+
args.flatMap((arg, index) => (arg === flag && args[index + 1] && !args[index + 1].startsWith("--") ? args[index + 1].split(",") : []))
|
|
77
|
+
.map((value) => value.trim())
|
|
78
|
+
.filter(Boolean);
|
|
79
|
+
|
|
70
80
|
const requireOption = (args, flag, label = flag.slice(2)) => {
|
|
71
81
|
const value = optionValue(args, flag);
|
|
72
82
|
if (!value) throw new LitgoalCliError(`missing ${label}`);
|
|
@@ -130,6 +140,18 @@ const requireState = (cwd) => {
|
|
|
130
140
|
return state;
|
|
131
141
|
};
|
|
132
142
|
|
|
143
|
+
// Reopens stale passes and persists them; call inside the litgoal lock.
|
|
144
|
+
const persistStaleCriteria = (cwd, state) => {
|
|
145
|
+
const reopened = reopenStaleCriteria(state);
|
|
146
|
+
if (!reopened.length) return state;
|
|
147
|
+
state.updatedAt = nowIso();
|
|
148
|
+
writeLitgoalState(litgoalGoalsPath(cwd), state);
|
|
149
|
+
for (const entry of reopened) appendLedger(cwd, entry);
|
|
150
|
+
return state;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const currentStatus = (cwd) => withLitgoalLock(litgoalLockDir(cwd), () => persistStaleCriteria(cwd, requireState(cwd)));
|
|
154
|
+
|
|
133
155
|
const appendLedger = (cwd, entry) => appendLitgoalLedger(litgoalLedgerPath(cwd), entry);
|
|
134
156
|
|
|
135
157
|
const defaultCriterion = (brief) => ({
|
|
@@ -237,6 +259,11 @@ const updateCriterionWithEvidence = (cwd, args) => {
|
|
|
237
259
|
throw new LitgoalStateError("complete goal rejects non-pass evidence; open a new or explicitly reopened goal first");
|
|
238
260
|
}
|
|
239
261
|
|
|
262
|
+
const inputs = fingerprintInputs(cwd, [
|
|
263
|
+
...optionValues(args, "--inputs").map((path) => ({ path, role: "input" })),
|
|
264
|
+
...optionValues(args, "--reviewed").map((path) => ({ path, role: "reviewed" })),
|
|
265
|
+
]);
|
|
266
|
+
|
|
240
267
|
// Drift 6e — evidence is attempt-scoped and append-only. A retry adds attempt N+1;
|
|
241
268
|
// it never replaces what an earlier attempt recorded.
|
|
242
269
|
const priorEvidence = criterion.evidence ?? [];
|
|
@@ -245,9 +272,11 @@ const updateCriterionWithEvidence = (cwd, args) => {
|
|
|
245
272
|
...evidence,
|
|
246
273
|
attempt,
|
|
247
274
|
status,
|
|
275
|
+
...(inputs.length ? { inputs } : {}),
|
|
248
276
|
recordedAt: nowIso(),
|
|
249
277
|
};
|
|
250
278
|
criterion.status = status;
|
|
279
|
+
delete criterion.staleInputs;
|
|
251
280
|
criterion.attempts = attempt;
|
|
252
281
|
criterion.evidence = [...priorEvidence, record];
|
|
253
282
|
state.updatedAt = record.recordedAt;
|
|
@@ -258,6 +287,7 @@ const updateCriterionWithEvidence = (cwd, args) => {
|
|
|
258
287
|
attempt,
|
|
259
288
|
status,
|
|
260
289
|
evidence,
|
|
290
|
+
...(inputs.length ? { inputs } : {}),
|
|
261
291
|
});
|
|
262
292
|
return { criterion };
|
|
263
293
|
});
|
|
@@ -274,6 +304,7 @@ const checkpoint = (cwd, args) =>
|
|
|
274
304
|
if (!["active", "complete", "blocked", "review_blocked", "needs_user_decision", "abandoned"].includes(status)) {
|
|
275
305
|
throw new LitgoalCliError("invalid checkpoint status");
|
|
276
306
|
}
|
|
307
|
+
if (status === "complete") persistStaleCriteria(cwd, state);
|
|
277
308
|
const criteria = state.criteria ?? [];
|
|
278
309
|
if (status === "complete" && criteria.length === 0) {
|
|
279
310
|
throw new LitgoalStateError("non-empty criteria must pass before completion");
|
|
@@ -281,6 +312,10 @@ const checkpoint = (cwd, args) =>
|
|
|
281
312
|
if (status === "complete" && !criteria.every((criterion) => criterion.status === "pass")) {
|
|
282
313
|
throw new LitgoalStateError("criteria must pass before completion");
|
|
283
314
|
}
|
|
315
|
+
const critical = status === "complete" ? openCriticalUnknowns(state) : [];
|
|
316
|
+
if (critical.length) {
|
|
317
|
+
throw new LitgoalStateError(`open critical unknowns block completion: ${critical.map(({ id }) => id).join(", ")}`);
|
|
318
|
+
}
|
|
284
319
|
|
|
285
320
|
const record = {
|
|
286
321
|
status,
|
|
@@ -340,12 +375,36 @@ const recordReviewBlockers = (cwd, args) =>
|
|
|
340
375
|
return { ...record, goalStatus: state.status };
|
|
341
376
|
});
|
|
342
377
|
|
|
378
|
+
const unknown = (cwd, args) => {
|
|
379
|
+
const [action] = args;
|
|
380
|
+
if (action === "list") return { unknowns: requireState(cwd).unknowns ?? [] };
|
|
381
|
+
if (action !== "add" && action !== "resolve") throw new LitgoalCliError("usage: litgoal unknown add|resolve|list");
|
|
382
|
+
return withLitgoalLock(litgoalLockDir(cwd), () => {
|
|
383
|
+
const state = requireState(cwd);
|
|
384
|
+
const now = nowIso();
|
|
385
|
+
const record = action === "add"
|
|
386
|
+
? addUnknown(state, {
|
|
387
|
+
kind: (optionValue(args, "--kind") || "").toUpperCase(),
|
|
388
|
+
text: optionValue(args, "--text"),
|
|
389
|
+
source: optionValue(args, "--source"),
|
|
390
|
+
probe: optionValue(args, "--probe"),
|
|
391
|
+
critical: hasFlag(args, "--critical"),
|
|
392
|
+
now,
|
|
393
|
+
})
|
|
394
|
+
: resolveUnknown(state, { id: requireOption(args, "--id", "id"), evidence: optionValue(args, "--evidence"), now });
|
|
395
|
+
state.updatedAt = now;
|
|
396
|
+
writeLitgoalState(litgoalGoalsPath(cwd), state);
|
|
397
|
+
appendLedger(cwd, { event: action === "add" ? "unknown.added" : "unknown.resolved", ...record });
|
|
398
|
+
return { unknown: record };
|
|
399
|
+
});
|
|
400
|
+
};
|
|
401
|
+
|
|
343
402
|
const runCommand = (cwd, command, args) => {
|
|
344
403
|
switch (command) {
|
|
345
404
|
case "create-goals":
|
|
346
405
|
return createGoals(cwd, args);
|
|
347
406
|
case "status":
|
|
348
|
-
return
|
|
407
|
+
return currentStatus(cwd);
|
|
349
408
|
case "criteria":
|
|
350
409
|
return listCriteria(cwd);
|
|
351
410
|
case "record-evidence":
|
|
@@ -356,6 +415,8 @@ const runCommand = (cwd, command, args) => {
|
|
|
356
415
|
return steer(cwd, args);
|
|
357
416
|
case "record-review-blockers":
|
|
358
417
|
return recordReviewBlockers(cwd, args);
|
|
418
|
+
case "unknown":
|
|
419
|
+
return unknown(cwd, args);
|
|
359
420
|
case "native-worker":
|
|
360
421
|
return runNativeWorker(args, { cwd });
|
|
361
422
|
default:
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Evidence freshness: a file existing is not proof that a pass is current. `record-evidence --inputs` (and
|
|
2
|
+
// `--reviewed` for the artifact a human review looked at) binds the pass to each file's SHA-256 at the moment
|
|
3
|
+
// it was observed; when one of those files changes or disappears, the pass reopens as `stale`.
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { lstatSync, readFileSync } from "node:fs";
|
|
6
|
+
import { resolve } from "node:path";
|
|
7
|
+
|
|
8
|
+
import { LitgoalStateError } from "./state.mjs";
|
|
9
|
+
|
|
10
|
+
const MAX_INPUT_BYTES = 256 * 1024 * 1024;
|
|
11
|
+
|
|
12
|
+
const sha256Of = (path) => {
|
|
13
|
+
let info;
|
|
14
|
+
try {
|
|
15
|
+
info = lstatSync(path);
|
|
16
|
+
} catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
if (!info.isFile() || info.size > MAX_INPUT_BYTES) return null;
|
|
20
|
+
return createHash("sha256").update(readFileSync(path)).digest("hex");
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Fingerprints each path (relative to `cwd`) as { path, role, sha256 }; a missing or non-regular file is refused. */
|
|
24
|
+
export const fingerprintInputs = (cwd, entries) =>
|
|
25
|
+
entries.map(({ path, role }) => {
|
|
26
|
+
const absolute = resolve(cwd, path);
|
|
27
|
+
const sha256 = sha256Of(absolute);
|
|
28
|
+
if (!sha256) throw new LitgoalStateError(`evidence input is not a readable regular file: ${path}`);
|
|
29
|
+
return { path: absolute, role, sha256 };
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/** The inputs of an evidence record whose file changed or vanished since it was recorded. */
|
|
33
|
+
export const staleInputs = (record) =>
|
|
34
|
+
(Array.isArray(record?.inputs) ? record.inputs : []).flatMap(({ path, role, sha256 }) => {
|
|
35
|
+
const now = sha256Of(path);
|
|
36
|
+
if (now === sha256) return [];
|
|
37
|
+
return [{ path, role, reason: now === null ? "missing" : "changed" }];
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Reopens every passing criterion whose latest evidence has a changed or missing input: its status becomes
|
|
42
|
+
* `stale` and `staleInputs` says which. Mutates `state`; returns one ledger entry per reopened criterion.
|
|
43
|
+
*/
|
|
44
|
+
export const reopenStaleCriteria = (state) => {
|
|
45
|
+
const reopened = [];
|
|
46
|
+
for (const criterion of Array.isArray(state?.criteria) ? state.criteria : []) {
|
|
47
|
+
if (criterion?.status !== "pass") continue;
|
|
48
|
+
const stale = staleInputs(criterion.evidence?.at(-1));
|
|
49
|
+
if (!stale.length) continue;
|
|
50
|
+
criterion.status = "stale";
|
|
51
|
+
criterion.staleInputs = stale;
|
|
52
|
+
reopened.push({ event: "evidence.stale", criterionId: criterion.id, staleInputs: stale });
|
|
53
|
+
}
|
|
54
|
+
return reopened;
|
|
55
|
+
};
|
|
@@ -11,7 +11,7 @@ export const appendLitgoalLedger = (path, entry) => {
|
|
|
11
11
|
};
|
|
12
12
|
appendFileSync(path, `${JSON.stringify(record)}\n`, { flag: STATE_APPEND_FLAG });
|
|
13
13
|
// Flush the appended record to disk for durability.
|
|
14
|
-
const fd = openSync(path, "r");
|
|
14
|
+
const fd = openSync(path, "r+");
|
|
15
15
|
fsyncSync(fd);
|
|
16
16
|
closeSync(fd);
|
|
17
17
|
return record;
|
|
@@ -26,7 +26,7 @@ export const writeLitgoalState = (path, state) => {
|
|
|
26
26
|
const tmpPath = `${path}.${process.pid}.${Date.now()}.tmp`;
|
|
27
27
|
writeFileSync(tmpPath, `${JSON.stringify(state, null, 2)}\n`, { flag: STATE_WRITE_FLAG });
|
|
28
28
|
// Flush tmp file data to disk before rename so the rename is durable.
|
|
29
|
-
const fd = openSync(tmpPath, "r");
|
|
29
|
+
const fd = openSync(tmpPath, "r+");
|
|
30
30
|
fsyncSync(fd);
|
|
31
31
|
closeSync(fd);
|
|
32
32
|
renameSync(tmpPath, path);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// The unknown register: unknowns are reduced while the work runs, not only while it is planned. Each item is
|
|
2
|
+
// KK (known known: needs a source), KU (known unknown), UK (unknown known: something only the user can answer)
|
|
3
|
+
// or UU (unknown unknown). An open KU/UK/UU needs a deterministic probe, closing one needs evidence, and an
|
|
4
|
+
// open critical item blocks completion.
|
|
5
|
+
import { LitgoalStateError } from "./state.mjs";
|
|
6
|
+
|
|
7
|
+
export const UNKNOWN_KINDS = Object.freeze(["KK", "KU", "UK", "UU"]);
|
|
8
|
+
|
|
9
|
+
/** Adds an item to `state.unknowns`; returns the stored record. */
|
|
10
|
+
export const addUnknown = (state, { kind, text, source, probe, critical, now }) => {
|
|
11
|
+
if (!UNKNOWN_KINDS.includes(kind)) throw new LitgoalStateError(`unknown kind must be one of: ${UNKNOWN_KINDS.join(", ")}`, 64);
|
|
12
|
+
if (!text) throw new LitgoalStateError("missing text", 64);
|
|
13
|
+
if (kind === "KK" && !source) throw new LitgoalStateError("a KK item needs --source", 64);
|
|
14
|
+
if (kind !== "KK" && !probe) throw new LitgoalStateError(`an open ${kind} item needs --probe: how it will be checked`, 64);
|
|
15
|
+
const unknowns = Array.isArray(state.unknowns) ? state.unknowns : [];
|
|
16
|
+
const record = {
|
|
17
|
+
id: `unknown-${unknowns.length + 1}`,
|
|
18
|
+
kind,
|
|
19
|
+
text,
|
|
20
|
+
...(source ? { source } : {}),
|
|
21
|
+
...(probe ? { probe } : {}),
|
|
22
|
+
critical: Boolean(critical),
|
|
23
|
+
status: kind === "KK" ? "known" : "open",
|
|
24
|
+
createdAt: now,
|
|
25
|
+
};
|
|
26
|
+
state.unknowns = [...unknowns, record];
|
|
27
|
+
return record;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** Closes an open item with the evidence that answered it; returns the updated record. */
|
|
31
|
+
export const resolveUnknown = (state, { id, evidence, now }) => {
|
|
32
|
+
const record = (Array.isArray(state.unknowns) ? state.unknowns : []).find((item) => item.id === id);
|
|
33
|
+
if (!record) throw new LitgoalStateError("unknown item not found");
|
|
34
|
+
if (record.status !== "open") throw new LitgoalStateError(`${id} is not open`);
|
|
35
|
+
if (!evidence) throw new LitgoalStateError("closing an unknown needs --evidence", 64);
|
|
36
|
+
record.status = "resolved";
|
|
37
|
+
record.evidence = evidence;
|
|
38
|
+
record.resolvedAt = now;
|
|
39
|
+
return record;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** Open items marked critical: any one of them blocks completion. */
|
|
43
|
+
export const openCriticalUnknowns = (state) =>
|
|
44
|
+
(Array.isArray(state?.unknowns) ? state.unknowns : []).filter((item) => item?.status === "open" && item.critical === true);
|
|
Binary file
|