@octocodeai/octocode-tools-core 18.0.1 → 18.1.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.
- package/README.md +231 -98
- package/dist/direct.d.ts +1 -1
- package/dist/direct.js +28 -30
- package/dist/github/compare.d.ts +18 -9
- package/dist/index.js +30 -32
- package/dist/schema.js +1 -1
- package/dist/tools/directToolCatalog/toolCatalogFormatters.d.ts +0 -7
- package/dist/tools/github_clone_repo/scheme.d.ts +38 -20
- package/dist/tools/github_fetch_content/finalizer/types.d.ts +2 -0
- package/dist/tools/github_search_pull_requests/contentResponse/fileSurfaces.d.ts +1 -2
- package/dist/tools/github_search_pull_requests/splitSchemes.d.ts +3 -0
- package/dist/utils/file/configFiles.d.ts +70 -0
- package/package.json +3 -3
package/dist/schema.js
CHANGED
|
@@ -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{completeMetadata as kt}from"@octocodeai/octocode-core";var s=kt.toolNames,S=s.LSP_GET_SEMANTIC_CONTENT;function q(e=process.env){let t=e.ENABLE_RELEASES;return t===void 0?!1:["1","true","yes","on"].includes(t.trim().toLowerCase())}function w(e=process.env){let t=e.ENABLE_DISCUSSIONS;return t===void 0?!1:["1","true","yes","on"].includes(t.trim().toLowerCase())}var Pr=new Set([s.LOCAL_RIPGREP,s.LOCAL_FETCH_CONTENT,s.LOCAL_FIND_FILES,s.LOCAL_VIEW_STRUCTURE,S]);var Ae=["definition","references","callers","callees","callHierarchy","hover","documentSymbols","typeDefinition","implementation","workspaceSymbol","supertypes","subtypes","diagnostic"];import{CloneRepoQuerySchema as It}from"@octocodeai/octocode-core/schemas";import{z as F}from"zod";function a(e,t){return F.preprocess(r=>typeof r=="number"&&Number.isFinite(r)?Math.min(Math.max(r,e),t):r,F.number().int().min(e).max(t))}var m=a(1,1e3).optional().default(1),R=a(0,100).optional(),E=a(1,1e9).optional(),Dt={responseCharOffset:a(0,1e8).optional().describe("Full-response char offset; re-call with returned value when hasMore."),responseCharLength:a(1,5e4).optional().describe("Full-response char window.")};function u(e,t={}){let{maxQueries:r=5}=t;return F.object({queries:F.array(e).min(1).max(r).describe("Parallel queries."),...Dt}).superRefine((n,i)=>{let o=new Set;n.queries.forEach((c,d)=>{c&&typeof c=="object"&&"id"in c&&typeof c.id=="string"&&(o.has(c.id)&&i.addIssue({code:"custom",message:`Duplicate query id "${c.id}" at index ${d}`,path:["queries",d,"id"]}),o.add(c.id))})})}import{z as Pe}from"zod";function At(e,t){return e?.description&&!t.description?t.describe(e.description):t}function Ie(e,t){let r={};for(let[n,i]of Object.entries(t))r[n]=At(e.shape[n],i);return r}function Pt(e,t){let r=e;return r.safeExtend?r.safeExtend(t):e.extend(t)}function we(e,t){if(!t?.length)return e;let r=new Set(t);return Pe.object(Object.fromEntries(Object.entries(e.shape).filter(([n])=>!r.has(n))))}function l(e,t={},r={}){let n=we(e,r.omit),i=Pt(n,Ie(n,t));return r.strict?i.strict():i}function p(e,t={},r={}){let n=we(e,r.omit),i=Pe.object({...n.shape,...Ie(n,t)});return r.strict?i.strict():i}var Q=l(It),z=u(Q);import{z as wt}from"zod";import{FileContentQuerySchema as Fe}from"@octocodeai/octocode-core/schemas";var Ft=wt.enum(["none","standard","symbols"]).optional(),Qe={startLine:E,endLine:E,contextLines:R,charOffset:a(0,1e8).optional(),charLength:a(1,5e4).optional(),minify:Ft},Qt=p(Fe,Qe),V=l(Fe,Qe),$=u(Qt);import{z as Gt}from"zod";import{GitHubCodeSearchQuerySchema as Ge}from"@octocodeai/octocode-core/schemas";var He={limit:a(1,100).optional(),page:m.default(1),match:Gt.enum(["file","path"]).default("file").describe('"file" searches file contents and returns snippets with matchIndices. "path" searches only file paths/names \u2014 no snippets, far cheaper; use it to confirm a file exists before reading it. (Unlike ghSearchRepos/ghSearchPullRequests, where `match` instead selects which text FIELDS to search \u2014 a different concept sharing this name.)')},X=l(Ge,He),W=u(p(Ge,He));import{z as Z}from"zod";import{GitHubPullRequestSearchQuerySchema as Ne}from"@octocodeai/octocode-core/schemas";var Be={type:Z.enum(["prs","commits","releases","issues"]).optional().describe('Research mode: "prs" (default) searches pull requests; "commits" walks commit history for a repo or path; "releases" lists the repository releases (tagName, publishedAt, prerelease flag) and surfaces the latest stable release; "issues" searches or reads GitHub issues (body/discussion comments \u2014 not PRs).'),prNumber:a(1,1e9).optional(),issueNumber:a(1,1e9).optional().describe('Issue number for type:"issues" detail mode \u2014 reads that specific issue (body/discussion comments). Requires owner+repo. Falls back to prNumber if omitted.'),limit:a(1,100).optional().default(30),match:Z.array(Z.enum(["title","body","comments"])).optional().describe('Fields to match keywords against: "title", "body", "comments". Default searches all three. Use ["title"] for the most precise and fastest match. (Unlike ghSearchCode, where `match` instead selects file-contents vs file-paths \u2014 a different concept sharing this name.)'),page:m.default(1),filePage:m.optional(),commentPage:m.optional(),commitPage:m.optional(),itemsPerPage:a(1,100).optional().default(20),charOffset:a(0,1e8).optional(),commentBodyOffset:a(0,1e8).optional(),charLength:a(1,5e4).optional()},Ht=p(Ne,Be),Nt=l(Ne,Be),Bt=u(Ht);import{SearchPullRequestsQuerySchema as Me,SearchIssuesQuerySchema as ve,SearchCommitsQuerySchema as Ue,ListReleasesQuerySchema as qe}from"@octocodeai/octocode-core/schemas";var je={limit:a(1,100).optional().default(30),page:m.default(1),itemsPerPage:a(1,100).optional().default(20)},ze={...je,filePage:m.optional(),commentPage:m.optional(),commitPage:m.optional(),charOffset:a(0,1e8).optional(),commentBodyOffset:a(0,1e8).optional(),charLength:a(1,1e5).optional()},K=l(Me,ze),Y=u(p(Me,ze)),Ve={...je,commentPage:m.optional(),charOffset:a(0,1e8).optional(),commentBodyOffset:a(0,1e8).optional(),charLength:a(1,1e5).optional()},ee=l(ve,Ve),te=u(p(ve,Ve)),$e={page:m.default(1),limit:a(1,100).optional().describe("Commits per page \u2014 alias of itemsPerPage (preferred when both are set).")},re=l(Ue,$e),ne=u(p(Ue,$e)),Xe={page:m.default(1),limit:a(1,100).optional().describe("Releases per page \u2014 alias of itemsPerPage (preferred when both are set).")},G=l(qe,Xe),H=u(p(qe,Xe));import{SearchDiscussionsQuerySchema as We}from"@octocodeai/octocode-core/schemas";var Ze={itemsPerPage:a(1,100).optional().default(20),limit:a(1,100).optional()},N=l(We,Ze),B=u(p(We,Ze));import{z as Je}from"zod";import{GitHubReposSearchSingleQuerySchema as Ke}from"@octocodeai/octocode-core/schemas";var Ye={limit:a(1,100).optional(),page:m.default(1),match:Je.array(Je.enum(["name","description","readme"])).optional().describe("Which text fields to search: name, description, and/or readme. Defaults to name+description; add 'readme' for broader, slower full-text search. (Unlike ghSearchCode, where `match` instead selects file-contents vs file-paths \u2014 a different concept sharing this name.)")},oe=l(Ke,Ye),ie=u(p(Ke,Ye));import{GitHubViewRepoStructureQuerySchema as et}from"@octocodeai/octocode-core/schemas";var tt={maxDepth:a(0,20).optional(),page:m.default(1),itemsPerPage:a(1,200).optional()},ae=l(et,tt),se=u(p(et,tt));import{z as M}from"zod";import{NpmPackageQuerySchema as rt}from"@octocodeai/octocode-core/schemas";var nt={page:m,keywords:M.union([M.string(),M.array(M.string())]).optional().describe("Registry keyword query (string; an array of terms is accepted and joined with spaces).")},ce=l(rt,nt),ue=u(p(rt,nt,{strict:!0}),{maxQueries:5});import{z as vt}from"zod";import{FetchContentQuerySchema as ot}from"@octocodeai/octocode-core/schemas";var Ut=vt.enum(["none","standard","symbols"]).optional(),it={startLine:E,endLine:E,contextLines:R.default(5),charOffset:a(0,1e8).optional(),charLength:a(1,5e4).optional(),minify:Ut},qt=p(ot,it),le=l(ot,it),me=u(qt,{maxQueries:5});import{z as pe}from"zod";import{FindFilesQuerySchema as jt}from"@octocodeai/octocode-core/schemas";var at={maxDepth:a(0,100).optional(),minDepth:a(0,100).optional(),limit:a(1,1e4).optional().describe("Discovery cap applied after sort, before pagination \u2014 total results are capped here; itemsPerPage/page page within that cap."),page:m.default(1),itemsPerPage:a(1,50).optional(),excludeDir:pe.array(pe.string()).optional().describe("Directory names to prune from the walk. Common generated/vendor dirs are pruned by default (node_modules, .git, dist, build, out, coverage, target, .next, .cache); pass [] to prune nothing, or pass an explicit list to choose pruned dirs.")},st=pe.object(Object.fromEntries(Object.entries(jt.shape).filter(([e])=>e!=="regexType")));function zt(e,t){e.minDepth!==void 0&&e.maxDepth!==void 0&&e.minDepth>e.maxDepth&&t.addIssue({code:"custom",message:"minDepth must be less than or equal to maxDepth.",path:["minDepth"]})}var Vt=p(st,at),he=l(st,at).superRefine(zt),ge=u(Vt,{maxQueries:5});import{FindDeadCodeQuerySchema as ct}from"@octocodeai/octocode-core/schemas";var ut={maxFiles:a(1,5e4).optional(),limit:a(1,5e3).optional(),page:m.default(1),itemsPerPage:a(1,50).optional()},$t=p(ct,ut),ye=l(ct,ut),fe=u($t,{maxQueries:5});import{z as T}from"zod";import{RipgrepQuerySchema as lt}from"@octocodeai/octocode-core/schemas";var Xt=["paginated","discovery","detailed","structural"],Wt=["semanticRanking"],mt={mode:T.enum(Xt).optional().default("paginated").describe('"paginated" snippets; "discovery" paths only; "detailed" snippets plus context; "structural" AST/code-shape search with pattern or rule. Structural matches return line/capture anchors that can feed lspGetSemantics when symbol identity matters. (Unrelated to ghSearchPullRequests\'s `content.patches.mode` \u2014 different concepts sharing this name.)'),searchText:T.string().optional().describe('The search pattern. regex:"fixed" for a literal match, "perl" for advanced features (lookaheads, backreferences), else "smart". (Unlike ghSearchCode/ghSearchRepos, where `keywords` is an array of ANDed terms \u2014 this is a single string.)'),output:T.enum(["content","files","filesWithout","countLines","countMatches","matchOnly"]).optional().default("content").describe('"content" (default) matches with line text; "files"/"filesWithout" return matching/non-matching paths; "countLines"/"countMatches" return per-file counts; "matchOnly" returns just the matched substring (required for unique/matchWindow). ("files" is unlike localViewStructure\'s `filesOnly`, which filters a directory listing to file entries.)'),pattern:T.string().optional().describe("Structural only: code-shaped AST pattern with $X (one node) or $$$ARGS (node list). Modifiers are part of the node \u2014 `function $NAME` does not match `async function` or `export function`; include the modifiers or use a YAML `kind` rule for modifier-agnostic matches. Use this to find syntax shape, then use lspGetSemantics for semantic proof."),maxDepth:a(0,20).optional().describe("Keep files at most this many directory levels below the search root (0 = files directly in the root). Structural mode pushes this into the native walker; text/regex mode applies it after the native search and emits a warning when it filters deeper matches."),rule:T.string().optional().describe("Structural only: YAML ast-grep rule for not/inside/has/all/any. Use for partial or relational AST queries before escalating matched anchors to lspGetSemantics."),captureText:T.boolean().optional().describe("Structural only: return full verbatim capture text for `$$$` list metavars (bodies, arg lists). Default false \u2014 list-capture text is omitted from `metavars`, and `metavarRanges` entries are comment-pruned and truncated to keep results lean; ranges always remain as line anchors."),contextLines:R,matchContentLength:a(1,1e5).optional().default(500),maxMatchesPerFile:a(1,1e5).optional(),maxFiles:a(1,1e5).optional(),matchPage:m.optional(),itemsPerPage:a(1,1e3).optional(),page:m.default(1),unique:T.enum(["off","list","count"]).optional().default("off").describe('Needs output:"matchOnly". "list" returns each matched value once per file; "count" adds its frequency.')},Zt={...mt,semanticRanking:T.unknown().optional().superRefine((e,t)=>{e!==void 0&&t.addIssue({code:"custom",message:'semanticRanking is disabled in this build \u2014 sort:"relevance" already includes declaration/export/AST signals; remove this field.'})}).describe('DISABLED in this build \u2014 do not pass. sort:"relevance" already includes declaration/export/AST signals.')},Jt=p(lt,Zt),Kt=l(lt,mt,{strict:!0,omit:Wt}),be=Kt.superRefine((e,t)=>{if(e.mode==="structural"){!e.pattern&&!e.rule&&t.addIssue({code:"custom",message:'mode:"structural" requires `pattern` or `rule`.',path:["pattern"]}),e.pattern&&e.rule&&t.addIssue({code:"custom",message:"`pattern` and `rule` are mutually exclusive.",path:["rule"]}),e.wholeWord&&t.addIssue({code:"custom",message:'`wholeWord` is not valid with mode:"structural".',path:["wholeWord"]}),e.invertMatch&&t.addIssue({code:"custom",message:'`invertMatch` is not valid with mode:"structural".',path:["invertMatch"]}),e.regex&&e.regex!=="smart"&&t.addIssue({code:"custom",message:'`regex` is not valid with mode:"structural".',path:["regex"]}),e.caseMode&&e.caseMode!=="smart"&&t.addIssue({code:"custom",message:'`caseMode` is not valid with mode:"structural".',path:["caseMode"]}),e.multiline&&e.multiline!=="off"&&t.addIssue({code:"custom",message:'`multiline` is not valid with mode:"structural".',path:["multiline"]}),e.output&&e.output!=="content"&&e.output!=="countMatches"&&e.output!=="files"&&t.addIssue({code:"custom",message:'With mode:"structural", `output` supports only "content" (default), "countMatches" (per-file counts, no match content \u2014 cheapest for counting), or "files" (paths only).',path:["output"]}),e.unique&&e.unique!=="off"&&t.addIssue({code:"custom",message:'`unique` is not valid with mode:"structural".',path:["unique"]});let r=e.pattern&&!["php","bash","sh","zsh"].includes(e.langType??"")?/(?<!\$)\$\$(?!\$)[A-Z_][A-Z0-9_]*/.exec(e.pattern):null;if(r){let n=r[0].slice(2);t.addIssue({code:"custom",message:`\`${r[0]}\` is not a metavariable and matches nothing \u2014 use \`$${n}\` for one node or \`$$$${n}\` for a list of nodes.`,path:["pattern"]})}return}(e.pattern||e.rule)&&t.addIssue({code:"custom",message:'`pattern`/`rule` require mode:"structural".',path:[e.pattern?"pattern":"rule"]}),e.searchText||t.addIssue({code:"custom",message:'`searchText` is required unless mode:"structural".',path:["searchText"]}),e.matchWindow!==void 0&&e.output!=="matchOnly"&&t.addIssue({code:"custom",message:'matchWindow requires output:"matchOnly".',path:["matchWindow"]}),(e.unique==="list"||e.unique==="count")&&e.output!=="matchOnly"&&t.addIssue({code:"custom",message:'unique requires output:"matchOnly".',path:["unique"]})}),Le=u(Jt,{maxQueries:5});import{z as pt}from"zod";import{ViewStructureQuerySchema as dt}from"@octocodeai/octocode-core/schemas";var ht={excludeDir:pt.array(pt.string()).optional().describe("Directory names to prune from recursive walks (default: common generated/vendor dirs such as node_modules, dist, build, out, coverage, target). Pass [] to inspect everything."),maxDepth:a(0,20).optional(),limit:a(1,1e4).optional(),page:m.default(1),itemsPerPage:a(1,50).optional()},Yt=p(dt,ht),Te=l(dt,ht),Ce=u(Yt,{maxQueries:5});import{z as v}from"zod";import{LspGetSemanticsQuerySchema as gt}from"@octocodeai/octocode-core/schemas";var er=a(1,1e9).describe("1-based source line for symbol-anchored semantic operations. Get it from search/localSearchCode, structural AST captures, or documentSymbols; never guess."),tr=a(0,1e5).optional(),rr=["structured","compact"],yt={type:v.enum(Ae).default("definition").describe("Semantic operation for local code intelligence. Use after text or structural AST search when you need identity, references, call flow, type relations, hover, symbols, or diagnostics."),symbolName:v.string().min(1).max(1024).optional().describe("Exact bare identifier at the lineHint anchor for symbol operations; workspaceSymbol uses this as the fuzzy project-wide symbol query."),lineHint:er.optional(),orderHint:tr,depth:a(0,20).optional().describe("Traversal depth for call-hierarchy / type-hierarchy queries (0 = direct only)."),includeDeclaration:v.boolean().optional().default(!0),page:m.describe("Result page for paginated reference/symbol lists (advance while pagination.hasMore)."),itemsPerPage:a(1,100).optional().describe("References/symbols returned per page (with page)."),contextLines:a(0,100).optional().describe("Lines of surrounding source shown around each result location."),format:v.enum(rr).optional().default("structured")},nr=p(gt,yt),xe=l(gt,yt);var _e=u(nr,{maxQueries:5});var ft=["GitHub","Local Code","Package","Other"],St=new Map([s.GITHUB_SEARCH_CODE,s.GITHUB_SEARCH_REPOSITORIES,s.GITHUB_PULL_REQUESTS,s.GITHUB_ISSUES,s.GITHUB_COMMITS,s.GITHUB_FETCH_CONTENT,s.GITHUB_VIEW_REPO_STRUCTURE,s.GITHUB_CLONE_REPO,s.LOCAL_RIPGREP,s.LOCAL_FIND_FILES,s.LOCAL_FIND_DEAD_CODE,s.LOCAL_FETCH_CONTENT,s.LOCAL_VIEW_STRUCTURE,S,s.PACKAGE_SEARCH,...w()?[s.GITHUB_DISCUSSIONS]:[]].map((e,t)=>[e,t])),f=class extends Error{constructor(r,n=[]){super(r);this.details=n;this.name="DirectToolInputError"}details},or=["id","mainResearchGoal","researchGoal","reasoning"],I=new Set([...or]),ir=[{name:s.GITHUB_SEARCH_CODE,schema:X,inputSchema:W},{name:s.GITHUB_FETCH_CONTENT,schema:V,inputSchema:$},{name:s.GITHUB_VIEW_REPO_STRUCTURE,schema:ae,inputSchema:se},{name:s.GITHUB_SEARCH_REPOSITORIES,schema:oe,inputSchema:ie},{name:s.GITHUB_PULL_REQUESTS,schema:K,inputSchema:Y},{name:s.GITHUB_ISSUES,schema:ee,inputSchema:te},{name:s.GITHUB_COMMITS,schema:re,inputSchema:ne},...q()?[{name:s.GITHUB_RELEASES,schema:G,inputSchema:H}]:[],...w()?[{name:s.GITHUB_DISCUSSIONS,schema:N,inputSchema:B}]:[],{name:s.PACKAGE_SEARCH,schema:ce,inputSchema:ue},{name:s.GITHUB_CLONE_REPO,schema:Q,inputSchema:z},{name:s.LOCAL_RIPGREP,schema:be,inputSchema:Le},{name:s.LOCAL_VIEW_STRUCTURE,schema:Te,inputSchema:Ce},{name:s.LOCAL_FIND_FILES,schema:he,inputSchema:ge},{name:s.LOCAL_FIND_DEAD_CODE,schema:ye,inputSchema:fe},{name:s.LOCAL_FETCH_CONTENT,schema:le,inputSchema:me},{name:S,schema:xe,inputSchema:_e}],ar=[...q()?[]:[{name:s.GITHUB_RELEASES,schema:G,inputSchema:H,disabled:{envVar:"ENABLE_RELEASES"}}],...w()?[]:[{name:s.GITHUB_DISCUSSIONS,schema:N,inputSchema:B,disabled:{envVar:"ENABLE_DISCUSSIONS"}}]];function C(e){return ir.find(t=>t.name===e)??ar.find(t=>t.name===e)}function k(e){return e.startsWith("gh")?"GitHub":e.startsWith("local")||e.startsWith("lsp")?"Local Code":e===s.PACKAGE_SEARCH?"Package":"Other"}function Bo(e){return[...e].sort((t,r)=>{let n=ft.indexOf(k(t)),i=ft.indexOf(k(r));if(n!==i)return n-i;let o=St.get(t)??Number.MAX_SAFE_INTEGER,c=St.get(r)??Number.MAX_SAFE_INTEGER;return o!==c?o-c:t.localeCompare(r)})}import{z as bt}from"zod";var sr=["id","researchGoal","reasoning"],Lt=[{name:"content",type:"Array<{ type: string; text: string }>"},{name:"structuredContent",type:"object",optional:!0},{name:"isError",type:"boolean",optional:!0}];function qo(e){let t=C(e);if(!t)return"{}";try{return JSON.stringify(bt.toJSONSchema(t.inputSchema,{io:"input"}),null,2)}catch{return JSON.stringify(bt.toJSONSchema(t.schema,{io:"input"}),null,2)}}function jo(e){return JSON.stringify(e??{},null,2)}function zo(e){let t=k(e),r=[...sr];return(t==="GitHub"||t==="Package")&&r.splice(1,0,"mainResearchGoal"),r}function Vo(){return Lt.map(e=>({...e}))}function $o(){return JSON.stringify(Object.fromEntries(Lt.map(e=>[e.name,e.optional?`${e.type} (optional)`:e.type])),null,2)}function Xo(e,t){return t?.tools?.[e]?.description??e}import{z as cr}from"zod";function U(e){let t=C(e);if(!t)return[];let r=cr.toJSONSchema(t.schema,{io:"input"});if(!O(r))return[];let n=b(r.properties)?r.properties:{},i=new Set(Array.isArray(r.required)?r.required.filter(o=>!I.has(o)&&!ke(n[o])):[]);return Ee(n,i)}function ur(e){let t=[],r=typeof e.minimum=="number"?e.minimum:void 0,n=typeof e.maximum=="number"?e.maximum:void 0;return r!==void 0&&n!==void 0?t.push(`${r}-${n}`):r!==void 0?t.push(`>=${r}`):n!==void 0&&t.push(`<=${n}`),"default"in e&&t.push(`default ${JSON.stringify(e.default)}`),t.length>0?t.join(", "):void 0}function Re(e){if(Array.isArray(e.enum)&&e.enum.length>0)return`enum(${e.enum.map(String).join(", ")})`;if(e.type==="array"){let r=O(e.items)?e.items:void 0;return`array<${r?Re(r):"value"}>`}let t=Array.isArray(e.anyOf)?e.anyOf:Array.isArray(e.oneOf)?e.oneOf:void 0;if(t){let r=t.filter(O).map(Re).filter(n=>n!=="value");if(r.length>0)return[...new Set(r)].join(" | ")}return Array.isArray(e.type)?e.type.join(" | "):typeof e.type=="string"?e.type:"value"}function Ee(e,t,r=""){let n=[];for(let[i,o]of Object.entries(e)){if(!r&&I.has(i))continue;let c=O(o)?o:{},d=r?`${r}.${i}`:i;if(n.push({name:d,required:t.has(i),type:Re(c),constraints:ur(c),description:typeof c.description=="string"?c.description:void 0}),b(c.properties)){let g=new Set(Array.isArray(c.required)?c.required.filter(y=>typeof y=="string"?!ke(c.properties?.[y]):!1):[]);n.push(...Ee(c.properties,g,d))}let h=c.type==="array"&&O(c.items)?c.items:void 0;if(h&&b(h.properties)){let g=new Set(Array.isArray(h.required)?h.required.filter(y=>typeof y=="string"?!ke(h.properties?.[y]):!1):[]);n.push(...Ee(h.properties,g,d))}}return n}function Ct(e,t){if(t.startsWith("array<")){let r=t.slice(6,-1);return[Tt(e,r)]}return Tt(e,t)}function Tt(e,t){if(t.startsWith("enum("))return/^enum\(([^,)]+)/.exec(t)?.[1]??e;if(t==="integer"||t==="number")return e==="lineHint"?42:5;if(t==="boolean")return!0;switch(e){case"keywords":case"keywordsToSearch":case"query":case"text":return"runCLI";case"path":return".";case"uri":return"/path/to/file.ts";case"owner":return"bgauryy";case"repo":return"octocode";case"extension":return"ts";case"filename":return"package.json";case"language":return"TypeScript";case"symbolName":return"myFunction";case"name":case"packageName":return"zod";default:return e}}function b(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function O(e){return b(e)}function ke(e){return O(e)&&"default"in e}function xt(e){return e===s.GITHUB_PULL_REQUESTS?[{label:"PR search (list)",query:{owner:"bgauryy",repo:"octocode",keywordsToSearch:["localSearchCode"],concise:!0,limit:5}},{label:"PR detail (diffs + reviews)",query:{owner:"sindresorhus",repo:"slugify",prNumber:1,content:{comments:{discussion:!0},reviews:!0,patches:{mode:"all"}}}}]:e===s.GITHUB_SEARCH_CODE?[{label:"path search",query:{keywords:["package.json"],owner:"bgauryy",repo:"octocode",match:"path",concise:!0,limit:5}},{label:"content search",query:{keywords:["localSearchCode"],owner:"bgauryy",repo:"octocode",extension:"ts",limit:5}}]:e===s.GITHUB_SEARCH_REPOSITORIES?[{label:"repository search",query:{keywords:["react"],language:"TypeScript",stars:">1000",concise:!0,limit:5}},{label:"owner repositories",query:{owner:"bgauryy",concise:!0,limit:5}}]:e===s.GITHUB_VIEW_REPO_STRUCTURE?[{label:"repo tree",query:{owner:"bgauryy",repo:"octocode",path:"packages",maxDepth:2,itemsPerPage:50}}]:e===s.GITHUB_CLONE_REPO?[{label:"full repo clone",query:{owner:"bgauryy",repo:"octocode"}},{label:"subtree clone",query:{owner:"bgauryy",repo:"octocode",sparsePath:"packages/octocode-tools-core"}}]:e===s.LOCAL_RIPGREP?[{label:"text search",query:{path:"packages/octocode-tools-core/src",searchText:"buildDirectToolCommandPatterns",maxFiles:20}},{label:"structural code search",query:{path:"packages/octocode-tools-core/src/tools",mode:"structural",pattern:"eval($X)"}}]:e===s.LOCAL_FETCH_CONTENT?[{label:"exact line range",query:{path:"packages/octocode-tools-core/package.json",startLine:1,endLine:30,minify:"none"}},{label:"matched slice",query:{path:"packages/octocode-tools-core/src/tools/directToolCatalog.meta.ts",matchString:"buildKnownDirectToolCommandPatternQueries",contextLines:8,minify:"standard"}}]:e===s.LOCAL_FIND_FILES?[{label:"basename globs",query:{path:"packages/octocode-tools-core",names:["scheme.ts","package.json"],entryType:"f",itemsPerPage:20}},{label:"monorepo path glob",query:{path:".",pathPattern:"packages/*/src/tools/**",entryType:"f",itemsPerPage:20}},{label:"prune build dirs",query:{path:"packages/octocode-tools-core",names:["*.js"],entryType:"f",excludeDir:["node_modules","dist","coverage","out"],itemsPerPage:20}}]:e===s.LOCAL_FIND_DEAD_CODE?[{label:"default entrypoints (package.json + tests)",query:{path:"packages/octocode-tools-core",itemsPerPage:20}},{label:"explicit entrypoints",query:{path:"packages/octocode-tools-core",entrypoints:["src/index.ts","src/direct.ts"],includeTests:!1}}]:e===s.LOCAL_VIEW_STRUCTURE?[{label:"shallow tree",query:{path:"packages/octocode-tools-core/src/tools",maxDepth:2,itemsPerPage:50}},{label:"files only at depth 1",query:{path:"packages/octocode-engine/src",maxDepth:1,entryType:"f",itemsPerPage:100}}]:e===s.GITHUB_FETCH_CONTENT?[{label:"matched slice (cheap read of one function)",query:{owner:"bgauryy",repo:"octocode",path:"packages/octocode-tools-core/src/responses.ts",matchString:"export function cleanJsonObject",contextLines:8}},{label:"symbols outline (unknown/large file)",query:{owner:"bgauryy",repo:"octocode",path:"packages/octocode-tools-core/src/responses.ts",minify:"symbols"}}]:e===s.GITHUB_COMMITS?[{label:"file history (bounded window)",query:{owner:"bgauryy",repo:"octocode",path:"packages/octocode-tools-core/src/responses.ts",since:"6m",itemsPerPage:10}},{label:"compare two refs (base...head)",query:{owner:"bgauryy",repo:"octocode",base:"main",head:"update-tools"}}]:e===s.PACKAGE_SEARCH?[{label:"exact package \u2192 source repo",query:{packageName:"zod"}},{label:"keyword discovery (paged candidates)",query:{packageName:"schema validation",page:1}}]:e===S?[{label:"symbol outline (absolute uri)",query:{uri:"/ABS/packages/octocode-tools-core/src/scheme/pagination.ts",type:"documentSymbols"}},{label:"semantic definition (absolute uri + lineHint)",query:{uri:"/ABS/packages/octocode-tools-core/src/scheme/pagination.ts",type:"definition",symbolName:"buildNextPageContinuation",lineHint:72}}]:[]}function _t(e,t){return`tools ${e} --queries '${JSON.stringify(t)}'`}function lr(e){let t=xt(e);if(t.length>0)return t.map(n=>({...n,command:_t(e,n.query)}));let r=mr(e);return Object.keys(r).length===0?[]:[{label:"schema-derived",query:r,command:_t(e,r)}]}function ii(e){return lr(e)[0]?.query??{}}function mr(e){if(!C(e))return{};let t=U(e),r=t.filter(o=>!o.name.includes(".")),n=pr(r),i={};for(let o of n)i[o.name]=Ct(o.name,o.type);return e.startsWith("lsp")&&t.some(o=>o.name==="uri")&&(i.uri??="uri"),e===S&&(i.type??="definition",i.symbolName??="symbolName",i.lineHint??=1),i}var Rt=4,Oe=new Map([["keywords",10],["keywordsToSearch",11],["query",12],["text",13],["packageName",14],["name",15],["uri",20],["type",21],["owner",30],["repo",31],["extension",32],["filename",33],["language",34],["path",40],["target",50],["from",51],["scope",52],["pattern",60],["rule",61],["op",80],["operation",81],["minify",90]]),Et=new Set(["page","itemsPerPage","limit","matchPage","maxFiles","maxMatchesPerFile","matchContentLength","responseCharLength","responseCharOffset"]);function pr(e){let t=e.filter(o=>o.required),r=new Map;for(let o of t)r.set(o.name,o);let n=e.filter(o=>!o.required&&dr(o)).sort(hr),i=Math.max(Rt,t.length);for(let o of n){if(r.size>=i)break;r.set(o.name,o)}return r.size>0?[...r.values()]:e.filter(o=>!Et.has(o.name)).filter(o=>o.type!=="boolean").slice(0,Rt)}function dr(e){return Et.has(e.name)||e.type==="boolean"?!1:gr(e)?Oe.has(e.name):!0}function hr(e,t){let r=Oe.get(e.name)??Number.MAX_SAFE_INTEGER,n=Oe.get(t.name)??Number.MAX_SAFE_INTEGER;return r!==n?r-n:e.name.localeCompare(t.name)}function gr(e){return e.constraints?.includes("default ")===!0}function ui(e,t,r={}){if(typeof t!="string")return null;let n;try{n=JSON.parse(t)}catch{throw new f("Tool input must be valid JSON.")}return yr(e,n,r)}function yr(e,t,r={}){let n=Sr(e,t,r),i=C(e);if(!i)throw new f(`Unknown tool: ${e}`);let o=i.inputSchema.safeParse(n);if(!o.success)throw new f("Tool input does not match the expected schema.",fr(o.error));return o.data}function fr(e){return e.issues.map(t=>`${t.path.length>0?t.path.join("."):"input"}: ${t.message}`)}function Sr(e,t,r){let n=[];if(Array.isArray(t))n=t;else if(b(t)&&Array.isArray(t.queries))n=t.queries;else if(b(t))n=[t];else throw new f('Tool input must be a JSON object, an array of query objects, or { "queries": [...] }.');if(n.length===0)throw new f("At least one query is required.");let i=b(t)&&Array.isArray(t.queries)?Object.fromEntries(Object.entries(t).filter(([c])=>c!=="queries")):{},o=n.map((c,d)=>br(e,d,Er(e,c,d,r),{sourceLabel:r.sourceLabel}));return{...i,queries:o}}function br(e,t,r,n){let i={...r},o=k(e),c=n.sourceLabel??"direct tool execution",d=Lr(e,c);return(typeof i.id!="string"||i.id.trim().length===0)&&(i.id=`${e}-${t+1}`),(o==="GitHub"||o==="Package")&&(typeof i.mainResearchGoal!="string"||i.mainResearchGoal.trim().length===0)&&(i.mainResearchGoal=d),(typeof i.researchGoal!="string"||i.researchGoal.trim().length===0)&&(i.researchGoal=d),(typeof i.reasoning!="string"||i.reasoning.trim().length===0)&&(i.reasoning=`Executed via ${c} tool command`),i}function Lr(e,t){return`Execute ${e} via ${t}`}function Tr(e,t){let r=e.length+1,n=t.length+1,i=Array.from({length:r*n},()=>0);for(let o=0;o<r;o++)i[o*n]=o;for(let o=0;o<n;o++)i[o]=o;for(let o=1;o<r;o++)for(let c=1;c<n;c++){let d=e[o-1]===t[c-1]?0:1;i[o*n+c]=Math.min(i[(o-1)*n+c]+1,i[o*n+c-1]+1,i[(o-1)*n+c-1]+d)}return i[r*n-1]}function Cr(e,t){let r=e.toLowerCase(),n,i=Number.POSITIVE_INFINITY,o,c=Number.POSITIVE_INFINITY;for(let d of t){let h=d.toLowerCase(),g=Tr(r,h);if(h.includes(r)||r.includes(h)){g<i&&(n=d,i=g);continue}if(r.length<3)continue;let y=Math.max(2,Math.floor(d.length/3));g<=y&&g<c&&(o=d,c=g)}return n??o}var xr=new Set(["none","standard","symbols"]),_r={ghSearchCode:{keywordsToSearch:"keywords"},ghSearchRepos:{keywordsToSearch:"keywords"},npmSearch:{name:"packageName"},ghViewRepoStructure:{depth:"maxDepth"},lspGetSemantics:{op:"type",line:"lineHint",path:"uri"},localGetFileContent:{filePath:"path"},localSearchCode:{keywordsToSearch:"searchText",keywords:"searchText",language:"langType"},ghGetFileContent:{matchStringContextLines:"contextLines",minified:{field:"minify",map:e=>{if(e===!0)return"standard";if(e===!1)return"none";if(typeof e=="string"&&xr.has(e))return e}}},ghSearchPullRequests:{merged:{field:"state",map:e=>e===!0?"merged":void 0}},ghSearchCommits:{filePath:"path"},localFindFiles:{maxResults:"limit"}};function Rr(e,t){let r=_r[e];if(!r)return t;let n;for(let[i,o]of Object.entries(r)){if(!(i in t))continue;let c=typeof o=="string"?o:o.field;if(c in t){n??={...t},delete n[i];continue}let d=typeof o=="string"?t[i]:o.map(t[i]);d!==void 0&&(n??={...t},n[c]=d,delete n[i])}return n??t}function Er(e,t,r,n={}){if(!b(t))throw new f("Tool input must be a JSON object or an array of objects.");let i=Rr(e,t),o=new Set([...U(e).filter(h=>!h.name.includes(".")).map(h=>h.name),...I]),c={},d=[];for(let[h,g]of Object.entries(i)){if(o.has(h)){c[h]=g;continue}d.push(h)}if(d.length>0&&o.size>0&&(n.onUnknownFields?.(d,r),n.rejectUnknownFields===!0)){let h=d.map(g=>{let y=Cr(g,o);return y?`'${g}' \u2192 did you mean '${y}'?`:""}).filter(Boolean);throw new f(`Unknown field(s): ${d.join(", ")}`,[...h,`Remove unknown field(s) from query ${r+1}: ${d.join(", ")}`,`Run tools ${e} --scheme to see valid fields.`])}return c}import{completeMetadata as kr}from"@octocodeai/octocode-core";var De=null;function Or(){return De||(De=kr),De}async function Dr(){return Or()}export{I as DIRECT_TOOL_AUTO_FILLED_FIELDS,ft as DIRECT_TOOL_CATEGORIES,ir as DIRECT_TOOL_DEFINITIONS,f as DirectToolInputError,lr as buildDirectToolCommandPatterns,ii as buildDirectToolExampleQuery,Ct as buildExampleValue,Tt as buildScalarExampleValue,Ee as collectDisplayFields,ur as describeSchemaConstraints,Re as describeSchemaType,C as findDirectToolDefinition,_t as formatDirectToolCommandPattern,jo as formatDirectToolMetadataSchemaText,$o as formatDirectToolOutputSchemaText,qo as formatDirectToolSchemaText,fr as formatDirectToolValidationIssues,zo as getDirectToolAutoFilledFields,k as getDirectToolCategory,Xo as getDirectToolDescription,U as getDirectToolDisplayFields,Vo as getDirectToolOutputFields,ke as hasSchemaDefault,O as isJsonSchemaObject,b as isRecord,Dr as loadToolContent,yr as prepareDirectToolInput,ui as prepareDirectToolInputFromJsonText,Bo as sortDirectToolNames};
|
|
8
|
+
import{completeMetadata as Et}from"@octocodeai/octocode-core";var s=Et.toolNames,S=s.LSP_GET_SEMANTIC_CONTENT;function q(e=process.env){let t=e.ENABLE_RELEASES;return t===void 0?!1:["1","true","yes","on"].includes(t.trim().toLowerCase())}function I(e=process.env){let t=e.ENABLE_DISCUSSIONS;return t===void 0?!1:["1","true","yes","on"].includes(t.trim().toLowerCase())}var Dr=new Set([s.LOCAL_RIPGREP,s.LOCAL_FETCH_CONTENT,s.LOCAL_FIND_FILES,s.LOCAL_VIEW_STRUCTURE,S]);var De=["definition","references","callers","callees","callHierarchy","hover","documentSymbols","typeDefinition","implementation","workspaceSymbol","supertypes","subtypes","diagnostic"];import{CloneRepoQuerySchema as Pt}from"@octocodeai/octocode-core/schemas";import{z as F}from"zod";function i(e,t){return F.preprocess(r=>typeof r=="number"&&Number.isFinite(r)?Math.min(Math.max(r,e),t):r,F.number().int().min(e).max(t))}var u=i(1,1e3).optional().default(1),_=i(0,100).optional(),E=i(1,1e9).optional(),Ot={responseCharOffset:i(0,1e8).optional().describe("Full-response char offset; re-call with returned value when hasMore."),responseCharLength:i(1,5e4).optional().describe("Full-response char window.")};function l(e,t={}){let{maxQueries:r=5}=t;return F.object({queries:F.array(e).min(1).max(r).describe("Parallel queries."),...Ot}).superRefine((n,a)=>{let o=new Set;n.queries.forEach((c,d)=>{c&&typeof c=="object"&&"id"in c&&typeof c.id=="string"&&(o.has(c.id)&&a.addIssue({code:"custom",message:`Duplicate query id "${c.id}" at index ${d}`,path:["queries",d,"id"]}),o.add(c.id))})})}import{z as Pe}from"zod";function At(e,t){return e?.description&&!t.description?t.describe(e.description):t}function we(e,t){let r={};for(let[n,a]of Object.entries(t))r[n]=At(e.shape[n],a);return r}function Dt(e,t){let r=e;return r.safeExtend?r.safeExtend(t):e.extend(t)}function Ie(e,t){if(!t?.length)return e;let r=new Set(t);return Pe.object(Object.fromEntries(Object.entries(e.shape).filter(([n])=>!r.has(n))))}function m(e,t={},r={}){let n=Ie(e,r.omit),a=Dt(n,we(n,t));return r.strict?a.strict():a}function p(e,t={},r={}){let n=Ie(e,r.omit),a=Pe.object({...n.shape,...we(n,t)});return r.strict?a.strict():a}var Q=m(Pt),z=l(Q);import{z as wt}from"zod";import{FileContentQuerySchema as Fe}from"@octocodeai/octocode-core/schemas";var It=wt.enum(["none","standard","symbols"]).optional(),Qe={startLine:E,endLine:E,contextLines:_,charOffset:i(0,1e8).optional(),charLength:i(1,5e4).optional(),minify:It},Ft=p(Fe,Qe),V=m(Fe,Qe),$=l(Ft);import{z as Qt}from"zod";import{GitHubCodeSearchQuerySchema as Ge}from"@octocodeai/octocode-core/schemas";var He={limit:i(1,100).optional(),page:u.default(1),match:Qt.enum(["file","path"]).default("file").describe('"file" searches file contents and returns snippets with matchIndices. "path" searches only file paths/names \u2014 no snippets, far cheaper; use it to confirm a file exists before reading it. (Unlike ghSearchRepos/ghSearchPullRequests, where `match` instead selects which text FIELDS to search \u2014 a different concept sharing this name.)')},X=m(Ge,He),W=l(p(Ge,He));import{z as Z}from"zod";import{GitHubPullRequestSearchQuerySchema as Ne}from"@octocodeai/octocode-core/schemas";var Be={type:Z.enum(["prs","commits","releases","issues"]).optional().describe('Research mode: "prs" (default) searches pull requests; "commits" walks commit history for a repo or path; "releases" lists the repository releases (tagName, publishedAt, prerelease flag) and surfaces the latest stable release; "issues" searches or reads GitHub issues (body/discussion comments \u2014 not PRs).'),prNumber:i(1,1e9).optional(),issueNumber:i(1,1e9).optional().describe('Issue number for type:"issues" detail mode \u2014 reads that specific issue (body/discussion comments). Requires owner+repo. Falls back to prNumber if omitted.'),limit:i(1,100).optional().default(30),match:Z.array(Z.enum(["title","body","comments"])).optional().describe('Fields to match keywords against: "title", "body", "comments". Default searches all three. Use ["title"] for the most precise and fastest match. (Unlike ghSearchCode, where `match` instead selects file-contents vs file-paths \u2014 a different concept sharing this name.)'),page:u.default(1),filePage:u.optional(),commentPage:u.optional(),commitPage:u.optional(),itemsPerPage:i(1,100).optional().default(20),charOffset:i(0,1e8).optional(),commentBodyOffset:i(0,1e8).optional(),charLength:i(1,5e4).optional()},Gt=p(Ne,Be),Ht=m(Ne,Be),Nt=l(Gt);import{SearchPullRequestsQuerySchema as Me,SearchIssuesQuerySchema as ve,SearchCommitsQuerySchema as Ue,ListReleasesQuerySchema as qe}from"@octocodeai/octocode-core/schemas";var je={limit:i(1,100).optional().default(30),page:u.default(1),itemsPerPage:i(1,100).optional().default(20)},ze={...je,filePage:u.optional(),commentPage:u.optional(),commitPage:u.optional(),charOffset:i(0,1e8).optional(),commentBodyOffset:i(0,1e8).optional(),charLength:i(1,1e5).optional()},K=m(Me,ze),Y=l(p(Me,ze)),Ve={...je,commentPage:u.optional(),charOffset:i(0,1e8).optional(),commentBodyOffset:i(0,1e8).optional(),charLength:i(1,1e5).optional()},ee=m(ve,Ve),te=l(p(ve,Ve)),$e={page:u.default(1),limit:i(1,100).optional().describe("Commits per page \u2014 alias of itemsPerPage (preferred when both are set)."),filePage:u.optional(),charOffset:i(0,1e8).optional(),charLength:i(1,1e5).optional()},re=m(Ue,$e),ne=l(p(Ue,$e)),Xe={page:u.default(1),limit:i(1,100).optional().describe("Releases per page \u2014 alias of itemsPerPage (preferred when both are set).")},G=m(qe,Xe),H=l(p(qe,Xe));import{SearchDiscussionsQuerySchema as We}from"@octocodeai/octocode-core/schemas";var Ze={itemsPerPage:i(1,100).optional().default(20),limit:i(1,100).optional()},N=m(We,Ze),B=l(p(We,Ze));import{z as Je}from"zod";import{GitHubReposSearchSingleQuerySchema as Ke}from"@octocodeai/octocode-core/schemas";var Ye={limit:i(1,100).optional(),page:u.default(1),match:Je.array(Je.enum(["name","description","readme"])).optional().describe("Which text fields to search: name, description, and/or readme. Defaults to name+description; add 'readme' for broader, slower full-text search. (Unlike ghSearchCode, where `match` instead selects file-contents vs file-paths \u2014 a different concept sharing this name.)")},oe=m(Ke,Ye),ie=l(p(Ke,Ye));import{GitHubViewRepoStructureQuerySchema as et}from"@octocodeai/octocode-core/schemas";var tt={maxDepth:i(0,20).optional(),page:u.default(1),itemsPerPage:i(1,200).optional()},ae=m(et,tt),se=l(p(et,tt));import{z as M}from"zod";import{NpmPackageQuerySchema as rt}from"@octocodeai/octocode-core/schemas";var nt={page:u,keywords:M.union([M.string(),M.array(M.string())]).optional().describe("Registry keyword query (string; an array of terms is accepted and joined with spaces).")},ce=m(rt,nt),ue=l(p(rt,nt,{strict:!0}),{maxQueries:5});import{z as Mt}from"zod";import{FetchContentQuerySchema as ot}from"@octocodeai/octocode-core/schemas";var vt=Mt.enum(["none","standard","symbols"]).optional(),it={startLine:E,endLine:E,contextLines:_.default(5),charOffset:i(0,1e8).optional(),charLength:i(1,5e4).optional(),minify:vt},Ut=p(ot,it),le=m(ot,it),me=l(Ut,{maxQueries:5});import{z as pe}from"zod";import{FindFilesQuerySchema as qt}from"@octocodeai/octocode-core/schemas";var at={maxDepth:i(0,100).optional(),minDepth:i(0,100).optional(),limit:i(1,1e4).optional().describe("Discovery cap applied after sort, before pagination \u2014 total results are capped here; itemsPerPage/page page within that cap."),page:u.default(1),itemsPerPage:i(1,50).optional(),excludeDir:pe.array(pe.string()).optional().describe("Directory names to prune from the walk. Common generated/vendor dirs are pruned by default (node_modules, .git, dist, build, out, coverage, target, .next, .cache); pass [] to prune nothing, or pass an explicit list to choose pruned dirs.")},st=pe.object(Object.fromEntries(Object.entries(qt.shape).filter(([e])=>e!=="regexType")));function jt(e,t){e.minDepth!==void 0&&e.maxDepth!==void 0&&e.minDepth>e.maxDepth&&t.addIssue({code:"custom",message:"minDepth must be less than or equal to maxDepth.",path:["minDepth"]})}var zt=p(st,at),he=m(st,at).superRefine(jt),ge=l(zt,{maxQueries:5});import{FindDeadCodeQuerySchema as ct}from"@octocodeai/octocode-core/schemas";var ut={maxFiles:i(1,5e4).optional(),limit:i(1,5e3).optional(),page:u.default(1),itemsPerPage:i(1,50).optional()},Vt=p(ct,ut),ye=m(ct,ut),fe=l(Vt,{maxQueries:5});import{z as T}from"zod";import{RipgrepQuerySchema as lt}from"@octocodeai/octocode-core/schemas";var $t=["paginated","discovery","detailed","structural"],Xt=["semanticRanking"],mt={mode:T.enum($t).optional().default("paginated").describe('"paginated" snippets; "discovery" paths only; "detailed" snippets plus context; "structural" AST/code-shape search with pattern or rule. Structural matches return line/capture anchors that can feed lspGetSemantics when symbol identity matters. (Unrelated to ghSearchPullRequests\'s `content.patches.mode` \u2014 different concepts sharing this name.)'),searchText:T.string().optional().describe('The search pattern. regex:"fixed" for a literal match, "perl" for advanced features (lookaheads, backreferences), else "smart". (Unlike ghSearchCode/ghSearchRepos, where `keywords` is an array of ANDed terms \u2014 this is a single string.)'),output:T.enum(["content","files","filesWithout","countLines","countMatches","matchOnly"]).optional().default("content").describe('"content" (default) matches with line text; "files"/"filesWithout" return matching/non-matching paths; "countLines"/"countMatches" return per-file counts; "matchOnly" returns just the matched substring (required for unique/matchWindow). ("files" is unlike localViewStructure\'s `filesOnly`, which filters a directory listing to file entries.)'),pattern:T.string().optional().describe("Structural only: code-shaped AST pattern with $X (one node) or $$$ARGS (node list). Modifiers are part of the node \u2014 `function $NAME` does not match `async function` or `export function`; include the modifiers or use a YAML `kind` rule for modifier-agnostic matches. Use this to find syntax shape, then use lspGetSemantics for semantic proof."),maxDepth:i(0,20).optional().describe("Keep files at most this many directory levels below the search root (0 = files directly in the root). Structural mode pushes this into the native walker; text/regex mode applies it after the native search and emits a warning when it filters deeper matches."),rule:T.string().optional().describe("Structural only: YAML ast-grep rule for not/inside/has/all/any. Use for partial or relational AST queries before escalating matched anchors to lspGetSemantics."),captureText:T.boolean().optional().describe("Structural only: return full verbatim capture text for `$$$` list metavars (bodies, arg lists). Default false \u2014 list-capture text is omitted from `metavars`, and `metavarRanges` entries are comment-pruned and truncated to keep results lean; ranges always remain as line anchors."),contextLines:_,matchContentLength:i(1,1e5).optional().default(500),maxMatchesPerFile:i(1,1e5).optional(),maxFiles:i(1,1e5).optional(),matchPage:u.optional(),itemsPerPage:i(1,1e3).optional(),page:u.default(1),unique:T.enum(["off","list","count"]).optional().default("off").describe('Needs output:"matchOnly". "list" returns each matched value once per file; "count" adds its frequency.')},Wt={...mt,semanticRanking:T.unknown().optional().superRefine((e,t)=>{e!==void 0&&t.addIssue({code:"custom",message:'semanticRanking is disabled in this build \u2014 sort:"relevance" already includes declaration/export/AST signals; remove this field.'})}).describe('DISABLED in this build \u2014 do not pass. sort:"relevance" already includes declaration/export/AST signals.')},Zt=p(lt,Wt),Jt=m(lt,mt,{strict:!0,omit:Xt}),be=Jt.superRefine((e,t)=>{if(e.mode==="structural"){!e.pattern&&!e.rule&&t.addIssue({code:"custom",message:'mode:"structural" requires `pattern` or `rule`.',path:["pattern"]}),e.pattern&&e.rule&&t.addIssue({code:"custom",message:"`pattern` and `rule` are mutually exclusive.",path:["rule"]}),e.wholeWord&&t.addIssue({code:"custom",message:'`wholeWord` is not valid with mode:"structural".',path:["wholeWord"]}),e.invertMatch&&t.addIssue({code:"custom",message:'`invertMatch` is not valid with mode:"structural".',path:["invertMatch"]}),e.regex&&e.regex!=="smart"&&t.addIssue({code:"custom",message:'`regex` is not valid with mode:"structural".',path:["regex"]}),e.caseMode&&e.caseMode!=="smart"&&t.addIssue({code:"custom",message:'`caseMode` is not valid with mode:"structural".',path:["caseMode"]}),e.multiline&&e.multiline!=="off"&&t.addIssue({code:"custom",message:'`multiline` is not valid with mode:"structural".',path:["multiline"]}),e.output&&e.output!=="content"&&e.output!=="countMatches"&&e.output!=="files"&&t.addIssue({code:"custom",message:'With mode:"structural", `output` supports only "content" (default), "countMatches" (per-file counts, no match content \u2014 cheapest for counting), or "files" (paths only).',path:["output"]}),e.unique&&e.unique!=="off"&&t.addIssue({code:"custom",message:'`unique` is not valid with mode:"structural".',path:["unique"]});let r=e.pattern&&!["php","bash","sh","zsh"].includes(e.langType??"")?/(?<!\$)\$\$(?!\$)[A-Z_][A-Z0-9_]*/.exec(e.pattern):null;if(r){let n=r[0].slice(2);t.addIssue({code:"custom",message:`\`${r[0]}\` is not a metavariable and matches nothing \u2014 use \`$${n}\` for one node or \`$$$${n}\` for a list of nodes.`,path:["pattern"]})}return}(e.pattern||e.rule)&&t.addIssue({code:"custom",message:'`pattern`/`rule` require mode:"structural".',path:[e.pattern?"pattern":"rule"]}),e.searchText||t.addIssue({code:"custom",message:'`searchText` is required unless mode:"structural".',path:["searchText"]}),e.matchWindow!==void 0&&e.output!=="matchOnly"&&t.addIssue({code:"custom",message:'matchWindow requires output:"matchOnly".',path:["matchWindow"]}),(e.unique==="list"||e.unique==="count")&&e.output!=="matchOnly"&&t.addIssue({code:"custom",message:'unique requires output:"matchOnly".',path:["unique"]})}),Le=l(Zt,{maxQueries:5});import{z as pt}from"zod";import{ViewStructureQuerySchema as dt}from"@octocodeai/octocode-core/schemas";var ht={excludeDir:pt.array(pt.string()).optional().describe("Directory names to prune from recursive walks (default: common generated/vendor dirs such as node_modules, dist, build, out, coverage, target). Pass [] to inspect everything."),maxDepth:i(0,20).optional(),limit:i(1,1e4).optional(),page:u.default(1),itemsPerPage:i(1,50).optional()},Kt=p(dt,ht),Te=m(dt,ht),Ce=l(Kt,{maxQueries:5});import{z as v}from"zod";import{LspGetSemanticsQuerySchema as gt}from"@octocodeai/octocode-core/schemas";var Yt=i(1,1e9).describe("1-based source line for symbol-anchored semantic operations. Get it from search/localSearchCode, structural AST captures, or documentSymbols; never guess."),er=i(0,1e5).optional(),tr=["structured","compact"],yt={type:v.enum(De).default("definition").describe("Semantic operation for local code intelligence. Use after text or structural AST search when you need identity, references, call flow, type relations, hover, symbols, or diagnostics."),symbolName:v.string().min(1).max(1024).optional().describe("Exact bare identifier at the lineHint anchor for symbol operations; workspaceSymbol uses this as the fuzzy project-wide symbol query."),lineHint:Yt.optional(),orderHint:er,depth:i(0,20).optional().describe("Traversal depth for call-hierarchy / type-hierarchy queries (0 = direct only)."),includeDeclaration:v.boolean().optional().default(!0),page:u.describe("Result page for paginated reference/symbol lists (advance while pagination.hasMore)."),itemsPerPage:i(1,100).optional().describe("References/symbols returned per page (with page)."),contextLines:i(0,100).optional().describe("Lines of surrounding source shown around each result location."),format:v.enum(tr).optional().default("structured")},rr=p(gt,yt),xe=m(gt,yt);var Re=l(rr,{maxQueries:5});var ft=["GitHub","Local Code","Package","Other"],St=new Map([s.GITHUB_SEARCH_CODE,s.GITHUB_SEARCH_REPOSITORIES,s.GITHUB_PULL_REQUESTS,s.GITHUB_ISSUES,s.GITHUB_COMMITS,s.GITHUB_FETCH_CONTENT,s.GITHUB_VIEW_REPO_STRUCTURE,s.GITHUB_CLONE_REPO,s.LOCAL_RIPGREP,s.LOCAL_FIND_FILES,s.LOCAL_FIND_DEAD_CODE,s.LOCAL_FETCH_CONTENT,s.LOCAL_VIEW_STRUCTURE,S,s.PACKAGE_SEARCH,...I()?[s.GITHUB_DISCUSSIONS]:[]].map((e,t)=>[e,t])),f=class extends Error{constructor(r,n=[]){super(r);this.details=n;this.name="DirectToolInputError"}details},nr=["id","mainResearchGoal","researchGoal","reasoning"],w=new Set([...nr]),or=[{name:s.GITHUB_SEARCH_CODE,schema:X,inputSchema:W},{name:s.GITHUB_FETCH_CONTENT,schema:V,inputSchema:$},{name:s.GITHUB_VIEW_REPO_STRUCTURE,schema:ae,inputSchema:se},{name:s.GITHUB_SEARCH_REPOSITORIES,schema:oe,inputSchema:ie},{name:s.GITHUB_PULL_REQUESTS,schema:K,inputSchema:Y},{name:s.GITHUB_ISSUES,schema:ee,inputSchema:te},{name:s.GITHUB_COMMITS,schema:re,inputSchema:ne},...q()?[{name:s.GITHUB_RELEASES,schema:G,inputSchema:H}]:[],...I()?[{name:s.GITHUB_DISCUSSIONS,schema:N,inputSchema:B}]:[],{name:s.PACKAGE_SEARCH,schema:ce,inputSchema:ue},{name:s.GITHUB_CLONE_REPO,schema:Q,inputSchema:z},{name:s.LOCAL_RIPGREP,schema:be,inputSchema:Le},{name:s.LOCAL_VIEW_STRUCTURE,schema:Te,inputSchema:Ce},{name:s.LOCAL_FIND_FILES,schema:he,inputSchema:ge},{name:s.LOCAL_FIND_DEAD_CODE,schema:ye,inputSchema:fe},{name:s.LOCAL_FETCH_CONTENT,schema:le,inputSchema:me},{name:S,schema:xe,inputSchema:Re}],ir=[...q()?[]:[{name:s.GITHUB_RELEASES,schema:G,inputSchema:H,disabled:{envVar:"ENABLE_RELEASES"}}],...I()?[]:[{name:s.GITHUB_DISCUSSIONS,schema:N,inputSchema:B,disabled:{envVar:"ENABLE_DISCUSSIONS"}}]];function C(e){return or.find(t=>t.name===e)??ir.find(t=>t.name===e)}function k(e){return e.startsWith("gh")?"GitHub":e.startsWith("local")||e.startsWith("lsp")?"Local Code":e===s.PACKAGE_SEARCH?"Package":"Other"}function No(e){return[...e].sort((t,r)=>{let n=ft.indexOf(k(t)),a=ft.indexOf(k(r));if(n!==a)return n-a;let o=St.get(t)??Number.MAX_SAFE_INTEGER,c=St.get(r)??Number.MAX_SAFE_INTEGER;return o!==c?o-c:t.localeCompare(r)})}import{z as bt}from"zod";var ar=["id","researchGoal","reasoning"];function Uo(e){let t=C(e);if(!t)return"{}";try{return JSON.stringify(bt.toJSONSchema(t.inputSchema,{io:"input"}),null,2)}catch{return JSON.stringify(bt.toJSONSchema(t.schema,{io:"input"}),null,2)}}function qo(e){return JSON.stringify(e??{},null,2)}function jo(e){let t=k(e),r=[...ar];return(t==="GitHub"||t==="Package")&&r.splice(1,0,"mainResearchGoal"),r}function zo(e,t){return t?.tools?.[e]?.description??e}import{z as sr}from"zod";function U(e){let t=C(e);if(!t)return[];let r=sr.toJSONSchema(t.schema,{io:"input"});if(!O(r))return[];let n=b(r.properties)?r.properties:{},a=new Set(Array.isArray(r.required)?r.required.filter(o=>!w.has(o)&&!ke(n[o])):[]);return Ee(n,a)}function cr(e){let t=[],r=typeof e.minimum=="number"?e.minimum:void 0,n=typeof e.maximum=="number"?e.maximum:void 0;return r!==void 0&&n!==void 0?t.push(`${r}-${n}`):r!==void 0?t.push(`>=${r}`):n!==void 0&&t.push(`<=${n}`),"default"in e&&t.push(`default ${JSON.stringify(e.default)}`),t.length>0?t.join(", "):void 0}function _e(e){if(Array.isArray(e.enum)&&e.enum.length>0)return`enum(${e.enum.map(String).join(", ")})`;if(e.type==="array"){let r=O(e.items)?e.items:void 0;return`array<${r?_e(r):"value"}>`}let t=Array.isArray(e.anyOf)?e.anyOf:Array.isArray(e.oneOf)?e.oneOf:void 0;if(t){let r=t.filter(O).map(_e).filter(n=>n!=="value");if(r.length>0)return[...new Set(r)].join(" | ")}return Array.isArray(e.type)?e.type.join(" | "):typeof e.type=="string"?e.type:"value"}function Ee(e,t,r=""){let n=[];for(let[a,o]of Object.entries(e)){if(!r&&w.has(a))continue;let c=O(o)?o:{},d=r?`${r}.${a}`:a;if(n.push({name:d,required:t.has(a),type:_e(c),constraints:cr(c),description:typeof c.description=="string"?c.description:void 0}),b(c.properties)){let g=new Set(Array.isArray(c.required)?c.required.filter(y=>typeof y=="string"?!ke(c.properties?.[y]):!1):[]);n.push(...Ee(c.properties,g,d))}let h=c.type==="array"&&O(c.items)?c.items:void 0;if(h&&b(h.properties)){let g=new Set(Array.isArray(h.required)?h.required.filter(y=>typeof y=="string"?!ke(h.properties?.[y]):!1):[]);n.push(...Ee(h.properties,g,d))}}return n}function Tt(e,t){if(t.startsWith("array<")){let r=t.slice(6,-1);return[Lt(e,r)]}return Lt(e,t)}function Lt(e,t){if(t.startsWith("enum("))return/^enum\(([^,)]+)/.exec(t)?.[1]??e;if(t==="integer"||t==="number")return e==="lineHint"?42:5;if(t==="boolean")return!0;switch(e){case"keywords":case"keywordsToSearch":case"query":case"text":return"runCLI";case"path":return".";case"uri":return"/path/to/file.ts";case"owner":return"bgauryy";case"repo":return"octocode";case"extension":return"ts";case"filename":return"package.json";case"language":return"TypeScript";case"symbolName":return"myFunction";case"name":case"packageName":return"zod";default:return e}}function b(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function O(e){return b(e)}function ke(e){return O(e)&&"default"in e}function Ct(e){return e===s.GITHUB_PULL_REQUESTS?[{label:"PR search (list)",query:{owner:"bgauryy",repo:"octocode",keywordsToSearch:["localSearchCode"],concise:!0,limit:5}},{label:"PR detail (diffs + reviews)",query:{owner:"sindresorhus",repo:"slugify",prNumber:1,content:{comments:{discussion:!0},reviews:!0,patches:{mode:"all"}}}}]:e===s.GITHUB_SEARCH_CODE?[{label:"path search",query:{keywords:["package.json"],owner:"bgauryy",repo:"octocode",match:"path",concise:!0,limit:5}},{label:"content search",query:{keywords:["localSearchCode"],owner:"bgauryy",repo:"octocode",extension:"ts",limit:5}}]:e===s.GITHUB_SEARCH_REPOSITORIES?[{label:"repository search",query:{keywords:["react"],language:"TypeScript",stars:">1000",concise:!0,limit:5}},{label:"owner repositories",query:{owner:"bgauryy",concise:!0,limit:5}}]:e===s.GITHUB_VIEW_REPO_STRUCTURE?[{label:"repo tree",query:{owner:"bgauryy",repo:"octocode",path:"packages",maxDepth:2,itemsPerPage:50}}]:e===s.GITHUB_CLONE_REPO?[{label:"full repo clone",query:{owner:"bgauryy",repo:"octocode"}},{label:"subtree clone",query:{owner:"bgauryy",repo:"octocode",sparsePath:"packages/octocode-tools-core"}}]:e===s.LOCAL_RIPGREP?[{label:"text search",query:{path:"packages/octocode-tools-core/src",searchText:"buildDirectToolCommandPatterns",maxFiles:20}},{label:"structural code search",query:{path:"packages/octocode-tools-core/src/tools",mode:"structural",pattern:"eval($X)"}}]:e===s.LOCAL_FETCH_CONTENT?[{label:"exact line range",query:{path:"packages/octocode-tools-core/package.json",startLine:1,endLine:30,minify:"none"}},{label:"matched slice",query:{path:"packages/octocode-tools-core/src/tools/directToolCatalog.meta.ts",matchString:"buildKnownDirectToolCommandPatternQueries",contextLines:8,minify:"standard"}}]:e===s.LOCAL_FIND_FILES?[{label:"basename globs",query:{path:"packages/octocode-tools-core",names:["scheme.ts","package.json"],entryType:"f",itemsPerPage:20}},{label:"monorepo path glob",query:{path:".",pathPattern:"packages/*/src/tools/**",entryType:"f",itemsPerPage:20}},{label:"prune build dirs",query:{path:"packages/octocode-tools-core",names:["*.js"],entryType:"f",excludeDir:["node_modules","dist","coverage","out"],itemsPerPage:20}}]:e===s.LOCAL_FIND_DEAD_CODE?[{label:"default entrypoints (package.json + tests)",query:{path:"packages/octocode-tools-core",itemsPerPage:20}},{label:"explicit entrypoints",query:{path:"packages/octocode-tools-core",entrypoints:["src/index.ts","src/direct.ts"],includeTests:!1}}]:e===s.LOCAL_VIEW_STRUCTURE?[{label:"shallow tree",query:{path:"packages/octocode-tools-core/src/tools",maxDepth:2,itemsPerPage:50}},{label:"files only at depth 1",query:{path:"packages/octocode-engine/src",maxDepth:1,entryType:"f",itemsPerPage:100}}]:e===s.GITHUB_FETCH_CONTENT?[{label:"matched slice (cheap read of one function)",query:{owner:"bgauryy",repo:"octocode",path:"packages/octocode-tools-core/src/responses.ts",matchString:"export function cleanJsonObject",contextLines:8}},{label:"symbols outline (unknown/large file)",query:{owner:"bgauryy",repo:"octocode",path:"packages/octocode-tools-core/src/responses.ts",minify:"symbols"}}]:e===s.GITHUB_COMMITS?[{label:"file history (bounded window)",query:{owner:"bgauryy",repo:"octocode",path:"packages/octocode-tools-core/src/responses.ts",since:"6m",itemsPerPage:10}},{label:"compare two refs (base...head)",query:{owner:"bgauryy",repo:"octocode",base:"main",head:"update-tools"}}]:e===s.PACKAGE_SEARCH?[{label:"exact package \u2192 source repo",query:{packageName:"zod"}},{label:"keyword discovery (paged candidates)",query:{packageName:"schema validation",page:1}}]:e===S?[{label:"symbol outline (absolute uri)",query:{uri:"/ABS/packages/octocode-tools-core/src/scheme/pagination.ts",type:"documentSymbols"}},{label:"semantic definition (absolute uri + lineHint)",query:{uri:"/ABS/packages/octocode-tools-core/src/scheme/pagination.ts",type:"definition",symbolName:"buildNextPageContinuation",lineHint:72}}]:[]}function xt(e,t){return`tools ${e} --queries '${JSON.stringify(t)}'`}function ur(e){let t=Ct(e);if(t.length>0)return t.map(n=>({...n,command:xt(e,n.query)}));let r=lr(e);return Object.keys(r).length===0?[]:[{label:"schema-derived",query:r,command:xt(e,r)}]}function ri(e){return ur(e)[0]?.query??{}}function lr(e){if(!C(e))return{};let t=U(e),r=t.filter(o=>!o.name.includes(".")),n=mr(r),a={};for(let o of n)a[o.name]=Tt(o.name,o.type);return e.startsWith("lsp")&&t.some(o=>o.name==="uri")&&(a.uri??="uri"),e===S&&(a.type??="definition",a.symbolName??="symbolName",a.lineHint??=1),a}var Rt=4,Oe=new Map([["keywords",10],["keywordsToSearch",11],["query",12],["text",13],["packageName",14],["name",15],["uri",20],["type",21],["owner",30],["repo",31],["extension",32],["filename",33],["language",34],["path",40],["target",50],["from",51],["scope",52],["pattern",60],["rule",61],["op",80],["operation",81],["minify",90]]),_t=new Set(["page","itemsPerPage","limit","matchPage","maxFiles","maxMatchesPerFile","matchContentLength","responseCharLength","responseCharOffset"]);function mr(e){let t=e.filter(o=>o.required),r=new Map;for(let o of t)r.set(o.name,o);let n=e.filter(o=>!o.required&&pr(o)).sort(dr),a=Math.max(Rt,t.length);for(let o of n){if(r.size>=a)break;r.set(o.name,o)}return r.size>0?[...r.values()]:e.filter(o=>!_t.has(o.name)).filter(o=>o.type!=="boolean").slice(0,Rt)}function pr(e){return _t.has(e.name)||e.type==="boolean"?!1:hr(e)?Oe.has(e.name):!0}function dr(e,t){let r=Oe.get(e.name)??Number.MAX_SAFE_INTEGER,n=Oe.get(t.name)??Number.MAX_SAFE_INTEGER;return r!==n?r-n:e.name.localeCompare(t.name)}function hr(e){return e.constraints?.includes("default ")===!0}function ai(e,t,r={}){if(typeof t!="string")return null;let n;try{n=JSON.parse(t)}catch{throw new f("Tool input must be valid JSON.")}return gr(e,n,r)}function gr(e,t,r={}){let n=fr(e,t,r),a=C(e);if(!a)throw new f(`Unknown tool: ${e}`);let o=a.inputSchema.safeParse(n);if(!o.success)throw new f("Tool input does not match the expected schema.",yr(o.error));return o.data}function yr(e){return e.issues.map(t=>`${t.path.length>0?t.path.join("."):"input"}: ${t.message}`)}function fr(e,t,r){let n=[];if(Array.isArray(t))n=t;else if(b(t)&&Array.isArray(t.queries))n=t.queries;else if(b(t))n=[t];else throw new f('Tool input must be a JSON object, an array of query objects, or { "queries": [...] }.');if(n.length===0)throw new f("At least one query is required.");let a=b(t)&&Array.isArray(t.queries)?Object.fromEntries(Object.entries(t).filter(([c])=>c!=="queries")):{},o=n.map((c,d)=>Sr(e,d,_r(e,c,d,r),{sourceLabel:r.sourceLabel}));return{...a,queries:o}}function Sr(e,t,r,n){let a={...r},o=k(e),c=n.sourceLabel??"direct tool execution",d=br(e,c);return(typeof a.id!="string"||a.id.trim().length===0)&&(a.id=`${e}-${t+1}`),(o==="GitHub"||o==="Package")&&(typeof a.mainResearchGoal!="string"||a.mainResearchGoal.trim().length===0)&&(a.mainResearchGoal=d),(typeof a.researchGoal!="string"||a.researchGoal.trim().length===0)&&(a.researchGoal=d),(typeof a.reasoning!="string"||a.reasoning.trim().length===0)&&(a.reasoning=`Executed via ${c} tool command`),a}function br(e,t){return`Execute ${e} via ${t}`}function Lr(e,t){let r=e.length+1,n=t.length+1,a=Array.from({length:r*n},()=>0);for(let o=0;o<r;o++)a[o*n]=o;for(let o=0;o<n;o++)a[o]=o;for(let o=1;o<r;o++)for(let c=1;c<n;c++){let d=e[o-1]===t[c-1]?0:1;a[o*n+c]=Math.min(a[(o-1)*n+c]+1,a[o*n+c-1]+1,a[(o-1)*n+c-1]+d)}return a[r*n-1]}function Tr(e,t){let r=e.toLowerCase(),n,a=Number.POSITIVE_INFINITY,o,c=Number.POSITIVE_INFINITY;for(let d of t){let h=d.toLowerCase(),g=Lr(r,h);if(h.includes(r)||r.includes(h)){g<a&&(n=d,a=g);continue}if(r.length<3)continue;let y=Math.max(2,Math.floor(d.length/3));g<=y&&g<c&&(o=d,c=g)}return n??o}var Cr=new Set(["none","standard","symbols"]),xr={ghSearchCode:{keywordsToSearch:"keywords"},ghSearchRepos:{keywordsToSearch:"keywords"},npmSearch:{name:"packageName"},ghViewRepoStructure:{depth:"maxDepth"},lspGetSemantics:{op:"type",line:"lineHint",path:"uri"},localGetFileContent:{filePath:"path"},localSearchCode:{keywordsToSearch:"searchText",keywords:"searchText",language:"langType"},ghGetFileContent:{matchStringContextLines:"contextLines",minified:{field:"minify",map:e=>{if(e===!0)return"standard";if(e===!1)return"none";if(typeof e=="string"&&Cr.has(e))return e}}},ghSearchPullRequests:{merged:{field:"state",map:e=>e===!0?"merged":void 0}},ghSearchCommits:{filePath:"path"},localFindFiles:{maxResults:"limit"}};function Rr(e,t){let r=xr[e];if(!r)return t;let n;for(let[a,o]of Object.entries(r)){if(!(a in t))continue;let c=typeof o=="string"?o:o.field;if(c in t){n??={...t},delete n[a];continue}let d=typeof o=="string"?t[a]:o.map(t[a]);d!==void 0&&(n??={...t},n[c]=d,delete n[a])}return n??t}function _r(e,t,r,n={}){if(!b(t))throw new f("Tool input must be a JSON object or an array of objects.");let a=Rr(e,t),o=new Set([...U(e).filter(h=>!h.name.includes(".")).map(h=>h.name),...w]),c={},d=[];for(let[h,g]of Object.entries(a)){if(o.has(h)){c[h]=g;continue}d.push(h)}if(d.length>0&&o.size>0&&(n.onUnknownFields?.(d,r),n.rejectUnknownFields===!0)){let h=d.map(g=>{let y=Tr(g,o);return y?`'${g}' \u2192 did you mean '${y}'?`:""}).filter(Boolean);throw new f(`Unknown field(s): ${d.join(", ")}`,[...h,`Remove unknown field(s) from query ${r+1}: ${d.join(", ")}`,`Run tools ${e} --scheme to see valid fields.`])}return c}import{completeMetadata as Er}from"@octocodeai/octocode-core";var Ae=null;function kr(){return Ae||(Ae=Er),Ae}async function Or(){return kr()}export{w as DIRECT_TOOL_AUTO_FILLED_FIELDS,ft as DIRECT_TOOL_CATEGORIES,or as DIRECT_TOOL_DEFINITIONS,f as DirectToolInputError,ur as buildDirectToolCommandPatterns,ri as buildDirectToolExampleQuery,Tt as buildExampleValue,Lt as buildScalarExampleValue,Ee as collectDisplayFields,cr as describeSchemaConstraints,_e as describeSchemaType,C as findDirectToolDefinition,xt as formatDirectToolCommandPattern,qo as formatDirectToolMetadataSchemaText,Uo as formatDirectToolSchemaText,yr as formatDirectToolValidationIssues,jo as getDirectToolAutoFilledFields,k as getDirectToolCategory,zo as getDirectToolDescription,U as getDirectToolDisplayFields,ke as hasSchemaDefault,O as isJsonSchemaObject,b as isRecord,Or as loadToolContent,gr as prepareDirectToolInput,ai as prepareDirectToolInputFromJsonText,No as sortDirectToolNames};
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { type DirectToolMetadata } from './toolCatalogDefinitions.js';
|
|
2
|
-
export interface DirectToolOutputField {
|
|
3
|
-
name: string;
|
|
4
|
-
type: string;
|
|
5
|
-
optional?: boolean;
|
|
6
|
-
}
|
|
7
2
|
export declare function formatDirectToolSchemaText(toolName: string): string;
|
|
8
3
|
export declare function formatDirectToolMetadataSchemaText(schema: Record<string, string> | undefined): string;
|
|
9
4
|
export declare function getDirectToolAutoFilledFields(toolName: string): string[];
|
|
10
|
-
export declare function getDirectToolOutputFields(): DirectToolOutputField[];
|
|
11
|
-
export declare function formatDirectToolOutputSchemaText(): string;
|
|
12
5
|
export declare function getDirectToolDescription(toolName: string, metadata?: DirectToolMetadata | null): string;
|
|
@@ -1,26 +1,44 @@
|
|
|
1
|
-
import type { z } from 'zod';
|
|
2
|
-
import { GitHubCloneRepoOutputSchema as UpstreamCloneRepoOutput } from '@octocodeai/octocode-core/schemas/outputs';
|
|
3
1
|
import type { ToolContinuation } from '../../scheme/pagination.js';
|
|
4
2
|
import type { ResponsePaginationInfo } from '../../types/toolOutput.js';
|
|
5
|
-
export declare const CloneRepoQueryLocalSchema:
|
|
6
|
-
owner:
|
|
7
|
-
repo:
|
|
8
|
-
branch:
|
|
9
|
-
sparsePath:
|
|
10
|
-
forceRefresh:
|
|
11
|
-
id:
|
|
12
|
-
mainResearchGoal:
|
|
13
|
-
researchGoal:
|
|
14
|
-
reasoning:
|
|
15
|
-
},
|
|
16
|
-
export declare const BulkCloneRepoLocalSchema:
|
|
17
|
-
responseCharOffset:
|
|
18
|
-
responseCharLength:
|
|
19
|
-
queries:
|
|
20
|
-
},
|
|
21
|
-
|
|
3
|
+
export declare const CloneRepoQueryLocalSchema: import("zod").ZodObject<{
|
|
4
|
+
owner: import("zod").ZodString;
|
|
5
|
+
repo: import("zod").ZodString;
|
|
6
|
+
branch: import("zod").ZodOptional<import("zod").ZodString>;
|
|
7
|
+
sparsePath: import("zod").ZodOptional<import("zod").ZodString>;
|
|
8
|
+
forceRefresh: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
9
|
+
id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
10
|
+
mainResearchGoal: import("zod").ZodOptional<import("zod").ZodString>;
|
|
11
|
+
researchGoal: import("zod").ZodOptional<import("zod").ZodString>;
|
|
12
|
+
reasoning: import("zod").ZodOptional<import("zod").ZodString>;
|
|
13
|
+
}, import("zod/v4/core").$strip>;
|
|
14
|
+
export declare const BulkCloneRepoLocalSchema: import("zod").ZodObject<{
|
|
15
|
+
responseCharOffset: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodNumber>>;
|
|
16
|
+
responseCharLength: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodNumber>>;
|
|
17
|
+
queries: import("zod").ZodArray<import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>;
|
|
18
|
+
}, import("zod/v4/core").$strip>;
|
|
19
|
+
interface GitHubCloneRepoData {
|
|
20
|
+
localPath: string;
|
|
21
|
+
resolvedBranch?: string;
|
|
22
|
+
cached?: boolean;
|
|
23
|
+
sparsePath?: string;
|
|
24
|
+
cloneTimeMs?: number;
|
|
25
|
+
totalSize?: number;
|
|
26
|
+
fileCount?: number;
|
|
27
|
+
location?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
export type GitHubCloneRepoOutputLocal = {
|
|
30
|
+
status?: string;
|
|
31
|
+
data?: GitHubCloneRepoData;
|
|
32
|
+
localPath?: string;
|
|
33
|
+
resolvedBranch?: string;
|
|
34
|
+
cached?: boolean;
|
|
35
|
+
sparsePath?: string;
|
|
36
|
+
location?: Record<string, unknown>;
|
|
37
|
+
warnings?: string[];
|
|
38
|
+
error?: string;
|
|
22
39
|
base?: string;
|
|
23
40
|
shared?: Record<string, string | number | boolean>;
|
|
24
41
|
responsePagination?: ResponsePaginationInfo;
|
|
25
42
|
next?: Record<string, ToolContinuation>;
|
|
26
|
-
}
|
|
43
|
+
} & Record<string, unknown>;
|
|
44
|
+
export {};
|
|
@@ -9,6 +9,8 @@ export type PartialFileContentQuery = WithOptionalMeta<FileContentQuery> & Query
|
|
|
9
9
|
export type FileEntry = {
|
|
10
10
|
path: string;
|
|
11
11
|
content: string;
|
|
12
|
+
/** Coarse file bucket to guide how bytes are read; omitted when uncertain. */
|
|
13
|
+
fileType?: 'code' | 'config' | 'lock' | 'doc';
|
|
12
14
|
localPath?: string;
|
|
13
15
|
repoRoot?: string;
|
|
14
16
|
contentView?: 'none' | 'standard' | 'symbols';
|
|
@@ -8,8 +8,7 @@ export declare function shapeFileChange(change: Record<string, unknown>, include
|
|
|
8
8
|
additions: number;
|
|
9
9
|
deletions: number;
|
|
10
10
|
};
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function shapeFileSurfaces(pr: Record<string, unknown>, query: QueryLike, request: NormalizedPrContentRequest, shouldMinify?: boolean): {
|
|
11
|
+
export declare function shapeFileSurfaces(pr: Record<string, unknown>, query: QueryLike, request: NormalizedPrContentRequest): {
|
|
13
12
|
changedFiles: {
|
|
14
13
|
patch?: string;
|
|
15
14
|
path: string;
|
|
@@ -188,6 +188,9 @@ export declare const SearchCommitsLocalSchema: import("zod").ZodObject<{
|
|
|
188
188
|
itemsPerPage: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodNumber>>;
|
|
189
189
|
includeDiff: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
|
|
190
190
|
page: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
191
|
+
filePage: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
192
|
+
charOffset: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
193
|
+
charLength: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
191
194
|
id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
192
195
|
mainResearchGoal: import("zod").ZodOptional<import("zod").ZodString>;
|
|
193
196
|
researchGoal: import("zod").ZodOptional<import("zod").ZodString>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common configuration / manifest file detection + coarse file-type
|
|
3
|
+
* classification.
|
|
4
|
+
*
|
|
5
|
+
* `isConfigFile` combines three matching strategies:
|
|
6
|
+
* 1. Exact basename match (e.g. `package.json`, `Cargo.toml`).
|
|
7
|
+
* 2. Basename regex match for variadic names (e.g. `.eslintrc.*`, `*.csproj`).
|
|
8
|
+
* 3. Config-ish extension match for structured formats (e.g. `.toml`, `.ini`).
|
|
9
|
+
*
|
|
10
|
+
* `classifyFileType` layers lock/doc/code detection on top so fetch tools can
|
|
11
|
+
* tell an agent whether a path is a `code`, `config`, `lock`, `doc`, or
|
|
12
|
+
* `other` file — a cheap signal that changes how the returned bytes should be
|
|
13
|
+
* read.
|
|
14
|
+
*
|
|
15
|
+
* Config vs lock — rule of thumb: a CONFIG/manifest file declares *how* a
|
|
16
|
+
* package/service/code is meant to work and *which* dependencies it wants
|
|
17
|
+
* (`package.json`, `Cargo.toml`, `go.mod`, `pyproject.toml`, `tsconfig.json`).
|
|
18
|
+
* A LOCK file is a generated snapshot pinning the *resolved* dependency tree
|
|
19
|
+
* (`yarn.lock`, `package-lock.json`, `Cargo.lock`, `go.sum`) — not authored,
|
|
20
|
+
* rarely worth reading in full, and never the source of truth for intent.
|
|
21
|
+
*
|
|
22
|
+
* Scope is deliberately limited to config/manifest/lock files of the top
|
|
23
|
+
* popular languages and platforms — not every conceivable dotfile.
|
|
24
|
+
*/
|
|
25
|
+
/** Exact config file basenames, grouped by ecosystem for readability. */
|
|
26
|
+
export declare const CONFIG_FILENAMES: readonly string[];
|
|
27
|
+
/**
|
|
28
|
+
* Dependency lock files — generated snapshots that pin a resolved dependency
|
|
29
|
+
* tree. Distinct from config/manifests: they are not authored by hand and
|
|
30
|
+
* rarely need to be read in full. Grouped by ecosystem.
|
|
31
|
+
*/
|
|
32
|
+
export declare const LOCK_FILENAMES: readonly string[];
|
|
33
|
+
/** Regex patterns for variadic / templated config filenames. */
|
|
34
|
+
export declare const CONFIG_FILENAME_PATTERNS: readonly RegExp[];
|
|
35
|
+
/** Extensions that indicate a structured config format. */
|
|
36
|
+
export declare const CONFIG_EXTENSIONS: readonly string[];
|
|
37
|
+
/**
|
|
38
|
+
* Coarse file-type buckets returned to fetch callers. Deliberately has no
|
|
39
|
+
* `other`/`unknown` member: when a path can't be confidently placed in one of
|
|
40
|
+
* these buckets, `classifyFileType` returns `undefined` and callers omit the
|
|
41
|
+
* field entirely rather than emit a low-confidence guess.
|
|
42
|
+
*/
|
|
43
|
+
export type FileType = 'code' | 'config' | 'lock' | 'doc';
|
|
44
|
+
/**
|
|
45
|
+
* Returns true when the given path points to a common config / manifest file.
|
|
46
|
+
*
|
|
47
|
+
* @param filePath A file path or bare filename.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isConfigFile(filePath: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Returns true when the path is a dependency lock file (a pinned, generated
|
|
52
|
+
* resolution snapshot) rather than an authored config/manifest.
|
|
53
|
+
*
|
|
54
|
+
* @param filePath A file path or bare filename.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isLockFile(filePath: string): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Classify a path into a coarse bucket so agents can decide how to read it.
|
|
59
|
+
*
|
|
60
|
+
* Precedence (most specific first): lock → config → doc → code. Lock wins
|
|
61
|
+
* first (a lockfile is never config/source). Config then wins over code/doc
|
|
62
|
+
* because manifests like `vite.config.js` or `pyproject.toml` carry a
|
|
63
|
+
* `.js`/`.toml` extension yet are configuration, not source.
|
|
64
|
+
*
|
|
65
|
+
* Returns `undefined` when the path matches none of the buckets — callers
|
|
66
|
+
* MUST omit the field in that case rather than emit an uncertain guess.
|
|
67
|
+
*
|
|
68
|
+
* @param filePath A file path or bare filename.
|
|
69
|
+
*/
|
|
70
|
+
export declare function classifyFileType(filePath: string): FileType | undefined;
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octocodeai/octocode-tools-core",
|
|
3
3
|
"description": "Core tool implementations for Octocode: GitHub, local filesystem, LSP, and package search tools.",
|
|
4
|
-
"version": "18.
|
|
4
|
+
"version": "18.1.2",
|
|
5
5
|
"author": "Guy Bary <bgauryy@octocodeai.com>",
|
|
6
6
|
"bugs": "https://github.com/bgauryy/octocode/issues",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
9
9
|
"@octocodeai/config": "18.0.1",
|
|
10
|
-
"@octocodeai/octocode-core": "18.0
|
|
11
|
-
"@octocodeai/octocode-engine": "18.
|
|
10
|
+
"@octocodeai/octocode-core": "18.2.0",
|
|
11
|
+
"@octocodeai/octocode-engine": "18.1.2",
|
|
12
12
|
"@octokit/oauth-methods": "^6.0.2",
|
|
13
13
|
"@octokit/plugin-throttling": "^11.0.3",
|
|
14
14
|
"@octokit/request": "^10.0.10",
|