@c4a/context-cli 0.5.35-beta.3 → 0.5.38
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 +7 -7
- package/cli.js +47004 -34404
- package/package.json +2 -1
- package/plugin/README.md +2 -2
- package/plugin/README_CN.md +2 -2
- package/plugin/commands/align.md +32 -98
- package/plugin/commands/capture.md +12 -13
- package/plugin/commands/compile.md +78 -149
- package/plugin/commands/init.md +15 -13
- package/plugin/commands/status.md +2 -0
- package/plugin/skills/skill-align-workflow/SKILL.md +41 -83
- package/plugin/skills/skill-align-workflow/references/candidate-resolution.md +1 -1
- package/plugin/skills/skill-align-workflow/references/density-profile.md +2 -0
- package/plugin/skills/skill-compile-close/SKILL.md +7 -9
- package/plugin/skills/skill-compile-draft/SKILL.md +43 -83
- package/plugin/skills/skill-compile-draft/references/notes.md +3 -3
- package/plugin/skills/skill-compile-draft/references/refresh-and-update.md +5 -5
- package/plugin/skills/skill-compile-draft/references/structural-challenges.md +1 -1
- package/plugin/skills/skill-compile-judge/SKILL.md +15 -12
- package/plugin/skills/skill-semantic-reconcile/SKILL.md +7 -7
- package/plugin/skills/skill-semantic-reconcile/references/leakage-and-ownership.md +1 -1
- package/scripts/build-plugin.ts +8 -6
- package/templates/aspect-runtime/aspectRunnerSdk.ts +749 -0
- package/templates/aspects/README.md +515 -0
- package/templates/aspects/code/aspect.yaml +2 -2
- package/templates/aspects/code/prompt.md +13 -12
|
@@ -1,170 +1,99 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "Compile the confirmed align plan into knowledge
|
|
3
|
-
argument-hint: "[--plan
|
|
2
|
+
description: "Compile the confirmed align plan into source-linked knowledge through CLI-guided workflow steps."
|
|
3
|
+
argument-hint: "[--plan|--aspect code [slug]|--aspect <name>|--all]"
|
|
4
4
|
allowed-tools: Bash(context:*)
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
<!--
|
|
8
|
-
This command is slightly over the 30-line default because it carries
|
|
9
|
-
the default-mode vs `--plan`-mode comparison inline; the mode contrast
|
|
10
|
-
belongs here rather than split across skill references.
|
|
11
|
-
The agent protocol itself still delegates to internal packaged procedures.
|
|
12
|
-
-->
|
|
13
|
-
|
|
14
7
|
## Your Task
|
|
15
8
|
|
|
16
|
-
|
|
9
|
+
Synthesize finalized align structure into knowledge. The CLI owns workflow routing, validation, reconciliation, apply, close, payload storage, and recovery commands. The agent reads evidence and emits semantic payloads only when `next_action` asks for them.
|
|
17
10
|
|
|
18
11
|
Naming convention:
|
|
19
12
|
|
|
20
13
|
- `/context:*` names user slash commands.
|
|
21
14
|
- `context ...` names CLI primitives.
|
|
22
|
-
-
|
|
15
|
+
- `context:skill-*` names packaged internal procedures, not user slash commands.
|
|
23
16
|
|
|
24
17
|
### Modes
|
|
25
18
|
|
|
26
|
-
- **Default
|
|
27
|
-
- **`--plan`**
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
- **Default** — follow `context compile scan --format json` and the returned `next_action` until compile is closed or no work remains.
|
|
20
|
+
- **`--plan`** — validate per-Node draft changes without closing or writing active knowledge; stop after the planned changes are reported.
|
|
21
|
+
- **`--aspect code [selector]`** — run `context compile --aspect code [selector]`, report the CLI result, and stop unless the CLI asks for a follow-up close. The selector may be omitted to process all actionable code sources; when present, the CLI resolves source slug, package name, or module path.
|
|
22
|
+
- **`--aspect <name>`** — run deterministic custom aspect projection for one configured aspect. Use `context compile --aspect <name> --allow-large-deprecate` only when the CLI rejected a large deprecate and the user confirms the runner output is intentionally empty or reduced.
|
|
23
|
+
- **`--all`** — run `context compile --all` to materialize code projection first and then custom aspect projections in deterministic order.
|
|
24
|
+
- **Delegated** — add `--delegated` only when the user explicitly authorized delegated/automatic mode at the start of this conversation. Do not infer it from vague "continue" permission.
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
- `--delegated` is a workflow-level authorization, not a per-review override. It only lets the CLI auto-accept low-risk defaults: weak lexical support with empty `source_support.missing_hard_terms`, or supported `keep_separate` decisions whose candidates have no duplicate/conflict/archive/reanchor risk and no pinned target Section. Missing hard facts, type drift, schema errors, ownership/structure challenges, user-confirmation gates, and destructive gates still block.
|
|
34
|
-
- Never hand-author `decided_by: delegated_agent`; the CLI injects it only inside a delegated compile workflow.
|
|
26
|
+
### Core Rules
|
|
35
27
|
|
|
36
|
-
|
|
28
|
+
- Follow top-level `next_action.kind` and `next_action.command` for every write.
|
|
29
|
+
- Use `views[].command` for evidence reads, prioritizing `expected: true`.
|
|
30
|
+
- Treat `allowed_actions[]` as permission for read-only insertions; it is not a menu of alternate write paths.
|
|
31
|
+
- Treat `agent_hints[]`, when present, as a temporary mirror or diagnostic. If it conflicts with `next_action`, follow `next_action`.
|
|
32
|
+
- Do not use direct file tools, shell scripts, `jq`, `sed`, `cat`, `head`, `tail`, Python, or Node.js to inspect workspace storage, workflow payload files, or `--format json` stdout.
|
|
37
33
|
|
|
38
|
-
|
|
34
|
+
Protocol discovery:
|
|
39
35
|
|
|
40
|
-
|
|
36
|
+
- `context schema workflow.next-action-envelope.v2 --view minimal --format json`
|
|
37
|
+
- `context protocol show align-compile --format json`
|
|
38
|
+
- command-specific `context schema <name> --view minimal --format json`
|
|
41
39
|
|
|
42
40
|
## Preflight
|
|
43
41
|
|
|
44
|
-
1. Run `context doctor
|
|
45
|
-
2. Run `context
|
|
46
|
-
3. Run `context compile scan --format json`
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
context compile draft billing-api --input - --prepare --format json <<'JSON'
|
|
104
|
-
{
|
|
105
|
-
"schema_version": "compile.draft.v2",
|
|
106
|
-
"target_node": "billing-api",
|
|
107
|
-
"actions": [
|
|
108
|
-
{
|
|
109
|
-
"op": "add",
|
|
110
|
-
"kind": "description",
|
|
111
|
-
"content": "Billing API exposes invoice lookup and payment capture endpoints.",
|
|
112
|
-
"source_refs": ["src-1#billing-api L10-18@7a6f4c9d2e10"]
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
}
|
|
116
|
-
JSON
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
For reviewed no-write material, keep the evidence in the skip action so semantic review can record it:
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
context compile draft billing-api --input - --prepare --format json <<'JSON'
|
|
123
|
-
{
|
|
124
|
-
"schema_version": "compile.draft.v2",
|
|
125
|
-
"target_node": "billing-api",
|
|
126
|
-
"actions": [
|
|
127
|
-
{
|
|
128
|
-
"op": "skip",
|
|
129
|
-
"reason": "reviewed; intentionally not written",
|
|
130
|
-
"source_refs": ["src-1#reviewed-note L12-14@7a6f4c9d2e10"]
|
|
131
|
-
}
|
|
132
|
-
]
|
|
133
|
-
}
|
|
134
|
-
JSON
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
For navigation-only or placeholder-only context, no active Section is the correct result:
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
context compile draft billing-api --input - --prepare --format json <<'JSON'
|
|
141
|
-
{
|
|
142
|
-
"schema_version": "compile.draft.v2",
|
|
143
|
-
"target_node": "billing-api",
|
|
144
|
-
"actions": [
|
|
145
|
-
{
|
|
146
|
-
"op": "skip",
|
|
147
|
-
"reason": "navigation-only context; align graph already preserves parent/child/related structure"
|
|
148
|
-
}
|
|
149
|
-
]
|
|
150
|
-
}
|
|
151
|
-
JSON
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Final Report Contract
|
|
155
|
-
|
|
156
|
-
- Report in the user's conversation language.
|
|
157
|
-
- Keep a stable structure with these semantic sections; translate section headings into the user's conversation language instead of copying these English labels verbatim:
|
|
158
|
-
1. Completion headline.
|
|
159
|
-
2. Semantic apply table. Include refreshed-source rows first in source-id order when the refreshed-source loop ran, then one row per Node in align frontmatter order. Columns: target (source id or Node title/slug), type (`refresh` or Node type), and the `context reconcile apply --format json` counts: `applied`, `skipped`, `merged`, `superseded`, `kept_separate`, `omitted`, and `questions_resolved`. Include `reanchored`, `removed_unsupported`, and `split_then_reanchored` only when non-zero.
|
|
160
|
-
3. Close stage with `context compile close` result, final node/section totals, verify status, changelog stamp, incremental counts (`recompiled`, `locator_updates`, `canonical_source_ref_updates`, `rebuilt`), section fingerprint rebuild count, and archive status / archived file count when reported by CLI. Do not use close output as the semantic apply summary; aggregate the per-Node `context reconcile apply` results from Step 6.
|
|
161
|
-
4. Before/after status diff table with at least total nodes, node counts by type, total sections, and last compile time.
|
|
162
|
-
5. Knowledge objects by semantic handle. Include every Node slug and `node_class` returned by `context mdrive node list --format json`; group or label term definitions separately from concrete entities when useful. Include human-readable links only when an explicit human/report view returns them, and state that they are not workflow inputs.
|
|
163
|
-
6. Optional next step only when there is a concrete useful follow-up (for example recapture stale material or run `/context:align` to revise structure).
|
|
164
|
-
- Do not say the user can inspect files without providing links.
|
|
165
|
-
|
|
166
|
-
## Plan Mode Final Report Contract
|
|
167
|
-
|
|
168
|
-
- Use the same stable shape where possible, but make the headline clearly indicate that this was a plan-only run.
|
|
169
|
-
- Replace the close-stage section with a not-written section and tell the user to re-run `/context:compile` without `--plan` to apply.
|
|
170
|
-
- Do not include knowledge file links for files that were not written.
|
|
42
|
+
1. Run `context doctor`. If output-align errors block compile, tell the user to run `/context:align` and stop.
|
|
43
|
+
2. Run `context status --format json` and `context mdrive workspace stats --format json` for before/after reporting.
|
|
44
|
+
3. Run `context compile scan --format json` (or `context compile scan --delegated --format json` only for explicit delegated mode).
|
|
45
|
+
4. If the scan returns `stop_noop` or no changed work, report that compile stopped before draft and no files were written.
|
|
46
|
+
|
|
47
|
+
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
|
+
|
|
49
|
+
## Main Loop
|
|
50
|
+
|
|
51
|
+
Repeat until the CLI returns `stop_noop`, `close_compile` succeeds, or a blocking user question remains.
|
|
52
|
+
|
|
53
|
+
Carry the latest envelope forward between iterations. After a successful node cycle, continue from its returned `next_action.command` / `workset_progress` rather than restarting at `context compile scan`.
|
|
54
|
+
|
|
55
|
+
### Step 1 — Read Expected Views
|
|
56
|
+
|
|
57
|
+
Run expected view commands from the envelope before writing. For compile evidence, prefer the CLI-returned source-ref/scaffold views. They may expose:
|
|
58
|
+
|
|
59
|
+
- `source_refs_index_command` / `source_refs_command` — compact block-id evidence index for drafting; use `items[].block_id` in `source_block_ids[]`.
|
|
60
|
+
- `source_refs_detail_command` — detailed source refs with quote previews; open only when the compact index is not enough.
|
|
61
|
+
- `citable_source_refs[]` — detailed-view refs eligible for draft citations; prefer `block_id` values in `source_block_ids[]`.
|
|
62
|
+
- `supporting_context_refs[]` — background/framing only.
|
|
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
|
+
- diagnostics such as citation eligibility, source support, coverage, engagement, and advisory foldbacks.
|
|
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.
|
|
67
|
+
|
|
68
|
+
### Step 2 — Produce Payloads Only When Requested
|
|
69
|
+
|
|
70
|
+
For `submit_compile_cycle`, load the Node evidence via the returned command/views, invoke packaged `context:skill-compile-draft` for exactly one Node, and pass the emitted JSON on stdin to the returned `next_action.command`.
|
|
71
|
+
|
|
72
|
+
For `continue_compile_cycle`, do not invoke the draft skill and do not attach `--input`; execute the returned `next_action.command` exactly. `--continue` resumes a saved draft session. If it returns `status: "noop"`, follow the returned `close_compile` next action.
|
|
73
|
+
|
|
74
|
+
For `patch_compile_draft`, submit only the patch schema requested by the CLI. Use `actions_meta[].action_id` for `replace_action` / `remove_action`, or `add_action` with `before` / `after`; do not use generic `op/path/value` aliases.
|
|
75
|
+
|
|
76
|
+
For `review_reconcile_decisions`, load the prepare payload through CLI views such as `context workflow show --payload prepare --unwrap --format json`, invoke packaged `context:skill-compile-judge` when semantic judgment is needed, run `context reconcile validate --mode compile --node <slug> --decisions - --format json`, repair any blocking diagnostics, then pass validated decisions to the returned review command.
|
|
77
|
+
|
|
78
|
+
Invoke `context:skill-compile-judge` only when the top-level `next_action.kind` is exactly `review_reconcile_decisions`. If `questions` are present but `next_action.kind` is `patch_compile_draft`, patch the draft first; do not infer judge mode from question counts.
|
|
79
|
+
|
|
80
|
+
For `apply_reconcile_review`, `close_compile`, `finish_current_node`, `submit_coverage_disposition`, or `abandon_or_rescan`, execute the returned command exactly. If it rejects, follow the new `next_action` and `reason_code`.
|
|
81
|
+
|
|
82
|
+
### Step 3 — Repair From Diagnostics
|
|
83
|
+
|
|
84
|
+
Use typed diagnostics as the repair contract:
|
|
85
|
+
|
|
86
|
+
- `reason_code`, `path`, and `missing[]` identify what to fix.
|
|
87
|
+
- `diagnostics.auto_repaired[]` records mechanical repairs; warning severity must be surfaced in the final report.
|
|
88
|
+
- `diagnostics.warnings[]` with info/advisory severity are not write blockers unless `blocking: true` or the next action says so.
|
|
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, URL preservation, split-by-evidence candidates, or explicit top-level `next_action`.
|
|
91
|
+
- stale prepare refresh returns `review_reconcile_decisions` with `reason_code: "prepare_refreshed"`; reread the new prepare result before reviewing.
|
|
92
|
+
|
|
93
|
+
Do not recover by replaying an old manual path, editing rendered files, or guessing schema aliases.
|
|
94
|
+
|
|
95
|
+
## Close And Report
|
|
96
|
+
|
|
97
|
+
When `next_action.kind` is `close_compile`, execute `context compile close` through packaged `context:skill-compile-close` or the returned command. Never claim success unless close exits 0 and verify is green, except the explicit no-work path.
|
|
98
|
+
|
|
99
|
+
Report in the user's conversation language. Include semantic apply counts, close/verify status, warning-level `auto_repaired[]`, `ready_with_debt` coverage/review-debt summaries when present, and before/after workspace totals. Do not surface internal workflow payload digests, source-ref hashes, archive paths, or absolute file paths unless a user-facing report view explicitly returns them.
|
package/plugin/commands/init.md
CHANGED
|
@@ -70,7 +70,10 @@ Q. What will this workspace mainly hold?
|
|
|
70
70
|
Interpret the answer:
|
|
71
71
|
- Chose A–D → generate a 2–3 line focus description in the user's language. Phrase it as
|
|
72
72
|
"primarily X; supporting materials such as Y may also be filed here" rather than exclusion
|
|
73
|
-
language — workspaces absorb auxiliary material in practice.
|
|
73
|
+
language — workspaces absorb auxiliary material in practice. Show the exact generated focus
|
|
74
|
+
text to the user and ask for one confirmation before running `context init`. If the user
|
|
75
|
+
approves, pass it as `--focus "..."`; if the user edits it, pass the edited text as
|
|
76
|
+
`--focus "..."`; if the user declines or says to skip, run without `--focus`.
|
|
74
77
|
- Chose E or described freely → pass the user's text verbatim as `--focus "..."`.
|
|
75
78
|
- User says "skip" / "don't care" → run `context init` without `--focus`.
|
|
76
79
|
- `$ARGUMENTS` already contains `--focus "..."` → skip this step entirely.
|
|
@@ -84,28 +87,27 @@ If the user request names specific aspects, map that directly:
|
|
|
84
87
|
- "all aspects" / "全部 aspect" → append `--with-all-aspects`
|
|
85
88
|
- "no aspects" / "不安装 aspect" / "minimal" → append `--no-aspects`
|
|
86
89
|
|
|
87
|
-
Otherwise ask **one**
|
|
90
|
+
Otherwise ask **one** short single-choice question. Keep the option count to three or fewer; host question tools reject longer option lists. Use the host's free-text `Other` escape hatch when the user needs a custom comma-separated aspect list.
|
|
88
91
|
|
|
89
92
|
```
|
|
90
|
-
Q. Which aspects should be installed?
|
|
91
|
-
A.
|
|
92
|
-
B.
|
|
93
|
-
C.
|
|
94
|
-
D. openapi — placeholder aspect template.
|
|
95
|
-
E. graphql — placeholder aspect template.
|
|
93
|
+
Q. Which aspects should be installed?
|
|
94
|
+
A. code — scripted local source-code capture. (Recommended)
|
|
95
|
+
B. all built-in aspects — code, design-system, openapi, graphql.
|
|
96
|
+
C. skip — install no aspects now; add later with `context init --with-aspects <name>`.
|
|
96
97
|
```
|
|
97
98
|
|
|
98
99
|
Hard rules when mapping into the host UI:
|
|
99
100
|
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
-
|
|
101
|
+
- Do not present separate options for every built-in aspect; that exceeds host option limits once `skip` is included.
|
|
102
|
+
- Put `code` first and mark it as recommended.
|
|
103
|
+
- Treat the host auto-injected `Other` as a free-text custom list such as `code,openapi`, not as "skip".
|
|
103
104
|
|
|
104
105
|
Map the answer:
|
|
105
106
|
|
|
107
|
+
- `code` selected → append `--with-aspects code`.
|
|
108
|
+
- `all built-in aspects` selected → append `--with-all-aspects`.
|
|
106
109
|
- `skip` selected → append `--no-aspects`.
|
|
107
|
-
-
|
|
108
|
-
- Host auto-injected `Other` selected → ignore it, fall back to the recommended default `--with-aspects code`.
|
|
110
|
+
- Host auto-injected `Other` selected → parse the user's comma-separated aspect names and append `--with-aspects <names>`. If the custom text is empty or invalid, ask once for clarification rather than silently installing all aspects.
|
|
109
111
|
|
|
110
112
|
Do not silently install all aspects when the user asked for a code-only workspace.
|
|
111
113
|
|
|
@@ -11,8 +11,10 @@ Run `context status` from the active workspace root only. `status` is intentiona
|
|
|
11
11
|
Surface the CLI's output verbatim — its trailing suggestions are already actionable. Do not invent additional suggestions; the CLI decides what to recommend based on the workspace state. Typical recommendations you will see:
|
|
12
12
|
|
|
13
13
|
- Run `/context:align` when there is active raw material but no align plan yet (compile's Stage 1 prerequisite).
|
|
14
|
+
- Run `/context:align` when JSON status reports `incremental.pending_align.status: "pending"` with `count > 0`. This structural signal takes precedence over a previous finalized align workflow's compile hint.
|
|
14
15
|
- Run `/context:compile` when align plan exists and raw is newer than the last compile.
|
|
15
16
|
- Run `/context:capture --code` when the repo is a git checkout but no source-code snapshot has been captured yet.
|
|
17
|
+
- Run `context compile --aspect code` when code projection is pending, or `context compile --aspect <name>` when a custom aspect projection is pending. JSON status includes `aspect_projection` and `code_projection` summaries for these deterministic paths.
|
|
16
18
|
|
|
17
19
|
Recent CLI output may include `incremental.cache_status`, `incremental.pending_align`, and `incremental.pending_compile`. Surface those fields verbatim. If the user asks what they mean, explain that they show the local incremental cache health and queued align/compile work; cache warnings are informational unless the CLI output includes a blocking error or an explicit next action.
|
|
18
20
|
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: skill-align-workflow
|
|
3
|
-
description: "Internal procedure for /context:align.
|
|
3
|
+
description: "Internal procedure for /context:align. Reads CLI-guided align evidence, applies semantic Node classification gates, and emits align structure-decision 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
|
|
10
|
+
Run `context align scan --format json`, read expected evidence views, produce semantic structure payloads, and follow 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
|
-
-
|
|
17
|
-
- `
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
- `
|
|
25
|
-
-
|
|
16
|
+
- `workflow.next-action-envelope.v2` is authoritative. Branch on `next_action.kind`, execute `next_action.command` for writes, and use `views[].command` for budget-safe evidence reads.
|
|
17
|
+
- `allowed_actions[]` may permit extra read-only work before the next write; it is not a menu of alternate write paths.
|
|
18
|
+
- `agent_hints[]`, when still present, is a short-term cutover mirror or diagnostic. Do not prefer it over top-level `next_action`.
|
|
19
|
+
- Schema names and enum values come from `context schema <name>`; use `--view minimal` for protocol discovery before full schema reads.
|
|
20
|
+
- Existing knowledge is the lookup registry. Use `context mdrive glossary match <name>` and `context mdrive node list --format json`; do not read `knowledge/**` or create a separate registry file.
|
|
21
|
+
- Code projection Nodes are reusable knowledge handles. When document evidence belongs on a code symbol, reuse the code slug instead of creating a parallel document Node.
|
|
22
|
+
- `diagnostics.automatic_ownership_adjustments[]` and validation diagnostics are the mechanical external-reference ownership source of truth. Independent reference definitions, pure URLs, relation kind blocks, and multiline reference-only lists default to context_only; submit an explicit `block_ownership[]` owned/shared entry only when such a reference block is primary citation evidence.
|
|
23
|
+
- When `pending-relation-refs` is present, inspect it before finalizing graph structure. Use existing matches for `contains_parent_ref` or `domain_gate.child_refs`; keep unresolved target slug hints deferred and do not write dangling parent or edge refs.
|
|
24
|
+
- `views[]` and diagnostics distinguish citable evidence from supporting context. Do not promote supporting/context-only material into cited Sections unless a later ownership correction makes it citation-eligible.
|
|
25
|
+
- Keep cache-friendly prompt order: fixed protocol/schema first, existing knowledge lookup second, source evidence views third, current semantic payload last. Preserve CLI JSON order and do not add timestamps, random ids, scratch paths, or host paths to generated payloads.
|
|
26
26
|
- Node type, tag, fake-Entity, `domain`, and `action` gates are in `references/gates.md`.
|
|
27
|
-
- Coarse
|
|
27
|
+
- Coarse reading density and neutral signal rules are in `references/density-profile.md`.
|
|
28
28
|
- Candidate anomaly handling, `label_hint`, and `llm_slug_hint` reference rules are in `references/candidate-resolution.md`.
|
|
29
29
|
|
|
30
30
|
</reference>
|
|
@@ -33,97 +33,55 @@ Run `context align --scan --format json`, inspect the needed evidence, and follo
|
|
|
33
33
|
|
|
34
34
|
Use this only inside `/context:align`.
|
|
35
35
|
|
|
36
|
-
### Step 1 — Start From
|
|
36
|
+
### Step 1 — Start From The Envelope
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
Run `context align scan --format json`. Confirm `schema_version: "workflow.next-action-envelope.v2"`, then identify `next_action`, `views`, `workflow`, `route`, and `diagnostics`.
|
|
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
|
-
|
|
42
|
+
### Step 2 — Inspect Expected Views
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
Query existing knowledge for reusable names before proposing new term/service/system/action Nodes. `context mdrive glossary match <name>` returns deterministic `match.kind`, `match.matched`, and `match.rank`; exact title/slug/alias hits should usually become references to the existing Node, not duplicate candidates.
|
|
47
|
-
|
|
48
|
-
### Step 4 — Default Path: Direct Finalize
|
|
49
|
-
|
|
50
|
-
When `align_route.next_command` points to `context align --finalize -`, do not run coarse-read, candidate ops, ledger, or aggregate. Inspect the evidence you need, produce one `align-structure-decision`, and submit it to the returned finalize command. Do not infer route thresholds from source count, token count, or window size; the CLI already made that decision.
|
|
51
|
-
|
|
52
|
-
Before producing `align-structure-decision`, refresh and apply `references/gates.md`: classify Node type in order (`action` scale + process evidence, then concrete/term `entity`, then child-bearing `domain`), reject fake Entities only when at least two suspicious signals match, keep `term` separate from concrete A/B tags, and provide required `action_gate` / `domain_gate` fields. Classification is about the content referent, not the source title. After type is chosen, rewrite the Node title to fit that type: Entities name concrete objects or atomic terms, Domains name grouping scopes, and Actions name executable processes.
|
|
53
|
-
|
|
54
|
-
### Step 5 — Staged Path: Batched Review
|
|
55
|
-
|
|
56
|
-
Use this path only when `align_route.next_command` points to `context align --coarse-read -` or the CLI explicitly returns a batched-review hint. This path is for large or ambiguous scans where the CLI requires a checkpoint before final structure.
|
|
44
|
+
Run `views[].command` entries marked `expected: true` before writing. Use additional `show_view` commands only when listed in `allowed_actions[]` or returned in `how_to_explore[]`.
|
|
57
45
|
|
|
58
|
-
|
|
46
|
+
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.
|
|
59
47
|
|
|
60
|
-
|
|
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; follow `page.next_command` or the `how_to_explore[]` source full-read / expand-budget command first, then decide whether to write, split, or leave evidence as context.
|
|
61
49
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
### Step 6 — Follow Hints
|
|
65
|
-
|
|
66
|
-
At any point, if the CLI returns `agent_hints[]`, follow the provided `command` / `next_action` before retrying. Legacy-protocol hints mean the submitted payload/schema is retired; switch to the named current schema instead of reshaping old fields.
|
|
67
|
-
|
|
68
|
-
### Step 7 — Finalize Structure
|
|
69
|
-
|
|
70
|
-
Produce `align-structure-decision` as JSON with finalized nodes, `contains_parent`, `depends_on`, and one `block_ownership[]` entry per coverable block. Node titles and summaries must follow the latest `generation_policy` language; do not default to English scaffolding such as "How-To", "Strategy", or "Architecture" when the workspace language is not English. Do not automatically add the original source title as an alias. Submit it through stdin with `context align --finalize -`; the CLI resolves the current align-segments payload. Prefer stable `llm_slug_hint` values for `contains_parent_ref`, `from_ref`, `to_ref`, owners, and section owners while the final slug is still being normalized.
|
|
71
|
-
|
|
72
|
-
If `align-segments.incremental.mode` is `incremental`, finalize is a delta merge. Submit only the Nodes and ownership supported by the current scanned sources; reference previous finalized Nodes when they are parents, dependencies, domain children, owners, or visibility targets. Absence of an old Node or edge is not a delete signal. Do not redeclare an old parent/domain just to attach a new child. `sections[].owner` must be a Node declared in the current payload; previous finalized Nodes can be referenced structurally but do not receive new section plans from this incremental payload. Existing or previously removed Node slugs cannot change `node_type`; `context align --scan --full` does not bypass that guard. Use a new slug for a different type, or retire the old slug through `context drop` or explicit structure correction before re-aligning.
|
|
50
|
+
### Step 3 — Reuse Existing Knowledge
|
|
73
51
|
|
|
74
|
-
|
|
52
|
+
Query existing knowledge for reusable names before proposing new term/service/system/action Nodes. Exact title/slug/alias hits should usually become references to the existing Node, not duplicate candidates.
|
|
75
53
|
|
|
76
|
-
|
|
54
|
+
When a code projection Node already represents the object, reuse its slug for prose evidence and plan only prose-owned Sections for the current source evidence.
|
|
77
55
|
|
|
78
|
-
|
|
56
|
+
### Step 4 — Classify Semantic Structure
|
|
79
57
|
|
|
80
|
-
|
|
58
|
+
Apply `references/gates.md` before authoring Nodes: classify Node type in order (`action` scale + process evidence, then concrete/term `entity`, then child-bearing `domain`), reject fake Entities only when at least two suspicious signals match, keep `term` separate from concrete tags, and provide required gate evidence.
|
|
81
59
|
|
|
82
|
-
|
|
60
|
+
Source titles and headings are ordinary evidence, not structural authority. Choose titles and summaries that fit the final Node type and the CLI-provided generation policy.
|
|
83
61
|
|
|
84
|
-
|
|
62
|
+
For large or batched payloads, use `references/density-profile.md` and `references/candidate-resolution.md` only when the CLI `next_action` asks for coarse-read or candidate-op payloads. Do not choose those stages yourself.
|
|
85
63
|
|
|
86
|
-
|
|
87
|
-
- `shared`: at least two slugs in `owners[]`, `primary_owner` chosen from those owners (the Node that authors cited Sections from this block; secondaries receive compact raw preview and must request full text or raise an ownership challenge before citing it), `visible_to[]`, `reason`. Do not include `question_id`.
|
|
88
|
-
- `context_only`: **omit `owners` and `primary_owner` entirely.** Required: `visible_to[]`, `reason`. Do not include `question_id`. Also use this for **external-URL reference-link blocks** (orphan `[label]: https://...` / `[label]: http://...` definitions, including ByteDance internal hosts and Lark / docs wikis) when no Node in this batch clearly owns the references — the URLs themselves are unique knowledge not duplicated in body prose, so they must stay reachable downstream even if no inline body usage exists. `context_only` keeps those URLs as raw background only; compile must not cite them as active Sections unless a later ownership patch upgrades the block to `owned` / primary `shared`.
|
|
89
|
-
- `ignored`: **omit `owners`, `primary_owner`, and `visible_to`.** Required: `reason`. Use for outdated markers, **intra-workspace navigation lines** (`Parent:` / `Children:` / `Related:` / `Relations:` rows whose targets are other Nodes already represented in the align graph), and placeholders without independent knowledge. **Do not put external-URL reference-link blocks here** — those carry unique URLs that the align graph cannot reconstruct; route them to `context_only` (or `owned` / `shared` if a Node should author a citation-eligible "相关链接" Section). Do not include `question_id`.
|
|
90
|
-
- `unresolved`: **omit `owners` and `primary_owner`.** Required: `question_id` (matching a top-level `unresolved[].question_id`) and `reason`. Use when classification is blocked by missing evidence.
|
|
64
|
+
### Step 5 — Build The Payload Requested By `next_action`
|
|
91
65
|
|
|
92
|
-
|
|
66
|
+
Use `next_action.input_schema` or the matching `context schema <name> --view minimal --format json` output to shape the payload.
|
|
93
67
|
|
|
94
|
-
|
|
68
|
+
For `submit_structure_decision`, produce one structure-decision document with finalized Nodes, document edges, planned Sections, and ownership. Planned Sections must carry the strongest source-backed `section_kind` that fits the current schema priority chain; do not plan an entire dense source as `description` when the evidence clearly contains examples, comparison tables, Q&A, decisions, specs, warnings, or principles. Keep only source-supported semantic decisions in the payload; leave mechanical repair and patch routing to CLI diagnostics.
|
|
95
69
|
|
|
96
|
-
|
|
97
|
-
{
|
|
98
|
-
"schema_version": "align.finalize-patch.v1",
|
|
99
|
-
"operations": [
|
|
100
|
-
{ "op": "replace", "path": "/block_ownership/3/primary_owner", "value": "rspack" }
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
```
|
|
70
|
+
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.
|
|
104
71
|
|
|
105
|
-
|
|
72
|
+
### Step 6 — Validate And Submit
|
|
106
73
|
|
|
107
|
-
|
|
74
|
+
Before finalizing a structure decision, run `context align validate --input - --format json`. 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.
|
|
108
75
|
|
|
109
|
-
|
|
110
|
-
{
|
|
111
|
-
"schema_version": "align.ownership-patch.v1",
|
|
112
|
-
"base_digest": "sha256:<finalized-ownership-digest>",
|
|
113
|
-
"block_ownership": [
|
|
114
|
-
{
|
|
115
|
-
"block_id": "<block-id>",
|
|
116
|
-
"ownership_role": "owned",
|
|
117
|
-
"owners": ["<node-slug>"],
|
|
118
|
-
"visible_to": ["<node-slug>"],
|
|
119
|
-
"reason": "Why this block is citation evidence for the node."
|
|
120
|
-
}
|
|
121
|
-
]
|
|
122
|
-
}
|
|
123
|
-
```
|
|
76
|
+
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.
|
|
124
77
|
|
|
125
|
-
|
|
78
|
+
### Step 7 — Self-verify
|
|
126
79
|
|
|
127
|
-
|
|
80
|
+
- [ ] All writes followed top-level `next_action.command`. If not, return to **Step 1**.
|
|
81
|
+
- [ ] Evidence was read through `views[].command`, `how_to_explore[]`, or CLI schema/protocol commands only. If not, return to **Step 2**.
|
|
82
|
+
- [ ] Node classification used the semantic gates in `references/gates.md`. If not, return to **Step 4**.
|
|
83
|
+
- [ ] URL/reference ownership followed CLI diagnostics, not static prompt rules. If not, return to **Step 5**.
|
|
84
|
+
- [ ] Structure decisions passed `context align validate --input - --format json` before finalize. If not, return to **Step 6**.
|
|
85
|
+
- [ ] 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**.
|
|
128
86
|
|
|
129
87
|
</procedures>
|