@c4a/context-cli 0.6.1 → 0.6.2

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 (236) hide show
  1. package/README.md +48 -10
  2. package/README.zh-CN.md +176 -0
  3. package/cli.js +60700 -35477
  4. package/docs/quickstart.md +23 -5
  5. package/package.json +4 -2
  6. package/plugins/README.md +60 -118
  7. package/plugins/README_CN.md +51 -102
  8. package/plugins/VERSION +1 -1
  9. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  10. package/plugins/claude/commands/continue.md +56 -10
  11. package/plugins/claude/commands/init.md +24 -11
  12. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  13. package/plugins/codex/skills/continue/SKILL.md +56 -11
  14. package/plugins/codex/skills/init/SKILL.md +23 -11
  15. package/plugins/cursor/.cursor-plugin/plugin.json +2 -3
  16. package/plugins/cursor/README.md +2 -2
  17. package/plugins/cursor/commands/context-continue.md +56 -10
  18. package/plugins/cursor/commands/context-init.md +24 -11
  19. package/plugins/skills/context-continue/SKILL.md +56 -11
  20. package/plugins/skills/context-init/SKILL.md +23 -11
  21. package/providers/context/actions/accept-package-templates.yaml +5 -0
  22. package/providers/context/actions/align-next.yaml +6 -0
  23. package/providers/context/actions/apply-managed-review.yaml +5 -0
  24. package/providers/context/actions/apply-structure-confirmation.yaml +5 -0
  25. package/providers/context/actions/build-next.yaml +5 -0
  26. package/providers/context/actions/capture-next.yaml +5 -0
  27. package/providers/context/actions/close-approved-knowledge.yaml +5 -0
  28. package/providers/context/actions/compile-next.yaml +5 -0
  29. package/providers/context/actions/configure-code-extraction.yaml +5 -0
  30. package/providers/context/actions/configure-document-capture.yaml +5 -0
  31. package/providers/context/actions/configure-package-output.yaml +5 -0
  32. package/providers/context/actions/configure-prose-lifecycle.yaml +5 -0
  33. package/providers/context/actions/ensure-repository-sources.yaml +5 -0
  34. package/providers/context/actions/extract-next.yaml +5 -0
  35. package/providers/context/actions/inspect-document-classification.yaml +5 -0
  36. package/providers/context/actions/inspect-review.yaml +5 -0
  37. package/providers/context/actions/inspect-structure.yaml +5 -0
  38. package/providers/context/actions/maintain-evidence.yaml +6 -0
  39. package/providers/context/actions/materialize-context-view.yaml +8 -0
  40. package/providers/context/actions/register-source-batch.yaml +7 -0
  41. package/providers/context/actions/repair-project-entry.yaml +5 -0
  42. package/providers/context/actions/repair-verification.yaml +5 -0
  43. package/providers/context/actions/repair-workspace-state.yaml +5 -0
  44. package/providers/context/codes.yaml +40 -0
  45. package/providers/context/graphs/workspace.yaml +494 -0
  46. package/providers/context/manifest.json +637 -0
  47. package/providers/context/provider.yaml +12 -0
  48. package/providers/context/resources/diagnostics/projection-stale.md +13 -0
  49. package/providers/context/resources/diagnostics/verification.md +21 -0
  50. package/providers/context/resources/diagnostics/workspace-state.md +27 -0
  51. package/providers/context/resources/dialogue/code-extraction.md +34 -0
  52. package/providers/context/resources/dialogue/document-capture.md +29 -0
  53. package/providers/context/resources/dialogue/document-classification.md +33 -0
  54. package/providers/context/resources/dialogue/evidence-maintenance.md +26 -0
  55. package/providers/context/resources/dialogue/human-gates.md +34 -0
  56. package/providers/context/resources/dialogue/knowledge-review.md +27 -0
  57. package/providers/context/resources/dialogue/package-output.md +30 -0
  58. package/providers/context/resources/dialogue/source-boundary.md +29 -0
  59. package/providers/context/resources/dialogue/structure-confirmation.md +44 -0
  60. package/providers/context/resources/manuals/guides/package-outputs.md +259 -0
  61. package/providers/context/resources/manuals/reference/package-templates.md +378 -0
  62. package/providers/context/resources/manuals/reference/project-api.md +789 -0
  63. package/providers/context/resources/manuals/reference/template-variables.md +248 -0
  64. package/providers/context/resources/procedures/close-and-build.md +21 -0
  65. package/providers/context/resources/procedures/code-extraction.md +50 -0
  66. package/providers/context/resources/procedures/document-capture.md +45 -0
  67. package/providers/context/resources/procedures/document-classification.md +22 -0
  68. package/providers/context/resources/procedures/evidence-maintenance.md +20 -0
  69. package/providers/context/resources/procedures/knowledge-review.md +24 -0
  70. package/providers/context/resources/procedures/package-output.md +37 -0
  71. package/providers/context/resources/procedures/project-configuration.md +21 -0
  72. package/providers/context/resources/procedures/prose-align.md +68 -0
  73. package/providers/context/resources/procedures/prose-compile.md +23 -0
  74. package/providers/context/resources/procedures/source-boundary.md +48 -0
  75. package/{plugins/codex/skills/init/references/internal-procedures/skill-source-scope/references/capture-source.md → providers/context/resources/procedures/source-capture-detailed.md} +41 -19
  76. package/providers/context/resources/procedures/verify-and-repair.md +19 -0
  77. package/{plugins/claude/skills/skill-prose-align/references/internal-procedures/structure-planning/references → providers/context/resources/semantic/align}/candidate-resolution.md +17 -2
  78. package/{plugins/claude/skills/skill-prose-align/references/internal-procedures/structure-planning/references → providers/context/resources/semantic/align}/density-profile.md +11 -0
  79. package/{plugins/codex/skills/init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references → providers/context/resources/semantic/align}/gates.md +13 -0
  80. package/{plugins/cursor/skills/skill-prose-align/references/internal-procedures → providers/context/resources/semantic/align}/structure-planning.md +62 -12
  81. package/providers/context/resources/semantic/compile/index.md +31 -0
  82. package/providers/context/resources/views/package-current.yaml +6 -0
  83. package/providers/context/resources/views/review-current.yaml +6 -0
  84. package/providers/context/resources/views/source-current.yaml +6 -0
  85. package/providers/context/resources/views/structure-current.yaml +6 -0
  86. package/providers/context/resources/views/verification-current.yaml +6 -0
  87. package/providers/context/resources/views/workspace-current.yaml +6 -0
  88. package/providers/context/schemas/evidence-maintenance-input.schema.json +30 -0
  89. package/providers/context/schemas/prose-structure-batch.schema.json +35 -0
  90. package/providers/context/schemas/source-batch-input.schema.json +189 -0
  91. package/providers/context/scripts/render-context-view.mjs +21 -0
  92. package/plugins/claude/skills/skill-continue-workflow/SKILL.md +0 -235
  93. package/plugins/claude/skills/skill-init-workspace/SKILL.md +0 -74
  94. package/plugins/claude/skills/skill-package-output/SKILL.md +0 -180
  95. package/plugins/claude/skills/skill-prose-align/SKILL.md +0 -322
  96. package/plugins/claude/skills/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +0 -263
  97. package/plugins/claude/skills/skill-prose-align/references/internal-procedures/structure-planning.md +0 -282
  98. package/plugins/claude/skills/skill-prose-compile/SKILL.md +0 -287
  99. package/plugins/claude/skills/skill-prose-compile/references/internal-procedures/close-gate.md +0 -132
  100. package/plugins/claude/skills/skill-prose-compile/references/internal-procedures/compile-actions/references/action-domain-gates.md +0 -52
  101. package/plugins/claude/skills/skill-prose-compile/references/internal-procedures/compile-actions/references/notes.md +0 -48
  102. package/plugins/claude/skills/skill-prose-compile/references/internal-procedures/compile-actions/references/refresh-and-update.md +0 -85
  103. package/plugins/claude/skills/skill-prose-compile/references/internal-procedures/compile-actions/references/structural-challenges.md +0 -73
  104. package/plugins/claude/skills/skill-prose-compile/references/internal-procedures/compile-actions.md +0 -413
  105. package/plugins/claude/skills/skill-prose-compile/references/internal-procedures/compile-judgment.md +0 -123
  106. package/plugins/claude/skills/skill-prose-compile/references/internal-procedures/semantic-judgment/references/disposition-semantics.md +0 -81
  107. package/plugins/claude/skills/skill-prose-compile/references/internal-procedures/semantic-judgment/references/leakage-and-ownership.md +0 -55
  108. package/plugins/claude/skills/skill-prose-compile/references/internal-procedures/semantic-judgment/references/scope-review-and-omit.md +0 -93
  109. package/plugins/claude/skills/skill-prose-compile/references/internal-procedures/semantic-judgment/references/temporal-and-evidence.md +0 -79
  110. package/plugins/claude/skills/skill-prose-compile/references/internal-procedures/semantic-judgment/references/user-confirmation.md +0 -111
  111. package/plugins/claude/skills/skill-prose-compile/references/internal-procedures/semantic-judgment.md +0 -194
  112. package/plugins/claude/skills/skill-review-gate/SKILL.md +0 -138
  113. package/plugins/claude/skills/skill-source-scope/SKILL.md +0 -525
  114. package/plugins/claude/skills/skill-source-scope/references/capture-source.md +0 -201
  115. package/plugins/codex/skills/continue/references/internal-procedures/skill-continue-workflow.md +0 -235
  116. package/plugins/codex/skills/continue/references/internal-procedures/skill-init-workspace.md +0 -74
  117. package/plugins/codex/skills/continue/references/internal-procedures/skill-package-output.md +0 -180
  118. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/candidate-resolution.md +0 -91
  119. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/density-profile.md +0 -30
  120. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +0 -263
  121. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +0 -282
  122. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-align.md +0 -322
  123. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/close-gate.md +0 -132
  124. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/action-domain-gates.md +0 -52
  125. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/notes.md +0 -48
  126. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/refresh-and-update.md +0 -85
  127. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/structural-challenges.md +0 -73
  128. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions.md +0 -413
  129. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-judgment.md +0 -123
  130. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/disposition-semantics.md +0 -81
  131. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/leakage-and-ownership.md +0 -55
  132. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/scope-review-and-omit.md +0 -93
  133. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/temporal-and-evidence.md +0 -79
  134. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/user-confirmation.md +0 -111
  135. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment.md +0 -194
  136. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile.md +0 -287
  137. package/plugins/codex/skills/continue/references/internal-procedures/skill-review-gate.md +0 -138
  138. package/plugins/codex/skills/continue/references/internal-procedures/skill-source-scope/references/capture-source.md +0 -201
  139. package/plugins/codex/skills/continue/references/internal-procedures/skill-source-scope.md +0 -525
  140. package/plugins/codex/skills/init/references/internal-procedures/skill-continue-workflow.md +0 -235
  141. package/plugins/codex/skills/init/references/internal-procedures/skill-init-workspace.md +0 -74
  142. package/plugins/codex/skills/init/references/internal-procedures/skill-package-output.md +0 -180
  143. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/candidate-resolution.md +0 -91
  144. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/density-profile.md +0 -30
  145. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +0 -282
  146. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-align.md +0 -322
  147. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile/references/internal-procedures/close-gate.md +0 -132
  148. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/action-domain-gates.md +0 -52
  149. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/notes.md +0 -48
  150. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/refresh-and-update.md +0 -85
  151. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/structural-challenges.md +0 -73
  152. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions.md +0 -413
  153. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-judgment.md +0 -123
  154. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/disposition-semantics.md +0 -81
  155. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/leakage-and-ownership.md +0 -55
  156. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/scope-review-and-omit.md +0 -93
  157. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/temporal-and-evidence.md +0 -79
  158. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/user-confirmation.md +0 -111
  159. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment.md +0 -194
  160. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile.md +0 -287
  161. package/plugins/codex/skills/init/references/internal-procedures/skill-review-gate.md +0 -138
  162. package/plugins/codex/skills/init/references/internal-procedures/skill-source-scope.md +0 -525
  163. package/plugins/cursor/skills/skill-continue-workflow/SKILL.md +0 -235
  164. package/plugins/cursor/skills/skill-init-workspace/SKILL.md +0 -74
  165. package/plugins/cursor/skills/skill-package-output/SKILL.md +0 -180
  166. package/plugins/cursor/skills/skill-prose-align/SKILL.md +0 -322
  167. package/plugins/cursor/skills/skill-prose-align/references/internal-procedures/structure-planning/references/candidate-resolution.md +0 -91
  168. package/plugins/cursor/skills/skill-prose-align/references/internal-procedures/structure-planning/references/density-profile.md +0 -30
  169. package/plugins/cursor/skills/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +0 -263
  170. package/plugins/cursor/skills/skill-prose-compile/SKILL.md +0 -287
  171. package/plugins/cursor/skills/skill-prose-compile/references/internal-procedures/close-gate.md +0 -132
  172. package/plugins/cursor/skills/skill-prose-compile/references/internal-procedures/compile-actions/references/action-domain-gates.md +0 -52
  173. package/plugins/cursor/skills/skill-prose-compile/references/internal-procedures/compile-actions/references/notes.md +0 -48
  174. package/plugins/cursor/skills/skill-prose-compile/references/internal-procedures/compile-actions/references/refresh-and-update.md +0 -85
  175. package/plugins/cursor/skills/skill-prose-compile/references/internal-procedures/compile-actions/references/structural-challenges.md +0 -73
  176. package/plugins/cursor/skills/skill-prose-compile/references/internal-procedures/compile-actions.md +0 -413
  177. package/plugins/cursor/skills/skill-prose-compile/references/internal-procedures/compile-judgment.md +0 -123
  178. package/plugins/cursor/skills/skill-prose-compile/references/internal-procedures/semantic-judgment/references/disposition-semantics.md +0 -81
  179. package/plugins/cursor/skills/skill-prose-compile/references/internal-procedures/semantic-judgment/references/leakage-and-ownership.md +0 -55
  180. package/plugins/cursor/skills/skill-prose-compile/references/internal-procedures/semantic-judgment/references/scope-review-and-omit.md +0 -93
  181. package/plugins/cursor/skills/skill-prose-compile/references/internal-procedures/semantic-judgment/references/temporal-and-evidence.md +0 -79
  182. package/plugins/cursor/skills/skill-prose-compile/references/internal-procedures/semantic-judgment/references/user-confirmation.md +0 -111
  183. package/plugins/cursor/skills/skill-prose-compile/references/internal-procedures/semantic-judgment.md +0 -194
  184. package/plugins/cursor/skills/skill-review-gate/SKILL.md +0 -138
  185. package/plugins/cursor/skills/skill-source-scope/SKILL.md +0 -525
  186. package/plugins/cursor/skills/skill-source-scope/references/capture-source.md +0 -201
  187. package/plugins/skills/context-continue/references/internal-procedures/skill-continue-workflow.md +0 -235
  188. package/plugins/skills/context-continue/references/internal-procedures/skill-init-workspace.md +0 -74
  189. package/plugins/skills/context-continue/references/internal-procedures/skill-package-output.md +0 -180
  190. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/candidate-resolution.md +0 -91
  191. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/density-profile.md +0 -30
  192. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +0 -263
  193. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +0 -282
  194. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-align.md +0 -322
  195. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/close-gate.md +0 -132
  196. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/action-domain-gates.md +0 -52
  197. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/notes.md +0 -48
  198. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/refresh-and-update.md +0 -85
  199. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/structural-challenges.md +0 -73
  200. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions.md +0 -413
  201. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-judgment.md +0 -123
  202. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/disposition-semantics.md +0 -81
  203. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/leakage-and-ownership.md +0 -55
  204. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/scope-review-and-omit.md +0 -93
  205. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/temporal-and-evidence.md +0 -79
  206. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/user-confirmation.md +0 -111
  207. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment.md +0 -194
  208. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile.md +0 -287
  209. package/plugins/skills/context-continue/references/internal-procedures/skill-review-gate.md +0 -138
  210. package/plugins/skills/context-continue/references/internal-procedures/skill-source-scope/references/capture-source.md +0 -201
  211. package/plugins/skills/context-continue/references/internal-procedures/skill-source-scope.md +0 -525
  212. package/plugins/skills/context-init/references/internal-procedures/skill-continue-workflow.md +0 -235
  213. package/plugins/skills/context-init/references/internal-procedures/skill-init-workspace.md +0 -74
  214. package/plugins/skills/context-init/references/internal-procedures/skill-package-output.md +0 -180
  215. package/plugins/skills/context-init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/candidate-resolution.md +0 -91
  216. package/plugins/skills/context-init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/density-profile.md +0 -30
  217. package/plugins/skills/context-init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +0 -263
  218. package/plugins/skills/context-init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +0 -282
  219. package/plugins/skills/context-init/references/internal-procedures/skill-prose-align.md +0 -322
  220. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile/references/internal-procedures/close-gate.md +0 -132
  221. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/action-domain-gates.md +0 -52
  222. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/notes.md +0 -48
  223. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/refresh-and-update.md +0 -85
  224. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions/references/structural-challenges.md +0 -73
  225. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-actions.md +0 -413
  226. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile/references/internal-procedures/compile-judgment.md +0 -123
  227. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/disposition-semantics.md +0 -81
  228. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/leakage-and-ownership.md +0 -55
  229. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/scope-review-and-omit.md +0 -93
  230. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/temporal-and-evidence.md +0 -79
  231. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment/references/user-confirmation.md +0 -111
  232. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile/references/internal-procedures/semantic-judgment.md +0 -194
  233. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile.md +0 -287
  234. package/plugins/skills/context-init/references/internal-procedures/skill-review-gate.md +0 -138
  235. package/plugins/skills/context-init/references/internal-procedures/skill-source-scope/references/capture-source.md +0 -201
  236. package/plugins/skills/context-init/references/internal-procedures/skill-source-scope.md +0 -525
