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:
@@ -68,5 +68,65 @@ JsonMap chatShownFixture(Object? sessionId) => {
|
||||
'priority': 'default',
|
||||
'delivered': true,
|
||||
},
|
||||
{
|
||||
'id': 'shown-diff',
|
||||
'kind': 'diff',
|
||||
'created_at': _at(19, 50),
|
||||
'title': 'Pull request preview',
|
||||
'diff_bytes': 612,
|
||||
'diff': {
|
||||
'repo': '/srv/probe/pipelines',
|
||||
'base': 'main',
|
||||
'base_commit': '79e51834a1b2',
|
||||
'head': 'show-diff-tool',
|
||||
'files': 3,
|
||||
'additions': 7,
|
||||
'deletions': 2,
|
||||
'changes': {
|
||||
'status': 'complete',
|
||||
'skipped': 0,
|
||||
'files': [
|
||||
{
|
||||
'path': 'internal/chattools/tools.go',
|
||||
'kind': 'modified',
|
||||
'patch':
|
||||
'diff --git a/internal/chattools/tools.go b/internal/chattools/tools.go\n'
|
||||
'--- a/internal/chattools/tools.go\n'
|
||||
'+++ b/internal/chattools/tools.go\n'
|
||||
'@@ -6,7 +6,8 @@ const (\n'
|
||||
' \tToolShowFile = "show_file"\n'
|
||||
' \tToolShowImage = "show_image"\n'
|
||||
'-\tToolShowHTML = "show_html"\n'
|
||||
'+\tToolShowHTML = "show_html"\n'
|
||||
'+\tToolShowDiff = "show_diff"\n'
|
||||
' \tToolNotify = "notify"\n'
|
||||
' )\n',
|
||||
},
|
||||
{
|
||||
'path': 'internal/server/chat_tools_diff.go',
|
||||
'kind': 'added',
|
||||
'patch':
|
||||
'--- /dev/null\n'
|
||||
'+++ b/internal/server/chat_tools_diff.go\n'
|
||||
'@@ -0,0 +1,5 @@\n'
|
||||
'+package server\n'
|
||||
'+\n'
|
||||
'+// runShowDiff compares a repository inside the operator\'s home\n'
|
||||
'+// and records the per-file patches as one diff item.\n'
|
||||
'+const showDiffMaxFiles = 300\n',
|
||||
},
|
||||
{
|
||||
'path': 'docs/old-notes.md',
|
||||
'kind': 'deleted',
|
||||
'patch':
|
||||
'--- a/docs/old-notes.md\n'
|
||||
'+++ /dev/null\n'
|
||||
'@@ -1,1 +0,0 @@\n'
|
||||
'-Superseded notes.\n',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user