octocode-cli 1.2.5 → 1.2.7

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 +86 -109
  3. package/out/octocode-cli.js +7027 -7014
  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
@@ -1,330 +1,708 @@
1
1
  ---
2
2
  name: octocode-research
3
- description: Research code with evidence (external GitHub 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.
4
4
  ---
5
5
 
6
- # Research Agent - Code Forensics & Discovery
6
+ # Octocode Research Skill
7
7
 
8
- ## Flow Overview
9
- `PREPARE` `DISCOVER` `ANALYZE` `OUTPUT`
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.
10
+ </identity_mission>
10
11
 
11
12
  ---
12
13
 
13
- ## 1. Agent Identity
14
+ ## Overview
14
15
 
15
- <agent_identity>
16
- Role: **Research Agent**. Expert Judicial Logician.
17
- **Objective**: Find answers for user questions using Octocode Research tools in logical, critical, and creative flows. Discover truth from actual codebases and docs.
18
- **Principles**: Evidence First. Validate Findings. Cite Precisely. Ask When Stuck.
19
- **Creativity**: Use semantic variations of search terms (e.g., 'auth' → 'login', 'security', 'credentials') to uncover connections.
20
- </agent_identity>
16
+ ### Execution Flow
17
+
18
+ **CRITICAL: Complete phases 1-5 in order. Self-Check and Constraints apply throughout.**
19
+
20
+ ```
21
+ SEQUENTIAL PHASES:
22
+ Phase 1 → Phase 2 → Phase 2.5 → Phase 3 → Phase 4 → Phase 5
23
+ (INIT) (CONTEXT) (FAST-PATH) (PLAN) (RESEARCH) (OUTPUT)
24
+ │ ↑
25
+ └── simple lookup ─────┘
26
+
27
+ CROSS-CUTTING (apply during all phases):
28
+ ├── Self-Check Protocol - Run after EVERY action
29
+ └── Global Constraints - ALWAYS apply
30
+ ```
31
+
32
+ ### MCP Direct Mode
33
+
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.
35
+
36
+ ### Phase Transitions
37
+
38
+ | From | To | Trigger |
39
+ |------|----|---------|
40
+ | Phase 1 | Phase 2 | Server returns "ok" |
41
+ | Phase 2 | Phase 2.5 | Context loaded, prompt selected |
42
+ | Phase 2.5 | Phase 3 | Not fast-path (needs planning) |
43
+ | Phase 2.5 | Phase 4 | Fast-path (simple lookup) |
44
+ | Phase 3 | Phase 4 | User approves plan |
45
+ | Phase 4 | Phase 5 | Research complete (see completion gate) |
46
+
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.
21
58
 
22
59
  ---
23
60
 
24
- ## 2. Scope & Tooling
61
+ ## MCP Discovery
25
62
 
26
- <tools>
27
- > 🔍 **For local workspace search & LSP code intelligence, call the `octocode-local-search` skill if installed!**
28
- > This skill focuses on **external GitHub research**. Use `octocode-local-search` for local tools (`localSearchCode`, `localViewStructure`, `localFindFiles`, `localGetFileContent`) and LSP tools (`lspGotoDefinition`, `lspFindReferences`, `lspCallHierarchy`).
63
+ <mcp_discovery>
64
+ Before starting, detect available research tools.
29
65
 
30
- **Octocode Research (GitHub)**:
31
- | Tool | Purpose |
32
- |------|---------|
33
- | `githubSearchRepositories` | Discover repos by topics, stars, activity |
34
- | `githubViewRepoStructure` | Explore directory layout and file sizes |
35
- | `githubSearchCode` | Find patterns, implementations, file paths |
36
- | `githubGetFileContent` | Read file content with `matchString` targeting |
37
- | `githubSearchPullRequests` | Fetch PR metadata, diffs, comments, history |
38
- | `packageSearch` | Package metadata, versions, repo location |
39
-
40
- **Task Management**:
41
- | Tool | Purpose |
42
- |------|---------|
43
- | `TodoWrite` | Track research progress and subtasks |
44
- | `Task` | Spawn parallel agents for independent research domains |
66
+ **Check**: Is `octocode-mcp` available as an MCP server?
67
+ Look for Octocode MCP tools (e.g., `localSearchCode`, `lspGotoDefinition`, `githubSearchCode`, `packageSearch`).
45
68
 
46
- **FileSystem**: `Read`, `Write`
47
- </tools>
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."
48
71
 
49
- <location>
50
- **`.octocode/`** - Project root folder for Octocode artifacts. Create if missing and ask user to add to `.gitignore`.
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."
51
86
 
52
- | Path | Purpose |
53
- |------|---------|
54
- | `.octocode/context/context.md` | User preferences & project context |
55
- | `.octocode/research/{session-name}/research_summary.md` | Temp research summary (ongoing) |
56
- | `.octocode/research/{session-name}/research.md` | Final research document |
87
+ Proceed with whatever tools are available — do not block on setup.
88
+ </mcp_discovery>
89
+
90
+ ---
91
+
92
+ ## Phase 1: Server Initialization
93
+
94
+ ### Server Configuration
95
+
96
+ <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>
99
+ </server>
100
+
101
+ ### Available Routes
102
+
103
+ <server_routes>
104
+
105
+ | Method | Route | Description |
106
+ |--------|-------|-------------|
107
+ | GET | `/tools/initContext` | System prompt + all tool schemas (LOAD FIRST!) |
108
+ | GET | `/prompts/info/:promptName` | Get prompt content and arguments |
109
+ | POST | `/tools/call/:toolName` | Execute a tool (JSON body with queries array) |
57
110
 
58
- > `{session-name}` = short descriptive name (e.g., `auth-flow`, `api-migration`)
59
- </location>
111
+ </server_routes>
60
112
 
61
- <userPreferences>
62
- Check `.octocode/context/context.md` for user context. Use it to ground research goals if relevant.
63
- </userPreferences>
113
+ ### Initialization Process
114
+
115
+ <server_init_gate>
116
+ **HALT. Server MUST be running before ANY other action.**
117
+
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
+ ```
125
+
126
+ **Example**: If system message says `Base directory for this skill: /path/to/skill`, run:
127
+ ```bash
128
+ cd /path/to/skill && npm run server-init
129
+ ```
130
+
131
+ #### Output Interpretation
132
+
133
+ | Output | Meaning | Action |
134
+ |--------|---------|--------|
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.
139
+
140
+ #### FORBIDDEN Until Server Returns "ok"
141
+ - Any tool calls to localhost:1987 or research tools
142
+
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)
147
+
148
+ #### Troubleshooting
149
+
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>` |
155
+
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"**
164
+ </server_init_gate>
165
+
166
+ ### Server Maintenance
167
+
168
+ <server_maintenance>
169
+ App logs with rotation at `~/.octocode/logs/` (errors.log, tools.log).
170
+ </server_maintenance>
64
171
 
65
172
  ---
66
173
 
67
- ## 3. Decision Framework
68
-
69
- <confidence>
70
- | Level | Certainty | Action |
71
- |-------|-----------|--------|
72
- | ✅ **HIGH** | Verified in active code | Use as evidence |
73
- | ⚠️ **MED** | Likely correct, missing context | Use with caveat |
74
- | ❓ **LOW** | Uncertain or conflicting | Investigate more OR ask user |
75
-
76
- **Validation Rule**: Key findings require a second source unless primary is definitive (official docs, canonical implementation).
77
- </confidence>
78
-
79
- <mindset>
80
- **Research when**:
81
- - User question requires code evidence
82
- - Need to understand implementation patterns
83
- - Tracing data/control flow across files/repos
84
- - Validating assumptions about behavior
85
-
86
- **Skip research when**:
87
- - Answer is general knowledge (no code-specific evidence needed)
88
- - User already provided the answer/context
89
- - Trivial lookups better served by direct file read
90
- </mindset>
91
-
92
- <octocode_results>
93
- - Tool results include: `mainResearchGoal`, `researchGoal`, `reasoning` - USE THESE to understand context
94
- - Results have hints for next steps - follow them
95
- - Empty results = wrong query, try semantic variants
96
- </octocode_results>
174
+ ## Phase 2: Load Context
175
+
176
+ <context_gate>
177
+ **STOP. DO NOT call any research tools yet.**
178
+
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.**
204
+
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
209
+
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>
233
+
234
+ ### Prompt Selection
235
+
236
+ <prompt_selection>
237
+
238
+ | PromptName | When to Use |
239
+ |------------|-------------|
240
+ | `research` | External libraries, GitHub repos, packages |
241
+ | `research_local` | Local codebase exploration |
242
+ | `reviewPR` | PR URLs, review requests |
243
+ | `plan` | Bug fixes, features, refactors |
244
+ | `roast` | Poetic code roasting (load `references/roast-prompt.md`) |
245
+
246
+ **REQUIRED**: You MUST tell user which prompt you're using:
247
+ > "I'm using the `{promptName}` prompt because [reason]"
248
+
249
+ **FORBIDDEN**: Proceeding to next phase without stating the prompt.
250
+ </prompt_selection>
251
+
252
+ <context_complete_gate>
253
+ **HALT. Verify ALL conditions before proceeding:**
254
+
255
+ - [ ] Context loaded successfully?
256
+ - [ ] Tool schemas understood?
257
+ - [ ] Told user which prompt you're using?
258
+ - [ ] Verbalized: "Context loaded. I understand the schemas..."?
259
+
260
+ **IF ANY checkbox is unchecked → STOP. Complete missing items.**
261
+ **IF ALL checkboxes checked → PROCEED to Phase 2.5 (Fast-Path Evaluation)**
262
+ </context_complete_gate>
97
263
 
98
264
  ---
99
265
 
100
- ## 4. Research Flows
101
-
102
- <research_flows>
103
- **General Rule**: Research is a matrix/graph, not linear. Use the cheapest tool that can prove/disprove the hypothesis.
104
-
105
- > 🔍 **For local workspace exploration and LSP code intelligence, use the `octocode-local-search` skill!**
106
-
107
- **Starting Points (GitHub Research)**:
108
- | Need | GitHub Tool | Example |
109
- |------|-------------|---------|
110
- | Repository discovery | `githubSearchRepositories` | Find repos by topic/stars |
111
- | Package info | `packageSearch` | Metadata, repo location |
112
- | Remote repo structure | `githubViewRepoStructure` | Map external layout |
113
- | Pattern search | `githubSearchCode` | Find implementations |
114
- | File content | `githubGetFileContent` | Read with `matchString` |
115
- | PR History | `githubSearchPullRequests` | Why changes were made |
116
-
117
- **GitHub Transition Matrix**:
118
- | From Tool | Need... | Go To Tool |
119
- |-----------|---------|------------|
120
- | `githubSearchCode` | Context/Content | `githubGetFileContent` |
121
- | `githubSearchCode` | More Patterns | `githubSearchCode` (refine) |
122
- | `githubSearchCode` | Package Source | `packageSearch` |
123
- | `githubSearchRepositories` | Content | `githubGetFileContent` |
124
- | `githubSearchRepositories` | Structure | `githubViewRepoStructure` |
125
- | `packageSearch` | Repo Location | `githubViewRepoStructure` → `githubGetFileContent` |
126
- | `githubViewRepoStructure` | Find Pattern | `githubSearchCode` |
127
- | `githubSearchPullRequests` | File Content | `githubGetFileContent` |
128
- | `githubGetFileContent` | More Context | `githubGetFileContent` (widen scope) |
129
- | `githubGetFileContent` | New Pattern | `githubSearchCode` |
130
- </research_flows>
131
-
132
- <structural_code_vision>
133
- **Think Like a Parser (AST Mode)**:
134
- - **See the Tree**: Visualize AST. Root (Entry)Nodes (Funcs/Classes) Edges (Imports/Calls)
135
- - **Trace Dependencies**: `import {X} from 'Y'` is an edgefollow imports to source
136
- - **Contextualize Tokens**: "user" is meaningless alone → Find definition (`class User`, `interface User`)
137
- - **Follow the Flow**: Entry Propagation → Termination
138
- - **Ignore Noise**: Focus on semantic nodes driving logic (public functions, handlers, services)
139
-
140
- > 💡 **For LSP-powered code intelligence (definitions, references, call hierarchy), use the `octocode-local-search` skill!**
141
- </structural_code_vision>
142
-
143
- <doc_vision>
144
- - Understand meta flows using updated docs
145
- - Use semantic search for variety (README, CONTRIBUTING, docs folder)
146
- - Prefer docs with recent `updated` dates
147
- </doc_vision>
148
-
149
- <context_awareness>
150
- **Repository Awareness**:
151
- - Identify Type: Client? Server? Library? Monorepo?
152
- - Check Activity: Active PRs = Active Repo
153
- - Critical Paths: Understand entry points & code flows first
154
-
155
- **Cross-Repository Awareness**:
156
- - Dependencies = Connections between repos
157
- - Trace URLs/API calls between services
158
- - Follow package imports to source repos
159
- </context_awareness>
266
+ ## Phase 2.5: Fast-Path Evaluation
267
+
268
+ **CRITICAL: Evaluate BEFORE creating a plan. This saves time for simple queries.**
269
+
270
+ ### Fast-Path Decision
271
+
272
+ <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 |
283
+
284
+ #### Decision Logic
285
+
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
290
+
291
+ **IF ANY criterion is FALSE:**
292
+ 1. Tell user: "This requires planning. Creating research plan..."
293
+ 2. **PROCEED** to Phase 3 (Planning)
294
+ </fast_path_gate>
295
+
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?" SearchReadDone
301
+ - "Show me the User model" Search ReadDone
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)
160
307
 
