@octocodeai/octocode-tools-core 16.3.0 → 16.5.1

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 (127) hide show
  1. package/README.md +546 -0
  2. package/dist/config.d.ts +7 -0
  3. package/dist/direct.js +34 -41
  4. package/dist/errors/pathUtils.d.ts +1 -1
  5. package/dist/github/directoryFetch.d.ts +2 -1
  6. package/dist/github/githubAPI.d.ts +10 -1
  7. package/dist/github/repoStructureRecursive.d.ts +6 -0
  8. package/dist/index.d.ts +15 -27
  9. package/dist/index.js +41 -48
  10. package/dist/providers/providerQueries.d.ts +9 -0
  11. package/dist/providers/providerResults.d.ts +2 -0
  12. package/dist/scheme/coreSchemas.d.ts +5 -5
  13. package/dist/scheme/fields.d.ts +6 -6
  14. package/dist/serverConfig.d.ts +1 -1
  15. package/dist/session.d.ts +1 -1
  16. package/dist/shared/config/defaults.d.ts +15 -0
  17. package/dist/shared/config/index.d.ts +10 -0
  18. package/dist/shared/config/index.js +10 -0
  19. package/dist/shared/config/loader.d.ts +7 -0
  20. package/dist/shared/config/resolver.d.ts +2 -0
  21. package/dist/shared/config/resolverCache.d.ts +12 -0
  22. package/dist/shared/config/resolverSections.d.ts +12 -0
  23. package/dist/shared/config/runtimeSurface.d.ts +21 -0
  24. package/dist/shared/config/schemas.d.ts +12 -0
  25. package/dist/shared/config/types.d.ts +100 -0
  26. package/dist/shared/config/validator.d.ts +2 -0
  27. package/dist/shared/credentials/constants.d.ts +2 -0
  28. package/dist/shared/credentials/credentialCache.d.ts +13 -0
  29. package/dist/shared/credentials/credentialEncryption.d.ts +10 -0
  30. package/dist/shared/credentials/credentialUtils.d.ts +4 -0
  31. package/dist/shared/credentials/envTokens.d.ts +9 -0
  32. package/dist/shared/credentials/ghCli.d.ts +1 -0
  33. package/dist/shared/credentials/index.d.ts +3 -0
  34. package/dist/shared/credentials/index.js +9 -0
  35. package/dist/shared/credentials/schemas.d.ts +22 -0
  36. package/dist/shared/credentials/storage.d.ts +30 -0
  37. package/dist/shared/credentials/testing.d.ts +2 -0
  38. package/dist/shared/credentials/testing.js +8 -0
  39. package/dist/shared/credentials/tokenRefresh.d.ts +24 -0
  40. package/dist/shared/credentials/tokenResolution.d.ts +30 -0
  41. package/dist/shared/credentials/types.d.ts +28 -0
  42. package/dist/shared/fs-utils.d.ts +2 -0
  43. package/dist/shared/fs-utils.js +8 -0
  44. package/dist/shared/index.d.ts +7 -0
  45. package/dist/shared/logger/index.d.ts +2 -0
  46. package/dist/shared/logger/logger.d.ts +17 -0
  47. package/dist/shared/paths.d.ts +33 -0
  48. package/dist/shared/paths.js +8 -0
  49. package/dist/shared/platform/index.d.ts +1 -0
  50. package/dist/shared/platform/index.js +8 -0
  51. package/dist/shared/platform/platform.d.ts +8 -0
  52. package/dist/shared/session/index.d.ts +5 -0
  53. package/dist/shared/session/index.js +9 -0
  54. package/dist/shared/session/schemas.d.ts +103 -0
  55. package/dist/shared/session/sessionCache.d.ts +9 -0
  56. package/dist/shared/session/sessionDiskIO.d.ts +6 -0
  57. package/dist/shared/session/statsDefaults.d.ts +4 -0
  58. package/dist/shared/session/storage.d.ts +20 -0
  59. package/dist/shared/session/types.d.ts +53 -0
  60. package/dist/tools/github_clone_repo/cache.d.ts +4 -0
  61. package/dist/tools/github_clone_repo/scheme.d.ts +56 -9
  62. package/dist/tools/github_clone_repo/types.d.ts +1 -1
  63. package/dist/tools/github_fetch_content/scheme.d.ts +8 -4
  64. package/dist/tools/github_fetch_content/types.d.ts +12 -0
  65. package/dist/tools/github_search_code/scheme.d.ts +6 -6
  66. package/dist/tools/github_search_pull_requests/contentResponse.d.ts +0 -1
  67. package/dist/tools/github_search_pull_requests/execution.d.ts +1 -11
  68. package/dist/tools/github_search_pull_requests/scheme.d.ts +6 -2
  69. package/dist/tools/github_search_repos/scheme.d.ts +7 -6
  70. package/dist/tools/github_view_repo_structure/execution.d.ts +0 -9
  71. package/dist/tools/github_view_repo_structure/scheme.d.ts +10 -6
  72. package/dist/tools/local_binary_inspect/archiveOps.d.ts +2 -0
  73. package/dist/tools/local_binary_inspect/binaryInspector.d.ts +48 -7
  74. package/dist/tools/local_binary_inspect/binaryOps.d.ts +16 -7
  75. package/dist/tools/local_binary_inspect/scheme.d.ts +10 -7
  76. package/dist/tools/local_fetch_content/scheme.d.ts +2 -2
  77. package/dist/tools/local_find_files/scheme.d.ts +2 -2
  78. package/dist/tools/local_ripgrep/lspBoost.d.ts +54 -0
  79. package/dist/tools/local_ripgrep/rankingProfile.d.ts +113 -0
  80. package/dist/tools/local_ripgrep/ripgrepResultBuilder.d.ts +10 -1
  81. package/dist/tools/local_ripgrep/scheme.d.ts +29 -4
  82. package/dist/tools/local_ripgrep/structuralSearch.d.ts +3 -4
  83. package/dist/tools/local_view_structure/scheme.d.ts +2 -2
  84. package/dist/tools/local_view_structure/structureFilters.d.ts +1 -3
  85. package/dist/tools/local_view_structure/structureResponse.d.ts +1 -0
  86. package/dist/tools/lsp/semantic_content/scheme.d.ts +4 -8
  87. package/dist/tools/lsp/shared/callHierarchyTraversal.d.ts +2 -2
  88. package/dist/tools/lsp/shared/semanticTypes.d.ts +2 -1
  89. package/dist/tools/package_search/scheme.d.ts +9 -7
  90. package/dist/tools/providerMappers.d.ts +19 -0
  91. package/dist/tools/toolMetadata/proxies.d.ts +0 -6
  92. package/dist/tools/utils.d.ts +3 -7
  93. package/dist/types/bulk.d.ts +0 -2
  94. package/dist/types/execution.d.ts +1 -2
  95. package/dist/types/toolResults.d.ts +2 -3
  96. package/dist/utils/contextUtils.d.ts +35 -2
  97. package/dist/utils/core/lines.d.ts +16 -0
  98. package/dist/utils/core/types.d.ts +10 -0
  99. package/dist/utils/file/filters.d.ts +2 -11
  100. package/dist/utils/parsers/diff.d.ts +18 -0
  101. package/dist/utils/ranking/evidenceRanker.d.ts +86 -0
  102. package/dist/utils/response/error.d.ts +38 -4
  103. package/dist/utils/response/groupedFinalizer.d.ts +0 -2
  104. package/package.json +43 -14
  105. package/dist/commands/RipgrepCommandBuilder.d.ts +0 -27
  106. package/dist/hints/dynamic.d.ts +0 -6
  107. package/dist/hints/index.d.ts +0 -2
  108. package/dist/hints/types.d.ts +0 -1
  109. package/dist/tools/github_clone_repo/hints.d.ts +0 -2
  110. package/dist/tools/github_fetch_content/hints.d.ts +0 -2
  111. package/dist/tools/github_search_code/hints.d.ts +0 -2
  112. package/dist/tools/github_search_pull_requests/hints.d.ts +0 -2
  113. package/dist/tools/github_search_repos/hints.d.ts +0 -2
  114. package/dist/tools/github_view_repo_structure/hints.d.ts +0 -2
  115. package/dist/tools/local_fetch_content/hints.d.ts +0 -2
  116. package/dist/tools/local_find_files/hints.d.ts +0 -2
  117. package/dist/tools/local_ripgrep/grepFallbackExecutor.d.ts +0 -3
  118. package/dist/tools/local_ripgrep/hints.d.ts +0 -2
  119. package/dist/tools/local_ripgrep/ripgrepParser.d.ts +0 -9
  120. package/dist/tools/local_view_structure/hints.d.ts +0 -2
  121. package/dist/tools/local_view_structure/structureParser.d.ts +0 -3
  122. package/dist/tools/local_view_structure/structureWalker.d.ts +0 -24
  123. package/dist/tools/lsp/semantic_content/hints.d.ts +0 -4
  124. package/dist/tools/package_search/hints.d.ts +0 -2
  125. package/dist/types/metadata.d.ts +0 -69
  126. package/dist/utils/exec/commandAvailability.d.ts +0 -19
  127. package/dist/utils/exec/ripgrepBinary.d.ts +0 -3
