feat(coding-agent): added matcherDigest hook for TTSR wire-format normalization

- Added optional `AgentTool.matcherDigest(args)` hook so tools can expose plain source text instead of wire-encoded arguments to TTSR rule matchers.
- Implemented `matcherDigest` on edit (all modes: hashline, patch, apply_patch, replace) and write tools, stripping patch prefixes and JSON escaping.
- Added `TtsrManager.checkSnapshot()` to replace the scoped buffer with a tool digest rather than appending raw deltas.
- Fixed TTSR conditions never matching streamed edit/write calls whose wire format obscured real content.
This commit is contained in:
can1357
2026-06-03 10:05:24 +02:00
parent b92aa30b24
commit eda1a1056b
10 changed files with 272 additions and 9 deletions
+6
View File
@@ -273,6 +273,12 @@ export class WriteTool implements AgentTool<typeof writeSchema, WriteToolDetails
readonly loadMode = "discoverable";
readonly summary = "Write content to a file (creates or overwrites)";
/** Stream matchers should see the real file content, not its JSON-escaped argument encoding. */
matcherDigest(args: unknown): string | undefined {
const content = (args as Partial<WriteParams>).content;
return typeof content === "string" ? content : undefined;
}
readonly #writethrough: WritethroughCallback;
constructor(private readonly session: ToolSession) {