ghostfix 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.
Files changed (44) hide show
  1. ghostfix-0.1.0/CHANGELOG.md +28 -0
  2. ghostfix-0.1.0/CONTRIBUTING.md +39 -0
  3. ghostfix-0.1.0/LICENSE +21 -0
  4. ghostfix-0.1.0/MANIFEST.in +9 -0
  5. ghostfix-0.1.0/PKG-INFO +222 -0
  6. ghostfix-0.1.0/README.md +201 -0
  7. ghostfix-0.1.0/SECURITY.md +40 -0
  8. ghostfix-0.1.0/docs/ARCHITECTURE.md +75 -0
  9. ghostfix-0.1.0/docs/CONFIGURATION.md +87 -0
  10. ghostfix-0.1.0/docs/INSTALLATION.md +59 -0
  11. ghostfix-0.1.0/docs/PROVIDERS.md +112 -0
  12. ghostfix-0.1.0/docs/RELEASE_CHECKLIST.md +72 -0
  13. ghostfix-0.1.0/docs/TROUBLESHOOTING.md +69 -0
  14. ghostfix-0.1.0/docs/assets/Screen Recording 2026-06-06 143114.mp4 +0 -0
  15. ghostfix-0.1.0/docs/assets/ghostfix-demo.gif +0 -0
  16. ghostfix-0.1.0/docs/make_demo_gif.py +136 -0
  17. ghostfix-0.1.0/ghostfix/__init__.py +1 -0
  18. ghostfix-0.1.0/ghostfix/ai/__init__.py +4 -0
  19. ghostfix-0.1.0/ghostfix/ai/base.py +8 -0
  20. ghostfix-0.1.0/ghostfix/ai/claude_provider.py +34 -0
  21. ghostfix-0.1.0/ghostfix/ai/custom_provider.py +93 -0
  22. ghostfix-0.1.0/ghostfix/ai/gemini_provider.py +33 -0
  23. ghostfix-0.1.0/ghostfix/ai/openai_provider.py +34 -0
  24. ghostfix-0.1.0/ghostfix/ai/router.py +127 -0
  25. ghostfix-0.1.0/ghostfix/cli.py +181 -0
  26. ghostfix-0.1.0/ghostfix/config/__init__.py +2 -0
  27. ghostfix-0.1.0/ghostfix/config/manager.py +159 -0
  28. ghostfix-0.1.0/ghostfix/core/__init__.py +5 -0
  29. ghostfix-0.1.0/ghostfix/core/context_builder.py +129 -0
  30. ghostfix-0.1.0/ghostfix/core/error_parser.py +144 -0
  31. ghostfix-0.1.0/ghostfix/core/patcher.py +164 -0
  32. ghostfix-0.1.0/ghostfix/core/watcher.py +186 -0
  33. ghostfix-0.1.0/ghostfix/parsers/__init__.py +2 -0
  34. ghostfix-0.1.0/ghostfix/ui/__init__.py +2 -0
  35. ghostfix-0.1.0/ghostfix/ui/renderer.py +129 -0
  36. ghostfix-0.1.0/ghostfix.egg-info/PKG-INFO +222 -0
  37. ghostfix-0.1.0/ghostfix.egg-info/SOURCES.txt +42 -0
  38. ghostfix-0.1.0/ghostfix.egg-info/dependency_links.txt +1 -0
  39. ghostfix-0.1.0/ghostfix.egg-info/entry_points.txt +2 -0
  40. ghostfix-0.1.0/ghostfix.egg-info/requires.txt +11 -0
  41. ghostfix-0.1.0/ghostfix.egg-info/top_level.txt +1 -0
  42. ghostfix-0.1.0/pyproject.toml +30 -0
  43. ghostfix-0.1.0/setup.cfg +4 -0
  44. ghostfix-0.1.0/tests/test_error_parser.py +53 -0
