agents-gitflow-guard 0.0.20 → 0.0.21
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 +12 -12
- package/README.zh.md +12 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,17 +40,17 @@ You define your own branches —
|
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
# DSH — in-process plugin; restart DSH afterwards (plugins load at startup)
|
|
43
|
-
dsh plugin --profile web add agents-gitflow-guard@0.0.
|
|
43
|
+
dsh plugin --profile web add agents-gitflow-guard@0.0.21
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
```bash
|
|
47
47
|
# Claude Code · Codex · OpenCode · Antigravity — standalone hooks, no DSH needed
|
|
48
|
-
npm i -g agents-gitflow-guard@0.0.
|
|
48
|
+
npm i -g agents-gitflow-guard@0.0.21
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
52
|
# Pi — in-process extension
|
|
53
|
-
npm i -D agents-gitflow-guard@0.0.
|
|
53
|
+
npm i -D agents-gitflow-guard@0.0.21
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
> **Version gotcha**: a bare `add` or unpinned `npm i` resolves whatever `latest` is at install time — on machines behind a stale npm/pnpm registry cache or mirror it may install an old version. If the installed version looks wrong, pin it explicitly. (DSH users: the pnpm peer-dependency *warning* is expected — DSH supplies `@deepseek-ai/cordis` / `@deepseek-ai/dsh-tools` through its shared profile module fallback at startup; the plugin works normally.)
|
|
@@ -82,14 +82,14 @@ gitflow-guard setup
|
|
|
82
82
|
|
|
83
83
|
> ⚠️ **main is protected by default.** Trunk / single-branch users (everyone pushes straight to one branch) will get blocked on direct `main` pushes until they opt out — create `gitflow-guard.config.json` with `{ "enabled": false }`, or map your own branches (see [Configuration Reference](#configuration-reference)). `gitflow-guard status` repeats this notice whenever the built-in defaults are in effect.
|
|
84
84
|
|
|
85
|
-
**Step 3 — verify.** Ask the agent
|
|
85
|
+
**Step 3 — verify.** Ask the agent to `git push origin develop`. Expect the tool call to be denied:
|
|
86
86
|
|
|
87
87
|
```text
|
|
88
88
|
Error: [gitflow-guard] blocked: Protected branch "develop" forbids direct push
|
|
89
89
|
Next: Integration branch (develop) is updated via PR/MR from a feature branch: push the feature first, then `gh pr create --base develop` / `glab mr create --target-branch develop`.
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
Messages are English by default; create a config with `"locale": "zh"` to switch to Chinese (see [Configuration Reference](#configuration-reference)).
|
|
92
|
+
Messages are English by default; create a config with `"locale": "zh"` to switch to Chinese — messages then read like: *已拦截:受保护分支「develop」禁止直推 / 下一步:集成分支(develop)由 PR/MR 合入 feature……* (see [Configuration Reference](#configuration-reference)).
|
|
93
93
|
|
|
94
94
|
**Done.** The guard is live for this repo with the built-in defaults. Want more stages (`preview` / `production`) or different branch names? Write a `gitflow-guard.config.json` and only the fields you care about — everything else keeps the built-in defaults. For the full decision table, see the [Gate Matrix](#gate-matrix--what-gets-blocked-what-passes).
|
|
95
95
|
|
|
@@ -356,14 +356,14 @@ The PR/MR target is resolved via `gh pr view` (GitHub) or `glab mr view` (GitLab
|
|
|
356
356
|
|
|
357
357
|
| Agent | Install command | After that |
|
|
358
358
|
|---|---|---|
|
|
359
|
-
| DSH | `dsh plugin --profile web add agents-gitflow-guard@0.0.
|
|
360
|
-
| Claude Code · Codex · OpenCode · Antigravity | `npm i -g agents-gitflow-guard@0.0.
|
|
361
|
-
| Pi | `npm i -D agents-gitflow-guard@0.0.
|
|
359
|
+
| DSH | `dsh plugin --profile web add agents-gitflow-guard@0.0.21` | restart DSH — the plugin auto-mounts as a profile layer |
|
|
360
|
+
| Claude Code · Codex · OpenCode · Antigravity | `npm i -g agents-gitflow-guard@0.0.21` | `gitflow-guard wire --client <name>` — one command per client (below) |
|
|
361
|
+
| Pi | `npm i -D agents-gitflow-guard@0.0.21` | copy `pi/gitflow-guard.ts` into `.pi/extensions/` (below) |
|
|
362
362
|
|
|
363
363
|
**DSH — in-process plugin** (the standard path, already covered in [Quick Start](#quick-start--30-seconds-to-a-guarded-repo)):
|
|
364
364
|
|
|
365
365
|
```bash
|
|
366
|
-
dsh plugin --profile web add agents-gitflow-guard@0.0.
|
|
366
|
+
dsh plugin --profile web add agents-gitflow-guard@0.0.21 # pin recommended, see note above
|
|
367
367
|
```
|
|
368
368
|
|
|
369
369
|
Then restart DSH. Upgrades are the same command, followed by another restart.
|
|
@@ -380,7 +380,7 @@ The package declares `dsh.bundle.patch`, so `dsh plugin add` automatically makes
|
|
|
380
380
|
**Standalone agent hooks** — Claude Code / Codex / OpenCode / Antigravity, no DSH required. Install the CLI once, then wire one client per command (the guard is on by default via its built-in config, so wiring is all that remains):
|
|
381
381
|
|
|
382
382
|
```bash
|
|
383
|
-
npm i -g agents-gitflow-guard@0.0.
|
|
383
|
+
npm i -g agents-gitflow-guard@0.0.21 # provides the `gitflow-guard` binary
|
|
384
384
|
gitflow-guard wire --client claude --project --yes
|
|
385
385
|
gitflow-guard wire --client codex --project --yes
|
|
386
386
|
gitflow-guard wire --client opencode --project --yes
|
|
@@ -440,7 +440,7 @@ hooks:
|
|
|
440
440
|
Pi loads extensions in-process (no stdin payload, no subprocess hook). Install the shipped entry point into the project and keep the package in devDependencies:
|
|
441
441
|
|
|
442
442
|
```bash
|
|
443
|
-
npm i -D agents-gitflow-guard@0.0.
|
|
443
|
+
npm i -D agents-gitflow-guard@0.0.21
|
|
444
444
|
mkdir -p .pi/extensions
|
|
445
445
|
cp node_modules/agents-gitflow-guard/pi/gitflow-guard.ts .pi/extensions/gitflow-guard.ts
|
|
446
446
|
```
|
|
@@ -535,7 +535,7 @@ If it saves your team from a shortcut gone wrong, the coffee button at the top o
|
|
|
535
535
|
| **integration** | the core role (built-in default: `develop`); features merge in via PR/MR; protected |
|
|
536
536
|
| **preview** | optional env-endpoint branches (`branches.preview`, array); updates via PR/MR only |
|
|
537
537
|
| **production** | optional production branches (`branches.production`, array); PR/MR + merge by user only |
|
|
538
|
-
| **archive** | optional post-release archive branch (`branches.archive
|
|
538
|
+
| **archive** | optional post-release archive branch (`branches.archive`, array); agents may create PR/MRs into it, but the merge stays user-hand only |
|
|
539
539
|
| **feature branch** | your working branch, matched by `featurePattern`; free zone |
|
|
540
540
|
| **gate matrix** | the decision table mapping each classified command to allow/deny |
|
|
541
541
|
| **pre-execute** | the tool-pipeline hook where denial happens — before the command runs |
|
package/README.zh.md
CHANGED
|
@@ -39,17 +39,17 @@
|
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
41
|
# DSH —— 进程内插件(装完重启 DSH; 插件在进程启动时加载)
|
|
42
|
-
dsh plugin --profile web add agents-gitflow-guard@0.0.
|
|
42
|
+
dsh plugin --profile web add agents-gitflow-guard@0.0.21
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
```bash
|
|
46
46
|
# Claude Code · Codex · OpenCode · Antigravity —— 独立 hook,不需要 DSH
|
|
47
|
-
npm i -g agents-gitflow-guard@0.0.
|
|
47
|
+
npm i -g agents-gitflow-guard@0.0.21
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
51
|
# Pi —— 进程内扩展
|
|
52
|
-
npm i -D agents-gitflow-guard@0.0.
|
|
52
|
+
npm i -D agents-gitflow-guard@0.0.21
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
> **版本坑**: 裸 `add` 或不带版本的 `npm i` 装的是安装时刻的 `latest`——在 npm/pnpm 注册表缓存或镜像陈旧的机器上可能拿到旧版本。看到版本不对就锁版本。(DSH 用户: pnpm 打印的 peer 依赖 *警告* 属预期——DSH 启动时经共享模块回退提供 `@deepseek-ai/cordis` / `@deepseek-ai/dsh-tools`,插件正常工作。)
|
|
@@ -115,7 +115,9 @@ AI 编码 agent 在你的仓库里工作。它通过系统提示词、项目智
|
|
|
115
115
|
|
|
116
116
|
**这是软规则。** Agent 会跳过、重排、干脆"忘记"它——不是因为恶意,而是因为软指令对模型来说本来就是可选的。
|
|
117
117
|
|
|
118
|
-
这个插件把软规则变成**硬机制**。agent 每次尝试的 git
|
|
118
|
+
这个插件把软规则变成**硬机制**。agent 每次尝试的 git 操作都会对照*本地仓库的真实状态*检查;违规在命令执行前就被拦截,并给出原因和下一步。
|
|
119
|
+
|
|
120
|
+
没人需要记得规则——规则被强制执行。
|
|
119
121
|
|
|
120
122
|
---
|
|
121
123
|
|
|
@@ -352,14 +354,14 @@ PR/MR 目标通过 `gh pr view`(GitHub)或 `glab mr view`(GitLab)解析;没有
|
|
|
352
354
|
|
|
353
355
|
| 客户端 | 安装命令 | 装完再做什么 |
|
|
354
356
|
|---|---|---|
|
|
355
|
-
| DSH | `dsh plugin --profile web add agents-gitflow-guard@0.0.
|
|
356
|
-
| Claude Code · Codex · OpenCode · Antigravity | `npm i -g agents-gitflow-guard@0.0.
|
|
357
|
-
| Pi | `npm i -D agents-gitflow-guard@0.0.
|
|
357
|
+
| DSH | `dsh plugin --profile web add agents-gitflow-guard@0.0.21` | 重启 DSH——插件自动挂为 profile 层 |
|
|
358
|
+
| Claude Code · Codex · OpenCode · Antigravity | `npm i -g agents-gitflow-guard@0.0.21` | `gitflow-guard wire --client <名>`——每个客户端一条命令(见下) |
|
|
359
|
+
| Pi | `npm i -D agents-gitflow-guard@0.0.21` | 把 `pi/gitflow-guard.ts` 拷进 `.pi/extensions/`(见下) |
|
|
358
360
|
|
|
359
361
|
**DSH —— 进程内插件**(标准路径,已在[快速开始](#快速开始30-秒用上)覆盖):
|
|
360
362
|
|
|
361
363
|
```bash
|
|
362
|
-
dsh plugin --profile web add agents-gitflow-guard@0.0.
|
|
364
|
+
dsh plugin --profile web add agents-gitflow-guard@0.0.21 # 建议锁版本, 见上文提示
|
|
363
365
|
```
|
|
364
366
|
|
|
365
367
|
然后重启 DSH。升级用同一命令,再重启一次。
|
|
@@ -376,7 +378,7 @@ dsh plugin --profile web add file:/path/to/agents-gitflow-guard
|
|
|
376
378
|
**各 agent 独立 hook**——Claude Code / Codex / OpenCode / Antigravity,不依赖 DSH。全局装一次 CLI,然后**每客户端一条命令接线**(守卫凭内置默认配置已默认开启,接线是唯一剩下的事):
|
|
377
379
|
|
|
378
380
|
```bash
|
|
379
|
-
npm i -g agents-gitflow-guard@0.0.
|
|
381
|
+
npm i -g agents-gitflow-guard@0.0.21 # 提供 `gitflow-guard` 二进制
|
|
380
382
|
gitflow-guard wire --client claude --project --yes
|
|
381
383
|
gitflow-guard wire --client codex --project --yes
|
|
382
384
|
gitflow-guard wire --client opencode --project --yes
|
|
@@ -436,7 +438,7 @@ hooks:
|
|
|
436
438
|
Pi 以进程内扩展装载(没有 stdin payload,也没有子进程 hook)。把随包发布的入口装进项目、包留在 devDependencies:
|
|
437
439
|
|
|
438
440
|
```bash
|
|
439
|
-
npm i -D agents-gitflow-guard@0.0.
|
|
441
|
+
npm i -D agents-gitflow-guard@0.0.21
|
|
440
442
|
mkdir -p .pi/extensions
|
|
441
443
|
cp node_modules/agents-gitflow-guard/pi/gitflow-guard.ts .pi/extensions/gitflow-guard.ts
|
|
442
444
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agents-gitflow-guard",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "A configurable branch-role guard for AI coding agents (DSH / Claude Code / Codex / OpenCode / Antigravity / Pi) — zero-config defaults (develop+main) out of the box, deep-merge override, and per-client native hooks via gitflow-guard wire/setup; integration/preview/production/archive, each with its own update rules",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|