@c4a/context-cli 0.7.0 → 0.7.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.
Files changed (88) hide show
  1. package/cli.js +32779 -32620
  2. package/indexers/capability-manifest.json +4 -9
  3. package/indexers/release-manifest.json +1 -1
  4. package/package.json +3 -3
  5. package/plugins/VERSION +1 -1
  6. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  7. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  8. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  9. package/providers/context/actions/run-indexer-lifecycle.yaml +7 -0
  10. package/providers/context/codes.yaml +3 -27
  11. package/providers/context/graphs/indexer.yaml +2 -28
  12. package/providers/context/graphs/workspace.yaml +37 -473
  13. package/providers/context/manifest.json +58 -558
  14. package/providers/context/provider.yaml +2 -2
  15. package/providers/context/resources/diagnostics/projection-stale.md +0 -1
  16. package/providers/context/resources/manuals/reference/project-api.md +39 -38
  17. package/providers/context/resources/views/document-optimization-current.yaml +1 -1
  18. package/providers/context/resources/views/package-current.yaml +1 -1
  19. package/providers/context/resources/views/resolved-indexer-instructions.yaml +1 -1
  20. package/providers/context/resources/views/review-current.yaml +1 -1
  21. package/providers/context/resources/views/source-boundary.yaml +1 -1
  22. package/providers/context/resources/views/source-current.yaml +1 -1
  23. package/providers/context/resources/views/verification-current.yaml +1 -1
  24. package/providers/context/resources/views/workspace-current.yaml +1 -1
  25. package/providers/context/schemas/indexer-contract-overlay-validation-input.schema.json +0 -42
  26. package/providers/context/schemas/indexer-contract-overlay-validation-result.schema.json +27 -122
  27. package/providers/context/schemas/indexer-lifecycle-continuation.schema.json +15 -0
  28. package/providers/context/schemas/indexer-overlay-question-proposal-input.schema.json +4 -4
  29. package/providers/context/schemas/indexer-overlay-question-rebind-input.schema.json +4 -4
  30. package/providers/context/skills/run-indexer-lifecycle/SKILL.md +36 -0
  31. package/providers/context/actions/align-next.yaml +0 -6
  32. package/providers/context/actions/apply-code-index-guidance.yaml +0 -5
  33. package/providers/context/actions/apply-document-optimization-guidance.yaml +0 -5
  34. package/providers/context/actions/apply-structure-confirmation.yaml +0 -5
  35. package/providers/context/actions/authorize-indexer-contract-overlay.yaml +0 -7
  36. package/providers/context/actions/compile-next.yaml +0 -5
  37. package/providers/context/actions/configure-code-extraction.yaml +0 -5
  38. package/providers/context/actions/configure-prose-lifecycle.yaml +0 -5
  39. package/providers/context/actions/extract-next.yaml +0 -5
  40. package/providers/context/actions/inspect-code-extraction.yaml +0 -5
  41. package/providers/context/actions/inspect-document-classification.yaml +0 -5
  42. package/providers/context/actions/inspect-structure.yaml +0 -5
  43. package/providers/context/actions/migrate-codeindex.yaml +0 -5
  44. package/providers/context/actions/optimize-documents.yaml +0 -6
  45. package/providers/context/actions/preview-extraction-batch.yaml +0 -5
  46. package/providers/context/actions/revise-code-index-audit.yaml +0 -5
  47. package/providers/context/actions/submit-code-index-audit.yaml +0 -6
  48. package/providers/context/resources/dialogue/code-extraction.md +0 -87
  49. package/providers/context/resources/dialogue/document-classification.md +0 -33
  50. package/providers/context/resources/dialogue/structure-confirmation.md +0 -44
  51. package/providers/context/resources/dialogue/workflow-mode-after-capture.md +0 -25
  52. package/providers/context/resources/manuals/reference/code-extractors.md +0 -152
  53. package/providers/context/resources/procedures/code-extraction.md +0 -188
  54. package/providers/context/resources/procedures/code-index-audit.md +0 -113
  55. package/providers/context/resources/procedures/document-classification.md +0 -22
  56. package/providers/context/resources/procedures/document-optimization.md +0 -110
  57. package/providers/context/resources/procedures/prose-align.md +0 -68
  58. package/providers/context/resources/procedures/prose-compile.md +0 -23
  59. package/providers/context/resources/semantic/align/candidate-resolution.md +0 -106
  60. package/providers/context/resources/semantic/align/density-profile.md +0 -41
  61. package/providers/context/resources/semantic/align/gates.md +0 -276
  62. package/providers/context/resources/semantic/align/structure-planning.md +0 -337
  63. package/providers/context/resources/semantic/code-index/classification.md +0 -270
  64. package/providers/context/resources/semantic/code-index/templates/adapter.md +0 -118
  65. package/providers/context/resources/semantic/code-index/templates/api-service.md +0 -116
  66. package/providers/context/resources/semantic/code-index/templates/background-runtime.md +0 -109
  67. package/providers/context/resources/semantic/code-index/templates/cli-tool.md +0 -129
  68. package/providers/context/resources/semantic/code-index/templates/contract-source.md +0 -73
  69. package/providers/context/resources/semantic/code-index/templates/contracts-and-chains.md +0 -81
  70. package/providers/context/resources/semantic/code-index/templates/cross-module-chain.md +0 -78
  71. package/providers/context/resources/semantic/code-index/templates/derived-source.md +0 -116
  72. package/providers/context/resources/semantic/code-index/templates/domain-service.md +0 -109
  73. package/providers/context/resources/semantic/code-index/templates/event-flow.md +0 -62
  74. package/providers/context/resources/semantic/code-index/templates/monorepo-container.md +0 -124
  75. package/providers/context/resources/semantic/code-index/templates/persistence-boundary.md +0 -56
  76. package/providers/context/resources/semantic/code-index/templates/plugin-extension.md +0 -52
  77. package/providers/context/resources/semantic/code-index/templates/protocol-boundary.md +0 -88
  78. package/providers/context/resources/semantic/code-index/templates/sdk-library.md +0 -132
  79. package/providers/context/resources/semantic/code-index/templates/web-application.md +0 -145
  80. package/providers/context/resources/semantic/compile/index.md +0 -31
  81. package/providers/context/resources/views/code-index-audit.yaml +0 -6
  82. package/providers/context/resources/views/extraction-preview.yaml +0 -6
  83. package/providers/context/resources/views/structure-current.yaml +0 -6
  84. package/providers/context/schemas/code-index-audit-decision.schema.json +0 -94
  85. package/providers/context/schemas/document-optimization-decisions.schema.json +0 -57
  86. package/providers/context/schemas/indexer-contract-overlay-authorization-input.schema.json +0 -32
  87. package/providers/context/schemas/indexer-contract-overlay-authorization-result.schema.json +0 -121
  88. package/providers/context/schemas/prose-structure-batch.schema.json +0 -35
