octocode-cli 1.2.8 → 1.2.10

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 (282) hide show
  1. package/README.md +45 -38
  2. package/out/octocode-cli.js +73 -11763
  3. package/package.json +35 -36
  4. package/skills/README.md +42 -114
  5. package/skills/{octocode-code-engineer → octocode-engineer}/.claude/settings.local.json +2 -1
  6. package/skills/octocode-engineer/README.md +99 -0
  7. package/skills/octocode-engineer/SKILL.md +413 -0
  8. package/skills/octocode-engineer/build.mjs +29 -0
  9. package/skills/{octocode-code-engineer → octocode-engineer}/eslint.config.mjs +3 -13
  10. package/skills/{octocode-code-engineer → octocode-engineer}/package.json +28 -27
  11. package/skills/octocode-engineer/references/ast-reference.md +166 -0
  12. package/skills/{octocode-code-engineer → octocode-engineer}/references/cli-reference.md +80 -6
  13. package/skills/octocode-engineer/references/externals.md +86 -0
  14. package/skills/{octocode-code-engineer → octocode-engineer}/references/output-files.md +46 -6
  15. package/skills/octocode-engineer/references/quality-indicators.md +202 -0
  16. package/skills/octocode-engineer/references/tool-workflows.md +298 -0
  17. package/skills/octocode-engineer/references/validation-playbooks.md +99 -0
  18. package/skills/octocode-engineer/scripts/ast/search.js +45 -0
  19. package/skills/octocode-engineer/scripts/ast/tree-search.js +27 -0
  20. package/skills/octocode-engineer/scripts/index.js +173 -0
  21. package/skills/octocode-engineer/scripts/run.js +179 -0
  22. package/skills/octocode-engineer/src/analysis/dependencies.ts +378 -0
  23. package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/discovery.test.ts +57 -0
  24. package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/discovery.ts +43 -0
  25. package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/search.test.ts +113 -0
  26. package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/search.ts +64 -1
  27. package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/tree-sitter.test.ts +118 -2
  28. package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/tree-sitter.ts +65 -3
  29. package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/ts-analyzer.test.ts +281 -1
  30. package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/ts-analyzer.ts +173 -3
  31. package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/security.test.ts +73 -0
  32. package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/security.ts +62 -4
  33. package/skills/octocode-engineer/src/detector-gating.test.ts +59 -0
  34. package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/code-quality.ts +342 -0
  35. package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/index.ts +8 -0
  36. package/skills/{octocode-code-engineer → octocode-engineer}/src/index.test.ts +565 -11
  37. package/skills/octocode-engineer/src/index.ts +468 -0
  38. package/skills/octocode-engineer/src/pipeline/affected.test.ts +147 -0
  39. package/skills/octocode-engineer/src/pipeline/affected.ts +68 -0
  40. package/skills/octocode-engineer/src/pipeline/baseline.test.ts +276 -0
  41. package/skills/octocode-engineer/src/pipeline/baseline.ts +76 -0
  42. package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/cli.test.ts +300 -53
  43. package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/cli.ts +180 -36
  44. package/skills/octocode-engineer/src/pipeline/config-loader.test.ts +264 -0
  45. package/skills/octocode-engineer/src/pipeline/config-loader.ts +109 -0
  46. package/skills/octocode-engineer/src/pipeline/create-options.ts +55 -0
  47. package/skills/octocode-engineer/src/pipeline/health-score.test.ts +65 -0
  48. package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/main.ts +130 -17
  49. package/skills/octocode-engineer/src/pipeline/progress.ts +51 -0
  50. package/skills/octocode-engineer/src/pipeline/reporters.test.ts +155 -0
  51. package/skills/octocode-engineer/src/pipeline/reporters.ts +64 -0
  52. package/skills/octocode-engineer/src/reporting/graph-features.test.ts +279 -0
  53. package/skills/{octocode-code-engineer → octocode-engineer}/src/reporting/output-contract.test.ts +6 -0
  54. package/skills/octocode-engineer/src/reporting/summary-md.test.ts +1066 -0
  55. package/skills/octocode-engineer/src/reporting/summary-md.ts +1604 -0
  56. package/skills/{octocode-code-engineer → octocode-engineer}/src/reporting/writer.ts +136 -13
  57. package/skills/octocode-engineer/src/run.ts +78 -0
  58. package/skills/{octocode-code-engineer → octocode-engineer}/src/sanity.test.ts +1 -1
  59. package/skills/octocode-engineer/src/types/analysis.ts +25 -0
  60. package/skills/octocode-engineer/src/types/collectors.ts +134 -0
  61. package/skills/{octocode-code-engineer → octocode-engineer}/src/types/constants.ts +75 -41
  62. package/skills/octocode-engineer/src/types/core.ts +203 -0
  63. package/skills/octocode-engineer/src/types/dependency.ts +215 -0
  64. package/skills/octocode-engineer/src/types/file-entry.ts +108 -0
  65. package/skills/octocode-engineer/src/types/findings.ts +105 -0
  66. package/skills/{octocode-code-engineer → octocode-engineer}/src/types/index.ts +60 -30
  67. package/skills/octocode-engineer/src/types/tree-sitter.ts +38 -0
  68. package/skills/{octocode-code-engineer → octocode-engineer}/tsconfig.json +1 -0
  69. package/skills/octocode-research/.octocode/scan/.cache/analysis-cache.json +1 -0
  70. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/architecture.json +1 -0
  71. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/ast-trees.txt +5566 -0
  72. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/code-quality.json +1 -0
  73. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/dead-code.json +1 -0
  74. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/file-inventory.json +1 -0
  75. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/findings.json +1 -0
  76. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/graph.md +189 -0
  77. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/security.json +1 -0
  78. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/summary.json +1 -0
  79. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/summary.md +265 -0
  80. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/architecture.json +1 -0
  81. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/ast-trees.txt +5555 -0
  82. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/code-quality.json +1 -0
  83. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/dead-code.json +1 -0
  84. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/file-inventory.json +1 -0
  85. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/findings.json +1 -0
  86. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/graph.md +190 -0
  87. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/security.json +1 -0
  88. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/summary.json +1 -0
  89. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/summary.md +265 -0
  90. package/skills/octocode-research/CHANGELOG.md +60 -0
  91. package/skills/octocode-research/README.md +102 -388
  92. package/skills/octocode-research/SKILL.md +169 -498
  93. package/skills/octocode-research/package.json +19 -31
  94. package/skills/octocode-research/references/PARALLEL_AGENT_PROTOCOL.md +19 -0
  95. package/skills/octocode-research/references/SESSION_MANAGEMENT.md +38 -0
  96. package/skills/octocode-research/scripts/server-init.js +1 -1
  97. package/skills/octocode-research/scripts/server.d.ts +2 -1
  98. package/skills/octocode-research/scripts/server.js +329 -233
  99. package/skills/octocode-research/src/__tests__/integration/promptsRoutes.test.ts +180 -0
  100. package/skills/octocode-research/src/__tests__/integration/serverHttp.test.ts +221 -0
  101. package/skills/octocode-research/src/__tests__/integration/serverLifecycle.test.ts +194 -0
  102. package/skills/octocode-research/src/__tests__/integration/toolsRoutes.test.ts +501 -0
  103. package/skills/octocode-research/src/__tests__/unit/readiness.test.ts +61 -0
  104. package/skills/octocode-research/src/__tests__/unit/resilience.test.ts +192 -0
  105. package/skills/octocode-research/src/__tests__/unit/responseFactory.test.ts +172 -0
  106. package/skills/octocode-research/src/__tests__/unit/responseParser.test.ts +288 -0
  107. package/skills/octocode-research/src/__tests__/unit/schemas.test.ts +509 -0
  108. package/skills/octocode-research/src/index.ts +4 -124
  109. package/skills/octocode-research/src/middleware/queryParser.ts +0 -26
  110. package/skills/octocode-research/src/routes/lsp.ts +58 -59
  111. package/skills/octocode-research/src/routes/package.ts +35 -65
  112. package/skills/octocode-research/src/routes/prompts.ts +3 -3
  113. package/skills/octocode-research/src/routes/tools.ts +8 -20
  114. package/skills/octocode-research/src/server-init.ts +30 -237
  115. package/skills/octocode-research/src/server.ts +50 -23
  116. package/skills/octocode-research/src/types/errorGuards.ts +9 -80
  117. package/skills/octocode-research/src/types/guards.ts +0 -28
  118. package/skills/octocode-research/src/types/mcp.ts +11 -66
  119. package/skills/octocode-research/src/types/responses.ts +11 -129
  120. package/skills/octocode-research/src/utils/circuitBreaker.ts +0 -21
  121. package/skills/octocode-research/src/utils/logger.ts +1 -97
  122. package/skills/octocode-research/src/utils/resilience.ts +2 -12
  123. package/skills/octocode-research/src/utils/responseFactory.ts +0 -42
  124. package/skills/octocode-research/src/utils/responseParser.ts +3 -25
  125. package/skills/octocode-research/src/utils/retry.ts +0 -63
  126. package/skills/octocode-research/src/utils/routeFactory.ts +1 -1
  127. package/skills/octocode-research/src/validation/httpPreprocess.ts +0 -3
  128. package/skills/octocode-research/src/validation/index.ts +0 -1
  129. package/skills/octocode-research/src/validation/schemas.ts +0 -63
  130. package/skills/octocode-research/src/validation/toolCallSchema.ts +3 -3
  131. package/skills/octocode-research/tsdown.config.ts +4 -0
  132. package/skills/octocode-research/vitest.config.ts +3 -0
  133. package/skills/octocode-code-engineer/.plan/VALIDATED_PLAN.md +0 -223
  134. package/skills/octocode-code-engineer/README.md +0 -178
  135. package/skills/octocode-code-engineer/SKILL.md +0 -418
  136. package/skills/octocode-code-engineer/minify-scripts.mjs +0 -32
  137. package/skills/octocode-code-engineer/references/agent-ast-reading-rfc.md +0 -95
  138. package/skills/octocode-code-engineer/references/architecture-techniques.md +0 -121
  139. package/skills/octocode-code-engineer/references/ast-search.md +0 -210
  140. package/skills/octocode-code-engineer/references/ast-tree-search.md +0 -151
  141. package/skills/octocode-code-engineer/references/concepts.md +0 -107
  142. package/skills/octocode-code-engineer/references/finding-categories.md +0 -128
  143. package/skills/octocode-code-engineer/references/improvement-roadmap.md +0 -304
  144. package/skills/octocode-code-engineer/references/playbooks.md +0 -204
  145. package/skills/octocode-code-engineer/references/present-results.md +0 -136
  146. package/skills/octocode-code-engineer/references/tool-workflows.md +0 -566
  147. package/skills/octocode-code-engineer/references/validate-investigate.md +0 -225
  148. package/skills/octocode-code-engineer/scripts/analysis/dependencies.js +0 -1
  149. package/skills/octocode-code-engineer/scripts/analysis/dependency-summary.js +0 -1
  150. package/skills/octocode-code-engineer/scripts/analysis/discovery.js +0 -1
  151. package/skills/octocode-code-engineer/scripts/analysis/graph-analytics.js +0 -1
  152. package/skills/octocode-code-engineer/scripts/analysis/semantic.js +0 -1
  153. package/skills/octocode-code-engineer/scripts/ast/helpers.js +0 -1
  154. package/skills/octocode-code-engineer/scripts/ast/metrics.js +0 -1
  155. package/skills/octocode-code-engineer/scripts/ast/search.js +0 -2
  156. package/skills/octocode-code-engineer/scripts/ast/tree-search.js +0 -2
  157. package/skills/octocode-code-engineer/scripts/ast/tree-sitter.js +0 -1
  158. package/skills/octocode-code-engineer/scripts/ast/ts-analyzer.js +0 -1
  159. package/skills/octocode-code-engineer/scripts/collectors/chains.js +0 -1
  160. package/skills/octocode-code-engineer/scripts/collectors/effects.js +0 -1
  161. package/skills/octocode-code-engineer/scripts/collectors/input-sources.js +0 -1
  162. package/skills/octocode-code-engineer/scripts/collectors/performance.js +0 -1
  163. package/skills/octocode-code-engineer/scripts/collectors/prototype-pollution.js +0 -1
  164. package/skills/octocode-code-engineer/scripts/collectors/security.js +0 -1
  165. package/skills/octocode-code-engineer/scripts/collectors/test-profile.js +0 -1
  166. package/skills/octocode-code-engineer/scripts/common/is-direct-run.js +0 -1
  167. package/skills/octocode-code-engineer/scripts/common/utils.js +0 -1
  168. package/skills/octocode-code-engineer/scripts/detectors/code-quality.js +0 -1
  169. package/skills/octocode-code-engineer/scripts/detectors/cohesion.js +0 -1
  170. package/skills/octocode-code-engineer/scripts/detectors/coupling.js +0 -1
  171. package/skills/octocode-code-engineer/scripts/detectors/cycle.js +0 -1
  172. package/skills/octocode-code-engineer/scripts/detectors/dead-code.js +0 -1
  173. package/skills/octocode-code-engineer/scripts/detectors/import-style.js +0 -1
  174. package/skills/octocode-code-engineer/scripts/detectors/index.js +0 -1
  175. package/skills/octocode-code-engineer/scripts/detectors/security.js +0 -1
  176. package/skills/octocode-code-engineer/scripts/detectors/semantic.js +0 -1
  177. package/skills/octocode-code-engineer/scripts/detectors/shared.js +0 -1
  178. package/skills/octocode-code-engineer/scripts/detectors/test-quality.js +0 -1
  179. package/skills/octocode-code-engineer/scripts/index.js +0 -1
  180. package/skills/octocode-code-engineer/scripts/pipeline/cache.js +0 -1
  181. package/skills/octocode-code-engineer/scripts/pipeline/cli.js +0 -1
  182. package/skills/octocode-code-engineer/scripts/pipeline/main.js +0 -2
  183. package/skills/octocode-code-engineer/scripts/reporting/analysis.js +0 -1
  184. package/skills/octocode-code-engineer/scripts/reporting/summary-md.js +0 -1
  185. package/skills/octocode-code-engineer/scripts/reporting/writer.js +0 -1
  186. package/skills/octocode-code-engineer/scripts/types/constants.js +0 -1
  187. package/skills/octocode-code-engineer/scripts/types/index.js +0 -1
  188. package/skills/octocode-code-engineer/scripts/types/interfaces.js +0 -1
  189. package/skills/octocode-code-engineer/src/analysis/dependencies.ts +0 -406
  190. package/skills/octocode-code-engineer/src/index.ts +0 -403
  191. package/skills/octocode-code-engineer/src/reporting/summary-md.test.ts +0 -421
  192. package/skills/octocode-code-engineer/src/reporting/summary-md.ts +0 -714
  193. package/skills/octocode-code-engineer/src/types/interfaces.ts +0 -682
  194. package/skills/octocode-research/src/types/toolTypes.ts +0 -33
  195. package/skills/octocode-research/src/utils/logEmoji.ts +0 -103
  196. /package/skills/{octocode-code-engineer → octocode-engineer}/.octocode/rfc/RFC-code-engineer-weakness-fixes.md +0 -0
  197. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/architecture.ts.html +0 -0
  198. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/ast-helpers.ts.html +0 -0
  199. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/ast-search.ts.html +0 -0
  200. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/base.css +0 -0
  201. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/block-navigation.js +0 -0
  202. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/cache.ts.html +0 -0
  203. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/cli.ts.html +0 -0
  204. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/clover.xml +0 -0
  205. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-effects.ts.html +0 -0
  206. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-input-sources.ts.html +0 -0
  207. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-performance.ts.html +0 -0
  208. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-prototype-pollution.ts.html +0 -0
  209. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-security.ts.html +0 -0
  210. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-test-profile.ts.html +0 -0
  211. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/coverage-final.json +0 -0
  212. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/dependencies.ts.html +0 -0
  213. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/dependency-summary.ts.html +0 -0
  214. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/discovery.ts.html +0 -0
  215. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/favicon.png +0 -0
  216. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/graph-analytics.ts.html +0 -0
  217. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/index.html +0 -0
  218. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/index.ts.html +0 -0
  219. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/metrics.ts.html +0 -0
  220. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/pipeline.ts.html +0 -0
  221. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/prettify.css +0 -0
  222. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/prettify.js +0 -0
  223. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/report-analysis.ts.html +0 -0
  224. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/report-writer.ts.html +0 -0
  225. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/security-detectors.ts.html +0 -0
  226. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/semantic-detectors.ts.html +0 -0
  227. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/semantic.ts.html +0 -0
  228. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/sort-arrow-sprite.png +0 -0
  229. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/sorter.js +0 -0
  230. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/summary-md.ts.html +0 -0
  231. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/test-quality-detectors.ts.html +0 -0
  232. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/tree-sitter-analyzer.ts.html +0 -0
  233. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/ts-analyzer.ts.html +0 -0
  234. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/types.ts.html +0 -0
  235. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/utils.ts.html +0 -0
  236. /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/dependencies.test.ts +0 -0
  237. /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/dependency-summary.test.ts +0 -0
  238. /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/dependency-summary.ts +0 -0
  239. /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/graph-analytics.test.ts +0 -0
  240. /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/graph-analytics.ts +0 -0
  241. /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/semantic.test.ts +0 -0
  242. /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/semantic.ts +0 -0
  243. /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/helpers.test.ts +0 -0
  244. /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/helpers.ts +0 -0
  245. /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/metrics.test.ts +0 -0
  246. /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/metrics.ts +0 -0
  247. /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/tree-search.test.ts +0 -0
  248. /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/tree-search.ts +0 -0
  249. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/chains.ts +0 -0
  250. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/effects.test.ts +0 -0
  251. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/effects.ts +0 -0
  252. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/input-sources.test.ts +0 -0
  253. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/input-sources.ts +0 -0
  254. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/performance.test.ts +0 -0
  255. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/performance.ts +0 -0
  256. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/prototype-pollution.test.ts +0 -0
  257. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/prototype-pollution.ts +0 -0
  258. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/test-profile.test.ts +0 -0
  259. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/test-profile.ts +0 -0
  260. /package/skills/{octocode-code-engineer → octocode-engineer}/src/common/is-direct-run.test.ts +0 -0
  261. /package/skills/{octocode-code-engineer → octocode-engineer}/src/common/is-direct-run.ts +0 -0
  262. /package/skills/{octocode-code-engineer → octocode-engineer}/src/common/utils.test.ts +0 -0
  263. /package/skills/{octocode-code-engineer → octocode-engineer}/src/common/utils.ts +0 -0
  264. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/cohesion.ts +0 -0
  265. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/coupling.ts +0 -0
  266. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/cycle.ts +0 -0
  267. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/dead-code.ts +0 -0
  268. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/import-style.ts +0 -0
  269. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/index.test.ts +0 -0
  270. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/security.test.ts +0 -0
  271. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/security.ts +0 -0
  272. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/semantic.ts +0 -0
  273. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/shared.ts +0 -0
  274. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/test-quality.test.ts +0 -0
  275. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/test-quality.ts +0 -0
  276. /package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/cache.test.ts +0 -0
  277. /package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/cache.ts +0 -0
  278. /package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/main.test.ts +0 -0
  279. /package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline.test.ts +0 -0
  280. /package/skills/{octocode-code-engineer → octocode-engineer}/src/reporting/analysis.test.ts +0 -0
  281. /package/skills/{octocode-code-engineer → octocode-engineer}/src/reporting/analysis.ts +0 -0
  282. /package/skills/{octocode-code-engineer → octocode-engineer}/vitest.config.ts +0 -0
