@octocodeai/octocode-tools-core 18.3.0 → 19.1.0
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/README.md +19 -19
- package/dist/chunks/direct/chunk-3AA4F3QO.js +10 -0
- package/dist/chunks/direct/chunk-43RVQWTG.js +8 -0
- package/dist/chunks/direct/chunk-7DYE654A.js +8 -0
- package/dist/chunks/direct/chunk-A4WMBDEC.js +8 -0
- package/dist/chunks/direct/chunk-AWZG43MA.js +8 -0
- package/dist/chunks/direct/chunk-BICVXQ5F.js +8 -0
- package/dist/chunks/direct/chunk-BMM5H6QF.js +11 -0
- package/dist/chunks/direct/chunk-C6HFNIDL.js +8 -0
- package/dist/chunks/direct/chunk-CBCZVCTZ.js +8 -0
- package/dist/chunks/direct/chunk-CBIKUVP6.js +11 -0
- package/dist/chunks/direct/chunk-CKB2ME2J.js +8 -0
- package/dist/chunks/direct/chunk-DBI23PBG.js +9 -0
- package/dist/chunks/direct/chunk-DBSQWRFS.js +9 -0
- package/dist/chunks/direct/chunk-DKGYPFGX.js +8 -0
- package/dist/chunks/direct/chunk-EOLHXX5I.js +8 -0
- package/dist/chunks/direct/chunk-IFPXDKUV.js +8 -0
- package/dist/chunks/direct/chunk-J3WYA3IJ.js +8 -0
- package/dist/chunks/direct/chunk-MCMOWPYL.js +8 -0
- package/dist/chunks/direct/chunk-MPTAIBY7.js +8 -0
- package/dist/chunks/direct/chunk-NQRDACK3.js +8 -0
- package/dist/chunks/direct/chunk-O5ETB2W5.js +8 -0
- package/dist/chunks/direct/chunk-OA6NU4KO.js +8 -0
- package/dist/chunks/direct/chunk-QKDE2HIF.js +10 -0
- package/dist/chunks/direct/chunk-RRSY2ZPX.js +13 -0
- package/dist/chunks/direct/chunk-UKQLRZEW.js +8 -0
- package/dist/chunks/direct/chunk-USZL65FN.js +8 -0
- package/dist/chunks/direct/chunk-WH6GL3J2.js +8 -0
- package/dist/chunks/direct/chunk-Y5OCKUQX.js +9 -0
- package/dist/chunks/direct/chunk-ZO44CZN5.js +8 -0
- package/dist/chunks/direct/chunk-ZSXRT7JL.js +12 -0
- package/dist/chunks/direct/chunk-ZUNPQVMO.js +8 -0
- package/dist/chunks/direct/execution-3T4B776P.js +9 -0
- package/dist/chunks/direct/execution-5BJNS7D7.js +8 -0
- package/dist/chunks/direct/execution-5O6QHKBR.js +8 -0
- package/dist/chunks/direct/execution-A4NK3BQO.js +8 -0
- package/dist/chunks/direct/execution-K4UOPXRQ.js +9 -0
- package/dist/chunks/direct/execution-SWWZOOA7.js +13 -0
- package/dist/chunks/direct/execution-X4MUJL4L.js +8 -0
- package/dist/chunks/direct/execution-XA6PXPRB.js +8 -0
- package/dist/chunks/direct/historyExecutions-6F3AA5PY.js +14 -0
- package/dist/direct.d.ts +6 -1
- package/dist/direct.js +2 -46
- package/dist/github/canonicalRepo.d.ts +2 -1
- package/dist/github/client.d.ts +3 -8
- package/dist/github/codeSearch/compactFragment.d.ts +7 -0
- package/dist/github/codeSearch.d.ts +2 -3
- package/dist/github/commit.d.ts +8 -0
- package/dist/github/commitDetail.d.ts +20 -0
- package/dist/github/commitSearch.d.ts +17 -0
- package/dist/github/compare.d.ts +15 -0
- package/dist/github/directoryFetch/cacheMetadata.d.ts +25 -0
- package/dist/github/directoryFetch/helpers.d.ts +1 -3
- package/dist/github/directoryFetch/snapshot.d.ts +10 -0
- package/dist/github/fileContentProcess.d.ts +0 -1
- package/dist/github/fileContentRaw/cache.d.ts +9 -0
- package/dist/github/fileContentRaw/fetch.d.ts +1 -1
- package/dist/github/githubAPI.d.ts +19 -2
- package/dist/github/history/commitFiles.d.ts +12 -0
- package/dist/github/issues/fetchers.d.ts +1 -1
- package/dist/github/issues/types.d.ts +3 -1
- package/dist/github/prContentFetcher/collectionPaging.d.ts +27 -0
- package/dist/github/prContentFetcher/comments.d.ts +7 -5
- package/dist/github/prContentFetcher/commits.d.ts +13 -14
- package/dist/github/prContentFetcher/flags.d.ts +0 -1
- package/dist/github/prContentFetcher/transform.d.ts +1 -1
- package/dist/github/prTransformation.d.ts +3 -1
- package/dist/github/queryBuilders/codeAndRepo.d.ts +2 -1
- package/dist/github/repoSearch.d.ts +2 -1
- package/dist/github/repoStructure/fetchOrchestration.d.ts +1 -1
- package/dist/github/repoStructurePagination.d.ts +1 -1
- package/dist/github/repoStructureTree.d.ts +4 -2
- package/dist/graph/advancedOperations.d.ts +2 -2
- package/dist/graph/buildFileGraph.d.ts +8 -13
- package/dist/graph/coverage.d.ts +6 -0
- package/dist/graph/diagnosticSnapshot.d.ts +10 -0
- package/dist/graph/fileImportLinker.d.ts +28 -0
- package/dist/graph/importResolver.d.ts +1 -1
- package/dist/graph/languageImportResolver.d.ts +5 -0
- package/dist/graph/metadataImports.d.ts +7 -0
- package/dist/graph/packageExportTargets.d.ts +11 -0
- package/dist/graph/rustCargoMetadata.d.ts +31 -0
- package/dist/graph/rustCargoProcess.d.ts +16 -0
- package/dist/graph/rustModules.d.ts +7 -0
- package/dist/graph/rustWorkspace.d.ts +5 -0
- package/dist/graph/types.d.ts +94 -3
- package/dist/graph/workspacePackageResolver.d.ts +7 -2
- package/dist/index.d.ts +46 -19
- package/dist/index.js +36 -45
- package/dist/providers/github/GitHubProvider.d.ts +3 -1
- package/dist/providers/github/githubContent.d.ts +3 -2
- package/dist/providers/github/githubPullRequests.d.ts +3 -2
- package/dist/providers/github/githubSearch.d.ts +6 -3
- package/dist/providers/github/githubStructure.d.ts +3 -2
- package/dist/providers/providerQueries.d.ts +4 -0
- package/dist/providers/providerResults.d.ts +29 -1
- package/dist/providers/types.d.ts +0 -2
- package/dist/schema.d.ts +9 -3
- package/dist/schema.js +4 -12
- package/dist/scheme/fields.d.ts +8 -8
- package/dist/scheme/pagination.d.ts +1 -0
- package/dist/serverConfig.d.ts +1 -1
- package/dist/shared/session/index.d.ts +1 -1
- package/dist/shared/session/index.js +1 -1
- package/dist/shared/session/storage.d.ts +0 -1
- package/dist/toolContract/descriptions.d.ts +6 -6
- package/dist/toolContract/input/resources/tools/ghSearch.d.ts +21 -20
- package/dist/toolContract/input/resources/tools/githubHistorySchema.d.ts +14 -6
- package/dist/toolContract/input/resources/tools/githubRepositoriesOperation.d.ts +3 -3
- package/dist/toolContract/input/resources/tools/githubTreeOperation.d.ts +4 -2
- package/dist/toolContract/input/resources/tools/historyCommitInput.d.ts +9 -0
- package/dist/toolContract/input/resources/tools/historyIssueInput.d.ts +4 -4
- package/dist/toolContract/input/resources/tools/historyPullRequestInput.d.ts +13 -5
- package/dist/toolContract/input/resources/tools/localAnalyzeGraph.d.ts +74 -32
- package/dist/toolContract/input/resources/tools/localFilesOperation.d.ts +1 -1
- package/dist/toolContract/input/resources/tools/localSearch.d.ts +43 -43
- package/dist/toolContract/input/resources/tools/localTextOperation.d.ts +1 -1
- package/dist/toolContract/input/resources/tools/localTreeOperation.d.ts +2 -2
- package/dist/toolContract/input/resources/tools/lspGetSemantics.d.ts +11 -2
- package/dist/toolContract/input/resources/tools/npmSearch.d.ts +2 -1
- package/dist/toolContract/metadata.d.ts +1 -1
- package/dist/toolContract/runtime.d.ts +1 -1
- package/dist/toolContract/types.d.ts +0 -1
- package/dist/tools/directToolCatalog/toolCatalogDefinitions.d.ts +2 -4
- package/dist/tools/directToolCatalog/toolInputPreparation.d.ts +2 -5
- package/dist/tools/directToolCatalog.exec.d.ts +10 -7
- package/dist/tools/github_clone_repo/cache.d.ts +0 -2
- package/dist/tools/github_clone_repo/cacheArtifacts.d.ts +3 -1
- package/dist/tools/github_clone_repo/cachePaths.d.ts +3 -2
- package/dist/tools/github_clone_repo/gitCheckout.d.ts +5 -0
- package/dist/tools/github_clone_repo/scheme.d.ts +3 -3
- package/dist/tools/github_clone_repo/types.d.ts +6 -1
- package/dist/tools/github_fetch_content/finalizer/types.d.ts +10 -2
- package/dist/tools/github_fetch_content/scheme.d.ts +3 -4
- package/dist/tools/github_fetch_content/types.d.ts +4 -3
- package/dist/tools/github_search/scheme.d.ts +24 -23
- package/dist/tools/github_search_code/execution.d.ts +1 -1
- package/dist/tools/github_search_code/finalizer/groups.d.ts +1 -1
- package/dist/tools/github_search_code/finalizer/ranking.d.ts +1 -1
- package/dist/tools/github_search_code/scheme.d.ts +3 -3
- package/dist/tools/github_search_pull_requests/contentResponse/commentsShaping.d.ts +4 -1
- package/dist/tools/github_search_pull_requests/contentResponse/contentView.d.ts +3 -0
- package/dist/tools/github_search_pull_requests/contentResponse/fileSurfaces.d.ts +30 -2
- package/dist/tools/github_search_pull_requests/contentResponse/nextCalls.d.ts +1 -7
- package/dist/tools/github_search_pull_requests/contentResponse/pagination.d.ts +14 -2
- package/dist/tools/github_search_pull_requests/historyContinuations.d.ts +1 -1
- package/dist/tools/github_search_pull_requests/historyDiffContinuations.d.ts +2 -0
- package/dist/tools/github_search_pull_requests/historySchemes.d.ts +23 -22
- package/dist/tools/github_search_pull_requests/scheme.d.ts +17 -9
- package/dist/tools/github_search_pull_requests/splitSchemes.d.ts +35 -26
- package/dist/tools/github_search_pull_requests/types.d.ts +5 -0
- package/dist/tools/github_search_repos/execution/pagination.d.ts +0 -17
- package/dist/tools/github_search_repos/execution/queryVariants.d.ts +1 -23
- package/dist/tools/github_search_repos/execution.d.ts +0 -1
- package/dist/tools/github_search_repos/scheme.d.ts +6 -6
- package/dist/tools/github_view_repo_structure/execution.d.ts +1 -1
- package/dist/tools/github_view_repo_structure/scheme.d.ts +6 -5
- package/dist/tools/local_analyze_graph/analysisTypes.d.ts +16 -3
- package/dist/tools/local_analyze_graph/analyzeGraph.d.ts +1 -1
- package/dist/tools/local_analyze_graph/completeness.d.ts +3 -0
- package/dist/tools/local_analyze_graph/deadCodeScan.d.ts +9 -5
- package/dist/tools/local_analyze_graph/rootInference.d.ts +2 -0
- package/dist/tools/local_analyze_graph/scheme.d.ts +13 -25
- package/dist/tools/local_fetch_content/fetchContent/pagination.d.ts +7 -0
- package/dist/tools/local_fetch_content/scheme.d.ts +3 -3
- package/dist/tools/local_find_files/findFiles.d.ts +1 -1
- package/dist/tools/local_find_files/scheme.d.ts +4 -4
- package/dist/tools/local_ripgrep/execution.d.ts +0 -1
- package/dist/tools/local_ripgrep/rankingProfile/rankingProfiles.d.ts +1 -2
- package/dist/tools/local_ripgrep/rankingProfile/rankingResults.d.ts +2 -2
- package/dist/tools/local_ripgrep/rankingProfile/rankingScoring.d.ts +1 -3
- package/dist/tools/local_ripgrep/ripgrepResultBuilder/buildResult.d.ts +0 -4
- package/dist/tools/local_ripgrep/ripgrepResultBuilder/searchNext.d.ts +1 -0
- package/dist/tools/local_ripgrep/scheme.d.ts +13 -5
- package/dist/tools/local_ripgrep/structuralCompleteness.d.ts +9 -0
- package/dist/tools/local_search/execution.d.ts +0 -1
- package/dist/tools/local_search/scheme.d.ts +46 -46
- package/dist/tools/local_view_structure/scheme.d.ts +5 -5
- package/dist/tools/lsp/semantic_content/scheme.d.ts +29 -7
- package/dist/tools/lsp/semantic_content/semanticAnchored.d.ts +2 -9
- package/dist/tools/lsp/semantic_content/semanticEnvelopes/callEnvelopes.d.ts +2 -2
- package/dist/tools/lsp/semantic_content/semanticEnvelopes/envelopeHelpers.d.ts +2 -1
- package/dist/tools/lsp/semantic_content/semanticEnvelopes/locationEnvelopes.d.ts +2 -3
- package/dist/tools/lsp/semantic_content/semanticFileOps/anchor.d.ts +0 -1
- package/dist/tools/lsp/semantic_content/semanticPresentation.d.ts +1 -0
- package/dist/tools/lsp/semantic_content/semanticSnapshot.d.ts +16 -0
- package/dist/tools/lsp/shared/callHierarchyTraversal.d.ts +2 -1
- package/dist/tools/lsp/shared/semanticTypes.d.ts +19 -10
- package/dist/tools/package_search/execution.d.ts +3 -4
- package/dist/tools/package_search/pagination.d.ts +1 -0
- package/dist/tools/package_search/scheme.d.ts +5 -4
- package/dist/tools/providerMappers/codeSearch.d.ts +2 -9
- package/dist/tools/providerMappers/fileContent.d.ts +1 -1
- package/dist/tools/providerMappers/pullRequests.d.ts +24 -4
- package/dist/tools/providerMappers/repoSearch.d.ts +4 -4
- package/dist/tools/providerMappers/repoStructure.d.ts +4 -3
- package/dist/tools/toolAvailability.d.ts +19 -0
- package/dist/tools/toolConfig.d.ts +1 -3
- package/dist/types/toolResults.d.ts +1 -0
- package/dist/utils/contextUtils.d.ts +1 -1
- package/dist/utils/core/types.d.ts +0 -2
- package/dist/utils/exec/npm.d.ts +2 -0
- package/dist/utils/file/byteOffset.d.ts +1 -1
- package/dist/utils/package/common.d.ts +0 -3
- package/dist/utils/package/npm/npmDeprecation.d.ts +1 -2
- package/dist/utils/package/npm/npmDetailsFetchers.d.ts +3 -15
- package/dist/utils/package/npm/npmMappers.d.ts +0 -4
- package/dist/utils/package/npm/npmRegistry.d.ts +9 -1
- package/dist/utils/package/npm/npmSearchStrategies.d.ts +2 -5
- package/dist/utils/package/types.d.ts +3 -0
- package/dist/utils/pagination/types.d.ts +1 -0
- package/dist/utils/response/callToolResult.d.ts +3 -1
- package/package.json +19 -15
- package/dist/errors/pathUtils.d.ts +0 -1
- package/dist/github/directoryFetch.d.ts +0 -3
- package/dist/github/fileContentRaw.d.ts +0 -2
- package/dist/github/issues.d.ts +0 -3
- package/dist/github/prContentFetcher.d.ts +0 -2
- package/dist/github/queryBuilders.d.ts +0 -4
- package/dist/github/repoStructure.d.ts +0 -1
- package/dist/shared/index.d.ts +0 -6
- package/dist/shared/languageSelectors.d.ts +0 -3
- package/dist/toolContract/schemas.d.ts +0 -31
- package/dist/tools/directToolCatalog.d.ts +0 -15
- package/dist/tools/directToolCatalog.meta.d.ts +0 -28
- package/dist/tools/github_search_code/finalizer.d.ts +0 -2
- package/dist/tools/github_search_repos/execution/ranking.d.ts +0 -4
- package/dist/tools/local_ripgrep/rankingProfile.d.ts +0 -35
- package/dist/tools/local_ripgrep/ripgrepResultBuilder.d.ts +0 -2
- package/dist/tools/lsp/semantic_content/index.d.ts +0 -3
- package/dist/tools/lsp/semantic_content/semanticEnvelopes.d.ts +0 -3
- package/dist/tools/lsp/semantic_content/semanticFileOps.d.ts +0 -8
- package/dist/tools/providerMappers.d.ts +0 -11
- package/dist/tools/toolMetadata/baseSchema.d.ts +0 -1
- package/dist/tools/toolMetadata/descriptions.d.ts +0 -1
- package/dist/tools/toolMetadata/proxies.d.ts +0 -4
- package/dist/tools/toolSchemaImports.d.ts +0 -16
- package/dist/utils/exec/spawn.d.ts +0 -2
- package/dist/utils/file/filters.d.ts +0 -2
- package/dist/utils/http/cache.d.ts +0 -5
- package/dist/utils/package/npm.d.ts +0 -2
- package/dist/utils/response/bulk.d.ts +0 -2
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ Octocode researches **your local code and external code alike** (GitHub reposito
|
|
|
40
40
|
|
|
41
41
|
## Quick start
|
|
42
42
|
|
|
43
|
-
**Prerequisites:** Node.js
|
|
43
|
+
**Prerequisites:** Node.js 22.22.2+ (22.x), 24.15.0+ (24.x), or 26+
|
|
44
44
|
|
|
45
45
|
**1. Run the Octocode CLI with `npx`**
|
|
46
46
|
|
|
@@ -55,8 +55,8 @@ npx octocode auth login
|
|
|
55
55
|
npx octocode status # verify the active token source
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
**3. Choose your interface.** Same tools and Rust engine on both.
|
|
59
|
-
|
|
58
|
+
**3. Choose your interface.** Same tools and Rust engine on both. Cloning is
|
|
59
|
+
opt-in on CLI and MCP.
|
|
60
60
|
|
|
61
61
|
**🖥️ CLI** - research straight from your terminal:
|
|
62
62
|
|
|
@@ -66,18 +66,18 @@ npx octocode
|
|
|
66
66
|
|
|
67
67
|
**🤖 MCP** - one-click install:
|
|
68
68
|
|
|
69
|
-
- [<img src="https://cursor.com/deeplink/mcp-install-dark.svg" alt="Install in Cursor">](https://cursor.com/en/install-mcp?name=octocode&config=
|
|
70
|
-
- [<img src="https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white" alt="Install in VS Code">](https://insiders.vscode.dev/redirect/mcp/install?name=octocode&config=%7B%22command%22%3A%22npx%22%2C%22type%22%3A%22stdio%22%2C%22args%22%3A%5B%22%
|
|
69
|
+
- [<img src="https://cursor.com/deeplink/mcp-install-dark.svg" alt="Install in Cursor">](https://cursor.com/en/install-mcp?name=octocode&config=eyJjb21tYW5kIjoibnB4IiwidHlwZSI6InN0ZGlvIiwiYXJncyI6WyIteSIsIm9jdG9jb2RlLW1jcEBsYXRlc3QiXX0=)
|
|
70
|
+
- [<img src="https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white" alt="Install in VS Code">](https://insiders.vscode.dev/redirect/mcp/install?name=octocode&config=%7B%22command%22%3A%22npx%22%2C%22type%22%3A%22stdio%22%2C%22args%22%3A%5B%22-y%22%2C%22octocode-mcp%40latest%22%5D%7D)
|
|
71
71
|
|
|
72
72
|
<details>
|
|
73
73
|
<summary><b>Show more install options (Windsurf, Kiro, Goose, LM Studio, Claude Code)</b></summary>
|
|
74
74
|
<br>
|
|
75
75
|
|
|
76
|
-
- [<img src="https://img.shields.io/badge/VS_Code_Insiders-Install_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white" alt="Install in VS Code Insiders">](https://insiders.vscode.dev/redirect/mcp/install?name=octocode&config=%7B%22command%22%3A%22npx%22%2C%22type%22%3A%22stdio%22%2C%22args%22%3A%5B%22%
|
|
77
|
-
- [<img src="https://img.shields.io/badge/Windsurf-Install_Server-1a1a1a?style=flat-square&logoColor=white" alt="Install in Windsurf">](windsurf://mcp/install?name=octocode&config=%7B%22command%22%3A%22npx%22%2C%22type%22%3A%22stdio%22%2C%22args%22%3A%5B%22%
|
|
78
|
-
- [<img src="https://kiro.dev/images/add-to-kiro.svg" alt="Install in Kiro">](https://kiro.dev/launch/mcp/add?name=octocode&config=%7B%22command%22%3A%22npx%22%2C%22type%22%3A%22stdio%22%2C%22args%22%3A%5B%22%
|
|
79
|
-
- [<img src="https://goose-docs.ai/img/extension-install-dark.svg" alt="Install in Goose">](https://goose-docs.ai/extension?cmd=npx&arg
|
|
80
|
-
- [<img src="https://files.lmstudio.ai/deeplink/mcp-install-light.svg" alt="Install in LM Studio">](https://lmstudio.ai/install-mcp?name=octocode&config=
|
|
76
|
+
- [<img src="https://img.shields.io/badge/VS_Code_Insiders-Install_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white" alt="Install in VS Code Insiders">](https://insiders.vscode.dev/redirect/mcp/install?name=octocode&config=%7B%22command%22%3A%22npx%22%2C%22type%22%3A%22stdio%22%2C%22args%22%3A%5B%22-y%22%2C%22octocode-mcp%40latest%22%5D%7D&quality=insiders)
|
|
77
|
+
- [<img src="https://img.shields.io/badge/Windsurf-Install_Server-1a1a1a?style=flat-square&logoColor=white" alt="Install in Windsurf">](windsurf://mcp/install?name=octocode&config=%7B%22command%22%3A%22npx%22%2C%22type%22%3A%22stdio%22%2C%22args%22%3A%5B%22-y%22%2C%22octocode-mcp%40latest%22%5D%7D)
|
|
78
|
+
- [<img src="https://kiro.dev/images/add-to-kiro.svg" alt="Install in Kiro">](https://kiro.dev/launch/mcp/add?name=octocode&config=%7B%22command%22%3A%22npx%22%2C%22type%22%3A%22stdio%22%2C%22args%22%3A%5B%22-y%22%2C%22octocode-mcp%40latest%22%5D%7D)
|
|
79
|
+
- [<img src="https://goose-docs.ai/img/extension-install-dark.svg" alt="Install in Goose">](https://goose-docs.ai/extension?cmd=npx&arg=-y&arg=octocode-mcp%40latest&id=octocode&name=octocode&description=Evidence-first%20code%20research%20for%20AI%20agents)
|
|
80
|
+
- [<img src="https://files.lmstudio.ai/deeplink/mcp-install-light.svg" alt="Install in LM Studio">](https://lmstudio.ai/install-mcp?name=octocode&config=eyJjb21tYW5kIjoibnB4IiwidHlwZSI6InN0ZGlvIiwiYXJncyI6WyIteSIsIm9jdG9jb2RlLW1jcEBsYXRlc3QiXX0=)
|
|
81
81
|
|
|
82
82
|
**Claude Code:**
|
|
83
83
|
|
|
@@ -169,7 +169,7 @@ Most tools do one slice (web search, or grep your repository) and hand back a fi
|
|
|
169
169
|
A blind, head-to-head test on **research-oriented flows rather than plain lookups** (multi-hop traces,
|
|
170
170
|
dependency/call-graph chains, commit ranges, blast-radius, PR reviews across repositories).
|
|
171
171
|
|
|
172
|
-
[](https://raw.githack.com/bgauryy/octocode/main/packages/octocode-benchmark/results/index.html)
|
|
172
|
+
[](https://raw.githack.com/bgauryy/octocode/main/packages/octocode-benchmark/results/index.html)
|
|
173
173
|
|
|
174
174
|
**How it works:** 30 GitHub questions × 3 passes; Octocode vs `gh`, `gh`+Headroom, and `gh`+RTK on
|
|
175
175
|
identical questions (only the CLI differs). A blind judge (gpt-5.5) grades correctness; the metric is
|
|
@@ -183,13 +183,13 @@ than `gh`+Headroom, and ~3.2× fewer than `gh`+RTK** in the local-build headline
|
|
|
183
183
|
|
|
184
184
|
## Tools
|
|
185
185
|
|
|
186
|
-
**10 tools in the full discovery catalog.**
|
|
187
|
-
|
|
186
|
+
**10 tools in the full discovery catalog.** Nine are enabled by default on
|
|
187
|
+
CLI and MCP. Repository cloning is opt-in:
|
|
188
188
|
|
|
189
189
|
| Surface | Registers | What that set is |
|
|
190
190
|
|---|---:|---|
|
|
191
|
-
| MCP, no flags |
|
|
192
|
-
| CLI, no flags |
|
|
191
|
+
| MCP, no flags | 9 | GitHub, package, local, graph, and LSP tools |
|
|
192
|
+
| CLI, no flags | 9 | The same default tools as MCP |
|
|
193
193
|
|
|
194
194
|
Use `TOOLS_TO_RUN` for a strict allowlist or `DISABLE_TOOLS` to remove tools from
|
|
195
195
|
the default set. `ENABLE_LOCAL=false` disables local, graph, and LSP tools;
|
|
@@ -206,7 +206,7 @@ Flags: [Configuration](https://github.com/bgauryy/octocode/blob/main/docs/CONFIG
|
|
|
206
206
|
| `ghGetFileContent` | Read a GitHub file or region: full file, line range, match slice, or paginated chars. | `minify` |
|
|
207
207
|
| `ghSearchHistory` | Search or list pull requests, issues, or commits through strict `operation:"pullRequests"`, `"issues"`, or `"commits"` queries. | `operation` |
|
|
208
208
|
| `ghGetHistoryItem` | Read one pull request or issue by `number`, one commit by `ref`, or a comparison by `base`+`head`. | `operation` |
|
|
209
|
-
| `ghCloneRepo` | Clone a repository or sparse subtree into the local cache for local and LSP analysis.
|
|
209
|
+
| `ghCloneRepo` | Clone a repository or sparse subtree into the local cache for local and LSP analysis. Requires `ENABLE_LOCAL=true`, `ENABLE_CLONE=true`, and persistent storage. | `sparsePath` |
|
|
210
210
|
|
|
211
211
|
`ghSearch` is the only GitHub discovery interface; select code, repositories,
|
|
212
212
|
or trees with its strict `operation` field.
|
|
@@ -315,7 +315,7 @@ Most-used settings (both CLI and MCP unless noted):
|
|
|
315
315
|
|---------|-------------------|---------|--------------|
|
|
316
316
|
| `OCTOCODE_TOKEN` / `GH_TOKEN` / `GITHUB_TOKEN` | env only | unset | GitHub token, in priority order. Never in `.octocoderc`. |
|
|
317
317
|
| `ENABLE_LOCAL` | `local.enabled` | `true` | Local filesystem and LSP tools on or off. Set `false` to disable them. |
|
|
318
|
-
| `ENABLE_CLONE` | `local.enableClone` | `
|
|
318
|
+
| `ENABLE_CLONE` | `local.enableClone` | `false` | Opt in to `ghCloneRepo` with `true`; local access and persistent storage are also required. |
|
|
319
319
|
| `WORKSPACE_ROOT` | `local.workspaceRoot` | `cwd` | Root for resolving relative local paths. |
|
|
320
320
|
| `ALLOWED_PATHS` | `local.allowedPaths` | `[]` | Extra path allowlist for local access. |
|
|
321
321
|
| `OCTOCODE_OUTPUT_FORMAT` | `output.format` | `yaml` | Response format: `yaml` or `json`. |
|
|
@@ -434,7 +434,7 @@ npx octocode skill help
|
|
|
434
434
|
| [**octocode-scraping**](https://github.com/bgauryy/octocode/tree/main/skills/octocode-scraping) | Public page extraction and crawl triage: static corpus + graph v2 (pages/data/actions/risks/evidence), then CDP handoff for dynamic actions and blocked pages. |
|
|
435
435
|
| [**octocode-chrome-devtools**](https://github.com/bgauryy/octocode/tree/main/skills/octocode-chrome-devtools) | Browser/CDP evidence: network, console, performance, cookies/storage, screenshots, auth-gated pages, and live validation of scrape-graph actions. |
|
|
436
436
|
|
|
437
|
-
###
|
|
437
|
+
### Plan and architecture
|
|
438
438
|
| Skill | Use when |
|
|
439
439
|
|-------|----------|
|
|
440
440
|
| [**octocode-brainstorming**](https://github.com/bgauryy/octocode/tree/main/skills/octocode-brainstorming) | Disciplined idea exploration before building: options, worth-building tests, prior-art maps. |
|
|
@@ -549,7 +549,7 @@ npx node-doctor
|
|
|
549
549
|
npx octocode skill install octocode-research --platform pi
|
|
550
550
|
```
|
|
551
551
|
|
|
552
|
-
- **Adapter route — full tool surface.** Install [`pi-mcp-adapter`](https://github.com/nicobailon/pi-mcp-adapter) to expose Octocode MCP tools behind a single ~200-token proxy tool, so servers stay disconnected until a tool is called.
|
|
552
|
+
- **Adapter route — full tool surface.** Install [`pi-mcp-adapter`](https://github.com/nicobailon/pi-mcp-adapter) to expose Octocode MCP tools behind a single ~200-token proxy tool, so servers stay disconnected until a tool is called. Cloning requires explicit enablement.
|
|
553
553
|
|
|
554
554
|
### Research-driven loop
|
|
555
555
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
var e={ghSearch:'Discover GitHub code with operation:"code", repositories with "repositories", or a known repository tree with "tree". Code search covers the default branch; tree accepts branch. Read known paths with ghGetFileContent. Empty or incomplete search results do not prove absence.',ghGetFileContent:'Read a known GitHub path. branch is honored when supplied; omission uses the default branch. A path-only call returns bounded, standard-minified content; optionally select fullContent, matchString, or startLine+endLine. minify:"none" preserves text; "symbols" returns an outline. Run returned continuations for partial content. matchedLines are exact source-line anchors. type:"directory" materializes localPath with persistent local access; use ghSearch operation:"tree" to browse remotely.',ghSearchHistory:'Discover history metadata with operation:"pullRequests", "issues", or "commits". Pull requests may be searched globally; issues and commits require owner+repo. Commit keywords search messages on the default branch; omit keywords to walk history by path/ref/date. Retrieve a known number or commit ref with ghGetHistoryItem.',ghGetHistoryItem:'Read known history with owner+repo: operation:"pullRequest" or "issue" takes number, "commit" takes ref, and "compare" takes base+head. PR/issue content selectors request bodies, comments, or review/change details; commit/compare includeDiff requests patches. Follow returned continuations for each partial surface.',npmSearch:"Look up npm package metadata with packageName, or discover npm packages with keywords. Uses npm configuration and registry-scoped credentials; exact scoped names honor scope mappings. Optional registry overrides routing. Keyword search targets one registry and supports page; follow returned continuations. Use returned repository links for source-code research.",ghCloneRepo:"Create a cached, shallow checkout for repeated reads, local AST/regex, or LSP. Optional sparsePath scopes a file/subtree; complete refers to that scope. branch selects a branch, tag, or full commit SHA; omission uses the default branch. location.commitSha identifies HEAD; cached working-tree contents are not reverified. forceRefresh renews the checkout. Requires git and persistent local storage. Pass results[].data.location.localPath to local tools; ghGetFileContent also supports individual remote reads.",localSearch:'Choose operation:"text" for lexical anchors, "structural" for AST matches, "files" for path or metadata discovery, and "tree" for directory orientation. Each operation has a strict branch, so do not mix fields across operations. Files/tree prune common generated and vendor directories by default; pass excludeDir:[] to prune nothing. Read exact hits with localGetFileContent and prove symbol identity with lspGetSemantics.',localAnalyzeGraph:"Map file topology, not symbol identity. dependencies/dependents need file; path needs file+target; deadCode/reachability accept roots; cycles needs no selector. Import edges and dead-code results are candidates\u2014verify changes and deletions with exact reads plus LSP.",localGetFileContent:`Read a known local path after search, find, or structure discovery. A path-only call returns a bounded standard-minified view. For large files, get a symbols outline, then an exact range or match. Read small config files whole with minify:"none".
|
|
9
|
+
Optionally choose fullContent, matchString, or startLine+endLine. Partial content cannot prove absence; run the returned continuation. matchedLines are LSP anchors; match ranges and character offsets are not. Report fetched bytes only.`,lspGetSemantics:`Use a real search/read line anchor for semantic proof. references finds usages; callers incoming calls; callees outgoing calls; callHierarchy both. Fall back to references if call hierarchy is unavailable.
|
|
10
|
+
documentSymbols/diagnostic need uri; workspaceSymbol needs symbolName; other operations need uri+symbolName+lineHint. orderHint resolves same-line names. format:"compact" saves tokens. Empty/unavailable results call for a new anchor or text search.`};export{e as a};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{a as i}from"./chunk-3AA4F3QO.js";import{c as C}from"./chunk-OA6NU4KO.js";import{a as b,b as y}from"./chunk-DKGYPFGX.js";import{a as p,c as g,d as n,e as d,f}from"./chunk-USZL65FN.js";import{C as a,D as s,I as t,J as c,K as l,L as m,M as u,N as h,j as o}from"./chunk-BMM5H6QF.js";import{z as L}from"zod";import{z as e}from"zod";var S=a({name:"ghGetFileContent",type:"Github",shortDescription:"Read a file or a specific region from a GitHub repository.",instructions:i.ghGetFileContent,schema:{branch:"Exact branch, tag, or commit ref; defaults to the repository default branch.",startLine:"Requires endLine; exclusive with fullContent/matchString.",endLine:"Requires startLine; must be >= startLine.",fullContent:"Whole file, default minify:none; only explicit character windows paginate. Exclusive with range/match.",matchString:"Anchor returning padded matchRanges and exact matchedLines; preserves matched text without minification.",matchStringIsRegex:"Makes matchString a regex.",matchStringCaseSensitive:"Case-sensitive matchString.",type:'"file" reads; "directory" materializes localPath when clone/local access is enabled\u2014otherwise use ghSearch operation:"tree".',forceRefresh:"Bypass the 24h fetch cache and re-read from GitHub.",charOffset:"Character continuation offset; copy the complete returned next query.",minify:'"symbols" paginated outline (no range/match selectors), "standard" compact source, "none" unminified. Security redaction applies. Default none for fullContent, standard otherwise; matches force none.'}}),r=u(S.schema,{...m,owner:e.string(),repo:e.string(),branch:e.string().optional(),path:e.string(),startLine:t(),endLine:t(),fullContent:e.boolean().optional(),matchString:e.string().optional(),matchStringIsRegex:e.boolean().optional(),matchStringCaseSensitive:e.boolean().optional(),forceRefresh:e.boolean().optional(),type:e.enum(["file","directory"]).default("file"),contextLines:s(0,o).default(5),charOffset:c(),charLength:l(),minify:e.enum(["none","standard","symbols"]).default("standard")}).superRefine(h);var R=L.enum(["none","standard","symbols"]).optional(),F={startLine:n,endLine:n,contextLines:g,charOffset:d.optional(),charLength:p(1,5e4).optional(),minify:R},G=y(r,F),Q=b(r,F),k=f(C(G,{githubDirectoryMode:!0}));export{Q as a,k as b};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{v as s,w as c}from"./chunk-RRSY2ZPX.js";import{d as f,l as m}from"./chunk-CBCZVCTZ.js";var h=60;async function l(e,r,t,i){let o=(await(await c(i)).rest.repos.getCommit({owner:e,repo:r,ref:t})).data.sha;if(typeof o!="string"||!/^[0-9a-f]{40}$/i.test(o))throw new Error(`GitHub returned an invalid commit SHA for ref "${t}".`);return o.toLowerCase()}async function g(e,r,t,i){return{commitSha:await l(e,r,t,i),resolvedRef:t}}async function d(e,r,t,i,n=!1){let a=await s(i),o=f("gh-api-ref-resolution",{owner:e,repo:r,ref:t,auth:a});return m(o,()=>g(e,r,t,i),{ttl:h,forceRefresh:n,cacheRole:"helper"})}export{d as a};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{a as c}from"./chunk-3AA4F3QO.js";import{a as t,b as S}from"./chunk-OA6NU4KO.js";import{a as h,b as f}from"./chunk-DKGYPFGX.js";import{a as k,b as y,f as l}from"./chunk-USZL65FN.js";import{C as m,G as g,L as d,M as u}from"./chunk-BMM5H6QF.js";import{z as r}from"zod";import{z as i}from"zod";var b=m({name:"npmSearch",type:"NPM",shortDescription:"Look up npm packages and find their source repositories.",instructions:c.npmSearch,schema:{keywords:"Discovery terms joined with spaces. Mutually exclusive with packageName.",packageName:"Exact package name; include scope for scoped packages.",page:"Keyword-result page only.",registry:"Optional registry URL overriding npm defaults and scope mappings. Credentials come from npm configuration, never tool arguments."}}),s=u(b.schema,{...d,packageName:i.string().trim().min(1).optional(),keywords:i.array(i.string().trim().min(1)).min(1).optional(),page:g(),registry:i.string().url().refine(e=>{let a=new URL(e);return["http:","https:"].includes(a.protocol)&&!a.username&&!a.password&&!a.search&&!a.hash},"Use an HTTP(S) registry URL without credentials, query, or fragment.").optional()}).superRefine((e,a)=>{e.packageName===void 0&&e.keywords===void 0&&a.addIssue({code:"custom",path:["packageName"],message:"Set packageName or keywords."}),e.packageName!==void 0&&e.keywords!==void 0&&a.addIssue({code:"custom",path:["keywords"],message:"Set packageName or keywords, not both."}),e.packageName!==void 0&&e.page!==void 0&&a.addIssue({code:"custom",path:["page"],message:"page applies only to keyword discovery; omit it for an exact package lookup."})});var N={page:y.removeDefault(),pageSize:k(1,100).optional().describe("Packages returned per keyword-discovery page."),keywords:r.array(r.string()).optional()};function n(e,a){let p=Array.isArray(e.keywords)?e.keywords.join(" ").trim():e.keywords?.trim();!e.packageName?.trim()&&!p&&a.addIssue({code:"custom",path:["packageName"],message:"provide packageName or keywords"}),e.packageName?.trim()&&p&&a.addIssue({code:"custom",path:["keywords"],message:"provide packageName or keywords, not both"}),e.packageName?.trim()&&e.pageSize!==void 0&&a.addIssue({code:"custom",path:["pageSize"],message:"pageSize is only available for keyword discovery"})}var j=h(s,N).superRefine(n),o=f(s,N,{strict:!0}),w=o.omit({packageName:!0,keywords:!0,pageSize:!0,page:!0}).shape,P=r.object({...w,packageName:S(o.shape,"packageName")}).strict().superRefine((e,a)=>n(e,a)),x=r.object({...w,keywords:r.array(r.string()).min(1).describe(t(o.shape,"keywords").description??""),pageSize:t(o.shape,"pageSize"),page:t(o.shape,"page")}).strict().superRefine((e,a)=>n(e,a)),D=l(r.union([P,x]),{maxQueries:5});export{j as a,D as b};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{v as a}from"./chunk-RRSY2ZPX.js";import{d as c,l}from"./chunk-CBCZVCTZ.js";async function T(e,t,r,s){try{let u=await a(s),i=await l(c("gh-canonical-repo",{owner:t,repo:r,auth:u}),()=>e.rest.repos.get({owner:t,repo:r}),{cacheRole:"helper",ttl:300,shouldCache:h=>{let[d,p]=h.data.full_name?.split("/")??[];return!!(d&&p)}}),[n,o]=i.data.full_name?.split("/")??[];return!n||!o?{owner:t,repo:r,renamed:!1}:{owner:n,repo:o,renamed:n!==t||o!==r}}catch{return{owner:t,repo:r,renamed:!1}}}function x(e,t){return e&&t?`${e}/${t}`:void 0}function y(e){let t=e.lastIndexOf("/");return t<=0?{owner:"",repo:e}:{owner:e.substring(0,t),repo:e.substring(t+1)}}function w(e){return{...typeof e?.reportedTotalMatches=="number"?{reportedTotalMatches:e.reportedTotalMatches}:{},...typeof e?.reachableTotalMatches=="number"?{reachableTotalMatches:e.reachableTotalMatches}:{},...e?.totalMatchesKind?{totalMatchesKind:e.totalMatchesKind}:{},...typeof e?.totalMatchesCapped=="boolean"?{totalMatchesCapped:e.totalMatchesCapped}:{},...typeof e?.uniqueFileCount=="number"?{uniqueFileCount:e.uniqueFileCount}:{}}}export{x as a,y as b,w as c,T as d};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{a as z,b as n}from"./chunk-MPTAIBY7.js";import{f as T}from"./chunk-USZL65FN.js";import{C as D,D as a,E as l,F as g,L as x,M as d,n as w,o as y,p as h,q as f}from"./chunk-BMM5H6QF.js";import{z as B}from"zod";import{z as s}from"zod";import{z as r}from"zod";var R={maxDepth:"Maximum levels below path; 0 is direct entries.",minDepth:"Requires <= maxDepth when both set.",names:"Basename globs; ORed.",pathPattern:"Full-path glob.",regex:"Basename Rust regex.",empty:"Match only empty files/dirs.",time:"Time filters using d/h/w/m durations.","time.modifiedWithin":"Modified within this duration, e.g. 2d or 6h.","time.modifiedBefore":"Modified before this duration ago, e.g. 30d.","time.accessedWithin":"Accessed within this duration, e.g. 1w.",size:"Size range, e.g. 100k or 1m.","size.greater":"Minimum file size, e.g. 100k or 1m.","size.less":"Maximum file size, e.g. 500b or 2m.",extensions:'Extensions without dots, e.g. ["ts","tsx"].',excludeDir:"Directory names; generated/vendor dirs are pruned by default. Pass [] to prune nothing.",entryType:'"f" files, "d" dirs.',permissions:"Exact permission filter.",access:'"executable", "readable", or "writable" filter.',detail:'"basic" (default), "modified" (+mtime), or "full" (all metadata).',sortBy:'"modified" (default), "name", "path", or "size".',limit:"Post-sort result cap; pagination stays within it."},S=R,u=d(S,{...x,path:r.string(),maxDepth:a(0,y).optional(),minDepth:a(0,y).optional(),names:l,pathPattern:r.string().optional(),regex:r.string().optional(),empty:r.boolean().optional(),time:d(S,{modifiedWithin:r.string().optional(),modifiedBefore:r.string().optional(),accessedWithin:r.string().optional()},"time").optional(),size:d(S,{greater:r.string().optional(),less:r.string().optional()},"size").optional(),permissions:r.string().optional(),access:r.enum(["executable","readable","writable"]).optional(),extensions:l,excludeDir:l,limit:a(1,h).optional(),detail:r.enum(["basic","modified","full"]).default("basic"),sortBy:r.enum(["modified","name","path","size"]).default("modified"),entryType:r.enum(["f","d"]).optional(),page:g(),itemsPerPage:a(1,f).optional()}).superRefine((e,i)=>{e.minDepth!==void 0&&e.maxDepth!==void 0&&e.minDepth>e.maxDepth&&i.addIssue({code:"custom",message:"minDepth must be less than or equal to maxDepth.",path:["minDepth"]})});import{z as c}from"zod";var P={pattern:"Name glob or substring; use the files operation for regex.",entryType:'"f" files only, "d" dirs only; omit for both.',detail:'"basic" (default), "modified" (+mtime), or "full" (size/perms).',hidden:"Include dot-files/dirs.",recursive:"true enables the default recursive depth; omit with maxDepth for immediate children.",maxDepth:"Recursion depth. Omitted: immediate children, or 5 if recursive:true; maxDepth alone enables recursion, so recursive:true is not required. 0 uses those defaults.",extensions:"Allowlist without dots.",excludeDir:"Directories to prune; [] includes generated/vendor directories.",sortBy:'"name" (default), "size", "time", or "extension".',reverse:"Reverse the sort order.",limit:"Discovery cap before pagination."},p=d(P,{...x,path:c.string(),detail:c.enum(["basic","modified","full"]).default("basic"),hidden:c.boolean().optional(),sortBy:c.enum(["name","size","time","extension"]).default("name"),reverse:c.boolean().optional(),pattern:c.string().optional(),entryType:c.enum(["f","d"]).optional(),recursive:c.boolean().optional(),extensions:l,excludeDir:l,maxDepth:a(0,w).optional(),limit:a(1,h).optional(),page:g(),itemsPerPage:a(1,f).optional()});var m={...z};delete m.mode;delete m.output;delete m.itemsPerPage;delete m.sortReverse;var Q={...P};delete Q.recursive;var ae=D({name:"localSearch",type:"Local",shortDescription:"Search local text, syntax, paths, or directory trees through one operation.",instructions:'Choose operation:"text" for lexical anchors, "structural" for AST matches, "files" for path or metadata discovery, and "tree" for directory orientation. Each operation has a strict branch, so do not mix fields across operations. Files/tree prune common generated and vendor directories by default; pass excludeDir:[] to prune nothing. Read exact hits with localGetFileContent and prove symbol identity with lspGetSemantics.',schema:{...R,...Q,...m,operation:'Required branch: "text", "structural", "files", or "tree".',resultView:'Text/structural result shape. Text also supports "paginated", "discovery", and "detailed".',pattern:"Structural AST pattern.",namePattern:"Tree entry name glob or substring.",pathRegex:"Files operation: basename Rust regex.",limit:"Files/tree discovery cap before pagination.",pageSize:"Results returned per page.",sort:"Operation-specific sort order.",reverse:"Reverse the selected sort order."}}),M=s.object(n.shape),_=s.object(u.shape),E=s.enum(["paginated","discovery","detailed","content","files","filesWithout","countLines","countMatches","matchOnly"]),I=s.enum(["content","files","countLines","countMatches","matchOnly"]),V=M.omit({pattern:!0,rule:!0,captureText:!0,mode:!0,output:!0,itemsPerPage:!0,sortReverse:!0}).extend({operation:s.literal("text").describe('Use "text" for lexical search.'),searchText:s.string().describe("Single lexical pattern."),resultView:E.optional().default("paginated").describe("Text result shape; paginated is the default."),pageSize:n.shape.itemsPerPage.describe("Matches returned per page."),reverse:n.shape.sortReverse.describe("Reverse the selected sort order."),unique:n.shape.unique.describe('With resultView:"matchOnly", deduplicate values or count frequency.'),matchWindow:n.shape.matchWindow.describe('Requires resultView:"matchOnly".')}).strict(),O=M.omit({searchText:!0,pattern:!0,rule:!0,mode:!0,regex:!0,caseMode:!0,wholeWord:!0,invertMatch:!0,multiline:!0,unique:!0,matchWindow:!0,output:!0,itemsPerPage:!0,sortReverse:!0}).extend({operation:s.literal("structural").describe('Use "structural" for AST matching.'),resultView:I.optional().default("content").describe("Structural result shape; content is the default."),pageSize:n.shape.itemsPerPage.describe("Matches returned per page."),reverse:n.shape.sortReverse.describe("Reverse the selected sort order.")}).strict(),W=O.extend({pattern:s.string().describe("Structural AST pattern.")}).strict(),k=O.extend({rule:s.string().describe("Structural YAML ast-grep rule.")}).strict(),C=_.omit({regex:!0,limit:!0,sortBy:!0,itemsPerPage:!0}).extend({operation:s.literal("files").describe('Use "files" for path and metadata discovery.'),pathRegex:u.shape.regex.describe("Basename Rust regex."),limit:u.shape.limit.describe("Post-sort discovery cap."),sort:u.shape.sortBy.describe("File sort order."),pageSize:u.shape.itemsPerPage.describe("Files returned per page.")}).strict(),j=p.omit({pattern:!0,recursive:!0,limit:!0,sortBy:!0,itemsPerPage:!0}).extend({operation:s.literal("tree").describe('Use "tree" for directory orientation.'),namePattern:p.shape.pattern.describe("Entry name glob or substring."),limit:p.shape.limit.describe("Discovery cap before pagination."),sort:p.shape.sortBy.describe("Tree sort order."),pageSize:p.shape.itemsPerPage.describe("Entries returned per page.")}).strict();function L(e,i){if("error"in e)for(let t of e.error.issues)t.code==="custom"&&i.addIssue({code:"custom",message:t.message,path:t.path})}var A=s.union([V,W,k,C,j]).superRefine((e,i)=>{if(e.operation==="text"){let t=e.resultView,o={...e,itemsPerPage:e.pageSize,sortReverse:e.reverse};delete o.operation,delete o.resultView,delete o.pageSize,delete o.reverse;let b=["paginated","discovery","detailed"].includes(t)?{...o,mode:t}:{...o,mode:"paginated",output:t};L(n.safeParse(b),i);return}if(e.operation!=="structural"&&e.operation==="files"){let t={...e,regex:e.pathRegex,limit:e.limit,sortBy:e.sort,itemsPerPage:e.pageSize};delete t.operation,delete t.pathRegex,delete t.pageSize,delete t.sort,L(u.safeParse(t),i)}});function de(e,i){let{pageSize:t,reverse:o,...b}=e,v={...b,...t!==void 0?{itemsPerPage:t}:{},...o!==void 0?{sortReverse:o}:{}};return i==="paginated"||i==="discovery"||i==="detailed"?{...v,mode:i}:{...v,mode:"paginated",output:i}}var[X,G,N,U,H]=A.options,F=B.enum(["content","files","countMatches"]).optional().default("content").describe("Structural result shape; content is the default."),Y=B.union([X,G.extend({resultView:F}),N.extend({resultView:F}),U,H]),pe=T(Y,{maxQueries:5});export{de as a,Y as b,pe as c};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{z as w}from"zod";var m={GITHUB_SEARCH:"ghSearch",GITHUB_FETCH_CONTENT:"ghGetFileContent",GITHUB_SEARCH_HISTORY:"ghSearchHistory",GITHUB_GET_HISTORY_ITEM:"ghGetHistoryItem",PACKAGE_SEARCH:"npmSearch",GITHUB_CLONE_REPO:"ghCloneRepo",LOCAL_SEARCH:"localSearch",LOCAL_ANALYZE_GRAPH:"localAnalyzeGraph",LOCAL_FETCH_CONTENT:"localGetFileContent",LSP_GET_SEMANTIC_CONTENT:"lspGetSemantics"},B=w.object({goal:w.string().optional().describe("What this query should accomplish."),reasoning:w.string().optional().describe("Why this query advances the goal.")}),q=Object.fromEntries(Object.entries(B.shape).map(([e,t])=>[e,t.description??""]));var Ge=m.LOCAL_ANALYZE_GRAPH,we="localSearch",fr=m.GITHUB_SEARCH,Be="ghSearchHistory",je="ghGetHistoryItem",N={GITHUB_SEARCH:m.GITHUB_SEARCH,GITHUB_FETCH_CONTENT:m.GITHUB_FETCH_CONTENT,PACKAGE_SEARCH:m.PACKAGE_SEARCH,GITHUB_CLONE_REPO:m.GITHUB_CLONE_REPO,LOCAL_FETCH_CONTENT:m.LOCAL_FETCH_CONTENT,LOCAL_ANALYZE_GRAPH:m.LOCAL_ANALYZE_GRAPH,LSP_GET_SEMANTIC_CONTENT:m.LSP_GET_SEMANTIC_CONTENT,GITHUB_SEARCH_HISTORY:Be,GITHUB_GET_HISTORY_ITEM:je},ze=N.LSP_GET_SEMANTIC_CONTENT,mr=new Set([we,N.LOCAL_FETCH_CONTENT,Ge,ze]);import{AsyncLocalStorage as $e}from"node:async_hooks";var P=new $e;async function Tr(e){let t={hit:!1};return{value:await P.run({root:t,depth:0,role:"response"},e),cacheHit:t.hit}}function gr(e,t="response"){let r=P.getStore();return r?P.run({root:r.root,depth:r.depth+1,role:t},e):e()}function _r(){let e=P.getStore();e&&e.depth<=1&&e.role==="response"&&(e.root.hit=!0)}var Q=Symbol.for("octocode.rawResponseChars");function Ye(e){if(typeof e=="string")return e.length;try{return JSON.stringify(e)?.length??0}catch{return String(e).length}}function ee(e){if(!(typeof e!="number"||!Number.isFinite(e)))return Math.max(0,e)}function Er(e,t){let r=typeof t=="number"?ee(t):Ye(t);if(r===void 0)return e;try{Object.defineProperty(e,Q,{value:r,enumerable:!1,configurable:!0})}catch{}return e}function Rr(e){if(!(typeof e!="object"||e===null))return ee(e[Q])}var Or={...N,LOCAL_SEARCH:"localSearch",GITHUB_SEARCH_CODE:"github.code",GITHUB_VIEW_REPO_STRUCTURE:"github.tree",GITHUB_SEARCH_REPOSITORIES:"github.repositories",LOCAL_RIPGREP:"local.text",LOCAL_VIEW_STRUCTURE:"local.tree",LOCAL_FIND_FILES:"local.files"};import{ContentSanitizer as Je}from"@octocodeai/octocode-engine/contentSanitizer";import{getConfigSync as Ke}from"@octocodeai/config";import{createRequire as Xe}from"node:module";var Ve=Xe(import.meta.url),te="@octocodeai/octocode-engine",We=()=>globalThis.__OCTOCODE_ENGINE_BINDING__??Ve(te),k,Ze=We,j=class extends Error{constructor(r){super(`Failed to load native dependency ${te}`);this.cause=r;this.name="ContextUtilsLoadError"}cause};function c(){if(k)return k;try{return k=Ze(),k}catch(e){throw new j(e)}}var re={applyContentViewMinification(e,t){return c().applyContentViewMinification(e,t)},applyMinification(e,t){return c().applyMinification(e,t)},minifyContent(e,t){return c().minifyContent(e,t)},minifyContentSync(e,t){return c().minifyContentSync(e,t)},minifyContentResult(e,t){return c().minifyContentResult(e,t)},minifyMarkdownCore(e){return c().minifyMarkdownCore(e)},extractSignatures(e,t){return c().extractSignatures(e,t)},extractJsSymbols(e,t){return c().extractJsSymbols(e,t)},findInFileReferences(e,t,r,n){return c().findInFileReferences(e,t,r,n)},extractGraphFacts(e,t){return c().extractGraphFacts(e,t)},scanGraphFacts(e){return c().scanGraphFacts(e)},getSupportedJsTsExtensions(){return c().getSupportedJsTsExtensions()},getSupportedGraphFactExtensions(){return c().getSupportedGraphFactExtensions()},getGraphFactCapabilities(){return c().getGraphFactCapabilities()},structuralSearch(e,t,r,n){return c().structuralSearch(e,t,r,n)},structuralSearchFiles(e){return c().structuralSearchFiles(e)},structuralSearchFilesDetailed(e){return c().structuralSearchFilesDetailed(e)},getSupportedStructuralExtensions(){return c().getSupportedStructuralExtensions()},validateRipgrepPattern(e,t,r){return c().validateRipgrepPattern(e,t,r)},getSemanticBoundaryOffsets(e,t){return c().getSemanticBoundaryOffsets(e,t)},jsonToYamlString(e,t){return c().jsonToYamlString(e,t)},parseRipgrepJson(e,t){return c().parseRipgrepJson(e,t)},searchRipgrep(e){return c().searchRipgrep(e)},queryFileSystem(e){return c().queryFileSystem(e)},extractMatchingLines(e,t,r){return c().extractMatchingLines(e,t,r)},filterPatch(e,t){return c().filterPatch(e,t)},computeLineDiff(e,t){return c().computeLineDiff(e,t)},charToByteOffset(e,t){return c().charToByteOffset(e,t)},byteToCharOffset(e,t){return c().byteToCharOffset(e,t)},byteSliceContent(e,t,r){return c().byteSliceContent(e,t,r)},sliceContent(e,t,r,n){return c().sliceContent(e,t,r,n)},get SIGNATURES_ONLY_HINT(){return c().SIGNATURES_ONLY_HINT}};function qe(){try{return Ke().output.format}catch{return"yaml"}}function z(e){if(e==null)return e;if(typeof e=="string")return Je.sanitizeContent(e).content;if(Array.isArray(e))return e.map(t=>z(t));if(typeof e=="object"){let t={};for(let[r,n]of Object.entries(e))r!=="warnings"&&(t[r]=z(n));return t}return e}function br(e,t){if(t==="json")return JSON.stringify(e);let r=Array.isArray(e.content)?e.content.map(n=>"text"in n&&typeof n.text=="string"?n.text:"").filter(n=>n.length>0):[];return r.length>0?r.join(`
|
|
9
|
+
|
|
10
|
+
`):e.structuredContent!==void 0?JSON.stringify(e.structuredContent,null,2):JSON.stringify(e,null,2)}function Hr(e,t){let r=$(e)??{},n=z(r),s=qe(),o="results"in n?["results","index","status","cache","meta","data"]:["instructions","status","data"];return s==="json"?JSON.stringify(b(n,t||o),null,2):re.jsonToYamlString(n,{keysPriority:t||o})}function b(e,t){if(e==null)return e;if(Array.isArray(e))return e.map(s=>b(s,t));if(typeof e!="object")return e;let r=e,n={};for(let s of t)s in r&&(n[s]=b(r[s],t));for(let s of Object.keys(r))s in n||(n[s]=b(r[s],t));return n}var Qe=new Set(["currentPage","totalPages","perPage","itemsPerPage","entriesPerPage","filesPerPage","totalMatches","totalFiles","totalEntries","totalItems","totalResults","totalReferences","reportedTotalMatches","reachableTotalMatches","totalMatchesKind","totalMatchesCapped","hasMore","nextPage","charOffset","charLength","totalChars","totalBytes","nextCharOffset"]),et=["totalMatches","totalItems","totalFiles","totalEntries","totalResults","totalReferences","reportedTotalMatches","reachableTotalMatches"];function tt(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=e,r=Object.keys(t);return r.length===0||!r.every(n=>Qe.has(n))||et.some(n=>typeof t[n]=="number"&&t[n]>0)||t.hasMore!==!1?!1:typeof t.totalPages=="number"?t.totalPages<=1:"charOffset"in t||"nextCharOffset"in t?(t.charOffset??0)===0:!0}function $(e,t={}){if(e==null||Number.isNaN(e))return;let{inFilesObject:r=!1,depth:n=0}=t;if(Array.isArray(e)){let s=e.map(a=>$(a,{inFilesObject:r,depth:n+1})).filter(a=>a!==void 0),o=r&&n>=2;return s.length>0||o?s:void 0}if(typeof e=="object"&&e!==null){let s={},o=!1;for(let[a,u]of Object.entries(e)){if(a==="query"&&typeof e.tool=="string"&&u!==null&&typeof u=="object"&&!Array.isArray(u)){s[a]=u,o=!0;continue}if(a==="results"&&n===0&&Array.isArray(u)&&u.length===0){s[a]=[],o=!0;continue}if(a==="warnings"||tt(u))continue;let f=(a==="files"||a==="repositories")&&!r,K=$(u,{inFilesObject:r||f,depth:f?0:n+1});K!==void 0&&(s[a]=K,o=!0)}return o?s:void 0}return e}import{z as H}from"zod";var rt=100,ne=1e3,nt=1e8,st=5e4,ot=1e9,Mr=1e5,Dr=20,Gr=100,wr=1e4,Br=50,jr=100,zr=30,$r=200,Yr=100;var Xr=1e5,Vr=500,Wr=1e5,Zr=1e3,Jr=20,Kr=100,qr=20;function Qr(e){return{...e,description:e.instructions}}function _(e,t){return H.number().int().min(e).max(t)}var en=H.array(H.string()).optional();function tn(){return _(1,ne).default(1)}function rn(){return _(1,ne).optional()}function nn(){return _(0,rt).optional()}function sn(){return _(1,ot).optional()}function on(){return _(0,nt).optional()}function an(){return _(1,st).optional()}var it=B.shape,at=new Set(Object.keys(it)),ct={owner:"Repository owner (user or org).",repo:"Repository name, without the owner.",branch:"Branch, tag, or commit SHA; omit for the default branch.",path:"Target path. GitHub tools: repo-relative, exact case, no leading slash. Local tools: absolute path.",page:"Result page, 1-based. Advance only while pagination.hasMore.",itemsPerPage:"Items per result page.",limit:"Total result cap applied before pagination.",pageSize:"Results returned in one page.",contextLines:"Extra source lines around each match/anchor.",charLength:"Content-window length; continue with the returned offset when partial.",charOffset:"Content-window start; copy the returned offset. A partial window cannot prove absence."};function cn(e,t,r=""){let n={};for(let s of Object.keys(t)){let o=t[s],a=r?`${r}.${s}`:s,f=r===""&&at.has(s)?q[a]:e[a]??(o.description?void 0:ct[s]);n[s]=f?o.describe(f):o}return H.object(n).strict()}function un(e,t){let r=e.fullContent===!0,n=e.matchString!==void 0,s=e.startLine!==void 0||e.endLine!==void 0;r&&n&&t.addIssue({code:"custom",message:"Choose fullContent or matchString.",path:["matchString"]}),r&&s&&t.addIssue({code:"custom",message:"Choose fullContent or startLine/endLine.",path:["startLine"]}),n&&s&&t.addIssue({code:"custom",message:"Choose matchString or startLine/endLine.",path:["startLine"]}),e.startLine===void 0!=(e.endLine===void 0)&&t.addIssue({code:"custom",message:"Set startLine and endLine together.",path:[e.startLine===void 0?"startLine":"endLine"]}),e.startLine!==void 0&&e.endLine!==void 0&&e.endLine<e.startLine&&t.addIssue({code:"custom",message:"Set endLine greater than or equal to startLine.",path:["endLine"]})}import{existsSync as ut,mkdirSync as lt}from"node:fs";import{join as d}from"node:path";import{getOctocodeHome as pt}from"@octocodeai/config";var dt=448;function ft(){return pt(process.env)}function Sn(){return p}var p=ft(),S={home:p,config:d(p,".octocoderc"),credentials:d(p,"credentials.json"),key:d(p,".key"),session:d(p,"session.json"),stats:d(p,"stats.json"),tmp:d(p,"tmp"),clone:d(p,"tmp","clone"),tree:d(p,"tmp","tree"),response:d(p,"tmp","response"),repos:d(p,"tmp","clone"),cliConfig:d(p,"config.json"),lspConfig:d(p,"lsp-servers.json")};function se(){ut(S.home)||lt(S.home,{recursive:!0,mode:dt})}import{randomUUID as gs}from"node:crypto";import{existsSync as Le,readFileSync as Ie,writeFileSync as wt,unlinkSync as rs,renameSync as Bt}from"node:fs";import{isPersistentStorageEnabled as Ne,isStatsEnabled as Pe}from"@octocodeai/config";function h(e){return e.toLowerCase().replace(/^https?:\/\//,"").replace(/\/$/,"")}function x(e){if(!e.token.expiresAt)return!1;let t=new Date(e.token.expiresAt);if(isNaN(t.getTime()))return!0;let r=new Date;return t.getTime()-r.getTime()<300*1e3}function Y(e){if(!e.token.refreshTokenExpiresAt)return!1;let t=new Date(e.token.refreshTokenExpiresAt);return isNaN(t.getTime())?!0:new Date>=t}var O=new Map,mt=300*1e3;function St(e){let t=h(e),r=O.get(t);return!r||Date.now()-r.cachedAt>=mt?!1:r.credentials?!x(r.credentials):!0}function oe(e){e?O.delete(h(e)):O.clear()}function ie(e){let t=h(e);if(St(t))return O.get(t).credentials}function ae(e,t){let r=h(e);O.set(r,{credentials:t,cachedAt:Date.now()})}import{existsSync as ue,readFileSync as le,writeFileSync as pe,unlinkSync as An,statSync as gt,chmodSync as _t}from"node:fs";import{createCipheriv as Ct,createDecipheriv as Et,randomBytes as de}from"node:crypto";import{z as l}from"zod";var ht=l.object({token:l.string(),tokenType:l.literal("oauth"),scopes:l.array(l.string()).optional(),refreshToken:l.string().optional(),expiresAt:l.string().optional(),refreshTokenExpiresAt:l.string().optional()}),Tt=l.object({hostname:l.string(),username:l.string(),token:ht,gitProtocol:l.enum(["ssh","https"]),createdAt:l.string(),updatedAt:l.string()}),ce=l.object({version:l.number(),credentials:l.record(l.string(),Tt)});var Rt=S.home,v=S.credentials,C=S.key,fe="aes-256-gcm",At=16;function E(){se()}function me(){if(E(),ue(C))return gt(C).mode&511&63&&_t(C,384),Buffer.from(le(C,"utf8"),"hex");let e=de(32);return pe(C,e.toString("hex"),{mode:384}),e}function Se(e){let t=me(),r=de(At),n=Ct(fe,t,r),s=n.update(e,"utf8","hex");s+=n.final("hex");let o=n.getAuthTag();return`${r.toString("hex")}:${o.toString("hex")}:${s}`}function he(e){let t=me(),[r,n,s]=e.split(":");if(!r||!n||!s)throw new Error("Invalid encrypted data format");let o=Buffer.from(r,"hex"),a=Buffer.from(n,"hex"),u=Et(fe,t,o);u.setAuthTag(a);let f=u.update(s,"hex","utf8");return f+=u.final("utf8"),f}function X(){if(E(),!ue(v))return{version:1,credentials:{}};try{let e=le(v,"utf8"),t=he(e),r=JSON.parse(t),n=ce.safeParse(r);return n.success?n.data:{version:1,credentials:{}}}catch{return{version:1,credentials:{}}}}function Te(e){E();let t=Se(JSON.stringify(e,null,2));pe(v,t,{mode:384})}import{refreshToken as xt}from"@octokit/oauth-methods";import{request as Ot}from"@octokit/request";var y="178c6fc778ccc68e1d6a",R="github.com";function yt(e){return e.replace(/\b(ghp_|gho_|ghu_|ghs_|ghr_)[a-zA-Z0-9]{36,}\b/g,"***MASKED***").replace(/\b[a-zA-Z0-9]{40,}\b/g,"***MASKED***")}function Lt(e){return e==="github.com"||e===R?"https://api.github.com":`https://${e}/api/v3`}async function ge(e,t=R,r=y){let n=await e.getCredentials(t);if(!n)return{success:!1,error:`Not logged in to ${t}`};if(!n.token.refreshToken)return{success:!1,error:"Token does not support refresh (OAuth App tokens do not expire)"};if(Y(n))return{success:!1,error:"Refresh token has expired. Please login again."};try{let s=await xt({clientType:"github-app",clientId:r,clientSecret:"",refreshToken:n.token.refreshToken,request:Ot.defaults({baseUrl:Lt(t)})}),o={token:s.authentication.token,tokenType:"oauth",refreshToken:s.authentication.refreshToken,expiresAt:s.authentication.expiresAt,refreshTokenExpiresAt:s.authentication.refreshTokenExpiresAt};return await e.updateToken(t,o),{success:!0,username:n.username,hostname:t}}catch(s){return{success:!1,error:s instanceof Error?yt(s.message):"Token refresh failed"}}}async function _e(e,t=R,r=y){let n=await e.getCredentials(t);if(!n||!n.token)return{token:null,source:"none"};if(!x(n))return{token:n.token.token,source:"stored",username:n.username};if(n.token.refreshToken){let s=await ge(e,t,r);if(s.success){let o=await e.getCredentials(t);if(o?.token.token)return{token:o.token.token,source:"refreshed",username:o.username}}return{token:null,source:"none",refreshError:s.error}}return{token:null,source:"none",refreshError:"Token expired and no refresh token available"}}import{resolveEnvToken as Pt}from"@octocodeai/config";import{execFile as It}from"child_process";var Nt=["/opt/homebrew/bin","/usr/local/bin","/home/linuxbrew/.linuxbrew/bin"];function Ce(e){return new Promise(t=>{let r=["auth","token"];e&&r.push("--hostname",e);let n=process.env.PATH??"",s=new Set(n.split(":")),o=Nt.filter(u=>!s.has(u)),a=o.length?`${o.join(":")}:${n}`:n;It("gh",r,{encoding:"utf8",timeout:5e3,env:{...process.env,PATH:a}},(u,f)=>{if(u||!f){t(null);return}t(f.trim()||null)})})}var V=null;function Ee(e){V=e}function kt(){if(!V)throw new Error("Token resolution not initialized. Call initTokenResolution() first.");return V}async function bt(e){let t=e?.hostname??R,r=e?.clientId??y,n=e?.getGhCliToken??Ce,s=Pt();if(s)return{token:s.token,source:s.source,wasRefreshed:!1};let o=await kt().getTokenWithRefresh(t,r);if(o.token)return{token:o.token,source:"octocode-storage",wasRefreshed:o.source==="refreshed",username:o.username};try{let a=await Promise.resolve(n(t));if(a?.trim())return{token:a.trim(),source:"gh-cli",wasRefreshed:!1}}catch(a){process.stderr.write(`[octocode] gh auth token failed: ${a instanceof Error?a.message:String(a)}
|
|
11
|
+
`)}return null}async function Ht(e){let t=h(e.hostname),r={...e,hostname:t,updatedAt:new Date().toISOString()};try{let n=X();return n.credentials[t]=r,Te(n),oe(t),{success:!0}}catch{throw new Error("Failed to store credentials")}}async function Re(e="github.com",t){let r=h(e);if(!t?.bypassCache){let o=ie(r);if(o!==void 0)return o}let s=X().credentials[r]||null;return ae(r,s),s}async function vt(e,t){let r=await Re(e);return r?(r.token=t,r.updatedAt=new Date().toISOString(),await Ht(r),!0):!1}async function Ft(e,t){return _e({getCredentials:Re,updateToken:vt},e,t)}Ee({getTokenWithRefresh:Ft});import{z as i}from"zod";var Ut=i.object({rawChars:i.number(),responseChars:i.number(),savedChars:i.number(),calls:i.number()}),Mt=i.object({hits:i.record(i.string(),i.number()).default({}),rateLimits:i.number().default(0)}),F=i.record(i.string(),i.number()).default({}),Dt=i.object({toolCalls:i.number(),errors:i.number(),rateLimits:i.number(),rateLimitsByProvider:F,rawChars:i.number(),responseChars:i.number(),savedChars:i.number(),charSavingsCalls:i.number(),githubCacheHits:i.number(),githubCacheRateLimits:i.number(),packageRegistryFailures:i.number().default(0),packageRegistryFailuresByRegistry:F}),U=i.object({toolCalls:i.number(),errors:i.number(),rateLimits:i.number(),rateLimitsByProvider:F,charsSavedByTool:i.record(i.string(),Ut).default({}),githubCacheHits:Mt.default({hits:{},rateLimits:0}),packageRegistryFailures:F,totalUsage:Dt.optional()}),Ae=i.object({version:i.literal(1),sessionId:i.string(),createdAt:i.string(),lastActiveAt:i.string(),stats:U.optional()}),xe=i.object({version:i.literal(1),stats:U});function Oe(e){return Object.values(e).reduce((t,r)=>t+r,0)}function Gt(e){let t=e.charsSavedByTool??{},r=e.githubCacheHits??{hits:{},rateLimits:0},n=e.rateLimitsByProvider??{},s=e.packageRegistryFailures??{},o=Object.values(t).reduce((a,u)=>({rawChars:a.rawChars+u.rawChars,responseChars:a.responseChars+u.responseChars,savedChars:a.savedChars+u.savedChars,charSavingsCalls:a.charSavingsCalls+u.calls}),{rawChars:0,responseChars:0,savedChars:0,charSavingsCalls:0});return{toolCalls:e.toolCalls,errors:e.errors,rateLimits:e.rateLimits,rateLimitsByProvider:n,...o,githubCacheHits:Oe(r.hits),githubCacheRateLimits:r.rateLimits,packageRegistryFailures:Oe(s),packageRegistryFailuresByRegistry:s}}function T(e){let t={...e,rateLimitsByProvider:e.rateLimitsByProvider??{},charsSavedByTool:e.charsSavedByTool??{},githubCacheHits:e.githubCacheHits??{hits:{},rateLimits:0},packageRegistryFailures:e.packageRegistryFailures??{}};return{...t,totalUsage:Gt(t)}}function A(){return T({toolCalls:0,errors:0,rateLimits:0,rateLimitsByProvider:{},charsSavedByTool:{},githubCacheHits:{hits:{},rateLimits:0},packageRegistryFailures:{}})}var M=S.session,D=S.stats;function ye(e,t){let r=`${e}.tmp`;wt(r,JSON.stringify(t,null,2),{mode:384}),Bt(r,e)}function jt(e){let t=JSON.parse(e),r=xe.safeParse(t);if(r.success)return T(r.data.stats);let n=U.safeParse(t);return n.success?T(n.data):null}function zt(){if(!Le(D))return A();try{let e=Ie(D,"utf8");return jt(e)??A()}catch{return A()}}function W(e){if(!Ne())return;E(),Pe()&&ye(D,{version:e.version,stats:T(e.stats)});let{stats:t,...r}=e;ye(M,r)}function ke(){if(!Ne()||!Le(M))return null;try{let e=Ie(M,"utf8"),t=JSON.parse(e),r=Ae.safeParse(t);return r.success?{...r.data,stats:Pe()?zt():A()}:null}catch{return null}}var $t=6e4,g=null,L=!1,Z=null,be=!1,He=null,ve=null,Fe=null,J=!1;function Yt(){be||(be=!0,He=()=>{G()},ve=()=>{G()},Fe=()=>{G()},process.on("exit",He),process.on("SIGINT",ve),process.on("SIGTERM",Fe))}function Xt(){Z||(Z=setInterval(()=>{L&&g&&(W(g),L=!1)},$t),Z.unref())}function Ue(){if(g)return g;let e=ke();return e&&(g=e),e}function Me(e){g=e,L=!0,Yt(),Xt()}function G(){if(!J&&L&&g){J=!0;try{W(g),L=!1}catch{}finally{J=!1}}}function Vt(e){return T(e)}function Wt(e,t){if(!t)return e;let r={...e};for(let[n,s]of Object.entries(t)){let o=r[n]??{rawChars:0,responseChars:0,savedChars:0,calls:0};r[n]={rawChars:o.rawChars+s.rawChars,responseChars:o.responseChars+s.responseChars,savedChars:o.savedChars+s.savedChars,calls:o.calls+s.calls}}return r}function De(e,t){if(!t)return e;let r={...e};for(let[n,s]of Object.entries(t))r[n]=(r[n]??0)+s;return r}function Zt(e,t){if(!t)return e;let r={...e.hits};for(let[n,s]of Object.entries(t.hits??{}))r[n]=(r[n]??0)+s;return{hits:r,rateLimits:e.rateLimits+(t.rateLimits??0)}}function I(e){let t=Ue();if(!t)return{success:!1,session:null};let r=Vt(t.stats),n=T({toolCalls:r.toolCalls+(e.toolCalls??0),errors:r.errors+(e.errors??0),rateLimits:r.rateLimits+(e.rateLimits??0),rateLimitsByProvider:De(r.rateLimitsByProvider,e.rateLimitsByProvider),charsSavedByTool:Wt(r.charsSavedByTool,e.charsSavedByTool),githubCacheHits:Zt(r.githubCacheHits,e.githubCacheHits),packageRegistryFailures:De(r.packageRegistryFailures,e.packageRegistryFailures)}),s={...t,lastActiveAt:new Date().toISOString(),stats:n};return Me(s),{success:!0,session:s}}function Jt(e=1){return I({rateLimits:e})}function Kt(e,t,r){let n=Number.isFinite(t)?Math.max(0,t):0,s=Number.isFinite(r)?Math.max(0,r):0;return I({charsSavedByTool:{[e]:{rawChars:n,responseChars:s,savedChars:Math.max(0,n-s),calls:1}}})}function qt(e,t=1){return I({githubCacheHits:{hits:{[e]:t},rateLimits:0}})}function Qt(e=1){return I({githubCacheHits:{hits:{},rateLimits:e}})}var er={NOT_INITIALIZED:{code:"CONFIG_NOT_INITIALIZED",message:"Configuration not initialized. Call initialize() and await its completion before calling getServerConfig()."}},tr={PROMISES_NOT_ARRAY:{code:"VALIDATION_PROMISES_NOT_ARRAY",message:"promises must be an array"},TIMEOUT_NOT_POSITIVE:{code:"VALIDATION_TIMEOUT_NOT_POSITIVE",message:"timeout must be positive"},CONCURRENCY_NOT_POSITIVE:{code:"VALIDATION_CONCURRENCY_NOT_POSITIVE",message:"concurrency must be positive"}},rr={FETCH_NOT_AVAILABLE:{code:"FETCH_NOT_AVAILABLE",message:"Global fetch is not available in this environment."},FETCH_FAILED_AFTER_RETRIES:{code:"FETCH_FAILED_AFTER_RETRIES",message:(e,t)=>`Failed to fetch after ${e} attempts: ${t}`},FETCH_HTTP_ERROR:{code:"FETCH_HTTP_ERROR",message:(e,t)=>`Failed to fetch (${e} ${t})`}},nr={INVALID_FORMAT:{code:"TOOL_METADATA_INVALID_FORMAT",message:"Invalid tool metadata format from remote source."},INVALID_API_RESPONSE:{code:"TOOL_METADATA_INVALID_API_RESPONSE",message:"Invalid API response structure"}},sr={PATH_IS_DIRECTORY:{code:"FILE_PATH_IS_DIRECTORY",message:e=>`Path is a directory. Use ${e} to list directory contents`},FILE_TOO_LARGE:{code:"FILE_TOO_LARGE",message:(e,t,r)=>`File too large (${e}KB > ${t}KB). Use ${r} to search within the file or use startLine/endLine parameters to get specific sections`},FILE_EMPTY:{code:"FILE_EMPTY",message:"File is empty - no content to display"},BINARY_FILE:{code:"FILE_BINARY",message:"Binary file detected. Cannot display as text - download directly from GitHub"},DECODE_FAILED:{code:"FILE_DECODE_FAILED",message:"Failed to decode file. Encoding may not be supported (expected UTF-8)"},UNSUPPORTED_TYPE:{code:"FILE_UNSUPPORTED_TYPE",message:e=>`Unsupported file type: ${e}`}},or={NOT_FOUND:{code:"REPO_NOT_FOUND",message:(e,t,r)=>`Repository "${e}/${t}" not found or not accessible: ${r}`},PATH_NOT_FOUND:{code:"REPO_PATH_NOT_FOUND",message:(e,t,r,n)=>`Path "${e}" not found in repository "${t}/${r}" on branch "${n}"`},PATH_NOT_FOUND_ANY_BRANCH:{code:"REPO_PATH_NOT_FOUND_ANY_BRANCH",message:(e,t,r)=>`Path "${e}" not found in repository "${t}/${r}" on any common branch`},ACCESS_FAILED:{code:"REPO_ACCESS_FAILED",message:(e,t,r)=>`Failed to access repository "${e}/${t}": ${r}`},STRUCTURE_EXPLORATION_FAILED:{code:"REPO_STRUCTURE_EXPLORATION_FAILED",message:"Failed to explore repository structure"}},ir={QUERY_EMPTY:{code:"SEARCH_QUERY_EMPTY",message:"Search query cannot be empty"},NO_VALID_PARAMETERS:{code:"SEARCH_NO_VALID_PARAMETERS",message:"No valid search parameters provided"},PR_REQUIRED_PARAMS:{code:"SEARCH_PR_REQUIRED_PARAMS",message:"Owner, repo, and prNumber are required parameters"},PR_SINGLE_VALUES:{code:"SEARCH_PR_SINGLE_VALUES",message:"Owner and repo must be single values"},PULL_REQUEST_SEARCH_FAILED:{code:"SEARCH_PR_SEARCH_FAILED",message:e=>`Pull request search failed: ${e}`},PULL_REQUEST_LIST_FAILED:{code:"SEARCH_PR_LIST_FAILED",message:e=>`Pull request list failed: ${e}`},PULL_REQUEST_FETCH_FAILED:{code:"SEARCH_PR_FETCH_FAILED",message:(e,t)=>`Failed to fetch pull request #${e}: ${t}`}},ar={NO_TOOLS_REGISTERED:{code:"STARTUP_NO_TOOLS_REGISTERED",message:"No tools were successfully registered"},UNCAUGHT_EXCEPTION:{code:"STARTUP_UNCAUGHT_EXCEPTION",message:e=>`Uncaught exception: ${e}`},UNHANDLED_REJECTION:{code:"STARTUP_UNHANDLED_REJECTION",message:e=>`Unhandled rejection: ${e}`},STARTUP_FAILED:{code:"STARTUP_FAILED",message:e=>`Startup failed: ${e}`}},cr={TIMEOUT:{code:"PROMISE_TIMEOUT",message:(e,t)=>`Query ${e+1} timed out after ${t}ms \u2014 retry it alone, with tighter caps (maxFiles/maxMatchesPerFile/itemsPerPage) if it was large`},NOT_A_FUNCTION:{code:"PROMISE_NOT_A_FUNCTION",message:e=>`Promise function at index ${e} is not a function`},FUNCTION_UNDEFINED:{code:"PROMISE_FUNCTION_UNDEFINED",message:"Promise function is undefined"}},ur={EXECUTION_FAILED:{code:"TOOL_EXECUTION_FAILED",message:(e,t)=>`Tool ${e} execution failed: ${t}`},SECURITY_VALIDATION_FAILED:{code:"TOOL_SECURITY_VALIDATION_FAILED",message:(e,t)=>`Security validation failed for ${e}: ${t}`}},Bs={...er,...tr,...rr,...nr,...sr,...or,...ir,...ar,...cr,...ur};export{m as a,q as b,Ge as c,we as d,fr as e,Be as f,je as g,N as h,ze as i,rt as j,ne as k,ot as l,Mr as m,Dr as n,Gr as o,wr as p,Br as q,jr as r,zr as s,$r as t,Yr as u,Xr as v,Vr as w,Wr as x,Zr as y,Jr as z,Kr as A,qr as B,Qr as C,_ as D,en as E,tn as F,rn as G,nn as H,sn as I,on as J,an as K,it as L,cn as M,un as N,ft as O,Sn as P,bt as Q,er as R,tr as S,sr as T,or as U,ir as V,cr as W,re as X,I as Y,Jt as Z,Kt as _,qt as $,Qt as aa,Tr as ba,gr as ca,_r as da,Ye as ea,Er as fa,Rr as ga,Or as ha,z as ia,br as ja,Hr as ka,$ as la};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
var t=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","async","await"]);function n(e){return e?!t.has(e):!1}export{n as a};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{$ as R,O as T,ca as v,da as b}from"./chunk-BMM5H6QF.js";import W from"crypto";var Y="v2",J=new Set([]);function K(e){if(e===null||typeof e!="object"||Array.isArray(e))return e;let r=e,t=!1,s={};for(let n of Object.keys(r)){if(J.has(n)){t=!0;continue}s[n]=r[n]}return t?s:e}function ge(e,r,t){let s=D(K(r)),n=t?`${t}:${s}`:s,i=W.createHash("sha256").update(n).digest("hex");return`${Y}-${e}:${i}`}function D(e,r=new WeakSet){return e===null?"null":e===void 0?"undefined":typeof e!="object"?String(e):r.has(e)?'"[Circular]"':(r.add(e),Array.isArray(e)?`[${e.map(n=>D(n,r)).join(",")}]`:`{${Object.keys(e).sort().map(n=>{let i=e[n];return`"${n}":${D(i,r)}`}).join(",")}}`)}import V from"node-cache";var Z=300*1e3,d=new V({stdTTL:86400,checkperiod:300,maxKeys:5e3,deleteOnExpire:!0,useClones:!1}),h={hits:0,misses:0,sets:0,totalKeys:0,lastReset:new Date},P={"gh-api-code":3600,"gh-api-repos":7200,"gh-api-prs":1800,"gh-api-issues":1800,"gh-api-history":1800,"gh-api-releases":3600,"gh-api-file-content":300,"gh-repo-structure-api":7200,"github-user":900,"npm-search":14400,default:86400},g=new Map;function Q(e){return e.match(/^v\d+-([^:]+):/)?.[1]}function ee(e){return e.startsWith("gh-api-")||e.startsWith("gh-repo-")||e==="github-user"}function k(e){let r=Q(e);if(!(!r||!ee(r)))try{R(r,1)}catch{}}function O(){let e=Date.now();for(let[r,t]of g.entries())e-t.startedAt>Z&&g.delete(r)}function M(e){return P[e]||P.default}function x(e,r,t){try{return d.set(e,r,t),h.sets++,h.totalKeys=d.keys().length,!0}catch{try{let s=d.keys();for(let n of s)d.get(n);return d.set(e,r,t),h.sets++,h.totalKeys=d.keys().length,!0}catch{return!1}}}import{createHash as te}from"node:crypto";import{chmod as N,mkdir as H,readFile as F,readdir as re,rename as I,rm as ne,stat as _,writeFile as L}from"node:fs/promises";import{join as E}from"node:path";import{isPersistentStorageEnabled as se}from"@octocodeai/config";var j=1,$=5*1024*1024,ie=5e3,oe=256*1024*1024,ae=1440*60*1e3,ce=900*1e3,U=".last-gc",c={hits:0,misses:0,sets:0,errors:0,evictions:0};function S(e,r){let t=Number(process.env[e]);return Number.isFinite(t)&&t>0?Math.floor(t):r}function A(){if(!se())return!1;let e=process.env.OCTOCODE_DISK_CACHE?.trim().toLowerCase();return!(e==="false"||e==="0")}function X(e=T()){return E(e,"tmp","response")}function ue(e){return(e.match(/^v\d+-([^:]+):/)?.[1]??"default").replace(/[^a-zA-Z0-9._-]/g,"_")}function q(e,r=T()){let t=te("sha256").update(e).digest("hex");return E(X(r),ue(e),t.slice(0,2),`${t}.json`)}function z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function fe(e,r){let t;try{t=JSON.parse(e)}catch{return null}return!z(t)||t.version!==j||t.key!==r||typeof t.createdAt!="number"||typeof t.expiresAt!="number"||typeof t.staleUntil!="number"||!("value"in t)||t.etag!==void 0&&typeof t.etag!="string"?null:t}async function p(e){try{await ne(e,{force:!0,recursive:!0})}catch{}}async function G(e,r={}){if(!A())return;let t=q(e);try{let s=await _(t);if(!s.isFile()||s.size>S("OCTOCODE_DISK_CACHE_MAX_ENTRY_SIZE",$)){await p(t),c.errors++;return}let n=fe(await F(t,"utf8"),e);if(!n){await p(t),c.errors++;return}let i=Date.now();if(i>=n.staleUntil){await p(t),c.evictions++,c.misses++;return}if(i>=n.expiresAt&&!r.allowStale){c.misses++;return}return c.hits++,{value:n.value,...n.etag?{etag:n.etag}:{},state:i<n.expiresAt?"fresh":"stale",expiresAt:n.expiresAt}}catch(s){s.code!=="ENOENT"&&c.errors++,c.misses++;return}}async function B(e,r,t,s={}){if(!A())return!1;let n=Date.now(),i=Math.max(1,t*1e3),a=Math.max(i,(s.staleTtlSeconds??t)*1e3),m={version:j,key:e,createdAt:n,expiresAt:n+i,staleUntil:n+a,value:r,...s.etag?{etag:s.etag}:{}},f;try{f=JSON.stringify(m)}catch{return c.errors++,!1}if(f===void 0||Buffer.byteLength(f)>S("OCTOCODE_DISK_CACHE_MAX_ENTRY_SIZE",$))return!1;let u=q(e),w=E(u,".."),o=`${u}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{await H(w,{recursive:!0,mode:448}),await N(w,448),await L(o,f,{encoding:"utf8",mode:384}),await N(o,384);try{await I(o,u)}catch(l){let y=l.code;if(y!=="EEXIST"&&y!=="EPERM")throw l;await p(u),await I(o,u)}return c.sets++,!0}catch{return c.errors++,await p(o),!1}}async function le(e){let r=[],t=[e];for(;t.length>0;){let s=t.pop(),n;try{n=await re(s,{withFileTypes:!0})}catch{continue}for(let i of n){let a=E(s,i.name);i.isDirectory()?t.push(a):i.isFile()&&i.name!==U&&r.push(a)}}return r}async function de(e,r,t){if(!A())return 0;let s=X(e),n=E(s,U);if(t)try{let o=await _(n);if(r-o.mtimeMs<ae)return 0}catch{}let i=0,a=await le(s),m=S("OCTOCODE_DISK_CACHE_MAX_ENTRIES",ie),f=S("OCTOCODE_DISK_CACHE_MAX_SIZE",oe),u=[],w=0;for(let o of a)try{let l=await _(o);if(o.includes(".tmp-")){r-l.mtimeMs>ce&&(await p(o),i++);continue}let y=await F(o,"utf8"),C;try{C=JSON.parse(y)}catch{C=null}if(!z(C)||typeof C.staleUntil!="number"||r>=C.staleUntil){await p(o),i++;continue}u.push({path:o,size:l.size,modified:l.mtimeMs}),w+=l.size}catch{}for(u.sort((o,l)=>o.modified-l.modified);u.length>m||w>f;){let o=u.shift();if(!o)break;await p(o.path),w-=o.size,i++}try{await H(s,{recursive:!0,mode:448}),await L(n,String(r),{encoding:"utf8",mode:384})}catch{c.errors++}return c.evictions+=i,i}function xe(e=T(),r=Date.now()){return de(e,r,!1)}function he(e,r){if(r)return r;let t=e.match(/^v\d+-([^:]+):/);return M(t?.[1]??"default")}async function Pe(e,r,t={}){return v(()=>pe(e,r,t),t.cacheRole)}async function pe(e,r,t){if(t.skipCache)return await r();if(!t.forceRefresh){try{let m=d.get(e);if(m!==void 0)return h.hits++,k(e),b(),m}catch{}let a=await G(e);if(a?.state==="fresh")return h.hits++,k(e),b(),x(e,a.value,Math.max(1,(a.expiresAt-Date.now())/1e3)),a.value}O();let s=g.get(e);if(s)return s.promise;let n=Symbol(e),i=(async()=>{try{let a=await r();if(t.forceRefresh||h.misses++,(t.shouldCache??(()=>!0))(a)){let f=he(e,t.ttl);x(e,a,f),await B(e,a,f)}return a}finally{g.get(e)?.requestId===n&&g.delete(e)}})();return g.set(e,{promise:i,startedAt:Date.now(),requestId:n}),i}export{G as a,B as b,xe as c,ge as d,d as e,h as f,g,k as h,O as i,M as j,x as k,Pe as l};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{X as g}from"./chunk-BMM5H6QF.js";import{getConfigSync as S,DEFAULT_OUTPUT_CONFIG as k}from"@octocodeai/config";function _(){try{return S().output.pagination.defaultCharLength}catch{return k.pagination.defaultCharLength}}function O(e,t){return g.byteToCharOffset(e,t)}function M(e,t){return g.charToByteOffset(e,t)}function L(e){return g.charToByteOffset(e,e.length)}function C(e,t,i,n){return g.sliceContent(e,t,i,n)}function T(e,t=0,i,n={}){let c=n.mode??"characters",r=e.length,s=L(e);if(i===void 0)return t>0?T(e,t,c==="bytes"?s:r,n):{paginatedContent:e,byteOffset:0,byteLength:s,totalBytes:s,nextByteOffset:void 0,charOffset:0,charLength:r,totalChars:r,nextCharOffset:void 0,hasMore:!1,estimatedTokens:Math.ceil(e.length/4),currentPage:1,totalPages:1};let f=Math.max(1,n.pageSize??i),o,a,h,m,l,b,p,x;if(c==="bytes"){let u=Math.min(t,s),y=Math.min(u+i,s);m=O(e,u),l=O(e,y),l<r&&M(e,l)<y&&(l+=1);let d=C(e,m,l-m);o=d.text,m=d.charOffset,l=d.charOffset+d.charLength,a=d.byteOffset,h=d.byteOffset+d.byteLength,b=h<s;let P=n.actualOffset??u;p=Math.floor(P/f)+1,x=Math.max(p,Math.ceil(s/f))}else{let u=C(e,t,i);o=u.text,m=u.charOffset,l=u.charOffset+u.charLength,a=u.byteOffset,h=u.byteOffset+u.byteLength,b=l<r;let y=n.actualOffset??m;p=Math.floor(y/f)+1,x=Math.max(p,Math.ceil(r/f))}return{paginatedContent:o,byteOffset:a,byteLength:h-a,totalBytes:s,nextByteOffset:b?h:void 0,charOffset:m,charLength:o.length,totalChars:r,nextCharOffset:b?l:void 0,hasMore:b,estimatedTokens:Math.ceil(o.length/4),currentPage:p,totalPages:x}}function $(e){return{...e.pageCountsKind?{pageCountsKind:e.pageCountsKind}:{},currentPage:e.currentPage,totalPages:e.totalPages,hasMore:e.hasMore,charOffset:e.charOffset,charLength:e.charLength,totalChars:e.totalChars,...e.nextCharOffset!==void 0&&{nextCharOffset:e.nextCharOffset}}}var E=8e3,I="__octocode_generic__.unknown";function R(e){return e&&e.trim().length>0?e:I}async function B(e,t){return(await g.getSemanticBoundaryOffsets(e,R(t))).filter(n=>Number.isInteger(n)&&n>=0&&n<=e.length)}function w(e,t){let i=e.indexOf(`
|
|
9
|
+
`,t);return i===-1?void 0:i+1}function z(e){let t=e.trimEnd().split(`
|
|
10
|
+
`).at(-1)??"";return t.length>0&&(t[0]===" "||t[0]===" ")}async function K(e,t,i){let n=w(e,Math.max(0,t));return n===void 0?void 0:(await B(e,i)).find(r=>r>=n&&r>t)}async function D(e,t,i,n){let c=Math.min(Math.max(0,t),e.length),r=Math.max(1,i),s=c+r;if(s>=e.length)return{length:e.length-c,chunkMode:"char-limit"};let f=await B(e,n);if(f.length===0)return{length:r,chunkMode:"char-limit"};let o=f.find(h=>h>s);return o===void 0?{length:r,chunkMode:"char-limit"}:o-s<=E?{length:o-c,chunkMode:"semantic"}:{length:r,chunkMode:"char-limit"}}function X(e,t,i,n=!1,c=!1,r){if(n)try{new RegExp(t)}catch(a){let h=a instanceof Error?a.message:String(a);throw new Error(`Invalid regex pattern: ${h}`,{cause:a})}if(r!==void 0&&r<=0)return{lines:[],matchRanges:[],matchCount:0,matchingLines:[]};let s=e.join(`
|
|
11
|
+
`),f={isRegex:n,caseSensitive:c,contextLines:i,maxMatches:r},o=g.extractMatchingLines(s,t,f);return{lines:o.lines,matchRanges:o.matchRanges.map(a=>({start:a.start,end:a.end})),matchCount:o.matchCount,matchingLines:o.matchingLines.map(a=>a)}}export{_ as a,T as b,$ as c,z as d,K as e,D as f,X as g};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{z as e}from"zod";var i=e.object({currentPage:e.number(),totalPages:e.number(),hasMore:e.boolean(),nextPage:e.number().optional(),pageSize:e.number().optional(),totalItems:e.number().optional(),perPage:e.number().optional(),totalFound:e.number().optional(),returned:e.number().optional(),totalMatches:e.number().optional(),reportedTotalMatches:e.number().optional().describe("Provider-reported raw total (e.g. GitHub's match count) \u2014 may exceed what pagination can actually reach."),reachableTotalMatches:e.number().optional().describe("Matches reachable by walking pages (bounded by the provider's result window, e.g. GitHub caps at 1000); totalPages is computed from this, not from reportedTotalMatches."),totalMatchesKind:e.enum(["exact","reported","lowerBound"]).optional(),totalMatchesCapped:e.boolean().optional(),totalResults:e.number().optional(),itemsPerPage:e.number().optional()}),s=e.object({charOffset:e.number(),charLength:e.number(),totalChars:e.number(),hasMore:e.boolean(),nextCharOffset:e.number().optional(),currentPage:e.number().optional(),totalPages:e.number().optional(),chunkMode:e.enum(["semantic","char-limit"]).optional(),pageCountsKind:e.literal("estimated").optional()}),h=e.object({tool:e.string(),query:e.record(e.string(),e.unknown()),why:e.string().optional(),confidence:e.enum(["exact","high","medium","low"]).optional()}),m=i.extend({filesPerPage:e.number().optional(),entriesPerPage:e.number().optional(),matchesPerPage:e.number().optional(),totalFiles:e.number().optional(),totalEntries:e.number().optional(),totalMatches:e.number().optional(),totalFilesFound:e.number().optional(),nextMatchPage:e.number().optional()}),l=["goal","reasoning"];function u(o){let t;for(let n of l)n in o&&(t??={...o},delete t[n]);return t??o}function p(o,t,n="Continue to the next page of results."){return{tool:o,query:u(t),why:n,confidence:"exact"}}function d(o,t,n,a){if(!n||!n.hasMore||n.nextCharOffset===void 0)return;let r=a?.includeCharLength!==!1;return{continueChars:{tool:o,query:{...t,charOffset:n.nextCharOffset,...r&&n.charLength!==void 0?{charLength:t.charLength??n.charLength}:{}}}}}export{p as a,d as b};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{c as C}from"./chunk-OA6NU4KO.js";import{a as g,b as y}from"./chunk-DKGYPFGX.js";import{a as u,c as d,d as n,e as p,f}from"./chunk-USZL65FN.js";import{C as r,D as i,I as t,J as c,K as s,L as l,M as m,N as h,j as a}from"./chunk-BMM5H6QF.js";import{z as x}from"zod";import{z as e}from"zod";var S=r({name:"localGetFileContent",type:"Local",shortDescription:"Read a local file or a specific region.",instructions:`Read a known local path after search, find, or structure discovery. For large files, get a symbols outline, then an exact range or match. Read small config files whole with minify:"none".
|
|
9
|
+
Choose fullContent, matchString, or startLine+endLine. Partial content cannot prove absence; continue with the returned charOffset. matchedLines are LSP anchors; match ranges and character offsets are not. Report fetched bytes only.`,schema:{fullContent:"Whole file; small files only; exclusive with range/match.",matchString:"Anchor returning padded matchRanges and exact matchedLines.",matchStringIsRegex:"Makes matchString a regex.",matchStringCaseSensitive:"Case-sensitive matchString.",startLine:"Requires endLine; exclusive with fullContent/matchString.",endLine:"Requires startLine; must be >= startLine.",charOffset:"Copy the complete returned next query; semantic windows may expand beyond charLength.",minify:'"symbols" paginated outline (no range/match selectors), "standard" compact source, "none" unminified. Security redaction applies. Default none for fullContent/ranges, standard otherwise; matches force none.'}}),o=m(S.schema,{...l,path:e.string(),fullContent:e.boolean().optional(),matchString:e.string().optional(),matchStringIsRegex:e.boolean().optional(),matchStringCaseSensitive:e.boolean().optional(),startLine:t(),endLine:t(),contextLines:i(0,a).default(5),charOffset:c(),charLength:s(),minify:e.enum(["none","standard","symbols"]).default("standard")}).superRefine(h);var F=x.enum(["none","standard","symbols"]).optional(),L={startLine:n,endLine:n,contextLines:d.default(5),charOffset:p.optional(),charLength:u(1,5e4).optional(),minify:F},R=y(o,L),G=g(o,L),I=f(C(R),{maxQueries:5});export{G as a,I as b};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{b as i}from"./chunk-OA6NU4KO.js";import{a as C,b as L}from"./chunk-DKGYPFGX.js";import{a,b as f,f as h}from"./chunk-USZL65FN.js";import{A as p,C as d,D as s,F as y,H as g,L as b,M as S,l as c,m as u,z as l}from"./chunk-BMM5H6QF.js";import{z as o}from"zod";import{z as t}from"zod";var R=d({name:"lspGetSemantics",type:"Local",shortDescription:"Run LSP semantic queries \u2014 definitions, references, call hierarchy, symbols, type hierarchy, diagnostics.",instructions:`Use a real search/read line anchor for semantic proof. references finds usages; callers incoming calls; callees outgoing calls; callHierarchy both. Fall back to references if call hierarchy is unavailable.
|
|
9
|
+
documentSymbols/diagnostic need uri; workspaceSymbol needs symbolName; other operations need uri+symbolName+lineHint. orderHint resolves same-line names. format:"compact" saves tokens. Empty/unavailable results call for a new anchor or text search.`,schema:{pageSize:"References or symbols returned per page.",page:"Reference/symbol result page.",snapshot:"Result-set token from next.nextPage; required after page 1. On paginationChanged, discard prior pages and execute next.restartPagination.",type:"Identity, usage, hierarchy, hover, symbol, or diagnostic operation.",uri:"Target file path/URI; required for every type except workspaceSymbol.",symbolName:"Bare anchored identifier, or fuzzy workspace symbol query.",lineHint:"Observed line containing symbolName.",orderHint:"Disambiguate repeated symbols on one line.",depth:"Call/type hierarchy depth; 0 is direct only.",includeDeclaration:"references: include the declaration; disable before unused analysis.",groupByFile:"references summary mode.",contextLines:"Lines of surrounding source shown around each result location.",format:'"compact" saves tokens; "structured" has typed locations.',workspaceRoot:"Use when auto-root is wrong.",rustContext:"Explicit Rust build context (requires a .rs uri). Features/target/cfgs select rust-analyzer semantics. buildScripts and procMacros default false; enabling either permits workspace code execution. procMacros requires buildScripts:true. Context partitions server reuse and pagination; syntax graphs remain unexpanded."}}),m=S(R.schema,{...b,uri:t.string().optional(),type:t.enum(["definition","references","callers","callees","callHierarchy","hover","documentSymbols","typeDefinition","implementation","workspaceSymbol","supertypes","subtypes","diagnostic"]).default("definition"),symbolName:t.string().min(1).optional(),lineHint:s(1,c).optional(),orderHint:s(0,u).default(0),depth:s(0,l).optional(),includeDeclaration:t.boolean().default(!0),groupByFile:t.boolean().optional(),page:y(),pageSize:s(1,p).optional(),snapshot:t.string().min(1).max(128).optional(),contextLines:g(),format:t.enum(["structured","compact"]).default("structured"),workspaceRoot:t.string().optional(),rustContext:t.object({features:t.union([t.literal("all"),t.array(t.string().min(1).max(128)).max(128)]).default([]),noDefaultFeatures:t.boolean().default(!1),target:t.string().min(1).max(256).optional(),cfgs:t.array(t.string().min(1).max(256)).max(128).default([]),buildScripts:t.boolean().default(!1),procMacros:t.boolean().default(!1)}).strict().superRefine((e,n)=>{e.procMacros&&!e.buildScripts&&n.addIssue({code:"custom",path:["procMacros"],message:"procMacros requires buildScripts:true because rust-analyzer builds procedural macros through Cargo."})}).optional()}).superRefine((e,n)=>{if(e.rustContext&&!e.uri?.toLowerCase().endsWith(".rs")&&n.addIssue({code:"custom",path:["rustContext"],message:"rustContext requires a Rust .rs uri, including for workspaceSymbol."}),e.type==="workspaceSymbol"){e.symbolName||n.addIssue({code:"custom",path:["symbolName"],message:"Set symbolName for workspaceSymbol."});return}e.uri||n.addIssue({code:"custom",path:["uri"],message:"Set uri for file-scoped operations."}),!(e.type==="documentSymbols"||e.type==="diagnostic")&&(e.symbolName||n.addIssue({code:"custom",path:["symbolName"],message:"Set symbolName for anchored operations."}),Number.isInteger(e.lineHint)||n.addIssue({code:"custom",path:["lineHint"],message:"Set lineHint for anchored operations."}))});var k=["definition","references","callers","callees","callHierarchy","hover","documentSymbols","typeDefinition","implementation","workspaceSymbol","supertypes","subtypes","diagnostic"];function F(e){return{name:e.name,uri:e.uri,foundAtLine:e.foundAtLine,...e.orderHint!==void 0&&{orderHint:e.orderHint},...e.isAmbiguous===!0&&{isAmbiguous:!0},...e.lineDeviation!==void 0&&{lineDeviation:e.lineDeviation}}}function B(e){let n=e.displayRange??(e.range?{startLine:e.range.start.line+1,endLine:e.range.end.line+1}:void 0);return{uri:e.uri,...e.content!==void 0&&{content:e.content},...n&&{displayRange:n},...e.isDefinition&&{isDefinition:!0}}}var E=a(1,1e9),v=a(0,1e5).optional(),N=["structured","compact"],x={type:o.enum(k).default("definition"),symbolName:o.string().min(1).max(1024).optional(),lineHint:E.optional(),orderHint:v,depth:a(0,20).optional(),includeDeclaration:o.boolean().optional().default(!0),page:f,pageSize:a(1,100).optional(),contextLines:a(0,100).optional(),format:o.enum(N).optional().default("structured")},r=L(m,x),T=["definition","references","callers","callees","callHierarchy","hover","typeDefinition","implementation","supertypes","subtypes"],A=["documentSymbols","diagnostic"],D=r.extend({type:o.enum(T).optional(),uri:i(r.shape,"uri"),symbolName:i(r.shape,"symbolName"),lineHint:i(r.shape,"lineHint")}),H=r.extend({type:o.enum(A),uri:i(r.shape,"uri")}),P=r.extend({type:o.literal("workspaceSymbol"),symbolName:i(r.shape,"symbolName")}),X=C(m,x),Y=h(o.union([D,H,P]),{maxQueries:5});export{F as a,B as b,X as c,Y as d};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{z as r}from"zod";function a(n,e){return n?.description&&!e.description?e.describe(n.description):e}function c(n,e){let t={};for(let[o,d]of Object.entries(e))t[o]=a(n.shape[o],d);return t}function i(n,e){let t=n;return t.safeExtend?t.safeExtend(e):n.extend(e)}function s(n,e){if(!e?.length)return n;let t=new Set(e);return r.object(Object.fromEntries(Object.entries(n.shape).filter(([o])=>!t.has(o))))}function p(n,e={},t={}){let o=s(n,t.omit);return i(o,c(o,e)).strict()}function u(n,e={},t={}){let o=s(n,t.omit);return r.object({...o.shape,...c(o,e)}).strict()}export{p as a,u as b};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{J as u,t as n,u as p}from"./chunk-RRSY2ZPX.js";import{i as d}from"./chunk-ZSXRT7JL.js";function c(e){return e.data!==void 0&&!e.error}import{maskSensitiveData as l}from"@octocodeai/octocode-engine/mask";var i=class extends Error{providerType;constructor(o,r){super(r),this.name="ProviderInitializationError",this.providerType=o}};function T(e){let o=p(),r=o.provider??n(),{baseUrl:s,token:a}=o;try{let t=u(r,{type:r,baseUrl:s,token:a,authInfo:e});return{providerType:r,provider:t,capabilities:t.capabilities,baseUrl:s,token:a,authInfo:e}}catch(t){let v=t instanceof Error?t.message:"Unknown provider error",P=l(v);throw new i(r,`Failed to initialize ${r} provider: ${P}`)}}function g(e){let o;return()=>o??=T(e)}function C(e,o){return e.capabilities[o]}async function S(e,o){let r=await o();return c(r)?{ok:!0,response:r}:{ok:!1,result:d(r,e)}}export{g as a,C as b,S as c};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{f as l}from"./chunk-USZL65FN.js";import{C as c,L as d,k as s,q as p}from"./chunk-BMM5H6QF.js";import{z as e}from"zod";var y="localAnalyzeGraph",b=c({name:y,type:"Local",shortDescription:"Analyze a repository file graph through one bounded operation.",instructions:"Map file topology, not symbol identity. dependencies/dependents need file; path needs file+target; deadCode/reachability accept roots; cycles needs no selector. Read completeness.results, completeness.graph, and completeness.diagnostics independently. Import edges and dead-code results are candidates\u2014verify changes and deletions with exact reads plus LSP.",schema:{path:"Absolute repository or package root to scan.",operation:"One bounded operation: deadCode, cycles, dependencies, dependents, path, or reachability.",file:"Repository-relative source file for dependencies, dependents, or path.",target:"Repository-relative destination file for path.",depth:"Traversal depth for dependencies or dependents.",entrypoints:"Repository-relative file or dynamic asset directory roots for deadCode or reachability.",includeTests:"Treat test files as reachability roots.",excludeDir:"Directory names to prune from graph construction.",maxFiles:"Maximum source files scanned; truncation is reported.",limit:"Result cap applied before pagination.",page:"Result page, 1-based; advance only while pagination.hasMore.",pageSize:"Results returned per page.",diagnosticPage:"Coverage diagnostic page, independent of result pagination.",diagnosticPageSize:"Coverage diagnostics per page (default 25).",diagnosticSnapshot:"Snapshot from next.nextDiagnostics; restart if diagnostics changed.",rustWorkspace:"Rust resolution: syntax (default) or opt-in cargo workspace metadata."}}),t=(a,n)=>e.preprocess(i=>typeof i=="number"&&Number.isFinite(i)?Math.min(Math.max(i,a),n):i,e.number().int().min(a).max(n)),r=(a,n)=>e.literal(a).describe(n),o={...d,path:e.string().optional().describe("Absolute repository or package root to scan. Omit when file is absolute \u2014 the root is inferred by walking up to the nearest package.json."),excludeDir:e.array(e.string()).optional().describe("Directory names to prune from graph construction."),maxFiles:t(1,5e4).optional().describe("Maximum source files scanned; truncation is reported."),limit:t(1,5e3).optional().describe("Result cap applied before pagination."),page:t(1,s).optional().default(1).describe("Result page, 1-based."),pageSize:t(1,p).optional().describe("Results returned per page."),diagnosticPage:t(1,s).optional().describe("Coverage diagnostic page, 1-based and independent of result page."),diagnosticPageSize:t(1,100).optional().describe("Coverage diagnostics returned per page (default 25, maximum 100)."),diagnosticSnapshot:e.string().regex(/^[a-f0-9]{64}$/).optional().describe("Diagnostic snapshot from next.nextDiagnostics; detects changes between pages."),rustWorkspace:e.enum(["syntax","cargo"]).optional().describe("Rust resolution: syntax by default; cargo opts into workspace metadata.")},u={entrypoints:e.array(e.string()).optional().describe("Repo-relative file or dynamic asset directory roots; omit to detect package.json main/exports/bin."),includeTests:e.boolean().optional().default(!0).describe("Treat tests as reachability roots (default true).")},g={file:e.string().describe("Repo-relative source file."),depth:t(1,50).optional().default(1).describe("Maximum traversal depth (default 1).")},m=e.discriminatedUnion("operation",[e.object({...o,...u,operation:r("deadCode","Find unreachable or unretained exported symbols and dead SCCs.")}).strict(),e.object({...o,operation:r("cycles","Find strongly connected file components.")}).strict(),e.object({...o,...g,operation:r("dependencies","Traverse files imported or re-exported by the source file; results include edgeKinds and syntactic confidence.")}).strict(),e.object({...o,...g,operation:r("dependents","Traverse files that import or re-export the source file; results include edgeKinds and syntactic confidence.")}).strict(),e.object({...o,file:e.string().describe("Repo-relative source file."),target:e.string().describe("Repo-relative destination file."),operation:r("path","Find the shortest directed import/re-export path with per-edge provenance.")}).strict(),e.object({...o,...u,operation:r("reachability","Classify scanned files by reachability from entrypoints.")}).strict()]);var A=l(m,{maxQueries:5});export{m as a,A as b};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
var E={MCP_MAX_TOKENS:25e3,CHARS_PER_TOKEN:4,MAX_FETCH_CONTENT_CHARS:5e4,MAX_OUTPUT_SIZE_BYTES:10*1024*1024,LARGE_FILE_THRESHOLD_KB:100,MAX_ENTRIES_BEFORE_PAGINATION:100,MAX_FILES_DEFAULT:1e3,DEFAULT_ENTRIES_PER_PAGE:100,MAX_ENTRIES_PER_PAGE:200,MAX_LIST_ITEMS_DETAILED:100,MAX_LIST_ITEMS_SIMPLE:200,MAX_ARCHIVE_ENTRIES_PER_PAGE:100,MAX_DIR_ENTRIES_PER_PAGE:100,MAX_DIR_ENTRIES_TREE:1e3,DEFAULT_EXEC_TIMEOUT_MS:3e4,DEFAULT_MAX_MATCHES_PER_FILE:3,DEFAULT_CONTEXT_LINES:5,DEFAULT_MATCH_CONTENT_LENGTH:500,MAX_MATCH_CONTENT_LENGTH:800,DEFAULT_MATCHES_PER_PAGE:10,MAX_MATCHES_PER_PAGE:100,DEFAULT_FILES_PER_PAGE:20,MAX_FILES_PER_PAGE:50,MAX_RIPGREP_DIRECTORY_SIZE_MB:100,MAX_FILE_COUNT_FOR_SEARCH:1e3,ESTIMATED_AVG_FILE_SIZE_BYTES:50*1024,LARGE_RESULT_BYTES_HINT:1.5*1024*1024,BINARY_MAX_BYTES:10*1024,BINARY_DEFAULT_HEX_LINES:20,BINARY_DEFAULT_MIN_STRING_LENGTH:6,MAX_ARCHIVE_FILES:1e3,DEFAULT_ARCHIVE_MAX_FILES:200,GLOBAL_MEMORY_LIMIT_BYTES:100*1024*1024,PER_OPERATION_MEMORY_LIMIT_BYTES:10*1024*1024,MEMORY_RESERVATION_TIMEOUT_MS:300*1e3,TOKEN_CRITICAL_THRESHOLD:5e4,TOKEN_HIGH_THRESHOLD:25e3,TOKEN_MODERATE_THRESHOLD:1e4,TOKEN_NOTICE_THRESHOLD:2500};export{E as a};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
function i(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function d(e){if(typeof e=="string")return{message:e};if(typeof e=="object"&&e!==null){let r=e;return{message:typeof r.error=="string"&&r.error.length>0?r.error:"Provider error",status:i(r.status),retryAfterSeconds:i(r.retryAfter),rateLimitRemaining:i(r.rateLimitRemaining),rateLimitReset:i(r.rateLimitReset)}}return{message:"Provider error"}}function f(e){let r=[];for(let t of e){if(t.status!=="error")continue;let{message:o,status:n,retryAfterSeconds:s,rateLimitRemaining:u,rateLimitReset:a}=d(t.data.error),m=n!==void 0?`${o} (HTTP ${n})`:o;r.push({index:t.index,error:m,...n!==void 0?{status:n}:{},...s!==void 0?{retryAfterSeconds:s}:{},...u!==void 0?{rateLimitRemaining:u}:{},...a!==void 0?{rateLimitReset:a}:{}})}return r}function y(e,r,t){return{structuredContent:e,keysPriority:r,isError:t}}export{f as a,y as b};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{D as o,E as s,F as d,G as m,H as p,L as h,M as f,n as r,v as l,w as u,x as i,y as c}from"./chunk-BMM5H6QF.js";import{z as e}from"zod";var v={searchText:'Single lexical pattern. regex:"fixed" is literal and "perl" enables advanced syntax.',mode:'Search mode: "discovery" paths; "paginated" snippets; "detailed" context; "structural" AST.',pattern:"Structural code pattern: $X matches one node; $$$ARGS matches a list. Include modifiers or use a kind rule.",rule:"Structural YAML ast-grep rule for relational matches.",regex:'"smart" (default), "fixed" (literal), or "perl" (advanced).',caseMode:'"smart" (default), "sensitive", or "insensitive".',wholeWord:"Match whole words only (text/regex modes).",invertMatch:"Return non-matching lines (text/regex modes).",multiline:'"off" (default), "on", or "dotall" (. spans newlines).',include:"Glob(s) of files to include.",exclude:"Glob(s) of files to exclude.",excludeDir:"Directory names to prune from the walk.",noIgnore:"Also search .gitignored files.",hidden:"Include dot-files.",matchContentLength:"Matched-line characters kept per hit; longer lines are truncated.",maxFiles:"Text: page ceiling. Structural: scan cap; stats report truncation.",maxDepth:"Maximum levels below the search root; 0 means root files.",output:'"content" lines; "files"/"filesWithout" paths; count modes totals; "matchOnly" substrings.',unique:'With output:"matchOnly", deduplicate values or count frequency.',sort:'"relevance" (default), "matchCount", "path", "modified", "accessed", or "created".',sortReverse:"Reverse the sort order.",rankingProfile:'Language tuning for sort:"relevance"; "auto" detects.',langType:'Language/file type, e.g. "ts"; structural mode maps it to include globs.',captureText:"Structural: include verbatim $$$ list captures; ranges remain available when omitted.",maxMatchesPerFile:"Pairs with matchPage.",matchWindow:'Requires output:"matchOnly".',matchPage:"Per-file match page."},w=f(v,{...h,searchText:e.string().optional(),path:e.string(),mode:e.enum(["paginated","discovery","detailed","structural"]).default("paginated"),pattern:e.string().optional(),rule:e.string().optional(),regex:e.enum(["smart","fixed","perl"]).default("smart"),caseMode:e.enum(["smart","sensitive","insensitive"]).default("smart"),wholeWord:e.boolean().optional(),invertMatch:e.boolean().optional(),include:s,exclude:s,excludeDir:s,noIgnore:e.boolean().optional(),hidden:e.boolean().optional(),contextLines:p(),matchContentLength:o(1,l).default(u),maxMatchesPerFile:o(1,i).optional(),maxFiles:o(1,i).optional(),maxDepth:o(0,r).optional(),multiline:e.enum(["off","on","dotall"]).default("off"),sort:e.enum(["relevance","matchCount","path","modified","accessed","created"]).default("relevance"),sortReverse:e.boolean().optional(),rankingProfile:e.enum(["auto","typescript","javascript","rust","python","go","java","scala","markdown","json","yaml","generic"]).default("auto"),langType:e.string().optional(),captureText:e.boolean().optional(),output:e.enum(["content","files","filesWithout","countLines","countMatches","matchOnly"]).default("content"),unique:e.enum(["off","list","count"]).default("off"),matchWindow:o(0,200).optional(),matchPage:m(),itemsPerPage:o(1,c).optional(),page:d()}).superRefine((t,a)=>{if(t.mode==="structural"){!t.pattern&&!t.rule&&a.addIssue({code:"custom",message:"Set pattern or rule for structural mode.",path:["pattern"]}),t.pattern&&t.rule&&a.addIssue({code:"custom",message:"Choose pattern or rule, not both.",path:["rule"]}),t.wholeWord&&a.addIssue({code:"custom",message:"Remove wholeWord in structural mode.",path:["wholeWord"]}),t.invertMatch&&a.addIssue({code:"custom",message:"Remove invertMatch in structural mode.",path:["invertMatch"]});for(let n of["regex","caseMode","multiline"]){let g=n==="multiline"?"off":"smart";t[n]!==g&&a.addIssue({code:"custom",message:`Remove ${n} in structural mode.`,path:[n]})}t.output!=="content"&&a.addIssue({code:"custom",message:"Remove output in structural mode.",path:["output"]}),t.unique!=="off"&&a.addIssue({code:"custom",message:"Remove unique in structural mode.",path:["unique"]})}else(t.pattern||t.rule)&&a.addIssue({code:"custom",message:"Use structural mode with pattern or rule.",path:[t.pattern?"pattern":"rule"]}),t.searchText||a.addIssue({code:"custom",message:"Set searchText for text modes.",path:["searchText"]});t.matchWindow!==void 0&&t.output!=="matchOnly"&&a.addIssue({code:"custom",message:'Use output:"matchOnly" with matchWindow.',path:["matchWindow"]}),t.unique!=="off"&&t.output!=="matchOnly"&&a.addIssue({code:"custom",message:'Use output:"matchOnly" with unique.',path:["unique"]})});export{v as a,w as b};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{d as n,e as s,f as u}from"./chunk-ZSXRT7JL.js";import{redactPath as l}from"@octocodeai/octocode-engine/pathUtils";var f={pathValidationFailed:(e,t,o)=>new s(n.PATH_VALIDATION_FAILED,t||`Path validation failed: ${l(e,o)}`,{path:e}),fileAccessFailed:(e,t,o)=>{let i=l(e,o),r=`Cannot access file: ${i}`,a=t?.code;return a==="ENOENT"?r=`File not found: ${i}. Verify the path with localSearch operation:"files".`:a==="EACCES"?r=`Permission denied: ${i}. Check file permissions.`:a==="EISDIR"?r=`Path is a directory: ${i}. Use localSearch operation:"tree".`:a==="ENOTDIR"?r=`Invalid path: ${i}. A component of the path is not a directory.`:a==="ENAMETOOLONG"&&(r=`Path too long: ${i}`),new s(n.FILE_ACCESS_FAILED,r,{path:e,errorCode:a},t)},fileReadFailed:(e,t,o)=>new s(n.FILE_READ_FAILED,`Failed to read file: ${l(e,o)}`,{path:e,errorCode:t?.code},t),fileTooLarge:(e,t,o)=>new s(n.FILE_TOO_LARGE,(()=>{let i=r=>Number.isInteger(r)?`${r}KB`:`${r.toFixed(1)}KB`;return`File too large: ${i(t)} (limit: ${i(o)}). Use startLine/endLine, matchString, or charOffset/charLength to read a bounded slice.`})(),{path:e,sizeKB:t,limitKB:o}),binaryFileUnsupported:e=>new s(n.BINARY_FILE_UNSUPPORTED,`Binary file unsupported: ${l(e)}. Use localSearch operation:"text" for embedded strings.`,{path:e}),outputTooLarge:(e,t)=>new s(n.OUTPUT_TOO_LARGE,`Output too large: ${e} (limit: ${t})`,{size:e,limit:t}),commandNotAvailable:(e,t)=>new s(n.COMMAND_NOT_AVAILABLE,`Command '${e}' is not available. ${t||"Please install it and ensure it is in your PATH."}`,{command:e,installHint:t}),commandExecutionFailed:(e,t,o)=>new s(n.COMMAND_EXECUTION_FAILED,o?`Command '${e}' failed: ${o}`:`Command execution failed: ${e}`,{command:e,stderr:o},t),toolExecutionFailed:(e,t)=>new s(n.TOOL_EXECUTION_FAILED,`Tool execution failed: ${e}`,{toolName:e},t)};import d from"path";import{pathValidator as c}from"@octocodeai/octocode-engine/pathValidator";import{getConfigSync as h,getOctocodeHome as g}from"@octocodeai/config";function E(e=h().local.allowedPaths){for(let t of e)typeof t=="string"&&t.trim()!==""&&c.addAllowedRoot(t)}function m(){let e=g(process.env);c.addAllowedRoot(d.join(e,"tmp","clone")),c.addAllowedRoot(d.join(e,"tmp","tree"))}function _(e,t){if(!e.path?.trim()){let p=f.pathValidationFailed("","path is required");return{isValid:!1,errorResult:u(p,e,{toolName:t})}}E(),m();let o=process.env.WORKSPACE_ROOT?.trim()||h().local.workspaceRoot||process.cwd(),i=e.path.replace(/^file:\/\//,""),r=d.isAbsolute(i)?i:d.resolve(o,i),a=c.validate(r);if(!a.isValid){let p=f.pathValidationFailed(e.path,a.error);return{isValid:!1,errorResult:u(p,e,{toolName:t,extra:{cwd:o,resolvedPath:r}})}}return{isValid:!0,sanitizedPath:a.sanitizedPath??r}}export{f as a,_ as b};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{a as S}from"./chunk-3AA4F3QO.js";import{f as x}from"./chunk-USZL65FN.js";import{B as R,C as w,D as o,E as c,F as a,L as i,M as s,r as u,s as d,t as y,u as T}from"./chunk-BMM5H6QF.js";import{z as m}from"zod";import{z as r}from"zod";var G={keywords:"ANDed; keep a phrase as one item; alternatives need separate queries.",path:"Repo path prefix, not a full file path.",match:'For ghSearch operation:"code": "file" returns snippets and character matchIndices; "path" returns paths only. Operation:"repositories" uses text-field names.',extension:'File extension filter, e.g. "ts" (no dot).',filename:"Exact filename filter.",language:'GitHub language filter, e.g. "typescript".',concise:'Flat "owner/repo:path" rows.',limit:"Results per page (paginate with page)."},h=s(G,{...i,keywords:c,owner:r.string().optional(),repo:r.string().optional(),extension:r.string().optional(),filename:r.string().optional(),path:r.string().optional(),language:r.string().optional(),match:r.enum(["file","path"]).default("file"),limit:o(1,u).default(d),page:a(),concise:r.boolean().optional()});import{z as t}from"zod";var _={keywords:"ANDed; keep a phrase as one item; alternatives need separate queries.",topicsToSearch:"ANDed topic filters; metadata can be sparse.",match:'For ghSearch operation:"repositories": text fields to search are name, description, and readme; readme is broader and slower. Operation:"code" uses "file" or "path".',sort:"stars, forks, updated, help-wanted-issues, best-match.",language:'Primary language filter, e.g. "rust".',stars:'Star range: ">100", "10..50".',forks:'Fork range: ">50", "10..100".',goodFirstIssues:'Good-first-issue count range, e.g. ">5".',updated:'Last push date: ">2024-01-01" or "a..b".',created:'Creation date: ">2023-01-01" or "a..b".',size:'Repo size in KB: ">1000", "50..500".',license:'SPDX id, e.g. "mit".',archived:"true = archived only; default excludes archived.",visibility:'"public" or "private" (private needs token scope).',concise:'Flat "owner/repo" rows for triage.',limit:"Results per page (paginate with page)."},l=s(_,{...i,keywords:c,topicsToSearch:c,language:t.string().optional(),owner:t.string().optional(),stars:t.string().optional(),forks:t.string().optional(),goodFirstIssues:t.string().optional(),updated:t.string().optional(),created:t.string().optional(),size:t.string().optional(),match:t.array(t.enum(["name","description","readme"])).optional(),sort:t.enum(["stars","forks","help-wanted-issues","updated","best-match"]).default("best-match"),limit:o(1,u).default(d),page:a(),archived:t.boolean().optional(),visibility:t.enum(["public","private"]).optional(),license:t.string().optional(),concise:t.boolean().optional()});import{z as n}from"zod";var I={path:'Repo-relative directory; ""/"." for root.',branch:"Ref; fallback warning means default branch was used.",maxDepth:"Tree recursion depth.",page:"Advance only on hasMore.",metadataPage:"Page of the requested contributors, branches, or tags; follow next for each list independently.",include:"Optional sizes, languages, contributors, branches, or tags; each adds an API call."},g=s(I,{...i,owner:n.string(),repo:n.string(),branch:n.string().optional(),path:n.string().optional(),maxDepth:o(0,R).optional(),page:a(),metadataPage:a().optional(),itemsPerPage:o(1,y).default(T),include:n.array(n.enum(["sizes","languages","contributors","branches","tags"])).optional()});var $=w({name:"ghSearch",type:"Github",shortDescription:"Search GitHub code or repositories, or browse a repository tree.",instructions:S.ghSearch,schema:{operation:'Required: "code", "repositories", or "tree".'}}),k=h.omit({limit:!0}).extend({match:h.shape.match.describe('For operation:"code": "file" returns snippets; "path" returns paths only.'),pageSize:h.shape.limit.describe("Results returned per page."),operation:m.literal("code").describe("Search code contents or file paths.")}).strict(),A=l.omit({topicsToSearch:!0,limit:!0}).extend({topics:l.shape.topicsToSearch.describe("Repository topics; all must match."),pageSize:l.shape.limit.describe("Results returned per page."),match:l.shape.match.describe('For operation:"repositories": fields to search: name, description, or readme.'),operation:m.literal("repositories").describe("Discover repositories by keywords and repository filters.")}).strict(),Q=g.omit({itemsPerPage:!0}).extend({operation:m.literal("tree").describe("Browse the tree of a known repository."),pageSize:g.shape.itemsPerPage.describe("Tree entries returned per page.")}).strict(),H=m.discriminatedUnion("operation",[k,A,Q]);function b(e){return typeof e=="string"&&e.trim().length>0}function f(e){return Array.isArray(e)&&e.some(b)}function E(e){return e.operation==="code"?f(e.keywords)||["owner","path","extension","filename","language"].some(p=>b(e[p])):e.operation==="repositories"?f(e.keywords)||f(e.topics)||["owner","language","stars","forks","goodFirstIssues","updated","created","size","visibility","license"].some(p=>b(e[p]))||typeof e.archived=="boolean":!0}var P=H.superRefine((e,p)=>{E(e)||p.addIssue({code:"custom",path:["operation"],message:`${e.operation} needs at least one search term or scope filter`})}),Z=x(P,{maxQueries:5});export{P as a,Z as b};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_fn } from 'path';
|
|
5
|
+
const require = __createRequire(import.meta.url);
|
|
6
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __dirname_fn(__filename);
|
|
8
|
+
import{z as o}from"zod";var y=["fullContent","matchString","matchStringIsRegex","matchStringCaseSensitive","startLine","endLine"],L=[...y,"contextLines","charOffset","charLength","minify"];function m(e,t){let n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([i])=>!n.has(i)))}function d(e,t){return e.description?t.describe(e.description):t}function r(e,t){let n=e[t];if(!n)throw new TypeError(`Expected schema field: ${t}`);return n}function f(e,t){return r(e,t).nonoptional()}function u(e,t){let n=m(e.shape,[...y,...t?["type"]:[]]),i=t?{type:t}:{},s=d(r(e.shape,"fullContent"),o.literal(!1).optional()),p=d(r(e.shape,"fullContent"),o.literal(!0)),h=o.object({...n,...i,fullContent:s}).strict(),c=o.object({...n,...i,fullContent:p}).strict(),l=o.object({...n,...i,fullContent:s,matchString:f(e.shape,"matchString"),matchStringIsRegex:r(e.shape,"matchStringIsRegex"),matchStringCaseSensitive:r(e.shape,"matchStringCaseSensitive")}).strict(),S=o.object({...n,...i,fullContent:s,startLine:f(e.shape,"startLine"),endLine:f(e.shape,"endLine")}).strict().superRefine((a,g)=>{typeof a.startLine=="number"&&typeof a.endLine=="number"&&a.endLine<a.startLine&&g.addIssue({code:"custom",path:["endLine"],message:"Set endLine greater than or equal to startLine."})});return[h,c,l,S]}function T(e,t={}){let n=(c,l)=>{c.minify==="symbols"&&(c.matchString!==void 0||c.startLine!==void 0||c.endLine!==void 0)&&l.addIssue({code:"custom",path:["minify"],message:'minify:"symbols" cannot be combined with matchString or startLine/endLine. Read the outline, then request a source slice.'})};if(!t.githubDirectoryMode)return o.union(u(e)).superRefine(n);let i=d(r(e.shape,"type"),o.literal("file").optional()),s=d(r(e.shape,"type"),o.literal("directory")),p=m(e.shape,[...L,"type"]),h=o.object({...p,type:s}).strict();return o.union([...u(e,i),h]).superRefine(n)}export{r as a,f as b,T as c};
|