Add show_diff chat tool and diff card
The Pipelines MCP server gains show_diff: it runs Git in a repository inside the operator's home (default: the chat's directory) and records the per-file patches. Without base it shows uncommitted work against HEAD; with base it shows everything since the merge base (a pull request preview), optionally committed changes only. Bounded at 300 files, 256 KiB per patch and 1 MiB total, with partial diffs labelled; diff bodies share the per-chat retention budget with HTML views. The chat draws the item as a card listing each changed file with its stat; a row opens the existing file diff viewer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,8 @@ func (s *chatToolService) run(ctx context.Context, sessionID, tool string, argum
|
||||
HeightHint int `json:"height_hint"`
|
||||
Message string `json:"message"`
|
||||
Priority string `json:"priority"`
|
||||
Base string `json:"base"`
|
||||
Committed bool `json:"committed_only"`
|
||||
}
|
||||
if err := json.Unmarshal(arguments, &in); err != nil {
|
||||
return fail("The arguments must be a JSON object matching the %s schema: %v", tool, err)
|
||||
@@ -72,6 +74,8 @@ func (s *chatToolService) run(ctx context.Context, sessionID, tool string, argum
|
||||
}
|
||||
item := protocol.ChatShownItem{Kind: protocol.ChatShownHTML, Title: title, HTML: in.HTML, HTMLBytes: len(in.HTML), HeightHint: clampHeightHint(in.HeightHint)}
|
||||
return &item, chattools.Result{Text: fmt.Sprintf("Shown in the operator's Pipelines chat (%s, sandboxed: scripts and network are disabled).", humanBytes(int64(len(in.HTML))))}
|
||||
case chattools.ToolShowDiff:
|
||||
return s.runShowDiff(ctx, sessionID, showDiffRequest{Path: in.Path, Base: in.Base, CommittedOnly: in.Committed, Title: title})
|
||||
case chattools.ToolNotify:
|
||||
return s.runNotify(ctx, sessionID, title, in.Message, in.Priority)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user