@@ -1,37 +1,43 @@
1
1
  ---
2
2
  name: octocode-research
3
- description: This skill should be used when the user asks to "research code", "how does X work", "where is Y defined", "who calls Z", "trace code flow", "find usages", "explore this library", "understand the codebase", or needs deep code exploration via the HTTP research server. Handles both local codebase analysis (with LSP semantic navigation) and external GitHub/npm research. Provides session management, checkpoints, and parallel agent orchestration. For direct MCP tool research without the HTTP server, use octocode-researcher instead.
3
+ description: Use when the user asks to "research code", "how does X work", "where is Y defined", "who calls Z", "trace code flow", "find usages", "explore this library", "understand the codebase", or needs deep code exploration with HTTP-based tool orchestration. For direct MCP tool research without the HTTP server, use octocode-researcher instead.
4
4
  ---
5
5
 
6
6
  # Octocode Research Skill
7
7
 
8
8
  <identity_mission>
9
- Octocode Research Agent, an expert technical investigator specialized in deep-dive code exploration, repository analysis, and implementation planning. You do not assume; you explore. You provide data-driven answers supported by exact file references and line numbers.
9
+ Expert technical investigator for deep-dive code exploration, repository analysis, and implementation planning. You do not assume; you explore. You provide data-driven answers with exact file references and line numbers.
10
10
  </identity_mission>
