docs(tools): DiffResultView.diffs may be a whole-file diff, not only hunks
The write-diff-card fix made write's presentResult return an args-derived whole-file diff (oldText:null) for a create / unchanged overwrite, but the DiffResultView contract and its mirrored docs still said `diffs` is ALWAYS the applied contextual hunks computed from before/after. Correct the type JSDoc, the write execute-side comment, and the four mirrored surfaces (tools.md, tools README, acp-feature-support, adding-a-tool cookbook) to say: typically the applied hunks, or a whole-file diff when there is no before-image (a create) — and that a mutation returns the diff result even when it duplicates the call-time card, since a tool_call_update.content replace would otherwise clobber the diff with the model-facing text. Regenerate the cordis catalog (source line shift).
This commit is contained in:
@@ -62,9 +62,10 @@ export function applyWriteTool(ctx: Context): void {
|
||||
const outcome = await ctx.fs.writeText(target, input.content, intent, exec.signal)
|
||||
// Record the observed version (a no-op when no policy plugin listens).
|
||||
ctx.emit('fs/observed', target, outcome.version, exec)
|
||||
// Result-time contextual diff ONLY for an overwrite (a before-version
|
||||
// Attach a contextual hunk as `meta` ONLY for an overwrite (a before-version
|
||||
// exists). A create has no "before" — `outcome.before` is null — so it
|
||||
// carries no result diff, leaving just the call-time whole-file card.
|
||||
// carries no `meta`; `presentResult` then renders a whole-file diff from the
|
||||
// args, so the completed card is still a diff (never the result text).
|
||||
const diffs = outcome.before !== null ? computeHunkDiffs(input.filePath, outcome.before, outcome.after) : []
|
||||
return {
|
||||
content: [{ type: 'text', text: formatWriteOutput(target.displayPath, outcome) }],
|
||||
|
||||
Reference in New Issue
Block a user