@quolu/lattice 0.63.0 → 0.63.2
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/LICENSE +147 -147
- package/README.ja.md +378 -378
- package/README.md +303 -303
- package/bin/lattice-mcp.mjs +0 -0
- package/bin/lattice-scripted-adapter.mjs +0 -0
- package/bin/lattice-scripted-worker.mjs +0 -0
- package/bin/lattice-work-order-adapter.mjs +0 -0
- package/bin/lattice.mjs +3 -1
- package/docs/bridge-setup.md +248 -248
- package/docs/schemas/lattice.executor_packet.v1.schema.json +57 -57
- package/docs/schemas/lattice.executor_receipt.v1.schema.json +66 -66
- package/docs/schemas/lattice.phase_todo_revision.v3.schema.json +360 -360
- package/docs/schemas/lattice.plan_create_input.v1.schema.json +56 -56
- package/docs/schemas/lattice.plan_create_input.v2.schema.json +72 -72
- package/docs/schemas/lattice.plan_create_input.v3.schema.json +81 -81
- package/docs/schemas/lattice.plan_create_input.v4.schema.json +357 -85
- package/docs/schemas/lattice.plan_scope_review.v1.schema.json +55 -55
- package/docs/schemas/lattice.run_request.v1.schema.json +238 -238
- package/docs/schemas/lattice.runtime_adapter_capabilities.v2.schema.json +55 -55
- package/docs/schemas/lattice.runtime_adapter_registration_input.v1.schema.json +78 -78
- package/docs/schemas/lattice.runtime_adapter_registration_input.v2.schema.json +86 -86
- package/docs/schemas/lattice.todo_extraction.v2.schema.json +298 -298
- package/docs/schemas/lattice.todo_extraction.v3.schema.json +150 -150
- package/docs/schemas/lattice.todo_extraction.v4.schema.json +161 -161
- package/docs/schemas/lattice.todo_revision.v2.schema.json +260 -260
- package/docs/schemas/lattice.todo_revision_set.v3.schema.json +363 -363
- package/docs/schemas/lattice.todo_structure_binding.v1.schema.json +47 -47
- package/docs/schemas/lattice.todo_structure_realization.v1.schema.json +55 -55
- package/docs/schemas/lattice.todo_structure_set.v1.schema.json +264 -264
- package/package.json +109 -109
- package/sensor/LICENSE +21 -21
- package/sensor/NOTICE +19 -19
- package/sensor/dist/bin/lattice-sensor.js +9 -9
- package/sensor/dist/db/index.js +24 -24
- package/sensor/dist/db/migrations.js +41 -41
- package/sensor/dist/db/queries.js +164 -164
- package/sensor/dist/db/schema.sql +205 -205
- package/sensor/dist/directory.js +5 -5
- package/sensor/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/sensor/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
- package/sensor/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
- package/sensor/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
- package/sensor/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
- package/sensor/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
- package/sensor/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
- package/sensor/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
- package/sensor/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
- package/sensor/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
- package/sensor/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
- package/sensor/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
- package/sensor/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
- package/sensor/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
- package/sensor/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
- package/sensor/dist/mcp/liveness-watchdog.js +53 -53
- package/sensor/dist/mcp/server-instructions.js +95 -95
- package/sensor/package.json +56 -56
- package/src/project-cli.mjs +164 -24
- package/src/todo-authoring-input.mjs +35 -5
- package/src/todo-cli.mjs +2 -2
- package/src/todo-store.mjs +52 -21
|
@@ -18,79 +18,79 @@ exports.SERVER_INSTRUCTIONS_NO_ROOT_INDEX = exports.SERVER_INSTRUCTIONS = void 0
|
|
|
18
18
|
* burn tokens. ADR 0049 / 0059 require the eight compatibility tools to remain
|
|
19
19
|
* visible by default; provider identity is Lattice regardless of their names.
|
|
20
20
|
*/
|
|
21
|
-
exports.SERVER_INSTRUCTIONS = `# Lattice sensor — code intelligence over an indexed knowledge graph
|
|
22
|
-
|
|
23
|
-
Provider identity: lattice. The lattice_sensor_* names below are compatibility tool names served by Lattice's own bundled sensor; they do not call or require the independent Lattice sensor product.
|
|
24
|
-
|
|
25
|
-
Lattice sensor is a SQLite knowledge graph of every symbol, edge, and file in
|
|
26
|
-
the workspace — pre-computed structure you would otherwise re-derive by
|
|
27
|
-
reading files (cached intelligence: thousands of parse/trace decisions you
|
|
28
|
-
don't pay to re-reason each run). Reads are sub-millisecond; the index lags
|
|
29
|
-
writes by ~1s through the file watcher. Reach for it BEFORE *and* while
|
|
30
|
-
writing or editing code — not just for questions: one call returns the
|
|
31
|
-
verbatim source PLUS who calls it and what it affects, so you edit with the
|
|
32
|
-
blast radius in view. More accurate context, in far fewer tokens and
|
|
33
|
-
round-trips than reading files yourself.
|
|
34
|
-
|
|
35
|
-
## One tool: lattice_sensor_explore — use it instead of reading files
|
|
36
|
-
|
|
37
|
-
There is a single tool, \`lattice_sensor_explore\`, and it is Read-equivalent. It
|
|
38
|
-
takes either a natural-language question or a bag of symbol/file names and
|
|
39
|
-
returns the **verbatim, line-numbered source** of the relevant symbols
|
|
40
|
-
grouped by file — the same \`<n>\\t<line>\` shape \`Read\` gives you, safe to
|
|
41
|
-
\`Edit\` from — PLUS the call path among them (including dynamic-dispatch hops
|
|
42
|
-
like callbacks, React re-render, and JSX children that grep can't follow) and
|
|
43
|
-
a blast-radius summary of what depends on them.
|
|
44
|
-
|
|
45
|
-
Whether you're answering "how does X work" or implementing a change (fixing a
|
|
46
|
-
bug, adding a feature), call \`lattice_sensor_explore\` before you Read. ONE call
|
|
47
|
-
usually answers the whole question. Lattice sensor IS the pre-built search index —
|
|
48
|
-
so running your own grep + read loop, or delegating the lookup to a separate
|
|
49
|
-
file-reading sub-task/agent, repeats work lattice sensor already did and costs more
|
|
50
|
-
for the same answer. A direct lattice sensor answer is typically one to a few
|
|
51
|
-
calls; a grep/read exploration is dozens.
|
|
52
|
-
|
|
53
|
-
## How to query
|
|
54
|
-
|
|
55
|
-
- **Almost any question — "how does X work", architecture, a bug, "what/where is X", or surveying an area** → \`lattice_sensor_explore\` with a natural-language question or the relevant names. ONE capped call returns the verbatim source grouped by file; most often the ONLY call you need.
|
|
56
|
-
- **"How does X reach/become Y? / the flow / the path from X to Y"** → \`lattice_sensor_explore\`, naming the symbols that span the flow (e.g. \`mutateElement renderScene\`) — it surfaces the call path among them, riding dynamic-dispatch hops, and returns their source.
|
|
57
|
-
- **Reading or editing a file/symbol you can name** → put its name or file path in the \`lattice_sensor_explore\` query — it returns that current line-numbered source (safe to \`Edit\` from) with the call path and blast radius attached, so you don't Read it separately. For an overloaded name it returns every matching definition's body in one call.
|
|
58
|
-
- **Need more?** Call \`lattice_sensor_explore\` again with more specific names — treat the source it returns as already Read.
|
|
59
|
-
|
|
60
|
-
## Anti-patterns
|
|
61
|
-
|
|
62
|
-
- **Trust lattice sensor's results — don't re-verify them with grep.** They come from a full AST parse; re-checking with grep is slower, less accurate, and wastes context.
|
|
63
|
-
- **Don't grep or Read first** to find or understand indexed code — ONE \`lattice_sensor_explore\` returns the relevant symbols' source together in a single round-trip. Reach for raw \`Read\`/\`Grep\` only to confirm a specific detail lattice sensor didn't cover, or for what lattice sensor doesn't index (configs, docs).
|
|
64
|
-
- **Don't reconstruct a flow by hand** — name the endpoints in one \`lattice_sensor_explore\` and it surfaces the path between them, dynamic-dispatch hops included.
|
|
65
|
-
- **After editing, check the staleness banner.** When a tool response starts with "⚠️ Some files referenced below were edited since the last index sync…", the listed files are pending re-index — Read those specific files for accurate content. Every file NOT in that banner is fresh, so still trust lattice sensor. A different, rarer banner — "⚠️ LatticeSensor auto-sync is DISABLED…" — means live watching stopped entirely (the whole index is frozen, not just a few files); until it's resolved, Read files directly to confirm anything that may have changed.
|
|
66
|
-
- **A file flagged "⚠ changed on disk after the last index sync" drifted from its index** (most common on projects queried via \`projectPath\`, which have no live watcher). LatticeSensor never serves a possibly-mis-sliced body from such a file — it either shows the file's full CURRENT source (trust it as a Read) or omits the source with this flag. When the source was omitted, Read that specific file; line numbers referencing it elsewhere in the response may be shifted until that project's next sync. All unflagged files remain trustworthy.
|
|
67
|
-
|
|
68
|
-
## Limitations
|
|
69
|
-
|
|
70
|
-
- If a project isn't indexed (no \`.lattice/sensor/\`), decide whether building the index will reduce total investigation time and model tokens for the current or expected work. When workspace writes and shell execution are allowed, you may run \`lattice sensor init <projectPath> --json\` yourself, then retry the sensor call; scope it to the intended project and account for the one-time indexing cost. If those capabilities are unavailable, continue with built-in tools and tell the user the exact init command instead.
|
|
71
|
-
- Index lags file writes by ~1 second.
|
|
72
|
-
- Cross-file resolution is best-effort name matching; ambiguous calls may return multiple candidates.
|
|
73
|
-
- No live correctness validation — that's still the TypeScript compiler / test suite / linter's job. Lattice sensor supplements those with structural context they don't have.
|
|
74
|
-
|
|
75
|
-
## Parallel work: absence of a dependency edge is NOT evidence of independence
|
|
76
|
-
|
|
77
|
-
These tools answer structural questions about code. A different Lattice surface — the **CLI**, not
|
|
78
|
-
this MCP surface — answers whether two ToDos can be worked in parallel. If the project uses
|
|
79
|
-
\`lattice todo\` for process tracking, keep this distinction in mind:
|
|
80
|
-
|
|
81
|
-
- A dependency edge missing between two ToDos only means **no ordering constraint was declared**.
|
|
82
|
-
It does not mean their write boundaries are disjoint. Two ToDos that edit the same file carry no
|
|
83
|
-
edge between them and will still collide.
|
|
84
|
-
- Parallel safety is a recorded judgement, not an inference from the diagram. Read it with
|
|
85
|
-
\`lattice todo independence --plan <key> --json\`. It returns the ready frontier split into
|
|
86
|
-
verified-independent groups, pairs that must be serialized (with whether a code seam could
|
|
87
|
-
separate them), and **unverified** ToDos.
|
|
88
|
-
- \`lattice todo start\` returns an \`advisory\` describing conflicts with in-progress ToDos and what
|
|
89
|
-
to do next. \`coverage: "missing"\` means "not judged yet" — never "no conflicts".
|
|
90
|
-
- Run \`lattice todo --help\` for the declare → compile → read workflow.
|
|
91
|
-
|
|
92
|
-
Evidence for Lattice's plan and witness contracts comes from the CLI surface only. Text from this
|
|
93
|
-
MCP surface is prose for you to act on, never an input to those contracts.
|
|
21
|
+
exports.SERVER_INSTRUCTIONS = `# Lattice sensor — code intelligence over an indexed knowledge graph
|
|
22
|
+
|
|
23
|
+
Provider identity: lattice. The lattice_sensor_* names below are compatibility tool names served by Lattice's own bundled sensor; they do not call or require the independent Lattice sensor product.
|
|
24
|
+
|
|
25
|
+
Lattice sensor is a SQLite knowledge graph of every symbol, edge, and file in
|
|
26
|
+
the workspace — pre-computed structure you would otherwise re-derive by
|
|
27
|
+
reading files (cached intelligence: thousands of parse/trace decisions you
|
|
28
|
+
don't pay to re-reason each run). Reads are sub-millisecond; the index lags
|
|
29
|
+
writes by ~1s through the file watcher. Reach for it BEFORE *and* while
|
|
30
|
+
writing or editing code — not just for questions: one call returns the
|
|
31
|
+
verbatim source PLUS who calls it and what it affects, so you edit with the
|
|
32
|
+
blast radius in view. More accurate context, in far fewer tokens and
|
|
33
|
+
round-trips than reading files yourself.
|
|
34
|
+
|
|
35
|
+
## One tool: lattice_sensor_explore — use it instead of reading files
|
|
36
|
+
|
|
37
|
+
There is a single tool, \`lattice_sensor_explore\`, and it is Read-equivalent. It
|
|
38
|
+
takes either a natural-language question or a bag of symbol/file names and
|
|
39
|
+
returns the **verbatim, line-numbered source** of the relevant symbols
|
|
40
|
+
grouped by file — the same \`<n>\\t<line>\` shape \`Read\` gives you, safe to
|
|
41
|
+
\`Edit\` from — PLUS the call path among them (including dynamic-dispatch hops
|
|
42
|
+
like callbacks, React re-render, and JSX children that grep can't follow) and
|
|
43
|
+
a blast-radius summary of what depends on them.
|
|
44
|
+
|
|
45
|
+
Whether you're answering "how does X work" or implementing a change (fixing a
|
|
46
|
+
bug, adding a feature), call \`lattice_sensor_explore\` before you Read. ONE call
|
|
47
|
+
usually answers the whole question. Lattice sensor IS the pre-built search index —
|
|
48
|
+
so running your own grep + read loop, or delegating the lookup to a separate
|
|
49
|
+
file-reading sub-task/agent, repeats work lattice sensor already did and costs more
|
|
50
|
+
for the same answer. A direct lattice sensor answer is typically one to a few
|
|
51
|
+
calls; a grep/read exploration is dozens.
|
|
52
|
+
|
|
53
|
+
## How to query
|
|
54
|
+
|
|
55
|
+
- **Almost any question — "how does X work", architecture, a bug, "what/where is X", or surveying an area** → \`lattice_sensor_explore\` with a natural-language question or the relevant names. ONE capped call returns the verbatim source grouped by file; most often the ONLY call you need.
|
|
56
|
+
- **"How does X reach/become Y? / the flow / the path from X to Y"** → \`lattice_sensor_explore\`, naming the symbols that span the flow (e.g. \`mutateElement renderScene\`) — it surfaces the call path among them, riding dynamic-dispatch hops, and returns their source.
|
|
57
|
+
- **Reading or editing a file/symbol you can name** → put its name or file path in the \`lattice_sensor_explore\` query — it returns that current line-numbered source (safe to \`Edit\` from) with the call path and blast radius attached, so you don't Read it separately. For an overloaded name it returns every matching definition's body in one call.
|
|
58
|
+
- **Need more?** Call \`lattice_sensor_explore\` again with more specific names — treat the source it returns as already Read.
|
|
59
|
+
|
|
60
|
+
## Anti-patterns
|
|
61
|
+
|
|
62
|
+
- **Trust lattice sensor's results — don't re-verify them with grep.** They come from a full AST parse; re-checking with grep is slower, less accurate, and wastes context.
|
|
63
|
+
- **Don't grep or Read first** to find or understand indexed code — ONE \`lattice_sensor_explore\` returns the relevant symbols' source together in a single round-trip. Reach for raw \`Read\`/\`Grep\` only to confirm a specific detail lattice sensor didn't cover, or for what lattice sensor doesn't index (configs, docs).
|
|
64
|
+
- **Don't reconstruct a flow by hand** — name the endpoints in one \`lattice_sensor_explore\` and it surfaces the path between them, dynamic-dispatch hops included.
|
|
65
|
+
- **After editing, check the staleness banner.** When a tool response starts with "⚠️ Some files referenced below were edited since the last index sync…", the listed files are pending re-index — Read those specific files for accurate content. Every file NOT in that banner is fresh, so still trust lattice sensor. A different, rarer banner — "⚠️ LatticeSensor auto-sync is DISABLED…" — means live watching stopped entirely (the whole index is frozen, not just a few files); until it's resolved, Read files directly to confirm anything that may have changed.
|
|
66
|
+
- **A file flagged "⚠ changed on disk after the last index sync" drifted from its index** (most common on projects queried via \`projectPath\`, which have no live watcher). LatticeSensor never serves a possibly-mis-sliced body from such a file — it either shows the file's full CURRENT source (trust it as a Read) or omits the source with this flag. When the source was omitted, Read that specific file; line numbers referencing it elsewhere in the response may be shifted until that project's next sync. All unflagged files remain trustworthy.
|
|
67
|
+
|
|
68
|
+
## Limitations
|
|
69
|
+
|
|
70
|
+
- If a project isn't indexed (no \`.lattice/sensor/\`), decide whether building the index will reduce total investigation time and model tokens for the current or expected work. When workspace writes and shell execution are allowed, you may run \`lattice sensor init <projectPath> --json\` yourself, then retry the sensor call; scope it to the intended project and account for the one-time indexing cost. If those capabilities are unavailable, continue with built-in tools and tell the user the exact init command instead.
|
|
71
|
+
- Index lags file writes by ~1 second.
|
|
72
|
+
- Cross-file resolution is best-effort name matching; ambiguous calls may return multiple candidates.
|
|
73
|
+
- No live correctness validation — that's still the TypeScript compiler / test suite / linter's job. Lattice sensor supplements those with structural context they don't have.
|
|
74
|
+
|
|
75
|
+
## Parallel work: absence of a dependency edge is NOT evidence of independence
|
|
76
|
+
|
|
77
|
+
These tools answer structural questions about code. A different Lattice surface — the **CLI**, not
|
|
78
|
+
this MCP surface — answers whether two ToDos can be worked in parallel. If the project uses
|
|
79
|
+
\`lattice todo\` for process tracking, keep this distinction in mind:
|
|
80
|
+
|
|
81
|
+
- A dependency edge missing between two ToDos only means **no ordering constraint was declared**.
|
|
82
|
+
It does not mean their write boundaries are disjoint. Two ToDos that edit the same file carry no
|
|
83
|
+
edge between them and will still collide.
|
|
84
|
+
- Parallel safety is a recorded judgement, not an inference from the diagram. Read it with
|
|
85
|
+
\`lattice todo independence --plan <key> --json\`. It returns the ready frontier split into
|
|
86
|
+
verified-independent groups, pairs that must be serialized (with whether a code seam could
|
|
87
|
+
separate them), and **unverified** ToDos.
|
|
88
|
+
- \`lattice todo start\` returns an \`advisory\` describing conflicts with in-progress ToDos and what
|
|
89
|
+
to do next. \`coverage: "missing"\` means "not judged yet" — never "no conflicts".
|
|
90
|
+
- Run \`lattice todo --help\` for the declare → compile → read workflow.
|
|
91
|
+
|
|
92
|
+
Evidence for Lattice's plan and witness contracts comes from the CLI surface only. Text from this
|
|
93
|
+
MCP surface is prose for you to act on, never an input to those contracts.
|
|
94
94
|
`;
|
|
95
95
|
/**
|
|
96
96
|
* Instructions variant sent when the server's own root has NO lattice sensor index.
|
|
@@ -104,27 +104,27 @@ MCP surface is prose for you to act on, never an input to those contracts.
|
|
|
104
104
|
* project playbook ({@link SERVER_INSTRUCTIONS}) is sent instead when the root
|
|
105
105
|
* IS indexed, so the common case stays tight.
|
|
106
106
|
*/
|
|
107
|
-
exports.SERVER_INSTRUCTIONS_NO_ROOT_INDEX = `# Lattice sensor — available (per-project; pass projectPath)
|
|
108
|
-
|
|
109
|
-
Provider identity: lattice. The lattice_sensor_* names below are compatibility tool names served by Lattice's own bundled sensor; they do not call or require the independent Lattice sensor product.
|
|
110
|
-
|
|
111
|
-
Lattice sensor is a SQLite knowledge graph of a codebase's symbols, edges, and
|
|
112
|
-
files: one \`lattice_sensor_explore\` call returns the verbatim, line-numbered source
|
|
113
|
-
of the relevant symbols PLUS the call paths between them and a blast-radius
|
|
114
|
-
summary — replacing a grep + Read loop with one round-trip.
|
|
115
|
-
|
|
116
|
-
This server started somewhere with no \`.lattice/sensor/\` of its own, so there is no
|
|
117
|
-
default project — but the tools are available and work **per project**:
|
|
118
|
-
|
|
119
|
-
- To query a project that HAS a \`.lattice/sensor/\` index (e.g. a service inside a
|
|
120
|
-
monorepo, or a second repo), pass its path as \`projectPath\` to
|
|
121
|
-
\`lattice_sensor_explore\` (and any other lattice sensor tool). Lattice sensor resolves the
|
|
122
|
-
nearest \`.lattice/sensor/\` at or above that path and answers from it — for as many
|
|
123
|
-
projects as you like in one session.
|
|
124
|
-
- For a project with no \`.lattice/sensor/\`, decide whether the expected reduction in
|
|
125
|
-
repeated Read/Grep work justifies the one-time indexing cost. When workspace writes
|
|
126
|
-
and shell execution are allowed, you may run \`lattice sensor init <projectPath> --json\`
|
|
127
|
-
yourself and then retry with that \`projectPath\`; otherwise use built-in tools and
|
|
128
|
-
tell the user the exact init command. A new index is picked up live, with no restart.
|
|
107
|
+
exports.SERVER_INSTRUCTIONS_NO_ROOT_INDEX = `# Lattice sensor — available (per-project; pass projectPath)
|
|
108
|
+
|
|
109
|
+
Provider identity: lattice. The lattice_sensor_* names below are compatibility tool names served by Lattice's own bundled sensor; they do not call or require the independent Lattice sensor product.
|
|
110
|
+
|
|
111
|
+
Lattice sensor is a SQLite knowledge graph of a codebase's symbols, edges, and
|
|
112
|
+
files: one \`lattice_sensor_explore\` call returns the verbatim, line-numbered source
|
|
113
|
+
of the relevant symbols PLUS the call paths between them and a blast-radius
|
|
114
|
+
summary — replacing a grep + Read loop with one round-trip.
|
|
115
|
+
|
|
116
|
+
This server started somewhere with no \`.lattice/sensor/\` of its own, so there is no
|
|
117
|
+
default project — but the tools are available and work **per project**:
|
|
118
|
+
|
|
119
|
+
- To query a project that HAS a \`.lattice/sensor/\` index (e.g. a service inside a
|
|
120
|
+
monorepo, or a second repo), pass its path as \`projectPath\` to
|
|
121
|
+
\`lattice_sensor_explore\` (and any other lattice sensor tool). Lattice sensor resolves the
|
|
122
|
+
nearest \`.lattice/sensor/\` at or above that path and answers from it — for as many
|
|
123
|
+
projects as you like in one session.
|
|
124
|
+
- For a project with no \`.lattice/sensor/\`, decide whether the expected reduction in
|
|
125
|
+
repeated Read/Grep work justifies the one-time indexing cost. When workspace writes
|
|
126
|
+
and shell execution are allowed, you may run \`lattice sensor init <projectPath> --json\`
|
|
127
|
+
yourself and then retry with that \`projectPath\`; otherwise use built-in tools and
|
|
128
|
+
tell the user the exact init command. A new index is picked up live, with no restart.
|
|
129
129
|
`;
|
|
130
130
|
//# sourceMappingURL=server-instructions.js.map
|
package/sensor/package.json
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@quolu/lattice-sensor",
|
|
3
|
-
"version": "0.7.3-lattice.1",
|
|
4
|
-
"private": true,
|
|
5
|
-
"description": "Lattice-owned local structural sensor.",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/kitepon/Lattice.git"
|
|
9
|
-
},
|
|
10
|
-
"main": "dist/index.js",
|
|
11
|
-
"types": "dist/index.d.ts",
|
|
12
|
-
"files": [
|
|
13
|
-
"dist",
|
|
14
|
-
"README.md"
|
|
15
|
-
],
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "npm run clean && tsc && npm run copy-assets",
|
|
18
|
-
"copy-assets": "node -e \"const fs=require('fs');fs.mkdirSync('dist/db',{recursive:true});fs.copyFileSync('src/db/schema.sql','dist/db/schema.sql');fs.mkdirSync('dist/extraction/wasm',{recursive:true});fs.readdirSync('src/extraction/wasm').filter(f=>f.endsWith('.wasm')).forEach(f=>fs.copyFileSync('src/extraction/wasm/'+f,'dist/extraction/wasm/'+f))\"",
|
|
19
|
-
"dev": "tsc --watch",
|
|
20
|
-
"build:kernel": "bash scripts/build-kernel.sh",
|
|
21
|
-
"test": "vitest run --maxWorkers=4 --minWorkers=1",
|
|
22
|
-
"test:watch": "vitest",
|
|
23
|
-
"test:eval": "vitest run __tests__/evaluation/",
|
|
24
|
-
"eval": "npm run build && npx tsx __tests__/evaluation/runner.ts",
|
|
25
|
-
"clean": "node -e \"const fs=require('fs');fs.rmSync('dist',{recursive:true,force:true})\""
|
|
26
|
-
},
|
|
27
|
-
"keywords": [
|
|
28
|
-
"code-intelligence",
|
|
29
|
-
"knowledge-graph",
|
|
30
|
-
"static-analysis"
|
|
31
|
-
],
|
|
32
|
-
"author": "",
|
|
33
|
-
"license": "MIT",
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"@clack/prompts": "^1.3.0",
|
|
36
|
-
"commander": "^14.0.2",
|
|
37
|
-
"fast-string-width": "^3.0.2",
|
|
38
|
-
"fast-wrap-ansi": "^0.2.0",
|
|
39
|
-
"ignore": "^7.0.5",
|
|
40
|
-
"jsonc-parser": "^3.3.1",
|
|
41
|
-
"picomatch": "^4.0.4",
|
|
42
|
-
"sisteransi": "^1.0.5",
|
|
43
|
-
"tree-sitter-wasms": "^0.1.11",
|
|
44
|
-
"web-tree-sitter": "^0.25.3"
|
|
45
|
-
},
|
|
46
|
-
"devDependencies": {
|
|
47
|
-
"@types/better-sqlite3": "^7.6.0",
|
|
48
|
-
"@types/node": "^20.19.30",
|
|
49
|
-
"@types/picomatch": "^4.0.2",
|
|
50
|
-
"typescript": "^5.0.0",
|
|
51
|
-
"vitest": "^2.1.9"
|
|
52
|
-
},
|
|
53
|
-
"engines": {
|
|
54
|
-
"node": ">=20.0.0 <25.0.0 || >=26.0.0"
|
|
55
|
-
}
|
|
56
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@quolu/lattice-sensor",
|
|
3
|
+
"version": "0.7.3-lattice.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Lattice-owned local structural sensor.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/kitepon/Lattice.git"
|
|
9
|
+
},
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "npm run clean && tsc && npm run copy-assets",
|
|
18
|
+
"copy-assets": "node -e \"const fs=require('fs');fs.mkdirSync('dist/db',{recursive:true});fs.copyFileSync('src/db/schema.sql','dist/db/schema.sql');fs.mkdirSync('dist/extraction/wasm',{recursive:true});fs.readdirSync('src/extraction/wasm').filter(f=>f.endsWith('.wasm')).forEach(f=>fs.copyFileSync('src/extraction/wasm/'+f,'dist/extraction/wasm/'+f))\"",
|
|
19
|
+
"dev": "tsc --watch",
|
|
20
|
+
"build:kernel": "bash scripts/build-kernel.sh",
|
|
21
|
+
"test": "vitest run --maxWorkers=4 --minWorkers=1",
|
|
22
|
+
"test:watch": "vitest",
|
|
23
|
+
"test:eval": "vitest run __tests__/evaluation/",
|
|
24
|
+
"eval": "npm run build && npx tsx __tests__/evaluation/runner.ts",
|
|
25
|
+
"clean": "node -e \"const fs=require('fs');fs.rmSync('dist',{recursive:true,force:true})\""
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"code-intelligence",
|
|
29
|
+
"knowledge-graph",
|
|
30
|
+
"static-analysis"
|
|
31
|
+
],
|
|
32
|
+
"author": "",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@clack/prompts": "^1.3.0",
|
|
36
|
+
"commander": "^14.0.2",
|
|
37
|
+
"fast-string-width": "^3.0.2",
|
|
38
|
+
"fast-wrap-ansi": "^0.2.0",
|
|
39
|
+
"ignore": "^7.0.5",
|
|
40
|
+
"jsonc-parser": "^3.3.1",
|
|
41
|
+
"picomatch": "^4.0.4",
|
|
42
|
+
"sisteransi": "^1.0.5",
|
|
43
|
+
"tree-sitter-wasms": "^0.1.11",
|
|
44
|
+
"web-tree-sitter": "^0.25.3"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/better-sqlite3": "^7.6.0",
|
|
48
|
+
"@types/node": "^20.19.30",
|
|
49
|
+
"@types/picomatch": "^4.0.2",
|
|
50
|
+
"typescript": "^5.0.0",
|
|
51
|
+
"vitest": "^2.1.9"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=20.0.0 <25.0.0 || >=26.0.0"
|
|
55
|
+
}
|
|
56
|
+
}
|
package/src/project-cli.mjs
CHANGED
|
@@ -397,7 +397,100 @@ async function readCanonicalInput(repoRoot, inputRef) {
|
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
-
|
|
400
|
+
/**
|
|
401
|
+
* buildTodoPlanは通ったか否かしか返さない。authorが実際に書くtasks・phasesについて、
|
|
402
|
+
* 落ちた最初の条件をpointer付きで名指しする。ここで拾えない違反だけ総称へ落とす。
|
|
403
|
+
* 整列要求(task_id昇順など)はJSON Schemaに書けないので、ここが唯一の案内面になる。
|
|
404
|
+
*/
|
|
405
|
+
function describePlanShapeViolation(value, { phaseInput }) {
|
|
406
|
+
const TASK_KEYS = ['task_id', 'title', 'lane', 'design_memo', 'narrative_ref',
|
|
407
|
+
'narrative_anchor', 'compile_binding', 'parent_task_id', 'phase_id'];
|
|
408
|
+
const PHASE_KEYS = ['phase_id', 'title', 'gate_policy', 'predecessor_phase_ids',
|
|
409
|
+
'required_evidence_slots'];
|
|
410
|
+
|
|
411
|
+
if (value.tasks.length === 0) {
|
|
412
|
+
return { violation_kind: 'empty', pointer: '/tasks',
|
|
413
|
+
expected: { min_items: 1 }, actual: { length: 0 } };
|
|
414
|
+
}
|
|
415
|
+
for (const [index, task] of value.tasks.entries()) {
|
|
416
|
+
if (!exactRecord(task, TASK_KEYS)) {
|
|
417
|
+
return { violation_kind: 'unexpected_or_missing_keys', pointer: `/tasks/${index}`,
|
|
418
|
+
expected: { keys: [...TASK_KEYS].sort() },
|
|
419
|
+
actual: (task === null || typeof task !== 'object')
|
|
420
|
+
? { type: task === null ? 'null' : typeof task }
|
|
421
|
+
: { keys: Object.keys(task).sort() } };
|
|
422
|
+
}
|
|
423
|
+
for (const field of ['task_id', 'lane', 'phase_id']) {
|
|
424
|
+
if (!isTodoIdentifier(task[field])) {
|
|
425
|
+
return { violation_kind: 'identifier_invalid', pointer: `/tasks/${index}/${field}`,
|
|
426
|
+
expected: { format: 'todo_identifier' }, actual: task[field] };
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
if (index > 0 && !(value.tasks[index - 1].task_id < task.task_id)) {
|
|
430
|
+
return { violation_kind: 'unsorted', pointer: `/tasks/${index}/task_id`,
|
|
431
|
+
expected: { greater_than: value.tasks[index - 1].task_id, order: 'ascending_unique' },
|
|
432
|
+
actual: task.task_id };
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
if (!phaseInput) return null;
|
|
436
|
+
|
|
437
|
+
if (!Array.isArray(value.phases) || value.phases.length === 0) {
|
|
438
|
+
return { violation_kind: 'empty', pointer: '/phases', expected: { min_items: 1 },
|
|
439
|
+
actual: Array.isArray(value.phases) ? { length: 0 } : { type: typeof value.phases } };
|
|
440
|
+
}
|
|
441
|
+
for (const [index, phase] of value.phases.entries()) {
|
|
442
|
+
if (!exactRecord(phase, PHASE_KEYS)) {
|
|
443
|
+
return { violation_kind: 'unexpected_or_missing_keys', pointer: `/phases/${index}`,
|
|
444
|
+
expected: { keys: [...PHASE_KEYS].sort() },
|
|
445
|
+
actual: (phase === null || typeof phase !== 'object')
|
|
446
|
+
? { type: phase === null ? 'null' : typeof phase }
|
|
447
|
+
: { keys: Object.keys(phase).sort() } };
|
|
448
|
+
}
|
|
449
|
+
for (const field of ['phase_id', 'gate_policy']) {
|
|
450
|
+
if (!isTodoIdentifier(phase[field])) {
|
|
451
|
+
return { violation_kind: 'identifier_invalid', pointer: `/phases/${index}/${field}`,
|
|
452
|
+
expected: { format: 'todo_identifier' }, actual: phase[field] };
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
if (!Array.isArray(phase.required_evidence_slots) || phase.required_evidence_slots.length === 0) {
|
|
456
|
+
return { violation_kind: 'empty',
|
|
457
|
+
pointer: `/phases/${index}/required_evidence_slots`,
|
|
458
|
+
expected: { min_items: 1, note: 'Phase gateが要求する証跡slotを1つ以上挙げる' },
|
|
459
|
+
actual: Array.isArray(phase.required_evidence_slots)
|
|
460
|
+
? { length: 0 } : { type: typeof phase.required_evidence_slots } };
|
|
461
|
+
}
|
|
462
|
+
for (const field of ['predecessor_phase_ids', 'required_evidence_slots']) {
|
|
463
|
+
const list = phase[field];
|
|
464
|
+
const unsorted = list.findIndex((entry, i) => i > 0 && !(list[i - 1] < entry));
|
|
465
|
+
if (unsorted > 0) {
|
|
466
|
+
return { violation_kind: 'unsorted', pointer: `/phases/${index}/${field}/${unsorted}`,
|
|
467
|
+
expected: { greater_than: list[unsorted - 1], order: 'ascending_unique' },
|
|
468
|
+
actual: list[unsorted] };
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
if (index > 0 && !(value.phases[index - 1].phase_id < phase.phase_id)) {
|
|
472
|
+
return { violation_kind: 'unsorted', pointer: `/phases/${index}/phase_id`,
|
|
473
|
+
expected: { greater_than: value.phases[index - 1].phase_id, order: 'ascending_unique' },
|
|
474
|
+
actual: phase.phase_id };
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
const phaseIds = new Set(value.phases.map(({ phase_id }) => phase_id));
|
|
478
|
+
const orphan = value.tasks.findIndex(({ phase_id }) => !phaseIds.has(phase_id));
|
|
479
|
+
if (orphan >= 0) {
|
|
480
|
+
return { violation_kind: 'unknown_reference', pointer: `/tasks/${orphan}/phase_id`,
|
|
481
|
+
expected: { one_of: [...phaseIds].sort() }, actual: value.tasks[orphan].phase_id };
|
|
482
|
+
}
|
|
483
|
+
return null;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* plan create入力の違反を、通ったか否かでなく「どこがどう違うか」で返す。
|
|
488
|
+
* 以前は巨大な `||` 連鎖と `catch { return false }` で理由を捨てており、
|
|
489
|
+
* 呼び手には pointer `/` と `validation: failed` しか届かなかった。
|
|
490
|
+
* 直せない指摘は指摘ではないので、最初に落ちた条件をpointer付きで返す。
|
|
491
|
+
* 違反が無ければ null。
|
|
492
|
+
*/
|
|
493
|
+
function describeCreateInputViolation(value) {
|
|
401
494
|
const phaseInput = [PHASE_CREATE_INPUT_SCHEMA, DECOUPLED_PHASE_CREATE_INPUT_SCHEMA,
|
|
402
495
|
MEMO_PHASE_CREATE_INPUT_SCHEMA].includes(value?.schema);
|
|
403
496
|
const decoupledPhaseInput = [DECOUPLED_PHASE_CREATE_INPUT_SCHEMA,
|
|
@@ -408,18 +501,61 @@ function validateCreateInput(value) {
|
|
|
408
501
|
];
|
|
409
502
|
if (phaseInput) keys.push('phases');
|
|
410
503
|
if (decoupledPhaseInput) keys.push('phase_accept_dependencies');
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
504
|
+
|
|
505
|
+
if (!exactRecord(value, keys)) {
|
|
506
|
+
const actual = (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
507
|
+
? { type: value === null ? 'null' : typeof value }
|
|
508
|
+
: { keys: Object.keys(value).sort() };
|
|
509
|
+
return { violation_kind: 'unexpected_or_missing_keys', pointer: '/',
|
|
510
|
+
expected: { keys: [...keys].sort() }, actual };
|
|
511
|
+
}
|
|
512
|
+
const schemas = [CREATE_INPUT_SCHEMA, PHASE_CREATE_INPUT_SCHEMA,
|
|
513
|
+
DECOUPLED_PHASE_CREATE_INPUT_SCHEMA, MEMO_PHASE_CREATE_INPUT_SCHEMA];
|
|
514
|
+
if (!schemas.includes(value.schema)) {
|
|
515
|
+
return { violation_kind: 'const_mismatch', pointer: '/schema',
|
|
516
|
+
expected: { one_of: schemas }, actual: value.schema };
|
|
517
|
+
}
|
|
518
|
+
for (const field of ['project_id', 'plan_key', 'plan_version']) {
|
|
519
|
+
if (!isTodoIdentifier(value[field])) {
|
|
520
|
+
return { violation_kind: 'identifier_invalid', pointer: `/${field}`,
|
|
521
|
+
expected: { format: 'todo_identifier' }, actual: value[field] };
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (!exactRecord(value.actor, ['host', 'session', 'agent'])) {
|
|
525
|
+
return { violation_kind: 'unexpected_or_missing_keys', pointer: '/actor',
|
|
526
|
+
expected: { keys: ['agent', 'host', 'session'] },
|
|
527
|
+
actual: (value.actor === null || typeof value.actor !== 'object')
|
|
528
|
+
? { type: value.actor === null ? 'null' : typeof value.actor }
|
|
529
|
+
: { keys: Object.keys(value.actor).sort() } };
|
|
530
|
+
}
|
|
531
|
+
for (const field of ['host', 'session', 'agent']) {
|
|
532
|
+
if (!isTodoIdentifier(value.actor[field])) {
|
|
533
|
+
return { violation_kind: 'identifier_invalid', pointer: `/actor/${field}`,
|
|
534
|
+
expected: { format: 'todo_identifier' }, actual: value.actor[field] };
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
if (!isStrictTodoTimestamp(value.recorded_at)) {
|
|
538
|
+
return { violation_kind: 'timestamp_invalid', pointer: '/recorded_at',
|
|
539
|
+
expected: { format: 'strict_iso8601_utc_milliseconds' }, actual: value.recorded_at };
|
|
540
|
+
}
|
|
541
|
+
if (!isTodoDigest(value.input_digest)
|
|
542
|
+
|| value.input_digest !== todoSelfDigest(value, 'input_digest')) {
|
|
543
|
+
return { violation_kind: 'input_digest_mismatch', pointer: '/input_digest',
|
|
544
|
+
expected: todoSelfDigest(value, 'input_digest'),
|
|
545
|
+
actual: { type: typeof value.input_digest, matches_canonical_input: false } };
|
|
546
|
+
}
|
|
547
|
+
if (!Array.isArray(value.tasks)) {
|
|
548
|
+
return { violation_kind: 'type', pointer: '/tasks', expected: { type: 'array' },
|
|
549
|
+
actual: { type: value.tasks === null ? 'null' : typeof value.tasks } };
|
|
550
|
+
}
|
|
551
|
+
for (const [index, task] of value.tasks.entries()) {
|
|
552
|
+
for (const field of ['narrative_anchor', 'compile_binding']) {
|
|
553
|
+
if (task?.[field] !== null) {
|
|
554
|
+
return { violation_kind: 'not_authorable_at_create', pointer: `/tasks/${index}/${field}`,
|
|
555
|
+
expected: null, actual: task?.[field] };
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
423
559
|
try {
|
|
424
560
|
buildTodoPlan({
|
|
425
561
|
schema: value.schema === MEMO_PHASE_CREATE_INPUT_SCHEMA ? 'lattice.todo_plan.v7'
|
|
@@ -431,8 +567,18 @@ function validateCreateInput(value) {
|
|
|
431
567
|
...(phaseInput ? { phases: value.phases } : {}),
|
|
432
568
|
...(decoupledPhaseInput ? { phase_accept_dependencies: value.phase_accept_dependencies } : {}),
|
|
433
569
|
});
|
|
434
|
-
|
|
435
|
-
|
|
570
|
+
} catch (error) {
|
|
571
|
+
// buildTodoPlanは通否しか返さない。authorが書いた形を自分で診てpointerを出す。
|
|
572
|
+
const shape = describePlanShapeViolation(value, { phaseInput });
|
|
573
|
+
if (shape !== null) return shape;
|
|
574
|
+
return {
|
|
575
|
+
violation_kind: error?.reason ?? error?.code ?? 'topology_invalid',
|
|
576
|
+
pointer: error?.detail?.pointer ?? '/',
|
|
577
|
+
expected: error?.detail?.expected ?? { schema: value.schema },
|
|
578
|
+
actual: error?.detail?.actual ?? { message: String(error?.message ?? error) },
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
return null;
|
|
436
582
|
}
|
|
437
583
|
|
|
438
584
|
export async function runPlanCreate({ cwd, inputRef, stdout }) {
|
|
@@ -463,16 +609,10 @@ export async function runPlanCreate({ cwd, inputRef, stdout }) {
|
|
|
463
609
|
prompt: TODO_DESIGN_MEMO_PROMPT, next_action: CURRENT_CREATE_SCHEMA_COMMAND,
|
|
464
610
|
});
|
|
465
611
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
&& input.input_digest === todoSelfDigest(input, 'input_digest');
|
|
612
|
+
const violation = describeCreateInputViolation(input);
|
|
613
|
+
if (violation !== null) {
|
|
469
614
|
throw new TodoStoreError('INPUT_INVALID', 'plan_create_schema_invalid', undefined, {
|
|
470
|
-
|
|
471
|
-
pointer: digestValid ? '/' : '/input_digest',
|
|
472
|
-
expected: digestValid ? { schema: MEMO_PHASE_CREATE_INPUT_SCHEMA }
|
|
473
|
-
: todoSelfDigest(input, 'input_digest'),
|
|
474
|
-
actual: digestValid ? { validation: 'failed' }
|
|
475
|
-
: { type: typeof input.input_digest, matches_canonical_input: false },
|
|
615
|
+
...violation,
|
|
476
616
|
next_action: 'correct_the_reported_pointer_then_rerun_plan_create',
|
|
477
617
|
});
|
|
478
618
|
}
|
|
@@ -91,7 +91,20 @@ export function repairAuthoringArtifact(value) {
|
|
|
91
91
|
return next;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
/**
|
|
95
|
+
* 渡された値がpathでなく本文そのものに見えるか。
|
|
96
|
+
* `--input`/`--evidence`はfileを取るが、AIも人もインラインの文章を渡して詰まる。
|
|
97
|
+
* 詰まった時に「fileを取る/文章なら--message」と言えるように判定する。
|
|
98
|
+
*/
|
|
99
|
+
function looksLikeProse(value) {
|
|
100
|
+
if (typeof value !== 'string') return false;
|
|
101
|
+
return value.length > 160
|
|
102
|
+
|| /[\n\r]/u.test(value)
|
|
103
|
+
|| /[、。「」()]/u.test(value)
|
|
104
|
+
|| (/\s/u.test(value) && !/[/\\]/u.test(value));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export async function resolveAuthoringInputPath(repoRoot, inputRef, { inlineFlag = null } = {}) {
|
|
95
108
|
if (typeof inputRef !== 'string' || inputRef.length === 0) {
|
|
96
109
|
fail('INPUT_UNREADABLE', 'input_ref_invalid', { input_ref: inputRef });
|
|
97
110
|
}
|
|
@@ -101,19 +114,35 @@ export async function resolveAuthoringInputPath(repoRoot, inputRef) {
|
|
|
101
114
|
: path.resolve(canonicalRoot, inputRef);
|
|
102
115
|
let stats;
|
|
103
116
|
try { stats = await lstat(candidate); } catch {
|
|
104
|
-
fail('INPUT_UNREADABLE', 'input_missing', {
|
|
117
|
+
fail('INPUT_UNREADABLE', 'input_missing', {
|
|
118
|
+
input_ref: inputRef,
|
|
119
|
+
repo_root: canonicalRoot,
|
|
120
|
+
next_action: looksLikeProse(inputRef)
|
|
121
|
+
? (inlineFlag
|
|
122
|
+
? `この引数はrepo内のfile pathを取る。文章をそのまま渡すなら ${inlineFlag} <text> を使う`
|
|
123
|
+
: 'この引数はrepo内のfile pathを取る。渡された値は本文に見える——先にfileへ書いてからそのpathを渡す')
|
|
124
|
+
: `repo内に存在するfile pathを渡す(repo_root: ${canonicalRoot})`,
|
|
125
|
+
});
|
|
105
126
|
}
|
|
106
127
|
if (stats.isSymbolicLink() || !stats.isFile()) {
|
|
107
128
|
fail('INPUT_UNREADABLE', 'unsafe_input_path', { input_ref: inputRef });
|
|
108
129
|
}
|
|
109
130
|
const resolved = await realpath(candidate);
|
|
110
131
|
if (!within(canonicalRoot, resolved) || resolved === canonicalRoot) {
|
|
111
|
-
fail('INPUT_UNREADABLE', 'input_path_outside_repo', {
|
|
132
|
+
fail('INPUT_UNREADABLE', 'input_path_outside_repo', {
|
|
133
|
+
input_ref: inputRef,
|
|
134
|
+
repo_root: canonicalRoot,
|
|
135
|
+
next_action: `repo内のfileだけ受理する。repo外(/tmp等)にあるならrepo内へ写してから渡す(repo_root: ${canonicalRoot})`,
|
|
136
|
+
});
|
|
112
137
|
}
|
|
113
138
|
if (stats.size > MAX_AUTHORING_INPUT_BYTES) fail('INPUT_TOO_LARGE', 'input_size_limit_exceeded');
|
|
114
139
|
const relative = path.relative(canonicalRoot, resolved);
|
|
115
140
|
if (relative.startsWith(`..${path.sep}`) || relative === '..' || path.isAbsolute(relative)) {
|
|
116
|
-
fail('INPUT_UNREADABLE', 'input_path_outside_repo', {
|
|
141
|
+
fail('INPUT_UNREADABLE', 'input_path_outside_repo', {
|
|
142
|
+
input_ref: inputRef,
|
|
143
|
+
repo_root: canonicalRoot,
|
|
144
|
+
next_action: `repo内のfileだけ受理する。repo外(/tmp等)にあるならrepo内へ写してから渡す(repo_root: ${canonicalRoot})`,
|
|
145
|
+
});
|
|
117
146
|
}
|
|
118
147
|
return {
|
|
119
148
|
absolute: resolved,
|
|
@@ -124,8 +153,9 @@ export async function resolveAuthoringInputPath(repoRoot, inputRef) {
|
|
|
124
153
|
|
|
125
154
|
export async function readAuthoringJsonFile(repoRoot, inputRef, {
|
|
126
155
|
invalidCode = 'INVALID_JSON',
|
|
156
|
+
inlineFlag = null,
|
|
127
157
|
} = {}) {
|
|
128
|
-
const located = await resolveAuthoringInputPath(repoRoot, inputRef);
|
|
158
|
+
const located = await resolveAuthoringInputPath(repoRoot, inputRef, { inlineFlag });
|
|
129
159
|
const bytes = await readFile(located.absolute);
|
|
130
160
|
if (bytes.length > located.maxBytes) fail('INPUT_TOO_LARGE', 'input_size_limit_exceeded');
|
|
131
161
|
let text;
|
package/src/todo-cli.mjs
CHANGED
|
@@ -325,7 +325,7 @@ function selectNoteTask(member, requestedTaskId) {
|
|
|
325
325
|
}
|
|
326
326
|
|
|
327
327
|
async function readNoteTextInput(repoRoot, inputRef) {
|
|
328
|
-
const located = await resolveAuthoringInputPath(repoRoot, inputRef);
|
|
328
|
+
const located = await resolveAuthoringInputPath(repoRoot, inputRef, { inlineFlag: '--message' });
|
|
329
329
|
const bytes = await readFile(located.absolute);
|
|
330
330
|
if (bytes.length > MAX_NOTE_INPUT_BYTES) {
|
|
331
331
|
throw new TodoStoreError('INPUT_TOO_LARGE', 'note_input_too_large');
|
|
@@ -463,7 +463,7 @@ async function resolveDoneEvidence({ repoRoot, evidenceRef, evidenceMessage, pla
|
|
|
463
463
|
}
|
|
464
464
|
return descriptor;
|
|
465
465
|
}
|
|
466
|
-
const located = await resolveAuthoringInputPath(repoRoot, evidenceRef);
|
|
466
|
+
const located = await resolveAuthoringInputPath(repoRoot, evidenceRef, { inlineFlag: '--message' });
|
|
467
467
|
const bytes = await readFile(located.absolute);
|
|
468
468
|
let text;
|
|
469
469
|
try { text = new TextDecoder('utf-8', { fatal: true }).decode(bytes); }
|