agy-git-graph 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/bin/cli.mjs +2 -0
- package/mcp/ext-apps-bridge.js +112 -0
- package/mcp/server.mjs +289 -0
- package/mcp_config.json +8 -0
- package/package.json +3 -1
- package/plugin.json +1 -1
- package/sidecars/git_graph/index.html +175 -34
- package/sidecars/git_graph/lib/render.mjs +41 -0
- package/sidecars/git_graph/server.mjs +2 -27
package/mcp/server.mjs
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { createHandlers } from '../sidecars/git_graph/lib/handlers.mjs';
|
|
5
|
+
import { renderIndexHtml } from '../sidecars/git_graph/lib/render.mjs';
|
|
6
|
+
import { discoverWorkspaces } from '../sidecars/git_graph/lib/workspaces.mjs';
|
|
7
|
+
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const PLUGIN_ROOT = resolve(__dirname, '..');
|
|
10
|
+
const APP_URI = 'ui://git-graph/app.html';
|
|
11
|
+
const APP_MIME = 'text/html;profile=mcp-app';
|
|
12
|
+
|
|
13
|
+
for (const stream of [process.stdout, process.stderr]) {
|
|
14
|
+
stream.on('error', (error) => {
|
|
15
|
+
if (error?.code !== 'EPIPE') throw error;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function readPackageVersion() {
|
|
20
|
+
try {
|
|
21
|
+
const pkg = JSON.parse(readFileSync(join(PLUGIN_ROOT, 'package.json'), 'utf8'));
|
|
22
|
+
if (typeof pkg?.version === 'string' && pkg.version.trim()) return pkg.version.trim();
|
|
23
|
+
} catch {
|
|
24
|
+
// Fallback below.
|
|
25
|
+
}
|
|
26
|
+
return '1.1.0';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const SERVER_VERSION = readPackageVersion();
|
|
30
|
+
const handlers = createHandlers();
|
|
31
|
+
|
|
32
|
+
const TOOLS = [
|
|
33
|
+
{
|
|
34
|
+
name: 'open_git_graph',
|
|
35
|
+
title: 'Git Graph',
|
|
36
|
+
description:
|
|
37
|
+
'Open the Git Graph view to inspect working-tree changes, stage/commit files, view diffs, and browse the multi-branch SVG commit graph.',
|
|
38
|
+
inputSchema: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
repoPath: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
description: 'Optional local Git repository path to open.',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
additionalProperties: false,
|
|
47
|
+
},
|
|
48
|
+
_meta: {
|
|
49
|
+
ui: { resourceUri: APP_URI },
|
|
50
|
+
'com.google.antigravity/ui': {
|
|
51
|
+
entrypoints: [{ type: 'global', title: 'Git Graph' }],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'git_graph_rpc',
|
|
57
|
+
title: 'Git Graph App RPC',
|
|
58
|
+
description: 'App-only RPC bridge for Git Graph UI.',
|
|
59
|
+
inputSchema: {
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: {
|
|
62
|
+
route: { type: 'string' },
|
|
63
|
+
payload: { type: 'object' },
|
|
64
|
+
},
|
|
65
|
+
required: ['route'],
|
|
66
|
+
additionalProperties: false,
|
|
67
|
+
},
|
|
68
|
+
_meta: {
|
|
69
|
+
ui: { visibility: ['app'] },
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
const RESOURCES = [
|
|
75
|
+
{
|
|
76
|
+
uri: APP_URI,
|
|
77
|
+
name: 'Git Graph',
|
|
78
|
+
description: 'Interactive Git working-tree changes, diffs, and multi-branch SVG commit graph.',
|
|
79
|
+
mimeType: APP_MIME,
|
|
80
|
+
_meta: {
|
|
81
|
+
ui: { prefersBorder: false },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
function sendMessage(msg) {
|
|
87
|
+
try {
|
|
88
|
+
process.stdout.write(JSON.stringify(msg) + '\n');
|
|
89
|
+
} catch {
|
|
90
|
+
// Ignore closed stdout during shutdown.
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function sendResult(id, result) {
|
|
95
|
+
if (id === undefined || id === null) return;
|
|
96
|
+
sendMessage({ jsonrpc: '2.0', id, result });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function sendError(id, code, message) {
|
|
100
|
+
if (id === undefined || id === null) return;
|
|
101
|
+
sendMessage({ jsonrpc: '2.0', id, error: { code, message: String(message || 'Internal error') } });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function readAppHtml() {
|
|
105
|
+
const bridgePath = join(__dirname, 'ext-apps-bridge.js');
|
|
106
|
+
const mcpBridgeScript = readFileSync(bridgePath, 'utf8');
|
|
107
|
+
return renderIndexHtml({ mcpBridgeScript });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function handleToolCall(params = {}) {
|
|
111
|
+
const name = params?.name;
|
|
112
|
+
const args = params?.arguments && typeof params.arguments === 'object' ? params.arguments : {};
|
|
113
|
+
|
|
114
|
+
if (name === 'open_git_graph') {
|
|
115
|
+
const { repos } = await discoverWorkspaces();
|
|
116
|
+
const initialRepoPath = typeof args.repoPath === 'string' ? args.repoPath.trim() : '';
|
|
117
|
+
const structuredContent = { ok: true, initialRepoPath, repos };
|
|
118
|
+
return {
|
|
119
|
+
content: [{ type: 'text', text: 'Opened Git Graph.' }],
|
|
120
|
+
structuredContent,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (name === 'git_graph_rpc') {
|
|
125
|
+
const route = typeof args.route === 'string' ? args.route.trim().replace(/^\/+/, '') : '';
|
|
126
|
+
const apiRoute = '/api/' + route;
|
|
127
|
+
if (!route || !Object.hasOwn(handlers, apiRoute)) {
|
|
128
|
+
const msg = `Unknown Git Graph RPC route: ${route}`;
|
|
129
|
+
return {
|
|
130
|
+
isError: true,
|
|
131
|
+
content: [{ type: 'text', text: msg }],
|
|
132
|
+
structuredContent: { ok: false, error: msg },
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
const payload = args.payload && typeof args.payload === 'object' ? args.payload : {};
|
|
137
|
+
const result = await handlers[apiRoute](payload);
|
|
138
|
+
return {
|
|
139
|
+
content: [{ type: 'text', text: JSON.stringify(result) }],
|
|
140
|
+
structuredContent: result,
|
|
141
|
+
};
|
|
142
|
+
} catch (error) {
|
|
143
|
+
const msg = error?.message || String(error);
|
|
144
|
+
return {
|
|
145
|
+
isError: true,
|
|
146
|
+
content: [{ type: 'text', text: msg }],
|
|
147
|
+
structuredContent: { ok: false, error: msg },
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
isError: true,
|
|
154
|
+
content: [{ type: 'text', text: `Unknown tool: ${name}` }],
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function dispatch(msg) {
|
|
159
|
+
if (!msg || typeof msg !== 'object') {
|
|
160
|
+
sendError(null, -32600, 'Invalid Request');
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const { id, method, params } = msg;
|
|
164
|
+
const isNotification = id === undefined || id === null;
|
|
165
|
+
|
|
166
|
+
if (typeof method !== 'string') {
|
|
167
|
+
if (!isNotification) sendError(id, -32600, 'Invalid Request');
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (method === 'notifications/initialized' || method === 'notifications/cancelled') {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
switch (method) {
|
|
177
|
+
case 'initialize': {
|
|
178
|
+
const protocolVersion = typeof params?.protocolVersion === 'string' && params.protocolVersion
|
|
179
|
+
? params.protocolVersion
|
|
180
|
+
: '2025-03-26';
|
|
181
|
+
sendResult(id, {
|
|
182
|
+
protocolVersion,
|
|
183
|
+
capabilities: {
|
|
184
|
+
tools: { listChanged: false },
|
|
185
|
+
resources: { subscribe: false, listChanged: false },
|
|
186
|
+
},
|
|
187
|
+
serverInfo: {
|
|
188
|
+
name: 'agy-git-graph_git_graph',
|
|
189
|
+
version: SERVER_VERSION,
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
case 'ping':
|
|
195
|
+
sendResult(id, {});
|
|
196
|
+
return;
|
|
197
|
+
case 'tools/list':
|
|
198
|
+
sendResult(id, { tools: TOOLS });
|
|
199
|
+
return;
|
|
200
|
+
case 'tools/call':
|
|
201
|
+
sendResult(id, await handleToolCall(params));
|
|
202
|
+
return;
|
|
203
|
+
case 'resources/list':
|
|
204
|
+
sendResult(id, { resources: RESOURCES });
|
|
205
|
+
return;
|
|
206
|
+
case 'resources/templates/list':
|
|
207
|
+
sendResult(id, { resourceTemplates: [] });
|
|
208
|
+
return;
|
|
209
|
+
case 'resources/read': {
|
|
210
|
+
if (params?.uri !== APP_URI) {
|
|
211
|
+
sendError(id, -32602, `Resource not found: ${params?.uri || ''}`);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
sendResult(id, {
|
|
215
|
+
contents: [
|
|
216
|
+
{
|
|
217
|
+
uri: APP_URI,
|
|
218
|
+
mimeType: APP_MIME,
|
|
219
|
+
text: readAppHtml(),
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
});
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
default:
|
|
226
|
+
if (!isNotification) sendError(id, -32601, `Method not found: ${method}`);
|
|
227
|
+
}
|
|
228
|
+
} catch (error) {
|
|
229
|
+
if (!isNotification) sendError(id, -32603, error?.message || 'Internal error');
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function startStdioServer() {
|
|
234
|
+
const inFlight = new Set();
|
|
235
|
+
let closing = false;
|
|
236
|
+
|
|
237
|
+
const track = (parsed) => {
|
|
238
|
+
if (closing) return;
|
|
239
|
+
const task = dispatch(parsed).catch((error) => {
|
|
240
|
+
sendError(parsed?.id, -32603, error?.message || 'Internal error');
|
|
241
|
+
});
|
|
242
|
+
inFlight.add(task);
|
|
243
|
+
task.finally(() => inFlight.delete(task));
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
let buffer = '';
|
|
247
|
+
process.stdin.setEncoding('utf8');
|
|
248
|
+
process.stdin.on('data', (chunk) => {
|
|
249
|
+
buffer += chunk;
|
|
250
|
+
const lines = buffer.split(/\r?\n/);
|
|
251
|
+
buffer = lines.pop() ?? '';
|
|
252
|
+
for (const rawLine of lines) {
|
|
253
|
+
const line = rawLine.trim();
|
|
254
|
+
if (!line) continue;
|
|
255
|
+
try {
|
|
256
|
+
track(JSON.parse(line));
|
|
257
|
+
} catch {
|
|
258
|
+
sendError(null, -32700, 'Parse error');
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
const shutdown = async () => {
|
|
264
|
+
if (closing) return;
|
|
265
|
+
closing = true;
|
|
266
|
+
await Promise.allSettled([...inFlight]);
|
|
267
|
+
process.exit(0);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
process.stdin.on('end', () => {
|
|
271
|
+
const trailing = buffer.trim();
|
|
272
|
+
if (trailing) {
|
|
273
|
+
try {
|
|
274
|
+
track(JSON.parse(trailing));
|
|
275
|
+
} catch {
|
|
276
|
+
sendError(null, -32700, 'Parse error');
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
void shutdown();
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
process.once('SIGINT', () => void shutdown());
|
|
283
|
+
process.once('SIGTERM', () => void shutdown());
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const isMain = process.argv[1] && resolve(process.argv[1]) === resolve(fileURLToPath(import.meta.url));
|
|
287
|
+
if (isMain) {
|
|
288
|
+
startStdioServer();
|
|
289
|
+
}
|
package/mcp_config.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agy-git-graph",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "DSH-style Git changes, commit box, diff viewer, and multi-branch SVG commit graph side panel plugin for Google Antigravity 2.0.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
"files": [
|
|
36
36
|
"bin/",
|
|
37
37
|
"assets/",
|
|
38
|
+
"mcp/",
|
|
39
|
+
"mcp_config.json",
|
|
38
40
|
"skills/",
|
|
39
41
|
"sidecars/git_graph/sidecar.json",
|
|
40
42
|
"sidecars/git_graph/server.mjs",
|
package/plugin.json
CHANGED
|
@@ -7,21 +7,85 @@
|
|
|
7
7
|
<style>
|
|
8
8
|
:root {
|
|
9
9
|
color-scheme: dark;
|
|
10
|
-
--bg: #0f0f11;
|
|
11
|
-
--surface: #141416;
|
|
12
|
-
--surface-2: #1b1b1e;
|
|
13
|
-
--
|
|
14
|
-
--
|
|
15
|
-
--
|
|
10
|
+
--bg: var(--color-background-primary, #0f0f11);
|
|
11
|
+
--surface: var(--color-background-secondary, #141416);
|
|
12
|
+
--surface-2: var(--color-background-tertiary, #1b1b1e);
|
|
13
|
+
--hover-bg: #29292e;
|
|
14
|
+
--even-row: #121214;
|
|
15
|
+
--active-row: #222331;
|
|
16
|
+
--border: var(--color-border-primary, rgba(255,255,255,0.08));
|
|
17
|
+
--drawer-border: #35353d;
|
|
18
|
+
--text: var(--color-text-primary, #ededef);
|
|
19
|
+
--text-secondary: var(--color-text-secondary, #a1a1aa);
|
|
16
20
|
--muted: #71717a;
|
|
17
|
-
--ui-font-default: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", sans-serif;
|
|
21
|
+
--ui-font-default: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", sans-serif);
|
|
18
22
|
--ui-font: var(--ui-font-default);
|
|
19
23
|
--ui-font-weight: 400;
|
|
20
24
|
--mono: "Cascadia Code", Consolas, monospace;
|
|
21
25
|
--accent: #a5b4fc;
|
|
26
|
+
--branch-bg: #1c1d2c;
|
|
27
|
+
--branch-mark: #818cf8;
|
|
28
|
+
--primary-bg: #4f46b6;
|
|
29
|
+
--primary-hover: #6057d2;
|
|
30
|
+
--primary-border: #6b61df;
|
|
31
|
+
--primary-text: #ffffff;
|
|
22
32
|
--green: #86efac;
|
|
33
|
+
--green-bg: #162820;
|
|
23
34
|
--red: #fda4af;
|
|
35
|
+
--red-bg: #311b23;
|
|
36
|
+
--red-border: #723545;
|
|
24
37
|
--amber: #fcd34d;
|
|
38
|
+
--amber-bg: #282117;
|
|
39
|
+
--info-fg: #7dd3fc;
|
|
40
|
+
--info-bg: #132534;
|
|
41
|
+
--hunk-fg: #a5b4fc;
|
|
42
|
+
--hunk-bg: #1c2036;
|
|
43
|
+
--ref-head-fg: #a7f3d0;
|
|
44
|
+
--ref-head-bg: #15352d;
|
|
45
|
+
--ref-local-fg: #bae6fd;
|
|
46
|
+
--ref-local-bg: #153045;
|
|
47
|
+
--ref-remote-fg: #cbd5e1;
|
|
48
|
+
--ref-remote-border: #374151;
|
|
49
|
+
--ref-tag-bg: #392b15;
|
|
50
|
+
}
|
|
51
|
+
:root[data-theme="light"] {
|
|
52
|
+
color-scheme: light;
|
|
53
|
+
--bg: var(--color-background-primary, #faf8f5);
|
|
54
|
+
--surface: var(--color-background-secondary, #f3efe8);
|
|
55
|
+
--surface-2: var(--color-background-tertiary, #eae4da);
|
|
56
|
+
--hover-bg: #e1d9cc;
|
|
57
|
+
--even-row: #f5f1ea;
|
|
58
|
+
--active-row: #e6e9f8;
|
|
59
|
+
--border: var(--color-border-primary, rgba(24,24,27,0.12));
|
|
60
|
+
--drawer-border: rgba(24,24,27,0.2);
|
|
61
|
+
--text: var(--color-text-primary, #1f1f23);
|
|
62
|
+
--text-secondary: var(--color-text-secondary, #57534e);
|
|
63
|
+
--muted: #78716c;
|
|
64
|
+
--accent: #4338ca;
|
|
65
|
+
--branch-bg: #e5e7fb;
|
|
66
|
+
--branch-mark: #4f46e5;
|
|
67
|
+
--primary-bg: #4338ca;
|
|
68
|
+
--primary-hover: #3730a3;
|
|
69
|
+
--primary-border: #3730a3;
|
|
70
|
+
--primary-text: #ffffff;
|
|
71
|
+
--green: #15803d;
|
|
72
|
+
--green-bg: #dcfce7;
|
|
73
|
+
--red: #be123c;
|
|
74
|
+
--red-bg: #ffe4e6;
|
|
75
|
+
--red-border: #fda4af;
|
|
76
|
+
--amber: #b45309;
|
|
77
|
+
--amber-bg: #fef3c7;
|
|
78
|
+
--info-fg: #0369a1;
|
|
79
|
+
--info-bg: #e0f2fe;
|
|
80
|
+
--hunk-fg: #4338ca;
|
|
81
|
+
--hunk-bg: #e0e7ff;
|
|
82
|
+
--ref-head-fg: #047857;
|
|
83
|
+
--ref-head-bg: #d1fae5;
|
|
84
|
+
--ref-local-fg: #0369a1;
|
|
85
|
+
--ref-local-bg: #e0f2fe;
|
|
86
|
+
--ref-remote-fg: #475569;
|
|
87
|
+
--ref-remote-border: #cbd5e1;
|
|
88
|
+
--ref-tag-bg: #fef3c7;
|
|
25
89
|
}
|
|
26
90
|
/*__POWERTOOLS_FONT_CSS__*/
|
|
27
91
|
* { box-sizing: border-box; }
|
|
@@ -36,7 +100,7 @@
|
|
|
36
100
|
min-width: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2);
|
|
37
101
|
}
|
|
38
102
|
button { cursor: pointer; padding: 3px 8px; }
|
|
39
|
-
button:hover:not(:disabled) { background:
|
|
103
|
+
button:hover:not(:disabled) { background: var(--hover-bg); }
|
|
40
104
|
button:disabled { opacity: .45; cursor: default; }
|
|
41
105
|
button:focus-visible, input:focus-visible, select:focus-visible,
|
|
42
106
|
textarea:focus-visible, summary:focus-visible, [role="separator"]:focus-visible {
|
|
@@ -55,9 +119,9 @@
|
|
|
55
119
|
#repos { flex: 1 1 105px; width: 0; }
|
|
56
120
|
.branch {
|
|
57
121
|
max-width: 44%; padding: 3px 7px; display: flex; gap: 5px; align-items: center;
|
|
58
|
-
color: var(--accent); background:
|
|
122
|
+
color: var(--accent); background: var(--branch-bg); border-radius: 5px;
|
|
59
123
|
}
|
|
60
|
-
.branch-mark { color:
|
|
124
|
+
.branch-mark { color: var(--branch-mark); flex: none; }
|
|
61
125
|
#branchCounts { color: var(--text-secondary); flex: none; white-space: nowrap; }
|
|
62
126
|
.repo-form {
|
|
63
127
|
display: flex; align-items: center; gap: 5px; padding: 7px 10px;
|
|
@@ -65,7 +129,7 @@
|
|
|
65
129
|
}
|
|
66
130
|
.repo-form input { flex: 1; }
|
|
67
131
|
.notice { padding: 5px 10px; color: var(--text-secondary); overflow-wrap: anywhere; max-height: 6em; overflow: auto; }
|
|
68
|
-
.notice[data-error="true"] { color: var(--red); background:
|
|
132
|
+
.notice[data-error="true"] { color: var(--red); background: var(--red-bg); }
|
|
69
133
|
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
|
|
70
134
|
.section-bar, .history-bar {
|
|
71
135
|
display: flex; align-items: center; gap: 6px; flex: none;
|
|
@@ -90,10 +154,10 @@
|
|
|
90
154
|
}
|
|
91
155
|
.commit-form textarea::placeholder, input::placeholder { color: var(--text-secondary); }
|
|
92
156
|
.primary {
|
|
93
|
-
background:
|
|
94
|
-
align-self: stretch; min-height: 27px;
|
|
157
|
+
background: var(--primary-bg); border-color: var(--primary-border); color: var(--primary-text);
|
|
158
|
+
font-weight: 650; align-self: stretch; min-height: 27px;
|
|
95
159
|
}
|
|
96
|
-
.primary:hover:not(:disabled) { background:
|
|
160
|
+
.primary:hover:not(:disabled) { background: var(--primary-hover); }
|
|
97
161
|
.change-header {
|
|
98
162
|
display: flex; align-items: center; justify-content: space-between;
|
|
99
163
|
gap: 4px; padding: 3px 10px; border-top: 1px solid var(--border);
|
|
@@ -112,23 +176,23 @@
|
|
|
112
176
|
.file-name { flex: 0 1 auto; }
|
|
113
177
|
.file-status {
|
|
114
178
|
display: grid; place-items: center; flex: 0 0 16px; height: 16px; border-radius: 4px;
|
|
115
|
-
color: var(--amber); background:
|
|
179
|
+
color: var(--amber); background: var(--amber-bg); font: 10px var(--mono);
|
|
116
180
|
}
|
|
117
|
-
.file-status[data-status="A"], .file-status[data-status="?"] { color: var(--green); background:
|
|
118
|
-
.file-status[data-status="D"], .file-status[data-status="U"] { color: var(--red); background:
|
|
119
|
-
.file-status[data-status="R"], .file-status[data-status="C"] { color:
|
|
181
|
+
.file-status[data-status="A"], .file-status[data-status="?"] { color: var(--green); background: var(--green-bg); }
|
|
182
|
+
.file-status[data-status="D"], .file-status[data-status="U"] { color: var(--red); background: var(--red-bg); }
|
|
183
|
+
.file-status[data-status="R"], .file-status[data-status="C"] { color: var(--info-fg); background: var(--info-bg); }
|
|
120
184
|
.row-actions { display: flex; align-items: center; flex: none; opacity: 0; }
|
|
121
185
|
.change-row:hover .row-actions, .change-row:focus-within .row-actions,
|
|
122
186
|
.row-actions:has(.confirm) { opacity: 1; }
|
|
123
187
|
@media (hover: none) { .row-actions { opacity: 1; } }
|
|
124
188
|
.row-actions button { height: 23px; min-width: 22px; padding: 0 4px; }
|
|
125
|
-
.row-actions .confirm { color: var(--red); border-color:
|
|
189
|
+
.row-actions .confirm { color: var(--red); border-color: var(--red-border); background: var(--red-bg); }
|
|
126
190
|
#splitter {
|
|
127
191
|
flex: 0 0 7px; background: var(--surface); border-block: 1px solid var(--border);
|
|
128
192
|
cursor: row-resize; touch-action: none; display: grid; place-items: center;
|
|
129
193
|
}
|
|
130
|
-
#splitter::before { content: ""; height: 2px; width: 26px; background:
|
|
131
|
-
#splitter:hover::before, #splitter:focus-visible::before { background: var(--accent); }
|
|
194
|
+
#splitter::before { content: ""; height: 2px; width: 26px; background: var(--muted); opacity: .45; border-radius: 2px; }
|
|
195
|
+
#splitter:hover::before, #splitter:focus-visible::before { background: var(--accent); opacity: 1; }
|
|
132
196
|
#history { flex: 1; min-height: 0; display: flex; flex-direction: column; }
|
|
133
197
|
.history-bar { border-bottom: 1px solid var(--border); }
|
|
134
198
|
.history-bar h1 { white-space: nowrap; margin-right: 3px; }
|
|
@@ -141,8 +205,8 @@
|
|
|
141
205
|
display: grid; grid-template-columns: var(--lane-width) minmax(0, 1fr) auto;
|
|
142
206
|
align-items: center; gap: 6px; text-align: left; background: var(--bg);
|
|
143
207
|
}
|
|
144
|
-
.commit-row:nth-child(even) { background:
|
|
145
|
-
.commit-row:hover:not(:disabled), .commit-row[aria-current="true"] { background:
|
|
208
|
+
.commit-row:nth-child(even) { background: var(--even-row); }
|
|
209
|
+
.commit-row:hover:not(:disabled), .commit-row[aria-current="true"] { background: var(--active-row); }
|
|
146
210
|
.commit-row svg { display: block; overflow: hidden; }
|
|
147
211
|
.commit-center { display: flex; align-items: center; gap: 4px; overflow: hidden; min-width: 0; }
|
|
148
212
|
.subject { flex: 1 1 50px; }
|
|
@@ -151,19 +215,30 @@
|
|
|
151
215
|
max-width: 118px; min-width: 18px; padding: 0 4px; border: 1px solid transparent;
|
|
152
216
|
border-radius: 4px; font-size: 10px; line-height: 15px;
|
|
153
217
|
}
|
|
154
|
-
.ref.head { color:
|
|
155
|
-
.ref.local { color:
|
|
156
|
-
.ref.remote { color:
|
|
157
|
-
.ref.tag { color: var(--amber); background:
|
|
218
|
+
.ref.head { color: var(--ref-head-fg); background: var(--ref-head-bg); }
|
|
219
|
+
.ref.local { color: var(--ref-local-fg); background: var(--ref-local-bg); }
|
|
220
|
+
.ref.remote { color: var(--ref-remote-fg); border-color: var(--ref-remote-border); }
|
|
221
|
+
.ref.tag { color: var(--amber); background: var(--ref-tag-bg); }
|
|
158
222
|
.commit-meta { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 10px; }
|
|
159
223
|
.commit-author { max-width: 64px; }
|
|
160
224
|
@media (max-width: 440px) { .commit-author { display: none; } }
|
|
161
225
|
@media (max-width: 325px) { .commit-time { display: none; } .toolbar, .history-bar { gap: 4px; } }
|
|
226
|
+
@media (min-width: 960px) {
|
|
227
|
+
main { flex-direction: row; }
|
|
228
|
+
#changes { flex: 0 0 360px; width: 360px; border-right: 1px solid var(--border); }
|
|
229
|
+
#changesBody { max-height: none; flex: 1; }
|
|
230
|
+
#splitter { display: none; }
|
|
231
|
+
#history { flex: 1; min-width: 0; }
|
|
232
|
+
#repos { max-width: 320px; }
|
|
233
|
+
#branchFilter { max-width: 240px; }
|
|
234
|
+
#search { max-width: 240px; }
|
|
235
|
+
.commit-author { max-width: 120px; }
|
|
236
|
+
}
|
|
162
237
|
.empty { padding: 8px 12px; color: var(--text-secondary); }
|
|
163
238
|
#more { display: block; margin: 8px auto; }
|
|
164
239
|
dialog {
|
|
165
240
|
inset: auto 0 0; margin: 0; width: 100%; max-width: none; max-height: min(78dvh, 100%);
|
|
166
|
-
padding: 0; border: 1px solid
|
|
241
|
+
padding: 0; border: 1px solid var(--drawer-border); border-radius: 12px 12px 0 0;
|
|
167
242
|
background: var(--surface); color: var(--text);
|
|
168
243
|
}
|
|
169
244
|
dialog[open] { display: flex; flex-direction: column; }
|
|
@@ -185,16 +260,16 @@
|
|
|
185
260
|
display: flex; width: 100%; align-items: center; gap: 6px;
|
|
186
261
|
border: 0; border-radius: 0; padding: 4px 10px; background: transparent; text-align: left;
|
|
187
262
|
}
|
|
188
|
-
.commit-files button[aria-current="true"] { background:
|
|
263
|
+
.commit-files button[aria-current="true"] { background: var(--active-row); }
|
|
189
264
|
.commit-files .file-path { flex: 1; }
|
|
190
265
|
.stat { font: 10px var(--mono); white-space: nowrap; }
|
|
191
266
|
.stat.add { color: var(--green); }
|
|
192
267
|
.stat.del { color: var(--red); }
|
|
193
268
|
.diff { margin: 0; overflow-x: auto; font: 11px/1.6 var(--mono); tab-size: 4; }
|
|
194
269
|
.diff span { display: block; min-width: 100%; width: max-content; padding: 0 9px; }
|
|
195
|
-
.diff .addition { color: var(--green); background:
|
|
196
|
-
.diff .deletion { color: var(--red); background:
|
|
197
|
-
.diff .hunk { color:
|
|
270
|
+
.diff .addition { color: var(--green); background: var(--green-bg); }
|
|
271
|
+
.diff .deletion { color: var(--red); background: var(--red-bg); }
|
|
272
|
+
.diff .hunk { color: var(--hunk-fg); background: var(--hunk-bg); }
|
|
198
273
|
.diff .header { color: var(--text-secondary); background: var(--surface-2); }
|
|
199
274
|
</style>
|
|
200
275
|
</head>
|
|
@@ -269,6 +344,7 @@
|
|
|
269
344
|
</header>
|
|
270
345
|
<div id="drawerBody"></div>
|
|
271
346
|
</dialog>
|
|
347
|
+
<!--__MCP_APP_BRIDGE__-->
|
|
272
348
|
<script>
|
|
273
349
|
'use strict';
|
|
274
350
|
|
|
@@ -278,6 +354,10 @@
|
|
|
278
354
|
const timeFormat = new Intl.DateTimeFormat('zh-CN', { dateStyle: 'medium', timeStyle: 'short' });
|
|
279
355
|
const relativeFormat = new Intl.RelativeTimeFormat('zh-CN', { numeric: 'auto' });
|
|
280
356
|
const emptyStatus = { staged: [], unstaged: [] };
|
|
357
|
+
const mcpBridge = globalThis.__AGY_MCP_EXT_APPS__ || null;
|
|
358
|
+
let mcpApp = null;
|
|
359
|
+
let mcpConnectPromise = null;
|
|
360
|
+
let bootedFromToolResult = false;
|
|
281
361
|
let selected = '';
|
|
282
362
|
let repos = [];
|
|
283
363
|
let repoState = null;
|
|
@@ -304,7 +384,45 @@
|
|
|
304
384
|
$('notice').dataset.error = isError;
|
|
305
385
|
}
|
|
306
386
|
|
|
387
|
+
function applyHostCtx(ctx) {
|
|
388
|
+
if (!ctx || !mcpBridge) return;
|
|
389
|
+
if (ctx.theme) {
|
|
390
|
+
document.documentElement.dataset.theme = ctx.theme;
|
|
391
|
+
mcpBridge.applyDocumentTheme?.(ctx.theme);
|
|
392
|
+
}
|
|
393
|
+
if (ctx.styles?.variables) {
|
|
394
|
+
mcpBridge.applyHostStyleVariables?.(ctx.styles.variables);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function parseToolResultPayload(result) {
|
|
399
|
+
if (result?.structuredContent && typeof result.structuredContent === 'object') {
|
|
400
|
+
return result.structuredContent;
|
|
401
|
+
}
|
|
402
|
+
const text = result?.content?.[0]?.text;
|
|
403
|
+
if (typeof text === 'string' && text.trim()) {
|
|
404
|
+
try {
|
|
405
|
+
return JSON.parse(text);
|
|
406
|
+
} catch {
|
|
407
|
+
return { ok: !result.isError, message: text };
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return {};
|
|
411
|
+
}
|
|
412
|
+
|
|
307
413
|
async function api(route, data = {}) {
|
|
414
|
+
if (mcpApp) {
|
|
415
|
+
if (mcpConnectPromise) await mcpConnectPromise;
|
|
416
|
+
const result = await mcpApp.callServerTool({
|
|
417
|
+
name: 'git_graph_rpc',
|
|
418
|
+
arguments: { route, payload: data },
|
|
419
|
+
});
|
|
420
|
+
const payload = parseToolResultPayload(result);
|
|
421
|
+
if (result?.isError || payload?.ok === false) {
|
|
422
|
+
throw new Error(payload?.error || payload?.message || 'MCP RPC 调用失败');
|
|
423
|
+
}
|
|
424
|
+
return payload;
|
|
425
|
+
}
|
|
308
426
|
const response = await fetch('/api/' + route, {
|
|
309
427
|
method: 'POST',
|
|
310
428
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -510,7 +628,7 @@
|
|
|
510
628
|
straightIn + straightOut + row.mergeInEdges.map((edge) => curve(edge, 0, 13)).join('') +
|
|
511
629
|
row.branchOutEdges.map((edge) => curve(edge, 13, 26)).join('') +
|
|
512
630
|
(commit.isHead ? circle(5.8, 'none', color, .65) : '') +
|
|
513
|
-
circle(commit.isMerge ? 3.8 : 3, commit.isMerge ? '
|
|
631
|
+
circle(commit.isMerge ? 3.8 : 3, commit.isMerge ? 'var(--surface)' : color, color) + '</svg>';
|
|
514
632
|
}
|
|
515
633
|
|
|
516
634
|
function renderHistory() {
|
|
@@ -850,7 +968,30 @@
|
|
|
850
968
|
});
|
|
851
969
|
|
|
852
970
|
renderState();
|
|
853
|
-
|
|
971
|
+
if (mcpBridge) {
|
|
972
|
+
mcpApp = new mcpBridge.App({ name: 'Git Graph', version: '1.1.0' }, {});
|
|
973
|
+
mcpApp.onhostcontextchanged = applyHostCtx;
|
|
974
|
+
mcpApp.ontoolresult = (result) => {
|
|
975
|
+
const data = parseToolResultPayload(result);
|
|
976
|
+
if (Array.isArray(data?.repos)) {
|
|
977
|
+
bootedFromToolResult = true;
|
|
978
|
+
repos = data.repos;
|
|
979
|
+
const preferred = data.initialRepoPath || '';
|
|
980
|
+
const next = [preferred, selected].find((path) => repos.some((repo) => repo.path === path));
|
|
981
|
+
switchRepo(next || repos[0]?.path || '');
|
|
982
|
+
renderRepoOptions();
|
|
983
|
+
void refreshState();
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
mcpConnectPromise = mcpApp.connect().then(() => {
|
|
987
|
+
applyHostCtx(mcpApp.getHostContext());
|
|
988
|
+
if (!bootedFromToolResult) return refreshRepos();
|
|
989
|
+
}).catch((error) => {
|
|
990
|
+
notice(error?.message || '连接 Antigravity MCP App 失败', true);
|
|
991
|
+
});
|
|
992
|
+
} else {
|
|
993
|
+
refreshRepos();
|
|
994
|
+
}
|
|
854
995
|
</script>
|
|
855
996
|
</body>
|
|
856
997
|
</html>
|