agent-guardrails 0.1.0
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/LICENSE +21 -0
- package/README.md +335 -0
- package/adapters/README.md +18 -0
- package/adapters/claude-code/README.md +38 -0
- package/adapters/codex/README.md +39 -0
- package/adapters/cursor/README.md +38 -0
- package/adapters/openclaw/OPENCLAW.md +35 -0
- package/adapters/openclaw/README.md +41 -0
- package/adapters/openhands/README.md +38 -0
- package/bin/agent-guardrails.js +9 -0
- package/lib/benchmark/runner.js +272 -0
- package/lib/check/detectors/oss.js +374 -0
- package/lib/check/finding.js +30 -0
- package/lib/check/pipeline.js +25 -0
- package/lib/check/plugins.js +124 -0
- package/lib/check/policy.js +40 -0
- package/lib/check/review.js +39 -0
- package/lib/cli.js +86 -0
- package/lib/commands/check.js +506 -0
- package/lib/commands/init.js +140 -0
- package/lib/commands/plan.js +232 -0
- package/lib/i18n.js +362 -0
- package/lib/utils.js +359 -0
- package/package.json +55 -0
- package/templates/adapters/claude-code/CLAUDE.md +24 -0
- package/templates/adapters/cursor/agent-guardrails.mdc +13 -0
- package/templates/adapters/openclaw/OPENCLAW.md +34 -0
- package/templates/adapters/openhands/agent-guardrails.md +8 -0
- package/templates/base/AGENTS.md +31 -0
- package/templates/base/IMPLEMENT_PROMPT.md +21 -0
- package/templates/base/PROJECT_STATE.md +23 -0
- package/templates/base/PR_CHECKLIST.md +11 -0
- package/templates/base/TASK_TEMPLATE.md +31 -0
- package/templates/base/workflows/agent-guardrails.yml +33 -0
- package/templates/locales/zh-CN/adapters/claude-code/CLAUDE.md +24 -0
- package/templates/locales/zh-CN/adapters/cursor/agent-guardrails.mdc +13 -0
- package/templates/locales/zh-CN/adapters/openclaw/OPENCLAW.md +34 -0
- package/templates/locales/zh-CN/adapters/openhands/agent-guardrails.md +8 -0
- package/templates/locales/zh-CN/base/AGENTS.md +31 -0
- package/templates/locales/zh-CN/base/IMPLEMENT_PROMPT.md +21 -0
- package/templates/locales/zh-CN/base/PROJECT_STATE.md +23 -0
- package/templates/locales/zh-CN/base/PR_CHECKLIST.md +11 -0
- package/templates/locales/zh-CN/base/TASK_TEMPLATE.md +31 -0
- package/templates/presets/monorepo/config.json +96 -0
- package/templates/presets/nextjs/config.json +97 -0
- package/templates/presets/node-service/config.json +105 -0
- package/templates/presets/python-fastapi/config.json +96 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
# Agent Guardrails
|
|
2
|
+
|
|
3
|
+
Ship AI-written code with production guardrails.
|
|
4
|
+
|
|
5
|
+
`agent-guardrails` is a zero-dependency CLI for teams that want coding agents to work like disciplined contributors instead of improvisational code generators. It adds repo-local memory, task contracts, and production-shaped validation around agent workflows so changes stay smaller, more testable, risk-aware, and easier to review.
|
|
6
|
+
|
|
7
|
+
## Why this exists
|
|
8
|
+
|
|
9
|
+
Coding agents usually fail in predictable ways:
|
|
10
|
+
|
|
11
|
+
- they invent abstractions that do not match the repo
|
|
12
|
+
- they change too many files at once
|
|
13
|
+
- they skip tests when behavior changes
|
|
14
|
+
- they ignore project-specific rules unless those rules are explicit and easy to load
|
|
15
|
+
|
|
16
|
+
`agent-guardrails` gives repos a small, practical workflow:
|
|
17
|
+
|
|
18
|
+
1. `init` seeds repo-local instructions and templates
|
|
19
|
+
2. `plan` writes a bounded task contract
|
|
20
|
+
3. `check` validates scope, consistency, correctness, and review or risk signals
|
|
21
|
+
|
|
22
|
+
## 60-Second Quick Start
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install -g agent-guardrails
|
|
26
|
+
agent-guardrails init . --preset node-service --adapter openclaw --lang en
|
|
27
|
+
agent-guardrails plan --task "Add refund status transitions to the order service" --allow-paths "src/,tests/" --intended-files "src/orders/refund.js,tests/refund.test.js" --allowed-change-types "implementation-only" --required-commands "npm test" --evidence ".agent-guardrails/evidence/current-task.md" --lang en
|
|
28
|
+
agent-guardrails check --base-ref origin/main --commands-run "npm test" --review --lang en
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If you do not want a global install, `npx agent-guardrails ...` works too.
|
|
32
|
+
|
|
33
|
+
The CLI currently supports `en` and `zh-CN`. You can switch with `--lang zh-CN` or `AGENT_GUARDRAILS_LOCALE=zh-CN`.
|
|
34
|
+
|
|
35
|
+
## What This Proves
|
|
36
|
+
|
|
37
|
+
The flagship proof-of-value examples are:
|
|
38
|
+
|
|
39
|
+
- the bounded-scope demo in [examples/bounded-scope-demo](./examples/bounded-scope-demo)
|
|
40
|
+
- the first semantic pattern-drift demo in [examples/pattern-drift-demo](./examples/pattern-drift-demo)
|
|
41
|
+
- the interface-drift demo in [examples/interface-drift-demo](./examples/interface-drift-demo)
|
|
42
|
+
- the boundary-violation demo in [examples/boundary-violation-demo](./examples/boundary-violation-demo)
|
|
43
|
+
- the source-test-relevance demo in [examples/source-test-relevance-demo](./examples/source-test-relevance-demo)
|
|
44
|
+
- the pilot write-up in [docs/REAL_REPO_PILOT.md](./docs/REAL_REPO_PILOT.md)
|
|
45
|
+
|
|
46
|
+
Together they show:
|
|
47
|
+
|
|
48
|
+
- a narrow task contract can block out-of-scope changes before merge
|
|
49
|
+
- required commands and evidence notes are part of the merge gate, not optional ceremony
|
|
50
|
+
- the OSS baseline can stay green while a semantic pack adds a higher-signal consistency warning
|
|
51
|
+
- the semantic layer can also block implementation-only work when it silently changes the public surface
|
|
52
|
+
- the semantic layer can block a controller that crosses a declared module boundary even when the task contract still looks narrow
|
|
53
|
+
- the semantic layer can tell the difference between "a test changed" and "the right test changed"
|
|
54
|
+
- the same public CLI can surface deeper enforcement without splitting into a second product
|
|
55
|
+
|
|
56
|
+
Run it with:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
node ./examples/bounded-scope-demo/scripts/run-demo.mjs all
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Then run the OSS benchmark suite:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm run benchmark
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
And run the first semantic proof demo:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm run demo:pattern-drift
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Then run the interface drift proof demo:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm run demo:interface-drift
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Then run the boundary and source-to-test proof demos:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm run demo:boundary-violation
|
|
84
|
+
npm run demo:source-test-relevance
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Local Workflow
|
|
88
|
+
|
|
89
|
+
Use this docs-first loop in day-to-day work:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
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"
|
|
93
|
+
agent-guardrails check --base-ref origin/main --commands-run "npm test,npm run lint" --review
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Keep a short evidence note at `.agent-guardrails/evidence/current-task.md` with:
|
|
97
|
+
|
|
98
|
+
- task name
|
|
99
|
+
- commands run
|
|
100
|
+
- notable results
|
|
101
|
+
- residual risk or `none`
|
|
102
|
+
|
|
103
|
+
Example:
|
|
104
|
+
|
|
105
|
+
```md
|
|
106
|
+
# Task Evidence
|
|
107
|
+
|
|
108
|
+
- Task: Add audit logging to the release approval endpoint
|
|
109
|
+
- Commands run: npm test, npm run lint
|
|
110
|
+
- Notable results: Tests and lint passed after updating the approval endpoint and audit assertions.
|
|
111
|
+
- Residual risk: none
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## CI and Automation Workflow
|
|
115
|
+
|
|
116
|
+
For CI, hooks, or orchestrated agent runs, prefer machine-readable output:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
agent-guardrails check --base-ref origin/main --json
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
If the workflow wants parity with locally reported commands, set:
|
|
123
|
+
|
|
124
|
+
```text
|
|
125
|
+
AGENT_GUARDRAILS_COMMANDS_RUN=npm test,npm run lint
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The generated user-repo workflow template lives in [templates/base/workflows/agent-guardrails.yml](./templates/base/workflows/agent-guardrails.yml).
|
|
129
|
+
The maintainer CI for this package lives in [guardrails.yml](./.github/workflows/guardrails.yml).
|
|
130
|
+
|
|
131
|
+
## Production Baseline
|
|
132
|
+
|
|
133
|
+
The current product direction is a generic, repo-local production baseline for AI-written code:
|
|
134
|
+
|
|
135
|
+
- `plan` shapes the task before implementation with bounded paths, intended files, change-type intent, and risk metadata
|
|
136
|
+
- `check` enforces small-scope, test-aware, evidence-backed, reviewable changes
|
|
137
|
+
- `check --review` turns the same findings into a concise reviewer-oriented report
|
|
138
|
+
|
|
139
|
+
This is intentionally generic-first. It relies on file-shape heuristics, repo policy, task contracts, and command/evidence enforcement rather than framework-specific AST logic.
|
|
140
|
+
|
|
141
|
+
## Open Source vs Pro
|
|
142
|
+
|
|
143
|
+
### Today
|
|
144
|
+
|
|
145
|
+
The open-source core is already the product:
|
|
146
|
+
|
|
147
|
+
- repo-local production baseline
|
|
148
|
+
- smaller, more reviewable AI changes
|
|
149
|
+
- stronger validation and risk visibility before merge
|
|
150
|
+
- public benchmarks and cross-platform CI proof
|
|
151
|
+
- active semantic proof points for pattern drift, interface drift, boundary violation, and source-to-test relevance
|
|
152
|
+
|
|
153
|
+
### Next
|
|
154
|
+
|
|
155
|
+
The next technical step is deeper enforcement behind the same CLI:
|
|
156
|
+
|
|
157
|
+
- detector pipeline foundation
|
|
158
|
+
- benchmarked proof-of-value
|
|
159
|
+
- a repo-contained first TypeScript or JavaScript semantic pack under `plugins/plugin-ts/`
|
|
160
|
+
- first active semantic proofs for pattern drift, interface drift, boundary violation, and source-to-test relevance
|
|
161
|
+
- semantic analyzers for TypeScript or JavaScript first, Python second
|
|
162
|
+
- broader real-repo pilots beyond the documented pilot
|
|
163
|
+
|
|
164
|
+
### Paid
|
|
165
|
+
|
|
166
|
+
Paid tiers should extend the baseline rather than replace it:
|
|
167
|
+
|
|
168
|
+
- `Pro Local`: semantic packs, richer local review, and pattern-learning workflows
|
|
169
|
+
- `Pro Cloud`: hosted review, shared policies, trend dashboards, and centralized governance
|
|
170
|
+
|
|
171
|
+
Baseline merge-gate features stay open source.
|
|
172
|
+
|
|
173
|
+
The first semantic pack lives publicly in this repo today as a proof point. It is positioned as the future `Pro Local` direction, not as a separate closed-source runtime.
|
|
174
|
+
|
|
175
|
+
## Supported Agents
|
|
176
|
+
|
|
177
|
+
| Tool | Seeded file | Local workflow support | Automation guidance support |
|
|
178
|
+
| :-- | :-- | :-- | :-- |
|
|
179
|
+
| Codex | `AGENTS.md` | Yes | Yes |
|
|
180
|
+
| Claude Code | `CLAUDE.md` | Yes | Yes |
|
|
181
|
+
| Cursor | `.cursor/rules/agent-guardrails.mdc` | Yes | Yes |
|
|
182
|
+
| OpenHands | `.agents/skills/agent-guardrails.md` | Yes | Yes |
|
|
183
|
+
| OpenClaw | `OPENCLAW.md` | Yes | Yes |
|
|
184
|
+
|
|
185
|
+
## CLI Commands
|
|
186
|
+
|
|
187
|
+
### `init`
|
|
188
|
+
|
|
189
|
+
Seeds a repo with:
|
|
190
|
+
|
|
191
|
+
- `AGENTS.md`
|
|
192
|
+
- `docs/PROJECT_STATE.md`
|
|
193
|
+
- `docs/PR_CHECKLIST.md`
|
|
194
|
+
- `.agent-guardrails/config.json`
|
|
195
|
+
- `.agent-guardrails/tasks/TASK_TEMPLATE.md`
|
|
196
|
+
- `.github/workflows/agent-guardrails.yml`
|
|
197
|
+
|
|
198
|
+
Example:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
agent-guardrails init . --preset nextjs --adapter openclaw
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### `plan`
|
|
205
|
+
|
|
206
|
+
Prints a bounded implementation brief and writes a task contract by default.
|
|
207
|
+
|
|
208
|
+
Example:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
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"
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### `check`
|
|
215
|
+
|
|
216
|
+
Runs baseline guardrail checks against the current repo and git working tree.
|
|
217
|
+
|
|
218
|
+
Example:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
agent-guardrails check --base-ref origin/main --commands-run "npm test,npm run lint" --review
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
For JSON output:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
agent-guardrails check --base-ref origin/main --json
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Minimal contract example:
|
|
231
|
+
|
|
232
|
+
```json
|
|
233
|
+
{
|
|
234
|
+
"schemaVersion": 3,
|
|
235
|
+
"task": "Add audit logging to the release approval endpoint",
|
|
236
|
+
"preset": "node-service",
|
|
237
|
+
"allowedPaths": ["src/", "tests/"],
|
|
238
|
+
"intendedFiles": ["src/release/approve.js", "tests/release/approve.test.js"],
|
|
239
|
+
"allowedChangeTypes": ["implementation-only"],
|
|
240
|
+
"riskLevel": "medium",
|
|
241
|
+
"requiredCommands": ["npm test", "npm run lint"],
|
|
242
|
+
"evidencePaths": [".agent-guardrails/evidence/current-task.md"]
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Presets
|
|
247
|
+
|
|
248
|
+
- `node-service`
|
|
249
|
+
- `nextjs`
|
|
250
|
+
- `python-fastapi`
|
|
251
|
+
- `monorepo`
|
|
252
|
+
|
|
253
|
+
Each preset adjusts file heuristics and recommended read-before-write paths while keeping the same mental model.
|
|
254
|
+
|
|
255
|
+
## Adapters
|
|
256
|
+
|
|
257
|
+
The core workflow is generic, but `agent-guardrails` ships first-pass adapters for:
|
|
258
|
+
|
|
259
|
+
- [Codex](./adapters/codex/README.md)
|
|
260
|
+
- [Claude Code](./adapters/claude-code/README.md)
|
|
261
|
+
- [Cursor](./adapters/cursor/README.md)
|
|
262
|
+
- [OpenHands](./adapters/openhands/README.md)
|
|
263
|
+
- [OpenClaw](./adapters/openclaw/README.md)
|
|
264
|
+
|
|
265
|
+
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.
|
|
266
|
+
|
|
267
|
+
## FAQ
|
|
268
|
+
|
|
269
|
+
### Do I need all adapters?
|
|
270
|
+
|
|
271
|
+
No. Use only the adapter that matches your coding tool. The core workflow still works without tool-specific seed files.
|
|
272
|
+
|
|
273
|
+
### Do I need evidence files?
|
|
274
|
+
|
|
275
|
+
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.
|
|
276
|
+
|
|
277
|
+
### When should I use `--json`?
|
|
278
|
+
|
|
279
|
+
Use `--json` for CI, hooks, or automation that needs machine-readable results. For normal local work, the human-readable output is the intended default.
|
|
280
|
+
|
|
281
|
+
## Current Limits
|
|
282
|
+
|
|
283
|
+
This project is useful today as a repo-local guardrail layer, but it still has important limits:
|
|
284
|
+
|
|
285
|
+
- the heuristics are still intentionally lightweight and may need tuning for larger repos
|
|
286
|
+
- the semantic detectors are still string- and path-driven, not full AST or type-graph analyzers
|
|
287
|
+
- module boundaries still depend on explicit repo policy instead of automatic architecture inference
|
|
288
|
+
- source-to-test relevance is heuristic and should be treated as reviewer guidance plus contract enforcement, not coverage proof
|
|
289
|
+
- CI users still need to choose their canonical base ref, such as `origin/main`
|
|
290
|
+
- the current pilot is documented in [docs/REAL_REPO_PILOT.md](./docs/REAL_REPO_PILOT.md), and broader external pilots are still pending
|
|
291
|
+
|
|
292
|
+
## Roadmap
|
|
293
|
+
|
|
294
|
+
See [docs/ROADMAP.md](./docs/ROADMAP.md).
|
|
295
|
+
|
|
296
|
+
## Strategy
|
|
297
|
+
|
|
298
|
+
See [docs/PRODUCT_STRATEGY.md](./docs/PRODUCT_STRATEGY.md) for the current semantic-analysis direction, proof-of-value plan, and open-source versus paid product split.
|
|
299
|
+
|
|
300
|
+
## Architecture
|
|
301
|
+
|
|
302
|
+
See [docs/SEMANTIC_ARCHITECTURE.md](./docs/SEMANTIC_ARCHITECTURE.md).
|
|
303
|
+
|
|
304
|
+
## Benchmarks
|
|
305
|
+
|
|
306
|
+
See [docs/BENCHMARKS.md](./docs/BENCHMARKS.md).
|
|
307
|
+
|
|
308
|
+
## Pilot
|
|
309
|
+
|
|
310
|
+
See [docs/REAL_REPO_PILOT.md](./docs/REAL_REPO_PILOT.md).
|
|
311
|
+
|
|
312
|
+
## Commercialization
|
|
313
|
+
|
|
314
|
+
See [docs/COMMERCIALIZATION.md](./docs/COMMERCIALIZATION.md).
|
|
315
|
+
|
|
316
|
+
## Chinese Docs
|
|
317
|
+
|
|
318
|
+
- [Chinese Overview](./docs/zh-CN/README.md)
|
|
319
|
+
- [Product Strategy (Chinese)](./docs/zh-CN/PRODUCT_STRATEGY.md)
|
|
320
|
+
|
|
321
|
+
## Contributing
|
|
322
|
+
|
|
323
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
324
|
+
|
|
325
|
+
## Troubleshooting
|
|
326
|
+
|
|
327
|
+
See [docs/TROUBLESHOOTING.md](./docs/TROUBLESHOOTING.md).
|
|
328
|
+
|
|
329
|
+
## Changelog
|
|
330
|
+
|
|
331
|
+
See [CHANGELOG.md](./CHANGELOG.md).
|
|
332
|
+
|
|
333
|
+
## License
|
|
334
|
+
|
|
335
|
+
MIT
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Adapters
|
|
2
|
+
|
|
3
|
+
This directory holds small, tool-specific guidance for teams that want to use `agent-guardrails` from a particular coding agent or workflow surface.
|
|
4
|
+
|
|
5
|
+
All adapter docs now use the same docs-first task loop:
|
|
6
|
+
|
|
7
|
+
1. Run `plan` with `--allow-paths`, `--required-commands`, and `--evidence ".agent-guardrails/evidence/current-task.md"`.
|
|
8
|
+
2. Implement inside the task contract.
|
|
9
|
+
3. Update the evidence note with the task name, commands run, notable results, and residual risk or `none`.
|
|
10
|
+
4. Run `check --commands-run ...` locally, or `check --json` in automation.
|
|
11
|
+
|
|
12
|
+
## Available
|
|
13
|
+
|
|
14
|
+
- [Codex](./codex/README.md)
|
|
15
|
+
- [Claude Code](./claude-code/README.md)
|
|
16
|
+
- [Cursor](./cursor/README.md)
|
|
17
|
+
- [OpenHands](./openhands/README.md)
|
|
18
|
+
- [OpenClaw](./openclaw/README.md)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Claude Code Adapter
|
|
2
|
+
|
|
3
|
+
Claude Code supports project memory via `CLAUDE.md`, so this adapter seeds a project-level memory file that points Claude Code at the `agent-guardrails` workflow.
|
|
4
|
+
|
|
5
|
+
## Seeded file
|
|
6
|
+
|
|
7
|
+
- `CLAUDE.md`
|
|
8
|
+
|
|
9
|
+
## Recommended flow
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
agent-guardrails init . --preset node-service --adapter claude-code
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then:
|
|
16
|
+
|
|
17
|
+
1. Launch Claude Code in the repo.
|
|
18
|
+
2. Let it load `CLAUDE.md` and `AGENTS.md`.
|
|
19
|
+
3. Run `agent-guardrails plan --task "<task>" --allow-paths "src/,tests/" --intended-files "src/file.js,tests/file.test.js" --allowed-change-types "implementation-only" --required-commands "npm test" --evidence ".agent-guardrails/evidence/current-task.md"`.
|
|
20
|
+
4. Update `.agent-guardrails/evidence/current-task.md` with the task name, commands run, notable results, and residual risk or `none`, then finish with `agent-guardrails check --base-ref origin/main --commands-run "npm test" --review`.
|
|
21
|
+
|
|
22
|
+
Example:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
agent-guardrails plan --task "Add refund status transitions" --allow-paths "src/,tests/" --intended-files "src/orders/refund.js,tests/refund.test.js" --allowed-change-types "implementation-only" --required-commands "npm test" --evidence ".agent-guardrails/evidence/current-task.md"
|
|
26
|
+
agent-guardrails check --base-ref origin/main --commands-run "npm test" --review
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Use `agent-guardrails check --json` for CI or automation hooks, not as the main local developer loop.
|
|
30
|
+
|
|
31
|
+
## Automation recipe
|
|
32
|
+
|
|
33
|
+
```yaml
|
|
34
|
+
- name: Run guardrails
|
|
35
|
+
env:
|
|
36
|
+
AGENT_GUARDRAILS_COMMANDS_RUN: npm test
|
|
37
|
+
run: agent-guardrails check --base-ref origin/${{ github.event.repository.default_branch }} --json > agent-guardrails-report.json
|
|
38
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Codex Adapter
|
|
2
|
+
|
|
3
|
+
Codex already uses `AGENTS.md` as a repository instruction surface, so the core `agent-guardrails` setup is enough for Codex to work well.
|
|
4
|
+
|
|
5
|
+
## What to use
|
|
6
|
+
|
|
7
|
+
- `AGENTS.md` for repo instructions
|
|
8
|
+
- `docs/PROJECT_STATE.md` for short-term project memory
|
|
9
|
+
- `.agent-guardrails/task-contract.json` for per-task scope
|
|
10
|
+
|
|
11
|
+
## Recommended flow
|
|
12
|
+
|
|
13
|
+
1. Initialize the repo with `agent-guardrails`.
|
|
14
|
+
2. Ask Codex to read `AGENTS.md` and project state first.
|
|
15
|
+
3. Run `agent-guardrails plan --task "<task>" --allow-paths "src/,tests/" --intended-files "src/file.js,tests/file.test.js" --allowed-change-types "implementation-only" --required-commands "npm test" --evidence ".agent-guardrails/evidence/current-task.md"`.
|
|
16
|
+
4. Implement within the task contract and keep `.agent-guardrails/evidence/current-task.md` updated with the task name, commands run, notable results, and residual risk or `none`.
|
|
17
|
+
5. Run `agent-guardrails check --base-ref origin/main --commands-run "npm test" --review`.
|
|
18
|
+
|
|
19
|
+
Example:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
agent-guardrails plan --task "Add refund status transitions" --allow-paths "src/,tests/" --intended-files "src/orders/refund.js,tests/refund.test.js" --allowed-change-types "implementation-only" --required-commands "npm test" --evidence ".agent-guardrails/evidence/current-task.md"
|
|
23
|
+
agent-guardrails check --base-ref origin/main --commands-run "npm test" --review
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Use `agent-guardrails check --json` when Codex is being orchestrated by automation or CI, not as the default local workflow.
|
|
27
|
+
|
|
28
|
+
## Automation recipe
|
|
29
|
+
|
|
30
|
+
For GitHub Actions or another orchestrator, report the commands through `AGENT_GUARDRAILS_COMMANDS_RUN` and collect JSON output:
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
- name: Run guardrails
|
|
34
|
+
env:
|
|
35
|
+
AGENT_GUARDRAILS_COMMANDS_RUN: npm test
|
|
36
|
+
run: agent-guardrails check --base-ref origin/${{ github.event.repository.default_branch }} --json > agent-guardrails-report.json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Codex does not need a separate adapter file today because `AGENTS.md` is already the primary repo-level instruction file.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Cursor Adapter
|
|
2
|
+
|
|
3
|
+
Cursor supports repository rules in `.cursor/rules`, so this adapter seeds a project rule that reinforces the `agent-guardrails` workflow.
|
|
4
|
+
|
|
5
|
+
## Seeded file
|
|
6
|
+
|
|
7
|
+
- `.cursor/rules/agent-guardrails.mdc`
|
|
8
|
+
|
|
9
|
+
## Recommended flow
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
agent-guardrails init . --preset node-service --adapter cursor
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then:
|
|
16
|
+
|
|
17
|
+
1. Open the repo in Cursor.
|
|
18
|
+
2. Let Cursor load the project rule alongside `AGENTS.md`.
|
|
19
|
+
3. Run `agent-guardrails plan --task "<task>" --allow-paths "src/,tests/" --intended-files "src/file.js,tests/file.test.js" --allowed-change-types "implementation-only" --required-commands "npm test" --evidence ".agent-guardrails/evidence/current-task.md"`.
|
|
20
|
+
4. Update `.agent-guardrails/evidence/current-task.md` with the task name, commands run, notable results, and residual risk or `none`, then finish with `agent-guardrails check --base-ref origin/main --commands-run "npm test" --review`.
|
|
21
|
+
|
|
22
|
+
Example:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
agent-guardrails plan --task "Add refund status transitions" --allow-paths "src/,tests/" --intended-files "src/orders/refund.js,tests/refund.test.js" --allowed-change-types "implementation-only" --required-commands "npm test" --evidence ".agent-guardrails/evidence/current-task.md"
|
|
26
|
+
agent-guardrails check --base-ref origin/main --commands-run "npm test" --review
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Use `agent-guardrails check --json` for automation or CI integrations, not as the primary local interaction.
|
|
30
|
+
|
|
31
|
+
## Automation recipe
|
|
32
|
+
|
|
33
|
+
```yaml
|
|
34
|
+
- name: Run guardrails
|
|
35
|
+
env:
|
|
36
|
+
AGENT_GUARDRAILS_COMMANDS_RUN: npm test
|
|
37
|
+
run: agent-guardrails check --base-ref origin/${{ github.event.repository.default_branch }} --json > agent-guardrails-report.json
|
|
38
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# OpenClaw Instructions
|
|
2
|
+
|
|
3
|
+
Use this repo with `agent-guardrails` as the shared workflow guardrail layer.
|
|
4
|
+
|
|
5
|
+
## Read First
|
|
6
|
+
|
|
7
|
+
Before editing, read:
|
|
8
|
+
|
|
9
|
+
1. `AGENTS.md`
|
|
10
|
+
2. `docs/PROJECT_STATE.md`
|
|
11
|
+
3. `README.md`
|
|
12
|
+
4. `adapters/openclaw/README.md`
|
|
13
|
+
5. the target files for the task
|
|
14
|
+
|
|
15
|
+
## Working Rules
|
|
16
|
+
|
|
17
|
+
- Keep tasks small and reviewable.
|
|
18
|
+
- Prefer the existing repo structure over new abstractions.
|
|
19
|
+
- If the task scope is narrow, declare it with `agent-guardrails plan --allow-paths ... --required-commands "npm test" --evidence ".agent-guardrails/evidence/current-task.md"`.
|
|
20
|
+
- If the task touches behavior, include tests and update `.agent-guardrails/evidence/current-task.md` with the task name, commands run, notable results, and residual risk or `none`.
|
|
21
|
+
- Before finishing, run `agent-guardrails check --base-ref origin/main --commands-run "npm test"`.
|
|
22
|
+
- Use `agent-guardrails check --json` for automation or CI, not as the primary local loop.
|
|
23
|
+
|
|
24
|
+
## Default Task Pattern
|
|
25
|
+
|
|
26
|
+
1. Read the repo state and the task brief.
|
|
27
|
+
2. Run `agent-guardrails plan --task "<task>" --allow-paths "src/,tests/" --required-commands "npm test" --evidence ".agent-guardrails/evidence/current-task.md"`.
|
|
28
|
+
3. Make the smallest implementation that fits the task contract.
|
|
29
|
+
4. Update `.agent-guardrails/evidence/current-task.md` with the real commands run and results, then run `agent-guardrails check --base-ref origin/main --commands-run "npm test"`.
|
|
30
|
+
5. Update `docs/PROJECT_STATE.md` if the next step changed.
|
|
31
|
+
|
|
32
|
+
## Notes
|
|
33
|
+
|
|
34
|
+
- If the task needs broader scope, update the task contract first.
|
|
35
|
+
- If `check` fails, fix the scope or the tests before expanding the change.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# OpenClaw Adapter
|
|
2
|
+
|
|
3
|
+
This is the smallest useful OpenClaw slice for `agent-guardrails`.
|
|
4
|
+
|
|
5
|
+
It does not add a custom binary integration. Instead, it gives OpenClaw users a ready-to-use instruction template and a clear workflow for using the repo-local guardrails already in this project.
|
|
6
|
+
|
|
7
|
+
## What it gives you
|
|
8
|
+
|
|
9
|
+
- A repo-local instruction template in [OPENCLAW.md](./OPENCLAW.md)
|
|
10
|
+
- A simple adoption flow that uses `init`, `plan`, and `check`
|
|
11
|
+
- A documented path to task contracts and base-ref checks
|
|
12
|
+
|
|
13
|
+
## Recommended flow
|
|
14
|
+
|
|
15
|
+
1. Initialize the repo with `agent-guardrails`, ideally with `--adapter openclaw`.
|
|
16
|
+
2. Use the OpenClaw instruction template to keep tasks bounded.
|
|
17
|
+
3. Run `plan --allow-paths ... --intended-files ... --allowed-change-types "implementation-only" --required-commands "npm test" --evidence ".agent-guardrails/evidence/current-task.md"` to write a task contract for the current task.
|
|
18
|
+
4. Update `.agent-guardrails/evidence/current-task.md` with the task name, commands run, notable results, and residual risk or `none`, then run `check --base-ref origin/main --commands-run "npm test" --review` before finishing.
|
|
19
|
+
|
|
20
|
+
Example:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
node ./bin/agent-guardrails.js init . --preset node-service --adapter openclaw
|
|
24
|
+
node ./bin/agent-guardrails.js plan --task "Add refund status transitions" --allow-paths "src/,tests/" --intended-files "src/orders/refund.js,tests/refund.test.js" --allowed-change-types "implementation-only" --required-commands "npm test" --evidence ".agent-guardrails/evidence/current-task.md"
|
|
25
|
+
node ./bin/agent-guardrails.js check --base-ref origin/main --commands-run "npm test" --review
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Use `agent-guardrails check --json` when OpenClaw is being orchestrated by automation or CI, not as the default local loop.
|
|
29
|
+
|
|
30
|
+
## Automation recipe
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
- name: Run guardrails
|
|
34
|
+
env:
|
|
35
|
+
AGENT_GUARDRAILS_COMMANDS_RUN: npm test
|
|
36
|
+
run: agent-guardrails check --base-ref origin/${{ github.event.repository.default_branch }} --json > agent-guardrails-report.json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Best fit
|
|
40
|
+
|
|
41
|
+
OpenClaw works best here when it is used as the task-execution layer and `agent-guardrails` is the repo policy layer. That keeps the setup lightweight while still enforcing scope, test expectations, and CI-friendly diffs.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# OpenHands Adapter
|
|
2
|
+
|
|
3
|
+
OpenHands supports repository guidance through `.agents/skills`, so this adapter seeds a repo-level skill that tells OpenHands to use the `agent-guardrails` workflow.
|
|
4
|
+
|
|
5
|
+
## Seeded file
|
|
6
|
+
|
|
7
|
+
- `.agents/skills/agent-guardrails.md`
|
|
8
|
+
|
|
9
|
+
## Recommended flow
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
agent-guardrails init . --preset node-service --adapter openhands
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then:
|
|
16
|
+
|
|
17
|
+
1. Start OpenHands in the repo.
|
|
18
|
+
2. Let it load the repo skill and `AGENTS.md`.
|
|
19
|
+
3. Run `agent-guardrails plan --task "<task>" --allow-paths "src/,tests/" --intended-files "src/file.js,tests/file.test.js" --allowed-change-types "implementation-only" --required-commands "npm test" --evidence ".agent-guardrails/evidence/current-task.md"`.
|
|
20
|
+
4. Update `.agent-guardrails/evidence/current-task.md` with the task name, commands run, notable results, and residual risk or `none`, then finish with `agent-guardrails check --base-ref origin/main --commands-run "npm test" --review`.
|
|
21
|
+
|
|
22
|
+
Example:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
agent-guardrails plan --task "Add refund status transitions" --allow-paths "src/,tests/" --intended-files "src/orders/refund.js,tests/refund.test.js" --allowed-change-types "implementation-only" --required-commands "npm test" --evidence ".agent-guardrails/evidence/current-task.md"
|
|
26
|
+
agent-guardrails check --base-ref origin/main --commands-run "npm test" --review
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Use `agent-guardrails check --json` for automation or CI orchestration, not as the main local workflow.
|
|
30
|
+
|
|
31
|
+
## Automation recipe
|
|
32
|
+
|
|
33
|
+
```yaml
|
|
34
|
+
- name: Run guardrails
|
|
35
|
+
env:
|
|
36
|
+
AGENT_GUARDRAILS_COMMANDS_RUN: npm test
|
|
37
|
+
run: agent-guardrails check --base-ref origin/${{ github.event.repository.default_branch }} --json > agent-guardrails-report.json
|
|
38
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { runCli } from "../lib/cli.js";
|
|
4
|
+
|
|
5
|
+
runCli(process.argv.slice(2)).catch((error) => {
|
|
6
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
7
|
+
console.error(`agent-guardrails: ${message}`);
|
|
8
|
+
process.exit(1);
|
|
9
|
+
});
|