@@ -1,337 +0,0 @@
1
- ---
2
- context_resource: semantic/align/structure-planning
3
- id: context.semantic.align.structure-planning
4
- kind: procedure
5
- media-type: text/markdown
6
- applies-to:
7
- - node_type
8
- - title
9
- - tags
10
- - ownership
11
- - edges
12
- - structure
13
- name: structure-planning
14
- description: "Internal procedure for the current align gate. Reads CLI-guided align evidence, applies semantic Node classification gates, and emits context.structure.v1 payloads for CLI validation/stage."
15
- ---
16
-
17
- # Structure Planning Procedure
18
-
19
- ## TL;DR
20
-
21
- Run `context run align:<type>:<source>:<collection> --view read-plan --format json`, follow the top-level `next_action.command` to read the CLI-selected evidence path, produce a `context.structure.v1` structure payload, and continue following top-level `next_action`. The CLI owns route, validation, repair commands, and stage guards; the Agent owns only semantic classification and source-bound structure judgment.
22
-
23
- <reference>
24
-
25
- ## Canonical Data
26
-
27
- - The current phase view result is authoritative. Branch on `next_action.kind`,
28
- execute `next_action.command`, and treat listed views as detail reads rather
29
- than a checklist.
30
- - `allowed_actions[]` describes capabilities on the current view result; it is
31
- not a menu of alternate write paths and does not override `next_action`.
32
- - `agent_hints[]`, when present, are diagnostics. Do not prefer them over
33
- top-level `next_action`.
34
- - Schema names and enum values come from
35
- `context run align:<type>:<source>:<collection> --view schema --format json`. Use
36
- that schema as the authoring contract for `context.structure.v1`.
37
- - Existing approved knowledge is the lookup registry exposed by the current
38
- align `existing-knowledge` View. Do not read `knowledge/**`, guess a top-level
39
- query command, or create a separate registry file.
40
- - 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.
41
- - Validation diagnostics are the mechanical structure ownership source of
42
- truth. Non-content spans such as navigation references, placeholders, front
43
- matter, marker quotes, embed tags, and embedded assets should not become
44
- reader-facing Sections unless the evidence itself is the cited knowledge.
45
- - When relation hints are present, inspect them before finalizing graph
46
- structure. Use existing/current matches for typed `edges[]`; keep unresolved
47
- target ref/title hints deferred in `unresolved[]` and do not write dangling
48
- parent, child, or edge refs. Ordinary source-bound views require at least one
49
- source-backed planned section. The only empty-section exception is a generated
50
- parent index view: it must use `generated: parent_index`, `sections: []`, and
51
- source-backed `contains` edges to child views. For navigation-only /
52
- placeholder-only sources, keep useful source/page identities as `unresolved[]`
53
- notes until there is source-backed section evidence, a supported edge target,
54
- a valid parent-index container, or a later compile `skip` decision. If a
55
- placeholder/relation source is skipped entirely, leave its relation clues in
56
- `unresolved[]` only when they still matter; otherwise omit them.
57
- - `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.
58
- - Keep cache-friendly prompt order: fixed protocol/schema first, source evidence
59
- views second, targeted existing-knowledge results third, and the current
60
- semantic payload last. Preserve CLI JSON order and do not add timestamps,
61
- random ids, scratch paths, or host paths to generated payloads.
62
- - Structure digests and snapshot hashes are stale guards. Follow returned
63
- `next_action.command` and do not invent digest values.
64
- - Node type, tag, fake-Entity, `domain`, and `action` gates are in `structure-planning/references/gates.md`.
65
- - Coarse reading density and neutral signal rules are in `structure-planning/references/density-profile.md`.
66
- - Candidate anomaly handling, stable references, duplicate handling, and
67
- conflict handling are in
68
- `structure-planning/references/candidate-resolution.md`.
69
-
70
- </reference>
71
-
72
- <procedures>
73
-
74
- Use this only inside the current align gate.
75
-
76
- ### Step 1 — Start From The Envelope
77
-
78
- Run `context run align:<type>:<source>:<collection> --view read-plan --format json`.
79
- Confirm the response is the current prose align view result, then identify
80
- `next_action`, available views, source metadata, and diagnostics.
81
-
82
- If the host truncates a view result but the preview includes top-level
83
- `next_action.command`, run that command. If `next_action` is not visible, rerun
84
- the current view command; do not recover host tool-result files.
85
-
86
- If no current phase view result is present, stop and surface the CLI output; do
87
- not reconstruct an align route from prior prompt memory.
88
-
89
- ### Step 2 — Follow The Evidence Read Path
90
-
91
- Run the returned `next_action.command`. For structural align work this is
92
- normally `read-plan`; after that, follow the evidence view's `next_action.command`
93
- or `next_command`.
94
-
95
- `read-plan` is the navigation surface. It chooses whether the next evidence read
96
- is `source-index`, `span-detail`, `span-text`, or another current evidence view.
97
- Read those views and then author the requested `context.structure.v1` payload
98
- yourself after completing the targeted lookup in Step 3. Never pipe evidence
99
- text into validate.
100
-
101
- If an evidence view is truncated, `page.has_more: true`, or the CLI returns a
102
- `next_command`, run that command before authoring.
103
-
104
- Read evidence through semantic CLI views, not shell parsing. Follow `page.next_command` for pagination. If the command contains `--read-cursor`, treat it as opaque continuation state and run it exactly; do not replace it with hand-written `--source`, `--heading`, `--window`, or `--range` selectors. Use `--source`, `--heading`, `--window`, `--range`, and `--token-budget` as view filters only. `--unwrap` removes workflow metadata; it does not expand a compact view into full detail.
105
-
106
- If an evidence view returns `page.has_more`, `truncated: true`, or a
107
- view-specific incomplete-read diagnostic, treat that response as a partial
108
- read. Do not decide source-wide ownership or dense planned Sections from
109
- headings alone; continue the current detail view only when `page.next_command`
110
- is explicitly needed, otherwise return to the CLI-designated navigation view.
111
-
112
- ### Step 3 — Reuse Existing Knowledge
113
-
114
- After source evidence identifies a candidate title or stable ref, run:
115
-
116
- ```bash
117
- context run align:<type>:<source>:<collection> --view existing-knowledge --query <title-or-stable-ref> --format json
118
- ```
119
-
120
- Use the returned pagination command when present. Exact title, NodeRef, or
121
- ViewRef hits should usually reuse the existing Node instead of creating a
122
- duplicate candidate. The lookup returns only the best title/NodeRef/ViewRef
123
- identity tier. Shared tag matches are summarized separately and never require
124
- walking the related subgraph merely to determine whether a root identity
125
- exists. The lookup is deterministic identity discovery; the Agent still
126
- decides whether the source evidence describes the same concept.
127
-
128
- 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.
129
-
130
- ### Step 4 — Route Collection, Then Classify Semantic Structure
131
-
132
- Before choosing Node type or Section kind, route each evidence unit to its
133
- internal collection. The phase `<collection>` is only the entry profile for the
134
- current run; it is not a cap on what this structure may contain. A mixed source
135
- can produce multiple `views[]` in one confirmed structure when source evidence
136
- supports them.
137
-
138
- Use collection routing first:
139
-
140
- - product intent, user story, requirement, roadmap, or product scenario ->
141
- `product`;
142
- - architecture, service/module/system design, runtime dependency, code-adjacent
143
- prose -> `architecture`; if an existing code projection already owns the
144
- object, reuse its NodeRef/ViewRef instead of creating a `codeindex` prose
145
- view;
146
- - SOP, runbook, operation drill, workflow, or how-to procedure -> `sop`;
147
- - FAQ, question/answer, support notes -> `faq` only when the evidence is an
148
- independent FAQ page or cross-cutting support knowledge; a single Q&A or
149
- scattered support note stays as a `faq` Section under the owning view;
150
- - standards, policy, rules, conventions, reusable constraints -> `standards`;
151
- - decision record, trade-off, migration conclusion -> `decision` only when it
152
- is an independent decision record with owner/date/lifecycle or cross-cutting
153
- decision scope; one-off conclusions stay as `decision` Sections under the
154
- owning view;
155
- - incident, postmortem, outage, fault timeline, action item -> `incident` only
156
- when it has incident identity, timeline, follow-up, or tracking lifecycle;
157
- isolated warnings/failures/action items stay as `incident` or `warning`
158
- Sections under the owning view;
159
- - test plan, validation scenario, acceptance case -> `test`;
160
-
161
- Do not route prose align views to `codeindex` or `feats`: `codeindex` is
162
- produced by code extraction / AST projection, and `feats` is reserved for the
163
- dedicated feature workflow. For section-vs-collection overlap, keep a local
164
- `faq`, `decision`, or `incident` as a Section kind under the owning view unless
165
- the source is independently queryable across the package and has its own
166
- lifecycle, ownership, timeline, or cross-cutting scope.
167
-
168
- After collection routing, apply `structure-planning/references/gates.md` before
169
- authoring Nodes: classify Node type in order (`action` scale + process evidence,
170
- then concrete/term `entity`, then child-bearing `domain`), reject fake Entities
171
- only when at least two suspicious signals match, keep `term` separate from
172
- concrete tags, and provide required gate evidence.
173
-
174
- Preserve shared-source intent when the same source span legitimately supports
175
- multiple views. Do not copy the span text into multiple rewritten bodies; cite
176
- the same CLI `source_ref` in each supported view and let structure-summary mark
177
- the shared evidence.
178
-
179
- 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.
180
-
181
- Plan source material as Sections first. A source heading only becomes a child
182
- Node/View when the cited evidence names a concrete independent subject, an
183
- atomic term, a gated Action, or a child-bearing Domain. A `contains` edge only
184
- states hierarchy; it does not prove that a thin child page has standalone
185
- retrieval value.
186
-
187
- Avoid same-source fragmentation. If one parent would contain many single-section
188
- child Entities from the same source document, keep them as Sections unless each
189
- child has an independent product/code object, atomic term, Action, or Domain
190
- identity. Also avoid copying the parent `system` / `application` scope tag onto
191
- local child aspects; tag a child by what it independently is.
192
-
193
- Do not promote a source fragment into a child page solely because it has a
194
- heading or a recognized section kind. Judge every proposed child with the same
195
- source-backed criteria: independent subject identity, sufficient context, and
196
- standalone retrieval value. The CLI may warn about repeated same-source thin
197
- children, but page granularity remains an evidence-backed structure decision
198
- for the review report rather than a content-type-specific hard gate.
199
-
200
- For `node.title` and `node.summary`, follow the workspace/source language
201
- surfaced by the current view or the user's instruction. In Chinese workspaces,
202
- translate descriptive scaffold words such as architecture, strategy, lifecycle,
203
- overview, scheduling, high availability, and warning into Chinese while
204
- preserving product names, code identifiers, CLI flags, slugs, source_ref tokens,
205
- and citation tokens exactly when needed. Do not copy an English source title
206
- into `node.title` merely because the source is English.
207
-
208
- Do not classify a broad architecture/system/方案 source as `domain` just because the title sounds like a scope. If it has writable Sections but no resolvable current/existing child Nodes, use an `entity` tag such as `system` or `application`; reserve `domain` for grouping child Nodes through typed `edges[]` with supported child targets.
209
-
210
- For large or batched payloads, use
211
- `structure-planning/references/density-profile.md` and
212
- `structure-planning/references/candidate-resolution.md` as judgment aids.
213
- They do not create additional workflow stages or alternate payloads.
214
-
215
- ### Step 5 — Build The Payload Requested By `next_action`
216
-
217
- Use `context run align:<type>:<source>:<collection> --view schema --format json` to
218
- shape the payload. Treat that schema as the authoring contract.
219
-
220
- Produce one `context.structure.v1` document with semantic Nodes, planned
221
- Sections, typed edges, unresolved items, lifecycle state, sources, and evidence
222
- snapshot hash. Section identities are part of the structure gate: choose stable
223
- section ids such as `overview`, `behavior`, `constraints`, or a source-backed
224
- domain-specific name when the evidence supports it.
225
-
226
- For an independent collection entry, omit `containment`; the CLI derives
227
- `<collection>/<slug>.md`. Set `containment` only when the confirmed structure
228
- intentionally places the View under a parent path. Do not add a source/module
229
- wrapper merely to make every page use the same directory depth.
230
-
231
- Use only CLI-provided `source_refs[]` for section and edge evidence. Continuity
232
- is a per-Section constraint, not a per-View constraint: one View may contain
233
- many independently retrievable Sections, each with its own continuous mirror.
234
- Do not invent heading/range/window selectors inside the structure. Treat source
235
- heading changes as section-planning signals: sibling sub-headings under a shared parent
236
- may stay in one Section when they form one coherent semantic topic; headings
237
- with no shared parent should usually split unless you intentionally want one
238
- Section to span them. If a semantic section would require non-contiguous or
239
- cross-source evidence, split it during align or return the issue to the
240
- structure gate. Current compile writes approved knowledge by mirroring source
241
- spans; it does not use rewritten multi-ref sections to compress unrelated
242
- evidence.
243
-
244
- Validate will surface source mirror blockers before confirmation. Treat
245
- `section.source_mirror_split_required`,
246
- `section.source_mirror_repair_required`, and
247
- `section.source_mirror_source_refs_missing` as structure problems, not compile
248
- drafting problems. Use the returned `repair.suggested_splits[]` when present;
249
- otherwise repair source refs from CLI evidence views or move unsupported
250
- material to `unresolved[]`.
251
-
252
- For pure suggested-split repairs, prefer the CLI repair view before hand-editing:
253
- Deterministic source-boundary repairs are applied internally by validate/stage
254
- and are not a separate Agent command.
255
- It splits non-contiguous Section mirrors and can expand a broad cross-heading
256
- Section into Markdown structural groups within the same View. Apply the
257
- non-blocking repair hint when the groups should be independently retrievable;
258
- otherwise keep the Section and explain the grouping in structure review.
259
- Oversized Views still require the Agent to apply the returned child-View and
260
- contains-edge suggestions while classifying every child Node from evidence.
261
- Those suggestions preserve Section order and place adjacent Sections into
262
- bounded groups; `part-N` names are placeholders, not semantic titles. Rename
263
- and classify each child from evidence instead of expanding one child View per
264
- Section or treating the suggested grouping as a content decision. The repair
265
- command does not resolve orphan ownership, unsupported evidence, or competing
266
- semantic groupings.
267
-
268
- When the cited source sentence itself is uncertain, preserve that uncertainty on
269
- the edge with `confidence: possible` or `confidence: hypothesis`. This is only
270
- for source-authored uncertainty such as "可能", "疑似", "may", or "might". If
271
- you are unsure whether the source supports the relation, do not add an uncertain
272
- edge; move the relation to `unresolved[]`.
273
-
274
- No-write/navigation-only/placeholder-only material should become `unresolved`
275
- at align time when it has retrieval or graph value but lacks source-backed
276
- section evidence. Do not turn relation-only navigation into a factual Section.
277
- Do not submit `sections: []` for an ordinary source-bound view. Use
278
- `sections: []` only for a generated parent index view, and only when it has
279
- `generated: parent_index` plus source-backed `contains` edges to child views.
280
- If the relationship matters but evidence or a target node is missing, keep it
281
- unresolved instead of writing a dangling edge.
282
-
283
- Emit `depends_on` edges only when cited source refs explicitly say one Node
284
- consumes, requires, calls, is configured by, or is downstream of another Node as
285
- a prerequisite, capability provider, upstream input, runtime dependency, or
286
- data-flow source. Direction is consumer/downstream -> provider/upstream. Do not
287
- create `depends_on` for parent/child containment, `Related`/`See also` lists,
288
- sibling co-occurrence, shared table membership, name similarity, or a plain
289
- mention without a dependency predicate. `edges[].source_refs[]` must include the
290
- source ref that states the dependency; if the relationship matters but evidence
291
- is missing, leave the edge unresolved instead of guessing.
292
-
293
- Prefer the strongest source-backed `section_kind` using the current schema's
294
- `section_kind_priority` and the semantic rules below; avoid planning an entire
295
- dense source as `description` when the evidence clearly contains fenced
296
- examples, comparison tables, Q&A, decisions, specs, warnings, or principles.
297
- Use `example` for fenced command/config/code or literal sample blocks, not
298
- ordinary scenario prose. Use `comparison` for two or more subjects compared
299
- across two or more dimensions. Use `faq` for a question-and-answer pair. Use
300
- `incident` only for dated or timestamped failure evidence with impact scope
301
- plus root cause, mitigation, or handling record. Use `changelog` for a
302
- versioned or dated change record. Use `decision` only when the source surfaces
303
- two or more alternatives or options plus the chosen path and rationale. Use
304
- `spec` for a verifiable rule, threshold, requirement, constraint, or checkable
305
- target; `warning` for an explicit caveat, risk, hazard, or limitation;
306
- `principle` for a stable invariant, design rule, or core mechanism without a
307
- check method; and `description` only as the narrative fallback. Treat kind
308
- precision as a drafting quality preference, not a reason to block an otherwise
309
- source-backed write. Keep only raw-backed semantic decisions in the payload;
310
- leave mechanical repair and patch routing to CLI diagnostics.
311
-
312
- There is no parallel candidate-body authoring path. Emit only the
313
- `context.structure.v1` payload accepted by the current schema view.
314
-
315
- ### Step 6 — Validate And Submit
316
-
317
- Before staging, write the `context.structure.v1` payload to the Route-selected `.tmp/agent-payloads/` path and run the returned `context run align:<type>:<source>:<collection> --validate --input <payload-file> --format json` command. The CLI applies deterministic boundary repairs internally and returns only remaining blockers. For oversized Views, apply the returned child-View and contains-edge suggestions while classifying child Nodes from evidence. Resolve other blockers from evidence; ask the user only when evidence supports multiple incompatible semantic choices. Stage only after validation state is `ready`. The stage result opens the final HTML report for the Route-selected structure-confirmation gate. Execute the revision-bound confirmation command returned by `workflow.current`; managed session authority may resolve that gate without another question.
318
-
319
- After stage succeeds, do not rerun the same write command to confirm success.
320
- Use `context status --format json` or the returned result for read-only
321
- confirmation; then continue with the returned `next_action.command`, normally
322
- `context run compile:<type>:<source>:<collection> --view read-plan --format json`.
323
-
324
- If any write is rejected, follow the returned `next_action` and `reason_code`.
325
- Do not retry by guessing direct/batched stages, forcing route bypasses, or
326
- editing CLI-managed files.
327
-
328
- ### Step 7 — Self-verify
329
-
330
- - [ ] All writes followed top-level `next_action.command`. If not, return to **Step 1**.
331
- - [ ] Evidence was read through returned `next_action.command`, `next_command`, or current CLI schema/view commands only. If not, return to **Step 2**.
332
- - [ ] Node classification used the semantic gates in `structure-planning/references/gates.md`. If not, return to **Step 4**.
333
- - [ ] URL/reference ownership followed CLI diagnostics, not static prompt rules. If not, return to **Step 5**.
334
- - [ ] The requested align payload passed the exact Route-selected `--validate --input <payload-file>` command before stage. If not, return to **Step 6**.
335
- - [ ] No `sources/`, `knowledge/`, `dist/`, `.tmp`, host tool-results, or CLI-managed files were read or written with generic tools. If violated, restart from **Step 1**.
336
-
337
- </procedures>
@@ -1,270 +0,0 @@
1
- ---
2
- id: semantic.code-index.classification
3
- kind: procedure
4
- media-type: text/markdown
5
- ---
6
-
7
- # Classify code modules before choosing a template
8
-
9
- This procedure is the first semantic step for code extraction. Start from the
10
- Route-selected batch inspection. Do not open an archetype template and then fit
11
- the module to it. First classify every confirmed module from inspected evidence,
12
- then read only the matching templates.
13
-
14
- Classification determines which reader questions the index must answer. It
15
- does not grant access to undeclared sources, prove a relationship, or override
16
- the measured extraction preview.
17
-
18
- ## 1. Use one batch evidence pass
19
-
20
- Use the inspection result for every confirmed module before opening more files.
21
- It already reports manifests, maintained documentation, entry candidates,
22
- protocol locators, lifecycle signals, and generic structural capabilities.
23
- Open source files only for unresolved facts, and follow stable registration or
24
- executable wiring rather than scanning the whole tree.
25
-
26
- Confirm, where applicable:
27
-
28
- - the module manifest or workspace registration;
29
- - its README or nearest maintained operating documentation;
30
- - build, executable, application, service, or library entrypoints;
31
- - route, command, service, event, job, plugin, or export registries;
32
- - authoritative protocol/schema locations and concrete consumer call sites;
33
- - generated, mirrored, vendored, legacy, test, fixture, and mock boundaries;
34
- - development, configuration, deployment, and release entrypoints owned by the
35
- module.
36
-
37
- A language, framework dependency, exported symbol, or folder name does not by
38
- itself prove a module type.
39
-
40
- ## 2. Record classification before reading templates
41
-
42
- Produce one batch table first:
43
-
44
- | module | primary type | additional types | facets | evidence paths | gaps |
45
- | --- | --- | --- | --- | --- | --- |
46
- | `customer-portal` | `web-application` | — | `page-routing`, `protocol-consumer` | `package.json`, `src/routes.ts` | upstream schema is external |
47
- | `edge-gateway` | `api-service` | `adapter` | `protocol-provider`, `protocol-consumer` | `cmd/server.go`, `api/openapi.yaml` | — |
48
-
49
- Each module must have:
50
-
51
- - one primary `moduleType` for concise reports;
52
- - every additional applicable type in `moduleTypes`;
53
- - relevant behavior and boundary `facets`;
54
- - concrete inspected paths in `moduleTypeEvidence`;
55
- - exact source-relative Markdown paths already read in `documents`;
56
- - an explicit gap when available source cannot support a reliable claim.
57
-
58
- Choose the primary type from the boundary through which a reader most often
59
- enters the module. A gateway is normally `api-service`, a plugin-hosting command
60
- application is normally `cli-tool`, and a generated client is normally
61
- `sdk-library`; their translation or provenance roles remain additional types.
62
-
63
- Supported types are:
64
-
65
- - `web-application`: browser, native mobile, desktop, embedded, or cross-platform
66
- interactive applications with routes, pages, screens, or host integration;
67
- - `api-service`: an HTTP, RPC, GraphQL, message-request, or similar inbound
68
- protocol surface with dispatch to handlers;
69
- - `service`: a stable domain/use-case or reusable service boundary whose public
70
- operations coordinate implementation or persistence;
71
- - `background-runtime`: workers, consumers, schedulers, pipelines, functions,
72
- or long-running processes driven by triggers rather than interactive calls;
73
- - `sdk-library`: a reusable package with a deliberately supported consumer API;
74
- - `cli-tool`: an executable tool organized around commands, flags,
75
- configuration, outputs, and exit behavior;
76
- - `adapter`: a bridge that translates protocols, identities, models, lifecycle,
77
- or host capabilities between boundaries;
78
- - `monorepo-container`: a workspace whose stable value is its child-module,
79
- ownership, dependency, build, or release topology;
80
- - `derived-source`: generated, mirrored, vendored, or legacy source whose
81
- authority lives elsewhere;
82
- - `contract-source`: an authoritative IDL, API description, schema, or contract
83
- registry used by providers, consumers, generators, or validators;
84
- - `unknown`: the source is insufficient to classify without guessing.
85
-
86
- `unknown` cannot be combined with a known type. A hybrid module may combine
87
- several known types. Independent infrastructure definitions, migration sets,
88
- or data-model projects that do not fit a supported type remain `unknown` and
89
- use a project-owned inspection/extraction adapter; do not force them into an
90
- unrelated application type.
91
-
92
- ## 3. Add composable facets
93
-
94
- Facets identify behavior that may cross the primary type:
95
-
96
- - `page-routing`: concrete route, page, screen, or navigation registration;
97
- - `public-api`: a deliberately supported programmatic consumer surface;
98
- - `protocol-provider` / `protocol-consumer`: inbound or outbound operation
99
- boundaries with authoritative locators;
100
- - `event-producer` / `event-consumer`: asynchronous trigger and delivery flow;
101
- - `persistence`: repository, datastore, cache, or durable-state boundary;
102
- - `plugin-extension`: discovery, activation, contribution, or host extension;
103
- - `configuration-runtime`: configuration or runtime selection that changes
104
- observable behavior;
105
- - `build-release`: module-owned build, packaging, deployment, or release entry;
106
- - `cross-module-chain`: an evidenced flow joins two or more registered modules;
107
- - `generated-contract`: generated code represents or locates an upstream
108
- schema but is not automatically authoritative.
109
-
110
- Require a registration, call site, schema locator, or runtime entry. A matching
111
- dependency alone is not evidence.
112
-
113
- ## 4. Read matching templates
114
-
115
- After the batch table is complete, read every applicable type template and only
116
- the applicable facet template:
117
-
118
- | Type or facet | Template path |
119
- | --- | --- |
120
- | `web-application` | `resources/semantic/code-index/templates/web-application.md` |
121
- | `api-service` | `resources/semantic/code-index/templates/api-service.md` |
122
- | `service` | `resources/semantic/code-index/templates/domain-service.md` |
123
- | `background-runtime` | `resources/semantic/code-index/templates/background-runtime.md` |
124
- | `sdk-library` | `resources/semantic/code-index/templates/sdk-library.md` |
125
- | `cli-tool` | `resources/semantic/code-index/templates/cli-tool.md` |
126
- | `adapter` | `resources/semantic/code-index/templates/adapter.md` |
127
- | `monorepo-container` | `resources/semantic/code-index/templates/monorepo-container.md` |
128
- | `derived-source` | `resources/semantic/code-index/templates/derived-source.md` |
129
- | `contract-source` | `resources/semantic/code-index/templates/contract-source.md` |
130
- | `protocol-provider`, `protocol-consumer`, `generated-contract` | `resources/semantic/code-index/templates/protocol-boundary.md` |
131
- | `event-producer`, `event-consumer` | `resources/semantic/code-index/templates/event-flow.md` |
132
- | `persistence` | `resources/semantic/code-index/templates/persistence-boundary.md` |
133
- | `plugin-extension` | `resources/semantic/code-index/templates/plugin-extension.md` |
134
- | `cross-module-chain` | `resources/semantic/code-index/templates/cross-module-chain.md` |
135
-
136
- `page-routing` and `public-api` refine their matching application or library
137
- template. `configuration-runtime` and `build-release` add chapter expectations
138
- to the selected type template. They do not require duplicate pages.
139
-
140
- Templates are question sets and chapter blueprints. Omit unsupported sections,
141
- merge overlapping output, and retain concrete identifiers and source locators
142
- for every kept claim.
143
-
144
- ## 5. Match the plan to the extractor
145
-
146
- Extractor shape is part of the plan, not an implementation detail:
147
-
148
- - `extractTs()` projects each selected symbol to its own candidate page. It is
149
- suitable for a deliberately granular public reference, but it does not
150
- produce an aggregated module map, registry, protocol index, or chain page.
151
- - `extractTs()` assigns ownership by source. A source can belong to only one
152
- index unit in a phase. Splitting one source into several units or adding an
153
- overlapping cross-source unit causes `ownership-ambiguous`.
154
- - Use `extractCustom()` for aggregate pages or multiple units over one source.
155
- Every candidate must declare its owning `module`, and its evidence must cover
156
- the Route-reported structural probes. The custom-candidate contract has no
157
- page-level Markdown fallback: every candidate must provide at least one
158
- evidence-scoped `section`, and each section declares a coverage kind and the
159
- exact source evidence supporting that part of the page. Resolve source roots
160
- from the extractor context's `sources[].absolutePath`; never embed a
161
- machine-specific checkout path.
162
- - Register independently visible monorepo children as separate sources before
163
- giving them separate `extractTs()` units. An `include` pattern filters files;
164
- it does not create a source boundary.
165
-
166
- Do not wait for an expensive preview to discover that the chosen extractor
167
- cannot produce the planned page shape.
168
-
169
- ## 6. Produce one deduplicated plan
170
-
171
- Create one `CodeIndexUnitPlan` per user-visible module or independently useful
172
- custom cross-module flow. A minimal plan has this shape:
173
-
174
- ```ts
175
- {
176
- module: "customer-portal",
177
- moduleType: "web-application",
178
- moduleTypes: ["web-application"],
179
- facets: ["page-routing", "protocol-consumer"],
180
- moduleTypeEvidence: ["package.json", "src/routes.ts"],
181
- documents: ["README.md", "docs/architecture.md"],
182
- outputOwner: "customer-portal",
183
- outputProfile: "application-map",
184
- inputSources: ["repo:customer-portal"],
185
- entries: ["src/bootstrap.ts", "src/routes.ts"],
186
- protocols: ["api/openapi.yaml"],
187
- excludes: ["dist/**", "**/*.test.ts"],
188
- lifecycle: "source",
189
- pageKinds: ["application-map", "route-registry", "protocol-boundary"],
190
- capability: "complete"
191
- }
192
- ```
193
-
194
- `outputProfile` is a closed value and selects structural coverage expectations:
195
-
196
- | Profile | Intended output |
197
- | --- | --- |
198
- | `module-map` | stable module responsibility and entry map |
199
- | `application-map` | application entry, route, state, and boundary map |
200
- | `protocol-index` | provider/consumer operations anchored to contracts |
201
- | `service-boundary` | service operations, orchestration, and dependencies |
202
- | `runtime-map` | triggers, processing, state, effects, and recovery |
203
- | `public-api-reference` | deliberately supported consumer API |
204
- | `command-map` | commands, options, effects, outputs, and recovery |
205
- | `adapter-contract` | inbound-to-outbound translation contract |
206
- | `module-registry` | workspace child modules, ownership, and topology |
207
- | `cross-module-flow` | evidenced handoffs across registered modules |
208
- | `provenance-only` | source identity, derivation, consumers, and authority |
209
-
210
- The preview also requires these evidence-scoped section kinds:
211
-
212
- | Profile | Required section coverage |
213
- | --- | --- |
214
- | `module-map` | `responsibility`, `entrypoint` |
215
- | `application-map` | `entrypoint`, `operation`, `handoff` |
216
- | `protocol-index` | `contract`, `operation`, `handoff` |
217
- | `service-boundary` | `operation`, `handoff` |
218
- | `runtime-map` | `entrypoint`, `operation`, `failure-recovery` |
219
- | `public-api-reference` | `contract` |
220
- | `adapter-contract` | `contract`, `handoff` |
221
- | `command-map` | `entrypoint`, `operation`, `failure-recovery` |
222
- | `module-registry` | `responsibility`, `source-authority` |
223
- | `cross-module-flow` | `operation`, `handoff`, plus at least one structured edge |
224
- | `provenance-only` | `source-authority` |
225
-
226
- The `build-release`, `persistence`, `configuration-runtime`, and
227
- `generated-contract` facets additionally require `delivery`, `state-boundary`,
228
- `state-boundary`, and `source-authority` respectively. A heading without an
229
- evidence-scoped section does not satisfy coverage.
230
-
231
- The profile affects structural probes and advisory risks. `pageKinds` remains
232
- free-form so projects can name useful page families, but use stable kebab-case
233
- tokens consistently within a project. Type templates provide recommended
234
- tokens.
235
-
236
- For a multi-module round, finish all classifications first, read the union of
237
- matching templates once, and revise affected plans together. Do not create a
238
- copy of the same operation or plugin record for each selected template.
239
-
240
- ## 7. Capability gaps and preview
241
-
242
- Use `capability: "material-required"` when an unsupported parser, missing
243
- project adapter, absent evidence, or unresolved source boundary prevents the
244
- promised output. This typed capability is valid in ordinary and fully managed
245
- flows and stops both at the same Route Gate.
246
-
247
- Missing authority does not always block all output. For generated or mirrored
248
- source whose upstream schema cannot be located, a `provenance-only` unit may
249
- still record source identity, known derivation facts, and evidenced consumers.
250
- Keep field semantics and compatibility claims material-required. Stop the
251
- whole unit only when those semantics are the confirmed knowledge goal.
252
-
253
- Run the Route-selected batch preview after every plan is evidence-backed. Its
254
- projected Markdown count is authoritative per index unit:
255
-
256
- - up to 100 pages: continue;
257
- - 101–300 pages: report an advisory and continue;
258
- - more than 300 pages: block and revise, including in fully managed mode.
259
-
260
- A large batch also reports a batch-total advisory even when each unit remains
261
- within its limit. Advisory risks describe quality or cost; they do not become a
262
- new human Gate. `scale-limit-exceeded`, `ownership-ambiguous`, and
263
- `material-required` capability gaps remain blocking.
264
-
265
- Legal recovery includes narrowing `include`, excluding generated or mirrored
266
- areas, using `exportedOnly`, changing a symbol catalog into an aggregated
267
- `extractCustom()` output, or registering real child sources. Splitting one
268
- `extractTs()` source into overlapping units is not a valid workaround. Group all
269
- affected modules into one plan revision instead of creating one Gate per
270
- module.