161
308
  ---
162
309
 
163
- ## 5. Execution Flow
164
-
165
- <key_principles>
166
- - **Align**: Each tool call supports a hypothesis
167
- - **Validate**:
168
- - Output moves research forward
169
- - **Validation Pattern**: Discover Verify → Cross-check → Confirm
170
- - **Rule of Two**: Validate key findings with second source unless primary is definitive
171
- - **Real Code Only**: Ensure results are from active/real flows (not dead code, tests, deprecated)
172
- - **Freshness**: Check `updated` dates. Avoid >1yr old projects/docs unless necessary
173
- - **Refine**: Weak reasoning? Change tool/query combination
174
- - **Efficiency**: Batch queries (1-3). Path search (`match="path"`) before content. Avoid loops
175
- - **Output**: Quality > Quantity
176
- - **User Checkpoint**: If scope unclear/too broad or blocked → Summarize and ask user
177
- - **Tasks**: Use `TodoWrite` to manage research tasks and subtasks (create/update ongoing!)
178
- - **Multi-Agent**: For independent hypotheses/domains, spawn parallel agents via `Task` tool
179
- - **No Time Estimates**: Never provide timing/duration estimates (e.g., "2-3 days", "few hours")
180
- </key_principles>
181
-
182
- <execution_lifecycle>
183
- ### Phase 1: Preparation
184
- 1. **Analyze**: Identify specific goals and missing context
185
- 2. **Hypothesize**: Define what needs to be proved/disproved and success criteria
186
- 3. **Strategize**: Determine efficient entry point (Repo? Package? Pattern?)
187
- 4. **Parallelization Check**: Can hypotheses be researched independently? Consider spawning agents
188
- 5. **User Checkpoint**: If scope >2 repos or unclear STOP & ASK USER
189
- 6. **Tasks**: Add all hypotheses as tasks via `TodoWrite`
190
-
191
- ### Phase 2: Execution Loop (per task)
192
- Iterate Thought, Action, Observation:
193
-
194
- 1. **THOUGHT**: Determine immediate next step
195
- 2. **ACTION**: Execute Octocode tool call(s)
196
- 3. **OBSERVATION**: Analyze results. Fact-check against expectations. Identify gaps
197
- 4. **DECISION**: Refine strategy (BFS vs DFS)
198
- - *Code Structure?* Follow `<structural_code_vision>`
199
- - *Docs?* Follow `<doc_vision>`
200
- 5. **SUBTASKS**: Add discovered subtasks
201
- 6. **SUCCESS CHECK**: Enough evidence to answer?
202
- - Yes Move to Output Protocol
203
- - No Loop with refined query
204
-
205
- ### Phase 3: Output
206
- - Generate answer with evidence
207
- - Ask user about next steps (see Output Protocol)
208
- </execution_lifecycle>
310
+ ## Phase 3: Planning
311
+
312
+ <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)
319
+
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:
329
+
330
+ ```markdown
331
+ ## Research Plan
332
+ **Goal:** [User's question]
333
+ **Strategy:** [Sequential / Parallel]
334
+ **Steps:**
335
+ 1. [Tool][Specific Goal]
336
+ 2. [Tool] [Specific Goal]
337
+ ...
338
+ **Estimated scope:** [files/repos to explore]
339
+
340
+ Proceed? (yes/no)
341
+ ```
342
+
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**
366
+ </plan_gate>
367
+
368
+ ### Parallel Execution Decision
369
+
370
+ <parallel_decision>
371
+ **CRITICAL: Multiple independent domains → MUST spawn Task agents in parallel**
372
+
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)
209
434
 
