@quolu/lattice 0.84.2 → 0.85.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/README.ja.md +2 -1
- package/bin/lattice.mjs +37 -13
- package/docs/schemas/lattice.plan_create_input.v4.schema.json +1 -1
- package/docs/schemas/lattice.plan_create_input.v5.schema.json +1 -3
- package/docs/schemas/lattice.plan_revise_input.v1.schema.json +1 -1
- package/docs/schemas/lattice.todo_extraction.v3.schema.json +1 -1
- package/docs/schemas/lattice.todo_extraction.v4.schema.json +1 -1
- package/package.json +1 -1
- package/src/cli-help.mjs +15 -6
- package/src/cli-refusal-guidance.mjs +57 -3
- package/src/hooks-cli.mjs +6 -1
- package/src/plan-backchain.mjs +21 -3
- package/src/plan-revise.mjs +13 -4
- package/src/project-cli.mjs +47 -23
- package/src/runtime-pull-intake.mjs +2 -2
- package/src/seam-proposal-contracts.mjs +2 -1
- package/src/setup-cli.mjs +4 -1
- package/src/todo-authoring-input.mjs +26 -8
- package/src/todo-cli.mjs +332 -153
- package/src/todo-independence-contracts.mjs +4 -1
- package/src/todo-independence-guidance.mjs +43 -38
- package/src/todo-store.mjs +14 -4
package/src/setup-cli.mjs
CHANGED
|
@@ -24,7 +24,9 @@ async function hookResult(host, options, statusOnly) {
|
|
|
24
24
|
if (installed.exit !== 0) return { ...installed.result, state: 'failed' };
|
|
25
25
|
}
|
|
26
26
|
const status = await invoke('status');
|
|
27
|
-
|
|
27
|
+
if (status.exit === 0 && status.result.state === 'wired') return { ...status.result, state: 'verified' };
|
|
28
|
+
// Keep setup's verified/failed, and name the hooks status state as the code (as MCP does).
|
|
29
|
+
return { ...status.result, state: 'failed', code: `HOOKS_${String(status.result.state ?? 'failed').toUpperCase()}` };
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
async function configureHost(host, options, statusOnly) {
|
|
@@ -47,6 +49,7 @@ async function configureHost(host, options, statusOnly) {
|
|
|
47
49
|
if (!statusOnly) action = await writeSetupFile(paths.mcp, before, updateMcpConfig(before.text, paths.format, desired));
|
|
48
50
|
const saved = (await readSetupFile(paths.mcp)).text;
|
|
49
51
|
const entry = mcpEntry(saved, paths.format);
|
|
52
|
+
if (!entry && statusOnly) throw setupError('MCP_NOT_REGISTERED', `LatticeのMCPは未登録です。lattice setup --host ${host} で登録します`);
|
|
50
53
|
if (!entry || entry.command !== desired.command || JSON.stringify(entry.args) !== JSON.stringify(desired.args)) {
|
|
51
54
|
throw setupError('MCP_REGISTRATION_DRIFT', 'MCP登録が現在のLattice実行体と一致しません');
|
|
52
55
|
}
|
|
@@ -231,12 +231,15 @@ function fillEach(next, key, fill) {
|
|
|
231
231
|
next[key] = next[key].map((entry) => (isRecord(entry) ? fill(entry) : entry));
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
|
|
234
|
+
// a17: project_id・plan_versionは機械が決める事実。書かなければ呼び出し側が渡した値(storeのid等)で埋める。
|
|
235
|
+
export function completeCreateInput(value, { env, now, projectId, planVersion }) {
|
|
235
236
|
if (!isRecord(value)) return value;
|
|
236
237
|
const next = { ...value };
|
|
237
238
|
// a11: schemaを書かなければ現行のcreate入力(v5)。他のschemaを持つ値は作成入力でないのでそのまま返す。
|
|
238
239
|
if (absent(next.schema)) next.schema = DEFAULT_CREATE_INPUT_SCHEMA;
|
|
239
240
|
if (typeof next.schema !== 'string' || !CREATE_INPUT_SCHEMA.test(next.schema)) return value;
|
|
241
|
+
if (absent(next.project_id) && projectId !== undefined) next.project_id = projectId;
|
|
242
|
+
if (absent(next.plan_version) && planVersion !== undefined) next.plan_version = planVersion;
|
|
240
243
|
const fillNode = (ref) => fillRef(ref, next.project_id, next.plan_key);
|
|
241
244
|
const phaseInput = next.schema !== 'lattice.plan_create_input.v1';
|
|
242
245
|
const memoInput = ['lattice.plan_create_input.v4', 'lattice.plan_create_input.v5'].includes(next.schema);
|
|
@@ -304,7 +307,16 @@ function looksLikeProse(value) {
|
|
|
304
307
|
|| (/\s/u.test(value) && !/[/\\]/u.test(value));
|
|
305
308
|
}
|
|
306
309
|
|
|
307
|
-
|
|
310
|
+
function outsideRepoAction(canonicalRoot, inlineFlag) {
|
|
311
|
+
return 'この引数は証拠としてrepo内のpathとgit blobで記録し、他の席がそれを検証するので、repo内のfileだけ受理する。'
|
|
312
|
+
+ `repo外(/tmp等)にあるならrepo内へ写してから渡す${inlineFlag ? `か、本文を ${inlineFlag} <text> で渡す` : ''}(repo_root: ${canonicalRoot})`;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// allowOutsideRepo: 中身だけを読むcaller(JSON入力・note本文・test result)はrepo外の絶対pathも受ける(a17, a23)。
|
|
316
|
+
// 証拠はrepo内のpathとgit blobで記録し他の席が検証するので、既定のまま拒む。
|
|
317
|
+
export async function resolveAuthoringInputPath(repoRoot, inputRef, {
|
|
318
|
+
inlineFlag = null, allowOutsideRepo = false,
|
|
319
|
+
} = {}) {
|
|
308
320
|
if (typeof inputRef !== 'string' || inputRef.length === 0) {
|
|
309
321
|
fail('INPUT_UNREADABLE', 'input_ref_invalid', { input_ref: inputRef });
|
|
310
322
|
}
|
|
@@ -312,6 +324,8 @@ export async function resolveAuthoringInputPath(repoRoot, inputRef, { inlineFlag
|
|
|
312
324
|
const candidate = path.isAbsolute(inputRef)
|
|
313
325
|
? inputRef
|
|
314
326
|
: path.resolve(canonicalRoot, inputRef);
|
|
327
|
+
// a23: 「repo内」と言うのは、repo外を拒むcallerの時だけ。
|
|
328
|
+
const fileKind = allowOutsideRepo ? 'file path(repo外は絶対path)' : 'repo内のfile path';
|
|
315
329
|
let stats;
|
|
316
330
|
try { stats = await lstat(candidate); } catch {
|
|
317
331
|
fail('INPUT_UNREADABLE', 'input_missing', {
|
|
@@ -319,20 +333,24 @@ export async function resolveAuthoringInputPath(repoRoot, inputRef, { inlineFlag
|
|
|
319
333
|
repo_root: canonicalRoot,
|
|
320
334
|
next_action: looksLikeProse(inputRef)
|
|
321
335
|
? (inlineFlag
|
|
322
|
-
?
|
|
323
|
-
:
|
|
324
|
-
:
|
|
336
|
+
? `この引数は${fileKind}を取る。文章をそのまま渡すなら ${inlineFlag} <text> を使う`
|
|
337
|
+
: `この引数は${fileKind}を取る。渡された値は本文に見える——先にfileへ書いてからそのpathを渡す`)
|
|
338
|
+
: `存在する${fileKind}を渡す(相対pathはrepo_rootから解く: ${canonicalRoot})`,
|
|
325
339
|
});
|
|
326
340
|
}
|
|
327
341
|
if (stats.isSymbolicLink() || !stats.isFile()) {
|
|
328
342
|
fail('INPUT_UNREADABLE', 'unsafe_input_path', { input_ref: inputRef });
|
|
329
343
|
}
|
|
330
344
|
const resolved = await realpath(candidate);
|
|
345
|
+
if (allowOutsideRepo && !within(canonicalRoot, resolved)) {
|
|
346
|
+
if (stats.size > MAX_AUTHORING_INPUT_BYTES) fail('INPUT_TOO_LARGE', 'input_size_limit_exceeded');
|
|
347
|
+
return { absolute: resolved, inputRef: resolved, maxBytes: MAX_AUTHORING_INPUT_BYTES };
|
|
348
|
+
}
|
|
331
349
|
if (!within(canonicalRoot, resolved) || resolved === canonicalRoot) {
|
|
332
350
|
fail('INPUT_UNREADABLE', 'input_path_outside_repo', {
|
|
333
351
|
input_ref: inputRef,
|
|
334
352
|
repo_root: canonicalRoot,
|
|
335
|
-
next_action:
|
|
353
|
+
next_action: outsideRepoAction(canonicalRoot, inlineFlag),
|
|
336
354
|
});
|
|
337
355
|
}
|
|
338
356
|
if (stats.size > MAX_AUTHORING_INPUT_BYTES) fail('INPUT_TOO_LARGE', 'input_size_limit_exceeded');
|
|
@@ -341,7 +359,7 @@ export async function resolveAuthoringInputPath(repoRoot, inputRef, { inlineFlag
|
|
|
341
359
|
fail('INPUT_UNREADABLE', 'input_path_outside_repo', {
|
|
342
360
|
input_ref: inputRef,
|
|
343
361
|
repo_root: canonicalRoot,
|
|
344
|
-
next_action:
|
|
362
|
+
next_action: outsideRepoAction(canonicalRoot, inlineFlag),
|
|
345
363
|
});
|
|
346
364
|
}
|
|
347
365
|
return {
|
|
@@ -355,7 +373,7 @@ export async function readAuthoringJsonFile(repoRoot, inputRef, {
|
|
|
355
373
|
invalidCode = 'INVALID_JSON',
|
|
356
374
|
inlineFlag = null,
|
|
357
375
|
} = {}) {
|
|
358
|
-
const located = await resolveAuthoringInputPath(repoRoot, inputRef, { inlineFlag });
|
|
376
|
+
const located = await resolveAuthoringInputPath(repoRoot, inputRef, { inlineFlag, allowOutsideRepo: true });
|
|
359
377
|
const bytes = await readFile(located.absolute);
|
|
360
378
|
if (bytes.length > located.maxBytes) fail('INPUT_TOO_LARGE', 'input_size_limit_exceeded');
|
|
361
379
|
let text;
|