kernhell 0.1.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.
Potentially problematic release.
This version of kernhell might be problematic. Click here for more details.
- kernhell-0.1.0/.gitignore +79 -0
- kernhell-0.1.0/.kernhellrc.toml +31 -0
- kernhell-0.1.0/LICENSE +21 -0
- kernhell-0.1.0/PKG-INFO +245 -0
- kernhell-0.1.0/README.md +184 -0
- kernhell-0.1.0/pyproject.toml +101 -0
- kernhell-0.1.0/src/kernhell/__init__.py +8 -0
- kernhell-0.1.0/src/kernhell/__main__.py +6 -0
- kernhell-0.1.0/src/kernhell/analyzer/analyzer.py +178 -0
- kernhell-0.1.0/src/kernhell/analyzer/healer.py +249 -0
- kernhell-0.1.0/src/kernhell/analyzer/prompts.py +89 -0
- kernhell-0.1.0/src/kernhell/api/__init__.py +5 -0
- kernhell-0.1.0/src/kernhell/api/server.py +367 -0
- kernhell-0.1.0/src/kernhell/cache/__init__.py +13 -0
- kernhell-0.1.0/src/kernhell/cache/cache_manager.py +221 -0
- kernhell-0.1.0/src/kernhell/cache/embedder.py +104 -0
- kernhell-0.1.0/src/kernhell/cache/schemas.py +42 -0
- kernhell-0.1.0/src/kernhell/cli/__init__.py +1 -0
- kernhell-0.1.0/src/kernhell/cli/app.py +62 -0
- kernhell-0.1.0/src/kernhell/cli/commands/__init__.py +1 -0
- kernhell-0.1.0/src/kernhell/cli/commands/cache.py +96 -0
- kernhell-0.1.0/src/kernhell/cli/commands/config.py +111 -0
- kernhell-0.1.0/src/kernhell/cli/commands/dashboard.py +55 -0
- kernhell-0.1.0/src/kernhell/cli/commands/heal.py +141 -0
- kernhell-0.1.0/src/kernhell/cli/commands/scan.py +87 -0
- kernhell-0.1.0/src/kernhell/cli/ui.py +176 -0
- kernhell-0.1.0/src/kernhell/core/__init__.py +1 -0
- kernhell-0.1.0/src/kernhell/core/config.py +219 -0
- kernhell-0.1.0/src/kernhell/core/exceptions.py +104 -0
- kernhell-0.1.0/src/kernhell/core/models.py +174 -0
- kernhell-0.1.0/src/kernhell/core/orchestrator.py +245 -0
- kernhell-0.1.0/src/kernhell/patcher/patcher.py +215 -0
- kernhell-0.1.0/src/kernhell/patcher/verifier.py +82 -0
- kernhell-0.1.0/src/kernhell/pruner/__init__.py +1 -0
- kernhell-0.1.0/src/kernhell/pruner/dom_pruner.py +240 -0
- kernhell-0.1.0/src/kernhell/reporter/__init__.py +5 -0
- kernhell-0.1.0/src/kernhell/reporter/reporter.py +124 -0
- kernhell-0.1.0/src/kernhell/scanner/__init__.py +1 -0
- kernhell-0.1.0/src/kernhell/scanner/parser.py +276 -0
- kernhell-0.1.0/src/kernhell/scanner/runner.py +242 -0
- kernhell-0.1.0/src/kernhell/utils/__init__.py +1 -0
- kernhell-0.1.0/src/kernhell/utils/file_utils.py +117 -0
- kernhell-0.1.0/src/kernhell/utils/logger.py +78 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
/lib/
|
|
14
|
+
/lib64/
|
|
15
|
+
!dashboard/src/lib/**
|
|
16
|
+
parts/
|
|
17
|
+
sdist/
|
|
18
|
+
var/
|
|
19
|
+
wheels/
|
|
20
|
+
share/python-wheels/
|
|
21
|
+
*.egg-info/
|
|
22
|
+
.installed.cfg
|
|
23
|
+
*.egg
|
|
24
|
+
MANIFEST
|
|
25
|
+
|
|
26
|
+
# Virtual Environments & Secrets
|
|
27
|
+
.env
|
|
28
|
+
.env.*
|
|
29
|
+
!.env.example
|
|
30
|
+
.venv
|
|
31
|
+
env/
|
|
32
|
+
venv/
|
|
33
|
+
ENV/
|
|
34
|
+
env.bak/
|
|
35
|
+
venv.bak/
|
|
36
|
+
|
|
37
|
+
# Testing & Coverage
|
|
38
|
+
.pytest_cache/
|
|
39
|
+
.coverage
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
coverage.xml
|
|
44
|
+
*.cover
|
|
45
|
+
*.py,cover
|
|
46
|
+
.hypothesis/
|
|
47
|
+
|
|
48
|
+
# Type Checking & Linting
|
|
49
|
+
.mypy_cache/
|
|
50
|
+
.dmypy.json
|
|
51
|
+
dmypy.json
|
|
52
|
+
.ruff_cache/
|
|
53
|
+
|
|
54
|
+
# KernHell runtime
|
|
55
|
+
.kernhell_cache/
|
|
56
|
+
*.kernhell.bak
|
|
57
|
+
.kernhell_*.tmp
|
|
58
|
+
|
|
59
|
+
# Playwright
|
|
60
|
+
test-results/
|
|
61
|
+
playwright-report/
|
|
62
|
+
blob-report/
|
|
63
|
+
playwright/.cache/
|
|
64
|
+
|
|
65
|
+
# IDE & OS
|
|
66
|
+
.vscode/
|
|
67
|
+
.idea/
|
|
68
|
+
*.swp
|
|
69
|
+
*.swo
|
|
70
|
+
*~
|
|
71
|
+
.DS_Store
|
|
72
|
+
Thumbs.db
|
|
73
|
+
|
|
74
|
+
# Dashboard (Next.js / Node)
|
|
75
|
+
dashboard/node_modules/
|
|
76
|
+
dashboard/.next/
|
|
77
|
+
dashboard/out/
|
|
78
|
+
*.tsbuildinfo
|
|
79
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# KernHell Default Configuration
|
|
2
|
+
# Override by placing a copy at ~/.kernhellrc.toml or ./.kernhellrc.toml
|
|
3
|
+
|
|
4
|
+
[llm]
|
|
5
|
+
provider = "gemini" # gemini | groq | openai | anthropic | ollama
|
|
6
|
+
model = "gemini-1.5-flash" # gemini-1.5-flash | gemini-2.0-flash | gemini-1.5-pro
|
|
7
|
+
temperature = 0.1
|
|
8
|
+
max_tokens = 2048
|
|
9
|
+
# api_key = "" # Optional: can also be set via GEMINI_API_KEY in .env
|
|
10
|
+
|
|
11
|
+
[healing]
|
|
12
|
+
confidence_threshold = 0.85
|
|
13
|
+
max_heals_per_file = 5
|
|
14
|
+
dry_run = false
|
|
15
|
+
auto_commit = false
|
|
16
|
+
|
|
17
|
+
[cache]
|
|
18
|
+
enabled = true
|
|
19
|
+
similarity_threshold = 0.92
|
|
20
|
+
cache_dir = "~/.kernhell/cache"
|
|
21
|
+
embedding_model = "all-MiniLM-L6-v2"
|
|
22
|
+
|
|
23
|
+
[scanner]
|
|
24
|
+
timeout_ms = 5000
|
|
25
|
+
capture_screenshot = true
|
|
26
|
+
browser = "chromium" # chromium | firefox | webkit
|
|
27
|
+
headless = true
|
|
28
|
+
|
|
29
|
+
[logging]
|
|
30
|
+
level = "INFO" # DEBUG | INFO | WARNING | ERROR
|
|
31
|
+
json_output = false # true for CI environments
|
kernhell-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ritesh (KernHell)
|
|
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.
|
kernhell-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: kernhell
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AI-Powered Autonomous Self-Healing Testing Engine β The Heart of Your System Where Innovation Meets Precision
|
|
5
|
+
Project-URL: Homepage, https://github.com/riteshkumar072/KernHell
|
|
6
|
+
Project-URL: Documentation, https://github.com/riteshkumar072/KernHell#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/riteshkumar072/KernHell
|
|
8
|
+
Project-URL: Issues, https://github.com/riteshkumar072/KernHell/issues
|
|
9
|
+
Author-email: Ritesh <ritesh@kernhell.dev>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai,cli,playwright,self-healing,testing
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
20
|
+
Classifier: Topic :: Software Development :: Testing
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: libcst>=1.1.0
|
|
23
|
+
Requires-Dist: litellm<2.0,>=1.30
|
|
24
|
+
Requires-Dist: playwright<2.0,>=1.40
|
|
25
|
+
Requires-Dist: pydantic-settings<3.0,>=2.1
|
|
26
|
+
Requires-Dist: pydantic<3.0,>=2.5
|
|
27
|
+
Requires-Dist: rich<16.0,>=13.0
|
|
28
|
+
Requires-Dist: selectolax<1.0,>=0.3
|
|
29
|
+
Requires-Dist: structlog>=24.0
|
|
30
|
+
Requires-Dist: tomli>=2.0; python_version < '3.11'
|
|
31
|
+
Requires-Dist: typer<1.0,>=0.12
|
|
32
|
+
Provides-Extra: all
|
|
33
|
+
Requires-Dist: aiosqlite<1.0,>=0.19; extra == 'all'
|
|
34
|
+
Requires-Dist: build>=1.0.0; extra == 'all'
|
|
35
|
+
Requires-Dist: chromadb<1.0,>=0.4; extra == 'all'
|
|
36
|
+
Requires-Dist: fastapi<1.0,>=0.110; extra == 'all'
|
|
37
|
+
Requires-Dist: mypy<2.0,>=1.8; extra == 'all'
|
|
38
|
+
Requires-Dist: pytest-asyncio<1.0,>=0.23; extra == 'all'
|
|
39
|
+
Requires-Dist: pytest-cov<6.0,>=5.0; extra == 'all'
|
|
40
|
+
Requires-Dist: pytest<9.0,>=8.0; extra == 'all'
|
|
41
|
+
Requires-Dist: ruff<1.0,>=0.3; extra == 'all'
|
|
42
|
+
Requires-Dist: sentence-transformers<3.0,>=2.2; extra == 'all'
|
|
43
|
+
Requires-Dist: twine>=5.0.0; extra == 'all'
|
|
44
|
+
Requires-Dist: uvicorn[standard]<1.0,>=0.27; extra == 'all'
|
|
45
|
+
Provides-Extra: cache
|
|
46
|
+
Requires-Dist: chromadb<1.0,>=0.4; extra == 'cache'
|
|
47
|
+
Requires-Dist: sentence-transformers<3.0,>=2.2; extra == 'cache'
|
|
48
|
+
Provides-Extra: dashboard
|
|
49
|
+
Requires-Dist: aiosqlite<1.0,>=0.19; extra == 'dashboard'
|
|
50
|
+
Requires-Dist: fastapi<1.0,>=0.110; extra == 'dashboard'
|
|
51
|
+
Requires-Dist: uvicorn[standard]<1.0,>=0.27; extra == 'dashboard'
|
|
52
|
+
Provides-Extra: dev
|
|
53
|
+
Requires-Dist: build>=1.0.0; extra == 'dev'
|
|
54
|
+
Requires-Dist: mypy<2.0,>=1.8; extra == 'dev'
|
|
55
|
+
Requires-Dist: pytest-asyncio<1.0,>=0.23; extra == 'dev'
|
|
56
|
+
Requires-Dist: pytest-cov<6.0,>=5.0; extra == 'dev'
|
|
57
|
+
Requires-Dist: pytest<9.0,>=8.0; extra == 'dev'
|
|
58
|
+
Requires-Dist: ruff<1.0,>=0.3; extra == 'dev'
|
|
59
|
+
Requires-Dist: twine>=5.0.0; extra == 'dev'
|
|
60
|
+
Description-Content-Type: text/markdown
|
|
61
|
+
|
|
62
|
+
# π₯ KernHell
|
|
63
|
+
|
|
64
|
+
> *"The Heart of Your System Where Innovation Meets Precision"*
|
|
65
|
+
|
|
66
|
+
**AI-Powered Autonomous Self-Healing Testing Engine & CLI tool for Playwright.**
|
|
67
|
+
|
|
68
|
+
[](https://www.python.org/)
|
|
69
|
+
[](https://nextjs.org/)
|
|
70
|
+
[](https://opensource.org/licenses/MIT)
|
|
71
|
+
[-brightgreen.svg)](https://github.com/riteshkumar072/KernHell)
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## β‘ The Problem
|
|
76
|
+
|
|
77
|
+
Modern frontend engineering moves fast. When developers refactor classes, IDs, or DOM wrappers (e.g., `#buy-now` becomes `#purchase-btn`), automated Playwright and Selenium test suites fail even though the business functionality works seamlessly. QA teams waste 30β40% of their time manually maintaining broken selectors.
|
|
78
|
+
|
|
79
|
+
**KernHell autonomously resolves broken selectors in real-time, preserving 100% of your code formatting, comments, and QA sanity.**
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## ποΈ Autonomous 6-Stage Healing Architecture
|
|
84
|
+
|
|
85
|
+
```mermaid
|
|
86
|
+
flowchart TD
|
|
87
|
+
A[Playwright Locator Timeout] -->|1. Intercept| B(Scanner & Live DOM Capture)
|
|
88
|
+
B -->|2. Prune| C(Selectolax Lexbor HTML5 Pruner)
|
|
89
|
+
C -->|85% Token Reduction| D{3. Dense Vector Cache}
|
|
90
|
+
D -->|Cache Hit <5ms| G[Strict DOM Verification]
|
|
91
|
+
D -->|Cache Miss| E[4. AI Brain: LiteLLM Gateway]
|
|
92
|
+
E -->|Intent Diagnosis| F{RENAME vs MISSING?}
|
|
93
|
+
F -->|MISSING: Real Bug| H[Anti-Hallucination Guardrail: Abort Healing]
|
|
94
|
+
F -->|RENAME: Safe Refactor| G
|
|
95
|
+
G -->|5. Verify Unambiguous Element| I[Selector Fix: role / data-testid / text]
|
|
96
|
+
I -->|Store Embedding| D
|
|
97
|
+
I -->|6. Surgical Patch| J[LibCST AST Patcher]
|
|
98
|
+
J -->|Preserve Comments & Formatting| K[Automatic Verification Runner]
|
|
99
|
+
K -->|Pass| L[Commit Fix & Log Run]
|
|
100
|
+
K -->|Fail| M[Immediate Rollback from .kernhell.bak]
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## π Key Features
|
|
106
|
+
|
|
107
|
+
- **Failure Interception & Live DOM Capture (`Scanner`)**: Intercepts Playwright selector timeouts and crashes, capturing the error stack trace, line number, broken selector, and live DOM snapshot (`page.content()`).
|
|
108
|
+
- **High-Speed Semantic DOM Pruning (`DOMPruner`)**: Strips scripts, styles, SVGs, base64 data, and non-semantic wrappers using `selectolax` to slash token usage by 80β90% while keeping semantic landmarks and accessibility roles.
|
|
109
|
+
- **Semantic Vector Memory (`Vector Cache`)**: 384-dimensional dense cosine index matching broken selectors against historical fixes. Resolves recurring failures in **<5ms** with zero LLM API cost.
|
|
110
|
+
- **Strict Anti-Hallucination Guardrails**: Distinguishes between renamed selectors (`RENAME`) and genuine missing features (`MISSING`) to prevent false-positive heals on actual product regressions.
|
|
111
|
+
- **Surgical LibCST AST Patching (`Patcher`)**: Surgically transforms only the target locator expression in the AST without reformatting unrelated code or stripping inline comments.
|
|
112
|
+
- **Automated Verification & Zero-Risk Rollback (`Verifier`)**: Re-runs the patched test in a sandbox; if it fails, immediately restores the code from `.kernhell.bak`.
|
|
113
|
+
- **Mission Control Dashboard (`Next.js App Router`)**: High-tech, dark-mode glassmorphic web dashboard providing live stats, real-time healing stream, semantic memory inspector, and interactive simulation playground.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## π¦ Installation
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Clone the repository
|
|
121
|
+
git clone https://github.com/riteshkumar072/KernHell.git
|
|
122
|
+
cd KernHell
|
|
123
|
+
|
|
124
|
+
# Install Python package in editable mode with all dependencies
|
|
125
|
+
pip install -e ".[all]"
|
|
126
|
+
|
|
127
|
+
# Install Mission Control dashboard dependencies
|
|
128
|
+
cd dashboard
|
|
129
|
+
npm install
|
|
130
|
+
cd ..
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## π οΈ CLI Usage
|
|
136
|
+
|
|
137
|
+
```text
|
|
138
|
+
Usage: kernhell [OPTIONS] COMMAND [ARGS]...
|
|
139
|
+
|
|
140
|
+
ββ Commands βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
141
|
+
β scan Scan a test file to detect broken selectors and capture DOM β
|
|
142
|
+
β snapshots. β
|
|
143
|
+
β heal Autonomously heal broken Playwright selectors in a test file. β
|
|
144
|
+
β dashboard Launch the KernHell Mission Control Dashboard and REST API. β
|
|
145
|
+
β ui Alias for 'dashboard' command. β
|
|
146
|
+
β cache Inspect, query, and manage KernHell's Semantic Vector Cache. β
|
|
147
|
+
β config View and configure KernHell engine parameters. β
|
|
148
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 1. Scan a Test File for Broken Selectors
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
kernhell scan tests/test_checkout.py
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 2. Autonomously Heal a Test File or Suite
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# Preview changes without modifying code (dry run)
|
|
161
|
+
kernhell heal tests/test_checkout.py --dry-run
|
|
162
|
+
|
|
163
|
+
# Surgically patch and verify fix with automatic backup
|
|
164
|
+
kernhell heal tests/test_checkout.py
|
|
165
|
+
|
|
166
|
+
# Batch heal all test files in a folder
|
|
167
|
+
kernhell heal tests/
|
|
168
|
+
|
|
169
|
+
# Export machine-readable report for CI/CD pipelines
|
|
170
|
+
kernhell heal tests/ --output json
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 3. Launch the Mission Control Dashboard
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Start FastAPI REST API and open dashboard in browser
|
|
177
|
+
kernhell dashboard
|
|
178
|
+
|
|
179
|
+
# Or run Next.js frontend directly:
|
|
180
|
+
cd dashboard
|
|
181
|
+
npm run dev
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Visit **`http://localhost:3000`** to view the live dashboard and interactive playground.
|
|
185
|
+
|
|
186
|
+
### 4. Semantic Vector Memory & Cache
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# List all verified cached selector mappings
|
|
190
|
+
kernhell cache list
|
|
191
|
+
|
|
192
|
+
# View cache hit/miss ratio and efficiency metrics
|
|
193
|
+
kernhell cache stats
|
|
194
|
+
|
|
195
|
+
# Purge semantic memory
|
|
196
|
+
kernhell cache clear
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### 5. Engine Configuration
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Display active settings
|
|
203
|
+
kernhell config show
|
|
204
|
+
|
|
205
|
+
# Run the interactive configuration wizard
|
|
206
|
+
kernhell config init
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## π₯οΈ Mission Control Dashboard
|
|
212
|
+
|
|
213
|
+
The dashboard provides a production-grade operations center:
|
|
214
|
+
|
|
215
|
+
- **Overview (`/`)**: Real-time healing metrics (autonomous fixes, cache efficiency, real bugs guarded, dollar savings), live 6-stage pipeline status, and recent activity stream.
|
|
216
|
+
- **Interactive Playground (`/playground`)**: Test healer sandbox with pre-configured refactor scenarios and out-of-stock guardrail alerts.
|
|
217
|
+
- **Semantic Memory Explorer (`/cache`)**: Searchable browser for 384-dimensional dense vector embeddings with hit counts and verification badges.
|
|
218
|
+
- **Run History & Diffs (`/history`)**: Audit trail with side-by-side syntax-highlighted unified diffs of AST code patches.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## π§ͺ Running the Test Suite
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
# Run all 59 unit and integration tests
|
|
226
|
+
python -m pytest -v
|
|
227
|
+
|
|
228
|
+
# Run with test coverage
|
|
229
|
+
python -m pytest tests/unit -v --cov=src/kernhell
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## πΊοΈ Execution Roadmap
|
|
235
|
+
|
|
236
|
+
- [x] **Weekend 1: Foundation (Scanner, Pruner, Core Models & CLI)**
|
|
237
|
+
- [x] **Weekend 2: AI Brain (Analyzer, Healer, CST Surgical Patcher & Verifier)**
|
|
238
|
+
- [x] **Weekend 3: Semantic Memory (Vector Cache, Embedder, Batch Healing & CI Export)**
|
|
239
|
+
- [x] **Weekend 4: Mission Control Dashboard (Next.js & Production Release)**
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## π License
|
|
244
|
+
|
|
245
|
+
MIT © 2026 Ritesh Kumar β’ KernHell Systems
|
kernhell-0.1.0/README.md
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# π₯ KernHell
|
|
2
|
+
|
|
3
|
+
> *"The Heart of Your System Where Innovation Meets Precision"*
|
|
4
|
+
|
|
5
|
+
**AI-Powered Autonomous Self-Healing Testing Engine & CLI tool for Playwright.**
|
|
6
|
+
|
|
7
|
+
[](https://www.python.org/)
|
|
8
|
+
[](https://nextjs.org/)
|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
10
|
+
[-brightgreen.svg)](https://github.com/riteshkumar072/KernHell)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## β‘ The Problem
|
|
15
|
+
|
|
16
|
+
Modern frontend engineering moves fast. When developers refactor classes, IDs, or DOM wrappers (e.g., `#buy-now` becomes `#purchase-btn`), automated Playwright and Selenium test suites fail even though the business functionality works seamlessly. QA teams waste 30β40% of their time manually maintaining broken selectors.
|
|
17
|
+
|
|
18
|
+
**KernHell autonomously resolves broken selectors in real-time, preserving 100% of your code formatting, comments, and QA sanity.**
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## ποΈ Autonomous 6-Stage Healing Architecture
|
|
23
|
+
|
|
24
|
+
```mermaid
|
|
25
|
+
flowchart TD
|
|
26
|
+
A[Playwright Locator Timeout] -->|1. Intercept| B(Scanner & Live DOM Capture)
|
|
27
|
+
B -->|2. Prune| C(Selectolax Lexbor HTML5 Pruner)
|
|
28
|
+
C -->|85% Token Reduction| D{3. Dense Vector Cache}
|
|
29
|
+
D -->|Cache Hit <5ms| G[Strict DOM Verification]
|
|
30
|
+
D -->|Cache Miss| E[4. AI Brain: LiteLLM Gateway]
|
|
31
|
+
E -->|Intent Diagnosis| F{RENAME vs MISSING?}
|
|
32
|
+
F -->|MISSING: Real Bug| H[Anti-Hallucination Guardrail: Abort Healing]
|
|
33
|
+
F -->|RENAME: Safe Refactor| G
|
|
34
|
+
G -->|5. Verify Unambiguous Element| I[Selector Fix: role / data-testid / text]
|
|
35
|
+
I -->|Store Embedding| D
|
|
36
|
+
I -->|6. Surgical Patch| J[LibCST AST Patcher]
|
|
37
|
+
J -->|Preserve Comments & Formatting| K[Automatic Verification Runner]
|
|
38
|
+
K -->|Pass| L[Commit Fix & Log Run]
|
|
39
|
+
K -->|Fail| M[Immediate Rollback from .kernhell.bak]
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## π Key Features
|
|
45
|
+
|
|
46
|
+
- **Failure Interception & Live DOM Capture (`Scanner`)**: Intercepts Playwright selector timeouts and crashes, capturing the error stack trace, line number, broken selector, and live DOM snapshot (`page.content()`).
|
|
47
|
+
- **High-Speed Semantic DOM Pruning (`DOMPruner`)**: Strips scripts, styles, SVGs, base64 data, and non-semantic wrappers using `selectolax` to slash token usage by 80β90% while keeping semantic landmarks and accessibility roles.
|
|
48
|
+
- **Semantic Vector Memory (`Vector Cache`)**: 384-dimensional dense cosine index matching broken selectors against historical fixes. Resolves recurring failures in **<5ms** with zero LLM API cost.
|
|
49
|
+
- **Strict Anti-Hallucination Guardrails**: Distinguishes between renamed selectors (`RENAME`) and genuine missing features (`MISSING`) to prevent false-positive heals on actual product regressions.
|
|
50
|
+
- **Surgical LibCST AST Patching (`Patcher`)**: Surgically transforms only the target locator expression in the AST without reformatting unrelated code or stripping inline comments.
|
|
51
|
+
- **Automated Verification & Zero-Risk Rollback (`Verifier`)**: Re-runs the patched test in a sandbox; if it fails, immediately restores the code from `.kernhell.bak`.
|
|
52
|
+
- **Mission Control Dashboard (`Next.js App Router`)**: High-tech, dark-mode glassmorphic web dashboard providing live stats, real-time healing stream, semantic memory inspector, and interactive simulation playground.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## π¦ Installation
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Clone the repository
|
|
60
|
+
git clone https://github.com/riteshkumar072/KernHell.git
|
|
61
|
+
cd KernHell
|
|
62
|
+
|
|
63
|
+
# Install Python package in editable mode with all dependencies
|
|
64
|
+
pip install -e ".[all]"
|
|
65
|
+
|
|
66
|
+
# Install Mission Control dashboard dependencies
|
|
67
|
+
cd dashboard
|
|
68
|
+
npm install
|
|
69
|
+
cd ..
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## π οΈ CLI Usage
|
|
75
|
+
|
|
76
|
+
```text
|
|
77
|
+
Usage: kernhell [OPTIONS] COMMAND [ARGS]...
|
|
78
|
+
|
|
79
|
+
ββ Commands βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
80
|
+
β scan Scan a test file to detect broken selectors and capture DOM β
|
|
81
|
+
β snapshots. β
|
|
82
|
+
β heal Autonomously heal broken Playwright selectors in a test file. β
|
|
83
|
+
β dashboard Launch the KernHell Mission Control Dashboard and REST API. β
|
|
84
|
+
β ui Alias for 'dashboard' command. β
|
|
85
|
+
β cache Inspect, query, and manage KernHell's Semantic Vector Cache. β
|
|
86
|
+
β config View and configure KernHell engine parameters. β
|
|
87
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 1. Scan a Test File for Broken Selectors
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
kernhell scan tests/test_checkout.py
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 2. Autonomously Heal a Test File or Suite
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Preview changes without modifying code (dry run)
|
|
100
|
+
kernhell heal tests/test_checkout.py --dry-run
|
|
101
|
+
|
|
102
|
+
# Surgically patch and verify fix with automatic backup
|
|
103
|
+
kernhell heal tests/test_checkout.py
|
|
104
|
+
|
|
105
|
+
# Batch heal all test files in a folder
|
|
106
|
+
kernhell heal tests/
|
|
107
|
+
|
|
108
|
+
# Export machine-readable report for CI/CD pipelines
|
|
109
|
+
kernhell heal tests/ --output json
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 3. Launch the Mission Control Dashboard
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Start FastAPI REST API and open dashboard in browser
|
|
116
|
+
kernhell dashboard
|
|
117
|
+
|
|
118
|
+
# Or run Next.js frontend directly:
|
|
119
|
+
cd dashboard
|
|
120
|
+
npm run dev
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Visit **`http://localhost:3000`** to view the live dashboard and interactive playground.
|
|
124
|
+
|
|
125
|
+
### 4. Semantic Vector Memory & Cache
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# List all verified cached selector mappings
|
|
129
|
+
kernhell cache list
|
|
130
|
+
|
|
131
|
+
# View cache hit/miss ratio and efficiency metrics
|
|
132
|
+
kernhell cache stats
|
|
133
|
+
|
|
134
|
+
# Purge semantic memory
|
|
135
|
+
kernhell cache clear
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 5. Engine Configuration
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Display active settings
|
|
142
|
+
kernhell config show
|
|
143
|
+
|
|
144
|
+
# Run the interactive configuration wizard
|
|
145
|
+
kernhell config init
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## π₯οΈ Mission Control Dashboard
|
|
151
|
+
|
|
152
|
+
The dashboard provides a production-grade operations center:
|
|
153
|
+
|
|
154
|
+
- **Overview (`/`)**: Real-time healing metrics (autonomous fixes, cache efficiency, real bugs guarded, dollar savings), live 6-stage pipeline status, and recent activity stream.
|
|
155
|
+
- **Interactive Playground (`/playground`)**: Test healer sandbox with pre-configured refactor scenarios and out-of-stock guardrail alerts.
|
|
156
|
+
- **Semantic Memory Explorer (`/cache`)**: Searchable browser for 384-dimensional dense vector embeddings with hit counts and verification badges.
|
|
157
|
+
- **Run History & Diffs (`/history`)**: Audit trail with side-by-side syntax-highlighted unified diffs of AST code patches.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## π§ͺ Running the Test Suite
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Run all 59 unit and integration tests
|
|
165
|
+
python -m pytest -v
|
|
166
|
+
|
|
167
|
+
# Run with test coverage
|
|
168
|
+
python -m pytest tests/unit -v --cov=src/kernhell
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## πΊοΈ Execution Roadmap
|
|
174
|
+
|
|
175
|
+
- [x] **Weekend 1: Foundation (Scanner, Pruner, Core Models & CLI)**
|
|
176
|
+
- [x] **Weekend 2: AI Brain (Analyzer, Healer, CST Surgical Patcher & Verifier)**
|
|
177
|
+
- [x] **Weekend 3: Semantic Memory (Vector Cache, Embedder, Batch Healing & CI Export)**
|
|
178
|
+
- [x] **Weekend 4: Mission Control Dashboard (Next.js & Production Release)**
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## π License
|
|
183
|
+
|
|
184
|
+
MIT © 2026 Ritesh Kumar β’ KernHell Systems
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "kernhell"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "AI-Powered Autonomous Self-Healing Testing Engine β The Heart of Your System Where Innovation Meets Precision"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Ritesh", email = "ritesh@kernhell.dev" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["testing", "playwright", "self-healing", "ai", "cli"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Topic :: Software Development :: Testing",
|
|
24
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"typer>=0.12,<1.0",
|
|
28
|
+
"rich>=13.0,<16.0",
|
|
29
|
+
"pydantic>=2.5,<3.0",
|
|
30
|
+
"pydantic-settings>=2.1,<3.0",
|
|
31
|
+
"playwright>=1.40,<2.0",
|
|
32
|
+
"selectolax>=0.3,<1.0",
|
|
33
|
+
"libcst>=1.1.0",
|
|
34
|
+
"structlog>=24.0",
|
|
35
|
+
"litellm>=1.30,<2.0",
|
|
36
|
+
"tomli>=2.0;python_version<'3.11'",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
cache = [
|
|
41
|
+
"chromadb>=0.4,<1.0",
|
|
42
|
+
"sentence-transformers>=2.2,<3.0",
|
|
43
|
+
]
|
|
44
|
+
dashboard = [
|
|
45
|
+
"fastapi>=0.110,<1.0",
|
|
46
|
+
"uvicorn[standard]>=0.27,<1.0",
|
|
47
|
+
"aiosqlite>=0.19,<1.0",
|
|
48
|
+
]
|
|
49
|
+
dev = [
|
|
50
|
+
"pytest>=8.0,<9.0",
|
|
51
|
+
"pytest-asyncio>=0.23,<1.0",
|
|
52
|
+
"pytest-cov>=5.0,<6.0",
|
|
53
|
+
"ruff>=0.3,<1.0",
|
|
54
|
+
"mypy>=1.8,<2.0",
|
|
55
|
+
"build>=1.0.0",
|
|
56
|
+
"twine>=5.0.0",
|
|
57
|
+
]
|
|
58
|
+
all = ["kernhell[cache,dashboard,dev]"]
|
|
59
|
+
|
|
60
|
+
[project.scripts]
|
|
61
|
+
kernhell = "kernhell.cli.app:app"
|
|
62
|
+
|
|
63
|
+
[project.urls]
|
|
64
|
+
Homepage = "https://github.com/riteshkumar072/KernHell"
|
|
65
|
+
Documentation = "https://github.com/riteshkumar072/KernHell#readme"
|
|
66
|
+
Repository = "https://github.com/riteshkumar072/KernHell"
|
|
67
|
+
Issues = "https://github.com/riteshkumar072/KernHell/issues"
|
|
68
|
+
|
|
69
|
+
[tool.hatch.build.targets.wheel]
|
|
70
|
+
packages = ["src/kernhell"]
|
|
71
|
+
|
|
72
|
+
[tool.hatch.build.targets.sdist]
|
|
73
|
+
include = [
|
|
74
|
+
"/src/kernhell",
|
|
75
|
+
"/README.md",
|
|
76
|
+
"/LICENSE",
|
|
77
|
+
"/pyproject.toml",
|
|
78
|
+
"/.kernhellrc.toml",
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
[tool.pytest.ini_options]
|
|
82
|
+
testpaths = ["tests/unit", "tests/integration"]
|
|
83
|
+
pythonpath = ["src"]
|
|
84
|
+
asyncio_mode = "auto"
|
|
85
|
+
markers = [
|
|
86
|
+
"integration: marks tests requiring Playwright browsers (deselect with '-m \"not integration\"')",
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
[tool.ruff]
|
|
90
|
+
target-version = "py311"
|
|
91
|
+
line-length = 100
|
|
92
|
+
src = ["src"]
|
|
93
|
+
|
|
94
|
+
[tool.ruff.lint]
|
|
95
|
+
select = ["E", "F", "W", "I", "N", "UP", "B", "SIM", "RUF"]
|
|
96
|
+
|
|
97
|
+
[tool.mypy]
|
|
98
|
+
python_version = "3.11"
|
|
99
|
+
strict = true
|
|
100
|
+
warn_return_any = true
|
|
101
|
+
warn_unused_configs = true
|