@@ -0,0 +1,17 @@
1
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
2
+ export interface LogEntry {
3
+ level: LogLevel;
4
+ module: string;
5
+ message: string;
6
+ data?: Record<string, unknown>;
7
+ }
8
+ type LogHandler = (entry: LogEntry) => void;
9
+ export declare function setLogHandler(handler: LogHandler | null): void;
10
+ export declare function _getLogHandler(): LogHandler | null;
11
+ export declare function createLogger(module: string): {
12
+ debug: (message: string, data?: Record<string, unknown>) => void;
13
+ info: (message: string, data?: Record<string, unknown>) => void;
14
+ warn: (message: string, data?: Record<string, unknown>) => void;
15
+ error: (message: string, data?: Record<string, unknown>) => void;
16
+ };
17
+ export {};
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Octocode's home directory. Fixed per platform — there is no override env var:
3
+ * - macOS: `~/.octocode`
4
+ * - Linux: `${XDG_CONFIG_HOME:-~/.config}/.octocode`
5
+ * - Windows: `%APPDATA%\.octocode`
6
+ */
7
+ export declare function getDefaultOctocodeHome(): string;
8
+ export declare const OCTOCODE_HOME: string;
9
+ export declare const paths: {
10
+ readonly home: string;
11
+ readonly config: string;
12
+ readonly credentials: string;
13
+ readonly key: string;
14
+ readonly session: string;
15
+ readonly stats: string;
16
+ readonly tmp: string;
17
+ readonly clone: string;
18
+ readonly tree: string;
19
+ readonly binary: string;
20
+ readonly repos: string;
21
+ readonly logs: string;
22
+ readonly unzip: string;
23
+ readonly cliConfig: string;
24
+ readonly lspConfig: string;
25
+ };
26
+ export declare function ensureHome(): void;
27
+ export declare function ensureRepos(): void;
28
+ export declare function ensureTmp(): void;
29
+ export declare function ensureClone(): void;
30
+ export declare function ensureLogs(): void;
31
+ export declare function ensureTree(): void;
32
+ export declare function ensureBinary(): void;
33
+ export declare function ensureUnzip(): void;
@@ -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{existsSync as r,mkdirSync as n}from"node:fs";import{join as e}from"node:path";import p from"node:os";import x from"node:path";var c=p.platform()==="win32",f=p.platform()==="darwin",v=p.platform()==="linux",s=p.homedir();function m(){return c?process.env.APPDATA||x.join(s,"AppData","Roaming"):s}var d=".octocode",i=448;function A(g){let a=process.env[g];return a&&a.trim().length>0?a:void 0}function h(){return c?e(m(),d):f?e(s,d):e(A("XDG_CONFIG_HOME")??e(s,".config"),d)}var o=h(),t={home:o,config:e(o,".octocoderc"),credentials:e(o,"credentials.json"),key:e(o,".key"),session:e(o,"session.json"),stats:e(o,"stats.json"),tmp:e(o,"tmp"),clone:e(o,"tmp","clone"),tree:e(o,"tmp","tree"),binary:e(o,"tmp","binary"),repos:e(o,"tmp","clone"),logs:e(o,"logs"),unzip:e(o,"tmp","unzip"),cliConfig:e(o,"config.json"),lspConfig:e(o,"lsp-servers.json")};function l(){r(t.home)||n(t.home,{recursive:!0,mode:i})}function z(){D()}function u(){l(),r(t.tmp)||n(t.tmp,{recursive:!0,mode:i})}function D(){u(),r(t.clone)||n(t.clone,{recursive:!0,mode:i})}function N(){l(),r(t.logs)||n(t.logs,{recursive:!0,mode:i})}function T(){u(),r(t.tree)||n(t.tree,{recursive:!0,mode:i})}function _(){u(),r(t.binary)||n(t.binary,{recursive:!0,mode:i})}function R(){u(),r(t.unzip)||n(t.unzip,{recursive:!0,mode:i})}export{o as OCTOCODE_HOME,_ as ensureBinary,D as ensureClone,l as ensureHome,N as ensureLogs,z as ensureRepos,u as ensureTmp,T as ensureTree,R as ensureUnzip,h as getDefaultOctocodeHome,t as paths};
@@ -0,0 +1 @@
1
+ export { isWindows, isMac, isLinux, HOME, getAppDataPath, getLocalAppDataPath, getPlatformName, getArchitecture, } from './platform.js';
@@ -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 t from"node:os";import n from"node:path";var o=t.platform()==="win32",e=t.platform()==="darwin",a=t.platform()==="linux",r=t.homedir();function i(){return o?process.env.APPDATA||n.join(r,"AppData","Roaming"):r}function p(){return o?process.env.LOCALAPPDATA||n.join(r,"AppData","Local"):r}function s(){return e?"macOS":o?"Windows":a?"Linux":t.platform()}function c(){return t.arch()}export{r as HOME,i as getAppDataPath,c as getArchitecture,p as getLocalAppDataPath,s as getPlatformName,a as isLinux,e as isMac,o as isWindows};
@@ -0,0 +1,8 @@
1
+ export declare const isWindows: boolean;
2
+ export declare const isMac: boolean;
3
+ export declare const isLinux: boolean;
4
+ export declare const HOME: string;
5
+ export declare function getAppDataPath(): string;
6
+ export declare function getLocalAppDataPath(): string;
7
+ export declare function getPlatformName(): string;
8
+ export declare function getArchitecture(): string;
@@ -0,0 +1,5 @@
1
+ export type { GitHubCacheHitStats, PersistedStats, PersistedSession, SessionStats, SessionTotalUsageStats, SessionUpdateResult, SessionOptions, StatsCounterMap, ToolCharSavingsStats, } from './types.js';
2
+ export { SESSION_FILE, STATS_FILE } from './storage.js';
3
+ export { readSession, writeSession, getOrCreateSession, getSessionId, deleteSession, flushSession, flushSessionSync, } from './storage.js';
4
+ export { updateSessionStats, incrementToolCalls, incrementErrors, incrementRateLimits, incrementRateLimitByProvider, incrementToolCharSavings, incrementGitHubCacheHits, incrementGitHubCacheRateLimits, incrementPackageRegistryFailures, resetSessionStats, } from './storage.js';
5
+ export { _resetSessionState } from './storage.js';
@@ -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{randomUUID as kt}from"node:crypto";import{existsSync as Z,readFileSync as Re,writeFileSync as lt,unlinkSync as ft,renameSync as dt}from"node:fs";var He=null;function Oe(e){let t=`[${e.module}]`,r=e.data&&Object.keys(e.data).length>0?` ${JSON.stringify(e.data)}`:"";process.stderr.write(`${t} ${e.level}: ${e.message}${r}
9
+ `)}function S(e){function t(r,s,n){let i={level:r,module:e,message:s,...n&&{data:n}};(He??Oe)(i)}return{debug:(r,s)=>t("debug",r,s),info:(r,s)=>t("info",r,s),warn:(r,s)=>t("warn",r,s),error:(r,s)=>t("error",r,s)}}function g(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 W(e){if(!e.token.refreshTokenExpiresAt)return!1;let t=new Date(e.token.refreshTokenExpiresAt);return isNaN(t.getTime())?!0:new Date>=t}var A=new Map,De=300*1e3;function _e(e){let t=g(e),r=A.get(t);return!r||Date.now()-r.cachedAt>=De?!1:r.credentials?!w(r.credentials):!0}function te(e){e?A.delete(g(e)):A.clear()}function re(e){let t=g(e);if(_e(t))return A.get(t).credentials}function se(e,t){let r=g(e);A.set(r,{credentials:t,cachedAt:Date.now()})}import{existsSync as ae,readFileSync as ce,writeFileSync as ue,unlinkSync as lr,statSync as We,chmodSync as $e}from"node:fs";import{createCipheriv as Ke,createDecipheriv as Ve,randomBytes as le}from"node:crypto";import{existsSync as Ne,mkdirSync as Ge}from"node:fs";import{join as a}from"node:path";import N from"node:os";import Fe from"node:path";var G=N.platform()==="win32",$=N.platform()==="darwin",Ie=N.platform()==="linux",y=N.homedir();function K(){return G?process.env.APPDATA||Fe.join(y,"AppData","Roaming"):y}var V=".octocode",Me=448;function je(e){let t=process.env[e];return t&&t.trim().length>0?t:void 0}function Ue(){return G?a(K(),V):$?a(y,V):a(je("XDG_CONFIG_HOME")??a(y,".config"),V)}var u=Ue(),f={home:u,config:a(u,".octocoderc"),credentials:a(u,"credentials.json"),key:a(u,".key"),session:a(u,"session.json"),stats:a(u,"stats.json"),tmp:a(u,"tmp"),clone:a(u,"tmp","clone"),tree:a(u,"tmp","tree"),binary:a(u,"tmp","binary"),repos:a(u,"tmp","clone"),logs:a(u,"logs"),unzip:a(u,"tmp","unzip"),cliConfig:a(u,"config.json"),lspConfig:a(u,"lsp-servers.json")};function ne(){Ne(f.home)||Ge(f.home,{recursive:!0,mode:Me})}import{z as c}from"zod";var Be=c.object({token:c.string(),tokenType:c.literal("oauth"),scopes:c.array(c.string()).optional(),refreshToken:c.string().optional(),expiresAt:c.string().optional(),refreshTokenExpiresAt:c.string().optional()}),ze=c.object({hostname:c.string(),username:c.string(),token:Be,gitProtocol:c.enum(["ssh","https"]),createdAt:c.string(),updatedAt:c.string()}),oe=c.object({version:c.number(),credentials:c.record(c.string(),ze)});var ie=S("token-storage");function Je(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***")}var Ze=f.home,R=f.credentials,v=f.key,fe="aes-256-gcm",qe=16;function b(){ne()}function de(){if(b(),ae(v))return We(v).mode&511&63&&$e(v,384),Buffer.from(ce(v,"utf8"),"hex");let e=le(32);return ue(v,e.toString("hex"),{mode:384}),e}function pe(e){let t=de(),r=le(qe),s=Ke(fe,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 me(e){let t=de(),[r,s,n]=e.split(":");if(!r||!s||!n)throw new Error("Invalid encrypted data format");let i=Buffer.from(r,"hex"),x=Buffer.from(s,"hex"),m=Ve(fe,t,i);m.setAuthTag(x);let ee=m.update(n,"hex","utf8");return ee+=m.final("utf8"),ee}function J(){if(b(),!ae(R))return{version:1,credentials:{}};try{let e=ce(R,"utf8"),t=me(e),r=JSON.parse(t),s=oe.safeParse(r);return s.success?s.data:(ie.warn("Credentials file has invalid format \u2014 starting fresh",{file:R}),{version:1,credentials:{}})}catch(e){let t=e instanceof Error&&e.message?Je(e.message):void 0;return ie.warn("Could not read credentials file \u2014 you may need to login again",{file:R,...t&&{reason:t}}),{version:1,credentials:{}}}}function ge(e){b();let t=pe(JSON.stringify(e,null,2));ue(R,t,{mode:384})}import{refreshToken as Ye}from"@octokit/oauth-methods";import{request as Xe}from"@octokit/request";var M="178c6fc778ccc68e1d6a",P="github.com";function Qe(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 et(e){return e==="github.com"||e===P?"https://api.github.com":`https://${e}/api/v3`}async function he(e,t=P,r=M){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(W(s))return{success:!1,error:"Refresh token has expired. Please login again."};try{let n=await Ye({clientType:"github-app",clientId:r,clientSecret:"",refreshToken:s.token.refreshToken,request:Xe.defaults({baseUrl:et(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?Qe(n.message):"Token refresh failed"}}}async function Se(e,t=P,r=M){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 he(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{execFile as Rr}from"child_process";var tt=null;function Ce(e){tt=e}var rt=S("token-storage");async function st(e){let t=g(e.hostname),r={...e,hostname:t,updatedAt:new Date().toISOString()};try{let s=J();return s.credentials[t]=r,ge(s),te(t),{success:!0}}catch(s){let n=s instanceof Error?s.message:String(s);throw rt.error("CRITICAL: Storage failed",{error:n.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***")}),new Error("Failed to store credentials")}}async function ke(e="github.com",t){let r=g(e);if(!t?.bypassCache){let i=re(r);if(i!==void 0)return i}let n=J().credentials[r]||null;return se(r,n),n}async function nt(e,t){let r=await ke(e);return r?(r.token=t,r.updatedAt=new Date().toISOString(),await st(r),!0):!1}async function ot(e,t){return Se({getCredentials:ke,updateToken:nt},e,t)}Ce({getTokenWithRefresh:ot});import{z as o}from"zod";var it=o.object({rawChars:o.number(),responseChars:o.number(),savedChars:o.number(),calls:o.number()}),at=o.object({hits:o.record(o.string(),o.number()).default({}),rateLimits:o.number().default(0)}),j=o.record(o.string(),o.number()).default({}),ct=o.object({toolCalls:o.number(),errors:o.number(),rateLimits:o.number(),rateLimitsByProvider:j,rawChars:o.number(),responseChars:o.number(),savedChars:o.number(),charSavingsCalls:o.number(),githubCacheHits:o.number(),githubCacheRateLimits:o.number(),packageRegistryFailures:o.number().default(0),packageRegistryFailuresByRegistry:j}),U=o.object({toolCalls:o.number(),errors:o.number(),rateLimits:o.number(),rateLimitsByProvider:j,charsSavedByTool:o.record(o.string(),it).default({}),githubCacheHits:at.default({hits:{},rateLimits:0}),packageRegistryFailures:j,totalUsage:ct.optional()}),Te=o.object({version:o.literal(1),sessionId:o.string(),createdAt:o.string(),lastActiveAt:o.string(),stats:U.optional()}),xe=o.object({version:o.literal(1),stats:U});function ye(e){return Object.values(e).reduce((t,r)=>t+r,0)}function ut(e){let t=e.charsSavedByTool??{},r=e.githubCacheHits??{hits:{},rateLimits:0},s=e.rateLimitsByProvider??{},n=e.packageRegistryFailures??{},i=Object.values(t).reduce((x,m)=>({rawChars:x.rawChars+m.rawChars,responseChars:x.responseChars+m.responseChars,savedChars:x.savedChars+m.savedChars,charSavingsCalls:x.charSavingsCalls+m.calls}),{rawChars:0,responseChars:0,savedChars:0,charSavingsCalls:0});return{toolCalls:e.toolCalls,errors:e.errors,rateLimits:e.rateLimits,rateLimitsByProvider:s,...i,githubCacheHits:ye(r.hits),githubCacheRateLimits:r.rateLimits,packageRegistryFailures:ye(n),packageRegistryFailuresByRegistry:n}}function d(e){let t={...e,rateLimitsByProvider:e.rateLimitsByProvider??{},charsSavedByTool:e.charsSavedByTool??{},githubCacheHits:e.githubCacheHits??{hits:{},rateLimits:0},packageRegistryFailures:e.packageRegistryFailures??{}};return{...t,totalUsage:ut(t)}}function H(){return d({toolCalls:0,errors:0,rateLimits:0,rateLimitsByProvider:{},charsSavedByTool:{},githubCacheHits:{hits:{},rateLimits:0},packageRegistryFailures:{}})}var be=S("session"),C=f.session,k=f.stats;function ve(e,t){let r=`${e}.tmp`;lt(r,JSON.stringify(t,null,2),{mode:384}),dt(r,e)}function pt(e){let{stats:t,...r}=e;return r}function mt(e){let t=JSON.parse(e),r=xe.safeParse(t);if(r.success)return d(r.data.stats);let s=U.safeParse(t);return s.success?d(s.data):null}function gt(e){let t=e?d(e):H();if(!Z(k))return t;try{let r=Re(k,"utf8"),s=mt(r);return s||(be.warn("Stats file has invalid format",{file:k}),t)}catch{return t}}function B(e){b(),ve(k,{version:e.version,stats:d(e.stats)}),ve(C,pt(e))}function Ee(){if(!Z(C))return null;try{let e=Re(C,"utf8"),t=JSON.parse(e),r=Te.safeParse(t);return r.success?{...r.data,stats:gt(r.data.stats)}:(be.warn("Session file has invalid format",{file:C}),null)}catch{return null}}function Le(){let e=!1;for(let t of[C,k])if(Z(t))try{ft(t),e=!0}catch{return!1}return e}var ht=6e4,l=null,h=!1,E=null,q=!1,O=null,D=null,_=null,z=!1;function St(){q||(q=!0,O=()=>{F()},D=()=>{F()},_=()=>{F()},process.on("exit",O),process.on("SIGINT",D),process.on("SIGTERM",_))}function Y(){O&&(process.removeListener("exit",O),O=null),D&&(process.removeListener("SIGINT",D),D=null),_&&(process.removeListener("SIGTERM",_),_=null),q=!1}function Ct(){E||(E=setInterval(()=>{h&&l&&(B(l),h=!1)},ht),E.unref())}function X(){E&&(clearInterval(E),E=null)}function L(){if(l)return l;let e=Ee();return e&&(l=e),e}function T(e){l=e,h=!0,St(),Ct()}function I(){h&&l&&(B(l),h=!1)}function F(){if(!z&&h&&l){z=!0;try{B(l),h=!1}catch{}finally{z=!1}}}function Q(){l=null,h=!1,z=!1}function we(){Q(),X(),Y()}var Tt=1;function xt(e){return d(e)}function yt(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 Ae(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 vt(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 Pe(){let e=new Date().toISOString();return{version:Tt,sessionId:kt(),createdAt:e,lastActiveAt:e,stats:H()}}function Rt(){return L()}function bt(e){T(e)}function Et(){I()}function Lt(){F()}function wt(e){if(e?.forceNew){let s=Pe();return T(s),I(),s}let t=L();if(t){let s={...t,lastActiveAt:new Date().toISOString()};return T(s),I(),s}let r=Pe();return T(r),I(),r}function At(){return L()?.sessionId??null}function p(e){let t=L();if(!t)return{success:!1,session:null};let r=xt(t.stats),s=d({toolCalls:r.toolCalls+(e.toolCalls??0),errors:r.errors+(e.errors??0),rateLimits:r.rateLimits+(e.rateLimits??0),rateLimitsByProvider:Ae(r.rateLimitsByProvider,e.rateLimitsByProvider),charsSavedByTool:yt(r.charsSavedByTool,e.charsSavedByTool),githubCacheHits:vt(r.githubCacheHits,e.githubCacheHits),packageRegistryFailures:Ae(r.packageRegistryFailures,e.packageRegistryFailures)}),n={...t,lastActiveAt:new Date().toISOString(),stats:s};return T(n),{success:!0,session:n}}function Pt(e=1){return p({toolCalls:e})}function Ht(e=1){return p({errors:e})}function Ot(e=1){return p({rateLimits:e})}function Dt(e,t=1){return p({rateLimits:t,rateLimitsByProvider:{[e]:t}})}function _t(e,t,r){let s=Number.isFinite(t)?Math.max(0,t):0,n=Number.isFinite(r)?Math.max(0,r):0;return p({charsSavedByTool:{[e]:{rawChars:s,responseChars:n,savedChars:Math.max(0,s-n),calls:1}}})}function Ft(e,t=1){return p({githubCacheHits:{hits:{[e]:t},rateLimits:0}})}function It(e=1){return p({githubCacheHits:{hits:{},rateLimits:e}})}function Nt(e,t=1){return p({packageRegistryFailures:{[e]:t}})}function Gt(){let e=L();if(!e)return{success:!1,session:null};let t={...e,lastActiveAt:new Date().toISOString(),stats:H()};return T(t),{success:!0,session:t}}function Mt(){return Q(),X(),Y(),Le()}function jt(){we()}export{C as SESSION_FILE,k as STATS_FILE,jt as _resetSessionState,Mt as deleteSession,Et as flushSession,Lt as flushSessionSync,wt as getOrCreateSession,At as getSessionId,Ht as incrementErrors,Ft as incrementGitHubCacheHits,It as incrementGitHubCacheRateLimits,Nt as incrementPackageRegistryFailures,Dt as incrementRateLimitByProvider,Ot as incrementRateLimits,Pt as incrementToolCalls,_t as incrementToolCharSavings,Rt as readSession,Gt as resetSessionStats,p as updateSessionStats,bt as writeSession};
@@ -0,0 +1,103 @@
1
+ import { z } from 'zod';
2
+ export declare const SessionStatsSchema: z.ZodObject<{
3
+ toolCalls: z.ZodNumber;
4
+ errors: z.ZodNumber;
5
+ rateLimits: z.ZodNumber;
6
+ rateLimitsByProvider: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
7
+ charsSavedByTool: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
8
+ rawChars: z.ZodNumber;
9
+ responseChars: z.ZodNumber;
10
+ savedChars: z.ZodNumber;
11
+ calls: z.ZodNumber;
12
+ }, z.core.$strip>>>;
13
+ githubCacheHits: z.ZodDefault<z.ZodObject<{
14
+ hits: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
15
+ rateLimits: z.ZodDefault<z.ZodNumber>;
16
+ }, z.core.$strip>>;
17
+ packageRegistryFailures: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
18
+ totalUsage: z.ZodOptional<z.ZodObject<{
19
+ toolCalls: z.ZodNumber;
20
+ errors: z.ZodNumber;
21
+ rateLimits: z.ZodNumber;
22
+ rateLimitsByProvider: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
23
+ rawChars: z.ZodNumber;
24
+ responseChars: z.ZodNumber;
25
+ savedChars: z.ZodNumber;
26
+ charSavingsCalls: z.ZodNumber;
27
+ githubCacheHits: z.ZodNumber;
28
+ githubCacheRateLimits: z.ZodNumber;
29
+ packageRegistryFailures: z.ZodDefault<z.ZodNumber>;
30
+ packageRegistryFailuresByRegistry: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
31
+ }, z.core.$strip>>;
32
+ }, z.core.$strip>;
33
+ export declare const PersistedSessionSchema: z.ZodObject<{
34
+ version: z.ZodLiteral<1>;
35
+ sessionId: z.ZodString;
36
+ createdAt: z.ZodString;
37
+ lastActiveAt: z.ZodString;
38
+ stats: z.ZodOptional<z.ZodObject<{
39
+ toolCalls: z.ZodNumber;
40
+ errors: z.ZodNumber;
41
+ rateLimits: z.ZodNumber;
42
+ rateLimitsByProvider: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
43
+ charsSavedByTool: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
44
+ rawChars: z.ZodNumber;
45
+ responseChars: z.ZodNumber;
46
+ savedChars: z.ZodNumber;
47
+ calls: z.ZodNumber;
48
+ }, z.core.$strip>>>;
49
+ githubCacheHits: z.ZodDefault<z.ZodObject<{
50
+ hits: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
51
+ rateLimits: z.ZodDefault<z.ZodNumber>;
52
+ }, z.core.$strip>>;
53
+ packageRegistryFailures: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
54
+ totalUsage: z.ZodOptional<z.ZodObject<{
55
+ toolCalls: z.ZodNumber;
56
+ errors: z.ZodNumber;
57
+ rateLimits: z.ZodNumber;
58
+ rateLimitsByProvider: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
59
+ rawChars: z.ZodNumber;
60
+ responseChars: z.ZodNumber;
61
+ savedChars: z.ZodNumber;
62
+ charSavingsCalls: z.ZodNumber;
63
+ githubCacheHits: z.ZodNumber;
64
+ githubCacheRateLimits: z.ZodNumber;
65
+ packageRegistryFailures: z.ZodDefault<z.ZodNumber>;
66
+ packageRegistryFailuresByRegistry: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
67
+ }, z.core.$strip>>;
68
+ }, z.core.$strip>>;
69
+ }, z.core.$strip>;
70
+ export declare const PersistedStatsSchema: z.ZodObject<{
71
+ version: z.ZodLiteral<1>;
72
+ stats: z.ZodObject<{
73
+ toolCalls: z.ZodNumber;
74
+ errors: z.ZodNumber;
75
+ rateLimits: z.ZodNumber;
76
+ rateLimitsByProvider: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
77
+ charsSavedByTool: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
78
+ rawChars: z.ZodNumber;
79
+ responseChars: z.ZodNumber;
80
+ savedChars: z.ZodNumber;
81
+ calls: z.ZodNumber;
82
+ }, z.core.$strip>>>;
83
+ githubCacheHits: z.ZodDefault<z.ZodObject<{
84
+ hits: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
85
+ rateLimits: z.ZodDefault<z.ZodNumber>;
86
+ }, z.core.$strip>>;
87
+ packageRegistryFailures: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
88
+ totalUsage: z.ZodOptional<z.ZodObject<{
89
+ toolCalls: z.ZodNumber;
90
+ errors: z.ZodNumber;
91
+ rateLimits: z.ZodNumber;
92
+ rateLimitsByProvider: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
93
+ rawChars: z.ZodNumber;
94
+ responseChars: z.ZodNumber;
95
+ savedChars: z.ZodNumber;
96
+ charSavingsCalls: z.ZodNumber;
97
+ githubCacheHits: z.ZodNumber;
98
+ githubCacheRateLimits: z.ZodNumber;
99
+ packageRegistryFailures: z.ZodDefault<z.ZodNumber>;
100
+ packageRegistryFailuresByRegistry: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
101
+ }, z.core.$strip>>;
102
+ }, z.core.$strip>;
103
+ }, z.core.$strip>;
@@ -0,0 +1,9 @@
1
+ import type { PersistedSession } from './types.js';
2
+ export declare function unregisterExitHandlers(): void;
3
+ export declare function stopFlushTimer(): void;
4
+ export declare function readSession(): PersistedSession | null;
5
+ export declare function writeSession(session: PersistedSession): void;
6
+ export declare function flushSession(): void;
7
+ export declare function flushSessionSync(): void;
8
+ export declare function clearCache(): void;
9
+ export declare function resetCacheState(): void;
@@ -0,0 +1,6 @@
1
+ import type { PersistedSession } from './types.js';
2
+ export declare const SESSION_FILE: string;
3
+ export declare const STATS_FILE: string;
4
+ export declare function writeSessionToDisk(session: PersistedSession): void;
5
+ export declare function readSessionFromDisk(): PersistedSession | null;
6
+ export declare function deleteSessionFile(): boolean;
@@ -0,0 +1,4 @@
1
+ import type { SessionStats, SessionTotalUsageStats } from './types.js';
2
+ export declare function calculateTotalUsageStats(stats: SessionStats): SessionTotalUsageStats;
3
+ export declare function withDerivedUsageTotals(stats: SessionStats): SessionStats;
4
+ export declare function createDefaultStats(): SessionStats;
@@ -0,0 +1,20 @@
1
+ import type { PersistedSession, SessionStats, SessionUpdateResult, SessionOptions } from './types.js';
2
+ export declare function readSession(): PersistedSession | null;
3
+ export declare function writeSession(session: PersistedSession): void;
4
+ export declare function flushSession(): void;
5
+ export declare function flushSessionSync(): void;
6
+ export declare function getOrCreateSession(options?: SessionOptions): PersistedSession;
7
+ export declare function getSessionId(): string | null;
8
+ export declare function updateSessionStats(updates: Partial<SessionStats>): SessionUpdateResult;
9
+ export declare function incrementToolCalls(count?: number): SessionUpdateResult;
10
+ export declare function incrementErrors(count?: number): SessionUpdateResult;
11
+ export declare function incrementRateLimits(count?: number): SessionUpdateResult;
12
+ export declare function incrementRateLimitByProvider(provider: string, count?: number): SessionUpdateResult;
13
+ export declare function incrementToolCharSavings(toolName: string, rawChars: number, responseChars: number): SessionUpdateResult;
14
+ export declare function incrementGitHubCacheHits(cacheName: string, count?: number): SessionUpdateResult;
15
+ export declare function incrementGitHubCacheRateLimits(count?: number): SessionUpdateResult;
16
+ export declare function incrementPackageRegistryFailures(registry: string, count?: number): SessionUpdateResult;
17
+ export declare function resetSessionStats(): SessionUpdateResult;
18
+ export declare function deleteSession(): boolean;
19
+ export declare function _resetSessionState(): void;
20
+ export { SESSION_FILE, STATS_FILE } from './sessionDiskIO.js';
@@ -0,0 +1,53 @@
1
+ export interface ToolCharSavingsStats {
2
+ rawChars: number;
3
+ responseChars: number;
4
+ savedChars: number;
5
+ calls: number;
6
+ }
7
+ export interface GitHubCacheHitStats {
8
+ hits: Record<string, number>;
9
+ rateLimits: number;
10
+ }
11
+ export type StatsCounterMap = Record<string, number>;
12
+ export interface SessionTotalUsageStats {
13
+ toolCalls: number;
14
+ errors: number;
15
+ rateLimits: number;
16
+ rateLimitsByProvider: StatsCounterMap;
17
+ rawChars: number;
18
+ responseChars: number;
19
+ savedChars: number;
20
+ charSavingsCalls: number;
21
+ githubCacheHits: number;
22
+ githubCacheRateLimits: number;
23
+ packageRegistryFailures: number;
24
+ packageRegistryFailuresByRegistry: StatsCounterMap;
25
+ }
26
+ export interface SessionStats {
27
+ toolCalls: number;
28
+ errors: number;
29
+ rateLimits: number;
30
+ rateLimitsByProvider?: StatsCounterMap;
31
+ charsSavedByTool?: Record<string, ToolCharSavingsStats>;
32
+ githubCacheHits?: GitHubCacheHitStats;
33
+ packageRegistryFailures?: StatsCounterMap;
34
+ totalUsage?: SessionTotalUsageStats;
35
+ }
36
+ export interface PersistedSession {
37
+ version: 1;
38
+ sessionId: string;
39
+ createdAt: string;
40
+ lastActiveAt: string;
41
+ stats: SessionStats;
42
+ }
43
+ export interface PersistedStats {
44
+ version: 1;
45
+ stats: SessionStats;
46
+ }
47
+ export interface SessionUpdateResult {
48
+ success: boolean;
49
+ session: PersistedSession | null;
50
+ }
51
+ export interface SessionOptions {
52
+ forceNew?: boolean;
53
+ }
@@ -1,6 +1,9 @@
1
1
  import type { CloneCacheMeta, CacheSource } from './types.js';