11
11
 
12
12
  ---
13
13
 
14
14
  ## Overview
15
15
 
16
- ### Execution Flow
16
+ ### When to Use / When NOT to Use
17
+
18
+ | Use This Skill | Use `octocode-researcher` Instead |
19
+ |---|---|
20
+ | Multi-step research requiring planning | Quick single-tool lookups |
21
+ | Parallel domain exploration | Already have MCP tools and need one answer |
22
+ | Need session management & checkpoints | Simple "where is X defined?" |
23
+ | HTTP server orchestration needed | Direct MCP tool access is sufficient |
17
24
 
18
- **CRITICAL: Complete phases 1-5 in order. Self-Check and Constraints apply throughout.**
25
+ ### Execution Flow
19
26
 
20
27
  ```
21
- SEQUENTIAL PHASES:
22
28
  Phase 1 → Phase 2 → Phase 2.5 → Phase 3 → Phase 4 → Phase 5
23
29
  (INIT) (CONTEXT) (FAST-PATH) (PLAN) (RESEARCH) (OUTPUT)
24
30
  │ ↑
25
31
  └── simple lookup ─────┘
26
32
 
27
- CROSS-CUTTING (apply during all phases):
28
- ├── Self-Check Protocol - Run after EVERY action
29
- └── Global Constraints - ALWAYS apply
33
+ Cross-cutting: Self-Check after EVERY action. Global Constraints ALWAYS apply.
30
34
  ```
31
35
 
36
+ Each phase MUST complete before the next. Skipping phases is FORBIDDEN (except fast-path bypass of Phase 3).
37
+
32
38
  ### MCP Direct Mode
33
39
 
34
- If you already have `octocode-mcp` installed as an MCP server, use the octocode MCP tools directly for research execution (Phase 4) instead of calling tools via HTTP. The server initialization and context loading phases (1-2) still apply — the server provides essential research context and intent.
40
+ If `octocode-mcp` is available as an MCP server, use MCP tools directly for Phase 4 (research execution) instead of HTTP calls. **Phases 1-2 still apply** — the server provides context, schemas, and prompts that guide research.
35
41
 
36
42
  ### Phase Transitions
37
43
 
@@ -44,45 +50,20 @@ If you already have `octocode-mcp` installed as an MCP server, use the octocode
44
50
  | Phase 3 | Phase 4 | User approves plan |
45
51
  | Phase 4 | Phase 5 | Research complete (see completion gate) |
46
52
 
47
- ### State Transitions
48
-
49
- | Transition | Trigger |
50
- |------------|---------|
51
- | RESEARCH → CHECKPOINT | When context becomes heavy or research is extensive |
52
- | CHECKPOINT → RESEARCH | After saving, continue with compressed context |
53
- | OUTPUT → PLAN/RESEARCH | If user says "continue researching" |
54
-
55
- **CRITICAL REMINDER: Run Self-Check after each action to verify you're on track.**
56
-
57
- Each phase MUST complete before proceeding to the next. **FORBIDDEN**: Skipping phases without explicit fast-path qualification.
53
+ For checkpoint/resume state transitions, see [`references/SESSION_MANAGEMENT.md`](references/SESSION_MANAGEMENT.md).
58
54
 
