@dcode-dev/dcode-cli 1.0.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/NPM_README.md +78 -0
- package/README.md +341 -0
- package/bin/dcode-bin +0 -0
- package/bin/dcode.js +44 -0
- package/cmd/agent_v2.go +448 -0
- package/cmd/analyze.go +97 -0
- package/cmd/auth.go +338 -0
- package/cmd/compose.go +284 -0
- package/cmd/context.go +111 -0
- package/cmd/edit.go +116 -0
- package/cmd/env.go +10 -0
- package/cmd/fix.go +145 -0
- package/cmd/gemini.go +20 -0
- package/cmd/generate.go +47 -0
- package/cmd/interactive.go +33 -0
- package/cmd/mcp.go +196 -0
- package/cmd/patch.go +19 -0
- package/cmd/providers.go +67 -0
- package/cmd/root.go +41 -0
- package/cmd/search.go +61 -0
- package/cmd/server.go +36 -0
- package/cmd/switch.go +122 -0
- package/cmd/terminal.go +277 -0
- package/go.mod +42 -0
- package/go.sum +86 -0
- package/internal/agent/agent.go +332 -0
- package/internal/agent/parse.go +25 -0
- package/internal/agents/base.go +154 -0
- package/internal/agents/documenter.go +77 -0
- package/internal/agents/generalist.go +266 -0
- package/internal/agents/investigator.go +60 -0
- package/internal/agents/registry.go +34 -0
- package/internal/agents/reviewer.go +67 -0
- package/internal/agents/tester.go +73 -0
- package/internal/ai/client.go +634 -0
- package/internal/ai/tools.go +332 -0
- package/internal/auth/adc.go +108 -0
- package/internal/auth/apikey.go +67 -0
- package/internal/auth/factory.go +145 -0
- package/internal/auth/oauth2.go +227 -0
- package/internal/auth/store.go +216 -0
- package/internal/auth/types.go +79 -0
- package/internal/auth/vertex.go +138 -0
- package/internal/config/config.go +428 -0
- package/internal/config/policy.go +251 -0
- package/internal/context/builder.go +312 -0
- package/internal/detector/detector.go +204 -0
- package/internal/diffutil/diffutil.go +30 -0
- package/internal/fsutil/fsutil.go +35 -0
- package/internal/mcp/client.go +314 -0
- package/internal/mcp/manager.go +221 -0
- package/internal/policy/policy.go +89 -0
- package/internal/prompt/interactive.go +338 -0
- package/internal/registry/agent.go +201 -0
- package/internal/registry/tool.go +181 -0
- package/internal/scheduler/scheduler.go +250 -0
- package/internal/server/server.go +167 -0
- package/internal/tools/file.go +183 -0
- package/internal/tools/filesystem.go +286 -0
- package/internal/tools/git.go +355 -0
- package/internal/tools/memory.go +269 -0
- package/internal/tools/registry.go +49 -0
- package/internal/tools/search.go +230 -0
- package/internal/tools/shell.go +84 -0
- package/internal/websearch/search.go +40 -0
- package/internal/websearch/tavily.go +79 -0
- package/main.go +19 -0
- package/package.json +57 -0
- package/scripts/install.js +59 -0
- package/scripts/uninstall.js +28 -0
package/NPM_README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# DCode CLI
|
|
2
|
+
|
|
3
|
+
AI-powered coding assistant for developers.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### Global Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @dcode/dcode-cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Prerequisites
|
|
14
|
+
|
|
15
|
+
- **Go 1.21+** - Required to build the binary
|
|
16
|
+
- **Node.js 14+** - Required for npm package
|
|
17
|
+
- **Gemini API Key** - Get from [Google AI Studio](https://makersuite.google.com/app/apikey)
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
After installation:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Start DCode
|
|
25
|
+
dcode
|
|
26
|
+
|
|
27
|
+
# Or use specific agent
|
|
28
|
+
dcode --agent generalist
|
|
29
|
+
|
|
30
|
+
# With custom provider
|
|
31
|
+
dcode --provider gemini --model gemini-pro
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
- 🤖 AI-powered code generation and editing
|
|
37
|
+
- 📝 Intelligent file operations
|
|
38
|
+
- 🔍 Smart code search
|
|
39
|
+
- 🎨 Typewriter animation for responses
|
|
40
|
+
- 🛠️ Extensible tool system
|
|
41
|
+
- 💾 Persistent memory
|
|
42
|
+
- 🔄 Git integration
|
|
43
|
+
|
|
44
|
+
## Configuration
|
|
45
|
+
|
|
46
|
+
Set your API key:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
export GEMINI_API_KEY="your-api-key-here"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Or configure in `~/.dcode/config.yaml`
|
|
53
|
+
|
|
54
|
+
## Development
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Clone repository
|
|
58
|
+
git clone https://github.com/ddhanush1/dcode.git
|
|
59
|
+
cd dcode
|
|
60
|
+
|
|
61
|
+
# Install dependencies
|
|
62
|
+
npm install
|
|
63
|
+
|
|
64
|
+
# Build
|
|
65
|
+
npm run build
|
|
66
|
+
|
|
67
|
+
# Test
|
|
68
|
+
npm test
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT
|
|
74
|
+
|
|
75
|
+
## Support
|
|
76
|
+
|
|
77
|
+
- Issues: https://github.com/ddhanush1/dcode/issues
|
|
78
|
+
- Docs: https://github.com/ddhanush1/dcode#readme
|
package/README.md
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
# DCode - Cursor-Like AI Coding Agent
|
|
2
|
+
|
|
3
|
+
🚀 **Transform your coding workflow with AI-powered assistance** - Like Cursor, but open-source and multi-provider!
|
|
4
|
+
|
|
5
|
+
**✨ NEW: Automatic Project Intelligence!** DCode now automatically detects your project type, indexes relevant files, and provides context-aware assistance. No configuration needed!
|
|
6
|
+
|
|
7
|
+
[](https://go.dev/)
|
|
8
|
+
[](https://code.visualstudio.com/)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
|
|
11
|
+
## 🎯 What Makes DCode Special?
|
|
12
|
+
|
|
13
|
+
### 🧠 **Intelligent & Context-Aware** (NEW!)
|
|
14
|
+
- **Auto-detects** your programming language and framework
|
|
15
|
+
- **Indexes** relevant files automatically (Go, Python, JS/TS, Rust, Java, etc.)
|
|
16
|
+
- **Prioritizes** important files (entry points, configs, README)
|
|
17
|
+
- **Understands** your project structure instantly
|
|
18
|
+
- **No configuration required** - just run `dcode agent` and go!
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
$ cd ~/my-django-app
|
|
22
|
+
$ dcode agent
|
|
23
|
+
✨ DCode AI Agent
|
|
24
|
+
Analyzing project... ✓
|
|
25
|
+
Project: python (django) | 127 files indexed
|
|
26
|
+
›
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## ✨ Features
|
|
30
|
+
|
|
31
|
+
### 🎯 Cursor-Like Experience
|
|
32
|
+
- **Inline Chat** (Ctrl+K) - Edit code directly in your editor
|
|
33
|
+
- **Composer Mode** - Multi-file generation and editing
|
|
34
|
+
- **Smart Context** - Auto-detect relevant files
|
|
35
|
+
- **Code Actions** - Right-click to fix, explain, refactor, or test
|
|
36
|
+
- **Terminal Integration** - Natural language to shell commands
|
|
37
|
+
|
|
38
|
+
### 🤖 AI Capabilities
|
|
39
|
+
- **Multi-Provider Support**: OpenAI (GPT-4), Claude, Gemini
|
|
40
|
+
- **Web Search**: Integrated Tavily search for up-to-date info
|
|
41
|
+
- **Context-Aware**: Understands your entire codebase
|
|
42
|
+
- **Streaming Responses**: Real-time AI feedback
|
|
43
|
+
- **Vision Support**: Analyze images and screenshots
|
|
44
|
+
|
|
45
|
+
### 💻 CLI Power Tools
|
|
46
|
+
```bash
|
|
47
|
+
# Interactive agent with chat
|
|
48
|
+
dcode agent
|
|
49
|
+
|
|
50
|
+
# Composer - Multi-file edits
|
|
51
|
+
dcode compose "Create a REST API with authentication"
|
|
52
|
+
|
|
53
|
+
# Context management
|
|
54
|
+
dcode context analyze
|
|
55
|
+
|
|
56
|
+
# Terminal assistance
|
|
57
|
+
dcode terminal "find all TODO comments"
|
|
58
|
+
|
|
59
|
+
# Edit files
|
|
60
|
+
dcode edit --file main.go --prompt "Add logging"
|
|
61
|
+
|
|
62
|
+
# Fix problems
|
|
63
|
+
dcode fix --file api.go
|
|
64
|
+
|
|
65
|
+
# Web search
|
|
66
|
+
dcode search "Go context best practices"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 🎨 VS Code Extension
|
|
70
|
+
- **Chat Panel**: Persistent conversation with your codebase
|
|
71
|
+
- **Inline Chat**: Quick edits without leaving your code
|
|
72
|
+
- **Code Actions**: AI-powered quick fixes and refactorings
|
|
73
|
+
- **Composer**: Generate entire features
|
|
74
|
+
- **Context Menu**: Right-click for AI assistance
|
|
75
|
+
|
|
76
|
+
## 🚀 Quick Start
|
|
77
|
+
|
|
78
|
+
### 1. Installation
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Clone the repository
|
|
82
|
+
git clone https://github.com/yourusername/dcode.git
|
|
83
|
+
cd dcode
|
|
84
|
+
|
|
85
|
+
# Install dependencies
|
|
86
|
+
go mod download
|
|
87
|
+
|
|
88
|
+
# Build CLI
|
|
89
|
+
go build -o dcode main.go
|
|
90
|
+
|
|
91
|
+
# Make it available globally (optional)
|
|
92
|
+
sudo mv dcode /usr/local/bin/
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 2. Configuration
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Create config file
|
|
99
|
+
cp .env.example .env
|
|
100
|
+
|
|
101
|
+
# Edit .env and add your API key
|
|
102
|
+
AI_PROVIDER=openai # or: claude, gemini
|
|
103
|
+
OPENAI_API_KEY=sk-... # your API key
|
|
104
|
+
AI_MODEL=gpt-4 # optional: specific model
|
|
105
|
+
|
|
106
|
+
# Optional: Web search
|
|
107
|
+
WEB_SEARCH_PROVIDER=tavily
|
|
108
|
+
TAVILY_API_KEY=tvly-...
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 3. Start Using
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Interactive agent with automatic project detection
|
|
115
|
+
dcode agent
|
|
116
|
+
|
|
117
|
+
# Analyze your project
|
|
118
|
+
dcode context analyze
|
|
119
|
+
|
|
120
|
+
# Or start with a prompt
|
|
121
|
+
dcode compose "Create a todo list API"
|
|
122
|
+
|
|
123
|
+
# Get help
|
|
124
|
+
dcode --help
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**NEW:** When you run `dcode agent`, it automatically:
|
|
128
|
+
- Detects your language (Go, Python, JS, etc.)
|
|
129
|
+
- Identifies your framework (Django, React, Gin, etc.)
|
|
130
|
+
- Indexes relevant files
|
|
131
|
+
- Shows you what it understands about your project!
|
|
132
|
+
|
|
133
|
+
### 4. VS Code Extension
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
cd vscode-extension
|
|
137
|
+
npm install
|
|
138
|
+
npm run compile
|
|
139
|
+
|
|
140
|
+
# Then in VS Code:
|
|
141
|
+
# 1. Press F5 to open Extension Development Host
|
|
142
|
+
# 2. Start DCode server: Cmd+Shift+P → "DCode: Start Local Server"
|
|
143
|
+
# 3. Use Ctrl+K for inline chat, or Cmd+Shift+L for chat panel
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## 📖 Usage Examples
|
|
147
|
+
|
|
148
|
+
### Composer Mode
|
|
149
|
+
```bash
|
|
150
|
+
# Create entire features
|
|
151
|
+
dcode compose "Add user authentication with JWT tokens"
|
|
152
|
+
|
|
153
|
+
# Multi-file refactoring
|
|
154
|
+
dcode compose --files "*.go" "Add structured logging everywhere"
|
|
155
|
+
|
|
156
|
+
# Generate with context
|
|
157
|
+
dcode compose "Create tests for all API endpoints"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Interactive Agent
|
|
161
|
+
```bash
|
|
162
|
+
dcode agent
|
|
163
|
+
|
|
164
|
+
# In the agent:
|
|
165
|
+
› /project # View project overview (NEW!)
|
|
166
|
+
› /edit main.go "add error handling"
|
|
167
|
+
› @utils.go how does this work?
|
|
168
|
+
› /fix api.go
|
|
169
|
+
› /search "golang context cancellation"
|
|
170
|
+
› /web on
|
|
171
|
+
› /help
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**NEW `/project` command** shows what DCode understands about your codebase:
|
|
175
|
+
- Language & framework
|
|
176
|
+
- Entry points
|
|
177
|
+
- Key files ranked by importance
|
|
178
|
+
- File type breakdown
|
|
179
|
+
|
|
180
|
+
### Terminal Integration
|
|
181
|
+
```bash
|
|
182
|
+
# Natural language → shell commands
|
|
183
|
+
dcode terminal "list all go files modified today"
|
|
184
|
+
dcode cmd "create a git branch for feature X"
|
|
185
|
+
dcode run "install dependencies for this project"
|
|
186
|
+
|
|
187
|
+
# With dry-run
|
|
188
|
+
dcode terminal --dry-run "delete all .log files"
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Context Management
|
|
192
|
+
```bash
|
|
193
|
+
# Analyze project structure (auto-detects language & framework)
|
|
194
|
+
dcode context analyze
|
|
195
|
+
|
|
196
|
+
# List files by relevance (shows importance scores)
|
|
197
|
+
dcode context list
|
|
198
|
+
|
|
199
|
+
# Clear context cache
|
|
200
|
+
dcode context clear
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Output Example:**
|
|
204
|
+
```
|
|
205
|
+
🔍 Analyzing project...
|
|
206
|
+
|
|
207
|
+
# Project Overview
|
|
208
|
+
|
|
209
|
+
**Language:** go
|
|
210
|
+
**Framework:** gin
|
|
211
|
+
**Build System:** go.mod
|
|
212
|
+
**Total Files:** 28
|
|
213
|
+
|
|
214
|
+
**Entry Points:**
|
|
215
|
+
- main.go
|
|
216
|
+
|
|
217
|
+
**Key Files (by relevance):**
|
|
218
|
+
- main.go (100.0%)
|
|
219
|
+
- README.md (95.0%)
|
|
220
|
+
- go.mod (90.0%)
|
|
221
|
+
...
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## 🎯 VS Code Keybindings
|
|
225
|
+
|
|
226
|
+
| Command | Keybinding | Description |
|
|
227
|
+
|---------|------------|-------------|
|
|
228
|
+
| Inline Chat | `Ctrl+K` / `Cmd+K` | Edit code inline |
|
|
229
|
+
| Chat Panel | `Ctrl+Shift+L` / `Cmd+Shift+L` | Open chat |
|
|
230
|
+
| Composer | `Ctrl+Shift+I` / `Cmd+Shift+I` | Multi-file composer |
|
|
231
|
+
|
|
232
|
+
## 🏗️ Architecture
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
dcode/
|
|
236
|
+
├── cmd/ # CLI commands
|
|
237
|
+
│ ├── agent.go # Interactive agent
|
|
238
|
+
│ ├── compose.go # Composer mode
|
|
239
|
+
│ ├── context.go # Context management
|
|
240
|
+
│ ├── terminal.go # Terminal integration
|
|
241
|
+
│ ├── edit.go # File editing
|
|
242
|
+
│ ├── fix.go # Error fixing
|
|
243
|
+
│ └── server.go # HTTP server
|
|
244
|
+
│
|
|
245
|
+
├── internal/ # Core packages
|
|
246
|
+
│ ├── agent/ # AI agent logic
|
|
247
|
+
│ ├── ai/ # AI provider clients
|
|
248
|
+
│ ├── server/ # HTTP API server
|
|
249
|
+
│ ├── analyzer/ # Code analysis
|
|
250
|
+
│ ├── websearch/ # Web search integration
|
|
251
|
+
│ └── ...
|
|
252
|
+
│
|
|
253
|
+
└── vscode-extension/ # VS Code extension
|
|
254
|
+
├── src/
|
|
255
|
+
│ ├── extension.ts # Main extension
|
|
256
|
+
│ ├── inlineChat.ts # Inline chat (Ctrl+K)
|
|
257
|
+
│ ├── chatPanel.ts # Chat sidebar
|
|
258
|
+
│ └── codeActions.ts # Quick fixes
|
|
259
|
+
└── package.json
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## 🔧 Configuration
|
|
263
|
+
|
|
264
|
+
### Environment Variables
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
# AI Provider (required)
|
|
268
|
+
AI_PROVIDER=openai # openai | claude | gemini
|
|
269
|
+
OPENAI_API_KEY=sk-... # Your API key
|
|
270
|
+
AI_MODEL=gpt-4 # Optional: specific model
|
|
271
|
+
|
|
272
|
+
# Claude
|
|
273
|
+
CLAUDE_API_KEY=sk-ant-...
|
|
274
|
+
AI_MODEL=claude-3-5-sonnet-20241022
|
|
275
|
+
|
|
276
|
+
# Gemini
|
|
277
|
+
GEMINI_API_KEY=...
|
|
278
|
+
AI_MODEL=gemini-2.0-flash-exp
|
|
279
|
+
|
|
280
|
+
# Web Search (optional)
|
|
281
|
+
WEB_SEARCH_PROVIDER=tavily
|
|
282
|
+
TAVILY_API_KEY=tvly-...
|
|
283
|
+
|
|
284
|
+
# Server (optional)
|
|
285
|
+
PORT=8765
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### VS Code Settings
|
|
289
|
+
|
|
290
|
+
```json
|
|
291
|
+
{
|
|
292
|
+
"dcode.serverUrl": "http://127.0.0.1:8765",
|
|
293
|
+
"dcode.serverCommand": "dcode server",
|
|
294
|
+
"dcode.autoStart": false,
|
|
295
|
+
"dcode.enableWebSearch": false
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## 🆚 DCode vs Cursor
|
|
300
|
+
|
|
301
|
+
| Feature | DCode | Cursor |
|
|
302
|
+
|---------|-------|--------|
|
|
303
|
+
| **Open Source** | ✅ | ❌ |
|
|
304
|
+
| **Multi-Provider** | ✅ (OpenAI, Claude, Gemini) | ❌ (OpenAI only) |
|
|
305
|
+
| **Auto Project Detection** | ✅ 10+ languages | ⚠️ Limited |
|
|
306
|
+
| **Context Intelligence** | ✅ Smart file ranking | ✅ |
|
|
307
|
+
| **Local Models** | ✅ (via API) | ❌ |
|
|
308
|
+
| **CLI** | ✅ Full-featured | ❌ |
|
|
309
|
+
| **Web Search** | ✅ Built-in | ❌ |
|
|
310
|
+
| **Self-Hosted** | ✅ | ❌ |
|
|
311
|
+
| **Price** | Free (API costs only) | Subscription |
|
|
312
|
+
| **Customizable** | ✅ Fully | ⚠️ Limited |
|
|
313
|
+
|
|
314
|
+
## 🤝 Contributing
|
|
315
|
+
|
|
316
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
|
317
|
+
|
|
318
|
+
## 📝 License
|
|
319
|
+
|
|
320
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
321
|
+
|
|
322
|
+
## 🙏 Acknowledgments
|
|
323
|
+
|
|
324
|
+
- Inspired by [Cursor](https://cursor.sh/) and [Aider](https://aider.chat/)
|
|
325
|
+
- Built with [Cobra](https://github.com/spf13/cobra) and VS Code Extension API
|
|
326
|
+
|
|
327
|
+
## 📚 Documentation
|
|
328
|
+
|
|
329
|
+
- **[Quick Start (Enhanced)](QUICK_START_ENHANCED.md)** - Get started with new intelligence features
|
|
330
|
+
- **[Project Intelligence Guide](PROJECT_INTELLIGENCE_IMPROVEMENTS.md)** - Deep dive into auto-detection
|
|
331
|
+
- **[Quick Start Guide](QUICKSTART.md)** - Basic setup
|
|
332
|
+
- **[Usage Guide](USAGE_GUIDE.md)** - Complete command reference
|
|
333
|
+
- **[Enhancement Plan](CURSOR_ENHANCEMENT_PLAN.md)** - Roadmap & future features
|
|
334
|
+
|
|
335
|
+
## 🐛 Issues & Support
|
|
336
|
+
|
|
337
|
+
Found a bug or have a feature request? Please open an issue on [GitHub](https://github.com/yourusername/dcode/issues).
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
**Made with ❤️ by the DCode team**
|
package/bin/dcode-bin
ADDED
|
Binary file
|
package/bin/dcode.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* DCode CLI wrapper
|
|
5
|
+
* This script launches the Go binary with the appropriate platform executable
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const { spawn } = require('child_process');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const os = require('os');
|
|
11
|
+
|
|
12
|
+
// Determine the binary name based on platform
|
|
13
|
+
const platform = os.platform();
|
|
14
|
+
const arch = os.arch();
|
|
15
|
+
|
|
16
|
+
let binaryName = 'dcode-bin';
|
|
17
|
+
if (platform === 'win32') {
|
|
18
|
+
binaryName = 'dcode-bin.exe';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const binaryPath = path.join(__dirname, binaryName);
|
|
22
|
+
|
|
23
|
+
// Pass all arguments to the Go binary
|
|
24
|
+
const args = process.argv.slice(2);
|
|
25
|
+
|
|
26
|
+
// Spawn the Go binary
|
|
27
|
+
const child = spawn(binaryPath, args, {
|
|
28
|
+
stdio: 'inherit',
|
|
29
|
+
shell: false
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Handle exit
|
|
33
|
+
child.on('exit', (code) => {
|
|
34
|
+
process.exit(code || 0);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Handle errors
|
|
38
|
+
child.on('error', (err) => {
|
|
39
|
+
console.error('Failed to start DCode:', err.message);
|
|
40
|
+
console.error('\nPlease ensure Go is installed and run:');
|
|
41
|
+
console.error(' cd', path.dirname(__dirname));
|
|
42
|
+
console.error(' npm run build');
|
|
43
|
+
process.exit(1);
|
|
44
|
+
});
|