@c4a/context-cli 0.7.0 → 0.7.4

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.
Files changed (219) hide show
  1. package/README.md +18 -39
  2. package/README.zh-CN.md +13 -27
  3. package/cli.js +59230 -80555
  4. package/indexers/bundles/context-code-indexer/SKILL.md +30 -3
  5. package/indexers/bundles/context-code-indexer/context-indexer.yaml +3 -8
  6. package/indexers/bundles/context-code-indexer/references/indexer.md +110 -7
  7. package/indexers/bundles/context-code-indexer/references/metrics.md +143 -37
  8. package/indexers/bundles/context-code-indexer/templates/adapter-integration.md +2 -2
  9. package/indexers/bundles/context-code-indexer/templates/component-library.md +8 -0
  10. package/indexers/bundles/context-code-indexer/templates/gateway-facade.md +16 -0
  11. package/indexers/bundles/context-markdown-indexer/SKILL.md +13 -3
  12. package/indexers/bundles/context-markdown-indexer/context-indexer.yaml +20 -7
  13. package/indexers/bundles/context-markdown-indexer/references/indexer.md +33 -4
  14. package/indexers/bundles/context-markdown-indexer/references/semantic-planning.md +30 -14
  15. package/indexers/bundles/context-markdown-indexer/references/structure-and-artifacts.md +6 -0
  16. package/indexers/bundles/context-markdown-indexer/tests/fixtures/anonymous.json +1 -1
  17. package/indexers/bundles/context-markdown-indexer/tests/fixtures/profiles.json +13 -13
  18. package/indexers/bundles/context-markdown-indexer/tests/fixtures/routing.json +122 -0
  19. package/indexers/contracts/operator-contract.json +2 -2
  20. package/indexers/contracts/profile-contract.json +3819 -454
  21. package/indexers/release-manifest.json +22 -22
  22. package/package.json +13 -3
  23. package/plugins/VERSION +1 -1
  24. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  25. package/plugins/claude/commands/context.md +44 -85
  26. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  27. package/plugins/codex/skills/context/SKILL.md +44 -85
  28. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  29. package/plugins/cursor/commands/c4a-context.md +44 -85
  30. package/plugins/skills/context/SKILL.md +44 -85
  31. package/plugins/skills/context-code-indexer/SKILL.md +30 -3
  32. package/plugins/skills/context-code-indexer/context-indexer.yaml +3 -8
  33. package/plugins/skills/context-code-indexer/references/indexer.md +110 -7
  34. package/plugins/skills/context-code-indexer/references/metrics.md +143 -37
  35. package/plugins/skills/context-code-indexer/templates/adapter-integration.md +2 -2
  36. package/plugins/skills/context-code-indexer/templates/component-library.md +8 -0
  37. package/plugins/skills/context-code-indexer/templates/gateway-facade.md +16 -0
  38. package/plugins/skills/context-markdown-indexer/SKILL.md +13 -3
  39. package/plugins/skills/context-markdown-indexer/context-indexer.yaml +20 -7
  40. package/plugins/skills/context-markdown-indexer/references/indexer.md +33 -4
  41. package/plugins/skills/context-markdown-indexer/references/semantic-planning.md +30 -14
  42. package/plugins/skills/context-markdown-indexer/references/structure-and-artifacts.md +6 -0
  43. package/plugins/skills/context-markdown-indexer/tests/fixtures/anonymous.json +1 -1
  44. package/plugins/skills/context-markdown-indexer/tests/fixtures/profiles.json +13 -13
  45. package/plugins/skills/context-markdown-indexer/tests/fixtures/routing.json +122 -0
  46. package/providers/context/actions/advance-current-indexer-lifecycle.yaml +6 -0
  47. package/providers/context/actions/configure-indexer-providers.yaml +1 -1
  48. package/providers/context/actions/materialize-indexer-workset-view.yaml +7 -0
  49. package/providers/context/actions/run-indexer-lifecycle.yaml +7 -0
  50. package/providers/context/actions/run-indexer-post-author-composer.yaml +1 -1
  51. package/providers/context/codes.yaml +9 -49
  52. package/providers/context/graphs/indexer.yaml +75 -592
  53. package/providers/context/graphs/workspace.yaml +25 -500
  54. package/providers/context/manifest.json +110 -1199
  55. package/providers/context/provider.yaml +2 -2
  56. package/providers/context/resources/diagnostics/projection-stale.md +0 -1
  57. package/providers/context/resources/dialogue/human-gates.md +3 -3
  58. package/providers/context/resources/manuals/reference/package-templates.md +2 -3
  59. package/providers/context/resources/manuals/reference/project-api.md +52 -985
  60. package/providers/context/resources/procedures/close-and-build.md +8 -23
  61. package/providers/context/resources/procedures/knowledge-review.md +13 -4
  62. package/providers/context/resources/procedures/source-capture-detailed.md +6 -8
  63. package/providers/context/resources/views/authorized-indexer-workset-view.yaml +15 -0
  64. package/providers/context/resources/views/package-current.yaml +1 -1
  65. package/providers/context/resources/views/resolved-indexer-instructions.yaml +1 -1
  66. package/providers/context/resources/views/review-current.yaml +1 -1
  67. package/providers/context/resources/views/source-boundary.yaml +1 -1
  68. package/providers/context/resources/views/source-current.yaml +1 -1
  69. package/providers/context/resources/views/verification-current.yaml +1 -1
  70. package/providers/context/resources/views/workspace-current.yaml +1 -1
  71. package/providers/context/schemas/indexer-agent-step-input.schema.json +2 -2
  72. package/providers/context/schemas/indexer-agent-step-result.schema.json +298 -32
  73. package/providers/context/schemas/indexer-authorized-workset-view.schema.json +65 -0
  74. package/providers/context/schemas/indexer-contract-overlay-validation-input.schema.json +0 -42
  75. package/providers/context/schemas/indexer-contract-overlay-validation-result.schema.json +27 -122
  76. package/providers/context/schemas/indexer-lifecycle-continuation.schema.json +15 -0
  77. package/providers/context/schemas/indexer-main-lifecycle-input.schema.json +13 -20
  78. package/providers/context/schemas/indexer-main-lifecycle-output.schema.json +17 -2
  79. package/providers/context/schemas/indexer-materialized-resource.schema.json +8 -1
  80. package/providers/context/schemas/indexer-overlay-question-proposal-input.schema.json +55 -6
  81. package/providers/context/schemas/indexer-overlay-question-rebind-input.schema.json +4 -4
  82. package/providers/context/schemas/indexer-workset-view-materialization-request.schema.json +32 -0
  83. package/providers/context/skills/configure-indexer-providers/SKILL.md +40 -27
  84. package/providers/context/skills/run-indexer-agent-step/SKILL.md +34 -8
  85. package/providers/context/skills/run-indexer-lifecycle/SKILL.md +37 -0
  86. package/providers/context/skills/run-indexer-post-author-composer/SKILL.md +38 -9
  87. package/docs/document-optimization.md +0 -82
  88. package/docs/document-optimization.zh-CN.md +0 -70
  89. package/indexers/capability-manifest.json +0 -40
  90. package/indexers/contracts/hard-rule-conformance.json +0 -2644
  91. package/providers/context/actions/accept-main-index-run.yaml +0 -7
  92. package/providers/context/actions/accept-material-answer-run.yaml +0 -7
  93. package/providers/context/actions/accept-post-author-composer-run.yaml +0 -7
  94. package/providers/context/actions/actualize-material-answer-bindings.yaml +0 -8
  95. package/providers/context/actions/align-next.yaml +0 -6
  96. package/providers/context/actions/apply-code-index-guidance.yaml +0 -5
  97. package/providers/context/actions/apply-document-optimization-guidance.yaml +0 -5
  98. package/providers/context/actions/apply-structure-confirmation.yaml +0 -5
  99. package/providers/context/actions/audit-material-gap-state.yaml +0 -8
  100. package/providers/context/actions/audit-projected-artifact-fan-out.yaml +0 -8
  101. package/providers/context/actions/authorize-indexer-contract-overlay.yaml +0 -7
  102. package/providers/context/actions/build-main-index-author-worksets.yaml +0 -7
  103. package/providers/context/actions/build-main-index-catalog-fallback.yaml +0 -7
  104. package/providers/context/actions/build-main-index-partition-worksets.yaml +0 -7
  105. package/providers/context/actions/build-material-question-workset.yaml +0 -7
  106. package/providers/context/actions/build-post-author-composer-worksets.yaml +0 -7
  107. package/providers/context/actions/build-question-target-inventory.yaml +0 -7
  108. package/providers/context/actions/build-subject-catalog.yaml +0 -7
  109. package/providers/context/actions/build-target-resolution-views.yaml +0 -7
  110. package/providers/context/actions/checkpoint-material-answer-review.yaml +0 -8
  111. package/providers/context/actions/checkpoint-material-gaps.yaml +0 -8
  112. package/providers/context/actions/close-indexer-approved-knowledge.yaml +0 -8
  113. package/providers/context/actions/compile-next.yaml +0 -5
  114. package/providers/context/actions/compose-indexer-post-author-fragments.yaml +0 -7
  115. package/providers/context/actions/configure-code-extraction.yaml +0 -5
  116. package/providers/context/actions/configure-prose-lifecycle.yaml +0 -5
  117. package/providers/context/actions/converge-main-index-partition-run.yaml +0 -7
  118. package/providers/context/actions/evaluate-material-gaps.yaml +0 -8
  119. package/providers/context/actions/extract-next.yaml +0 -5
  120. package/providers/context/actions/fail-main-index-run.yaml +0 -7
  121. package/providers/context/actions/fail-material-answer-run.yaml +0 -7
  122. package/providers/context/actions/fail-post-author-composer-run.yaml +0 -7
  123. package/providers/context/actions/inspect-code-extraction.yaml +0 -5
  124. package/providers/context/actions/inspect-document-classification.yaml +0 -5
  125. package/providers/context/actions/inspect-index-candidate-review-readiness.yaml +0 -8
  126. package/providers/context/actions/inspect-index-profile-failure.yaml +0 -7
  127. package/providers/context/actions/inspect-material-answer-review.yaml +0 -8
  128. package/providers/context/actions/inspect-structure.yaml +0 -5
  129. package/providers/context/actions/migrate-codeindex.yaml +0 -5
  130. package/providers/context/actions/observe-main-index-run-ledger.yaml +0 -7
  131. package/providers/context/actions/observe-material-answer-runs.yaml +0 -7
  132. package/providers/context/actions/observe-post-author-composer-worksets.yaml +0 -7
  133. package/providers/context/actions/optimize-documents.yaml +0 -6
  134. package/providers/context/actions/override-index-profile-audit.yaml +0 -7
  135. package/providers/context/actions/prepare-main-index-run-ledger.yaml +0 -7
  136. package/providers/context/actions/prepare-material-answer-runs.yaml +0 -7
  137. package/providers/context/actions/preview-extraction-batch.yaml +0 -5
  138. package/providers/context/actions/reconcile-indexer-results.yaml +0 -7
  139. package/providers/context/actions/reconcile-review-identities.yaml +0 -5
  140. package/providers/context/actions/record-index-profile-revision.yaml +0 -7
  141. package/providers/context/actions/report-index-profile-failure.yaml +0 -7
  142. package/providers/context/actions/resolve-effective-composers.yaml +0 -7
  143. package/providers/context/actions/review-material-answer-candidate.yaml +0 -8
  144. package/providers/context/actions/revise-code-index-audit.yaml +0 -5
  145. package/providers/context/actions/revise-document.yaml +0 -5
  146. package/providers/context/actions/revise-index-output.yaml +0 -7
  147. package/providers/context/actions/run-material-answer-indexers.yaml +0 -7
  148. package/providers/context/actions/start-main-index-run.yaml +0 -7
  149. package/providers/context/actions/start-material-answer-run.yaml +0 -7
  150. package/providers/context/actions/start-post-author-composer-run.yaml +0 -7
  151. package/providers/context/actions/submit-code-index-audit.yaml +0 -6
  152. package/providers/context/resources/dialogue/code-extraction.md +0 -87
  153. package/providers/context/resources/dialogue/document-classification.md +0 -33
  154. package/providers/context/resources/dialogue/structure-confirmation.md +0 -44
  155. package/providers/context/resources/dialogue/workflow-mode-after-capture.md +0 -25
  156. package/providers/context/resources/manuals/reference/code-extractors.md +0 -152
  157. package/providers/context/resources/procedures/code-extraction.md +0 -188
  158. package/providers/context/resources/procedures/code-index-audit.md +0 -113
  159. package/providers/context/resources/procedures/document-classification.md +0 -22
  160. package/providers/context/resources/procedures/document-optimization.md +0 -110
  161. package/providers/context/resources/procedures/document-revision.md +0 -36
  162. package/providers/context/resources/procedures/prose-align.md +0 -68
  163. package/providers/context/resources/procedures/prose-compile.md +0 -23
  164. package/providers/context/resources/semantic/align/candidate-resolution.md +0 -106
  165. package/providers/context/resources/semantic/align/density-profile.md +0 -41
  166. package/providers/context/resources/semantic/align/gates.md +0 -276
  167. package/providers/context/resources/semantic/align/structure-planning.md +0 -337
  168. package/providers/context/resources/semantic/code-index/classification.md +0 -270
  169. package/providers/context/resources/semantic/code-index/templates/adapter.md +0 -118
  170. package/providers/context/resources/semantic/code-index/templates/api-service.md +0 -116
  171. package/providers/context/resources/semantic/code-index/templates/background-runtime.md +0 -109
  172. package/providers/context/resources/semantic/code-index/templates/cli-tool.md +0 -129
  173. package/providers/context/resources/semantic/code-index/templates/contract-source.md +0 -73
  174. package/providers/context/resources/semantic/code-index/templates/contracts-and-chains.md +0 -81
  175. package/providers/context/resources/semantic/code-index/templates/cross-module-chain.md +0 -78
  176. package/providers/context/resources/semantic/code-index/templates/derived-source.md +0 -116
  177. package/providers/context/resources/semantic/code-index/templates/domain-service.md +0 -109
  178. package/providers/context/resources/semantic/code-index/templates/event-flow.md +0 -62
  179. package/providers/context/resources/semantic/code-index/templates/monorepo-container.md +0 -124
  180. package/providers/context/resources/semantic/code-index/templates/persistence-boundary.md +0 -56
  181. package/providers/context/resources/semantic/code-index/templates/plugin-extension.md +0 -52
  182. package/providers/context/resources/semantic/code-index/templates/protocol-boundary.md +0 -88
  183. package/providers/context/resources/semantic/code-index/templates/sdk-library.md +0 -132
  184. package/providers/context/resources/semantic/code-index/templates/web-application.md +0 -145
  185. package/providers/context/resources/semantic/compile/index.md +0 -31
  186. package/providers/context/resources/views/code-index-audit.yaml +0 -6
  187. package/providers/context/resources/views/document-optimization-current.yaml +0 -6
  188. package/providers/context/resources/views/extraction-preview.yaml +0 -6
  189. package/providers/context/resources/views/structure-current.yaml +0 -6
  190. package/providers/context/schemas/code-index-audit-decision.schema.json +0 -94
  191. package/providers/context/schemas/document-optimization-decisions.schema.json +0 -57
  192. package/providers/context/schemas/indexer-candidate-review-readiness-input.schema.json +0 -46
  193. package/providers/context/schemas/indexer-candidate-review-readiness-output.schema.json +0 -104
  194. package/providers/context/schemas/indexer-contract-overlay-authorization-input.schema.json +0 -32
  195. package/providers/context/schemas/indexer-contract-overlay-authorization-result.schema.json +0 -121
  196. package/providers/context/schemas/indexer-material-answer-lifecycle-input.schema.json +0 -90
  197. package/providers/context/schemas/indexer-material-answer-lifecycle-output.schema.json +0 -80
  198. package/providers/context/schemas/indexer-material-answer-review-inspection-input.schema.json +0 -32
  199. package/providers/context/schemas/indexer-material-answer-review-inspection-output.schema.json +0 -32
  200. package/providers/context/schemas/indexer-material-answer-review-resolution-input.schema.json +0 -19
  201. package/providers/context/schemas/indexer-material-answer-review-resolution-output.schema.json +0 -87
  202. package/providers/context/schemas/indexer-material-gap-lifecycle-input.schema.json +0 -86
  203. package/providers/context/schemas/indexer-material-gap-lifecycle-output.schema.json +0 -19
  204. package/providers/context/schemas/indexer-post-author-fragment-result.schema.json +0 -18
  205. package/providers/context/schemas/indexer-post-author-lifecycle-input.schema.json +0 -94
  206. package/providers/context/schemas/indexer-post-author-lifecycle-output.schema.json +0 -72
  207. package/providers/context/schemas/indexer-profile-failure-inspection-input.schema.json +0 -13
  208. package/providers/context/schemas/indexer-profile-failure-inspection-result.schema.json +0 -19
  209. package/providers/context/schemas/indexer-profile-failure-report-input.schema.json +0 -22
  210. package/providers/context/schemas/indexer-profile-failure-report-result.schema.json +0 -49
  211. package/providers/context/schemas/indexer-profile-override-decision.schema.json +0 -20
  212. package/providers/context/schemas/indexer-profile-override-result.schema.json +0 -49
  213. package/providers/context/schemas/indexer-profile-revision-agent-input.schema.json +0 -18
  214. package/providers/context/schemas/indexer-profile-revision-record-input.schema.json +0 -31
  215. package/providers/context/schemas/indexer-profile-revision-record-result.schema.json +0 -45
  216. package/providers/context/schemas/indexer-result-reconciliation-input.schema.json +0 -59
  217. package/providers/context/schemas/indexer-result-reconciliation-output.schema.json +0 -43
  218. package/providers/context/schemas/prose-structure-batch.schema.json +0 -35
  219. package/providers/context/skills/revise-index-output/SKILL.md +0 -12