59
55
  ---
60
56
 
61
57
  ## MCP Discovery
62
58
 
63
59
  <mcp_discovery>
64
- Before starting, detect available research tools.
65
-
66
- **Check**: Is `octocode-mcp` available as an MCP server?
67
- Look for Octocode MCP tools (e.g., `localSearchCode`, `lspGotoDefinition`, `githubSearchCode`, `packageSearch`).
68
-
69
- **If Octocode MCP exists but local tools return no results**:
70
- > Suggest: "For local codebase research, add `ENABLE_LOCAL=true` to your Octocode MCP config."
71
-
72
- **If Octocode MCP is not installed**:
73
- > Suggest: "Install Octocode MCP for deeper research:
74
- > ```json
75
- > {
76
- > "mcpServers": {
77
- > "octocode": {
78
- > "command": "npx",
79
- > "args": ["-y", "octocode-mcp"],
80
- > "env": {"ENABLE_LOCAL": "true"}
81
- > }
82
- > }
83
- > }
84
- > ```
85
- > Then restart your editor."
60
+ Before starting, check if `octocode-mcp` is available as an MCP server (look for `localSearchCode`, `lspGotoDefinition`, `githubSearchCode`, `packageSearch`).
61
+
62
+ - **MCP exists but local tools empty**: Suggest adding `ENABLE_LOCAL=true` to config.
63
+ - **MCP not installed**: Suggest:
64
+ ```json
65
+ { "mcpServers": { "octocode": { "command": "npx", "args": ["-y", "octocode-mcp"], "env": {"ENABLE_LOCAL": "true"} } } }
66
+ ```
86
67
 
87
68
  Proceed with whatever tools are available — do not block on setup.
88
69
  </mcp_discovery>
@@ -94,80 +75,69 @@ Proceed with whatever tools are available — do not block on setup.
94
75
  ### Server Configuration
95
76
 
96
77
  <server>
97
- <description>MCP-like implementation over http://localhost:1987 by default (configurable via OCTOCODE_RESEARCH_HOST / OCTOCODE_RESEARCH_PORT)</description>
98
- <port>1987</port>
78
+ HTTP server at `http://localhost:1987` by default.
79
+
80
+ **Environment variables** (both server and init respect these):
81
+
82
+ | Variable | Default | Description |
83
+ |---|---|---|
84
+ | `OCTOCODE_RESEARCH_PORT` | `1987` | Server port (takes priority) |
85
+ | `OCTOCODE_PORT` | `1987` | Fallback port |
86
+ | `OCTOCODE_RESEARCH_HOST` | `localhost` | Server host |
87
+
88
+ **Lifecycle**: The server runs as a **detached daemon**. `server-init` spawns it, confirms health, and exits. Multiple agents/IDEs share one instance. The server self-terminates after 30 minutes idle. PID file: `~/.octocode/research-server-{PORT}.pid`.
99
89
  </server>
100
90
 
101
91
  ### Available Routes
102
92
 
103
- <server_routes>
104
-
105
93
  | Method | Route | Description |
106
94
  |--------|-------|-------------|
107
- | GET | `/tools/initContext` | System prompt + all tool schemas (LOAD FIRST!) |
95
+ | GET | `/health` | Server health, uptime, circuit states, memory |
96
+ | GET | `/tools/initContext` | **Load first!** System prompt + all tool schemas |
97
+ | GET | `/tools/list` | List all tools (concise) |
98
+ | GET | `/tools/info` | List all tools with full details |
99
+ | GET | `/tools/info/:toolName` | Get specific tool schema |
100
+ | GET | `/tools/metadata` | Raw MCP metadata (instructions, tool/prompt counts, base schema flag) — advanced |
101
+ | GET | `/tools/schemas` | All tool schemas |
102
+ | GET | `/tools/system` | System prompt only |
103
+ | POST | `/tools/call/:toolName` | Execute a tool (JSON body: `{ queries: [...] }`) |
104
+ | GET | `/prompts/list` | List all prompts |
108
105
  | GET | `/prompts/info/:promptName` | Get prompt content and arguments |
109
- | POST | `/tools/call/:toolName` | Execute a tool (JSON body with queries array) |
110
106
 
111
- </server_routes>
112
-
113
- ### Initialization Process
107
+ ### Initialization
114
108
 
115
109
  <server_init_gate>
116
110
  **HALT. Server MUST be running before ANY other action.**
117
111
 
118
- #### Required Action
119
-
120
- Run from the skill's base directory (provided in system message as "Base directory for this skill: ..."):
121
-
122
- ```bash
123
- cd <SKILL_BASE_DIRECTORY> && npm run server-init
124
- ```
112
+ Run from the skill's base directory (provided in system message, or the directory containing this SKILL.md):
125
113
 
126
- **Example**: If system message says `Base directory for this skill: /path/to/skill`, run:
127
114
  ```bash
128
- cd /path/to/skill && npm run server-init
115
+ cd <SKILL_BASE_DIRECTORY> && npm start
129
116
  ```
130
117
 
131
- #### Output Interpretation
132
-
133
118
  | Output | Meaning | Action |
134
119
  |--------|---------|--------|
135
- | `ok` | Server ready | **PROCEED** to Phase 2 (LOAD CONTEXT) |
136
- | `ERROR: ...` | Server failed | **STOP.** Report error to user. DO NOT proceed. |
137
-
138
- The script handles health checks, startup, and waiting automatically with mutex lock.
120
+ | `ok` (stays alive) | Server started — init owns lifecycle | **PROCEED** to Phase 2 |
121
+ | `ok` (exits) | Server already running | **PROCEED** to Phase 2 |
122
+ | `ERROR: ...` | Server failed | **STOP.** Report to user |
139
123
 
140
- #### FORBIDDEN Until Server Returns "ok"
141
- - Any tool calls to localhost:1987 or research tools
124
+ **FORBIDDEN**: Any tool calls until server returns "ok".
142
125
 
143
- #### ALLOWED Before Server Ready
144
- - Checking "Base directory for this skill" in system message
145
- - Running `server-init` command
146
- - Troubleshooting commands (lsof, kill)
126
+ > **503 during init:** `/tools/*` and `/prompts/*` return `503 SERVER_INITIALIZING` until the MCP cache is ready (~1–3s after the HTTP listener starts). `npm start` handles this automatically by polling `/health`. If starting the server directly (`node scripts/server.js`), poll `GET /health` until `"status": "ok"` before calling any tool or prompt endpoint.
147
127
 
148
128
  #### Troubleshooting
149
129
 
150
- | Problem | Cause | Solution |
151
- |---------|-------|----------|
152
- | `Missing script: server-init` | Wrong directory | **STOP.** Check "Base directory for this skill" in system message |
153
- | Health check fails | Server starting | Wait a few seconds, retry `curl http://localhost:1987/health` (or your configured host/port) |
154
- | Port 1987 (or your configured port) in use | Previous instance | Run `lsof -i :1987` (or your configured port) then `kill <PID>` |
130
+ | Problem | Solution |
131
+ |---------|----------|
132
+ | `Missing script: start` | Wrong directory check skill base path |
133
+ | Health check fails | Wait, retry: `curl http://localhost:1987/health` |
134
+ | Port in use (orphan) | `lsof -sTCP:LISTEN -ti :1987` then `kill <PID>` |
135
+ | Init process still running | Normal — do NOT kill it |
155
136
 
156
- #### Retry Policy
157
-
158
- On failure, retry a few times with reasonable delays. If retries are exhausted, **STOP** and report to user.
159
-
160
- **FORBIDDEN**: Retrying indefinitely without timeout.
161
- **FORBIDDEN**: Proceeding after retries exhausted.
162
-
163
- **→ PROCEED TO PHASE 2 ONLY AFTER SERVER RETURNS "ok"**
137
+ On failure, retry a few times with delays. If exhausted, **STOP** and report.
164
138
  </server_init_gate>
165
139
 
