@c4a/context-cli 0.5.38 → 0.5.39-beta.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.md +1 -1
- package/cli.js +6039 -3768
- package/package.json +3 -1
- package/plugin/commands/align.md +17 -10
- package/plugin/commands/capture.md +2 -2
- package/plugin/commands/compile.md +7 -7
- package/plugin/skills/skill-align-workflow/SKILL.md +24 -10
- package/plugin/skills/skill-align-workflow/references/candidate-resolution.md +3 -3
- package/plugin/skills/skill-align-workflow/references/density-profile.md +1 -1
- package/plugin/skills/skill-align-workflow/references/gates.md +1 -1
- package/plugin/skills/skill-compile-draft/SKILL.md +7 -7
- package/plugin/skills/skill-compile-judge/SKILL.md +1 -1
- package/plugin/skills/skill-semantic-reconcile/references/temporal-and-evidence.md +4 -4
- package/scripts/build-aspect-runtime.ts +45 -0
- package/templates/aspect-runtime/aspectRunnerSdk.js +776 -0
- package/templates/aspects/README.md +7 -5
- package/templates/aspect-runtime/aspectRunnerSdk.ts +0 -749
- /package/templates/aspects/code/{prompt.md → README.md} +0 -0
- /package/templates/aspects/design-system/{prompt.md → README.md} +0 -0
- /package/templates/aspects/graphql/{prompt.md → README.md} +0 -0
- /package/templates/aspects/openapi/{prompt.md → README.md} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c4a/context-cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.39-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"context": "./cli.js"
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"mdast-util-to-string": "^4.0.0",
|
|
12
12
|
"react": "^18.3.1",
|
|
13
13
|
"remark-gfm": "^4.0.1",
|
|
14
|
+
"remark-mdx": "^3.1.1",
|
|
14
15
|
"remark-parse": "^11.0.0",
|
|
16
|
+
"remark-stringify": "^11.0.0",
|
|
15
17
|
"typescript": "^5.5.4",
|
|
16
18
|
"unified": "^11.0.5",
|
|
17
19
|
"yaml": "^2.5.1"
|
package/plugin/commands/align.md
CHANGED
|
@@ -17,33 +17,36 @@ Run `context align scan --format json`.
|
|
|
17
17
|
Use the returned `workflow.next-action-envelope.v2` as the source of truth:
|
|
18
18
|
|
|
19
19
|
- Follow top-level `next_action.kind` and `next_action.command` for every write.
|
|
20
|
-
- Use `
|
|
20
|
+
- Use only the returned `next_action.command` for the next required step. When it points at `read-plan`, run that one command first.
|
|
21
21
|
- Treat `allowed_actions[]` as permission for read-only insertions such as `show_view`; do not choose a different write path from it.
|
|
22
22
|
- Treat `agent_hints[]`, when present, as a temporary mirror or diagnostic only. If it conflicts with `next_action`, follow `next_action`.
|
|
23
|
+
- Read workflow payload views only through returned `context workflow show` commands.
|
|
23
24
|
|
|
24
25
|
For protocol discovery, prefer narrow commands:
|
|
25
26
|
|
|
26
27
|
- `context schema workflow.next-action-envelope.v2 --view minimal --format json`
|
|
27
28
|
- `context protocol show align-compile --format json`
|
|
28
|
-
- `context schema align-structure-
|
|
29
|
+
- `context schema align-structure-intent --view minimal --format json`
|
|
30
|
+
- `context schema align-structure-decision --view minimal --format json` only when auditing canonical output or repairing an advanced canonical payload.
|
|
29
31
|
|
|
30
|
-
### Step 2 — Read Evidence Through
|
|
32
|
+
### Step 2 — Read Evidence Through The Single Evidence Path
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
If scan returns a `read-plan` command, run it and then follow the next command returned by that view. The normal path is:
|
|
33
35
|
|
|
34
|
-
- `
|
|
35
|
-
- `
|
|
36
|
-
- `
|
|
36
|
+
- `read-plan` summarizes source size, active source set, navigation/placeholder sources, and the next evidence command.
|
|
37
|
+
- `source-bundle` returns the selected source text with `@c4a` block annotations. Read it, then write the requested align JSON yourself, normally `align-structure-intent`; do not pipe the bundle text into `context align validate`.
|
|
38
|
+
- If `source-bundle` omits text for budget, run its `next_action.command`.
|
|
39
|
+
- `blocks`, `windows`, `block-index`, `source-mapping`, and `pending-relation-refs` are detail views only. Use them when the read-plan/source-bundle next action or `how_to_explore[]` asks for a narrow follow-up.
|
|
37
40
|
|
|
38
41
|
When a view returns `page.next_command`, follow that command to continue the same semantic view. Use `--source`, `--heading`, `--window`, or `--token-budget` only as view filters; do not inspect workflow files, cache files, host tool-results, or stdout fragments with generic tools.
|
|
39
42
|
|
|
40
|
-
If a
|
|
43
|
+
If a detail view returns `align-blocks-read-incomplete`, `page.has_more`, or `truncated: true`, the response is a partial read. Return to the read-plan/source-bundle continuation instead of treating that partial JSON page as the complete source.
|
|
41
44
|
|
|
42
45
|
### Step 3 — Produce The Semantic Payload
|
|
43
46
|
|
|
44
47
|
Reuse existing knowledge before inventing new Nodes: use `context mdrive glossary match <name>` and `context mdrive node list --format json` for term/entity reuse.
|
|
45
48
|
|
|
46
|
-
Apply packaged `context:skill-align-workflow` Node classification gates and
|
|
49
|
+
Apply packaged `context:skill-align-workflow` Node classification gates and align intent procedure. Keep generated payloads on stdin. Do not create scratch files under the workspace or `/tmp`.
|
|
47
50
|
|
|
48
51
|
Use CLI diagnostics instead of static prompt rules:
|
|
49
52
|
|
|
@@ -54,7 +57,11 @@ Use CLI diagnostics instead of static prompt rules:
|
|
|
54
57
|
|
|
55
58
|
### Step 4 — Validate And Submit
|
|
56
59
|
|
|
57
|
-
When the envelope asks for `validate_align_decision`, submit the structure-
|
|
60
|
+
When the envelope asks for `validate_align_decision`, submit the payload matching `next_action.input_schema`, normally the `align-structure-intent` you authored after reading evidence, to `context align validate --input - --format json` or the exact returned command. If validate returns blocking diagnostics, repair the payload and rerun validate. If validate returns a `submit_structure_decision` next_action, execute that command with the same validated payload.
|
|
61
|
+
|
|
62
|
+
After a finalize command succeeds, do not submit finalize again to confirm it. Use returned `payloads.*.show_command` values, or `context workflow show --payload finalized-ownership --unwrap --format json`, for read-only confirmation; then follow `next_action.command`, normally `context compile scan --format json`.
|
|
63
|
+
|
|
64
|
+
If finalize reports node reclassification hints, treat finalized ownership as the source of truth. `context status` reports finalized node types, not the originally submitted proposal.
|
|
58
65
|
|
|
59
66
|
For any other write kind, execute the top-level `next_action.command` exactly. If the command rejects the payload, follow the returned `next_action` and `reason_code`; do not infer a route fallback from memory.
|
|
60
67
|
|
|
@@ -18,9 +18,9 @@ Capture is entirely CLI-driven — your role is to route the right `context capt
|
|
|
18
18
|
|
|
19
19
|
Do not run hand-written dependency preflight commands before `context capture --code`. The CLI owns TypeScript runner/plugin resolution and returns structured `agent_hints[]` when the runner is missing or misconfigured.
|
|
20
20
|
|
|
21
|
-
If `context capture --code ...` fails with install or runner hints, surface the CLI's `agent_hints[]` install command exactly as printed. Ask the user once whether to run that command on their behalf; global installs touch shared state, so explicit confirmation is required before invoking `Bash`. If approved, run the exact command from `agent_hints[0].command`, then retry the original `context capture --code ...` invocation. If declined, leave the command visible so the user can run it manually. Do not inline
|
|
21
|
+
If `context capture --code ...` fails with install or runner hints, surface the CLI's `agent_hints[]` install command exactly as printed. Ask the user once whether to run that command on their behalf; global installs touch shared state, so explicit confirmation is required before invoking `Bash`. If approved, run the exact command from `agent_hints[0].command`, then retry the original `context capture --code ...` invocation. If declined, leave the command visible so the user can run it manually. Do not inline extraction packages, do not hand-write code snapshots, and do not continue with partial capture.
|
|
22
22
|
|
|
23
|
-
Invocation note: code capture does not run through `npx`.
|
|
23
|
+
Invocation note: code capture does not run through `npx`. The default code aspect uses the `@c4a/extract` runner and `@c4a/extract-ts` plugin bundled into the installed `@c4a/context-cli`, then records the bundled runner identity in the user-cache manifest. Only non-default runner/plugin packages configured in `aspects/code/aspect.yaml` need to be resolvable from the same global install that provides `context`; when they are missing, the CLI returns structured install hints.
|
|
24
24
|
|
|
25
25
|
### Route by argument
|
|
26
26
|
|
|
@@ -37,12 +37,11 @@ Protocol discovery:
|
|
|
37
37
|
- `context protocol show align-compile --format json`
|
|
38
38
|
- command-specific `context schema <name> --view minimal --format json`
|
|
39
39
|
|
|
40
|
-
##
|
|
40
|
+
## Start
|
|
41
41
|
|
|
42
|
-
1. Run `context
|
|
43
|
-
2.
|
|
44
|
-
3. Run `context
|
|
45
|
-
4. If the scan returns `stop_noop` or no changed work, report that compile stopped before draft and no files were written.
|
|
42
|
+
1. Run `context compile scan --format json` (or `context compile scan --delegated --format json` only for explicit delegated mode).
|
|
43
|
+
2. If the scan returns `stop_noop` or no changed work, report that compile stopped before draft and no files were written.
|
|
44
|
+
3. Run `context status --format json` or `context mdrive workspace stats --format json` only when needed for the final before/after report or when the CLI asks for diagnostics. Do not run doctor/status/source-list as a required preflight before following a valid compile scan or align-finalize handoff.
|
|
46
45
|
|
|
47
46
|
Run `context compile scan` only for this initial preflight unless the CLI explicitly returns it as the next command after a terminal/no-work state. During an active compile workflow, discover the next node from the current envelope (`next_action`, `views[]`, `workset_progress`) and follow returned commands; do not rerun scan between node cycles to probe for the next node.
|
|
48
47
|
|
|
@@ -58,12 +57,13 @@ Run expected view commands from the envelope before writing. For compile evidenc
|
|
|
58
57
|
|
|
59
58
|
- `source_refs_index_command` / `source_refs_command` — compact block-id evidence index for drafting; use `items[].block_id` in `source_block_ids[]`.
|
|
60
59
|
- `source_refs_detail_command` — detailed source refs with quote previews; open only when the compact index is not enough.
|
|
60
|
+
- `request_full_text_command` / `--view text` — narrow text view for one block when quote preview is not enough; this is still Node-scoped, not a workspace evidence bundle.
|
|
61
61
|
- `citable_source_refs[]` — detailed-view refs eligible for draft citations; prefer `block_id` values in `source_block_ids[]`.
|
|
62
62
|
- `supporting_context_refs[]` — background/framing only.
|
|
63
63
|
- `required_preserved_literals[]` — URL, code identifier, `source_ref`, or `block_id` literals that must stay visible in the generated content or repair report.
|
|
64
64
|
- diagnostics such as citation eligibility, source support, coverage, engagement, and advisory foldbacks.
|
|
65
65
|
|
|
66
|
-
Follow `page.next_command` for pagination. Use `how_to_explore[]` for narrow reads. Do not expand workflow payloads through host tool-results. Node-cycle receipts are compact by default; `actions_meta[]` exposes current draft action handles for patching without an extra status read.
|
|
66
|
+
Follow `page.next_command` for pagination. Use `how_to_explore[]` for narrow reads. Do not expand workflow payloads through host tool-results. Node-cycle receipts are compact by default; `actions_meta[]` exposes current draft action handles for patching without an extra status read. When advisory foldbacks say `agent_recommended_action: ignore`, do not inspect each detail row unless the user asks for cleanup or the cited source appears to lose meaning.
|
|
67
67
|
|
|
68
68
|
### Step 2 — Produce Payloads Only When Requested
|
|
69
69
|
|
|
@@ -87,7 +87,7 @@ Use typed diagnostics as the repair contract:
|
|
|
87
87
|
- `diagnostics.auto_repaired[]` records mechanical repairs; warning severity must be surfaced in the final report.
|
|
88
88
|
- `diagnostics.warnings[]` with info/advisory severity are not write blockers unless `blocking: true` or the next action says so.
|
|
89
89
|
- `agent_recommended_action` classifies warning handling: `ignore` means continue unless the user asks for cleanup, `respond_optional` means repair only when semantically useful, and `respond_required` means resolve before the returned write action can succeed.
|
|
90
|
-
- `source_support` is advisory lexical diagnostics, not a keyword gate. Do not patch drafts only to satisfy term overlap. Blocking evidence checks should come from invalid source refs, changed evidence boundaries,
|
|
90
|
+
- `source_support` is advisory lexical diagnostics, not a keyword gate. Do not patch drafts only to satisfy term overlap. Blocking evidence checks should come from invalid source refs, changed evidence boundaries, unsupported confirmed hard facts, or explicit top-level `next_action`. URL preservation, section kind precision, example formatting, and summary style are advisory/debt unless the CLI explicitly marks them blocking.
|
|
91
91
|
- stale prepare refresh returns `review_reconcile_decisions` with `reason_code: "prepare_refreshed"`; reread the new prepare result before reviewing.
|
|
92
92
|
|
|
93
93
|
Do not recover by replaying an old manual path, editing rendered files, or guessing schema aliases.
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: skill-align-workflow
|
|
3
|
-
description: "Internal procedure for /context:align. Reads CLI-guided align evidence, applies semantic Node classification gates, and emits align structure-
|
|
3
|
+
description: "Internal procedure for /context:align. Reads CLI-guided align evidence, applies semantic Node classification gates, and emits align structure-intent payloads for CLI validation/finalize."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Align Workflow Procedure
|
|
7
7
|
|
|
8
8
|
## TL;DR
|
|
9
9
|
|
|
10
|
-
Run `context align scan --format json`, read
|
|
10
|
+
Run `context align scan --format json`, follow the top-level `next_action.command` to read the CLI-selected evidence path, produce semantic structure payloads, and continue following top-level `next_action`. The CLI owns route, validation, repair commands, and stage guards; this skill owns only semantic classification and source-bound structure judgment.
|
|
11
11
|
|
|
12
12
|
<reference>
|
|
13
13
|
|
|
14
14
|
## Canonical Data
|
|
15
15
|
|
|
16
|
-
- `workflow.next-action-envelope.v2` is authoritative. Branch on `next_action.kind`, execute `next_action.command
|
|
16
|
+
- `workflow.next-action-envelope.v2` is authoritative. Branch on `next_action.kind`, execute `next_action.command`, and treat `views[].command` as detail reads rather than a checklist.
|
|
17
17
|
- `allowed_actions[]` may permit extra read-only work before the next write; it is not a menu of alternate write paths.
|
|
18
18
|
- `agent_hints[]`, when still present, is a short-term cutover mirror or diagnostic. Do not prefer it over top-level `next_action`.
|
|
19
19
|
- Schema names and enum values come from `context schema <name>`; use `--view minimal` for protocol discovery before full schema reads.
|
|
@@ -39,13 +39,17 @@ Run `context align scan --format json`. Confirm `schema_version: "workflow.next-
|
|
|
39
39
|
|
|
40
40
|
If no envelope is present, stop and surface the CLI output; do not reconstruct an align route from old prompt memory.
|
|
41
41
|
|
|
42
|
-
### Step 2 —
|
|
42
|
+
### Step 2 — Follow The Evidence Read Path
|
|
43
43
|
|
|
44
|
-
Run `
|
|
44
|
+
Run the returned `next_action.command`. For structural align work this is normally `read-plan`; after that, follow the `read-plan` / `source-bundle` response's `next_action.command`.
|
|
45
|
+
|
|
46
|
+
`read-plan` is the navigation surface. It chooses whether the next evidence read is a whole-batch `source-bundle`, a scoped source/window bundle, or an existing coarse-read route. `source-bundle` is annotated source text; read it and then author the requested align JSON yourself, normally `align-structure-intent`. Never pipe bundle text into `context align validate`.
|
|
47
|
+
|
|
48
|
+
If `source-bundle` omits text for budget, run its `next_action.command`.
|
|
45
49
|
|
|
46
50
|
Read evidence through semantic CLI views, not shell parsing. Follow `page.next_command` for pagination. Use `--source`, `--heading`, `--window`, and `--token-budget` as view filters only. `--unwrap` removes workflow metadata; it does not expand a compact view into full detail.
|
|
47
51
|
|
|
48
|
-
If a blocks view returns `align-blocks-read-incomplete`, `page.has_more`, or `truncated: true`, treat that response as a partial read. Do not finalize source-wide ownership or dense planned Sections from source-mapping/headings alone;
|
|
52
|
+
If a blocks view returns `align-blocks-read-incomplete`, `page.has_more`, or `truncated: true`, treat that response as a partial read. Do not finalize source-wide ownership or dense planned Sections from source-mapping/headings alone; continue the current detail view only when `page.next_command` is explicitly needed, otherwise return to the read-plan/source-bundle continuation.
|
|
49
53
|
|
|
50
54
|
### Step 3 — Reuse Existing Knowledge
|
|
51
55
|
|
|
@@ -65,23 +69,33 @@ For large or batched payloads, use `references/density-profile.md` and `referenc
|
|
|
65
69
|
|
|
66
70
|
Use `next_action.input_schema` or the matching `context schema <name> --view minimal --format json` output to shape the payload.
|
|
67
71
|
|
|
68
|
-
For `
|
|
72
|
+
For the default `align-structure-intent` path, produce one intent document with semantic Nodes, `section_groups[]`, `ownership_groups[]`, optional explicit `block_ownership[]` patches, and edges. Let CLI generate `section_id` values and expand ownership groups into canonical defaults/exceptions.
|
|
73
|
+
|
|
74
|
+
Use only `block_ids[]` in `section_groups[]`. Do not invent heading/range/window selectors inside the intent. Every block you leave as `owned` or `shared` citation evidence must appear in some section group; otherwise reclassify it as `context_only` or `ignored`. If a no-write/navigation-only/placeholder-only Node has no section group, set `planned_sections: []` explicitly so the CLI knows this was intentional.
|
|
75
|
+
|
|
76
|
+
Prefer the strongest source-backed `section_kind` that fits the current schema priority chain; avoid planning an entire dense source as `description` when the evidence clearly contains examples, comparison tables, Q&A, decisions, specs, warnings, or principles. Treat kind precision as a drafting quality preference, not a reason to block an otherwise source-backed write. Keep only source-supported semantic decisions in the payload; leave mechanical repair and patch routing to CLI diagnostics.
|
|
77
|
+
|
|
78
|
+
Canonical `align-structure-decision` is not a parallel authoring path. Use it only when `next_action.input_schema` explicitly asks for it or when auditing/repairing canonical output returned by the CLI.
|
|
69
79
|
|
|
70
80
|
For coarse-read, candidate-op, patch, ownership, or rescan actions, follow the command and schema in the returned `next_action`. Do not carry old candidate-table, decision-patch, or full-tree payload shapes forward.
|
|
71
81
|
|
|
72
82
|
### Step 6 — Validate And Submit
|
|
73
83
|
|
|
74
|
-
Before finalizing
|
|
84
|
+
Before finalizing, run `context align validate --input - --format json` with the payload matching `next_action.input_schema`. If validate returns blocking diagnostics, repair the exact paths it reports and rerun validate. If validate returns a finalize `next_action`, submit the same validated payload to that command; do not copy compiled canonical JSON from validation output unless the CLI explicitly asks for canonical input.
|
|
85
|
+
|
|
86
|
+
After finalize succeeds, do not rerun the finalize submit command to confirm success. Use returned `payloads.*.show_command` values, or `context workflow show --payload finalized-ownership --unwrap --format json`, for read-only confirmation; then continue with the returned `next_action.command`, normally `context compile scan --format json`.
|
|
87
|
+
|
|
88
|
+
If finalize reports node reclassification hints, the submitted Node was changed by a semantic gate. Treat finalized ownership as the source of truth; status counts finalized Nodes, not submitted proposals.
|
|
75
89
|
|
|
76
90
|
If any write is rejected, follow the returned `next_action` and `reason_code`. Do not retry by guessing direct/batched stages, forcing route bypasses, or editing workflow files.
|
|
77
91
|
|
|
78
92
|
### Step 7 — Self-verify
|
|
79
93
|
|
|
80
94
|
- [ ] All writes followed top-level `next_action.command`. If not, return to **Step 1**.
|
|
81
|
-
- [ ] Evidence was read through `
|
|
95
|
+
- [ ] Evidence was read through returned `next_action.command`, `how_to_explore[]`, or CLI schema/protocol commands only. If not, return to **Step 2**.
|
|
82
96
|
- [ ] Node classification used the semantic gates in `references/gates.md`. If not, return to **Step 4**.
|
|
83
97
|
- [ ] URL/reference ownership followed CLI diagnostics, not static prompt rules. If not, return to **Step 5**.
|
|
84
|
-
- [ ]
|
|
98
|
+
- [ ] The requested align payload passed `context align validate --input - --format json` before finalize. If not, return to **Step 6**.
|
|
85
99
|
- [ ] No raw, cache, knowledge, `/tmp`, host tool-results, or workflow scratch files were read or written with generic tools. If violated, restart from **Step 1**.
|
|
86
100
|
|
|
87
101
|
</procedures>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Candidate Resolution Rules
|
|
2
2
|
|
|
3
|
-
Use these rules after reading candidate ledger and aggregate payloads, before `
|
|
3
|
+
Use these rules after reading candidate ledger and aggregate payloads, before authoring the align payload requested by `next_action.input_schema`.
|
|
4
4
|
|
|
5
5
|
## Anomaly Signals
|
|
6
6
|
|
|
@@ -35,7 +35,7 @@ These hints are for audit and Agent DX. Copy them from ledger labels/titles when
|
|
|
35
35
|
|
|
36
36
|
## `llm_slug_hint` And Refs
|
|
37
37
|
|
|
38
|
-
Use `llm_slug_hint` as the stable reference inside one
|
|
38
|
+
Use `llm_slug_hint` as the stable reference inside one align payload when final slugs may be normalized by the CLI.
|
|
39
39
|
|
|
40
40
|
Recommended pattern:
|
|
41
41
|
|
|
@@ -57,4 +57,4 @@ block_ownership:
|
|
|
57
57
|
- owners: [local:data-region]
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
Refs may point to `llm_slug_hint` or final `slug`; prefer `*_ref` fields when a schema provides them. If the CLI rejects an unknown ref, use the top-level envelope diagnostics (`issues[].expected_shape.available_node_refs`, `diagnostics.*.available_node_refs`, or the returned repair view) and resubmit the corrected `
|
|
60
|
+
Refs may point to `llm_slug_hint` or final `slug`; prefer `*_ref` fields when a schema provides them. If the CLI rejects an unknown ref, use the top-level envelope diagnostics (`issues[].expected_shape.available_node_refs`, `diagnostics.*.available_node_refs`, or the returned repair view) and resubmit the corrected payload using the same `next_action.input_schema`. `agent_hints[]`, when present, is only a cutover mirror and must not be the source of truth.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Use `density_profile` in `align-coarse-read` to describe how much structure the document needs before candidate discovery. This is a reading strategy, not a quality score.
|
|
4
4
|
|
|
5
|
-
This reference applies only when the current envelope asks for `next_action.kind: "submit_coarse_read"`.
|
|
5
|
+
This reference applies only when the current envelope asks for `next_action.kind: "submit_coarse_read"`. In normal direct routes, read-plan/source-bundle already selected the evidence path; do not emit a `single_pass` coarse-read payload unless the CLI requested coarse-read.
|
|
6
6
|
|
|
7
7
|
| Profile | Use When | Agent Behavior |
|
|
8
8
|
|---|---|---|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Node Classification Gates
|
|
2
2
|
|
|
3
|
-
Use these gates before every candidate batch and
|
|
3
|
+
Use these gates before every candidate batch and before authoring the align payload requested by `next_action.input_schema`.
|
|
4
4
|
Align owns Node type, tag, graph, planned Section, and ownership classification. It does **not** write Section prose.
|
|
5
5
|
|
|
6
6
|
## Node Type Order
|
|
@@ -23,14 +23,14 @@ Classify raw evidence for one Node into `add` / `skip` (and on refresh: `update`
|
|
|
23
23
|
- Evidence boundary: treat the CLI-provided NodeContext and evidence views as complete. Cite only block ids surfaced as citation-eligible in `source-refs-index` `items[]`, `citable_source_refs[]`, or `raw_snippet_indexes.citation_eligible`; treat `supporting_context_refs[]`, `context_only`, and secondary-shared snippets as background. `request_full_text` may expose visible text for inspection through the narrow text view (`context compile context <slug> --request-full-text <block_id> --view text --format json`), and it does not change citation eligibility. If supporting/context-only evidence is needed as a citation, emit `pending_ownership_challenge` or `structure_challenge` — see [references/structural-challenges.md](references/structural-challenges.md). Never `grep` / `sed` / `jq` / `cat` / `head` raw `--format json` stdout or workflow scratch files in `/tmp` or `.context/.cache/`; use semantic views and follow returned `next_command` / `how_to_explore[]`. For write commands that take `--payload-digest`, omit the flag unless the CLI explicitly asks for a stale guard.
|
|
24
24
|
- Actions are candidate write actions, not final semantic decisions; `context reconcile prepare` re-derives near-duplicate / conflict / merge relations from `candidates[]` on its own. Op naming is scoped by schema: compile-draft `actions[]` already targets Sections, so Section lifecycle ops are verb-only (`add`, `update`, `supersede`, `deprecate`, `skip`). Do not use align-style names such as `add_section`, `write_section`, or `propose_section`.
|
|
25
25
|
- Source support passing is not completion. Before emitting, estimate coverage from the provided `raw_snippets[]`: if there are 3+ citation-eligible snippets, a one-action draft is valid only when the later snippets are duplicates, navigation, placeholders, or continuations of the same fact. Small dense docs still need multiple actions when later snippets state distinct capabilities, constraints, examples, risks, FAQ, or usage notes. Large manuals/design docs should compile to several orthogonal actions in the same draft. Do not switch into "speed mode" because the first action validates; coverage is part of the draft task.
|
|
26
|
-
- Pick `kind` from the CLI's `context schema compile-draft` contract, especially `section_kind_priority` and the mount matrix.
|
|
26
|
+
- Pick `kind` from the CLI's `context schema compile-draft` contract, especially `section_kind_priority` and the mount matrix. Treat kind precision as a drafting quality preference, not a reason to loop forever when the CLI accepts the write. A `decision` needs at least two surfaced alternatives plus a reason; bare "we use X because Y" is usually `spec`. Reach `description` only after every more specific kind fails.
|
|
27
27
|
- `node.planned_sections[]` is an align-time scaffold hint, not a hard completion gate. Prefer a planned kind when the evidence fits; if a source-backed stronger kind differs, emit it and let the CLI warning guide review.
|
|
28
28
|
- `kind × node.type` must satisfy the CLI Section mount matrix; mismatches get rejected at write time. When the strongest kind is blocked by mount matrix, fall to the next legal kind whose form actually fits — do not collapse to `description` just because it mounts everywhere, and do not invent thin precision (e.g. one-line `spec`) just to avoid `description` either. See [Description anti-abuse gates](#description-anti-abuse-gates) for the classification checks at the description boundary.
|
|
29
29
|
- Every write action cites raw via `source_block_ids[]` from `source-refs-index` `items[].block_id` or `citable_source_refs[].block_id`; the CLI expands it to canonical `source_refs[]` before saving. Use explicit `source_refs[]` only when the CLI gives no block id for the needed citation. Never mix both fields in one action, fabricate ids, or cite navigation-only blocks as evidence for a content Section.
|
|
30
30
|
- For large source-ref views, prefer the returned `source_refs_index_command` / `source_refs_command` / `--view source-refs-index` when you only need block ids; open `source_refs_detail_command` only when you need quote preview or explicit `source_refs[]`.
|
|
31
31
|
- Use `content` for the Section text the reader should see. It may be long and may contain URLs, tables, commands, config, or code fences. Add `summary` for long content or when it helps readers/query output; omit it when content is short. Summary quality checks are warning hints only, not schema or evidence failures. The CLI rejects retired fields (`body`, `detail`, `raw`, singular `source_ref`, quoted-evidence) with canonical repair hints — read those hints rather than memorising the blacklist. Omit optional fields when empty.
|
|
32
|
-
- Preserve user-facing Markdown structure from cited raw when it carries meaning: inline code/code fences, Markdown links and URLs, blockquotes, list nesting, tables, and emphasis around key terms. Summary remains plain text; content may keep raw Markdown when that is the clearest faithful Section text.
|
|
33
|
-
- Preserve literals
|
|
32
|
+
- Preserve user-facing Markdown structure from cited raw when it carries meaning: inline code/code fences, Markdown links and URLs, blockquotes, list nesting, tables, and emphasis around key terms. Summary remains plain text; content may keep raw Markdown when that is the clearest faithful Section text. If the CLI later reports URL, example, section-kind, or summary-style issues as advisory/debt, do not patch solely for those unless the cited source meaning is materially lost.
|
|
33
|
+
- Preserve literals surfaced by the CLI when they are part of the user-facing knowledge. When source-refs or scaffold output lists `required_preserved_literals[]`, keep source-backed URL, code identifier, `source_ref`, or `block_id` literals visible in the relevant `content`, `summary`, skip reason, or repair challenge when doing so carries meaning. Do not rely on memorized URL rules; let CLI literal fields and citation diagnostics define what matters, and treat URL/style preservation warnings as advisory unless the next action is blocking.
|
|
34
34
|
- `refers_to_nodes[]` only carries slugs present in the context's glossary, existing Sections, or the current align plan; never invent one.
|
|
35
35
|
- `skip` is the honest default when raw adds nothing. Bare `skip` (no evidence) is only for deterministic no-ops such as unchanged input, pure navigation, or context-only/background snippets. When a citation-eligible snippet was reviewed and intentionally not written, emit `skip` with `source_block_ids[]` from `source-refs-index` `items[].block_id` or `citable_source_refs[].block_id` so semantic review can record `reviewed_no_write`. Never attach `context_only` / supporting block ids to skip; raise a challenge if they should become citation evidence.
|
|
36
36
|
- Any Node may legitimately compile to no Sections when the provided snippets contain only navigation (`Parent` / `Children` / `Related` / `Relations`) or placeholder text that explicitly says no detailed content is available. Emit `skip`; do not turn align summaries, parent/child lists, sibling links, or placeholders into `description` Sections. The align graph and Node metadata preserve structure; active Sections need citation-eligible content.
|
|
@@ -79,7 +79,7 @@ Minimal valid draft envelope:
|
|
|
79
79
|
|
|
80
80
|
`update` / `supersede` / `deprecate` ops live in [references/refresh-and-update.md](references/refresh-and-update.md). `structure_challenge` / `pending_ownership_challenge` ops live in [references/structural-challenges.md](references/structural-challenges.md). Do not emit them from the main path.
|
|
81
81
|
|
|
82
|
-
`source_block_ids[]` is a mechanical shorthand over the same citation-eligible evidence; a single citation is still a single-element array. When one Section summarises contiguous multi-block evidence, list only the block ids the `content` actually consumes. If using explicit `source_refs[]`, copy them verbatim from `raw_snippets[].source_ref`. If the CLI reports `compile-source-refs-auto-narrowed`, it safely reduced an over-wide citation; removed refs are still uncovered, so add separate actions for distinct knowledge or leave them to an evidence-carrying `skip`. Preserve raw wording in `content` when it is already clear. Preserving a cited prose/bullet list as the Section's user-facing content is allowed when that list is the actual knowledge; the anti-pattern is copying raw text only as traceability or lexical-score padding. For `example` Sections that cite command / config / code fences, include the relevant fenced block in `content`.
|
|
82
|
+
`source_block_ids[]` is a mechanical shorthand over the same citation-eligible evidence; a single citation is still a single-element array. When source-refs or draft-scaffold output provides `planned_section_groups[].draft_action_templates`, copy each template as a separate draft action and fill only `content`/`summary`; do not merge multiple planned groups, templates, or contiguous runs into one action. When one Section summarises contiguous multi-block evidence, list only the block ids the `content` actually consumes. If using explicit `source_refs[]`, copy them verbatim from `raw_snippets[].source_ref`. If the CLI reports `compile-source-refs-auto-narrowed`, it safely reduced an over-wide citation; removed refs are still uncovered, so add separate actions for distinct knowledge or leave them to an evidence-carrying `skip`. Preserve raw wording in `content` when it is already clear. Preserving a cited prose/bullet list as the Section's user-facing content is allowed when that list is the actual knowledge; the anti-pattern is copying raw text only as traceability or lexical-score padding. For `example` Sections that cite command / config / code fences, include the relevant fenced block in `content`.
|
|
83
83
|
|
|
84
84
|
## Section Kind Choice
|
|
85
85
|
|
|
@@ -107,7 +107,7 @@ When raw mentions a name that overlaps the workspace glossary, put that name's s
|
|
|
107
107
|
|
|
108
108
|
If the CLI returns `compile-missing-refers-to-node`, treat it as advisory: add the suggested slug only when the Section actually depends on that Node; otherwise leave the draft unchanged and rely on the cited `source_ref`.
|
|
109
109
|
|
|
110
|
-
If the CLI returns source-ref narrowing, candidate hard-fact, summary quality, or low-coverage advisories with `agent_recommended_action: ignore`, do not patch solely to satisfy the advisory. Patch only when the cited source actually loses meaning, a confirmed hard fact is unsupported, or the returned `next_action` asks for a draft patch.
|
|
110
|
+
If the CLI returns source-ref narrowing, candidate hard-fact, summary quality, or low-coverage advisories with `agent_recommended_action: ignore`, do not patch solely to satisfy the advisory and do not inspect every folded detail row by default. Patch only when the cited source actually loses meaning, a confirmed hard fact is unsupported, the user asks for cleanup, or the returned `next_action` asks for a draft patch.
|
|
111
111
|
|
|
112
112
|
## FAQ attachment priority
|
|
113
113
|
|
|
@@ -158,10 +158,10 @@ For each classified snippet:
|
|
|
158
158
|
- For `description` / `spec`, a concise summary plus the cited bullet list is acceptable when the bullets are the useful user-facing knowledge. It becomes echo only when the copied text is not meant to be read as active knowledge.
|
|
159
159
|
- For `example` Sections that cite a code, config, or command fence, keep `content` centered on the cited fenced block. Put framing prose such as "basic configuration example" in `summary`, or cite a separate prose block in a separate action when that prose is itself source-backed knowledge.
|
|
160
160
|
3. For long `content`, add `summary` when it helps readers or query output. Summary is LLM-authored reader/query aid: one plain paragraph, no Markdown, and should stay compact. The CLI only reports advisory hints for missing summaries on long content, Markdown/multi-paragraph formatting, or clearly overlong summaries; it does not enforce a content-length ratio and does not treat summary quality as an evidence failure. Lexical `source_support` checks `content` (and legacy `detail` when present), not `summary`; keep summaries faithful to `content`, but do not copy raw-only keywords into `summary` for lexical scoring.
|
|
161
|
-
4. Preserve `required_preserved_literals[]` from the CLI evidence view. For link-heavy citation-eligible evidence, keep
|
|
161
|
+
4. Preserve `required_preserved_literals[]` from the CLI evidence view when the literal is part of the source-backed knowledge. For link-heavy citation-eligible evidence, keep meaningful URLs in `content` when the action writes knowledge; for supporting-only literals, keep them in the repair/challenge context instead of citing them. Do not patch only to satisfy non-blocking URL or style advisories.
|
|
162
162
|
5. Omit `confidence` for ordinary confirmed claims. Assign it only when the evidence is clearly verified, inferred, or speculative according to the schema enum.
|
|
163
163
|
6. Fill `refers_to_nodes[]` per [Glossary and refers_to_nodes](#glossary-and-refers_to_nodes).
|
|
164
|
-
7. Cite evidence with `source_block_ids[]`, picking values from `source-refs-index` `items[].block_id` or `citable_source_refs[].block_id`. When one Section summarizes contiguous multi-block evidence, list only the block ids consumed by that Section content; the CLI expands and verifies that the refs can collapse to one canonical citation token and may auto-narrow over-wide citations. If the evidence is non-contiguous or contains separable claims, split the draft into separately cited actions instead of stretching one action across unrelated blocks. For `skip`, include `source_block_ids[]` only when the skip represents reviewed no-write material from citation-eligible evidence; omit evidence for purely deterministic no-ops, navigation, and context-only/background snippets. Never submit singular `source_ref`, mix `source_block_ids` with `source_refs`, or use quoted-evidence fields;
|
|
164
|
+
7. Cite evidence with `source_block_ids[]`, picking values from `source-refs-index` `items[].block_id` or `citable_source_refs[].block_id`. Keep CLI-provided `planned_section_groups[].draft_action_templates` one-to-one with draft actions; fallback may split them finer, but must not merge them. When one Section summarizes contiguous multi-block evidence, list only the block ids consumed by that Section content; the CLI expands and verifies that the refs can collapse to one canonical citation token and may auto-narrow over-wide citations. If the evidence is non-contiguous or contains separable claims, split the draft into separately cited actions instead of stretching one action across unrelated blocks. For `skip`, include `source_block_ids[]` only when the skip represents reviewed no-write material from citation-eligible evidence; omit evidence for purely deterministic no-ops, navigation, and context-only/background snippets. Never submit singular `source_ref`, mix `source_block_ids` with `source_refs`, or use quoted-evidence fields; invalid evidence references remain blocking.
|
|
165
165
|
|
|
166
166
|
Rendered knowledge starts with optional `c4a:summary`, then the active `content`. If `content` differs from the cited raw, the CLI may render a debug-only `c4a:raw` block for audit; agents must not emit `raw`.
|
|
167
167
|
|
|
@@ -29,7 +29,7 @@ decisions only; the CLI reviews, applies, and writes every workspace change.
|
|
|
29
29
|
- For `duplicate`, `supersede`, `conflict`, or `merge_into`, set `target_section_id` to the matched candidate Section id.
|
|
30
30
|
- Same `source_ref` can support different Section kinds only when the semantic role differs. Detect and explain same-source-ref multi-kind cases instead of treating them as automatic duplicates.
|
|
31
31
|
- `source_support` is advisory lexical diagnostics, not a keyword gate. A supported judge verdict may override low lexical `source_support` when the cited raw evidence semantically covers the claim.
|
|
32
|
-
- Evidence-boundary errors
|
|
32
|
+
- Evidence-boundary errors and unsupported confirmed hard facts remain blocking evidence issues. Missing URLs, section kind precision, example formatting, summary style, and lexical hard-term spelling/casing/punctuation/paraphrase mismatches are advisory unless the active CLI `next_action` explicitly blocks on them.
|
|
33
33
|
- Weak support is a warning-level verdict, not permission to invent missing facts. Unsupported support should normally pair with `conflict` or a later user question rather than a write decision.
|
|
34
34
|
|
|
35
35
|
<reference>
|
|
@@ -51,12 +51,12 @@ When the prepare item carries long `proposed.content` or a `proposed.summary`, t
|
|
|
51
51
|
- Preserve prepared `content` and `summary` on executable write decisions (`merge_update`, `supersede.new`, `keep_separate`, `split_then_reanchor` sub-Sections) unless the decision intentionally rewrites the user-facing content.
|
|
52
52
|
- The only legitimate way to clear `summary` is an update-style decision that explicitly emits `summary: null` as the chosen outcome.
|
|
53
53
|
|
|
54
|
-
## Example content preservation
|
|
54
|
+
## Example content preservation advisory
|
|
55
55
|
|
|
56
|
-
If review reports that a cited example evidence contains a command / config / code fence missing from `proposed.content`,
|
|
56
|
+
If review reports that a cited example evidence contains a command / config / code fence missing from `proposed.content`, first check the CLI issue severity and next action.
|
|
57
57
|
|
|
58
|
-
- **
|
|
59
|
-
- **
|
|
58
|
+
- **When blocking**: regenerate the decision with the relevant fenced block included in `proposed.content` (preserve language, fences, and exact code), then rerun review.
|
|
59
|
+
- **When advisory/debt**: do not patch solely for formatting. Patch only if the missing command/config/code changes the user-facing meaning or the user asks for fidelity cleanup.
|
|
60
60
|
|
|
61
61
|
## How this slots into the main procedure
|
|
62
62
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import { basename, join } from "node:path";
|
|
4
|
+
|
|
5
|
+
const outdir = join(process.cwd(), "templates", "aspect-runtime");
|
|
6
|
+
await mkdir(outdir, { recursive: true });
|
|
7
|
+
|
|
8
|
+
const result = await Bun.build({
|
|
9
|
+
entrypoints: [join(process.cwd(), "src", "aspect-runtime", "index.ts")],
|
|
10
|
+
outdir,
|
|
11
|
+
naming: "aspectRunnerSdk.js",
|
|
12
|
+
target: "node",
|
|
13
|
+
format: "esm",
|
|
14
|
+
external: [
|
|
15
|
+
"remark-gfm",
|
|
16
|
+
"remark-mdx",
|
|
17
|
+
"remark-parse",
|
|
18
|
+
"remark-stringify",
|
|
19
|
+
"typescript",
|
|
20
|
+
"unified",
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (!result.success) {
|
|
25
|
+
for (const log of result.logs) {
|
|
26
|
+
console.error(log);
|
|
27
|
+
}
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
for (const output of result.outputs) {
|
|
32
|
+
console.log(` ${basename(output.path)} ${(output.size / 1024).toFixed(1)} KB`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const target = join(outdir, "aspectRunnerSdk.js");
|
|
36
|
+
if (!existsSync(target)) {
|
|
37
|
+
throw new Error(`aspect runtime build did not emit ${target}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let content = await readFile(target, "utf8");
|
|
41
|
+
content = [
|
|
42
|
+
"/* Generated by packages/context-cli/scripts/build-aspect-runtime.ts. Do not edit directly. */",
|
|
43
|
+
content,
|
|
44
|
+
].join("\n");
|
|
45
|
+
await writeFile(target, content);
|