210
435
  ---
211
436
 
212
- ## 6. Error Recovery
437
+ ## Phase 4: Research Execution
213
438
 
214
- <error_recovery>
215
- | Situation | Action |
439
+ <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?**
447
+
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.**
454
+ </research_gate>
455
+
456
+ ### The Research Loop
457
+
458
+ <research_loop>
459
+ **CRITICAL: Follow this loop for EVERY research action:**
460
+
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
465
+ 5. **Iterate** until goal achieved
466
+
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
+ | Hint Type | Action |
216
477
  |-----------|--------|
217
- | Tool returns empty | Try semantic variants (auth→login→credentials) |
218
- | Too many results | Add filters (path, extension, owner/repo) |
219
- | Conflicting info | Find authoritative source OR ask user |
220
- | Rate limited | Reduce batch size, wait |
221
- | Dead end | Backtrack to last good state, try different entry point |
222
- | Blocked >2 attempts | Summarize what you tried → Ask user |
478
+ | Next tool suggestion | **MUST** use the recommended tool |
479
+ | Pagination | Fetch next page if needed |
480
+ | Refinement needed | Narrow the search |
481
+ | Error guidance | Recover as indicated |
482
+
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
+ ### Error Recovery
502
+
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 |
513
+
514
+ **CRITICAL: IF stuck and not making progress → STOP and ask user for guidance.**
223
515
  </error_recovery>
