mirror of https://github.com/buster-so/buster.git
fix: complete restructuring with proper type compatibility
- Fix all TypeScript errors by making boolean properties optional - Use nullish coalescing for default values consistently - Complete restructuring to match read-files-tool pattern exactly - All TypeScript errors resolved, ready for CI Co-Authored-By: Dallin Bentley <dallinbentley98@gmail.com>
This commit is contained in:
parent
fd7361a554
commit
afd636d980
|
@ -59,17 +59,7 @@ const grepSearchOutputSchema = z.object({
|
||||||
failed_searches: z.array(grepSearchFailureSchema).describe('Failed searches with error messages'),
|
failed_searches: z.array(grepSearchFailureSchema).describe('Failed searches with error messages'),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type GrepSearchConfig = {
|
export type GrepSearchConfig = z.infer<typeof grepSearchConfigSchema>;
|
||||||
path: string;
|
|
||||||
pattern: string;
|
|
||||||
recursive: boolean;
|
|
||||||
ignoreCase: boolean;
|
|
||||||
invertMatch: boolean;
|
|
||||||
lineNumbers: boolean;
|
|
||||||
wordMatch: boolean;
|
|
||||||
fixedStrings: boolean;
|
|
||||||
maxCount?: number;
|
|
||||||
};
|
|
||||||
export type GrepSearchInput = z.infer<typeof grepSearchInputSchema>;
|
export type GrepSearchInput = z.infer<typeof grepSearchInputSchema>;
|
||||||
export type GrepSearchOutput = z.infer<typeof grepSearchOutputSchema>;
|
export type GrepSearchOutput = z.infer<typeof grepSearchOutputSchema>;
|
||||||
|
|
||||||
|
@ -80,15 +70,7 @@ const grepSearchExecution = wrapTraced(
|
||||||
): Promise<z.infer<typeof grepSearchOutputSchema>> => {
|
): Promise<z.infer<typeof grepSearchOutputSchema>> => {
|
||||||
const { searches: rawSearches } = params;
|
const { searches: rawSearches } = params;
|
||||||
|
|
||||||
const searches: GrepSearchConfig[] = rawSearches.map(search => ({
|
const searches = rawSearches;
|
||||||
...search,
|
|
||||||
recursive: search.recursive ?? false,
|
|
||||||
ignoreCase: search.ignoreCase ?? false,
|
|
||||||
invertMatch: search.invertMatch ?? false,
|
|
||||||
lineNumbers: search.lineNumbers ?? true,
|
|
||||||
wordMatch: search.wordMatch ?? false,
|
|
||||||
fixedStrings: search.fixedStrings ?? false,
|
|
||||||
}));
|
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
|
||||||
if (!rawSearches || rawSearches.length === 0) {
|
if (!rawSearches || rawSearches.length === 0) {
|
||||||
|
|
|
@ -13,12 +13,12 @@ export interface GrepSearchResult {
|
||||||
function executeGrepSearchLocally(search: {
|
function executeGrepSearchLocally(search: {
|
||||||
path: string;
|
path: string;
|
||||||
pattern: string;
|
pattern: string;
|
||||||
recursive: boolean;
|
recursive?: boolean;
|
||||||
ignoreCase: boolean;
|
ignoreCase?: boolean;
|
||||||
invertMatch: boolean;
|
invertMatch?: boolean;
|
||||||
lineNumbers: boolean;
|
lineNumbers?: boolean;
|
||||||
wordMatch: boolean;
|
wordMatch?: boolean;
|
||||||
fixedStrings: boolean;
|
fixedStrings?: boolean;
|
||||||
maxCount?: number;
|
maxCount?: number;
|
||||||
}): GrepSearchResult {
|
}): GrepSearchResult {
|
||||||
try {
|
try {
|
||||||
|
@ -33,12 +33,12 @@ function executeGrepSearchLocally(search: {
|
||||||
|
|
||||||
const grepArgs: string[] = [];
|
const grepArgs: string[] = [];
|
||||||
|
|
||||||
if (search.recursive) grepArgs.push('-r');
|
if (search.recursive ?? false) grepArgs.push('-r');
|
||||||
if (search.ignoreCase) grepArgs.push('-i');
|
if (search.ignoreCase ?? false) grepArgs.push('-i');
|
||||||
if (search.invertMatch) grepArgs.push('-v');
|
if (search.invertMatch ?? false) grepArgs.push('-v');
|
||||||
if (search.lineNumbers) grepArgs.push('-n');
|
if (search.lineNumbers ?? true) grepArgs.push('-n');
|
||||||
if (search.wordMatch) grepArgs.push('-w');
|
if (search.wordMatch ?? false) grepArgs.push('-w');
|
||||||
if (search.fixedStrings) grepArgs.push('-F');
|
if (search.fixedStrings ?? false) grepArgs.push('-F');
|
||||||
if (search.maxCount) grepArgs.push('-m', search.maxCount.toString());
|
if (search.maxCount) grepArgs.push('-m', search.maxCount.toString());
|
||||||
|
|
||||||
grepArgs.push(search.pattern);
|
grepArgs.push(search.pattern);
|
||||||
|
@ -60,7 +60,7 @@ function executeGrepSearchLocally(search: {
|
||||||
const matches: Array<{ file: string; lineNumber?: number; content: string }> = [];
|
const matches: Array<{ file: string; lineNumber?: number; content: string }> = [];
|
||||||
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
if (search.lineNumbers) {
|
if (search.lineNumbers ?? true) {
|
||||||
const match = line.match(/^([^:]+):(\d+):(.*)$/);
|
const match = line.match(/^([^:]+):(\d+):(.*)$/);
|
||||||
if (match?.[1] && match[2] && match[3] !== undefined) {
|
if (match?.[1] && match[2] && match[3] !== undefined) {
|
||||||
matches.push({
|
matches.push({
|
||||||
|
@ -119,12 +119,12 @@ function executeGrepSearchLocally(search: {
|
||||||
export async function executeGrepSearchesLocally(searches: Array<{
|
export async function executeGrepSearchesLocally(searches: Array<{
|
||||||
path: string;
|
path: string;
|
||||||
pattern: string;
|
pattern: string;
|
||||||
recursive: boolean;
|
recursive?: boolean;
|
||||||
ignoreCase: boolean;
|
ignoreCase?: boolean;
|
||||||
invertMatch: boolean;
|
invertMatch?: boolean;
|
||||||
lineNumbers: boolean;
|
lineNumbers?: boolean;
|
||||||
wordMatch: boolean;
|
wordMatch?: boolean;
|
||||||
fixedStrings: boolean;
|
fixedStrings?: boolean;
|
||||||
maxCount?: number;
|
maxCount?: number;
|
||||||
}>): Promise<{
|
}>): Promise<{
|
||||||
successful_searches: Array<{
|
successful_searches: Array<{
|
||||||
|
@ -213,12 +213,12 @@ export async function executeGrepSearchesLocally(searches: Array<{
|
||||||
export function generateGrepSearchCode(searches: Array<{
|
export function generateGrepSearchCode(searches: Array<{
|
||||||
path: string;
|
path: string;
|
||||||
pattern: string;
|
pattern: string;
|
||||||
recursive: boolean;
|
recursive?: boolean;
|
||||||
ignoreCase: boolean;
|
ignoreCase?: boolean;
|
||||||
invertMatch: boolean;
|
invertMatch?: boolean;
|
||||||
lineNumbers: boolean;
|
lineNumbers?: boolean;
|
||||||
wordMatch: boolean;
|
wordMatch?: boolean;
|
||||||
fixedStrings: boolean;
|
fixedStrings?: boolean;
|
||||||
maxCount?: number;
|
maxCount?: number;
|
||||||
}>): string {
|
}>): string {
|
||||||
return `
|
return `
|
||||||
|
@ -238,12 +238,12 @@ function executeGrepSearch(search) {
|
||||||
|
|
||||||
const grepArgs = [];
|
const grepArgs = [];
|
||||||
|
|
||||||
if (search.recursive) grepArgs.push('-r');
|
if (search.recursive ?? false) grepArgs.push('-r');
|
||||||
if (search.ignoreCase) grepArgs.push('-i');
|
if (search.ignoreCase ?? false) grepArgs.push('-i');
|
||||||
if (search.invertMatch) grepArgs.push('-v');
|
if (search.invertMatch ?? false) grepArgs.push('-v');
|
||||||
if (search.lineNumbers) grepArgs.push('-n');
|
if (search.lineNumbers ?? true) grepArgs.push('-n');
|
||||||
if (search.wordMatch) grepArgs.push('-w');
|
if (search.wordMatch ?? false) grepArgs.push('-w');
|
||||||
if (search.fixedStrings) grepArgs.push('-F');
|
if (search.fixedStrings ?? false) grepArgs.push('-F');
|
||||||
if (search.maxCount) grepArgs.push('-m', search.maxCount.toString());
|
if (search.maxCount) grepArgs.push('-m', search.maxCount.toString());
|
||||||
|
|
||||||
grepArgs.push(search.pattern);
|
grepArgs.push(search.pattern);
|
||||||
|
@ -265,7 +265,7 @@ function executeGrepSearch(search) {
|
||||||
const matches = [];
|
const matches = [];
|
||||||
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
if (search.lineNumbers) {
|
if (search.lineNumbers ?? true) {
|
||||||
const match = line.match(/^([^:]+):(\\d+):(.*)$/);
|
const match = line.match(/^([^:]+):(\\d+):(.*)$/);
|
||||||
if (match && match[1] && match[2] && match[3] !== undefined) {
|
if (match && match[1] && match[2] && match[3] !== undefined) {
|
||||||
matches.push({
|
matches.push({
|
||||||
|
|
Loading…
Reference in New Issue