agy-git-graph 0.0.0-stage → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 s17765152890-gif
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,80 @@
1
- # Temporary Holding Version
1
+ # Git Graph (提交图) for Antigravity
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm version](https://img.shields.io/npm/v/agy-git-graph.svg)](https://www.npmjs.com/package/agy-git-graph)
4
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
+
6
+ 在 **Google Antigravity 2.0** 中提供两种入口查看 Git 工作区更改、快捷提交、Diff 预览与多分支 SVG 可视化提交图(Commit Graph),运行时零外部 npm 依赖:
7
+
8
+ - **左侧主导航栏一级入口(MCP App Global View)**:一点直达全页双栏 Git Graph 视图(自适应亮/暗主题)。
9
+ - **右侧辅助侧边栏(Sidecar Aux Pane)**:在对话旁常驻窄屏紧凑 Git 面板。
10
+
11
+ A lightweight, zero-dependency Git plugin for **Google Antigravity 2.0** with both a **1-click left-sidebar full-page view** (via official MCP App `global` entrypoint) and a **right-hand sidecar panel**, providing working-tree changes, quick commits, colored diffs, branch filtering, and a multi-branch SVG commit graph.
12
+
13
+ ---
14
+
15
+ ## 功能特性 / Features
16
+
17
+ - **仓库自动发现**:自动从 Antigravity 会话列表与历史摘要快照中发现最近使用的 Git 仓库,也支持点击 `+` 手动添加任意本地仓库路径。
18
+ - **工作区更改 & 提交**:
19
+ - 展示 `已暂存更改 (Staged)` 与 `更改 (Unstaged)` 列表,区分 `M` / `A` / `D` / `R` / `C` / `?` / `U` 状态;
20
+ - 支持单文件或全部暂存(`+`)、取消暂存(`−`)、放弃更改(`↺` 两步确认)以及 `Ctrl+Enter` 快捷提交;
21
+ - 点击文件行即可在抽屉面板查看彩色 Diff(含中文文件名、重命名与未跟踪文件预览)。
22
+ - **多分支 SVG 提交图(Commit Graph)**:
23
+ - 左侧渲染多通道 SVG 彩色分支线与贝塞尔分叉/合并曲线,高亮 `HEAD` 与合并节点;
24
+ - 展示 `HEAD`、本地分支、远端分支与 Tag 徽章;
25
+ - 支持按 **所有分支 / 当前分支 / 指定分支** 筛选、提交信息搜索以及分页加载更多;
26
+ - 点击任意提交可查看完整 Hash、作者时间、正文及逐文件增删统计与 Diff。
27
+
28
+ ---
29
+
30
+ ## 快速安装 / Quick Install
31
+
32
+ 环境要求 / Requirements:**Node.js >= 22.5.0**(推荐 Node 26)与系统 `PATH` 中的 **Git**。
33
+
34
+ ### 方式一:通过 npm 一键安装(推荐)
35
+
36
+ ```bash
37
+ npx agy-git-graph@latest install
38
+ ```
39
+
40
+ 安装完成后,**重启 Antigravity 2.0**(或在 Customizations 页面重新开关一次插件),然后在对话中输入「打开 Git Graph」或点击插件卡片上的 `[Git Graph](sidecar://agy-git-graph/git_graph/)` 即可在右侧边栏打开。
41
+
42
+ ### 方式二:通过 GitHub 手动安装
43
+
44
+ 将本仓库克隆到 Antigravity 插件目录:
45
+
46
+ - **Windows (PowerShell)**:
47
+ ```powershell
48
+ git clone https://github.com/s17765152890-gif/agy-git-graph.git "$env:USERPROFILE\.gemini\config\plugins\agy-git-graph"
49
+ ```
50
+ - **macOS / Linux**:
51
+ ```bash
52
+ git clone https://github.com/s17765152890-gif/agy-git-graph.git ~/.gemini/config/plugins/agy-git-graph
53
+ ```
54
+
55
+ 然后重启 Antigravity 2.0 即可生效。
56
+
57
+ ---
58
+
59
+ ## CLI 命令 / CLI Usage
60
+
61
+ ```bash
62
+ npx agy-git-graph install [--dir <pluginsDir>] # 安装插件到 Antigravity 插件目录
63
+ npx agy-git-graph status [--dir <pluginsDir>] # 查看安装状态
64
+ npx agy-git-graph uninstall [--dir <pluginsDir>] # 卸载插件
65
+ npx agy-git-graph standalone [--port <port>] # 独立启动本地预览服务
66
+ ```
67
+
68
+ ## 独立调试与测试 / Standalone & Tests
69
+
70
+ ```bash
71
+ # 运行全部单元测试与端到端集成测试
72
+ npm test
73
+
74
+ # 独立启动本地预览服务(浏览器打开 READY 后的地址)
75
+ npm run standalone
76
+ ```
77
+
78
+ ## 开源协议 / License
79
+
80
+ [MIT](LICENSE) © 2026 [s17765152890-gif](https://github.com/s17765152890-gif)
@@ -0,0 +1,17 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
2
+ <g fill="none" stroke="#1e293b" stroke-width="14" stroke-linecap="round">
3
+ <path d="M34 25v78"/>
4
+ <path d="M34 89c0-28 60-19 60-59"/>
5
+ </g>
6
+ <g fill="none" stroke-width="6">
7
+ <path d="M34 25v78" stroke="#818cf8"/>
8
+ <path d="M34 89c0-28 60-19 60-59" stroke="#34d399"/>
9
+ </g>
10
+ <g fill="#1e293b" stroke="#a5b4fc" stroke-width="4">
11
+ <circle cx="34" cy="25" r="10"/>
12
+ <circle cx="34" cy="63" r="8"/>
13
+ <circle cx="34" cy="103" r="10"/>
14
+ <circle cx="94" cy="30" r="10" stroke="#6ee7b7"/>
15
+ <circle cx="84" cy="54" r="7" stroke="#6ee7b7"/>
16
+ </g>
17
+ </svg>
package/bin/cli.mjs ADDED
@@ -0,0 +1,160 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from 'node:child_process';
3
+ import { cpSync, existsSync, mkdirSync, readFileSync, realpathSync, rmSync } from 'node:fs';
4
+ import { homedir } from 'node:os';
5
+ import { dirname, join, resolve } from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+
8
+ const PLUGIN_NAME = 'agy-git-graph';
9
+ const PKG_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
10
+ const PKG_JSON = JSON.parse(readFileSync(join(PKG_ROOT, 'package.json'), 'utf8'));
11
+
12
+ function pathKey(p) {
13
+ let resolved = resolve(p);
14
+ try {
15
+ resolved = realpathSync(resolved);
16
+ } catch {
17
+ // Keep resolved path when target does not exist yet.
18
+ }
19
+ return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
20
+ }
21
+
22
+ function getFlagValue(args, flag) {
23
+ for (let i = 0; i < args.length; i++) {
24
+ if (args[i] === flag && args[i + 1]) return args[i + 1];
25
+ if (args[i].startsWith(flag + '=')) return args[i].slice(flag.length + 1);
26
+ }
27
+ return '';
28
+ }
29
+
30
+ function resolvePluginsDir(args) {
31
+ const custom = getFlagValue(args, '--dir');
32
+ return custom ? resolve(custom) : join(homedir(), '.gemini', 'config', 'plugins');
33
+ }
34
+
35
+ function printHelp() {
36
+ console.log(`agy-git-graph v${PKG_JSON.version}
37
+
38
+ Usage:
39
+ agy-git-graph [install] [--dir <pluginsDir>] Install plugin into Antigravity plugins directory
40
+ agy-git-graph uninstall [--dir <pluginsDir>] Remove installed plugin from Antigravity plugins directory
41
+ agy-git-graph status [--dir <pluginsDir>] Show installation status
42
+ agy-git-graph standalone [--port <port>] Run standalone preview HTTP server
43
+ agy-git-graph --version Print version
44
+ agy-git-graph --help Show this help
45
+ `);
46
+ }
47
+
48
+ function copyRuntimeFiles(targetDir) {
49
+ const items = [
50
+ ['plugin.json', false],
51
+ ['mcp_config.json', false],
52
+ ['README.md', false],
53
+ ['LICENSE', false],
54
+ ['assets', true],
55
+ ['mcp', true],
56
+ ['skills', true],
57
+ ['sidecars/git_graph/sidecar.json', false],
58
+ ['sidecars/git_graph/server.mjs', false],
59
+ ['sidecars/git_graph/index.html', false],
60
+ ['sidecars/git_graph/lib', true],
61
+ ];
62
+
63
+ rmSync(targetDir, { recursive: true, force: true });
64
+ mkdirSync(targetDir, { recursive: true });
65
+
66
+ for (const [rel, isDir] of items) {
67
+ const src = join(PKG_ROOT, rel);
68
+ const dest = join(targetDir, rel);
69
+ if (!existsSync(src)) continue;
70
+ mkdirSync(dirname(dest), { recursive: true });
71
+ cpSync(src, dest, { recursive: isDir });
72
+ }
73
+ }
74
+
75
+ function cmdInstall(args) {
76
+ const pluginsDir = resolvePluginsDir(args);
77
+ const targetDir = join(pluginsDir, PLUGIN_NAME);
78
+
79
+ if (pathKey(targetDir) === pathKey(PKG_ROOT)) {
80
+ console.log(`agy-git-graph v${PKG_JSON.version} is already running from ${targetDir}.`);
81
+ return;
82
+ }
83
+
84
+ copyRuntimeFiles(targetDir);
85
+ console.log(`Installed agy-git-graph v${PKG_JSON.version} to:`);
86
+ console.log(` ${targetDir}`);
87
+ console.log('');
88
+ console.log('Next steps:');
89
+ console.log(' 1. Restart or reload Antigravity 2.0 to load the new sidecar panel.');
90
+ console.log(' 2. Ask Antigravity "打开 Git Graph" or enable it in Customizations.');
91
+ }
92
+
93
+ function cmdUninstall(args) {
94
+ const pluginsDir = resolvePluginsDir(args);
95
+ const targetDir = join(pluginsDir, PLUGIN_NAME);
96
+
97
+ if (!existsSync(targetDir)) {
98
+ console.log(`agy-git-graph is not installed at ${targetDir}.`);
99
+ return;
100
+ }
101
+ if (pathKey(targetDir) === pathKey(PKG_ROOT)) {
102
+ console.error(`Refusing to remove active package directory: ${targetDir}`);
103
+ process.exitCode = 1;
104
+ return;
105
+ }
106
+
107
+ rmSync(targetDir, { recursive: true, force: true });
108
+ console.log(`Removed agy-git-graph from ${targetDir}.`);
109
+ }
110
+
111
+ function cmdStatus(args) {
112
+ const pluginsDir = resolvePluginsDir(args);
113
+ const targetDir = join(pluginsDir, PLUGIN_NAME);
114
+ const manifestPath = join(targetDir, 'plugin.json');
115
+
116
+ if (!existsSync(manifestPath)) {
117
+ console.log(`Not installed (${targetDir})`);
118
+ process.exitCode = 1;
119
+ return;
120
+ }
121
+
122
+ try {
123
+ const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
124
+ console.log(`Installed: ${manifest.name || PLUGIN_NAME} v${manifest.version || 'unknown'}`);
125
+ console.log(`Path: ${targetDir}`);
126
+ } catch (err) {
127
+ console.error(`Installed directory exists at ${targetDir}, but failed to read plugin.json: ${err.message}`);
128
+ process.exitCode = 1;
129
+ }
130
+ }
131
+
132
+ function cmdStandalone(args) {
133
+ const port = getFlagValue(args, '--port');
134
+ const serverPath = join(PKG_ROOT, 'sidecars', 'git_graph', 'server.mjs');
135
+ const childArgs = [serverPath, '--standalone'];
136
+ if (port) childArgs.push('--port', port);
137
+ const child = spawn(process.execPath, childArgs, { stdio: 'inherit', windowsHide: false });
138
+ child.on('exit', (code, signal) => {
139
+ if (signal) process.exit(1);
140
+ process.exit(code ?? 0);
141
+ });
142
+ }
143
+
144
+ const args = process.argv.slice(2);
145
+ if (args.includes('--help') || args.includes('-h') || args[0] === 'help') {
146
+ printHelp();
147
+ } else if (args.includes('--version') || args.includes('-v')) {
148
+ console.log(PKG_JSON.version);
149
+ } else {
150
+ const cmd = !args[0] || args[0].startsWith('-') ? 'install' : args[0];
151
+ if (cmd === 'install') cmdInstall(args);
152
+ else if (cmd === 'uninstall') cmdUninstall(args);
153
+ else if (cmd === 'status') cmdStatus(args);
154
+ else if (cmd === 'standalone') cmdStandalone(args);
155
+ else {
156
+ console.error(`Unknown command: ${cmd}`);
157
+ printHelp();
158
+ process.exitCode = 1;
159
+ }
160
+ }