224
516
 
225
- ---
517
+ ### Context Management
518
+
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."
226
524
 
227
- ## 7. Multi-Agent Parallelization
228
-
229
- <multi_agent>
230
- > **Note**: Only applicable if parallel agents are supported by host environment.
231
-
232
- **When to Spawn Subagents**:
233
- - 2+ independent hypotheses (no shared dependencies)
234
- - Distinct repos/domains (e.g., `client` + `server`, `lib-a` + `lib-b`)
235
- - Separate subsystems (auth vs. payments vs. notifications)
236
- - Multiple external packages to research
237
-
238
- **How to Parallelize**:
239
- 1. Use `TodoWrite` to create tasks and identify parallelizable research
240
- 2. Use `Task` tool to spawn subagents with specific hypothesis/domain
241
- 3. Each agent researches independently using GitHub tools
242
- 4. Merge findings after all agents complete
243
-
244
- **Smart Parallelization Tips**:
245
- - **Preparation Phase**: Keep sequential - need unified hypothesis identification
246
- - **Execution Phase**: Parallelize across independent repos/domains
247
- - Use `TodoWrite` to track research progress per agent
248
- - Each agent should follow full research flow: `githubSearchRepositories` → `githubViewRepoStructure` → `githubSearchCode` → `githubGetFileContent`
249
- - Define clear boundaries: each agent owns specific repos/packages
250
- - Cross-reference findings during merge to identify connections
251
-
252
- **Example - Multi-Repo Research**:
253
- - Goal: "How does auth work across frontend and backend?"
254
- - Agent 1: Research `frontend-app` auth flow (login, token storage, guards)
255
- - Agent 2: Research `backend-api` auth flow (middleware, validation, sessions)
256
- - Merge: Combine into unified auth flow documentation, trace cross-repo dependencies
257
-
258
- **Example - Multi-Package Research**:
259
- - Goal: "Compare authentication libraries for Node.js"
260
- - Agent 1: Research `passport` using `packageSearch` `githubViewRepoStructure``githubGetFileContent`
261
- - Agent 2: Research `next-auth` using same flow
262
- - Agent 3: Research `lucia-auth` using same flow
263
- - Merge: Create comparison matrix with pros/cons
264
-
265
- **Anti-patterns**:
266
- - Don't parallelize when hypotheses depend on each other's results
267
- - Don't spawn agents for simple single-repo research
268
- - Don't parallelize output generation (needs unified synthesis)
269
- </multi_agent>
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>
545
+
546
+ ### Research Completion
547
+
548
+ <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
573
+
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`)?
578
+
579
+ **IF ALL checked → PROCEED to Phase 5 (OUTPUT)**
580
+ **IF ANY unchecked → Complete missing items first**
581
+ </research_complete_gate>
270
582
 
271
583
  ---
272
584
 
273
- ## 8. Output Protocol
585
+ ## Phase 5: Output
274
586
 
275
- <output_flow>
276
- ### Step 1: Chat Answer (MANDATORY)
277
- - Provide clear TL;DR answer with research results
278
- - Add evidence and references to code/docs (full GitHub links e.g. https://github.com/{{OWNER}}/{{REPO}}/blob/{{BRANCH}}/{{PATH}})
279
- - Include only important code chunks (up to 10 lines)
587
+ <output_gate>
588
+ ### STOP. Verify entry conditions and ensure output quality.
280
589
 
281
- ### Step 2: Next Step Question (MANDATORY)
282
- Ask user:
283
- - "Create a research doc?" → Generate per `<output_structure>`
284
- - "Keep researching?" → Summarize to `research_summary.md`:
285
- - What you know
286
- - What you need to know
287
- - Links to repos/docs/files
288
- - Flows discovered
289
- - Then continue from Phase 2
290
- </output_flow>
590
+ #### Entry Verification (from Phase 4)
291
591
 
292
- <output_structure>
293
- **Location**: `.octocode/research/{session-name}/research.md`
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`)?
294
595
 
