octocode-cli 1.2.6 → 1.2.8

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 (303) hide show
  1. package/LICENSE +21 -63
  2. package/README.md +85 -142
  3. package/out/octocode-cli.js +7063 -6934
  4. package/package.json +8 -6
  5. package/skills/README.md +97 -120
  6. package/skills/octocode-code-engineer/.claude/settings.local.json +18 -0
  7. package/skills/octocode-code-engineer/.octocode/rfc/RFC-code-engineer-weakness-fixes.md +255 -0
  8. package/skills/octocode-code-engineer/.plan/VALIDATED_PLAN.md +223 -0
  9. package/skills/octocode-code-engineer/README.md +178 -0
  10. package/skills/octocode-code-engineer/SKILL.md +418 -0
  11. package/skills/octocode-code-engineer/coverage/architecture.ts.html +7828 -0
  12. package/skills/octocode-code-engineer/coverage/ast-helpers.ts.html +211 -0
  13. package/skills/octocode-code-engineer/coverage/ast-search.ts.html +1795 -0
  14. package/skills/octocode-code-engineer/coverage/base.css +224 -0
  15. package/skills/octocode-code-engineer/coverage/block-navigation.js +87 -0
  16. package/skills/octocode-code-engineer/coverage/cache.ts.html +376 -0
  17. package/skills/octocode-code-engineer/coverage/cli.ts.html +982 -0
  18. package/skills/octocode-code-engineer/coverage/clover.xml +3217 -0
  19. package/skills/octocode-code-engineer/coverage/collect-effects.ts.html +664 -0
  20. package/skills/octocode-code-engineer/coverage/collect-input-sources.ts.html +577 -0
  21. package/skills/octocode-code-engineer/coverage/collect-performance.ts.html +331 -0
  22. package/skills/octocode-code-engineer/coverage/collect-prototype-pollution.ts.html +421 -0
  23. package/skills/octocode-code-engineer/coverage/collect-security.ts.html +604 -0
  24. package/skills/octocode-code-engineer/coverage/collect-test-profile.ts.html +589 -0
  25. package/skills/octocode-code-engineer/coverage/coverage-final.json +30 -0
  26. package/skills/octocode-code-engineer/coverage/dependencies.ts.html +997 -0
  27. package/skills/octocode-code-engineer/coverage/dependency-summary.ts.html +688 -0
  28. package/skills/octocode-code-engineer/coverage/discovery.ts.html +322 -0
  29. package/skills/octocode-code-engineer/coverage/favicon.png +0 -0
  30. package/skills/octocode-code-engineer/coverage/graph-analytics.ts.html +1510 -0
  31. package/skills/octocode-code-engineer/coverage/index.html +536 -0
  32. package/skills/octocode-code-engineer/coverage/index.ts.html +826 -0
  33. package/skills/octocode-code-engineer/coverage/metrics.ts.html +553 -0
  34. package/skills/octocode-code-engineer/coverage/pipeline.ts.html +2044 -0
  35. package/skills/octocode-code-engineer/coverage/prettify.css +1 -0
  36. package/skills/octocode-code-engineer/coverage/prettify.js +2 -0
  37. package/skills/octocode-code-engineer/coverage/report-analysis.ts.html +1570 -0
  38. package/skills/octocode-code-engineer/coverage/report-writer.ts.html +1102 -0
  39. package/skills/octocode-code-engineer/coverage/security-detectors.ts.html +1747 -0
  40. package/skills/octocode-code-engineer/coverage/semantic-detectors.ts.html +2152 -0
  41. package/skills/octocode-code-engineer/coverage/semantic.ts.html +1897 -0
  42. package/skills/octocode-code-engineer/coverage/sort-arrow-sprite.png +0 -0
  43. package/skills/octocode-code-engineer/coverage/sorter.js +210 -0
  44. package/skills/octocode-code-engineer/coverage/summary-md.ts.html +1222 -0
  45. package/skills/octocode-code-engineer/coverage/test-quality-detectors.ts.html +1039 -0
  46. package/skills/octocode-code-engineer/coverage/tree-sitter-analyzer.ts.html +955 -0
  47. package/skills/octocode-code-engineer/coverage/ts-analyzer.ts.html +1213 -0
  48. package/skills/octocode-code-engineer/coverage/types.ts.html +2473 -0
  49. package/skills/octocode-code-engineer/coverage/utils.ts.html +820 -0
  50. package/skills/octocode-code-engineer/eslint.config.mjs +54 -0
  51. package/skills/octocode-code-engineer/minify-scripts.mjs +32 -0
  52. package/skills/octocode-code-engineer/package.json +54 -0
  53. package/skills/octocode-code-engineer/references/agent-ast-reading-rfc.md +95 -0
  54. package/skills/octocode-code-engineer/references/architecture-techniques.md +121 -0
  55. package/skills/octocode-code-engineer/references/ast-search.md +210 -0
  56. package/skills/octocode-code-engineer/references/ast-tree-search.md +151 -0
  57. package/skills/octocode-code-engineer/references/cli-reference.md +167 -0
  58. package/skills/octocode-code-engineer/references/concepts.md +107 -0
  59. package/skills/octocode-code-engineer/references/finding-categories.md +128 -0
  60. package/skills/octocode-code-engineer/references/improvement-roadmap.md +304 -0
  61. package/skills/octocode-code-engineer/references/output-files.md +144 -0
  62. package/skills/octocode-code-engineer/references/playbooks.md +204 -0
  63. package/skills/octocode-code-engineer/references/present-results.md +136 -0
  64. package/skills/octocode-code-engineer/references/tool-workflows.md +566 -0
  65. package/skills/octocode-code-engineer/references/validate-investigate.md +225 -0
  66. package/skills/octocode-code-engineer/scripts/analysis/dependencies.js +1 -0
  67. package/skills/octocode-code-engineer/scripts/analysis/dependency-summary.js +1 -0
  68. package/skills/octocode-code-engineer/scripts/analysis/discovery.js +1 -0
  69. package/skills/octocode-code-engineer/scripts/analysis/graph-analytics.js +1 -0
  70. package/skills/octocode-code-engineer/scripts/analysis/semantic.js +1 -0
  71. package/skills/octocode-code-engineer/scripts/ast/helpers.js +1 -0
  72. package/skills/octocode-code-engineer/scripts/ast/metrics.js +1 -0
  73. package/skills/octocode-code-engineer/scripts/ast/search.js +2 -0
  74. package/skills/octocode-code-engineer/scripts/ast/tree-search.js +2 -0
  75. package/skills/octocode-code-engineer/scripts/ast/tree-sitter.js +1 -0
  76. package/skills/octocode-code-engineer/scripts/ast/ts-analyzer.js +1 -0
  77. package/skills/octocode-code-engineer/scripts/collectors/chains.js +1 -0
  78. package/skills/octocode-code-engineer/scripts/collectors/effects.js +1 -0
  79. package/skills/octocode-code-engineer/scripts/collectors/input-sources.js +1 -0
  80. package/skills/octocode-code-engineer/scripts/collectors/performance.js +1 -0
  81. package/skills/octocode-code-engineer/scripts/collectors/prototype-pollution.js +1 -0
  82. package/skills/octocode-code-engineer/scripts/collectors/security.js +1 -0
  83. package/skills/octocode-code-engineer/scripts/collectors/test-profile.js +1 -0
  84. package/skills/octocode-code-engineer/scripts/common/is-direct-run.js +1 -0
  85. package/skills/octocode-code-engineer/scripts/common/utils.js +1 -0
  86. package/skills/octocode-code-engineer/scripts/detectors/code-quality.js +1 -0
  87. package/skills/octocode-code-engineer/scripts/detectors/cohesion.js +1 -0
  88. package/skills/octocode-code-engineer/scripts/detectors/coupling.js +1 -0
  89. package/skills/octocode-code-engineer/scripts/detectors/cycle.js +1 -0
  90. package/skills/octocode-code-engineer/scripts/detectors/dead-code.js +1 -0
  91. package/skills/octocode-code-engineer/scripts/detectors/import-style.js +1 -0
  92. package/skills/octocode-code-engineer/scripts/detectors/index.js +1 -0
  93. package/skills/octocode-code-engineer/scripts/detectors/security.js +1 -0
  94. package/skills/octocode-code-engineer/scripts/detectors/semantic.js +1 -0
  95. package/skills/octocode-code-engineer/scripts/detectors/shared.js +1 -0
  96. package/skills/octocode-code-engineer/scripts/detectors/test-quality.js +1 -0
  97. package/skills/octocode-code-engineer/scripts/index.js +1 -0
  98. package/skills/octocode-code-engineer/scripts/pipeline/cache.js +1 -0
  99. package/skills/octocode-code-engineer/scripts/pipeline/cli.js +1 -0
  100. package/skills/octocode-code-engineer/scripts/pipeline/main.js +2 -0
  101. package/skills/octocode-code-engineer/scripts/reporting/analysis.js +1 -0
  102. package/skills/octocode-code-engineer/scripts/reporting/summary-md.js +1 -0
  103. package/skills/octocode-code-engineer/scripts/reporting/writer.js +1 -0
  104. package/skills/octocode-code-engineer/scripts/types/constants.js +1 -0
  105. package/skills/octocode-code-engineer/scripts/types/index.js +1 -0
  106. package/skills/octocode-code-engineer/scripts/types/interfaces.js +1 -0
  107. package/skills/octocode-code-engineer/src/analysis/dependencies.test.ts +545 -0
  108. package/skills/octocode-code-engineer/src/analysis/dependencies.ts +406 -0
  109. package/skills/octocode-code-engineer/src/analysis/dependency-summary.test.ts +566 -0
  110. package/skills/octocode-code-engineer/src/analysis/dependency-summary.ts +257 -0
  111. package/skills/octocode-code-engineer/src/analysis/discovery.test.ts +420 -0
  112. package/skills/octocode-code-engineer/src/analysis/discovery.ts +87 -0
  113. package/skills/octocode-code-engineer/src/analysis/graph-analytics.test.ts +449 -0
  114. package/skills/octocode-code-engineer/src/analysis/graph-analytics.ts +534 -0
  115. package/skills/octocode-code-engineer/src/analysis/semantic.test.ts +1533 -0
  116. package/skills/octocode-code-engineer/src/analysis/semantic.ts +830 -0
  117. package/skills/octocode-code-engineer/src/ast/helpers.test.ts +185 -0
  118. package/skills/octocode-code-engineer/src/ast/helpers.ts +62 -0
  119. package/skills/octocode-code-engineer/src/ast/metrics.test.ts +304 -0
  120. package/skills/octocode-code-engineer/src/ast/metrics.ts +204 -0
  121. package/skills/octocode-code-engineer/src/ast/search.test.ts +647 -0
  122. package/skills/octocode-code-engineer/src/ast/search.ts +648 -0
  123. package/skills/octocode-code-engineer/src/ast/tree-search.test.ts +199 -0
  124. package/skills/octocode-code-engineer/src/ast/tree-search.ts +392 -0
  125. package/skills/octocode-code-engineer/src/ast/tree-sitter.test.ts +407 -0
  126. package/skills/octocode-code-engineer/src/ast/tree-sitter.ts +402 -0
  127. package/skills/octocode-code-engineer/src/ast/ts-analyzer.test.ts +1864 -0
  128. package/skills/octocode-code-engineer/src/ast/ts-analyzer.ts +509 -0
  129. package/skills/octocode-code-engineer/src/collectors/chains.ts +74 -0
  130. package/skills/octocode-code-engineer/src/collectors/effects.test.ts +490 -0
  131. package/skills/octocode-code-engineer/src/collectors/effects.ts +332 -0
  132. package/skills/octocode-code-engineer/src/collectors/input-sources.test.ts +144 -0
  133. package/skills/octocode-code-engineer/src/collectors/input-sources.ts +196 -0
  134. package/skills/octocode-code-engineer/src/collectors/performance.test.ts +82 -0
  135. package/skills/octocode-code-engineer/src/collectors/performance.ts +141 -0
  136. package/skills/octocode-code-engineer/src/collectors/prototype-pollution.test.ts +55 -0
  137. package/skills/octocode-code-engineer/src/collectors/prototype-pollution.ts +162 -0
  138. package/skills/octocode-code-engineer/src/collectors/security.test.ts +124 -0
  139. package/skills/octocode-code-engineer/src/collectors/security.ts +309 -0
  140. package/skills/octocode-code-engineer/src/collectors/test-profile.test.ts +97 -0
  141. package/skills/octocode-code-engineer/src/collectors/test-profile.ts +269 -0
  142. package/skills/octocode-code-engineer/src/common/is-direct-run.test.ts +32 -0
  143. package/skills/octocode-code-engineer/src/common/is-direct-run.ts +13 -0
  144. package/skills/octocode-code-engineer/src/common/utils.test.ts +463 -0
  145. package/skills/octocode-code-engineer/src/common/utils.ts +304 -0
  146. package/skills/octocode-code-engineer/src/detectors/code-quality.ts +966 -0
  147. package/skills/octocode-code-engineer/src/detectors/cohesion.ts +539 -0
  148. package/skills/octocode-code-engineer/src/detectors/coupling.ts +323 -0
  149. package/skills/octocode-code-engineer/src/detectors/cycle.ts +349 -0
  150. package/skills/octocode-code-engineer/src/detectors/dead-code.ts +320 -0
  151. package/skills/octocode-code-engineer/src/detectors/import-style.ts +376 -0
  152. package/skills/octocode-code-engineer/src/detectors/index.test.ts +3061 -0
  153. package/skills/octocode-code-engineer/src/detectors/index.ts +88 -0
  154. package/skills/octocode-code-engineer/src/detectors/security.test.ts +882 -0
  155. package/skills/octocode-code-engineer/src/detectors/security.ts +821 -0
  156. package/skills/octocode-code-engineer/src/detectors/semantic.ts +758 -0
  157. package/skills/octocode-code-engineer/src/detectors/shared.ts +49 -0
  158. package/skills/octocode-code-engineer/src/detectors/test-quality.test.ts +388 -0
  159. package/skills/octocode-code-engineer/src/detectors/test-quality.ts +367 -0
  160. package/skills/octocode-code-engineer/src/index.test.ts +4425 -0
  161. package/skills/octocode-code-engineer/src/index.ts +403 -0
  162. package/skills/octocode-code-engineer/src/pipeline/cache.test.ts +199 -0
  163. package/skills/octocode-code-engineer/src/pipeline/cache.ts +130 -0
  164. package/skills/octocode-code-engineer/src/pipeline/cli.test.ts +493 -0
  165. package/skills/octocode-code-engineer/src/pipeline/cli.ts +344 -0
  166. package/skills/octocode-code-engineer/src/pipeline/main.test.ts +174 -0
  167. package/skills/octocode-code-engineer/src/pipeline/main.ts +1074 -0
  168. package/skills/octocode-code-engineer/src/pipeline.test.ts +84 -0
  169. package/skills/octocode-code-engineer/src/reporting/analysis.test.ts +782 -0
  170. package/skills/octocode-code-engineer/src/reporting/analysis.ts +688 -0
  171. package/skills/octocode-code-engineer/src/reporting/output-contract.test.ts +463 -0
  172. package/skills/octocode-code-engineer/src/reporting/summary-md.test.ts +421 -0
  173. package/skills/octocode-code-engineer/src/reporting/summary-md.ts +714 -0
  174. package/skills/octocode-code-engineer/src/reporting/writer.ts +430 -0
  175. package/skills/octocode-code-engineer/src/sanity.test.ts +47 -0
  176. package/skills/octocode-code-engineer/src/types/constants.ts +248 -0
  177. package/skills/octocode-code-engineer/src/types/index.ts +80 -0
  178. package/skills/octocode-code-engineer/src/types/interfaces.ts +682 -0
  179. package/skills/octocode-code-engineer/tsconfig.json +17 -0
  180. package/skills/octocode-code-engineer/vitest.config.ts +8 -0
  181. package/skills/octocode-documentation-writer/README.md +113 -0
  182. package/skills/octocode-documentation-writer/SKILL.md +886 -0
  183. package/skills/octocode-documentation-writer/references/agent-discovery-analysis.md +453 -0
  184. package/skills/octocode-documentation-writer/references/agent-documentation-writer.md +255 -0
  185. package/skills/octocode-documentation-writer/references/agent-engineer-questions.md +247 -0
  186. package/skills/octocode-documentation-writer/references/agent-orchestrator.md +370 -0
  187. package/skills/octocode-documentation-writer/references/agent-qa-validator.md +227 -0
  188. package/skills/octocode-documentation-writer/references/agent-researcher.md +250 -0
  189. package/skills/octocode-documentation-writer/schemas/analysis-schema.json +886 -0
  190. package/skills/octocode-documentation-writer/schemas/discovery-tasks.json +96 -0
  191. package/skills/octocode-documentation-writer/schemas/documentation-structure.json +373 -0
  192. package/skills/octocode-documentation-writer/schemas/partial-discovery-schema.json +102 -0
  193. package/skills/octocode-documentation-writer/schemas/partial-research-schema.json +98 -0
  194. package/skills/octocode-documentation-writer/schemas/qa-results-schema.json +113 -0
  195. package/skills/octocode-documentation-writer/schemas/questions-schema.json +228 -0
  196. package/skills/octocode-documentation-writer/schemas/research-schema.json +104 -0
  197. package/skills/octocode-documentation-writer/schemas/state-schema.json +222 -0
  198. package/skills/octocode-documentation-writer/schemas/work-assignments-schema.json +74 -0
  199. package/skills/octocode-plan/SKILL.md +122 -116
  200. package/skills/octocode-prompt-optimizer/SKILL.md +617 -0
  201. package/skills/octocode-pull-request-reviewer/README.md +249 -0
  202. package/skills/octocode-pull-request-reviewer/SKILL.md +479 -0
  203. package/skills/octocode-pull-request-reviewer/references/dependency-check.md +74 -0
  204. package/skills/octocode-pull-request-reviewer/references/domain-reviewers.md +24 -0
  205. package/skills/octocode-pull-request-reviewer/references/execution-lifecycle.md +441 -0
  206. package/skills/octocode-pull-request-reviewer/references/flow-analysis-protocol.md +64 -0
  207. package/skills/octocode-pull-request-reviewer/references/output-template.md +174 -0
  208. package/skills/octocode-pull-request-reviewer/references/parallel-agent-protocol.md +182 -0
  209. package/skills/octocode-pull-request-reviewer/references/review-guidelines.md +26 -0
  210. package/skills/octocode-pull-request-reviewer/references/verification-checklist.md +40 -0
  211. package/skills/octocode-research/.claude/settings.local.json +46 -0
  212. package/skills/octocode-research/.octocode/plan/code-review-fixes/plan.md +312 -0
  213. package/skills/octocode-research/.octocode/plan/code-review-fixes/research.md +212 -0
  214. package/skills/octocode-research/.octocode/plans/NODE_SERVER_START_PLAN.md +755 -0
  215. package/skills/octocode-research/.octocode/research/code-review/research.md +371 -0
  216. package/skills/octocode-research/.octocode/review/IMPROVEMENTS.md +391 -0
  217. package/skills/octocode-research/.octocode/review/REVIEW_PLAN.md +289 -0
  218. package/skills/octocode-research/.octocode/review/REVIEW_REPORT.md +356 -0
  219. package/skills/octocode-research/AGENTS.md +349 -0
  220. package/skills/octocode-research/README.md +494 -0
  221. package/skills/octocode-research/SKILL.md +652 -274
  222. package/skills/octocode-research/docs/API_REFERENCE.md +562 -0
  223. package/skills/octocode-research/docs/ARCHITECTURE.md +554 -0
  224. package/skills/octocode-research/docs/FLOWS.md +577 -0
  225. package/skills/octocode-research/docs/OVERVIEW.md +564 -0
  226. package/skills/octocode-research/docs/SERVER_FLOWS.md +631 -0
  227. package/skills/octocode-research/ecosystem.config.cjs +88 -0
  228. package/skills/octocode-research/eslint.config.mjs +27 -0
  229. package/skills/octocode-research/package.json +84 -0
  230. package/skills/octocode-research/references/GUARDRAILS.md +40 -0
  231. package/skills/octocode-research/references/PARALLEL_AGENT_PROTOCOL.md +178 -0
  232. package/skills/octocode-research/references/roast-prompt.md +149 -0
  233. package/skills/octocode-research/scripts/server-init.d.ts +2 -0
  234. package/skills/octocode-research/scripts/server-init.js +2 -0
  235. package/skills/octocode-research/scripts/server.d.ts +8 -0
  236. package/skills/octocode-research/scripts/server.js +445 -0
  237. package/skills/octocode-research/src/__tests__/integration/circuitBreaker.test.ts +205 -0
  238. package/skills/octocode-research/src/__tests__/integration/routes.test.ts +374 -0
  239. package/skills/octocode-research/src/__tests__/unit/circuitBreaker.test.ts +245 -0
  240. package/skills/octocode-research/src/__tests__/unit/errorHandler.test.ts +183 -0
  241. package/skills/octocode-research/src/__tests__/unit/httpPreprocess.test.ts +157 -0
  242. package/skills/octocode-research/src/__tests__/unit/logger.test.ts +143 -0
  243. package/skills/octocode-research/src/__tests__/unit/queryParser.test.ts +130 -0
  244. package/skills/octocode-research/src/__tests__/unit/responseBuilder.test.ts +469 -0
  245. package/skills/octocode-research/src/__tests__/unit/retry.test.ts +205 -0
  246. package/skills/octocode-research/src/index.ts +186 -0
  247. package/skills/octocode-research/src/mcpCache.ts +49 -0
  248. package/skills/octocode-research/src/middleware/errorHandler.ts +65 -0
  249. package/skills/octocode-research/src/middleware/logger.ts +61 -0
  250. package/skills/octocode-research/src/middleware/queryParser.ts +115 -0
  251. package/skills/octocode-research/src/middleware/readiness.ts +17 -0
  252. package/skills/octocode-research/src/routes/github.ts +197 -0
  253. package/skills/octocode-research/src/routes/local.ts +175 -0
  254. package/skills/octocode-research/src/routes/lsp.ts +177 -0
  255. package/skills/octocode-research/src/routes/package.ts +127 -0
  256. package/skills/octocode-research/src/routes/prompts.ts +138 -0
  257. package/skills/octocode-research/src/routes/tools.ts +677 -0
  258. package/skills/octocode-research/src/server-init.ts +363 -0
  259. package/skills/octocode-research/src/server.ts +285 -0
  260. package/skills/octocode-research/src/types/errorGuards.ts +151 -0
  261. package/skills/octocode-research/src/types/express.d.ts +76 -0
  262. package/skills/octocode-research/src/types/guards.ts +98 -0
  263. package/skills/octocode-research/src/types/mcp.ts +119 -0
  264. package/skills/octocode-research/src/types/responses.ts +199 -0
  265. package/skills/octocode-research/src/types/toolTypes.ts +33 -0
  266. package/skills/octocode-research/src/utils/asyncTimeout.ts +116 -0
  267. package/skills/octocode-research/src/utils/circuitBreaker.ts +492 -0
  268. package/skills/octocode-research/src/utils/colors.ts +53 -0
  269. package/skills/octocode-research/src/utils/errorQueue.ts +71 -0
  270. package/skills/octocode-research/src/utils/logEmoji.ts +103 -0
  271. package/skills/octocode-research/src/utils/logger.ts +413 -0
  272. package/skills/octocode-research/src/utils/resilience.ts +169 -0
  273. package/skills/octocode-research/src/utils/responseBuilder.ts +495 -0
  274. package/skills/octocode-research/src/utils/responseFactory.ts +100 -0
  275. package/skills/octocode-research/src/utils/responseParser.ts +272 -0
  276. package/skills/octocode-research/src/utils/retry.ts +280 -0
  277. package/skills/octocode-research/src/utils/routeFactory.ts +117 -0
  278. package/skills/octocode-research/src/utils/url.ts +20 -0
  279. package/skills/octocode-research/src/validation/httpPreprocess.ts +155 -0
  280. package/skills/octocode-research/src/validation/index.ts +2 -0
  281. package/skills/octocode-research/src/validation/schemas.ts +578 -0
  282. package/skills/octocode-research/src/validation/toolCallSchema.ts +132 -0
  283. package/skills/octocode-research/tsconfig.json +21 -0
  284. package/skills/octocode-research/tsdown.config.ts +42 -0
  285. package/skills/octocode-research/vitest.config.ts +20 -0
  286. package/skills/octocode-researcher/SKILL.md +461 -0
  287. package/skills/octocode-researcher/references/fallbacks.md +120 -0
  288. package/skills/{octocode-local-search → octocode-researcher}/references/tool-reference.md +132 -49
  289. package/skills/{octocode-local-search → octocode-researcher}/references/workflow-patterns.md +204 -4
  290. package/skills/octocode-rfc-generator/SKILL.md +223 -0
  291. package/skills/octocode-rfc-generator/references/rfc-template.md +193 -0
  292. package/skills/octocode-roast/SKILL.md +63 -21
  293. package/skills/octocode-implement/SKILL.md +0 -293
  294. package/skills/octocode-implement/references/execution-phases.md +0 -317
  295. package/skills/octocode-implement/references/tool-reference.md +0 -403
  296. package/skills/octocode-implement/references/workflow-patterns.md +0 -385
  297. package/skills/octocode-local-search/SKILL.md +0 -449
  298. package/skills/octocode-pr-review/SKILL.md +0 -391
  299. package/skills/octocode-pr-review/references/domain-reviewers.md +0 -105
  300. package/skills/octocode-pr-review/references/execution-lifecycle.md +0 -116
  301. package/skills/octocode-pr-review/references/research-flows.md +0 -75
  302. package/skills/octocode-research/references/tool-reference.md +0 -304
  303. package/skills/octocode-research/references/workflow-patterns.md +0 -325
