@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
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Resume And Artifacts
|
|
2
|
+
|
|
3
|
+
Use this reference when resuming a partial sweep or inspecting generated files.
|
|
4
|
+
|
|
5
|
+
## Resume Rules
|
|
6
|
+
|
|
7
|
+
Each phase is incremental:
|
|
8
|
+
|
|
9
|
+
1. Check `data/manifest.json` for phase state.
|
|
10
|
+
2. For scan, pass `--sweep-dir` to `scan.py`.
|
|
11
|
+
3. For verify, skip existing `data/verify/<id>.json` files.
|
|
12
|
+
4. For issue, `create_issue.py` skips if `issueUrl` exists in the manifest.
|
|
13
|
+
5. For patch, skip existing entries in `data/patches.jsonl`.
|
|
14
|
+
6. For organize, rerun safely.
|
|
15
|
+
|
|
16
|
+
Continue from the first incomplete phase. Do not start a new sweep unless the user asks for a clean run.
|
|
17
|
+
|
|
18
|
+
## Output Directory Structure
|
|
19
|
+
|
|
20
|
+
```text
|
|
21
|
+
.warden/sweeps/<run-id>/
|
|
22
|
+
summary.md # Stats, key findings, PR links
|
|
23
|
+
findings/ # One markdown per verified finding
|
|
24
|
+
<finding-id>.md
|
|
25
|
+
security/ # Security-specific view
|
|
26
|
+
index.jsonl # Security findings index
|
|
27
|
+
<finding-id>.md # Copies of security findings
|
|
28
|
+
data/ # Structured data for tooling
|
|
29
|
+
manifest.json # Run metadata, phase state
|
|
30
|
+
scan-index.jsonl # Per-file scan tracking
|
|
31
|
+
all-findings.jsonl # Every finding from scan
|
|
32
|
+
verified.jsonl # Findings that passed verification
|
|
33
|
+
rejected.jsonl # Findings that failed verification
|
|
34
|
+
patches.jsonl # Finding -> PR URL -> reviewers
|
|
35
|
+
existing-prs.json # Cached open Warden PRs
|
|
36
|
+
report.json # Machine-readable summary
|
|
37
|
+
verify/ # Individual verification results
|
|
38
|
+
<finding-id>.json
|
|
39
|
+
logs/ # Warden JSONL logs per file
|
|
40
|
+
<hash>.jsonl
|
|
41
|
+
pr-diffs/ # Cached PR diffs for dedup
|
|
42
|
+
<number>.diff
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Failure Handling
|
|
46
|
+
|
|
47
|
+
- Preserve partial artifacts.
|
|
48
|
+
- Record per-finding errors in the relevant JSONL file.
|
|
49
|
+
- Distinguish timed-out files from errored files.
|
|
50
|
+
- Clean up worktrees before retrying patch work.
|
|
51
|
+
- Re-run organize after manual recovery to refresh reports.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Scan Phase
|
|
2
|
+
|
|
3
|
+
Run Warden across repository files and collect normalized findings.
|
|
4
|
+
|
|
5
|
+
## Run
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
uv run <skill-root>/scripts/scan.py
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
To scan only specific files:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
uv run <skill-root>/scripts/scan.py src/foo.ts src/bar.ts
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
To resume a partial scan:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
uv run <skill-root>/scripts/scan.py --sweep-dir .warden/sweeps/<run-id>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Process
|
|
24
|
+
|
|
25
|
+
1. Parse the JSON stdout.
|
|
26
|
+
2. Save `runId` and `sweepDir`.
|
|
27
|
+
3. Treat exit code `1` as fatal and stop.
|
|
28
|
+
4. Treat exit code `2` as partial: report timed-out and errored files separately, then continue only if the user accepts the partial results.
|
|
29
|
+
5. Render every finding from the `findings` array.
|
|
30
|
+
6. Update the checklist: Phase 1 complete.
|
|
31
|
+
|
|
32
|
+
## Report Template
|
|
33
|
+
|
|
34
|
+
```markdown
|
|
35
|
+
## Scan Complete
|
|
36
|
+
|
|
37
|
+
Scanned **{filesScanned}** files, **{filesTimedOut}** timed out, **{filesErrored}** errors.
|
|
38
|
+
|
|
39
|
+
### Findings ({totalFindings} total)
|
|
40
|
+
|
|
41
|
+
| # | Severity | Skill | File | Title |
|
|
42
|
+
|---|----------|-------|------|-------|
|
|
43
|
+
| 1 | **HIGH** | security-review | `src/db/query.ts:42` | SQL injection in query builder |
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Bold severity for high and above.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Script Interfaces
|
|
2
|
+
|
|
3
|
+
Use this reference before running Warden Sweep scripts. Run scripts from the repository root and pass the host skill-root path.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- `scan.py`
|
|
8
|
+
- `index_prs.py`
|
|
9
|
+
- `create_issue.py`
|
|
10
|
+
- `organize.py`
|
|
11
|
+
- `extract_findings.py`
|
|
12
|
+
- `generate_report.py`
|
|
13
|
+
- `find_reviewers.py`
|
|
14
|
+
|
|
15
|
+
## `scripts/scan.py`
|
|
16
|
+
|
|
17
|
+
Runs setup and scan in one call: generates a run ID, creates the sweep directory, checks dependencies, creates the `warden` label, enumerates files, runs Warden per file, writes `scan-index.jsonl`, and extracts findings.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
uv run <skill-root>/scripts/scan.py [file ...]
|
|
21
|
+
uv run <skill-root>/scripts/scan.py --sweep-dir .warden/sweeps/<run-id>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Stdout JSON:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"runId": "abc123",
|
|
29
|
+
"sweepDir": ".warden/sweeps/abc123",
|
|
30
|
+
"filesScanned": 10,
|
|
31
|
+
"filesTimedOut": 0,
|
|
32
|
+
"filesErrored": 0,
|
|
33
|
+
"totalFindings": 3,
|
|
34
|
+
"findings": []
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Exit codes: `0` success, `1` fatal error, `2` partial scan.
|
|
39
|
+
|
|
40
|
+
## `scripts/index_prs.py`
|
|
41
|
+
|
|
42
|
+
Fetches open Warden-labeled PRs, builds a file-to-PR dedup index, and caches diffs for overlapping PRs.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
uv run <skill-root>/scripts/index_prs.py <sweep-dir>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Stdout JSON includes `fileIndex`. Side effects:
|
|
49
|
+
|
|
50
|
+
- writes `data/existing-prs.json`
|
|
51
|
+
- writes `data/pr-diffs/<number>.diff` for overlapping PRs
|
|
52
|
+
|
|
53
|
+
## `scripts/create_issue.py`
|
|
54
|
+
|
|
55
|
+
Creates a GitHub tracking issue summarizing verified sweep results.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
uv run <skill-root>/scripts/create_issue.py <sweep-dir>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Stdout JSON:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"issueUrl": "https://github.com/owner/repo/issues/123",
|
|
66
|
+
"issueNumber": 123
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Idempotent: skips creation when `issueUrl` already exists in the manifest.
|
|
71
|
+
|
|
72
|
+
## `scripts/organize.py`
|
|
73
|
+
|
|
74
|
+
Tags security findings, labels security PRs, updates finding reports with PR links, posts final results to the tracking issue, generates the summary report, and finalizes the manifest.
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
uv run <skill-root>/scripts/organize.py <sweep-dir>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Stdout JSON includes final sweep counts and report paths. Side effects:
|
|
81
|
+
|
|
82
|
+
- creates `security/index.jsonl`
|
|
83
|
+
- copies security finding reports to `security/`
|
|
84
|
+
- creates or reuses the `security` GitHub label
|
|
85
|
+
- labels security PRs
|
|
86
|
+
- appends PR links to `findings/*.md`
|
|
87
|
+
- writes `summary.md` and `data/report.json`
|
|
88
|
+
- updates `phases.organize` in `data/manifest.json`
|
|
89
|
+
|
|
90
|
+
## `scripts/extract_findings.py`
|
|
91
|
+
|
|
92
|
+
Parses Warden JSONL log files and extracts normalized findings. Usually called by `scan.py`.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
uv run <skill-root>/scripts/extract_findings.py <log-path-or-directory> -o <output.jsonl>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Writes one normalized finding per line to `<output.jsonl>`.
|
|
99
|
+
|
|
100
|
+
## `scripts/generate_report.py`
|
|
101
|
+
|
|
102
|
+
Builds `summary.md` and `report.json` from sweep data. Usually called by `organize.py`.
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
uv run <skill-root>/scripts/generate_report.py <sweep-dir>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Side effects:
|
|
109
|
+
|
|
110
|
+
- writes `<sweep-dir>/summary.md`
|
|
111
|
+
- writes `<sweep-dir>/data/report.json`
|
|
112
|
+
|
|
113
|
+
## `scripts/find_reviewers.py`
|
|
114
|
+
|
|
115
|
+
Finds the top two git contributors for a file from the last 12 months.
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
uv run <skill-root>/scripts/find_reviewers.py <file-path>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Stdout JSON:
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"reviewers": ["user1", "user2"]
|
|
126
|
+
}
|
|
127
|
+
```
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Verify Phase
|
|
2
|
+
|
|
3
|
+
Deep-trace every finding before patching. This phase qualifies true issues and rejects false positives.
|
|
4
|
+
|
|
5
|
+
## Input
|
|
6
|
+
|
|
7
|
+
Read findings from:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
<sweep-dir>/data/all-findings.jsonl
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Process
|
|
14
|
+
|
|
15
|
+
For each finding:
|
|
16
|
+
|
|
17
|
+
1. If `data/verify/<finding-id>.json` exists, skip it.
|
|
18
|
+
2. Launch verification work using the host agent's task/delegation mechanism when available. Process findings in parallel batches up to 8 if the host supports parallel work.
|
|
19
|
+
3. Read `references/verify-prompt.md` and substitute the finding values into the `${...}` placeholders.
|
|
20
|
+
4. Parse the returned JSON.
|
|
21
|
+
5. Write the raw result to `data/verify/<finding-id>.json`.
|
|
22
|
+
6. Append verified findings to `data/verified.jsonl`.
|
|
23
|
+
7. Append rejected findings to `data/rejected.jsonl`.
|
|
24
|
+
8. For verified findings, generate `findings/<finding-id>.md`.
|
|
25
|
+
|
|
26
|
+
If the host does not support delegated tasks, run the same verification prompt serially.
|
|
27
|
+
|
|
28
|
+
## Verified Finding Report
|
|
29
|
+
|
|
30
|
+
````markdown
|
|
31
|
+
# ${TITLE}
|
|
32
|
+
|
|
33
|
+
**ID**: ${FINDING_ID} | **Severity**: ${SEVERITY} | **Confidence**: ${CONFIDENCE}
|
|
34
|
+
**Skill**: ${SKILL} | **File**: ${FILE_PATH}:${START_LINE}
|
|
35
|
+
|
|
36
|
+
## Description
|
|
37
|
+
${DESCRIPTION}
|
|
38
|
+
|
|
39
|
+
## Verification
|
|
40
|
+
**Verdict**: Verified (${VERIFICATION_CONFIDENCE})
|
|
41
|
+
**Reasoning**: ${REASONING}
|
|
42
|
+
**Code trace**: ${TRACE_NOTES}
|
|
43
|
+
|
|
44
|
+
## Suggested Fix
|
|
45
|
+
${FIX_DESCRIPTION}
|
|
46
|
+
```diff
|
|
47
|
+
${FIX_DIFF}
|
|
48
|
+
```
|
|
49
|
+
````
|
|
50
|
+
|
|
51
|
+
Update the manifest: set `phases.verify` to `"complete"`.
|
|
52
|
+
|
|
53
|
+
## Report Template
|
|
54
|
+
|
|
55
|
+
```markdown
|
|
56
|
+
## Verification Complete
|
|
57
|
+
|
|
58
|
+
**{verified}** verified, **{rejected}** rejected.
|
|
59
|
+
|
|
60
|
+
### Verified Findings
|
|
61
|
+
|
|
62
|
+
| # | Severity | Confidence | File | Title | Reasoning |
|
|
63
|
+
|---|----------|------------|------|-------|-----------|
|
|
64
|
+
| 1 | **HIGH** | high | `src/db/query.ts:42` | SQL injection in query builder | User input flows directly into... |
|
|
65
|
+
|
|
66
|
+
### Rejected ({rejected_count})
|
|
67
|
+
|
|
68
|
+
- `{findingId}` {file}: {reasoning}
|
|
69
|
+
```
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { CLIOptions, LogsOptions } from '../args.js';
|
|
2
|
-
import type { Reporter } from '../output/reporter.js';
|
|
3
|
-
/**
|
|
4
|
-
* List all JSONL log files in .warden/logs/.
|
|
5
|
-
*/
|
|
6
|
-
export declare function runLogsList(options: CLIOptions, reporter: Reporter): Promise<number>;
|
|
7
|
-
/**
|
|
8
|
-
* Show results from JSONL log files (replaces `warden replay`).
|
|
9
|
-
*/
|
|
10
|
-
export declare function runLogsShow(logsOptions: LogsOptions, options: CLIOptions, reporter: Reporter): Promise<number>;
|
|
11
|
-
/**
|
|
12
|
-
* Garbage-collect expired log files.
|
|
13
|
-
*/
|
|
14
|
-
export declare function runLogsGc(options: CLIOptions, reporter: Reporter): Promise<number>;
|
|
15
|
-
/**
|
|
16
|
-
* Dispatch to the appropriate logs subcommand.
|
|
17
|
-
*/
|
|
18
|
-
export declare function runLogs(logsOptions: LogsOptions, options: CLIOptions, reporter: Reporter): Promise<number>;
|
|
19
|
-
//# sourceMappingURL=logs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/logs.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAI1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAsHtD;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAyL1F;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,MAAM,CAAC,CA0GjB;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAyCxF;AAED;;GAEG;AACH,wBAAsB,OAAO,CAC3B,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,MAAM,CAAC,CASjB"}
|