@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
56 lines • 3.22 kB
TypeScript
import type { AgentTool } from "@earendil-works/pi-agent-core";
import { type Static, Type } from "typebox";
import type { FilesystemPolicyChecker, ToolDefinition } from "../extensions/types.ts";
import { type FileMutationQueue, type ToolPathCanonicalizer, type ToolPathResolver } from "./file-tool-host.ts";
import type { ToolMachine } from "./tool-machine.ts";
declare const editSchema: Type.TObject<{
path: Type.TString;
edits: Type.TArray<Type.TObject<{
oldText: Type.TString;
newText: Type.TString;
}>>;
}>;
export declare const editToolSystemPromptContribution: {
readonly snippet: "Make precise file edits with exact text replacement, including multiple disjoint edits in one call";
readonly guidelines: readonly ["All changes to one file -> one edit call."];
readonly fullGuidelines: readonly ["Use edit for precise changes (edits[].oldText must match exactly)", "When changing multiple separate locations in one file, use one edit call with multiple entries in edits[] instead of multiple edit calls", "Each edits[].oldText is matched against the original file, not after earlier edits are applied. Do not emit overlapping or nested edits. Merge nearby changes into one edit.", "Keep edits[].oldText as small as possible while still being unique in the file. Do not pad with large unchanged regions."];
};
export type EditToolInput = Static<typeof editSchema>;
export interface EditToolDetails {
/** Display-oriented diff of the changes made */
diff: string;
/** Standard unified patch of the changes made */
patch: string;
/** Line number of the first change in the new file (for editor navigation) */
firstChangedLine?: number;
}
/**
* Pluggable operations for the edit tool.
* Override these to delegate file editing to remote systems (for example SSH).
*/
export interface EditOperations {
/** Read file contents */
readFile: (absolutePath: string) => Promise<Uint8Array>;
/** Write content to a file */
writeFile: (absolutePath: string, content: string) => Promise<void>;
/** Check if file is readable and writable (throw if not) */
access: (absolutePath: string) => Promise<void>;
}
export interface CoreEditToolOptions {
/** Operation layer and policy gate. */
machine: ToolMachine;
/** Custom operations for file editing. Default: edits through `machine` */
operations?: EditOperations;
/** Extension-registered filesystem policy checker. */
filesystemPolicy?: FilesystemPolicyChecker;
/** Default: POSIX resolution against the cwd. */
resolvePath?: ToolPathResolver;
/** Default: one queue per path string in this isolate, shared with the core write tool. */
withMutationQueue?: FileMutationQueue;
/** The path `filesystemPolicy` judges. Default: the resolved path as is. */
canonicalizePath?: ToolPathCanonicalizer;
}
export declare function createCoreEditToolDefinition(cwd: string, options: CoreEditToolOptions): ToolDefinition<typeof editSchema, EditToolDetails | undefined>;
export declare function createCoreEditTool(cwd: string, options: CoreEditToolOptions): AgentTool<typeof editSchema>;
export { editSchema };
//# sourceMappingURL=edit-core.d.ts.map