agents-gitflow-guard 0.0.17 → 0.0.18

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.
Files changed (3) hide show
  1. package/README.md +25 -11
  2. package/README.zh.md +25 -11
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -42,11 +42,13 @@ You define your own branches —
42
42
  # installs the latest release
43
43
  dsh plugin --profile web add agents-gitflow-guard
44
44
  # ...or pin an exact known-good version (recommended; also bypasses stale registry caches)
45
- dsh plugin --profile web add agents-gitflow-guard@0.0.17
45
+ dsh plugin --profile web add agents-gitflow-guard@0.0.18
46
46
  ```
47
47
 
48
48
  > **Version gotcha**: a bare `add` 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. The peer-dependency *warning* pnpm may print is expected: DSH supplies `@deepseek-ai/cordis` / `@deepseek-ai/dsh-tools` through its shared profile module fallback at startup (the plugin works normally).
49
49
 
50
+ Using another agent? The same npm package also serves Claude Code, Codex, OpenCode, Antigravity, and Pi — see the per-agent install table in [Installation in detail](#installation-in-detail).
51
+
50
52
  **Step 2 — configure**, create `gitflow-guard.config.json` in your **project root**:
51
53
 
52
54
  ```jsonc
@@ -307,12 +309,18 @@ The PR/MR target is resolved via `gh pr view` (GitHub) or `glab mr view` (GitLab
307
309
  ---
308
310
  ## Installation in detail
309
311
 
310
- **Prerequisite**: a working [DSH](https://github.com/deepseek-ai/deepseek-harness) installation and **Node.js ≥ 22** on your `PATH` (matches the package `engines` floor and the lowest CI matrix tier standalone hook users bypass npm but still need the runtime).
312
+ **Prerequisite**: **Node.js ≥ 22** on your `PATH` (the package `engines` floor and the lowest CI matrix tier). Every client consumes the **same npm package** `agents-gitflow-guard` only the mounting step differs.
313
+
314
+ | Agent | Install command | After that |
315
+ |---|---|---|
316
+ | DSH | `dsh plugin --profile web add agents-gitflow-guard@0.0.18` | restart DSH — the plugin auto-mounts as a profile layer |
317
+ | Claude Code · Codex · OpenCode · Antigravity | `npm i -g agents-gitflow-guard@0.0.18` | wire a hook to the `gitflow-guard` binary (below) |
318
+ | Pi | `npm i -D agents-gitflow-guard@0.0.18` | copy `pi/gitflow-guard.ts` into `.pi/extensions/` (below) |
311
319
 
312
- **From the npm registry** the standard path, already covered in [Quick Start](#quick-start--30-seconds-to-a-guarded-repo):
320
+ **DSH in-process plugin** (the standard path, already covered in [Quick Start](#quick-start--30-seconds-to-a-guarded-repo)):
313
321
 
314
322
  ```bash
315
- dsh plugin --profile web add agents-gitflow-guard@0.0.17 # pin recommended, see note above
323
+ dsh plugin --profile web add agents-gitflow-guard@0.0.18 # pin recommended, see note above
316
324
  ```
317
325
 
318
326
  Then restart DSH. Upgrades are the same command, followed by another restart.
@@ -326,14 +334,20 @@ dsh plugin --profile web add file:/path/to/agents-gitflow-guard
326
334
 
327
335
  The package declares `dsh.bundle.patch`, so `dsh plugin add` automatically makes it a profile layer — no manual profile editing.
328
336
 
329
- **Standalone agent hooks** — the same guard inside those agents, no DSH required. This repo ships project configs at `.claude/settings.json` (Claude Code), `.codex/hooks.json` (Codex), `.opencode/hook/hooks.yaml` (OpenCode), `.agents/hooks.json` (Antigravity / Google) and `.pi/settings.json` + `.pi/extensions/gitflow-guard.ts` (Pi); any other repo adds its own:
337
+ **Standalone agent hooks** — Claude Code / Codex / OpenCode / Antigravity, no DSH required. Install the CLI once, then reference the `gitflow-guard` binary in each hook config:
338
+
339
+ ```bash
340
+ npm i -g agents-gitflow-guard@0.0.18 # provides the `gitflow-guard` binary
341
+ ```
342
+
343
+ This repo ships project configs at `.claude/settings.json` (Claude Code), `.codex/hooks.json` (Codex), `.opencode/hook/hooks.yaml` (OpenCode) and `.agents/hooks.json` (Antigravity / Google); any other repo adds its own:
330
344
 
331
345
  ```jsonc
332
346
  // Claude Code — .claude/settings.json
333
347
  {
334
348
  "hooks": {
335
349
  "PreToolUse": [
336
- { "matcher": "Bash", "hooks": [{ "type": "command", "command": "/abs/path/gitflow-guard check --platform claude" }] }
350
+ { "matcher": "Bash", "hooks": [{ "type": "command", "command": "gitflow-guard check --platform claude" }] }
337
351
  ]
338
352
  }
339
353
  }
@@ -344,7 +358,7 @@ The package declares `dsh.bundle.patch`, so `dsh plugin add` automatically makes
344
358
  {
345
359
  "hooks": {
346
360
  "PreToolUse": [
347
- { "matcher": "^Bash$", "hooks": [{ "type": "command", "command": "node bin/gitflow-guard.mjs check --platform codex" }] }
361
+ { "matcher": "^Bash$", "hooks": [{ "type": "command", "command": "gitflow-guard check --platform codex" }] }
348
362
  ]
349
363
  }
350
364
  }
@@ -357,7 +371,7 @@ hooks:
357
371
  event: tool.before.bash
358
372
  actions:
359
373
  - bash: |
360
- node "$OPENCODE_PROJECT_DIR/bin/gitflow-guard.mjs" check --platform opencode
374
+ gitflow-guard check --platform opencode
361
375
  ```
362
376
 
363
377
  ```json
@@ -365,7 +379,7 @@ hooks:
365
379
  {
366
380
  "gitflow-guard": {
367
381
  "PreToolUse": [
368
- { "matcher": "run_command", "hooks": [ { "type": "command", "command": "node bin/gitflow-guard.mjs check --platform antigravity" } ] }
382
+ { "matcher": "run_command", "hooks": [ { "type": "command", "command": "gitflow-guard check --platform antigravity" } ] }
369
383
  ]
370
384
  }
371
385
  }
@@ -379,7 +393,7 @@ hooks:
379
393
  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:
380
394
 
381
395
  ```bash
382
- npm i -D agents-gitflow-guard
396
+ npm i -D agents-gitflow-guard@0.0.18
383
397
  mkdir -p .pi/extensions
384
398
  cp node_modules/agents-gitflow-guard/pi/gitflow-guard.ts .pi/extensions/gitflow-guard.ts
385
399
  ```
@@ -392,7 +406,7 @@ cp node_modules/agents-gitflow-guard/pi/gitflow-guard.ts .pi/extensions/gitflow-
392
406
 
393
407
  - The hook reads the payload on stdin and answers with that platform's protocol: Claude Code / OpenCode → `exit 2` (stderr is the reason + "next step" hint); Codex → JSON `{"hookSpecificOutput":{"permissionDecision":"deny",...}}` on stdout; Antigravity → JSON `{"decision":"deny","reason":...}` on stdout with `exit 0` (Antigravity requires exit 0 and rejects `hookSpecificOutput` / non-allow values). Pi has no stdin protocol: the in-process extension listens to the official `tool_call` event and denies via its return value `{ block: true, reason }` (the CLI subprocess only speaks the internal exit-2 contract).
394
408
  - Only the pre-tool event is needed: the guard blocks *before* the command runs. There is no permit to consume afterwards, so no post-tool hooks are required.
395
- - Use an **absolute path** to the binary hook subprocesses may not inherit your shell `PATH`. `${CLAUDE_PROJECT_DIR}/bin/gitflow-guard.mjs` (Claude Code), `node bin/gitflow-guard.mjs` (Codex, runs from the project working directory), or `$OPENCODE_PROJECT_DIR/bin/gitflow-guard.mjs` (OpenCode) or `node bin/gitflow-guard.mjs` (Antigravity, relative to the workspace `.agents/` dir) also work from a checkout.
409
+ - The examples above call the globally-installed `gitflow-guard` (`npm i -g`). If a hook subprocess can't see it on its `PATH`, point at the full binary path from `npm bin -g` hook subprocesses may not inherit your interactive shell `PATH`. The `bin/gitflow-guard.mjs` paths in this repo's shipped configs only work from a checkout.
396
410
  - Fully opt-in: the hook does nothing unless the repo has `gitflow-guard.config.json` with `enabled: true`.
397
411
 
398
412
  ---
package/README.zh.md CHANGED
@@ -41,11 +41,13 @@
41
41
  # 安装最新版
42
42
  dsh plugin --profile web add agents-gitflow-guard
43
43
  # ...或锁定已知良好版本(推荐; 同时绕开 registry 陈旧缓存)
44
- dsh plugin --profile web add agents-gitflow-guard@0.0.17
44
+ dsh plugin --profile web add agents-gitflow-guard@0.0.18
45
45
  ```
46
46
 
47
47
  > **版本坑**: 裸 `add` 装的是安装时刻的 `latest`——在 npm/pnpm 注册表缓存或镜像陈旧的机器上可能拿到旧版本。看到版本不对就锁版本。pnpm 打印的 peer 依赖 *警告* 属预期: DSH 启动时经共享模块回退提供 `@deepseek-ai/cordis` / `@deepseek-ai/dsh-tools`(插件正常工作)。
48
48
 
49
+ 用的是别的 agent? 同一个 npm 包也适用于 Claude Code / Codex / OpenCode / Antigravity / Pi——见[安装详解](#安装详解)的逐客户端安装表。
50
+
49
51
  **第 2 步——配置**,在**项目根目录**创建 `gitflow-guard.config.json`:
50
52
 
51
53
  ```jsonc
@@ -303,12 +305,18 @@ PR/MR 目标通过 `gh pr view`(GitHub)或 `glab mr view`(GitLab)解析;没有
303
305
  ---
304
306
  ## 安装详解
305
307
 
306
- **前置**:一个可用的 [DSH](https://github.com/deepseek-ai/deepseek-harness) 安装,且 `PATH` 上有 **Node.js ≥ 22**(与包 `engines` 及 CI 矩阵最低档一致——独立 hook 用户不经 npm 安装,同样需要运行时)。
308
+ **前置**:`PATH` 上有 **Node.js ≥ 22**(与包 `engines` 及 CI 矩阵最低档一致)。所有客户端都吃**同一个 npm 包** `agents-gitflow-guard`——只有挂载步骤不同。
309
+
310
+ | 客户端 | 安装命令 | 装完再做什么 |
311
+ |---|---|---|
312
+ | DSH | `dsh plugin --profile web add agents-gitflow-guard@0.0.18` | 重启 DSH——插件自动挂为 profile 层 |
313
+ | Claude Code · Codex · OpenCode · Antigravity | `npm i -g agents-gitflow-guard@0.0.18` | 在各自 hook 配置里指向 `gitflow-guard` 二进制(见下) |
314
+ | Pi | `npm i -D agents-gitflow-guard@0.0.18` | 把 `pi/gitflow-guard.ts` 拷进 `.pi/extensions/`(见下) |
307
315
 
308
- **从 npm registry**——标准路径,已在[快速开始](#快速开始30-秒用上)覆盖:
316
+ **DSH —— 进程内插件**(标准路径,已在[快速开始](#快速开始30-秒用上)覆盖):
309
317
 
310
318
  ```bash
311
- dsh plugin --profile web add agents-gitflow-guard@0.0.17 # 建议锁版本, 见上文提示
319
+ dsh plugin --profile web add agents-gitflow-guard@0.0.18 # 建议锁版本, 见上文提示
312
320
  ```
313
321
 
314
322
  然后重启 DSH。升级用同一命令,再重启一次。
@@ -322,14 +330,20 @@ dsh plugin --profile web add file:/path/to/agents-gitflow-guard
322
330
 
323
331
  包自带 `dsh.bundle.patch` 声明,`dsh plugin add` 自动把它挂为 profile 层,无需手工编辑 profile。
324
332
 
325
- **各 agent 独立 hook**——同一守卫也能在这些 agent 里跑,不依赖 DSH。本仓库已自带 `.claude/settings.json`(Claude Code)、`.codex/hooks.json`(Codex)、`.opencode/hook/hooks.yaml`(OpenCode)、`.agents/hooks.json`(Antigravity / Google)和 `.pi/settings.json` + `.pi/extensions/gitflow-guard.ts`(Pi);其他仓库加自己的 hooks:
333
+ **各 agent 独立 hook**——Claude Code / Codex / OpenCode / Antigravity,不依赖 DSH。全局装一次 CLI,然后引用 `gitflow-guard` 二进制:
334
+
335
+ ```bash
336
+ npm i -g agents-gitflow-guard@0.0.18 # 提供 `gitflow-guard` 二进制
337
+ ```
338
+
339
+ 本仓库已自带 `.claude/settings.json`(Claude Code)、`.codex/hooks.json`(Codex)、`.opencode/hook/hooks.yaml`(OpenCode)和 `.agents/hooks.json`(Antigravity / Google);其他仓库加自己的 hooks:
326
340
 
327
341
  ```jsonc
328
342
  // Claude Code — .claude/settings.json
329
343
  {
330
344
  "hooks": {
331
345
  "PreToolUse": [
332
- { "matcher": "Bash", "hooks": [{ "type": "command", "command": "/abs/path/gitflow-guard check --platform claude" }] }
346
+ { "matcher": "Bash", "hooks": [{ "type": "command", "command": "gitflow-guard check --platform claude" }] }
333
347
  ]
334
348
  }
335
349
  }
@@ -340,7 +354,7 @@ dsh plugin --profile web add file:/path/to/agents-gitflow-guard
340
354
  {
341
355
  "hooks": {
342
356
  "PreToolUse": [
343
- { "matcher": "^Bash$", "hooks": [{ "type": "command", "command": "node bin/gitflow-guard.mjs check --platform codex" }] }
357
+ { "matcher": "^Bash$", "hooks": [{ "type": "command", "command": "gitflow-guard check --platform codex" }] }
344
358
  ]
345
359
  }
346
360
  }
@@ -353,7 +367,7 @@ hooks:
353
367
  event: tool.before.bash
354
368
  actions:
355
369
  - bash: |
356
- node "$OPENCODE_PROJECT_DIR/bin/gitflow-guard.mjs" check --platform opencode
370
+ gitflow-guard check --platform opencode
357
371
  ```
358
372
 
359
373
  ```json
@@ -361,7 +375,7 @@ hooks:
361
375
  {
362
376
  "gitflow-guard": {
363
377
  "PreToolUse": [
364
- { "matcher": "run_command", "hooks": [ { "type": "command", "command": "node bin/gitflow-guard.mjs check --platform antigravity" } ] }
378
+ { "matcher": "run_command", "hooks": [ { "type": "command", "command": "gitflow-guard check --platform antigravity" } ] }
365
379
  ]
366
380
  }
367
381
  }
@@ -375,7 +389,7 @@ hooks:
375
389
  Pi 以进程内扩展装载(没有 stdin payload,也没有子进程 hook)。把随包发布的入口装进项目、包留在 devDependencies:
376
390
 
377
391
  ```bash
378
- npm i -D agents-gitflow-guard
392
+ npm i -D agents-gitflow-guard@0.0.18
379
393
  mkdir -p .pi/extensions
380
394
  cp node_modules/agents-gitflow-guard/pi/gitflow-guard.ts .pi/extensions/gitflow-guard.ts
381
395
  ```
@@ -388,7 +402,7 @@ cp node_modules/agents-gitflow-guard/pi/gitflow-guard.ts .pi/extensions/gitflow-
388
402
 
389
403
  - hook 读 stdin payload,按**各平台协议**作答:Claude Code / OpenCode → `exit 2`(stderr 展示原因 + "下一步"提示);Codex → stdout 输出 JSON `{"hookSpecificOutput":{"permissionDecision":"deny",...}}`;Antigravity → stdout 输出 `{"decision":"deny","reason":...}` 且 **exit 0**(Antigravity 要求 exit 0,拒绝 hookSpecificOutput/非 allow 值)。Pi 没有 stdin 协议:进程内扩展监听官方 `tool_call` 事件,经返回值 `{ block: true, reason }` 拒绝(守卫 CLI 子进程只承载内部 exit-2 契约)。
390
404
  - 只需要**执行前事件**:守卫在命令执行*之前*拦截;没有特许可事后消费,因此无需执行后钩子。
391
- - 用**绝对路径**指向二进制——hook 子进程不一定继承你的 shell PATH。Claude Code `${CLAUDE_PROJECT_DIR}/bin/gitflow-guard.mjs`,Codex `node bin/gitflow-guard.mjs`,OpenCode `$OPENCODE_PROJECT_DIR/bin/gitflow-guard.mjs`、Antigravity `node bin/gitflow-guard.mjs`(相对 workspace `.agents/` 目录)也可以。
405
+ - 上面示例调的是全局安装的 `gitflow-guard`(`npm i -g`)。若 hook 子进程在它的 `PATH` 里找不到,就指向 `npm bin -g` 给出的完整二进制路径——hook 子进程不一定继承你交互 shell 的 PATH。本仓库自带配置里的 `bin/gitflow-guard.mjs` 路径只对 checkout 贡献者有效。
392
406
  - 完全 opt-in:仓库没有 `gitflow-guard.config.json`(或 `enabled` 非 true)时 hook 什么都不做。
393
407
 
394
408
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-gitflow-guard",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "A configurable branch-role guard for AI coding agents (DSH / Claude Code / Codex / OpenCode / Antigravity / Pi) — integration/preview/production/archive, each with its own update rules",
5
5
  "license": "MIT",
6
6
  "type": "module",