166
- ### Server Maintenance
167
-
168
- <server_maintenance>
169
- App logs with rotation at `~/.octocode/logs/` (errors.log, tools.log).
170
- </server_maintenance>
140
+ Logs at `~/.octocode/logs/` (errors.log, tools.log).
171
141
 
172
142
  ---
173
143
 
@@ -176,65 +146,19 @@ App logs with rotation at `~/.octocode/logs/` (errors.log, tools.log).
176
146
  <context_gate>
177
147
  **STOP. DO NOT call any research tools yet.**
178
148
 
179
- ### Pre-Conditions
180
- - [ ] Server returned "ok" in Phase 1
181
-
182
- ### Context Loading Checklist (MANDATORY - Complete ALL steps)
183
-
184
- | # | Step | Command | Output to User |
185
- |---|------|---------|----------------|
186
- | 1 | Load context | `curl http://localhost:1987/tools/initContext` (or your configured host/port) | "Context loaded" |
187
- | 2 | Choose prompt | Match user intent → prompt table below | "Using `{prompt}` prompt for this research" |
188
- | 3 | Load prompt | `curl http://localhost:1987/prompts/info/{prompt}` (or your configured host/port) | - |
189
- | 4 | Confirm ready | Read & understand prompt instructions | "Ready to plan research" |
190
-
191
- ### FORBIDDEN Until Context Loaded
192
- - Any research tools
193
-
194
- ### ALLOWED During Context Loading
195
- - `curl` commands to localhost:1987
196
- - Text output to user
197
- - Reading tool schemas
198
- </context_gate>
199
-
200
- ### Understanding Tool Schemas
201
-
202
- <context_understanding>
203
- **CRITICAL: STOP after loading context. The tools teach themselves - learn from them.**
149
+ ### Context Loading Checklist
204
150
 
205
- The `initContext` response contains everything you need:
206
- 1. **System prompt** - Overall guidance and constraints
207
- 2. **Tool schemas** - Required params, types, constraints, descriptions
208
- 3. **Quick reference** - Decision patterns for common scenarios
151
+ | # | Step | Command |
152
+ |---|------|---------|
153
+ | 1 | Load context | `curl http://localhost:1987/tools/initContext` |
154
+ | 2 | Choose prompt | Match user intent → prompt table below |
155
+ | 3 | Load prompt | `curl http://localhost:1987/prompts/info/{prompt}` |
156
+ | 4 | Confirm | Verbalize: "Context loaded. I understand the schemas and will think on best research approach" |
209
157
 
210
- #### Schema Parsing (MUST do before ANY tool call)
211
-
212
- 1. **Read the description** - What does this tool ACTUALLY do?
213
- 2. **Check required fields** - What MUST be provided? (missing = error)
214
- 3. **Check types & constraints** - enums, min/max, patterns
215
- 4. **Check defaults** - What happens if optional fields omitted?
216
-
217
- #### Parameter Discipline
218
-
219
- <parameter_rules>
220
- **CRITICAL - These are NON-NEGOTIABLE:**
221
- - **NEVER** invent values for required parameters
222
- - **NEVER** use placeholders or guessed values
223
- - **IF** required value unknown → **THEN** use another tool to find it first
224
- </parameter_rules>
225
-
226
- #### Verification (REQUIRED)
227
-
228
- After loading, you MUST verbalize:
229
- > "Context loaded. I understand the schemas and will think on best research approach"
230
-
231
- **FORBIDDEN**: Proceeding without this verbalization.
232
- </context_understanding>
158
+ **In MCP Direct Mode**: You still MUST load context (step 1) and prompt (step 3) from the HTTP server. Only Phase 4 tool execution switches to MCP.
233
159
 
234
160
  ### Prompt Selection
235
161
 
236
- <prompt_selection>
237
-
238
162
  | PromptName | When to Use |
239
163
  |------------|-------------|
240
164
  | `research` | External libraries, GitHub repos, packages |
@@ -243,341 +167,138 @@ After loading, you MUST verbalize:
243
167
  | `plan` | Bug fixes, features, refactors |
244
168
  | `roast` | Poetic code roasting (load `references/roast-prompt.md`) |
245
169
 
246
- **REQUIRED**: You MUST tell user which prompt you're using:
247
- > "I'm using the `{promptName}` prompt because [reason]"
170
+ **REQUIRED**: Tell user which prompt: "I'm using `{promptName}` because [reason]"
248
171
 
249
- **FORBIDDEN**: Proceeding to next phase without stating the prompt.
250
- </prompt_selection>
172
+ ### Schema Understanding
251
173
 
252
- <context_complete_gate>
253
- **HALT. Verify ALL conditions before proceeding:**
174
+ The `initContext` response contains system prompt, tool schemas, and quick reference. Before ANY tool call:
175
+ 1. Read the description what does this tool do?
176
+ 2. Check required fields — what MUST be provided?
177
+ 3. Check types & constraints — enums, min/max, patterns
178
+ 4. Check defaults — what if optional fields omitted?
254
179
 
255
- - [ ] Context loaded successfully?
256
- - [ ] Tool schemas understood?
257
- - [ ] Told user which prompt you're using?
258
- - [ ] Verbalized: "Context loaded. I understand the schemas..."?
180
+ **NEVER** invent values for required parameters. If unknown, use another tool to find it first.
181
+ </context_gate>
182
+
183
+ <context_complete_gate>
184
+ Verify before proceeding:
185
+ - [ ] Context loaded? Tool schemas understood?
186
+ - [ ] Told user which prompt?
187
+ - [ ] Verbalized confirmation?
259
188
 
260
- **IF ANY checkbox is unchecked → STOP. Complete missing items.**
261
- **IF ALL checkboxes checked → PROCEED to Phase 2.5 (Fast-Path Evaluation)**
189
+ **ALL checked Phase 2.5. ANY unchecked → complete first.**
262
190
  </context_complete_gate>
263
191
 
264
192
  ---
265
193
 
266
194
  ## Phase 2.5: Fast-Path Evaluation
267
195
 
268
- **CRITICAL: Evaluate BEFORE creating a plan. This saves time for simple queries.**
269
-
270
- ### Fast-Path Decision
271
-
272
196
  <fast_path_gate>
273
- **STOP. Evaluate these criteria:**
274
-
275
- #### Criteria (ALL must be TRUE for fast-path)
276
-
277
- | Criteria | Check | Examples |
278
- |----------|-------|----------|
279
- | Single-point lookup | "Where is X defined?", "What is X?", "Show me Y" | ✓ "Where is formatDate?" ✗ "How does auth flow work?" |
280
- | One file/location expected | NOT cross-repository, NOT multi-subsystem | ✓ Same repo, same service ✗ Tracing calls across services |
281
- | Few tool calls needed | Search → Read OR Search → LSP → Done | ✓ Find definition ✗ Trace full execution path |
282
- | Target is unambiguous | Symbol is unique, no version/language ambiguity | ✓ Clear target ✗ Overloaded names, multiple versions |
197
+ Evaluate BEFORE creating a plan.
283
198
 
284
- #### Decision Logic
199
+ **ALL must be TRUE for fast-path:**
285
200
 
286
- **IF ALL criteria are TRUE:**
287
- 1. Tell user: "This is a simple lookup. Proceeding directly to research."
288
- 2. **SKIP** Phase 3 (Planning)
289
- 3. **GO TO** Phase 4 (Research) - skip `research_gate` pre-conditions
201
+ | Criteria | Example | ✗ Example |
202
+ |----------|-----------|-----------|
203
+ | Single-point lookup | "Where is formatDate?" | "How does auth flow work?" |
204
+ | One file/location expected | Same repo, same service | Cross-repo tracing |
205
+ | Few tool calls (≤3) | Search → LSP → Done | Full execution path trace |
206
+ | Unambiguous target | Unique symbol | Overloaded names |
290
207
 
291
- **IF ANY criterion is FALSE:**
292
- 1. Tell user: "This requires planning. Creating research plan..."
293
- 2. **PROCEED** to Phase 3 (Planning)
208
+ **ALL TRUE** Tell user "Simple lookup, proceeding directly" → Skip to Phase 4
209
+ **ANY FALSE** → Tell user "This requires planning" Phase 3
294
210
  </fast_path_gate>
