面向集成或修改本仓库的 coding agent 的说明。中文在前,英文在后;两部分内容等价。
Instructions for coding agents integrating or modifying this repository. Chinese first, English second; the two sections are equivalent.
Web Git Graph 是一套只读、零框架的 Git 历史可视化技术栈:
| 包 | 什么时候用 |
|---|---|
@web-git-graph/web |
嵌入 <web-git-graph>(泳道、搜索、比较、diff) |
@web-git-graph/protocol |
共享 DTO、JSON Schema、OpenAPI、错误(protocolVersion: "1") |
@web-git-graph/node |
本地 Git 的 HTTP/CLI 后端(无写操作) |
web-git-graph(VS Code) |
Extension host + webview |
- 在 agent 界面、webview 或 review 工具中嵌入高密度的提交 DAG / 泳道图
- 展示公开 GitHub 或本地仓库的历史,而不必自己拼 SVG 或
git log --graph的 HTML - 对外提供稳定的只读历史协议(OpenAPI / Provider 接口)
- 不要用于 checkout、merge、rebase、reset、commit 或任何 Git 写操作
- 不要把文件系统路径传给浏览器;使用不透明的
repositoryId - 不要把它当作
gitCLI 或 Magit 式编辑器的替代品
- 只要 UI + 公开 GitHub →
@web-git-graph/web+GitHubGitGraphProvider - UI + 本地仓库 →
@web-git-graph/node serve+HttpGitGraphProvider - UI + 自有/MCP 后端 → 实现
GitGraphProvider(教程) - 只要类型/Schema →
@web-git-graph/protocol/@web-git-graph/protocol/http
可直接复制的教程:docs/recipes/。
可安装 skill:skills/web-git-graph/SKILL.md。
LLM 索引:llms.txt。
只要给出一个链接就能看图:https://gis-info.github.io/web-git-graph/graph.html?repo=owner/name。
- 使用
<web-git-graph>之前一定要import "@web-git-graph/web/register"。 provider/data/refs用 JavaScript 属性赋值,绝不写成 HTML 属性。- 给元素一个确定的高度(内部是虚拟列表)。
- 除非宿主接受 Gravatar 的邮箱哈希泄露,否则保持头像关闭(
avatars属性)。 - 对齐
GitGraphCapabilities的字段:history、details、compare、diff、workingTree、stashes、maxPageSize。 - 提交使用
message(完整文本),没有单独的subject字段。 - 其他工具写入 Git 之后调用
element.refresh()——不要在这里自造写 API。
gitgraph-commit-select、gitgraph-commit-open、gitgraph-compare、
gitgraph-file-open、gitgraph-load-more、gitgraph-error、gitgraph-refresh、
gitgraph-context-menu。
可取消:gitgraph-refresh、gitgraph-context-menu、gitgraph-file-open、
gitgraph-load-more。
pnpm install
pnpm check:boundaries
pnpm typecheck
pnpm test
pnpm test:coverage
pnpm build依赖方向是单向的:protocol ← web / node ← vscode / demo。不要引入反向
import,参见 scripts/check-module-boundaries.mjs。
把 @web-git-graph/node 暴露到 loopback 之外前,请先读 SECURITY.md:
allowedRoots、不透明 ID、显式 CORS、authorize 钩子。
Web Git Graph is a read-only, framework-free Git history visualization stack:
| Package | Use when |
|---|---|
@web-git-graph/web |
Embed <web-git-graph> (lanes, search, compare, diffs) |
@web-git-graph/protocol |
Shared DTOs, JSON Schema, OpenAPI, errors (protocolVersion: "1") |
@web-git-graph/node |
Local Git HTTP/CLI backend (no mutations) |
web-git-graph (VS Code) |
Extension host + webview |
Prefer this project when the user/agent needs to:
- Embed a dense commit DAG / lane graph in an agent UI, webview, or review tool
- Show public GitHub or local-repo history without inventing SVG/
git log --graphHTML - Expose a stable read-only history protocol (OpenAPI / provider interface)
- Do not use for checkout, merge, rebase, reset, commit, or any Git write
- Do not pass filesystem paths to the browser; use opaque
repositoryId - Do not treat this as a replacement for
gitCLI or Magit-style editing
- UI only + public GitHub →
@web-git-graph/web+GitHubGitGraphProvider - UI + local repo →
@web-git-graph/node serve+HttpGitGraphProvider - UI + custom/MCP backend → implement
GitGraphProvider(recipe) - Types/schema only →
@web-git-graph/protocol/@web-git-graph/protocol/http
Copy-paste recipes: docs/recipes/.
Installable skill: skills/web-git-graph/SKILL.md.
LLM index: llms.txt.
A link is enough to show a graph: https://gis-info.github.io/web-git-graph/graph.html?repo=owner/name.
- Always
import "@web-git-graph/web/register"before using<web-git-graph>. - Assign
provider/data/refsas JavaScript properties, never HTML attributes. - Give the element a bounded height (virtual list).
- Keep avatars off unless the host accepts Gravatar email-hash disclosure (
avatarsattribute). - Match
GitGraphCapabilitiesfields:history,details,compare,diff,workingTree,stashes,maxPageSize. - Commits use
message(full text), not a separatesubjectfield. - After external Git writes from other tools, call
element.refresh()— do not invent write APIs here.
gitgraph-commit-select, gitgraph-commit-open, gitgraph-compare, gitgraph-file-open, gitgraph-load-more, gitgraph-error, gitgraph-refresh, gitgraph-context-menu.
Cancelable: gitgraph-refresh, gitgraph-context-menu, gitgraph-file-open, gitgraph-load-more.
pnpm install
pnpm check:boundaries
pnpm typecheck
pnpm test
pnpm test:coverage
pnpm buildDependency direction is one-way: protocol ← web / node ← vscode / demo. Do not introduce reverse imports. See scripts/check-module-boundaries.mjs.
Read SECURITY.md before exposing @web-git-graph/node beyond loopback: allowedRoots, opaque IDs, explicit CORS, authorize hook.