prism-pr 1.0.0-alpha.67 → 1.0.0-alpha.68
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/README.md +339 -339
- package/bin/run.js +1 -1
- package/dist/ai/agents/framework-rules/index.d.ts.map +1 -1
- package/dist/ai/agents/framework-rules/index.js +21 -0
- package/dist/ai/agents/framework-rules/index.js.map +1 -1
- package/dist/ai/agents/prompts/html-reviewer.txt +9 -0
- package/dist/ai/agents/prompts/ts-reviewer.txt +4 -0
- package/dist/ai/agents/shared/finding-schema.d.ts +3 -0
- package/dist/ai/agents/shared/finding-schema.d.ts.map +1 -1
- package/dist/ai/agents/shared/finding-schema.js +3 -3
- package/dist/ai/agents/shared/finding-schema.js.map +1 -1
- package/dist/bitbucket/client.d.ts +1 -0
- package/dist/bitbucket/client.d.ts.map +1 -1
- package/dist/bitbucket/client.js +21 -0
- package/dist/bitbucket/client.js.map +1 -1
- package/dist/commands/rules/bootstrap.d.ts.map +1 -1
- package/dist/commands/rules/bootstrap.js +3 -1
- package/dist/commands/rules/bootstrap.js.map +1 -1
- package/dist/core/workflow-engine.d.ts.map +1 -1
- package/dist/core/workflow-engine.js +14 -0
- package/dist/core/workflow-engine.js.map +1 -1
- package/dist/persistence/migrations/0005_pattern_feedback.sql +16 -16
- package/dist/rule-catalog/angular/base.d.ts.map +1 -1
- package/dist/rule-catalog/angular/base.js +116 -1
- package/dist/rule-catalog/angular/base.js.map +1 -1
- package/dist/rule-catalog/angular/v2.d.ts +3 -0
- package/dist/rule-catalog/angular/v2.d.ts.map +1 -0
- package/dist/rule-catalog/angular/v2.js +44 -0
- package/dist/rule-catalog/angular/v2.js.map +1 -0
- package/dist/rule-catalog/index.d.ts.map +1 -1
- package/dist/rule-catalog/index.js +2 -0
- package/dist/rule-catalog/index.js.map +1 -1
- package/dist/rule-catalog/ruleset-mapper.d.ts +11 -0
- package/dist/rule-catalog/ruleset-mapper.d.ts.map +1 -1
- package/dist/rule-catalog/ruleset-mapper.js +32 -0
- package/dist/rule-catalog/ruleset-mapper.js.map +1 -1
- package/dist/rule-catalog/shared/general.d.ts.map +1 -1
- package/dist/rule-catalog/shared/general.js +129 -0
- package/dist/rule-catalog/shared/general.js.map +1 -1
- package/dist/rule-catalog/shared/security.d.ts.map +1 -1
- package/dist/rule-catalog/shared/security.js +10 -2
- package/dist/rule-catalog/shared/security.js.map +1 -1
- package/dist/rule-catalog/shared/typescript.js +3 -3
- package/dist/rule-catalog/shared/typescript.js.map +1 -1
- package/dist/rules-engine/types.d.ts +5 -0
- package/dist/rules-engine/types.d.ts.map +1 -1
- package/dist/rules-engine/types.js.map +1 -1
- package/dist/rules-repo/manifest-resolver.d.ts.map +1 -1
- package/dist/rules-repo/manifest-resolver.js +12 -0
- package/dist/rules-repo/manifest-resolver.js.map +1 -1
- package/dist/rules-repo/manifest-types.d.ts +2 -0
- package/dist/rules-repo/manifest-types.d.ts.map +1 -1
- package/dist/rules-repo/rules-repo-client.d.ts +2 -2
- package/dist/rules-repo/rules-repo-client.d.ts.map +1 -1
- package/dist/rules-repo/rules-repo-client.js +8 -6
- package/dist/rules-repo/rules-repo-client.js.map +1 -1
- package/dist/tui/hooks/use-suggest-rules.d.ts.map +1 -1
- package/dist/tui/hooks/use-suggest-rules.js +1 -4
- package/dist/tui/hooks/use-suggest-rules.js.map +1 -1
- package/dist/tui/screens/rule-suggestions.d.ts.map +1 -1
- package/dist/tui/screens/rule-suggestions.js +18 -4
- package/dist/tui/screens/rule-suggestions.js.map +1 -1
- package/dist/utils/summary-generator.d.ts +1 -0
- package/dist/utils/summary-generator.d.ts.map +1 -1
- package/dist/utils/summary-generator.js +12 -6
- package/dist/utils/summary-generator.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +118 -118
package/README.md
CHANGED
|
@@ -1,339 +1,339 @@
|
|
|
1
|
-
# PRISM-PR
|
|
2
|
-
|
|
3
|
-
> **Alpha** — this package is in active development (`1.0.0-alpha`). APIs and commands may change between releases.
|
|
4
|
-
|
|
5
|
-
Intelligent Pull Request review orchestrator for Bitbucket. AI-powered code review plus pattern-based pre-checks using ast-grep structural matching, a shared team rules repository, and a self-evolving rule system that learns from your feedback.
|
|
6
|
-
|
|
7
|
-
## Install
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm i -g prism-pr
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Requirements
|
|
14
|
-
|
|
15
|
-
- Node.js **>= 22.5.0** (SQLite is loaded via the native `node:sqlite` module)
|
|
16
|
-
- Bitbucket Cloud account with an Atlassian API token
|
|
17
|
-
- AI provider (one of):
|
|
18
|
-
- `ANTHROPIC_API_KEY` environment variable (preferred), or
|
|
19
|
-
- [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code) installed and authenticated
|
|
20
|
-
|
|
21
|
-
## Setup
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
prism login
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Your Bitbucket app password / API token needs these permissions:
|
|
28
|
-
|
|
29
|
-
- Repositories: **Read** + **Write**
|
|
30
|
-
- Pull requests: **Read** + **Write**
|
|
31
|
-
|
|
32
|
-
## Discoverability — always available
|
|
33
|
-
|
|
34
|
-
Every command documents itself via `--help`. If something in this README is stale, trust `--help`:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
prism --help # full command tree
|
|
38
|
-
prism rules --help # subcommands under `rules`
|
|
39
|
-
prism guard --help # subcommands under `guard`
|
|
40
|
-
prism rules bootstrap --help # flags + examples for a specific command
|
|
41
|
-
prism guard check --help
|
|
42
|
-
prism review start --help
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
## Quick start — zero config
|
|
48
|
-
|
|
49
|
-
PRISM auto-detects your stack and bootstraps rules on the first run. No setup needed.
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
cd your-bitbucket-repo
|
|
53
|
-
prism guard check
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
That's it. On first run, PRISM will:
|
|
57
|
-
|
|
58
|
-
1. Detect workspace/repo from your git remote
|
|
59
|
-
2. Fetch `package.json` via Bitbucket API to detect your stack (TypeScript, Angular, React, NestJS, AG Grid, …)
|
|
60
|
-
3. Generate a manifest with the matching rulesets
|
|
61
|
-
4. Push everything to the shared rules repository
|
|
62
|
-
5. Resolve patterns and check your PR
|
|
63
|
-
|
|
64
|
-
### Manual bootstrap (optional)
|
|
65
|
-
|
|
66
|
-
If you prefer explicit control:
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
# Detect stack and push manifest + rulesets to the shared rules repo
|
|
70
|
-
prism rules bootstrap
|
|
71
|
-
|
|
72
|
-
# Preview without pushing
|
|
73
|
-
prism rules bootstrap --dry-run
|
|
74
|
-
|
|
75
|
-
# JSON output (CI-friendly)
|
|
76
|
-
prism rules bootstrap --dry-run --json
|
|
77
|
-
|
|
78
|
-
# Explicit workspace/repo/branch
|
|
79
|
-
prism rules bootstrap --workspace acme --repo my-repo --branch develop
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### Check a PR
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
# Interactive PR picker (auto-detects workspace/repo from git origin)
|
|
86
|
-
prism guard check
|
|
87
|
-
|
|
88
|
-
# Pick a PR by ID
|
|
89
|
-
prism guard check --pr 42
|
|
90
|
-
|
|
91
|
-
# Full output with code snippets and suggestions
|
|
92
|
-
prism guard check --pr 42 --verbose
|
|
93
|
-
|
|
94
|
-
# Filter by severity
|
|
95
|
-
prism guard check --pr 42 --min-severity high --verbose
|
|
96
|
-
|
|
97
|
-
# JSON output for CI
|
|
98
|
-
prism guard check --pr 42 --json
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
**`--verbose` gates the snippet and suggestion.** Without it, matches show severity badge + title + file:line only. With `--verbose`, you get diff context with a pointer on the exact line, plus the fix suggestion.
|
|
102
|
-
|
|
103
|
-
---
|
|
104
|
-
|
|
105
|
-
## Living Rules — self-evolving rule system
|
|
106
|
-
|
|
107
|
-
PRISM's rules aren't static. They learn, adapt, and grow with your codebase.
|
|
108
|
-
|
|
109
|
-
### Auto-Refresh
|
|
110
|
-
|
|
111
|
-
Manifests detect when your stack changes. If you add a new framework (e.g. NestJS) to your project, the next guard check automatically updates the manifest with the new rulesets. Default staleness threshold: 7 days.
|
|
112
|
-
|
|
113
|
-
### Versioned Catalog
|
|
114
|
-
|
|
115
|
-
Rulesets are published as immutable versioned artifacts:
|
|
116
|
-
|
|
117
|
-
```
|
|
118
|
-
catalog/
|
|
119
|
-
shared/security/1.0.0.json # immutable, infinite cache
|
|
120
|
-
shared/general/1.0.0.json
|
|
121
|
-
angular/v17/1.0.0.json
|
|
122
|
-
...
|
|
123
|
-
catalog/index.json # lists all rulesets + latest versions
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
Manifests can pin versions: `"shared/security@1.2.0"`. Unversioned includes resolve to latest. A 3-level fallback chain ensures resilience: versioned remote → unversioned remote → static builtin catalog.
|
|
127
|
-
|
|
128
|
-
### Feedback Loop & Auto-Tune
|
|
129
|
-
|
|
130
|
-
Mark findings as false positives. After enough feedback, PRISM auto-excludes noisy patterns.
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
# CLI: mark specific pattern IDs as false positive
|
|
134
|
-
prism guard check --pr 42 --mark-fp "security--xss--innerHTML-usage,general--debug--console-log"
|
|
135
|
-
|
|
136
|
-
# CLI: auto-exclude patterns with 3+ false positives
|
|
137
|
-
prism guard check --pr 42 --auto-tune
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
In the TUI, press `[f]` on any finding to mark it as a false positive. Press `[t]` in the results screen to apply auto-tune.
|
|
141
|
-
|
|
142
|
-
### AI Rule Suggestion
|
|
143
|
-
|
|
144
|
-
PRISM can analyze findings from any review and generate new ast-grep rules automatically. Rule suggestions are a **post-review** action — you see the findings first, then decide which patterns should become permanent rules.
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
# CLI: generate rules from guard findings
|
|
148
|
-
prism guard check --pr 42 --suggest-rules
|
|
149
|
-
|
|
150
|
-
# CLI: generate rules from AI review findings
|
|
151
|
-
prism review start --workspace acme --repo app --pr 42 --suggest-rules
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
PRISM uses the same AI provider configured for reviews (auto-detects from `ANTHROPIC_API_KEY` or falls back to Claude Code CLI).
|
|
155
|
-
|
|
156
|
-
In the TUI, press `[g]` on any results screen (guard results or AI review findings) to generate rule suggestions on demand. Review, accept/reject, and apply to the manifest.
|
|
157
|
-
|
|
158
|
-
---
|
|
159
|
-
|
|
160
|
-
## Interactive TUI
|
|
161
|
-
|
|
162
|
-
```bash
|
|
163
|
-
prism # main TUI (review + navigation)
|
|
164
|
-
prism guard # guard-focused TUI
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
Launches a full Ink-based terminal UI with keyboard navigation.
|
|
168
|
-
|
|
169
|
-
### Guardian Angel section
|
|
170
|
-
|
|
171
|
-
- **Guard Check** — select workspace → repo → PR → run check
|
|
172
|
-
- **Guard Check (auto-detect)** — detects workspace/repo from git origin, skips manual selection
|
|
173
|
-
- **Rules Bootstrap** — detect stack and push manifest (dry-run toggle, branch override)
|
|
174
|
-
|
|
175
|
-
### Guard options (toggleable in guard-home)
|
|
176
|
-
|
|
177
|
-
| Key | Option | Description |
|
|
178
|
-
|-----|--------|-------------|
|
|
179
|
-
| `v` | Verbose | Show context lines and suggestions |
|
|
180
|
-
| `s` | Severity | Cycle minimum severity filter |
|
|
181
|
-
| `a` | AST | Toggle ast-grep matching on/off |
|
|
182
|
-
|
|
183
|
-
### Guard results actions
|
|
184
|
-
|
|
185
|
-
| Key | Action | Description |
|
|
186
|
-
|-----|--------|-------------|
|
|
187
|
-
| `↑↓` | Navigate | Browse findings |
|
|
188
|
-
| `Enter` | Detail | View finding detail with context |
|
|
189
|
-
| `f` | False positive | Mark finding as FP (in detail view) |
|
|
190
|
-
| `j` | Export JSON | Export results to `prism-guard-results.json` |
|
|
191
|
-
| `t` | Auto-tune | Batch-exclude patterns with enough FP feedback |
|
|
192
|
-
| `g` | AI suggestions | Generate and review AI-suggested rules (on demand) |
|
|
193
|
-
| `Esc` | Back | Return to previous screen |
|
|
194
|
-
|
|
195
|
-
### AI Review findings actions
|
|
196
|
-
|
|
197
|
-
| Key | Action | Description |
|
|
198
|
-
|-----|--------|-------------|
|
|
199
|
-
| `↑↓` | Navigate | Browse findings |
|
|
200
|
-
| `Enter` | Detail | View finding detail |
|
|
201
|
-
| `g` | AI suggestions | Generate rules from review findings (on demand) |
|
|
202
|
-
| `p` | Publish | Publish findings to Bitbucket PR |
|
|
203
|
-
| `Esc` | Back | Return to previous screen |
|
|
204
|
-
|
|
205
|
-
---
|
|
206
|
-
|
|
207
|
-
## AI Review — full PR analysis (LLM-powered)
|
|
208
|
-
|
|
209
|
-
```bash
|
|
210
|
-
prism review start --workspace acme --repo app --pr 42
|
|
211
|
-
|
|
212
|
-
# Verbose logging
|
|
213
|
-
prism review start --workspace acme --repo app --pr 42 --verbose
|
|
214
|
-
|
|
215
|
-
# Pick a provider explicitly
|
|
216
|
-
prism review start --workspace acme --repo app --pr 42 --provider anthropic
|
|
217
|
-
prism review start --workspace acme --repo app --pr 42 --provider claude-code
|
|
218
|
-
|
|
219
|
-
# Generate rule suggestions from findings
|
|
220
|
-
prism review start --workspace acme --repo app --pr 42 --suggest-rules
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
> **Note:** `review start` requires `--workspace` and `--repo` explicitly (no auto-detect from git origin). `guard check` auto-detects both.
|
|
224
|
-
|
|
225
|
-
The AI review runs specialized agents (TypeScript, PHP, CSS, Security, Architecture, Performance, …) and produces findings with inline suggestions. Findings are stored in a local SQLite database for review memory and pattern generation.
|
|
226
|
-
|
|
227
|
-
---
|
|
228
|
-
|
|
229
|
-
## Commands
|
|
230
|
-
|
|
231
|
-
| Command | Purpose |
|
|
232
|
-
|---------|---------|
|
|
233
|
-
| `prism` | Launch main interactive TUI |
|
|
234
|
-
| `prism login` | Authenticate with Bitbucket |
|
|
235
|
-
| `prism logout` | Remove stored credentials |
|
|
236
|
-
| `prism guard` | Guard Check TUI |
|
|
237
|
-
| `prism guard check` | Non-interactive pattern check (manifest v3) |
|
|
238
|
-
| `prism rules bootstrap` | Detect stack, generate manifest, push to rules repo |
|
|
239
|
-
| `prism rules sync` | ~~Legacy v2.~~ Generate `.prism-patterns.json` from local review history (deprecated) |
|
|
240
|
-
| `prism rules push` | ~~Legacy v2.~~ Push a local `.prism-patterns.json` to the rules repo (deprecated) |
|
|
241
|
-
| `prism rules stats` | Show aggregated finding patterns from local review history |
|
|
242
|
-
| `prism review start` | Run an AI code review on a PR |
|
|
243
|
-
|
|
244
|
-
### guard check flags
|
|
245
|
-
|
|
246
|
-
| Flag | Description |
|
|
247
|
-
|------|-------------|
|
|
248
|
-
| `--workspace, -w` | Bitbucket workspace (auto-detected from git origin) |
|
|
249
|
-
| `--repo, -r` | Repository slug (auto-detected from git origin) |
|
|
250
|
-
| `--pr, -p` | Pull request ID (interactive picker if omitted) |
|
|
251
|
-
| `--verbose` | Show diff context and suggestions |
|
|
252
|
-
| `--min-severity` | Filter: `critical`, `high`, `medium`, `low`, `info` |
|
|
253
|
-
| `--json` | Structured JSON output (CI-friendly) |
|
|
254
|
-
| `--skip-ast` | Skip ast-grep, keyword-only matching |
|
|
255
|
-
| `--auto-tune` | Auto-exclude patterns with repeated false positives |
|
|
256
|
-
| `--suggest-rules` | Generate AI rules from recurring findings |
|
|
257
|
-
| `--mark-fp` | Mark pattern IDs as false positive (comma-separated) |
|
|
258
|
-
| `--patterns` | Path to local patterns file (bypasses manifest) |
|
|
259
|
-
| `--remote` | **Deprecated.** Use v2 remote fetch path |
|
|
260
|
-
|
|
261
|
-
### Exit codes (guard check)
|
|
262
|
-
|
|
263
|
-
- `0` — no matches found
|
|
264
|
-
- `1` — matches found (or error)
|
|
265
|
-
|
|
266
|
-
Useful in CI:
|
|
267
|
-
|
|
268
|
-
```bash
|
|
269
|
-
prism guard check --pr "$PR_ID" --min-severity high --json > findings.json
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
---
|
|
273
|
-
|
|
274
|
-
## Concepts
|
|
275
|
-
|
|
276
|
-
### Manifest v3
|
|
277
|
-
|
|
278
|
-
A `ProjectManifest` lives at `projects/<workspace>/<repo>.json` in the shared rules repo. It references rulesets by id instead of inlining patterns:
|
|
279
|
-
|
|
280
|
-
```json
|
|
281
|
-
{
|
|
282
|
-
"version": 3,
|
|
283
|
-
"generatedAt": "2026-04-13T21:00:00.000Z",
|
|
284
|
-
"stack": {
|
|
285
|
-
"languages": ["typescript"],
|
|
286
|
-
"frameworks": [{ "name": "angular", "version": "17.3.0" }],
|
|
287
|
-
"detectedAt": "2026-04-13T21:00:00.000Z"
|
|
288
|
-
},
|
|
289
|
-
"includes": ["angular/base", "angular/v17", "shared/typescript", "shared/security@1.0.0"],
|
|
290
|
-
"excludes": ["general--debug--console-log"],
|
|
291
|
-
"patterns": []
|
|
292
|
-
}
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
- `includes` — ruleset IDs to pull in (supports `@version` pinning)
|
|
296
|
-
- `excludes` — pattern IDs to skip (auto-tune populates this)
|
|
297
|
-
- `patterns` — project-specific custom patterns (AI suggestions land here)
|
|
298
|
-
|
|
299
|
-
### Rulesets
|
|
300
|
-
|
|
301
|
-
Built-in rulesets today (9 rulesets, 30+ ast-grep patterns):
|
|
302
|
-
|
|
303
|
-
- `shared/general`, `shared/security`, `shared/typescript`
|
|
304
|
-
- `angular/base`, `angular/v17`
|
|
305
|
-
- `react/base`
|
|
306
|
-
- `nestjs/base`
|
|
307
|
-
- `ag-grid/base`, `ag-grid/v32`
|
|
308
|
-
|
|
309
|
-
### Remote catalog structure
|
|
310
|
-
|
|
311
|
-
All teams share a single Bitbucket rules repository that hosts manifests and versioned rulesets. The default shared repo is `walzate1/prism-rules`:
|
|
312
|
-
|
|
313
|
-
```
|
|
314
|
-
{rules-repo} (Bitbucket)
|
|
315
|
-
├── projects/{workspace}/{repo}.json # per-project manifest
|
|
316
|
-
├── rulesets/{id}.json # unversioned rulesets (backward compat)
|
|
317
|
-
└── catalog/
|
|
318
|
-
├── index.json # catalog index (all rulesets + versions)
|
|
319
|
-
└── {id}/{version}.json # immutable versioned rulesets
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
### Severity levels
|
|
323
|
-
|
|
324
|
-
`critical` · `high` · `medium` · `low` · `info`
|
|
325
|
-
|
|
326
|
-
### Pattern resolution flow
|
|
327
|
-
|
|
328
|
-
1. `--patterns <file>` explicitly set → use local file (bypasses manifest)
|
|
329
|
-
2. Fetch manifest from `projects/<ws>/<repo>.json`
|
|
330
|
-
3. If no manifest → **auto-bootstrap** (detect stack → generate → push → continue)
|
|
331
|
-
4. If manifest is stale (>7 days) → **auto-refresh** (re-detect stack → smart merge → push)
|
|
332
|
-
5. Resolve includes via 3-level fallback (versioned → unversioned → static builtin)
|
|
333
|
-
6. Apply excludes → merge custom patterns → run guard
|
|
334
|
-
|
|
335
|
-
---
|
|
336
|
-
|
|
337
|
-
## License
|
|
338
|
-
|
|
339
|
-
UNLICENSED — All rights reserved.
|
|
1
|
+
# PRISM-PR
|
|
2
|
+
|
|
3
|
+
> **Alpha** — this package is in active development (`1.0.0-alpha`). APIs and commands may change between releases.
|
|
4
|
+
|
|
5
|
+
Intelligent Pull Request review orchestrator for Bitbucket. AI-powered code review plus pattern-based pre-checks using ast-grep structural matching, a shared team rules repository, and a self-evolving rule system that learns from your feedback.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i -g prism-pr
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
- Node.js **>= 22.5.0** (SQLite is loaded via the native `node:sqlite` module)
|
|
16
|
+
- Bitbucket Cloud account with an Atlassian API token
|
|
17
|
+
- AI provider (one of):
|
|
18
|
+
- `ANTHROPIC_API_KEY` environment variable (preferred), or
|
|
19
|
+
- [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code) installed and authenticated
|
|
20
|
+
|
|
21
|
+
## Setup
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
prism login
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Your Bitbucket app password / API token needs these permissions:
|
|
28
|
+
|
|
29
|
+
- Repositories: **Read** + **Write**
|
|
30
|
+
- Pull requests: **Read** + **Write**
|
|
31
|
+
|
|
32
|
+
## Discoverability — always available
|
|
33
|
+
|
|
34
|
+
Every command documents itself via `--help`. If something in this README is stale, trust `--help`:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
prism --help # full command tree
|
|
38
|
+
prism rules --help # subcommands under `rules`
|
|
39
|
+
prism guard --help # subcommands under `guard`
|
|
40
|
+
prism rules bootstrap --help # flags + examples for a specific command
|
|
41
|
+
prism guard check --help
|
|
42
|
+
prism review start --help
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Quick start — zero config
|
|
48
|
+
|
|
49
|
+
PRISM auto-detects your stack and bootstraps rules on the first run. No setup needed.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
cd your-bitbucket-repo
|
|
53
|
+
prism guard check
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
That's it. On first run, PRISM will:
|
|
57
|
+
|
|
58
|
+
1. Detect workspace/repo from your git remote
|
|
59
|
+
2. Fetch `package.json` via Bitbucket API to detect your stack (TypeScript, Angular, React, NestJS, AG Grid, …)
|
|
60
|
+
3. Generate a manifest with the matching rulesets
|
|
61
|
+
4. Push everything to the shared rules repository
|
|
62
|
+
5. Resolve patterns and check your PR
|
|
63
|
+
|
|
64
|
+
### Manual bootstrap (optional)
|
|
65
|
+
|
|
66
|
+
If you prefer explicit control:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Detect stack and push manifest + rulesets to the shared rules repo
|
|
70
|
+
prism rules bootstrap
|
|
71
|
+
|
|
72
|
+
# Preview without pushing
|
|
73
|
+
prism rules bootstrap --dry-run
|
|
74
|
+
|
|
75
|
+
# JSON output (CI-friendly)
|
|
76
|
+
prism rules bootstrap --dry-run --json
|
|
77
|
+
|
|
78
|
+
# Explicit workspace/repo/branch
|
|
79
|
+
prism rules bootstrap --workspace acme --repo my-repo --branch develop
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Check a PR
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Interactive PR picker (auto-detects workspace/repo from git origin)
|
|
86
|
+
prism guard check
|
|
87
|
+
|
|
88
|
+
# Pick a PR by ID
|
|
89
|
+
prism guard check --pr 42
|
|
90
|
+
|
|
91
|
+
# Full output with code snippets and suggestions
|
|
92
|
+
prism guard check --pr 42 --verbose
|
|
93
|
+
|
|
94
|
+
# Filter by severity
|
|
95
|
+
prism guard check --pr 42 --min-severity high --verbose
|
|
96
|
+
|
|
97
|
+
# JSON output for CI
|
|
98
|
+
prism guard check --pr 42 --json
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**`--verbose` gates the snippet and suggestion.** Without it, matches show severity badge + title + file:line only. With `--verbose`, you get diff context with a pointer on the exact line, plus the fix suggestion.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Living Rules — self-evolving rule system
|
|
106
|
+
|
|
107
|
+
PRISM's rules aren't static. They learn, adapt, and grow with your codebase.
|
|
108
|
+
|
|
109
|
+
### Auto-Refresh
|
|
110
|
+
|
|
111
|
+
Manifests detect when your stack changes. If you add a new framework (e.g. NestJS) to your project, the next guard check automatically updates the manifest with the new rulesets. Default staleness threshold: 7 days.
|
|
112
|
+
|
|
113
|
+
### Versioned Catalog
|
|
114
|
+
|
|
115
|
+
Rulesets are published as immutable versioned artifacts:
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
catalog/
|
|
119
|
+
shared/security/1.0.0.json # immutable, infinite cache
|
|
120
|
+
shared/general/1.0.0.json
|
|
121
|
+
angular/v17/1.0.0.json
|
|
122
|
+
...
|
|
123
|
+
catalog/index.json # lists all rulesets + latest versions
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Manifests can pin versions: `"shared/security@1.2.0"`. Unversioned includes resolve to latest. A 3-level fallback chain ensures resilience: versioned remote → unversioned remote → static builtin catalog.
|
|
127
|
+
|
|
128
|
+
### Feedback Loop & Auto-Tune
|
|
129
|
+
|
|
130
|
+
Mark findings as false positives. After enough feedback, PRISM auto-excludes noisy patterns.
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# CLI: mark specific pattern IDs as false positive
|
|
134
|
+
prism guard check --pr 42 --mark-fp "security--xss--innerHTML-usage,general--debug--console-log"
|
|
135
|
+
|
|
136
|
+
# CLI: auto-exclude patterns with 3+ false positives
|
|
137
|
+
prism guard check --pr 42 --auto-tune
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
In the TUI, press `[f]` on any finding to mark it as a false positive. Press `[t]` in the results screen to apply auto-tune.
|
|
141
|
+
|
|
142
|
+
### AI Rule Suggestion
|
|
143
|
+
|
|
144
|
+
PRISM can analyze findings from any review and generate new ast-grep rules automatically. Rule suggestions are a **post-review** action — you see the findings first, then decide which patterns should become permanent rules.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# CLI: generate rules from guard findings
|
|
148
|
+
prism guard check --pr 42 --suggest-rules
|
|
149
|
+
|
|
150
|
+
# CLI: generate rules from AI review findings
|
|
151
|
+
prism review start --workspace acme --repo app --pr 42 --suggest-rules
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
PRISM uses the same AI provider configured for reviews (auto-detects from `ANTHROPIC_API_KEY` or falls back to Claude Code CLI).
|
|
155
|
+
|
|
156
|
+
In the TUI, press `[g]` on any results screen (guard results or AI review findings) to generate rule suggestions on demand. Review, accept/reject, and apply to the manifest.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Interactive TUI
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
prism # main TUI (review + navigation)
|
|
164
|
+
prism guard # guard-focused TUI
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Launches a full Ink-based terminal UI with keyboard navigation.
|
|
168
|
+
|
|
169
|
+
### Guardian Angel section
|
|
170
|
+
|
|
171
|
+
- **Guard Check** — select workspace → repo → PR → run check
|
|
172
|
+
- **Guard Check (auto-detect)** — detects workspace/repo from git origin, skips manual selection
|
|
173
|
+
- **Rules Bootstrap** — detect stack and push manifest (dry-run toggle, branch override)
|
|
174
|
+
|
|
175
|
+
### Guard options (toggleable in guard-home)
|
|
176
|
+
|
|
177
|
+
| Key | Option | Description |
|
|
178
|
+
|-----|--------|-------------|
|
|
179
|
+
| `v` | Verbose | Show context lines and suggestions |
|
|
180
|
+
| `s` | Severity | Cycle minimum severity filter |
|
|
181
|
+
| `a` | AST | Toggle ast-grep matching on/off |
|
|
182
|
+
|
|
183
|
+
### Guard results actions
|
|
184
|
+
|
|
185
|
+
| Key | Action | Description |
|
|
186
|
+
|-----|--------|-------------|
|
|
187
|
+
| `↑↓` | Navigate | Browse findings |
|
|
188
|
+
| `Enter` | Detail | View finding detail with context |
|
|
189
|
+
| `f` | False positive | Mark finding as FP (in detail view) |
|
|
190
|
+
| `j` | Export JSON | Export results to `prism-guard-results.json` |
|
|
191
|
+
| `t` | Auto-tune | Batch-exclude patterns with enough FP feedback |
|
|
192
|
+
| `g` | AI suggestions | Generate and review AI-suggested rules (on demand) |
|
|
193
|
+
| `Esc` | Back | Return to previous screen |
|
|
194
|
+
|
|
195
|
+
### AI Review findings actions
|
|
196
|
+
|
|
197
|
+
| Key | Action | Description |
|
|
198
|
+
|-----|--------|-------------|
|
|
199
|
+
| `↑↓` | Navigate | Browse findings |
|
|
200
|
+
| `Enter` | Detail | View finding detail |
|
|
201
|
+
| `g` | AI suggestions | Generate rules from review findings (on demand) |
|
|
202
|
+
| `p` | Publish | Publish findings to Bitbucket PR |
|
|
203
|
+
| `Esc` | Back | Return to previous screen |
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## AI Review — full PR analysis (LLM-powered)
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
prism review start --workspace acme --repo app --pr 42
|
|
211
|
+
|
|
212
|
+
# Verbose logging
|
|
213
|
+
prism review start --workspace acme --repo app --pr 42 --verbose
|
|
214
|
+
|
|
215
|
+
# Pick a provider explicitly
|
|
216
|
+
prism review start --workspace acme --repo app --pr 42 --provider anthropic
|
|
217
|
+
prism review start --workspace acme --repo app --pr 42 --provider claude-code
|
|
218
|
+
|
|
219
|
+
# Generate rule suggestions from findings
|
|
220
|
+
prism review start --workspace acme --repo app --pr 42 --suggest-rules
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
> **Note:** `review start` requires `--workspace` and `--repo` explicitly (no auto-detect from git origin). `guard check` auto-detects both.
|
|
224
|
+
|
|
225
|
+
The AI review runs specialized agents (TypeScript, PHP, CSS, Security, Architecture, Performance, …) and produces findings with inline suggestions. Findings are stored in a local SQLite database for review memory and pattern generation.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Commands
|
|
230
|
+
|
|
231
|
+
| Command | Purpose |
|
|
232
|
+
|---------|---------|
|
|
233
|
+
| `prism` | Launch main interactive TUI |
|
|
234
|
+
| `prism login` | Authenticate with Bitbucket |
|
|
235
|
+
| `prism logout` | Remove stored credentials |
|
|
236
|
+
| `prism guard` | Guard Check TUI |
|
|
237
|
+
| `prism guard check` | Non-interactive pattern check (manifest v3) |
|
|
238
|
+
| `prism rules bootstrap` | Detect stack, generate manifest, push to rules repo |
|
|
239
|
+
| `prism rules sync` | ~~Legacy v2.~~ Generate `.prism-patterns.json` from local review history (deprecated) |
|
|
240
|
+
| `prism rules push` | ~~Legacy v2.~~ Push a local `.prism-patterns.json` to the rules repo (deprecated) |
|
|
241
|
+
| `prism rules stats` | Show aggregated finding patterns from local review history |
|
|
242
|
+
| `prism review start` | Run an AI code review on a PR |
|
|
243
|
+
|
|
244
|
+
### guard check flags
|
|
245
|
+
|
|
246
|
+
| Flag | Description |
|
|
247
|
+
|------|-------------|
|
|
248
|
+
| `--workspace, -w` | Bitbucket workspace (auto-detected from git origin) |
|
|
249
|
+
| `--repo, -r` | Repository slug (auto-detected from git origin) |
|
|
250
|
+
| `--pr, -p` | Pull request ID (interactive picker if omitted) |
|
|
251
|
+
| `--verbose` | Show diff context and suggestions |
|
|
252
|
+
| `--min-severity` | Filter: `critical`, `high`, `medium`, `low`, `info` |
|
|
253
|
+
| `--json` | Structured JSON output (CI-friendly) |
|
|
254
|
+
| `--skip-ast` | Skip ast-grep, keyword-only matching |
|
|
255
|
+
| `--auto-tune` | Auto-exclude patterns with repeated false positives |
|
|
256
|
+
| `--suggest-rules` | Generate AI rules from recurring findings |
|
|
257
|
+
| `--mark-fp` | Mark pattern IDs as false positive (comma-separated) |
|
|
258
|
+
| `--patterns` | Path to local patterns file (bypasses manifest) |
|
|
259
|
+
| `--remote` | **Deprecated.** Use v2 remote fetch path |
|
|
260
|
+
|
|
261
|
+
### Exit codes (guard check)
|
|
262
|
+
|
|
263
|
+
- `0` — no matches found
|
|
264
|
+
- `1` — matches found (or error)
|
|
265
|
+
|
|
266
|
+
Useful in CI:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
prism guard check --pr "$PR_ID" --min-severity high --json > findings.json
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Concepts
|
|
275
|
+
|
|
276
|
+
### Manifest v3
|
|
277
|
+
|
|
278
|
+
A `ProjectManifest` lives at `projects/<workspace>/<repo>.json` in the shared rules repo. It references rulesets by id instead of inlining patterns:
|
|
279
|
+
|
|
280
|
+
```json
|
|
281
|
+
{
|
|
282
|
+
"version": 3,
|
|
283
|
+
"generatedAt": "2026-04-13T21:00:00.000Z",
|
|
284
|
+
"stack": {
|
|
285
|
+
"languages": ["typescript"],
|
|
286
|
+
"frameworks": [{ "name": "angular", "version": "17.3.0" }],
|
|
287
|
+
"detectedAt": "2026-04-13T21:00:00.000Z"
|
|
288
|
+
},
|
|
289
|
+
"includes": ["angular/base", "angular/v17", "shared/typescript", "shared/security@1.0.0"],
|
|
290
|
+
"excludes": ["general--debug--console-log"],
|
|
291
|
+
"patterns": []
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
- `includes` — ruleset IDs to pull in (supports `@version` pinning)
|
|
296
|
+
- `excludes` — pattern IDs to skip (auto-tune populates this)
|
|
297
|
+
- `patterns` — project-specific custom patterns (AI suggestions land here)
|
|
298
|
+
|
|
299
|
+
### Rulesets
|
|
300
|
+
|
|
301
|
+
Built-in rulesets today (9 rulesets, 30+ ast-grep patterns):
|
|
302
|
+
|
|
303
|
+
- `shared/general`, `shared/security`, `shared/typescript`
|
|
304
|
+
- `angular/base`, `angular/v17`
|
|
305
|
+
- `react/base`
|
|
306
|
+
- `nestjs/base`
|
|
307
|
+
- `ag-grid/base`, `ag-grid/v32`
|
|
308
|
+
|
|
309
|
+
### Remote catalog structure
|
|
310
|
+
|
|
311
|
+
All teams share a single Bitbucket rules repository that hosts manifests and versioned rulesets. The default shared repo is `walzate1/prism-rules`:
|
|
312
|
+
|
|
313
|
+
```
|
|
314
|
+
{rules-repo} (Bitbucket)
|
|
315
|
+
├── projects/{workspace}/{repo}.json # per-project manifest
|
|
316
|
+
├── rulesets/{id}.json # unversioned rulesets (backward compat)
|
|
317
|
+
└── catalog/
|
|
318
|
+
├── index.json # catalog index (all rulesets + versions)
|
|
319
|
+
└── {id}/{version}.json # immutable versioned rulesets
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Severity levels
|
|
323
|
+
|
|
324
|
+
`critical` · `high` · `medium` · `low` · `info`
|
|
325
|
+
|
|
326
|
+
### Pattern resolution flow
|
|
327
|
+
|
|
328
|
+
1. `--patterns <file>` explicitly set → use local file (bypasses manifest)
|
|
329
|
+
2. Fetch manifest from `projects/<ws>/<repo>.json`
|
|
330
|
+
3. If no manifest → **auto-bootstrap** (detect stack → generate → push → continue)
|
|
331
|
+
4. If manifest is stale (>7 days) → **auto-refresh** (re-detect stack → smart merge → push)
|
|
332
|
+
5. Resolve includes via 3-level fallback (versioned → unversioned → static builtin)
|
|
333
|
+
6. Apply excludes → merge custom patterns → run guard
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## License
|
|
338
|
+
|
|
339
|
+
UNLICENSED — All rights reserved.
|