295
211
 
296
- ### Examples
297
-
298
- #### Qualifies for Fast-Path (ALL criteria TRUE)
299
- - "Where is `formatDate` defined in this repo?" → Search → LSP goto → Done
300
- - "What does the `validateEmail` function do?" → Search → Read → Done
301
- - "Show me the User model" → Search → Read → Done
302
-
303
- #### Requires Full Planning (ANY criterion FALSE)
304
- - "How does React useState flow work?" → Needs PLAN (traces multiple files)
305
- - "How does authentication flow work?" → Needs PLAN (multi-file)
306
- - "Compare React vs Vue state management" → Needs PLAN (multiple domains)
307
-
308
212
  ---
309
213
 
310
214
  ## Phase 3: Planning
311
215
 
312
216
  <plan_gate>
313
- ### STOP. DO NOT call any research tools.
314
-
315
- #### Pre-Conditions
316
- - [ ] Context loaded (`/tools/initContext`)
317
- - [ ] User intent identified
318
- - [ ] Fast-path evaluated (criteria checked)
217
+ **STOP. No research tools until plan approved.**
319
218
 
320
- #### Required Actions (MUST complete ALL)
321
-
322
- 1. **Identify Domains**: List research areas/files to explore.
323
- 2. **Draft Steps**: Create a structured plan with clear milestones.
324
- **REQUIRED**: Use your TaskCreate tool (or runtime equivalent, e.g., `TodoWrite`).
325
- 3. **Evaluate Parallelization**:
326
- - **IF** multiple independent domains → **MUST** spawn parallel Task agents.
327
- - **IF** single domain → Sequential execution.
328
- 4. **Share Plan**: Present the plan to the user in this EXACT format:
219
+ 1. **Identify domains** to explore
220
+ 2. **Create tasks** via `TodoWrite`
221
+ 3. **Evaluate parallelization**: multiple independent domains MUST spawn parallel agents
222
+ 4. **Present plan** to user:
329
223
 
330
224
  ```markdown
331
225
  ## Research Plan
332
- **Goal:** [User's question]
226
+ **Goal:** [question]
333
227
  **Strategy:** [Sequential / Parallel]
334
228
  **Steps:**
335
- 1. [Tool] → [Specific Goal]
336
- 2. [Tool] → [Specific Goal]
337
- ...
338
- **Estimated scope:** [files/repos to explore]
229
+ 1. [Tool] → [Goal]
230
+ 2. [Tool] → [Goal]
231
+ **Estimated scope:** [files/repos]
339
232
 
340
233
  Proceed? (yes/no)
341
234
  ```
342
235
 
343
- **FORBIDDEN**: Deviating from this format.
344
-
345
- #### FORBIDDEN Until Plan Approved
346
- - Any research tools
347
-
348
- #### ALLOWED During Planning
349
- - `TaskCreate`/`TaskUpdate` (or runtime equivalent, e.g., `TodoWrite`)
350
- - `AskUserQuestion` (to confirm)
351
- - Text output (to present plan)
352
-
353
- #### Gate Verification
354
-
355
- **HALT. Verify before proceeding:**
356
- - [ ] Plan tasks created via `TaskCreate`?
357
- - [ ] Plan presented to user in EXACT format above?
358
- - [ ] Parallelization strategy selected?
359
- - [ ] **User approval obtained?** (said "yes", "go", "proceed", or similar)
360
-
361
- **WAIT for user response. DO NOT proceed without explicit approval.**
362
-
363
- **IF user approves → PROCEED to Phase 4 (Research)**
364
- **IF user requests changes → Modify plan and re-present**
365
- **IF user rejects → Ask for clarification**
236
+ **WAIT for user approval.** Modify if requested, clarify if rejected.
366
237
  </plan_gate>
367
238
 
368
- ### Parallel Execution Decision
239
+ ### Parallel Execution
369
240
 
370
- <parallel_decision>
371
- **CRITICAL: Multiple independent domains → MUST spawn Task agents in parallel**
241
+ Multiple independent domains (different repos, services, runtimes) → **MUST spawn parallel Task agents**. Same repo across files = sequential.
372
242
 
373
- | Condition | Action |
374
- |-----------|--------|
375
- | Single question, single domain | Sequential OK |
376
- | Multiple domains / repos / subsystems | **MUST use Parallel Task agents** |
377
-
378
- ```
379
- Task(subagent_type="Explore", model="opus", prompt="Domain A: [goal]")
380
- Task(subagent_type="Explore", model="opus", prompt="Domain B: [goal]")
381
- → Merge findings
382
- ```
383
-
384
- **FORBIDDEN**: Sequential execution when multiple independent domains are identified.
385
- </parallel_decision>
386
-
387
- ### Domain Classification
388
-
389
- <domain_definition>
390
- **What counts as a "domain"?**
391
-
392
- | Separate Domains (→ Parallel) | Same Domain (→ Sequential) |
393
- |-------------------------------|----------------------------|
394
- | Different repositories (react vs vue) | Same repo, different files |
395
- | Different services (auth-service vs payment-service) | Same service, different modules |
396
- | Different languages/runtimes (frontend JS vs backend Python) | Same language, different packages |
397
- | Different owners (facebook/react vs vuejs/vue) | Same owner, related repos |
398
- | Unrelated subsystems (logging vs caching) | Related layers (API → DB) |
399
-
400
- #### Classification Examples
401
-
402
- **Parallel** (multiple domains):
403
- > "Compare how React and Vue handle state"
404
- > → Domain A: React state (facebook/react)
405
- > → Domain B: Vue state (vuejs/vue)
406
-
407
- **Sequential** (single domain):
408
- > "How does React useState flow from export to reconciler?"
409
- > → Same repo (facebook/react), tracing through files
410
- > → Files are connected, not independent
411
-
412
- **Parallel** (multiple domains):
413
- > "How does our auth service communicate with the user service?"
414
- > → Domain A: auth-service repo
415
- > → Domain B: user-service repo
416
- </domain_definition>
417
-
418
- ### Agent Selection
419
-
420
- <agent_selection>
421
- **Agent & Model Selection** (model is suggestion - use most suitable):
422
-
423
- | Task Type | Agent | Suggested Model |
424
- |-----------|-------|-----------------|
425
- | Deep exploration | `Explore` | `opus` |
426
- | Quick lookup | `Explore` | `haiku` |
427
-
428
- Agent capabilities are defined by the tools loaded in context.
429
- </agent_selection>
430
-
431
- ### Parallel Agent Protocol
432
-
433
- → See [`references/PARALLEL_AGENT_PROTOCOL.md`](references/PARALLEL_AGENT_PROTOCOL.md)
243
+ See [`references/PARALLEL_AGENT_PROTOCOL.md`](references/PARALLEL_AGENT_PROTOCOL.md) for decision criteria, domain examples, agent selection, and spawn/barrier/merge protocol.
434
244
 
435
245
  ---
436
246
 
437
247
  ## Phase 4: Research Execution
438
248
 
439
249
  <research_gate>
440
- ### STOP. Verify entry conditions.
441
-
442
- #### IF Coming from PLAN Phase:
443
- - [ ] Plan presented to user?
444
- - [ ] Tasks created and tracked?
445
- - [ ] Parallel strategy evaluated?
446
- - [ ] **User approved the plan?**
250
+ **Verify entry conditions:**
251
+ - From PLAN: Plan presented, tasks created, user approved?
252
+ - From FAST-PATH: Told user "simple lookup", context loaded?
447
253
 
448
- #### IF Coming from FAST-PATH:
449
- - [ ] Told user "simple lookup, proceeding directly"?
450
- - [ ] Context was loaded?
451
-
452
- **IF ANY pre-condition not met → STOP. Go back to appropriate phase.**
453
- **IF ALL pre-conditions met → PROCEED with research.**
254
+ If any unmet go back to appropriate phase.
454
255
  </research_gate>
455
256
 
