@sentry/warden 0.3.0 → 0.5.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.
Files changed (148) hide show
  1. package/.claude-plugin/marketplace.json +20 -0
  2. package/README.md +1 -1
  3. package/dist/cli/args.d.ts +3 -1
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +15 -4
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli/commands/add.d.ts.map +1 -1
  8. package/dist/cli/commands/add.js +51 -31
  9. package/dist/cli/commands/add.js.map +1 -1
  10. package/dist/cli/commands/init.d.ts.map +1 -1
  11. package/dist/cli/commands/init.js +12 -14
  12. package/dist/cli/commands/init.js.map +1 -1
  13. package/dist/cli/context.d.ts.map +1 -1
  14. package/dist/cli/context.js +3 -1
  15. package/dist/cli/context.js.map +1 -1
  16. package/dist/cli/git.d.ts +4 -0
  17. package/dist/cli/git.d.ts.map +1 -1
  18. package/dist/cli/git.js +7 -1
  19. package/dist/cli/git.js.map +1 -1
  20. package/dist/cli/index.js +11 -4
  21. package/dist/cli/index.js.map +1 -1
  22. package/dist/cli/main.d.ts +7 -0
  23. package/dist/cli/main.d.ts.map +1 -1
  24. package/dist/cli/main.js +41 -26
  25. package/dist/cli/main.js.map +1 -1
  26. package/dist/cli/output/formatters.d.ts +18 -3
  27. package/dist/cli/output/formatters.d.ts.map +1 -1
  28. package/dist/cli/output/formatters.js +32 -7
  29. package/dist/cli/output/formatters.js.map +1 -1
  30. package/dist/cli/output/index.d.ts +1 -1
  31. package/dist/cli/output/index.d.ts.map +1 -1
  32. package/dist/cli/output/index.js +1 -1
  33. package/dist/cli/output/index.js.map +1 -1
  34. package/dist/cli/output/ink-runner.d.ts.map +1 -1
  35. package/dist/cli/output/ink-runner.js +29 -8
  36. package/dist/cli/output/ink-runner.js.map +1 -1
  37. package/dist/cli/output/jsonl.d.ts +39 -1
  38. package/dist/cli/output/jsonl.d.ts.map +1 -1
  39. package/dist/cli/output/jsonl.js +12 -0
  40. package/dist/cli/output/jsonl.js.map +1 -1
  41. package/dist/cli/output/reporter.d.ts +2 -2
  42. package/dist/cli/output/reporter.d.ts.map +1 -1
  43. package/dist/cli/output/reporter.js +70 -37
  44. package/dist/cli/output/reporter.js.map +1 -1
  45. package/dist/cli/output/tasks.d.ts +12 -0
  46. package/dist/cli/output/tasks.d.ts.map +1 -1
  47. package/dist/cli/output/tasks.js +157 -42
  48. package/dist/cli/output/tasks.js.map +1 -1
  49. package/dist/cli/output/tty.d.ts +9 -0
  50. package/dist/cli/output/tty.d.ts.map +1 -1
  51. package/dist/cli/output/tty.js +13 -0
  52. package/dist/cli/output/tty.js.map +1 -1
  53. package/dist/cli/output/verbosity.d.ts +2 -1
  54. package/dist/cli/output/verbosity.d.ts.map +1 -1
  55. package/dist/cli/output/verbosity.js +3 -2
  56. package/dist/cli/output/verbosity.js.map +1 -1
  57. package/dist/cli/terminal.d.ts +2 -2
  58. package/dist/cli/terminal.d.ts.map +1 -1
  59. package/dist/cli/terminal.js +33 -20
  60. package/dist/cli/terminal.js.map +1 -1
  61. package/dist/config/loader.d.ts +40 -12
  62. package/dist/config/loader.d.ts.map +1 -1
  63. package/dist/config/loader.js +71 -23
  64. package/dist/config/loader.js.map +1 -1
  65. package/dist/config/schema.d.ts +147 -111
  66. package/dist/config/schema.d.ts.map +1 -1
  67. package/dist/config/schema.js +67 -49
  68. package/dist/config/schema.js.map +1 -1
  69. package/dist/config/writer.d.ts +5 -5
  70. package/dist/config/writer.d.ts.map +1 -1
  71. package/dist/config/writer.js +76 -45
  72. package/dist/config/writer.js.map +1 -1
  73. package/dist/event/context.d.ts.map +1 -1
  74. package/dist/event/context.js +3 -1
  75. package/dist/event/context.js.map +1 -1
  76. package/dist/event/schedule-context.d.ts.map +1 -1
  77. package/dist/event/schedule-context.js +1 -0
  78. package/dist/event/schedule-context.js.map +1 -1
  79. package/dist/index.d.ts +5 -5
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +5 -3
  82. package/dist/index.js.map +1 -1
  83. package/dist/output/dedup.d.ts +3 -1
  84. package/dist/output/dedup.d.ts.map +1 -1
  85. package/dist/output/dedup.js +25 -32
  86. package/dist/output/dedup.js.map +1 -1
  87. package/dist/output/github-checks.d.ts +6 -4
  88. package/dist/output/github-checks.d.ts.map +1 -1
  89. package/dist/output/github-checks.js +67 -88
  90. package/dist/output/github-checks.js.map +1 -1
  91. package/dist/output/github-issues.d.ts.map +1 -1
  92. package/dist/output/github-issues.js +9 -14
  93. package/dist/output/github-issues.js.map +1 -1
  94. package/dist/output/issue-renderer.js +1 -1
  95. package/dist/output/issue-renderer.js.map +1 -1
  96. package/dist/output/renderer.d.ts.map +1 -1
  97. package/dist/output/renderer.js +18 -31
  98. package/dist/output/renderer.js.map +1 -1
  99. package/dist/output/stale.d.ts +4 -0
  100. package/dist/output/stale.d.ts.map +1 -1
  101. package/dist/output/stale.js +7 -2
  102. package/dist/output/stale.js.map +1 -1
  103. package/dist/output/types.d.ts +2 -7
  104. package/dist/output/types.d.ts.map +1 -1
  105. package/dist/sdk/analyze.d.ts.map +1 -1
  106. package/dist/sdk/analyze.js +89 -24
  107. package/dist/sdk/analyze.js.map +1 -1
  108. package/dist/sdk/extract.d.ts +12 -2
  109. package/dist/sdk/extract.d.ts.map +1 -1
  110. package/dist/sdk/extract.js +22 -3
  111. package/dist/sdk/extract.js.map +1 -1
  112. package/dist/sdk/haiku.d.ts +55 -0
  113. package/dist/sdk/haiku.d.ts.map +1 -0
  114. package/dist/sdk/haiku.js +190 -0
  115. package/dist/sdk/haiku.js.map +1 -0
  116. package/dist/sdk/model-pricing.json +104 -0
  117. package/dist/sdk/pricing.d.ts +17 -0
  118. package/dist/sdk/pricing.d.ts.map +1 -0
  119. package/dist/sdk/pricing.js +41 -0
  120. package/dist/sdk/pricing.js.map +1 -0
  121. package/dist/sdk/runner.d.ts +4 -3
  122. package/dist/sdk/runner.d.ts.map +1 -1
  123. package/dist/sdk/runner.js +4 -2
  124. package/dist/sdk/runner.js.map +1 -1
  125. package/dist/sdk/types.d.ts +15 -0
  126. package/dist/sdk/types.d.ts.map +1 -1
  127. package/dist/sdk/types.js.map +1 -1
  128. package/dist/sdk/usage.d.ts +13 -1
  129. package/dist/sdk/usage.d.ts.map +1 -1
  130. package/dist/sdk/usage.js +46 -0
  131. package/dist/sdk/usage.js.map +1 -1
  132. package/dist/triggers/matcher.d.ts +18 -3
  133. package/dist/triggers/matcher.d.ts.map +1 -1
  134. package/dist/triggers/matcher.js +75 -18
  135. package/dist/triggers/matcher.js.map +1 -1
  136. package/dist/types/index.d.ts +42 -0
  137. package/dist/types/index.d.ts.map +1 -1
  138. package/dist/types/index.js +14 -0
  139. package/dist/types/index.js.map +1 -1
  140. package/package.json +4 -2
  141. package/plugins/.claude-plugin/marketplace.json +14 -0
  142. package/plugins/warden/.claude-plugin/plugin.json +7 -0
  143. package/plugins/warden/skills/warden/SKILL.md +78 -0
  144. package/plugins/warden/skills/warden/references/cli-reference.md +144 -0
  145. package/plugins/warden/skills/warden/references/config-schema.md +111 -0
  146. package/plugins/warden/skills/warden/references/configuration.md +108 -0
  147. package/plugins/warden/skills/warden/references/creating-skills.md +85 -0
  148. package/scripts/update-pricing.ts +88 -0
