@sentry/warden 0.0.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/.agents/skills/find-bugs/SKILL.md +75 -0
- package/.agents/skills/vercel-react-best-practices/AGENTS.md +2934 -0
- package/.agents/skills/vercel-react-best-practices/SKILL.md +136 -0
- package/.agents/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/.agents/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
- package/.agents/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
- package/.agents/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/.agents/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/.agents/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/.agents/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/.agents/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
- package/.agents/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/.agents/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
- package/.claude/settings.json +57 -0
- package/.claude/settings.local.json +88 -0
- package/.claude/skills/agent-prompt/SKILL.md +54 -0
- package/.claude/skills/agent-prompt/references/agentic-patterns.md +94 -0
- package/.claude/skills/agent-prompt/references/anti-patterns.md +140 -0
- package/.claude/skills/agent-prompt/references/context-design.md +124 -0
- package/.claude/skills/agent-prompt/references/core-principles.md +75 -0
- package/.claude/skills/agent-prompt/references/model-guidance.md +118 -0
- package/.claude/skills/agent-prompt/references/output-formats.md +98 -0
- package/.claude/skills/agent-prompt/references/skill-structure.md +115 -0
- package/.claude/skills/agent-prompt/references/system-prompts.md +115 -0
- package/.claude/skills/notseer/SKILL.md +131 -0
- package/.claude/skills/skill-writer/SKILL.md +140 -0
- package/.claude/skills/testing-guidelines/SKILL.md +132 -0
- package/.claude/skills/warden-skill/SKILL.md +250 -0
- package/.claude/skills/warden-skill/references/config-schema.md +133 -0
- package/.dex/config.toml +2 -0
- package/.github/workflows/ci.yml +33 -0
- package/.github/workflows/release.yml +54 -0
- package/.github/workflows/warden.yml +40 -0
- package/AGENTS.md +89 -0
- package/CONTRIBUTING.md +60 -0
- package/LICENSE +105 -0
- package/README.md +43 -0
- package/SPEC.md +263 -0
- package/action.yml +87 -0
- package/assets/favicon.png +0 -0
- package/assets/warden-icon-bw.svg +5 -0
- package/assets/warden-icon-purple.png +0 -0
- package/assets/warden-icon-purple.svg +5 -0
- package/docs/.claude/settings.local.json +11 -0
- package/docs/astro.config.mjs +43 -0
- package/docs/package.json +19 -0
- package/docs/pnpm-lock.yaml +4000 -0
- package/docs/public/favicon.svg +5 -0
- package/docs/src/components/Code.astro +141 -0
- package/docs/src/components/PackageManagerTabs.astro +183 -0
- package/docs/src/components/Terminal.astro +212 -0
- package/docs/src/layouts/Base.astro +380 -0
- package/docs/src/pages/cli.astro +167 -0
- package/docs/src/pages/config.astro +394 -0
- package/docs/src/pages/guide.astro +449 -0
- package/docs/src/pages/index.astro +490 -0
- package/docs/src/styles/global.css +551 -0
- package/docs/tsconfig.json +3 -0
- package/docs/vercel.json +5 -0
- package/eslint.config.js +33 -0
- package/package.json +73 -0
- package/src/action/index.ts +1 -0
- package/src/action/main.ts +868 -0
- package/src/cli/args.test.ts +477 -0
- package/src/cli/args.ts +415 -0
- package/src/cli/commands/add.ts +447 -0
- package/src/cli/commands/init.test.ts +136 -0
- package/src/cli/commands/init.ts +132 -0
- package/src/cli/commands/setup-app/browser.ts +38 -0
- package/src/cli/commands/setup-app/credentials.ts +45 -0
- package/src/cli/commands/setup-app/manifest.ts +48 -0
- package/src/cli/commands/setup-app/server.ts +172 -0
- package/src/cli/commands/setup-app.ts +156 -0
- package/src/cli/commands/sync.ts +114 -0
- package/src/cli/context.ts +131 -0
- package/src/cli/files.test.ts +155 -0
- package/src/cli/files.ts +89 -0
- package/src/cli/fix.test.ts +310 -0
- package/src/cli/fix.ts +387 -0
- package/src/cli/git.test.ts +119 -0
- package/src/cli/git.ts +318 -0
- package/src/cli/index.ts +14 -0
- package/src/cli/main.ts +672 -0
- package/src/cli/output/box.ts +235 -0
- package/src/cli/output/formatters.test.ts +187 -0
- package/src/cli/output/formatters.ts +269 -0
- package/src/cli/output/icons.ts +13 -0
- package/src/cli/output/index.ts +44 -0
- package/src/cli/output/ink-runner.tsx +337 -0
- package/src/cli/output/jsonl.test.ts +347 -0
- package/src/cli/output/jsonl.ts +126 -0
- package/src/cli/output/reporter.ts +435 -0
- package/src/cli/output/tasks.ts +374 -0
- package/src/cli/output/tty.test.ts +117 -0
- package/src/cli/output/tty.ts +60 -0
- package/src/cli/output/verbosity.test.ts +40 -0
- package/src/cli/output/verbosity.ts +31 -0
- package/src/cli/terminal.test.ts +148 -0
- package/src/cli/terminal.ts +301 -0
- package/src/config/index.ts +3 -0
- package/src/config/loader.test.ts +313 -0
- package/src/config/loader.ts +103 -0
- package/src/config/schema.ts +168 -0
- package/src/config/writer.test.ts +119 -0
- package/src/config/writer.ts +84 -0
- package/src/diff/classify.test.ts +162 -0
- package/src/diff/classify.ts +92 -0
- package/src/diff/coalesce.test.ts +208 -0
- package/src/diff/coalesce.ts +133 -0
- package/src/diff/context.test.ts +226 -0
- package/src/diff/context.ts +201 -0
- package/src/diff/index.ts +4 -0
- package/src/diff/parser.test.ts +212 -0
- package/src/diff/parser.ts +149 -0
- package/src/event/context.ts +132 -0
- package/src/event/index.ts +2 -0
- package/src/event/schedule-context.ts +101 -0
- package/src/examples/examples.integration.test.ts +66 -0
- package/src/examples/index.test.ts +101 -0
- package/src/examples/index.ts +122 -0
- package/src/examples/setup.ts +25 -0
- package/src/index.ts +115 -0
- package/src/output/dedup.test.ts +419 -0
- package/src/output/dedup.ts +607 -0
- package/src/output/github-checks.test.ts +300 -0
- package/src/output/github-checks.ts +476 -0
- package/src/output/github-issues.ts +329 -0
- package/src/output/index.ts +5 -0
- package/src/output/issue-renderer.ts +197 -0
- package/src/output/renderer.test.ts +727 -0
- package/src/output/renderer.ts +217 -0
- package/src/output/stale.test.ts +375 -0
- package/src/output/stale.ts +155 -0
- package/src/output/types.ts +34 -0
- package/src/sdk/index.ts +1 -0
- package/src/sdk/runner.test.ts +806 -0
- package/src/sdk/runner.ts +1232 -0
- package/src/skills/index.ts +36 -0
- package/src/skills/loader.test.ts +300 -0
- package/src/skills/loader.ts +423 -0
- package/src/skills/remote.test.ts +704 -0
- package/src/skills/remote.ts +604 -0
- package/src/triggers/matcher.test.ts +277 -0
- package/src/triggers/matcher.ts +152 -0
- package/src/types/index.ts +194 -0
- package/src/utils/async.ts +18 -0
- package/src/utils/index.test.ts +84 -0
- package/src/utils/index.ts +50 -0
- package/tsconfig.json +25 -0
- package/vitest.config.ts +8 -0
- package/vitest.integration.config.ts +11 -0
- package/warden.toml +19 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: warden-skill
|
|
3
|
+
description: Guide for using Warden CLI locally to analyze code changes. Use when running warden commands, configuring warden.toml, creating custom skills, understanding triggers, or troubleshooting analysis issues. Triggers on "run warden", "warden config", "warden.toml", "create warden skill", "add trigger", or any Warden-related local development task.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Warden Usage
|
|
7
|
+
|
|
8
|
+
Warden is an event-driven AI agent that analyzes code changes and executes configurable skills to produce structured reports with findings.
|
|
9
|
+
|
|
10
|
+
## Quick Start
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Set API key
|
|
14
|
+
export WARDEN_ANTHROPIC_API_KEY=sk-ant-...
|
|
15
|
+
|
|
16
|
+
# Analyze uncommitted changes (uses warden.toml triggers)
|
|
17
|
+
warden
|
|
18
|
+
|
|
19
|
+
# Run specific skill on uncommitted changes
|
|
20
|
+
warden --skill find-bugs
|
|
21
|
+
|
|
22
|
+
# Analyze specific files
|
|
23
|
+
warden src/auth.ts src/database.ts
|
|
24
|
+
|
|
25
|
+
# Analyze changes from git ref
|
|
26
|
+
warden main..HEAD
|
|
27
|
+
warden HEAD~3
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## CLI Reference
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
warden [command] [targets...] [options]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Commands:**
|
|
37
|
+
- `(default)` - Run analysis
|
|
38
|
+
- `init` - Initialize warden.toml and GitHub workflow
|
|
39
|
+
- `add [skill]` - Add skill trigger to warden.toml
|
|
40
|
+
- `sync [repo]` - Update cached remote skills to latest
|
|
41
|
+
- `setup-app` - Create GitHub App via manifest flow
|
|
42
|
+
|
|
43
|
+
**Targets:**
|
|
44
|
+
- `<files>` - Specific files (e.g., `src/auth.ts`)
|
|
45
|
+
- `<glob>` - Pattern match (e.g., `src/**/*.ts`)
|
|
46
|
+
- `<git-ref>` - Git range (e.g., `main..HEAD`, `HEAD~3`)
|
|
47
|
+
- `(none)` - Uncommitted changes
|
|
48
|
+
|
|
49
|
+
**Key Options:**
|
|
50
|
+
| Option | Description |
|
|
51
|
+
|--------|-------------|
|
|
52
|
+
| `--skill <name>` | Run only this skill |
|
|
53
|
+
| `--config <path>` | Path to warden.toml (default: ./warden.toml) |
|
|
54
|
+
| `-m, --model <model>` | Model to use |
|
|
55
|
+
| `--json` | Output as JSON |
|
|
56
|
+
| `-o, --output <path>` | Write output to JSONL file |
|
|
57
|
+
| `--fail-on <severity>` | Exit 1 if findings >= severity |
|
|
58
|
+
| `--comment-on <severity>` | Show findings >= severity |
|
|
59
|
+
| `--fix` | Auto-apply suggested fixes |
|
|
60
|
+
| `--parallel <n>` | Concurrent executions (default: 4) |
|
|
61
|
+
| `--offline` | Use cached remote skills only |
|
|
62
|
+
| `-q, --quiet` | Errors and summary only |
|
|
63
|
+
| `-v, --verbose` | Show real-time findings |
|
|
64
|
+
| `-vv` | Debug info (tokens, latency) |
|
|
65
|
+
|
|
66
|
+
**Severity levels:** `critical`, `high`, `medium`, `low`, `info`, `off`
|
|
67
|
+
|
|
68
|
+
## Configuration (warden.toml)
|
|
69
|
+
|
|
70
|
+
See [references/config-schema.md](references/config-schema.md) for complete schema.
|
|
71
|
+
|
|
72
|
+
**Minimal example:**
|
|
73
|
+
|
|
74
|
+
```toml
|
|
75
|
+
version = 1
|
|
76
|
+
|
|
77
|
+
[defaults]
|
|
78
|
+
model = "claude-sonnet-4-20250514"
|
|
79
|
+
|
|
80
|
+
[[triggers]]
|
|
81
|
+
name = "find-bugs"
|
|
82
|
+
event = "pull_request"
|
|
83
|
+
actions = ["opened", "synchronize"]
|
|
84
|
+
skill = "find-bugs"
|
|
85
|
+
|
|
86
|
+
[triggers.filters]
|
|
87
|
+
paths = ["src/**/*.ts"]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**With custom output thresholds:**
|
|
91
|
+
|
|
92
|
+
```toml
|
|
93
|
+
[[triggers]]
|
|
94
|
+
name = "security-strict"
|
|
95
|
+
event = "pull_request"
|
|
96
|
+
actions = ["opened", "synchronize"]
|
|
97
|
+
skill = "security-review"
|
|
98
|
+
|
|
99
|
+
[triggers.filters]
|
|
100
|
+
paths = ["src/auth/**", "src/payments/**"]
|
|
101
|
+
|
|
102
|
+
[triggers.output]
|
|
103
|
+
failOn = "critical"
|
|
104
|
+
commentOn = "high"
|
|
105
|
+
maxFindings = 20
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Creating Custom Skills
|
|
109
|
+
|
|
110
|
+
Skills live in `.warden/skills/`, `.agents/skills/`, or `.claude/skills/`.
|
|
111
|
+
|
|
112
|
+
**Structure:**
|
|
113
|
+
```
|
|
114
|
+
.warden/skills/my-skill/
|
|
115
|
+
└── SKILL.md
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**SKILL.md format:**
|
|
119
|
+
|
|
120
|
+
```markdown
|
|
121
|
+
---
|
|
122
|
+
name: my-skill
|
|
123
|
+
description: What this skill analyzes
|
|
124
|
+
allowed-tools: Read Grep Glob
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
[Analysis instructions for the agent]
|
|
128
|
+
|
|
129
|
+
## What to Look For
|
|
130
|
+
- Specific issue type 1
|
|
131
|
+
- Specific issue type 2
|
|
132
|
+
|
|
133
|
+
## Output Format
|
|
134
|
+
Report findings with severity, location, and suggested fix.
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Available tools:** `Read`, `Glob`, `Grep`, `WebFetch`, `WebSearch`, `Bash`, `Write`, `Edit`
|
|
138
|
+
|
|
139
|
+
## Remote Skills
|
|
140
|
+
|
|
141
|
+
Skills can be fetched from GitHub repositories:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Add a remote skill
|
|
145
|
+
warden add --remote getsentry/skills --skill security-review
|
|
146
|
+
|
|
147
|
+
# Add with version pinning (recommended for reproducibility)
|
|
148
|
+
warden add --remote getsentry/skills@abc123 --skill security-review
|
|
149
|
+
|
|
150
|
+
# List skills in a remote repo
|
|
151
|
+
warden add --remote getsentry/skills --list
|
|
152
|
+
|
|
153
|
+
# Update all unpinned remote skills
|
|
154
|
+
warden sync
|
|
155
|
+
|
|
156
|
+
# Update specific repo
|
|
157
|
+
warden sync getsentry/skills
|
|
158
|
+
|
|
159
|
+
# Run with cached skills only (no network)
|
|
160
|
+
warden --offline
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Remote trigger in warden.toml:**
|
|
164
|
+
|
|
165
|
+
```toml
|
|
166
|
+
[[triggers]]
|
|
167
|
+
name = "security-review"
|
|
168
|
+
event = "pull_request"
|
|
169
|
+
actions = ["opened", "synchronize"]
|
|
170
|
+
skill = "security-review"
|
|
171
|
+
remote = "getsentry/skills@abc123"
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Cache location:** `~/.local/warden/skills/` (override with `WARDEN_STATE_DIR`)
|
|
175
|
+
|
|
176
|
+
**Cache TTL:** 24 hours for unpinned refs (override with `WARDEN_SKILL_CACHE_TTL` in seconds)
|
|
177
|
+
|
|
178
|
+
**Inline skill in warden.toml:**
|
|
179
|
+
|
|
180
|
+
```toml
|
|
181
|
+
[[skills]]
|
|
182
|
+
name = "custom-check"
|
|
183
|
+
description = "Check for TODO comments"
|
|
184
|
+
prompt = """
|
|
185
|
+
Find TODO comments that have been in the code for too long.
|
|
186
|
+
Report as low severity findings.
|
|
187
|
+
"""
|
|
188
|
+
|
|
189
|
+
[skills.tools]
|
|
190
|
+
allowed = ["Read", "Grep", "Glob"]
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Built-in Skills
|
|
194
|
+
|
|
195
|
+
| Skill | Purpose |
|
|
196
|
+
|-------|---------|
|
|
197
|
+
| `find-bugs` | Logical/functional bugs, null handling, async issues |
|
|
198
|
+
| `security-review` | Injection, auth, CSRF, crypto, race conditions |
|
|
199
|
+
| `code-simplifier` | Readability, consistency, redundancy removal |
|
|
200
|
+
| `performance-review` | N+1 queries, blocking I/O, memory leaks |
|
|
201
|
+
|
|
202
|
+
## Common Patterns
|
|
203
|
+
|
|
204
|
+
**Strict security on critical files:**
|
|
205
|
+
```toml
|
|
206
|
+
[[triggers]]
|
|
207
|
+
name = "auth-security"
|
|
208
|
+
event = "pull_request"
|
|
209
|
+
actions = ["opened", "synchronize"]
|
|
210
|
+
skill = "security-review"
|
|
211
|
+
model = "claude-opus-4-20250514"
|
|
212
|
+
maxTurns = 100
|
|
213
|
+
|
|
214
|
+
[triggers.filters]
|
|
215
|
+
paths = ["src/auth/**", "src/payments/**"]
|
|
216
|
+
|
|
217
|
+
[triggers.output]
|
|
218
|
+
failOn = "critical"
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Skip test files:**
|
|
222
|
+
```toml
|
|
223
|
+
[triggers.filters]
|
|
224
|
+
paths = ["src/**/*.ts"]
|
|
225
|
+
ignorePaths = ["**/*.test.ts", "**/*.spec.ts"]
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**Whole-file analysis for configs:**
|
|
229
|
+
```toml
|
|
230
|
+
[defaults.chunking.filePatterns]
|
|
231
|
+
pattern = "*.config.*"
|
|
232
|
+
mode = "whole-file"
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Troubleshooting
|
|
236
|
+
|
|
237
|
+
**No findings reported:**
|
|
238
|
+
- Check `--comment-on` threshold (default shows all)
|
|
239
|
+
- Verify skill matches file types in `filters.paths`
|
|
240
|
+
- Use `-v` to see which files are being analyzed
|
|
241
|
+
|
|
242
|
+
**Files being skipped:**
|
|
243
|
+
- Built-in skip patterns: lock files, minified, `node_modules/`, `dist/`
|
|
244
|
+
- Check `ignorePaths` in config
|
|
245
|
+
- Use `-vv` to see skip reasons
|
|
246
|
+
|
|
247
|
+
**Token/cost issues:**
|
|
248
|
+
- Reduce `maxTurns` (default: 50)
|
|
249
|
+
- Use chunking settings to control chunk size
|
|
250
|
+
- Filter to relevant files with `paths`
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# warden.toml Configuration Schema
|
|
2
|
+
|
|
3
|
+
## Top-Level Structure
|
|
4
|
+
|
|
5
|
+
```toml
|
|
6
|
+
version = 1 # Required, must be 1
|
|
7
|
+
|
|
8
|
+
[defaults] # Optional, inherited by all triggers
|
|
9
|
+
[[triggers]] # Required, array of trigger configs
|
|
10
|
+
[[skills]] # Optional, inline skill definitions
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Defaults Section
|
|
14
|
+
|
|
15
|
+
```toml
|
|
16
|
+
[defaults]
|
|
17
|
+
model = "claude-sonnet-4-20250514" # Default model
|
|
18
|
+
maxTurns = 50 # Max agentic turns per hunk
|
|
19
|
+
defaultBranch = "main" # Base branch for comparisons
|
|
20
|
+
|
|
21
|
+
[defaults.output]
|
|
22
|
+
failOn = "high" # Exit 1 if findings >= this severity
|
|
23
|
+
commentOn = "medium" # Show findings >= this severity
|
|
24
|
+
maxFindings = 50 # Max findings to report (0 = unlimited)
|
|
25
|
+
commentOnSuccess = false # Post comment even with no findings
|
|
26
|
+
|
|
27
|
+
[defaults.filters]
|
|
28
|
+
paths = ["src/**/*.ts"] # Include only matching files
|
|
29
|
+
ignorePaths = ["*.test.ts"] # Exclude matching files
|
|
30
|
+
|
|
31
|
+
[defaults.chunking]
|
|
32
|
+
enabled = true # Enable hunk-based chunking
|
|
33
|
+
|
|
34
|
+
[defaults.chunking.coalesce]
|
|
35
|
+
enabled = true # Merge nearby hunks
|
|
36
|
+
maxGapLines = 30 # Lines between hunks to merge
|
|
37
|
+
maxChunkSize = 8000 # Max chars per chunk
|
|
38
|
+
|
|
39
|
+
[[defaults.chunking.filePatterns]]
|
|
40
|
+
pattern = "*.config.*" # Glob pattern
|
|
41
|
+
mode = "whole-file" # per-hunk | whole-file | skip
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Triggers Section
|
|
45
|
+
|
|
46
|
+
```toml
|
|
47
|
+
[[triggers]]
|
|
48
|
+
name = "trigger-name" # Required, unique identifier
|
|
49
|
+
event = "pull_request" # Required: pull_request | issues | issue_comment | schedule
|
|
50
|
+
actions = ["opened", "synchronize"] # Required for non-schedule events
|
|
51
|
+
skill = "find-bugs" # Required, skill name or path
|
|
52
|
+
remote = "owner/repo@sha" # Optional, fetch skill from GitHub repo
|
|
53
|
+
|
|
54
|
+
# Optional overrides (inherit from defaults if not set)
|
|
55
|
+
model = "claude-opus-4-20250514"
|
|
56
|
+
maxTurns = 100
|
|
57
|
+
|
|
58
|
+
[triggers.filters]
|
|
59
|
+
paths = ["src/**"]
|
|
60
|
+
ignorePaths = ["**/*.test.ts"]
|
|
61
|
+
|
|
62
|
+
[triggers.output]
|
|
63
|
+
failOn = "critical"
|
|
64
|
+
commentOn = "high"
|
|
65
|
+
maxFindings = 20
|
|
66
|
+
commentOnSuccess = true
|
|
67
|
+
|
|
68
|
+
# Schedule-specific (only for event = "schedule")
|
|
69
|
+
[triggers.schedule]
|
|
70
|
+
issueTitle = "Daily Security Review" # GitHub issue title for tracking
|
|
71
|
+
createFixPR = true # Create PR with fixes
|
|
72
|
+
fixBranchPrefix = "security-fix" # Branch name prefix
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Event types:**
|
|
76
|
+
- `pull_request` - Triggers on PR events
|
|
77
|
+
- `issues` - Triggers on issue events
|
|
78
|
+
- `issue_comment` - Triggers on issue/PR comments
|
|
79
|
+
- `schedule` - Triggers on cron schedule (GitHub Action)
|
|
80
|
+
|
|
81
|
+
**Actions (for non-schedule):**
|
|
82
|
+
- `opened`, `synchronize`, `reopened`, `closed`
|
|
83
|
+
|
|
84
|
+
## Skills Section (Inline Skills)
|
|
85
|
+
|
|
86
|
+
```toml
|
|
87
|
+
[[skills]]
|
|
88
|
+
name = "custom-skill"
|
|
89
|
+
description = "What this skill checks"
|
|
90
|
+
prompt = """
|
|
91
|
+
Analysis instructions here.
|
|
92
|
+
Look for specific issues.
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
[skills.tools]
|
|
96
|
+
allowed = ["Read", "Grep", "Glob"] # Whitelist tools
|
|
97
|
+
denied = ["Write", "Edit", "Bash"] # Blacklist tools (optional)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Severity Values
|
|
101
|
+
|
|
102
|
+
Used in `failOn` and `commentOn`:
|
|
103
|
+
- `critical` - Most severe
|
|
104
|
+
- `high`
|
|
105
|
+
- `medium`
|
|
106
|
+
- `low`
|
|
107
|
+
- `info` - Least severe
|
|
108
|
+
- `off` - Disable threshold
|
|
109
|
+
|
|
110
|
+
## Built-in Skip Patterns
|
|
111
|
+
|
|
112
|
+
Always skipped (cannot be overridden):
|
|
113
|
+
- Package locks: `pnpm-lock.yaml`, `package-lock.json`, `yarn.lock`, `Cargo.lock`, etc.
|
|
114
|
+
- Minified files: `**/*.min.js`, `**/*.min.css`
|
|
115
|
+
- Build artifacts: `dist/`, `build/`, `node_modules/`, `.next/`, `__pycache__/`
|
|
116
|
+
- Generated code: `*.generated.*`, `*.g.ts`, `__generated__/`
|
|
117
|
+
|
|
118
|
+
## Environment Variables
|
|
119
|
+
|
|
120
|
+
| Variable | Purpose |
|
|
121
|
+
|----------|---------|
|
|
122
|
+
| `WARDEN_ANTHROPIC_API_KEY` | Claude API key (required) |
|
|
123
|
+
| `WARDEN_MODEL` | Default model (lowest priority) |
|
|
124
|
+
| `WARDEN_STATE_DIR` | Override cache location (default: `~/.local/warden`) |
|
|
125
|
+
| `WARDEN_SKILL_CACHE_TTL` | Cache TTL in seconds for unpinned remotes (default: 86400) |
|
|
126
|
+
|
|
127
|
+
## Model Precedence (highest to lowest)
|
|
128
|
+
|
|
129
|
+
1. Trigger-level `model`
|
|
130
|
+
2. `[defaults]` `model`
|
|
131
|
+
3. CLI `--model` flag
|
|
132
|
+
4. `WARDEN_MODEL` env var
|
|
133
|
+
5. SDK default
|
package/.dex/config.toml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
permissions:
|
|
4
|
+
contents: read
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [main]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [main]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- uses: pnpm/action-setup@v4
|
|
19
|
+
with:
|
|
20
|
+
version: 9
|
|
21
|
+
|
|
22
|
+
- uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: '20'
|
|
25
|
+
cache: 'pnpm'
|
|
26
|
+
|
|
27
|
+
- run: pnpm install --frozen-lockfile
|
|
28
|
+
|
|
29
|
+
- run: pnpm typecheck
|
|
30
|
+
- run: pnpm lint
|
|
31
|
+
- run: pnpm test
|
|
32
|
+
- run: pnpm build
|
|
33
|
+
- run: pnpm build:action
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*.*.*'
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
release:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- uses: pnpm/action-setup@v4
|
|
18
|
+
with:
|
|
19
|
+
version: 9
|
|
20
|
+
|
|
21
|
+
- uses: actions/setup-node@v4
|
|
22
|
+
with:
|
|
23
|
+
node-version: '20'
|
|
24
|
+
cache: 'pnpm'
|
|
25
|
+
|
|
26
|
+
- run: pnpm install --frozen-lockfile
|
|
27
|
+
- run: pnpm build
|
|
28
|
+
- run: pnpm build:action
|
|
29
|
+
|
|
30
|
+
- name: Get version info
|
|
31
|
+
id: version
|
|
32
|
+
run: |
|
|
33
|
+
echo "tag=$GITHUB_REF_NAME" >> $GITHUB_OUTPUT
|
|
34
|
+
echo "major=${GITHUB_REF_NAME%%.*}" >> $GITHUB_OUTPUT
|
|
35
|
+
|
|
36
|
+
- name: Commit dist/action to tag
|
|
37
|
+
run: |
|
|
38
|
+
git config user.name "github-actions[bot]"
|
|
39
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
40
|
+
git add -f dist/action/
|
|
41
|
+
git commit -m "Build action for ${{ steps.version.outputs.tag }}"
|
|
42
|
+
git tag -f ${{ steps.version.outputs.tag }}
|
|
43
|
+
git push -f origin ${{ steps.version.outputs.tag }}
|
|
44
|
+
|
|
45
|
+
- name: Update major version tag
|
|
46
|
+
run: |
|
|
47
|
+
git tag -f ${{ steps.version.outputs.major }}
|
|
48
|
+
git push -f origin ${{ steps.version.outputs.major }}
|
|
49
|
+
|
|
50
|
+
- name: Create GitHub Release
|
|
51
|
+
uses: softprops/action-gh-release@v2
|
|
52
|
+
with:
|
|
53
|
+
tag_name: ${{ steps.version.outputs.tag }}
|
|
54
|
+
generate_release_notes: true
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Warden
|
|
2
|
+
|
|
3
|
+
permissions:
|
|
4
|
+
contents: read
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
pull_request:
|
|
8
|
+
types: [opened, synchronize, reopened]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
review:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
env:
|
|
14
|
+
WARDEN_ANTHROPIC_API_KEY: ${{ secrets.WARDEN_ANTHROPIC_API_KEY }}
|
|
15
|
+
WARDEN_MODEL: ${{ secrets.WARDEN_MODEL }}
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- uses: pnpm/action-setup@v4
|
|
20
|
+
with:
|
|
21
|
+
version: 9
|
|
22
|
+
|
|
23
|
+
- uses: actions/setup-node@v4
|
|
24
|
+
with:
|
|
25
|
+
node-version: '20'
|
|
26
|
+
cache: 'pnpm'
|
|
27
|
+
|
|
28
|
+
- run: pnpm install --frozen-lockfile
|
|
29
|
+
- run: pnpm build
|
|
30
|
+
- run: pnpm build:action
|
|
31
|
+
|
|
32
|
+
- uses: actions/create-github-app-token@v1
|
|
33
|
+
id: app-token
|
|
34
|
+
with:
|
|
35
|
+
app-id: ${{ secrets.WARDEN_APP_ID }}
|
|
36
|
+
private-key: ${{ secrets.WARDEN_PRIVATE_KEY }}
|
|
37
|
+
|
|
38
|
+
- uses: ./
|
|
39
|
+
with:
|
|
40
|
+
github-token: ${{ steps.app-token.outputs.token }}
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Agent Instructions
|
|
2
|
+
|
|
3
|
+
## Package Manager
|
|
4
|
+
|
|
5
|
+
Use **pnpm**: `pnpm install`, `pnpm build`, `pnpm test`
|
|
6
|
+
|
|
7
|
+
## Commit Attribution
|
|
8
|
+
|
|
9
|
+
AI commits MUST include:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Co-Authored-By: <model name> <noreply@anthropic.com>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Example: `Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>`
|
|
16
|
+
|
|
17
|
+
## Architecture
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
src/
|
|
21
|
+
├── index.ts # Library entry point
|
|
22
|
+
├── types/ # Zod schemas and types
|
|
23
|
+
├── config/ # Config loading (warden.toml)
|
|
24
|
+
├── triggers/ # Event trigger matching
|
|
25
|
+
├── event/ # GitHub event parsing
|
|
26
|
+
├── diff/ # Diff parsing and context
|
|
27
|
+
├── output/ # Report rendering
|
|
28
|
+
├── skills/ # Skill discovery and loading
|
|
29
|
+
├── sdk/ # Claude Code SDK runner
|
|
30
|
+
├── cli/ # CLI entry and commands
|
|
31
|
+
│ └── output/ # CLI output formatting
|
|
32
|
+
├── action/ # GitHub Action entry
|
|
33
|
+
├── utils/ # Shared utilities
|
|
34
|
+
└── examples/ # Example configurations
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Key Conventions
|
|
38
|
+
|
|
39
|
+
- TypeScript strict mode
|
|
40
|
+
- Zod for runtime validation
|
|
41
|
+
- ESM modules (`"type": "module"`)
|
|
42
|
+
- Vitest for testing
|
|
43
|
+
|
|
44
|
+
## TypeScript Exports
|
|
45
|
+
|
|
46
|
+
Use `export type` for type-only exports. This is required for Bun compatibility:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
// Good
|
|
50
|
+
export type { SkillReport } from "./types/index.js";
|
|
51
|
+
export { runSkill } from "./sdk/runner.js";
|
|
52
|
+
|
|
53
|
+
// Bad - fails in Bun
|
|
54
|
+
export { SkillReport, runSkill } from "./types/index.js";
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Testing
|
|
58
|
+
|
|
59
|
+
**Always reference `/testing-guidelines` when writing tests.** Key principles:
|
|
60
|
+
|
|
61
|
+
- Mock external services, use sanitized real-world fixtures
|
|
62
|
+
- Prefer integration tests over unit tests
|
|
63
|
+
- Always add regression tests for bugs
|
|
64
|
+
- Cover every user entry point with at least a happy-path test
|
|
65
|
+
- Co-locate tests with source (`foo.ts` → `foo.test.ts`)
|
|
66
|
+
|
|
67
|
+
## Verifying Changes
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pnpm lint && pnpm build && pnpm test
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Task Management
|
|
74
|
+
|
|
75
|
+
Use `/dex` to break down complex work, track progress across sessions, and coordinate multi-step implementations.
|
|
76
|
+
|
|
77
|
+
## Skills Policy
|
|
78
|
+
|
|
79
|
+
Skills define **what to look for**, not how to respond to findings:
|
|
80
|
+
|
|
81
|
+
- When Warden reports findings, fix the code. Don't modify skills to suppress results
|
|
82
|
+
- Skills should only change to improve detection accuracy, not to reduce reported findings
|
|
83
|
+
- Each skill owns its domain expertise; severity definitions are intentionally domain-agnostic
|
|
84
|
+
|
|
85
|
+
## Voice
|
|
86
|
+
|
|
87
|
+
Warden watches over your code. Not "AI code reviewer" or similar.
|
|
88
|
+
|
|
89
|
+
Keep it brief, dry, and slightly ominous. Think security guard who's seen everything. Professional but with personality. No fluff, no hype, no em-dashes.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Contributing to Warden
|
|
2
|
+
|
|
3
|
+
## Prerequisites
|
|
4
|
+
|
|
5
|
+
- Node.js >= 20.0.0
|
|
6
|
+
- pnpm (install via `npm install -g pnpm`)
|
|
7
|
+
- An Anthropic API key for running skills
|
|
8
|
+
|
|
9
|
+
## Setup
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm install
|
|
13
|
+
pnpm build
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Development
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm dev # Watch mode (rebuilds on changes)
|
|
20
|
+
pnpm typecheck # Type check
|
|
21
|
+
pnpm lint # Lint
|
|
22
|
+
pnpm test # Run unit tests in watch mode
|
|
23
|
+
pnpm test:run # Run unit tests once
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Testing Locally
|
|
27
|
+
|
|
28
|
+
The CLI runs skills against local git changes. Set up your API key and run it:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Create .env.local (gitignored)
|
|
32
|
+
echo 'WARDEN_ANTHROPIC_API_KEY=sk-ant-...' > .env.local
|
|
33
|
+
|
|
34
|
+
# Run against uncommitted changes
|
|
35
|
+
pnpm cli run
|
|
36
|
+
|
|
37
|
+
# Run against recent commits
|
|
38
|
+
pnpm cli run --base HEAD~3
|
|
39
|
+
|
|
40
|
+
# Run against a branch
|
|
41
|
+
pnpm cli run --base origin/main
|
|
42
|
+
|
|
43
|
+
# Run a specific skill
|
|
44
|
+
pnpm cli run --skill security-review
|
|
45
|
+
|
|
46
|
+
# JSON output
|
|
47
|
+
pnpm cli run --json
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Project Structure
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
src/
|
|
54
|
+
├── action/ # GitHub Action entry point
|
|
55
|
+
├── cli/ # Local CLI
|
|
56
|
+
├── config/ # Config loading (warden.toml)
|
|
57
|
+
├── skills/ # Built-in skills
|
|
58
|
+
├── triggers/ # Trigger matching logic
|
|
59
|
+
└── types/ # Type definitions
|
|
60
|
+
```
|