@c4a/context-cli 0.6.1 → 0.6.3

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