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.
Files changed (54) hide show
  1. prism_radar-2.0.0/LICENSE +21 -0
  2. prism_radar-2.0.0/PKG-INFO +519 -0
  3. prism_radar-2.0.0/README.md +483 -0
  4. prism_radar-2.0.0/pyproject.toml +68 -0
  5. prism_radar-2.0.0/setup.cfg +4 -0
  6. prism_radar-2.0.0/src/prism/__init__.py +7 -0
  7. prism_radar-2.0.0/src/prism/cli.py +553 -0
  8. prism_radar-2.0.0/src/prism/core/__init__.py +1 -0
  9. prism_radar-2.0.0/src/prism/core/blast.py +246 -0
  10. prism_radar-2.0.0/src/prism/core/config.py +111 -0
  11. prism_radar-2.0.0/src/prism/core/contracts.py +205 -0
  12. prism_radar-2.0.0/src/prism/core/git.py +193 -0
  13. prism_radar-2.0.0/src/prism/core/graph.py +145 -0
  14. prism_radar-2.0.0/src/prism/core/hook.py +86 -0
  15. prism_radar-2.0.0/src/prism/core/patch.py +94 -0
  16. prism_radar-2.0.0/src/prism/core/remediation.py +60 -0
  17. prism_radar-2.0.0/src/prism/core/sarif.py +113 -0
  18. prism_radar-2.0.0/src/prism/core/tests.py +116 -0
  19. prism_radar-2.0.0/src/prism/core/visual.py +126 -0
  20. prism_radar-2.0.0/src/prism/core/watch.py +58 -0
  21. prism_radar-2.0.0/src/prism/parsers/__init__.py +1 -0
  22. prism_radar-2.0.0/src/prism/parsers/base.py +99 -0
  23. prism_radar-2.0.0/src/prism/parsers/js_ts_parser.py +329 -0
  24. prism_radar-2.0.0/src/prism/parsers/python_parser.py +352 -0
  25. prism_radar-2.0.0/src/prism/ui/__init__.py +1 -0
  26. prism_radar-2.0.0/src/prism/ui/console.py +195 -0
  27. prism_radar-2.0.0/src/prism_radar.egg-info/PKG-INFO +519 -0
  28. prism_radar-2.0.0/src/prism_radar.egg-info/SOURCES.txt +52 -0
  29. prism_radar-2.0.0/src/prism_radar.egg-info/dependency_links.txt +1 -0
  30. prism_radar-2.0.0/src/prism_radar.egg-info/entry_points.txt +2 -0
  31. prism_radar-2.0.0/src/prism_radar.egg-info/requires.txt +7 -0
  32. prism_radar-2.0.0/src/prism_radar.egg-info/top_level.txt +1 -0
  33. prism_radar-2.0.0/tests/test_async_contracts.py +113 -0
  34. prism_radar-2.0.0/tests/test_blast.py +60 -0
  35. prism_radar-2.0.0/tests/test_cli.py +44 -0
  36. prism_radar-2.0.0/tests/test_cli_v1.py +75 -0
  37. prism_radar-2.0.0/tests/test_cli_v2.py +87 -0
  38. prism_radar-2.0.0/tests/test_config.py +77 -0
  39. prism_radar-2.0.0/tests/test_contracts.py +152 -0
  40. prism_radar-2.0.0/tests/test_contracts_advanced.py +90 -0
  41. prism_radar-2.0.0/tests/test_contracts_double_count.py +61 -0
  42. prism_radar-2.0.0/tests/test_dag.py +28 -0
  43. prism_radar-2.0.0/tests/test_diamond.py +41 -0
  44. prism_radar-2.0.0/tests/test_git_advanced.py +98 -0
  45. prism_radar-2.0.0/tests/test_graph.py +121 -0
  46. prism_radar-2.0.0/tests/test_hook.py +26 -0
  47. prism_radar-2.0.0/tests/test_parsers.py +69 -0
  48. prism_radar-2.0.0/tests/test_parsers_advanced.py +128 -0
  49. prism_radar-2.0.0/tests/test_patch.py +64 -0
  50. prism_radar-2.0.0/tests/test_remediation.py +41 -0
  51. prism_radar-2.0.0/tests/test_sarif.py +50 -0
  52. prism_radar-2.0.0/tests/test_test_impact.py +35 -0
  53. prism_radar-2.0.0/tests/test_visual_graph.py +97 -0
  54. 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
+ [![PyPI version](https://img.shields.io/pypi/v/prism-radar.svg?color=00d4ff&style=flat-square)](https://pypi.org/project/prism-radar/)
53
+ [![GitHub Release](https://img.shields.io/github/v/release/shenald-dev/prism?color=00d4ff&style=flat-square&logo=github)](https://github.com/shenald-dev/prism/releases)
54
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg?style=flat-square)](https://www.python.org/downloads/)
55
+ [![License: MIT](https://img.shields.io/badge/License-MIT-purple.svg?style=flat-square)](LICENSE)
56
+ [![CI Passing](https://img.shields.io/badge/CI-Passing-brightgreen.svg?style=flat-square)](https://github.com/shenald-dev/prism/actions)
57
+ [![Speed](https://img.shields.io/badge/speed-%3C50ms-cyan.svg?style=flat-square)](#architecture)
58
+ [![Zero Config](https://img.shields.io/badge/config-zero-success.svg?style=flat-square)](#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).