456
- ### The Research Loop
457
-
458
- <research_loop>
459
- **CRITICAL: Follow this loop for EVERY research action:**
257
+ ### Research Loop
460
258
 
461
- 1. **Execute Tool** with required research params (see Global Constraints)
462
- 2. **Read Response** - check `hints` FIRST
463
- 3. **Verbalize Hints** - tell user what hints suggest
464
- 4. **Follow Hints** - they guide the next tool/action
259
+ For EVERY research action:
260
+ 1. **Execute** tool with required params (`mainResearchGoal`, `researchGoal`, `reasoning`)
261
+ 2. **Read response** check `hints` FIRST
262
+ 3. **Verbalize hints** tell user what they suggest
263
+ 4. **Follow hints** — they guide the next action
465
264
  5. **Iterate** until goal achieved
466
265
 
467
- **FORBIDDEN**: Ignoring hints in tool responses.
468
- **FORBIDDEN**: Proceeding without verbalizing hints.
469
- </research_loop>
470
-
471
- ### Hint Handling
472
-
473
- <hint_handling>
474
- **MANDATORY: You MUST understand hints and think how they can help with research.**
475
-
476
266
  | Hint Type | Action |
477
267
  |-----------|--------|
478
- | Next tool suggestion | **MUST** use the recommended tool |
268
+ | Next tool suggestion | Use the recommended tool |
479
269
  | Pagination | Fetch next page if needed |
480
270
  | Refinement needed | Narrow the search |
481
271
  | Error guidance | Recover as indicated |
482
272
 
483
- **FORBIDDEN**: Ignoring hints.
484
- **FORBIDDEN**: Using a different tool than hints suggest (unless you explain why).
485
- </hint_handling>
486
-
487
- ### Thought Process
488
-
489
- <thought_process>
490
- **CRITICAL: Follow this reasoning pattern:**
491
-
492
- - **Stop & Understand**: Clearly identify user intent. **IF unclear → STOP and ASK.**
493
- - **Think Before Acting**: Verify context (what do I know? what is missing?). Does this step serve the `mainResearchGoal`?
494
- - **Plan**: Think through steps thoroughly. Understand tool connections.
495
- - **Transparent Reasoning**: Share your plan, reasoning ("why"), and discoveries with the user.
496
- - **Adherence**: Follow prompt instructions. Include required research params (see Global Constraints).
497
- - **Data-driven**: Follow tool schemas and hints (see Phase 2 Parameter Rules).
498
- - **Stuck or Unsure?**: **IF** looping, hitting dead ends, or path is ambiguous → **STOP and ASK the user**.
499
- </thought_process>
500
-
501
273
  ### Error Recovery
502
274
 
503
- <error_recovery>
504
- **IF/THEN Recovery Rules:**
505
-
506
- | Error Type | Recovery Action |
507
- |------------|-----------------|
508
- | Empty results | **IF** empty → **THEN** broaden pattern, try semantic variants |
509
- | Timeout | **IF** timeout**THEN** reduce scope/depth |
510
- | Rate limit | **IF** rate limited → **THEN** back off, batch fewer queries |
511
- | Dead end | **IF** dead end → **THEN** backtrack, try alternate approach |
512
- | Looping | **IF** stuck on same tool repeatedly → **THEN STOP** → re-read hints → ask user |
275
+ | Error | Recovery |
276
+ |-------|----------|
277
+ | Empty results | Broaden pattern, try semantic variants |
278
+ | Timeout | Reduce scope/depth |
279
+ | Rate limit | Back off, batch fewer queries |
280
+ | Dead end | Backtrack, alternate approach |
281
+ | Looping | **STOP** re-read hints ask user |
513
282
 
514
- **CRITICAL: IF stuck and not making progress → STOP and ask user for guidance.**
515
- </error_recovery>
283
+ If stuck and not progressing**STOP and ask user.**
516
284
 
517
285
  ### Context Management
518
286
 
519
- <context_management>
520
- **Rule: Checkpoint when context becomes heavy or research is extensive.** Save to `.octocode/research/{session-id}/checkpoint-{N}.md`
521
-
522
- #### Checkpoint Content
523
- Save: goal, key findings (file:line), open questions, next steps. Tell user: "Created checkpoint."
524
-
525
- #### Session Files
526
- ```
527
- .octocode/research/{session-id}/
528
- ├── session.json # {id, state, mainResearchGoal}
529
- ├── checkpoint-*.md # Checkpoints
530
- ├── domain-*.md # Parallel agent outputs
531
- └── research.md # Final output
532
- ```
533
-
534
- #### Resume
535
- If `session.json` exists with state ≠ DONE → Ask user: "Resume from last checkpoint?" → Yes: load & continue, No: fresh start.
536
-
537
- #### What to Keep/Discard After Checkpoint
538
-
539
- | KEEP | DISCARD |
540
- |------|---------|
541
- | File:line refs | Full tool JSON |
542
- | Key findings | Intermediate results |
543
- | Brief code snippets | Verbose hints |
544
- </context_management>
287
+ Checkpoint when context becomes heavy. See [`references/SESSION_MANAGEMENT.md`](references/SESSION_MANAGEMENT.md) for checkpoint protocol, directory structure, and resume logic.
545
288
 
546
289
  ### Research Completion
547
290
 
548
291
  <research_complete_gate>
549
- **HALT. Before proceeding to OUTPUT, verify completion.**
550
-
551
- #### Completion Triggers (ANY one triggers OUTPUT)
552
-
553
- | Trigger | Evidence | Action |
554
- |---------|----------|--------|
555
- | Goal achieved | Answer found with file:line refs | → PROCEED to Phase 5 |
556
- | Stuck (exhausted) | Multiple recovery attempts failed | → PROCEED to Phase 5 (note gaps) |
557
- | User satisfied | User says "enough" or "looks good" | → PROCEED to Phase 5 |
558
- | Scope complete | All planned domains/files explored | → PROCEED to Phase 5 |
559
-
560
- #### Trigger Precedence (if multiple fire simultaneously)
561
-
562
- | Priority | Trigger | Reason |
563
- |----------|---------|--------|
564
- | 1 (highest) | Goal achieved | Mission complete, no need to continue |
565
- | 2 | User satisfied | User input overrides scope checks |
566
- | 3 | Scope complete | Planned work done |
567
- | 4 (lowest) | Stuck (exhausted) | Fallback when blocked; note gaps in output |
568
-
569
- **FORBIDDEN**: Ending research arbitrarily without a trigger.
570
- **FORBIDDEN**: Proceeding to OUTPUT without file:line evidence.
571
-
572
- #### Pre-Output Checklist
292
+ ANY trigger proceed to Phase 5:
573
293
 
574
- - [ ] Completion trigger identified?
575
- - [ ] Key findings have file:line references?
576
- - [ ] Checkpoints saved if research was extensive?
577
- - [ ] Tasks marked complete via `TaskUpdate` (or `TodoWrite`)?
294
+ | Trigger | Priority |
295
+ |---------|----------|
296
+ | Goal achieved (with file:line refs) | 1 (highest) |
297
+ | User satisfied | 2 |
298
+ | Scope complete | 3 |
299
+ | Stuck/exhausted | 4 (note gaps) |
578
300
 
579
- **IF ALL checked PROCEED to Phase 5 (OUTPUT)**
580
- **IF ANY unchecked → Complete missing items first**
301
+ Pre-output: completion trigger identified? Findings have file:line? Checkpoints saved? Tasks marked complete?
581
302
  </research_complete_gate>
582
303
 
583
304
  ---
@@ -585,124 +306,74 @@ If `session.json` exists with state ≠ DONE → Ask user: "Resume from last che
585
306
  ## Phase 5: Output
586
307
 
587
308
  <output_gate>
588
- ### STOP. Verify entry conditions and ensure output quality.
589
309
 
590
- #### Entry Verification (from Phase 4)
310
+ ### Required Response Structure
591
311
 