@@ -0,0 +1,886 @@
1
+ ---
2
+ name: octocode-documentation-writer
3
+ description: This skill should be used when the user asks to "generate documentation", "document this project", "create docs", "write documentation", "update documentation", "document all APIs", "generate onboarding docs", "create developer docs", or needs comprehensive codebase documentation. Orchestrates parallel AI agents to analyze code and produce documentation files.
4
+ ---
5
+
6
+ # Repository Documentation Generator
7
+
8
+ **Production-ready 6-phase pipeline with intelligent orchestration, research-first validation, and conflict-free file ownership.**
9
+
10
+
11
+ <what>
12
+ This command orchestrates specialized AI agents in 6 phases to analyze your code repository and generate comprehensive documentation:
13
+ </what>
14
+
15
+ ## Runtime Compatibility
16
+
17
+ - Model labels such as `Opus`, `Sonnet`, and `Haiku` are role hints, not hard requirements. Map them to the strongest available host models for the job.
18
+ - `Task` means the host runtime's parallel subagent mechanism. **IF** the host cannot run true parallel subagents → **THEN** execute the same work sequentially and preserve exclusive file ownership.
19
+ - Pseudocode blocks in this document are behavioral templates. Adapt helper names, file APIs, and retry helpers to the active runtime instead of treating them as literal APIs.
20
+ - Session artifacts live under `.octocode/documentation/{session-name}/`. Short names like `analysis.json` below refer to files inside that session directory unless stated otherwise.
21
+
22
+ <steps>
23
+ <phase_1>
24
+ **Discovery+Analysis** (Phase 1)
25
+ Agent Role: High-capability reasoning model
26
+ Parallel: 4 parallel agents
27
+ What: Analyze language, architecture, flows, and APIs
28
+ Input: Repository path
29
+ Output: `analysis.json`
30
+ </phase_1>
31
+
32
+ <phase_2>
33
+ **Engineer Questions** (Phase 2)
34
+ Agent Role: High-capability reasoning model
35
+ What: Generates comprehensive questions based on the analysis
36
+ Input: `analysis.json`
37
+ Output: `questions.json`
38
+ </phase_2>
39
+
40
+ <phase_3>
41
+ **Research Agent** (Phase 3) 🆕
42
+ Agent Role: Fast research/execution model
43
+ Parallel: Dynamic (based on question volume)
44
+ What: Deep-dive code forensics to ANSWER the questions with evidence
45
+ Input: `analysis.json` + `questions.json`
46
+ Output: `research.json`
47
+ </phase_3>
48
+
49
+ <phase_4>
50
+ **Orchestrator** (Phase 4)
51
+ Agent Role: High-capability reasoning model
52
+ What: Groups questions by file target and assigns exclusive file ownership to writers
53
+ Input: `questions.json` + `research.json`
54
+ Output: `work-assignments.json` (file-based assignments for parallel writers)
55
+ </phase_4>
56
+
57
+ <phase_5>
58
+ **Documentation Writers** (Phase 5)
59
+ Agent Role: Fast writing model
60
+ Parallel: 1-8 parallel agents (dynamic based on workload)
61
+ What: Synthesize research and write comprehensive documentation with exclusive file ownership
62
+ Input: `analysis.json` + `questions.json` + `research.json` + `work-assignments.json`
63
+ Output: `documentation/*.md` (16 core docs, 5 required, plus writer-owned supplementary files; `QA-SUMMARY.md` is generated in Phase 6)
64
+ </phase_5>
65
+
66
+ <phase_6>
67
+ **QA Validator** (Phase 6)
68
+ Agent Role: Fast validation model
69
+ What: Validates documentation quality using LSP-powered verification
70
+ Input: `documentation/*.md` + `analysis.json` + `questions.json` + `research.json`
71
+ Output: `qa-results.json` + `QA-SUMMARY.md`
72
+ </phase_6>
73
+ </steps>
74
+
75
+ <subagents>
76
+ Use the host's subagent mechanism to explore code with MCP tools (`localSearchCode`, `lspGotoDefinition`, `lspCallHierarchy`, `lspFindReferences`). Pick model tiers by capability, not by hard-coded model names.
77
+ </subagents>
78
+
79
+ <mcp_discovery>
80
+ Before starting, detect available research tools.
81
+
82
+ **Check**: Is `octocode-mcp` available as an MCP server?
83
+ Look for Octocode MCP tools (e.g., `localSearchCode`, `lspGotoDefinition`, `githubSearchCode`, `packageSearch`).
84
+
85
+ **If Octocode MCP exists but local tools return no results**:
86
+ > Suggest: "For local codebase research, add `ENABLE_LOCAL=true` to your Octocode MCP config."
87
+
88
+ **If Octocode MCP is not installed**:
89
+ > Suggest: "Install Octocode MCP for deeper research:
90
+ > ```json
91
+ > {
92
+ > "mcpServers": {
93
+ > "octocode": {
94
+ > "command": "npx",
95
+ > "args": ["-y", "octocode-mcp"],
96
+ > "env": {"ENABLE_LOCAL": "true"}
97
+ > }
98
+ > }
99
+ > }
100
+ > ```
101
+ > Then restart your editor."
102
+
103
+ Proceed with whatever tools are available — do not block on setup.
104
+ </mcp_discovery>
105
+
106
+ **Documentation Flow:** analysis.json → questions.json → **research.json** → work-assignments.json → documentation (conflict-free!)
107
+
108
+ ---
109
+
110
+ ## ⚠️ CRITICAL: Parallel Agent Execution
111
+
112
+ <parallel_execution_critical importance="maximum">
113
+
114
+ **STOP. READ THIS TWICE.**
115
+
116
+ ### 1. THE RULE
117
+ **Use the strongest parallel mechanism the host supports.** Prefer single-message fan-out when the runtime supports concurrent `Task` calls.
118
+
119
+ ### 2. FORBIDDEN BEHAVIOR
120
+ **FORBIDDEN:** Claiming work ran in parallel when the host actually executed it sequentially.
121
+ **REASON:** False concurrency claims hide runtime limits and make failures harder to reason about.
122
+
123
+ ### 3. REQUIRED FALLBACK
124
+ **IF** the runtime cannot perform true parallel fan-out:
125
+ - Run the same worker scopes sequentially
126
+ - Preserve exclusive file ownership
127
+ - Keep the same phase boundaries and aggregation steps
128
+ - Tell the user that execution is in sequential fallback mode
129
+
130
+ ### 4. REQUIRED CONFIRMATION
131
+ Before launching any parallel phase (1, 3, 5), you **MUST** verify:
132
+ - [ ] The host can run the chosen fan-out pattern
133
+ - [ ] No dependencies exist between these parallel agents
134
+ - [ ] Each agent has exclusive scope (no file conflicts)
135
+
136
+ <correct_pattern title="✅ CORRECT: Single response launches all agents concurrently">
137
+ ```
138
+ // In ONE assistant message, include ALL Task tool invocations when the host supports it:
139
+ Task(description="Discovery 1A-language", subagent_type="general-purpose", prompt="...", model="opus")
140
+ Task(description="Discovery 1B-components", subagent_type="general-purpose", prompt="...", model="opus")
141
+ Task(description="Discovery 1C-dependencies", subagent_type="general-purpose", prompt="...", model="opus")
142
+ Task(description="Discovery 1D-flows", subagent_type="general-purpose", prompt="...", model="opus")
143
+ // ↑ All 4 execute SIMULTANEOUSLY
144
+ ```
145
+ </correct_pattern>
146
+
147
+ <wrong_pattern title="❌ WRONG: Sequential calls lose parallelism">
148
+ ```
149
+ // DON'T DO THIS when the host supports concurrency - each waits for previous to complete
150
+ Message 1: Task(description="Discovery 1A") → wait for result
151
+ Message 2: Task(description="Discovery 1B") → wait for result
152
+ Message 3: Task(description="Discovery 1C") → wait for result
153
+ Message 4: Task(description="Discovery 1D") → wait for result
154
+ // ↑ 4x slower! No parallelism achieved
155
+ ```
156
+ </wrong_pattern>
157
+
158
+ </parallel_execution_critical>
159
+
160
+ ---
161
+
162
+ ## Execution Flow Diagram
163
+
164
+ ```mermaid
165
+ flowchart TB
166
+ Start([/octocode-documentation-writer PATH]) --> Validate[Pre-Flight Validation]
167
+ Validate --> Init[Initialize Workspace]
168
+
169
+ Init --> P1[Phase 1: Discovery+Analysis]
170
+
171
+ subgraph P1_Parallel["🔄 RUN IN PARALLEL (4 agents)"]
172
+ P1A[Agent 1A:<br/>Language & Manifests]
173
+ P1B[Agent 1B:<br/>Components]
174
+ P1C[Agent 1C:<br/>Dependencies]
175
+ P1D[Agent 1D:<br/>Flows & APIs]
176
+ end
177
+
178
+ P1 --> P1_Parallel
179
+ P1_Parallel --> P1Agg[Aggregation:<br/>Merge into analysis.json]
180
+ P1Agg --> P1Done[✅ analysis.json created]
181
+
182
+ P1Done -->|Reads analysis.json| P2[Phase 2: Engineer Questions<br/>Single High-Capability Agent]
183
+ P2 --> P2Done[✅ questions.json created]
184
+
185
+ P2Done -->|Reads questions.json| P3[Phase 3: Research 🆕<br/>Parallel Research Agents]
186
+
187
+ subgraph P3_Parallel["🔄 RUN IN PARALLEL"]
188
+ P3A[Researcher 1]
189
+ P3B[Researcher 2]
190
+ P3C[Researcher 3]
191
+ end
192
+
193
+ P3 --> P3_Parallel
194
+ P3_Parallel --> P3Agg[Aggregation:<br/>Merge into research.json]
195
+ P3Agg --> P3Done[✅ research.json created<br/>Evidence-backed answers]
196
+
197
+ P3Done -->|Reads questions + research| P4[Phase 4: Orchestrator<br/>Single High-Capability Agent]
198
+ P4 --> P4Group[Group questions<br/>by file target]
199
+ P4 --> P4Assign[Assign file ownership<br/>to writers]
200
+ P4Assign --> P4Done[✅ work-assignments.json]
201
+
202
+ P4Done --> P5[Phase 5: Documentation Writers]
203
+ P5 --> P5Input[📖 Input:<br/>work-assignments.json<br/>+ research.json]
204
+ P5Input --> P5Dist[Each writer gets<br/>exclusive file ownership]
205
+
206
+ subgraph P5_Parallel["🔄 RUN IN PARALLEL (1-8 agents)"]
207
+ P5W1[Writer 1]
208
+ P5W2[Writer 2]
209
+ P5W3[Writer 3]
210
+ P5W4[Writer 4]
211
+ end
212
+
213
+ P5Dist --> P5_Parallel
214
+ P5_Parallel --> P5Verify[Verify Structure]
215
+ P5Verify --> P5Done[✅ documentation/*.md created]
216
+
217
+ P5Done --> P6[Phase 6: QA Validator<br/>Single Validation Agent]
218
+ P6 --> P6Done[✅ qa-results.json +<br/>QA-SUMMARY.md]
219
+
220
+ P6Done --> Complete([✅ Documentation Complete])
221
+
222
+ style P1_Parallel fill:#e1f5ff
223
+ style P3_Parallel fill:#e1f5ff
224
+ style P5_Parallel fill:#ffe1f5
225
+ style P4 fill:#fff3cd
226
+ style Complete fill:#28a745,color:#fff
227
+ ```
228
+
229
+ ### Parallel Execution Rules
230
+
231
+ <execution_rules>
232
+ <phase name="1-discovery" type="parallel" critical="true" spawn="single_message">
233
+ <gate>
234
+ **STOP.** Verify parallel spawn requirements.
235
+ **REQUIRED:** Use host parallelism when available.
236
+ **FALLBACK:** Sequential execution is allowed only when the host cannot run true parallel work.
237
+ </gate>
238
+ <agent_count>4</agent_count>
239
+ <description>Discovery and Analysis</description>
240
+ <spawn_instruction>Prefer one-response fan-out; otherwise run sequential fallback and preserve exclusive scopes</spawn_instruction>
241
+ <rules>
242
+ <rule>Run all 4 agents concurrently when the host supports it; otherwise use sequential fallback</rule>
243
+ <rule>Wait for ALL 4 to complete before aggregation</rule>
244
+ <rule>Must aggregate 4 partial JSONs into analysis.json</rule>
245
+ </rules>
246
+ </phase>
247
+
248
+ <phase name="2-questions" type="single" critical="true" spawn="sequential">
249
+ <agent_count>1</agent_count>
250
+ <description>Engineer Questions Generation</description>
251
+ <spawn_instruction>Single agent, wait for completion</spawn_instruction>
252
+ </phase>
253
+
254
+ <phase name="3-research" type="parallel" critical="true" spawn="single_message">
255
+ <gate>
256
+ **STOP.** Verify parallel spawn requirements.
257
+ **REQUIRED:** Use host parallelism when available.
258
+ **FALLBACK:** Sequential execution is allowed only when the host cannot run true parallel work.
259
+ </gate>
260
+ <agent_count_logic>
261
+ <case condition="questions &lt; 10">1 agent</case>
262
+ <case condition="questions &gt;= 10">Ceil(questions / 15)</case>
263
+ </agent_count_logic>
264
+ <description>Evidence Gathering</description>
265
+ <spawn_instruction>Prefer one-response fan-out; otherwise run sequential fallback and preserve batch boundaries</spawn_instruction>
266
+ <rules>
267
+ <rule>Split questions into batches BEFORE spawning</rule>
268
+ <rule>Run all researchers concurrently when the host supports it; otherwise use sequential fallback</rule>
269
+ <rule>Aggregate findings into research.json</rule>
270
+ </rules>
271
+ </phase>
272
+
273
+ <phase name="4-orchestrator" type="single" critical="true" spawn="sequential">
274
+ <agent_count>1</agent_count>
275
+ <description>Orchestration and Assignment</description>
276
+ <spawn_instruction>Single agent, wait for completion</spawn_instruction>
277
+ <rules>
278
+ <rule>Assign EXCLUSIVE file ownership to writers</rule>
279
+ <rule>Distribute research findings to relevant writers</rule>
280
+ </rules>
281
+ </phase>
282
+
283
+ <phase name="5-writers" type="dynamic_parallel" critical="false" spawn="single_message">
284
+ <gate>
285
+ **STOP.** Verify parallel spawn requirements.
286
+ **REQUIRED:** Use host parallelism when available.
287
+ **FALLBACK:** Sequential execution is allowed only when the host cannot run true parallel work.
288
+ </gate>
289
+ <agent_count_logic>
290
+ <case condition="questions &lt; 25">1 agent</case>
291
+ <case condition="questions 25-49">2-4 agents</case>
292
+ <case condition="questions &gt;= 50">4-8 agents</case>
293
+ </agent_count_logic>
294
+ <spawn_instruction>Prefer one-response fan-out; otherwise run sequential fallback and preserve exclusive ownership</spawn_instruction>
295
+ <rules>
296
+ <rule>Each writer owns EXCLUSIVE files - no conflicts possible</rule>
297
+ <rule>Run all writers concurrently when the host supports it; otherwise use sequential fallback</rule>
298
+ <rule>Use provided research.json as primary source</rule>
299
+ </rules>
300
+ </phase>
301
+
302
+ <phase name="6-qa" type="single" critical="false" spawn="sequential">
303
+ <agent_count>1</agent_count>
304
+ <description>Quality Validation</description>
305
+ <spawn_instruction>Single agent, wait for completion</spawn_instruction>
306
+ </phase>
307
+ </execution_rules>
308
+
309
+ ## Pre-Flight Checks
310
+
311
+ <pre_flight_gate>
312
+ **HALT. Complete these requirements before proceeding:**
313
+
314
+ ### Required Checks
315
+ 1. **Verify Path Existence**
316
+ - **IF** `repository_path` missing → **THEN** ERROR & EXIT
317
+ 2. **Verify Directory Status**
318
+ - **IF** not a directory → **THEN** ERROR & EXIT
319
+ 3. **Source Code Check**
320
+ - **IF** < 3 source files → **THEN** WARN & Ask User (Exit if no)
321
+ 4. **Build Directory Check**
322
+ - **IF** contains `node_modules` or `dist` → **THEN** ERROR & EXIT
323
+ 5. **Size Estimation**
324
+ - **IF** > 200k LOC → **THEN** WARN & Ask User (Exit if no)
325
+
326
+ **FORBIDDEN until gate passes:**
327
+ - Any agent spawning
328
+ - Workspace initialization
329
+ </pre_flight_gate>
330
+
331
+ <instruction>
332
+ Before starting, validate the repository path and check for edge cases.
333
+
334
+ 1. **Verify Path Existence**
335
+ - Ensure `repository_path` exists.
336
+ - If not, raise an ERROR: "Repository path does not exist: " + path and EXIT.
337
+
338
+ 2. **Verify Directory Status**
339
+ - Confirm `repository_path` is a directory.
340
+ - If not, raise an ERROR: "Path is not a directory: " + path and EXIT.
341
+
342
+ 3. **Source Code Check**
343
+ - Count files ending in `.ts`, `.js`, `.py`, `.go`, or `.rs`.
344
+ - Exclude directories: `node_modules`, `.git`, `dist`, `build`.
345
+ - If fewer than 3 source files are found:
346
+ - WARN: "Very few source files detected ({count}). This may not be a code repository."
347
+ - Continue automatically in low-confidence mode unless the caller explicitly requested strict validation.
348
+
349
+ 4. **Build Directory Check**
350
+ - Ensure the path does not contain `node_modules`, `dist`, or `build`.
351
+ - If it does, raise an ERROR: "Repository path appears to be a build directory. Please specify the project root." and EXIT.
352
+
353
+ 5. **Size Estimation**
354
+ - Estimate the repository size.
355
+ - If larger than 200,000 LOC:
356
+ - WARN: "Large repository detected (~{size} LOC)."
357
+ - Continue automatically, but prefer conservative exploration and batching.
358
+ </instruction>
359
+
360
+ ## Initialize Workspace
361
+
362
+ <init_gate>
363
+ **STOP. Verify state before initialization.**
364
+
365
+ ### Required Actions
366
+ 1. **Define Directories** (`CONTEXT_DIR`, `DOC_DIR`)
367
+ - **REQUIRED:** Derive a stable `SESSION_NAME` first (caller-provided if available; otherwise use a short repository-based name)
368
+ 2. **Handle Existing State**
369
+ - **IF** `state.json` exists in a non-terminal phase → **THEN** Resume automatically
370
+ - **IF** caller explicitly requests a fresh run → **THEN** Reset state
371
+ 3. **Create Directories**
372
+ 4. **Initialize New State** (if not resuming)
373
+
374
+ **FORBIDDEN:**
375
+ - Starting Phase 1 before state is initialized.
376
+ </init_gate>
377
+
378
+ <instruction>
379
+ ### Workspace Initialization
380
+ Before starting the pipeline, set up the working environment and handle any existing state.
381
+
382
+ 1. **Define Directories**
383
+ - Session Directory (`CONTEXT_DIR`): `${REPOSITORY_PATH}/.octocode/documentation/${SESSION_NAME}`
384
+ - Documentation Directory (`DOC_DIR`): `${REPOSITORY_PATH}/documentation`
385
+
386
+ 2. **Handle Existing State**
387
+ - Check if `${CONTEXT_DIR}/state.json` exists.
388
+ - If it exists and the phase is NOT "complete" or "failed":
389
+ - **Default Behavior**: Resume from the saved checkpoint.
390
+ - Set `RESUME_MODE = true`
391
+ - Set `START_PHASE` from the saved state.
392
+ - **Only if** the caller explicitly requests restart/fresh generation:
393
+ - **WARN**: "Restarting from beginning. Previous progress will be overwritten."
394
+ - Set `RESUME_MODE = false`
395
+ - Set `START_PHASE = "initialized"`
396
+ - If `state.json` does not exist or previous run finished/failed, start fresh (`RESUME_MODE = false`).
397
+
398
+ 3. **Create Directories**
399
+ - Ensure `CONTEXT_DIR` exists (create if missing).
400
+ - Ensure `DOC_DIR` exists (create if missing).
401
+
402
+ 4. **Initialize New State** (If NOT Resuming)
403
+ - Create a new `state.json` using the schema defined in `schemas/state-schema.json`.
404
+ </instruction>
405
+
406
+ ## Progress Tracker
407
+
408
+ Display real-time progress:
409
+
410
+ ```
411
+ 📊 Documentation Generation Progress v3.1
412
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
413
+
414
+ Repository: {REPOSITORY_PATH}
415
+ Mode: {RESUME_MODE ? "Resume" : "New"}
416
+
417
+ {if RESUME_MODE}
418
+ Resuming from: {START_PHASE}
419
+ {end}
420
+
421
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
422
+ ```
423
+
424
+ ## Agent Pipeline Execution
425
+
426
+ ### Phase 1: Discovery+Analysis Agent
427
+
428
+ <phase_1_gate>
429
+ **GATE: START Phase 1**
430
+ **REQUIRED:** Spawn 4 agents in **ONE** message.
431
+ **FORBIDDEN:** Sequential calls.
432
+ </phase_1_gate>
433
+
434
+ **Agent Spec**: `references/agent-discovery-analysis.md`
435
+ **Task Schema/Config**: `schemas/discovery-tasks.json`
436
+
437
+ | Property | Value |
438
+ |----------|-------|
439
+ | Parallel Agents | 4 (1a-language, 1b-components, 1c-dependencies, 1d-flows-apis) |
440
+ | Critical | Yes |
441
+ | Output | `.octocode/documentation/{session-name}/analysis.json` |
442
+
443
+ > See `references/agent-discovery-analysis.md` → **Orchestrator Execution Logic** section for full implementation.
444
+
445
+ ### Phase 2: Engineer Questions Agent
446
+
447
+ **Agent Spec**: `references/agent-engineer-questions.md`
448
+
449
+ | Property | Value |
450
+ |----------|-------|
451
+ | Agent Type | Single (high-capability reasoning model) |
452
+ | Critical | Yes |
453
+ | Input | `.octocode/documentation/{session-name}/analysis.json`, `schemas/documentation-structure.json` |
454
+ | Output | `.octocode/documentation/{session-name}/questions.json` |
455
+
456
+ > See `references/agent-engineer-questions.md` → **Orchestrator Execution Logic** section for full implementation.
457
+
458
+
459
+ ### Phase 3: Research Agent 🆕
460
+
461
+ <phase_3_gate>
462
+ **GATE: START Phase 3**
463
+ **REQUIRED:** Spawn N agents in **ONE** message.
464
+ **FORBIDDEN:** Sequential calls.
465
+ </phase_3_gate>
466
+
467
+ **Agent Spec**: `references/agent-researcher.md`
468
+
469
+ | Property | Value |
470
+ |----------|-------|
471
+ | Agent Type | Parallel (research-capable execution model) |
472
+ | Critical | Yes |
473
+ | Input | `.octocode/documentation/{session-name}/analysis.json`, `.octocode/documentation/{session-name}/questions.json` |
474
+ | Output | `.octocode/documentation/{session-name}/research.json` |
475
+
476
+ > See `references/agent-researcher.md` → **Orchestrator Execution Logic** section for full implementation.
477
+
478
+
479
+ ### Phase 4: Orchestrator Agent
480
+
481
+ **Agent Spec**: `references/agent-orchestrator.md`
482
+
483
+ | Property | Value |
484
+ |----------|-------|
485
+ | Agent Type | Single (high-capability reasoning model) |
486
+ | Critical | Yes |
487
+ | Input | `.octocode/documentation/{session-name}/analysis.json`, `.octocode/documentation/{session-name}/questions.json`, `.octocode/documentation/{session-name}/research.json`, `schemas/documentation-structure.json` |
488
+ | Output | `.octocode/documentation/{session-name}/work-assignments.json` |
489
+
490
+ > See `references/agent-orchestrator.md` → **Orchestrator Execution Logic** section for full implementation.
491
+
492
+ ### Phase 5: Documentation Writers
493
+
494
+ <phase_5_gate>
495
+ **GATE: START Phase 5**
496
+ **REQUIRED:** Spawn all writers in **ONE** message.
497
+ **FORBIDDEN:** Sequential calls.
498
+ </phase_5_gate>
499
+
500
+ **Agent Spec**: `references/agent-documentation-writer.md`
501
+
502
+ | Property | Value |
503
+ |----------|-------|
504
+ | Agent Type | Parallel (1-8 writing-capable agents) |
505
+ | Critical Writer | Writer owning the majority of primary core files (01-08) |
506
+ | Non-Primary | Partial failure allowed |
507
+ | Retry Logic | Up to 2 retries per failed writer |
508
+ | Input | `.octocode/documentation/{session-name}/analysis.json`, `.octocode/documentation/{session-name}/questions.json`, `.octocode/documentation/{session-name}/research.json`, `.octocode/documentation/{session-name}/work-assignments.json`, `schemas/documentation-structure.json` |
509
+ | Output | `documentation/*.md` (16 core, 5 required, plus writer-owned supplementary files; `QA-SUMMARY.md` is Phase 6 output) |
510
+ | File Ownership | Exclusive (no conflicts) |
511
+
512
+ #### Writer Scaling Strategy
513
+
514
+ | Strategy | Agent Count | When Used |
515
+ |----------|-------------|-----------|
516
+ | `sequential` | 1 | < 25 questions |
517
+ | `parallel-core` | 2-4 | 25-49 questions |
518
+ | `parallel-all` | 4-8 | >= 50 questions |
519
+
520
+ > See `references/agent-documentation-writer.md` → **Orchestrator Execution Logic** section for full implementation.
521
+
522
+ ### Phase 6: QA Validator
523
+
524
+ **Agent Spec**: `references/agent-qa-validator.md`
525
+
526
+ | Property | Value |
527
+ |----------|-------|
528
+ | Agent Type | Single (validation-capable model) |
529
+ | Critical | No (failure produces warning) |
530
+ | Input | `.octocode/documentation/{session-name}/analysis.json`, `.octocode/documentation/{session-name}/questions.json`, `.octocode/documentation/{session-name}/research.json`, `documentation/*.md`, `schemas/documentation-structure.json` |
531
+ | Output | `.octocode/documentation/{session-name}/qa-results.json`, `documentation/QA-SUMMARY.md` |
532
+ | Score Range | 0-100 |
533
+ | Quality Ratings | `excellent` (≥90), `good` (≥75), `fair` (≥60), `needs-improvement` (<60) |
534
+
535
+ > See `references/agent-qa-validator.md` → **Orchestrator Execution Logic** section for full implementation.
536
+
537
+ ## Completion
538
+
539
+ ```javascript
540
+ update_state({
541
+ phase: "complete",
542
+ completed_at: new Date().toISOString(),
543
+ current_agent: null
544
+ })
545
+
546
+ DISPLAY: "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
547
+ DISPLAY: "✅ Documentation Complete!"
548
+ DISPLAY: ""
549
+ DISPLAY: "📁 Location: {DOC_DIR}/"
550
+ DISPLAY: "📊 QA Report: {DOC_DIR}/QA-SUMMARY.md"
551
+ DISPLAY: ""
552
+
553
+ if (parsed_qa && parsed_qa.overall_score):
554
+ DISPLAY: "Quality Score: {parsed_qa.overall_score}/100 ({parsed_qa.quality_rating})"
555
+
556
+ if (parsed_qa.overall_score >= 90):
557
+ DISPLAY: "Status: Excellent ✅ - Ready for release"
558
+ else if (parsed_qa.overall_score >= 75):
559
+ DISPLAY: "Status: Good ✅ - Minor improvements recommended"
560
+ else if (parsed_qa.overall_score >= 60):
561
+ DISPLAY: "Status: Fair -️ - Address gaps before release"
562
+ else:
563
+ DISPLAY: "Status: Needs Work -️ - Major improvements required"
564
+
565
+ if (parsed_qa.gaps && parsed_qa.gaps.length > 0):
566
+ DISPLAY: ""
567
+ DISPLAY: "Next Steps:"
568
+ for (i = 0; i < Math.min(3, parsed_qa.gaps.length); i++):
569
+ gap = parsed_qa.gaps[i]
570
+ DISPLAY: " {i+1}. {gap.fix}"
571
+
572
+ DISPLAY: ""
573
+ DISPLAY: "📝 Documentation Coverage:"
574
+ DISPLAY: " {parsed_questions.summary.total_questions} questions researched"
575
+ DISPLAY: " {parsed_qa.question_coverage.answered} questions answered in docs"
576
+ DISPLAY: ""
577
+ if (exists(DOC_DIR + "/index.md")):
578
+ DISPLAY: "View documentation: {DOC_DIR}/index.md"
579
+ else:
580
+ DISPLAY: "View documentation: {DOC_DIR}/01-project-overview.md"
581
+ DISPLAY: "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
582
+
583
+ EXIT code 0
584
+ ```
585
+
586
+ ## Error Recovery
587
+
588
+ If any agent fails critically:
589
+
590
+ ```javascript
591
+ function handle_critical_failure(phase, error):
592
+ DISPLAY: "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
593
+ DISPLAY: "❌ Documentation Generation Failed"
594
+ DISPLAY: ""
595
+ DISPLAY: "Phase: {phase}"
596
+ DISPLAY: "Error: {error.message}"
597
+ DISPLAY: ""
598
+
599
+ if (error.recoverable):
600
+ DISPLAY: "This error is recoverable. Run /octocode-documentation-writer again to resume."
601
+ DISPLAY: "State saved in: {CONTEXT_DIR}/state.json"
602
+ else:
603
+ DISPLAY: "This error is not recoverable. Please check the error and try again."
604
+ DISPLAY: "You may need to fix the issue before retrying."
605
+
606
+ DISPLAY: ""
607
+ DISPLAY: "Logs: {CONTEXT_DIR}/state.json"
608
+ DISPLAY: "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
609
+
610
+ EXIT code 1
611
+ ```
612
+
613
+ ## Helper Functions
614
+
615
+ > **IMPORTANT: State Synchronization**
616
+ > Only the main orchestrator process should update `state.json`. Individual parallel agents
617
+ > (Discovery 1A-1D, Researchers, Writers) must NOT directly modify `state.json` to avoid
618
+ > race conditions. Parallel agents should only write to their designated partial result files
619
+ > inside `.octocode/documentation/{session-name}/` using their phase-specific contract paths
620
+ > (for example `partial-1a-language.json` or `research-results/partial-research-0.json`). The orchestrator aggregates these results and updates
621
+ > `state.json` after all parallel agents complete.
622
+
623
+ ```javascript
624
+ // NOTE: This function should ONLY be called by the main orchestrator process,
625
+ // never by parallel sub-agents. Parallel agents use their designated partial-result path instead.
626
+ function update_state(updates):
627
+ current_state = Read(CONTEXT_DIR + "/state.json")
628
+ parsed = JSON.parse(current_state)
629
+
630
+ for key, value in updates:
631
+ parsed[key] = value
632
+
633
+ Write(CONTEXT_DIR + "/state.json", JSON.stringify(parsed, null, 2))
634
+
635
+ function estimate_repo_size(path):
636
+ // Quick estimate: count source files
637
+ files = count_files(path, ["*.ts", "*.js", "*.py", "*.go", "*.rs", "*.java"], excludeDir=["node_modules", ".git", "dist", "build"])
638
+ // Assume ~200 LOC per file average
639
+ return files * 200
640
+
641
+ function count_files(path, patterns, excludeDir):
642
+ // Use localFindFiles MCP tool (mcp__octocode__localFindFiles)
643
+ // Return count of matching files
644
+ ```
645
+
646
+ ## Retry & Data Preservation Logic
647
+
648
+ **CRITICAL**: Never lose partial work. All agents support retry with state preservation.
649
+
650
+ ```javascript
651
+ const RETRY_CONFIG = {
652
+ discovery_analysis: { max_attempts: 3, backoff_ms: 2000 },
653
+ engineer_questions: { max_attempts: 3, backoff_ms: 2000 },
654
+ research: { max_attempts: 3, backoff_ms: 3000 },
655
+ orchestrator: { max_attempts: 3, backoff_ms: 2000 },
656
+ documentation: { max_attempts: 3, backoff_ms: 5000 }, // per writer
657
+ qa: { max_attempts: 2, backoff_ms: 1000 }
658
+ }
659
+
660
+ // === RETRY WRAPPER FOR ALL AGENTS ===
661
+ function retry_agent(phase_name, agent_fn, options = {}):
662
+ config = RETRY_CONFIG[phase_name]
663
+ state = get_retry_state(phase_name)
664
+
665
+ while (state.attempts < config.max_attempts):
666
+ state.attempts++
667
+ update_retry_state(phase_name, state)
668
+
669
+ DISPLAY: `⟳ ${phase_name} attempt ${state.attempts}/${config.max_attempts}`
670
+
671
+ try:
672
+ result = agent_fn(options)
673
+
674
+ // Success - clear retry state
675
+ clear_retry_state(phase_name)
676
+ return { success: true, result }
677
+
678
+ catch (error):
679
+ state.last_error = error.message
680
+ update_retry_state(phase_name, state)
681
+
682
+ DISPLAY: `⚠️ ${phase_name} failed: ${error.message}`
683
+
684
+ if (state.attempts < config.max_attempts):
685
+ DISPLAY: ` Retrying in ${config.backoff_ms}ms...`
686
+ sleep(config.backoff_ms * state.attempts) // Exponential backoff
687
+ else:
688
+ DISPLAY: `❌ ${phase_name} exhausted all ${config.max_attempts} attempts`
689
+ return { success: false, error, attempts: state.attempts }
690
+
691
+ return { success: false, error: state.last_error, attempts: state.attempts }
692
+
693
+ // === PARALLEL AGENT RETRY (for Discovery, Research, Writers) ===
694
+ function retry_parallel_agents(phase_name, agent_tasks, options = {}):
695
+ config = RETRY_CONFIG[phase_name]
696
+ results = {}
697
+ failed_tasks = []
698
+
699
+ // First attempt - run all in parallel
700
+ parallel_results = Task_Parallel(agent_tasks)
701
+
702
+ for (task_id, result) in parallel_results:
703
+ if (result.success):
704
+ results[task_id] = result
705
+ save_partial_result(phase_name, task_id, result)
706
+ else:
707
+ failed_tasks.push({ id: task_id, task: agent_tasks[task_id], attempts: 1 })
708
+
709
+ // Retry failed tasks individually
710
+ for failed in failed_tasks:
711
+ while (failed.attempts < config.max_attempts):
712
+ failed.attempts++
713
+ DISPLAY: `⟳ Retrying ${phase_name}/${failed.id} (attempt ${failed.attempts}/${config.max_attempts})`
714
+
715
+ try:
716
+ result = Task(failed.task)
717
+ if (result.success):
718
+ results[failed.id] = result
719
+ save_partial_result(phase_name, failed.id, result)
720
+ break
721
+ catch (error):
722
+ DISPLAY: `⚠️ ${phase_name}/${failed.id} failed: ${error.message}`
723
+ if (failed.attempts < config.max_attempts):
724
+ sleep(config.backoff_ms * failed.attempts)
725
+
726
+ if (failed.attempts >= config.max_attempts && !results[failed.id]):
727
+ DISPLAY: `❌ ${phase_name}/${failed.id} failed after ${config.max_attempts} attempts`
728
+ // Load any partial result saved during attempts
729
+ results[failed.id] = load_partial_result(phase_name, failed.id) || { success: false, partial: true }
730
+
731
+ return results
732
+
733
+ // === PARTIAL RESULT PRESERVATION ===
734
+ // Uses atomic writes to prevent corruption from concurrent access
735
+ function resolve_partial_result_path(phase_name, task_id):
736
+ if (phase_name == "discovery-analysis"):
737
+ discovery_paths = {
738
+ "agent-1a-language": CONTEXT_DIR + "/partial-1a-language.json",
739
+ "agent-1b-components": CONTEXT_DIR + "/partial-1b-components.json",
740
+ "agent-1c-dependencies": CONTEXT_DIR + "/partial-1c-dependencies.json",
741
+ "agent-1d-flows-apis": CONTEXT_DIR + "/partial-1d-flows-apis.json"
742
+ }
743
+ return discovery_paths[task_id] || (CONTEXT_DIR + "/partials/" + phase_name + "/" + task_id + ".json")
744
+
745
+ if (phase_name == "research"):
746
+ index = task_id.replace("researcher-", "")
747
+ return CONTEXT_DIR + "/research-results/partial-research-" + index + ".json"
748
+
749
+ return CONTEXT_DIR + "/partials/" + phase_name + "/" + task_id + ".json"
750
+
751
+ function save_partial_result(phase_name, task_id, result):
752
+ target_path = resolve_partial_result_path(phase_name, task_id)
753
+ partial_dir = dirname(target_path)
754
+ mkdir_p(partial_dir)
755
+ temp_path = target_path + ".tmp." + random_uuid()
756
+
757
+ // Atomic write: write to temp file, then rename (rename is atomic on POSIX)
758
+ Write(temp_path, JSON.stringify(result))
759
+ rename(temp_path, target_path) // Atomic operation
760
+
761
+ function load_partial_result(phase_name, task_id):
762
+ path = resolve_partial_result_path(phase_name, task_id)
763
+ if (exists(path)):
764
+ return JSON.parse(Read(path))
765
+ return null
766
+
767
+ function load_all_partial_results(phase_name):
768
+ partial_dir = CONTEXT_DIR + "/partials/" + phase_name
769
+ if (!exists(partial_dir)):
770
+ return {}
771
+ files = list_files(partial_dir, "*.json")
772
+ results = {}
773
+ for file in files:
774
+ task_id = file.replace(".json", "")
775
+ results[task_id] = JSON.parse(Read(partial_dir + "/" + file))
776
+ return results
777
+
778
+ // === RETRY STATE MANAGEMENT ===
779
+ function get_retry_state(phase_name):
780
+ state = Read(CONTEXT_DIR + "/state.json")
781
+ parsed = JSON.parse(state)
782
+ return parsed.retry_state?.[phase_name] || { attempts: 0 }
783
+
784
+ function update_retry_state(phase_name, retry_state):
785
+ update_state({
786
+ retry_state: {
787
+ ...current_state.retry_state,
788
+ [phase_name]: retry_state
789
+ }
790
+ })
791
+
792
+ function clear_retry_state(phase_name):
793
+ state = JSON.parse(Read(CONTEXT_DIR + "/state.json"))
794
+ if (state.retry_state):
795
+ delete state.retry_state[phase_name]
796
+ Write(CONTEXT_DIR + "/state.json", JSON.stringify(state, null, 2))
797
+ ```
798
+
799
+ ### Phase-Specific Retry Behavior
800
+
801
+ | Phase | Retry Strategy | Partial Data Preserved |
802
+ |-------|----------------|------------------------|
803
+ | **Discovery** | Retry failed sub-agents (1A-1D) individually | `partials/discovery/*.json` |
804
+ | **Questions** | Retry entire phase | Previous `questions.json` kept until success |
805
+ | **Research** | Retry failed batches only | `partials/research/batch-*.json` |
806
+ | **Orchestrator** | Retry entire phase | Previous `work-assignments.json` kept |
807
+ | **Writers** | Retry failed writers only | `partials/writers/writer-*.json` + completed files |
808
+ | **QA** | Retry once, then warn | `partials/qa/partial-results.json` |
809
+
810
+ ### Critical Data Protection Rules
811
+
812
+ ```javascript
813
+ // RULE 1: Never overwrite successful output until new output is validated
814
+ function safe_write_output(path, content):
815
+ backup_path = path + ".backup"
816
+ if (exists(path)):
817
+ copy(path, backup_path)
818
+
819
+ try:
820
+ Write(path, content)
821
+ validate_json(path) // Ensure valid JSON
822
+ delete(backup_path) // Only delete backup after validation
823
+ catch (error):
824
+ // Restore from backup
825
+ if (exists(backup_path)):
826
+ copy(backup_path, path)
827
+ throw error
828
+
829
+ // RULE 2: Aggregate partial results even on failure
830
+ // Uses file locking to prevent race conditions during aggregation
831
+ function aggregate_with_partials(phase_name, new_results):
832
+ lock_file = CONTEXT_DIR + "/partials/" + phase_name + "/.aggregate.lock"
833
+
834
+ // Acquire exclusive lock before aggregation
835
+ lock_fd = acquire_file_lock(lock_file, timeout_ms=5000)
836
+ if (!lock_fd):
837
+ throw new Error("Failed to acquire lock for aggregation: " + phase_name)
838
+
839
+ try:
840
+ existing = load_all_partial_results(phase_name)
841
+ merged = { ...existing, ...new_results }
842
+ return merged
843
+ finally:
844
+ release_file_lock(lock_fd)
845
+ delete(lock_file)
846
+
847
+ // RULE 3: Resume-aware execution
848
+ function should_skip_task(phase_name, task_id):
849
+ partial = load_partial_result(phase_name, task_id)
850
+ return partial?.success === true
851
+ ```
852
+ ---
853
+
854
+ ## Key Features
855
+
856
+ <key_features>
857
+
858
+ | # | Feature | Description |
859
+ |---|---------|-------------|
860
+ | 1 | **Host-Aware Parallel Execution** | Phases 1, 3, 5 use true parallel fan-out when supported, with sequential fallback when not |
861
+ | 2 | **Honest Concurrency** | Parallel execution is preferred, but the skill never pretends sequential work is concurrent |
862
+ | 3 | **Evidence-Based** | Research agent proves answers with code traces before writing |
863
+ | 4 | **Engineer-Driven Questions** | Phase 2 generates comprehensive questions |
864
+ | 5 | **Conflict-Free Writing** | Orchestrator assigns exclusive file ownership per writer |
865
+ | 6 | **LSP-Powered** | Intelligent verification with semantic analysis |
866
+ | 7 | **State Recovery** | Resume from any phase if interrupted |
867
+ | 8 | **Unified Toolset** | All agents use octocode local + LSP tools |
868
+ | 9 | **Dynamic Scaling** | Agent count scales based on question volume |
869
+
870
+ </key_features>
871
+
872
+ <efficiency_summary>
873
+ ### Efficiency Maximization
874
+
875
+ ```
876
+ Phase 1: 4 agents × parallel = ~4x faster than sequential
877
+ Phase 3: N agents × parallel = ~Nx faster than sequential
878
+ Phase 5: M agents × parallel = ~Mx faster than sequential
879
+
880
+ Total speedup: Significant when host parallelism is available
881
+ ```
882
+
883
+ **Remember**: Use the strongest fan-out the host supports. When true parallelism is unavailable, fall back to sequential execution and preserve the same ownership boundaries.
884
+ </efficiency_summary>
885
+
886
+ ---