chore: rename smart-edit to edit (#15923)

This commit is contained in:
Abhi
2026-01-05 15:25:54 -05:00
committed by GitHub
parent 3c92666ec2
commit b13c6b57ae
14 changed files with 79 additions and 87 deletions

View File

@@ -7,7 +7,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { SmartEditTool } from './smart-edit.js';
import { EditTool } from './edit.js';
import { WriteFileTool } from './write-file.js';
import { WebFetchTool } from './web-fetch.js';
import { ToolConfirmationOutcome } from './tools.js';
@@ -21,8 +21,8 @@ import os from 'node:os';
// Mock telemetry loggers to avoid failures
vi.mock('../telemetry/loggers.js', () => ({
logSmartEditStrategy: vi.fn(),
logSmartEditCorrectionEvent: vi.fn(),
logEditStrategy: vi.fn(),
logEditCorrectionEvent: vi.fn(),
logFileOperation: vi.fn(),
}));
@@ -81,9 +81,8 @@ describe('Tool Confirmation Policy Updates', () => {
const tools = [
{
name: 'SmartEditTool',
create: (config: Config, bus: MessageBus) =>
new SmartEditTool(config, bus),
name: 'EditTool',
create: (config: Config, bus: MessageBus) => new EditTool(config, bus),
params: {
file_path: 'test.txt',
instruction: 'change content',

View File

@@ -43,11 +43,11 @@ import {
type Mock,
} from 'vitest';
import {
SmartEditTool,
EditTool,
type EditToolParams,
applyReplacement,
calculateReplacement,
} from './smart-edit.js';
} from './edit.js';
import { type FileDiff, ToolConfirmationOutcome } from './tools.js';
import { ToolErrorType } from './tool-error.js';
import {
@@ -64,8 +64,8 @@ import { createMockWorkspaceContext } from '../test-utils/mockWorkspaceContext.j
import { StandardFileSystemService } from '../services/fileSystemService.js';
import type { BaseLlmClient } from '../core/baseLlmClient.js';
describe('SmartEditTool', () => {
let tool: SmartEditTool;
describe('EditTool', () => {
let tool: EditTool;
let tempDir: string;
let rootDir: string;
let mockConfig: Config;
@@ -75,7 +75,7 @@ describe('SmartEditTool', () => {
beforeEach(() => {
vi.restoreAllMocks();
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'smart-edit-tool-test-'));
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'edit-tool-test-'));
rootDir = path.join(tempDir, 'root');
fs.mkdirSync(rootDir);
@@ -172,7 +172,7 @@ describe('SmartEditTool', () => {
const bus = createMockMessageBus();
getMockMessageBusInstance(bus).defaultToolDecision = 'ask_user';
tool = new SmartEditTool(mockConfig, bus);
tool = new EditTool(mockConfig, bus);
});
afterEach(() => {
@@ -393,9 +393,7 @@ describe('SmartEditTool', () => {
const invocation = tool.build(params);
const abortController = new AbortController();
const abortError = new Error(
'Abort requested during smart edit execution',
);
const abortError = new Error('Abort requested during edit execution');
const calculateSpy = vi
.spyOn(invocation as any, 'calculateEdit')
@@ -755,9 +753,7 @@ describe('SmartEditTool', () => {
const invocation = tool.build(params);
const abortController = new AbortController();
const abortError = new Error(
'Abort requested during smart edit confirmation',
);
const abortError = new Error('Abort requested during edit confirmation');
const calculateSpy = vi
.spyOn(invocation as any, 'calculateEdit')

View File

@@ -35,10 +35,10 @@ import {
import { IdeClient } from '../ide/ide-client.js';
import { FixLLMEditWithInstruction } from '../utils/llm-edit-fixer.js';
import { safeLiteralReplace } from '../utils/textUtils.js';
import { SmartEditStrategyEvent } from '../telemetry/types.js';
import { logSmartEditStrategy } from '../telemetry/loggers.js';
import { SmartEditCorrectionEvent } from '../telemetry/types.js';
import { logSmartEditCorrectionEvent } from '../telemetry/loggers.js';
import { EditStrategyEvent } from '../telemetry/types.js';
import { logEditStrategy } from '../telemetry/loggers.js';
import { EditCorrectionEvent } from '../telemetry/types.js';
import { logEditCorrectionEvent } from '../telemetry/loggers.js';
import { correctPath } from '../utils/pathCorrector.js';
import { EDIT_TOOL_NAME, READ_FILE_TOOL_NAME } from './tool-names.js';
@@ -289,22 +289,22 @@ export async function calculateReplacement(
const exactResult = await calculateExactReplacement(context);
if (exactResult) {
const event = new SmartEditStrategyEvent('exact');
logSmartEditStrategy(config, event);
const event = new EditStrategyEvent('exact');
logEditStrategy(config, event);
return exactResult;
}
const flexibleResult = await calculateFlexibleReplacement(context);
if (flexibleResult) {
const event = new SmartEditStrategyEvent('flexible');
logSmartEditStrategy(config, event);
const event = new EditStrategyEvent('flexible');
logEditStrategy(config, event);
return flexibleResult;
}
const regexResult = await calculateRegexReplacement(context);
if (regexResult) {
const event = new SmartEditStrategyEvent('regex');
logSmartEditStrategy(config, event);
const event = new EditStrategyEvent('regex');
logEditStrategy(config, event);
return regexResult;
}
@@ -500,8 +500,8 @@ class EditToolInvocation
if (secondError) {
// The fix failed, log failure and return the original error
const event = new SmartEditCorrectionEvent('failure');
logSmartEditCorrectionEvent(this.config, event);
const event = new EditCorrectionEvent('failure');
logEditCorrectionEvent(this.config, event);
return {
currentContent: contentForLlmEditFixer,
@@ -513,8 +513,8 @@ class EditToolInvocation
};
}
const event = new SmartEditCorrectionEvent('success');
logSmartEditCorrectionEvent(this.config, event);
const event = new EditCorrectionEvent('success');
logEditCorrectionEvent(this.config, event);
return {
currentContent: contentForLlmEditFixer,
@@ -703,7 +703,7 @@ class EditToolInvocation
onConfirm: async (outcome: ToolConfirmationOutcome) => {
if (outcome === ToolConfirmationOutcome.ProceedAlways) {
// No need to publish a policy update as the default policy for
// AUTO_EDIT already reflects always approving smart-edit.
// AUTO_EDIT already reflects always approving edit.
this.config.setApprovalMode(ApprovalMode.AUTO_EDIT);
} else {
await this.publishPolicyUpdate(outcome);
@@ -866,7 +866,7 @@ class EditToolInvocation
/**
* Implementation of the Edit tool logic
*/
export class SmartEditTool
export class EditTool
extends BaseDeclarativeTool<EditToolParams, ToolResult>
implements ModifiableDeclarativeTool<EditToolParams>
{
@@ -877,7 +877,7 @@ export class SmartEditTool
messageBus: MessageBus,
) {
super(
SmartEditTool.Name,
EditTool.Name,
'Edit',
`Replaces text within a file. By default, replaces a single occurrence, but can replace multiple occurrences when \`expected_replacements\` is specified. This tool requires providing significant context around the change to ensure precise targeting. Always use the ${READ_FILE_TOOL_NAME} tool to examine the file's current content before attempting a text replacement.

View File

@@ -23,7 +23,7 @@ import type {
ToolResult,
} from './tools.js';
import { ToolConfirmationOutcome } from './tools.js';
import { type EditToolParams } from './smart-edit.js';
import { type EditToolParams } from './edit.js';
import type { Config } from '../config/config.js';
import { ApprovalMode } from '../policy/types.js';
import type { ToolRegistry } from './tool-registry.js';