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:
@@ -75,7 +75,7 @@ func TestHandshakeListAndCall(t *testing.T) {
|
||||
t.Fatalf("tool without description or schema: %v", entry)
|
||||
}
|
||||
}
|
||||
if strings.Join(names, ",") != "show_file,show_image,show_html,notify" {
|
||||
if strings.Join(names, ",") != "show_file,show_image,show_html,show_diff,notify" {
|
||||
t.Fatalf("tools = %v", names)
|
||||
}
|
||||
if list["id"] != "l" {
|
||||
|
||||
@@ -5,6 +5,7 @@ const (
|
||||
ToolShowFile = "show_file"
|
||||
ToolShowImage = "show_image"
|
||||
ToolShowHTML = "show_html"
|
||||
ToolShowDiff = "show_diff"
|
||||
ToolNotify = "notify"
|
||||
)
|
||||
|
||||
@@ -15,7 +16,7 @@ const MaxHTMLBytes = 512 << 10
|
||||
// IsTool reports whether name is one of the Pipelines tools.
|
||||
func IsTool(name string) bool {
|
||||
switch name {
|
||||
case ToolShowFile, ToolShowImage, ToolShowHTML, ToolNotify:
|
||||
case ToolShowFile, ToolShowImage, ToolShowHTML, ToolShowDiff, ToolNotify:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -24,6 +25,7 @@ func IsTool(name string) bool {
|
||||
// Instructions is the MCP initialize instructions text.
|
||||
const Instructions = "These tools act on Pipelines, the app the operator reads this chat in, not on your workspace. " +
|
||||
"Use show_file / show_image instead of telling the operator a path to open, show_html for diagrams, charts or small visual views, " +
|
||||
"show_diff when the operator asks to see changes or a diff (for example before submitting a pull request), " +
|
||||
"and notify only when the operator should look at their phone now."
|
||||
|
||||
type toolDefinition struct {
|
||||
@@ -84,6 +86,24 @@ func definitions() []toolDefinition {
|
||||
}),
|
||||
Annotations: map[string]any{"readOnlyHint": true, "openWorldHint": false},
|
||||
},
|
||||
{
|
||||
Name: ToolShowDiff,
|
||||
Title: "Show a Git diff in the chat",
|
||||
Description: "Show the operator the changes in a Git repository on this machine as a diff card in the Pipelines chat: " +
|
||||
"every changed file with its added and removed lines, each opening the app's diff viewer. " +
|
||||
"Use it when the operator asks to see the diff or the changes, for example before a pull request is submitted. " +
|
||||
"Pipelines runs Git itself, so do not paste the diff. Without base it shows uncommitted work (staged, unstaged and untracked files) against HEAD. " +
|
||||
"With base (the pull request's target branch, such as main or origin/main) it shows everything since the branch left base, " +
|
||||
"which is what the pull request would contain, plus uncommitted work unless committed_only is true. " +
|
||||
"The repository must be inside the operator's home directory. Very large diffs are shown partially and say so.",
|
||||
InputSchema: objectSchema([]string{}, map[string]any{
|
||||
"path": stringProperty("Optional repository directory: absolute, ~/path, or relative to the chat's working directory. Defaults to the chat's working directory."),
|
||||
"base": stringProperty("Optional branch, tag or commit to compare against, such as main or origin/main. Omit to show uncommitted changes."),
|
||||
"committed_only": map[string]any{"type": "boolean", "description": "Only with base: show the committed changes (base...HEAD) and leave out uncommitted work."},
|
||||
"title": stringProperty("Optional short caption shown above the diff."),
|
||||
}),
|
||||
Annotations: map[string]any{"readOnlyHint": true, "openWorldHint": false},
|
||||
},
|
||||
{
|
||||
Name: ToolNotify,
|
||||
Title: "Notify the operator's phone",
|
||||
|
||||
Reference in New Issue
Block a user