2
2
  export declare function getReposBaseDir(octocodeDir: string): string;
3
+ export declare function getCloneBaseDir(octocodeDir: string): string;
4
+ export declare function getTreeBaseDir(octocodeDir: string): string;
3
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;
4
7
  export declare function readCacheMeta(cloneDir: string): CloneCacheMeta | null;
5
8
  export declare function writeCacheMeta(cloneDir: string, meta: CloneCacheMeta): void;
6
9
  export declare function isCacheValid(meta: CloneCacheMeta): boolean;
@@ -17,5 +20,6 @@ export declare function createCacheMeta(owner: string, repo: string, branch: str
17
20
  export declare function ensureCloneParentDir(cloneDir: string): void;
18
21
  export declare function removeCloneDir(cloneDir: string): void;
19
22
  export declare function evictExpiredClones(octocodeDir: string): number;
23
+ export declare function evictExpiredTrees(octocodeDir: string): number;
20
24
  export declare function startCacheGC(octocodeDir: string): void;
21
25
  export declare function stopCacheGC(): void;
@@ -10,8 +10,8 @@ export declare const CloneRepoQueryLocalSchema: import("zod").ZodObject<{
10
10
  reasoning: import("zod").ZodOptional<import("zod").ZodString>;
11
11
  }, import("zod/v4/core").$strip>;
12
12
  export declare const BulkCloneRepoLocalSchema: import("zod").ZodObject<{
13
- responseCharOffset: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNumber>>;
14
- responseCharLength: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNumber>>;
13
+ responseCharOffset: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodNumber>>;
14
+ responseCharLength: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodNumber>>;
15
15
  queries: import("zod").ZodArray<import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>;
16
16
  }, import("zod/v4/core").$strip>;
17
17
  export declare const GitHubCloneRepoOutputLocalSchema: import("zod").ZodObject<{
@@ -21,24 +21,71 @@ export declare const GitHubCloneRepoOutputLocalSchema: import("zod").ZodObject<{
21
21
  }>>;
22
22
  data: import("zod").ZodOptional<import("zod").ZodObject<{
23
23
  localPath: import("zod").ZodString;
24
- branch: import("zod").ZodString;
25
- cached: import("zod").ZodBoolean;
24
+ resolvedBranch: import("zod").ZodOptional<import("zod").ZodString>;
25
+ cached: import("zod").ZodOptional<import("zod").ZodBoolean>;
26
26
  sparsePath: import("zod").ZodOptional<import("zod").ZodString>;
27
27
  cloneTimeMs: import("zod").ZodOptional<import("zod").ZodNumber>;
28
28
  totalSize: import("zod").ZodOptional<import("zod").ZodNumber>;
29
29
  fileCount: import("zod").ZodOptional<import("zod").ZodNumber>;
30
+ location: import("zod").ZodOptional<import("zod").ZodObject<{
31
+ kind: import("zod").ZodEnum<{
32
+ file: "file";
33
+ directory: "directory";
34
+ repo: "repo";
35
+ tree: "tree";
36
+ "archive-entry": "archive-entry";
37
+ }>;
38
+ localPath: import("zod").ZodString;
39
+ repoRoot: import("zod").ZodOptional<import("zod").ZodString>;
40
+ requestedPath: import("zod").ZodOptional<import("zod").ZodString>;
41
+ source: import("zod").ZodOptional<import("zod").ZodEnum<{
42
+ extract: "extract";
43
+ decompress: "decompress";
44
+ strings: "strings";
45
+ unpack: "unpack";
46
+ tree: "tree";
47
+ clone: "clone";
48
+ }>>;
49
+ cached: import("zod").ZodOptional<import("zod").ZodBoolean>;
50
+ complete: import("zod").ZodOptional<import("zod").ZodBoolean>;
51
+ resolvedBranch: import("zod").ZodOptional<import("zod").ZodString>;
52
+ }, import("zod/v4/core").$strip>>;
30
53
  }, import("zod/v4/core").$strip>>;
31
54
  localPath: import("zod").ZodOptional<import("zod").ZodString>;
32
- branch: import("zod").ZodOptional<import("zod").ZodString>;
55
+ resolvedBranch: import("zod").ZodOptional<import("zod").ZodString>;
33
56
  cached: import("zod").ZodOptional<import("zod").ZodBoolean>;
57
+ sparsePath: import("zod").ZodOptional<import("zod").ZodString>;
58
+ location: import("zod").ZodOptional<import("zod").ZodObject<{
59
+ kind: import("zod").ZodEnum<{
60
+ file: "file";
61
+ directory: "directory";
62
+ repo: "repo";
63
+ tree: "tree";
64
+ "archive-entry": "archive-entry";
65
+ }>;
66
+ localPath: import("zod").ZodString;
67
+ repoRoot: import("zod").ZodOptional<import("zod").ZodString>;
68
+ requestedPath: import("zod").ZodOptional<import("zod").ZodString>;
69
+ source: import("zod").ZodOptional<import("zod").ZodEnum<{
70
+ extract: "extract";
71
+ decompress: "decompress";
72
+ strings: "strings";
73
+ unpack: "unpack";
74
+ tree: "tree";
75
+ clone: "clone";
76
+ }>>;
77
+ cached: import("zod").ZodOptional<import("zod").ZodBoolean>;
78
+ complete: import("zod").ZodOptional<import("zod").ZodBoolean>;
79
+ resolvedBranch: import("zod").ZodOptional<import("zod").ZodString>;
80
+ }, import("zod/v4/core").$strip>>;
34
81
  warnings: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
35
82
  kind: import("zod").ZodString;
36
83
  }, import("zod/v4/core").$loose>]>>>;
