@litfamily/litclaude 1.0.56 → 1.0.57
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 +9 -0
- package/README.md +8 -8
- package/README_ko-KR.md +8 -8
- package/docs/assets/readme/badge-version.svg +1 -1
- package/package.json +1 -1
- package/plugins/litclaude/.claude-plugin/plugin.json +1 -1
- package/plugins/litclaude/bin/litclaude-hook.js +45 -11
- package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
- package/plugins/litclaude/lib/goal-pipeline.mjs +23 -2
- package/plugins/litclaude/lib/mod/goal.mjs +1 -0
- package/plugins/litclaude/scripts/goal-propose.mjs +39 -3
- package/plugins/litclaude/skills/lit-loop/SKILL.md +10 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.57 - 2026-11-20
|
|
4
|
+
|
|
5
|
+
- A lit-loop, litwork or other run with no plan can now get a native `/goal` too. Once its failing check
|
|
6
|
+
exists, the loop asks one question, `Set goal for this lit-loop: /goal <cond>? (yes / no)`, where the
|
|
7
|
+
condition is that check exiting 0 with the objective done. When the project has a test command, the
|
|
8
|
+
prompt hook shows that question itself as the loop starts, so it never depends on the model asking. An exact `yes` lets the LitClaude mod run `/goal`
|
|
9
|
+
when that turn ends, the same way a plan's goal is set, and starts no start-work. A check that already
|
|
10
|
+
passes, cannot run or is not an allowlisted test command asks nothing. litgoal keeps its ready-to-paste line.
|
|
11
|
+
|
|
3
12
|
## 1.0.56 - 2026-11-20
|
|
4
13
|
|
|
5
14
|
- `litclaude-ai extensions prune-versions` lists the version folders older LitClaude installs left in
|
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
<p align="center"><picture><source media="(prefers-reduced-motion: reduce)" srcset="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
1
|
+
<p align="center"><picture><source media="(prefers-reduced-motion: reduce)" srcset="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/docs/assets/cover-motion-still.webp" /><img src="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/docs/assets/cover-motion.webp" width="100%" alt="LitFamily motion cover: seven armored robots power on one by one, the LitClaude robot wakes with glowing eyes and a lit frame, then LITFAMILY and KEEP THE WORK LIT. light up." /></picture></p>
|
|
2
2
|
|
|
3
3
|
<h1 align="center">LitClaude</h1>
|
|
4
4
|
<p align="center"><strong>Keep the work lit.</strong></p>
|
|
5
5
|
<p align="center">A Claude Code plugin that helps every session plan the work, build it, check it, and leave a note the next session can pick up.</p>
|
|
6
6
|
<p align="center">
|
|
7
|
-
<img src="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
8
|
-
<a href="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
7
|
+
<img src="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/docs/assets/readme/badge-version.svg" alt="1.0.57" />
|
|
8
|
+
<a href="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/LICENSE"><img src="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/docs/assets/readme/badge-license.svg" alt="MIT license" /></a>
|
|
9
9
|
</p>
|
|
10
10
|
<p align="center">
|
|
11
|
-
<a href="https://github.com/wjgoarxiv/litclaude#readme">Full guide and skills gallery on GitHub</a> · <a href="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
11
|
+
<a href="https://github.com/wjgoarxiv/litclaude#readme">Full guide and skills gallery on GitHub</a> · <a href="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/README_ko-KR.md">한국어</a>
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
14
|
Add `lit` to a Claude Code prompt and Claude pins the goal, writes a failing test first,
|
|
@@ -83,7 +83,7 @@ the `/plugin` menu.
|
|
|
83
83
|
## More
|
|
84
84
|
|
|
85
85
|
- [Full guide and skills gallery on GitHub](https://github.com/wjgoarxiv/litclaude#readme)
|
|
86
|
-
- [Privacy and network behavior](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
87
|
-
- [Migration and ownership conflicts](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
88
|
-
- [Release history](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
89
|
-
- [MIT license](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
86
|
+
- [Privacy and network behavior](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/docs/privacy.md)
|
|
87
|
+
- [Migration and ownership conflicts](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/docs/migration.md)
|
|
88
|
+
- [Release history](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/CHANGELOG.md)
|
|
89
|
+
- [MIT license](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/LICENSE)
|
package/README_ko-KR.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
<p align="center"><picture><source media="(prefers-reduced-motion: reduce)" srcset="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
1
|
+
<p align="center"><picture><source media="(prefers-reduced-motion: reduce)" srcset="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/docs/assets/cover-motion-still.webp" /><img src="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/docs/assets/cover-motion.webp" width="100%" alt="LitFamily 모션 커버: 일곱 로봇 패널이 차례로 켜지고, LitClaude 로봇의 눈과 테두리가 빛난 뒤 LITFAMILY와 KEEP THE WORK LIT. 문구가 밝아지는 영상" /></picture></p>
|
|
2
2
|
|
|
3
3
|
<h1 align="center">LitClaude</h1>
|
|
4
4
|
<p align="center"><strong>Keep the work lit.</strong></p>
|
|
5
5
|
<p align="center">Claude Code에서 세션마다 계획하고, 만들고, 확인한 뒤 다음 세션이 이어받을 기록을 남기게 돕는 플러그인입니다.</p>
|
|
6
6
|
<p align="center">
|
|
7
|
-
<img src="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
8
|
-
<a href="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
7
|
+
<img src="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/docs/assets/readme/badge-version.svg" alt="1.0.57" />
|
|
8
|
+
<a href="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/LICENSE"><img src="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/docs/assets/readme/badge-license.svg" alt="MIT license" /></a>
|
|
9
9
|
</p>
|
|
10
10
|
<p align="center">
|
|
11
|
-
<a href="https://github.com/wjgoarxiv/litclaude/blob/main/README_ko-KR.md">전체 안내와 스킬 갤러리는 GitHub에서</a> · <a href="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
11
|
+
<a href="https://github.com/wjgoarxiv/litclaude/blob/main/README_ko-KR.md">전체 안내와 스킬 갤러리는 GitHub에서</a> · <a href="https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/README.md">English</a>
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
14
|
Claude Code 프롬프트에 `lit`을 붙이면 Claude가 목표를 고정하고, 실패하는 테스트를 먼저 쓰고,
|
|
@@ -81,7 +81,7 @@ npx @litfamily/litclaude@latest uninstall
|
|
|
81
81
|
## 더 보기
|
|
82
82
|
|
|
83
83
|
- [전체 안내와 스킬 갤러리 (GitHub)](https://github.com/wjgoarxiv/litclaude/blob/main/README_ko-KR.md)
|
|
84
|
-
- [개인정보와 네트워크 동작](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
85
|
-
- [이전과 소유권 충돌](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
86
|
-
- [변경 이력](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
87
|
-
- [MIT 라이선스](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.
|
|
84
|
+
- [개인정보와 네트워크 동작](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/docs/privacy.md)
|
|
85
|
+
- [이전과 소유권 충돌](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/docs/migration.md)
|
|
86
|
+
- [변경 이력](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/CHANGELOG.md)
|
|
87
|
+
- [MIT 라이선스](https://cdn.jsdelivr.net/npm/@litfamily/litclaude@1.0.57/LICENSE)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="146" height="20" role="img" aria-label="release: 1.0.
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="146" height="20" role="img" aria-label="release: 1.0.57"><title>release: 1.0.57</title><g shape-rendering="crispEdges"><rect width="49" height="20" fill="#080d14"/><rect x="49" width="97" height="20" fill="#ff6337"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text x="255" y="140" textLength="390" transform="scale(.1)">release</text><text x="965" y="140" textLength="870" transform="scale(.1)" fill="#080D14">1.0.57</text></g></svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@litfamily/litclaude",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.57",
|
|
4
4
|
"description": "Claude Code plugin: add lit to a prompt and Claude plans, tests, checks and reviews the work, then leaves a handoff for the next session.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -69,6 +69,7 @@ import { inviteMessage, parseInvitePrompt, recordInvite, shareLine } from "../li
|
|
|
69
69
|
import { claimSessionExtensionsNotice } from "../lib/extensions-notice.mjs";
|
|
70
70
|
import { buildSkillPlan, installedExtensionPlugins, parseSkillHatch, skillPlanContext, skillPlanIds } from "../lib/skill-plan.mjs";
|
|
71
71
|
import { GOAL_DIR, GOAL_STATUS, consentAnswer, consentIsLive } from "../lib/goal-pipeline.mjs";
|
|
72
|
+
import { detectCheck, proposeLoopGoal } from "../scripts/goal-propose.mjs";
|
|
72
73
|
|
|
73
74
|
const formatDurablePlanNotice = (cwd) => {
|
|
74
75
|
try {
|
|
@@ -1173,14 +1174,39 @@ const objectiveTail = (prompt) => {
|
|
|
1173
1174
|
const raw = withoutCode(prompt);
|
|
1174
1175
|
const match = /\blit(?:work)?\b\s*(.*)$/isu.exec(raw);
|
|
1175
1176
|
const tail = (match?.[1] ?? raw).replace(
|
|
1176
|
-
/^\s*(?:-loop|-plan|goal|plan|workflow|dynamic\s+workflow|work)\b\s*/iu,
|
|
1177
|
+
/^\s*(?:-loop|-plan|loop|goal|plan|workflow|dynamic\s+workflow|work)\b\s*/iu,
|
|
1177
1178
|
"",
|
|
1178
1179
|
);
|
|
1179
1180
|
return normalizeGoalObjective(tail);
|
|
1180
1181
|
};
|
|
1181
1182
|
|
|
1182
|
-
|
|
1183
|
-
|
|
1183
|
+
// A run route gets one question and the mod sets the goal on the user's yes; litgoal, the hand-held
|
|
1184
|
+
// goal tool, keeps its ready-to-paste line.
|
|
1185
|
+
const LOOP_GOAL_LINE = "Native goal: LitClaude can set /goal for this run. Once one failing check proves the objective (after the RED test), run `node \"${CLAUDE_PLUGIN_ROOT}/scripts/goal-propose.mjs\" --loop --check \"<check>\" <objective>` and ask the line it prints once, as the last line of your reply; only the user's exact `yes` on the next prompt lets the LitClaude mod run /goal when that turn ends. If it prints `No goal set: <reason>`, or no single check proves the objective, go on without a goal and keep the durable `litgoal` ledger authoritative. Never type or send /goal yourself.";
|
|
1186
|
+
|
|
1187
|
+
const RUN_GOAL_ROUTES = new Set(["lit-loop", "native-workflow", "litwork", "lit-hijack"]);
|
|
1188
|
+
|
|
1189
|
+
// A run's first activation asks the goal question itself, shown to the user by the hook, when the project
|
|
1190
|
+
// has a test command and LitClaude owns or asks no goal yet. Returns { line, consent } or null.
|
|
1191
|
+
const offerLoopGoal = (discipline, input) => {
|
|
1192
|
+
if (!RUN_GOAL_ROUTES.has(discipline)) return null;
|
|
1193
|
+
try {
|
|
1194
|
+
const cwd = typeof input.cwd === "string" ? input.cwd : process.cwd();
|
|
1195
|
+
const objective = objectiveTail(input.prompt ?? "");
|
|
1196
|
+
if (!objective || readGoalFile(cwd, "owner.json") || readGoalFile(cwd, "consent.json")) return null;
|
|
1197
|
+
const check = detectCheck(cwd);
|
|
1198
|
+
if (!check) return null;
|
|
1199
|
+
const offer = proposeLoopGoal({ cwd, check, objective, falsifyNow: false });
|
|
1200
|
+
return offer.consent ? offer : null;
|
|
1201
|
+
} catch {
|
|
1202
|
+
return null;
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
|
|
1206
|
+
const goalBindingContext = ({ discipline, prompt, activeGoal, loopGoal }) => {
|
|
1207
|
+
if (loopGoal) return [`Native goal: LitClaude has shown the user this goal question: ${loopGoal.line} Do not ask it again. Never type or send /goal yourself: the user's exact \`yes\` on a later prompt lets the LitClaude mod run /goal when that turn ends. Until then, keep the durable \`litgoal\` ledger authoritative.`];
|
|
1208
|
+
if (RUN_GOAL_ROUTES.has(discipline)) return [LOOP_GOAL_LINE];
|
|
1209
|
+
if (discipline !== "litgoal") return [];
|
|
1184
1210
|
const guidance = buildNativeGoalBindingGuidance({ objective: objectiveTail(prompt), activeGoal });
|
|
1185
1211
|
if (!guidance.command) return [guidance.message];
|
|
1186
1212
|
return [`Native goal binding attempt: BLOCKED: native \`/goal\` not programmatically bound. READY_TO_PASTE: Copy, paste, and send this line in the current Claude Code session: ${guidance.command} Offer it to the user once. Do not auto-type or inject the user's slash commands. Keep the durable \`litgoal\` ledger authoritative.`];
|
|
@@ -1342,7 +1368,7 @@ const litworkContext = ({ command, skill, skillId, discipline, softConfirm, safe
|
|
|
1342
1368
|
...(agentId ? [`Native agent route: litclaude:${agentId}. Preserve the shipped agent permissions and delegation gates; a prompt hook does not launch or switch agents.`] : []),
|
|
1343
1369
|
...canonicalFamilySourceContext(discipline),
|
|
1344
1370
|
"Secret-bearing prompt material is never persisted raw; record only redacted summaries and evidence paths in durable state.",
|
|
1345
|
-
...goalBindingContext({ discipline, prompt: input.prompt, activeGoal: input.native_goal ?? input.active_goal ?? input.goal }),
|
|
1371
|
+
...goalBindingContext({ discipline, prompt: input.prompt, activeGoal: input.native_goal ?? input.active_goal ?? input.goal, loopGoal: input.loopGoal }),
|
|
1346
1372
|
llmContractReference,
|
|
1347
1373
|
...skillBodyPointerContext({ skillId, safetyBlock }),
|
|
1348
1374
|
"Dynamic workflow: propose one for broad, risky, parallel, or long-running work; call the Workflow tool only after the user opts in or the session already permits it.",
|
|
@@ -1556,11 +1582,18 @@ const goalConsentOf = (prompt, input) => {
|
|
|
1556
1582
|
if (!consent) return null;
|
|
1557
1583
|
const answer = consentAnswer(prompt);
|
|
1558
1584
|
dropGoalFile(cwd, "consent.json");
|
|
1559
|
-
const
|
|
1560
|
-
if (!answer || !consentIsLive(consent, Date.now()) || (
|
|
1585
|
+
const noEdit = consent.condition === null || consent.kind === "loop";
|
|
1586
|
+
if (!answer || !consentIsLive(consent, Date.now()) || (noEdit && answer === "edit")) return null;
|
|
1561
1587
|
return { cwd, consent, answer };
|
|
1562
1588
|
};
|
|
1563
|
-
const goalConsentTurn = ({ consent, answer }) => {
|
|
1589
|
+
const goalConsentTurn = ({ cwd, consent, answer }, sessionId) => {
|
|
1590
|
+
if (consent.kind === "loop") {
|
|
1591
|
+
if (answer === "no") return [`The user answered no to the lit-loop goal question, so no goal is set. Make the first line of your reply exactly \`${GOAL_STATUS.skipped("you said no")}\`, then go on with the lit-loop work.`, "LitClaude goal: not set."];
|
|
1592
|
+
const armed = writeGoalFile(cwd, "intent.json", { version: 1, condition: consent.condition, hash: consent.hash, id: consent.id, plan: null, sessionId, armedAt: new Date().toISOString() });
|
|
1593
|
+
return armed
|
|
1594
|
+
? [`The user approved the lit-loop goal with yes. Make the first line of your reply exactly \`${GOAL_STATUS.armed(consent.id)}\`, then go on with the lit-loop work: when this turn ends, LitClaude runs /goal with the approved condition. Do not run /goal yourself.`, "LitClaude goal: armed."]
|
|
1595
|
+
: [`The goal could not be armed. Make the first line of your reply exactly \`${GOAL_STATUS.notConfirmed(consent.condition)}\`, then go on with the lit-loop work.`, "LitClaude goal: not armed."];
|
|
1596
|
+
}
|
|
1564
1597
|
if (answer === "no") {
|
|
1565
1598
|
return consent.condition === null
|
|
1566
1599
|
? ["The user answered no to the plan approval question: start-work did not start. Ask how to go on with the plan in one sentence; start nothing.", "LitClaude plan: not started."]
|
|
@@ -1921,7 +1954,7 @@ switch (eventName) {
|
|
|
1921
1954
|
// takes that run over instead (D8).
|
|
1922
1955
|
// An exact `yes` to lit-plan's approval question is a typed start-work for that plan (R1).
|
|
1923
1956
|
const consentReply = trustedResume ? null : goalConsentOf(prompt, input);
|
|
1924
|
-
const approved = consentReply?.answer === "yes" ? consentReply : null;
|
|
1957
|
+
const approved = consentReply?.answer === "yes" && consentReply.consent.kind !== "loop" ? consentReply : null;
|
|
1925
1958
|
const briefed = trustedResume || approved ? null : briefedStep(prompt, input);
|
|
1926
1959
|
const parsedInvocation = trustedResume ? null : approved ? { kind: "start", plan: approved.consent.plan } : briefed?.invocation ?? parseStartWorkInvocation(prompt);
|
|
1927
1960
|
// `lit cancel` counts only as a prompt the user typed: a payload naming another event is not one.
|
|
@@ -1972,7 +2005,7 @@ switch (eventName) {
|
|
|
1972
2005
|
}
|
|
1973
2006
|
// approve, deny and cancel are answered here alone: no workflow trigger, ignition or stage record.
|
|
1974
2007
|
const settlesBoundary = Boolean(invocation) && invocation.kind !== "start";
|
|
1975
|
-
const goalAnswer = consentReply && !approved && !invocation ? goalConsentTurn(consentReply) : null;
|
|
2008
|
+
const goalAnswer = consentReply && !approved && !invocation ? goalConsentTurn(consentReply, typeof input.session_id === "string" ? input.session_id : null) : null;
|
|
1976
2009
|
const goalNote = approved ? approvedGoalNote(approved, { invoked, adoption, sessionId: typeof input.session_id === "string" ? input.session_id : null }) : "";
|
|
1977
2010
|
if (invocation?.kind === "cancel" && invoked) invoked.goalClear = requestGoalClear(typeof input.cwd === "string" ? input.cwd : null, "lit cancel");
|
|
1978
2011
|
const exactBareHandoff = isExactBareHandoff(prompt);
|
|
@@ -2079,14 +2112,15 @@ switch (eventName) {
|
|
|
2079
2112
|
} else if (trigger && trigger.discipline === "lit-comprehend") {
|
|
2080
2113
|
writeContext(withPromptRules(`${probeInstruction(trigger.discipline)}\n\n${comprehendContext(trigger)}`), activationMessage(trigger.discipline));
|
|
2081
2114
|
} else if (trigger) {
|
|
2082
|
-
const
|
|
2115
|
+
const loopGoal = reentry || trigger.safetyBlock ? null : offerLoopGoal(trigger.discipline, input);
|
|
2116
|
+
const systemMessage = loopGoal ? `${activationMessage(effectiveDiscipline)}\n${loopGoal.line}` : activationMessage(effectiveDiscipline);
|
|
2083
2117
|
let context = reentry?.context ?? (["frontend-ui-ux", "visual-qa"].includes(trigger.discipline)
|
|
2084
2118
|
? uiuxActivationContext({ ...trigger, uiMode: interfaceMode(normalizedTriggerText(prompt)) })
|
|
2085
2119
|
: ["lit-diagram-drawer", "lit-schematic", "lit-typographic-motion", "readme-studio"].includes(trigger.discipline)
|
|
2086
2120
|
? pointerStubActivationContext(trigger)
|
|
2087
2121
|
: ["lit-pptx", "lit-docx"].includes(trigger.discipline)
|
|
2088
2122
|
? officeActivationContext(trigger)
|
|
2089
|
-
: litworkContext(trigger, input));
|
|
2123
|
+
: litworkContext(trigger, loopGoal ? { ...input, loopGoal } : input));
|
|
2090
2124
|
if (skillPlan.plan) context = `${context}\n\n${skillPlanContext(skillPlan.plan, skillPlan.installed)}`;
|
|
2091
2125
|
if (!reentry) {
|
|
2092
2126
|
if (trigger.renameFrom) context = `${renameNote(trigger.renameFrom)}\n\n${context}`;
|
|
@@ -67,6 +67,14 @@ export const compileCondition = ({ plan, check }) => {
|
|
|
67
67
|
return { ok: true, condition, id };
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
+
/** A lit-loop's condition: its check exits 0 and its objective is done. No plan, so no rows. */
|
|
71
|
+
export const compileLoopCondition = ({ objective, check }) => {
|
|
72
|
+
const id = goalId(`loop\u0000${objective}`, check);
|
|
73
|
+
const condition = `\`${check}\` exits 0 and this is done: ${objective} [lit:${id}]`;
|
|
74
|
+
if (condition.length > GOAL_MAX_CHARS) return { ok: false, reason: `the condition is over ${GOAL_MAX_CHARS} characters; shorten the objective` };
|
|
75
|
+
return { ok: true, condition, id };
|
|
76
|
+
};
|
|
77
|
+
|
|
70
78
|
/** Rejects judgment words, outward-only success and conditions over the cap. */
|
|
71
79
|
export const lintCondition = (condition, check) => {
|
|
72
80
|
const reasons = [];
|
|
@@ -96,6 +104,16 @@ export const falsify = ({ cwd, plan, planText, check, timeoutMs = FALSIFY_TIMEOU
|
|
|
96
104
|
return { ok: true, open, exit: result.status };
|
|
97
105
|
};
|
|
98
106
|
|
|
107
|
+
/** A lit-loop has no unticked rows to keep its goal false, so its check must fail right now. */
|
|
108
|
+
export const falsifyLoop = ({ cwd, check, timeoutMs = FALSIFY_TIMEOUT_MS, run = spawnSync }) => {
|
|
109
|
+
const [cmd, ...args] = check.split(/\s+/u);
|
|
110
|
+
const result = run(cmd, args, { cwd, encoding: "utf8", timeout: timeoutMs, stdio: ["ignore", "ignore", "ignore"], shell: false });
|
|
111
|
+
if (result.error?.code === "ETIMEDOUT" || result.signal === "SIGTERM") return { ok: false, reason: `\`${check}\` did not finish within ${Math.round(timeoutMs / 1000)} s` };
|
|
112
|
+
if (result.error || result.status === 127) return { ok: false, reason: `\`${check}\` cannot run here` };
|
|
113
|
+
if (result.status === 0) return { ok: false, reason: `\`${check}\` already passes, so the goal would be met at once; write the failing test first` };
|
|
114
|
+
return { ok: true, exit: result.status };
|
|
115
|
+
};
|
|
116
|
+
|
|
99
117
|
/** `yes` (exactly, any case) arms; `edit` and `no` are answers too; anything else is no answer. */
|
|
100
118
|
export const consentAnswer = (prompt) => {
|
|
101
119
|
const text = String(prompt ?? "").trim().toLowerCase();
|
|
@@ -103,8 +121,11 @@ export const consentAnswer = (prompt) => {
|
|
|
103
121
|
};
|
|
104
122
|
|
|
105
123
|
/** The consent record is fresh and is the one the user is answering. */
|
|
106
|
-
export const consentIsLive = (consent, now) => Boolean(consent
|
|
107
|
-
&& (
|
|
124
|
+
export const consentIsLive = (consent, now) => Boolean(consent
|
|
125
|
+
&& (consent.kind === "loop"
|
|
126
|
+
? consent.plan === null && typeof consent.condition === "string" && consent.hash === conditionHash(consent.condition)
|
|
127
|
+
: typeof consent.plan === "string"
|
|
128
|
+
&& (typeof consent.condition === "string" ? consent.hash === conditionHash(consent.condition) : consent.condition === null && consent.hash === startOnlyHash(consent.plan)))
|
|
108
129
|
&& Number.isFinite(Date.parse(consent.askedAt)) && now - Date.parse(consent.askedAt) <= CONSENT_TTL_MS);
|
|
109
130
|
|
|
110
131
|
/** The hash a start-only question (no goal could be set) binds: the plan it would start. */
|
|
@@ -7,6 +7,7 @@ export const GOAL_DIR = ".litclaude/goal";
|
|
|
7
7
|
export const GOAL_STATUS = Object.freeze({
|
|
8
8
|
asked: (cond) => `Approve plan, start work and set goal: /goal ${cond}? (yes / edit / no)`,
|
|
9
9
|
startOnly: "Approve plan and start work? (yes / no)",
|
|
10
|
+
loopAsked: (cond) => `Set goal for this lit-loop: /goal ${cond}? (yes / no)`,
|
|
10
11
|
skipped: (reason) => `No goal set: ${reason}`,
|
|
11
12
|
notStarted: (why) => `No goal set: start-work did not start (${why})`,
|
|
12
13
|
armed: (id) => `LitClaude goal armed [lit:${id}]; it is set when this turn ends.`,
|
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
// (yes starts the work and arms the goal), or, when no goal can be set for a readable plan, the
|
|
7
7
|
// start-only question and the `No goal set: <reason>` line. It never sets a goal or starts work
|
|
8
8
|
// itself; only the user's exact `yes` on the next prompt does, through the prompt hook.
|
|
9
|
-
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
10
10
|
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
11
11
|
import { pathToFileURL } from "node:url";
|
|
12
12
|
|
|
13
|
-
import { GOAL_DIR, GOAL_STATUS, compileCondition, conditionHash, falsify, lintCondition, parseDoneWhen, startOnlyHash } from "../lib/goal-pipeline.mjs";
|
|
13
|
+
import { GOAL_DIR, GOAL_STATUS, compileCondition, compileLoopCondition, conditionHash, falsify, falsifyLoop, lintCondition, parseDoneWhen, startOnlyHash } from "../lib/goal-pipeline.mjs";
|
|
14
|
+
import { normalizeGoalObjective } from "../lib/native-goal-binding.mjs";
|
|
14
15
|
|
|
15
16
|
const record = (cwd, consent) => {
|
|
16
17
|
const dir = join(cwd, GOAL_DIR);
|
|
@@ -51,7 +52,42 @@ export const proposeGoal = ({ cwd, planArg, now = Date.now(), timeoutMs, run } =
|
|
|
51
52
|
return { line: GOAL_STATUS.asked(built.condition), consent };
|
|
52
53
|
};
|
|
53
54
|
|
|
55
|
+
// `goal-propose.mjs --loop --check "<cmd>" <objective...>`: lit-loop's question, once its failing check
|
|
56
|
+
// exists. With no settable goal it records nothing and prints only `No goal set: <reason>`.
|
|
57
|
+
// The project's own test command, for the question the prompt hook shows; null when there is none.
|
|
58
|
+
export const detectCheck = (cwd) => {
|
|
59
|
+
try {
|
|
60
|
+
if (typeof JSON.parse(readFileSync(join(cwd, "package.json"), "utf8"))?.scripts?.test === "string") return "npm test";
|
|
61
|
+
} catch {
|
|
62
|
+
// No readable package.json.
|
|
63
|
+
}
|
|
64
|
+
for (const [file, check] of [["pytest.ini", "pytest"], ["pyproject.toml", "pytest"], ["Cargo.toml", "cargo test"], ["go.mod", "go test ./..."]]) {
|
|
65
|
+
if (existsSync(join(cwd, file))) return check;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// falsifyNow: false skips the dry run (the prompt hook cannot wait on a test run); the objective clause
|
|
71
|
+
// still keeps such a goal false until the work is done.
|
|
72
|
+
export const proposeLoopGoal = ({ cwd, check, objective, now = Date.now(), timeoutMs, run, falsifyNow = true } = {}) => {
|
|
73
|
+
const goal = normalizeGoalObjective(String(objective ?? ""));
|
|
74
|
+
const command = String(check ?? "").trim();
|
|
75
|
+
if (!goal) return { line: GOAL_STATUS.skipped("name what the loop should finish") };
|
|
76
|
+
const built = compileLoopCondition({ objective: goal, check: command });
|
|
77
|
+
if (!built.ok) return { line: GOAL_STATUS.skipped(built.reason) };
|
|
78
|
+
const lint = lintCondition(built.condition, command);
|
|
79
|
+
if (!lint.ok) return { line: GOAL_STATUS.skipped(lint.reasons.join("; ")) };
|
|
80
|
+
const dry = falsifyNow ? falsifyLoop({ cwd, check: command, ...(timeoutMs ? { timeoutMs } : {}), ...(run ? { run } : {}) }) : { ok: true };
|
|
81
|
+
if (!dry.ok) return { line: GOAL_STATUS.skipped(dry.reason) };
|
|
82
|
+
const consent = { version: 1, kind: "loop", condition: built.condition, hash: conditionHash(built.condition), id: built.id, plan: null, objective: goal, askedAt: new Date(now).toISOString() };
|
|
83
|
+
record(cwd, consent);
|
|
84
|
+
return { line: GOAL_STATUS.loopAsked(built.condition), consent };
|
|
85
|
+
};
|
|
86
|
+
|
|
54
87
|
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
55
|
-
const
|
|
88
|
+
const [first, ...rest] = process.argv.slice(2);
|
|
89
|
+
const { line } = first === "--loop" && rest[0] === "--check"
|
|
90
|
+
? proposeLoopGoal({ cwd: process.cwd(), check: rest[1], objective: rest.slice(2).join(" ") })
|
|
91
|
+
: proposeGoal({ cwd: process.cwd(), planArg: first });
|
|
56
92
|
process.stdout.write(`${line}\n`);
|
|
57
93
|
}
|
|
@@ -174,11 +174,16 @@ slash command and this session may expose no model-facing goal tools. Bind goals
|
|
|
174
174
|
like this:
|
|
175
175
|
|
|
176
176
|
- LitClaude sets the native goal itself: lit-plan asks once (`Approve plan, start work and set goal: /goal <cond>? (yes / edit / no)`), and only the user's exact `yes` starts start-work on that plan, with the grants a typed `/litclaude:start-work <plan>` gets, and lets the LitClaude mod run `/goal <cond>` when that turn ends; it clears only the goal it set. Never clobber a different active goal without explicit replacement.
|
|
177
|
-
-
|
|
178
|
-
|
|
179
|
-
`
|
|
180
|
-
|
|
181
|
-
|
|
177
|
+
- A lit-loop with no plan gets one question too. When the project has a test command (`npm test`,
|
|
178
|
+
`pytest`, `cargo test`, `go test ./...`), the prompt hook shows the user
|
|
179
|
+
`Set goal for this lit-loop: /goal <cond>? (yes / no)` itself at the loop's first activation; do
|
|
180
|
+
not ask it again. Without one, once a failing check proves the objective (after the RED step), run
|
|
181
|
+
`node "${CLAUDE_PLUGIN_ROOT}/scripts/goal-propose.mjs" --loop --check "<check>" <objective>` and end
|
|
182
|
+
the reply with the line it prints; a check that already passes, cannot run or is not allowlisted
|
|
183
|
+
prints `No goal set: <reason>` and records nothing. Either way only the user's exact `yes` on a
|
|
184
|
+
later prompt arms it, and the LitClaude mod runs `/goal <cond>` when that turn ends.
|
|
185
|
+
- Without an armed goal, go on in degraded mode with the local evidence ledger. LitClaude never
|
|
186
|
+
types or sends `/goal` itself and never claims native activation without observed evidence.
|
|
182
187
|
- Forward-compat only: if a future Claude Code build exposes model-facing goal tools, prefer
|
|
183
188
|
them according to the no-clobber rule above.
|
|
184
189
|
- litgoal sets and keeps the finish line; lit-loop and start-work run toward it.
|