refactor(ast-tools): reorganized ast-edit+grep hashline sep and lax strict
- Applied HASHLINE_CONTENT_SEPARATOR in AstEditTool output so hashline entries share a shared delimiter. - Set AstEditTool and AstGrepTool strict defaults to false for more permissive tool call input handling.
This commit is contained in:
@@ -5,7 +5,7 @@ import type { Component } from "@oh-my-pi/pi-tui";
|
||||
import { Text } from "@oh-my-pi/pi-tui";
|
||||
import { $envpos, prompt, untilAborted } from "@oh-my-pi/pi-utils";
|
||||
import { type Static, Type } from "@sinclair/typebox";
|
||||
import { computeLineHash } from "../edit/line-hash";
|
||||
import { computeLineHash, HASHLINE_CONTENT_SEPARATOR } from "../edit/line-hash";
|
||||
import type { RenderResultOptions } from "../extensibility/custom-tools/types";
|
||||
import type { Theme } from "../modes/theme/theme";
|
||||
import astEditDescription from "../prompts/tools/ast-edit.md" with { type: "text" };
|
||||
@@ -72,7 +72,7 @@ export class AstEditTool implements AgentTool<typeof astEditSchema, AstEditToolD
|
||||
readonly label = "AST Edit";
|
||||
readonly description: string;
|
||||
readonly parameters = astEditSchema;
|
||||
readonly strict = true;
|
||||
readonly strict = false;
|
||||
readonly deferrable = true;
|
||||
constructor(private readonly session: ToolSession) {
|
||||
this.description = prompt.render(astEditDescription);
|
||||
@@ -221,7 +221,7 @@ export class AstEditTool implements AgentTool<typeof astEditSchema, AstEditToolD
|
||||
const afterRef = useHashLines
|
||||
? `${change.startLine}${computeLineHash(change.startLine, afterFirstLine)}`
|
||||
: `${change.startLine}:${change.startColumn}`;
|
||||
const lineSeparator = useHashLines ? "\t" : " ";
|
||||
const lineSeparator = useHashLines ? HASHLINE_CONTENT_SEPARATOR : " ";
|
||||
outputLines.push(`-${beforeRef}${lineSeparator}${beforeLine}`);
|
||||
outputLines.push(`+${afterRef}${lineSeparator}${afterLine}`);
|
||||
displayLines.push(formatCodeFrameLine("-", change.startLine, beforeLine, lineNumberWidth));
|
||||
|
||||
@@ -63,7 +63,7 @@ export class AstGrepTool implements AgentTool<typeof astGrepSchema, AstGrepToolD
|
||||
readonly label = "AST Grep";
|
||||
readonly description: string;
|
||||
readonly parameters = astGrepSchema;
|
||||
readonly strict = true;
|
||||
readonly strict = false;
|
||||
|
||||
constructor(private readonly session: ToolSession) {
|
||||
this.description = prompt.render(astGrepDescription);
|
||||
|
||||
Reference in New Issue
Block a user