Diffinery

homeflare/diffinerypublic

Open-source, agent-first GitHub and GitHub Actions alternative that runs on your own Cloudflare account: git hosting, pull requests, code review and drop-in GitHub Actions YAML on Workers, Durable Objects, R2 and Containers.

diffinery/plugins/README.md
204 lines · 10.5 KBRaw History
1# Diffinery plugins for Claude Code and Codex
2
3A plugin marketplace, kept in the Diffinery repository itself, that makes Claude Code and
4OpenAI's Codex CLI work smoothly with repositories hosted on [Diffinery](https://diffinery.com),
5the open-source git forge built for AI agents: on diffinery.com or on any instance you deploy
6yourself (see [Any Diffinery instance](#any-diffinery-instance)).
7It has two plugins: `diffinery` (Claude Code and Codex) and `diffinery-ci` (Claude Code),
8described below.
9
10The plugin adds:
11
12| Piece | Claude Code | Codex |
13| --- | --- | --- |
14| `diffinery` MCP server (`<Diffinery URL>/mcp`, OAuth sign-in) | yes | yes (diffinery.com; see below for others) |
15| `diffinery` skill: the CLI, git auth, the branch → PR → CI → merge loop, Diffinery's agent rules | yes | yes |
16| `pr-status`: this branch's PR, its checks, and the log tail of failing jobs | `/diffinery:pr-status` command | `pr-status` skill |
17| SessionStart hook: in a Diffinery clone, tells the agent the repo is on Diffinery and whether the `diffinery` CLI is installed and signed in | yes | yes, once you trust it (`/hooks`) |
18
19`diffinery-ci` is a Claude Code [mod](https://code.claude.com/docs/en/plugins/mods/overview)
20that shows the branch's pull request and its CI checks live, and tells Claude when CI settles:
21
22| Piece | Where it works |
23| --- | --- |
24| Band above the prompt: PR number, title, checks (`✗ 1 failed · ● 3 running · ✓ 6`), review and merge state | Terminal, desktop app (Code tab), VS Code |
25| `/diffinery-ci`: a pane with every check, its time and a link to its log, plus **Fix CI** and **Refresh**; `/diffinery-ci on` / `off` | Pane where Claude Code draws; a text answer everywhere else |
26| Status line entry (`PR #7 ✓ 10/10`) and a toast when CI passes or fails | Where Claude Code draws |
27| After the session pushes a branch or opens its PR, a note to Claude once that commit's checks settle (failures where the band shows the rest, passes too where nothing draws, so a cloud thread hears either way; `/diffinery-ci notes auto|failures|all|off` changes it, nothing to set up) | Everywhere hooks run, cloud sessions and project threads included |
28
29It reads the GraphQL API of the Diffinery instance in `DIFFINERY_URL`, the plugin's Diffinery
30URL setting or the CLI's saved URL (in that order, else diffinery.com), with the token from
31`DIFFINERY_TOKEN`, `diffinery login`, or gh signed in to the host (`diffinery auth setup-gh`),
32and sends a token only to the instance it belongs to. It needs
33Claude Code 2.1.287 or later (the desktop app: 2.1.286). Cloud sessions run its hooks but
34draw no mod interface, so there it's the note to Claude and the `/diffinery-ci` text.
35
36Nothing here is needed just to use git: clone, fetch and push work with any git client
37(`diffinery auth setup-git` or a token as the HTTPS password). The plugin is for pull
38requests, CI and issues.
39
40## Install
41
42The marketplace is the public GitHub repository codician-team/diffinery, so adding it needs
43no sign-in. The plugin works through the `diffinery` CLI, so install it and sign in once per
44machine:
45
46```sh
47curl -fsSL https://diffinery.com/install | bash # Windows: irm https://diffinery.com/install.ps1 | iex
48diffinery login
49diffinery auth setup-git
50```
51
52### Claude Code
53
54```sh
55claude plugin marketplace add codician-team/diffinery
56claude plugin install diffinery@diffinery
57```
58
59Or inside a session: `/plugin marketplace add codician-team/diffinery`,
60then `/plugin install diffinery@diffinery`, then `/reload-plugins` (or restart).
61
62Add `claude plugin install diffinery-ci@diffinery` for the live CI band.
63
64### claude.ai, cloud sessions and projects
65
66claude.ai can't read this repository, so upload the plugins as files: download
67https://diffinery.com/-/claude/diffinery.zip and https://diffinery.com/-/claude/diffinery-ci.zip,
68then in claude.ai open **Customize → Plugins → Add → Upload plugin** for each. They reach your
69cloud sessions at their next start. For a project's threads, also add them under
70**Project settings → Plugins**. Build the same zips from a checkout with
71`python3 scripts/pack-plugins.py` at the repository root (they land in `dist/`).
72
73### Codex
74
75```sh
76codex plugin marketplace add codician-team/diffinery
77codex plugin add diffinery@diffinery
78```
79
80Check with `codex plugin list` and `codex mcp list`. Codex runs plugin hooks only after
81you review and trust them: open `/hooks` in the Codex TUI and trust the `diffinery`
82SessionStart hook (optional; the skill works without it).
83
84## Any Diffinery instance
85
86Diffinery is open source, and every plugin here works with any instance, not only
87diffinery.com. Both Claude Code plugins have a **Diffinery URL** setting (`userConfig.url`,
88default `https://diffinery.com`). It sets the MCP server's address (`.mcp.json` uses
89`${user_config.url}/mcp`), the instance the SessionStart hook recognises in a clone (it gets
90the value as `CLAUDE_PLUGIN_OPTION_URL`), and the instance `diffinery-ci` reads.
91
92- `diffinery setup --url https://git.example.com` sets it for you, in `pluginConfigs` in
93 `~/.claude/settings.json`, for the copies it installs (`diffinery@inline`) and for
94 marketplace installs alike. Install the CLI from the instance itself:
95 `curl -fsSL https://git.example.com/install | bash`.
96- Claude Code asks for it when you enable a marketplace install; change it later in `/config`.
97- The zips an instance serves at `/-/claude/<name>.zip` default the setting to that instance
98 (`apps/diffinery/src/docs/claude-plugins.ts`), so uploads to claude.ai need nothing else.
99- The hook also knows `DIFFINERY_URL` and the URL `diffinery login` saved; `DIFFINERY_URL`
100 takes precedence for the hook and for `diffinery-ci`, as it does for the CLI.
101
102Codex substitutes no plugin settings, so the Codex manifest reads its own
103`codex.mcp.json`, which names `https://diffinery.com/mcp`. A server of your own named
104`diffinery` replaces it, and `diffinery setup --url` adds one when Codex is installed:
105`codex mcp add diffinery --url https://git.example.com/mcp`. The skills and the hook work
106with any instance in Codex too.
107
108## Sign in
109
110The MCP server signs you in with OAuth in the browser:
111
112- Claude Code: run `/mcp`, pick `plugin:diffinery:diffinery`, choose Authenticate.
113- Codex: `codex mcp login diffinery`.
114
115The skill also uses the `diffinery` CLI, which has its own sign-in:
116
117```sh
118curl -fsSL https://diffinery.com/install | bash # Windows: irm https://diffinery.com/install.ps1 | iex
119diffinery login # or: diffinery login --device
120diffinery auth setup-git # optional: git credential helper
121```
122
123## Headless use (CI, cloud sessions): `DIFFINERY_TOKEN`
124
125The `diffinery` CLI and `diffinery auth setup-git` pick up `DIFFINERY_TOKEN` on their own.
126
127The plugin's MCP server uses OAuth only. Neither client can take a token from the
128environment when it is set and fall back to OAuth when it is not, from one config:
129
130- Claude Code turns OAuth off as soon as the server config has an `Authorization`
131 header, even an empty one, and plugin header helpers do not see variables like
132 `DIFFINERY_TOKEN`.
133- Codex's `bearer_token_env_var` makes the server fail to start when the variable is unset.
134
135So on headless machines, add a token-based server of your own. It takes precedence over
136the plugin's:
137
138```sh
139# Claude Code: same URL, so the plugin's OAuth entry is hidden while this one exists
140claude mcp add --scope user --transport http diffinery https://diffinery.com/mcp \
141 --header 'Authorization: Bearer ${DIFFINERY_TOKEN}'
142
143# Codex: same name, so it replaces the plugin's server
144codex mcp add diffinery --url https://diffinery.com/mcp --bearer-token-env-var DIFFINERY_TOKEN
145# ...or just for one run, without touching config.toml:
146codex -c 'mcp_servers.diffinery.url="https://diffinery.com/mcp"' \
147 -c 'mcp_servers.diffinery.bearer_token_env_var="DIFFINERY_TOKEN"' exec "..."
148```
149
150Keep the single quotes in the Claude Code command: Claude Code expands
151`${DIFFINERY_TOKEN}` when it connects, so the token is never written to its config.
152
153## claude.ai and the Claude apps
154
155Settings → Connectors → Add custom connector, with the URL `https://diffinery.com/mcp`
156(or your own instance's `https://git.example.com/mcp`). You sign in with your Diffinery
157account when you connect it.
158
159## gh
160
161Prefer the `diffinery` CLI: it knows Diffinery's extras (`--intent`, auto-merge,
162`run logs`). `gh` works too once you run `diffinery auth setup-gh`, which signs gh in to
163the Diffinery host (diffinery.com or yours) as a GitHub Enterprise host. That is also what lets Claude Code show the
164branch's pull request with its CI status. See https://diffinery.com/docs/agents/github-cli.
165
166## Layout
167
168Paths from the repository root:
169
170```
171.claude-plugin/marketplace.json Claude Code marketplace
172.agents/plugins/marketplace.json Codex marketplace
173plugins/diffinery/
174 .claude-plugin/plugin.json Claude Code manifest
175 .codex-plugin/plugin.json Codex manifest
176 .claude-plugin/icon.png the listing icon (also in diffinery-ci)
177 .mcp.json the diffinery MCP server (Claude Code: ${user_config.url}/mcp)
178 codex.mcp.json the diffinery MCP server (Codex: diffinery.com)
179 skills/diffinery/SKILL.md the skill (both clients)
180 commands/pr-status.md /pr-status (Claude Code)
181 codex-skills/pr-status/SKILL.md pr-status skill (Codex has no plugin commands)
182 hooks/hooks.json SessionStart hook (both clients)
183 hooks/session-start.sh the hook: POSIX sh, no network, silent outside Diffinery repos
184plugins/diffinery-ci/ Claude Code only (a mod)
185 .claude-plugin/plugin.json manifest
186 hooks/hooks.json names the hooks module
187 hooks/register.tsx the mod: band, pane, status line, CI watch
188 hooks/lib.ts parsing and wording, no engine calls
189 types/index.d.ts the mod's state contract
190 tests/ci.test.tsx `claude plugin test plugins/diffinery-ci`
191scripts/pack-plugins.py builds dist/<plugin>-<version>.zip for upload
192apps/diffinery/claude-plugins/ the packed zips diffinery.com serves (see its README)
193```
194
195Check changes with `claude plugin validate .` and `claude plugin validate plugins/diffinery`
196from the repository root, and for the mod `claude plugin validate plugins/diffinery-ci` and
197`claude plugin test plugins/diffinery-ci`. Bump `version` in both plugin manifests and both marketplace entries
198together.
199
200More: https://diffinery.com/docs/connect
201
202## License
203
204Apache-2.0, like the rest of the repository. See [LICENSE](../LICENSE).