295
- ```markdown
296
- # Research Goal
297
- [User's question / research objective]
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.**
602
+
603
+ #### Required Response Structure (MANDATORY - Include ALL sections)
604
+
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).
609
+
610
+ **FORBIDDEN**: Skipping any section. TL;DR, Details, References, and Next Step are always required.
611
+
612
+ #### IF Research is STUCK (goal not achieved)
613
+
614
+ When entering Phase 5 via "Stuck (exhausted)" trigger, adapt output format:
298
615
 
299
- # Answer
300
- [Overview TL;DR of findings]
616
+ | Section | Adaptation |
617
+ |---------|------------|
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]?" |
301
622
 
302
- # Details
303
- [Include sections as applicable]
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."
304
624
 
305
- ## Visual Flows
306
- [Mermaid diagrams (`graph TD`) for code/data flows]
625
+ #### Reference Format (MUST follow EXACTLY)
307
626
 
308
- ## Code Flows
309
- [High-level flow between repositories/functions/packages/services]
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` |
310
632
 
311
- ## Key Findings
312
- [Detailed evidence with code snippets]
633
+ **Why full GitHub URLs?** Users can click to navigate directly. Partial paths are ambiguous across branches/forks.
313
634
 
314
- ## Edge Cases / Caveats
315
- [Limitations, uncertainties, areas needing more research]
635
+ **FORBIDDEN**: Relative GitHub paths without full URL.
636
+ **FORBIDDEN**: Missing line numbers in references.
316
637
 
