@octocodeai/octocode-tools-core 16.6.3 → 17.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/README.md +22 -50
  2. package/dist/direct.js +33 -38
  3. package/dist/github/botFilter.d.ts +1 -0
  4. package/dist/github/client.d.ts +6 -0
  5. package/dist/github/directoryFetch/fetchDirectoryContents.d.ts +3 -0
  6. package/dist/github/directoryFetch/fetchFileContentToDisk.d.ts +3 -0
  7. package/dist/github/directoryFetch/helpers.d.ts +35 -0
  8. package/dist/github/directoryFetch.d.ts +3 -6
  9. package/dist/github/fileContentPagination.d.ts +9 -0
  10. package/dist/github/fileContentProcess.d.ts +1 -8
  11. package/dist/github/fileContentRaw/fetch.d.ts +20 -0
  12. package/dist/github/fileContentRaw/pathSuggestions.d.ts +3 -0
  13. package/dist/github/fileContentRaw.d.ts +2 -12
  14. package/dist/github/githubAPI.d.ts +4 -1
  15. package/dist/github/history.d.ts +6 -2
  16. package/dist/github/issues/fetchers.d.ts +7 -0
  17. package/dist/github/issues/helpers.d.ts +32 -0
  18. package/dist/github/issues/orchestrator.d.ts +4 -0
  19. package/dist/github/issues/types.d.ts +72 -0
  20. package/dist/github/issues.d.ts +3 -0
  21. package/dist/github/prContentFetcher/comments.d.ts +11 -0
  22. package/dist/github/prContentFetcher/commits.d.ts +27 -0
  23. package/dist/github/prContentFetcher/flags.d.ts +21 -0
  24. package/dist/github/prContentFetcher/transform.d.ts +5 -0
  25. package/dist/github/prContentFetcher.d.ts +2 -5
  26. package/dist/github/pullRequestSearch/restSearch.d.ts +6 -0
  27. package/dist/github/pullRequestSearch.d.ts +1 -1
  28. package/dist/github/queryBuilders/base.d.ts +25 -0
  29. package/dist/github/queryBuilders/codeAndRepo.d.ts +20 -0
  30. package/dist/github/queryBuilders/issues.d.ts +42 -0
  31. package/dist/github/queryBuilders/pullRequests.d.ts +13 -0
  32. package/dist/github/queryBuilders.d.ts +4 -12
  33. package/dist/github/releases.d.ts +37 -0
  34. package/dist/github/repoStructure/contentResolution.d.ts +12 -0
  35. package/dist/github/repoStructure/fetchOrchestration.d.ts +7 -0
  36. package/dist/github/repoStructure/resultBuilder.d.ts +22 -0
  37. package/dist/github/repoStructure.d.ts +1 -7
  38. package/dist/github/repoStructureTree.d.ts +38 -0
  39. package/dist/github/responseHeaders.d.ts +2 -0
  40. package/dist/github/searchKeyword.d.ts +2 -0
  41. package/dist/index.d.ts +1 -4
  42. package/dist/index.js +35 -40
  43. package/dist/oql/adapters/github/execute.d.ts +16 -0
  44. package/dist/oql/adapters/github/provider-diagnostics.d.ts +14 -0
  45. package/dist/oql/adapters/github/shared.d.ts +75 -0
  46. package/dist/oql/adapters/github.d.ts +11 -0
  47. package/dist/oql/adapters/graphView/filters.d.ts +25 -0
  48. package/dist/oql/adapters/graphView/nativeEdges.d.ts +5 -0
  49. package/dist/oql/adapters/graphView.d.ts +17 -16
  50. package/dist/oql/adapters/local/code.d.ts +3 -0
  51. package/dist/oql/adapters/local/codeBoolean.d.ts +3 -0
  52. package/dist/oql/adapters/local/fileRowOps.d.ts +11 -0
  53. package/dist/oql/adapters/local/files.d.ts +3 -0
  54. package/dist/oql/adapters/local/filesBoolean.d.ts +10 -0
  55. package/dist/oql/adapters/local/filesContentLeaf.d.ts +12 -0
  56. package/dist/oql/adapters/local/filesUniverse.d.ts +6 -0
  57. package/dist/oql/adapters/local/findToolType.d.ts +10 -0
  58. package/dist/oql/adapters/local/predicates.d.ts +18 -0
  59. package/dist/oql/adapters/local/scope.d.ts +14 -0
  60. package/dist/oql/adapters/local/searchToolType.d.ts +7 -0
  61. package/dist/oql/adapters/local/structureContent.d.ts +6 -0
  62. package/dist/oql/adapters/local/types.d.ts +34 -0
  63. package/dist/oql/adapters/local.d.ts +3 -7
  64. package/dist/oql/adapters/researchTargets/diff.d.ts +16 -0
  65. package/dist/oql/adapters/researchTargets/graph.d.ts +3 -0
  66. package/dist/oql/adapters/researchTargets/history.d.ts +20 -0
  67. package/dist/oql/adapters/researchTargets/pagination.d.ts +54 -0
  68. package/dist/oql/adapters/researchTargets/repositories.d.ts +4 -0
  69. package/dist/oql/adapters/researchTargets/research.d.ts +3 -0
  70. package/dist/oql/adapters/researchTargets/rows.d.ts +16 -0
  71. package/dist/oql/adapters/researchTargets/semantics.d.ts +3 -0
  72. package/dist/oql/adapters/researchTargets/shared.d.ts +11 -0
  73. package/dist/oql/adapters/researchTargets.d.ts +4 -46
  74. package/dist/oql/defaults.d.ts +1 -1
  75. package/dist/oql/index.js +34 -39
  76. package/dist/oql/normalize/batch.d.ts +2 -0
  77. package/dist/oql/normalize/materialize.d.ts +2 -0
  78. package/dist/oql/normalize/params.d.ts +2 -0
  79. package/dist/oql/normalize/query.d.ts +2 -0
  80. package/dist/oql/normalize/scope.d.ts +2 -0
  81. package/dist/oql/normalize/shared.d.ts +7 -0
  82. package/dist/oql/normalize/source.d.ts +2 -0
  83. package/dist/oql/normalize/where.d.ts +2 -0
  84. package/dist/oql/normalize.d.ts +19 -4
  85. package/dist/oql/planner/planDiagnostics.d.ts +13 -0
  86. package/dist/oql/planner/predicateRouting.d.ts +35 -0
  87. package/dist/oql/predicateUtils.d.ts +3 -0
  88. package/dist/oql/research/analyze/manifest-scan.d.ts +4 -0
  89. package/dist/oql/research/analyze/source-graph.d.ts +7 -0
  90. package/dist/oql/research/analyze/symbol-scoring.d.ts +4 -0
  91. package/dist/oql/research/analyze/types.d.ts +163 -0
  92. package/dist/oql/research/analyze/utils.d.ts +16 -0
  93. package/dist/oql/research/analyze.d.ts +2 -133
  94. package/dist/oql/research/packets/builders.d.ts +4 -0
  95. package/dist/oql/research/packets/types.d.ts +91 -0
  96. package/dist/oql/research/packets.d.ts +21 -80
  97. package/dist/oql/run/batch.d.ts +3 -0
  98. package/dist/oql/run/continuations/records.d.ts +19 -0
  99. package/dist/oql/run/continuations/registry.d.ts +22 -0
  100. package/dist/oql/run/continuations/semantics.d.ts +3 -0
  101. package/dist/oql/run/continuations/types.d.ts +12 -0
  102. package/dist/oql/run/dryRun.d.ts +11 -0
  103. package/dist/oql/run/paths.d.ts +15 -0
  104. package/dist/oql/run/proofGrades.d.ts +8 -0
  105. package/dist/oql/run/select.d.ts +10 -0
  106. package/dist/oql/run/single.d.ts +22 -0
  107. package/dist/oql/run.d.ts +4 -31
  108. package/dist/oql/schema/predicates.d.ts +12 -0
  109. package/dist/oql/schema.d.ts +50 -35
  110. package/dist/oql/schemeText.d.ts +10 -13
  111. package/dist/oql/shorthand/predicates.d.ts +15 -0
  112. package/dist/oql/shorthand/query-controls.d.ts +18 -0
  113. package/dist/oql/shorthand/target-params.d.ts +9 -0
  114. package/dist/oql/shorthand/types.d.ts +159 -0
  115. package/dist/oql/shorthand/utils.d.ts +7 -0
  116. package/dist/oql/shorthand.d.ts +2 -171
  117. package/dist/oql/targetParams.d.ts +0 -13
  118. package/dist/oql/transformers/github/code.d.ts +1 -9
  119. package/dist/oql/types/diagnostics.d.ts +22 -0
  120. package/dist/oql/types/envelope.d.ts +78 -0
  121. package/dist/oql/types/guards.d.ts +9 -0
  122. package/dist/oql/types/planner.d.ts +46 -0
  123. package/dist/oql/types/predicates.d.ts +93 -0
  124. package/dist/oql/types/query.d.ts +143 -0
  125. package/dist/oql/types/recordData.d.ts +127 -0
  126. package/dist/oql/types/recordRows.d.ts +48 -0
  127. package/dist/oql/types/results.d.ts +118 -0
  128. package/dist/oql/types/targets.d.ts +22 -0
  129. package/dist/oql/types.d.ts +17 -640
  130. package/dist/providers/github/paginationMetadata.d.ts +12 -0
  131. package/dist/providers/providerResults.d.ts +0 -1
  132. package/dist/schema.js +2 -2
  133. package/dist/scheme/pagination.d.ts +65 -0
  134. package/dist/shared/config/index.js +1 -1
  135. package/dist/shared/credentials/index.js +2 -2
  136. package/dist/shared/credentials/testing.js +1 -1
  137. package/dist/shared/languageSelectors/classify.d.ts +15 -0
  138. package/dist/shared/languageSelectors/data.d.ts +12 -0
  139. package/dist/shared/languageSelectors.d.ts +3 -23
  140. package/dist/shared/paths.d.ts +0 -4
  141. package/dist/shared/paths.js +1 -1
  142. package/dist/shared/session/index.js +1 -1
  143. package/dist/shared/session/statsDefaults.d.ts +1 -2
  144. package/dist/tools/directToolCatalog/toolCatalogDefinitions.d.ts +68 -0
  145. package/dist/tools/directToolCatalog/toolCommandPatternQueries.d.ts +4 -0
  146. package/dist/tools/directToolCatalog/toolCommandPatterns.d.ts +4 -0
  147. package/dist/tools/directToolCatalog/toolInputPreparation.d.ts +12 -0
  148. package/dist/tools/directToolCatalog/toolSchemaIntrospection.d.ts +19 -0
  149. package/dist/tools/directToolCatalog.meta.d.ts +10 -67
  150. package/dist/tools/github_clone_repo/cache.d.ts +1 -5
  151. package/dist/tools/github_clone_repo/cachePaths.d.ts +5 -0
  152. package/dist/tools/github_fetch_content/finalizer/entryParsers.d.ts +9 -0
  153. package/dist/tools/github_fetch_content/finalizer/types.d.ts +101 -0
  154. package/dist/tools/github_fetch_content/finalizer.d.ts +1 -7
  155. package/dist/tools/github_fetch_content/scheme.d.ts +42 -9
  156. package/dist/tools/github_fetch_content/types.d.ts +1 -2
  157. package/dist/tools/github_search_code/execution.d.ts +9 -0
  158. package/dist/tools/github_search_code/finalizer/build.d.ts +4 -0
  159. package/dist/tools/github_search_code/finalizer/groups.d.ts +23 -0
  160. package/dist/tools/github_search_code/finalizer/ranking.d.ts +12 -0
  161. package/dist/tools/github_search_code/finalizer.d.ts +2 -6
  162. package/dist/tools/github_search_code/scheme.d.ts +29 -2
  163. package/dist/tools/github_search_pull_requests/contentResponse/commentsShaping.d.ts +68 -0
  164. package/dist/tools/github_search_pull_requests/contentResponse/fileSurfaces.d.ts +52 -0
  165. package/dist/tools/github_search_pull_requests/contentResponse/nextCalls.d.ts +17 -0
  166. package/dist/tools/github_search_pull_requests/contentResponse/pagination.d.ts +63 -0
  167. package/dist/tools/github_search_pull_requests/contentResponse.d.ts +1 -15
  168. package/dist/tools/github_search_pull_requests/execution/commitsMode.d.ts +4 -0
  169. package/dist/tools/github_search_pull_requests/execution/issuesMode.d.ts +4 -0
  170. package/dist/tools/github_search_pull_requests/execution/pullRequestsMode.d.ts +4 -0
  171. package/dist/tools/github_search_pull_requests/execution/releasesMode.d.ts +4 -0
  172. package/dist/tools/github_search_pull_requests/execution/types.d.ts +6 -0
  173. package/dist/tools/github_search_pull_requests/execution.d.ts +1 -4
  174. package/dist/tools/github_search_pull_requests/scheme.d.ts +11 -1
  175. package/dist/tools/github_search_repos/execution/pagination.d.ts +39 -0
  176. package/dist/tools/github_search_repos/execution/queryVariants.d.ts +38 -0
  177. package/dist/tools/github_search_repos/execution/ranking.d.ts +4 -0
  178. package/dist/tools/github_search_repos/execution.d.ts +3 -71
  179. package/dist/tools/github_search_repos/scheme.d.ts +8 -0
  180. package/dist/tools/github_view_repo_structure/types.d.ts +2 -0
  181. package/dist/tools/local_fetch_content/fetchContent/extraction.d.ts +15 -0
  182. package/dist/tools/local_fetch_content/fetchContent/pagination.d.ts +38 -0
  183. package/dist/tools/local_fetch_content/fetchContent/validation.d.ts +26 -0
  184. package/dist/tools/local_fetch_content/fetchContent.d.ts +2 -0
  185. package/dist/tools/local_fetch_content/scheme.d.ts +25 -1
  186. package/dist/tools/local_find_files/scheme.d.ts +32 -0
  187. package/dist/tools/local_ripgrep/rankingProfile/rankingProfiles.d.ts +70 -0
  188. package/dist/tools/local_ripgrep/rankingProfile/rankingResults.d.ts +47 -0
  189. package/dist/tools/local_ripgrep/rankingProfile/rankingScoring.d.ts +41 -0
  190. package/dist/tools/local_ripgrep/rankingProfile.d.ts +16 -95
  191. package/dist/tools/local_ripgrep/ripgrepResultBuilder/buildResult.d.ts +10 -0
  192. package/dist/tools/local_ripgrep/ripgrepResultBuilder/searchNext.d.ts +46 -0
  193. package/dist/tools/local_ripgrep/ripgrepResultBuilder.d.ts +2 -18
  194. package/dist/tools/local_ripgrep/scheme.d.ts +95 -0
  195. package/dist/tools/local_view_structure/scheme.d.ts +31 -0
  196. package/dist/tools/lsp/semantic_content/scheme.d.ts +61 -0
  197. package/dist/tools/lsp/semantic_content/semanticAnchored.d.ts +7 -0
  198. package/dist/tools/lsp/semantic_content/semanticEnvelopes/callEnvelopes.d.ts +5 -0
  199. package/dist/tools/lsp/semantic_content/semanticEnvelopes/envelopeHelpers.d.ts +20 -0
  200. package/dist/tools/lsp/semantic_content/semanticEnvelopes/locationEnvelopes.d.ts +13 -0
  201. package/dist/tools/lsp/semantic_content/semanticEnvelopes.d.ts +3 -0
  202. package/dist/tools/lsp/semantic_content/semanticFileOps/anchor.d.ts +24 -0
  203. package/dist/tools/lsp/semantic_content/semanticFileOps/documentSymbols.d.ts +27 -0
  204. package/dist/tools/lsp/semantic_content/semanticFileOps/workspaceSymbolsAndDiagnostics.d.ts +20 -0
  205. package/dist/tools/lsp/semantic_content/semanticFileOps.d.ts +8 -0
  206. package/dist/tools/lsp/semantic_content/semanticPresentation.d.ts +53 -0
  207. package/dist/tools/lsp/shared/semanticTypes.d.ts +6 -0
  208. package/dist/tools/package_search/execution.d.ts +8 -0
  209. package/dist/tools/package_search/scheme.d.ts +43 -2
  210. package/dist/tools/providerMappers/codeSearch.d.ts +66 -0
  211. package/dist/tools/providerMappers/fileContent.d.ts +28 -0
  212. package/dist/tools/providerMappers/pullRequests.d.ts +158 -0
  213. package/dist/tools/providerMappers/repoSearch.d.ts +30 -0
  214. package/dist/tools/providerMappers/repoStructure.d.ts +20 -0
  215. package/dist/tools/providerMappers/shared.d.ts +23 -0
  216. package/dist/tools/providerMappers.d.ts +9 -294
  217. package/dist/tools/toolConfig.d.ts +0 -2
  218. package/dist/tools/toolMetadata/descriptionOverrides.d.ts +4 -0
  219. package/dist/tools/toolSchemaImports.d.ts +13 -0
  220. package/dist/utils/contextUtils.d.ts +5 -16
  221. package/dist/utils/core/types.d.ts +2 -24
  222. package/dist/utils/exec/spawn/env.d.ts +5 -0
  223. package/dist/utils/exec/spawn/wrappers.d.ts +29 -0
  224. package/dist/utils/exec/spawn.d.ts +2 -34
  225. package/dist/utils/file/toolHelpers.d.ts +12 -0
  226. package/dist/utils/http/cache/conditional.d.ts +21 -0
  227. package/dist/utils/http/cache/dataCache.d.ts +6 -0
  228. package/dist/utils/http/cache/key.d.ts +1 -0
  229. package/dist/utils/http/cache/management.d.ts +9 -0
  230. package/dist/utils/http/cache/store.d.ts +28 -0
  231. package/dist/utils/http/cache.d.ts +4 -16
  232. package/dist/utils/markdownOutline.d.ts +0 -2
  233. package/dist/utils/package/npm/npmDeprecation.d.ts +5 -0
  234. package/dist/utils/package/npm/npmDetailsFetchers.d.ts +15 -0
  235. package/dist/utils/package/npm/npmMappers.d.ts +12 -0
  236. package/dist/utils/package/npm/npmRegistry.d.ts +79 -0
  237. package/dist/utils/package/npm/npmSearchStrategies.d.ts +6 -0
  238. package/dist/utils/package/npm.d.ts +2 -8
  239. package/dist/utils/pagination/boundary.d.ts +5 -5
  240. package/dist/utils/response/bulk/pagination.d.ts +6 -0
  241. package/dist/utils/response/bulk/queries.d.ts +19 -0
  242. package/dist/utils/response/bulk/response.d.ts +4 -0
  243. package/dist/utils/response/bulk.d.ts +2 -6
  244. package/package.json +42 -35
  245. package/dist/tools/local_binary_inspect/archiveOps.d.ts +0 -24
  246. package/dist/tools/local_binary_inspect/binaryInspector.d.ts +0 -86
  247. package/dist/tools/local_binary_inspect/binaryOps.d.ts +0 -27
  248. package/dist/tools/local_binary_inspect/decompressOps.d.ts +0 -16
  249. package/dist/tools/local_binary_inspect/execution.d.ts +0 -4
  250. package/dist/tools/local_binary_inspect/scheme.d.ts +0 -144
  251. package/dist/tools/local_ripgrep/lspBoost.d.ts +0 -54
  252. package/dist/utils/parsers/ripgrep.d.ts +0 -11
