@alanwchat/coder 0.1.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/README.md +289 -0
- package/dist/index.cjs +2987 -0
- package/dist/index.cjs.map +7 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# Coder CLI
|
|
2
|
+
|
|
3
|
+
**Coder CLI** is a terminal-based AI coding assistant that brings the full power of the [Coder](https://github.com/coder/coder) AI agent to your command line. It supports multiple AI providers, file operations, shell execution, web search, and more — all from the terminal.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🤖 **Full agent mode** – read, write, edit files, run shell commands, browse the web
|
|
8
|
+
- 📖 **Ask mode** – read-only queries (file reading, search, web)
|
|
9
|
+
- 📋 **Plan mode** – create and manage structured plans
|
|
10
|
+
- 💬 **Interactive REPL** – persistent chat sessions
|
|
11
|
+
- 🔧 **Multiple AI providers** – DeepSeek, GLM, Agnes, NVIDIA, MiniMax, custom OpenAI-compatible
|
|
12
|
+
- 🌐 **Cross-platform** – macOS, Windows, Linux
|
|
13
|
+
- 🚀 **Pipe-friendly** – works with stdin/stdout for scripting
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
### Prerequisites
|
|
18
|
+
|
|
19
|
+
- **Node.js 18+** (Node.js 20+ recommended)
|
|
20
|
+
|
|
21
|
+
### Quick Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Clone the repository
|
|
25
|
+
git clone https://github.com/your-org/coder.git
|
|
26
|
+
cd coder/cli
|
|
27
|
+
|
|
28
|
+
# Install dependencies
|
|
29
|
+
npm install
|
|
30
|
+
|
|
31
|
+
# Build the CLI
|
|
32
|
+
npm run build
|
|
33
|
+
|
|
34
|
+
# Install globally (optional)
|
|
35
|
+
npm link
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Or run directly:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
node dist/index.js --help
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
### 1. Initialize Configuration
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
coder init
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
This will guide you through setting up your AI provider and API key.
|
|
53
|
+
|
|
54
|
+
### 2. Run a Prompt
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
coder "What files are in this directory?"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 3. Ask Mode (Read-Only)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
coder ask "Explain the architecture of this project"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 4. Interactive REPL
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
coder repl
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 5. With Specific Model/Provider
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
coder -m deepseek-v4-flash -p deepseek "Show me the main entry point"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Usage Guide
|
|
79
|
+
|
|
80
|
+
### Command Reference
|
|
81
|
+
|
|
82
|
+
| Command | Description |
|
|
83
|
+
|---------|-------------|
|
|
84
|
+
| `coder <prompt>` | Run agent with inline prompt |
|
|
85
|
+
| `coder ask <prompt>` | Read-only query mode |
|
|
86
|
+
| `coder plan <prompt>` | Plan creation/management mode |
|
|
87
|
+
| `coder repl` | Start interactive REPL session |
|
|
88
|
+
| `coder init` | First-time configuration setup |
|
|
89
|
+
| `coder config` | View or edit configuration |
|
|
90
|
+
| `coder --help` | Show help |
|
|
91
|
+
| `coder --version` | Show version |
|
|
92
|
+
|
|
93
|
+
### Global Options
|
|
94
|
+
|
|
95
|
+
| Option | Description |
|
|
96
|
+
|--------|-------------|
|
|
97
|
+
| `-m, --model <model>` | Model ID to use |
|
|
98
|
+
| `-p, --provider <provider>` | Provider ID (`deepseek`, `glm`, `agnes`, `nvidia`, `minimax`, `custom`) |
|
|
99
|
+
| `-w, --workspace <path>` | Workspace directory (default: current directory) |
|
|
100
|
+
| `-y, --yes` | Auto-confirm prompts |
|
|
101
|
+
| `--no-stream` | Disable streaming output |
|
|
102
|
+
|
|
103
|
+
### REPL Commands
|
|
104
|
+
|
|
105
|
+
Inside the REPL, you can use:
|
|
106
|
+
|
|
107
|
+
| Command | Description |
|
|
108
|
+
|---------|-------------|
|
|
109
|
+
| `<prompt>` | Ask the agent anything |
|
|
110
|
+
| `exit` / `quit` | Exit REPL |
|
|
111
|
+
| `clear` | Clear screen |
|
|
112
|
+
| `help` | Show REPL commands |
|
|
113
|
+
| `model <id>` | Switch model |
|
|
114
|
+
|
|
115
|
+
### Configuration
|
|
116
|
+
|
|
117
|
+
Configuration is stored in a platform-appropriate directory:
|
|
118
|
+
|
|
119
|
+
- **macOS / Linux**: `~/.config/coder/cli/config.json`
|
|
120
|
+
- **Windows**: `%APPDATA%/Coder/cli/config.json`
|
|
121
|
+
|
|
122
|
+
View current configuration:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
coder config
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Set a specific value:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
coder config activeProvider deepseek
|
|
132
|
+
coder config lastModel deepseek-v4-flash
|
|
133
|
+
coder config providers.deepseek.apiKeySource env
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Environment Variables
|
|
137
|
+
|
|
138
|
+
API keys can be set via environment variables (recommended for security):
|
|
139
|
+
|
|
140
|
+
| Provider | Environment Variable |
|
|
141
|
+
|----------|---------------------|
|
|
142
|
+
| DeepSeek | `DEEPSEEK_API_KEY` |
|
|
143
|
+
| GLM | `GLM_API_KEY` |
|
|
144
|
+
| Agnes | `AGNES_API_KEY` |
|
|
145
|
+
| NVIDIA | `NVIDIA_API_KEY` |
|
|
146
|
+
| MiniMax | `MINIMAX_API_KEY` |
|
|
147
|
+
| Custom | `CUSTOM_API_KEY` (configurable) |
|
|
148
|
+
|
|
149
|
+
Set an API key:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# macOS / Linux
|
|
153
|
+
export DEEPSEEK_API_KEY=your-api-key-here
|
|
154
|
+
|
|
155
|
+
# Windows (Command Prompt)
|
|
156
|
+
set DEEPSEEK_API_KEY=your-api-key-here
|
|
157
|
+
|
|
158
|
+
# Windows (PowerShell)
|
|
159
|
+
$env:DEEPSEEK_API_KEY="your-api-key-here"
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Examples
|
|
163
|
+
|
|
164
|
+
### File Operations
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Read a file
|
|
168
|
+
coder "Show me the contents of package.json"
|
|
169
|
+
|
|
170
|
+
# Edit a file
|
|
171
|
+
coder "Add a 'test' script to package.json that runs vitest"
|
|
172
|
+
|
|
173
|
+
# Search for code
|
|
174
|
+
coder ask "Find all places where we handle API errors"
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Web Browsing
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Web search
|
|
181
|
+
coder "Search for the latest TypeScript release notes"
|
|
182
|
+
|
|
183
|
+
# Browse a page
|
|
184
|
+
coder "Read https://nodejs.org/en/about and summarize"
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Shell Commands
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
# Run a build
|
|
191
|
+
coder "Run npm test and fix any failures"
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Pipe Mode
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Pipe input
|
|
198
|
+
cat errors.txt | coder "Analyze these errors and suggest fixes"
|
|
199
|
+
|
|
200
|
+
# Pipe output
|
|
201
|
+
coder "Generate a .gitignore for a Node.js project" >> .gitignore
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Platform Notes
|
|
205
|
+
|
|
206
|
+
### macOS
|
|
207
|
+
- Works out of the box with Terminal, iTerm2, or Warp
|
|
208
|
+
- For best REPL experience, use a terminal that supports true color
|
|
209
|
+
|
|
210
|
+
### Windows
|
|
211
|
+
- Works with Command Prompt, PowerShell, and Windows Terminal
|
|
212
|
+
- For the REPL, Windows Terminal is recommended
|
|
213
|
+
- Path separators are automatically handled
|
|
214
|
+
|
|
215
|
+
### Linux
|
|
216
|
+
- Works with any terminal emulator
|
|
217
|
+
- Requires Node.js 18+ (install via nvm or package manager)
|
|
218
|
+
|
|
219
|
+
## Development
|
|
220
|
+
|
|
221
|
+
### Project Structure
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
cli/
|
|
225
|
+
├── src/
|
|
226
|
+
│ ├── index.ts # CLI entrypoint
|
|
227
|
+
│ ├── agent/ # Agent loop & LLM streaming
|
|
228
|
+
│ │ ├── runner.ts # Multi-turn agent execution
|
|
229
|
+
│ │ ├── llm-stream.ts # SSE streaming from OpenAI-compatible APIs
|
|
230
|
+
│ │ ├── session.ts # Agent session lifecycle
|
|
231
|
+
│ │ ├── types.ts # Agent types
|
|
232
|
+
│ │ └── environment/ # Environment resolution
|
|
233
|
+
│ ├── commands/ # CLI command implementations
|
|
234
|
+
│ │ ├── run.ts # coder <prompt>
|
|
235
|
+
│ │ ├── ask.ts # coder ask
|
|
236
|
+
│ │ ├── plan.ts # coder plan
|
|
237
|
+
│ │ ├── repl.ts # coder repl
|
|
238
|
+
│ │ ├── init.ts # coder init
|
|
239
|
+
│ │ └── config.ts # coder config
|
|
240
|
+
│ ├── config/ # Configuration management
|
|
241
|
+
│ │ └── index.ts
|
|
242
|
+
│ ├── handlers/ # Node.js-native tool handlers
|
|
243
|
+
│ │ ├── index.ts # Handler registry & definitions
|
|
244
|
+
│ │ ├── list-dir.ts
|
|
245
|
+
│ │ ├── read-file.ts
|
|
246
|
+
│ │ ├── write-file.ts
|
|
247
|
+
│ │ ├── replace-file.ts
|
|
248
|
+
│ │ ├── edit-file.ts
|
|
249
|
+
│ │ ├── replace-lines.ts
|
|
250
|
+
│ │ ├── glob.ts
|
|
251
|
+
│ │ ├── grep.ts
|
|
252
|
+
│ │ ├── shell.ts
|
|
253
|
+
│ │ ├── shell-manager.ts
|
|
254
|
+
│ │ ├── web-search.ts
|
|
255
|
+
│ │ ├── browse-page.ts
|
|
256
|
+
│ │ ├── workspace-tree.ts
|
|
257
|
+
│ │ ├── todos.ts
|
|
258
|
+
│ │ ├── plans.ts
|
|
259
|
+
│ │ ├── ask-question.ts
|
|
260
|
+
│ │ └── spawn-subagent.ts
|
|
261
|
+
│ └── ui/ # Terminal UI utilities
|
|
262
|
+
│ └── index.ts
|
|
263
|
+
├── build.mjs # esbuild configuration
|
|
264
|
+
├── build.sh # Unix build script
|
|
265
|
+
├── build.ps1 # Windows build script
|
|
266
|
+
├── package.json
|
|
267
|
+
├── tsconfig.json
|
|
268
|
+
└── README.md
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Build
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# Development build
|
|
275
|
+
node build.mjs
|
|
276
|
+
|
|
277
|
+
# Production build
|
|
278
|
+
NODE_ENV=production node build.mjs
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Type Check
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
npx tsc --noEmit
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## License
|
|
288
|
+
|
|
289
|
+
MIT
|