@@ -0,0 +1,789 @@
1
+ ---
2
+ id: context.sdk.project-api
3
+ kind: procedure
4
+ mediaType: text/markdown
5
+ ---
6
+
7
+ # Project API
8
+
9
+ Import from `@c4a/context` in `src/index.ts`.
10
+
11
+ ## `defineProject`
12
+
13
+ ```ts
14
+ import { defineProject } from "@c4a/context";
15
+
16
+ export default defineProject({
17
+ sources: [],
18
+ phases: [],
19
+ packages: [],
20
+ });
21
+ ```
22
+
23
+ The project file is executable TypeScript, but the preferred style is a small
24
+ declaration list. Put heavy logic in imported transform files.
25
+
26
+ ## Sources
27
+
28
+ A source is a stable knowledge boundary, not only a display label. Repo, file,
29
+ and Lark sources use a date batch plus a concrete module name; multiple code or
30
+ document modules may share the date. The flattened selector `YYYYMMDD/module`
31
+ is the source identity used by phases, snapshot paths, and source refs.
32
+ Codegraph NodeRef/ViewRef and knowledge paths use the stable module name without
33
+ the date:
34
+
35
+ ```text
36
+ knowledge/<collection>/<slug>.md
37
+ knowledge/<collection>/<containment>/<slug>.md # only for an intentional hierarchy
38
+ knowledge/codegraph/<module>/symbol/<slug>.md
39
+ repo:<date>/<module>#symbol:...
40
+ file:<date>/<module>/<document>#span:...
41
+ lark:<date>/<module>/<document>#span:...
42
+ capture:file:<date>/<module>
43
+ align:lark:<date>/<module>:architecture
44
+ dist/<source-name>-kb/...
45
+ ```
46
+
47
+ Choose the module boundary before extraction. In a monorepo, register each
48
+ confirmed package/subdirectory under the same date batch. A repo root that
49
+ resolves to multiple modules is for inspection; it is not an extraction unit.
50
+ Approved codegraph paths use the stable module name; the date remains only in
51
+ source selectors, phase ids, and evidence refs:
52
+
53
+ ```text
54
+ knowledge/codegraph/module-a/...
55
+ knowledge/codegraph/module-b/...
56
+ ```
57
+
58
+ For prose Views, provide a stable filename `slug` and omit `path`; the CLI
59
+ derives the path. Omit `containment` when the page is an independent collection
60
+ entry, producing `knowledge/<collection>/<slug>.md`. Set `containment` only
61
+ when the approved structure intentionally places the page under a parent path;
62
+ it is not a required source/module wrapper.
63
+
64
+ The registry stores this as one date entry containing several `modules` entries,
65
+ and materializes each module at `sources/repo/<date>/<module>`.
66
+ Repo module names are project-wide codegraph identities and therefore cannot be
67
+ reused under another date batch. Refresh an existing module through its original
68
+ date/module selector.
69
+ When a repo module and the Context workspace share the same Git root, the CLI
70
+ normalizes even an absolute `--local` input into a path relative to the
71
+ workspace and stores the package directory as `subpath`. Materialized repo
72
+ links always use relative symlink targets. This keeps the registry and links
73
+ valid when the whole checkout moves. Cross-repository absolute checkout roots
74
+ remain absolute because no shared movable root can be assumed.
75
+ The date entry must be a valid calendar date in `YYYYMMDD` form. Use
76
+ `context source ensure <date>` or `context source inspect <date>` for the whole
77
+ batch, and `<date>/<module>` when targeting one module.
78
+
79
+ ```yaml
80
+ sources:
81
+ - name: "20260712"
82
+ modules:
83
+ - name: module-a
84
+ local: ../monorepo
85
+ subpath: packages/module-a
86
+ git:
87
+ remote: https://git.example.com/product/monorepo.git
88
+ ref: <full-commit-sha>
89
+ - name: module-b
90
+ local: ../monorepo
91
+ subpath: packages/module-b
92
+ git:
93
+ remote: https://git.example.com/product/monorepo.git
94
+ ref: <full-commit-sha>
95
+ ```
96
+
97
+ File and Lark registries use the same outer shape. Their modules hold local
98
+ document boundaries or remote document identities:
99
+
100
+ ```yaml
101
+ sources:
102
+ - name: "20260712"
103
+ modules:
104
+ - name: local-manual
105
+ local: ../manual
106
+ - name: api-guide
107
+ local: ../api-guide
108
+ ```
109
+
110
+ ### Batch source registration
111
+
112
+ Use one command when a user confirms several source modules together:
113
+
114
+ ```bash
115
+ context source add batch [YYYYMMDD] --input <sources.yaml|json|-> --format json
116
+ ```
117
+
118
+ The payload is a non-empty `sources` array. Every item requires `type`. Repo
119
+ also requires `module` and accepts `local`/`remote`/`ref`. File requires `local`
120
+ and accepts `include`; Lark accepts exactly one of `url`, `docToken`, or
121
+ `wikiToken` plus optional `title`. File/Lark `module` is optional and is derived
122
+ with the same lowercase path-safe rule as the single-source commands. Resolved
123
+ module identities must be unique across the batch.
124
+
125
+ Source mutations share a project write lock, and every registry file is
126
+ replaced atomically. Never run separate `source add` processes in parallel. A
127
+ batch executes items in order; if a runtime item fails, its error lists the
128
+ completed items and the same payload may be rerun idempotently.
129
+
130
+ ```yaml
131
+ sources:
132
+ - name: "20260712"
133
+ modules:
134
+ - name: user-manual
135
+ url: https://example.larksuite.com/wiki/example-a
136
+ - name: migration-guide
137
+ url: https://example.larksuite.com/wiki/example-b
138
+ ```
139
+
140
+ ### `source(name)`
141
+
142
+ Reference one registered source by name. The reference is type-neutral in
143
+ project code; each phase resolves it through the registry and checks whether it
144
+ is a repo, file, or lark source:
145
+
146
+ ```ts
147
+ import { source } from "@c4a/context";
148
+
149
+ const productDocs = source("product-docs");
150
+ ```
151
+
152
+ ### `source(namespace, module)`
153
+
154
+ Reference one registered repo module. Use the date batch and module name
155
+ returned by `context source add repo`:
156
+
157
+ ```ts
158
+ const moduleA = source("20260712", "module-a");
159
+ const moduleB = source("20260712", "module-b");
160
+ ```
161
+
162
+ These references resolve to `20260712/module-a` and `20260712/module-b`;
163
+ extraction and verification remain independent.
164
+
165
+ ### `source(namespace, module, { type })`
166
+
167
+ Reference one file or Lark module under a date batch:
168
+
169
+ ```ts
170
+ const localManual = source("20260712", "local-manual", { type: "file" });
171
+ const userManual = source("20260712", "user-manual", { type: "lark" });
172
+ ```
173
+
174
+ These references produce module-scoped phase ids and manifest entries without
175
+ treating the date as one document identity. Captured document files remain
176
+ siblings under `sources/file|lark/<date>/` and share the date-level
177
+ `manifest.json`; the logical `date/module` identity does not create another
178
+ directory level.
179
+
180
+ For a confirmed multi-document request, declare one capture phase per module.
181
+ While any module is uncaptured, `context status --format json` selects either
182
+ the `route.capture.configuration-required` Route with
183
+ `workflow.current.configuration`, or the `route.capture.pending-target` Route
184
+ with the next declared command in `workflow.current.commands`.
185
+
186
+ Each command item declares its effect and availability. The current route's
187
+ `gate` identifies the decision and authority boundary. Write commands are bound
188
+ to the workflow revision; after one succeeds, rerun status instead of reusing
189
+ the old command. An external command also declares
190
+ `execution.target: agent-host`; execute it as a top-level Agent-host action so
191
+ network and credential-store access are not lost inside a restricted child
192
+ sandbox.
193
+
194
+ ### `allSources("repo")`
195
+
196
+ Reference all repo sources as one collection:
197
+
198
+ ```ts
199
+ import { allSources } from "@c4a/context";
200
+
201
+ const repoSources = allSources("repo");
202
+ ```
203
+
204
+ Use `allSources("repo")` only when the project should list every registered
205
+ repo module. Prefer a specific `source("date", "module")` for extraction phases.
206
+
207
+ ## Phases
208
+
209
+ Phases declare reads and writes. The runtime can inspect them, dry-run them, and
210
+ record per-phase logs.
211
+
212
+ The API exposes the current declared workflow only. Declare file/lark sources,
213
+ capture phases, prose structure gates, source-bound compile phases, code
214
+ extraction phases, review gates, close/build, and packages explicitly. The CLI
215
+ then routes work through `context status`, `context run <phase-id>`, `context
216
+ review html/apply`, `context close`, `context verify`, and `context build`.
217
+
218
+ ### Status declaration coverage
219
+
220
+ `context status --format json --view full` includes a `declarationGraph` and
221
+ `configurationGaps` for document workflows. Each row reports capture, align,
222
+ compile, and Review coverage for a canonical source plus collection. Gaps are
223
+ non-blocking before structure confirmation. Once a structure is confirmed,
224
+ compile routing is exact: phase selection uses canonical source plus collection,
225
+ and candidate progress remains bound to the current `structure_digest`. A
226
+ compile phase from another collection is never used as fallback.
227
+
228
+ Captured align targets that do not yet have an active confirmed structure are
229
+ reported in `pendingStructureTargets`. They remain unfinished even when the
230
+ currently active structures have been closed, verified, and built. Missing
231
+ compile or Review declarations route to `needs-prose-configuration`; once the
232
+ declarations are complete, status returns the exact align investigation command
233
+ for the next target. A built package does not freeze the workspace or require a
234
+ new workspace for later sources.
235
+
236
+ `context status --format json` defaults to the compact workflow route, target,
237
+ progress, counts, and aggregated diagnostics. Use `--view full` only when
238
+ source, phase, package, and lifecycle inventories are needed for debugging.
239
+
240
+ ### Current-conversation managed execution
241
+
242
+ `context status --managed --format json` exposes
243
+ `executionMode: { mode: "managed", scope: "current-conversation" }` and resolves
244
+ eligible human gates into immediate commands. The flag is deliberately absent
245
+ from `defineProject`: callers start each workflow evaluation loop with managed
246
+ status, then execute the returned revision-bound command unchanged. Returned
247
+ commands carry a compact current-conversation marker instead of repeating every
248
+ authority. A later process or conversation gets ordinary human-gated behavior
249
+ by default.
250
+
251
+ Managed Review is atomic and scope-validated:
252
+
253
+ ```bash
254
+ context review approve-all <collection> --managed --format json
255
+ context review approve-all --all --managed --format json
256
+ ```
257
+
258
+ The default JSON result reports counts and change totals without listing every
259
+ candidate id or materialized path. Add `--verbose` only when debugging requires
260
+ the complete candidate and page details.
261
+
262
+ Managed structure confirmation and Review use only the revision-bound commands
263
+ returned by `workflow.current`. Source boundaries and unread source bodies,
264
+ external operations, payload validation, deterministic close, and verification
265
+ errors are never bypassed.
266
+
267
+ For consecutive mechanical routes, the Agent may run:
268
+
269
+ ```bash
270
+ context run --managed --until blocked-or-complete --format json
271
+ ```
272
+
273
+ This is a bounded host loop over the same revisioned routes. It stops before
274
+ read-only interpretation, project configuration, unresolved authority,
275
+ diagnostics, or a non-unique command plan; it does not add another workflow
276
+ entry or make semantic decisions.
277
+
278
+ ### `captureFile`
279
+
280
+ Capture a registered file source into a committed normalized document snapshot.
281
+ Default file capture treats `.md` files as document bodies. For MDX
282
+ documentation sites that use `_meta.json` route metadata, declare the processor
283
+ in `src/index.ts`:
284
+
285
+ ```ts
286
+ captureFile({ source: docs, processor: mdxJsonDocs() });
287
+ ```
288
+
289
+ With that processor, `.md` and `.mdx` are document bodies. Included
290
+ `_meta.json` files are captured as route metadata assets, surfaced in
291
+ `read-plan` / `source-index`, and mechanically projected into
292
+ `__context_route_metadata.md` so route facts can be cited as evidence. The route
293
+ projection records the canonical extensionless route form instead of treating a
294
+ local `.html` URL as the source of truth.
295
+
296
+ MDX component text is extracted separately: string props such as `title`,
297
+ `label`, `description`, `href`, `to`, and component children are projected into
298
+ `__context_mdx_component_text.md` as generated evidence. The original `.mdx`
299
+ file remains in the snapshot unchanged. If a documentation page renders body
300
+ text only at runtime from application code or remote data, configure that
301
+ documentation site as an explicit source boundary instead of hand-writing route
302
+ or body facts.
303
+
304
+ ```ts
305
+ captureFile({ source: docs });
306
+ ```
307
+
308
+ Phase id:
309
+
310
+ ```text
311
+ capture:file:<source-name>
312
+ ```
313
+
314
+ Register the source first with
315
+ `context source add file [YYYYMMDD] --module <module> --local <path>`.
316
+ The first registration requires `--local`; the registry may later keep `local`
317
+ only as a refresh hint while committed snapshots remain verifiable. Multiple
318
+ file modules may share one date. When `--module` is omitted, the CLI derives it
319
+ from the local file or directory name.
320
+
321
+ ### `captureLark`
322
+
323
+ Capture a registered Lark / Feishu document source into a committed normalized
324
+ Markdown snapshot:
325
+
326
+ ```ts
327
+ captureLark({ source: handbook });
328
+ ```
329
+
330
+ Phase id:
331
+
332
+ ```text
333
+ capture:lark:<source-name>
334
+ ```
335
+
336
+ Register each source with
337
+ `context source add lark [YYYYMMDD] --module <module>` and exactly one identity
338
+ flag: `--url`, `--doc-token`, or `--wiki-token`. Multiple documents may share
339
+ one date batch; when `--module` is omitted, the CLI derives an opaque,
340
+ credential-safe module id. Capture reads the
341
+ remote document through the CLI runner as structured Docx XML. Context keeps a
342
+ redacted XML audit asset, projects supported blocks deterministically into
343
+ readable Markdown, and registers external resources such as document citations,
344
+ images, video, whiteboards, and Base references in the snapshot manifest even
345
+ when their binary content is not downloaded. The projection does not infer or
346
+ summarize document meaning. Its fidelity report closes discovered blocks
347
+ against converted and intentionally skipped blocks and reports evidence
348
+ completeness separately from Markdown projection quality. Unknown non-empty XML
349
+ blocks receive a generic, auditable, non-interactive projection and do not block
350
+ downstream work. Missing source content or unresolved external-resource identity
351
+ remains an evidence error and prevents downstream Review.
352
+ Snapshot files live under `sources/lark/<date>/` as sibling document files
353
+ tracked by one date-level `manifest.json`. Access credentials and transient
354
+ signed media URLs are not written into the workspace.
355
+
356
+ Use a typed document reference in project declarations:
357
+
358
+ ```ts
359
+ const handbook = source("20260712", "user-manual", { type: "lark" });
360
+ const localDocs = source("20260712", "local-manual", { type: "file" });
361
+ ```
362
+
363
+ ### `alignProse`
364
+
365
+ Open the prose structure gate for document evidence:
366
+
367
+ ```ts
368
+ alignProse({
369
+ source: docs,
370
+ collection: "architecture",
371
+ });
372
+ ```
373
+
374
+ `collection` is an internal knowledge classification, not a package directory.
375
+ Package build maps `codegraph`/`business`/`product` to `wikis/`,
376
+ `architecture`/`sop`/`faq`/`decision`/`incident` to `guides/`,
377
+ `standards`/`test` to `rules/`, and `feats` to `feats/`. The complete output
378
+ contract is documented in [Package Outputs](../guides/package-outputs.md).
379
+
380
+ When `source("name")` is type-neutral, the SDK may declare
381
+ `align:source:<source-name>:architecture`; the CLI resolves it to
382
+ `align:file:<source-name>:architecture` or `align:lark:<source-name>:architecture` after
383
+ reading the registry.
384
+
385
+ Align is a gated workflow. It produces and validates a structure draft, not
386
+ final approved body:
387
+
388
+ ```bash
389
+ context run align:file:<source-name>:architecture --view read-plan --format json
390
+ context run align:file:<source-name>:architecture --view source-index --compact --format json
391
+ context run align:file:<source-name>:architecture --view span-detail --span <source-ref> --format json
392
+ context run align:file:<source-name>:architecture --view span-text --span <source-ref> --format json
393
+ context run align:file:<source-name>:architecture --view existing-knowledge --query <title-or-stable-ref> --format json
394
+ context run align:file:<source-name>:architecture --view schema --format json
395
+ context run align:file:<source-name>:architecture --view semantic-rules --format json
396
+ context run align:file:<source-name>:architecture --validate --input <structure.yaml> --format json
397
+ context run align:file:<source-name>:architecture --view diagnostics --input <structure.yaml> --format json
398
+ context run align:file:<source-name>:architecture --view structure-summary --input <structure.yaml> --format json
399
+ context run align:file:<source-name>:architecture --stage --input <structure.yaml> --format json
400
+ ```
401
+
402
+ When `workflow.current.batch` is present, several independent document slots
403
+ can be prepared in one Agent pass and validated or staged through one command:
404
+
405
+ ```yaml
406
+ schema: context.prose.structure-batch.v1
407
+ items:
408
+ - phase_id: align:file:<source-a>:architecture
409
+ input: .tmp/agent-payloads/<source-a>-structure.yaml
410
+ - phase_id: align:file:<source-b>:architecture
411
+ input: .tmp/agent-payloads/<source-b>-structure.yaml
412
+ ```
413
+
414
+ ```bash
415
+ context run --batch-input .tmp/agent-payloads/prose-structure-batch.yaml --validate --format json
416
+ context run --batch-input .tmp/agent-payloads/prose-structure-batch.yaml --stage --managed --format json
417
+ ```
418
+
419
+ Batch preflight validates every payload before writing. Stage writes ready
420
+ slots serially; it does not merge documents or decide their semantic shape.
421
+
422
+ Align results expose a recommended `payload_target.path` under
423
+ `.tmp/agent-payloads/`. Agents should use it for transient structure inputs and
424
+ may remove the file after a successful stage. The CLI continues to accept an
425
+ explicit alternative path; this is an authoring convention, not validation.
426
+
427
+ For the ordinary path, `read-plan` is a complete authoring packet: it includes
428
+ the payload contract, a budgeted canonical source-ref map, exact source-body
429
+ resources, and a direct `--stage` command. Read the bodies, author the payload,
430
+ and run that stage command. Request `source-index` only when the packet reports
431
+ omitted refs, and request `existing-knowledge` only when reusing or checking an
432
+ approved identity. The separate schema and validate views are optional
433
+ diagnostic tools, not required lifecycle steps.
434
+
435
+ `--validate`, `--stage`, and `--confirm` are mutually exclusive operations. An
436
+ `--input` without an operation is rejected unless the selected view explicitly
437
+ consumes that input. Deterministic boundary repairs run internally before the
438
+ result is returned. `self_healed` includes input/output Section counts, the
439
+ number of original Sections split, and structural reason codes. Stage performs validation before writing and returns the
440
+ same diagnostics on failure; in managed mode, a valid stage also confirms the
441
+ structure. Successful standalone validation returns a stage command with the
442
+ same file path. JSON run output keeps `next_action` first;
443
+ schema and full reports stay behind explicit Views, while `--verbose` restores
444
+ the full phase result and repeated contracts. Long diagnostics return a compact
445
+ first page plus an exact diagnostics continuation command.
446
+
447
+ Validation returns `state: ready | repair-required | invalid`. Only `ready`
448
+ sets `valid: true` and may proceed to stage. `error_free: true` with
449
+ `state: repair-required` means no error diagnostic remains, but a declared
450
+ confirmation blocker still requires repair; it is not a successful result.
451
+
452
+ `existing-knowledge` is the authoring-time lookup for approved identities. It
453
+ returns stable NodeRefs, ViewRefs, titles, tags, collections, and section counts
454
+ without exposing workspace storage paths. `--query` performs deterministic
455
+ case-insensitive exact/prefix/substring matching; `--collection`,
456
+ `--node-type`, `--page-size`, and the returned continuation command narrow or
457
+ page the same View. Use it after reading source evidence and before introducing
458
+ a new Node identity. Structure validation remains the final duplicate gate.
459
+
460
+ Align and compile evidence results include `semantic_rules`. Its `required`
461
+ array is the rule subset selected for the current judgment, with a selection
462
+ reason and content digest for each rule. `handle`, `digest`, and
463
+ `rules_version` are stable cache checks: reuse a loaded ruleset only while its
464
+ content remains in the active context and both handle and digest still match.
465
+ After context compaction, resume the paginated `semantic-rules` View for the
466
+ returned required subset; a handle alone does not imply that the rule text is
467
+ still available.
468
+
469
+ Document evidence boundaries are deterministic rather than semantic.
470
+ `source-index` and `chunks` mark Markdown AST blocks with
471
+ `boundary_role: "markdown-ast-block"` and `section_candidate: true`.
472
+ `span-text`/`span-detail` mark each returned page as
473
+ `range_role: "transport-page"` and `section_candidate: false`; pagination line
474
+ ranges are never structure boundaries. Structure validation blocks repeated
475
+ fixed-width line grids that cut through AST blocks and reports sections that
476
+ cross multiple heading paths, without classifying document topics.
477
+
478
+ After capture, the capture phase itself exposes collection-neutral `read-plan`,
479
+ `source-index`, `span-detail`, `span-text`, and other read-only evidence views.
480
+ Status selects `route.document.classification-required` until every captured
481
+ target has an evidence-backed, user-confirmed align declaration. Align then
482
+ adds `schema` and `structure-summary` for structure work. Agents should not
483
+ scan `sources/` or `.tmp` to invent evidence. They may read only the exact
484
+ source-body files selected as required resources by the current Route; those
485
+ files carry stable content digests and must be read in full before a receipt is
486
+ reported. Read all required direct paths, then execute the Route's single
487
+ `resources.after_read.command`; the CLI writes and carries the merged receipt
488
+ set without requiring Agent-authored JSON. That acknowledgement response
489
+ already contains the re-evaluated `workflow.current`, so no additional status
490
+ command is needed.
491
+
492
+ Generated Context Views use the same content-addressed rule. Materialization
493
+ returns a receipt-set path and an exact post-read command. Read the complete
494
+ file, then execute that command; unchanged content remains current across
495
+ workflow revisions, while write and external commands still require the exact
496
+ current revision.
497
+
498
+ Compile `read-plan`, `blockers`, and `diagnostics` Views are workspace-read-only
499
+ and may run concurrently. Compile `--validate`, compile `--stage`, structure
500
+ confirmation, Review apply, and close are serial operations.
501
+
502
+ Structure payloads use `schema_version: "context.structure.v1"` and canonical
503
+ `file:` / `lark:` `#span` source refs. A one-file-to-one-page plan is represented
504
+ as ordinary `nodes[]` and `views[]` in the structure. It does not bypass
505
+ structure confirmation or compile. Continuity applies to each Section, while one View/Page may
506
+ contain multiple independently retrievable continuous Sections. Deterministic
507
+ boundary splitting is applied internally during validate/stage; it is not a
508
+ separate Agent-authored payload or approval step.
509
+
510
+ ### `compileProse`
511
+
512
+ Compile confirmed prose structure into reviewable source-bound draft pages:
513
+
514
+ ```ts
515
+ compileProse({
516
+ source: docs,
517
+ collection: "architecture",
518
+ });
519
+ ```
520
+
521
+ When `source("name")` is type-neutral, the SDK may declare
522
+ `compile:source:<source-name>:architecture`; the CLI resolves it to
523
+ `compile:file:<source-name>:architecture` or `compile:lark:<source-name>:architecture` after
524
+ reading the registry.
525
+
526
+ Phase id:
527
+
528
+ ```text
529
+ compile:file:<source-name>:architecture
530
+ compile:lark:<source-name>:architecture
531
+ ```
532
+
533
+ Compile requires confirmed CLI-managed lifecycle structure. It freezes the
534
+ current structure for the compile round; if the user wants to change nodes,
535
+ section ownership, or relationships, return to the align/structure gate.
536
+
537
+ Common commands:
538
+
539
+ ```bash
540
+ context run compile:file:<source-name>:architecture --view read-plan --format json
541
+ context run compile:file:<source-name>:architecture --validate --format json
542
+ context run compile:file:<source-name>:architecture --stage --format json
543
+ context run compile:file:<source-name>:architecture --view diagnostics --format json
544
+ ```
545
+
546
+ Compile validates the complete confirmed source/collection slot before writing
547
+ any candidate, then materializes the slot atomically. Section bodies are
548
+ source-mirrored from the confirmed spans; the Agent does not create a separate
549
+ compile-actions payload. Each canonical source plus collection remains an
550
+ independent structure slot. When other captured align targets remain pending,
551
+ status routes to those slots before opening one collection-level Review
552
+ payload. `context close` is blocked while a planned View is unprepared, still
553
+ draft, or rejected without a structure revision.
554
+
555
+ Relationships stay in `structure.yaml` typed edges in current output; compile
556
+ does not infer relationships or inject relation markers into verbatim body.
557
+
558
+ ### `extractTs`
559
+
560
+ Extract exported TypeScript / TSX symbols into draft candidates:
561
+
562
+ ```ts
563
+ extractTs({
564
+ source: componentLib,
565
+ collection: "codegraph",
566
+ });
567
+ ```
568
+
569
+ Options:
570
+
571
+ | Field | Meaning |
572
+ |---|---|
573
+ | `source` | `source("date", "module")` for one repo module |
574
+ | `collection` | Code extraction uses `"codegraph"` |
575
+ | `include` | Optional glob list inside the selected source; default is `["src/**/*.{ts,tsx}"]` |
576
+ | `mode` | `"exports"` (default) traces public exports from automatic or configured entries; `"scan"` uses every file matched by `include` as an entry root |
577
+ | `entries` | Optional source-relative entry files for `"exports"` mode. They override `package.json` entry detection and live only in the Context project configuration |
578
+ | `exportedOnly` | Defaults to `true` in `"exports"` mode and `false` in `"scan"` mode |
579
+ | `transform` | Optional markdown transform function or functions |
580
+
581
+ `source` is the only package/module boundary. `include` narrows files inside
582
+ that source; it does not select a second module. Standard packages can omit
583
+ `entries` and use `package.json` `exports`, `main`, or `bin` detection. For a
584
+ non-standard package, configure `entries` in the Context project instead of
585
+ editing the source repository:
586
+
587
+ ```ts
588
+ extractTs({
589
+ source: componentLib,
590
+ collection: "codegraph",
591
+ include: ["src/**/*.ts"],
592
+ entries: ["src/api.ts"],
593
+ });
594
+ ```
595
+
596
+ When the intended knowledge scope is every declaration in the selected files
597
+ rather than a public export graph, use `mode: "scan"`. Scan mode does not accept
598
+ `entries`; `include` supplies its file roots.
599
+
600
+ Entry failures use the stable machine code `NO_ENTRY_DETECTED`. This includes
601
+ `entries: []`, exports mode with no detected/configured entry, and scan mode
602
+ with no files matched by `include`; these cases never succeed silently.
603
+
604
+ TypeScript extraction reads the selected module's `tsconfig.json` or
605
+ `jsconfig.json`. JSONC comments/trailing commas, local or installed `extends`,
606
+ `compilerOptions.baseUrl`, and `compilerOptions.paths` are used for export
607
+ tracing and internal dependency relations, so aliases such as `@/*` resolve to
608
+ their source files.
609
+
610
+ In monorepos, make each package/subdirectory a module boundary. Register the
611
+ chosen package path with `context source add repo [YYYYMMDD] --module <module> --local <package-dir>` and
612
+ reference it with `source("<date>", "<module>")`.
613
+ Do not use `include` to choose a
614
+ package from a larger monorepo source.
615
+
616
+ Use `context source inspect <date>/<module>` to list detected module/package
617
+ boundaries before choosing the source. Use `context run <phase-id> --dry-run
618
+ --format json` to check the resolved modules, file counts, symbol counts, and
619
+ candidate estimate before writing the ignored lifecycle candidate ledger. The dry-run
620
+ preview also includes `knowledgeTree` and `knowledgePathExamples`, which show
621
+ where approved Markdown will land after review apply.
622
+ Its module and total summaries distinguish `discoveredFiles`, `analyzedFiles`,
623
+ `skippedFiles`, `symbols`, and `relations`. Module summaries also expose the
624
+ resolved `entryFiles`, exported/internal symbol counts, and a structural
625
+ `candidateKinds` count. These fields describe extractor output only; the CLI
626
+ does not infer which symbols are meaningful to a particular product or
627
+ audience. Modules with skipped files include the deterministic traversal
628
+ reason, such as files not reachable from exports-mode entries.
629
+
630
+ Phase id shape:
631
+
632
+ ```text
633
+ extract:<source-name-or-repo>:codegraph
634
+ ```
635
+
636
+ Codegraph extraction has two execution policies:
637
+
638
+ - `context run <phase-id>` is the Agent/user default. The first run sends every
639
+ code symbol to Review. Later runs preserve unchanged approved symbols and send
640
+ only `add`, `update`, and `remove` deltas to Review. After every phase result,
641
+ the Agent re-evaluates `context status --format json`; only
642
+ `workflow.current` decides whether Review is now required.
643
+ - `context run <phase-id> --auto-promote` is the explicit CI/CD path. It is valid
644
+ only for `phase.extract.ts` codegraph phases, applies deterministic code deltas
645
+ without Review, refreshes deterministic close when approved knowledge changed,
646
+ then runs project verification. Close or verification errors make the command
647
+ fail; JSON output reports applied/materialized/removed counts plus a `close`
648
+ state of `refreshed`, `current`, or `not-required`. Package build remains a
649
+ separate pipeline step; existing package outputs are reported stale.
650
+
651
+ This policy never auto-promotes architecture, business, decision, test, or
652
+ other semantic knowledge. Agents must not infer a human gate from a phase-local
653
+ result. Human gates and their inspection/resolution Actions are exposed only by
654
+ `workflow.current`.
655
+
656
+ Approved codegraph sections use the local evidence form
657
+ `src-N#symbol:<file>:<symbol>:<kind>@<digest>`. The file segment makes reverse
658
+ lookup exact when multiple files contain the same symbol name, kind, and digest;
659
+ the complete ref remains opaque to agents. New pages keep only top-level
660
+ `candidate_fingerprint` and do not emit `code_origin`.
661
+
662
+ ### `extractCustom`
663
+
664
+ Use a project-owned extractor when code facts cannot be represented by the
665
+ TypeScript symbol extractor, for example a language-specific parser or an
666
+ aggregated repository protocol:
667
+
668
+ ```ts
669
+ extractCustom({
670
+ id: "extract:service:protocol",
671
+ sources: [service],
672
+ collection: "codegraph",
673
+ extract: async ({ projectRoot }) => ({
674
+ candidates: [{
675
+ nodeRef: "service/protocol",
676
+ kind: "protocol",
677
+ visibility: "exported",
678
+ module: "service",
679
+ markdown: renderProtocol(projectRoot),
680
+ evidence: [{
681
+ source: "20260811/service",
682
+ file: "src/protocol.ts",
683
+ symbol: "protocol",
684
+ kind: "variable",
685
+ digest: "0123456789ab",
686
+ }],
687
+ review: {
688
+ title: "Service protocol",
689
+ summary: "Aggregated protocol boundary.",
690
+ signals: ["source-backed"],
691
+ reason: "Review the project-owned extraction.",
692
+ },
693
+ }],
694
+ }),
695
+ });
696
+ ```
697
+
698
+ `sources` is the complete registered repo scope for the phase. Every candidate
699
+ and edge carries structured `evidence`; the CLI validates that evidence against
700
+ the declared sources, creates canonical `source_ref` values, writes the symbol
701
+ index, candidate ledger and Review snapshots atomically, and records a phase
702
+ fingerprint. `context status` therefore treats this phase exactly like another
703
+ pending code extraction target, and Review can verify snapshot freshness
704
+ without a placeholder `extractTs` phase.
705
+
706
+ The extractor returns knowledge semantics (`nodeRef`, rendered Markdown,
707
+ Review summary and source-backed evidence). It must not write `knowledge/`,
708
+ `.tmp/context-runtime/lifecycle/candidates.jsonl`, extraction fingerprints or
709
+ Review snapshots directly. Context owns those files and preserves rejected and
710
+ unchanged-approved decisions across reruns.
711
+
712
+ ### `reviewValidity`
713
+
714
+ Declare the review step for a collection:
715
+
716
+ ```ts
717
+ reviewValidity({ collection: "codegraph" });
718
+ ```
719
+
720
+ Declare one review gate for all current draft collections:
721
+
722
+ ```ts
723
+ reviewValidity({ scope: "all" });
724
+ ```
725
+
726
+ Phase id:
727
+
728
+ ```text
729
+ review:codegraph:validity
730
+ review:all:validity
731
+ ```
732
+
733
+ The review HTML and apply flow are CLI-owned.
734
+
735
+ This phase marks a human review gate when current candidates exist. Agents
736
+ should run `context review html <collection> --open --format json` or `context
737
+ review html --all --open --format json`, confirm the returned `opened` field,
738
+ and wait for the user-copied payload. They should not run the phase as an
739
+ automatic approval step or synthesize a payload themselves.
740
+
741
+ The only batch-wide exception is explicit current-conversation fully managed
742
+ authority. In that mode, follow the `context status --managed` route to
743
+ `context review approve-all ... --managed`; the CLI validates the exact current
744
+ scope before applying one default-approved decision.
745
+
746
+ The gate is batch-scoped: prose waits for every planned View across all active
747
+ structure slots and every declared `pendingStructureTargets` item in the round;
748
+ codegraph waits for every pending extract phase in the confirmed module round.
749
+ Candidate count/hash therefore describes the complete current batch rather than
750
+ one page, source slot, or module. Deterministic close later merges all active
751
+ slots into `knowledge/structure.yaml`, retains only their source, collection,
752
+ and consumed snapshot hash as `source_inputs`, then removes the lifecycle slots.
753
+
754
+ `status.structureBatch` lists unclassified, configuration-required, pending,
755
+ and active structure slots together with the execution policy for the round.
756
+
757
+ If the user explicitly asks for an automated or quick approval/rejection path,
758
+ use the scoped quick commands instead of hand-writing a payload:
759
+
760
+ ```bash
761
+ context review approve <candidate-id> --collection <collection>
762
+ context review reject <candidate-id> --all
763
+ ```
764
+
765
+ These commands still compute the current review scope and apply the same
766
+ candidate-id gate as the copied payload flow. They are not a replacement for the
767
+ default human review gate.
768
+
769
+ ### `customPhase`
770
+
771
+ Use only when the typed factories cannot express a project-specific workflow:
772
+
773
+ ```ts
774
+ const sample = source("20260712", "sample");
775
+
776
+ customPhase("custom:20260712/sample:review", async (ctx) => {
777
+ await ctx.ensureSources({ source: sample });
778
+ await ctx.extract.ts(extractTs({ source: sample, collection: "codegraph" }));
779
+ await ctx.review.html(reviewValidity({ collection: "codegraph" }));
780
+ });
781
+ ```
782
+
783
+ Custom phases are an orchestration escape hatch. Use `extractCustom()` instead
784
+ when project code needs to publish codegraph candidates. The supported runtime
785
+ helpers are:
786
+
787
+ - `ctx.ensureSources(...)` for repo source readiness.
788
+ - `ctx.extract.ts(...)` for declared TypeScript extraction.
789
+ - `ctx.review.html(...)` for the human review HTML gate.