@quolu/lattice 0.85.5 → 0.86.1
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/bin/lattice.mjs +2 -2
- package/package.json +1 -1
- package/src/cli-help.mjs +11 -4
- package/src/plan-revise.mjs +19 -2
- package/src/project-cli.mjs +2 -0
- package/src/todo-cli.mjs +70 -4
- package/src/todo-parallel-candidates.mjs +2 -0
package/bin/lattice.mjs
CHANGED
|
@@ -140,7 +140,7 @@ if (help !== null) {
|
|
|
140
140
|
} else if (args[0] === 'plan' && args[1] === 'revise') {
|
|
141
141
|
const { matchFlagCommand } = await import('../src/todo-authoring-input.mjs');
|
|
142
142
|
const spec = {
|
|
143
|
-
known: ['input', 'dry-run', 'json'], required: ['input'], booleans: ['dry-run', 'json'],
|
|
143
|
+
known: ['plan', 'input', 'dry-run', 'json'], required: ['input'], booleans: ['dry-run', 'json'],
|
|
144
144
|
};
|
|
145
145
|
const flags = matchFlagCommand(args, ['plan', 'revise'], spec);
|
|
146
146
|
if (flags === null || flags.json !== true) {
|
|
@@ -150,7 +150,7 @@ if (help !== null) {
|
|
|
150
150
|
const { runPlanRevise } = await import('../src/plan-revise.mjs');
|
|
151
151
|
const { projectCliFailure } = await import('../src/project-cli.mjs');
|
|
152
152
|
try {
|
|
153
|
-
process.exitCode = await runPlanRevise({ cwd: process.cwd(), inputRef: flags.input,
|
|
153
|
+
process.exitCode = await runPlanRevise({ cwd: process.cwd(), inputRef: flags.input, planKey: flags.plan,
|
|
154
154
|
dryRun: flags['dry-run'] === true, stdout: process.stdout, env: process.env });
|
|
155
155
|
} catch (error) {
|
|
156
156
|
process.exitCode = projectCliFailure(process.stderr, error, { command: 'revise', flags });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quolu/lattice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.86.1",
|
|
4
4
|
"description": "Schedulability compiler for multi-agent development: observe real code boundaries, refactor the conflicting seam, recompile the plan for parallel execution",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Quo / クオ at kitepon.dev",
|
package/src/cli-help.mjs
CHANGED
|
@@ -31,7 +31,8 @@ Commands:
|
|
|
31
31
|
create --schema-version <1|2|3|4|5> --json
|
|
32
32
|
create --template --json # 作者が書くkeyだけの最小のv5入力(そのままplan createが受理する)
|
|
33
33
|
backchain --schema --json # 最終成果から必要な機能を逆算する入力契約
|
|
34
|
-
revise --input <file> [--dry-run] [--json]
|
|
34
|
+
revise [--plan <key>] --input <file> [--dry-run] [--json]
|
|
35
|
+
# --planは任意。入力にplan_keyが無ければ補い、違えばplan_revise_plan_key_mismatchで断る
|
|
35
36
|
# 改訂後の計画の全体を、plan createと同じ形で渡す(plan create --template --jsonから始められる)。
|
|
36
37
|
# 継続方針を自分で書くなら {"schema":"lattice.plan_revise_input.v1","desired":<計画>,"continuity":[...]}
|
|
37
38
|
revise --schema --json
|
|
@@ -97,7 +98,7 @@ Read commands:
|
|
|
97
98
|
verify [--plan <key>] [--json]
|
|
98
99
|
snapshot --rebuild --plan <key>
|
|
99
100
|
gantt serve --port <port> [--scope live|all] # 動的表示。opt-in済みplanは工程図と別の構造検査面を持つ
|
|
100
|
-
phase status --plan <key>
|
|
101
|
+
phase status --plan <key> [--json]
|
|
101
102
|
|
|
102
103
|
Write commands:
|
|
103
104
|
repair-eol --json # Git checkoutでCRLF化された既存storeをcanonical LFへ戻し、EOL保護を追加する
|
|
@@ -121,6 +122,10 @@ Write commands:
|
|
|
121
122
|
block --plan <key> --task <id> --reason <text>
|
|
122
123
|
unblock --plan <key> --task <id>
|
|
123
124
|
retire --plan <key> --task <id> --reason <text>
|
|
125
|
+
# 1件を閉じる。planは書き直さず、他のtaskの状態とjournalはそのまま
|
|
126
|
+
add --plan <key> --task <id> --title <text> [--phase <id>] [--lane <lane>] [--done-condition <text>]
|
|
127
|
+
[--design-memo <text>] [--after <id>[,<id>...]] [--before <id>[,<id>...]] [--reason <text>]
|
|
128
|
+
# 1件を足す(a39)。planの全体を書かずに軽量改訂で新plan_versionを作り、他のtaskはcarry
|
|
124
129
|
done --plan <key> --task <id> [--evidence <file>] [--message <text>]
|
|
125
130
|
# taskを閉じる。どちらも省略でき、両方なら本文がfileを名指す(A58)。--evidenceはdescriptor JSONでも証拠本文でもよい。repo内なら絶対path可。
|
|
126
131
|
# 既にdoneなら何も足さずunchanged:trueで成功する(a12)
|
|
@@ -253,7 +258,7 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
253
258
|
'plan show': 'plan show <plan_key> --json',
|
|
254
259
|
'plan scope-review': 'plan scope-review --plan-input <plan-create-or-extraction.json> --review <scope-review.json> --json | --schema --json',
|
|
255
260
|
'plan backchain': 'plan backchain --input <file> [--dry-run] [--json] | --schema --json',
|
|
256
|
-
'plan revise': 'plan revise --input <file> [--dry-run] [--json] | --schema --json\n\n'
|
|
261
|
+
'plan revise': 'plan revise [--plan <key>] --input <file> [--dry-run] [--json] | --schema --json\n\n'
|
|
257
262
|
+ '--input: the whole desired plan in the same shape as `plan create` (start from `plan create --template --json`),\n'
|
|
258
263
|
+ 'or {"schema":"lattice.plan_revise_input.v1","desired":<that plan>,"continuity":[{task_id, policy: carry|reset|retire, reason}]}.\n'
|
|
259
264
|
+ 'Without continuity the machine computes carry/reset/retire. A plan_key with no active plan is made with `plan create`.',
|
|
@@ -313,7 +318,7 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
313
318
|
'todo dashboard remove': 'todo dashboard remove <project_id> --json # 登録簿から1件外す(対象repo不在でも可)',
|
|
314
319
|
'todo phase': 'todo phase <status|review|accept|reject|reopen|close-unaudited> --plan <key> [options]'
|
|
315
320
|
+ ' | baseline --reason <text> [--except <plan_key>]...',
|
|
316
|
-
'todo phase status': 'todo phase status --plan <key>',
|
|
321
|
+
'todo phase status': 'todo phase status --plan <key> [--json]',
|
|
317
322
|
'todo phase review': 'todo phase review --plan <key> --phase <id> --reason <text>',
|
|
318
323
|
'todo phase accept': 'todo phase accept --plan <key> --phase <id> --evidence <file> | --input <file>',
|
|
319
324
|
'todo phase reject': 'todo phase reject --plan <key> --phase <id> --reason <text> --evidence <file> | --input <file>',
|
|
@@ -325,6 +330,8 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
325
330
|
'todo block': 'todo block --plan <key> --task <id> --reason <text>',
|
|
326
331
|
'todo unblock': 'todo unblock --plan <key> --task <id>',
|
|
327
332
|
'todo retire': 'todo retire --plan <key> --task <id> --reason <text>',
|
|
333
|
+
'todo add': 'todo add --plan <key> --task <id> --title <text> [--phase <id>] [--lane <lane>] [--done-condition <text>]'
|
|
334
|
+
+ ' [--design-memo <text>] [--after <id>[,<id>...]] [--before <id>[,<id>...]] [--reason <text>]',
|
|
328
335
|
'todo done': 'todo done --plan <key> --task <id> [--evidence <file>] [--message <text>] [--test-result <markdown-file>]',
|
|
329
336
|
'todo reopen': 'todo reopen --plan <key> --task <id> --reason <text> [--override-reason <text>]',
|
|
330
337
|
'todo evidence': 'todo evidence promote --plan <key> --task <id> --evidence <file>',
|
package/src/plan-revise.mjs
CHANGED
|
@@ -412,14 +412,31 @@ export async function applyPlanRevision({
|
|
|
412
412
|
return result;
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
-
|
|
415
|
+
/** a39: `--plan` names the plan as every todo write does; it fills a missing plan_key and must match a written one. */
|
|
416
|
+
export function applyPlanFlag(input, planKey) {
|
|
417
|
+
if (planKey === undefined || !isRecord(input)) return input;
|
|
418
|
+
const wrapped = !isBareCreateInput(input) && isRecord(input.desired);
|
|
419
|
+
const target = wrapped ? input.desired : input;
|
|
420
|
+
if (target.plan_key === undefined) return wrapped ? { ...input, desired: { ...target, plan_key: planKey } }
|
|
421
|
+
: { ...input, plan_key: planKey };
|
|
422
|
+
if (target.plan_key !== planKey) {
|
|
423
|
+
fail('plan_revise_plan_key_mismatch', wrapped ? '/desired/plan_key' : '/plan_key', {
|
|
424
|
+
expected: planKey, actual: target.plan_key,
|
|
425
|
+
next_action: `--plan is "${planKey}" but the input revises "${target.plan_key}": make them the same, or drop --plan (the input's plan_key names the plan).`,
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
return input;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export async function runPlanRevise({ cwd, inputRef, planKey, stdout, dryRun = false, env = process.env }) {
|
|
416
432
|
let repoRoot;
|
|
417
433
|
try {
|
|
418
434
|
repoRoot = path.resolve(gitSync(['rev-parse', '--show-toplevel'], {
|
|
419
435
|
cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'],
|
|
420
436
|
}).replace(/\r?\n$/u, ''));
|
|
421
437
|
} catch { throw new TodoStoreError('REPO_UNRESOLVED', 'git_toplevel_unresolved'); }
|
|
422
|
-
const input =
|
|
438
|
+
const input = applyPlanFlag(
|
|
439
|
+
await readAuthoringJsonFile(repoRoot, inputRef, { invalidCode: 'INPUT_INVALID' }), planKey);
|
|
423
440
|
const result = await applyPlanRevision({ repoRoot, input, env, dryRun });
|
|
424
441
|
stdout.write(`${JSON.stringify(result)}\n`);
|
|
425
442
|
return 0;
|
package/src/project-cli.mjs
CHANGED
|
@@ -1002,6 +1002,8 @@ export async function runPlanShow({ cwd, planKey, stdout }) {
|
|
|
1002
1002
|
phase_id: phaseInput ? task.phase_id : null,
|
|
1003
1003
|
state: stateByTaskId.get(task.task_id).status,
|
|
1004
1004
|
done_condition: task.done_condition ?? null,
|
|
1005
|
+
// a39: with design_memo, plan show holds every authored field a plan revise input needs.
|
|
1006
|
+
design_memo: task.design_memo ?? null,
|
|
1005
1007
|
depends_on_count: dependsOnCount.get(task.task_id) ?? 0,
|
|
1006
1008
|
}));
|
|
1007
1009
|
|
package/src/todo-cli.mjs
CHANGED
|
@@ -292,7 +292,7 @@ const TODO_COMMAND_NAMES = Object.freeze([
|
|
|
292
292
|
'status', 'show', 'note', 'bindings', 'display', 'independence', 'structure', 'seam-profile', 'seam-proposal',
|
|
293
293
|
'verify', 'repair-eol', 'snapshot', 'gantt', 'dashboard', 'phase', 'migrate', 'start', 'block',
|
|
294
294
|
'unblock', 'retire', 'done', 'reopen', 'evidence', 'split', 'revise', 'revise-phase', 'revise-set',
|
|
295
|
-
'retract', 'dependency',
|
|
295
|
+
'retract', 'dependency', 'add',
|
|
296
296
|
]);
|
|
297
297
|
|
|
298
298
|
function typedArgumentFailure(stderr, code, message, detail, context = {}) {
|
|
@@ -330,6 +330,10 @@ const TODO_FLAG_SPECS = Object.freeze({
|
|
|
330
330
|
unblock: Object.freeze({ known: ['plan', 'task'], required: ['plan', 'task'] }),
|
|
331
331
|
reopen: Object.freeze({ known: ['plan', 'task', 'reason', 'override-reason'], required: ['plan', 'task', 'reason'] }),
|
|
332
332
|
'dependency connect': DEPENDENCY_FLAG_SPEC,
|
|
333
|
+
add: Object.freeze({
|
|
334
|
+
known: ['plan', 'task', 'title', 'phase', 'lane', 'done-condition', 'design-memo', 'after', 'before', 'reason'],
|
|
335
|
+
required: ['plan', 'task', 'title'],
|
|
336
|
+
}),
|
|
333
337
|
'dependency disconnect': DEPENDENCY_FLAG_SPEC,
|
|
334
338
|
// a23: the remaining writes whose refusal pointed only at --help.
|
|
335
339
|
'phase review': PHASE_REASON_FLAG_SPEC,
|
|
@@ -346,6 +350,7 @@ const TODO_FLAG_SPECS = Object.freeze({
|
|
|
346
350
|
'independence witness scaffold': Object.freeze({ known: ['plan', 'input'], required: ['plan', 'input'] }),
|
|
347
351
|
show: Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan', 'task'], booleans: ['json'] }),
|
|
348
352
|
'note list': Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan'], booleans: ['json'] }),
|
|
353
|
+
'phase status': Object.freeze({ known: ['plan', 'json'], required: ['plan'], booleans: ['json'] }),
|
|
349
354
|
structure: Object.freeze({ known: ['plan', 'json'], required: [], booleans: ['json'] }),
|
|
350
355
|
status: Object.freeze({ known: ['json'], required: [], booleans: ['json'] }),
|
|
351
356
|
});
|
|
@@ -1653,6 +1658,61 @@ async function dependencyRevision({
|
|
|
1653
1658
|
return result;
|
|
1654
1659
|
}
|
|
1655
1660
|
|
|
1661
|
+
/**
|
|
1662
|
+
* a39: 1件のtaskを、planを書き直さずに足す。dependency connectと同じ軽量改訂の道で、
|
|
1663
|
+
* 現行planから作ったdesiredへtaskと辺(after→新task、新task→before)を足して適用する。
|
|
1664
|
+
*/
|
|
1665
|
+
async function addTask({ repoRoot, env, planKey, flags }) {
|
|
1666
|
+
const { applyPlanRevision, desiredFromPlan } = await import('./plan-revise.mjs');
|
|
1667
|
+
const store = await readTodoStore({ repoRoot });
|
|
1668
|
+
const member = store.members.find(({ plan }) => plan.plan_key === planKey);
|
|
1669
|
+
if (member === undefined) {
|
|
1670
|
+
throw new TodoStoreError('STORE_INCONSISTENT', 'plan_not_active', undefined, { plan_key: planKey });
|
|
1671
|
+
}
|
|
1672
|
+
const taskId = flags.task;
|
|
1673
|
+
const known = new Set(member.plan.tasks.map(({ task_id: id }) => id));
|
|
1674
|
+
if (known.has(taskId)) {
|
|
1675
|
+
throw new TodoStoreError('INPUT_INVALID', 'todo_add_task_exists', undefined, {
|
|
1676
|
+
plan_key: planKey, task_id: taskId, pointer: '--task',
|
|
1677
|
+
next_action: `${planKey}/${taskId} already exists: pick an unused --task id (see \`lattice plan show ${planKey} --json\`), or change the task with \`lattice plan revise --input <file>\`.`,
|
|
1678
|
+
});
|
|
1679
|
+
}
|
|
1680
|
+
const ids = (value) => (typeof value === 'string' ? value.split(',').map((id) => id.trim()).filter(Boolean) : []);
|
|
1681
|
+
const after = ids(flags.after);
|
|
1682
|
+
const before = ids(flags.before);
|
|
1683
|
+
for (const id of [...after, ...before]) {
|
|
1684
|
+
if (!known.has(id)) {
|
|
1685
|
+
throw new TodoStoreError('DEPENDENCY_INVALID', 'dependency_task_not_found', undefined, {
|
|
1686
|
+
ref: dependencyRef(store, planKey, id),
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
const task = { task_id: taskId, title: flags.title };
|
|
1691
|
+
for (const [flag, field] of [['phase', 'phase_id'], ['lane', 'lane'],
|
|
1692
|
+
['done-condition', 'done_condition'], ['design-memo', 'design_memo']]) {
|
|
1693
|
+
if (typeof flags[flag] === 'string') task[field] = flags[flag];
|
|
1694
|
+
}
|
|
1695
|
+
const desired = desiredFromPlan(member.plan, { env });
|
|
1696
|
+
const ref = (id) => dependencyRef(store, planKey, id);
|
|
1697
|
+
desired.tasks = [...desired.tasks, task];
|
|
1698
|
+
desired.hard_dependencies = [...desired.hard_dependencies,
|
|
1699
|
+
...after.map((id) => ({ from: ref(id), to: ref(taskId) })),
|
|
1700
|
+
...before.map((id) => ({ from: ref(taskId), to: ref(id) }))];
|
|
1701
|
+
const reason = typeof flags.reason === 'string' ? flags.reason : null;
|
|
1702
|
+
const applied = await applyPlanRevision({
|
|
1703
|
+
repoRoot, env, input: { schema: 'lattice.plan_revise_input.v1', desired },
|
|
1704
|
+
notes: [{ task_id: taskId, body: `todo add ${taskId}${reason === null ? '' : `: ${reason}`}` }],
|
|
1705
|
+
});
|
|
1706
|
+
const result = {
|
|
1707
|
+
schema: 'lattice.todo_task_add_result.v1', project_id: store.project_id, plan_key: planKey,
|
|
1708
|
+
task_id: taskId, after, before, reason, actor: desired.actor,
|
|
1709
|
+
plan_version: applied.plan_version, revision_digest: applied.revision?.revision_digest ?? null,
|
|
1710
|
+
rebound_task_ids: applied.rebound_task_ids, result_digest: '',
|
|
1711
|
+
};
|
|
1712
|
+
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
1713
|
+
return result;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1656
1716
|
const samePlanEdge = (member, fromTaskId, toTaskId) => member.plan.hard_dependencies.some((edge) => (
|
|
1657
1717
|
edge.from.task_id === fromTaskId && edge.to.task_id === toTaskId));
|
|
1658
1718
|
|
|
@@ -4846,9 +4906,10 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4846
4906
|
if (flags !== null && isTodoIdentifier(flags.plan) && isAuthoringPathToken(flags.input)) {
|
|
4847
4907
|
action = (repoRoot) => revisePhase({ repoRoot, env, planKey: flags.plan, inputRef: flags.input });
|
|
4848
4908
|
}
|
|
4849
|
-
} else if (argv
|
|
4850
|
-
|
|
4851
|
-
|
|
4909
|
+
} else if (argv[0] === 'phase' && argv[1] === 'status' && readFlags(argv, ['phase', 'status']) !== null) {
|
|
4910
|
+
// a28: a read's --json is optional; its output is JSON either way.
|
|
4911
|
+
const flags = readFlags(argv, ['phase', 'status']);
|
|
4912
|
+
action = (repoRoot) => phaseStatus({ repoRoot, planKey: flags.plan });
|
|
4852
4913
|
} else if (argv[0] === 'phase' && argv[1] === 'review'
|
|
4853
4914
|
&& phaseReasonFlags(argv) !== null) {
|
|
4854
4915
|
const flags = phaseReasonFlags(argv);
|
|
@@ -4935,6 +4996,11 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4935
4996
|
kind: 'block', payload: { reason: flags.reason }, evidenceRef: null,
|
|
4936
4997
|
}) });
|
|
4937
4998
|
}
|
|
4999
|
+
} else if (argv[0] === 'add') {
|
|
5000
|
+
const flags = matchFlagCommand(argv, ['add'], TODO_FLAG_SPECS.add);
|
|
5001
|
+
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
5002
|
+
action = (repoRoot) => addTask({ repoRoot, env, planKey: flags.plan, flags });
|
|
5003
|
+
}
|
|
4938
5004
|
} else if (argv[0] === 'retire') {
|
|
4939
5005
|
// 恒久除去(2026-08-29オーナー裁定)。planの形は変えず、状態遷移として工程を閉じる。
|
|
4940
5006
|
const flags = matchFlagCommand(argv, ['retire'], TODO_FLAG_SPECS.retire);
|
|
@@ -31,6 +31,8 @@ export async function readTodoParallelCandidatesForStatus(options = {}) {
|
|
|
31
31
|
const candidates = [];
|
|
32
32
|
for (const member of store.members) {
|
|
33
33
|
const planKey = member.plan.plan_key;
|
|
34
|
+
// ADR 0160 §2: a plan that chose conversation gets no witness prompt (BellTeam 0.85.5 report).
|
|
35
|
+
if (member.coordination?.mode === 'conversation') continue;
|
|
34
36
|
const readyTaskIds = frontier.filter((task) => task.plan_key === planKey)
|
|
35
37
|
.map(({ task_id: taskId }) => taskId);
|
|
36
38
|
let artifact = null;
|