octocode-cli 1.2.6 → 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.
- package/LICENSE +21 -63
- package/README.md +85 -142
- package/out/octocode-cli.js +7026 -6945
- package/package.json +8 -6
- package/skills/README.md +97 -120
- package/skills/octocode-code-engineer/.claude/settings.local.json +18 -0
- package/skills/octocode-code-engineer/.octocode/rfc/RFC-code-engineer-weakness-fixes.md +255 -0
- package/skills/octocode-code-engineer/.plan/VALIDATED_PLAN.md +223 -0
- package/skills/octocode-code-engineer/README.md +178 -0
- package/skills/octocode-code-engineer/SKILL.md +418 -0
- package/skills/octocode-code-engineer/coverage/architecture.ts.html +7828 -0
- package/skills/octocode-code-engineer/coverage/ast-helpers.ts.html +211 -0
- package/skills/octocode-code-engineer/coverage/ast-search.ts.html +1795 -0
- package/skills/octocode-code-engineer/coverage/base.css +224 -0
- package/skills/octocode-code-engineer/coverage/block-navigation.js +87 -0
- package/skills/octocode-code-engineer/coverage/cache.ts.html +376 -0
- package/skills/octocode-code-engineer/coverage/cli.ts.html +982 -0
- package/skills/octocode-code-engineer/coverage/clover.xml +3217 -0
- package/skills/octocode-code-engineer/coverage/collect-effects.ts.html +664 -0
- package/skills/octocode-code-engineer/coverage/collect-input-sources.ts.html +577 -0
- package/skills/octocode-code-engineer/coverage/collect-performance.ts.html +331 -0
- package/skills/octocode-code-engineer/coverage/collect-prototype-pollution.ts.html +421 -0
- package/skills/octocode-code-engineer/coverage/collect-security.ts.html +604 -0
- package/skills/octocode-code-engineer/coverage/collect-test-profile.ts.html +589 -0
- package/skills/octocode-code-engineer/coverage/coverage-final.json +30 -0
- package/skills/octocode-code-engineer/coverage/dependencies.ts.html +997 -0
- package/skills/octocode-code-engineer/coverage/dependency-summary.ts.html +688 -0
- package/skills/octocode-code-engineer/coverage/discovery.ts.html +322 -0
- package/skills/octocode-code-engineer/coverage/favicon.png +0 -0
- package/skills/octocode-code-engineer/coverage/graph-analytics.ts.html +1510 -0
- package/skills/octocode-code-engineer/coverage/index.html +536 -0
- package/skills/octocode-code-engineer/coverage/index.ts.html +826 -0
- package/skills/octocode-code-engineer/coverage/metrics.ts.html +553 -0
- package/skills/octocode-code-engineer/coverage/pipeline.ts.html +2044 -0
- package/skills/octocode-code-engineer/coverage/prettify.css +1 -0
- package/skills/octocode-code-engineer/coverage/prettify.js +2 -0
- package/skills/octocode-code-engineer/coverage/report-analysis.ts.html +1570 -0
- package/skills/octocode-code-engineer/coverage/report-writer.ts.html +1102 -0
- package/skills/octocode-code-engineer/coverage/security-detectors.ts.html +1747 -0
- package/skills/octocode-code-engineer/coverage/semantic-detectors.ts.html +2152 -0
- package/skills/octocode-code-engineer/coverage/semantic.ts.html +1897 -0
- package/skills/octocode-code-engineer/coverage/sort-arrow-sprite.png +0 -0
- package/skills/octocode-code-engineer/coverage/sorter.js +210 -0
- package/skills/octocode-code-engineer/coverage/summary-md.ts.html +1222 -0
- package/skills/octocode-code-engineer/coverage/test-quality-detectors.ts.html +1039 -0
- package/skills/octocode-code-engineer/coverage/tree-sitter-analyzer.ts.html +955 -0
- package/skills/octocode-code-engineer/coverage/ts-analyzer.ts.html +1213 -0
- package/skills/octocode-code-engineer/coverage/types.ts.html +2473 -0
- package/skills/octocode-code-engineer/coverage/utils.ts.html +820 -0
- package/skills/octocode-code-engineer/eslint.config.mjs +54 -0
- package/skills/octocode-code-engineer/minify-scripts.mjs +32 -0
- package/skills/octocode-code-engineer/package.json +54 -0
- package/skills/octocode-code-engineer/references/agent-ast-reading-rfc.md +95 -0
- package/skills/octocode-code-engineer/references/architecture-techniques.md +121 -0
- package/skills/octocode-code-engineer/references/ast-search.md +210 -0
- package/skills/octocode-code-engineer/references/ast-tree-search.md +151 -0
- package/skills/octocode-code-engineer/references/cli-reference.md +167 -0
- package/skills/octocode-code-engineer/references/concepts.md +107 -0
- package/skills/octocode-code-engineer/references/finding-categories.md +128 -0
- package/skills/octocode-code-engineer/references/improvement-roadmap.md +304 -0
- package/skills/octocode-code-engineer/references/output-files.md +144 -0
- package/skills/octocode-code-engineer/references/playbooks.md +204 -0
- package/skills/octocode-code-engineer/references/present-results.md +136 -0
- package/skills/octocode-code-engineer/references/tool-workflows.md +566 -0
- package/skills/octocode-code-engineer/references/validate-investigate.md +225 -0
- package/skills/octocode-code-engineer/scripts/analysis/dependencies.js +1 -0
- package/skills/octocode-code-engineer/scripts/analysis/dependency-summary.js +1 -0
- package/skills/octocode-code-engineer/scripts/analysis/discovery.js +1 -0
- package/skills/octocode-code-engineer/scripts/analysis/graph-analytics.js +1 -0
- package/skills/octocode-code-engineer/scripts/analysis/semantic.js +1 -0
- package/skills/octocode-code-engineer/scripts/ast/helpers.js +1 -0
- package/skills/octocode-code-engineer/scripts/ast/metrics.js +1 -0
- package/skills/octocode-code-engineer/scripts/ast/search.js +2 -0
- package/skills/octocode-code-engineer/scripts/ast/tree-search.js +2 -0
- package/skills/octocode-code-engineer/scripts/ast/tree-sitter.js +1 -0
- package/skills/octocode-code-engineer/scripts/ast/ts-analyzer.js +1 -0
- package/skills/octocode-code-engineer/scripts/collectors/chains.js +1 -0
- package/skills/octocode-code-engineer/scripts/collectors/effects.js +1 -0
- package/skills/octocode-code-engineer/scripts/collectors/input-sources.js +1 -0
- package/skills/octocode-code-engineer/scripts/collectors/performance.js +1 -0
- package/skills/octocode-code-engineer/scripts/collectors/prototype-pollution.js +1 -0
- package/skills/octocode-code-engineer/scripts/collectors/security.js +1 -0
- package/skills/octocode-code-engineer/scripts/collectors/test-profile.js +1 -0
- package/skills/octocode-code-engineer/scripts/common/is-direct-run.js +1 -0
- package/skills/octocode-code-engineer/scripts/common/utils.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/code-quality.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/cohesion.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/coupling.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/cycle.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/dead-code.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/import-style.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/index.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/security.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/semantic.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/shared.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/test-quality.js +1 -0
- package/skills/octocode-code-engineer/scripts/index.js +1 -0
- package/skills/octocode-code-engineer/scripts/pipeline/cache.js +1 -0
- package/skills/octocode-code-engineer/scripts/pipeline/cli.js +1 -0
- package/skills/octocode-code-engineer/scripts/pipeline/main.js +2 -0
- package/skills/octocode-code-engineer/scripts/reporting/analysis.js +1 -0
- package/skills/octocode-code-engineer/scripts/reporting/summary-md.js +1 -0
- package/skills/octocode-code-engineer/scripts/reporting/writer.js +1 -0
- package/skills/octocode-code-engineer/scripts/types/constants.js +1 -0
- package/skills/octocode-code-engineer/scripts/types/index.js +1 -0
- package/skills/octocode-code-engineer/scripts/types/interfaces.js +1 -0
- package/skills/octocode-code-engineer/src/analysis/dependencies.test.ts +545 -0
- package/skills/octocode-code-engineer/src/analysis/dependencies.ts +406 -0
- package/skills/octocode-code-engineer/src/analysis/dependency-summary.test.ts +566 -0
- package/skills/octocode-code-engineer/src/analysis/dependency-summary.ts +257 -0
- package/skills/octocode-code-engineer/src/analysis/discovery.test.ts +420 -0
- package/skills/octocode-code-engineer/src/analysis/discovery.ts +87 -0
- package/skills/octocode-code-engineer/src/analysis/graph-analytics.test.ts +449 -0
- package/skills/octocode-code-engineer/src/analysis/graph-analytics.ts +534 -0
- package/skills/octocode-code-engineer/src/analysis/semantic.test.ts +1533 -0
- package/skills/octocode-code-engineer/src/analysis/semantic.ts +830 -0
- package/skills/octocode-code-engineer/src/ast/helpers.test.ts +185 -0
- package/skills/octocode-code-engineer/src/ast/helpers.ts +62 -0
- package/skills/octocode-code-engineer/src/ast/metrics.test.ts +304 -0
- package/skills/octocode-code-engineer/src/ast/metrics.ts +204 -0
- package/skills/octocode-code-engineer/src/ast/search.test.ts +647 -0
- package/skills/octocode-code-engineer/src/ast/search.ts +648 -0
- package/skills/octocode-code-engineer/src/ast/tree-search.test.ts +199 -0
- package/skills/octocode-code-engineer/src/ast/tree-search.ts +392 -0
- package/skills/octocode-code-engineer/src/ast/tree-sitter.test.ts +407 -0
- package/skills/octocode-code-engineer/src/ast/tree-sitter.ts +402 -0
- package/skills/octocode-code-engineer/src/ast/ts-analyzer.test.ts +1864 -0
- package/skills/octocode-code-engineer/src/ast/ts-analyzer.ts +509 -0
- package/skills/octocode-code-engineer/src/collectors/chains.ts +74 -0
- package/skills/octocode-code-engineer/src/collectors/effects.test.ts +490 -0
- package/skills/octocode-code-engineer/src/collectors/effects.ts +332 -0
- package/skills/octocode-code-engineer/src/collectors/input-sources.test.ts +144 -0
- package/skills/octocode-code-engineer/src/collectors/input-sources.ts +196 -0
- package/skills/octocode-code-engineer/src/collectors/performance.test.ts +82 -0
- package/skills/octocode-code-engineer/src/collectors/performance.ts +141 -0
- package/skills/octocode-code-engineer/src/collectors/prototype-pollution.test.ts +55 -0
- package/skills/octocode-code-engineer/src/collectors/prototype-pollution.ts +162 -0
- package/skills/octocode-code-engineer/src/collectors/security.test.ts +124 -0
- package/skills/octocode-code-engineer/src/collectors/security.ts +309 -0
- package/skills/octocode-code-engineer/src/collectors/test-profile.test.ts +97 -0
- package/skills/octocode-code-engineer/src/collectors/test-profile.ts +269 -0
- package/skills/octocode-code-engineer/src/common/is-direct-run.test.ts +32 -0
- package/skills/octocode-code-engineer/src/common/is-direct-run.ts +13 -0
- package/skills/octocode-code-engineer/src/common/utils.test.ts +463 -0
- package/skills/octocode-code-engineer/src/common/utils.ts +304 -0
- package/skills/octocode-code-engineer/src/detectors/code-quality.ts +966 -0
- package/skills/octocode-code-engineer/src/detectors/cohesion.ts +539 -0
- package/skills/octocode-code-engineer/src/detectors/coupling.ts +323 -0
- package/skills/octocode-code-engineer/src/detectors/cycle.ts +349 -0
- package/skills/octocode-code-engineer/src/detectors/dead-code.ts +320 -0
- package/skills/octocode-code-engineer/src/detectors/import-style.ts +376 -0
- package/skills/octocode-code-engineer/src/detectors/index.test.ts +3061 -0
- package/skills/octocode-code-engineer/src/detectors/index.ts +88 -0
- package/skills/octocode-code-engineer/src/detectors/security.test.ts +882 -0
- package/skills/octocode-code-engineer/src/detectors/security.ts +821 -0
- package/skills/octocode-code-engineer/src/detectors/semantic.ts +758 -0
- package/skills/octocode-code-engineer/src/detectors/shared.ts +49 -0
- package/skills/octocode-code-engineer/src/detectors/test-quality.test.ts +388 -0
- package/skills/octocode-code-engineer/src/detectors/test-quality.ts +367 -0
- package/skills/octocode-code-engineer/src/index.test.ts +4425 -0
- package/skills/octocode-code-engineer/src/index.ts +403 -0
- package/skills/octocode-code-engineer/src/pipeline/cache.test.ts +199 -0
- package/skills/octocode-code-engineer/src/pipeline/cache.ts +130 -0
- package/skills/octocode-code-engineer/src/pipeline/cli.test.ts +493 -0
- package/skills/octocode-code-engineer/src/pipeline/cli.ts +344 -0
- package/skills/octocode-code-engineer/src/pipeline/main.test.ts +174 -0
- package/skills/octocode-code-engineer/src/pipeline/main.ts +1074 -0
- package/skills/octocode-code-engineer/src/pipeline.test.ts +84 -0
- package/skills/octocode-code-engineer/src/reporting/analysis.test.ts +782 -0
- package/skills/octocode-code-engineer/src/reporting/analysis.ts +688 -0
- package/skills/octocode-code-engineer/src/reporting/output-contract.test.ts +463 -0
- package/skills/octocode-code-engineer/src/reporting/summary-md.test.ts +421 -0
- package/skills/octocode-code-engineer/src/reporting/summary-md.ts +714 -0
- package/skills/octocode-code-engineer/src/reporting/writer.ts +430 -0
- package/skills/octocode-code-engineer/src/sanity.test.ts +47 -0
- package/skills/octocode-code-engineer/src/types/constants.ts +248 -0
- package/skills/octocode-code-engineer/src/types/index.ts +80 -0
- package/skills/octocode-code-engineer/src/types/interfaces.ts +682 -0
- package/skills/octocode-code-engineer/tsconfig.json +17 -0
- package/skills/octocode-code-engineer/vitest.config.ts +8 -0
- package/skills/octocode-documentation-writer/README.md +113 -0
- package/skills/octocode-documentation-writer/SKILL.md +886 -0
- package/skills/octocode-documentation-writer/references/agent-discovery-analysis.md +453 -0
- package/skills/octocode-documentation-writer/references/agent-documentation-writer.md +255 -0
- package/skills/octocode-documentation-writer/references/agent-engineer-questions.md +247 -0
- package/skills/octocode-documentation-writer/references/agent-orchestrator.md +370 -0
- package/skills/octocode-documentation-writer/references/agent-qa-validator.md +227 -0
- package/skills/octocode-documentation-writer/references/agent-researcher.md +250 -0
- package/skills/octocode-documentation-writer/schemas/analysis-schema.json +886 -0
- package/skills/octocode-documentation-writer/schemas/discovery-tasks.json +96 -0
- package/skills/octocode-documentation-writer/schemas/documentation-structure.json +373 -0
- package/skills/octocode-documentation-writer/schemas/partial-discovery-schema.json +102 -0
- package/skills/octocode-documentation-writer/schemas/partial-research-schema.json +98 -0
- package/skills/octocode-documentation-writer/schemas/qa-results-schema.json +113 -0
- package/skills/octocode-documentation-writer/schemas/questions-schema.json +228 -0
- package/skills/octocode-documentation-writer/schemas/research-schema.json +104 -0
- package/skills/octocode-documentation-writer/schemas/state-schema.json +222 -0
- package/skills/octocode-documentation-writer/schemas/work-assignments-schema.json +74 -0
- package/skills/octocode-plan/SKILL.md +122 -116
- package/skills/octocode-prompt-optimizer/SKILL.md +617 -0
- package/skills/octocode-pull-request-reviewer/README.md +249 -0
- package/skills/octocode-pull-request-reviewer/SKILL.md +479 -0
- package/skills/octocode-pull-request-reviewer/references/dependency-check.md +74 -0
- package/skills/octocode-pull-request-reviewer/references/domain-reviewers.md +24 -0
- package/skills/octocode-pull-request-reviewer/references/execution-lifecycle.md +441 -0
- package/skills/octocode-pull-request-reviewer/references/flow-analysis-protocol.md +64 -0
- package/skills/octocode-pull-request-reviewer/references/output-template.md +174 -0
- package/skills/octocode-pull-request-reviewer/references/parallel-agent-protocol.md +182 -0
- package/skills/octocode-pull-request-reviewer/references/review-guidelines.md +26 -0
- package/skills/octocode-pull-request-reviewer/references/verification-checklist.md +40 -0
- package/skills/octocode-research/.claude/settings.local.json +46 -0
- package/skills/octocode-research/.octocode/plan/code-review-fixes/plan.md +312 -0
- package/skills/octocode-research/.octocode/plan/code-review-fixes/research.md +212 -0
- package/skills/octocode-research/.octocode/plans/NODE_SERVER_START_PLAN.md +755 -0
- package/skills/octocode-research/.octocode/research/code-review/research.md +371 -0
- package/skills/octocode-research/.octocode/review/IMPROVEMENTS.md +391 -0
- package/skills/octocode-research/.octocode/review/REVIEW_PLAN.md +289 -0
- package/skills/octocode-research/.octocode/review/REVIEW_REPORT.md +356 -0
- package/skills/octocode-research/AGENTS.md +349 -0
- package/skills/octocode-research/README.md +494 -0
- package/skills/octocode-research/SKILL.md +652 -274
- package/skills/octocode-research/docs/API_REFERENCE.md +562 -0
- package/skills/octocode-research/docs/ARCHITECTURE.md +554 -0
- package/skills/octocode-research/docs/FLOWS.md +577 -0
- package/skills/octocode-research/docs/OVERVIEW.md +564 -0
- package/skills/octocode-research/docs/SERVER_FLOWS.md +631 -0
- package/skills/octocode-research/ecosystem.config.cjs +88 -0
- package/skills/octocode-research/eslint.config.mjs +27 -0
- package/skills/octocode-research/package.json +84 -0
- package/skills/octocode-research/references/GUARDRAILS.md +40 -0
- package/skills/octocode-research/references/PARALLEL_AGENT_PROTOCOL.md +178 -0
- package/skills/octocode-research/references/roast-prompt.md +149 -0
- package/skills/octocode-research/scripts/server-init.d.ts +2 -0
- package/skills/octocode-research/scripts/server-init.js +2 -0
- package/skills/octocode-research/scripts/server.d.ts +8 -0
- package/skills/octocode-research/scripts/server.js +445 -0
- package/skills/octocode-research/src/__tests__/integration/circuitBreaker.test.ts +205 -0
- package/skills/octocode-research/src/__tests__/integration/routes.test.ts +374 -0
- package/skills/octocode-research/src/__tests__/unit/circuitBreaker.test.ts +245 -0
- package/skills/octocode-research/src/__tests__/unit/errorHandler.test.ts +183 -0
- package/skills/octocode-research/src/__tests__/unit/httpPreprocess.test.ts +157 -0
- package/skills/octocode-research/src/__tests__/unit/logger.test.ts +143 -0
- package/skills/octocode-research/src/__tests__/unit/queryParser.test.ts +130 -0
- package/skills/octocode-research/src/__tests__/unit/responseBuilder.test.ts +469 -0
- package/skills/octocode-research/src/__tests__/unit/retry.test.ts +205 -0
- package/skills/octocode-research/src/index.ts +186 -0
- package/skills/octocode-research/src/mcpCache.ts +49 -0
- package/skills/octocode-research/src/middleware/errorHandler.ts +65 -0
- package/skills/octocode-research/src/middleware/logger.ts +61 -0
- package/skills/octocode-research/src/middleware/queryParser.ts +115 -0
- package/skills/octocode-research/src/middleware/readiness.ts +17 -0
- package/skills/octocode-research/src/routes/github.ts +197 -0
- package/skills/octocode-research/src/routes/local.ts +175 -0
- package/skills/octocode-research/src/routes/lsp.ts +177 -0
- package/skills/octocode-research/src/routes/package.ts +127 -0
- package/skills/octocode-research/src/routes/prompts.ts +138 -0
- package/skills/octocode-research/src/routes/tools.ts +677 -0
- package/skills/octocode-research/src/server-init.ts +363 -0
- package/skills/octocode-research/src/server.ts +285 -0
- package/skills/octocode-research/src/types/errorGuards.ts +151 -0
- package/skills/octocode-research/src/types/express.d.ts +76 -0
- package/skills/octocode-research/src/types/guards.ts +98 -0
- package/skills/octocode-research/src/types/mcp.ts +119 -0
- package/skills/octocode-research/src/types/responses.ts +199 -0
- package/skills/octocode-research/src/types/toolTypes.ts +33 -0
- package/skills/octocode-research/src/utils/asyncTimeout.ts +116 -0
- package/skills/octocode-research/src/utils/circuitBreaker.ts +492 -0
- package/skills/octocode-research/src/utils/colors.ts +53 -0
- package/skills/octocode-research/src/utils/errorQueue.ts +71 -0
- package/skills/octocode-research/src/utils/logEmoji.ts +103 -0
- package/skills/octocode-research/src/utils/logger.ts +413 -0
- package/skills/octocode-research/src/utils/resilience.ts +169 -0
- package/skills/octocode-research/src/utils/responseBuilder.ts +495 -0
- package/skills/octocode-research/src/utils/responseFactory.ts +100 -0
- package/skills/octocode-research/src/utils/responseParser.ts +272 -0
- package/skills/octocode-research/src/utils/retry.ts +280 -0
- package/skills/octocode-research/src/utils/routeFactory.ts +117 -0
- package/skills/octocode-research/src/utils/url.ts +20 -0
- package/skills/octocode-research/src/validation/httpPreprocess.ts +155 -0
- package/skills/octocode-research/src/validation/index.ts +2 -0
- package/skills/octocode-research/src/validation/schemas.ts +578 -0
- package/skills/octocode-research/src/validation/toolCallSchema.ts +132 -0
- package/skills/octocode-research/tsconfig.json +21 -0
- package/skills/octocode-research/tsdown.config.ts +42 -0
- package/skills/octocode-research/vitest.config.ts +20 -0
- package/skills/octocode-researcher/SKILL.md +461 -0
- package/skills/octocode-researcher/references/fallbacks.md +120 -0
- package/skills/{octocode-local-search → octocode-researcher}/references/tool-reference.md +132 -49
- package/skills/{octocode-local-search → octocode-researcher}/references/workflow-patterns.md +204 -4
- package/skills/octocode-rfc-generator/SKILL.md +223 -0
- package/skills/octocode-rfc-generator/references/rfc-template.md +193 -0
- package/skills/octocode-roast/SKILL.md +63 -21
- package/skills/octocode-implement/SKILL.md +0 -293
- package/skills/octocode-implement/references/execution-phases.md +0 -317
- package/skills/octocode-implement/references/tool-reference.md +0 -403
- package/skills/octocode-implement/references/workflow-patterns.md +0 -385
- package/skills/octocode-local-search/SKILL.md +0 -449
- package/skills/octocode-pr-review/SKILL.md +0 -391
- package/skills/octocode-pr-review/references/domain-reviewers.md +0 -105
- package/skills/octocode-pr-review/references/execution-lifecycle.md +0 -116
- package/skills/octocode-pr-review/references/research-flows.md +0 -75
- package/skills/octocode-research/references/tool-reference.md +0 -304
- package/skills/octocode-research/references/workflow-patterns.md +0 -325
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
# Octocode Research - Main Flows & Architecture
|
|
2
|
+
|
|
3
|
+
> Understanding how the octocode-research skill works from server startup to tool execution.
|
|
4
|
+
> **v2.1.0** - Process managed by PM2
|
|
5
|
+
|
|
6
|
+
## Table of Contents
|
|
7
|
+
|
|
8
|
+
- [Overview](#overview)
|
|
9
|
+
- [Architecture Diagram](#architecture-diagram)
|
|
10
|
+
- [Main Components](#main-components)
|
|
11
|
+
- [Core Flows](#core-flows)
|
|
12
|
+
- [Server Startup Flow](#1-server-startup-flow)
|
|
13
|
+
- [Tool Execution Flow](#2-tool-execution-flow)
|
|
14
|
+
- [Discovery Flow](#3-discovery-flow)
|
|
15
|
+
- [PM2 Process Management](#pm2-process-management)
|
|
16
|
+
- [Component Connections](#component-connections)
|
|
17
|
+
- [Quick Reference](#quick-reference)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Overview
|
|
22
|
+
|
|
23
|
+
The **octocode-research** skill is a lightweight HTTP API server that wraps `octocode-mcp` tools for code research. It provides:
|
|
24
|
+
|
|
25
|
+
- **HTTP Interface**: REST API on `localhost:1987` by default (configurable via `OCTOCODE_RESEARCH_HOST` / `OCTOCODE_RESEARCH_PORT`)
|
|
26
|
+
- **HTTP Clients**: curl, fetch, or any HTTP client
|
|
27
|
+
- **Unified Tool API**: All tools via `POST /tools/call/:toolName`
|
|
28
|
+
- **Resilience**: Circuit breaker + retry patterns for reliability
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
32
|
+
│ OCTOCODE RESEARCH SKILL │
|
|
33
|
+
├─────────────────────────────────────────────────────────────────────────────┤
|
|
34
|
+
│ HTTP Clients (curl/fetch) ←──────→ HTTP Server (port 1987) ←→ octocode-mcp │
|
|
35
|
+
│ │ │
|
|
36
|
+
│ ├─→ Local Tools (ripgrep, fs) │
|
|
37
|
+
│ ├─→ LSP Tools (semantic analysis)│
|
|
38
|
+
│ ├─→ GitHub Tools (API) │
|
|
39
|
+
│ └─→ Package Tools (npm/PyPI) │
|
|
40
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Architecture Diagram
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
┌───────────────────────────┐
|
|
49
|
+
│ AI Agent / User │
|
|
50
|
+
└─────────────┬─────────────┘
|
|
51
|
+
│
|
|
52
|
+
┌─────────────────┼─────────────────┐
|
|
53
|
+
│ │ │
|
|
54
|
+
▼ ▼ ▼
|
|
55
|
+
┌─────────┐ ┌─────────┐ ┌─────────┐
|
|
56
|
+
│ curl │ │ fetch │ │ HTTP │
|
|
57
|
+
│ │ │ │ │ Client │
|
|
58
|
+
└────┬────┘ └────┬────┘ └────┬────┘
|
|
59
|
+
│ │ │
|
|
60
|
+
└─────────────────┼─────────────────┘
|
|
61
|
+
│ HTTP Request
|
|
62
|
+
▼
|
|
63
|
+
┌──────────────────────────────────────────────────────────────────────────────┐
|
|
64
|
+
│ EXPRESS SERVER (port 1987) │
|
|
65
|
+
├──────────────────────────────────────────────────────────────────────────────┤
|
|
66
|
+
│ ┌──────────────────────────────────────────────────────────────────────────┐ │
|
|
67
|
+
│ │ MIDDLEWARE LAYER │ │
|
|
68
|
+
│ │ ┌─────────────┐ ┌───────────────┐ ┌─────────────┐ ┌───────────────┐ │ │
|
|
69
|
+
│ │ │requestLogger│→│ express.json │→│contextPropag│→│ errorHandler │ │ │
|
|
70
|
+
│ │ └─────────────┘ └───────────────┘ └─────────────┘ └───────────────┘ │ │
|
|
71
|
+
│ └──────────────────────────────────────────────────────────────────────────┘ │
|
|
72
|
+
│ │ │
|
|
73
|
+
│ ▼ │
|
|
74
|
+
│ ┌──────────────────────────────────────────────────────────────────────────┐ │
|
|
75
|
+
│ │ ROUTE HANDLERS │ │
|
|
76
|
+
│ │ ┌─────────────────────────────────────────────────────────────────────┐ │ │
|
|
77
|
+
│ │ │ /tools/* │ │ │
|
|
78
|
+
│ │ │ • GET /tools/list - List all tools │ │ │
|
|
79
|
+
│ │ │ • GET /tools/info/:name - Get tool schema │ │ │
|
|
80
|
+
│ │ │ • GET /tools/system - Get system prompt │ │ │
|
|
81
|
+
│ │ │ • POST /tools/call/:name - Execute any tool │ │ │
|
|
82
|
+
│ │ └─────────────────────────────────────────────────────────────────────┘ │ │
|
|
83
|
+
│ │ ┌─────────────────────────────────────────────────────────────────────┐ │ │
|
|
84
|
+
│ │ │ /prompts/* │ │ │
|
|
85
|
+
│ │ │ • GET /prompts/list - List all prompts │ │ │
|
|
86
|
+
│ │ │ • GET /prompts/info/:name - Get prompt details │ │ │
|
|
87
|
+
│ │ └─────────────────────────────────────────────────────────────────────┘ │ │
|
|
88
|
+
│ │ │ │ │
|
|
89
|
+
│ │ ┌─────┴─────────────────────────────────────────────────────┐ │ │
|
|
90
|
+
│ │ │ RESILIENCE LAYER │ │ │
|
|
91
|
+
│ │ │ (Circuit Breaker + Retry + Rate Limit Handling) │ │ │
|
|
92
|
+
│ │ └───────────────────────────┬────────────────────────────────┘ │ │
|
|
93
|
+
│ └──────────────────────────────┼────────────────────────────────────────────┘ │
|
|
94
|
+
└────────────────────────────────┼────────────────────────────────────────────┘
|
|
95
|
+
│
|
|
96
|
+
▼
|
|
97
|
+
┌──────────────────────────────────────────────────────────────────────────────┐
|
|
98
|
+
│ OCTOCODE-MCP PACKAGE │
|
|
99
|
+
├──────────────────────────────────────────────────────────────────────────────┤
|
|
100
|
+
│ src/index.ts (re-exports) → Tool Execution Functions │
|
|
101
|
+
│ ┌────────────────────────────────────────────────────────────────────────┐ │
|
|
102
|
+
│ │ localSearchCode, localGetFileContent, localFindFiles, localViewStructure│ │
|
|
103
|
+
│ │ lspGotoDefinition, lspFindReferences, lspCallHierarchy │ │
|
|
104
|
+
│ │ githubSearchCode, githubGetFileContent, githubViewRepoStructure, etc. │ │
|
|
105
|
+
│ │ packageSearch │ │
|
|
106
|
+
│ └────────────────────────────────────────────────────────────────────────┘ │
|
|
107
|
+
└──────────────────────────────────────────────────────────────────────────────┘
|
|
108
|
+
│
|
|
109
|
+
▼
|
|
110
|
+
┌──────────────────────────────────────────────────────────────────────────────┐
|
|
111
|
+
│ EXTERNAL SYSTEMS │
|
|
112
|
+
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
113
|
+
│ │ Filesystem │ │ GitHub API │ │ NPM/PyPI │ │ LSP Server │ │
|
|
114
|
+
│ │ (ripgrep) │ │ (Octokit) │ │ APIs │ │ │ │
|
|
115
|
+
│ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
|
|
116
|
+
└──────────────────────────────────────────────────────────────────────────────┘
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Main Components
|
|
122
|
+
|
|
123
|
+
### 1. **Server (\`src/server.ts\`)**
|
|
124
|
+
|
|
125
|
+
The Express HTTP server that:
|
|
126
|
+
- Initializes MCP content cache at startup
|
|
127
|
+
- Mounts \`/tools\` and \`/prompts\` route handlers
|
|
128
|
+
- Handles graceful shutdown
|
|
129
|
+
- Exposes \`/health\` endpoint for monitoring
|
|
130
|
+
|
|
131
|
+
### 2. **MCP Cache (\`src/mcpCache.ts\`)**
|
|
132
|
+
|
|
133
|
+
Singleton cache that:
|
|
134
|
+
- Loads tool metadata ONCE at startup
|
|
135
|
+
- Provides fast access to tool schemas
|
|
136
|
+
- Avoids repeated initialization costs
|
|
137
|
+
|
|
138
|
+
### 3. **Index (\`src/index.ts\`)**
|
|
139
|
+
|
|
140
|
+
Re-exports layer that:
|
|
141
|
+
- Maps \`octocode-mcp\` functions to skill-friendly names
|
|
142
|
+
- Provides type exports for TypeScript consumers
|
|
143
|
+
- Centralizes all tool imports
|
|
144
|
+
|
|
145
|
+
### 4. **Routes (\`src/routes/\`)**
|
|
146
|
+
|
|
147
|
+
| File | Endpoints | Purpose |
|
|
148
|
+
|------|-----------|---------|
|
|
149
|
+
| \`tools.ts\` | \`/tools/list\`, \`/tools/info/:name\`, \`/tools/call/:name\`, \`/tools/system\` | **Main API** - Tool discovery & execution |
|
|
150
|
+
| \`prompts.ts\` | \`/prompts/list\`, \`/prompts/info/:name\` | Prompt discovery |
|
|
151
|
+
| \`local.ts\` | *(Not mounted - used in tests only)* | Filesystem operations handlers |
|
|
152
|
+
| \`lsp.ts\` | *(Not mounted - used in tests only)* | Semantic analysis handlers |
|
|
153
|
+
| \`github.ts\` | *(Not mounted - used in tests only)* | GitHub API handlers |
|
|
154
|
+
| \`package.ts\` | *(Not mounted - used in tests only)* | npm/PyPI search handlers |
|
|
155
|
+
|
|
156
|
+
> **Note**: Only \`/tools/*\` and \`/prompts/*\` are mounted in production. The individual route files contain handler logic used by the unified \`/tools/call/:toolName\` endpoint.
|
|
157
|
+
|
|
158
|
+
### 5. **Build Output (\`scripts/\`)**
|
|
159
|
+
|
|
160
|
+
The bundled server output from tsdown:
|
|
161
|
+
|
|
162
|
+
| File | Purpose |
|
|
163
|
+
|------|---------|
|
|
164
|
+
| \`server.js\` | Bundled server (standalone, all deps included) |
|
|
165
|
+
| \`server.d.ts\` | TypeScript type declarations |
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Core Flows
|
|
170
|
+
|
|
171
|
+
### 1. Server Startup Flow
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
┌────────────────────────────────────────────────────────────────────────────┐
|
|
175
|
+
│ SERVER STARTUP FLOW (PM2 Managed) │
|
|
176
|
+
└────────────────────────────────────────────────────────────────────────────┘
|
|
177
|
+
|
|
178
|
+
npm run pm2:start (or pm2 start ecosystem.config.cjs)
|
|
179
|
+
│
|
|
180
|
+
▼
|
|
181
|
+
┌──────────────────────────────────────┐
|
|
182
|
+
│ PM2 Process Manager │
|
|
183
|
+
│ - Reads ecosystem.config.cjs │
|
|
184
|
+
│ - Spawns node scripts/server.js │
|
|
185
|
+
│ - Sets wait_ready: true │
|
|
186
|
+
└────────┬─────────────────────────────┘
|
|
187
|
+
│
|
|
188
|
+
▼
|
|
189
|
+
┌──────────────────────────────────────┐
|
|
190
|
+
│ src/server.ts │
|
|
191
|
+
│ startServer() │
|
|
192
|
+
└────────┬─────────────────────────────┘
|
|
193
|
+
│
|
|
194
|
+
▼
|
|
195
|
+
┌──────────────────────────────────────┐
|
|
196
|
+
│ 1. createServer() │
|
|
197
|
+
│ ├─ initializeLogger() │
|
|
198
|
+
│ ├─ initializeSession() │
|
|
199
|
+
│ ├─ express() │
|
|
200
|
+
│ ├─ use(requestLogger) │
|
|
201
|
+
│ ├─ mount(/health) │
|
|
202
|
+
│ ├─ mount(/tools, toolsRoutes) │
|
|
203
|
+
│ ├─ mount(/prompts, promptsRoutes) │
|
|
204
|
+
│ └─ use(errorHandler) │
|
|
205
|
+
└────────┬─────────────────────────────┘
|
|
206
|
+
│
|
|
207
|
+
▼
|
|
208
|
+
┌──────────────────────────────────────┐
|
|
209
|
+
│ 2. app.listen(1987) │
|
|
210
|
+
│ └─ HTTP server listening │
|
|
211
|
+
│ └─ Status: "initializing" │
|
|
212
|
+
└────────┬─────────────────────────────┘
|
|
213
|
+
│
|
|
214
|
+
▼
|
|
215
|
+
┌──────────────────────────────────────┐
|
|
216
|
+
│ 3. Background initialization (async) │
|
|
217
|
+
│ ├─ initializeMcpContent() │
|
|
218
|
+
│ │ ├─ initialize() (octocode-mcp) │
|
|
219
|
+
│ │ └─ loadToolContent() → cache │
|
|
220
|
+
│ ├─ initializeProviders() │
|
|
221
|
+
│ │ └─ Resolve GitHub token │
|
|
222
|
+
│ └─ process.send('ready') ◄─────────│── PM2 ready signal
|
|
223
|
+
└────────┬─────────────────────────────┘
|
|
224
|
+
│
|
|
225
|
+
▼
|
|
226
|
+
┌──────────────────────────────────────┐
|
|
227
|
+
│ 4. PM2 marks process "online" │
|
|
228
|
+
│ └─ Status: "ok" │
|
|
229
|
+
│ └─ Server Ready! │
|
|
230
|
+
└──────────────────────────────────────┘
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### 2. Tool Execution Flow
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
┌────────────────────────────────────────────────────────────────────────────┐
|
|
237
|
+
│ TOOL EXECUTION FLOW │
|
|
238
|
+
└────────────────────────────────────────────────────────────────────────────┘
|
|
239
|
+
|
|
240
|
+
POST /tools/call/localSearchCode
|
|
241
|
+
Body: { "queries": [{ "pattern": "auth", "path": "src", ... }] }
|
|
242
|
+
│
|
|
243
|
+
▼
|
|
244
|
+
┌──────────────────────────────────────┐
|
|
245
|
+
│ requestLogger Middleware │
|
|
246
|
+
│ → Log: tool, params, timestamp │
|
|
247
|
+
│ → Write to ~/.octocode/logs/ │
|
|
248
|
+
└────────┬─────────────────────────────┘
|
|
249
|
+
│
|
|
250
|
+
▼
|
|
251
|
+
┌──────────────────────────────────────┐
|
|
252
|
+
│ Route Handler (routes/tools.ts) │
|
|
253
|
+
│ POST /tools/call/:toolName │
|
|
254
|
+
│ │
|
|
255
|
+
│ 1. Lookup tool in TOOL_REGISTRY │
|
|
256
|
+
│ 2. Validate queries array │
|
|
257
|
+
│ 3. Get resilience wrapper │
|
|
258
|
+
└────────┬─────────────────────────────┘
|
|
259
|
+
│
|
|
260
|
+
▼
|
|
261
|
+
┌──────────────────────────────────────┐
|
|
262
|
+
│ Body Validation │
|
|
263
|
+
│ │
|
|
264
|
+
│ Input: { queries: [...] } │
|
|
265
|
+
│ Checks: │
|
|
266
|
+
│ - queries is array │
|
|
267
|
+
│ - 1-3 queries per request │
|
|
268
|
+
│ - Tool exists in registry │
|
|
269
|
+
└────────┬─────────────────────────────┘
|
|
270
|
+
│
|
|
271
|
+
▼
|
|
272
|
+
┌──────────────────────────────────────┐
|
|
273
|
+
│ Resilience Wrapper │
|
|
274
|
+
│ │
|
|
275
|
+
│ toolEntry.resilience(fn, toolName) │
|
|
276
|
+
│ ├─ Circuit Breaker Check │
|
|
277
|
+
│ │ └─ OPEN? → Fail fast │
|
|
278
|
+
│ │ └─ CLOSED/HALF-OPEN? → Proceed │
|
|
279
|
+
│ ├─ Retry with Backoff │
|
|
280
|
+
│ │ └─ Config per tool category │
|
|
281
|
+
│ └─ Execute Tool Function │
|
|
282
|
+
└────────┬─────────────────────────────┘
|
|
283
|
+
│
|
|
284
|
+
▼
|
|
285
|
+
┌──────────────────────────────────────┐
|
|
286
|
+
│ octocode-mcp Tool Function │
|
|
287
|
+
│ │
|
|
288
|
+
│ localSearchCode({ queries: [...] }) │
|
|
289
|
+
│ ├─ Execute ripgrep search │
|
|
290
|
+
│ ├─ Parse results │
|
|
291
|
+
│ ├─ Apply hints │
|
|
292
|
+
│ └─ Return CallToolResult │
|
|
293
|
+
└────────┬─────────────────────────────┘
|
|
294
|
+
│
|
|
295
|
+
▼
|
|
296
|
+
┌──────────────────────────────────────┐
|
|
297
|
+
│ Response Transformation │
|
|
298
|
+
│ │
|
|
299
|
+
│ parseToolResponse(rawResult) │
|
|
300
|
+
│ ├─ Extract data, hints, research │
|
|
301
|
+
│ └─ Detect errors │
|
|
302
|
+
└────────┬─────────────────────────────┘
|
|
303
|
+
│
|
|
304
|
+
▼
|
|
305
|
+
┌──────────────────────────────────────┐
|
|
306
|
+
│ HTTP Response │
|
|
307
|
+
│ │
|
|
308
|
+
│ { │
|
|
309
|
+
│ tool: "localSearchCode", │
|
|
310
|
+
│ success: true, │
|
|
311
|
+
│ data: { ... }, │
|
|
312
|
+
│ hints: [...], │
|
|
313
|
+
│ research: { ... } │
|
|
314
|
+
│ } │
|
|
315
|
+
└──────────────────────────────────────┘
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### 3. Discovery Flow
|
|
319
|
+
|
|
320
|
+
```
|
|
321
|
+
┌────────────────────────────────────────────────────────────────────────────┐
|
|
322
|
+
│ DISCOVERY FLOW │
|
|
323
|
+
└────────────────────────────────────────────────────────────────────────────┘
|
|
324
|
+
|
|
325
|
+
GET /tools/list GET /tools/info/localSearchCode
|
|
326
|
+
│ │
|
|
327
|
+
▼ ▼
|
|
328
|
+
┌──────────────────────┐ ┌──────────────────────┐
|
|
329
|
+
│ Static tool list │ │ getMcpContent() │
|
|
330
|
+
│ (hardcoded in │ │ └─ Return cached │
|
|
331
|
+
│ tools.ts) │ │ metadata │
|
|
332
|
+
└────────┬─────────────┘ └────────┬─────────────┘
|
|
333
|
+
│ │
|
|
334
|
+
▼ ▼
|
|
335
|
+
┌──────────────────────┐ ┌──────────────────────┐
|
|
336
|
+
│ Return tool list: │ │ Find tool by name: │
|
|
337
|
+
│ - name │ │ - name │
|
|
338
|
+
│ - description │ │ - description │
|
|
339
|
+
│ - _hint: use │ │ - inputSchema (Zod)│
|
|
340
|
+
│ /tools/info │ │ - hints │
|
|
341
|
+
│ │ │ │
|
|
342
|
+
│ (concise discovery) │ │ (full schema) │
|
|
343
|
+
└──────────────────────┘ └──────────────────────┘
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## Component Connections
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
┌────────────────────────────────────────────────────────────────────────────┐
|
|
352
|
+
│ COMPONENT DEPENDENCY GRAPH │
|
|
353
|
+
└────────────────────────────────────────────────────────────────────────────┘
|
|
354
|
+
|
|
355
|
+
┌─────────────────┐
|
|
356
|
+
│ package.json │
|
|
357
|
+
│ (scripts) │
|
|
358
|
+
└────────┬────────┘
|
|
359
|
+
│
|
|
360
|
+
┌───────────────────┼───────────────────┐
|
|
361
|
+
│ │ │
|
|
362
|
+
▼ ▼ ▼
|
|
363
|
+
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
|
|
364
|
+
│ scripts/ │ │ src/server.ts │ │ src/cli.ts │
|
|
365
|
+
│ server.ts │──│ (entry) │ │ (entry) │
|
|
366
|
+
└───────┬───────┘ └───────┬───────┘ └───────────────┘
|
|
367
|
+
│ │
|
|
368
|
+
│ ├─────────────────────────────┐
|
|
369
|
+
│ │ │
|
|
370
|
+
▼ ▼ ▼
|
|
371
|
+
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
|
|
372
|
+
│ octocode- │ │ src/mcpCache │ │ src/routes/ │
|
|
373
|
+
│ shared │ │ .ts │◄───────────│ tools.ts │
|
|
374
|
+
│ (session) │ └───────┬───────┘ │ prompts.ts │
|
|
375
|
+
└───────────────┘ │ └───────┬───────┘
|
|
376
|
+
│ │
|
|
377
|
+
▼ ▼
|
|
378
|
+
┌───────────────┐ ┌───────────────┐
|
|
379
|
+
│ src/index.ts │◄───────────│ src/utils/ │
|
|
380
|
+
│ (re-exports) │ │ resilience │
|
|
381
|
+
└───────┬───────┘ └───────┬───────┘
|
|
382
|
+
│ │
|
|
383
|
+
│ │
|
|
384
|
+
▼ ▼
|
|
385
|
+
┌───────────────┐ ┌───────────────┐
|
|
386
|
+
│ octocode-mcp │ │ src/utils/ │
|
|
387
|
+
│ (tools) │ │ circuitBreaker│
|
|
388
|
+
└───────────────┘ │ retry.ts │
|
|
389
|
+
└───────────────┘
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## PM2 Process Management
|
|
395
|
+
|
|
396
|
+
The server is managed by PM2 for automatic restarts, monitoring, and log management.
|
|
397
|
+
|
|
398
|
+
### PM2 Features
|
|
399
|
+
|
|
400
|
+
| Feature | Configuration | Description |
|
|
401
|
+
|---------|---------------|-------------|
|
|
402
|
+
| **Cron Restart** | `0 * * * *` | Restarts every hour for memory hygiene |
|
|
403
|
+
| **Memory Guard** | `500M` | Auto-restart if memory exceeds threshold |
|
|
404
|
+
| **Ready Signal** | `wait_ready: true` | PM2 waits for `process.send('ready')` |
|
|
405
|
+
| **Kill Timeout** | `10000ms` | Graceful shutdown timeout |
|
|
406
|
+
| **Auto Restart** | `max_restarts: 10` | Restart on crash with backoff |
|
|
407
|
+
|
|
408
|
+
### PM2 Commands
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
# NPM Scripts
|
|
412
|
+
npm run pm2:start # Start with PM2
|
|
413
|
+
npm run pm2:stop # Stop gracefully
|
|
414
|
+
npm run pm2:restart # Restart
|
|
415
|
+
npm run pm2:reload # Zero-downtime reload
|
|
416
|
+
npm run pm2:delete # Remove from PM2
|
|
417
|
+
npm run pm2:logs # View logs
|
|
418
|
+
npm run pm2:monit # Dashboard
|
|
419
|
+
|
|
420
|
+
# Direct PM2 Commands
|
|
421
|
+
pm2 status # List processes
|
|
422
|
+
pm2 logs octocode-research # Tail logs
|
|
423
|
+
pm2 describe octocode-research # Process details
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### Lifecycle Diagram
|
|
427
|
+
|
|
428
|
+
```
|
|
429
|
+
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
430
|
+
│ PM2 LIFECYCLE │
|
|
431
|
+
├─────────────────────────────────────────────────────────────────────────────┤
|
|
432
|
+
│ │
|
|
433
|
+
│ pm2 start ──▶ [STARTING] ──▶ [WAITING READY] ──▶ [ONLINE] │
|
|
434
|
+
│ │ │ │
|
|
435
|
+
│ process.send('ready') │ │
|
|
436
|
+
│ │ │
|
|
437
|
+
│ ┌──────────────────────────────────────────────────┴──────────────────┐ │
|
|
438
|
+
│ │ RUNNING │ │
|
|
439
|
+
│ │ - Cron restart every hour │ │
|
|
440
|
+
│ │ - Memory check (restart if > 500MB) │ │
|
|
441
|
+
│ │ - Auto-restart on crash (with backoff) │ │
|
|
442
|
+
│ └──────────────────────────────────────────────────────────────────────┘ │
|
|
443
|
+
│ │ │
|
|
444
|
+
│ SIGINT/SIGTERM ──────────────────▶│ │
|
|
445
|
+
│ │ │
|
|
446
|
+
│ ┌───────────────┴───────────────┐ │
|
|
447
|
+
│ │ gracefulShutdown() │ │
|
|
448
|
+
│ │ 1. stopCircuitCleanup() │ │
|
|
449
|
+
│ │ 2. clearAllCircuits() │ │
|
|
450
|
+
│ │ 3. server.close() │ │
|
|
451
|
+
│ │ 4. process.exit(0) │ │
|
|
452
|
+
│ └───────────────────────────────┘ │
|
|
453
|
+
│ │ │
|
|
454
|
+
│ ▼ │
|
|
455
|
+
│ PM2 Auto-Restart │
|
|
456
|
+
│ │
|
|
457
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
---
|
|
461
|
+
|
|
462
|
+
## Quick Reference
|
|
463
|
+
|
|
464
|
+
### Start Server
|
|
465
|
+
|
|
466
|
+
```bash
|
|
467
|
+
# Development (with hot reload)
|
|
468
|
+
npm run dev
|
|
469
|
+
|
|
470
|
+
# Production (PM2 managed - RECOMMENDED)
|
|
471
|
+
npm run pm2:start
|
|
472
|
+
npm run pm2:logs # View logs
|
|
473
|
+
|
|
474
|
+
# Direct (no PM2)
|
|
475
|
+
npm start
|
|
476
|
+
# Or: node scripts/server.js
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### HTTP Examples
|
|
480
|
+
|
|
481
|
+
```bash
|
|
482
|
+
# Discovery
|
|
483
|
+
curl http://localhost:1987/health # Health check
|
|
484
|
+
curl http://localhost:1987/tools/list # List all tools
|
|
485
|
+
curl http://localhost:1987/tools/info/localSearchCode # Get tool schema
|
|
486
|
+
curl http://localhost:1987/tools/system # Load system prompt
|
|
487
|
+
curl http://localhost:1987/prompts/list # List all prompts
|
|
488
|
+
|
|
489
|
+
# Tool Execution (ALL tools via POST /tools/call/:toolName)
|
|
490
|
+
curl -X POST http://localhost:1987/tools/call/localSearchCode \
|
|
491
|
+
-H "Content-Type: application/json" \
|
|
492
|
+
-d '{"queries": [{"mainResearchGoal": "Find auth", "researchGoal": "Search", "reasoning": "Test", "pattern": "auth", "path": "src"}]}'
|
|
493
|
+
|
|
494
|
+
curl -X POST http://localhost:1987/tools/call/lspGotoDefinition \
|
|
495
|
+
-H "Content-Type: application/json" \
|
|
496
|
+
-d '{"queries": [{"mainResearchGoal": "Find def", "researchGoal": "Locate", "reasoning": "Test", "uri": "file:///path/file.ts", "symbolName": "createServer", "lineHint": 20}]}'
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
### HTTP Endpoints
|
|
500
|
+
|
|
501
|
+
| Category | Endpoint | Method | Description |
|
|
502
|
+
|----------|----------|--------|-------------|
|
|
503
|
+
| **Health** | \`/health\` | GET | Server health + circuit states |
|
|
504
|
+
| **Discovery** | \`/tools/list\` | GET | List all tools (concise) |
|
|
505
|
+
| | \`/tools/info/:name\` | GET | Get tool schema + hints |
|
|
506
|
+
| | \`/tools/system\` | GET | Get system prompt |
|
|
507
|
+
| | \`/prompts/list\` | GET | List all prompts |
|
|
508
|
+
| | \`/prompts/info/:name\` | GET | Get prompt details |
|
|
509
|
+
| **Execution** | \`/tools/call/:toolName\` | POST | **Execute any tool** |
|
|
510
|
+
|
|
511
|
+
### Available Tools (via \`/tools/call/:toolName\`)
|
|
512
|
+
|
|
513
|
+
| Tool Name | Category | Description |
|
|
514
|
+
|-----------|----------|-------------|
|
|
515
|
+
| \`localSearchCode\` | Local | Search code with ripgrep |
|
|
516
|
+
| \`localGetFileContent\` | Local | Read local file content |
|
|
517
|
+
| \`localFindFiles\` | Local | Find files by pattern/metadata |
|
|
518
|
+
| \`localViewStructure\` | Local | View local directory tree |
|
|
519
|
+
| \`lspGotoDefinition\` | LSP | Go to symbol definition |
|
|
520
|
+
| \`lspFindReferences\` | LSP | Find all symbol references |
|
|
521
|
+
| \`lspCallHierarchy\` | LSP | Get call hierarchy |
|
|
522
|
+
| \`githubSearchCode\` | GitHub | Search code in GitHub repos |
|
|
523
|
+
| \`githubGetFileContent\` | GitHub | Read file from GitHub repo |
|
|
524
|
+
| \`githubViewRepoStructure\` | GitHub | View GitHub repo tree |
|
|
525
|
+
| \`githubSearchRepositories\` | GitHub | Search GitHub repositories |
|
|
526
|
+
| \`githubSearchPullRequests\` | GitHub | Search pull requests |
|
|
527
|
+
| \`packageSearch\` | Package | Search npm/PyPI packages |
|
|
528
|
+
|
|
529
|
+
### Resilience Configuration
|
|
530
|
+
|
|
531
|
+
| Service | Max Attempts | Initial Delay | Max Delay | Backoff |
|
|
532
|
+
|---------|--------------|---------------|-----------|---------|
|
|
533
|
+
| GitHub | 3 | 1000ms | 30000ms | 3x |
|
|
534
|
+
| LSP | 3 | 500ms | 5000ms | 2x |
|
|
535
|
+
| Local | 2 | 100ms | 1000ms | 2x |
|
|
536
|
+
| Package | 3 | 1000ms | 15000ms | 2x |
|
|
537
|
+
|
|
538
|
+
### Circuit Breaker States
|
|
539
|
+
|
|
540
|
+
```
|
|
541
|
+
CLOSED (normal) ──[3 failures]──► OPEN (reject all)
|
|
542
|
+
▲ │
|
|
543
|
+
│ [30s timeout]
|
|
544
|
+
│ │
|
|
545
|
+
└──[1 success]─── HALF-OPEN ◄──┘
|
|
546
|
+
(probe)
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
**Per-service configuration:**
|
|
550
|
+
- **LSP**: 3 failures, 1 success, 10s timeout
|
|
551
|
+
- **GitHub**: 2 failures, 1 success, 60s timeout
|
|
552
|
+
|
|
553
|
+
---
|
|
554
|
+
|
|
555
|
+
## Files Summary
|
|
556
|
+
|
|
557
|
+
| File | Purpose |
|
|
558
|
+
|------|---------|
|
|
559
|
+
| `ecosystem.config.cjs` | **PM2 configuration** - restart strategies, memory limits, ready signal |
|
|
560
|
+
| `src/server.ts` | Express server, route mounting (`/tools`, `/prompts`), graceful shutdown |
|
|
561
|
+
| `src/index.ts` | Re-exports from octocode-mcp |
|
|
562
|
+
| `src/mcpCache.ts` | Tool metadata caching |
|
|
563
|
+
| `src/routes/tools.ts` | **Main API** - `/tools/call/:toolName` and discovery |
|
|
564
|
+
| `src/routes/prompts.ts` | Prompt discovery |
|
|
565
|
+
| `src/routes/local.ts` | Handler logic (used by tools.ts registry) |
|
|
566
|
+
| `src/routes/lsp.ts` | Handler logic (used by tools.ts registry) |
|
|
567
|
+
| `src/routes/github.ts` | Handler logic (used by tools.ts registry) |
|
|
568
|
+
| `src/routes/package.ts` | Handler logic (used by tools.ts registry) |
|
|
569
|
+
| `src/middleware/*.ts` | Logging, validation, error handling |
|
|
570
|
+
| `src/utils/*.ts` | Resilience, formatting, parsing |
|
|
571
|
+
| `src/validation/schemas.ts` | Zod validation schemas |
|
|
572
|
+
| `scripts/server.js` | Bundled server (tsdown output) |
|
|
573
|
+
|
|
574
|
+
---
|
|
575
|
+
|
|
576
|
+
*Created by Octocode Research Skill v2.1.0*
|
|
577
|
+
*Last validated: 2026-01-20*
|