@@ -21,9 +21,7 @@ export declare const paths: {
21
21
  readonly tmp: string;
22
22
  readonly clone: string;
23
23
  readonly tree: string;
24
- readonly binary: string;
25
24
  readonly repos: string;
26
- readonly unzip: string;
27
25
  readonly cliConfig: string;
28
26
  readonly lspConfig: string;
29
27
  };
@@ -32,5 +30,3 @@ export declare function ensureRepos(): void;
32
30
  export declare function ensureTmp(): void;
33
31
  export declare function ensureClone(): void;
34
32
  export declare function ensureTree(): void;
35
- export declare function ensureBinary(): void;
36
- export declare function ensureUnzip(): void;
@@ -5,4 +5,4 @@ import { dirname as __dirname_fn } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __dirname_fn(__filename);
8
- import{existsSync as r,mkdirSync as i}from"node:fs";import{join as t}from"node:path";import T from"node:fs";import _ from"node:path";import p from"node:os";import n from"node:path";import{existsSync as L,readFileSync as R}from"node:fs";import S from"node:path";function d(c=process.env){let u=c.OCTOCODE_HOME;if(u&&u.trim())return n.resolve(u.trim());let l=p.homedir(),f=p.platform();if(f==="win32"){let h=c.APPDATA??n.join(l,"AppData","Roaming");return n.join(h,".octocode")}if(f==="darwin")return n.join(l,".octocode");let v=c.XDG_CONFIG_HOME??n.join(l,".config");return n.join(v,".octocode")}var s=448;function m(){return d(process.env)}function M(){return e}var e=m(),o={home:e,config:t(e,".octocoderc"),credentials:t(e,"credentials.json"),key:t(e,".key"),session:t(e,"session.json"),stats:t(e,"stats.json"),tmp:t(e,"tmp"),clone:t(e,"tmp","clone"),tree:t(e,"tmp","tree"),binary:t(e,"tmp","binary"),repos:t(e,"tmp","clone"),unzip:t(e,"tmp","unzip"),cliConfig:t(e,"config.json"),lspConfig:t(e,"lsp-servers.json")};function O(){r(o.home)||i(o.home,{recursive:!0,mode:s})}function I(){E()}function a(){O(),r(o.tmp)||i(o.tmp,{recursive:!0,mode:s})}function E(){a(),r(o.clone)||i(o.clone,{recursive:!0,mode:s})}function D(){a(),r(o.tree)||i(o.tree,{recursive:!0,mode:s})}function j(){a(),r(o.binary)||i(o.binary,{recursive:!0,mode:s})}function F(){a(),r(o.unzip)||i(o.unzip,{recursive:!0,mode:s})}export{e as OCTOCODE_HOME,j as ensureBinary,E as ensureClone,O as ensureHome,I as ensureRepos,a as ensureTmp,D as ensureTree,F as ensureUnzip,m as getDefaultOctocodeHome,M as getOctocodeDir,o as paths};
8
+ import{existsSync as r,mkdirSync as n}from"node:fs";import{join as o}from"node:path";import{getOctocodeHome as c}from"@octocodeai/config";var s=448;function p(){return c(process.env)}function v(){return e}var e=p(),t={home:e,config:o(e,".octocoderc"),credentials:o(e,"credentials.json"),key:o(e,".key"),session:o(e,"session.json"),stats:o(e,"stats.json"),tmp:o(e,"tmp"),clone:o(e,"tmp","clone"),tree:o(e,"tmp","tree"),repos:o(e,"tmp","clone"),cliConfig:o(e,"config.json"),lspConfig:o(e,"lsp-servers.json")};function m(){r(t.home)||n(t.home,{recursive:!0,mode:s})}function x(){u()}function i(){m(),r(t.tmp)||n(t.tmp,{recursive:!0,mode:s})}function u(){i(),r(t.clone)||n(t.clone,{recursive:!0,mode:s})}function g(){i(),r(t.tree)||n(t.tree,{recursive:!0,mode:s})}export{e as OCTOCODE_HOME,u as ensureClone,m as ensureHome,x as ensureRepos,i as ensureTmp,g as ensureTree,p as getDefaultOctocodeHome,v as getOctocodeDir,t as paths};
@@ -5,4 +5,4 @@ import { dirname as __dirname_fn } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __dirname_fn(__filename);
8
- import{randomUUID as it}from"node:crypto";import{existsSync as $,readFileSync as Te,writeFileSync as Ye,unlinkSync as Qe,renameSync as Ze}from"node:fs";function m(e){return e.toLowerCase().replace(/^https?:\/\//,"").replace(/\/$/,"")}function O(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 G(e){if(!e.token.refreshTokenExpiresAt)return!1;let t=new Date(e.token.refreshTokenExpiresAt);return isNaN(t.getTime())?!0:new Date>=t}var x=new Map,Ee=300*1e3;function Oe(e){let t=m(e),r=x.get(t);return!r||Date.now()-r.cachedAt>=Ee?!1:r.credentials?!O(r.credentials):!0}function X(e){e?x.delete(m(e)):x.clear()}function q(e){let t=m(e);if(Oe(t))return x.get(t).credentials}function Y(e,t){let r=m(e);x.set(r,{credentials:t,cachedAt:Date.now()})}import{existsSync as re,readFileSync as ne,writeFileSync as se,unlinkSync as qt,statSync as Fe,chmodSync as Ie}from"node:fs";import{createCipheriv as De,createDecipheriv as He,randomBytes as oe}from"node:crypto";import{existsSync as xe,mkdirSync as Ae}from"node:fs";import{join as u}from"node:path";import Pt from"node:fs";import It from"node:path";import Q from"node:os";import T from"node:path";import{existsSync as Nt,readFileSync as Mt}from"node:fs";import Gt from"node:path";function Z(e=process.env){let t=e.OCTOCODE_HOME;if(t&&t.trim())return T.resolve(t.trim());let r=Q.homedir(),n=Q.platform();if(n==="win32"){let i=e.APPDATA??T.join(r,"AppData","Roaming");return T.join(i,".octocode")}if(n==="darwin")return T.join(r,".octocode");let s=e.XDG_CONFIG_HOME??T.join(r,".config");return T.join(s,".octocode")}var _e=448;function we(){return Z(process.env)}var c=we(),f={home:c,config:u(c,".octocoderc"),credentials:u(c,"credentials.json"),key:u(c,".key"),session:u(c,"session.json"),stats:u(c,"stats.json"),tmp:u(c,"tmp"),clone:u(c,"tmp","clone"),tree:u(c,"tmp","tree"),binary:u(c,"tmp","binary"),repos:u(c,"tmp","clone"),unzip:u(c,"tmp","unzip"),cliConfig:u(c,"config.json"),lspConfig:u(c,"lsp-servers.json")};function ee(){xe(f.home)||Ae(f.home,{recursive:!0,mode:_e})}import{z as a}from"zod";var Le=a.object({token:a.string(),tokenType:a.literal("oauth"),scopes:a.array(a.string()).optional(),refreshToken:a.string().optional(),expiresAt:a.string().optional(),refreshTokenExpiresAt:a.string().optional()}),Pe=a.object({hostname:a.string(),username:a.string(),token:Le,gitProtocol:a.enum(["ssh","https"]),createdAt:a.string(),updatedAt:a.string()}),te=a.object({version:a.number(),credentials:a.record(a.string(),Pe)});var Ue=f.home,D=f.credentials,C=f.key,ie="aes-256-gcm",Ne=16;function y(){ee()}function ae(){if(y(),re(C))return Fe(C).mode&511&63&&Ie(C,384),Buffer.from(ne(C,"utf8"),"hex");let e=oe(32);return se(C,e.toString("hex"),{mode:384}),e}function ce(e){let t=ae(),r=oe(Ne),n=De(ie,t,r),s=n.update(e,"utf8","hex");s+=n.final("hex");let i=n.getAuthTag();return`${r.toString("hex")}:${i.toString("hex")}:${s}`}function ue(e){let t=ae(),[r,n,s]=e.split(":");if(!r||!n||!s)throw new Error("Invalid encrypted data format");let i=Buffer.from(r,"hex"),v=Buffer.from(n,"hex"),h=He(ie,t,i);h.setAuthTag(v);let J=h.update(s,"hex","utf8");return J+=h.final("utf8"),J}function B(){if(y(),!re(D))return{version:1,credentials:{}};try{let e=ne(D,"utf8"),t=ue(e),r=JSON.parse(t),n=te.safeParse(r);return n.success?n.data:{version:1,credentials:{}}}catch{return{version:1,credentials:{}}}}function le(e){y();let t=ce(JSON.stringify(e,null,2));se(D,t,{mode:384})}import{refreshToken as Me}from"@octokit/oauth-methods";import{request as je}from"@octokit/request";var H="178c6fc778ccc68e1d6a",A="github.com";function Ge(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 Be(e){return e==="github.com"||e===A?"https://api.github.com":`https://${e}/api/v3`}async function fe(e,t=A,r=H){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(G(n))return{success:!1,error:"Refresh token has expired. Please login again."};try{let s=await Me({clientType:"github-app",clientId:r,clientSecret:"",refreshToken:n.token.refreshToken,request:je.defaults({baseUrl:Be(t)})}),i={token:s.authentication.token,tokenType:"oauth",refreshToken:s.authentication.refreshToken,expiresAt:s.authentication.expiresAt,refreshTokenExpiresAt:s.authentication.refreshTokenExpiresAt};return await e.updateToken(t,i),{success:!0,username:n.username,hostname:t}}catch(s){return{success:!1,error:s instanceof Error?Ge(s.message):"Token refresh failed"}}}async function de(e,t=A,r=H){let n=await e.getCredentials(t);if(!n||!n.token)return{token:null,source:"none"};if(!O(n))return{token:n.token.token,source:"stored",username:n.username};if(n.token.refreshToken){let s=await fe(e,t,r);if(s.success){let i=await e.getCredentials(t);if(i?.token.token)return{token:i.token.token,source:"refreshed",username:i.username}}return{token:null,source:"none",refreshError:s.error}}return{token:null,source:"none",refreshError:"Token expired and no refresh token available"}}import{execFile as cr}from"child_process";var $e=null;function pe(e){$e=e}async function We(e){let t=m(e.hostname),r={...e,hostname:t,updatedAt:new Date().toISOString()};try{let n=B();return n.credentials[t]=r,le(n),X(t),{success:!0}}catch{throw new Error("Failed to store credentials")}}async function he(e="github.com",t){let r=m(e);if(!t?.bypassCache){let i=q(r);if(i!==void 0)return i}let s=B().credentials[r]||null;return Y(r,s),s}async function ze(e,t){let r=await he(e);return r?(r.token=t,r.updatedAt=new Date().toISOString(),await We(r),!0):!1}async function Ke(e,t){return de({getCredentials:he,updateToken:ze},e,t)}pe({getTokenWithRefresh:Ke});import{z as o}from"zod";var Ve=o.object({rawChars:o.number(),responseChars:o.number(),savedChars:o.number(),calls:o.number()}),Je=o.object({hits:o.record(o.string(),o.number()).default({}),rateLimits:o.number().default(0)}),U=o.record(o.string(),o.number()).default({}),Xe=o.object({toolCalls:o.number(),errors:o.number(),rateLimits:o.number(),rateLimitsByProvider:U,rawChars:o.number(),responseChars:o.number(),savedChars:o.number(),charSavingsCalls:o.number(),githubCacheHits:o.number(),githubCacheRateLimits:o.number(),packageRegistryFailures:o.number().default(0),packageRegistryFailuresByRegistry:U}),N=o.object({toolCalls:o.number(),errors:o.number(),rateLimits:o.number(),rateLimitsByProvider:U,charsSavedByTool:o.record(o.string(),Ve).default({}),githubCacheHits:Je.default({hits:{},rateLimits:0}),packageRegistryFailures:U,totalUsage:Xe.optional()}),me=o.object({version:o.literal(1),sessionId:o.string(),createdAt:o.string(),lastActiveAt:o.string(),stats:N.optional()}),ge=o.object({version:o.literal(1),stats:N});function Se(e){return Object.values(e).reduce((t,r)=>t+r,0)}function qe(e){let t=e.charsSavedByTool??{},r=e.githubCacheHits??{hits:{},rateLimits:0},n=e.rateLimitsByProvider??{},s=e.packageRegistryFailures??{},i=Object.values(t).reduce((v,h)=>({rawChars:v.rawChars+h.rawChars,responseChars:v.responseChars+h.responseChars,savedChars:v.savedChars+h.savedChars,charSavingsCalls:v.charSavingsCalls+h.calls}),{rawChars:0,responseChars:0,savedChars:0,charSavingsCalls:0});return{toolCalls:e.toolCalls,errors:e.errors,rateLimits:e.rateLimits,rateLimitsByProvider:n,...i,githubCacheHits:Se(r.hits),githubCacheRateLimits:r.rateLimits,packageRegistryFailures:Se(s),packageRegistryFailuresByRegistry:s}}function d(e){let t={...e,rateLimitsByProvider:e.rateLimitsByProvider??{},charsSavedByTool:e.charsSavedByTool??{},githubCacheHits:e.githubCacheHits??{hits:{},rateLimits:0},packageRegistryFailures:e.packageRegistryFailures??{}};return{...t,totalUsage:qe(t)}}function _(){return d({toolCalls:0,errors:0,rateLimits:0,rateLimitsByProvider:{},charsSavedByTool:{},githubCacheHits:{hits:{},rateLimits:0},packageRegistryFailures:{}})}var k=f.session,b=f.stats;function ve(e,t){let r=`${e}.tmp`;Ye(r,JSON.stringify(t,null,2),{mode:384}),Ze(r,e)}function et(e){let{stats:t,...r}=e;return r}function tt(e){let t=JSON.parse(e),r=ge.safeParse(t);if(r.success)return d(r.data.stats);let n=N.safeParse(t);return n.success?d(n.data):null}function rt(e){let t=e?d(e):_();if(!$(b))return t;try{let r=Te(b,"utf8"),n=tt(r);return n||t}catch{return t}}function M(e){y(),ve(b,{version:e.version,stats:d(e.stats)}),ve(k,et(e))}function Ce(){if(!$(k))return null;try{let e=Te(k,"utf8"),t=JSON.parse(e),r=me.safeParse(t);return r.success?{...r.data,stats:rt(r.data.stats)}:null}catch{return null}}function ye(){let e=!1;for(let t of[k,b])if($(t))try{Qe(t),e=!0}catch{return!1}return e}var nt=6e4,l=null,g=!1,R=null,W=!1,w=null,L=null,P=null,j=!1;function st(){W||(W=!0,w=()=>{F()},L=()=>{F()},P=()=>{F()},process.on("exit",w),process.on("SIGINT",L),process.on("SIGTERM",P))}function z(){w&&(process.removeListener("exit",w),w=null),L&&(process.removeListener("SIGINT",L),L=null),P&&(process.removeListener("SIGTERM",P),P=null),W=!1}function ot(){R||(R=setInterval(()=>{g&&l&&(M(l),g=!1)},nt),R.unref())}function K(){R&&(clearInterval(R),R=null)}function E(){if(l)return l;let e=Ce();return e&&(l=e),e}function S(e){l=e,g=!0,st(),ot()}function I(){g&&l&&(M(l),g=!1)}function F(){if(!j&&g&&l){j=!0;try{M(l),g=!1}catch{}finally{j=!1}}}function V(){l=null,g=!1,j=!1}function ke(){V(),K(),z()}var at=1;function ct(e){return d(e)}function ut(e,t){if(!t)return e;let r={...e};for(let[n,s]of Object.entries(t)){let i=r[n]??{rawChars:0,responseChars:0,savedChars:0,calls:0};r[n]={rawChars:i.rawChars+s.rawChars,responseChars:i.responseChars+s.responseChars,savedChars:i.savedChars+s.savedChars,calls:i.calls+s.calls}}return r}function be(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 lt(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 Re(){let e=new Date().toISOString();return{version:at,sessionId:it(),createdAt:e,lastActiveAt:e,stats:_()}}function ft(){return E()}function dt(e){S(e)}function pt(){I()}function ht(){F()}function mt(e){if(e?.forceNew){let n=Re();return S(n),I(),n}let t=E();if(t){let n={...t,lastActiveAt:new Date().toISOString()};return S(n),I(),n}let r=Re();return S(r),I(),r}function gt(){return E()?.sessionId??null}function p(e){let t=E();if(!t)return{success:!1,session:null};let r=ct(t.stats),n=d({toolCalls:r.toolCalls+(e.toolCalls??0),errors:r.errors+(e.errors??0),rateLimits:r.rateLimits+(e.rateLimits??0),rateLimitsByProvider:be(r.rateLimitsByProvider,e.rateLimitsByProvider),charsSavedByTool:ut(r.charsSavedByTool,e.charsSavedByTool),githubCacheHits:lt(r.githubCacheHits,e.githubCacheHits),packageRegistryFailures:be(r.packageRegistryFailures,e.packageRegistryFailures)}),s={...t,lastActiveAt:new Date().toISOString(),stats:n};return S(s),{success:!0,session:s}}function St(e=1){return p({toolCalls:e})}function vt(e=1){return p({errors:e})}function Tt(e=1){return p({rateLimits:e})}function Ct(e,t=1){return p({rateLimits:t,rateLimitsByProvider:{[e]:t}})}function yt(e,t,r){let n=Number.isFinite(t)?Math.max(0,t):0,s=Number.isFinite(r)?Math.max(0,r):0;return p({charsSavedByTool:{[e]:{rawChars:n,responseChars:s,savedChars:Math.max(0,n-s),calls:1}}})}function kt(e,t=1){return p({githubCacheHits:{hits:{[e]:t},rateLimits:0}})}function bt(e=1){return p({githubCacheHits:{hits:{},rateLimits:e}})}function Rt(e,t=1){return p({packageRegistryFailures:{[e]:t}})}function Et(){let e=E();if(!e)return{success:!1,session:null};let t={...e,lastActiveAt:new Date().toISOString(),stats:_()};return S(t),{success:!0,session:t}}function Ot(){return V(),K(),z(),ye()}function xt(){ke()}export{k as SESSION_FILE,b as STATS_FILE,xt as _resetSessionState,Ot as deleteSession,pt as flushSession,ht as flushSessionSync,mt as getOrCreateSession,gt as getSessionId,vt as incrementErrors,kt as incrementGitHubCacheHits,bt as incrementGitHubCacheRateLimits,Rt as incrementPackageRegistryFailures,Ct as incrementRateLimitByProvider,Tt as incrementRateLimits,St as incrementToolCalls,yt as incrementToolCharSavings,ft as readSession,Et as resetSessionStats,p as updateSessionStats,dt as writeSession};
8
+ import{randomUUID as nt}from"node:crypto";import{existsSync as M,readFileSync as Se,writeFileSync as Ye,unlinkSync as Ze,renameSync as Qe}from"node:fs";import{isStatsEnabled as ge}from"@octocodeai/config";function p(e){return e.toLowerCase().replace(/^https?:\/\//,"").replace(/\/$/,"")}function w(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 B(e){if(!e.token.refreshTokenExpiresAt)return!1;let t=new Date(e.token.refreshTokenExpiresAt);return isNaN(t.getTime())?!0:new Date>=t}var P=new Map,ve=300*1e3;function Re(e){let t=p(e),r=P.get(t);return!r||Date.now()-r.cachedAt>=ve?!1:r.credentials?!w(r.credentials):!0}function q(e){e?P.delete(p(e)):P.clear()}function V(e){let t=p(e);if(Re(t))return P.get(t).credentials}function Y(e,t){let r=p(e);P.set(r,{credentials:t,cachedAt:Date.now()})}import{existsSync as X,readFileSync as ee,writeFileSync as te,unlinkSync as _t,statSync as He,chmodSync as Oe}from"node:fs";import{createCipheriv as De,createDecipheriv as Ie,randomBytes as re}from"node:crypto";import{existsSync as be,mkdirSync as we}from"node:fs";import{join as u}from"node:path";import{getOctocodeHome as Pe}from"@octocodeai/config";var Ee=448;function Ae(){return Pe(process.env)}var c=Ae(),d={home:c,config:u(c,".octocoderc"),credentials:u(c,"credentials.json"),key:u(c,".key"),session:u(c,"session.json"),stats:u(c,"stats.json"),tmp:u(c,"tmp"),clone:u(c,"tmp","clone"),tree:u(c,"tmp","tree"),repos:u(c,"tmp","clone"),cliConfig:u(c,"config.json"),lspConfig:u(c,"lsp-servers.json")};function Z(){be(d.home)||we(d.home,{recursive:!0,mode:Ee})}import{z as a}from"zod";var Le=a.object({token:a.string(),tokenType:a.literal("oauth"),scopes:a.array(a.string()).optional(),refreshToken:a.string().optional(),expiresAt:a.string().optional(),refreshTokenExpiresAt:a.string().optional()}),Fe=a.object({hostname:a.string(),username:a.string(),token:Le,gitProtocol:a.enum(["ssh","https"]),createdAt:a.string(),updatedAt:a.string()}),Q=a.object({version:a.number(),credentials:a.record(a.string(),Fe)});var _e=d.home,D=d.credentials,T=d.key,se="aes-256-gcm",Ge=16;function y(){Z()}function ne(){if(y(),X(T))return He(T).mode&511&63&&Oe(T,384),Buffer.from(ee(T,"utf8"),"hex");let e=re(32);return te(T,e.toString("hex"),{mode:384}),e}function oe(e){let t=ne(),r=re(Ge),s=De(se,t,r),n=s.update(e,"utf8","hex");n+=s.final("hex");let i=s.getAuthTag();return`${r.toString("hex")}:${i.toString("hex")}:${n}`}function ie(e){let t=ne(),[r,s,n]=e.split(":");if(!r||!s||!n)throw new Error("Invalid encrypted data format");let i=Buffer.from(r,"hex"),k=Buffer.from(s,"hex"),h=Ie(se,t,i);h.setAuthTag(k);let J=h.update(n,"hex","utf8");return J+=h.final("utf8"),J}function N(){if(y(),!X(D))return{version:1,credentials:{}};try{let e=ee(D,"utf8"),t=ie(e),r=JSON.parse(t),s=Q.safeParse(r);return s.success?s.data:{version:1,credentials:{}}}catch{return{version:1,credentials:{}}}}function ae(e){y();let t=oe(JSON.stringify(e,null,2));te(D,t,{mode:384})}import{refreshToken as Ue}from"@octokit/oauth-methods";import{request as je}from"@octokit/request";var I="178c6fc778ccc68e1d6a",E="github.com";function Be(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 Ne(e){return e==="github.com"||e===E?"https://api.github.com":`https://${e}/api/v3`}async function ce(e,t=E,r=I){let s=await e.getCredentials(t);if(!s)return{success:!1,error:`Not logged in to ${t}`};if(!s.token.refreshToken)return{success:!1,error:"Token does not support refresh (OAuth App tokens do not expire)"};if(B(s))return{success:!1,error:"Refresh token has expired. Please login again."};try{let n=await Ue({clientType:"github-app",clientId:r,clientSecret:"",refreshToken:s.token.refreshToken,request:je.defaults({baseUrl:Ne(t)})}),i={token:n.authentication.token,tokenType:"oauth",refreshToken:n.authentication.refreshToken,expiresAt:n.authentication.expiresAt,refreshTokenExpiresAt:n.authentication.refreshTokenExpiresAt};return await e.updateToken(t,i),{success:!0,username:s.username,hostname:t}}catch(n){return{success:!1,error:n instanceof Error?Be(n.message):"Token refresh failed"}}}async function ue(e,t=E,r=I){let s=await e.getCredentials(t);if(!s||!s.token)return{token:null,source:"none"};if(!w(s))return{token:s.token.token,source:"stored",username:s.username};if(s.token.refreshToken){let n=await ce(e,t,r);if(n.success){let i=await e.getCredentials(t);if(i?.token.token)return{token:i.token.token,source:"refreshed",username:i.username}}return{token:null,source:"none",refreshError:n.error}}return{token:null,source:"none",refreshError:"Token expired and no refresh token available"}}import{resolveEnvToken as Qt}from"@octocodeai/config";import{execFile as qt}from"child_process";var Me=null;function le(e){Me=e}async function ze(e){let t=p(e.hostname),r={...e,hostname:t,updatedAt:new Date().toISOString()};try{let s=N();return s.credentials[t]=r,ae(s),q(t),{success:!0}}catch{throw new Error("Failed to store credentials")}}async function de(e="github.com",t){let r=p(e);if(!t?.bypassCache){let i=V(r);if(i!==void 0)return i}let n=N().credentials[r]||null;return Y(r,n),n}async function We(e,t){let r=await de(e);return r?(r.token=t,r.updatedAt=new Date().toISOString(),await ze(r),!0):!1}async function $e(e,t){return ue({getCredentials:de,updateToken:We},e,t)}le({getTokenWithRefresh:$e});import{z as o}from"zod";var Ke=o.object({rawChars:o.number(),responseChars:o.number(),savedChars:o.number(),calls:o.number()}),Je=o.object({hits:o.record(o.string(),o.number()).default({}),rateLimits:o.number().default(0)}),_=o.record(o.string(),o.number()).default({}),qe=o.object({toolCalls:o.number(),errors:o.number(),rateLimits:o.number(),rateLimitsByProvider:_,rawChars:o.number(),responseChars:o.number(),savedChars:o.number(),charSavingsCalls:o.number(),githubCacheHits:o.number(),githubCacheRateLimits:o.number(),packageRegistryFailures:o.number().default(0),packageRegistryFailuresByRegistry:_}),G=o.object({toolCalls:o.number(),errors:o.number(),rateLimits:o.number(),rateLimitsByProvider:_,charsSavedByTool:o.record(o.string(),Ke).default({}),githubCacheHits:Je.default({hits:{},rateLimits:0}),packageRegistryFailures:_,totalUsage:qe.optional()}),fe=o.object({version:o.literal(1),sessionId:o.string(),createdAt:o.string(),lastActiveAt:o.string(),stats:G.optional()}),he=o.object({version:o.literal(1),stats:G});function pe(e){return Object.values(e).reduce((t,r)=>t+r,0)}function Ve(e){let t=e.charsSavedByTool??{},r=e.githubCacheHits??{hits:{},rateLimits:0},s=e.rateLimitsByProvider??{},n=e.packageRegistryFailures??{},i=Object.values(t).reduce((k,h)=>({rawChars:k.rawChars+h.rawChars,responseChars:k.responseChars+h.responseChars,savedChars:k.savedChars+h.savedChars,charSavingsCalls:k.charSavingsCalls+h.calls}),{rawChars:0,responseChars:0,savedChars:0,charSavingsCalls:0});return{toolCalls:e.toolCalls,errors:e.errors,rateLimits:e.rateLimits,rateLimitsByProvider:s,...i,githubCacheHits:pe(r.hits),githubCacheRateLimits:r.rateLimits,packageRegistryFailures:pe(n),packageRegistryFailuresByRegistry:n}}function m(e){let t={...e,rateLimitsByProvider:e.rateLimitsByProvider??{},charsSavedByTool:e.charsSavedByTool??{},githubCacheHits:e.githubCacheHits??{hits:{},rateLimits:0},packageRegistryFailures:e.packageRegistryFailures??{}};return{...t,totalUsage:Ve(t)}}function S(){return m({toolCalls:0,errors:0,rateLimits:0,rateLimitsByProvider:{},charsSavedByTool:{},githubCacheHits:{hits:{},rateLimits:0},packageRegistryFailures:{}})}var x=d.session,v=d.stats;function me(e,t){let r=`${e}.tmp`;Ye(r,JSON.stringify(t,null,2),{mode:384}),Qe(r,e)}function Xe(e){let t=JSON.parse(e),r=he.safeParse(t);if(r.success)return m(r.data.stats);let s=G.safeParse(t);return s.success?m(s.data):null}function et(){if(!M(v))return S();try{let e=Se(v,"utf8");return Xe(e)??S()}catch{return S()}}function U(e){y(),ge()&&me(v,{version:e.version,stats:m(e.stats)});let{stats:t,...r}=e;me(x,r)}function Ce(){if(!M(x))return null;try{let e=Se(x,"utf8"),t=JSON.parse(e),r=fe.safeParse(t);return r.success?{...r.data,stats:ge()?et():S()}:null}catch{return null}}function ke(){let e=!1;for(let t of[x,v])if(M(t))try{Ze(t),e=!0}catch{return!1}return e}var tt=6e4,l=null,g=!1,R=null,z=!1,A=null,L=null,F=null,j=!1;function rt(){z||(z=!0,A=()=>{H()},L=()=>{H()},F=()=>{H()},process.on("exit",A),process.on("SIGINT",L),process.on("SIGTERM",F))}function W(){A&&(process.removeListener("exit",A),A=null),L&&(process.removeListener("SIGINT",L),L=null),F&&(process.removeListener("SIGTERM",F),F=null),z=!1}function st(){R||(R=setInterval(()=>{g&&l&&(U(l),g=!1)},tt),R.unref())}function $(){R&&(clearInterval(R),R=null)}function b(){if(l)return l;let e=Ce();return e&&(l=e),e}function C(e){l=e,g=!0,rt(),st()}function O(){g&&l&&(U(l),g=!1)}function H(){if(!j&&g&&l){j=!0;try{U(l),g=!1}catch{}finally{j=!1}}}function K(){l=null,g=!1,j=!1}function Te(){K(),$(),W()}var ot=1;function it(e){return m(e)}function at(e,t){if(!t)return e;let r={...e};for(let[s,n]of Object.entries(t)){let i=r[s]??{rawChars:0,responseChars:0,savedChars:0,calls:0};r[s]={rawChars:i.rawChars+n.rawChars,responseChars:i.responseChars+n.responseChars,savedChars:i.savedChars+n.savedChars,calls:i.calls+n.calls}}return r}function ye(e,t){if(!t)return e;let r={...e};for(let[s,n]of Object.entries(t))r[s]=(r[s]??0)+n;return r}function ct(e,t){if(!t)return e;let r={...e.hits};for(let[s,n]of Object.entries(t.hits??{}))r[s]=(r[s]??0)+n;return{hits:r,rateLimits:e.rateLimits+(t.rateLimits??0)}}function xe(){let e=new Date().toISOString();return{version:ot,sessionId:nt(),createdAt:e,lastActiveAt:e,stats:S()}}function ut(){return b()}function lt(e){C(e)}function dt(){O()}function ft(){H()}function ht(e){if(e?.forceNew){let s=xe();return C(s),O(),s}let t=b();if(t){let s={...t,lastActiveAt:new Date().toISOString()};return C(s),O(),s}let r=xe();return C(r),O(),r}function pt(){return b()?.sessionId??null}function f(e){let t=b();if(!t)return{success:!1,session:null};let r=it(t.stats),s=m({toolCalls:r.toolCalls+(e.toolCalls??0),errors:r.errors+(e.errors??0),rateLimits:r.rateLimits+(e.rateLimits??0),rateLimitsByProvider:ye(r.rateLimitsByProvider,e.rateLimitsByProvider),charsSavedByTool:at(r.charsSavedByTool,e.charsSavedByTool),githubCacheHits:ct(r.githubCacheHits,e.githubCacheHits),packageRegistryFailures:ye(r.packageRegistryFailures,e.packageRegistryFailures)}),n={...t,lastActiveAt:new Date().toISOString(),stats:s};return C(n),{success:!0,session:n}}function mt(e=1){return f({toolCalls:e})}function St(e=1){return f({errors:e})}function gt(e=1){return f({rateLimits:e})}function Ct(e,t=1){return f({rateLimits:t,rateLimitsByProvider:{[e]:t}})}function kt(e,t,r){let s=Number.isFinite(t)?Math.max(0,t):0,n=Number.isFinite(r)?Math.max(0,r):0;return f({charsSavedByTool:{[e]:{rawChars:s,responseChars:n,savedChars:Math.max(0,s-n),calls:1}}})}function Tt(e,t=1){return f({githubCacheHits:{hits:{[e]:t},rateLimits:0}})}function yt(e=1){return f({githubCacheHits:{hits:{},rateLimits:e}})}function xt(e,t=1){return f({packageRegistryFailures:{[e]:t}})}function vt(){let e=b();if(!e)return{success:!1,session:null};let t={...e,lastActiveAt:new Date().toISOString(),stats:S()};return C(t),{success:!0,session:t}}function Rt(){return K(),$(),W(),ke()}function bt(){Te()}export{x as SESSION_FILE,v as STATS_FILE,bt as _resetSessionState,Rt as deleteSession,dt as flushSession,ft as flushSessionSync,ht as getOrCreateSession,pt as getSessionId,St as incrementErrors,Tt as incrementGitHubCacheHits,yt as incrementGitHubCacheRateLimits,xt as incrementPackageRegistryFailures,Ct as incrementRateLimitByProvider,gt as incrementRateLimits,mt as incrementToolCalls,kt as incrementToolCharSavings,ut as readSession,vt as resetSessionStats,f as updateSessionStats,lt as writeSession};
@@ -1,4 +1,3 @@
1
- import type { SessionStats, SessionTotalUsageStats } from './types.js';
2
- export declare function calculateTotalUsageStats(stats: SessionStats): SessionTotalUsageStats;
1
+ import type { SessionStats } from './types.js';
3
2
  export declare function withDerivedUsageTotals(stats: SessionStats): SessionStats;
4
3
  export declare function createDefaultStats(): SessionStats;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Engine-free direct-tool catalog: registry of tool definitions (name +
3
+ * display/bulk zod schemas) plus category/sort/output-field helpers. Split out
4
+ * of `directToolCatalog.meta.ts` (still the public barrel) — see that file's
5
+ * header comment for the full P3 engine-free rationale.
6
+ */
7
+ import { z } from 'zod';
8
+ export type DirectToolInput = Record<string, unknown> & {
9
+ queries: unknown[];
10
+ };
11
+ export interface DirectToolDefinition {
12
+ name: string;
13
+ schema: z.ZodType;
14
+ inputSchema: z.ZodType;
15
+ }
16
+ export type DirectToolCategory = 'GitHub' | 'Local Code' | 'Package' | 'Other';
17
+ export declare const DIRECT_TOOL_CATEGORIES: readonly DirectToolCategory[];
18
+ export interface DirectToolDisplayField {
19
+ name: string;
20
+ required: boolean;
21
+ type: string;
22
+ /** Numeric bounds and default, e.g. "1-100, default 30" — surfaced inline so
23
+ * agents see the full constraint without fetching the raw JSON schema. */
24
+ constraints?: string;
25
+ description?: string;
26
+ }
27
+ export interface DirectToolCommandPattern {
28
+ label: string;
29
+ query: Record<string, unknown>;
30
+ command: string;
31
+ }
32
+ export interface DirectToolOutputField {
33
+ name: string;
34
+ type: string;
35
+ optional?: boolean;
36
+ }
37
+ export interface DirectToolMetadata {
38
+ tools?: Record<string, {
39
+ description?: string;
40
+ schema?: Record<string, string>;
41
+ }>;
42
+ }
43
+ export type DirectToolAutoFilledField = 'id' | 'mainResearchGoal' | 'researchGoal' | 'reasoning';
44
+ export interface PrepareDirectToolInputOptions {
45
+ sourceLabel?: string;
46
+ rejectUnknownFields?: boolean;
47
+ onUnknownFields?: (unknownFields: string[], queryIndex: number) => void;
48
+ }
49
+ export declare class DirectToolInputError extends Error {
50
+ readonly details: string[];
51
+ constructor(message: string, details?: string[]);
52
+ }
53
+ export declare const DIRECT_TOOL_AUTO_FILLED_FIELDS: ReadonlySet<string>;
54
+ /**
55
+ * Engine-free tool definitions (name + display/bulk schema). Order mirrors
56
+ * `ALL_TOOLS` in `toolConfig.ts`; each schema is the SAME object that
57
+ * `toolConfig` attaches an executionFn to. Kept in lockstep by a drift test.
58
+ */
59
+ export declare const DIRECT_TOOL_DEFINITIONS: DirectToolDefinition[];
60
+ export declare function findDirectToolDefinition(name: string): DirectToolDefinition | undefined;
61
+ export declare function getDirectToolCategory(toolName: string): DirectToolCategory;
62
+ export declare function sortDirectToolNames(toolNames: string[]): string[];
63
+ export declare function formatDirectToolSchemaText(toolName: string): string;
64
+ export declare function formatDirectToolMetadataSchemaText(schema: Record<string, string> | undefined): string;
65
+ export declare function getDirectToolAutoFilledFields(toolName: string): string[];
66
+ export declare function getDirectToolOutputFields(): DirectToolOutputField[];
67
+ export declare function formatDirectToolOutputSchemaText(): string;
68
+ export declare function getDirectToolDescription(toolName: string, metadata?: DirectToolMetadata | null): string;
@@ -0,0 +1,4 @@
1
+ export declare function buildKnownDirectToolCommandPatternQueries(toolName: string): Array<{
2
+ label: string;
3
+ query: Record<string, unknown>;
4
+ }>;
@@ -0,0 +1,4 @@
1
+ import { type DirectToolCommandPattern } from './toolCatalogDefinitions.js';
2
+ export declare function formatDirectToolCommandPattern(toolName: string, query: Record<string, unknown>): string;
3
+ export declare function buildDirectToolCommandPatterns(toolName: string): DirectToolCommandPattern[];
4
+ export declare function buildDirectToolExampleQuery(toolName: string): Record<string, unknown>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Input preparation/normalization for the engine-free direct-tool catalog:
3
+ * JSON parsing, envelope handling, default-field filling, field-name alias
4
+ * folding, and unknown-field detection (with did-you-mean suggestions). Split
5
+ * out of `directToolCatalog.meta.ts` (still the public barrel) — see that
6
+ * file's header comment for the full P3 rationale.
7
+ */
8
+ import { z } from 'zod';
9
+ import { type DirectToolInput, type PrepareDirectToolInputOptions } from './toolCatalogDefinitions.js';
10
+ export declare function prepareDirectToolInputFromJsonText(toolName: string, inputText: string | undefined, options?: PrepareDirectToolInputOptions): DirectToolInput | null;
11
+ export declare function prepareDirectToolInput(toolName: string, rawPayload: unknown, options?: PrepareDirectToolInputOptions): DirectToolInput;
12
+ export declare function formatDirectToolValidationIssues(error: z.ZodError): string[];
@@ -0,0 +1,19 @@
1
+ import { type DirectToolDisplayField } from './toolCatalogDefinitions.js';
2
+ interface JsonSchemaObject extends Record<string, unknown> {
3
+ type?: string | string[];
4
+ description?: string;
5
+ enum?: unknown[];
6
+ required?: string[];
7
+ properties?: Record<string, unknown>;
8
+ items?: unknown;
9
+ }
10
+ export declare function getDirectToolDisplayFields(toolName: string): DirectToolDisplayField[];
11
+ export declare function describeSchemaConstraints(schema: JsonSchemaObject): string | undefined;
12
+ export declare function describeSchemaType(schema: JsonSchemaObject): string;
13
+ export declare function collectDisplayFields(properties: Record<string, unknown>, requiredFields: ReadonlySet<string>, prefix?: string): DirectToolDisplayField[];
14
+ export declare function buildExampleValue(name: string, type: string): unknown;
15
+ export declare function buildScalarExampleValue(name: string, type: string): unknown;
16
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
17
+ export declare function isJsonSchemaObject(value: unknown): value is JsonSchemaObject;
18
+ export declare function hasSchemaDefault(value: unknown): boolean;
19
+ export {};
@@ -13,71 +13,14 @@
13
13
  * which DOES import the engine; it is only reached when a tool actually runs.
14
14
  * The `@octocodeai/octocode-tools-core/schema` subpath re-exports only this
15
15
  * module so engine-less runtimes (e.g. Codex.app Node) can read schemas.
16
+ *
17
+ * This file is a thin barrel — the implementation is split across sibling
18
+ * modules under `./directToolCatalog/` (registry/helpers, schema
19
+ * introspection, command-pattern construction, and input preparation) purely
20
+ * to keep each file under the repo's max-lines lint budget. No consumer
21
+ * should need to import those sibling modules directly; import from here.
16
22
  */
17
- import { z } from 'zod';
18
- export type DirectToolInput = Record<string, unknown> & {
19
- queries: unknown[];
20
- };
21
- export interface DirectToolDefinition {
22
- name: string;
23
- schema: z.ZodType;
24
- inputSchema: z.ZodType;
25
- }
26
- export type DirectToolCategory = 'GitHub' | 'Local Code' | 'Package' | 'Other';
27
- export declare const DIRECT_TOOL_CATEGORIES: readonly DirectToolCategory[];
28
- export interface DirectToolDisplayField {
29
- name: string;
30
- required: boolean;
31
- type: string;
32
- /** Numeric bounds and default, e.g. "1-100, default 30" — surfaced inline so
33
- * agents see the full constraint without fetching the raw JSON schema. */
34
- constraints?: string;
35
- description?: string;
36
- }
37
- export interface DirectToolCommandPattern {
38
- label: string;
39
- query: Record<string, unknown>;
40
- command: string;
41
- }
42
- export interface DirectToolOutputField {
43
- name: string;
44
- type: string;
45
- optional?: boolean;
46
- }
47
- export interface DirectToolMetadata {
48
- tools?: Record<string, {
49
- description?: string;
50
- schema?: Record<string, string>;
51
- }>;
52
- }
53
- export interface PrepareDirectToolInputOptions {
54
- sourceLabel?: string;
55
- rejectUnknownFields?: boolean;
56
- onUnknownFields?: (unknownFields: string[], queryIndex: number) => void;
57
- }
58
- export declare class DirectToolInputError extends Error {
59
- readonly details: string[];
60
- constructor(message: string, details?: string[]);
61
- }
62
- /**
63
- * Engine-free tool definitions (name + display/bulk schema). Order mirrors
64
- * `ALL_TOOLS` in `toolConfig.ts`; each schema is the SAME object that
65
- * `toolConfig` attaches an executionFn to. Kept in lockstep by a drift test.
66
- */
67
- export declare const DIRECT_TOOL_DEFINITIONS: DirectToolDefinition[];
68
- export declare function findDirectToolDefinition(name: string): DirectToolDefinition | undefined;
69
- export declare function getDirectToolCategory(toolName: string): DirectToolCategory;
70
- export declare function sortDirectToolNames(toolNames: string[]): string[];
71
- export declare function formatDirectToolSchemaText(toolName: string): string;
72
- export declare function formatDirectToolMetadataSchemaText(schema: Record<string, string> | undefined): string;
73
- export declare function getDirectToolAutoFilledFields(toolName: string): string[];
74
- export declare function getDirectToolOutputFields(): DirectToolOutputField[];
75
- export declare function formatDirectToolOutputSchemaText(): string;
76
- export declare function getDirectToolDescription(toolName: string, metadata?: DirectToolMetadata | null): string;
77
- export declare function getDirectToolDisplayFields(toolName: string): DirectToolDisplayField[];
78
- export declare function formatDirectToolCommandPattern(toolName: string, query: Record<string, unknown>): string;
79
- export declare function buildDirectToolCommandPatterns(toolName: string): DirectToolCommandPattern[];
80
- export declare function buildDirectToolExampleQuery(toolName: string): Record<string, unknown>;
81
- export declare function prepareDirectToolInputFromJsonText(toolName: string, inputText: string | undefined, options?: PrepareDirectToolInputOptions): DirectToolInput | null;
82
- export declare function prepareDirectToolInput(toolName: string, rawPayload: unknown, options?: PrepareDirectToolInputOptions): DirectToolInput;
83
- export declare function formatDirectToolValidationIssues(error: z.ZodError): string[];
23
+ export * from './directToolCatalog/toolCatalogDefinitions.js';
24
+ export * from './directToolCatalog/toolSchemaIntrospection.js';
25
+ export * from './directToolCatalog/toolCommandPatterns.js';
26
+ export * from './directToolCatalog/toolInputPreparation.js';
@@ -1,9 +1,5 @@
1
1
  import type { CloneCacheMeta, CacheSource } from './types.js';
2
- export declare function getReposBaseDir(octocodeDir: string): string;
3
- export declare function getCloneBaseDir(octocodeDir: string): string;
4
- export declare function getTreeBaseDir(octocodeDir: string): string;
5
- export declare function getCloneDir(octocodeDir: string, owner: string, repo: string, branch: string, sparsePath?: string): string;
6
- export declare function getTreeDir(octocodeDir: string, owner: string, repo: string, branch: string): string;
2
+ export { getReposBaseDir, getCloneBaseDir, getTreeBaseDir, getCloneDir, getTreeDir, } from './cachePaths.js';
7
3
  export declare function readCacheMeta(cloneDir: string): CloneCacheMeta | null;
8
4
  export declare function writeCacheMeta(cloneDir: string, meta: CloneCacheMeta): void;
9
5
  export declare function isCacheValid(meta: CloneCacheMeta): boolean;
@@ -0,0 +1,5 @@
1
+ export declare function getReposBaseDir(octocodeDir: string): string;
2
+ export declare function getCloneBaseDir(octocodeDir: string): string;
3
+ export declare function getTreeBaseDir(octocodeDir: string): string;
4
+ export declare function getCloneDir(octocodeDir: string, owner: string, repo: string, branch: string, sparsePath?: string): string;
5
+ export declare function getTreeDir(octocodeDir: string, owner: string, repo: string, branch: string): string;
@@ -0,0 +1,9 @@
1
+ import type { PaginationInfo } from '../../../types/toolResults.js';
2
+ import type { DirectoryEntry, FileEntry, PartialFileContentQuery } from './types.js';
3
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
4
+ export declare function readString(value: unknown): string | undefined;
5
+ export declare function readNumber(value: unknown): number | undefined;
6
+ export declare function readStringArray(value: unknown): string[] | undefined;
7
+ export declare function readPagination(value: unknown): PaginationInfo | undefined;
8
+ export declare function readFileEntry(data: Record<string, unknown>, query: PartialFileContentQuery): FileEntry;
9
+ export declare function readDirectoryEntry(data: Record<string, unknown>, query: PartialFileContentQuery): DirectoryEntry;
@@ -0,0 +1,101 @@
1
+ import type { z } from 'zod';
2
+ import type { FileContentQuerySchema } from '@octocodeai/octocode-core/schemas';
3
+ type FileContentQuery = z.infer<typeof FileContentQuerySchema>;
4
+ import type { PaginationInfo } from '../../../types/toolResults.js';
5
+ import type { QueryWithPagination } from '../../../utils/response/groupedFinalizer.js';
6
+ import type { GitHubFetchContentOutputLocal } from '../scheme.js';
7
+ import type { WithOptionalMeta } from '../../../types/execution.js';
8
+ export type PartialFileContentQuery = WithOptionalMeta<FileContentQuery> & QueryWithPagination;
9
+ export type FileEntry = {
10
+ path: string;
11
+ content: string;
12
+ localPath?: string;
13
+ repoRoot?: string;
14
+ fileSize?: number;
15
+ contentView?: 'none' | 'standard' | 'symbols';
16
+ totalLines?: number;
17
+ sourceChars?: number;
18
+ sourceBytes?: number;
19
+ resolvedBranch?: string;
20
+ pagination?: PaginationInfo;
21
+ isPartial?: boolean;
22
+ startLine?: number;
23
+ endLine?: number;
24
+ matchRanges?: Array<{
25
+ start: number;
26
+ end: number;
27
+ }>;
28
+ lastModified?: string;
29
+ lastModifiedBy?: string;
30
+ warnings?: string[];
31
+ matchNotFound?: boolean;
32
+ searchedFor?: string;
33
+ cached?: boolean;
34
+ next?: FileContentNextMap;
35
+ };
36
+ export type FileContentNextMap = {
37
+ continueChars?: {
38
+ tool: 'ghGetFileContent';
39
+ query: Record<string, unknown>;
40
+ };
41
+ cloneForSemantics?: {
42
+ tool: 'ghCloneRepo';
43
+ query: Record<string, unknown>;
44
+ why: string;
45
+ confidence: 'exact';
46
+ };
47
+ };
48
+ export type DirectoryEntry = {
49
+ path: string;
50
+ localPath: string;
51
+ repoRoot?: string;
52
+ fileCount: number;
53
+ totalSize: number;
54
+ complete?: boolean;
55
+ verified?: boolean;
56
+ commitSha?: string;
57
+ hasSubdirectories?: boolean;
58
+ skippedSummary?: Record<string, number>;
59
+ directoryEntryCount?: number;
60
+ eligibleFileCount?: number;
61
+ savedFileCount?: number;
62
+ skipped?: {
63
+ nonFile: number;
64
+ missingDownloadUrl: number;
65
+ oversized: number;
66
+ binary: number;
67
+ fileLimit: number;
68
+ fetchFailed: number;
69
+ totalSizeLimit: number;
70
+ pathTraversal: number;
71
+ };
72
+ limits?: {
73
+ maxDirectoryFiles: number;
74
+ maxTotalSize: number;
75
+ maxFileSize: number;
76
+ };
77
+ warnings?: string[];
78
+ files?: Array<{
79
+ path: string;
80
+ size: number;
81
+ type: string;
82
+ }>;
83
+ cached?: boolean;
84
+ resolvedBranch?: string;
85
+ };
86
+ export type RepoGroup = {
87
+ id: string;
88
+ owner: string;
89
+ repo: string;
90
+ files?: FileEntry[];
91
+ directories?: DirectoryEntry[];
92
+ data?: RepoGroupData;
93
+ };
94
+ export type RepoGroupData = {
95
+ owner: string;
96
+ repo: string;
97
+ files?: FileEntry[];
98
+ directories?: DirectoryEntry[];
99
+ };
100
+ export type FileContentResponse = GitHubFetchContentOutputLocal;
101
+ export {};
@@ -1,10 +1,4 @@
1
- import type { z } from 'zod';
2
- import type { FileContentQuerySchema } from '@octocodeai/octocode-core/schemas';
3
- type FileContentQuery = z.infer<typeof FileContentQuerySchema>;
4
1
  import type { BulkFinalizer } from '../../types/bulk.js';
5
- import { type QueryWithPagination } from '../../utils/response/groupedFinalizer.js';
6
2
  import type { GitHubFetchContentOutputLocal } from './scheme.js';
7
- import type { WithOptionalMeta } from '../../types/execution.js';
8
- type PartialFileContentQuery = WithOptionalMeta<FileContentQuery> & QueryWithPagination;
3
+ import type { PartialFileContentQuery } from './finalizer/types.js';
9
4
  export declare function buildGithubFetchContentFinalizer<TQuery extends PartialFileContentQuery>(): BulkFinalizer<TQuery, GitHubFetchContentOutputLocal>;
10
- export {};
@@ -63,27 +63,60 @@ export declare const GitHubFetchContentOutputLocalSchema: z.ZodObject<{
63
63
  standard: "standard";
64
64
  symbols: "symbols";
65
65
  }>>;
66
- isSkeleton: z.ZodOptional<z.ZodBoolean>;
67
66
  totalLines: z.ZodOptional<z.ZodNumber>;
68
67
  sourceChars: z.ZodOptional<z.ZodNumber>;
69
68
  sourceBytes: z.ZodOptional<z.ZodNumber>;
70
69
  resolvedBranch: z.ZodOptional<z.ZodString>;
71
- pagination: z.ZodOptional<z.ZodObject<{
70
+ modified: z.ZodOptional<z.ZodString>;
71
+ fileSize: z.ZodOptional<z.ZodNumber>;
72
+ pagination: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
73
+ charOffset: z.ZodNumber;
74
+ charLength: z.ZodNumber;
75
+ totalChars: z.ZodNumber;
76
+ hasMore: z.ZodBoolean;
77
+ nextCharOffset: z.ZodOptional<z.ZodNumber>;
78
+ currentPage: z.ZodOptional<z.ZodNumber>;
79
+ totalPages: z.ZodOptional<z.ZodNumber>;
80
+ chunkMode: z.ZodOptional<z.ZodEnum<{
81
+ semantic: "semantic";
82
+ "char-limit": "char-limit";
83
+ }>>;
84
+ nextPage: z.ZodOptional<z.ZodNumber>;
85
+ }, z.core.$strip>, z.ZodObject<{
72
86
  currentPage: z.ZodNumber;
73
87
  totalPages: z.ZodNumber;
74
88
  hasMore: z.ZodBoolean;
75
89
  nextPage: z.ZodOptional<z.ZodNumber>;
90
+ pageSize: z.ZodOptional<z.ZodNumber>;
91
+ totalItems: z.ZodOptional<z.ZodNumber>;
92
+ perPage: z.ZodOptional<z.ZodNumber>;
93
+ totalFound: z.ZodOptional<z.ZodNumber>;
94
+ returned: z.ZodOptional<z.ZodNumber>;
95
+ totalMatches: z.ZodOptional<z.ZodNumber>;
96
+ reportedTotalMatches: z.ZodOptional<z.ZodNumber>;
97
+ reachableTotalMatches: z.ZodOptional<z.ZodNumber>;
98
+ totalMatchesKind: z.ZodOptional<z.ZodEnum<{
99
+ exact: "exact";
100
+ reported: "reported";
101
+ lowerBound: "lowerBound";
102
+ }>>;
103
+ totalMatchesCapped: z.ZodOptional<z.ZodBoolean>;
104
+ totalResults: z.ZodOptional<z.ZodNumber>;
105
+ itemsPerPage: z.ZodOptional<z.ZodNumber>;
76
106
  charOffset: z.ZodOptional<z.ZodNumber>;
77
107
  charLength: z.ZodOptional<z.ZodNumber>;
78
108
  totalChars: z.ZodOptional<z.ZodNumber>;
79
109
  nextCharOffset: z.ZodOptional<z.ZodNumber>;
80
- }, z.core.$strip>>;
81
- next: z.ZodOptional<z.ZodObject<{
82
- continueChars: z.ZodOptional<z.ZodObject<{
83
- tool: z.ZodLiteral<"ghGetFileContent">;
84
- query: z.ZodRecord<z.ZodString, z.ZodUnknown>;
85
- }, z.core.$strip>>;
86
- }, z.core.$strip>>;
110
+ }, z.core.$strip>]>>;
111
+ next: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
112
+ tool: z.ZodString;
113
+ query: z.ZodRecord<z.ZodString, z.ZodUnknown>;
114
+ why: z.ZodOptional<z.ZodString>;
115
+ confidence: z.ZodOptional<z.ZodEnum<{
116
+ exact: "exact";
117
+ heuristic: "heuristic";
118
+ }>>;
119
+ }, z.core.$strip>>>;
87
120
  isPartial: z.ZodOptional<z.ZodBoolean>;
88
121
  startLine: z.ZodOptional<z.ZodNumber>;
89
122
  endLine: z.ZodOptional<z.ZodNumber>;
@@ -2,7 +2,7 @@ import type { z } from 'zod';
2
2
  import type { FileContentQuerySchema } from '@octocodeai/octocode-core/schemas';
3
3
  import type { MinifyMode } from '../../scheme/fields.js';
4
4
  type FileContentQuery = z.infer<typeof FileContentQuerySchema>;
5
- import type { PaginationInfo } from '../../utils/core/types.js';
5
+ import type { PaginationInfo } from '../../types/toolResults.js';
6
6
  export type FileContentExecutionQuery = FileContentQuery & {
7
7
  noTimestamp?: boolean;
8
8
  minify: MinifyMode;
@@ -18,7 +18,6 @@ export interface GitHubFileContentApiData {
18
18
  path?: string;
19
19
  content?: string;
20
20
  contentView?: 'none' | 'standard' | 'symbols';
21
- isSkeleton?: boolean;
22
21
  branch?: string;
23
22
  resolvedBranch?: string;
24
23
  startLine?: number;
@@ -4,5 +4,14 @@ import type { GitHubCodeSearchQuerySchema } from '@octocodeai/octocode-core/sche
4
4
  type GitHubCodeSearchQuery = z.infer<typeof GitHubCodeSearchQuerySchema>;
5
5
  import type { ToolExecutionArgs, WithOptionalMeta } from '../../types/execution.js';
6
6
  type PartialCodeSearchQuery = WithOptionalMeta<GitHubCodeSearchQuery>;
7
+ export declare function hasValidCodeSearchParams(query: PartialCodeSearchQuery): boolean;
8
+ export type RepoState = {
9
+ kind: 'notFound';
10
+ } | {
11
+ kind: 'archived';
12
+ } | {
13
+ kind: 'renamed';
14
+ fullName: string;
15
+ };
7
16
  export declare function searchMultipleGitHubCode(args: ToolExecutionArgs<PartialCodeSearchQuery>): Promise<CallToolResult>;
8
17
  export {};
@@ -0,0 +1,4 @@
1
+ import type { BulkFinalizer } from '../../../types/bulk.js';
2
+ import { type QueryWithPagination } from '../../../utils/response/groupedFinalizer.js';
3
+ import type { GitHubCodeSearchOutputLocal } from '../scheme.js';
4
+ export declare function buildGhSearchCodeFinalizer<TQuery extends QueryWithPagination>(): BulkFinalizer<TQuery, GitHubCodeSearchOutputLocal>;
@@ -0,0 +1,23 @@
1
+ import { type QueryWithPagination } from '../../../utils/response/groupedFinalizer.js';
2
+ import type { ToolContinuation } from '../../../scheme/pagination.js';
3
+ import { type CodeSearchGroupedMatch, type CodeSearchGroupedResult, type CodeSearchPagination } from '../../providerMappers.js';
4
+ export type PerQueryGroups = {
5
+ id: string;
6
+ groups: CodeSearchGroupedResult[];
7
+ };
8
+ export type CodeSearchFileResult = {
9
+ owner: string;
10
+ repo: string;
11
+ path: string;
12
+ matches: Array<Omit<CodeSearchGroupedMatch, 'path'>>;
13
+ };
14
+ export type CodeSearchResultRecord = {
15
+ id: string;
16
+ data: {
17
+ files: CodeSearchFileResult[];
18
+ pagination?: CodeSearchPagination;
19
+ };
20
+ };
21
+ export declare function mergeGroups(perQuery: readonly PerQueryGroups[]): CodeSearchGroupedResult[];
22
+ export declare function buildResultRecords(queries: readonly QueryWithPagination[], groups: readonly CodeSearchGroupedResult[], paginationByQuery: ReadonlyMap<string, CodeSearchPagination>): CodeSearchResultRecord[];
23
+ export declare function buildNextMap(resultRecords: readonly CodeSearchResultRecord[], queries: readonly QueryWithPagination[], allKeywords: readonly string[]): Record<string, ToolContinuation> | undefined;
@@ -0,0 +1,12 @@
1
+ import type { FlatQueryResult } from '../../../types/toolResults.js';
2
+ import { type QueryWithPagination } from '../../../utils/response/groupedFinalizer.js';
3
+ import type { RepoState } from '../execution.js';
4
+ import { type CodeSearchFlatResult, type CodeSearchGroupedResult } from '../../providerMappers.js';
5
+ export declare function queryById(queries: readonly QueryWithPagination[]): ReadonlyMap<string, QueryWithPagination>;
6
+ export declare function hasScopedGitHubQuery(emptyQueries: readonly {
7
+ id: string;
8
+ }[], queries: readonly QueryWithPagination[]): boolean;
9
+ export declare function readPerQueryFlat(result: FlatQueryResult): CodeSearchFlatResult & {
10
+ repoState?: RepoState;
11
+ };
12
+ export declare function applyExactMatchRanking(groups: readonly CodeSearchGroupedResult[], keywords: readonly string[]): CodeSearchGroupedResult[];
@@ -1,6 +1,2 @@
1
- import type { BulkFinalizer } from '../../types/bulk.js';
2
- import { type QueryWithPagination } from '../../utils/response/groupedFinalizer.js';
3
- import type { GitHubCodeSearchOutputLocal } from './scheme.js';
4
- import { type CodeSearchGroupedResult } from '../providerMappers.js';
5
- export declare function applyExactMatchRanking(groups: readonly CodeSearchGroupedResult[], keywords: readonly string[]): CodeSearchGroupedResult[];
6
- export declare function buildGhSearchCodeFinalizer<TQuery extends QueryWithPagination>(): BulkFinalizer<TQuery, GitHubCodeSearchOutputLocal>;
1
+ export { applyExactMatchRanking } from './finalizer/ranking.js';
2
+ export { buildGhSearchCodeFinalizer } from './finalizer/build.js';