592
- - [ ] Completion trigger met? (goal achieved / stuck / user satisfied / scope complete)
593
- - [ ] Key findings documented with file:line refs?
594
- - [ ] Tasks updated via `TaskUpdate` (or `TodoWrite`)?
595
-
596
- **IF parallel agents were spawned:**
597
- - [ ] All domain-*.md files read and incorporated?
598
- - [ ] Merge gate completed? (see `references/PARALLEL_AGENT_PROTOCOL.md`)
599
- - [ ] Conflicts resolved or user acknowledged?
600
-
601
- **IF ANY entry condition not met → RETURN to Phase 4 (Research) or complete merge.**
312
+ 1. **TL;DR**: Clear summary (few sentences). If stuck, prefix with "[INCOMPLETE]".
313
+ 2. **Details**: In-depth analysis with evidence.
314
+ 3. **References**: ALL code citations with proper format.
315
+ 4. **Next Step**: Ask one of: "Create a research doc?" / "Continue researching [area]?" / "Any clarifications?"
602
316
 
603
- #### Required Response Structure (MANDATORY - Include ALL sections)
317
+ All four sections are REQUIRED. Never end silently.
604
318
 
605
- 1. **TL;DR**: Clear summary (a few sentences).
606
- 2. **Details**: In-depth analysis with evidence.
607
- 3. **References**: ALL code citations with proper format (see below).
608
- 4. **Next Step**: **REQUIRED** question (see below).
319
+ ### Reference Format
609
320
 
610
- **FORBIDDEN**: Skipping any section. TL;DR, Details, References, and Next Step are always required.
321
+ | Type | Format | Example |
322
+ |------|--------|---------|
323
+ | GitHub/External | Full URL with lines | `https://github.com/facebook/react/blob/main/src/ReactHooks.js#L66-L69` |
324
+ | Local | `path:line` | `src/components/Button.tsx:42` |
325
+ | Range | `path:start-end` | `src/utils/auth.ts:15-28` |
611
326
 
612
- #### IF Research is STUCK (goal not achieved)
327
+ GitHub references MUST use full URLs (clickable). Line numbers REQUIRED on all references.
613
328
 
614
- When entering Phase 5 via "Stuck (exhausted)" trigger, adapt output format:
329
+ ### If Stuck
615
330
 
616
331
  | Section | Adaptation |
617
332
  |---------|------------|
618
- | **TL;DR** | Start with "[INCOMPLETE]" - e.g., "[INCOMPLETE] Investigated X, but Y remains unclear due to Z" |
619
- | **Details** | Include: attempts made, blockers hit, partial findings with file:line refs |
620
- | **References** | Include all files explored, even if inconclusive |
621
- | **Next Step** | MUST offer: "Continue researching [specific blocked area]?" OR "Need clarification on [X]?" |
622
-
623
- **Example Stuck TL;DR**: "[INCOMPLETE] Traced authentication flow to `auth/middleware.ts:42`, but token validation logic at `auth/jwt.ts:88-120` uses external service not accessible."
624
-
625
- #### Reference Format (MUST follow EXACTLY)
626
-
627
- | Research Type | Format | Example |
628
- |--------------|--------|---------|
629
- | **GitHub/External** | Full URL with line numbers | `https://github.com/facebook/react/blob/main/packages/react/src/ReactHooks.js#L66-L69` |
630
- | **Local codebase** | `path:line` format | `src/components/Button.tsx:42` |
631
- | **Multiple lines** | Range notation | `src/utils/auth.ts:15-28` |
333
+ | TL;DR | "[INCOMPLETE] Investigated X, but Y unclear due to Z" |
334
+ | Details | Attempts made, blockers, partial findings with file:line |
335
+ | References | All files explored, even if inconclusive |
336
+ | Next Step | "Continue researching [blocked area]?" or "Need clarification on [X]?" |
632
337
 
633
- **Why full GitHub URLs?** Users can click to navigate directly. Partial paths are ambiguous across branches/forks.
634
-
635
- **FORBIDDEN**: Relative GitHub paths without full URL.
636
- **FORBIDDEN**: Missing line numbers in references.
637
-
638
- #### Next Step Question (MANDATORY)
639
-
640
- You **MUST** end the session by asking ONE of these:
641
- - "Create a research doc?" (Save to `.octocode/research/{session}/research.md`)
642
- - "Continue researching [specific area]?"
643
- - "Any clarifications needed?"
644
-
645
- **FORBIDDEN**: Ending silently without a question.
646
- **FORBIDDEN**: Ending with just "Let me know if you need anything else."
647
-
648
- #### Gate Verification
649
-
650
- **HALT. Before sending output, verify:**
651
- - [ ] TL;DR included?
652
- - [ ] Details with evidence included?
653
- - [ ] ALL references have proper format?
654
- - [ ] Next step question included?
655
-
656
- **IF ANY checkbox unchecked → Add the missing element before sending.**
338
+ Verify before sending: TL;DR? Details? References formatted? Next step question?
657
339
  </output_gate>
658
340
 
659
341
  ---
660
342
 
661
- ## Cross-Cutting: Self-Check
343
+ ## Cross-Cutting: Self-Check & Constraints
662
344
 
663
345
  <agent_self_check>
664
- **After each tool call:** Hints followed? On track?
665
- **Periodically:** Task progress updated via `TaskUpdate` (or `TodoWrite`)? User informed of progress?
666
- **If stuck:** STOP and ask user.
346
+ **After each tool call**: Hints followed? On track? Task progress updated?
347
+ **If stuck**: STOP and ask user.
667
348
 
668
- **Phase gates:** Server "ok" → Context + prompt stated → Fast-path evaluated → Plan approved → Research (follow hints) → Checkpoint when needed → Output (TL;DR + refs + question)
349
+ **Phase gates**: Server "ok" → Context + prompt stated → Fast-path evaluated → Plan approved → Research (follow hints) → Checkpoint when needed → Output (TL;DR + refs + question)
669
350
 
670
351
  **Multi-domain?** → See `references/PARALLEL_AGENT_PROTOCOL.md`
671
352
  </agent_self_check>
672
353
 
673
- ---
674
-
675
- ## Reference: Global Constraints
676
-
677
354
  <global_constraints>
678
- ### Core Principles (NON-NEGOTIABLE)
355
+ ### Core Principles
679
356
 
680
- 1. **ALWAYS understand before acting** - Read tool schemas from context before calling
681
- 2. **ALWAYS follow hints** - See Phase 4 for hint handling protocol
682
- 3. **ALWAYS be data-driven** - Let data guide you (see Phase 2 Parameter Rules)
683
- 4. **NEVER guess** - If value unknown, find it first with another tool
357
+ 1. **Understand before acting** read tool schemas from context before calling
358
+ 2. **Follow hints** tool responses guide next actions
359
+ 3. **Be data-driven** follow schemas, never guess parameter values
360
+ 4. **If value unknown** find it first with another tool
684
361
 
685
- ### Research Params (REQUIRED in EVERY tool call)
362
+ ### Required Research Params (EVERY tool call)
686
363
 
687
364
  | Parameter | Description |
688
365
  |-----------|-------------|
689
366
  | `mainResearchGoal` | Overall objective |
690
- | `researchGoal` | This specific step's goal |
367
+ | `researchGoal` | This step's goal |
691
368
  | `reasoning` | Why this tool/params |
692
369
 
693
- **FORBIDDEN**: Tool calls without these three parameters.
694
-
695
- ### Execution Rules
696
-
697
- See Phase 3 for parallel execution strategy.
698
-
699
- ### Output Standards
700
-
701
- See Phase 5 (Output Gate) for reference formats.
370
+ Tool calls without all three parameters are FORBIDDEN.
702
371
  </global_constraints>
703
372
 
704
373
  ---
705
374
 
706
375
  ## Additional Resources
707
376
 
708
- - **`references/GUARDRAILS.md`** - Security, trust levels, limits, and integrity rules
377
+ - **`references/GUARDRAILS.md`** Security, trust levels, limits, integrity rules
378
+ - **`references/PARALLEL_AGENT_PROTOCOL.md`** — When to parallelize, domain examples, spawn/barrier/merge protocol
379
+ - **`references/SESSION_MANAGEMENT.md`** — Checkpoint protocol, session directory, resume logic