@builder.io/dev-tools
Version:
Builder.io Visual CMS Devtools
64 lines (63 loc) • 2.31 kB
TypeScript
import type { CodeGenTools, CommitMode, ContentMessageItemToolResult, FusionConfig, ProjectFile, WorkspaceFolder } from "$/ai-utils";
import type { DevToolsSys } from "../core";
import { type DevServerOrchestrator } from "./launch/dev-server-orchestrator";
import type { CodeGenEventEmitter } from "./codegen";
export interface LLMToolCalls {
name: CodeGenTools;
input: Record<string, any>;
id: string;
}
export interface ToolResolution {
toolResult: string;
isError: boolean;
title?: string;
}
export interface FusionContext {
devServerOrchestrator?: DevServerOrchestrator;
checkCommand?: string;
allowedCommands: RegExp[];
commitMode: CommitMode;
git: boolean;
gitRemote?: string;
gitAutoInit?: boolean;
gitFeatureBranch?: string;
projectId?: string;
}
export interface ToolContext extends Partial<FusionContext> {
sys: DevToolsSys;
files: ProjectFile[];
emitter: CodeGenEventEmitter;
signal: AbortSignal | undefined;
workingDirectory: string;
bashWorkingDirectory: string;
resolveWorkspacePath: (path: string, forceWorkspace: boolean) => {
resolvedPath: string;
workspaceFolder?: WorkspaceFolder;
};
workspaceFolders: Array<{
path: string;
name?: string;
}>;
patchFusionConfig: (patch: Partial<FusionConfig>) => void;
readFile: (filePath: string) => Promise<string | null>;
writeFile: (filePath: string, content: string | Uint8Array) => Promise<boolean>;
deleteFile: (filePath: string) => Promise<boolean>;
fileExists: (filePath: string) => Promise<boolean>;
listDir: (dirPath: string) => Promise<string[]>;
stat: (filePath: string) => Promise<{
isDirectory: () => boolean;
isFile: () => boolean;
} | null>;
}
export declare function resolveToolCalls(toolContext: ToolContext, toolCalls: LLMToolCalls[]): Promise<ContentMessageItemToolResult[]>;
interface RipgrepMatch {
path: string;
lineNumber: number;
lineContent: string;
}
interface RipgrepResult {
matches: RipgrepMatch[];
}
export declare function runRipgrep(sys: DevToolsSys, bashWorkingDirectory: string, pattern: string, includeGlob?: string, excludeGlob?: string): Promise<RipgrepResult>;
export declare function newAbortError(): Error;
export {};