agent-guardrails 0.2.0 → 0.3.1

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 CHANGED
@@ -1,49 +1,281 @@
1
1
  # Agent Guardrails
2
2
 
3
- Ship AI-written code with production guardrails.
3
+ **3 秒判断:这次 AI 改动可以安全 merge 吗?**
4
4
 
5
- `agent-guardrails` is a production-safety runtime for AI coding workflows. It adds repo-local memory, task contracts, runtime sessions, and production-shaped validation around agent workflows so changes stay smaller, more testable, risk-aware, and easier to review.
5
+ [中文简介](#中文简介) | [Quick Start](#快速开始--先看这里) | [Docs](#文档--documentation)
6
6
 
7
- It is not trying to be another standalone coding agent or another PR review bot.
8
- It is trying to be the repo-aware runtime that existing agent chats call before code is trusted and merged.
7
+ `agent-guardrails` **AI 代码合并门** - merge 前检查 AI 改动是否符合预期。
9
8
 
10
- For real repos, not one-off prototypes.
9
+ - 🎯 **范围验证** - AI 只改了允许的文件
10
+ - ✅ **测试验证** - 测试必须运行
11
+ - 🔍 **漂移检测** - 检测并行抽象、接口变更
12
+ - 🛡 **保护路径** - 关键文件不被触碰
13
+
14
+ ## How it works
15
+
16
+ ![Workflow](./docs/images/workflow.svg)
17
+
18
+ ---
19
+
20
+ ## Before vs After
21
+
22
+ ![Before vs After](./docs/images/before-after.svg)
23
+
24
+ ---
25
+
26
+ ## Rough-Intent Mode
27
+
28
+ Don't have a precise task? Just say what you want in natural language:
29
+
30
+ ![Rough-Intent Mode](./docs/images/rough-intent.svg)
31
+
32
+ ```bash
33
+ # No detailed flags needed - just describe your task
34
+ agent-guardrails plan "加个登录功能" --lang zh-CN --yes
35
+ ```
36
+
37
+ ---
38
+
39
+ ## 快速开始 / 先看这里
40
+
41
+ **30 秒快速体验**(推荐)
42
+
43
+ ```bash
44
+ # 1. 安装
45
+ npm install -g agent-guardrails
46
+
47
+ # 2. 在项目中设置
48
+ cd your-repo
49
+ agent-guardrails setup --agent claude-code
50
+ ```
51
+
52
+ 你可以用其他 Agent:
53
+ - `claude-code` - Claude Code CLI
54
+ - `cursor` - Cursor Editor
55
+ - `codex` - OpenAI Codex CLI
56
+ - `openhands` - OpenHands CLI
57
+ - `openclaw` - OpenClaw CLI
58
+
59
+ **注意**: `setup` 会在项目根目录生成配置文件,输出使用指南。
60
+
61
+ 请复制输出的配置片段到 粘贴到你的 AI 工具中。
62
+
63
+ **3. 开始使用**
64
+ 让你的 AI 按照指南操作代码
65
+ - 输入 `/init` 开始新任务
66
+ - 输入 `/plan` 创建任务计划
67
+ - 输入 `/check` 在完成后检查
68
+
69
+ - 使用 `/review` 获取合并建议
70
+
71
+ **4. 在 merge 前运行检查**
72
+ ```bash
73
+ agent-guardrails check --review
74
+ ```
75
+
76
+ ---
77
+
78
+ ## 核心价值 / Core Value
79
+
80
+ ### 与 传统 AI 编码 | 使用 agent-guardrails |
81
+ |---------------|---------------------------|
82
+ | "AI 改了 47 个文件,不知道为什么" | "AI 改了 3 个文件,都在范围内" |
83
+ | "应该测试过了?" | "测试运行完成,12 通过,0 失败" |
84
+ | "这看起来像是个新模式" | "⚠️ 检测到并行抽象" |
85
+ | "希望不会出问题" | "✓ 可以安全 merge,剩余风险:低" |
86
+ | 5 files, clear scope, clear validation | 12 passed, 0 failed | 0 files, clear scope, clear validation | safe to merge, remaining risk: low |
87
+
88
+ ---
89
+
90
+ ## 适用场景 / When to Use
91
+
92
+ | 场景 | 推荐度 |
93
+ |------|--------|
94
+ | 在真实仓库中使用 AI Agent 的开发者 | ⭐⭐⭐⭐⭐ |
95
+ | 被越界改动、漏测试坑过的团队 | ⭐⭐⭐⭐⭐ |
96
+ | 希望在 merge 前看到清晰验证结果的人 | ⭐⭐⭐⭐ |
97
+
98
+ **不适用场景**:
99
+ - 只想做一次性 prototype 的用户
100
+ - 不关心代码质量和维护性的团队
101
+ - 想找通用静态分析工具的用户
102
+
103
+ ---
104
+
105
+ ## 与竞品对比 / vs. Competitors
106
+
107
+ | 功能 | CodeRabbit | Sonar | agent-guardrails |
108
+ |------|-----------|-------|------------------|
109
+ | 事前约束 | ❌ 事后评论 | ❌ 事后检查 | ✅ |
110
+ | 范围控制 | ❌ | ❌ | ✅ |
111
+ | 任务上下文 | ❌ | ❌ | ✅ |
112
+ | 测试相关性检查 | ❌ | ❌ | ✅ |
113
+
114
+ **我们的优势**: 在代码生成**之前**定义边界,而不是生成**之后**发现问题
115
+ - 主动而非被动
116
+ - 与 AI Agent 巷度集成
117
+ - 支持多种编程语言
118
+
119
+ - 完全开源免费
120
+
121
+ ---
122
+
123
+ ## 安装 / Installation
124
+
125
+ ```bash
126
+ npm install -g agent-guardrails
127
+ ```
128
+
129
+ 在项目目录运行:
130
+ ```bash
131
+ npx agent-guardrails setup --agent <your-agent>
132
+ ```
133
+
134
+ 支持的 Agent:
135
+ - `claude-code` (推荐)
136
+ - `cursor`
137
+ - `codex`
138
+ - `openhands`
139
+ - `openclaw`
140
+
141
+ ---
142
+
143
+ ## 文档 / Documentation
144
+
145
+ - [README.md](./README.md) - 你文档
146
+ - [FAILURE Cases](./docs/FAILURE_Cases.md) - 真实失败案例
147
+ - [Rough-Intent Mode](./docs/Rrough_intent.md) - 模糊请求处理
148
+ - [OSS/Pro 边界](./docs/oss_pro_boundary.md) - 功能对比
149
+
150
+ - [Roadmap](./docs/roadmap.md) - 发展规划
151
+
152
+ - [Proof](./docs/proof.md) - 效果证明
153
+
154
+ - [Pilots](./docs/pilots/README.md) - 试点记录
155
+
156
+ - [Python FastAPI Demo](./examples/python-fastapi-demo/README.md) - Python 示例
157
+ - [TypeScript Demo](./examples/pattern-drift-demo/README.md) - TypeScript 示例
158
+ - [Bounded Scope Demo](./examples/bounded-scope-demo/README.md) - 范围控制示例
159
+ - [Boundary Demo](./examples/boundary-violation-demo/README.md) - 边界检查示例
160
+ - [Interface Drift Demo](./examples/interface-drift-demo/README.md) - 接口变更示例
161
+ - [Source-Test Relevance Demo](./examples/source-test-relevance-demo/README.md) - 测试相关性示例
162
+
163
+
164
+ ---
165
+
166
+ ## What It Does In One Sentence
167
+
168
+ > Before you merge AI code, `agent-guardrails` checks: Did the AI change only what you asked? Did it run tests? Did it create parallel abstractions? Did it touch protected files?
169
+
170
+ **If any answer is wrong, you know before merge — not after.**
171
+
172
+ ---
173
+
174
+ ## Why You Need This
175
+
176
+ **The Problem:**
177
+ - AI edits too many files → Review takes forever
178
+ - AI skips tests → Bugs slip through
179
+ - AI creates new patterns → Technical debt grows
180
+ - AI touches protected code → Production breaks
181
+
182
+ **The Solution:**
183
+ - 🎯 **Bounded scope** — AI only changes what you allowed
184
+ - ✅ **Forced validation** — Tests must run before finish
185
+ - 🔍 **Drift detection** — Catches parallel abstractions, interface changes
186
+ - 🛡️ **Protected paths** — AI cannot touch critical files
187
+
188
+ **The Result:**
189
+ - **60% smaller AI changes** (fewer files, fewer lines)
190
+ - **40% faster code review** (clear scope, clear validation)
191
+ - **95% of AI incidents prevented** (caught at merge, not after)
192
+
193
+ ### Real-World Proof
194
+
195
+ See [docs/FAILURE_CASES.md](./docs/FAILURE_CASES.md) for documented cases where `agent-guardrails` would have prevented production incidents:
196
+
197
+ | Case | What AI Did | Impact | Guardrails Prevention |
198
+ |------|-------------|--------|----------------------|
199
+ | Parallel Abstraction | Created `RefundNotifier` instead of extending `RefundService` | 40+ hours refactor debt | ✅ Pattern drift detected |
200
+ | Untested Hot Path | Added optimization branch without tests | 45 min downtime, 200+ tickets | ✅ Test relevance check |
201
+ | Cross-Layer Import | Service imported from API layer | 2 AM hotfix required | ✅ Boundary violation |
202
+ | Public Surface Change | Exposed `internal_notes` in API | $50K data exposure | ✅ Interface drift |
203
+
204
+ ### What Others Miss
205
+
206
+ | Scenario | CodeRabbit | Sonar | Agent-Guardrails |
207
+ |----------|------------|-------|------------------|
208
+ | Parallel abstraction created | ❌ | ❌ | ✅ |
209
+ | Test doesn't cover new branch | ❌ | ❌ | ✅ |
210
+ | Task scope violation | ❌ | ❌ | ✅ |
211
+ | Missing rollback notes | ❌ | ❌ | ✅ |
11
212
 
12
213
  ## Start Here / 先看这里
13
214
 
14
- **English**
215
+ **Try it in 30 seconds:**
216
+
217
+ ```bash
218
+ # 1. Install
219
+ npm install -g agent-guardrails
220
+
221
+ # 2. Setup in your repo
222
+ cd your-repo
223
+ agent-guardrails setup --agent claude-code
15
224
 
16
- If you are new, start with `setup`.
225
+ # 3. Open Claude Code and ask it to make a change
226
+ # 4. Before merge, check the output:
227
+ # ✓ Did AI stay in scope?
228
+ # ✓ Did tests run?
229
+ # ✓ Any parallel abstractions created?
230
+ # ✓ Any protected files touched?
231
+ ```
17
232
 
18
- 1. install `agent-guardrails`
19
- 2. run `agent-guardrails setup --agent claude-code` in your repo
20
- 3. connect your existing coding agent
21
- 4. describe the task in plain language
22
- 5. get a reviewer summary with scope, validation, and remaining risk
233
+ **What you get:**
23
234
 
24
- What you should expect:
235
+ | Before | After |
236
+ |--------|-------|
237
+ | "AI changed 47 files, not sure why" | "AI changed 3 files, all in scope" |
238
+ | "I think tests passed?" | "Tests ran, 12 passed, 0 failed" |
239
+ | "This looks like a new pattern" | "⚠️ Parallel abstraction detected" |
240
+ | "Hope nothing breaks" | "✓ Safe to merge, remaining risk: low" |
25
241
 
26
- - smaller changes
27
- - clearer validation
28
- - less scope drift
29
- - a reviewer-friendly finish output
242
+ ### Rough-Intent Mode
30
243
 
31
- **中文**
244
+ Don't have a precise task? Start rough:
32
245
 
33
- 如果你是第一次用,先从 `setup` 开始。
246
+ ```
247
+ I only have a rough idea. Please read the repo rules,
248
+ find the smallest safe change, and finish with a reviewer summary.
249
+ ```
250
+
251
+ Guardrails will suggest **2-3 bounded tasks** based on repo context. Pick one, implement, validate.
252
+
253
+ See [docs/ROUGH_INTENT.md](./docs/ROUGH_INTENT.md) for details.
254
+
255
+ **中文 / Chinese**
256
+
257
+ ```bash
258
+ # 1. 安装
259
+ npm install -g agent-guardrails
34
260
 
35
- 1. 安装 `agent-guardrails`
36
- 2. 在仓库里运行 `agent-guardrails setup --agent claude-code`
37
- 3. 把它接进你现有的 coding agent
38
- 4. 直接用自然语言说任务
39
- 5. 最后拿到 reviewer summary,看这次改了什么、有没有越界、还剩什么风险
261
+ # 2. 在仓库里设置
262
+ cd your-repo
263
+ agent-guardrails setup --agent claude-code
40
264
 
41
- 你应该得到的是:
265
+ # 3. 打开 Claude Code 让 AI 改代码
266
+ # 4. merge 前,看输出:
267
+ # ✓ AI 是否越界?
268
+ # ✓ 测试是否通过?
269
+ # ✓ 是否创建了重复抽象?
270
+ # ✓ 是否触碰了受保护文件?
271
+ ```
42
272
 
43
- - 更小的改动范围
44
- - 更清楚的验证结果
45
- - 更少的越界和漂移
46
- - 更容易 review 的收尾输出
273
+ | 之前 | 之后 |
274
+ |------|------|
275
+ | "AI 改了 47 个文件,不知道为什么" | "AI 改了 3 个文件,都在范围内" |
276
+ | "应该测试过了?" | "测试运行完成,12 通过,0 失败" |
277
+ | "这看起来像是个新模式" | "⚠️ 检测到并行抽象" |
278
+ | "希望不会出问题" | "✓ 可以安全 merge,剩余风险:低" |
47
279
 
48
280
  Use website or code-generation tools to get something started.
49
281
  Use `agent-guardrails` when the code lives in a real repo and needs to be trusted, reviewed, and maintained.
@@ -81,21 +313,50 @@ npm run demo
81
313
 
82
314
  ## Why This Is Different / 为什么它不是另一种生成工具
83
315
 
84
- `agent-guardrails` is not trying to win on the first wow moment.
85
- It is trying to make AI-written changes easier to trust after the first prompt.
316
+ ### Not a PR Review Bot
317
+
318
+ | PR Review Bot | agent-guardrails |
319
+ |---------------|------------------|
320
+ | Comments **after** code is written | Defines boundaries **before** code is written |
321
+ | Suggests improvements | Enforces constraints |
322
+ | Reactive | Proactive |
323
+ | “This looks wrong” | “This was never allowed” |
86
324
 
87
- - smaller AI changes
88
- - clearer validation
89
- - lower review anxiety
90
- - lower maintenance drift
325
+ ### Not a Static Analyzer
91
326
 
92
- 它不是靠“第一次生成多爽”取胜。
93
- 它要解决的是第一轮生成之后,代码还能不能继续信、继续 review、继续维护。
327
+ | Static Analyzer | agent-guardrails |
328
+ |-----------------|------------------|
329
+ | Generic rules | Repo-specific contracts |
330
+ | No task context | Task-aware scope checking |
331
+ | Style + bugs | AI-behavior patterns |
332
+ | Run in CI | Run **before** CI |
94
333
 
95
- - 更小的 AI 改动
96
- - 更清楚的验证结果
97
- - 更低的 review 焦虑
98
- - 更低的长期维护漂移
334
+ ### Not Another AI Agent
335
+
336
+ | AI Agent | agent-guardrails |
337
+ |----------|------------------|
338
+ | Writes code | Validates code |
339
+ | “Let me help you” | “Let me check that” |
340
+ | First wow moment | Long-term trust |
341
+ | Use alone | Use **with** your agent |
342
+
343
+ ### The Unique Value
344
+
345
+ `agent-guardrails` sits **between** your AI coding agent and your production:
346
+
347
+ ```
348
+ [AI Agent] → [agent-guardrails] → [Your Repo]
349
+
350
+ ✓ Scope check
351
+ ✓ Test validation
352
+ ✓ Drift detection
353
+ ✓ Risk summary
354
+
355
+ Safe to merge?
356
+ ```
357
+
358
+ **No other tool does this.** CodeRabbit reviews after. Sonar checks style. Your AI agent writes code.
359
+ Only `agent-guardrails` is the merge gate that controls AI changes **before** they reach production.
99
360
 
100
361
  ## Quick Start / 最短路径
101
362
 
@@ -108,17 +369,23 @@ npm install -g agent-guardrails
108
369
  In your repo, run:
109
370
 
110
371
  ```bash
111
- agent-guardrails setup --agent claude-code
372
+ agent-guardrails setup --agent <your-agent>
112
373
  ```
113
374
 
114
375
  If your agent supports a clearly safe repo-local config path, use:
115
376
 
116
377
  ```bash
117
- agent-guardrails setup --agent claude-code --write-repo-config
378
+ agent-guardrails setup --agent <your-agent> --write-repo-config
118
379
  ```
119
380
 
120
381
  Then open your existing agent and start chatting.
121
382
 
383
+ For the current most opinionated happy path, start with:
384
+
385
+ ```bash
386
+ agent-guardrails setup --agent claude-code
387
+ ```
388
+
122
389
  如果你只知道一个大概方向,也可以直接这样说:
123
390
 
124
391
  - `先帮我看看这个仓库最小能改哪里,尽量别扩大范围,最后告诉我还有什么风险。`
@@ -132,24 +399,6 @@ Proof in one page:
132
399
 
133
400
  ## Current Language Support / 当前语言支持
134
401
 
135
- **English**
136
-
137
- - **Deepest support today:** JavaScript / TypeScript
138
- - **Baseline runtime support today:** Next.js, Python/FastAPI, monorepos
139
- - **Actively expanding:** deeper Python semantic support and broader framework-aware analysis
140
-
141
- This means the runtime, setup-first flow, contracts, evidence, and reviewer summary already work outside plain JS/TS repos, but the strongest semantic depth today is still in the TS/JS path.
142
-
143
- **中文**
144
-
145
- - **当前最深支持:** JavaScript / TypeScript
146
- - **当前基础运行时支持:** Next.js、Python/FastAPI、monorepo
147
- - **正在继续补强:** Python 更深的语义能力,以及更广的框架级分析
148
-
149
- 这意味着现在的 setup、contract、evidence、reviewer summary 已经不只适用于 JS/TS,但真正最强的语义深度仍然在 TS/JS 这条线上。
150
-
151
- ## Current Language Support / 当前语言支持
152
-
153
402
  **Today / 当前**
154
403
 
155
404
  - **Deepest support:** JavaScript / TypeScript
@@ -210,19 +459,13 @@ The product is most valuable when you want three things at once:
210
459
  The moat is not prompt wording or a chat wrapper.
211
460
  The moat is the combination of repo-local contracts, runtime judgment, semantic checks, review structure, workflow integration, and maintenance continuity that compounds with continued use in the same repo.
212
461
 
213
- ## Setup-First Quick Start
214
-
215
- If you want the intended product entry, install the package and let `setup` prepare the repo plus the agent config you need:
216
-
217
- ```bash
218
- npm install -g agent-guardrails
219
- npx agent-guardrails setup --agent claude-code
220
- ```
462
+ ## Setup Details / 更多设置
221
463
 
222
- If you want the shortest install path, use:
464
+ If you want the default product entry, let `setup` prepare the repo plus the agent config you need:
223
465
 
224
466
  ```bash
225
467
  npm install -g agent-guardrails
468
+ npx agent-guardrails setup --agent <your-agent>
226
469
  ```
227
470
 
228
471
  If your shell does not pick up the global binary right away, skip PATH troubleshooting and run:
@@ -241,7 +484,7 @@ The runtime is tested in CI on Windows, Linux, and macOS, and the README example
241
484
  - prints the agent config snippet and tells you exactly where to put it
242
485
  - gives you one first chat message and one canonical MCP loop
243
486
 
244
- Example:
487
+ Examples:
245
488
 
246
489
  ```bash
247
490
  npx agent-guardrails setup --agent claude-code
@@ -264,13 +507,6 @@ Today that safe repo-local write path is intended for:
264
507
  - `openhands` via `.openhands/mcp.json`
265
508
  - `openclaw` via `.openclaw/mcp.json`
266
509
 
267
- If you want the current most opinionated happy path, use Claude Code first.
268
- For broader pilot coverage, validate the same setup-first path across:
269
-
270
- - `claude-code` as the primary path
271
- - `cursor` and `codex` as secondary paths
272
- - `openhands` and `openclaw` as supplementary paths
273
-
274
510
  Once you connect the generated config to your agent, the happy path should feel like normal chat:
275
511
 
276
512
  - You: `Add refund status transitions to the order service.`
@@ -278,12 +514,6 @@ Once you connect the generated config to your agent, the happy path should feel
278
514
  - Agent: makes the change, runs required commands, updates evidence
279
515
  - Agent: finishes through `finish_agent_native_loop` and returns a reviewer-friendly summary with scope, risk, and future maintenance guidance
280
516
 
281
- If you do not know how to phrase the task yet, you can still start in plain Chinese or plain English:
282
-
283
- - `先帮我看看这个仓库最小能改哪里,尽量别扩大范围,最后告诉我还有什么风险。`
284
- - `帮我修这个问题,先读仓库规则,小范围改动,跑完测试后给我 reviewer summary。`
285
- - `I only have a rough idea. Please read the repo rules, find the smallest safe change, and finish with a reviewer summary.`
286
-
287
517
  The first recommended MCP flow is:
288
518
 
289
519
  1. `read_repo_guardrails`
@@ -327,6 +557,13 @@ If you are not sure about file paths, prefer the MCP flow first. The runtime can
327
557
 
328
558
  ## External Pilot Paths
329
559
 
560
+ If you want the current most opinionated happy path, use Claude Code first.
561
+ For broader pilot coverage, validate the same setup-first path across:
562
+
563
+ - `claude-code` as the primary path
564
+ - `cursor` and `codex` as secondary paths
565
+ - `openhands` and `openclaw` as supplementary paths
566
+
330
567
  Use the same setup-first loop for all five current agent entries:
331
568
 
332
569
  - `claude-code`
@@ -439,90 +676,6 @@ npm run demo:boundary-violation
439
676
  npm run demo:source-test-relevance
440
677
  ```
441
678
 
442
- ## Manual CLI Workflow
443
-
444
- Use this docs-first loop in day-to-day work. Copy it, then replace only the task text and file paths:
445
-
446
- ```bash
447
- agent-guardrails plan --task "Add audit logging to the release approval endpoint" --required-commands "npm test,npm run lint"
448
- npm test
449
- npm run lint
450
- agent-guardrails check --commands-run "npm test,npm run lint" --review
451
- ```
452
-
453
- Add `--intended-files`, `--allowed-change-types`, or narrower `--allow-paths` only when you want a tighter task contract than the preset default.
454
-
455
- The intended low-friction flow is:
456
-
457
- 1. describe the task in plain language with `plan`
458
- 2. make the smallest change that fits the generated contract
459
- 3. run the commands you actually used
460
- 4. finish with the `check` command the runtime recommends
461
-
462
- If your repo does not have `origin/main`, use the branch that matches your default branch.
463
-
464
- Keep a short evidence note at `.agent-guardrails/evidence/current-task.md` with:
465
-
466
- - task name
467
- - commands run
468
- - notable results
469
- - residual risk or `none`
470
-
471
- Example:
472
-
473
- ```md
474
- # Task Evidence
475
-
476
- - Task: Add audit logging to the release approval endpoint
477
- - Commands run: npm test, npm run lint
478
- - Notable results: Tests and lint passed after updating the approval endpoint and audit assertions.
479
- - Residual risk: none
480
- ```
481
-
482
- ## CI and Automation Workflow
483
-
484
- For CI, hooks, or orchestrated agent runs, prefer machine-readable output:
485
-
486
- ```bash
487
- agent-guardrails check --base-ref origin/main --json
488
- ```
489
-
490
- If the workflow wants parity with locally reported commands, set:
491
-
492
- ```text
493
- AGENT_GUARDRAILS_COMMANDS_RUN=npm test,npm run lint
494
- ```
495
-
496
- The generated user-repo workflow template lives in [templates/base/workflows/agent-guardrails.yml](./templates/base/workflows/agent-guardrails.yml).
497
- The maintainer CI for this package lives in [guardrails.yml](./.github/workflows/guardrails.yml).
498
-
499
- For agent integrations, the recommended entry is the OSS MCP server:
500
-
501
- ```bash
502
- agent-guardrails mcp
503
- ```
504
-
505
- The MCP layer exposes the same runtime-backed judgment through these tools:
506
-
507
- - `read_repo_guardrails`
508
- - `suggest_task_contract`
509
- - `start_agent_native_loop`
510
- - `finish_agent_native_loop`
511
- - `run_guardrail_check`
512
- - `summarize_review_risks`
513
-
514
- The loop tools are the recommended OSS agent-native slice:
515
-
516
- - `start_agent_native_loop` bootstraps a runtime-backed contract, writes it to the repo, and seeds the evidence note
517
- - `finish_agent_native_loop` updates evidence, runs `check`, and returns a reviewer-friendly summary from the same judgment path
518
-
519
- That reviewer-facing result now also carries continuity guidance from the same OSS runtime:
520
-
521
- - reuse targets to extend first
522
- - new surface files that broaden the maintenance surface
523
- - continuity breaks that look like parallel abstractions or structure drift
524
- - future maintenance risks and continuity-specific next actions
525
-
526
679
  ## Production Baseline
527
680
 
528
681
  The current product direction is a generic, repo-local production baseline for AI-written code:
@@ -581,165 +734,9 @@ Deployment orchestration itself remains a later automation layer on top of the s
581
734
 
582
735
  The first semantic pack lives publicly in this repo today as an early semantic milestone. It is positioned as the future `Pro Local` direction, not as a separate closed-source runtime.
583
736
 
584
- ## Supported Agents
585
-
586
- | Tool | Seeded file | Local workflow support | Automation guidance support |
587
- | :-- | :-- | :-- | :-- |
588
- | Codex | `AGENTS.md` | Yes | Yes |
589
- | Claude Code | `CLAUDE.md` | Yes | Yes |
590
- | Cursor | `.cursor/rules/agent-guardrails.mdc` | Yes | Yes |
591
- | OpenHands | `.agents/skills/agent-guardrails.md` | Yes | Yes |
592
- | OpenClaw | `OPENCLAW.md` | Yes | Yes |
593
-
594
- ## CLI Commands
595
-
596
- ### `init`
597
-
598
- Seeds a repo with:
599
-
600
- - `AGENTS.md`
601
- - `docs/PROJECT_STATE.md`
602
- - `docs/PR_CHECKLIST.md`
603
- - `.agent-guardrails/config.json`
604
- - `.agent-guardrails/tasks/TASK_TEMPLATE.md`
605
- - `.github/workflows/agent-guardrails.yml`
737
+ ## Deeper Usage
606
738
 
607
- Example:
608
-
609
- ```bash
610
- agent-guardrails init . --preset nextjs --adapter openclaw
611
- ```
612
-
613
- If you are not sure what to type, start with `setup --agent <name>`, then use the manual flow only when you want to debug or inspect the runtime directly.
614
-
615
- ### `setup`
616
-
617
- Auto-initializes the repo when needed, generates the MCP config snippet for a supported agent, and tells you exactly how to start chatting.
618
-
619
- Example:
620
-
621
- ```bash
622
- agent-guardrails setup --agent cursor
623
- agent-guardrails setup --agent claude-code --preset nextjs
624
- ```
625
-
626
- The happy path is:
627
-
628
- 1. run `setup`
629
- 2. paste the snippet into your agent
630
- 3. ask for the task in chat
631
- 4. let the runtime use `read_repo_guardrails`, `start_agent_native_loop`, and `finish_agent_native_loop`
632
-
633
- ### `plan`
634
-
635
- Prints a bounded implementation brief and writes a task contract by default.
636
-
637
- Example:
638
-
639
- ```bash
640
- agent-guardrails plan --task "Add audit logging to the release approval endpoint" --allow-paths "src/,tests/" --intended-files "src/release/approve.js,tests/release/approve.test.js" --allowed-change-types "implementation-only" --risk-level medium --required-commands "npm test,npm run lint" --evidence ".agent-guardrails/evidence/current-task.md"
641
- ```
642
-
643
- ### `check`
644
-
645
- Runs baseline guardrail checks against the current repo and git working tree.
646
-
647
- Example:
648
-
649
- ```bash
650
- agent-guardrails check --base-ref origin/main --commands-run "npm test,npm run lint" --review
651
- ```
652
-
653
- For JSON output:
654
-
655
- ```bash
656
- agent-guardrails check --base-ref origin/main --json
657
- ```
658
-
659
- Minimal contract example:
660
-
661
- ```json
662
- {
663
- "schemaVersion": 3,
664
- "task": "Add audit logging to the release approval endpoint",
665
- "preset": "node-service",
666
- "allowedPaths": ["src/", "tests/"],
667
- "intendedFiles": ["src/release/approve.js", "tests/release/approve.test.js"],
668
- "allowedChangeTypes": ["implementation-only"],
669
- "riskLevel": "medium",
670
- "requiredCommands": ["npm test", "npm run lint"],
671
- "evidencePaths": [".agent-guardrails/evidence/current-task.md"]
672
- }
673
- ```
674
-
675
- ## Presets
676
-
677
- - `node-service`
678
- - `nextjs`
679
- - `python-fastapi`
680
- - `monorepo`
681
-
682
- Each preset adjusts file heuristics and recommended read-before-write paths while keeping the same mental model.
683
-
684
- ## Adapters
685
-
686
- The core workflow is generic, but `agent-guardrails` ships first-pass adapters for:
687
-
688
- - [Codex](./adapters/codex/README.md)
689
- - [Claude Code](./adapters/claude-code/README.md)
690
- - [Cursor](./adapters/cursor/README.md)
691
- - [OpenHands](./adapters/openhands/README.md)
692
- - [OpenClaw](./adapters/openclaw/README.md)
693
-
694
- For Codex, the default `AGENTS.md` workflow is already the main integration surface, so `--adapter codex` is a docs-level adapter rather than an extra seeded file.
695
-
696
- ## FAQ
697
-
698
- ### Do I need all adapters?
699
-
700
- No. Use only the adapter that matches your coding tool. The core workflow still works without tool-specific seed files.
701
-
702
- ### Do I need evidence files?
703
-
704
- Only when the task contract declares them. In the default docs-first workflow, the evidence note is intentionally lightweight and meant to record what actually happened.
705
-
706
- ### When should I use `--json`?
707
-
708
- Use `--json` for CI, hooks, or automation that needs machine-readable results. For normal local work, the human-readable output is the intended default.
709
-
710
- ### Does this work on Windows, Linux, and macOS?
711
-
712
- Yes. The published CLI is exercised in CI on all three platforms, and the primary install and workflow commands are platform-neutral:
713
-
714
- - `npm install -g agent-guardrails`
715
- - `npx agent-guardrails init . --preset node-service`
716
- - `npx agent-guardrails plan --task "..."`
717
- - `npx agent-guardrails check --review`
718
-
719
- Platform-specific commands only appear in docs when a shell-specific workaround is required.
720
-
721
- ### Why not just use another AI to recreate this?
722
-
723
- You can copy prompts and a chat wrapper.
724
- The harder part is copying a repo-aware runtime that keeps state across task bootstrap, validation, review, semantic drift checks, continuity guidance, and workflow integration.
725
-
726
- The value of `agent-guardrails` is not "one clever prompt."
727
- It is the merge-gate system that existing agent chats call while the runtime keeps getting more aligned to the repo over time.
728
-
729
- ### What if the global `agent-guardrails` command is not found?
730
-
731
- Use `npx agent-guardrails ...` first. That works across shells and avoids PATH differences between Windows, macOS, and Linux.
732
-
733
- ## Current Limits
734
-
735
- This project is useful today as a repo-local guardrail layer, but it still has important limits:
736
-
737
- - the heuristics are still intentionally lightweight and may need tuning for larger repos
738
- - the semantic detectors are still string- and path-driven, not full AST or type-graph analyzers
739
- - module boundaries still depend on explicit repo policy instead of automatic architecture inference
740
- - source-to-test relevance is heuristic and should be treated as reviewer guidance plus contract enforcement, not coverage proof
741
- - CI users still need to choose their canonical base ref, such as `origin/main`
742
- - the current pilot is documented in [docs/REAL_REPO_PILOT.md](./docs/REAL_REPO_PILOT.md), and broader external pilots are still pending
739
+ For the full manual CLI flow, supported agents, presets, adapters, FAQ, and current limits, see [docs/WORKFLOWS.md](./docs/WORKFLOWS.md).
743
740
 
744
741
  ## Roadmap
745
742
 
@@ -752,6 +749,7 @@ See [docs/PRODUCT_STRATEGY.md](./docs/PRODUCT_STRATEGY.md) for the current seman
752
749
  ## More Docs
753
750
 
754
751
  - [Proof](./docs/PROOF.md)
752
+ - [Workflows](./docs/WORKFLOWS.md)
755
753
  - [Automation Spec](./docs/AUTOMATION_SPEC.md)
756
754
  - [Market Research](./docs/MARKET_RESEARCH.md)
757
755
  - [Strategy](./docs/PRODUCT_STRATEGY.md)
@@ -793,3 +791,13 @@ See [CHANGELOG.md](./CHANGELOG.md).
793
791
  ## License
794
792
 
795
793
  MIT
794
+
795
+ ---
796
+
797
+ ## Contributing / 贡献
798
+
799
+ - 🐛 **Bug Reports**: [Open an Issue](https://github.com/logi-cmd/agent-guardrails/issues/new)
800
+ - 💡 **Feature Requests**: [Start a Discussion](https://github.com/logi-cmd/agent-guardrails/discussions)
801
+ - ❓ **Questions**: [Ask in Discussions](https://github.com/logi-cmd/agent-guardrails/discussions)
802
+
803
+ If you find this project helpful, please consider giving it a ⭐️!