37
84
  error: import("zod").ZodOptional<import("zod").ZodString>;
38
- readonly hints: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
39
- readonly base: import("zod").ZodOptional<import("zod").ZodString>;
40
- readonly shared: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodBoolean]>>>;
41
- readonly responsePagination: import("zod").ZodOptional<import("zod").ZodObject<{
85
+ hints: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
86
+ base: import("zod").ZodOptional<import("zod").ZodString>;
87
+ shared: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodBoolean]>>>;
88
+ responsePagination: import("zod").ZodOptional<import("zod").ZodObject<{
42
89
  currentPage: import("zod").ZodNumber;
43
90
  totalPages: import("zod").ZodNumber;
44
91
  hasMore: import("zod").ZodBoolean;
@@ -1,4 +1,4 @@
1
- export type CacheSource = 'clone' | 'directoryFetch';
1
+ export type CacheSource = 'clone' | 'directoryFetch' | 'treeFetch';
2
2
  export interface CloneCacheMeta {
3
3
  clonedAt: string;
4
4
  expiresAt: string;
@@ -32,8 +32,8 @@ export declare const FileContentQueryLocalSchema: z.ZodObject<{
32
32
  reasoning: z.ZodOptional<z.ZodString>;
33
33
  }, z.core.$strip>;
34
34
  export declare const FileContentBulkQueryLocalSchema: z.ZodObject<{
35
- responseCharOffset: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNumber>>;
36
- responseCharLength: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNumber>>;
35
+ responseCharOffset: z.ZodOptional<z.ZodPreprocess<z.ZodNumber>>;
36
+ responseCharLength: z.ZodOptional<z.ZodPreprocess<z.ZodNumber>>;
37
37
  queries: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
38
38
  }, z.core.$strip>;
39
39
  export declare const GitHubFetchContentOutputLocalSchema: z.ZodObject<{
@@ -55,6 +55,8 @@ export declare const GitHubFetchContentOutputLocalSchema: z.ZodObject<{
55
55
  files: z.ZodOptional<z.ZodArray<z.ZodObject<{
56
56
  path: z.ZodString;
57
57
  content: z.ZodString;
58
+ localPath: z.ZodOptional<z.ZodString>;
59
+ repoRoot: z.ZodOptional<z.ZodString>;
58
60
  contentView: z.ZodOptional<z.ZodEnum<{
59
61
  none: "none";
60
62
  standard: "standard";
@@ -69,6 +71,8 @@ export declare const GitHubFetchContentOutputLocalSchema: z.ZodObject<{
69
71
  currentPage: z.ZodNumber;
70
72
  totalPages: z.ZodNumber;
71
73
  hasMore: z.ZodBoolean;
74
+ nextPage: z.ZodOptional<z.ZodNumber>;
75
+ nextMatchPage: z.ZodOptional<z.ZodNumber>;
72
76
  charOffset: z.ZodOptional<z.ZodNumber>;
73
77
  charLength: z.ZodOptional<z.ZodNumber>;
74
78
  totalChars: z.ZodOptional<z.ZodNumber>;
@@ -92,10 +96,12 @@ export declare const GitHubFetchContentOutputLocalSchema: z.ZodObject<{
92
96
  warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
93
97
  matchNotFound: z.ZodOptional<z.ZodBoolean>;
94
98
  searchedFor: z.ZodOptional<z.ZodString>;
99
+ cached: z.ZodOptional<z.ZodBoolean>;
95
100
  }, z.core.$strip>>>;
96
101
  directories: z.ZodOptional<z.ZodArray<z.ZodObject<{
97
102
  path: z.ZodString;
98
103
  localPath: z.ZodString;
104
+ repoRoot: z.ZodOptional<z.ZodString>;
99
105
  fileCount: z.ZodNumber;
100
106
  totalSize: z.ZodNumber;
101
107
  files: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -107,14 +113,12 @@ export declare const GitHubFetchContentOutputLocalSchema: z.ZodObject<{
107
113
  resolvedBranch: z.ZodOptional<z.ZodString>;
108
114
  }, z.core.$strip>>>;
109
115
  }, z.core.$strip>>;
110
- hints: z.ZodOptional<z.ZodArray<z.ZodString>>;
111
116
  errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
112
117
  id: z.ZodString;
113
118
  owner: z.ZodOptional<z.ZodString>;
114
119
  repo: z.ZodOptional<z.ZodString>;
115
120
  path: z.ZodOptional<z.ZodString>;
116
121
  error: z.ZodString;
117
- hints: z.ZodOptional<z.ZodArray<z.ZodString>>;
118
122
  }, z.core.$strip>>>;
119
123
  }, z.core.$strip>;
120
124
  export type GitHubFetchContentOutputLocal = z.infer<typeof GitHubFetchContentOutputLocalSchema>;
@@ -49,6 +49,7 @@ export interface GitHubFileContentApiResult extends GitHubFileContentApiResultBa
49
49
  }
50
50
  export interface DirectoryFetchResult {
51
51
  localPath: string;
52
+ repoRoot: string;
52
53
  files: Array<{
53
54
  path: string;
54
55
  size: number;
@@ -63,4 +64,15 @@ export interface DirectoryFetchResult {
63
64
  branch: string;
64
65
  directoryPath: string;
65
66
  }
67
+ export interface FileMaterializationResult {
68
+ localPath: string;
69
+ repoRoot: string;
70
+ path: string;
71
+ size: number;
72
+ cached: boolean;
73
+ expiresAt: string;
74
+ owner: string;
75
+ repo: string;
76
+ branch: string;
77
+ }
66
78
  export {};
@@ -20,8 +20,8 @@ export declare const GitHubCodeSearchQueryLocalSchema: z.ZodObject<{
20
20
  reasoning: z.ZodOptional<z.ZodString>;
21
21
  }, z.core.$strip>;
22
22
  export declare const GitHubCodeSearchBulkQueryLocalSchema: z.ZodObject<{
23
- responseCharOffset: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNumber>>;
24
- responseCharLength: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNumber>>;
23
+ responseCharOffset: z.ZodOptional<z.ZodPreprocess<z.ZodNumber>>;
24
+ responseCharLength: z.ZodOptional<z.ZodPreprocess<z.ZodNumber>>;
25
25
  queries: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
26
26
  }, z.core.$strip>;
27
27
  export declare const GitHubCodeSearchOutputLocalSchema: z.ZodObject<{
@@ -40,7 +40,6 @@ export declare const GitHubCodeSearchOutputLocalSchema: z.ZodObject<{
40
40
  id: z.ZodString;
41
41
  data: z.ZodObject<{
42
42
  files: z.ZodArray<z.ZodObject<{
43
- id: z.ZodString;
44
43
  owner: z.ZodString;
45
44
  repo: z.ZodString;
46
45
  path: z.ZodString;
@@ -51,6 +50,7 @@ export declare const GitHubCodeSearchOutputLocalSchema: z.ZodObject<{
51
50
  matchIndices: z.ZodOptional<z.ZodArray<z.ZodObject<{
52
51
  start: z.ZodNumber;
53
52
  end: z.ZodNumber;
53
+ lineOffset: z.ZodNumber;
54
54
  }, z.core.$strip>>>;
55
55
  url: z.ZodOptional<z.ZodString>;
56
56
  }, z.core.$strip>>;
@@ -69,20 +69,20 @@ export declare const GitHubCodeSearchOutputLocalSchema: z.ZodObject<{
69
69
  }>>;
70
70
  totalMatchesCapped: z.ZodOptional<z.ZodBoolean>;
71
71
  hasMore: z.ZodBoolean;
72
+ nextPage: z.ZodOptional<z.ZodNumber>;
72
73
  uniqueFileCount: z.ZodOptional<z.ZodNumber>;
73
74
  }, z.core.$strip>>;
74
75
  }, z.core.$strip>;
75
76
  }, z.core.$strip>>;
76
- hints: z.ZodOptional<z.ZodArray<z.ZodString>>;
77
77
  emptyQueries: z.ZodOptional<z.ZodArray<z.ZodObject<{
78
78
  id: z.ZodString;
79
- hints: z.ZodOptional<z.ZodArray<z.ZodString>>;
80
79
  nonExistentScope: z.ZodOptional<z.ZodLiteral<true>>;
80
+ incompleteResults: z.ZodOptional<z.ZodLiteral<true>>;
81
81
  }, z.core.$strip>>>;
82
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
82
83
  errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
83
84
  id: z.ZodString;
84
85
  error: z.ZodString;
85
- hints: z.ZodOptional<z.ZodArray<z.ZodString>>;
86
86
  }, z.core.$strip>>>;
87
87
  }, z.core.$strip>;
88
88
  export type GitHubCodeSearchOutputLocal = z.infer<typeof GitHubCodeSearchOutputLocalSchema>;
@@ -14,5 +14,4 @@ type QueryLike = {
14
14
  matchString?: string;
15
15
  };
16
16
  export declare function shapePullRequestForContent(pr: Record<string, unknown>, query: QueryLike, request: NormalizedPrContentRequest, shouldMinify?: boolean, showContentMap?: boolean): Record<string, unknown>;
17
- export declare function buildContentHints(pullRequests: Array<Record<string, unknown>>, request: NormalizedPrContentRequest): string[];
18
17
  export {};
@@ -1,17 +1,7 @@
1
1
  import { type CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
2
  import type { z } from 'zod';
3
3
  import { GitHubPullRequestSearchQueryLocalSchema } from './scheme.js';
4
- type GitHubPullRequestSearchQuery = z.infer<typeof GitHubPullRequestSearchQueryLocalSchema>;
5
- import type { ToolExecutionArgs, WithOptionalMeta } from '../../types/execution.js';
4
+ import type { ToolExecutionArgs } from '../../types/execution.js';
6
5
  type GitHubPullRequestSearchInput = z.input<typeof GitHubPullRequestSearchQueryLocalSchema>;
7
- type PartialPRQuery = WithOptionalMeta<GitHubPullRequestSearchQuery>;
8
6
  export declare function searchMultipleGitHubPullRequests(args: ToolExecutionArgs<GitHubPullRequestSearchInput>): Promise<CallToolResult>;
9
- export declare function buildPRSearchOutput(input: {
10
- data: Record<string, unknown>;
11
- pullRequests: Array<Record<string, unknown>>;
12
- extraHints: string[];
13
- }, _query: PartialPRQuery): {
14
- data: Record<string, unknown>;
15
- extraHints: string[];
16
- };
17
7
  export {};