prism-radar 2.0.0__tar.gz
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.
- prism_radar-2.0.0/LICENSE +21 -0
- prism_radar-2.0.0/PKG-INFO +519 -0
- prism_radar-2.0.0/README.md +483 -0
- prism_radar-2.0.0/pyproject.toml +68 -0
- prism_radar-2.0.0/setup.cfg +4 -0
- prism_radar-2.0.0/src/prism/__init__.py +7 -0
- prism_radar-2.0.0/src/prism/cli.py +553 -0
- prism_radar-2.0.0/src/prism/core/__init__.py +1 -0
- prism_radar-2.0.0/src/prism/core/blast.py +246 -0
- prism_radar-2.0.0/src/prism/core/config.py +111 -0
- prism_radar-2.0.0/src/prism/core/contracts.py +205 -0
- prism_radar-2.0.0/src/prism/core/git.py +193 -0
- prism_radar-2.0.0/src/prism/core/graph.py +145 -0
- prism_radar-2.0.0/src/prism/core/hook.py +86 -0
- prism_radar-2.0.0/src/prism/core/patch.py +94 -0
- prism_radar-2.0.0/src/prism/core/remediation.py +60 -0
- prism_radar-2.0.0/src/prism/core/sarif.py +113 -0
- prism_radar-2.0.0/src/prism/core/tests.py +116 -0
- prism_radar-2.0.0/src/prism/core/visual.py +126 -0
- prism_radar-2.0.0/src/prism/core/watch.py +58 -0
- prism_radar-2.0.0/src/prism/parsers/__init__.py +1 -0
- prism_radar-2.0.0/src/prism/parsers/base.py +99 -0
- prism_radar-2.0.0/src/prism/parsers/js_ts_parser.py +329 -0
- prism_radar-2.0.0/src/prism/parsers/python_parser.py +352 -0
- prism_radar-2.0.0/src/prism/ui/__init__.py +1 -0
- prism_radar-2.0.0/src/prism/ui/console.py +195 -0
- prism_radar-2.0.0/src/prism_radar.egg-info/PKG-INFO +519 -0
- prism_radar-2.0.0/src/prism_radar.egg-info/SOURCES.txt +52 -0
- prism_radar-2.0.0/src/prism_radar.egg-info/dependency_links.txt +1 -0
- prism_radar-2.0.0/src/prism_radar.egg-info/entry_points.txt +2 -0
- prism_radar-2.0.0/src/prism_radar.egg-info/requires.txt +7 -0
- prism_radar-2.0.0/src/prism_radar.egg-info/top_level.txt +1 -0
- prism_radar-2.0.0/tests/test_async_contracts.py +113 -0
- prism_radar-2.0.0/tests/test_blast.py +60 -0
- prism_radar-2.0.0/tests/test_cli.py +44 -0
- prism_radar-2.0.0/tests/test_cli_v1.py +75 -0
- prism_radar-2.0.0/tests/test_cli_v2.py +87 -0
- prism_radar-2.0.0/tests/test_config.py +77 -0
- prism_radar-2.0.0/tests/test_contracts.py +152 -0
- prism_radar-2.0.0/tests/test_contracts_advanced.py +90 -0
- prism_radar-2.0.0/tests/test_contracts_double_count.py +61 -0
- prism_radar-2.0.0/tests/test_dag.py +28 -0
- prism_radar-2.0.0/tests/test_diamond.py +41 -0
- prism_radar-2.0.0/tests/test_git_advanced.py +98 -0
- prism_radar-2.0.0/tests/test_graph.py +121 -0
- prism_radar-2.0.0/tests/test_hook.py +26 -0
- prism_radar-2.0.0/tests/test_parsers.py +69 -0
- prism_radar-2.0.0/tests/test_parsers_advanced.py +128 -0
- prism_radar-2.0.0/tests/test_patch.py +64 -0
- prism_radar-2.0.0/tests/test_remediation.py +41 -0
- prism_radar-2.0.0/tests/test_sarif.py +50 -0
- prism_radar-2.0.0/tests/test_test_impact.py +35 -0
- prism_radar-2.0.0/tests/test_visual_graph.py +97 -0
- prism_radar-2.0.0/tests/test_watch.py +45 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 shenald-dev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: prism-radar
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: π Real-time topological blast radius and contract analysis for AI-generated code. Know what will break before you commit.
|
|
5
|
+
Author-email: Shenal Diluksha <shenald@users.noreply.github.com>
|
|
6
|
+
Maintainer-email: shenald-dev <shenald@users.noreply.github.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/shenald-dev/prism
|
|
9
|
+
Project-URL: Documentation, https://github.com/shenald-dev/prism#readme
|
|
10
|
+
Project-URL: Repository, https://github.com/shenald-dev/prism
|
|
11
|
+
Project-URL: Issues, https://github.com/shenald-dev/prism/issues
|
|
12
|
+
Project-URL: Changelog, https://github.com/shenald-dev/prism/blob/main/CHANGELOG.md
|
|
13
|
+
Keywords: ai,vibe-coding,blast-radius,code-analysis,ast,cli,dependency-graph,contracts,git-diff
|
|
14
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
+
Classifier: Environment :: Console
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
24
|
+
Classifier: Topic :: Software Development :: Testing
|
|
25
|
+
Classifier: Topic :: Utilities
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: rich>=13.7.0
|
|
30
|
+
Requires-Dist: typer>=0.12.0
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: ruff>=0.3.0; extra == "dev"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
<div align="center">
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
βββββββ βββββββ βββββββββββββββ ββββ
|
|
41
|
+
ββββββββββββββββββββββββββββββββ βββββ
|
|
42
|
+
ββββββββββββββββββββββββββββββββββββββ
|
|
43
|
+
βββββββ ββββββββββββββββββββββββββββββ
|
|
44
|
+
βββ βββ βββββββββββββββββ βββ βββ
|
|
45
|
+
βββ βββ βββββββββββββββββ βββ
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### π Topological Blast Radius & Invariant Radar for AI-Generated Code
|
|
49
|
+
|
|
50
|
+
*Know what the AI just broke across your entire repository before you commit.*
|
|
51
|
+
|
|
52
|
+
[](https://pypi.org/project/prism-radar/)
|
|
53
|
+
[](https://github.com/shenald-dev/prism/releases)
|
|
54
|
+
[](https://www.python.org/downloads/)
|
|
55
|
+
[](LICENSE)
|
|
56
|
+
[](https://github.com/shenald-dev/prism/actions)
|
|
57
|
+
[](#architecture)
|
|
58
|
+
[](#quick-start)
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
[The Problem](#-the-problem) β’
|
|
63
|
+
[Key Highlights](#-key-highlights) β’
|
|
64
|
+
[Quick Start](#-quick-start) β’
|
|
65
|
+
[Terminal UI](#-terminal-ui) β’
|
|
66
|
+
[Visual DAG Diagrams](#-visual-blast-diagrams) β’
|
|
67
|
+
[CLI Commands](#-cli-commands) β’
|
|
68
|
+
[Agent Loop Mode](#-agent--llm-loop-mode) β’
|
|
69
|
+
[CI / CD Enforcement](#-ci--github-actions-enforcement) β’
|
|
70
|
+
[Architecture](#-architecture)
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
## π₯ The Problem
|
|
77
|
+
|
|
78
|
+
In the era of vibe coding and autonomous AI agents (**Cursor, Claude Code, Copilot, Cline, Aider**), AI writes code at 1,000 WPM.
|
|
79
|
+
|
|
80
|
+
**However, LLMs suffer from severe tunnel vision:**
|
|
81
|
+
- An AI refactors `authenticate_user(user_id, token, tenant_id=None)` to require `org_id` as a second parameter.
|
|
82
|
+
- Or an AI converts `fetch_user_profile()` to an `async def` function, forgetting to update 15 caller sites with `await`.
|
|
83
|
+
- The AI runs its isolated unit test in `test_auth.py`, reports *"Refactoring complete!"*, and stops.
|
|
84
|
+
- Downstream in `billing/webhook.py`, `api/v1/sessions.py`, and `workers/sync.ts`, 12 callers are now silently broken with:
|
|
85
|
+
```text
|
|
86
|
+
TypeError: authenticate_user() missing 1 required positional argument: 'org_id'
|
|
87
|
+
RuntimeWarning: coroutine 'fetch_user_profile' was never awaited
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Traditional typecheckers (mypy, tsc) require strict types everywhere or take seconds to recompile your whole project. Unit tests only catch downstream breakage if you already wrote tests for every transitive caller.
|
|
91
|
+
|
|
92
|
+
**`prism` is a zero-latency topological radar.** It scans your uncommitted git diff (`git diff HEAD`) or branch diff, builds an in-memory dependency graph, traces the ripple shockwave up to N hops deep, audits contract invariants and async boundaries on callers, visualizes blast graphs, and auto-patches broken callsitesβall in **<50ms**.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## β‘ Key Highlights
|
|
97
|
+
|
|
98
|
+
- π **Topological Ripple Shockwave:** Computes the multi-hop transitive caller tree of every symbol touched in your git working tree.
|
|
99
|
+
- β‘ **Async & Coroutine Invariant Radar:** Flags unawaited coroutines (`CRITICAL`) and awaiting synchronous functions (`HIGH`) across Python and TypeScript/JavaScript.
|
|
100
|
+
- π‘οΈ **Advanced Contract Invariant Checking:** Flags missing required arguments, excess positional parameters, unexpected keyword arguments, positional-only violations (`/`), duplicate bindings, and dataclass signatures across Python 3.8β3.12 and TypeScript/JavaScript.
|
|
101
|
+
- πΊοΈ **Visual Blast Diagrams (Mermaid.js & Graphviz DOT):** Generates interactive Mermaid.js flowcharts and DOT graphs of the blast radius with color-coded risk highlighting.
|
|
102
|
+
- π©Ή **Automated Call-Site Auto-Patching (`prism fix`):** Synthesizes surgical unified diffs or directly applies fixes to callers (e.g. inserting `await`) with zero manual effort.
|
|
103
|
+
- π **Live Vibe-Coding Watcher (`prism watch`):** Sub-second filesystem daemon monitoring working tree changes in real time as AI edits your code.
|
|
104
|
+
- π§ͺ **Intelligent Test Impact Radar:** Pinpoints exact test files and test functions that directly or transitively cover modified code, flags untested modified symbols, and runs only affected tests with one command.
|
|
105
|
+
- π€ **Agent Remediation Prompt Generator (`prism explain`):** Synthesizes high-density, zero-hallucination prompt context and exact code fixes for autonomous coding agents (Claude Code, Cursor, Copilot, Aider, Devin).
|
|
106
|
+
- π **Multi-Format Enterprise Reporting:** Emits Rich terminal UI, machine-readable JSON, GitHub Flavored Markdown (`$GITHUB_STEP_SUMMARY`), Mermaid, DOT, or SARIF 2.1.0 for GitHub Code Scanning inline PR annotations.
|
|
107
|
+
- π **Revision & CI Diffing:** Analyze uncommitted changes, staged changes (`--staged`), commits (`--commit`), or base branches (`--base origin/main`).
|
|
108
|
+
- β‘ **Sub-50ms Zero-Config Engine:** Pure AST visitor with zero heavy daemon overhead. Runs instantaneously on commit hooks.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## π» Terminal UI
|
|
113
|
+
|
|
114
|
+
When you run `prism scan` after an AI edits your code:
|
|
115
|
+
|
|
116
|
+
```text
|
|
117
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
118
|
+
β ____ ____ ___ ____ __ __ β
|
|
119
|
+
β | _ \| _ \|_ _/ ___|| \/ | β
|
|
120
|
+
β | |_) | |_) || |\___ \| |\/| | β
|
|
121
|
+
β | __/| _ < | | ___) | | | | β
|
|
122
|
+
β |_| |_| \_\___|____/|_| |_| β
|
|
123
|
+
β π Topological Blast Radius & Invariant Radar β’ Zero Bloat β
|
|
124
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
125
|
+
|
|
126
|
+
π‘ Topological Ripple Shockwave:
|
|
127
|
+
|
|
128
|
+
π MODIFIED: calculate_tax (tax.py:12)
|
|
129
|
+
> def calculate_tax(amount, rate, jurisdiction)
|
|
130
|
+
βββ β οΈ BROKEN CONTRACT order_service.py::process_checkout (order_service.py:45)
|
|
131
|
+
β > Missing 1 required argument(s): 'jurisdiction'.
|
|
132
|
+
β βββ [L2 Transitive] checkout_worker.py::run_job (checkout_worker.py:18)
|
|
133
|
+
βββ [π§ͺ Test Caller] tests/test_orders.py::test_tax_calculation (tests/test_orders.py:22)
|
|
134
|
+
βββ β οΈ BROKEN CONTRACT api/v2/orders.py::handle_post (api/v2/orders.py:89)
|
|
135
|
+
> Missing 1 required argument(s): 'jurisdiction'.
|
|
136
|
+
|
|
137
|
+
π¨ Contract Violations & Signature Mismatches (2)
|
|
138
|
+
ββββββββββββββ¬βββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
|
|
139
|
+
β Sev β Caller Location β Contract Violation Reason β Suggested Fix β
|
|
140
|
+
ββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββ€
|
|
141
|
+
β CRITICAL β order_service.py:45 β Missing 1 required arg... β Pass 'jurisdiction' parameter β
|
|
142
|
+
β CRITICAL β api/v2/orders.py:89 β Missing 1 required arg... β Pass 'jurisdiction' parameter β
|
|
143
|
+
ββββββββββββββ΄βββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββ
|
|
144
|
+
|
|
145
|
+
ββββββββββββββββββββββββββββ π§ͺ TEST IMPACT RADAR βββββββββββββββββββββββββββββ
|
|
146
|
+
β β’ Impacted Test Files: 1 β
|
|
147
|
+
β β’ Impacted Test Cases: 1 β
|
|
148
|
+
β β’ Recommended Run: pytest tests/test_orders.py β
|
|
149
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
150
|
+
|
|
151
|
+
ββββββββββββββββββββ π TOPOLOGICAL BLAST RADAR TELEMETRY βββββββββββββββββββββ
|
|
152
|
+
β Blast Impact Score: 85/100 [CRITICAL] β
|
|
153
|
+
β Assessment: π¨ CRITICAL (Broken Contracts Detected) β
|
|
154
|
+
β β’ Modified Symbols: 1 β’ Direct Callers: 2 β’ Transitive: 1 β
|
|
155
|
+
β β’ Broken Contracts: 2 β’ Impacted Tests: 1 β
|
|
156
|
+
β Analyzed 24 files in 0.038s. β
|
|
157
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## πΊοΈ Visual Blast Diagrams
|
|
163
|
+
|
|
164
|
+
Export topological DAG diagrams directly into Mermaid.js or Graphviz DOT format:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
prism visual --format mermaid
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
```mermaid
|
|
171
|
+
graph TD
|
|
172
|
+
N0["MODIFIED: calculate_tax<br/>tax.py:12"]:::modified
|
|
173
|
+
N1["process_checkout<br/>order_service.py:45"]:::violation
|
|
174
|
+
N2["handle_post<br/>api/v2/orders.py:89"]:::violation
|
|
175
|
+
N3["test_tax_calculation<br/>tests/test_orders.py:22"]:::test
|
|
176
|
+
N0 --> N1
|
|
177
|
+
N0 --> N2
|
|
178
|
+
N0 --> N3
|
|
179
|
+
classDef modified fill:#ff4444,stroke:#333,stroke-width:2px,color:#fff;
|
|
180
|
+
classDef violation fill:#ffaa00,stroke:#333,stroke-width:2px,color:#000;
|
|
181
|
+
classDef test fill:#00cc88,stroke:#333,stroke-width:1px,color:#000;
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## π Quick Start
|
|
187
|
+
|
|
188
|
+
### Installation
|
|
189
|
+
|
|
190
|
+
Install directly via `pip`:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
pip install prism-radar
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Or run via `pipx` / `uv`:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
pipx install prism-radar
|
|
200
|
+
# or
|
|
201
|
+
uv tool install prism-radar
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## π οΈ CLI Commands
|
|
207
|
+
|
|
208
|
+
### 1. `prism scan` (Core Blast & Contract Radar)
|
|
209
|
+
|
|
210
|
+
Scan your current git working tree (unstaged + staged changes):
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
prism scan
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Scan against a base branch (e.g. in PRs or feature branches):
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
prism scan --base origin/main
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Scan staged changes only:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
prism scan --staged
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Run in strict mode (fails with exit code `1` if broken contracts or high risk are found):
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
prism scan --strict
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Export results as Mermaid.js or Graphviz DOT:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
prism scan --format mermaid
|
|
238
|
+
prism scan --format dot
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Export results as SARIF 2.1.0 for GitHub Code Scanning:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
prism scan --format sarif -o results.sarif
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Export results as GitHub Flavored Markdown for PR comments:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
prism scan --format markdown
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### 2. `prism visual` (Interactive DAG Diagram Generator)
|
|
254
|
+
|
|
255
|
+
Generate visual diagrams of the blast shockwave:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
# Print Mermaid diagram
|
|
259
|
+
prism visual --format mermaid
|
|
260
|
+
|
|
261
|
+
# Save Graphviz DOT diagram to file
|
|
262
|
+
prism visual --format dot -o blast-graph.dot
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### 3. `prism fix` (Automated Call-site Auto-Patching)
|
|
266
|
+
|
|
267
|
+
Inspect proposed caller fixes for broken contracts (unawaited coroutines, missing arguments):
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
prism fix
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Save unified diff patch to a file:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
prism fix --patch fix.patch
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Automatically apply fixes directly into caller source files:
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
prism fix --apply
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### 4. `prism watch` (Real-Time Vibe-Coding Radar)
|
|
286
|
+
|
|
287
|
+
Run a continuous live watcher daemon that re-scans the repository as AI edits code:
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
prism watch
|
|
291
|
+
prism watch --interval 0.5
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### 5. `prism hook install` (Git Pre-Commit Hook)
|
|
295
|
+
|
|
296
|
+
Install an instant native Git pre-commit hook into `.git/hooks/pre-commit`:
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
prism hook install
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### 6. `prism ci init` (GitHub Actions CI Setup)
|
|
303
|
+
|
|
304
|
+
Bootstrap a ready-to-run GitHub Actions CI workflow at `.github/workflows/prism-radar.yml`:
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
prism ci init
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### 7. `prism test-impact` (Smart Test Selection)
|
|
311
|
+
|
|
312
|
+
Identify exactly which tests are impacted by your current changes and find coverage gaps:
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
prism test-impact
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Automatically execute only the impacted tests:
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
prism test-impact --run
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### 8. `prism explain` (AI Agent Self-Healing Context)
|
|
325
|
+
|
|
326
|
+
Generate high-density diagnostic context and remediation instructions ready to pipe into an AI coding agent:
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
prism explain
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### 9. `prism init` (Project Configuration)
|
|
333
|
+
|
|
334
|
+
Initialize a `prism.toml` file with sensible defaults:
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
prism init
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## π€ Agent / LLM Loop Mode
|
|
343
|
+
|
|
344
|
+
If you run autonomous coding loops (**Claude Code, Cursor Agent, Copilot Workspace, Aider, Devin**), use `prism` as your invariant guardrail:
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
# Provide structured context to agent when contracts break
|
|
348
|
+
prism explain | your-agent-fixer
|
|
349
|
+
|
|
350
|
+
# Or auto-apply deterministic callsite fixes
|
|
351
|
+
prism fix --apply
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
Or pipe structured JSON:
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
prism scan --json | your-agent-fixer
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Sample JSON output:
|
|
361
|
+
|
|
362
|
+
```json
|
|
363
|
+
{
|
|
364
|
+
"impact_score": 85,
|
|
365
|
+
"risk_level": "CRITICAL",
|
|
366
|
+
"metrics": {
|
|
367
|
+
"modified_symbols": 1,
|
|
368
|
+
"direct_callers": 2,
|
|
369
|
+
"transitive_callers": 1,
|
|
370
|
+
"total_affected_files": 4,
|
|
371
|
+
"contract_violations": 2
|
|
372
|
+
},
|
|
373
|
+
"violations": [
|
|
374
|
+
{
|
|
375
|
+
"callee_name": "fetch_user",
|
|
376
|
+
"caller_file": "order_service.py",
|
|
377
|
+
"caller_line": 45,
|
|
378
|
+
"severity": "CRITICAL",
|
|
379
|
+
"reason": "Unawaited coroutine call: 'fetch_user' is an async function but called synchronously without await",
|
|
380
|
+
"snippet": "fetch_user(order.user_id)",
|
|
381
|
+
"suggested_fix": "Add 'await' prefix to coroutine invocation: await fetch_user(order.user_id)"
|
|
382
|
+
}
|
|
383
|
+
],
|
|
384
|
+
"test_impact": {
|
|
385
|
+
"impacted_test_files": ["tests/test_orders.py"],
|
|
386
|
+
"impacted_test_cases": ["tests/test_orders.py::test_user_fetch"],
|
|
387
|
+
"recommended_command": "pytest tests/test_orders.py"
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## π‘οΈ CI & GitHub Actions Enforcement
|
|
395
|
+
|
|
396
|
+
### One-Command Setup
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
prism ci init
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
This generates `.github/workflows/prism-radar.yml`:
|
|
403
|
+
|
|
404
|
+
```yaml
|
|
405
|
+
name: PRISM Blast Radius Radar
|
|
406
|
+
|
|
407
|
+
on:
|
|
408
|
+
pull_request:
|
|
409
|
+
branches: [main, master]
|
|
410
|
+
push:
|
|
411
|
+
branches: [main, master]
|
|
412
|
+
|
|
413
|
+
jobs:
|
|
414
|
+
prism-radar:
|
|
415
|
+
name: Blast Radius & Contract Radar
|
|
416
|
+
runs-on: ubuntu-latest
|
|
417
|
+
steps:
|
|
418
|
+
- name: Checkout Code
|
|
419
|
+
uses: actions/checkout@v4
|
|
420
|
+
with:
|
|
421
|
+
fetch-depth: 0
|
|
422
|
+
|
|
423
|
+
- name: Set up Python
|
|
424
|
+
uses: actions/setup-python@v5
|
|
425
|
+
with:
|
|
426
|
+
python-version: "3.11"
|
|
427
|
+
|
|
428
|
+
- name: Install PRISM
|
|
429
|
+
run: |
|
|
430
|
+
pip install git+https://github.com/shenald-dev/prism.git
|
|
431
|
+
|
|
432
|
+
- name: Run PRISM Blast Radius Radar
|
|
433
|
+
run: |
|
|
434
|
+
prism scan --base origin/main --format sarif --output prism.sarif --format markdown > prism-summary.md
|
|
435
|
+
cat prism-summary.md >> $GITHUB_STEP_SUMMARY
|
|
436
|
+
continue-on-error: true
|
|
437
|
+
|
|
438
|
+
- name: Upload SARIF to GitHub Code Scanning
|
|
439
|
+
uses: github/codeql-action/upload-sarif@v3
|
|
440
|
+
if: always()
|
|
441
|
+
with:
|
|
442
|
+
sarif_file: prism.sarif
|
|
443
|
+
category: prism-radar
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
---
|
|
447
|
+
|
|
448
|
+
## βοΈ Configuration (`prism.toml`)
|
|
449
|
+
|
|
450
|
+
Customize PRISM's analysis behavior with an optional `prism.toml` or `pyproject.toml`:
|
|
451
|
+
|
|
452
|
+
```toml
|
|
453
|
+
[prism]
|
|
454
|
+
max_depth = 6
|
|
455
|
+
strict = false
|
|
456
|
+
fail_on = "CRITICAL" # "CRITICAL", "ELEVATED", "MODERATE", or "ANY"
|
|
457
|
+
ignore_symbols = ["__repr__", "__str__", "__init__"]
|
|
458
|
+
include_tests = true
|
|
459
|
+
default_format = "terminal" # "terminal", "json", "sarif", "markdown", "mermaid", "dot"
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
## βοΈ Architecture
|
|
465
|
+
|
|
466
|
+
```
|
|
467
|
+
ββββββββββββββββββββββββ
|
|
468
|
+
β Git Diff Workspace β
|
|
469
|
+
ββββββββββββ¬ββββββββββββ
|
|
470
|
+
β (modified line spans)
|
|
471
|
+
βΌ
|
|
472
|
+
ββββββββββββββββββββ βββββββββββββββββββββββ ββββββββββββββββββββ
|
|
473
|
+
β Python AST βββββΆβ Symbol Extraction ββββββ JS / TS Lexer β
|
|
474
|
+
β Visitor Engine β β & Parameter Schema β β Parser Engine β
|
|
475
|
+
ββββββββββ¬ββββββββββ ββββββββββββ¬βββββββββββ ββββββββββ¬ββββββββββ
|
|
476
|
+
β β β
|
|
477
|
+
βΌ βΌ βΌ
|
|
478
|
+
ββββββββββββββββββββ βββββββββββββββββββββββ ββββββββββββββββββββ
|
|
479
|
+
β Import Visitor βββββΆβ Topological Graph ββββββ Test Impact Radarβ
|
|
480
|
+
β Alias Resolver β β Transitive Callers β β Coverage Gaps β
|
|
481
|
+
ββββββββββββββββββββ ββββββββββββ¬βββββββββββ ββββββββββββββββββββ
|
|
482
|
+
β
|
|
483
|
+
βΌ
|
|
484
|
+
βββββββββββββββββββββββ
|
|
485
|
+
β Contract Invariant β
|
|
486
|
+
β & Async Auditor β
|
|
487
|
+
ββββββββββββ¬βββββββββββ
|
|
488
|
+
β
|
|
489
|
+
ββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββ
|
|
490
|
+
βΌ βΌ βΌ
|
|
491
|
+
[Rich Terminal Radar] [Visual Mermaid / DOT] [Auto-Patch Remediation]
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
1. **Diff Intersector:** `git diff` computes precise line ranges for uncommitted, staged, commit, or branch diffs.
|
|
495
|
+
2. **AST Symbol Extractor:** Full structural AST visitor captures functions, methods, async status, classes, dataclasses, positional-only, keyword-only, variadic, and default parameters.
|
|
496
|
+
3. **Import Resolver:** Resolves imported modules and aliases to eliminate cross-module name collisions.
|
|
497
|
+
4. **Topological Graph:** Computes the directed acyclic graph (DAG) of callers with cycle detection and centrality scoring.
|
|
498
|
+
5. **Contract Invariant & Async Auditor:** Verifies parameter counts, keyword alignment, positional-only rules, unawaited coroutines, and invalid awaits.
|
|
499
|
+
6. **Visual & Auto-Patch Engines:** Renders Mermaid/DOT DAGs and synthesizes surgical call-site fixes.
|
|
500
|
+
|
|
501
|
+
---
|
|
502
|
+
|
|
503
|
+
## π€ Contributing
|
|
504
|
+
|
|
505
|
+
Contributions are welcome! Please open an issue or PR on [GitHub](https://github.com/shenald-dev/prism).
|
|
506
|
+
|
|
507
|
+
```bash
|
|
508
|
+
git clone https://github.com/shenald-dev/prism.git
|
|
509
|
+
cd prism
|
|
510
|
+
pip install -e ".[dev]"
|
|
511
|
+
pytest
|
|
512
|
+
ruff check .
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
## π License
|
|
518
|
+
|
|
519
|
+
MIT License. Designed and built with β€οΈ by [shenald-dev](https://github.com/shenald-dev).
|