@@ -0,0 +1,111 @@
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 skills
9
+ [[skills]] # Required, array of skill configs
10
+ ```
11
+
12
+ ## Defaults Section
13
+
14
+ ```toml
15
+ [defaults]
16
+ model = "claude-sonnet-4-20250514" # Default model
17
+ maxTurns = 50 # Max agentic turns per hunk
18
+ defaultBranch = "main" # Base branch for comparisons
19
+ failOn = "high" # Exit 1 if findings >= this severity
20
+ reportOn = "medium" # Show findings >= this severity
21
+ maxFindings = 50 # Max findings to report (0 = unlimited)
22
+ reportOnSuccess = false # Post report even with no findings
23
+ paths = ["src/**/*.ts"] # Include only matching files
24
+ ignorePaths = ["*.test.ts"] # Exclude matching files
25
+
26
+ [defaults.chunking]
27
+ enabled = true # Enable hunk-based chunking
28
+
29
+ [defaults.chunking.coalesce]
30
+ enabled = true # Merge nearby hunks
31
+ maxGapLines = 30 # Lines between hunks to merge
32
+ maxChunkSize = 8000 # Max chars per chunk
33
+
34
+ [[defaults.chunking.filePatterns]]
35
+ pattern = "*.config.*" # Glob pattern
36
+ mode = "whole-file" # per-hunk | whole-file | skip
37
+ ```
38
+
39
+ ## Skills Section
40
+
41
+ ```toml
42
+ [[skills]]
43
+ name = "skill-name" # Required, unique identifier
44
+ remote = "owner/repo@sha" # Optional, fetch skill from GitHub repo
45
+ paths = ["src/**"] # Include only matching files
46
+ ignorePaths = ["**/*.test.ts"] # Exclude matching files
47
+
48
+ # Optional overrides (inherit from defaults if not set)
49
+ model = "claude-opus-4-20250514"
50
+ maxTurns = 100
51
+ failOn = "critical"
52
+ reportOn = "high"
53
+ maxFindings = 20
54
+ reportOnSuccess = true
55
+
56
+ [[skills.triggers]]
57
+ type = "pull_request" # Required: pull_request | local | schedule
58
+ actions = ["opened", "synchronize"] # Required for pull_request
59
+
60
+ # Schedule-specific (only for type = "schedule")
61
+ [[skills.triggers]]
62
+ type = "schedule"
63
+
64
+ [skills.triggers.schedule]
65
+ issueTitle = "Daily Security Review" # GitHub issue title for tracking
66
+ createFixPR = true # Create PR with fixes
67
+ fixBranchPrefix = "security-fix" # Branch name prefix
68
+ ```
69
+
70
+ **Trigger types:**
71
+ - `pull_request` - Triggers on PR events
72
+ - `local` - Triggers on local CLI runs
73
+ - `schedule` - Triggers on cron schedule (GitHub Action)
74
+
75
+ **Actions (for pull_request):**
76
+ - `opened`, `synchronize`, `reopened`, `closed`
77
+
78
+ ## Severity Values
79
+
80
+ Used in `failOn` and `reportOn`:
81
+ - `critical` - Most severe
82
+ - `high`
83
+ - `medium`
84
+ - `low`
85
+ - `info` - Least severe
86
+ - `off` - Disable threshold
87
+
88
+ ## Built-in Skip Patterns
89
+
90
+ Always skipped (cannot be overridden):
91
+ - Package locks: `pnpm-lock.yaml`, `package-lock.json`, `yarn.lock`, `Cargo.lock`, etc.
92
+ - Minified files: `**/*.min.js`, `**/*.min.css`
93
+ - Build artifacts: `dist/`, `build/`, `node_modules/`, `.next/`, `__pycache__/`
94
+ - Generated code: `*.generated.*`, `*.g.ts`, `__generated__/`
95
+
96
+ ## Environment Variables
97
+
98
+ | Variable | Purpose |
99
+ |----------|---------|
100
+ | `WARDEN_ANTHROPIC_API_KEY` | Claude API key (required) |
101
+ | `WARDEN_MODEL` | Default model (lowest priority) |
102
+ | `WARDEN_STATE_DIR` | Override cache location (default: `~/.local/warden`) |
103
+ | `WARDEN_SKILL_CACHE_TTL` | Cache TTL in seconds for unpinned remotes (default: 86400) |
104
+
105
+ ## Model Precedence (highest to lowest)
106
+
107
+ 1. Skill-level `model`
108
+ 2. `[defaults]` `model`
109
+ 3. CLI `--model` flag
110
+ 4. `WARDEN_MODEL` env var
111
+ 5. SDK default
@@ -0,0 +1,108 @@
1
+ # Configuration (warden.toml)
2
+
3
+ See [config-schema.md](config-schema.md) for the complete schema reference.
4
+
5
+ ## Minimal Example
6
+
7
+ ```toml
8
+ version = 1
9
+
10
+ [defaults]
11
+ model = "claude-sonnet-4-20250514"
12
+
13
+ [[skills]]
14
+ name = "find-bugs"
15
+ paths = ["src/**/*.ts"]
16
+
17
+ [[skills.triggers]]
18
+ type = "pull_request"
19
+ actions = ["opened", "synchronize"]
20
+ ```
21
+
22
+ ## Skill Configuration
23
+
24
+ Skills define what to analyze and when. Each skill requires a name and at least one trigger:
25
+
26
+ ```toml
27
+ [[skills]]
28
+ name = "security-review"
29
+ paths = ["src/auth/**", "src/payments/**"]
30
+ failOn = "critical"
31
+ reportOn = "high"
32
+ maxFindings = 20
33
+
34
+ [[skills.triggers]]
35
+ type = "pull_request"
36
+ actions = ["opened", "synchronize"]
37
+ ```
38
+
39
+ **Trigger types:** `pull_request`, `local`, `schedule`
40
+
41
+ **Actions (pull_request):** `opened`, `synchronize`, `reopened`, `closed`
42
+
43
+ ## Common Patterns
44
+
45
+ **Strict security on critical files:**
46
+ ```toml
47
+ [[skills]]
48
+ name = "security-review"
49
+ model = "claude-opus-4-20250514"
50
+ maxTurns = 100
51
+ paths = ["src/auth/**", "src/payments/**"]
52
+ failOn = "critical"
53
+
54
+ [[skills.triggers]]
55
+ type = "pull_request"
56
+ actions = ["opened", "synchronize"]
57
+ ```
58
+
59
+ **Skip test files:**
60
+ ```toml
61
+ [[skills]]
62
+ name = "find-bugs"
63
+ paths = ["src/**/*.ts"]
64
+ ignorePaths = ["**/*.test.ts", "**/*.spec.ts"]
65
+ ```
66
+
67
+ **Whole-file analysis for configs:**
68
+ ```toml
69
+ [defaults.chunking.filePatterns]
70
+ pattern = "*.config.*"
71
+ mode = "whole-file"
72
+ ```
73
+
74
+ ## Model Precedence
75
+
76
+ From highest to lowest priority:
77
+
78
+ 1. Skill-level `model`
79
+ 2. `[defaults]` `model`
80
+ 3. CLI `--model` flag
81
+ 4. `WARDEN_MODEL` env var
82
+ 5. SDK default
83
+
84
+ ## Environment Variables
85
+
86
+ | Variable | Purpose |
87
+ |----------|---------|
88
+ | `WARDEN_ANTHROPIC_API_KEY` | Claude API key (required unless using Claude Code subscription) |
89
+ | `WARDEN_MODEL` | Default model (lowest priority) |
90
+ | `WARDEN_STATE_DIR` | Override cache location (default: `~/.local/warden`) |
91
+ | `WARDEN_SKILL_CACHE_TTL` | Cache TTL in seconds for unpinned remotes (default: 86400) |
92
+
93
+ ## Troubleshooting
94
+
95
+ **No findings reported:**
96
+ - Check `--report-on` threshold (default shows all)
97
+ - Verify skill matches file types in `paths`
98
+ - Use `-v` to see which files are being analyzed
99
+
100
+ **Files being skipped:**
101
+ - Built-in skip patterns: lock files, minified, `node_modules/`, `dist/`
102
+ - Check `ignorePaths` in config
103
+ - Use `-vv` to see skip reasons
104
+
105
+ **Token/cost issues:**
106
+ - Reduce `maxTurns` (default: 50)
107
+ - Use chunking settings to control chunk size
108
+ - Filter to relevant files with `paths`
@@ -0,0 +1,85 @@
1
+ # Creating Skills
2
+
3
+ Skills are markdown files that tell Warden what to look for. They follow the [agentskills.io](https://agentskills.io) specification.
4
+
5
+ ## Skill Discovery
6
+
7
+ Warden searches these directories in order (first match wins):
8
+
9
+ ```
10
+ .warden/skills/{name}/SKILL.md # Warden-specific (highest priority)
11
+ .agents/skills/{name}/SKILL.md # Shared agent skills
12
+ .claude/skills/{name}/SKILL.md # Claude Code skills
13
+ ```
14
+
15
+ ## SKILL.md Format
16
+
17
+ ```markdown
18
+ ---
19
+ name: my-skill
20
+ description: What this skill analyzes
21
+ allowed-tools: Read Grep Glob
22
+ ---
23
+
24
+ [Analysis instructions for the agent]
25
+
26
+ ## What to Look For
27
+ - Specific issue type 1
28
+ - Specific issue type 2
29
+
30
+ ## Output Format
31
+ Report findings with severity, location, and suggested fix.
32
+ ```
33
+
34
+ ## Available Tools
35
+
36
+ `Read`, `Glob`, `Grep`, `WebFetch`, `WebSearch`, `Bash`, `Write`, `Edit`
37
+
38
+ Most review skills only need `Read`, `Grep`, and `Glob` for exploring context.
39
+
40
+ ## Writing Checklist
41
+
42
+ - One skill, one concern ("security review" not "code quality")
43
+ - Clear criteria for what counts as an issue and at what severity
44
+ - Actionable findings that include how to fix
45
+ - Examples of good and bad code where helpful
46
+
47
+ ## Remote Skills
48
+
49
+ Skills can be fetched from GitHub repositories:
50
+
51
+ ```bash
52
+ # Add a remote skill
53
+ warden add --remote getsentry/skills --skill security-review
54
+
55
+ # Add with version pinning (recommended for reproducibility)
56
+ warden add --remote getsentry/skills@abc123 --skill security-review
57
+
58
+ # List skills in a remote repo
59
+ warden add --remote getsentry/skills --list
60
+
61
+ # Update all unpinned remote skills
62
+ warden sync
63
+
64
+ # Update specific repo
65
+ warden sync getsentry/skills
66
+
67
+ # Run with cached skills only (no network)
68
+ warden --offline
69
+ ```
70
+
71
+ **Remote skill in warden.toml:**
72
+
73
+ ```toml
74
+ [[skills]]
75
+ name = "security-review"
76
+ remote = "getsentry/skills@abc123"
77
+
78
+ [[skills.triggers]]
79
+ type = "pull_request"
80
+ actions = ["opened", "synchronize"]
81
+ ```
82
+
83
+ **Cache location:** `~/.local/warden/skills/` (override with `WARDEN_STATE_DIR`)
84
+
85
+ **Cache TTL:** 24 hours for unpinned refs (override with `WARDEN_SKILL_CACHE_TTL` in seconds)
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Fetches Anthropic model pricing from pydantic/genai-prices and writes
3
+ * src/sdk/model-pricing.json. Rerun whenever prices change.
4
+ *
5
+ * Usage: pnpm update-pricing
6
+ */
7
+
8
+ const SOURCE_URL =
9
+ 'https://raw.githubusercontent.com/pydantic/genai-prices/main/prices/data.json';
10
+ const OUTPUT_PATH = new URL('../src/sdk/model-pricing.json', import.meta.url);
11
+
12
+ type PriceValue = number | { base: number; tiers: unknown[] };
13
+
14
+ interface PriceEntry {
15
+ input_mtok?: PriceValue;
16
+ output_mtok?: PriceValue;
17
+ cache_read_mtok?: PriceValue;
18
+ cache_write_mtok?: PriceValue;
19
+ }
20
+
21
+ /** Extract the base price from a flat number or tiered pricing object. */
22
+ function basePrice(v: PriceValue | undefined): number {
23
+ if (v == null) return 0;
24
+ if (typeof v === 'number') return v;
25
+ return v.base;
26
+ }
27
+
28
+ interface ModelEntry {
29
+ id: string;
30
+ name: string;
31
+ prices: PriceEntry;
32
+ }
33
+
34
+ interface ProviderEntry {
35
+ id: string;
36
+ models: ModelEntry[];
37
+ }
38
+
39
+ interface ModelPricingRecord {
40
+ inputPerMTok: number;
41
+ outputPerMTok: number;
42
+ cacheReadPerMTok: number;
43
+ cacheWritePerMTok: number;
44
+ }
45
+
46
+ async function main() {
47
+ const res = await fetch(SOURCE_URL);
48
+ if (!res.ok) {
49
+ throw new Error(`Failed to fetch pricing data: ${res.status} ${res.statusText}`);
50
+ }
51
+
52
+ const providers: ProviderEntry[] = await res.json();
53
+ const anthropic = providers.find((p) => p.id === 'anthropic');
54
+ if (!anthropic) {
55
+ throw new Error('Anthropic provider not found in pricing data');
56
+ }
57
+
58
+ const pricing: Record<string, ModelPricingRecord> = {};
59
+
60
+ if (!anthropic.models || !Array.isArray(anthropic.models)) {
61
+ throw new Error('Anthropic provider has invalid or missing models array');
62
+ }
63
+
64
+ for (const model of anthropic.models) {
65
+ const p = model.prices;
66
+ if (!p || typeof p !== 'object') {
67
+ continue;
68
+ }
69
+ pricing[model.id] = {
70
+ inputPerMTok: basePrice(p.input_mtok),
71
+ outputPerMTok: basePrice(p.output_mtok),
72
+ cacheReadPerMTok: basePrice(p.cache_read_mtok),
73
+ cacheWritePerMTok: basePrice(p.cache_write_mtok),
74
+ };
75
+ }
76
+
77
+ const { writeFileSync } = await import('node:fs');
78
+ const { fileURLToPath } = await import('node:url');
79
+ writeFileSync(fileURLToPath(OUTPUT_PATH), JSON.stringify(pricing, null, 2) + '\n');
80
+
81
+ const count = Object.keys(pricing).length;
82
+ console.log(`Wrote ${count} model(s) to src/sdk/model-pricing.json`);
83
+ }
84
+
85
+ main().catch((err) => {
86
+ console.error(err);
87
+ process.exit(1);
88
+ });