fixing imports

This commit is contained in:
2026-02-04 21:32:30 -05:00
parent 74b0a0dbab
commit db79856b08
166 changed files with 1986 additions and 982 deletions

View File

@@ -12,8 +12,17 @@ import {
PATCH_MESSAGES,
PATCH_TITLES,
} from "@constants/apply-patch";
import { parsePatch, validatePatch, getTargetPath, reversePatch } from "@tools/apply-patch/parser";
import { findHunkPosition, isHunkApplied, previewHunkApplication } from "@tools/apply-patch/matcher";
import {
parsePatch,
validatePatch,
getTargetPath,
reversePatch,
} from "@tools/apply-patch/parser";
import {
findHunkPosition,
isHunkApplied,
previewHunkApplication,
} from "@tools/apply-patch/matcher";
import type { ApplyPatchParams } from "@tools/apply-patch/params";
import type {
FilePatchResult,
@@ -79,14 +88,10 @@ export const executeApplyPatch = async (
: join(ctx.workingDir, targetPath);
// Apply the file patch
const result = await applyFilePatch(
filePatch,
absolutePath,
{
fuzz: params.fuzz ?? PATCH_DEFAULTS.FUZZ,
dryRun: params.dryRun ?? false,
},
);
const result = await applyFilePatch(filePatch, absolutePath, {
fuzz: params.fuzz ?? PATCH_DEFAULTS.FUZZ,
dryRun: params.dryRun ?? false,
});
results.push(result);
@@ -210,7 +215,9 @@ const applyFilePatch = async (
}
// Find position with fuzzy matching
const position = findHunkPosition(currentContent, hunk, { fuzz: options.fuzz });
const position = findHunkPosition(currentContent, hunk, {
fuzz: options.fuzz,
});
if (!position.found) {
hunkResults.push({
@@ -223,7 +230,11 @@ const applyFilePatch = async (
}
// Apply the hunk
const preview = previewHunkApplication(currentContent, hunk, position.lineNumber);
const preview = previewHunkApplication(
currentContent,
hunk,
position.lineNumber,
);
if (!preview.success) {
hunkResults.push({

View File

@@ -9,9 +9,23 @@ import { applyPatchParams } from "@tools/apply-patch/params";
import { executeApplyPatch } from "@tools/apply-patch/execute";
export { applyPatchParams } from "@tools/apply-patch/params";
export { executeApplyPatch, rollbackPatch, getAvailableRollbacks, clearRollbacks } from "@tools/apply-patch/execute";
export { parsePatch, validatePatch, getTargetPath, reversePatch } from "@tools/apply-patch/parser";
export { findHunkPosition, isHunkApplied, previewHunkApplication } from "@tools/apply-patch/matcher";
export {
executeApplyPatch,
rollbackPatch,
getAvailableRollbacks,
clearRollbacks,
} from "@tools/apply-patch/execute";
export {
parsePatch,
validatePatch,
getTargetPath,
reversePatch,
} from "@tools/apply-patch/parser";
export {
findHunkPosition,
isHunkApplied,
previewHunkApplication,
} from "@tools/apply-patch/matcher";
/**
* Tool description

View File

@@ -23,10 +23,7 @@ const DEFAULT_MATCH_OPTIONS: ContextMatchOptions = {
/**
* Normalize line for comparison
*/
const normalizeLine = (
line: string,
options: ContextMatchOptions,
): string => {
const normalizeLine = (line: string, options: ContextMatchOptions): string => {
let normalized = line;
if (options.ignoreWhitespace) {

View File

@@ -9,9 +9,7 @@ import { PATCH_DEFAULTS } from "@constants/apply-patch";
* Zod schema for apply_patch tool parameters
*/
export const applyPatchParams = z.object({
patch: z
.string()
.describe("The unified diff patch content to apply"),
patch: z.string().describe("The unified diff patch content to apply"),
targetFile: z
.string()
@@ -31,7 +29,9 @@ export const applyPatchParams = z.object({
.max(PATCH_DEFAULTS.MAX_FUZZ)
.optional()
.default(PATCH_DEFAULTS.FUZZ)
.describe(`Context line tolerance for fuzzy matching (0-${PATCH_DEFAULTS.MAX_FUZZ})`),
.describe(
`Context line tolerance for fuzzy matching (0-${PATCH_DEFAULTS.MAX_FUZZ})`,
),
reverse: z
.boolean()

View File

@@ -36,7 +36,10 @@ export const parsePatch = (patchContent: string): ParsedPatch => {
// Git diff header
const gitDiffMatch = line.match(PATCH_PATTERNS.GIT_DIFF);
if (gitDiffMatch) {
if (currentFile && (currentFile.hunks.length > 0 || currentFile.isBinary)) {
if (
currentFile &&
(currentFile.hunks.length > 0 || currentFile.isBinary)
) {
files.push(currentFile);
}
currentFile = createEmptyFilePatch(gitDiffMatch[1], gitDiffMatch[2]);
@@ -174,7 +177,10 @@ export const parsePatch = (patchContent: string): ParsedPatch => {
/**
* Create empty file patch structure
*/
const createEmptyFilePatch = (oldPath: string, newPath: string): ParsedFilePatch => ({
const createEmptyFilePatch = (
oldPath: string,
newPath: string,
): ParsedFilePatch => ({
oldPath: cleanPath(oldPath),
newPath: cleanPath(newPath),
hunks: [],

View File

@@ -109,13 +109,10 @@ const executeCommand = (
args: BashParams,
ctx: ToolContext,
): Promise<ToolResult> => {
const {
command,
workdir,
timeout = BASH_DEFAULTS.TIMEOUT,
} = args;
const { command, workdir, timeout = BASH_DEFAULTS.TIMEOUT } = args;
// Provide default description if not specified
const description = args.description ?? `Running: ${command.substring(0, 50)}`;
const description =
args.description ?? `Running: ${command.substring(0, 50)}`;
const cwd = workdir ?? ctx.workingDir;
updateRunningStatus(ctx, description);
@@ -179,7 +176,8 @@ export const executeBash = async (
}
// Provide default description if not specified
const description = args.description ?? `Running: ${command.substring(0, 50)}`;
const description =
args.description ?? `Running: ${command.substring(0, 50)}`;
const allowed = await checkPermission(
command,

View File

@@ -16,8 +16,8 @@ import { todoReadTool } from "@/tools/todo-read";
import { globToolDefinition } from "@/tools/glob/definition";
import { grepToolDefinition } from "@/tools/grep/definition";
import { webSearchTool } from "@/tools/web-search";
import { webFetchTool } from "@/tools/web-fetch";
import { multiEditTool } from "@/tools/multi-edit";
import { webFetchTool } from "@tools/web-fetch/execute";
import { multiEditTool } from "@tools/multi-edit/execute";
import { lspTool } from "@/tools/lsp";
import { applyPatchTool } from "@/tools/apply-patch";
import {

View File

@@ -6,7 +6,10 @@ import fs from "fs/promises";
import path from "path";
import { EDIT_MESSAGES, EDIT_TITLES, EDIT_DESCRIPTION } from "@constants/edit";
import { isFileOpAllowed, promptFilePermission } from "@services/core/permissions";
import {
isFileOpAllowed,
promptFilePermission,
} from "@services/core/permissions";
import { formatDiff } from "@utils/diff/format";
import { generateDiff } from "@utils/diff/generate";
import { editParams } from "@tools/edit/params";

View File

@@ -7,11 +7,17 @@ import { executeGlob } from "@tools/glob/execute";
import type { ToolDefinition, ToolContext, ToolResult } from "@/types/tools";
export const globParams = z.object({
pattern: z.string().describe("The glob pattern to match files against (e.g., '**/*.ts', 'src/**/*.tsx')"),
pattern: z
.string()
.describe(
"The glob pattern to match files against (e.g., '**/*.ts', 'src/**/*.tsx')",
),
path: z
.string()
.optional()
.describe("The directory to search in. Defaults to current working directory."),
.describe(
"The directory to search in. Defaults to current working directory.",
),
});
type GlobParams = z.infer<typeof globParams>;

View File

@@ -13,15 +13,14 @@ export const grepParams = z.object({
path: z
.string()
.optional()
.describe("File or directory to search in. Defaults to current working directory."),
.describe(
"File or directory to search in. Defaults to current working directory.",
),
glob: z
.string()
.optional()
.describe("Glob pattern to filter files (e.g., '*.ts', '**/*.tsx')"),
case_insensitive: z
.boolean()
.optional()
.describe("Case insensitive search"),
case_insensitive: z.boolean().optional().describe("Case insensitive search"),
context_lines: z
.number()
.optional()

View File

@@ -9,8 +9,8 @@ import { todoReadTool } from "@tools/todo-read";
import { globToolDefinition } from "@tools/glob/definition";
import { grepToolDefinition } from "@tools/grep/definition";
import { webSearchTool } from "@tools/web-search";
import { webFetchTool } from "@tools/web-fetch";
import { multiEditTool } from "@tools/multi-edit";
import { webFetchTool } from "@tools/web-fetch/execute";
import { multiEditTool } from "@tools/multi-edit/execute";
import { lspTool } from "@tools/lsp";
import { applyPatchTool } from "@tools/apply-patch";
import {

View File

@@ -183,10 +183,16 @@ Examples:
// Open file in LSP
await lspService.openFile(file);
const operationHandlers: Record<string, () => Promise<{ title: string; output: string }>> = {
const operationHandlers: Record<
string,
() => Promise<{ title: string; output: string }>
> = {
hover: async () => {
if (!position) {
return { title: "Error", output: "Position required for hover operation" };
return {
title: "Error",
output: "Position required for hover operation",
};
}
const hover = await lspService.getHover(file, position);
return { title: "Hover Info", output: formatHover(hover) };
@@ -194,7 +200,10 @@ Examples:
definition: async () => {
if (!position) {
return { title: "Error", output: "Position required for definition operation" };
return {
title: "Error",
output: "Position required for definition operation",
};
}
const definition = await lspService.getDefinition(file, position);
return { title: "Definition", output: formatLocations(definition) };
@@ -202,7 +211,10 @@ Examples:
references: async () => {
if (!position) {
return { title: "Error", output: "Position required for references operation" };
return {
title: "Error",
output: "Position required for references operation",
};
}
const references = await lspService.getReferences(file, position);
return {

View File

@@ -13,7 +13,10 @@ import {
MULTI_EDIT_TITLES,
MULTI_EDIT_DESCRIPTION,
} from "@constants/multi-edit";
import { isFileOpAllowed, promptFilePermission } from "@services/core/permissions";
import {
isFileOpAllowed,
promptFilePermission,
} from "@services/core/permissions";
import { formatDiff } from "@utils/diff/format";
import { generateDiff } from "@utils/diff/generate";
import { multiEditParams } from "@tools/multi-edit/params";

View File

@@ -11,7 +11,10 @@ import {
READ_TITLES,
READ_DESCRIPTION,
} from "@constants/read";
import { isFileOpAllowed, promptFilePermission } from "@services/core/permissions";
import {
isFileOpAllowed,
promptFilePermission,
} from "@services/core/permissions";
import { readParams } from "@tools/read/params";
import { processLines } from "@tools/read/format";
import type {

View File

@@ -318,10 +318,7 @@ export const executeWebFetch = async (
// Check content length
if (content.length > WEB_FETCH_DEFAULTS.MAX_CONTENT_LENGTH) {
content = truncateContent(
content,
WEB_FETCH_DEFAULTS.MAX_CONTENT_LENGTH,
);
content = truncateContent(content, WEB_FETCH_DEFAULTS.MAX_CONTENT_LENGTH);
}
// Process content based on type

View File

@@ -9,7 +9,9 @@ export const webFetchParams = z.object({
prompt: z
.string()
.optional()
.describe("Optional prompt to extract specific information from the content"),
.describe(
"Optional prompt to extract specific information from the content",
),
timeout: z
.number()
.optional()

View File

@@ -2,6 +2,9 @@
* Web Search tool for searching the web
*/
export { webSearchParams, type WebSearchParamsSchema } from "@tools/web-search/params";
export {
webSearchParams,
type WebSearchParamsSchema,
} from "@tools/web-search/params";
export { executeWebSearch, webSearchTool } from "@tools/web-search/execute";
export type { SearchResult } from "@tools/web-search/execute";

View File

@@ -38,10 +38,7 @@ const createSuccessResult = (
query: string,
): ToolResult => {
const formattedResults = results
.map(
(r, i) =>
`${i + 1}. **${r.title}**\n ${r.url}\n ${r.snippet}`,
)
.map((r, i) => `${i + 1}. **${r.title}**\n ${r.url}\n ${r.snippet}`)
.join("\n\n");
return {
@@ -93,7 +90,10 @@ const parseRssResults = (rss: string, maxResults: number): SearchResult[] => {
const itemPattern = /<item>([\s\S]*?)<\/item>/gi;
let match: RegExpExecArray | null;
while ((match = itemPattern.exec(rss)) !== null && results.length < maxResults) {
while (
(match = itemPattern.exec(rss)) !== null &&
results.length < maxResults
) {
const itemContent = match[1];
const titleMatch = itemContent.match(/<title>([^<]+)<\/title>/);

View File

@@ -10,7 +10,10 @@ import {
WRITE_TITLES,
WRITE_DESCRIPTION,
} from "@constants/write";
import { isFileOpAllowed, promptFilePermission } from "@services/core/permissions";
import {
isFileOpAllowed,
promptFilePermission,
} from "@services/core/permissions";
import { formatDiff } from "@utils/diff/format";
import { generateDiff } from "@utils/diff/generate";
import { writeParams } from "@tools/write/params";