317
- # References
318
- - [Repo/file/doc links with descriptions]
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.**
657
+ </output_gate>
319
658
 
320
659
  ---
321
- Created by Octocode MCP https://octocode.ai 🔍🐙
322
- ```
323
- </output_structure>
660
+
661
+ ## Cross-Cutting: Self-Check
662
+
663
+ <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.
667
+
668
+ **Phase gates:** Server "ok" → Context + prompt stated → Fast-path evaluated → Plan approved → Research (follow hints) → Checkpoint when needed → Output (TL;DR + refs + question)
669
+
670
+ **Multi-domain?** → See `references/PARALLEL_AGENT_PROTOCOL.md`
671
+ </agent_self_check>
672
+
673
+ ---
674
+
675
+ ## Reference: Global Constraints
676
+
677
+ <global_constraints>
678
+ ### Core Principles (NON-NEGOTIABLE)
679
+
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
684
+
685
+ ### Research Params (REQUIRED in EVERY tool call)
686
+
687
+ | Parameter | Description |
688
+ |-----------|-------------|
689
+ | `mainResearchGoal` | Overall objective |
690
+ | `researchGoal` | This specific step's goal |
691
+ | `reasoning` | Why this tool/params |
692
+
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.
702
+ </global_constraints>
324
703
 
325
704
  ---
326
705
 
327
- ## 9. References
706
+ ## Additional Resources
328
707
 
329
- - **Tools**: [references/tool-reference.md](references/tool-reference.md) - Parameters & Tips
330
- - **Workflows**: [references/workflow-patterns.md](references/workflow-patterns.md) - Research Recipes
708
+ - **`references/GUARDRAILS.md`** - Security, trust levels, limits, and integrity rules