ghostfix-ai 0.3.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 (84) hide show
  1. ghostfix_ai-0.3.0/LICENSE +21 -0
  2. ghostfix_ai-0.3.0/MANIFEST.in +34 -0
  3. ghostfix_ai-0.3.0/PKG-INFO +559 -0
  4. ghostfix_ai-0.3.0/README.md +517 -0
  5. ghostfix_ai-0.3.0/agent/__init__.py +1 -0
  6. ghostfix_ai-0.3.0/agent/daemon.py +438 -0
  7. ghostfix_ai-0.3.0/agent/daemon_runtime.py +110 -0
  8. ghostfix_ai-0.3.0/agent/terminal_watcher.py +593 -0
  9. ghostfix_ai-0.3.0/cli/__init__.py +1 -0
  10. ghostfix_ai-0.3.0/cli/main.py +1266 -0
  11. ghostfix_ai-0.3.0/core/__init__.py +1 -0
  12. ghostfix_ai-0.3.0/core/autofix.py +355 -0
  13. ghostfix_ai-0.3.0/core/command_rerunner.py +35 -0
  14. ghostfix_ai-0.3.0/core/confidence.py +23 -0
  15. ghostfix_ai-0.3.0/core/config.py +78 -0
  16. ghostfix_ai-0.3.0/core/context.py +75 -0
  17. ghostfix_ai-0.3.0/core/data_generator.py +272 -0
  18. ghostfix_ai-0.3.0/core/decision_engine.py +1145 -0
  19. ghostfix_ai-0.3.0/core/demo_report.py +379 -0
  20. ghostfix_ai-0.3.0/core/detector.py +83 -0
  21. ghostfix_ai-0.3.0/core/doctor.py +155 -0
  22. ghostfix_ai-0.3.0/core/event_classifier.py +236 -0
  23. ghostfix_ai-0.3.0/core/feedback.py +75 -0
  24. ghostfix_ai-0.3.0/core/fix_audit.py +76 -0
  25. ghostfix_ai-0.3.0/core/formatter.py +296 -0
  26. ghostfix_ai-0.3.0/core/incidents.py +137 -0
  27. ghostfix_ai-0.3.0/core/language_diagnostics.py +437 -0
  28. ghostfix_ai-0.3.0/core/local_llm.py +253 -0
  29. ghostfix_ai-0.3.0/core/log_events.py +220 -0
  30. ghostfix_ai-0.3.0/core/logger.py +71 -0
  31. ghostfix_ai-0.3.0/core/memory.py +302 -0
  32. ghostfix_ai-0.3.0/core/parser.py +387 -0
  33. ghostfix_ai-0.3.0/core/patch_generator.py +205 -0
  34. ghostfix_ai-0.3.0/core/patch_validator.py +173 -0
  35. ghostfix_ai-0.3.0/core/production_signals.py +43 -0
  36. ghostfix_ai-0.3.0/core/production_validator.py +216 -0
  37. ghostfix_ai-0.3.0/core/project_context.py +401 -0
  38. ghostfix_ai-0.3.0/core/release_verifier.py +125 -0
  39. ghostfix_ai-0.3.0/core/root_cause_analyzer.py +538 -0
  40. ghostfix_ai-0.3.0/core/rules.py +15 -0
  41. ghostfix_ai-0.3.0/core/runner.py +215 -0
  42. ghostfix_ai-0.3.0/core/runtime_detector.py +8 -0
  43. ghostfix_ai-0.3.0/core/safety_policy.py +77 -0
  44. ghostfix_ai-0.3.0/core/training_export.py +227 -0
  45. ghostfix_ai-0.3.0/core/training_memory.py +93 -0
  46. ghostfix_ai-0.3.0/ghostfix/__init__.py +2 -0
  47. ghostfix_ai-0.3.0/ghostfix_ai.egg-info/PKG-INFO +559 -0
  48. ghostfix_ai-0.3.0/ghostfix_ai.egg-info/SOURCES.txt +82 -0
  49. ghostfix_ai-0.3.0/ghostfix_ai.egg-info/dependency_links.txt +1 -0
  50. ghostfix_ai-0.3.0/ghostfix_ai.egg-info/entry_points.txt +2 -0
  51. ghostfix_ai-0.3.0/ghostfix_ai.egg-info/requires.txt +22 -0
  52. ghostfix_ai-0.3.0/ghostfix_ai.egg-info/top_level.txt +7 -0
  53. ghostfix_ai-0.3.0/ml/__init__.py +1 -0
  54. ghostfix_ai-0.3.0/ml/aggressive_prune.py +292 -0
  55. ghostfix_ai-0.3.0/ml/brain_v3_features.py +346 -0
  56. ghostfix_ai-0.3.0/ml/brain_v4_inference.py +701 -0
  57. ghostfix_ai-0.3.0/ml/check_brain_v4_model.py +178 -0
  58. ghostfix_ai-0.3.0/ml/configs/brain_v4_lora_config.yaml +34 -0
  59. ghostfix_ai-0.3.0/ml/download_base_model.py +37 -0
  60. ghostfix_ai-0.3.0/ml/embedding_retriever.py +108 -0
  61. ghostfix_ai-0.3.0/ml/evaluate_brain_v2_safety.py +304 -0
  62. ghostfix_ai-0.3.0/ml/evaluate_brain_v31.py +280 -0
  63. ghostfix_ai-0.3.0/ml/evaluate_brain_v33.py +50 -0
  64. ghostfix_ai-0.3.0/ml/evaluate_brain_v4.py +337 -0
  65. ghostfix_ai-0.3.0/ml/evaluate_runtime_brain_v4.py +766 -0
  66. ghostfix_ai-0.3.0/ml/evaluate_watch_mode.py +296 -0
  67. ghostfix_ai-0.3.0/ml/feedback_logger.py +115 -0
  68. ghostfix_ai-0.3.0/ml/ghostfix_brain_predict.py +213 -0
  69. ghostfix_ai-0.3.0/ml/ghostfix_brain_v2_predict.py +183 -0
  70. ghostfix_ai-0.3.0/ml/ghostfix_brain_v33_predict.py +162 -0
  71. ghostfix_ai-0.3.0/ml/model_inference.py +485 -0
  72. ghostfix_ai-0.3.0/ml/predict_fix.py +235 -0
  73. ghostfix_ai-0.3.0/ml/prepare_brain_v4_lora_dataset.py +738 -0
  74. ghostfix_ai-0.3.0/ml/project_audit.py +393 -0
  75. ghostfix_ai-0.3.0/ml/retriever_router.py +52 -0
  76. ghostfix_ai-0.3.0/ml/shadow_mode_runner.py +238 -0
  77. ghostfix_ai-0.3.0/ml/train_brain_v4_lora.py +525 -0
  78. ghostfix_ai-0.3.0/ml/train_ghostfix_brain.py +299 -0
  79. ghostfix_ai-0.3.0/ml/validate_brain_v33_production_candidate.py +234 -0
  80. ghostfix_ai-0.3.0/pyproject.toml +94 -0
  81. ghostfix_ai-0.3.0/setup.cfg +4 -0
  82. ghostfix_ai-0.3.0/utils/__init__.py +1 -0
  83. ghostfix_ai-0.3.0/utils/env.py +16 -0
  84. ghostfix_ai-0.3.0/utils/logger.py +9 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 GhostFix AI
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,34 @@
1
+ include README.md
2
+ include LICENSE
3
+ include pyproject.toml
4
+
5
+ prune .ghostfix
6
+ prune .ml
7
+ prune .github
8
+ prune .pytest_cache
9
+ prune .mypy_cache
10
+ prune .ruff_cache
11
+ prune archive_outside_git
12
+ prune build
13
+ prune dist
14
+ prune demos
15
+ prune docs
16
+ prune ghostfix_clean_test
17
+ prune ml/reports
18
+ prune tests
19
+
20
+ global-exclude __pycache__/*
21
+ global-exclude *.py[cod]
22
+ global-exclude *.bak_*
23
+ global-exclude *.zip
24
+ global-exclude *.db
25
+ global-exclude *.sqlite
26
+ global-exclude *.sqlite3
27
+ global-exclude *.bin
28
+ global-exclude *.ckpt
29
+ global-exclude *.pt
30
+ global-exclude *.pth
31
+ global-exclude *.safetensors
32
+ global-exclude *.pkl
33
+ prune ml/models
34
+ prune ml/processed
@@ -0,0 +1,559 @@
1
+ Metadata-Version: 2.4
2
+ Name: ghostfix-ai
3
+ Version: 0.3.0
4
+ Summary: Production-minded local-first runtime debugging CLI with safety-gated Python auto-fix.
5
+ Author: GhostFix AI
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/ghostfix-ai/ghostfix-ai
8
+ Project-URL: Documentation, https://github.com/ghostfix-ai/ghostfix-ai#readme
9
+ Project-URL: Security, https://github.com/ghostfix-ai/ghostfix-ai/blob/main/SECURITY.md
10
+ Keywords: debugging,cli,python,runtime-errors,developer-tools
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Debuggers
19
+ Classifier: Topic :: Software Development :: Quality Assurance
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: typer>=0.12.0
24
+ Requires-Dist: rich>=13.7.0
25
+ Provides-Extra: retriever
26
+ Requires-Dist: scikit-learn>=1.3.0; extra == "retriever"
27
+ Requires-Dist: numpy>=1.24.0; extra == "retriever"
28
+ Provides-Extra: cloud-memory
29
+ Requires-Dist: supabase>=2.3.0; extra == "cloud-memory"
30
+ Requires-Dist: python-dotenv>=1.0.0; extra == "cloud-memory"
31
+ Provides-Extra: brain-v4
32
+ Requires-Dist: torch>=2.0.0; extra == "brain-v4"
33
+ Requires-Dist: transformers>=4.35.0; extra == "brain-v4"
34
+ Requires-Dist: peft>=0.7.0; extra == "brain-v4"
35
+ Requires-Dist: accelerate>=0.25.0; extra == "brain-v4"
36
+ Provides-Extra: dev
37
+ Requires-Dist: build>=1.2.0; extra == "dev"
38
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
39
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
40
+ Requires-Dist: twine>=5.0.0; extra == "dev"
41
+ Dynamic: license-file
42
+
43
+ # GhostFix AI
44
+
45
+ <p align="center">
46
+ <strong>No prompts. Just logs. Instant diagnosis.</strong>
47
+ </p>
48
+
49
+ <p align="center">
50
+ <a href="https://github.com/Shibani987/ghostfix-ai/actions/workflows/ci.yml">
51
+ <img src="https://github.com/Shibani987/ghostfix-ai/actions/workflows/ci.yml/badge.svg" alt="CI">
52
+ </a>
53
+
54
+ <a href="https://pypi.org/project/ghostfix-ai/">
55
+ <img src="https://img.shields.io/pypi/v/ghostfix-ai?cacheSeconds=60" alt="PyPI">
56
+ </a>
57
+
58
+ <a href="https://pypi.org/project/ghostfix-ai/">
59
+ <img src="https://img.shields.io/pypi/pyversions/ghostfix-ai?cacheSeconds=60" alt="Python">
60
+ </a>
61
+
62
+ <a href="LICENSE">
63
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
64
+ </a>
65
+ </p>
66
+
67
+ GhostFix is a local-first runtime debugging CLI that watches terminal and dev-server logs, detects crashes automatically, explains likely root causes, and applies only safety-gated deterministic Python fixes. No API key required. Local-first by default.
68
+
69
+
70
+ ## See GhostFix in Action
71
+
72
+ <p align="center">
73
+ <img src="assets/demo/ghostfix-demo.gif" width="1000"/>
74
+ </p>
75
+
76
+ ## Quick install
77
+
78
+ ```bash
79
+ pip install ghostfix-ai
80
+ ghostfix setup
81
+ ghostfix demo
82
+ ```
83
+
84
+ ## Debug a crash
85
+
86
+ ```bash
87
+ ghostfix run app.py
88
+ ghostfix watch "python manage.py runserver"
89
+ ghostfix watch "npm run dev"
90
+ ghostfix watch "pnpm dev"
91
+ ghostfix watch "next dev"
92
+ ```
93
+
94
+ ## Why GhostFix?
95
+
96
+ | Feature | Description |
97
+ | --- | --- |
98
+ | Promptless runtime debugging | No prompts needed—just run your code and get instant diagnosis from logs. |
99
+ | Local-first by default | Works entirely offline, no API keys or cloud dependencies required. |
100
+ | No API key required | All processing happens locally on your machine. |
101
+ | Watch mode for dev servers | Monitors long-running processes and catches errors in real-time. |
102
+ | Safety-gated Python fixes | Only applies narrow, deterministic fixes with preview and rollback. |
103
+
104
+ ## Safety-first
105
+
106
+ GhostFix does not silently rewrite code. Fixes are offered only for narrow deterministic Python cases, with patch preview, validation, backup, and rollback metadata.
107
+
108
+ ## Current status
109
+
110
+ Production-minded local debugging CLI. Enterprise-evaluation-ready candidate. Not a hosted observability platform or unrestricted autonomous coding agent.
111
+
112
+ ## What Works Now
113
+
114
+ - Python traceback detection and diagnosis.
115
+ - Structured streaming log-event pipeline for noisy, partial, and long-running logs.
116
+ - Repo-aware context for project roots, dependency files, framework hints, and related local files.
117
+ - Safe deterministic Python auto-fix for a small allowlisted set of cases.
118
+ - Watch mode for terminal and server processes.
119
+ - Django, Flask, FastAPI, and Uvicorn startup/runtime diagnosis.
120
+ - JavaScript, Node.js, TypeScript, React, and Next.js dev-log diagnosis.
121
+ - Framework-aware Next.js suggestions for module resolution, missing env vars, build/syntax errors, TypeScript errors, port conflicts, and hydration-style messages.
122
+ - PHP error detection.
123
+ - Brain v4 runtime routing as an optional guarded local reasoning layer.
124
+ - Local incident history in `.ghostfix/incidents.jsonl`.
125
+ - Local stats and redacted training-data exports for user-reviewed closed-beta feedback.
126
+ - Local production-like log classification for user-provided logs, with anomaly rules for auth spikes, repeated failures, 5xx errors, and timeout clusters.
127
+ - Benchmarks for watch mode and Brain v4 routing.
128
+ - Local-first operation with no required external API calls.
129
+
130
+ ## What Does Not Work Yet
131
+
132
+ - JavaScript, TypeScript, React, Next.js, and PHP auto-fix are intentionally disabled.
133
+ - Framework configuration fixes are diagnosis-only.
134
+ - Repo-aware multi-file edits are not part of the current MVP.
135
+ - Brain v4 output is advisory and cannot bypass safety policy.
136
+ - CPU generation with Brain v4 can be slow, especially on Windows.
137
+ - GhostFix is not a security scanner, full static analyzer, or production observability platform.
138
+ - Sentry, PostHog, and Clarity support is currently architecture hooks only; GhostFix does not secretly monitor production systems or call external telemetry services.
139
+
140
+ ## Daily-Driver Beta Limitations
141
+
142
+ GhostFix is ready for local daily trial use, but it is still a beta-quality developer tool:
143
+
144
+ - Python runtime diagnosis is the most mature path.
145
+ - Node, JavaScript, TypeScript, React, Next.js, and PHP support are diagnosis-only.
146
+ - Framework configuration issues are explained, not auto-edited.
147
+ - Brain v4 is optional and advisory.
148
+ - Auto-fix covers only narrow deterministic Python patches.
149
+ - Long-running watch mode is bounded and duplicate-aware, but it is not a full observability system.
150
+
151
+ ## Safety Guarantees
152
+
153
+ - GhostFix does not silently rewrite files.
154
+ - Auto-fix is blocked unless the safety policy allows a deterministic validated patch.
155
+ - Patch previews are shown before confirmation unless explicitly auto-approved.
156
+ - Applied safe fixes create backups.
157
+ - Rollback uses local backup metadata and asks before restoring.
158
+ - Brain output cannot bypass the safety policy.
159
+
160
+ ## Trust & Safety
161
+
162
+ Use dry-run when you want diagnosis without any file writes:
163
+
164
+ ```powershell
165
+ ghostfix run tests/manual_errors/name_error.py --dry-run
166
+ ghostfix watch "python demos/python_name_error.py" --dry-run
167
+ ```
168
+
169
+ Auto-fix decisions are audited locally in `.ghostfix/fix_audit.jsonl`:
170
+
171
+ ```powershell
172
+ ghostfix audit
173
+ ghostfix audit --last 10
174
+ ```
175
+
176
+ Dry-run, rollback, and audit behavior are documented in [docs/TRUST_AND_SAFETY.md](docs/TRUST_AND_SAFETY.md).
177
+
178
+ ## Closed Beta Trial
179
+
180
+ Before inviting a small group of 2-5 developers, run:
181
+
182
+ ```powershell
183
+ ghostfix beta-check
184
+ ```
185
+
186
+ Closed beta users should start with `ghostfix quickstart`, `ghostfix examples`,
187
+ and dry-run mode. The closed beta guide is in
188
+ [docs/CLOSED_BETA_GUIDE.md](docs/CLOSED_BETA_GUIDE.md). GhostFix is still a
189
+ local developer beta, not an enterprise production platform.
190
+
191
+ ## What GhostFix Will Never Do
192
+
193
+ - It will never upload your code, logs, incidents, or feedback without an explicit feature and configuration.
194
+ - It will never enable broad autonomous coding from watch mode.
195
+ - It will never apply JavaScript, framework config, dependency install, database, network, or destructive filesystem fixes automatically.
196
+ - It will never run `npm install`, `pnpm install`, or dependency installation automatically.
197
+ - It will never treat model confidence alone as permission to edit files.
198
+
199
+ ## Local-First Promise
200
+
201
+ GhostFix works locally by default. Incidents, feedback, daemon state, and reports are written under `.ghostfix/`. Optional cloud memory hooks require explicit configuration; local diagnosis does not require external APIs.
202
+
203
+ Default configuration is local-only:
204
+
205
+ ```powershell
206
+ ghostfix config init
207
+ ghostfix config show
208
+ ```
209
+
210
+ The default policy disables auto-fix by default, disables telemetry, disables export until manually invoked, and keeps Brain mode off unless explicitly configured.
211
+
212
+ ## No Automatic Telemetry
213
+
214
+ GhostFix does not automatically upload incidents, feedback, logs, snippets, audit history, or training exports. Local feedback collection writes to `.ghostfix/feedback.jsonl`, and training exports are files you create and review manually.
215
+
216
+ ## Training Data Export
217
+
218
+ Closed-beta users can summarize local usage and create a redacted export for manual review:
219
+
220
+ ```powershell
221
+ ghostfix stats
222
+ ghostfix export-training-data
223
+ ghostfix export-training-data --include-snippets
224
+ ```
225
+
226
+ Exports are written under `.ghostfix/exports/` and include diagnosis, feedback, rollback, and validator fields useful for improving local retrieval and future local models. The export command prints `No data was uploaded.` every time.
227
+
228
+ Details are in [docs/TRAINING_DATA_EXPORT.md](docs/TRAINING_DATA_EXPORT.md).
229
+
230
+ ## Future Local Model Improvements
231
+
232
+ User-reviewed exports can help improve future local models and deterministic retrieval quality without requiring automatic telemetry. Shared exports should be inspected first, especially when snippets are included.
233
+
234
+ ## 2 Minute Quickstart
235
+
236
+ ```powershell
237
+ python -m venv .venv
238
+ .\.venv\Scripts\Activate.ps1
239
+ pip install -e .
240
+ ghostfix doctor
241
+ ghostfix quickstart
242
+ ```
243
+
244
+ ## Install From Source
245
+
246
+ Current beta installs from a local clone:
247
+
248
+ ```powershell
249
+ git clone <private-repo-url>
250
+ cd ghostfix
251
+ python -m venv .venv
252
+ .\.venv\Scripts\Activate.ps1
253
+ python -m pip install -e .
254
+ ghostfix doctor
255
+ ```
256
+
257
+ For a local wheel rehearsal:
258
+
259
+ ```powershell
260
+ python -m build
261
+ python -m pip install dist\ghostfix_ai-0.3.0-py3-none-any.whl
262
+ ghostfix --version
263
+ ```
264
+
265
+ Packaging details are in [docs/PACKAGING.md](docs/PACKAGING.md).
266
+
267
+ ## Installation
268
+
269
+ GhostFix is available on PyPI as `ghostfix-ai` with the `ghostfix` console command.
270
+
271
+ ```bash
272
+ pip install ghostfix-ai
273
+ ```
274
+
275
+ Optional ML, Brain, and cloud-memory dependencies are separate extras:
276
+
277
+ ```bash
278
+ pip install "ghostfix-ai[retriever]"
279
+ pip install "ghostfix-ai[brain-v4]"
280
+ pip install "ghostfix-ai[cloud-memory]"
281
+ ```
282
+
283
+ For development or local builds, use editable install or a locally built wheel from the repository.
284
+
285
+ Run a file and diagnose the failure:
286
+
287
+ ```powershell
288
+ ghostfix run tests/manual_errors/name_error.py
289
+ ghostfix run tests/manual_errors/name_error.py --verbose
290
+ ```
291
+
292
+ Try watch mode:
293
+
294
+ ```powershell
295
+ ghostfix watch "python demos/python_name_error.py"
296
+ ghostfix watch "npm run dev" --cwd demos/node_like
297
+ ```
298
+
299
+ Useful onboarding commands:
300
+
301
+ ```powershell
302
+ ghostfix examples
303
+ ghostfix incidents
304
+ ghostfix feedback --good
305
+ ghostfix rollback last
306
+ ```
307
+
308
+ The module entry point still works for development and troubleshooting:
309
+
310
+ ```powershell
311
+ python -m cli.main doctor
312
+ python -m cli.main run tests/manual_errors/name_error.py
313
+ ```
314
+
315
+ ## Demo Commands
316
+
317
+ ```powershell
318
+ python -m cli.main run tests/manual_errors/name_error.py
319
+ python -m cli.main run tests/manual_errors/name_error.py --verbose
320
+ python -m cli.main run tests/manual_errors/json_empty_v2.py --fix
321
+ python -m cli.main watch "python demos/python_name_error.py"
322
+ python -m cli.main watch "python demos/django_like/manage.py runserver"
323
+ python -m cli.main watch "python demos/fastapi_like/main.py"
324
+ python -m cli.main watch "npm run dev" --cwd demos/node_like
325
+ ```
326
+
327
+ More commands are collected in [docs/DEMO_COMMANDS.md](docs/DEMO_COMMANDS.md).
328
+ The short install path is in [docs/QUICKSTART.md](docs/QUICKSTART.md), and categorized command examples are in [docs/EXAMPLES.md](docs/EXAMPLES.md).
329
+
330
+ After `pip install -e .`, the same demos can be run through the installed CLI:
331
+
332
+ ```powershell
333
+ ghostfix doctor
334
+ ghostfix --version
335
+ ghostfix run tests/manual_errors/name_error.py
336
+ ghostfix watch "python demos/python_name_error.py"
337
+ ghostfix context tests/manual_errors/name_error.py
338
+ ghostfix classify-log path/to/log.txt
339
+ ghostfix verify-release
340
+ ghostfix validate-production
341
+ ghostfix daemon start "python demos/python_name_error.py"
342
+ ghostfix daemon status
343
+ ghostfix daemon stop
344
+ ghostfix incidents
345
+ ghostfix stats
346
+ ghostfix export-training-data
347
+ ghostfix incidents --last 10
348
+ ```
349
+
350
+ `validate-production` is a local release-validation gate. Passing it supports an enterprise-evaluation-ready claim; it does not make GhostFix a hosted enterprise observability platform.
351
+
352
+ ## Watch Mode
353
+
354
+ Watch mode runs a command, streams output live, and opens a GhostFix diagnosis when it sees a runtime error.
355
+
356
+ ```powershell
357
+ python -m cli.main watch "python demos/python_name_error.py"
358
+ python -m cli.main watch "python demos/django_like/manage.py runserver"
359
+ python -m cli.main watch "python demos/fastapi_like/main.py"
360
+ python -m cli.main watch "npm run dev" --cwd demos/node_like
361
+ ```
362
+
363
+ Useful options:
364
+
365
+ - `--verbose`: show routing, Brain telemetry, evidence, patch safety, and context.
366
+ - `--cwd PATH`: run the watched command from another directory.
367
+ - `--no-brain`: disable Brain routing/generation for the session.
368
+ - `--brain-mode auto|off|route-only|generate`: select Brain v4 runtime behavior.
369
+ - `--fix`: allow the existing deterministic Python auto-fix prompts.
370
+
371
+ Watch mode does not silently rewrite code. Non-Python errors remain diagnosis-only.
372
+
373
+ ## Repo Context
374
+
375
+ GhostFix can inspect bounded, safe repo context for a file:
376
+
377
+ ```powershell
378
+ ghostfix context tests/manual_errors/name_error.py
379
+ ```
380
+
381
+ The context engine detects project root markers, common Python/Node dependency files, framework hints, and related local files. It ignores secret files such as `.env`, skips heavy/generated directories such as `.git`, `node_modules`, `venv`, `.venv`, `dist`, and `build`, and enforces file and character budgets.
382
+
383
+ ## Production-Like Log Classification
384
+
385
+ GhostFix can classify a local log file into a production-style runtime category without external API calls:
386
+
387
+ ```powershell
388
+ ghostfix classify-log path/to/log.txt
389
+ ```
390
+
391
+ The classifier detects expected user errors, app bugs, infrastructure errors, dependency errors, auth anomalies, repeated failures, and unknown cases. It also reports severity, anomaly hints, and whether Brain escalation is needed. Normal expected user errors, such as a single wrong-password 401, do not trigger heavy Brain reasoning.
392
+
393
+ Current Sentry, PostHog, and Clarity modules are disabled-by-default local interfaces only. Future production mode would require explicit user-provided logs, events, or API access.
394
+
395
+ ## Daemon Mode
396
+
397
+ Daemon v1 runs in the foreground and reuses watch mode to continuously monitor a local dev command. It records incidents to `.ghostfix/incidents.jsonl`, suppresses repeated adjacent duplicates, and shuts down cleanly on Ctrl+C.
398
+
399
+ ```powershell
400
+ ghostfix daemon start "python demos/python_name_error.py"
401
+ ghostfix daemon status
402
+ ghostfix daemon stop
403
+ ```
404
+
405
+ In v1, `status` reads local daemon state from `.ghostfix/daemon.json`, and `stop` writes a local stop request for the foreground daemon loop. Auto-fix behavior remains the same guarded watch-mode behavior and requires `--fix`.
406
+
407
+ ## Incident History
408
+
409
+ GhostFix records local debugging incidents to `.ghostfix/incidents.jsonl`. Each JSONL row includes the timestamp, command, file, language, runtime, error type, likely cause, suggested fix, confidence, whether auto-fix was available, and whether the command was resolved after an applied fix.
410
+
411
+ ```powershell
412
+ ghostfix incidents
413
+ ghostfix incidents --last 10
414
+ ```
415
+
416
+ Repeated adjacent duplicates are suppressed so a crashing watch command does not flood history with the same incident. Incident memory is local history only; it does not retrain Brain v4 and does not weaken the safety policy.
417
+
418
+ ## Safe Auto-Fix Example
419
+
420
+ ```powershell
421
+ python -m cli.main run tests/manual_errors/json_empty_v2.py --fix
422
+ ```
423
+
424
+ Auto-fix is intentionally narrow. GhostFix creates a `*.bak_YYYYMMDD_HHMMSS` backup, validates the generated Python patch, and only applies fixes covered by the safe policy. Missing packages, framework config errors, JavaScript, TypeScript, PHP, and ambiguous project-intent cases are blocked.
425
+
426
+ For auto-fix, GhostFix validates the patch in a temporary sandbox copy before touching the real file. Incident records include rollback metadata when a patch is attempted.
427
+
428
+ See [docs/SAFETY.md](docs/SAFETY.md).
429
+
430
+ ## Brain v4 Modes
431
+
432
+ Brain v4 is an optional local LoRA reasoning layer. It does not replace deterministic rules, memory, or retrieval.
433
+
434
+ - `auto`: normal gated runtime mode. Brain is used only when the fast layers need help.
435
+ - `off`: disables Brain v4.
436
+ - `route-only`: measures whether a case would escalate, but skips generation.
437
+ - `generate`: runs Brain generation for escalated cases; useful for small quality checks.
438
+
439
+ Compatibility check:
440
+
441
+ ```powershell
442
+ python ml/check_brain_v4_model.py
443
+ ```
444
+
445
+ Optional local base model download:
446
+
447
+ ```powershell
448
+ pip install huggingface_hub transformers peft accelerate torch
449
+ python ml/download_base_model.py
450
+ ```
451
+
452
+ Downloaded model weights and checkpoints are local-only and intentionally ignored by Git.
453
+
454
+ Benchmark routing:
455
+
456
+ ```powershell
457
+ python ml/evaluate_runtime_brain_v4.py --dir tests/real_world_failures --brain-mode route-only
458
+ python ml/evaluate_runtime_brain_v4.py --dir tests/brain_escalation_cases --brain-mode route-only
459
+ ```
460
+
461
+ ## Benchmarks
462
+
463
+ ```powershell
464
+ python -m unittest discover tests
465
+ python -m cli.main verify-release
466
+ python -m cli.main validate-production
467
+ python ml/evaluate_watch_mode.py
468
+ python ml/evaluate_runtime_brain_v4.py --dir tests/real_world_failures --brain-mode route-only
469
+ python ml/evaluate_runtime_brain_v4.py --dir tests/brain_escalation_cases --brain-mode route-only
470
+ python ml/evaluate_runtime_brain_v4.py --dir tests/brain_escalation_cases --limit 2 --brain-mode generate
471
+ ```
472
+
473
+ Benchmark reports are generated under `ml/reports/`, which is intentionally ignored for public release hygiene.
474
+
475
+ Production validation reports are generated under `.ghostfix/reports/`, which is local runtime state and ignored by Git.
476
+
477
+ Latest verified public snapshot:
478
+
479
+ | Area | Result |
480
+ | --- | --- |
481
+ | Unit/integration tests | `python -m unittest discover tests`: 244 tests, OK |
482
+ | Watch mode benchmark | language 100%, runtime 100%, error_type 100%, root_cause 100%, safety 100% |
483
+ | Real-world deterministic route-only | 10 files, 7.492s total, 0.749s avg deterministic runtime, 100% deterministic solve rate, 0% unresolved, Brain activations 0/10 |
484
+ | Brain escalation route-only | 12 files, 3.435s total, 0.283s avg brain-assisted routing runtime, Brain activations 12/12, Brain escalations 12/12, 58.3% unresolved |
485
+ | Brain generate mode | 2 files, 111.337s total, 55.651s avg brain-assisted runtime, 37.740s avg Brain generation, 50% usable Brain output rate |
486
+
487
+ Interpretation:
488
+
489
+ - Deterministic rules and watch mode are the current reliable MVP path.
490
+ - `route-only` mode proves that hard cases are routed to Brain v4 without paying CPU-heavy generation cost.
491
+ - `generate` mode is experimental and slow on CPU. It is useful for small quality probes, not live demos.
492
+
493
+ ## Architecture
494
+
495
+ GhostFix uses a hybrid pipeline:
496
+
497
+ 1. Run or watch a command.
498
+ 2. Convert streaming output into bounded structured log events.
499
+ 3. Detect bounded repo context and framework hints.
500
+ 4. Classify local production-like runtime signals when a user provides log files.
501
+ 5. Parse runtime logs and tracebacks.
502
+ 6. Detect language, runtime, framework, error type, and source location.
503
+ 7. Apply deterministic rules and known-case memory first.
504
+ 8. Use retrieval and optional local reasoning for broader diagnosis.
505
+ 9. Route hard cases to Brain v4 when enabled.
506
+ 10. Generate a diagnosis, confidence, likely cause, and suggested fix.
507
+ 11. Offer auto-fix only when the safety policy allows a deterministic Python patch.
508
+ 12. Write local incident history for later review.
509
+
510
+ Beginner-friendly details are in [docs/PROJECT_OVERVIEW.md](docs/PROJECT_OVERVIEW.md). A comparison with other tools is in [docs/WHY_DIFFERENT.md](docs/WHY_DIFFERENT.md).
511
+
512
+ ## Files Expected In The Repo
513
+
514
+ - `agent/`, `cli/`, `core/`, `ghostfix/`, `ml/`, and `utils/` source.
515
+ - `tests/` unit, benchmark, manual, and demo fixtures.
516
+ - `demos/` watch-mode examples.
517
+ - `ml/models/` lightweight required model/retriever artifacts and Brain v4 adapter metadata/tokenizer files. Heavy model weights are downloaded locally and ignored.
518
+ - `ml/configs/` model configuration files.
519
+ - `docs/` public documentation.
520
+ - `requirements.txt`, `pyproject.toml`, `.gitignore`, and release checklist.
521
+
522
+ Generated reports, caches, local environment files, local feedback/runtime state, and backups are intentionally ignored.
523
+
524
+ ## Limitations
525
+
526
+ - Python is the mature path.
527
+ - JavaScript, TypeScript, and PHP support is diagnosis-only.
528
+ - Auto-fix is deliberately conservative.
529
+ - Brain v4 requires compatible local model files and optional ML dependencies.
530
+ - Brain v4 generation can be slow on CPU.
531
+ - GhostFix does not understand every project convention yet.
532
+
533
+ ## Roadmap
534
+
535
+ - Current MVP: promptless runtime diagnosis, reliability core v1, watch mode, daemon v1, safe Python auto-fix, guarded Brain v4 routing, local incident memory, and local production-like log classification.
536
+ - Next: recurring incident summaries and daemon polish.
537
+ - Later: VS Code extension.
538
+ - Later: repo-aware multi-file fixes.
539
+ - Later: stronger local model.
540
+ - Later: user-reviewed local training exports for model and retriever improvement.
541
+ - Later: CI/CD and observability integrations.
542
+
543
+ See [docs/ROADMAP.md](docs/ROADMAP.md).
544
+
545
+ ## More Docs
546
+
547
+ - [docs/SETUP.md](docs/SETUP.md)
548
+ - [docs/DEMO_COMMANDS.md](docs/DEMO_COMMANDS.md)
549
+ - [docs/SAFETY.md](docs/SAFETY.md)
550
+ - [docs/PACKAGING.md](docs/PACKAGING.md)
551
+ - [docs/TRAINING_DATA_EXPORT.md](docs/TRAINING_DATA_EXPORT.md)
552
+ - [docs/UX.md](docs/UX.md)
553
+ - [docs/RELIABILITY.md](docs/RELIABILITY.md)
554
+ - [docs/REAL_WORLD_RESULTS.md](docs/REAL_WORLD_RESULTS.md)
555
+ - [docs/PRODUCTION_READINESS.md](docs/PRODUCTION_READINESS.md)
556
+ - [docs/PRODUCTION_VALIDATION.md](docs/PRODUCTION_VALIDATION.md)
557
+ - [docs/PROJECT_OVERVIEW.md](docs/PROJECT_OVERVIEW.md)
558
+ - [docs/WHY_DIFFERENT.md](docs/WHY_DIFFERENT.md)
559
+ - [RELEASE_CANDIDATE_CHECKLIST.md](RELEASE_CANDIDATE_CHECKLIST.md)