@@ -0,0 +1,28 @@
1
+ # Changelog
2
+
3
+ All notable changes to GhostFix will be documented here.
4
+
5
+ ## 0.1.0
6
+
7
+ Initial release candidate.
8
+
9
+ ### Added
10
+
11
+ - `ghostfix watch` command for running and monitoring shell commands.
12
+ - Error detection and stack trace parsing for Python, Node.js, Java, Go, Rust, Ruby, and generic CLI output.
13
+ - Context builder for source snippets, related files, and project tree context.
14
+ - AI provider routing for OpenAI, Claude, Gemini, and custom/local endpoints.
15
+ - Unified-diff patch application with backup support.
16
+ - Project config generation through `ghostfix init`.
17
+ - Global setup and masked config display commands.
18
+ - Release-ready documentation set.
19
+
20
+ ### Changed
21
+
22
+ - `watch --ai` now asks for provider/API key on every run instead of silently reusing a saved provider.
23
+
24
+ ### Known Limitations
25
+
26
+ - Patch quality depends on model quality and stack trace context.
27
+ - Manual patch fallback supports simple diffs only.
28
+ - Generic CLI error parsing is partial.
@@ -0,0 +1,39 @@
1
+ # Contributing
2
+
3
+ Thanks for helping improve GhostFix.
4
+
5
+ ## Development Setup
6
+
7
+ ```bash
8
+ git clone https://github.com/Shibani987/ghostfix-ai.git
9
+ cd ghostfix-ai
10
+ python -m pip install -e ".[dev]"
11
+ python -m pytest
12
+ ```
13
+
14
+ ## Local Workflow
15
+
16
+ 1. Create a branch for the change.
17
+ 2. Keep changes focused.
18
+ 3. Add or update tests when behavior changes.
19
+ 4. Run `python -m pytest`.
20
+ 5. Update docs if commands, config, provider behavior, or safety behavior changes.
21
+
22
+ ## Code Style
23
+
24
+ - Prefer small, readable functions.
25
+ - Keep CLI behavior explicit and predictable.
26
+ - Avoid broad refactors in bug-fix PRs.
27
+ - Use structured parsing where possible.
28
+ - Keep patch application conservative.
29
+
30
+ ## Documentation Style
31
+
32
+ - Use short sections.
33
+ - Include copy-pasteable commands.
34
+ - Call out safety and provider/API-key behavior clearly.
35
+ - Keep release docs accurate to the current code.
36
+
37
+ ## Testing
38
+
39
+ Current tests focus on error parsing. When changing the repair loop, provider routing, or patching behavior, add focused tests around the changed contract.
ghostfix-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 GhostFix contributors
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,9 @@
1
+ include README.md
2
+ include LICENSE
3
+ include CHANGELOG.md
4
+ include CONTRIBUTING.md
5
+ include SECURITY.md
6
+ recursive-include docs *.md
7
+ include docs/make_demo_gif.py
8
+ recursive-include docs/assets *.gif
9
+ recursive-include docs/assets *.mp4
@@ -0,0 +1,222 @@
1
+ Metadata-Version: 2.4
2
+ Name: ghostfix
3
+ Version: 0.1.0
4
+ Summary: AI-powered terminal error watcher and auto-fixer for any project
5
+ License-Expression: MIT
6
+ Keywords: ai,debugging,cli,auto-fix,developer-tools
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: click>=8.0
11
+ Requires-Dist: rich>=13.0
12
+ Requires-Dist: httpx>=0.24
13
+ Requires-Dist: pydantic>=2.0
14
+ Requires-Dist: gitpython>=3.1
15
+ Requires-Dist: prompt_toolkit>=3.0
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest; extra == "dev"
18
+ Requires-Dist: black; extra == "dev"
19
+ Requires-Dist: mypy; extra == "dev"
20
+ Dynamic: license-file
21
+
22
+ # GhostFix
23
+
24
+ **AI-powered terminal error watcher and auto-fixer.**
25
+
26
+ GhostFix watches any command, detects runtime errors, gathers the relevant code context, asks an AI provider for a focused unified-diff patch, and applies the fix from your terminal.
27
+
28
+ ![GhostFix demo](docs/assets/ghostfix-demo.gif)
29
+
30
+ ## See GhostFix in Action
31
+
32
+ <video src="docs/assets/Screen%20Recording%202026-06-06%20143114.mp4" controls width="100%">
33
+ Watch the GhostFix demo video.
34
+ </video>
35
+
36
+ [Watch the demo video](docs/assets/Screen%20Recording%202026-06-06%20143114.mp4)
37
+
38
+ [![PyPI](https://img.shields.io/badge/pypi-ghostfix-6d4aff)](https://pypi.org/project/ghostfix/)
39
+ [![Python](https://img.shields.io/badge/python-3.9%2B-2f8fcb)](https://www.python.org/)
40
+ [![License](https://img.shields.io/badge/license-MIT-111827)](LICENSE)
41
+ [![CLI](https://img.shields.io/badge/cli-rich%20%2B%20click-ff4f87)](https://github.com/Shibani987/ghostfix-ai)
42
+
43
+ ## Why GhostFix?
44
+
45
+ Development servers, test runners, CLIs, scripts, and training jobs fail in noisy ways. GhostFix sits beside the command, reads the error stream, finds the file and line that matter, then proposes a small patch you can review before applying.
46
+
47
+ GhostFix is built for developers who want fast repair loops without giving up control.
48
+
49
+ ## Features
50
+
51
+ - Watch any shell command: Next.js, Django, Flask, pytest, Node, Go, Rust, Java, Ruby, and more.
52
+ - Detect common error signals and parse stack traces across multiple languages.
53
+ - Resolve source files from stack traces and collect nearby code context.
54
+ - Use cloud providers: OpenAI, Claude, or Gemini.
55
+ - Use local/custom models through Ollama, LM Studio, vLLM, or any OpenAI-compatible endpoint.
56
+ - Generate unified-diff patches and apply them with `git apply` first.
57
+ - Create backups in `.ghostfix_backups/` before patching.
58
+ - Restart the watched command after a successful fix.
59
+ - Limit repeated fixes for the same error with retry controls.
60
+ - Keep humans in the loop by default with patch confirmation prompts.
61
+
62
+ ## Install
63
+
64
+ ```bash
65
+ pip install ghostfix
66
+ ```
67
+
68
+ From source:
69
+
70
+ ```bash
71
+ git clone https://github.com/Shibani987/ghostfix-ai.git
72
+ cd ghostfix-ai
73
+ pip install -e .
74
+ ```
75
+
76
+ Python 3.9 or newer is required.
77
+
78
+ ## Quick Start
79
+
80
+ Cloud AI mode:
81
+
82
+ ```bash
83
+ ghostfix watch "npm run dev" --fix --ai
84
+ ```
85
+
86
+ GhostFix asks for the provider and API key each time `watch --ai` runs. This keeps new terminal sessions from silently reusing an old saved key.
87
+
88
+ Force a provider but still enter the key for this run:
89
+
90
+ ```bash
91
+ ghostfix watch "python manage.py runserver" --fix --ai --provider gemini
92
+ ```
93
+
94
+ Local/custom model mode:
95
+
96
+ ```bash
97
+ ghostfix init
98
+ ghostfix watch "python app.py" --fix
99
+ ```
100
+
101
+ Edit the generated `ghostfix.config.py` to point at Ollama, LM Studio, vLLM, or your own model server.
102
+
103
+ ## Commands
104
+
105
+ | Command | Description |
106
+ | --- | --- |
107
+ | `ghostfix watch "CMD"` | Watch a command and print its output. |
108
+ | `ghostfix watch "CMD" --fix --ai` | Watch and fix using a cloud AI provider. |
109
+ | `ghostfix watch "CMD" --fix` | Watch and fix using `ghostfix.config.py` custom model settings. |
110
+ | `ghostfix setup` | Save a default cloud provider/API key for setup workflows. |
111
+ | `ghostfix init` | Create a project-level `ghostfix.config.py`. |
112
+ | `ghostfix config-show` | Show the merged GhostFix configuration with masked API key. |
113
+
114
+ ## Flags
115
+
116
+ | Flag | Description |
117
+ | --- | --- |
118
+ | `--fix` | Enable the AI repair pipeline when an error is detected. |
119
+ | `--ai` | Use OpenAI, Claude, or Gemini instead of a custom model config. |
120
+ | `--provider <name>` | Force `openai`, `claude`, or `gemini`. |
121
+ | `--auto` | Apply patches without confirmation. Use carefully. |
122
+ | `--config <path>` | Load a specific `ghostfix.config.py`. |
123
+ | `--verbose` | Show extra renderer/debug output. |
124
+
125
+ ## How It Works
126
+
127
+ ```text
128
+ watched command fails
129
+ |
130
+ v
131
+ error parser detects language, error type, file, and line
132
+ |
133
+ v
134
+ context builder collects source snippets and project tree
135
+ |
136
+ v
137
+ AI provider returns root cause, explanation, and unified diff
138
+ |
139
+ v
140
+ GhostFix shows the fix and asks before applying
141
+ |
142
+ v
143
+ patcher backs up files, applies patch, and restarts command
144
+ ```
145
+
146
+ ## Configuration
147
+
148
+ Create a config file:
149
+
150
+ ```bash
151
+ ghostfix init
152
+ ```
153
+
154
+ Example:
155
+
156
+ ```python
157
+ GHOSTFIX_CONFIG = {
158
+ "model": {
159
+ "type": "custom",
160
+ "endpoint": "http://localhost:11434/api/chat",
161
+ "model_name": "codellama:13b",
162
+ },
163
+ "watch": {
164
+ "ignore": ["node_modules", ".git", "dist", "__pycache__"],
165
+ "max_file_size_kb": 500,
166
+ "context_lines": 60,
167
+ },
168
+ "fix": {
169
+ "auto_apply": False,
170
+ "create_backup": True,
171
+ "restart_on_fix": True,
172
+ "max_retries": 3,
173
+ },
174
+ }
175
+ ```
176
+
177
+ See [Configuration](docs/CONFIGURATION.md) and [Providers](docs/PROVIDERS.md).
178
+
179
+ ## Supported Error Families
180
+
181
+ | Ecosystem | Detection | Stack trace parsing |
182
+ | --- | --- | --- |
183
+ | Python, Django, Flask | Yes | Yes |
184
+ | Node.js, TypeScript, Next.js | Yes | Yes |
185
+ | Java | Yes | Yes |
186
+ | Go | Yes | Yes |
187
+ | Rust | Yes | Yes |
188
+ | Ruby | Yes | Yes |
189
+ | Generic CLI output | Yes | Partial |
190
+
191
+ ## Safety
192
+
193
+ GhostFix is designed to keep you in control:
194
+
195
+ - Patches are shown before applying unless `--auto` is enabled.
196
+ - Backups are created before patching by default.
197
+ - The same error is not fixed forever; retry limits stop loops.
198
+ - Project scanning ignores common generated folders.
199
+ - API keys are masked in `config-show`.
200
+
201
+ Read [Security](SECURITY.md) before using GhostFix on sensitive repositories.
202
+
203
+ ## Documentation
204
+
205
+ - [Installation](docs/INSTALLATION.md)
206
+ - [Configuration](docs/CONFIGURATION.md)
207
+ - [Providers](docs/PROVIDERS.md)
208
+ - [Architecture](docs/ARCHITECTURE.md)
209
+ - [Troubleshooting](docs/TROUBLESHOOTING.md)
210
+ - [Release Checklist](docs/RELEASE_CHECKLIST.md)
211
+ - [Contributing](CONTRIBUTING.md)
212
+ - [Changelog](CHANGELOG.md)
213
+
214
+ ## Release Status
215
+
216
+ Current version: `0.1.0`
217
+
218
+ This is an early release. The core loop is ready for testing, but patch quality depends on the chosen AI model and the context available in the error output.
219
+
220
+ ## License
221
+
222
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,201 @@
1
+ # GhostFix
2
+
3
+ **AI-powered terminal error watcher and auto-fixer.**
4
+
5
+ GhostFix watches any command, detects runtime errors, gathers the relevant code context, asks an AI provider for a focused unified-diff patch, and applies the fix from your terminal.
6
+
7
+ ![GhostFix demo](docs/assets/ghostfix-demo.gif)
8
+
9
+ ## See GhostFix in Action
10
+
11
+ <video src="docs/assets/Screen%20Recording%202026-06-06%20143114.mp4" controls width="100%">
12
+ Watch the GhostFix demo video.
13
+ </video>
14
+
15
+ [Watch the demo video](docs/assets/Screen%20Recording%202026-06-06%20143114.mp4)
16
+
17
+ [![PyPI](https://img.shields.io/badge/pypi-ghostfix-6d4aff)](https://pypi.org/project/ghostfix/)
18
+ [![Python](https://img.shields.io/badge/python-3.9%2B-2f8fcb)](https://www.python.org/)
19
+ [![License](https://img.shields.io/badge/license-MIT-111827)](LICENSE)
20
+ [![CLI](https://img.shields.io/badge/cli-rich%20%2B%20click-ff4f87)](https://github.com/Shibani987/ghostfix-ai)
21
+
22
+ ## Why GhostFix?
23
+
24
+ Development servers, test runners, CLIs, scripts, and training jobs fail in noisy ways. GhostFix sits beside the command, reads the error stream, finds the file and line that matter, then proposes a small patch you can review before applying.
25
+
26
+ GhostFix is built for developers who want fast repair loops without giving up control.
27
+
28
+ ## Features
29
+
30
+ - Watch any shell command: Next.js, Django, Flask, pytest, Node, Go, Rust, Java, Ruby, and more.
31
+ - Detect common error signals and parse stack traces across multiple languages.
32
+ - Resolve source files from stack traces and collect nearby code context.
33
+ - Use cloud providers: OpenAI, Claude, or Gemini.
34
+ - Use local/custom models through Ollama, LM Studio, vLLM, or any OpenAI-compatible endpoint.
35
+ - Generate unified-diff patches and apply them with `git apply` first.
36
+ - Create backups in `.ghostfix_backups/` before patching.
37
+ - Restart the watched command after a successful fix.
38
+ - Limit repeated fixes for the same error with retry controls.
39
+ - Keep humans in the loop by default with patch confirmation prompts.
40
+
41
+ ## Install
42
+
43
+ ```bash
44
+ pip install ghostfix
45
+ ```
46
+
47
+ From source:
48
+
49
+ ```bash
50
+ git clone https://github.com/Shibani987/ghostfix-ai.git
51
+ cd ghostfix-ai
52
+ pip install -e .
53
+ ```
54
+
55
+ Python 3.9 or newer is required.
56
+
57
+ ## Quick Start
58
+
59
+ Cloud AI mode:
60
+
61
+ ```bash
62
+ ghostfix watch "npm run dev" --fix --ai
63
+ ```
64
+
65
+ GhostFix asks for the provider and API key each time `watch --ai` runs. This keeps new terminal sessions from silently reusing an old saved key.
66
+
67
+ Force a provider but still enter the key for this run:
68
+
69
+ ```bash
70
+ ghostfix watch "python manage.py runserver" --fix --ai --provider gemini
71
+ ```
72
+
73
+ Local/custom model mode:
74
+
75
+ ```bash
76
+ ghostfix init
77
+ ghostfix watch "python app.py" --fix
78
+ ```
79
+
80
+ Edit the generated `ghostfix.config.py` to point at Ollama, LM Studio, vLLM, or your own model server.
81
+
82
+ ## Commands
83
+
84
+ | Command | Description |
85
+ | --- | --- |
86
+ | `ghostfix watch "CMD"` | Watch a command and print its output. |
87
+ | `ghostfix watch "CMD" --fix --ai` | Watch and fix using a cloud AI provider. |
88
+ | `ghostfix watch "CMD" --fix` | Watch and fix using `ghostfix.config.py` custom model settings. |
89
+ | `ghostfix setup` | Save a default cloud provider/API key for setup workflows. |
90
+ | `ghostfix init` | Create a project-level `ghostfix.config.py`. |
91
+ | `ghostfix config-show` | Show the merged GhostFix configuration with masked API key. |
92
+
93
+ ## Flags
94
+
95
+ | Flag | Description |
96
+ | --- | --- |
97
+ | `--fix` | Enable the AI repair pipeline when an error is detected. |
98
+ | `--ai` | Use OpenAI, Claude, or Gemini instead of a custom model config. |
99
+ | `--provider <name>` | Force `openai`, `claude`, or `gemini`. |
100
+ | `--auto` | Apply patches without confirmation. Use carefully. |
101
+ | `--config <path>` | Load a specific `ghostfix.config.py`. |
102
+ | `--verbose` | Show extra renderer/debug output. |
103
+
104
+ ## How It Works
105
+
106
+ ```text
107
+ watched command fails
108
+ |
109
+ v
110
+ error parser detects language, error type, file, and line
111
+ |
112
+ v
113
+ context builder collects source snippets and project tree
114
+ |
115
+ v
116
+ AI provider returns root cause, explanation, and unified diff
117
+ |
118
+ v
119
+ GhostFix shows the fix and asks before applying
120
+ |
121
+ v
122
+ patcher backs up files, applies patch, and restarts command
123
+ ```
124
+
125
+ ## Configuration
126
+
127
+ Create a config file:
128
+
129
+ ```bash
130
+ ghostfix init
131
+ ```
132
+
133
+ Example:
134
+
135
+ ```python
136
+ GHOSTFIX_CONFIG = {
137
+ "model": {
138
+ "type": "custom",
139
+ "endpoint": "http://localhost:11434/api/chat",
140
+ "model_name": "codellama:13b",
141
+ },
142
+ "watch": {
143
+ "ignore": ["node_modules", ".git", "dist", "__pycache__"],
144
+ "max_file_size_kb": 500,
145
+ "context_lines": 60,
146
+ },
147
+ "fix": {
148
+ "auto_apply": False,
149
+ "create_backup": True,
150
+ "restart_on_fix": True,
151
+ "max_retries": 3,
152
+ },
153
+ }
154
+ ```
155
+
156
+ See [Configuration](docs/CONFIGURATION.md) and [Providers](docs/PROVIDERS.md).
157
+
158
+ ## Supported Error Families
159
+
160
+ | Ecosystem | Detection | Stack trace parsing |
161
+ | --- | --- | --- |
162
+ | Python, Django, Flask | Yes | Yes |
163
+ | Node.js, TypeScript, Next.js | Yes | Yes |
164
+ | Java | Yes | Yes |
165
+ | Go | Yes | Yes |
166
+ | Rust | Yes | Yes |
167
+ | Ruby | Yes | Yes |
168
+ | Generic CLI output | Yes | Partial |
169
+
170
+ ## Safety
171
+
172
+ GhostFix is designed to keep you in control:
173
+
174
+ - Patches are shown before applying unless `--auto` is enabled.
175
+ - Backups are created before patching by default.
176
+ - The same error is not fixed forever; retry limits stop loops.
177
+ - Project scanning ignores common generated folders.
178
+ - API keys are masked in `config-show`.
179
+
180
+ Read [Security](SECURITY.md) before using GhostFix on sensitive repositories.
181
+
182
+ ## Documentation
183
+
184
+ - [Installation](docs/INSTALLATION.md)
185
+ - [Configuration](docs/CONFIGURATION.md)
186
+ - [Providers](docs/PROVIDERS.md)
187
+ - [Architecture](docs/ARCHITECTURE.md)
188
+ - [Troubleshooting](docs/TROUBLESHOOTING.md)
189
+ - [Release Checklist](docs/RELEASE_CHECKLIST.md)
190
+ - [Contributing](CONTRIBUTING.md)
191
+ - [Changelog](CHANGELOG.md)
192
+
193
+ ## Release Status
194
+
195
+ Current version: `0.1.0`
196
+
197
+ This is an early release. The core loop is ready for testing, but patch quality depends on the chosen AI model and the context available in the error output.
198
+
199
+ ## License
200
+
201
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,40 @@
1
+ # Security
2
+
3
+ GhostFix sends error output and selected source snippets to the configured AI provider. Review your provider's data policy before using GhostFix on private or regulated code.
4
+
5
+ ## Sensitive Data
6
+
7
+ Before running GhostFix, avoid printing secrets in command output. Error logs may include:
8
+
9
+ - API keys
10
+ - Database URLs
11
+ - Access tokens
12
+ - User data
13
+ - Internal file paths
14
+
15
+ If a command may print secrets, prefer a local model endpoint and sanitize logs where possible.
16
+
17
+ ## API Keys
18
+
19
+ `ghostfix watch --fix --ai` asks for provider/API key on each run.
20
+
21
+ `ghostfix setup` can save a global provider/API key at:
22
+
23
+ ```text
24
+ ~/.ghostfix/config.json
25
+ ```
26
+
27
+ Keep that file private.
28
+
29
+ ## Patches
30
+
31
+ GhostFix can modify files. By default it asks before applying patches and creates backups. Avoid `--auto` on sensitive repositories unless you trust the configured model and have version control in place.
32
+
33
+ ## Reporting Issues
34
+
35
+ If you find a security issue, do not open a public issue with exploit details. Contact the maintainers privately and include:
36
+
37
+ - Affected version
38
+ - Reproduction steps
39
+ - Impact
40
+ - Suggested mitigation, if known
@@ -0,0 +1,75 @@
1
+ # Architecture
2
+
3
+ GhostFix is a small pipeline-oriented CLI.
4
+
5
+ ## Modules
6
+
7
+ ```text
8
+ ghostfix/
9
+ cli.py command entry points
10
+ config/manager.py global and project config loading
11
+ core/watcher.py process runner and repair loop
12
+ core/error_parser.py language/error/file/line extraction
13
+ core/context_builder.py code context and project tree builder
14
+ core/patcher.py unified diff application and backups
15
+ ai/router.py prompt building and provider dispatch
16
+ ai/*_provider.py OpenAI, Claude, Gemini, custom endpoints
17
+ ui/renderer.py Rich terminal output
18
+ ```
19
+
20
+ ## Runtime Flow
21
+
22
+ 1. `cli.py` loads config and starts `ProcessWatcher`.
23
+ 2. `ProcessWatcher` runs the watched command with merged stdout/stderr.
24
+ 3. Each output line is passed to `ErrorParser.is_error_signal`.
25
+ 4. Error blocks are parsed into `ParsedError`.
26
+ 5. `ContextBuilder` resolves the primary file and related stack trace files.
27
+ 6. `AIRouter` builds a debugging prompt and calls the configured provider.
28
+ 7. The provider returns JSON with root cause, explanation, suggestion, and patch.
29
+ 8. `Renderer` shows the result.
30
+ 9. `Patcher` creates backups, applies the unified diff, and returns status.
31
+ 10. The watcher restarts the command if configured.
32
+
33
+ ## Patch Strategy
34
+
35
+ `Patcher` tries:
36
+
37
+ 1. `git apply --whitespace=nowarn -`
38
+ 2. A minimal manual unified-diff fallback for simple single-file patches
39
+
40
+ Backups are stored under:
41
+
42
+ ```text
43
+ .ghostfix_backups/<timestamp>/
44
+ ```
45
+
46
+ ## Error Parsing
47
+
48
+ GhostFix recognizes common signals from:
49
+
50
+ - Python
51
+ - Node.js and TypeScript
52
+ - Java
53
+ - Go
54
+ - Rust
55
+ - Ruby
56
+ - Generic CLI output
57
+
58
+ The parser chooses the most specific user file from the stack trace, then sends that location to the context builder.
59
+
60
+ ## AI Response Contract
61
+
62
+ Providers must return content that can be parsed as JSON:
63
+
64
+ ```json
65
+ {
66
+ "root_cause": "why the error happened",
67
+ "explanation": "deeper details",
68
+ "fix_suggestion": "what should change",
69
+ "patch": "--- a/file.py\n+++ b/file.py\n@@ ...",
70
+ "confidence": 0.75,
71
+ "related_files": ["optional.py"]
72
+ }
73
+ ```
74
+
75
+ If no code patch is appropriate, `patch` should be an empty string and `fix_suggestion` should explain the required command or manual action.