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:
can1357
2026-04-26 05:01:52 +02:00
parent d493f945e0
commit 2c8da2ce09
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -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));
+1 -1
View File
@@ -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);