@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,33 +0,0 @@
1
- ---
2
- id: dialogue.document-classification
3
- kind: procedure
4
- mediaType: text/markdown
5
- ---
6
-
7
- # Document-classification dialogue
8
-
9
- Do not recommend a collection before reading the collection-neutral evidence
10
- view and every required source-body resource. Summarize the observed document
11
- shape, explain one evidence-backed
12
- recommendation, and describe its package root:
13
-
14
- | Collection | Use when the evidence primarily represents | Package root |
15
- |---|---|---|
16
- | `business` | business domains, actors, objects, and non-technical domain knowledge | `wikis/` |
17
- | `product` | requirements, user behavior, user stories, and acceptance intent | `wikis/` |
18
- | `architecture` | system structure, module design, technical mechanisms, and platform/tooling design | `guides/` |
19
- | `sop` | procedures, runbooks, operations, maintenance, and troubleshooting steps | `guides/` |
20
- | `faq` | question-and-answer material intended for issue-oriented retrieval | `guides/` |
21
- | `standards` | normative rules, constraints, checklists, and quality/compliance requirements | `rules/` |
22
- | `decision` | explicit alternatives, selected choices, trade-offs, and decision records | `guides/` |
23
- | `incident` | incident timelines, impact, causes, response, and prevention | `guides/` |
24
- | `test` | test plans, validation scenarios, matrices, and acceptance cases | `rules/` |
25
-
26
- `codeindex` comes from code extraction and `feats` is not a document mainline
27
- collection. Filenames, URLs, titles, and example collection names are
28
- insufficient evidence.
29
-
30
- Ask the user to confirm exactly one mainline collection for the current source,
31
- unless session-managed authority resolves this gate. After confirmation,
32
- declare the complete align, compile, and Review lifecycle for the same source
33
- and collection, then re-evaluate because other captured targets may remain.
@@ -1,44 +0,0 @@
1
- ---
2
- id: dialogue.structure-confirmation
3
- kind: procedure
4
- mediaType: text/markdown
5
- ---
6
-
7
- # Structure-confirmation dialogue
8
-
9
- Present the staged structure as a proposal, not as approved knowledge. Explain
10
- that confirmation freezes the current round's:
11
-
12
- - knowledge pages and paths;
13
- - section ownership and source spans;
14
- - source-backed relationships; and
15
- - compile order.
16
-
17
- The final staged HTML report is the confirmation surface. Open it when the CLI
18
- returns it, report whether opening succeeded, and provide the file URL/path when
19
- it did not. Do not confirm from counts alone.
20
-
21
- Present these three outcomes in the user's language:
22
-
23
- - confirm the current staged structure digest;
24
- - revise the proposed structure and validate/stage it again; or
25
- - return to the source boundary when the current evidence scope is wrong.
26
-
27
- If staging changed the structure digest, any earlier confirmation no longer
28
- applies. When `workflow.current.gate.resolution` is `user`, explain the change
29
- and obtain a new confirmation. When it is `session-authority`, inspect the same
30
- report and continue without asking again. After resolution, execute only the
31
- revision-bound command returned by `workflow.current`; never construct or reuse
32
- a phase-local confirmation command.
33
-
34
- Deterministic boundary repairs are internal CLI maintenance and are not
35
- separate approval rounds. If `workflow.current.gate.resolution` is
36
- `session-authority`, inspect the final staged report and execute the returned
37
- resolution command without asking the user again. Otherwise ask for one final
38
- confirmation of the staged digest. Ask an earlier design question only when
39
- evidence supports multiple incompatible structures, and say clearly that it is
40
- not the final confirmation.
41
-
42
- One source document may map to one page, but that is still an ordinary
43
- structure proposal. A multi-source round confirms each source/collection slot;
44
- do not confuse one slot with completion of the entire document batch.
@@ -1,25 +0,0 @@
1
- ---
2
- id: dialogue.workflow-mode-after-capture
3
- kind: procedure
4
- mediaType: text/markdown
5
- ---
6
-
7
- # Workflow mode after source capture
8
-
9
- When source capture has completed, ask about execution mode only if the
10
- conversation still has no explicit choice and no earlier mode question was
11
- asked. If ordinary review or fully managed operation was already selected,
12
- continue without a reminder or another confirmation. When a choice is still
13
- needed, explain in the user's current conversation language that ordinary
14
- review pauses at review decisions and provides HTML reports for inspection.
15
- The current product estimate is that ordinary review makes the overall workflow
16
- about 40% slower, with the exact difference depending on scope and response
17
- time.
18
-
19
- Offer fully managed operation for the rest of the current conversation. Explain
20
- that it skips delegatable content-review surfaces and is faster, but reduces the
21
- user's ability to control or adjust intermediate content. It does not bypass
22
- source boundaries, external permissions, hard validation, evidence checks,
23
- verification failures, or other non-delegatable safety boundaries. Do not ask
24
- again after this one-time conversation choice, and never persist it in project
25
- files.
@@ -1,152 +0,0 @@
1
- ---
2
- id: manual.reference.code-extractors
3
- kind: procedure
4
- mediaType: text/markdown
5
- ---
6
-
7
- # Code Extractor Selection
8
-
9
- Use this manual only when the current code-extraction Route asks the Agent to
10
- choose or declare an extractor. The CLI reports repository facts; the Agent
11
- chooses how those facts become source-backed code knowledge.
12
-
13
- ## Inspect Before Declaring
14
-
15
- Run the single batch inspection command returned by the extraction-scope Gate.
16
- The result identifies every confirmed module, its recognized `manifests`,
17
- README locations, entry candidates, protocol locators, and lifecycle markers.
18
- Treat these as deterministic technology signals, not as product semantics:
19
-
20
- | Signal | Technology candidate |
21
- |---|---|
22
- | `package.json` | TypeScript, TSX, JavaScript, or JSX |
23
- | `go.mod` | Go |
24
- | `Cargo.toml` | Rust |
25
- | `pyproject.toml` or `setup.py` | Python |
26
- | `pom.xml` or `build.gradle` | Java or JVM |
27
- | multiple manifests | a mixed module that may need more than one extractor |
28
-
29
- Do not select `extractTs()` merely because a repository contains some
30
- TypeScript. Decide against the exact confirmed module and include boundary. A
31
- mixed module may compose multiple structural passes; parser selection is not an
32
- exclusive repository-wide switch.
33
-
34
- ## Selection Order
35
-
36
- Use the narrowest reusable capability that covers the confirmed source:
37
-
38
- 1. Use a Context-owned phase when its contract matches the source.
39
- 2. Otherwise use a reusable structural package inside `extractCustom()`.
40
- 3. If no reusable package covers the syntax or repository protocol, implement a
41
- project-owned adapter and keep it in the Context workspace.
42
-
43
- Current reusable capabilities are:
44
-
45
- | Source fact | Preferred capability | Lifecycle integration |
46
- |---|---|---|
47
- | TypeScript/JavaScript package or TSX/JSX file scope | `extractTs()` | Context-owned phase |
48
- | Go declarations, imports, calls, and common HTTP routes | `@c4a/extract-go` | call from `extractCustom()` |
49
- | Rush workspace packages, tags, dependencies, entries, and owners | `@c4a/extract-rush` | call from `extractCustom()`; may complement a language extractor |
50
- | React Router route declarations | `extractReactRouterRoutes()` from `@c4a/extract-ts` | call from `extractCustom()`; complements ECMAScript symbols |
51
- | Rust, Python, Java/JVM, or an unsupported framework/protocol | no assumed built-in parser | project-owned `extractCustom()` adapter |
52
-
53
- The custom extraction preview verifies this selection mechanically. Context
54
- detects applicable community capabilities from source manifests and stable path
55
- signals, then checks that candidate evidence covers every required entry,
56
- route, implementation boundary, workspace, or protocol probe. One aggregated
57
- module page is valid when it closes that structural coverage. A callback that
58
- only hashes a few filenames or renders configured prose does not satisfy the
59
- probe, even when its Markdown count is small.
60
-
61
- The probe does not assign business meaning and does not require one page per
62
- fact. The project adapter still owns grouping, titles, explanations, and
63
- cross-module semantics. If the source uses an unsupported language or protocol,
64
- report a capability gap instead of claiming that a known probe was consumed.
65
-
66
- An optional package does not create a new CLI phase. Add it as an explicit
67
- workspace dependency, then map its structural facts to candidates in the
68
- project callback. Do not add a parser package when its documented coverage does
69
- not match the inspected source.
70
-
71
- ## Read The Contract Before Extending
72
-
73
- Before editing `src/index.ts`, read the Route-selected Context lifecycle and
74
- extractor resources completely. They are the installed contract for
75
- Context-owned phases such as `extractTs()`; do not require a separate
76
- workspace copy of an implementation package and do not infer APIs from bundled
77
- JavaScript.
78
-
79
- Only a capability imported directly by a project-owned `extractCustom()`
80
- adapter requires its package README. Use this matrix to decide whether that
81
- optional capability is relevant, add only that dependency, then read the
82
- README from the resolved installed package before implementing the callback.
83
- Never assume that a transitive or dev-only package is present at a hard-coded
84
- `node_modules` path.
85
-
86
- A project-owned adapter may use an existing parser, compiler API, or command
87
- whose output is deterministic. It must return source-backed candidates through
88
- `extractCustom()`; it must not write lifecycle, knowledge, or Review files.
89
- Framework-specific classification and rendering remain in the project. The CLI
90
- and structural parser must not infer product meaning.
91
-
92
- ## Decision To Report
93
-
94
- Before the first extraction preview, state briefly:
95
-
96
- - the inspected module and manifest signals;
97
- - the selected Context phase or structural package;
98
- - whether coverage is complete or which facts remain project-owned; and
99
- - why another available extractor is not needed.
100
-
101
- After preview, use `inspection.structuralProbes` and each index unit's
102
- `structuralCoverage` as the exact audit result. An uncovered probe is a
103
- configuration problem, not a Review decision.
104
-
105
- If no current capability can parse the source reliably, stop at configuration
106
- and report the missing generic capability. Do not silently emit an empty
107
- codeindex or reuse an unrelated parser.
108
-
109
- ## Plan Before Parsing
110
-
111
- Classify the user-visible module before selecting language tooling or reading an
112
- archetype template: API/service, background runtime, SDK/library, interactive
113
- application, adapter, CLI/tool, monorepo container, derived source,
114
- authoritative contract source, or unknown.
115
- A hybrid module may declare several `moduleTypes` and several behavior `facets`;
116
- keep one primary `moduleType` for concise reports. Record inspected paths in
117
- `moduleTypeEvidence`, record every Markdown file actually read in `documents`, then read all matching Route-recommended files below
118
- `resources/semantic/code-index/templates/` and combine them into one plan.
119
- After that, choose exactly one closed output profile: `module-map`,
120
- `application-map`, `protocol-index`, `service-boundary`, `runtime-map`,
121
- `public-api-reference`, `command-map`, `adapter-contract`, `module-registry`,
122
- `cross-module-flow`, or `provenance-only`. The profile selects structural probes
123
- and advisory checks; an invented value is rejected.
124
-
125
- Each archetype resource is a working template for an Agent with limited prior
126
- context. It provides a minimum evidence pass, the reader questions the index
127
- must answer, suggested knowledge units, Markdown chapter blueprints,
128
- aggregation and relationship rules, composition examples, and stop conditions.
129
- The blueprints are illustrative: omit unsupported sections and merge overlap
130
- across selected templates instead of producing empty headings or duplicate
131
- pages. They shape content before the batch preview; they do not prescribe or
132
- override projected page counts.
133
-
134
- Extractor shape defines what can be emitted. `extractTs()` creates one page per
135
- selected symbol and permits one owning index unit per source. Use it for an
136
- intentional granular public reference. Use `extractCustom()` for module-level
137
- aggregation, registries, protocol indexes, cross-module flows, or multiple
138
- candidate owners over one source; each candidate declares its `module` and
139
- at least one evidence-scoped `section`; there is no page-level Markdown
140
- fallback. Each section's typed coverage and exact evidence is checked against
141
- the output profile during preview. Resolve repositories from
142
- the extractor context's `sources[].absolutePath`, never from a
143
- machine-specific checkout path. Cross-module flow output must also emit
144
- source-backed structured edges. Generated clients/models, mirrored sources, legacy
145
- implementations, and internal helpers should normally be excluded or recorded
146
- as provenance rather than expanded one symbol per page.
147
-
148
- If a repository uses service manifests or protocol registrations that the
149
- community inspector cannot interpret, keep that interpretation in a generic
150
- project-owned `inspect` adapter attached to `extractCustom()`. Return findings
151
- and capability gaps through the public Context contract; do not add internal
152
- framework names or directory rules to the CLI.
@@ -1,188 +0,0 @@
1
- ---
2
- id: procedure.code-extraction
3
- kind: procedure
4
- mediaType: text/markdown
5
- ---
6
-
7
- # Code extraction
8
-
9
- Code extraction operates on user-confirmed repository modules and source
10
- patterns. A source registration identifies the repository or module; the
11
- extraction declaration defines the code scope inside it.
12
-
13
- Before declaring a phase, run the Route-selected batch inspection once for all
14
- confirmed modules. Read their manifests, module documentation, stable entries,
15
- and dependency/protocol locators. First record an evidence-backed classification
16
- for every module without reading an archetype template. A module has one primary
17
- `moduleType`, may declare additional `moduleTypes`, and may combine relevant
18
- `facets`. Only after classification, read every matching file from the Route's
19
- recommended `resources/semantic/code-index/templates/` directory and merge them
20
- into one deduplicated plan per user-visible module or aggregate.
21
-
22
- The target is a stable module map, public contract, protocol boundary, or
23
- runtime map—not a page for every function, variable, constant, or internal type.
24
- Use the Code Extractor Selection manual to choose `extractTs`, an optional
25
- structural package inside `extractCustom`, or a project-owned adapter. Read the
26
- selected package's public SDK/README before editing `src/index.ts`; never infer
27
- its API from bundled output. `moduleTypeEvidence` must identify the inspected
28
- paths that support the classification. An `unknown` unit or a unit with no
29
- classification evidence is an incomplete index plan.
30
- Record exact source-relative Markdown paths read during classification in
31
- `indexUnits[].documents`. Context inventories module Markdown independently:
32
- root README or documentation entry files require complete reading, while other
33
- related Markdown uses the reported Floor and Target coverage.
34
-
35
- For every custom extraction preview, Context probes source paths for known
36
- community structural capabilities: TypeScript symbols, React Router routes, Go
37
- symbols, Rush workspace structure, and source-owned protocol schemas. Every
38
- probe applicable to an index unit's output profile must be represented by the
39
- candidate evidence for that unit. A project adapter may aggregate and explain
40
- those facts in one high-value page, but it cannot replace a matched structural
41
- probe with a static template or a manually listed filename. Missing probe
42
- coverage is a `material-required` capability gap and uses the same
43
- non-delegatable capability Gate in ordinary and fully managed conversations.
44
-
45
- `include` filters files inside a selected source; it is not a package/module
46
- selector. Use source declarations to select repository modules. Use configured
47
- entry patterns when entry-led traversal is meaningful, or scan mode when the
48
- selected module intentionally has no package entry. Do not require source-code
49
- rewrites merely to create an extraction entry.
50
-
51
- Exports-only single-package TypeScript extraction has a compatible stable
52
- public-contract plan. Scan mode, repository collections, and custom extraction
53
- must declare their index units explicitly; an inferred plan is diagnostic only
54
- and cannot write candidates.
55
-
56
- Every index unit must expose one inventory contract. Built-in parsers produce
57
- it from AST and source traversal; a project adapter returns the same generic
58
- shape. The inventory separates eligible/analyzed files and non-empty LOC,
59
- discovered/read Markdown, discovered/analyzed/target/exported symbols, stable
60
- entries and profile-selected boundaries, plus excluded files and reasons. JSON,
61
- YAML, lockfiles and assets may be evidence but do not inflate source LOC.
62
- Evidence-only adapter output is explicitly `unscorable` and cannot pass the
63
- mechanical quality Gate as a complete module index.
64
-
65
- Extractor output shape must match the semantic plan. `extractTs()` projects one
66
- candidate page per selected symbol and assigns each source to one index unit;
67
- it is suitable for a deliberately granular public reference. Aggregated module
68
- maps, registries, protocol indexes, cross-module flows, or multiple units over
69
- one source require `extractCustom()` with explicit candidate ownership. For a
70
- monorepo, register independently visible children as separate sources before
71
- giving them separate `extractTs()` units.
72
-
73
- The Route runs one cache-writing batch preview after classification, template
74
- selection, and configuration, but before any candidate write. Report
75
- discovered files, AST-analyzed files, skipped files, symbols, and relations
76
- separately, together with each index unit's output owner, output profile,
77
- projected Markdown count, total bytes, largest sampled page, and risk flags.
78
- For custom phases, also report detected structural probes, covered and uncovered
79
- probe counts, representative evidence paths, and the affected output profile.
80
- The preview command returns a bounded summary plus one digest-bound item view.
81
- Follow its `next_action.command` pages until `preview_items_complete` when the
82
- Route requires semantic scope, ownership, capability, or scale inspection;
83
- never recover omitted inventory with host-output slicing.
84
- Use resolved entry files, exported/internal counts, and symbol-kind counts as
85
- structural scope evidence only. Resolve TypeScript/JavaScript
86
- configuration and aliases through the extractor rather than guessing paths
87
- from imports.
88
-
89
- Template examples never determine the expected page count. Scale policy is
90
- applied only to the measured batch preview and is fixed per index unit: at most
91
- 100 pages continues normally,
92
- 101–300 pages continues with a warning, and more than 300 pages stops at the
93
- non-delegatable extraction-scale Gate. Fully managed authority cannot bypass
94
- that Gate. Ambiguous output ownership and `material-required` capability gaps
95
- also stop before candidate writes. Ambiguous ownership returns to project
96
- configuration without creating another human Gate. Revise all affected units
97
- together, re-check whether their classification or selected templates changed,
98
- rerun the batch preview, then process exactly one pending extraction target and
99
- evaluate again. Do not add a second classification Gate after the page-count
100
- Gate; a plan revision returns through the same configuration step.
101
-
102
- A batch-total page warning remains advisory. After extraction, independent
103
- mechanical dimensions enforce source analysis, target-boundary coverage,
104
- facts/explanation, evidence scope, implementation ratio, and page shape.
105
- Aggregate custom candidates are rendered only from evidence-scoped `sections`;
106
- free Markdown, empty optional sections, template instructions, and placeholders
107
- cannot become reader-facing knowledge. A required Section without evidence is a
108
- material/capability gap instead of an empty heading. Legal scale recovery
109
- includes narrowing `include`, excluding generated or mirrored directories,
110
- enabling `exportedOnly`, moving from a symbol catalog to an aggregated
111
- `extractCustom()` plan, or registering real child sources. Splitting one
112
- `extractTs()` source into overlapping units is not a valid workaround.
113
-
114
- Current previews are cached below `.tmp/context-runtime/extract/previews/` and
115
- formal extraction reuses their validated structural result. Cache identity is
116
- bound to source scope, phase/adapter declarations, project `src/`, dependency
117
- locks, and the preview protocol. Deleting
118
- `.tmp` only causes a fresh preview. Existing approved knowledge is not
119
- retroactively rejected solely because it is large.
120
-
121
- New workspaces write `knowledge/codeindex/**`. If an old workspace contains
122
- legacy `knowledge/codegraph/**`, follow the Route-returned
123
- `context migrate codeindex --format json` action. It rewrites formal collection
124
- identities and invalidates derived extraction/audit state without requiring
125
- `.tmp`. Never create a permanent dual-write or move the directory by hand.
126
-
127
- Do not open Review while another extraction target in the same batch remains.
128
- Unchanged approved or rejected symbols do not need another decision; new or
129
- changed candidates remain subject to the current Review policy.
130
-
131
- For TypeScript, JavaScript, TSX, and JSX sources, Context also carries extractor-reported AST relations
132
- between selected symbols. A relation is projected only when both endpoints
133
- resolve uniquely inside the selected module; external, unselected, and
134
- ambiguous endpoints are counted as omissions instead of guessed. The extract
135
- receipt reports `relationships.detected`, `emitted`, and omission counts.
136
- Review materializes those source-backed relations with the approved symbol,
137
- and deterministic close refreshes the typed edge projection.
138
-
139
- Project-owned custom edges use `source-backed-explicit` rather than claiming
140
- AST derivation. They remain subject to the same evidence, endpoint, Review, and
141
- close projection checks.
142
-
143
- Zero edges remain a valid result. Read `close.relationshipCoverage` or the
144
- package inventory's `structure.relationship_coverage` to distinguish a current
145
- source-backed extraction that found no approved edges from an older or
146
- otherwise unknown relationship mode. Never infer missing edges from symbol
147
- co-occurrence, filenames, or package size.
148
-
149
- When the built-in ECMAScript-family extractor cannot represent the code source, use a
150
- declared `extractCustom` phase. The project-owned callback returns candidate
151
- semantics plus structured source evidence; Context owns canonical refs,
152
- fingerprints, candidate storage, Review snapshots, freshness, and rerun cleanup.
153
- Do not use a generic `customPhase` callback to write lifecycle files directly.
154
- Large custom adapters may return candidates as an `AsyncIterable`; Context
155
- retains at most the proof boundary for an over-limit unit instead of collecting
156
- thousands of full Markdown candidates. A project-owned `inspect` adapter may
157
- report generic module/protocol findings and capability gaps without putting
158
- framework-specific rules in the community CLI.
159
-
160
- Prefer a reusable structural library over a project-local parser when one
161
- matches the confirmed source: `@c4a/extract-go` for Go facts,
162
- `@c4a/extract-rush` for Rush workspace facts, and
163
- `extractReactRouterRoutes()` from `@c4a/extract-ts` for React Router facts.
164
- These are optional project dependencies consumed inside `extractCustom()`;
165
- they are not built-in CLI phases. Keep product-specific classification and
166
- candidate rendering in the project, and do not ask the CLI or parser to infer
167
- business meaning.
168
-
169
- For Rust, Python, Java/JVM, or another source without a matching reusable
170
- extractor, keep the lifecycle in `extractCustom()` and implement only the
171
- missing project adapter. If reliable syntax facts cannot be produced, stop at
172
- configuration and report the generic capability gap rather than emitting an
173
- empty or guessed graph.
174
- # Agent audit after extraction
175
-
176
- After every complete code-extraction batch, the Route produces one batch-level
177
- code-index audit. Mechanical signals cover content depth, evidence scope,
178
- declared-source coverage, and structured handoffs. A dimension outside its
179
- absolute bounds is a mechanical rejection and cannot be accepted. Advisory or
180
- elevated signals inside those bounds remain review evidence: the Agent must
181
- inspect the affected pages and submit one `accept`, `revise`, or
182
- `request-input` decision for all index units together.
183
-
184
- Do not split this into one confirmation per module. In fully managed operation,
185
- real issues select `revise` and the Route returns through project configuration,
186
- batch Preview, extraction, and a new audit until the index is acceptable. A
187
- false positive may be accepted only with a concrete inspected reason. Ask the
188
- user only when reliable correction needs unavailable material or access.
@@ -1,113 +0,0 @@
1
- ---
2
- id: procedure.code-index-audit
3
- kind: procedure
4
- mediaType: text/markdown
5
- ---
6
-
7
- # Code-index Agent audit
8
-
9
- This Route is a required semantic review of the complete proposed code index.
10
- The CLI reports mechanical signals; the Agent reads the affected candidate
11
- content and evidence, compares registered sources with the user-confirmed
12
- scope, and decides whether the index is fit for its declared output profiles.
13
- Reader metrics exclude Context lifecycle comments and evidence annotations.
14
- Improve the source-backed knowledge itself; do not change Markdown syntax,
15
- sentence count, or pagination solely to influence a mechanical counter.
16
- The complete inventory is evidence, not the default reader-facing output. Do
17
- not create one sentence, bullet, table row, or page for every discovered file
18
- or symbol merely to satisfy coverage or density. Group related identities by a
19
- reader-visible capability, entrypoint, protocol boundary, lifecycle stage, or
20
- handoff, then explain the group's responsibility, stable inputs and outputs,
21
- state or failure boundary when applicable, next handoff, and exact supporting
22
- sources. A granular catalog is appropriate only for a declared public API,
23
- protocol, or command reference.
24
-
25
- When the report shows low density, add source-backed explanation or a complete
26
- relationship chain. Never add repeated `Observed ...` rows. When symbol
27
- coverage is low, use a verified evidence-backed group or a profile-appropriate
28
- catalog instead of copying the inventory into prose. Normalized template
29
- repetitions do not count as semantic facts, and enumeration-heavy output has a
30
- profile-specific ceiling.
31
-
32
- Identity groups and chain candidates are mechanical contracts, not optional
33
- notes. A group counts only when its members belong to the target inventory, its
34
- source files belong to the eligible inventory, and its reader-facing page cites
35
- those files. Every chain candidate must be documented, merged into a documented
36
- candidate, excluded with a concrete reason, or routed to missing-material input.
37
- For each discovered external boundary family, retain a representative
38
- source-backed chain or an explicit material gap.
39
- When the boundary inventory contains adjacent families such as operation and
40
- handler, handler and downstream, command and effect, event and processor, or a
41
- cross-source handoff, the adapter must return the corresponding candidate
42
- family. Returning an empty candidate list does not bypass chain review.
43
-
44
- The report contains no aggregate score. Every dimension is computed
45
- independently with its observed value, floor, recommended target, ceiling,
46
- mechanical score, uncovered identities, and legal repair actions. A dimension
47
- outside its absolute bounds cannot be accepted or offset by another strong
48
- dimension. Every elevated signal must receive an assessment tied to inspected
49
- content. Submit one `context.code-index-audit-decision.v1` payload for the
50
- complete batch.
51
-
52
- Read the complete digest-bound inventory before deciding. The Route-selected
53
- audit resource returns one budget-safe inspection command. Execute it and then
54
- each returned `next_action.command` until `audit_items_complete`; do not use
55
- host output truncation or shell slicing as pagination. The item stream separates
56
- eligible and analyzed files/LOC, read documents, target and exported symbols,
57
- stable entries, protocol boundaries, exclusions, and parser gaps. For each
58
- failed or below-target dimension, use the returned uncovered identities,
59
- affected pages, recommended template resources, and action vocabulary. Do not
60
- replace those facts with an inferred file list.
61
-
62
- For custom adapters, file and symbol identity arrays are complete denominators,
63
- not samples: their lengths must match the declared counts, analyzed identities
64
- must belong to eligible identities, and exported identities must belong to the
65
- target-symbol set. For a single-source unit, the CLI independently enumerates
66
- the represented language families plus Markdown/MDX after declared exclusions;
67
- an adapter cannot make its ratio pass by reporting only hand-picked evidence
68
- files. Conventional sibling page entries, Go route-register calls, and exported
69
- operations from a declared Go handler source of truth are also independently
70
- enumerated; include every discovered identity in the target-symbol and boundary
71
- denominators even when one aggregate page explains them. Section evidence may
72
- contain multiple files and may overlap
73
- another Section when one fact crosses a boundary. It must not be reduced to one
74
- arbitrary primary file, and every Section must not repeat the complete page
75
- evidence set merely to satisfy coverage. Distinct structured relationships must
76
- cite the concrete evidence for their own handoff instead of repeating one whole
77
- page evidence set across every destination.
78
-
79
- ## Decisions
80
-
81
- - `accept`: the requested scope is represented, every dimension is within its
82
- absolute bounds, and every real content-depth, evidence-scope, template, and
83
- relationship issue is resolved. A below-target dimension remains visible
84
- and needs a concrete reason in ordinary operation.
85
- - `revise`: one or more real problems remain. Identify the affected units and
86
- describe changes to scope, aggregation, sections, evidence, or structured
87
- handoffs. The Route returns to `src/index.ts`, Preview, extraction, and a new
88
- audit revision.
89
- - `request-input`: reliable revision requires material unavailable in the
90
- registered sources, such as an external protocol or missing source boundary.
91
- Ask only for that material, then submit a new decision.
92
-
93
- ## Fully managed operation
94
-
95
- Fully managed authority does not bypass the audit. When an absolute dimension
96
- fails, choose a returned repair action and continue through configuration,
97
- Preview, extraction, and audit without asking the user. Aim for the recommended
98
- target instead of stopping immediately at the floor. The retry ledger is bound
99
- to unit, source revision, profile, and problem fingerprint; superficial wording
100
- changes do not reset it. After three unsuccessful revisions of the same
101
- problem, Context combines all affected modules into one human-guidance Gate.
102
- Pause earlier only for unavailable material, source access, or missing parser
103
- capability.
104
-
105
- After each decision, briefly tell the user which decision was selected, the
106
- affected units, and the next Graph path. Do not stop a managed run merely to
107
- announce a successful automatic revision.
108
-
109
- The current `context.code-index-audit-report.v2` is computed from proposed or
110
- approved knowledge. Only its decision receipt and compact retry metrics stay
111
- under `.tmp/context-runtime/code-index-audit/`. Package output records only the
112
- selected report digest and decision; page metrics, exclusions, template
113
- fingerprints, and repair history are never published.
@@ -1,22 +0,0 @@
1
- ---
2
- id: procedure.document-classification
3
- kind: procedure
4
- mediaType: text/markdown
5
- ---
6
-
7
- # Document classification
8
-
9
- Classification chooses the main knowledge collection for a captured document.
10
- The choice must follow evidence investigation, not the URL, file name, a user
11
- example, or a fixed content-specific prompt.
12
-
13
- Read the current collection-neutral evidence view, explain a short
14
- evidence-backed recommendation and its output implications, then obtain the
15
- user decision unless the current session explicitly delegates this gate.
16
- Read every Route-selected `context.source-body/*` resource in full. Index and
17
- heading metadata support navigation but are not evidence that the document
18
- body was read.
19
-
20
- After the decision, declare the complete align, compile, and review lifecycle
21
- for the same canonical source and collection. Re-evaluate instead of assuming
22
- the declaration closed every document target.