@litfamily/litmuse 0.1.15 → 0.1.16
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 +5 -0
- package/package.json +1 -1
- package/plugin/.muse-plugin/plugin.json +11 -11
- package/plugin/hooks/lib/goal.mjs +60 -1
- package/plugin/hooks/post-tool-use.mjs +1 -1
- package/plugin/hooks/pre-tool-use.mjs +3 -3
- package/plugin/hooks/user-prompt-submit.mjs +58 -2
- package/plugin/skills/lit-loop/SKILL.md +6 -0
- package/plugin/skills/lit-plan/scripts/goal-propose.mjs +15 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.16 — 2026-11-21
|
|
4
|
+
|
|
5
|
+
- A lit-loop or litwork run with no plan can now get a Muse goal too, asked once. When the project has a test command (`npm test`, `pytest`, `cargo test` or `go test ./...`) and the prompt names an objective, the prompt hook records one question at the run's first activation and tells the model to end its first reply with `Set goal for this lit-loop: /goal <check> exits 0 and this is done: <objective>? (yes / no)`. Muse shows no hook text, so that is the model's job and cannot be forced. An exact `yes` arms the goal, and the model sets it with `create_goal` the way a plan's goal is set, but starts no start-work; `no`, `edit` or any other prompt drops the question. With no test command the model asks after its failing check through `goal-propose.mjs --loop --check "<check>" <objective>`, which runs the check once and prints `No goal set: <reason>` when it already passes, cannot run or is not an allowlisted test command. A repeat of `lit`, `lit goal`, a plan, and a session that already holds an open goal or a pending question ask nothing.
|
|
6
|
+
- The hook code changed, so Muse asks you to approve the LitMuse hooks again after the update.
|
|
7
|
+
|
|
3
8
|
## 0.1.15 — 2026-11-18
|
|
4
9
|
|
|
5
10
|
- `lit-adhd` now answers "so what do I do now?" with a verdict card of about six lines: what changed since your last look in this project, the one thing to do with the exact text to type, why and what skipping it costs, what else waits on you, and what was not read. A versioned rule table picks the action from proven records only (a ticked plan, a finished start-work run, a commit), a push is always a question for you, and a card whose action rested on records that moved says the old action is withdrawn. `lit adhd detail` opens the KPI board and the per-session brief; `litmuse rewind --json` carries the card under `verdict`.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "litmuse",
|
|
4
4
|
"displayName": "LitMuse",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.16",
|
|
6
6
|
"description": "LitFamily workflows for Muse Code: bare lit activation, planning, evidence-bound execution, review, research, handoff and Korean prose care.",
|
|
7
7
|
"compat": {
|
|
8
8
|
"source": "native",
|
|
@@ -251,7 +251,7 @@
|
|
|
251
251
|
"node",
|
|
252
252
|
"hooks/session-start.mjs",
|
|
253
253
|
"--digest",
|
|
254
|
-
"
|
|
254
|
+
"a4a3defb933793e6"
|
|
255
255
|
],
|
|
256
256
|
"timeoutMs": 5000
|
|
257
257
|
},
|
|
@@ -262,7 +262,7 @@
|
|
|
262
262
|
"node",
|
|
263
263
|
"hooks/user-prompt-submit.mjs",
|
|
264
264
|
"--digest",
|
|
265
|
-
"
|
|
265
|
+
"02f7f133ee18fa8f"
|
|
266
266
|
],
|
|
267
267
|
"timeoutMs": 5000,
|
|
268
268
|
"statusMessage": "LitMuse route check"
|
|
@@ -274,7 +274,7 @@
|
|
|
274
274
|
"node",
|
|
275
275
|
"hooks/pre-tool-use.mjs",
|
|
276
276
|
"--digest",
|
|
277
|
-
"
|
|
277
|
+
"61284066a83e7bf9"
|
|
278
278
|
],
|
|
279
279
|
"timeoutMs": 5000
|
|
280
280
|
},
|
|
@@ -285,7 +285,7 @@
|
|
|
285
285
|
"node",
|
|
286
286
|
"hooks/post-tool-use.mjs",
|
|
287
287
|
"--digest",
|
|
288
|
-
"
|
|
288
|
+
"c6a96dd6cbac119d"
|
|
289
289
|
],
|
|
290
290
|
"timeoutMs": 5000
|
|
291
291
|
},
|
|
@@ -296,7 +296,7 @@
|
|
|
296
296
|
"node",
|
|
297
297
|
"hooks/post-tool-use-failure.mjs",
|
|
298
298
|
"--digest",
|
|
299
|
-
"
|
|
299
|
+
"f4d021c9a022292c"
|
|
300
300
|
],
|
|
301
301
|
"timeoutMs": 5000
|
|
302
302
|
},
|
|
@@ -307,7 +307,7 @@
|
|
|
307
307
|
"node",
|
|
308
308
|
"hooks/stop.mjs",
|
|
309
309
|
"--digest",
|
|
310
|
-
"
|
|
310
|
+
"60f1b3268eb85120"
|
|
311
311
|
],
|
|
312
312
|
"timeoutMs": 5000
|
|
313
313
|
},
|
|
@@ -318,7 +318,7 @@
|
|
|
318
318
|
"node",
|
|
319
319
|
"hooks/subagent-start.mjs",
|
|
320
320
|
"--digest",
|
|
321
|
-
"
|
|
321
|
+
"d8b88f8c7d564788"
|
|
322
322
|
],
|
|
323
323
|
"timeoutMs": 5000
|
|
324
324
|
},
|
|
@@ -329,7 +329,7 @@
|
|
|
329
329
|
"node",
|
|
330
330
|
"hooks/subagent-stop.mjs",
|
|
331
331
|
"--digest",
|
|
332
|
-
"
|
|
332
|
+
"99aa8e23fc29a0a2"
|
|
333
333
|
],
|
|
334
334
|
"timeoutMs": 5000
|
|
335
335
|
},
|
|
@@ -340,7 +340,7 @@
|
|
|
340
340
|
"node",
|
|
341
341
|
"hooks/session-end.mjs",
|
|
342
342
|
"--digest",
|
|
343
|
-
"
|
|
343
|
+
"0a3ad8b835c39886"
|
|
344
344
|
],
|
|
345
345
|
"timeoutMs": 5000
|
|
346
346
|
},
|
|
@@ -351,7 +351,7 @@
|
|
|
351
351
|
"node",
|
|
352
352
|
"hooks/pre-compact.mjs",
|
|
353
353
|
"--digest",
|
|
354
|
-
"
|
|
354
|
+
"1b0c8c166a3ae681"
|
|
355
355
|
],
|
|
356
356
|
"timeoutMs": 5000
|
|
357
357
|
}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
// `<project state root>/.litmuse/goal/`:
|
|
8
8
|
//
|
|
9
9
|
// consent.json written by goal-propose.mjs: the objective (or none), its hash and the plan (asked)
|
|
10
|
+
// A lit-loop run with no plan asks one too (kind "loop", plan null, condition = its check exits 0 and the
|
|
11
|
+
// objective is done); its `yes` arms the goal and starts no start-work.
|
|
10
12
|
// intent.json written by the prompt hook when `yes` started the work and a goal is due (armed)
|
|
11
13
|
// owner.json written by PostToolUse after `create_goal` set that exact objective (set by LitMuse)
|
|
12
14
|
//
|
|
@@ -15,8 +17,9 @@
|
|
|
15
17
|
// by hand is reported and left alone.
|
|
16
18
|
import { spawnSync } from 'node:child_process';
|
|
17
19
|
import { createHash } from 'node:crypto';
|
|
18
|
-
import { lstatSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
20
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
19
21
|
import { join } from 'node:path';
|
|
22
|
+
import { clip } from './redact.mjs';
|
|
20
23
|
|
|
21
24
|
export const GOAL_DIR = join('.litmuse', 'goal');
|
|
22
25
|
export const GOAL_MAX_CHARS = 500;
|
|
@@ -31,6 +34,7 @@ export const GOAL_STATUS = Object.freeze({
|
|
|
31
34
|
declined: 'Nothing started and no goal set: you said no',
|
|
32
35
|
notStarted: (why) => `Work not started and no goal set: ${why}`,
|
|
33
36
|
notRecorded: (plan) => `Approval not recorded for this session. Run: lit start ${plan}`,
|
|
37
|
+
loopAsked: (cond) => `Set goal for this lit-loop: /goal ${cond}? (yes / no)`,
|
|
34
38
|
skipped: (reason) => `No goal set: ${reason}`,
|
|
35
39
|
set: (id) => `LitMuse goal set [lit:${id}]`,
|
|
36
40
|
yours: 'Your own goal is active; LitMuse left it alone.',
|
|
@@ -94,6 +98,61 @@ export function lintCondition(condition, check) {
|
|
|
94
98
|
return { ok: reasons.length === 0, reasons };
|
|
95
99
|
}
|
|
96
100
|
|
|
101
|
+
/** A lit-loop has no plan rows: its condition is the check exiting 0 together with the objective being done. */
|
|
102
|
+
export function compileLoopCondition({ objective, check }) {
|
|
103
|
+
const id = goalId(`loop\u0000${objective}`, check);
|
|
104
|
+
const condition = `\`${check}\` exits 0 and this is done: ${objective} [lit:${id}]`;
|
|
105
|
+
if (condition.length > GOAL_MAX_CHARS) return { ok: false, reason: `the condition is over ${GOAL_MAX_CHARS} characters; shorten the objective` };
|
|
106
|
+
return { ok: true, condition, id };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The objective text of a run prompt as a goal may carry it: no slash lines, no credential, no backtick or `[lit:` tag, one line, 200 characters. */
|
|
110
|
+
export function normalizeLoopObjective(value) {
|
|
111
|
+
if (typeof value !== 'string') return '';
|
|
112
|
+
const lines = value.split(/\r?\n/u).filter((line) => !line.trimStart().startsWith('/')).join(' ');
|
|
113
|
+
return clip(lines.replace(/\[lit:[^\]]*\]/giu, ' ').replace(/`/gu, "'"), 200);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** The project's own test command, for the question the prompt hook asks; null when there is none. */
|
|
117
|
+
export function detectCheck(cwd) {
|
|
118
|
+
try {
|
|
119
|
+
if (typeof JSON.parse(readFileSync(join(cwd, 'package.json'), 'utf8'))?.scripts?.test === 'string') return 'npm test';
|
|
120
|
+
} catch { /* no readable package.json */ }
|
|
121
|
+
for (const [file, check] of [['pytest.ini', 'pytest'], ['pyproject.toml', 'pytest'], ['Cargo.toml', 'cargo test'], ['go.mod', 'go test ./...']]) {
|
|
122
|
+
if (existsSync(join(cwd, file))) return check;
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** A lit-loop has no unticked rows to keep its goal false, so its check must fail right now. */
|
|
128
|
+
export function falsifyLoop({ cwd, check, timeoutMs = FALSIFY_TIMEOUT_MS, run = spawnSync }) {
|
|
129
|
+
const [cmd, ...args] = check.split(/\s+/u);
|
|
130
|
+
const result = run(cmd, args, { cwd, encoding: 'utf8', timeout: timeoutMs, stdio: ['ignore', 'ignore', 'ignore'], shell: false });
|
|
131
|
+
if (result.error?.code === 'ETIMEDOUT' || result.signal === 'SIGTERM') return { ok: false, reason: `\`${check}\` did not finish within ${Math.round(timeoutMs / 1000)} s` };
|
|
132
|
+
if (result.error || result.status === 127) return { ok: false, reason: `\`${check}\` cannot run here` };
|
|
133
|
+
if (result.status === 0) return { ok: false, reason: `\`${check}\` already passes, so the goal would be met at once; write the failing test first` };
|
|
134
|
+
return { ok: true, exit: result.status };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The lit-loop question and its consent record (kind "loop", no plan), or the one `No goal set: <reason>` line.
|
|
139
|
+
* Pure: the caller writes the record. falsifyNow: false skips the dry run (the prompt hook cannot wait on a test run);
|
|
140
|
+
* the objective clause still keeps such a goal false until the work is done.
|
|
141
|
+
*/
|
|
142
|
+
export function buildLoopConsent({ cwd, check, objective, now = Date.now(), timeoutMs, run, falsifyNow = true, sessionId = null } = {}) {
|
|
143
|
+
const goal = normalizeLoopObjective(String(objective ?? ''));
|
|
144
|
+
const command = String(check ?? '').trim();
|
|
145
|
+
if (!goal) return { line: GOAL_STATUS.skipped('name what the loop should finish') };
|
|
146
|
+
const built = compileLoopCondition({ objective: goal, check: command });
|
|
147
|
+
if (!built.ok) return { line: GOAL_STATUS.skipped(built.reason) };
|
|
148
|
+
const lint = lintCondition(built.condition, command);
|
|
149
|
+
if (!lint.ok) return { line: GOAL_STATUS.skipped(lint.reasons.join('; ')) };
|
|
150
|
+
const dry = falsifyNow ? falsifyLoop({ cwd, check: command, ...(timeoutMs ? { timeoutMs } : {}), ...(run ? { run } : {}) }) : { ok: true };
|
|
151
|
+
if (!dry.ok) return { line: GOAL_STATUS.skipped(dry.reason) };
|
|
152
|
+
const consent = { version: 1, kind: 'loop', goal: true, condition: built.condition, hash: conditionHash(built.condition), id: built.id, plan: null, check: command, objective: goal, sessionId, askedAt: new Date(now).toISOString() };
|
|
153
|
+
return { line: GOAL_STATUS.loopAsked(built.condition), consent };
|
|
154
|
+
}
|
|
155
|
+
|
|
97
156
|
const openRows = (planText) => String(planText ?? '').split('\n').filter((line) => /^- \[ \] (?:\d+|F\d+)\. /u.test(line)).length;
|
|
98
157
|
|
|
99
158
|
/**
|
|
@@ -96,7 +96,7 @@ run((payload) => {
|
|
|
96
96
|
// (The pattern lives inside the function: run() may call back before a module-level const below it is initialised.)
|
|
97
97
|
function stampConsent(payload) {
|
|
98
98
|
const command = String(toolInput(payload)?.command ?? '');
|
|
99
|
-
if (!payload.session_id || !/(?:^|\s)\S*goal-propose\.mjs
|
|
99
|
+
if (!payload.session_id || !/(?:^|\s)\S*goal-propose\.mjs"?\s+(?:plans\/[A-Za-z0-9._-]+\.md\s*$|--loop\s+--check\s)/u.test(command)) return;
|
|
100
100
|
const root = resolveProjectStateRoot(workspaceOf(payload));
|
|
101
101
|
const consent = readGoalRecord(root, 'consent');
|
|
102
102
|
if (!consent || consent.sessionId || consent.answeredAt || Date.now() - Date.parse(consent.askedAt) > 2 * 60_000) return;
|
|
@@ -128,8 +128,8 @@ function isGoalPropose(command) {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
// A goal tagged `[lit:<id>]` exists only after the user's exact yes at plan approval
|
|
132
|
-
// intent of this session. An untagged goal is the user's own business and passes.
|
|
131
|
+
// A goal tagged `[lit:<id>]` exists only after the user's exact yes at plan approval or at a lit-loop's goal question: its
|
|
132
|
+
// objective must equal the armed intent of this session. An untagged goal is the user's own business and passes.
|
|
133
133
|
function litGoalRefusal(payload, input) {
|
|
134
134
|
const objective = objectiveOf(input);
|
|
135
135
|
if (!LIT_TAG.test(objective)) return null;
|
|
@@ -138,7 +138,7 @@ function litGoalRefusal(payload, input) {
|
|
|
138
138
|
intent = readGoalRecord(resolveProjectStateRoot(workspaceOf(payload)), 'intent');
|
|
139
139
|
} catch { /* unreadable reads as no intent */ }
|
|
140
140
|
if (intent && !intent.consumedAt && intent.condition === objective && (!intent.sessionId || intent.sessionId === payload.session_id)) return null;
|
|
141
|
-
return 'LitMuse sets a [lit:…] goal only after the user typed yes to
|
|
141
|
+
return 'LitMuse sets a [lit:…] goal only after the user typed yes to a LitMuse goal question (plan approval or a lit-loop), with that exact objective. Ask the question again (run goal-propose) instead of creating it.';
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
run((payload) => {
|
|
@@ -7,7 +7,7 @@ import { applyStackEvent, readStack, writeStack, resolveProjectStateRoot, READ_O
|
|
|
7
7
|
import { isGoPrompt, takeNextStep } from './lib/next-step.mjs';
|
|
8
8
|
import { ROUTE_INTENTS } from './lib/routes.mjs';
|
|
9
9
|
import { buildSkillPlan, matchedSkills, parseSkillHatch, skillPlanContext, skillPlanIds } from './lib/skill-plan.mjs';
|
|
10
|
-
import { GOAL_STATUS, consentAnswer, consentIsLive, readGoalRecord, writeGoalRecord } from './lib/goal.mjs';
|
|
10
|
+
import { GOAL_STATUS, buildLoopConsent, consentAnswer, consentIsLive, detectCheck, dropGoalRecord, normalizeLoopObjective, readGoalRecord, writeGoalRecord } from './lib/goal.mjs';
|
|
11
11
|
import { readFileSync, writeFileSync, mkdirSync, readdirSync, statSync } from 'node:fs';
|
|
12
12
|
import { resolve, join, dirname } from 'node:path';
|
|
13
13
|
|
|
@@ -224,9 +224,10 @@ function startRefusal(payload, plan) {
|
|
|
224
224
|
// objective. When the start is refused, no goal is armed either.
|
|
225
225
|
function goalAnswer(payload) {
|
|
226
226
|
const answer = consentAnswer(payload.prompt);
|
|
227
|
-
if (!answer) return false;
|
|
228
227
|
const root = resolveProjectStateRoot(workspaceOf(payload));
|
|
229
228
|
const consent = readGoalRecord(root, 'consent');
|
|
229
|
+
if (consent?.kind === 'loop') return consentIsLive(consent) ? loopGoalAnswer(payload, root, consent, answer) : false;
|
|
230
|
+
if (!answer) return false;
|
|
230
231
|
if (!consentIsLive(consent)) return false;
|
|
231
232
|
// Only the session that was asked can answer. A yes typed elsewhere (or on a question no session was stamped on)
|
|
232
233
|
// starts nothing, but says why and how to start the plan instead of passing silently.
|
|
@@ -285,6 +286,59 @@ function goalAnswer(payload) {
|
|
|
285
286
|
return true;
|
|
286
287
|
}
|
|
287
288
|
|
|
289
|
+
// The answer to a lit-loop's goal question. Only the session that was asked can answer, and the question lives for one
|
|
290
|
+
// prompt: an exact `yes` arms the goal and starts no start-work (the loop goes on as it was), `no` sets nothing, and any
|
|
291
|
+
// other prompt (`edit` is not an answer here) drops the question and is read as ordinary text.
|
|
292
|
+
function loopGoalAnswer(payload, root, consent, answer) {
|
|
293
|
+
if (!consent.sessionId || consent.sessionId !== (payload.session_id ?? null)) return false;
|
|
294
|
+
const route = readSession(payload)?.route;
|
|
295
|
+
if (READ_ONLY_DISCIPLINES.includes(route)) return false;
|
|
296
|
+
dropGoalRecord(root, 'consent');
|
|
297
|
+
if (answer !== 'yes' && answer !== 'no') return false;
|
|
298
|
+
const head = banner('LIT CONTINUES', route ?? 'lit-loop');
|
|
299
|
+
if (answer === 'no') {
|
|
300
|
+
emitContext('UserPromptSubmit', [...head, `The user answered no to the lit-loop goal question, so no goal is set. Show this line as given: ${GOAL_STATUS.skipped('you said no')}, then go on with the lit-loop work.`].join('\n'));
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
writeGoalRecord(root, 'intent', { version: 1, condition: consent.condition, hash: consent.hash, id: consent.id, plan: null, check: consent.check, sessionId: payload.session_id ?? null, armedAt: new Date().toISOString() });
|
|
304
|
+
emitContext('UserPromptSubmit', [
|
|
305
|
+
...head,
|
|
306
|
+
'The user answered yes to the lit-loop goal question: the goal is approved and the loop work goes on as it was; no start-work run starts.',
|
|
307
|
+
`Before the next step, set the goal: call get_goal. With no unfinished goal, call create_goal with objective exactly \`${consent.condition}\` and nothing else. With an unfinished goal already there, leave it untouched and show: ${GOAL_STATUS.yours} If create_goal is refused, show: ${GOAL_STATUS.notConfirmed(consent.condition)}`,
|
|
308
|
+
`When \`${consent.check}\` exits 0 and the objective is done, call update_goal with status complete and show: ${GOAL_STATUS.met(consent.id)}. On a BLOCKED stop, call update_goal with status blocked and show: ${GOAL_STATUS.cleared(consent.id, 'blocked')}.`,
|
|
309
|
+
].join('\n'));
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// A run route's first activation asks one goal question when the prompt names an objective, and no goal of this session is
|
|
314
|
+
// open and no question is pending. With a test command the hook records the question itself (no test run here) and tells the
|
|
315
|
+
// model to end its first reply with it: Muse shows no hook text, so this is advisory. Without one, the model asks it after
|
|
316
|
+
// its RED check through goal-propose --loop, which dry-runs and refuses a check that already passes.
|
|
317
|
+
const RUN_GOAL_ROUTES = new Set(['lit-loop', 'litwork']);
|
|
318
|
+
function loopGoalNote(hit, payload) {
|
|
319
|
+
try {
|
|
320
|
+
if (!RUN_GOAL_ROUTES.has(hit.route) || hit.bare || hit.resume || hit.trailing || !safeId(payload.session_id)) return null;
|
|
321
|
+
const task = typeof hit.task === 'string' ? hit.task : String(payload.prompt ?? '').replace(/^\s*\/?(?:litmuse:)?(?:lit-loop|litwork)\b[\s:,.!?]*/iu, '');
|
|
322
|
+
const objective = normalizeLoopObjective(task);
|
|
323
|
+
if (!objective) return null;
|
|
324
|
+
const cwd = workspaceOf(payload);
|
|
325
|
+
const root = resolveProjectStateRoot(cwd);
|
|
326
|
+
const owner = readGoalRecord(root, 'owner');
|
|
327
|
+
if ((owner && !owner.closed && owner.sessionId === payload.session_id) || consentIsLive(readGoalRecord(root, 'consent'))) return null;
|
|
328
|
+
const check = detectCheck(cwd);
|
|
329
|
+
if (!check) {
|
|
330
|
+
const propose = join(PLUGIN_ROOT, 'skills', 'lit-plan', 'scripts', 'goal-propose.mjs');
|
|
331
|
+
return `Native goal: LitMuse can set a goal for this run. Once one failing check proves the objective (after the RED test), run \`node ${propose} --loop --check "<check>" <objective>\` and end that reply with the line it prints, asked once. Only the user's exact \`yes\` on a later prompt arms it, and you then call create_goal with that exact objective; do not call create_goal for this run before that. When it prints \`No goal set: <reason>\`, or no single check proves the objective, go on without a goal and keep the ledger authoritative. Never type or send /goal yourself.`;
|
|
332
|
+
}
|
|
333
|
+
const offer = buildLoopConsent({ cwd, check, objective, falsifyNow: false, sessionId: payload.session_id });
|
|
334
|
+
if (!offer.consent) return null;
|
|
335
|
+
writeGoalRecord(root, 'consent', offer.consent);
|
|
336
|
+
return `Native goal: LitMuse recorded one goal question for this run. End your first reply with exactly this line, as its last line and asked once: ${offer.line} Never type or send /goal yourself. Do not call create_goal for this run before the user's exact \`yes\` on a later prompt; the hook then gives you the objective. Until then keep the ledger authoritative.`;
|
|
337
|
+
} catch {
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
288
342
|
// `lit cancel` while this session owns an open LitMuse goal: close that goal only, never a goal the user set.
|
|
289
343
|
function cancelOwnedGoal(payload) {
|
|
290
344
|
if (!/^\s*\/?(?:litmuse:)?lit\s+cancel\s*$/iu.test(String(payload.prompt ?? ''))) return null;
|
|
@@ -413,7 +467,9 @@ run((payload) => {
|
|
|
413
467
|
writeSession(payload, { route: hit.route, turnId, activatedAt: Date.now(), stopHeldFor: null, pauseRequested });
|
|
414
468
|
stackStart(payload, hit.route, runPlan ? { plan: runPlan } : undefined, hit.restart);
|
|
415
469
|
recordRoute(payload, { route: hit.route, keyword: hit.keyword ?? null, kind: 'ignite', plan: runPlan, activatedAt: Date.now(), skills: skillPlanIds(skillPlan) });
|
|
470
|
+
const loopGoal = loopGoalNote(hit, payload);
|
|
416
471
|
emitContext('UserPromptSubmit', activation(hit, payload)
|
|
472
|
+
+ (loopGoal ? `\n${loopGoal}` : '')
|
|
417
473
|
+ (named ? `\nPlan: ${named}. The typed command is the approval: the work starts without a separate approval turn; work through its open rows in order.` : '')
|
|
418
474
|
+ (skillPlan ? `\n${skillPlanContext(skillPlan)}` : ''));
|
|
419
475
|
});
|
|
@@ -93,6 +93,12 @@ Write criteria before editing. Each names a command or an observation on a surfa
|
|
|
93
93
|
|
|
94
94
|
Durable path: create or reuse the record per `litgoal` (`read_skill` id `plugin:litmuse:litgoal` when the record is missing), every criterion `open`. litgoal also mirrors the objective into Muse's native goal (`get_goal` first, then `create_goal` when none matches); this loop leaves that tool's state to litgoal and updates the record and ledger itself. Ask the user to confirm only when a criterion rests on a guess about intent.
|
|
95
95
|
|
|
96
|
+
Native goal for a loop with no plan: LitMuse asks one question per run and the user's exact `yes` arms it, the way a plan's approval does but without starting `start-work`.
|
|
97
|
+
|
|
98
|
+
- When the project has a test command (`npm test`, `pytest`, `cargo test`, `go test ./...`) and the prompt names an objective, the prompt hook records the question at the loop's first activation and its context hands you the line. Muse shows no hook text, so end your first reply with exactly `Set goal for this lit-loop: /goal <condition>? (yes / no)`, once, with the condition the hook gave (`` `<check>` exits 0 and this is done: <objective> [lit:<id>] ``). Do not ask it again later.
|
|
99
|
+
- Without a test command, run `node <skill-dir-of-lit-plan>/scripts/goal-propose.mjs --loop --check "<check>" <objective>` once a failing check proves the objective (after the RED step) and end that reply with the line it prints. The script runs the check once: a check that already passes, cannot run or is not an allowlisted test command prints `No goal set: <reason>` and records nothing, and you go on without a goal.
|
|
100
|
+
- Only the user's exact `yes` (any case) on the next prompt arms it: the hook then tells you to call `get_goal` and, with no unfinished goal, `create_goal` with that exact objective (PreToolUse refuses any other `[lit:…]` objective), and to call `update_goal` with `complete` once the check exits 0 and the objective is done. `no` or any other prompt, including `edit`, drops the question. Never type `/goal` yourself and never call `create_goal` for this run before that `yes`; a goal the user set by hand stays untouched.
|
|
101
|
+
|
|
96
102
|
For a goal with several units, write a dependency map before delegating:
|
|
97
103
|
|
|
98
104
|
```text
|
|
@@ -6,10 +6,14 @@
|
|
|
6
6
|
// goal, or, when no goal is possible, the start-only question and the one `No goal set: <reason>` line. An unreadable
|
|
7
7
|
// plan prints that reason alone. It never starts work or sets a goal; only the user's exact `yes` does both. The lit-plan write guard allows
|
|
8
8
|
// this one command during a planning turn.
|
|
9
|
+
// `node <skill-dir>/scripts/goal-propose.mjs --loop --check "<check>" <objective...>` is the lit-loop form: a run with no
|
|
10
|
+
// plan asks one goal question once its failing check exists (the check must fail now; a check that already passes, cannot
|
|
11
|
+
// run or is not allowlisted records nothing and prints only `No goal set: <reason>`). Its `yes` arms the goal and starts no
|
|
12
|
+
// start-work.
|
|
9
13
|
import { readFileSync } from 'node:fs';
|
|
10
14
|
import { isAbsolute, relative, resolve } from 'node:path';
|
|
11
15
|
import { pathToFileURL } from 'node:url';
|
|
12
|
-
import { GOAL_STATUS, compileCondition, conditionHash, consentKey, falsify, lintCondition, parseDoneWhen, writeGoalRecord } from '../../../hooks/lib/goal.mjs';
|
|
16
|
+
import { GOAL_STATUS, buildLoopConsent, compileCondition, conditionHash, consentKey, falsify, lintCondition, parseDoneWhen, writeGoalRecord } from '../../../hooks/lib/goal.mjs';
|
|
13
17
|
import { resolveProjectStateRoot } from '../../../hooks/lib/workflow-stack.mjs';
|
|
14
18
|
|
|
15
19
|
export function proposeGoal({ cwd, planArg, now = Date.now(), timeoutMs, run, sessionId = null } = {}) {
|
|
@@ -44,7 +48,16 @@ export function proposeGoal({ cwd, planArg, now = Date.now(), timeoutMs, run, se
|
|
|
44
48
|
return { line: GOAL_STATUS.asked(built.condition), consent };
|
|
45
49
|
}
|
|
46
50
|
|
|
51
|
+
export function proposeLoopGoal({ cwd, check, objective, now = Date.now(), timeoutMs, run, sessionId = null } = {}) {
|
|
52
|
+
const proposed = buildLoopConsent({ cwd, check, objective, now, timeoutMs, run, sessionId });
|
|
53
|
+
if (proposed.consent) writeGoalRecord(resolveProjectStateRoot(cwd), 'consent', proposed.consent);
|
|
54
|
+
return proposed;
|
|
55
|
+
}
|
|
56
|
+
|
|
47
57
|
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
48
|
-
const
|
|
58
|
+
const [first, ...rest] = process.argv.slice(2);
|
|
59
|
+
const { line } = first === '--loop' && rest[0] === '--check'
|
|
60
|
+
? proposeLoopGoal({ cwd: process.cwd(), check: rest[1], objective: rest.slice(2).join(' ') })
|
|
61
|
+
: proposeGoal({ cwd: process.cwd(), planArg: first });
|
|
49
62
|
process.stdout.write(`${line}\n`);
|
|
50
63
|
}
|