@@ -1,110 +0,0 @@
1
- ---
2
- id: procedure.document-optimization
3
- kind: procedure
4
- mediaType: text/markdown
5
- ---
6
-
7
- # Source-constrained editorial revisions
8
-
9
- This optional phase improves the publication value and readability of approved
10
- file and document prose without mutating the approved page. It runs only when
11
- `package.json.context.documentOptimization` is true.
12
-
13
- Run the Route-selected plan command. Each fragment is one source-backed Context
14
- Section and includes mechanical readability signals, allowed actions, exact
15
- line ranges, and source identity. Read every returned Section and write one
16
- decision for each fragment to the returned `payload_target`:
17
-
18
- - `keep` when it is already useful and readable. If the fragment has any
19
- mechanical signal, include a concrete `assessment` that explains why every
20
- signal is a false positive or why changing the Section would reduce source
21
- fidelity. `high` signals cannot be kept unchanged. Name every remaining
22
- `review` signal code in that assessment so the CLI can verify complete
23
- coverage; do not use one generic assessment for a batch;
24
- - `repair` for local typography, Markdown, spacing, or a descriptive link label
25
- whose purpose is already stated in the same Section;
26
- - `reshape` for source-preserving structural changes such as a wide table into
27
- a short index plus detail entries, or a long paragraph into stable headings;
28
- - `omit` only when the plan permits it and the selected reason matches a
29
- mechanically identified non-knowledge Section.
30
-
31
- An unanswered question set, empty placeholder, decision-free draft, duplicate,
32
- or obsolete-only Section may be omitted. Questions with answers, limitations
33
- with impact and action, and deprecations with a replacement remain knowledge.
34
- Mechanical signals are review leads, not a complete readability verdict. Read
35
- every fragment even when it has no signal. A mixture of false positives and
36
- valid repair candidates does not justify keeping the whole batch unchanged.
37
- Signals marked `high` are deterministic presentation obligations. A repair or
38
- reshape is rescanned against the effective replacement and cannot complete
39
- while one of those signals remains. Signals marked `review` require semantic
40
- inspection and may be kept only with the signal-specific assessment below.
41
- Every actionable signal must end in a safe edit, an eligible omission, a
42
- batched input request, or a Section-specific explanation that the signal is a
43
- false positive or that the edit would damage source fidelity. Time, token or
44
- compute cost, workload, batch size, deadline, and desire to finish sooner are
45
- never valid reasons to keep, skip, defer, or reduce an optimization. Do not
46
- default a batch to `keep` because it contains many fragments; finish the
47
- complete current batch with the same quality standard as a single fragment.
48
- Signals that recommend `request-input` identify ambiguous currency, ownership,
49
- link purpose, or sensitive values. The plan returns all of them in
50
- `input_requests`: ask one concise, batched question and wait before applying
51
- the complete optimization payload. Do not convert a required input into
52
- `keep` merely to avoid a pause. Preserve the exact destination of a volatile
53
- URL and safely improve its descriptive label or surrounding layout when the
54
- same Section already states its purpose; ask only for information that cannot
55
- be recovered from the approved Section or its source evidence.
56
-
57
- In fully managed operation, apply every safe `repair`, `reshape`, and eligible
58
- `omit` autonomously and continue until the optimization status is current.
59
- Managed authority removes routine review pauses, not quality work or genuine
60
- missing-input boundaries. A large repair set is expected work, not a blocker.
61
- If an `input_requests` batch remains after completing all independently safe
62
- analysis, ask once for that batch and resume from the returned Route.
63
-
64
- If the same current-batch quality problem fails three consecutive apply
65
- attempts, stop the automatic revision loop and follow
66
- `route.document-optimization.guidance-required`. Present one aggregated report
67
- for all affected Sections and ask for content-organization, source-fidelity, or
68
- missing-material direction. Do not restart Sections that already pass. A
69
- successful complete-batch apply clears the temporary retry record; retry
70
- history is never knowledge or package content.
71
-
72
- Keep all work inside the same source Section. Preserve link destinations,
73
- images, code, commands, numbers, identifiers, conditions, and source markers
74
- exactly. Do not introduce facts, infer an answer, or replace a complete
75
- contract with a summary.
76
-
77
- After the complete payload is ready, execute the exact `next_action.command`
78
- returned by the plan. Context rejects stale, incomplete, duplicate,
79
- cross-Section, protected-value, semantically broad, or unexplained signaled
80
- `keep` decisions. It also rescans every repair and reshape against the same
81
- mechanical analyzer before writing the revision; submitting a decision is not
82
- proof that the effective Markdown is clean. A repair or reshape that retains a
83
- review-confidence signal must include a Section-specific assessment naming
84
- that signal. The apply result reports each signal as `resolved` or `justified`
85
- with its source and post-revision range. The assessment and rescan detail are
86
- used only to audit the current decision and are not stored in approved
87
- knowledge, revisions, or package output. Unchanged
88
- Sections reuse their previous decision; changed Sections alone return to this
89
- phase.
90
-
91
- Only pages with reader-visible changes are stored. A revision is a full
92
- Markdown sidecar beside its approved page: `knowledge/guides/setup.md` becomes
93
- `knowledge/guides/setup__revision.md`. Default knowledge discovery excludes the
94
- reserved suffix. The filename derives the base page; the revision stores only
95
- the base digest that cannot be derived. Unchanged Sections inside a full
96
- revision are inferred. A page with no changes stores one derived negative cache
97
- key below `.tmp/context-runtime/document-optimization/`; replacement prose and
98
- Section metadata are never duplicated there. An omitted Section keeps its
99
- lifecycle marker in the revision so its source identity remains auditable, but
100
- its reader-visible body and all revision audit state are absent from `dist/`.
101
-
102
- For a later user-requested correction, use `context revise "<title or approved
103
- path>" --format json`. The resulting `route.document-revision.requested` owns
104
- target selection, revision editing, and validation; it also works when broad
105
- document optimization was not previously enabled. The compatibility entry
106
- `context optimize-docs revise` accepts the same selectors. Validation rejects
107
- lifecycle metadata changes, stale page baselines, protected-value changes,
108
- cross-Section rewrites, unsupported omissions, and invalid Markdown structure.
109
- A source change makes the revision a blocking conflict instead of silently
110
- applying it. Do not create fragment JSON files or another revision namespace.
@@ -1,36 +0,0 @@
1
- ---
2
- id: procedure.document-revision
3
- kind: procedure
4
- mediaType: text/markdown
5
- ---
6
-
7
- # Conversational document correction
8
-
9
- Use this procedure only for a correction explicitly requested by the user after
10
- an approved knowledge page already exists. The request selects one page; it
11
- does not authorize a free rewrite or a change to source facts. It may repair or
12
- reshape reader-visible content within one existing Context Section, and may
13
- omit a complete Section only when the current source supports a documented
14
- non-knowledge reason.
15
-
16
- 1. Run the Route command `context optimize-docs revise-current --format json`.
17
- 2. Read the complete approved page and its sibling `__revision.md` page named
18
- by the returned plan. Check the cited source when the requested correction
19
- could change a fact rather than formatting or wording.
20
- 3. Edit only the returned revision page. Preserve its frontmatter identity,
21
- `context_revision` baseline, Context section boundaries, evidence markers,
22
- link destinations, images, code, numbers, identifiers, and supported facts.
23
- A wide table may become an index plus detail entries, and a source-backed
24
- list may be reorganized, but facts cannot move across Section boundaries.
25
- Never edit the approved base page for this operation.
26
- 4. Run `context optimize-docs validate --format json`. If validation reports a
27
- stale baseline, protected-value change, unsupported omission, broad rewrite,
28
- or missing evidence, stop and report the exact finding instead of weakening
29
- the correction.
30
- 5. Continue from the returned `context status --format json` Route. A valid
31
- correction makes the package stale, so the normal build Route will offer
32
- compilation without requiring a second correction decision.
33
-
34
- If the entry returned more than one target candidate, select a candidate only
35
- when the user's wording or current conversation identifies it uniquely;
36
- otherwise ask the user which approved page to correct. Do not guess.
@@ -1,68 +0,0 @@
1
- ---
2
- id: procedure.prose-align
3
- kind: procedure
4
- mediaType: text/markdown
5
- ---
6
-
7
- # Prose structure alignment
8
-
9
- Alignment proposes source-bound knowledge structure. It does not write approved
10
- knowledge.
11
-
12
- Follow the current route's evidence view and input schema. Prefer source heading
13
- and block boundaries when they preserve coherent reading units; fixed line
14
- windows are only a fallback for unstructured text. A page may contain multiple
15
- sections, each with its own continuous evidence span.
16
-
17
- The default `read-plan` is the authoring packet for ordinary documents. It
18
- includes the payload contract, a compact canonical source-ref map, exact source
19
- body resources, the recommended scratch path, and the direct stage command.
20
- Do not separately request `schema`, `source-index`, or `existing-knowledge`
21
- unless the packet reports truncation or the task specifically needs an existing
22
- approved identity. Those views are diagnostics and large-source fallbacks, not
23
- mandatory workflow steps.
24
-
25
- Every `context.source-body/*` item selected in `workflow.current.resources`
26
- is source evidence, not supporting metadata. Read the complete Markdown file
27
- when its `read_state` is `read-required`. A source index, heading tree, token
28
- count, or successful capture never substitutes for body reading. A matching
29
- content digest receipt may be reused only while that text remains available in
30
- the current conversation. After reading every selected direct path, execute the
31
- single `resources.after_read.command`. For a generated Context View, execute
32
- its materialization command, read its complete file, then execute its exact
33
- `next_action.command`. Context carries the merged receipt file forward. A Route
34
- revision change does not invalidate unchanged bytes, but every lifecycle
35
- command remains revision-bound.
36
-
37
- When the route returns `payload_target`, write the Agent-authored structure input
38
- to its recommended `.tmp/agent-payloads/` path. This scratch area is separate
39
- from CLI-owned `.tmp/context-runtime/` and can be discarded after a successful
40
- stage. The recommendation does not restrict an explicit user-selected path.
41
-
42
- Stage all required source/collection slots before batch Review. Structure
43
- confirmation is an explicit gate. A confirmation applies only to the staged
44
- slot digest shown by the route; if the digest changes, confirm again.
45
-
46
- When the current Route exposes `batch`, author every listed target payload in
47
- one Agent planning pass, then write the small batch manifest to `batch.input`.
48
- Use `batch.validate.command` for a read-only all-target check or
49
- `batch.stage.command` to validate every target before any stage begins and then
50
- write the ready slots serially. The manifest contains only each `phase_id` and
51
- its structure payload `input` path; it does not merge document semantics or let
52
- the CLI choose page structure. A failed preflight writes no slot. If a later
53
- filesystem write fails, the result identifies completed slots and the Route
54
- remains recoverable.
55
-
56
- `--stage` performs the same validation and deterministic self-repair as
57
- `--validate`; use the separate validation command only for a diagnostics-only
58
- pass. In a managed conversation, a valid stage also records structure
59
- confirmation in the same write. Validation states are literal: `ready` may
60
- stage, `repair-required` may not, and `invalid` contains errors. `valid` is true
61
- only for `ready`; `error_free` distinguishes a blocker-only result from one
62
- containing errors. `self_healed` reports the input and output Section counts,
63
- how many original Sections were split, and the structural reason codes used by
64
- the repair.
65
-
66
- Independent read-only evidence views may run in parallel. Structure stage,
67
- confirmation, compile writes, and Review application are serial lifecycle
68
- mutations; execute them in the order selected by `workflow.current`.
@@ -1,23 +0,0 @@
1
- ---
2
- id: procedure.prose-compile
3
- kind: procedure
4
- mediaType: text/markdown
5
- ---
6
-
7
- # Source-bound prose compilation
8
-
9
- Compile materializes review candidates from confirmed structure and source
10
- evidence. It never writes directly to approved knowledge.
11
-
12
- The CLI derives this projection mechanically from the confirmed section ids,
13
- kinds, and source spans. Run only the revision-bound compile command returned
14
- by the current Route. Do not create compile-action payloads or rewrite source
15
- content.
16
-
17
- One compile command validates every owned view first, then atomically
18
- materializes the source/collection candidate batch. In an explicitly managed
19
- conversation, the host loop may continue across the remaining deterministic
20
- compile slots after this procedure has been read; it re-evaluates revision and
21
- validation state after every write. The current structure view is optional
22
- inspection context because the CLI consumes the confirmed structure directly.
23
- Do not open a partial Review while planned views remain.
@@ -1,106 +0,0 @@
1
- ---
2
- id: context.semantic.align.candidate-resolution
3
- kind: procedure
4
- media-type: text/markdown
5
- applies-to:
6
- - duplicate
7
- - conflict
8
- - stable_id
9
- - path
10
- - unresolved
11
- ---
12
-
13
- # Candidate Resolution Rules
14
- <!-- Context workflow semantic resource. -->
15
-
16
- Use these rules after reading the current align evidence views and before
17
- authoring `context.structure.v1`. They define how current anomaly diagnostics
18
- map to supported structure outcomes.
19
-
20
- ## Anomaly Signals
21
-
22
- Anomaly diagnostics are mechanical warnings. Do not ignore them and do not treat
23
- them as recommendations.
24
-
25
- For each anomaly, choose one current outcome and record the reasoning in the
26
- structure payload or user-facing explanation:
27
-
28
- | Outcome | Use When |
29
- |---|---|
30
- | Accept the correction | The anomaly points to a real structure fix. Apply a concrete node, section, edge, or ownership correction supported by source refs. |
31
- | Dismiss with rationale | The warning is mechanically true but semantically harmless. Keep the structure and state why in the confirmation summary. |
32
- | Keep unresolved | The warning changes structure but source evidence is insufficient. Add an `unresolved[]` item instead of guessing. |
33
-
34
- Known anomaly kinds:
35
-
36
- | Kind | Meaning | Required handling |
37
- |---|---|---|
38
- | Missing evidence | A proposed node, section, or edge has no source-backed evidence. | Add source refs, remove it, or keep the issue unresolved. |
39
- | Structure churn | A node was renamed, split, merged, replaced, or rejected during investigation. | Confirm the final id/title/target with the user or keep the ambiguity unresolved. |
40
- | Duplicate evidence | The same source ref appears more than once for the same semantic role. | Deduplicate it or explain why the repeated ref supports different roles. |
41
- | Broad review needed | The CLI collapsed many anomalies or reports aggregate risk. | Review the affected structure broadly; do not finalize solely from ordering. |
42
-
43
- ## Stable References
44
-
45
- Use stable `node_ref`, `view_ref`, and `section_ref` values from the current
46
- `context.structure.v1` payload for in-payload references. A NodeRef should be
47
- safe, lower-case, and path-shaped, such as `entity/rspack` or
48
- `domain/build-tooling`. `slug` is the required stable filename choice for a
49
- View. `path` is derived from collection, optional containment, and slug; omit
50
- it or use the exact CLI-derived value. Do not invent alternate reference
51
- aliases.
52
-
53
- When an edge or section points at knowledge:
54
-
55
- - use the schema ref that matches the target layer:
56
- `node_ref` for a conceptual Node, `view_ref` for a collection view, and
57
- `section_ref` for a planned section;
58
- - ensure the target NodeRef, ViewRef, or SectionRef exists in the current
59
- structure or approved knowledge;
60
- - keep relation hints unresolved when the target does not exist;
61
- - follow CLI diagnostics if a ref is unknown or stale.
62
-
63
- Do not create alternate alias fields or non-schema candidate ledger fields.
64
- They are not part of the current structure contract.
65
-
66
- ## Visible Labels And Audit Rationale
67
-
68
- Humans need to understand merge, reject, rename, and replacement choices
69
- without decoding temporary ids. Keep that discipline in the current structure
70
- flow through current fields:
71
-
72
- - use `title` and `summary` to name the final node in user-facing language;
73
- - explain renamed/split/merged candidates in the confirmation summary, not by
74
- adding non-schema label fields;
75
- - when a relation or rename cannot be settled from evidence, put the visible
76
- title/target clue in `unresolved[]`;
77
- - when asking the user, phrase the choice with business labels ("Rspack build
78
- tool page" vs "Webpack page"), not with source refs or internal section ids.
79
-
80
- NodeRef is the stable conceptual identity. ViewRef is the collection-specific
81
- view identity and is the durable approved-page identity. SectionRef is the
82
- stable planned-section identity under a ViewRef. Package paths are derived from
83
- the approved ViewRef plus containment/slug; do not treat paths as an alternate
84
- identity contract. Visible labels help humans review the choice, but they do
85
- not authorize a different NodeRef, ViewRef, edge, or section ownership without
86
- source-backed evidence and user confirmation.
87
-
88
- ## Duplicate And Conflict Handling
89
-
90
- - Exact duplicate structure -> keep one node/section/edge and explain the
91
- duplicate in the confirmation summary.
92
- - Same topic but different evidence boundary -> keep separate sections only
93
- when each section has a distinct source-backed role.
94
- - Conflicting facts -> ask the user or keep an `unresolved[]` item. Do not
95
- pick a winner from title order or source order.
96
- - Replacement or rename -> ask the user when it changes NodeRef, ViewRef,
97
- containment, slug, or the derived approved path. These are durable user-facing
98
- identities, not disposable labels.
99
-
100
- ## Self-verify
101
-
102
- - [ ] Every accepted node, section, and edge has source-backed support.
103
- - [ ] Every unresolved relation or conflict is explicit in `unresolved[]`.
104
- - [ ] No non-schema candidate ledger fields or alias fields appear in the payload.
105
- - [ ] NodeRef, ViewRef, and SectionRef values, not temporary labels or paths,
106
- are used for current references.
@@ -1,41 +0,0 @@
1
- ---
2
- id: context.semantic.align.density-profile
3
- kind: procedure
4
- media-type: text/markdown
5
- applies-to:
6
- - coverage
7
- - reading_density
8
- - structure
9
- ---
10
-
11
- # Evidence Density Selection
12
- <!-- Context workflow semantic resource. -->
13
-
14
- Use density as a private reading and section-planning strategy. It is not a
15
- separate payload, not a quality score, and not a workflow stage. Persist only
16
- current `context.structure.v1` fields such as `nodes[]`, `sections[]`,
17
- `source_refs[]`, `edges[]`, and `unresolved[]`.
18
-
19
- Apply this reference when a captured source is long, dense, fragmented, or hard
20
- to split into stable planned sections. Use the current CLI evidence views
21
- (`read-plan`, `source-index`, `span-detail`, `span-text`) to inspect material;
22
- do not invent a separate coarse-read artifact.
23
-
24
- | Profile | Use When | Agent Behavior |
25
- |---|---|---|
26
- | `macro` | A long source has many headings, sections, or broad topic shifts. | Create section proposals around major headings and preserve document-level anchors so later passes do not flatten scope. |
27
- | `meso` | Default for normal product, design, or operational documents with several related sections. | Produce section proposals for meaningful local units and preserve evidence anchors. |
28
- | `micro` | The source is fragmented, note-like, or dense with short independent claims. | Keep section proposals narrow and avoid bundling unrelated blocks into one candidate. |
29
- | `single_pass` | The source is short enough that one read can safely discover all relevant structure. | Keep anchors minimal and avoid over-segmentation, but still validate the resulting structure. |
30
-
31
- Treat Markdown heading changes as section-planning hints, not hard boundaries.
32
- Sibling sub-headings under a shared parent can remain in one planned section
33
- when they form one coherent semantic topic for that parent. Headings with no
34
- shared parent should usually split unless you intentionally want one section to
35
- span them. When a dense source has many headings, split by heading first, then
36
- merge adjacent or sibling groups only when the merged section is still one
37
- coherent fact group.
38
-
39
- Do not let density alone choose `node_type`, `tags`, `section.kind`, or body
40
- content. Action/domain gates are decided from source evidence and the current
41
- schema, not from density metadata.