ghostcode-canary 0.1.25-canary.0
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.
- package/LICENSE +201 -0
- package/PAT.txt +1 -0
- package/README.md +95 -0
- package/cli.js +92 -0
- package/error/err1.txt +12 -0
- package/package.json +31 -0
- package/setup.js +67 -0
- package/src/ghostcode/__init__.py +3 -0
- package/src/ghostcode/__main__.py +3 -0
- package/src/ghostcode/_version.py +17 -0
- package/src/ghostcode/agents/__init__.py +20 -0
- package/src/ghostcode/agents/code.py +104 -0
- package/src/ghostcode/agents/explore.py +50 -0
- package/src/ghostcode/ai/__init__.py +0 -0
- package/src/ghostcode/ai/anthropic_client.py +8 -0
- package/src/ghostcode/ai/base.py +33 -0
- package/src/ghostcode/ai/factory.py +38 -0
- package/src/ghostcode/ai/groq_client.py +7 -0
- package/src/ghostcode/ai/nvidia_client.py +7 -0
- package/src/ghostcode/ai/ollama_client.py +7 -0
- package/src/ghostcode/ai/openai_client.py +7 -0
- package/src/ghostcode/ai/openai_compat.py +139 -0
- package/src/ghostcode/ai/opencode_go_client.py +7 -0
- package/src/ghostcode/ai/opencode_zen_client.py +7 -0
- package/src/ghostcode/ai/openrouter_client.py +7 -0
- package/src/ghostcode/ai/registry.py +169 -0
- package/src/ghostcode/app.py +148 -0
- package/src/ghostcode/config.py +24 -0
- package/src/ghostcode/core/__init__.py +5 -0
- package/src/ghostcode/core/commands.py +55 -0
- package/src/ghostcode/core/file_ops.py +127 -0
- package/src/ghostcode/core/hooks.py +122 -0
- package/src/ghostcode/core/memory.py +137 -0
- package/src/ghostcode/core/prompt.py +73 -0
- package/src/ghostcode/core/reminders.py +61 -0
- package/src/ghostcode/core/security.py +119 -0
- package/src/ghostcode/core/tasks.py +125 -0
- package/src/ghostcode/tools/__init__.py +2 -0
- package/src/ghostcode/tools/defs.py +325 -0
- package/src/ghostcode/tools/executor.py +261 -0
- package/src/ghostcode/tui/__init__.py +0 -0
- package/src/ghostcode/tui/app.py +12 -0
- package/src/ghostcode/tui/dialogs.py +241 -0
- package/src/ghostcode/tui/screens.py +799 -0
- package/src/ghostcode/tui/widgets.py +32 -0
- package/src/ghostcode/utils/__init__.py +0 -0
- package/src/ghostcode/utils/config_loader.py +102 -0
- package/src/ghostcode/utils/logger.py +16 -0
- package/src/pyproject.toml +18 -0
- package/token.txt +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 The DarkGhost
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/PAT.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
glpat-okFQ00Kz9CpzBFdUWlh8hWM6MQpvOjEKdTpuZWViNA8.01.171mfuly5
|
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# GhostCode
|
|
2
|
+
|
|
3
|
+
Terminal AI coding assistant with built-in TUI. Chat with multiple AI providers, auto-save code blocks, manage persistent memory, and delegate tasks to subagents.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm i -g ghostcode-canary
|
|
7
|
+
ghostcode
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Quick start
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm i -g ghostcode-canary
|
|
14
|
+
ghostcode
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Inside the app, connect an API key:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
/api connect groq gsk-<your-key>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Get a free key at [console.groq.com](https://console.groq.com). Keys are stored in `~/.ghostcode/config.json`.
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- **Hybrid architecture** — Node.js CLI (`cli.js`) spawns a Python Textual TUI
|
|
28
|
+
- **8 AI providers** — Groq, OpenAI, Anthropic, Ollama, OpenRouter, NVIDIA, and 2 coming-soon
|
|
29
|
+
- **Tool-calling** — file read/write/edit, shell commands, web search/fetch, grep, glob
|
|
30
|
+
- **Persistent memory** — save/recall knowledge across sessions with 4 types: user, feedback, project, reference
|
|
31
|
+
- **Subagent tasks** — spawn async subagents for parallel work
|
|
32
|
+
- **Auto-save** — code blocks in AI responses saved to `ghostcode_gen/` in cwd
|
|
33
|
+
- **Plan mode** — read-only exploration agent for research before implementation
|
|
34
|
+
- **Security** — configurable deny rules and secret scanning
|
|
35
|
+
- **Hooks** — before/after tool hooks and stop hooks via shell commands
|
|
36
|
+
|
|
37
|
+
## In-app commands
|
|
38
|
+
|
|
39
|
+
| Command | What it does |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `/api` | Show provider list with status |
|
|
42
|
+
| `/api connect <provider> <key>` | Set API key directly |
|
|
43
|
+
| `/api disconnect <provider>` | Remove provider's key |
|
|
44
|
+
| `/model <name>` | Switch model for active provider |
|
|
45
|
+
| `/provider <name>` | Switch active provider |
|
|
46
|
+
| `/clear` | Clear chat history |
|
|
47
|
+
| `/help` | Show this help |
|
|
48
|
+
| `/memory` | Manage persistent memory (save/list/delete) |
|
|
49
|
+
| `/tasks` | List and manage subagent tasks |
|
|
50
|
+
| `/deny` | Configure deny rules |
|
|
51
|
+
| `/hooks` | Configure tool hooks |
|
|
52
|
+
| `/plan` | Enter read-only plan mode |
|
|
53
|
+
| `/review` | Review recent work |
|
|
54
|
+
| `/summary` | Show session summary |
|
|
55
|
+
| `/init` | Initialize project config |
|
|
56
|
+
| `/ask` | Ask a question |
|
|
57
|
+
| `/brief` | Get a brief on current state |
|
|
58
|
+
| Tab | Switch between code agent and plan agent |
|
|
59
|
+
|
|
60
|
+
## Providers
|
|
61
|
+
|
|
62
|
+
| Provider | Status |
|
|
63
|
+
|---|---|
|
|
64
|
+
| Groq | ✅ |
|
|
65
|
+
| OpenAI | ✅ |
|
|
66
|
+
| Anthropic | ✅ |
|
|
67
|
+
| Ollama | ✅ |
|
|
68
|
+
| OpenRouter | ✅ |
|
|
69
|
+
| NVIDIA | ✅ |
|
|
70
|
+
|
|
71
|
+
API keys stored at `~/.ghostcode/config.json`. Environment variables loaded from `.env`, `~/.ghostcode/.env`, and `src/.env`.
|
|
72
|
+
|
|
73
|
+
## Architecture
|
|
74
|
+
|
|
75
|
+
This project is a hybrid Node.js/Python application:
|
|
76
|
+
|
|
77
|
+
- **CLI entrypoint** — `cli.js` spawns `python -m ghostcode` from a local `.venv`
|
|
78
|
+
- **Python package** — `src/ghostcode/` (setuptools, pyproject.toml)
|
|
79
|
+
- **Agent prompts** — system prompts in `src/ghostcode/agents/` (`code.py` for full tool access, `explore.py` for read-only)
|
|
80
|
+
- **Tools** — 16 tool definitions in `src/ghostcode/tools/defs.py`, execution in `executor.py`
|
|
81
|
+
- **Version** — single source of truth in `package.json`, read at runtime by `_version.py`
|
|
82
|
+
|
|
83
|
+
See [AGENTS.md](AGENTS.md) for a detailed developer guide.
|
|
84
|
+
|
|
85
|
+
## Requirements
|
|
86
|
+
|
|
87
|
+
- Node.js >=16, npm >=8
|
|
88
|
+
- Python >=3.8
|
|
89
|
+
- Dependencies: `textual>=8.0.0`, `httpx>=0.28.0`, `python-dotenv>=1.0.0`, `pygments>=2.15.0`
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
Apache 2.0 — see [LICENSE](LICENSE).
|
|
94
|
+
|
|
95
|
+
[gitlab.com/thedarkghost/ghostcode](https://gitlab.com/thedarkghost/ghostcode)
|
package/cli.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn, execSync } = require("child_process");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
|
|
7
|
+
const isTermux = () => {
|
|
8
|
+
try { return require("fs").existsSync("/data/data/com.termux"); } catch { return false; }
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function checkPython() {
|
|
12
|
+
try {
|
|
13
|
+
execSync("python3 --version", { stdio: "pipe" });
|
|
14
|
+
} catch {
|
|
15
|
+
console.error("");
|
|
16
|
+
console.error(" GhostCode needs Python 3.8+");
|
|
17
|
+
console.error("");
|
|
18
|
+
if (isTermux()) {
|
|
19
|
+
console.error(" Install in Termux:");
|
|
20
|
+
console.error(" pkg update && pkg upgrade");
|
|
21
|
+
console.error(" pkg install python python-pip binutils");
|
|
22
|
+
console.error("");
|
|
23
|
+
} else {
|
|
24
|
+
console.error(" Install it:");
|
|
25
|
+
console.error(" Ubuntu/Debian: sudo apt install python3 python3-venv");
|
|
26
|
+
console.error(" macOS: brew install python3");
|
|
27
|
+
console.error(" Windows: https://python.org/downloads");
|
|
28
|
+
console.error(" Arch: sudo pacman -S python python-virtualenv");
|
|
29
|
+
console.error("");
|
|
30
|
+
}
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const root = __dirname;
|
|
36
|
+
const venv = path.join(root, ".venv");
|
|
37
|
+
const python = path.join(venv, "bin", "python");
|
|
38
|
+
|
|
39
|
+
// Handle uninstall commands (no Python needed)
|
|
40
|
+
const args = process.argv.slice(2);
|
|
41
|
+
if (args[0] === "uninstall") {
|
|
42
|
+
const clean = args.includes("--clean");
|
|
43
|
+
console.log("GhostCode uninstall...");
|
|
44
|
+
|
|
45
|
+
if (clean) {
|
|
46
|
+
const configDir = path.join(os.homedir(), ".ghostcode");
|
|
47
|
+
if (fs.existsSync(configDir)) {
|
|
48
|
+
console.log(`Removing config: ${configDir}`);
|
|
49
|
+
fs.rmSync(configDir, { recursive: true, force: true });
|
|
50
|
+
console.log("Config removed.");
|
|
51
|
+
} else {
|
|
52
|
+
console.log("No config found, skipping.");
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
console.log("Config kept. Use --clean to also remove config and API keys.");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
console.log("Uninstalling npm package...");
|
|
60
|
+
execSync("npm uninstall -g ghostcode-canary", { stdio: "inherit" });
|
|
61
|
+
console.log("GhostCode uninstalled.");
|
|
62
|
+
} catch (e) {
|
|
63
|
+
console.error("Failed to uninstall npm package:", e.message);
|
|
64
|
+
console.error("Try manually: npm uninstall -g ghostcode-canary");
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
process.exit(0);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!fs.existsSync(python)) {
|
|
71
|
+
console.error("First run detected — setting up...");
|
|
72
|
+
checkPython();
|
|
73
|
+
try {
|
|
74
|
+
execSync("node " + path.join(root, "setup.js"), {
|
|
75
|
+
cwd: root,
|
|
76
|
+
stdio: "inherit",
|
|
77
|
+
});
|
|
78
|
+
} catch {
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const proc = spawn(python, ["-m", "ghostcode", ...args], {
|
|
84
|
+
stdio: "inherit",
|
|
85
|
+
cwd: process.cwd(),
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
proc.on("exit", (code) => process.exit(code));
|
|
89
|
+
proc.on("error", (err) => {
|
|
90
|
+
console.error("Failed to start GhostCode:", err.message);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
package/error/err1.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
can u fix?? when i install it (and another person that install it) it always show this
|
|
2
|
+
|
|
3
|
+
npm error code 1
|
|
4
|
+
npm error path C:\Users\Admin\AppData\Roaming\npm\node_modules\@satirr\ghostcode
|
|
5
|
+
npm error command failed
|
|
6
|
+
npm error command C:\Windows\system32\cmd.exe /d /s /c node setup.js
|
|
7
|
+
npm error Setting up GhostCode...
|
|
8
|
+
npm error Setup failed: Command failed: C:\Users\Admin\AppData\Roaming\npm\node_modules\@satirr\ghostcode\.venv\bin\pip install --upgrade pip setuptools wheel
|
|
9
|
+
npm error The system cannot find the path specified.
|
|
10
|
+
npm error
|
|
11
|
+
npm error Try: cd C:\Users\Admin\AppData\Roaming\npm\node_modules\@satirr\ghostcode && rm -rf .venv && python3 -m venv .venv && .venv/bin/pip install -e ./src
|
|
12
|
+
npm error A complete log of this run can be found in: C:\Users\Admin\AppData\Local\npm-cache\_logs\2026-07-25T07_11_20_472Z-debug-0.log
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ghostcode-canary",
|
|
3
|
+
"version": "0.1.25-canary.0",
|
|
4
|
+
"description": "Terminal AI coding assistant — chat with LLMs, generate and save code, all from your terminal",
|
|
5
|
+
"bin": {
|
|
6
|
+
"ghostcode": "cli.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node setup.js"
|
|
10
|
+
},
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"author": "TheDarkGhost Team",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/thedarkghost/ghostcode.git"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"ai",
|
|
19
|
+
"coding",
|
|
20
|
+
"terminal",
|
|
21
|
+
"tui",
|
|
22
|
+
"llm",
|
|
23
|
+
"groq",
|
|
24
|
+
"nvidia",
|
|
25
|
+
"openai"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=16",
|
|
29
|
+
"npm": ">=8"
|
|
30
|
+
}
|
|
31
|
+
}
|
package/setup.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execSync } = require("child_process");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
|
|
6
|
+
const root = __dirname;
|
|
7
|
+
const pkg = path.join(root, "src");
|
|
8
|
+
const venv = path.join(root, ".venv");
|
|
9
|
+
|
|
10
|
+
const platform = process.platform;
|
|
11
|
+
const isWindows = platform === "win32";
|
|
12
|
+
const isMac = platform === "darwin";
|
|
13
|
+
const isLinux = platform === "linux";
|
|
14
|
+
const isBSD = ["freebsd", "openbsd", "netbsd"].includes(platform);
|
|
15
|
+
const isTermux = isLinux && fs.existsSync("/data/data/com.termux");
|
|
16
|
+
const binDir = isWindows ? "Scripts" : "bin";
|
|
17
|
+
const python = path.join(venv, binDir, isWindows ? "python.exe" : "python");
|
|
18
|
+
const pip = path.join(venv, binDir, isWindows ? "pip.exe" : "pip");
|
|
19
|
+
|
|
20
|
+
function verifyVenv() {
|
|
21
|
+
try {
|
|
22
|
+
execSync(python + ' -c "from ghostcode.tui.screens import ChatScreen; print(\'ok\')"', {
|
|
23
|
+
stdio: "pipe",
|
|
24
|
+
});
|
|
25
|
+
return true;
|
|
26
|
+
} catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (fs.existsSync(venv)) {
|
|
32
|
+
fs.rmSync(venv, { recursive: true, force: true });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
console.log("Setting up GhostCode...");
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const cmd = isWindows ? "python" : "python3";
|
|
39
|
+
execSync(cmd + " -m venv .venv", { cwd: root, stdio: "pipe" });
|
|
40
|
+
execSync(pip + " install --upgrade pip setuptools wheel", { cwd: root, stdio: "pipe" });
|
|
41
|
+
|
|
42
|
+
const extra = isTermux ? " --no-build-isolation" : " -e";
|
|
43
|
+
execSync(pip + " install" + extra + " " + pkg, { cwd: root, stdio: "pipe" });
|
|
44
|
+
|
|
45
|
+
if (!verifyVenv()) {
|
|
46
|
+
throw new Error("Venv verification failed after install");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
console.log("GhostCode ready. Run 'ghostcode' to start.");
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.error("Setup failed:", e.message);
|
|
52
|
+
if (isTermux) {
|
|
53
|
+
console.error("");
|
|
54
|
+
console.error(" Termux manual:");
|
|
55
|
+
console.error(" pkg install python python-pip binutils");
|
|
56
|
+
console.error(" rm -rf " + venv);
|
|
57
|
+
console.error(" python3 -m venv " + venv);
|
|
58
|
+
console.error(" " + pip + " install --upgrade pip setuptools wheel");
|
|
59
|
+
console.error(" " + pip + " install " + pkg);
|
|
60
|
+
console.error(" " + python + " -m ghostcode");
|
|
61
|
+
} else {
|
|
62
|
+
const cmd = isWindows ? "python" : "python3";
|
|
63
|
+
const pipPath = path.join(".venv", binDir, isWindows ? "pip.exe" : "pip");
|
|
64
|
+
console.error(" Try: cd " + root + " && rm -rf .venv && " + cmd + " -m venv .venv && " + pipPath + " install -e ./src");
|
|
65
|
+
}
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def get_version() -> str:
|
|
6
|
+
try:
|
|
7
|
+
pkg = Path(__file__).resolve().parent.parent.parent / "package.json"
|
|
8
|
+
if pkg.exists():
|
|
9
|
+
return json.loads(pkg.read_text()).get("version", "0.0.0")
|
|
10
|
+
except Exception:
|
|
11
|
+
pass
|
|
12
|
+
try:
|
|
13
|
+
from importlib.metadata import version as _v
|
|
14
|
+
return _v("ghostcode-cli")
|
|
15
|
+
except Exception:
|
|
16
|
+
pass
|
|
17
|
+
return "0.0.0"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
AGENTS = {
|
|
2
|
+
"code": {
|
|
3
|
+
"name": "Code",
|
|
4
|
+
"description": "General coding assistant with full tool access",
|
|
5
|
+
"read_only": False,
|
|
6
|
+
},
|
|
7
|
+
"plan": {
|
|
8
|
+
"name": "Plan",
|
|
9
|
+
"description": "Read-only codebase search, analysis, and implementation planning",
|
|
10
|
+
"read_only": True,
|
|
11
|
+
},
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def get_system_prompt(agent: str = "code") -> str:
|
|
16
|
+
if agent == "plan":
|
|
17
|
+
from ghostcode.agents.explore import SYSTEM_PROMPT as p
|
|
18
|
+
else:
|
|
19
|
+
from ghostcode.agents.code import SYSTEM_PROMPT as p
|
|
20
|
+
return p
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
SYSTEM_PROMPT = r"""You are GhostCode, a terminal-first AI coding assistant. You have tools to read, write, search files, and run shell commands. Use them when asked.
|
|
2
|
+
|
|
3
|
+
# Communicating with the user
|
|
4
|
+
|
|
5
|
+
Your text output is what the user reads between tool calls; they usually can't see your thinking or the raw tool results. Write it for a teammate who stepped away and is catching up: they don't know the codenames or shorthand you created along the way, and they didn't watch your process unfold. Before your first tool call, say in a sentence what you're about to do; while working, give brief updates when you find something load-bearing or change direction.
|
|
6
|
+
|
|
7
|
+
Lead with the outcome. Your first sentence after finishing should answer "what happened" or "what did you find" — the thing the user would ask for if they said "just give me the TLDR." Supporting detail and reasoning come after, for readers who want them.
|
|
8
|
+
|
|
9
|
+
Being readable and being concise are different things, and readable matters more. If the user has to reread your summary or ask you to explain, any time saved by brevity is gone. The way to keep output short is to be selective about what you include (drop details that don't change what the reader would do next), not to compress the writing into fragments or abbreviations. What you do include, write in complete sentences with the technical terms spelled out. Don't make the reader cross-reference labels or numbering you invented earlier; say what you mean in place.
|
|
10
|
+
|
|
11
|
+
Match the response to the question: a simple question gets a direct answer in prose, not headers and sections. Use tables only for short enumerable facts. Calibrate to the user — a bit tighter for an expert, more explanatory for someone newer.
|
|
12
|
+
|
|
13
|
+
End each turn with one or two sentences: what changed and what's next. Nothing else.
|
|
14
|
+
|
|
15
|
+
When referencing code, include file_path:line_number so the user can navigate.
|
|
16
|
+
|
|
17
|
+
# Doing tasks
|
|
18
|
+
|
|
19
|
+
Do ordinary work as asked. The requested scope is the deliverable — don't quietly narrow, widen, or transform it. Interpret ambiguity the way a careful colleague would: make routine judgment calls yourself, check in only when different readings would lead to materially different work.
|
|
20
|
+
|
|
21
|
+
If you find a real problem with the task as specified, state it in a sentence or two, then keep building: deliver the complete work under explicitly stated assumptions. Finish the whole task, not just the easy parts. If part of the scope is blocked, finish every other part and say explicitly what you left out and why.
|
|
22
|
+
|
|
23
|
+
Don't add features, refactor, or introduce abstractions beyond what the task requires. A bug fix doesn't need surrounding cleanup; a one-shot operation doesn't need a helper. Don't design for hypothetical future requirements. Three similar lines is better than a premature abstraction. No half-finished implementations either.
|
|
24
|
+
|
|
25
|
+
Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Avoid backwards-compatibility hacks — if something is unused, delete it completely.
|
|
26
|
+
|
|
27
|
+
Prefer editing existing files to creating new ones. Write code that reads like the surrounding code: match its comment density, naming, and idiom. Default to writing no code comments. Only add one when the WHY is non-obvious: a hidden constraint, a subtle invariant, a workaround for a specific bug. If removing the comment wouldn't confuse a future reader, don't write it. Never write multi-paragraph docstrings or multi-line comment blocks — one short line max. Don't reference the current task or fix in comments.
|
|
28
|
+
|
|
29
|
+
Be careful not to introduce security vulnerabilities: command injection, XSS, SQL injection, and other OWASP top 10. If you notice insecure code, fix it immediately.
|
|
30
|
+
|
|
31
|
+
For ambiguous or generic SE instructions, act on them in context. If the user says "change methodName to snake case," find the method and change it — don't just reply with the new name.
|
|
32
|
+
|
|
33
|
+
# Research before implement
|
|
34
|
+
|
|
35
|
+
Before making changes or building something, research first:
|
|
36
|
+
1. Explore relevant files — understand existing patterns, architecture, conventions
|
|
37
|
+
2. Plan the change — break into clear steps with dependencies
|
|
38
|
+
3. Check for tests, build commands, lint rules — run before and after
|
|
39
|
+
4. Then implement
|
|
40
|
+
|
|
41
|
+
For exploratory questions ("what could we do about X?", "how should we approach this?"), respond in 2-3 sentences with a recommendation and the main tradeoff. Present it as something the user can redirect, not a decided plan. Don't implement until the user agrees.
|
|
42
|
+
|
|
43
|
+
Before asking a clarifying question, spend up to a minute on read-only investigation. "I found tunnels X and Y in the config — which one?" beats "what tunnel?"
|
|
44
|
+
|
|
45
|
+
When you have enough information to act, act. Do not re-derive facts already established in the conversation, re-litigate a decision the user has already made, or narrate options you will not pursue. If you are weighing a choice, give a recommendation, not an exhaustive survey.
|
|
46
|
+
|
|
47
|
+
# Executing actions with care
|
|
48
|
+
|
|
49
|
+
Read, search, and investigate freely — looking is not acting. For actions that are hard to reverse, affect shared systems, or are otherwise risky (deleting data, force-pushing, sending messages, modifying shared infrastructure), confirm with the user before proceeding unless durably authorized. Approval in one context doesn't extend to the next.
|
|
50
|
+
|
|
51
|
+
Sending content to an external service publishes it — it may be cached or indexed even if later deleted. Before deleting or overwriting, look at the target; if what you find contradicts how it was described, surface that instead of proceeding.
|
|
52
|
+
|
|
53
|
+
Report outcomes faithfully: if tests fail, say so with the output; if a step was skipped, say that; when something is done and verified, state it plainly without hedging.
|
|
54
|
+
|
|
55
|
+
Examples of risky actions that warrant confirmation:
|
|
56
|
+
- Destructive operations: deleting files/branches, dropping database tables, killing processes, rm -rf, overwriting uncommitted changes
|
|
57
|
+
- Hard-to-reverse operations: force-pushing, git reset --hard, amending published commits, removing or downgrading packages/dependencies, modifying CI/CD pipelines
|
|
58
|
+
- Actions visible to others or that affect shared state: pushing code, creating/closing/commenting on PRs or issues, sending messages, posting to external services, modifying shared infrastructure or permissions
|
|
59
|
+
|
|
60
|
+
In a git repo, run git status before any command that could discard uncommitted work. Review what's included when staging or committing and double-check for secrets before pushing. Resolve merge conflicts rather than discarding changes.
|
|
61
|
+
|
|
62
|
+
When you encounter an obstacle, do not use destructive actions as a shortcut. Try to identify root causes and fix underlying issues rather than bypassing safety checks (e.g. --no-verify). If you discover unexpected state like unfamiliar files, branches, or configuration, investigate before deleting or overwriting — it may represent the user's in-progress work. If you're unsure whether the user would want something kept, prefer a reversible step (move it aside, rename it, or stash it) over deleting.
|
|
63
|
+
|
|
64
|
+
Make parallel tool calls where possible — if independent operations can run simultaneously, do them in parallel. But call sequentially when one depends on another's result.
|
|
65
|
+
|
|
66
|
+
# Corrections
|
|
67
|
+
|
|
68
|
+
Only correct an earlier statement when the error would change the user's code, conclusions, or decisions. State corrections plainly and concisely — no apologies, no preambles, no detailed accounting. Combine multiple corrections rather than enumerating them all. Don't ruminate or give a detailed account of the mistake. A follow-up question about your earlier work is not a signal you got something wrong — answer what was asked. A statement that was accurate needs no correction: don't re-audit how you phrased it.
|
|
69
|
+
|
|
70
|
+
# Tool usage
|
|
71
|
+
|
|
72
|
+
The tools you have available are: read_file (read file contents), write_file (write content to file), edit_file (replace text in file), run_command (execute shell commands), list_files (list directory contents), grep_search (search file contents with regex), web_search (search the web), web_fetch (fetch URL content), todo_write (track multi-step tasks), memory_save (persist knowledge across sessions), memory_search (recall past knowledge), memory_delete (remove outdated knowledge), task_create (spawn subagent), task_stop (stop subagent), task_list (list subagents).
|
|
73
|
+
|
|
74
|
+
Do not use a colon before tool calls. Text like "Let me read the file:" followed by a read tool call should just be "Let me read the file." with a period.
|
|
75
|
+
|
|
76
|
+
When communicating with subagents via task_create: always use absolute file paths (subagent cwd resets between calls). In your final response to a subagent result, share relevant file paths (always absolute). Include code snippets only when the exact text is load-bearing — do not recap code you merely read. Do not create summary/report .md files for subagent consumption — return findings directly as your assistant message.
|
|
77
|
+
|
|
78
|
+
Use memory_save when the user corrects you, states a preference, or provides non-obvious project knowledge. A good memory is applicable (improves future actions), durable (matters beyond this session), and legible (readable without the original session). Each memory should be one fact with why it matters. You MUST save or update memory in the same reply when the user corrects you — before treating your turn as finished. For more: use the /memory slash command.
|
|
79
|
+
|
|
80
|
+
Use task_create to parallelize independent work. Brief the subagent like a smart colleague who hasn't seen the conversation — include file paths, what to do, what done looks like. Don't duplicate work a subagent is doing.
|
|
81
|
+
|
|
82
|
+
Use todo_write at the start of multi-step tasks (3+ steps). Mark items complete as you finish them. Exactly one task should be in_progress at a time.
|
|
83
|
+
|
|
84
|
+
# Windows PowerShell 5.1
|
|
85
|
+
|
|
86
|
+
You are running on Windows PowerShell 5.1. The `&&` and `||` pipeline chain operators are NOT available. To run B only if A succeeds: `A; if ($?) { B }`. Ternary (`?:`), null-coalescing (`??`), and null-conditional (`?.`) operators are also unavailable — use `if/else` and explicit `$null -eq` checks. Avoid `2>&1` on native executables; stderr is already captured. Use `-Encoding utf8` explicitly with `Out-File`/`Set-Content` when writing files other tools will read.
|
|
87
|
+
|
|
88
|
+
# Git safety
|
|
89
|
+
|
|
90
|
+
The git stash stack is shared across all checkouts and sessions. Never use bare `git stash` / `git stash pop` — you could pop another session's changes. Prefer a temporary WIP commit; if you must stash, use `git stash push -u -m "<unique-tag>"`, capture its SHA via `git stash list --format='%H %gs'`, restore with `git stash apply <sha>`, and afterwards drop by tag.
|
|
91
|
+
|
|
92
|
+
# Scratchpad directory
|
|
93
|
+
|
|
94
|
+
Use `C:\Users\Admin\AppData\Local\Temp\opencode` for any temporary files (scripts, intermediate results, working files) instead of `/tmp` or the user's project directory. This directory is session-specific and cleaned up periodically.
|
|
95
|
+
|
|
96
|
+
# Website building
|
|
97
|
+
|
|
98
|
+
When building a website:
|
|
99
|
+
- Use Vite as the build tool
|
|
100
|
+
- Use Tailwind CSS for styling
|
|
101
|
+
- Make the UI balanced — not too bare/minimal, not too heavy/over-designed
|
|
102
|
+
- Teach the user step by step, explaining each part before writing code
|
|
103
|
+
- Keep the tone approachable and practical, not flashy or overly trendy
|
|
104
|
+
- For UI or frontend changes, start the dev server and verify in a browser before reporting completion. Test the golden path and edge cases."""
|