@sourcebot/mcp 1.0.12 → 1.0.14
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/CHANGELOG.md +18 -0
- package/README.md +44 -18
- package/dist/client.d.ts +124 -4
- package/dist/client.js +63 -23
- package/dist/client.js.map +1 -1
- package/dist/index.js +78 -99
- package/dist/index.js.map +1 -1
- package/dist/schemas.d.ts +128 -34
- package/dist/schemas.js +94 -15
- package/dist/schemas.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +4 -2
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +7 -0
- package/dist/utils.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,iCAAiC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,oBAAoB;AACpB,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IACzB,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,OAAO;CACnB,CAAC,CAAC;AAGH,MAAM,CAAC,IAAI,CACP,aAAa,EACb;;;;;mIAK+H,EAC/H;IACI,KAAK,EAAE,CAAC;SACH,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B,CAAC,CAAC;IAEH,IAAI,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3B,OAAO;YACH,OAAO,EAAE,CAAC;oBACN,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,+BAA+B,QAAQ,CAAC,OAAO,EAAE;iBAC1D,CAAC;SACL,CAAC;IACN,CAAC;IAED,MAAM,OAAO,GAAkB,CAAC;YAC5B,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,SAAS,QAAQ,iBAAiB,MAAM,eAAe,QAAQ,CAAC,QAAQ,cAAc,QAAQ,CAAC,MAAM,EAAE;SAChH,CAAC,CAAA;IAEF,OAAO;QACH,OAAO;KACV,CAAC;AACN,CAAC,CACJ,CAAC;AAIF,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;IACzB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AACpC,CAAC,CAAA;AAED,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACxB,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;IACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\n// Entry point for the MCP server\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport escapeStringRegexp from 'escape-string-regexp';\nimport { z } from 'zod';\nimport { listRepos, search, getFileSource } from './client.js';\nimport { env, numberSchema } from './env.js';\nimport { listReposRequestSchema } from './schemas.js';\nimport { TextContent } from './types.js';\nimport { isServiceError } from './utils.js';\n\n// Create MCP server\nconst server = new McpServer({\n name: 'sourcebot-mcp-server',\n version: '0.1.0',\n});\n\n\nserver.tool(\n \"search_code\",\n `Fetches code that matches the provided regex pattern in \\`query\\`. This is NOT a semantic search.\n Results are returned as an array of matching files, with the file's URL, repository, and language.\n If you receive an error that indicates that you're not authenticated, please inform the user to set the SOURCEBOT_API_KEY environment variable.\n If the \\`includeCodeSnippets\\` property is true, code snippets containing the matches will be included in the response. Only set this to true if the request requires code snippets (e.g., show me examples where library X is used).\n When referencing a file in your response, **ALWAYS** include the file's external URL as a link. This makes it easier for the user to view the file, even if they don't have it locally checked out.\n **ONLY USE** the \\`filterByRepoIds\\` property if the request requires searching a specific repo(s). Otherwise, leave it empty.`,\n {\n query: z\n .string()\n .describe(`The regex pattern to search for. RULES:\n 1. When a regex special character needs to be escaped, ALWAYS use a single backslash (\\) (e.g., 'console\\.log')\n 2. **ALWAYS** escape spaces with a single backslash (\\) (e.g., 'console\\ log')\n `),\n filterByRepoIds: z\n .array(z.string())\n .describe(`Scope the search to the provided repositories to the Sourcebot compatible repository IDs. **DO NOT** use this property if you want to search all repositories. **YOU MUST** call 'list_repos' first to obtain the exact repository ID.`)\n .optional(),\n filterByLanguages: z\n .array(z.string())\n .describe(`Scope the search to the provided languages. The language MUST be formatted as a GitHub linguist language. Examples: Python, JavaScript, TypeScript, Java, C#, C++, PHP, Go, Rust, Ruby, Swift, Kotlin, Shell, C, Dart, HTML, CSS, PowerShell, SQL, R`)\n .optional(),\n caseSensitive: z\n .boolean()\n .describe(`Whether the search should be case sensitive (default: false).`)\n .optional(),\n includeCodeSnippets: z\n .boolean()\n .describe(`Whether to include the code snippets in the response (default: false). If false, only the file's URL, repository, and language will be returned. Set to false to get a more concise response.`)\n .optional(),\n maxTokens: numberSchema\n .describe(`The maximum number of tokens to return (default: ${env.DEFAULT_MINIMUM_TOKENS}). Higher values provide more context but consume more tokens. Values less than ${env.DEFAULT_MINIMUM_TOKENS} will be ignored.`)\n .transform((val) => (val < env.DEFAULT_MINIMUM_TOKENS ? env.DEFAULT_MINIMUM_TOKENS : val))\n .optional(),\n },\n async ({\n query,\n filterByRepoIds: repoIds = [],\n filterByLanguages: languages = [],\n maxTokens = env.DEFAULT_MINIMUM_TOKENS,\n includeCodeSnippets = false,\n caseSensitive = false,\n }) => {\n if (repoIds.length > 0) {\n query += ` ( repo:${repoIds.map(id => escapeStringRegexp(id)).join(' or repo:')} )`;\n }\n\n if (languages.length > 0) {\n query += ` ( lang:${languages.join(' or lang:')} )`;\n }\n\n const response = await search({\n query,\n matches: env.DEFAULT_MATCHES,\n contextLines: env.DEFAULT_CONTEXT_LINES,\n isRegexEnabled: true,\n isCaseSensitivityEnabled: caseSensitive,\n source: 'mcp'\n });\n\n if (isServiceError(response)) {\n return {\n content: [{\n type: \"text\",\n text: `Error searching code: ${response.message}`,\n }],\n };\n }\n\n if (response.files.length === 0) {\n return {\n content: [{\n type: \"text\",\n text: `No results found for the query: ${query}`,\n }],\n };\n }\n\n const content: TextContent[] = [];\n let totalTokens = 0;\n let isResponseTruncated = false;\n\n for (const file of response.files) {\n const numMatches = file.chunks.reduce(\n (acc, chunk) => acc + chunk.matchRanges.length,\n 0,\n );\n const fileIdentifier = file.webUrl ?? file.fileName.text;\n let text = `file: ${fileIdentifier}\\nnum_matches: ${numMatches}\\nrepository: ${file.repository}\\nlanguage: ${file.language}`;\n\n if (includeCodeSnippets) {\n const snippets = file.chunks.map(chunk => {\n return `\\`\\`\\`\\n${chunk.content}\\n\\`\\`\\``\n }).join('\\n');\n text += `\\n\\n${snippets}`;\n }\n\n\n // Rough estimate of the number of tokens in the text\n // @see: https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them\n const tokens = text.length / 4;\n\n if ((totalTokens + tokens) > maxTokens) {\n // Calculate remaining token budget\n const remainingTokens = maxTokens - totalTokens;\n\n if (remainingTokens > 100) { // Only truncate if meaningful space left\n // Truncate text to fit remaining tokens (tokens ≈ chars/4)\n const maxLength = Math.floor(remainingTokens * 4);\n const truncatedText = text.substring(0, maxLength) + \"\\n\\n...[content truncated due to token limit]\";\n\n content.push({\n type: \"text\",\n text: truncatedText,\n });\n\n totalTokens += remainingTokens;\n }\n\n isResponseTruncated = true;\n break;\n }\n\n totalTokens += tokens;\n content.push({\n type: \"text\",\n text,\n });\n }\n\n if (isResponseTruncated) {\n content.push({\n type: \"text\",\n text: `The response was truncated because the number of tokens exceeded the maximum limit of ${maxTokens}.`,\n });\n }\n\n return {\n content,\n }\n }\n);\n\nserver.tool(\n \"list_repos\",\n \"Lists repositories in the organization with optional filtering and pagination. If you receive an error that indicates that you're not authenticated, please inform the user to set the SOURCEBOT_API_KEY environment variable.\",\n listReposRequestSchema.shape,\n async ({ query, pageNumber = 1, limit = 50 }: {\n query?: string;\n pageNumber?: number;\n limit?: number;\n }) => {\n const response = await listRepos();\n if (isServiceError(response)) {\n return {\n content: [{\n type: \"text\",\n text: `Error listing repositories: ${response.message}`,\n }],\n };\n }\n\n // Apply query filter if provided\n let filtered = response;\n if (query) {\n const lowerQuery = query.toLowerCase();\n filtered = response.filter(repo =>\n repo.repoName.toLowerCase().includes(lowerQuery) ||\n repo.repoDisplayName?.toLowerCase().includes(lowerQuery)\n );\n }\n\n // Sort alphabetically for consistent pagination\n filtered.sort((a, b) => a.repoName.localeCompare(b.repoName));\n\n // Apply pagination\n const startIndex = (pageNumber - 1) * limit;\n const endIndex = startIndex + limit;\n const paginated = filtered.slice(startIndex, endIndex);\n\n // Format output\n const content: TextContent[] = paginated.map(repo => {\n const repoUrl = repo.webUrl ?? repo.repoCloneUrl;\n return {\n type: \"text\",\n text: `id: ${repo.repoName}\\nurl: ${repoUrl}`,\n }\n });\n\n // Add pagination info\n if (content.length === 0 && filtered.length > 0) {\n content.push({\n type: \"text\",\n text: `No results on page ${pageNumber}. Total matching repositories: ${filtered.length}`,\n });\n } else if (filtered.length > endIndex) {\n content.push({\n type: \"text\",\n text: `Showing ${paginated.length} repositories (page ${pageNumber}). Total matching: ${filtered.length}. Use pageNumber ${pageNumber + 1} to see more.`,\n });\n }\n\n return {\n content,\n };\n }\n);\n\nserver.tool(\n \"get_file_source\",\n \"Fetches the source code for a given file. If you receive an error that indicates that you're not authenticated, please inform the user to set the SOURCEBOT_API_KEY environment variable.\",\n {\n fileName: z.string().describe(\"The file to fetch the source code for.\"),\n repoId: z.string().describe(\"The repository to fetch the source code for. This is the Sourcebot compatible repository ID.\"),\n },\n async ({ fileName, repoId }) => {\n const response = await getFileSource({\n fileName,\n repository: repoId,\n });\n\n if (isServiceError(response)) {\n return {\n content: [{\n type: \"text\",\n text: `Error fetching file source: ${response.message}`,\n }],\n };\n }\n\n const content: TextContent[] = [{\n type: \"text\",\n text: `file: ${fileName}\\nrepository: ${repoId}\\nlanguage: ${response.language}\\nsource:\\n${response.source}`,\n }]\n\n return {\n content,\n };\n }\n);\n\n\n\nconst runServer = async () => {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n\nrunServer().catch((error) => {\n console.error('Failed to start MCP server:', error);\n process.exit(1);\n});\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,iCAAiC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,OAAO,MAAM,QAAQ,CAAC;AAC7B,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAGjH,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;AAE1D,oBAAoB;AACpB,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IACzB,IAAI,EAAE,sBAA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,OAAO,CAAC,SAAS,CAAC,CAAC;AACpC,CAAC,CAAA;AAED,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACxB,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;IACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\n// Entry point for the MCP server\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport _dedent from \"dedent\";\nimport escapeStringRegexp from 'escape-string-regexp';\nimport { z } from 'zod';\nimport { getFileSource, listCommits, listRepos, search } from './client.js';\nimport { env, numberSchema } from './env.js';\nimport { fileSourceRequestSchema, listCommitsQueryParamsSchema, listReposQueryParamsSchema } from './schemas.js';\nimport { FileSourceRequest, ListCommitsQueryParamsSchema, ListReposQueryParams, TextContent } from './types.js';\n\nconst dedent = _dedent.withOptions({ alignValues: true });\n\n// Create MCP server\nconst server = new McpServer({\n name: 'sourcebot-mcp-server',\n version: '0.1.0',\n});\n\n\nserver.tool(\n \"search_code\",\n dedent`\n Searches for code that matches the provided search query as a substring by default, or as a regular expression if useRegex is true. Useful for exploring remote repositories by searching for exact symbols, functions, variables, or specific code patterns. To determine if a repository is indexed, use the \\`list_repos\\` tool. By default, searches are global and will search the default branch of all repositories. Searches can be scoped to specific repositories, languages, and branches. When referencing code outputted by this tool, always include the file's external URL as a link. This makes it easier for the user to view the file, even if they don't have it locally checked out.\n `,\n {\n query: z\n .string()\n .describe(`The search pattern to match against code contents. Do not escape quotes in your query.`)\n // Escape backslashes first, then quotes, and wrap in double quotes\n // so the query is treated as a literal phrase (like grep).\n .transform((val) => {\n const escaped = val.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n return `\"${escaped}\"`;\n }),\n useRegex: z\n .boolean()\n .describe(`Whether to use regular expression matching to match the search query against code contents. When false, substring matching is used. (default: false)`)\n .optional(),\n filterByRepos: z\n .array(z.string())\n .describe(`Scope the search to the provided repositories.`)\n .optional(),\n filterByLanguages: z\n .array(z.string())\n .describe(`Scope the search to the provided languages.`)\n .optional(),\n filterByFilepaths: z\n .array(z.string())\n .describe(`Scope the search to the provided filepaths.`)\n .optional(),\n caseSensitive: z\n .boolean()\n .describe(`Whether the search should be case sensitive (default: false).`)\n .optional(),\n includeCodeSnippets: z\n .boolean()\n .describe(`Whether to include the code snippets in the response. If false, only the file's URL, repository, and language will be returned. (default: false)`)\n .optional(),\n ref: z\n .string()\n .describe(`Commit SHA, branch or tag name to search on. If not provided, defaults to the default branch (usually 'main' or 'master').`)\n .optional(),\n maxTokens: numberSchema\n .describe(`The maximum number of tokens to return (default: ${env.DEFAULT_MINIMUM_TOKENS}). Higher values provide more context but consume more tokens. Values less than ${env.DEFAULT_MINIMUM_TOKENS} will be ignored.`)\n .transform((val) => (val < env.DEFAULT_MINIMUM_TOKENS ? env.DEFAULT_MINIMUM_TOKENS : val))\n .optional(),\n },\n async ({\n query,\n filterByRepos: repos = [],\n filterByLanguages: languages = [],\n filterByFilepaths: filepaths = [],\n maxTokens = env.DEFAULT_MINIMUM_TOKENS,\n includeCodeSnippets = false,\n caseSensitive = false,\n ref,\n useRegex = false,\n }) => {\n if (repos.length > 0) {\n query += ` (repo:${repos.map(id => escapeStringRegexp(id)).join(' or repo:')})`;\n }\n\n if (languages.length > 0) {\n query += ` (lang:${languages.join(' or lang:')})`;\n }\n\n if (filepaths.length > 0) {\n query += ` (file:${filepaths.map(filepath => escapeStringRegexp(filepath)).join(' or file:')})`;\n }\n\n if (ref) {\n query += ` ( rev:${ref} )`;\n }\n\n const response = await search({\n query,\n matches: env.DEFAULT_MATCHES,\n contextLines: env.DEFAULT_CONTEXT_LINES,\n isRegexEnabled: useRegex,\n isCaseSensitivityEnabled: caseSensitive,\n source: 'mcp',\n });\n\n if (response.files.length === 0) {\n return {\n content: [{\n type: \"text\",\n text: `No results found for the query: ${query}`,\n }],\n };\n }\n\n const content: TextContent[] = [];\n let totalTokens = 0;\n let isResponseTruncated = false;\n\n for (const file of response.files) {\n const numMatches = file.chunks.reduce(\n (acc, chunk) => acc + chunk.matchRanges.length,\n 0,\n );\n let text = dedent`\n file: ${file.webUrl}\n num_matches: ${numMatches}\n repo: ${file.repository}\n language: ${file.language}\n `;\n\n if (includeCodeSnippets) {\n const snippets = file.chunks.map(chunk => {\n return `\\`\\`\\`\\n${chunk.content}\\n\\`\\`\\``\n }).join('\\n');\n text += `\\n\\n${snippets}`;\n }\n\n\n // Rough estimate of the number of tokens in the text\n // @see: https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them\n const tokens = text.length / 4;\n\n if ((totalTokens + tokens) > maxTokens) {\n // Calculate remaining token budget\n const remainingTokens = maxTokens - totalTokens;\n\n if (remainingTokens > 100) { // Only truncate if meaningful space left\n // Truncate text to fit remaining tokens (tokens ≈ chars/4)\n const maxLength = Math.floor(remainingTokens * 4);\n const truncatedText = text.substring(0, maxLength) + \"\\n\\n...[content truncated due to token limit]\";\n\n content.push({\n type: \"text\",\n text: truncatedText,\n });\n\n totalTokens += remainingTokens;\n }\n\n isResponseTruncated = true;\n break;\n }\n\n totalTokens += tokens;\n content.push({\n type: \"text\",\n text,\n });\n }\n\n if (isResponseTruncated) {\n content.push({\n type: \"text\",\n text: `The response was truncated because the number of tokens exceeded the maximum limit of ${maxTokens}.`,\n });\n }\n\n return {\n content,\n }\n }\n);\n\nserver.tool(\n \"list_commits\",\n dedent`Get a list of commits for a given repository.`,\n listCommitsQueryParamsSchema.shape,\n async (request: ListCommitsQueryParamsSchema) => {\n const result = await listCommits(request);\n\n return {\n content: [{\n type: \"text\", text: JSON.stringify(result)\n }],\n };\n }\n);\n\nserver.tool(\n \"list_repos\",\n dedent`Lists repositories in the organization with optional filtering and pagination.`,\n listReposQueryParamsSchema.shape,\n async (request: ListReposQueryParams) => {\n const result = await listRepos(request);\n\n return {\n content: [{\n type: \"text\", text: JSON.stringify({\n repos: result.repos.map((repo) => ({\n name: repo.repoName,\n url: repo.webUrl,\n pushedAt: repo.pushedAt,\n })),\n totalCount: result.totalCount,\n })\n }]\n };\n }\n);\n\nserver.tool(\n \"read_file\",\n dedent`Reads the source code for a given file.`,\n fileSourceRequestSchema.shape,\n async (request: FileSourceRequest) => {\n const response = await getFileSource(request);\n\n return {\n content: [{\n type: \"text\", text: JSON.stringify({\n source: response.source,\n language: response.language,\n path: response.path,\n url: response.webUrl,\n })\n }]\n };\n }\n);\n\n\n\nconst runServer = async () => {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n\nrunServer().catch((error) => {\n console.error('Failed to start MCP server:', error);\n process.exit(1);\n});\n"]}
|
package/dist/schemas.d.ts
CHANGED
|
@@ -352,7 +352,8 @@ export declare const searchResponseSchema: z.ZodObject<{
|
|
|
352
352
|
};
|
|
353
353
|
}[];
|
|
354
354
|
}>;
|
|
355
|
-
webUrl: z.
|
|
355
|
+
webUrl: z.ZodString;
|
|
356
|
+
externalWebUrl: z.ZodOptional<z.ZodString>;
|
|
356
357
|
repository: z.ZodString;
|
|
357
358
|
repositoryId: z.ZodNumber;
|
|
358
359
|
language: z.ZodString;
|
|
@@ -507,6 +508,7 @@ export declare const searchResponseSchema: z.ZodObject<{
|
|
|
507
508
|
branches: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
508
509
|
content: z.ZodOptional<z.ZodString>;
|
|
509
510
|
}, "strip", z.ZodTypeAny, {
|
|
511
|
+
webUrl: string;
|
|
510
512
|
fileName: {
|
|
511
513
|
text: string;
|
|
512
514
|
matchRanges: {
|
|
@@ -553,10 +555,11 @@ export declare const searchResponseSchema: z.ZodObject<{
|
|
|
553
555
|
} | undefined;
|
|
554
556
|
}[] | undefined;
|
|
555
557
|
}[];
|
|
556
|
-
|
|
558
|
+
externalWebUrl?: string | undefined;
|
|
557
559
|
content?: string | undefined;
|
|
558
560
|
branches?: string[] | undefined;
|
|
559
561
|
}, {
|
|
562
|
+
webUrl: string;
|
|
560
563
|
fileName: {
|
|
561
564
|
text: string;
|
|
562
565
|
matchRanges: {
|
|
@@ -603,7 +606,7 @@ export declare const searchResponseSchema: z.ZodObject<{
|
|
|
603
606
|
} | undefined;
|
|
604
607
|
}[] | undefined;
|
|
605
608
|
}[];
|
|
606
|
-
|
|
609
|
+
externalWebUrl?: string | undefined;
|
|
607
610
|
content?: string | undefined;
|
|
608
611
|
branches?: string[] | undefined;
|
|
609
612
|
}>, "many">;
|
|
@@ -652,6 +655,7 @@ export declare const searchResponseSchema: z.ZodObject<{
|
|
|
652
655
|
flushReason: string;
|
|
653
656
|
};
|
|
654
657
|
files: {
|
|
658
|
+
webUrl: string;
|
|
655
659
|
fileName: {
|
|
656
660
|
text: string;
|
|
657
661
|
matchRanges: {
|
|
@@ -698,7 +702,7 @@ export declare const searchResponseSchema: z.ZodObject<{
|
|
|
698
702
|
} | undefined;
|
|
699
703
|
}[] | undefined;
|
|
700
704
|
}[];
|
|
701
|
-
|
|
705
|
+
externalWebUrl?: string | undefined;
|
|
702
706
|
content?: string | undefined;
|
|
703
707
|
branches?: string[] | undefined;
|
|
704
708
|
}[];
|
|
@@ -735,6 +739,7 @@ export declare const searchResponseSchema: z.ZodObject<{
|
|
|
735
739
|
flushReason: string;
|
|
736
740
|
};
|
|
737
741
|
files: {
|
|
742
|
+
webUrl: string;
|
|
738
743
|
fileName: {
|
|
739
744
|
text: string;
|
|
740
745
|
matchRanges: {
|
|
@@ -781,7 +786,7 @@ export declare const searchResponseSchema: z.ZodObject<{
|
|
|
781
786
|
} | undefined;
|
|
782
787
|
}[] | undefined;
|
|
783
788
|
}[];
|
|
784
|
-
|
|
789
|
+
externalWebUrl?: string | undefined;
|
|
785
790
|
content?: string | undefined;
|
|
786
791
|
branches?: string[] | undefined;
|
|
787
792
|
}[];
|
|
@@ -799,92 +804,128 @@ export declare const repositoryQuerySchema: z.ZodObject<{
|
|
|
799
804
|
repoId: z.ZodNumber;
|
|
800
805
|
repoName: z.ZodString;
|
|
801
806
|
repoDisplayName: z.ZodOptional<z.ZodString>;
|
|
802
|
-
|
|
803
|
-
|
|
807
|
+
webUrl: z.ZodString;
|
|
808
|
+
externalWebUrl: z.ZodOptional<z.ZodString>;
|
|
804
809
|
imageUrl: z.ZodOptional<z.ZodString>;
|
|
805
810
|
indexedAt: z.ZodOptional<z.ZodDate>;
|
|
811
|
+
pushedAt: z.ZodOptional<z.ZodDate>;
|
|
806
812
|
}, "strip", z.ZodTypeAny, {
|
|
807
813
|
codeHostType: string;
|
|
814
|
+
webUrl: string;
|
|
808
815
|
repoId: number;
|
|
809
816
|
repoName: string;
|
|
810
|
-
|
|
811
|
-
webUrl?: string | undefined;
|
|
817
|
+
externalWebUrl?: string | undefined;
|
|
812
818
|
repoDisplayName?: string | undefined;
|
|
813
819
|
imageUrl?: string | undefined;
|
|
814
820
|
indexedAt?: Date | undefined;
|
|
821
|
+
pushedAt?: Date | undefined;
|
|
815
822
|
}, {
|
|
816
823
|
codeHostType: string;
|
|
824
|
+
webUrl: string;
|
|
817
825
|
repoId: number;
|
|
818
826
|
repoName: string;
|
|
819
|
-
|
|
820
|
-
webUrl?: string | undefined;
|
|
827
|
+
externalWebUrl?: string | undefined;
|
|
821
828
|
repoDisplayName?: string | undefined;
|
|
822
829
|
imageUrl?: string | undefined;
|
|
823
830
|
indexedAt?: Date | undefined;
|
|
831
|
+
pushedAt?: Date | undefined;
|
|
824
832
|
}>;
|
|
825
|
-
export declare const
|
|
833
|
+
export declare const listReposResponseSchema: z.ZodArray<z.ZodObject<{
|
|
826
834
|
codeHostType: z.ZodString;
|
|
827
835
|
repoId: z.ZodNumber;
|
|
828
836
|
repoName: z.ZodString;
|
|
829
837
|
repoDisplayName: z.ZodOptional<z.ZodString>;
|
|
830
|
-
|
|
831
|
-
|
|
838
|
+
webUrl: z.ZodString;
|
|
839
|
+
externalWebUrl: z.ZodOptional<z.ZodString>;
|
|
832
840
|
imageUrl: z.ZodOptional<z.ZodString>;
|
|
833
841
|
indexedAt: z.ZodOptional<z.ZodDate>;
|
|
842
|
+
pushedAt: z.ZodOptional<z.ZodDate>;
|
|
834
843
|
}, "strip", z.ZodTypeAny, {
|
|
835
844
|
codeHostType: string;
|
|
845
|
+
webUrl: string;
|
|
836
846
|
repoId: number;
|
|
837
847
|
repoName: string;
|
|
838
|
-
|
|
839
|
-
webUrl?: string | undefined;
|
|
848
|
+
externalWebUrl?: string | undefined;
|
|
840
849
|
repoDisplayName?: string | undefined;
|
|
841
850
|
imageUrl?: string | undefined;
|
|
842
851
|
indexedAt?: Date | undefined;
|
|
852
|
+
pushedAt?: Date | undefined;
|
|
843
853
|
}, {
|
|
844
854
|
codeHostType: string;
|
|
855
|
+
webUrl: string;
|
|
845
856
|
repoId: number;
|
|
846
857
|
repoName: string;
|
|
847
|
-
|
|
848
|
-
webUrl?: string | undefined;
|
|
858
|
+
externalWebUrl?: string | undefined;
|
|
849
859
|
repoDisplayName?: string | undefined;
|
|
850
860
|
imageUrl?: string | undefined;
|
|
851
861
|
indexedAt?: Date | undefined;
|
|
862
|
+
pushedAt?: Date | undefined;
|
|
852
863
|
}>, "many">;
|
|
853
|
-
export declare const
|
|
864
|
+
export declare const listReposQueryParamsSchema: z.ZodObject<{
|
|
854
865
|
query: z.ZodOptional<z.ZodString>;
|
|
855
|
-
|
|
856
|
-
|
|
866
|
+
page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
867
|
+
perPage: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
868
|
+
sort: z.ZodDefault<z.ZodOptional<z.ZodEnum<["name", "pushed"]>>>;
|
|
869
|
+
direction: z.ZodDefault<z.ZodOptional<z.ZodEnum<["asc", "desc"]>>>;
|
|
857
870
|
}, "strip", z.ZodTypeAny, {
|
|
858
|
-
|
|
859
|
-
|
|
871
|
+
sort: "name" | "pushed";
|
|
872
|
+
page: number;
|
|
873
|
+
perPage: number;
|
|
874
|
+
direction: "asc" | "desc";
|
|
860
875
|
query?: string | undefined;
|
|
861
876
|
}, {
|
|
877
|
+
sort?: "name" | "pushed" | undefined;
|
|
862
878
|
query?: string | undefined;
|
|
863
|
-
|
|
864
|
-
|
|
879
|
+
page?: number | undefined;
|
|
880
|
+
perPage?: number | undefined;
|
|
881
|
+
direction?: "asc" | "desc" | undefined;
|
|
865
882
|
}>;
|
|
866
883
|
export declare const fileSourceRequestSchema: z.ZodObject<{
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
884
|
+
repo: z.ZodString;
|
|
885
|
+
path: z.ZodString;
|
|
886
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
870
887
|
}, "strip", z.ZodTypeAny, {
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
888
|
+
path: string;
|
|
889
|
+
repo: string;
|
|
890
|
+
ref?: string | undefined;
|
|
874
891
|
}, {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
892
|
+
path: string;
|
|
893
|
+
repo: string;
|
|
894
|
+
ref?: string | undefined;
|
|
878
895
|
}>;
|
|
879
896
|
export declare const fileSourceResponseSchema: z.ZodObject<{
|
|
880
897
|
source: z.ZodString;
|
|
881
898
|
language: z.ZodString;
|
|
899
|
+
path: z.ZodString;
|
|
900
|
+
repo: z.ZodString;
|
|
901
|
+
repoCodeHostType: z.ZodString;
|
|
902
|
+
repoDisplayName: z.ZodOptional<z.ZodString>;
|
|
903
|
+
repoExternalWebUrl: z.ZodOptional<z.ZodString>;
|
|
904
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
905
|
+
webUrl: z.ZodString;
|
|
906
|
+
externalWebUrl: z.ZodOptional<z.ZodString>;
|
|
882
907
|
}, "strip", z.ZodTypeAny, {
|
|
908
|
+
path: string;
|
|
883
909
|
source: string;
|
|
910
|
+
webUrl: string;
|
|
884
911
|
language: string;
|
|
912
|
+
repo: string;
|
|
913
|
+
repoCodeHostType: string;
|
|
914
|
+
externalWebUrl?: string | undefined;
|
|
915
|
+
repoDisplayName?: string | undefined;
|
|
916
|
+
repoExternalWebUrl?: string | undefined;
|
|
917
|
+
branch?: string | undefined;
|
|
885
918
|
}, {
|
|
919
|
+
path: string;
|
|
886
920
|
source: string;
|
|
921
|
+
webUrl: string;
|
|
887
922
|
language: string;
|
|
923
|
+
repo: string;
|
|
924
|
+
repoCodeHostType: string;
|
|
925
|
+
externalWebUrl?: string | undefined;
|
|
926
|
+
repoDisplayName?: string | undefined;
|
|
927
|
+
repoExternalWebUrl?: string | undefined;
|
|
928
|
+
branch?: string | undefined;
|
|
888
929
|
}>;
|
|
889
930
|
export declare const serviceErrorSchema: z.ZodObject<{
|
|
890
931
|
statusCode: z.ZodNumber;
|
|
@@ -899,3 +940,56 @@ export declare const serviceErrorSchema: z.ZodObject<{
|
|
|
899
940
|
statusCode: number;
|
|
900
941
|
errorCode: string;
|
|
901
942
|
}>;
|
|
943
|
+
export declare const listCommitsQueryParamsSchema: z.ZodObject<{
|
|
944
|
+
repo: z.ZodString;
|
|
945
|
+
query: z.ZodOptional<z.ZodString>;
|
|
946
|
+
since: z.ZodOptional<z.ZodString>;
|
|
947
|
+
until: z.ZodOptional<z.ZodString>;
|
|
948
|
+
author: z.ZodOptional<z.ZodString>;
|
|
949
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
950
|
+
page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
951
|
+
perPage: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
952
|
+
}, "strip", z.ZodTypeAny, {
|
|
953
|
+
page: number;
|
|
954
|
+
perPage: number;
|
|
955
|
+
repo: string;
|
|
956
|
+
query?: string | undefined;
|
|
957
|
+
ref?: string | undefined;
|
|
958
|
+
since?: string | undefined;
|
|
959
|
+
until?: string | undefined;
|
|
960
|
+
author?: string | undefined;
|
|
961
|
+
}, {
|
|
962
|
+
repo: string;
|
|
963
|
+
query?: string | undefined;
|
|
964
|
+
page?: number | undefined;
|
|
965
|
+
perPage?: number | undefined;
|
|
966
|
+
ref?: string | undefined;
|
|
967
|
+
since?: string | undefined;
|
|
968
|
+
until?: string | undefined;
|
|
969
|
+
author?: string | undefined;
|
|
970
|
+
}>;
|
|
971
|
+
export declare const listCommitsResponseSchema: z.ZodArray<z.ZodObject<{
|
|
972
|
+
hash: z.ZodString;
|
|
973
|
+
date: z.ZodString;
|
|
974
|
+
message: z.ZodString;
|
|
975
|
+
refs: z.ZodString;
|
|
976
|
+
body: z.ZodString;
|
|
977
|
+
author_name: z.ZodString;
|
|
978
|
+
author_email: z.ZodString;
|
|
979
|
+
}, "strip", z.ZodTypeAny, {
|
|
980
|
+
message: string;
|
|
981
|
+
date: string;
|
|
982
|
+
hash: string;
|
|
983
|
+
refs: string;
|
|
984
|
+
body: string;
|
|
985
|
+
author_name: string;
|
|
986
|
+
author_email: string;
|
|
987
|
+
}, {
|
|
988
|
+
message: string;
|
|
989
|
+
date: string;
|
|
990
|
+
hash: string;
|
|
991
|
+
refs: string;
|
|
992
|
+
body: string;
|
|
993
|
+
author_name: string;
|
|
994
|
+
author_email: string;
|
|
995
|
+
}>, "many">;
|
package/dist/schemas.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @NOTE : Please keep this file in sync with @sourcebot/web/src/features/search/
|
|
1
|
+
// @NOTE : Please keep this file in sync with @sourcebot/web/src/features/search/types.ts
|
|
2
2
|
// At some point, we should move these to a shared package...
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
export const locationSchema = z.object({
|
|
@@ -96,7 +96,8 @@ export const searchResponseSchema = z.object({
|
|
|
96
96
|
// Any matching ranges
|
|
97
97
|
matchRanges: z.array(rangeSchema),
|
|
98
98
|
}),
|
|
99
|
-
webUrl: z.string()
|
|
99
|
+
webUrl: z.string(),
|
|
100
|
+
externalWebUrl: z.string().optional(),
|
|
100
101
|
repository: z.string(),
|
|
101
102
|
repositoryId: z.number(),
|
|
102
103
|
language: z.string(),
|
|
@@ -121,42 +122,120 @@ export const repositoryQuerySchema = z.object({
|
|
|
121
122
|
repoId: z.number(),
|
|
122
123
|
repoName: z.string(),
|
|
123
124
|
repoDisplayName: z.string().optional(),
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
webUrl: z.string(),
|
|
126
|
+
externalWebUrl: z.string().optional(),
|
|
126
127
|
imageUrl: z.string().optional(),
|
|
127
128
|
indexedAt: z.coerce.date().optional(),
|
|
129
|
+
pushedAt: z.coerce.date().optional(),
|
|
128
130
|
});
|
|
129
|
-
export const
|
|
130
|
-
export const
|
|
131
|
+
export const listReposResponseSchema = repositoryQuerySchema.array();
|
|
132
|
+
export const listReposQueryParamsSchema = z.object({
|
|
131
133
|
query: z
|
|
132
134
|
.string()
|
|
133
|
-
.describe("Filter repositories by name
|
|
135
|
+
.describe("Filter repositories by name (case-insensitive)")
|
|
134
136
|
.optional(),
|
|
135
|
-
|
|
137
|
+
page: z
|
|
136
138
|
.number()
|
|
137
139
|
.int()
|
|
138
140
|
.positive()
|
|
139
|
-
.describe("Page number (1
|
|
141
|
+
.describe("Page number for pagination (min 1). Default: 1")
|
|
142
|
+
.optional()
|
|
140
143
|
.default(1),
|
|
141
|
-
|
|
144
|
+
perPage: z
|
|
142
145
|
.number()
|
|
143
146
|
.int()
|
|
144
147
|
.positive()
|
|
145
|
-
.
|
|
146
|
-
.
|
|
148
|
+
.max(100)
|
|
149
|
+
.describe("Results per page for pagination (min 1, max 100). Default: 30")
|
|
150
|
+
.optional()
|
|
151
|
+
.default(30),
|
|
152
|
+
sort: z
|
|
153
|
+
.enum(['name', 'pushed'])
|
|
154
|
+
.describe("Sort repositories by 'name' or 'pushed' (most recent commit). Default: 'name'")
|
|
155
|
+
.optional()
|
|
156
|
+
.default('name'),
|
|
157
|
+
direction: z
|
|
158
|
+
.enum(['asc', 'desc'])
|
|
159
|
+
.describe("Sort direction: 'asc' or 'desc'. Default: 'asc'")
|
|
160
|
+
.optional()
|
|
161
|
+
.default('asc'),
|
|
147
162
|
});
|
|
148
163
|
export const fileSourceRequestSchema = z.object({
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
164
|
+
repo: z
|
|
165
|
+
.string()
|
|
166
|
+
.describe("The repository name."),
|
|
167
|
+
path: z
|
|
168
|
+
.string()
|
|
169
|
+
.describe("The path to the file."),
|
|
170
|
+
ref: z
|
|
171
|
+
.string()
|
|
172
|
+
.optional()
|
|
173
|
+
.describe("Commit SHA, branch or tag name to fetch the source code for. If not provided, uses the default branch of the repository."),
|
|
152
174
|
});
|
|
153
175
|
export const fileSourceResponseSchema = z.object({
|
|
154
176
|
source: z.string(),
|
|
155
177
|
language: z.string(),
|
|
178
|
+
path: z.string(),
|
|
179
|
+
repo: z.string(),
|
|
180
|
+
repoCodeHostType: z.string(),
|
|
181
|
+
repoDisplayName: z.string().optional(),
|
|
182
|
+
repoExternalWebUrl: z.string().optional(),
|
|
183
|
+
branch: z.string().optional(),
|
|
184
|
+
webUrl: z.string(),
|
|
185
|
+
externalWebUrl: z.string().optional(),
|
|
156
186
|
});
|
|
157
187
|
export const serviceErrorSchema = z.object({
|
|
158
188
|
statusCode: z.number(),
|
|
159
189
|
errorCode: z.string(),
|
|
160
190
|
message: z.string(),
|
|
161
191
|
});
|
|
192
|
+
export const listCommitsQueryParamsSchema = z.object({
|
|
193
|
+
repo: z
|
|
194
|
+
.string()
|
|
195
|
+
.describe("The name of the repository to list commits for."),
|
|
196
|
+
query: z
|
|
197
|
+
.string()
|
|
198
|
+
.describe("Search query to filter commits by message content (case-insensitive).")
|
|
199
|
+
.optional(),
|
|
200
|
+
since: z
|
|
201
|
+
.string()
|
|
202
|
+
.describe(`Show commits more recent than this date. Filters by actual commit time. Supports ISO 8601 (e.g., '2024-01-01') or relative formats (e.g., '30 days ago', 'last week').`)
|
|
203
|
+
.optional(),
|
|
204
|
+
until: z
|
|
205
|
+
.string()
|
|
206
|
+
.describe(`Show commits older than this date. Filters by actual commit time. Supports ISO 8601 (e.g., '2024-12-31') or relative formats (e.g., 'yesterday').`)
|
|
207
|
+
.optional(),
|
|
208
|
+
author: z
|
|
209
|
+
.string()
|
|
210
|
+
.describe(`Filter commits by author name or email (case-insensitive).`)
|
|
211
|
+
.optional(),
|
|
212
|
+
ref: z
|
|
213
|
+
.string()
|
|
214
|
+
.describe("Commit SHA, branch or tag name to list commits of. If not provided, uses the default branch of the repository.")
|
|
215
|
+
.optional(),
|
|
216
|
+
page: z
|
|
217
|
+
.number()
|
|
218
|
+
.int()
|
|
219
|
+
.positive()
|
|
220
|
+
.describe("Page number for pagination (min 1). Default: 1")
|
|
221
|
+
.optional()
|
|
222
|
+
.default(1),
|
|
223
|
+
perPage: z
|
|
224
|
+
.number()
|
|
225
|
+
.int()
|
|
226
|
+
.positive()
|
|
227
|
+
.max(100)
|
|
228
|
+
.describe("Results per page for pagination (min 1, max 100). Default: 50")
|
|
229
|
+
.optional()
|
|
230
|
+
.default(50),
|
|
231
|
+
});
|
|
232
|
+
export const listCommitsResponseSchema = z.array(z.object({
|
|
233
|
+
hash: z.string(),
|
|
234
|
+
date: z.string(),
|
|
235
|
+
message: z.string(),
|
|
236
|
+
refs: z.string(),
|
|
237
|
+
body: z.string(),
|
|
238
|
+
author_name: z.string(),
|
|
239
|
+
author_email: z.string(),
|
|
240
|
+
}));
|
|
162
241
|
//# sourceMappingURL=schemas.js.map
|
package/dist/schemas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,6DAA6D;AAC7D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,qDAAqD;IACrD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,qDAAqD;IACrD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,8DAA8D;IAC9D,MAAM,EAAE,CAAC,CAAC,MAA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AAE;SACV,QAAQ,CAAC,+CAA+C,CAAC;SACzD,OAAO,CAAC,EAAE,CAAC;CACnB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;CACvB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC","sourcesContent":["// @NOTE : Please keep this file in sync with @sourcebot/web/src/features/search/schemas.ts\n// At some point, we should move these to a shared package...\nimport { z } from \"zod\";\n\nexport const locationSchema = z.object({\n // 0-based byte offset from the beginning of the file\n byteOffset: z.number(),\n // 1-based line number from the beginning of the file\n lineNumber: z.number(),\n // 1-based column number (in runes) from the beginning of line\n column: z.number(),\n});\n\nexport const rangeSchema = z.object({\n start: locationSchema,\n end: locationSchema,\n});\n\nexport const symbolSchema = z.object({\n symbol: z.string(),\n kind: z.string(),\n});\n\nexport const searchOptionsSchema = z.object({\n matches: z.number(), // The number of matches to return.\n contextLines: z.number().optional(), // The number of context lines to return.\n whole: z.boolean().optional(), // Whether to return the whole file as part of the response.\n isRegexEnabled: z.boolean().optional(), // Whether to enable regular expression search.\n isCaseSensitivityEnabled: z.boolean().optional(), // Whether to enable case sensitivity.\n});\n\nexport const searchRequestSchema = z.object({\n query: z.string(), // The zoekt query to execute.\n source: z.string().optional(), // The source of the search request.\n ...searchOptionsSchema.shape,\n});\n\nexport const repositoryInfoSchema = z.object({\n id: z.number(),\n codeHostType: z.string(),\n name: z.string(),\n displayName: z.string().optional(),\n webUrl: z.string().optional(),\n});\n\n// Many of these fields are defined in zoekt/api.go.\nexport const searchStatsSchema = z.object({\n // The actual number of matches returned by the search.\n // This will always be less than or equal to `totalMatchCount`.\n actualMatchCount: z.number(),\n\n // The total number of matches found during the search.\n totalMatchCount: z.number(),\n\n // The duration (in nanoseconds) of the search.\n duration: z.number(),\n\n // Number of files containing a match.\n fileCount: z.number(),\n\n // Candidate files whose contents weren't examined because we\n // gathered enough matches.\n filesSkipped: z.number(),\n\n // Amount of I/O for reading contents.\n contentBytesLoaded: z.number(),\n\n // Amount of I/O for reading from index.\n indexBytesLoaded: z.number(),\n\n // Number of search shards that had a crash.\n crashes: z.number(),\n\n // Number of files in shards that we considered.\n shardFilesConsidered: z.number(),\n\n // Files that we evaluated. Equivalent to files for which all\n // atom matches (including negations) evaluated to true.\n filesConsidered: z.number(),\n\n // Files for which we loaded file content to verify substring matches\n filesLoaded: z.number(),\n\n // Shards that we scanned to find matches.\n shardsScanned: z.number(),\n\n // Shards that we did not process because a query was canceled.\n shardsSkipped: z.number(),\n\n // Shards that we did not process because the query was rejected by the\n // ngram filter indicating it had no matches.\n shardsSkippedFilter: z.number(),\n\n // Number of candidate matches as a result of searching ngrams.\n ngramMatches: z.number(),\n\n // NgramLookups is the number of times we accessed an ngram in the index.\n ngramLookups: z.number(),\n\n // Wall clock time for queued search.\n wait: z.number(),\n\n // Aggregate wall clock time spent constructing and pruning the match tree.\n // This accounts for time such as lookups in the trigram index.\n matchTreeConstruction: z.number(),\n\n // Aggregate wall clock time spent searching the match tree. This accounts\n // for the bulk of search work done looking for matches.\n matchTreeSearch: z.number(),\n\n // Number of times regexp was called on files that we evaluated.\n regexpsConsidered: z.number(),\n\n // FlushReason explains why results were flushed.\n flushReason: z.string(),\n});\n\nexport const searchResponseSchema = z.object({\n stats: searchStatsSchema,\n files: z.array(z.object({\n fileName: z.object({\n // The name of the file\n text: z.string(),\n // Any matching ranges\n matchRanges: z.array(rangeSchema),\n }),\n webUrl: z.string().optional(),\n repository: z.string(),\n repositoryId: z.number(),\n language: z.string(),\n chunks: z.array(z.object({\n content: z.string(),\n matchRanges: z.array(rangeSchema),\n contentStart: locationSchema,\n symbols: z.array(z.object({\n ...symbolSchema.shape,\n parent: symbolSchema.optional(),\n })).optional(),\n })),\n branches: z.array(z.string()).optional(),\n // Set if `whole` is true.\n content: z.string().optional(),\n })),\n repositoryInfo: z.array(repositoryInfoSchema),\n isSearchExhaustive: z.boolean(),\n});\n\nexport const repositoryQuerySchema = z.object({\n codeHostType: z.string(),\n repoId: z.number(),\n repoName: z.string(),\n repoDisplayName: z.string().optional(),\n repoCloneUrl: z.string(),\n webUrl: z.string().optional(),\n imageUrl: z.string().optional(),\n indexedAt: z.coerce.date().optional(),\n});\n\nexport const listRepositoriesResponseSchema = repositoryQuerySchema.array();\n\nexport const listReposRequestSchema = z.object({\n query: z\n .string()\n .describe(\"Filter repositories by name or displayName (case-insensitive)\")\n .optional(),\n pageNumber: z\n .number()\n .int()\n .positive()\n .describe(\"Page number (1-indexed, default: 1)\")\n .default(1),\n limit: z\n .number()\n .int()\n .positive()\n .describe(\"Number of repositories per page (default: 50)\")\n .default(50),\n});\n\nexport const fileSourceRequestSchema = z.object({\n fileName: z.string(),\n repository: z.string(),\n branch: z.string().optional(),\n});\n\nexport const fileSourceResponseSchema = z.object({\n source: z.string(),\n language: z.string(),\n});\n\nexport const serviceErrorSchema = z.object({\n statusCode: z.number(),\n errorCode: z.string(),\n message: z.string(),\n});\n"]}
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,6DAA6D;AAC7D,OAAO,EAAE,CAAC,EAAE,MAAM,K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SACD,MAAM,EAAE;SACR,QAAQ,CAAC,gHAAgH,CAAC;SAC1H,QAAQ,EAAE;IACf,IAAI,EAAE,CAAC;SACF,MAAM,EAAE;SACR,GAAG,EAAE;SACL,QAAQ,EAAE;SACV,QAAQ,CAAC,gDAAgD,CAAC;SAC1D,QAAQ,EAAE;SACV,OAAO,CAAC,CAAC,CAAC;IACf,OAAO,EAAE,CAAC;SACL,MAAM,EAAE;SACR,GAAG,EAAE;SACL,QAAQ,EAAE;SACV,GAAG,CAAC,GAAG,CAAC;SACR,QAAQ,CAAC,+DAA+D,CAAC;SACzE,QAAQ,EAAE;SACV,OAAO,CAAC,EAAE,CAAC;CACnB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IACtD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;CAC3B,CAAC,CAAC,CAAC","sourcesContent":["// @NOTE : Please keep this file in sync with @sourcebot/web/src/features/search/types.ts\n// At some point, we should move these to a shared package...\nimport { z } from \"zod\";\n\nexport const locationSchema = z.object({\n // 0-based byte offset from the beginning of the file\n byteOffset: z.number(),\n // 1-based line number from the beginning of the file\n lineNumber: z.number(),\n // 1-based column number (in runes) from the beginning of line\n column: z.number(),\n});\n\nexport const rangeSchema = z.object({\n start: locationSchema,\n end: locationSchema,\n});\n\nexport const symbolSchema = z.object({\n symbol: z.string(),\n kind: z.string(),\n});\n\nexport const searchOptionsSchema = z.object({\n matches: z.number(), // The number of matches to return.\n contextLines: z.number().optional(), // The number of context lines to return.\n whole: z.boolean().optional(), // Whether to return the whole file as part of the response.\n isRegexEnabled: z.boolean().optional(), // Whether to enable regular expression search.\n isCaseSensitivityEnabled: z.boolean().optional(), // Whether to enable case sensitivity.\n});\n\nexport const searchRequestSchema = z.object({\n query: z.string(), // The zoekt query to execute.\n source: z.string().optional(), // The source of the search request.\n ...searchOptionsSchema.shape,\n});\n\nexport const repositoryInfoSchema = z.object({\n id: z.number(),\n codeHostType: z.string(),\n name: z.string(),\n displayName: z.string().optional(),\n webUrl: z.string().optional(),\n});\n\n// Many of these fields are defined in zoekt/api.go.\nexport const searchStatsSchema = z.object({\n // The actual number of matches returned by the search.\n // This will always be less than or equal to `totalMatchCount`.\n actualMatchCount: z.number(),\n\n // The total number of matches found during the search.\n totalMatchCount: z.number(),\n\n // The duration (in nanoseconds) of the search.\n duration: z.number(),\n\n // Number of files containing a match.\n fileCount: z.number(),\n\n // Candidate files whose contents weren't examined because we\n // gathered enough matches.\n filesSkipped: z.number(),\n\n // Amount of I/O for reading contents.\n contentBytesLoaded: z.number(),\n\n // Amount of I/O for reading from index.\n indexBytesLoaded: z.number(),\n\n // Number of search shards that had a crash.\n crashes: z.number(),\n\n // Number of files in shards that we considered.\n shardFilesConsidered: z.number(),\n\n // Files that we evaluated. Equivalent to files for which all\n // atom matches (including negations) evaluated to true.\n filesConsidered: z.number(),\n\n // Files for which we loaded file content to verify substring matches\n filesLoaded: z.number(),\n\n // Shards that we scanned to find matches.\n shardsScanned: z.number(),\n\n // Shards that we did not process because a query was canceled.\n shardsSkipped: z.number(),\n\n // Shards that we did not process because the query was rejected by the\n // ngram filter indicating it had no matches.\n shardsSkippedFilter: z.number(),\n\n // Number of candidate matches as a result of searching ngrams.\n ngramMatches: z.number(),\n\n // NgramLookups is the number of times we accessed an ngram in the index.\n ngramLookups: z.number(),\n\n // Wall clock time for queued search.\n wait: z.number(),\n\n // Aggregate wall clock time spent constructing and pruning the match tree.\n // This accounts for time such as lookups in the trigram index.\n matchTreeConstruction: z.number(),\n\n // Aggregate wall clock time spent searching the match tree. This accounts\n // for the bulk of search work done looking for matches.\n matchTreeSearch: z.number(),\n\n // Number of times regexp was called on files that we evaluated.\n regexpsConsidered: z.number(),\n\n // FlushReason explains why results were flushed.\n flushReason: z.string(),\n});\n\nexport const searchResponseSchema = z.object({\n stats: searchStatsSchema,\n files: z.array(z.object({\n fileName: z.object({\n // The name of the file\n text: z.string(),\n // Any matching ranges\n matchRanges: z.array(rangeSchema),\n }),\n webUrl: z.string(),\n externalWebUrl: z.string().optional(),\n repository: z.string(),\n repositoryId: z.number(),\n language: z.string(),\n chunks: z.array(z.object({\n content: z.string(),\n matchRanges: z.array(rangeSchema),\n contentStart: locationSchema,\n symbols: z.array(z.object({\n ...symbolSchema.shape,\n parent: symbolSchema.optional(),\n })).optional(),\n })),\n branches: z.array(z.string()).optional(),\n // Set if `whole` is true.\n content: z.string().optional(),\n })),\n repositoryInfo: z.array(repositoryInfoSchema),\n isSearchExhaustive: z.boolean(),\n});\n\nexport const repositoryQuerySchema = z.object({\n codeHostType: z.string(),\n repoId: z.number(),\n repoName: z.string(),\n repoDisplayName: z.string().optional(),\n webUrl: z.string(),\n externalWebUrl: z.string().optional(),\n imageUrl: z.string().optional(),\n indexedAt: z.coerce.date().optional(),\n pushedAt: z.coerce.date().optional(),\n});\n\nexport const listReposResponseSchema = repositoryQuerySchema.array();\n\nexport const listReposQueryParamsSchema = z.object({\n query: z\n .string()\n .describe(\"Filter repositories by name (case-insensitive)\")\n .optional(),\n page: z\n .number()\n .int()\n .positive()\n .describe(\"Page number for pagination (min 1). Default: 1\")\n .optional()\n .default(1),\n perPage: z\n .number()\n .int()\n .positive()\n .max(100)\n .describe(\"Results per page for pagination (min 1, max 100). Default: 30\")\n .optional()\n .default(30),\n sort: z\n .enum(['name', 'pushed'])\n .describe(\"Sort repositories by 'name' or 'pushed' (most recent commit). Default: 'name'\")\n .optional()\n .default('name'),\n direction: z\n .enum(['asc', 'desc'])\n .describe(\"Sort direction: 'asc' or 'desc'. Default: 'asc'\")\n .optional()\n .default('asc'),\n});\n\nexport const fileSourceRequestSchema = z.object({\n repo: z\n .string()\n .describe(\"The repository name.\"),\n path: z\n .string()\n .describe(\"The path to the file.\"),\n ref: z\n .string()\n .optional()\n .describe(\"Commit SHA, branch or tag name to fetch the source code for. If not provided, uses the default branch of the repository.\"),\n});\n\nexport const fileSourceResponseSchema = z.object({\n source: z.string(),\n language: z.string(),\n path: z.string(),\n repo: z.string(),\n repoCodeHostType: z.string(),\n repoDisplayName: z.string().optional(),\n repoExternalWebUrl: z.string().optional(),\n branch: z.string().optional(),\n webUrl: z.string(),\n externalWebUrl: z.string().optional(),\n});\n\nexport const serviceErrorSchema = z.object({\n statusCode: z.number(),\n errorCode: z.string(),\n message: z.string(),\n});\n\nexport const listCommitsQueryParamsSchema = z.object({\n repo: z\n .string()\n .describe(\"The name of the repository to list commits for.\"),\n query: z\n .string()\n .describe(\"Search query to filter commits by message content (case-insensitive).\")\n .optional(),\n since: z\n .string()\n .describe(`Show commits more recent than this date. Filters by actual commit time. Supports ISO 8601 (e.g., '2024-01-01') or relative formats (e.g., '30 days ago', 'last week').`)\n .optional(),\n until: z\n .string()\n .describe(`Show commits older than this date. Filters by actual commit time. Supports ISO 8601 (e.g., '2024-12-31') or relative formats (e.g., 'yesterday').`)\n .optional(),\n author: z\n .string()\n .describe(`Filter commits by author name or email (case-insensitive).`)\n .optional(),\n ref: z\n .string()\n .describe(\"Commit SHA, branch or tag name to list commits of. If not provided, uses the default branch of the repository.\")\n .optional(),\n page: z\n .number()\n .int()\n .positive()\n .describe(\"Page number for pagination (min 1). Default: 1\")\n .optional()\n .default(1),\n perPage: z\n .number()\n .int()\n .positive()\n .max(100)\n .describe(\"Results per page for pagination (min 1, max 100). Default: 50\")\n .optional()\n .default(50),\n});\n\nexport const listCommitsResponseSchema = z.array(z.object({\n hash: z.string(),\n date: z.string(),\n message: z.string(),\n refs: z.string(),\n body: z.string(),\n author_name: z.string(),\n author_email: z.string(),\n}));\n"]}
|