@sentry/warden 0.20.0 → 0.22.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/CHANGELOG.md +353 -0
- package/README.md +3 -3
- package/dist/cli/args.d.ts +7 -5
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +31 -17
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/commands/runs.d.ts +26 -0
- package/dist/cli/commands/runs.d.ts.map +1 -0
- package/dist/cli/commands/runs.js +726 -0
- package/dist/cli/commands/runs.js.map +1 -0
- package/dist/cli/log-cleanup.d.ts.map +1 -1
- package/dist/cli/log-cleanup.js +4 -0
- package/dist/cli/log-cleanup.js.map +1 -1
- package/dist/cli/main.d.ts +15 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +428 -128
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/output/index.d.ts +1 -1
- package/dist/cli/output/index.d.ts.map +1 -1
- package/dist/cli/output/index.js +1 -1
- package/dist/cli/output/index.js.map +1 -1
- package/dist/cli/output/ink-runner.d.ts.map +1 -1
- package/dist/cli/output/ink-runner.js +50 -14
- package/dist/cli/output/ink-runner.js.map +1 -1
- package/dist/cli/output/jsonl-schema-gen.d.ts +16 -0
- package/dist/cli/output/jsonl-schema-gen.d.ts.map +1 -0
- package/dist/cli/output/jsonl-schema-gen.js +65 -0
- package/dist/cli/output/jsonl-schema-gen.js.map +1 -0
- package/dist/cli/output/jsonl.d.ts +266 -26
- package/dist/cli/output/jsonl.d.ts.map +1 -1
- package/dist/cli/output/jsonl.js +377 -139
- package/dist/cli/output/jsonl.js.map +1 -1
- package/dist/cli/output/tasks.d.ts +6 -1
- package/dist/cli/output/tasks.d.ts.map +1 -1
- package/dist/cli/output/tasks.js +183 -27
- package/dist/cli/output/tasks.js.map +1 -1
- package/dist/cli/terminal.d.ts.map +1 -1
- package/dist/cli/terminal.js +20 -0
- package/dist/cli/terminal.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/sdk/analyze.d.ts.map +1 -1
- package/dist/sdk/analyze.js +103 -10
- package/dist/sdk/analyze.js.map +1 -1
- package/dist/sdk/errors.d.ts +11 -0
- package/dist/sdk/errors.d.ts.map +1 -1
- package/dist/sdk/errors.js +50 -0
- package/dist/sdk/errors.js.map +1 -1
- package/dist/sdk/runner.d.ts +1 -1
- package/dist/sdk/runner.d.ts.map +1 -1
- package/dist/sdk/types.d.ts +28 -1
- package/dist/sdk/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +130 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +72 -3
- package/dist/types/index.js.map +1 -1
- package/package.json +2 -1
- package/skills/warden/SKILL.md +5 -5
- package/skills/warden/SOURCES.md +39 -0
- package/skills/warden/references/cli-reference.md +11 -4
- package/skills/warden/references/config-schema.md +9 -0
- package/skills/warden/references/configuration.md +9 -0
- package/skills/warden-sweep/SKILL.md +43 -365
- package/skills/warden-sweep/SOURCES.md +43 -0
- package/skills/warden-sweep/references/issue-phase.md +24 -0
- package/skills/warden-sweep/references/organize-phase.md +31 -0
- package/skills/warden-sweep/references/patch-phase.md +142 -0
- package/skills/warden-sweep/references/resume-and-artifacts.md +51 -0
- package/skills/warden-sweep/references/scan-phase.md +46 -0
- package/skills/warden-sweep/references/script-interfaces.md +127 -0
- package/skills/warden-sweep/references/verify-phase.md +69 -0
- package/dist/cli/commands/logs.d.ts +0 -19
- package/dist/cli/commands/logs.d.ts.map +0 -1
- package/dist/cli/commands/logs.js +0 -412
- package/dist/cli/commands/logs.js.map +0 -1
|
@@ -1,350 +1,70 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: warden-sweep
|
|
3
|
-
description: Full-repository code sweep. Scans every file with
|
|
3
|
+
description: Full-repository code sweep. Scans every file with Warden, verifies findings through deep tracing, creates draft PRs for validated issues. Use when asked to "sweep the repo", "scan everything", "find all bugs", "full codebase review", "batch code analysis", or run Warden across the entire repository.
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Warden Sweep
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Run a full-repository Warden sweep: scan files, verify findings, create a tracking issue, open draft PRs for validated issues, and organize the final report.
|
|
10
10
|
|
|
11
|
-
**Requires**: `warden`, `gh`, `git`, `jq`, `uv
|
|
11
|
+
**Requires**: `warden`, `gh`, `git`, `jq`, `uv`.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Run commands from the repository root. Use the host's skill-root path for bundled scripts and references.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Output goes to `.warden/sweeps/<run-id>/`.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## References
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Load only the reference for the current phase:
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### `scripts/create_issue.py`
|
|
35
|
-
|
|
36
|
-
Creates a GitHub tracking issue summarizing sweep results. Run after verification, before patching.
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
uv run ${CLAUDE_SKILL_ROOT}/scripts/create_issue.py <sweep-dir>
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### `scripts/organize.py`
|
|
43
|
-
|
|
44
|
-
Tags security findings, labels security PRs, updates finding reports with PR links, posts final results to tracking issue, generates summary report, finalizes manifest.
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
uv run ${CLAUDE_SKILL_ROOT}/scripts/organize.py <sweep-dir>
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### `scripts/extract_findings.py`
|
|
51
|
-
|
|
52
|
-
Parses warden JSONL log files and extracts normalized findings. Called automatically by `scan.py`.
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
uv run ${CLAUDE_SKILL_ROOT}/scripts/extract_findings.py <log-path-or-directory> -o <output.jsonl>
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### `scripts/generate_report.py`
|
|
59
|
-
|
|
60
|
-
Builds `summary.md` and `report.json` from sweep data. Called automatically by `organize.py`.
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
uv run ${CLAUDE_SKILL_ROOT}/scripts/generate_report.py <sweep-dir>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### `scripts/find_reviewers.py`
|
|
67
|
-
|
|
68
|
-
Finds top 2 git contributors for a file (last 12 months).
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
uv run ${CLAUDE_SKILL_ROOT}/scripts/find_reviewers.py <file-path>
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Returns JSON: `{"reviewers": ["user1", "user2"]}`
|
|
75
|
-
|
|
76
|
-
---
|
|
77
|
-
|
|
78
|
-
## Phase 1: Scan
|
|
79
|
-
|
|
80
|
-
**Run** (1 tool call):
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
uv run ${CLAUDE_SKILL_ROOT}/scripts/scan.py
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
To resume a partial scan:
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
uv run ${CLAUDE_SKILL_ROOT}/scripts/scan.py --sweep-dir .warden/sweeps/<run-id>
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Parse the JSON stdout. Save `runId` and `sweepDir` for subsequent phases.
|
|
93
|
-
|
|
94
|
-
**Report** to user:
|
|
95
|
-
|
|
96
|
-
```
|
|
97
|
-
## Scan Complete
|
|
98
|
-
|
|
99
|
-
Scanned **{filesScanned}** files, **{filesTimedOut}** timed out, **{filesErrored}** errors.
|
|
100
|
-
|
|
101
|
-
### Findings ({totalFindings} total)
|
|
102
|
-
|
|
103
|
-
| # | Severity | Skill | File | Title |
|
|
104
|
-
|---|----------|-------|------|-------|
|
|
105
|
-
| 1 | **HIGH** | security-review | `src/db/query.ts:42` | SQL injection in query builder |
|
|
106
|
-
...
|
|
107
|
-
```
|
|
21
|
+
| Need | Read |
|
|
22
|
+
|------|------|
|
|
23
|
+
| Script arguments, outputs, and side effects | `references/script-interfaces.md` |
|
|
24
|
+
| Phase 1 scan workflow | `references/scan-phase.md` |
|
|
25
|
+
| Phase 2 verification workflow | `references/verify-phase.md` |
|
|
26
|
+
| Phase 3 tracking issue workflow | `references/issue-phase.md` |
|
|
27
|
+
| Phase 4 patch and draft PR workflow | `references/patch-phase.md` |
|
|
28
|
+
| Phase 5 organize and final report workflow | `references/organize-phase.md` |
|
|
29
|
+
| Resume behavior and artifact layout | `references/resume-and-artifacts.md` |
|
|
30
|
+
| Verification task prompt template | `references/verify-prompt.md` |
|
|
31
|
+
| Patch task prompt template | `references/patch-prompt.md` |
|
|
108
32
|
|
|
109
|
-
|
|
33
|
+
## Workflow
|
|
110
34
|
|
|
111
|
-
|
|
35
|
+
Track progress across phases:
|
|
112
36
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
37
|
+
- [ ] Phase 1: Scan repository files with Warden.
|
|
38
|
+
- [ ] Phase 2: Verify findings before patching.
|
|
39
|
+
- [ ] Phase 3: Create a tracking issue.
|
|
40
|
+
- [ ] Phase 4: Patch verified findings and open draft PRs.
|
|
41
|
+
- [ ] Phase 5: Organize results and produce the final report.
|
|
118
42
|
|
|
119
|
-
|
|
43
|
+
## Phase Order
|
|
120
44
|
|
|
121
|
-
|
|
45
|
+
1. Read `references/script-interfaces.md` once before running scripts.
|
|
46
|
+
2. Run Phase 1 from `references/scan-phase.md`. Save `runId` and `sweepDir`.
|
|
47
|
+
3. Run Phase 2 from `references/verify-phase.md`. Verify every finding before patching.
|
|
48
|
+
4. Run Phase 3 from `references/issue-phase.md`. Continue if issue creation fails.
|
|
49
|
+
5. Run Phase 4 from `references/patch-phase.md`. Patch sequentially, one finding at a time.
|
|
50
|
+
6. Run Phase 5 from `references/organize-phase.md`.
|
|
51
|
+
7. For interrupted or partial runs, read `references/resume-and-artifacts.md` and continue from the first incomplete phase.
|
|
122
52
|
|
|
123
|
-
|
|
53
|
+
## Non-Negotiable Rules
|
|
124
54
|
|
|
125
|
-
|
|
55
|
+
- Verify findings before creating fixes.
|
|
56
|
+
- Use draft PRs for generated patches.
|
|
57
|
+
- Branch every patch from the repository default branch.
|
|
58
|
+
- Patch findings sequentially; do not run patch workers in parallel.
|
|
59
|
+
- Skip existing entries in sweep artifacts instead of duplicating work.
|
|
60
|
+
- Record failures in sweep data and continue to the next finding when possible.
|
|
61
|
+
- Clean up each worktree after patch success or failure.
|
|
126
62
|
|
|
127
|
-
|
|
63
|
+
## Final Response
|
|
128
64
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
Parse the JSON from the subagent response and:
|
|
132
|
-
- Write result to `data/verify/<finding-id>.json`
|
|
133
|
-
- Append to `data/verified.jsonl` or `data/rejected.jsonl`
|
|
134
|
-
- For verified findings, generate `findings/<finding-id>.md`:
|
|
65
|
+
After organizing, report:
|
|
135
66
|
|
|
136
67
|
```markdown
|
|
137
|
-
# ${TITLE}
|
|
138
|
-
|
|
139
|
-
**ID**: ${FINDING_ID} | **Severity**: ${SEVERITY} | **Confidence**: ${CONFIDENCE}
|
|
140
|
-
**Skill**: ${SKILL} | **File**: ${FILE_PATH}:${START_LINE}
|
|
141
|
-
|
|
142
|
-
## Description
|
|
143
|
-
${DESCRIPTION}
|
|
144
|
-
|
|
145
|
-
## Verification
|
|
146
|
-
**Verdict**: Verified (${VERIFICATION_CONFIDENCE})
|
|
147
|
-
**Reasoning**: ${REASONING}
|
|
148
|
-
**Code trace**: ${TRACE_NOTES}
|
|
149
|
-
|
|
150
|
-
## Suggested Fix
|
|
151
|
-
${FIX_DESCRIPTION}
|
|
152
|
-
```diff
|
|
153
|
-
${FIX_DIFF}
|
|
154
|
-
```
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
Update manifest: set `phases.verify` to `"complete"`.
|
|
158
|
-
|
|
159
|
-
**Report** to user after all verifications:
|
|
160
|
-
|
|
161
|
-
```
|
|
162
|
-
## Verification Complete
|
|
163
|
-
|
|
164
|
-
**{verified}** verified, **{rejected}** rejected.
|
|
165
|
-
|
|
166
|
-
### Verified Findings
|
|
167
|
-
|
|
168
|
-
| # | Severity | Confidence | File | Title | Reasoning |
|
|
169
|
-
|---|----------|------------|------|-------|-----------|
|
|
170
|
-
| 1 | **HIGH** | high | `src/db/query.ts:42` | SQL injection in query builder | User input flows directly into... |
|
|
171
|
-
...
|
|
172
|
-
|
|
173
|
-
### Rejected ({rejected_count})
|
|
174
|
-
|
|
175
|
-
- `{findingId}` {file}: {reasoning}
|
|
176
|
-
...
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
## Phase 3: Issue
|
|
182
|
-
|
|
183
|
-
Create a tracking issue that ties all PRs together and gives reviewers a single overview.
|
|
184
|
-
|
|
185
|
-
**Run** (1 tool call):
|
|
186
|
-
|
|
187
|
-
```bash
|
|
188
|
-
uv run ${CLAUDE_SKILL_ROOT}/scripts/create_issue.py ${SWEEP_DIR}
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
Parse the JSON stdout. Save `issueUrl` and `issueNumber` for Phase 4.
|
|
192
|
-
|
|
193
|
-
**Report** to user:
|
|
194
|
-
|
|
195
|
-
```
|
|
196
|
-
## Tracking Issue Created
|
|
197
|
-
|
|
198
|
-
{issueUrl}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
**On failure**: Show the error. Continue to Phase 4 (PRs can still be created without a tracking issue).
|
|
202
|
-
|
|
203
|
-
---
|
|
204
|
-
|
|
205
|
-
## Phase 4: Patch
|
|
206
|
-
|
|
207
|
-
For each verified finding, create a worktree, fix the code, and open a draft PR. Process findings **sequentially** (one at a time) since parallel subagents cross-contaminate worktrees.
|
|
208
|
-
|
|
209
|
-
**Severity triage**: Patch HIGH and above. For MEDIUM, only patch findings from bug-detection skills (e.g., `code-review`, `security-review`). Skip LOW and INFO findings.
|
|
210
|
-
|
|
211
|
-
**Step 0: Setup** (run once before the loop):
|
|
212
|
-
|
|
213
|
-
```bash
|
|
214
|
-
uv run ${CLAUDE_SKILL_ROOT}/scripts/index_prs.py ${SWEEP_DIR}
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
Parse the JSON stdout. Use `fileIndex` for dedup checks.
|
|
218
|
-
|
|
219
|
-
Determine the default branch and fetch latest so worktrees branch from current upstream:
|
|
220
|
-
|
|
221
|
-
```bash
|
|
222
|
-
DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')
|
|
223
|
-
git fetch origin "${DEFAULT_BRANCH}"
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
**For each finding in `data/verified.jsonl`:**
|
|
227
|
-
|
|
228
|
-
Check if finding ID already exists in `data/patches.jsonl` (incrementality). If it does, skip.
|
|
229
|
-
|
|
230
|
-
**Dedup check**: Use the file index from `index_prs.py` output to determine if an existing open PR already addresses the same issue.
|
|
231
|
-
|
|
232
|
-
1. **File match**: Look up the finding's file path in the `fileIndex`. If no PR touches that file, no conflict; proceed to Step 1.
|
|
233
|
-
2. **Chunk overlap**: If a PR does touch the same file, read its cached diff from `data/pr-diffs/<number>.diff` and check whether the PR's changed hunks overlap with the finding's line range (startLine-endLine). Overlapping or adjacent hunks (within ~10 lines) indicate the same code region.
|
|
234
|
-
3. **Same concern**: If the hunks overlap, compare the PR title and the finding title/description. Are they fixing the same kind of defect? A PR fixing an off-by-one error and a finding about a null check in the same function are different issues; both should proceed.
|
|
235
|
-
|
|
236
|
-
Skip the finding only when there is both chunk overlap AND the PR addresses the same concern. Record it in `data/patches.jsonl` with `"status": "existing"` and `"prUrl"` pointing to the matching PR, then continue to the next finding.
|
|
237
|
-
|
|
238
|
-
**Step 1: Create worktree**
|
|
239
|
-
|
|
240
|
-
```bash
|
|
241
|
-
BRANCH="warden-sweep/${RUN_ID}/${FINDING_ID}"
|
|
242
|
-
WORKTREE="${SWEEP_DIR}/worktrees/${FINDING_ID}"
|
|
243
|
-
git worktree add "${WORKTREE}" -b "${BRANCH}" "origin/${DEFAULT_BRANCH}"
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
Each finding branches from the repo's default branch so PRs contain only the fix commit.
|
|
247
|
-
|
|
248
|
-
**Step 2: Generate fix**
|
|
249
|
-
|
|
250
|
-
Launch a Task subagent (`subagent_type: "general-purpose"`) to apply the fix in the worktree. Read `${CLAUDE_SKILL_ROOT}/references/patch-prompt.md` for the prompt template. Substitute the finding's values and worktree path into the `${...}` placeholders.
|
|
251
|
-
|
|
252
|
-
**Step 2b: Handle skipped findings**
|
|
253
|
-
|
|
254
|
-
If the subagent returned `"status": "skipped"` (not `"applied"`), do NOT proceed to Steps 3-4. Instead:
|
|
255
|
-
1. Record the finding in `data/patches.jsonl` with `"status": "error"` and `"error": "Subagent skipped: ${skipReason}"`
|
|
256
|
-
2. Clean up the worktree
|
|
257
|
-
3. Continue to the next finding
|
|
258
|
-
|
|
259
|
-
**Step 3: Find reviewers**
|
|
260
|
-
|
|
261
|
-
```bash
|
|
262
|
-
uv run ${CLAUDE_SKILL_ROOT}/scripts/find_reviewers.py "${FILE_PATH}"
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
**Step 4: Create draft PR**
|
|
266
|
-
|
|
267
|
-
```bash
|
|
268
|
-
cd "${WORKTREE}" && git push -u origin HEAD:"${BRANCH}"
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
Create the PR with a 1-2 sentence "What" summary based on the finding and fix, followed by the finding description and verification reasoning:
|
|
272
|
-
|
|
273
|
-
```bash
|
|
274
|
-
REVIEWERS=""
|
|
275
|
-
# If find_reviewers.py returned reviewers, build the flags
|
|
276
|
-
# e.g., REVIEWERS="--reviewer user1 --reviewer user2"
|
|
277
|
-
|
|
278
|
-
gh pr create --draft \
|
|
279
|
-
--label "warden" \
|
|
280
|
-
--title "fix: ${TITLE}" \
|
|
281
|
-
--body "$(cat <<'EOF'
|
|
282
|
-
${FIX_WHAT_DESCRIPTION}
|
|
283
|
-
|
|
284
|
-
${DESCRIPTION}
|
|
285
|
-
|
|
286
|
-
${REASONING}
|
|
287
|
-
|
|
288
|
-
Automated fix for Warden finding ${FINDING_ID} (${SEVERITY}, detected by ${SKILL}).
|
|
289
|
-
|
|
290
|
-
<!-- Only include the next line if Phase 3 succeeded and ISSUE_NUMBER is available -->
|
|
291
|
-
Ref #${ISSUE_NUMBER}
|
|
292
|
-
|
|
293
|
-
> This PR was auto-generated by a Warden Sweep (run ${RUN_ID}).
|
|
294
|
-
> The finding has been validated through automated deep tracing,
|
|
295
|
-
> but human confirmation is requested as this is batch work.
|
|
296
|
-
EOF
|
|
297
|
-
)" ${REVIEWERS}
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
Save the PR URL.
|
|
301
|
-
|
|
302
|
-
**Step 5: Record and cleanup**
|
|
303
|
-
|
|
304
|
-
Append to `data/patches.jsonl` (use `"created"` as status for successful PRs, not the subagent's `"applied"`):
|
|
305
|
-
```json
|
|
306
|
-
{"findingId": "...", "prUrl": "https://...", "branch": "...", "reviewers": ["user1", "user2"], "filesChanged": ["..."], "status": "created|existing|error"}
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
Remove the worktree:
|
|
310
|
-
```bash
|
|
311
|
-
cd "$(git rev-parse --show-toplevel)"
|
|
312
|
-
git worktree remove "${WORKTREE}" --force
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
**Error handling**: On failure at any step, write to `data/patches.jsonl` with `"status": "error"` and `"error": "..."`, clean up the worktree, and continue to the next finding.
|
|
316
|
-
|
|
317
|
-
Update manifest: set `phases.patch` to `"complete"`.
|
|
318
|
-
|
|
319
|
-
**Report** to user after all patches:
|
|
320
|
-
|
|
321
|
-
```
|
|
322
|
-
## PRs Created
|
|
323
|
-
|
|
324
|
-
**{created}** created, **{skipped}** skipped (existing), **{failed}** failed.
|
|
325
|
-
|
|
326
|
-
| # | Finding | PR | Status |
|
|
327
|
-
|---|---------|-----|--------|
|
|
328
|
-
| 1 | `security-review-a1b2c3d4` SQL injection in query builder | #142 | created |
|
|
329
|
-
| 2 | `code-review-e5f6g7h8` Null pointer in handler | - | existing (#138) |
|
|
330
|
-
...
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
---
|
|
334
|
-
|
|
335
|
-
## Phase 5: Organize
|
|
336
|
-
|
|
337
|
-
**Run** (1 tool call):
|
|
338
|
-
|
|
339
|
-
```bash
|
|
340
|
-
uv run ${CLAUDE_SKILL_ROOT}/scripts/organize.py ${SWEEP_DIR}
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
Parse the JSON stdout.
|
|
344
|
-
|
|
345
|
-
**Report** to user:
|
|
346
|
-
|
|
347
|
-
```
|
|
348
68
|
## Sweep Complete
|
|
349
69
|
|
|
350
70
|
| Metric | Count |
|
|
@@ -356,45 +76,3 @@ Parse the JSON stdout.
|
|
|
356
76
|
|
|
357
77
|
Full report: `{summaryPath}`
|
|
358
78
|
```
|
|
359
|
-
|
|
360
|
-
**On failure**: Show the error and note which steps completed.
|
|
361
|
-
|
|
362
|
-
---
|
|
363
|
-
|
|
364
|
-
## Resuming a Sweep
|
|
365
|
-
|
|
366
|
-
Each phase is incremental. To resume from where you left off:
|
|
367
|
-
|
|
368
|
-
1. Check `data/manifest.json` to see which phases are complete
|
|
369
|
-
2. For scan: pass `--sweep-dir` to `scan.py`
|
|
370
|
-
3. For verify: existing `data/verify/<id>.json` files are skipped
|
|
371
|
-
4. For issue: `create_issue.py` is idempotent (skips if `issueUrl` in manifest)
|
|
372
|
-
5. For patch: existing entries in `data/patches.jsonl` are skipped
|
|
373
|
-
6. For organize: safe to re-run (idempotent)
|
|
374
|
-
|
|
375
|
-
## Output Directory Structure
|
|
376
|
-
|
|
377
|
-
```
|
|
378
|
-
.warden/sweeps/<run-id>/
|
|
379
|
-
summary.md # Stats, key findings, PR links
|
|
380
|
-
findings/ # One markdown per verified finding
|
|
381
|
-
<finding-id>.md
|
|
382
|
-
security/ # Security-specific view
|
|
383
|
-
index.jsonl # Security findings index
|
|
384
|
-
<finding-id>.md # Copies of security findings
|
|
385
|
-
data/ # Structured data for tooling
|
|
386
|
-
manifest.json # Run metadata, phase state
|
|
387
|
-
scan-index.jsonl # Per-file scan tracking
|
|
388
|
-
all-findings.jsonl # Every finding from scan
|
|
389
|
-
verified.jsonl # Findings that passed verification
|
|
390
|
-
rejected.jsonl # Findings that failed verification
|
|
391
|
-
patches.jsonl # Finding -> PR URL -> reviewers
|
|
392
|
-
existing-prs.json # Cached open warden PRs
|
|
393
|
-
report.json # Machine-readable summary
|
|
394
|
-
verify/ # Individual verification results
|
|
395
|
-
<finding-id>.json
|
|
396
|
-
logs/ # Warden JSONL logs per file
|
|
397
|
-
<hash>.jsonl
|
|
398
|
-
pr-diffs/ # Cached PR diffs for dedup
|
|
399
|
-
<number>.diff
|
|
400
|
-
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Warden Sweep Sources
|
|
2
|
+
|
|
3
|
+
## Source Inventory
|
|
4
|
+
|
|
5
|
+
| Source | Trust tier | Confidence | Usage constraints |
|
|
6
|
+
|--------|------------|------------|-------------------|
|
|
7
|
+
| `skills/warden-sweep/SKILL.md` | canonical runtime | high | Keep as router and phase overview. |
|
|
8
|
+
| `skills/warden-sweep/references/*.md` | bundled runtime references | high | Keep focused by phase or lookup need. |
|
|
9
|
+
| `skills/warden-sweep/scripts/*.py` | executable workflow | high | Script interfaces in references must match these files. |
|
|
10
|
+
| `src/cli/output/jsonl.ts` | Warden output contract | high | Verify JSONL parsing assumptions when Warden output changes. |
|
|
11
|
+
| `src/output/renderer.ts` and `src/types/` | finding/report semantics | high | Verify severity, confidence, and finding fields here. |
|
|
12
|
+
| GitHub CLI commands used by scripts | external tool contract | medium | Confirm command flags when GitHub CLI behavior changes. |
|
|
13
|
+
|
|
14
|
+
## Coverage Matrix
|
|
15
|
+
|
|
16
|
+
| Dimension | Coverage status | Evidence |
|
|
17
|
+
|-----------|-----------------|----------|
|
|
18
|
+
| Workflow phases | covered | `SKILL.md` routes scan, verify, issue, patch, organize, and resume behavior to focused references. |
|
|
19
|
+
| Script interfaces | covered | `references/script-interfaces.md` lists scripts, arguments, outputs, and side effects. |
|
|
20
|
+
| Artifact schema | covered | `references/resume-and-artifacts.md` documents directories and key JSONL/JSON files. |
|
|
21
|
+
| Verification behavior | covered | `references/verify-phase.md` and `references/verify-prompt.md` define qualification and rejection behavior. |
|
|
22
|
+
| Patch behavior | covered | `references/patch-phase.md` and `references/patch-prompt.md` define triage, worktree isolation, draft PR creation, and cleanup. |
|
|
23
|
+
| Known issues/workarounds | partial | Resume, partial scans, skipped findings, and existing PR dedup are covered; CI follow-up and rate-limit recovery are not. |
|
|
24
|
+
| Version/migration variance | partial | Current artifact names and script interfaces are documented; no formal migration path exists for old sweep directories. |
|
|
25
|
+
|
|
26
|
+
## Decisions
|
|
27
|
+
|
|
28
|
+
- Split phase detail out of `SKILL.md` so agents load only the current phase instructions.
|
|
29
|
+
- Keep script interface documentation separate from phase runbooks because scripts are reused across phases and by resume workflows.
|
|
30
|
+
- Describe verification and patch work in host-neutral terms while allowing parallel agent tasks when the host supports them.
|
|
31
|
+
- Keep prompt templates as separate references because they are substituted into delegated verification and patch work.
|
|
32
|
+
- Keep generated sweep artifacts under `.warden/sweeps/<run-id>/` so runs are resumable and isolated from normal source files.
|
|
33
|
+
|
|
34
|
+
## Open Gaps
|
|
35
|
+
|
|
36
|
+
- Add a redacted fixture sweep to validate the full workflow without touching real GitHub repositories.
|
|
37
|
+
- Document rate-limit and permission failure recovery if these become common in real sweeps.
|
|
38
|
+
- Add migration notes if artifact schemas change after users have existing sweep directories.
|
|
39
|
+
- Consider adding a script-level dry-run mode for issue and PR creation.
|
|
40
|
+
|
|
41
|
+
## Changelog
|
|
42
|
+
|
|
43
|
+
- 2026-04-27: Reverse-engineered maintenance spec and split the distributed `warden-sweep` workflow into phase references.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Issue Phase
|
|
2
|
+
|
|
3
|
+
Create a tracking issue that ties all generated PRs together and gives reviewers one overview.
|
|
4
|
+
|
|
5
|
+
## Run
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
uv run <skill-root>/scripts/create_issue.py ${SWEEP_DIR}
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Process
|
|
12
|
+
|
|
13
|
+
1. Parse the JSON stdout.
|
|
14
|
+
2. Save `issueUrl` and `issueNumber`.
|
|
15
|
+
3. If the script fails, show the error and continue to the patch phase. PRs can still be created without a tracking issue.
|
|
16
|
+
4. Update the checklist: Phase 3 complete.
|
|
17
|
+
|
|
18
|
+
## Report Template
|
|
19
|
+
|
|
20
|
+
```markdown
|
|
21
|
+
## Tracking Issue Created
|
|
22
|
+
|
|
23
|
+
{issueUrl}
|
|
24
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Organize Phase
|
|
2
|
+
|
|
3
|
+
Finalize sweep artifacts, security views, PR links, and the summary report.
|
|
4
|
+
|
|
5
|
+
## Run
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
uv run <skill-root>/scripts/organize.py ${SWEEP_DIR}
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Process
|
|
12
|
+
|
|
13
|
+
1. Parse the JSON stdout.
|
|
14
|
+
2. Confirm `summary.md` and `data/report.json` were produced.
|
|
15
|
+
3. If the script fails, show the error and note which phases completed.
|
|
16
|
+
4. Update the checklist: Phase 5 complete.
|
|
17
|
+
|
|
18
|
+
## Report Template
|
|
19
|
+
|
|
20
|
+
```markdown
|
|
21
|
+
## Sweep Complete
|
|
22
|
+
|
|
23
|
+
| Metric | Count |
|
|
24
|
+
|--------|-------|
|
|
25
|
+
| Files scanned | {filesScanned} |
|
|
26
|
+
| Findings verified | {verified} |
|
|
27
|
+
| PRs created | {prsCreated} |
|
|
28
|
+
| Security findings | {securityFindings} |
|
|
29
|
+
|
|
30
|
+
Full report: `{summaryPath}`
|
|
31
|
+
```
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Patch Phase
|
|
2
|
+
|
|
3
|
+
Create isolated fixes for verified findings and open draft PRs.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- Rules
|
|
8
|
+
- Setup
|
|
9
|
+
- Per-Finding Process
|
|
10
|
+
- Dedup Check
|
|
11
|
+
- Worktree, Fix, Reviewers, And PR
|
|
12
|
+
- Report Template
|
|
13
|
+
|
|
14
|
+
## Rules
|
|
15
|
+
|
|
16
|
+
- Patch high-severity and above.
|
|
17
|
+
- Patch medium findings only when they come from bug-detection skills such as `code-review` or `security-review`.
|
|
18
|
+
- Skip low and info findings.
|
|
19
|
+
- Process findings sequentially.
|
|
20
|
+
- Create one worktree and one branch per finding.
|
|
21
|
+
- Clean up worktrees after success or failure.
|
|
22
|
+
|
|
23
|
+
## Setup
|
|
24
|
+
|
|
25
|
+
Index existing PRs before patching:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
uv run <skill-root>/scripts/index_prs.py ${SWEEP_DIR}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Parse the JSON stdout and use `fileIndex` for dedup checks.
|
|
32
|
+
|
|
33
|
+
Determine the default branch and fetch latest:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')
|
|
37
|
+
git fetch origin "${DEFAULT_BRANCH}"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Per-Finding Process
|
|
41
|
+
|
|
42
|
+
For each finding in `data/verified.jsonl`:
|
|
43
|
+
|
|
44
|
+
1. If the finding ID already exists in `data/patches.jsonl`, skip it.
|
|
45
|
+
2. Run the dedup check.
|
|
46
|
+
3. Create a worktree.
|
|
47
|
+
4. Apply the fix using `references/patch-prompt.md`.
|
|
48
|
+
5. If the patch task returns `"status": "skipped"`, record an error, clean up the worktree, and continue.
|
|
49
|
+
6. Find reviewers.
|
|
50
|
+
7. Push the branch.
|
|
51
|
+
8. Create a draft PR.
|
|
52
|
+
9. Record the result in `data/patches.jsonl`.
|
|
53
|
+
10. Clean up the worktree.
|
|
54
|
+
|
|
55
|
+
## Dedup Check
|
|
56
|
+
|
|
57
|
+
Use the file index from `index_prs.py`:
|
|
58
|
+
|
|
59
|
+
1. File match: if no open Warden PR touches the finding file, proceed.
|
|
60
|
+
2. Chunk overlap: if a PR touches the same file, read `data/pr-diffs/<number>.diff` and check whether changed hunks overlap or sit within roughly 10 lines of the finding range.
|
|
61
|
+
3. Same concern: compare PR title and finding title/description.
|
|
62
|
+
|
|
63
|
+
Skip the finding only when there is both chunk overlap and the PR addresses the same concern. Record it with `"status": "existing"` and the matching `prUrl`.
|
|
64
|
+
|
|
65
|
+
## Worktree, Fix, Reviewers, And PR
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
BRANCH="warden-sweep/${RUN_ID}/${FINDING_ID}"
|
|
69
|
+
WORKTREE="${SWEEP_DIR}/worktrees/${FINDING_ID}"
|
|
70
|
+
git worktree add "${WORKTREE}" -b "${BRANCH}" "origin/${DEFAULT_BRANCH}"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Each finding branches from the default branch so PRs contain only the fix commit.
|
|
74
|
+
|
|
75
|
+
Run patch work using the host agent's task/delegation mechanism when available. Read `references/patch-prompt.md` and substitute the finding values and worktree path into the `${...}` placeholders.
|
|
76
|
+
|
|
77
|
+
If delegated tasks are not available, apply the prompt instructions yourself in the worktree.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
uv run <skill-root>/scripts/find_reviewers.py "${FILE_PATH}"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
cd "${WORKTREE}" && git push -u origin HEAD:"${BRANCH}"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Create the PR with a short "what" summary followed by the finding description and verification reasoning:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
gh pr create --draft \
|
|
91
|
+
--label "warden" \
|
|
92
|
+
--title "fix: ${TITLE}" \
|
|
93
|
+
--body "$(cat <<'EOF'
|
|
94
|
+
${FIX_WHAT_DESCRIPTION}
|
|
95
|
+
|
|
96
|
+
${DESCRIPTION}
|
|
97
|
+
|
|
98
|
+
${REASONING}
|
|
99
|
+
|
|
100
|
+
Automated fix for Warden finding ${FINDING_ID} (${SEVERITY}, detected by ${SKILL}).
|
|
101
|
+
|
|
102
|
+
<!-- Only include the next line if Phase 3 succeeded and ISSUE_NUMBER is available -->
|
|
103
|
+
Ref #${ISSUE_NUMBER}
|
|
104
|
+
|
|
105
|
+
> This PR was auto-generated by a Warden Sweep (run ${RUN_ID}).
|
|
106
|
+
> The finding has been validated through automated deep tracing,
|
|
107
|
+
> but human confirmation is requested as this is batch work.
|
|
108
|
+
EOF
|
|
109
|
+
)" ${REVIEWERS}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Record Result
|
|
113
|
+
|
|
114
|
+
Append to `data/patches.jsonl`. Use `"created"` for successful PRs, not the patch task's `"applied"` status.
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{"findingId": "...", "prUrl": "https://...", "branch": "...", "reviewers": ["user1", "user2"], "filesChanged": ["..."], "status": "created|existing|error"}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Clean up:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
cd "$(git rev-parse --show-toplevel)"
|
|
124
|
+
git worktree remove "${WORKTREE}" --force
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
On failure at any step, write `"status": "error"` with an `"error"` message, clean up the worktree, and continue.
|
|
128
|
+
|
|
129
|
+
Update the manifest: set `phases.patch` to `"complete"`.
|
|
130
|
+
|
|
131
|
+
## Report Template
|
|
132
|
+
|
|
133
|
+
```markdown
|
|
134
|
+
## PRs Created
|
|
135
|
+
|
|
136
|
+
**{created}** created, **{skipped}** skipped (existing), **{failed}** failed.
|
|
137
|
+
|
|
138
|
+
| # | Finding | PR | Status |
|
|
139
|
+
|---|---------|----|--------|
|
|
140
|
+
| 1 | `security-review-a1b2c3d4` SQL injection in query builder | #142 | created |
|
|
141
|
+
| 2 | `code-review-e5f6g7h8` Null pointer in handler | - | existing (#138) |
|
|
142
|
+
```
|