miii-cli 1.2.4 → 1.3.1
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 +159 -127
- package/dist/config.js +1 -1
- package/dist/init.js +47 -2
- package/dist/llm/stream.js +181 -18
- package/dist/mcp/client.js +8 -1
- package/dist/memory/extractor.js +34 -3
- package/dist/skills/loader.js +6 -2
- package/dist/tasks/compactor.js +4 -1
- package/dist/tools/index.js +73 -20
- package/dist/tui/InputBar.js +2 -2
- package/dist/tui/components/ConfigPicker.js +12 -2
- package/dist/tui/components/InputArea.js +15 -4
- package/dist/tui/deepThink.js +0 -1
- package/dist/tui/hooks/useRefactor.js +4 -3
- package/dist/tui/hooks/useRunLoop.js +158 -78
- package/dist/tui/hooks/useSession.js +2 -2
- package/dist/tui/hooks/useSubmit.js +12 -0
- package/dist/tui/printer.js +7 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# miii — Ollama Coding CLI. 176 KB. No API Key.
|
|
2
2
|
|
|
3
|
-
> **
|
|
3
|
+
> **Claude Code UX. Ollama models. No invoice.**
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/miii-cli)
|
|
8
|
-
[](https://www.npmjs.com/package/miii-cli)
|
|
9
8
|
[](LICENSE)
|
|
10
9
|
[](https://nodejs.org)
|
|
11
10
|
|
|
11
|
+
**176 KB · no API key · works offline**
|
|
12
|
+
|
|
12
13
|
---
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
Buy hardware once. Pay for AI never.
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
Your code never leaves your machine. Nothing sent to Anthropic, OpenAI, or anyone. If you're already running Ollama, miii adds $0 to your stack.
|
|
17
18
|
|
|
18
19
|
```bash
|
|
19
20
|
npm install -g miii-cli && miii
|
|
@@ -23,13 +24,59 @@ npm install -g miii-cli && miii
|
|
|
23
24
|
|
|
24
25
|
## Why Miii Exists
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
**You're probably paying for something miii does for free.**
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
Claude Code bills against your Anthropic API key. miii runs open models on Ollama — Llama, Mistral, Qwen, Phi. Fully local. $0. Claude Code has no built-in undo for file changes. A bad edit is a bad edit. Miii checkpoints every file before touching it.
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
The gap is what miii adds on top: file checkpoints before every edit, npm skills, live model switching, and full air-gap support.
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
- **16 GB RAM, a GPU** — if you're already running Ollama, miii adds $0 to your stack
|
|
34
|
+
- **Try Llama 3, Mistral, Qwen, Phi** side by side without switching tools
|
|
35
|
+
- **Literally cannot use cloud AI** — miii with Ollama is purpose-built for zero-internet environments
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## What Miii Actually Does
|
|
40
|
+
|
|
41
|
+
Not a chatbot with a file-write button. Miii is a **full autonomous agent loop** — reasons, plans, acts, self-corrects until the task is done.
|
|
42
|
+
|
|
43
|
+
1. Describe a goal in plain English
|
|
44
|
+
2. Miii reads your codebase, maps the changes, shows the plan
|
|
45
|
+
3. Asks permission before touching anything — every edit, command, delete
|
|
46
|
+
4. Shows exact diff of what changes *before* you approve
|
|
47
|
+
5. Runs tests. If they fail, reads the error, fixes autonomously
|
|
48
|
+
6. Every file checkpointed — hit Esc and everything rolls back
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## What a Real Session Looks Like
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
> refactor the auth module to use JWT instead of sessions
|
|
56
|
+
|
|
57
|
+
● thinking…
|
|
58
|
+
● read_file src/auth/session.ts (42 lines)
|
|
59
|
+
● read_file src/middleware/auth.ts (28 lines)
|
|
60
|
+
|
|
61
|
+
─ plan (2 actions)
|
|
62
|
+
◦ edit_file src/auth/session.ts
|
|
63
|
+
◦ edit_file src/middleware/auth.ts
|
|
64
|
+
|
|
65
|
+
⚠ edit_file src/auth/session.ts
|
|
66
|
+
┌─ diff preview ──────────────────────┐
|
|
67
|
+
│ - const session = req.session.user │
|
|
68
|
+
│ + const token = verifyJWT(req) │
|
|
69
|
+
└─────────────────────────────────────┘
|
|
70
|
+
y approve s approve all n deny
|
|
71
|
+
> s
|
|
72
|
+
|
|
73
|
+
● edit_file src/auth/session.ts done
|
|
74
|
+
● edit_file src/middleware/auth.ts done
|
|
75
|
+
● run_tests ✅ passed
|
|
76
|
+
─ done in 14.2s · branch: miii/task-2025-05-17-14-32
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Parallel file reads. Diff preview before approval. Auto-branched off `main`. Tests ran. Session over.
|
|
33
80
|
|
|
34
81
|
---
|
|
35
82
|
|
|
@@ -39,169 +86,153 @@ Your compute. Your data. Your rules.
|
|
|
39
86
|
|---|:---:|:---:|:---:|:---:|:---:|
|
|
40
87
|
| Monthly cost | **$0** | $20–200 | API cost | API cost | $0 |
|
|
41
88
|
| Bundle size | **176 KB** | ~50 MB | ~30 MB | ~20 MB | ~200 MB |
|
|
89
|
+
| Startup time | **<100ms** | ~2s | ~1s | ~1s | ~4s |
|
|
42
90
|
| Local / offline (Ollama) | **✅** | ❌ | partial | ❌ | ⚠️ |
|
|
43
91
|
| Air-gapped | **✅** | ❌ | ❌ | ❌ | ❌ |
|
|
44
|
-
|
|
|
92
|
+
| Any model | **✅** | ❌ | partial | ❌ | ✅ |
|
|
45
93
|
| File checkpoints (undo) | **✅** | ❌ | ❌ | ❌ | ❌ |
|
|
46
|
-
|
|
|
47
|
-
|
|
|
94
|
+
| Diff preview before approve | **✅** | ❌ | ❌ | ❌ | ❌ |
|
|
95
|
+
| Git auto-branch on edit | **✅** | ❌ | ❌ | ❌ | ❌ |
|
|
96
|
+
| Switch provider live | **✅** | ❌ | ❌ | ❌ | ❌ |
|
|
97
|
+
| Native tool_calls (Anthropic + OpenAI) | **✅** | ✅ | ✅ | ✅ | ❌ |
|
|
98
|
+
| Parallel read-only tools | **✅** | partial | ❌ | ❌ | ❌ |
|
|
99
|
+
| Two-phase plan→execute | **✅** | ❌ | ❌ | ❌ | ❌ |
|
|
100
|
+
| Live streaming toggle | **✅** | always on | always on | always on | ❌ |
|
|
48
101
|
| Semantic codebase index | **✅** | ❌ | ❌ | ❌ | ❌ |
|
|
49
|
-
|
|
|
50
|
-
|
|
|
102
|
+
| npm skills | **✅** | plugins | ❌ | ❌ | ❌ |
|
|
103
|
+
| MCP client | **✅** | ✅ | ✅ | ❌ | ❌ |
|
|
51
104
|
| License | **MIT** | Proprietary | MIT | MIT | Apache 2.0 |
|
|
52
105
|
|
|
53
106
|
---
|
|
54
107
|
|
|
55
|
-
##
|
|
108
|
+
## Eight Core Capabilities
|
|
56
109
|
|
|
57
|
-
|
|
110
|
+
**Local / Offline** — Ollama runs on your machine. No internet required after model pull.
|
|
58
111
|
|
|
59
|
-
|
|
60
|
-
2. Miii reads your codebase, plans the changes, edits the files
|
|
61
|
-
3. It asks your permission before touching anything (edit, delete, run commands)
|
|
62
|
-
4. It runs your test suite automatically after every change
|
|
63
|
-
5. If tests fail, it reads the error, fixes the code, re-runs
|
|
64
|
-
6. It repeats until the work is done — and checkpoints every file so you can abort safely
|
|
112
|
+
**Air-Gapped Ready** — regulated industries, defense, offline infrastructure. miii with Ollama works where cloud literally cannot.
|
|
65
113
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
## What a Session Looks Like
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
> refactor the auth module to use JWT instead of sessions
|
|
114
|
+
**Any Model** — Llama 3, Mistral, Qwen, Phi, or switch to Anthropic/OpenAI live. One tool, every model.
|
|
72
115
|
|
|
73
|
-
|
|
74
|
-
● Reading src/auth/session.ts
|
|
75
|
-
Read 42 lines
|
|
76
|
-
● Reading src/middleware/auth.ts
|
|
77
|
-
Read 28 lines
|
|
116
|
+
**File Checkpoints** — every file snapshotted before edit. Abort = full rollback. No bad edits stick.
|
|
78
117
|
|
|
79
|
-
|
|
80
|
-
◦ edit_file src/auth/session.ts
|
|
81
|
-
◦ edit_file src/middleware/auth.ts
|
|
118
|
+
**Permission Gates + Diff Preview** — approve every write, delete, or command. See the exact diff before you say yes.
|
|
82
119
|
|
|
83
|
-
|
|
84
|
-
> y
|
|
120
|
+
**MCP Client** — plug in any MCP-compatible tool server. Tools discovered automatically.
|
|
85
121
|
|
|
86
|
-
|
|
87
|
-
Wrote 12 lines
|
|
88
|
-
● edit_file src/middleware/auth.ts
|
|
89
|
-
Wrote 8 lines
|
|
90
|
-
● run_tests
|
|
91
|
-
✅ Tests passed
|
|
122
|
+
**npm Skills** — extend miii with plain Markdown files or npm packages. Ship reusable agent behaviors to your whole team.
|
|
92
123
|
|
|
93
|
-
|
|
94
|
-
```
|
|
124
|
+
**$0 / Month** — no subscription, no invoice, no API key required for local use.
|
|
95
125
|
|
|
96
126
|
---
|
|
97
127
|
|
|
98
|
-
##
|
|
99
|
-
|
|
100
|
-
**🔒 Privacy-First, Local by Default**
|
|
101
|
-
Run on Ollama and your code never leaves your machine. No account. No API key. No monthly bill. Switch to Anthropic or OpenAI when you need it — one command, live, mid-session.
|
|
102
|
-
|
|
103
|
-
**🔄 Live Provider Switching**
|
|
104
|
-
Type `/config` to open an interactive picker. Arrow-navigate between Ollama, Anthropic, and OpenAI-compatible endpoints. Change model, API key, base URL, or Tavily key without restarting. Config saves automatically.
|
|
128
|
+
## Features Worth Knowing
|
|
105
129
|
|
|
106
|
-
|
|
107
|
-
Miii asks before every edit, delete, or shell command — just like Claude Code. Every file is checkpointed before it's touched. Hit Esc to abort and all changes roll back automatically.
|
|
130
|
+
**Git Auto-Branch** — first approved edit auto-creates `miii/task-YYYY-MM-DD-HH-MM`. Your `main` is never touched until you decide.
|
|
108
131
|
|
|
109
|
-
|
|
110
|
-
Build a vector index of your entire codebase using local embeddings. Ask "where is the auth logic?" and Miii finds it by meaning, not keyword. No data leaves your machine.
|
|
132
|
+
**Parallel Read-Only Tools** — reading five files + git status + web search? All fire at once. Write ops stay sequential. Speed where safe, safety where it matters.
|
|
111
133
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
**🛠 Surgical File Editing**
|
|
119
|
-
`patch_file` replaces exact strings in your files. No full rewrites. No formatting destruction. Exactly the change, nothing more.
|
|
120
|
-
|
|
121
|
-
**🔁 Self-Healing Test Loop**
|
|
122
|
-
Runs `npm test` after every file change. If something breaks, reads the failure trace and fixes it autonomously — up to 3 retries before surfacing the issue.
|
|
134
|
+
**Two-Phase Plan → Execute**
|
|
135
|
+
```
|
|
136
|
+
/plan exec refactor the payment module
|
|
137
|
+
```
|
|
138
|
+
First turn: numbered plan, tools disabled — you read it, decide. Second turn: execution with plan as context. No surprises.
|
|
123
139
|
|
|
124
|
-
|
|
125
|
-
Pick up exactly where you left off. Named sessions mean your context, history, and goal survive terminal restarts.
|
|
140
|
+
**Native Tool Calls** — Anthropic uses `tool_use` blocks, OpenAI uses `tool_calls` arrays, exactly as the API intended. Faster, more reliable, less hallucination. Ollama uses compact XML fallback.
|
|
126
141
|
|
|
127
|
-
|
|
128
|
-
Extend Miii with plain Markdown files or npm packages. Ship reusable agent behaviors as versioned packages your whole team can pull.
|
|
142
|
+
**Live Streaming Toggle** — turn on in `/config` to watch tokens appear in real time. Turn off for clean batch output. Toggle mid-session, no restart.
|
|
129
143
|
|
|
130
|
-
|
|
131
|
-
Connect any MCP-compatible tool server. Miii discovers tools automatically and makes them available to the agent.
|
|
144
|
+
**Semantic Codebase Search** — local vector index, no embeddings sent anywhere. `/index build` once. Ask "where is the payment logic?" by meaning, not grep.
|
|
132
145
|
|
|
133
146
|
---
|
|
134
147
|
|
|
135
|
-
##
|
|
148
|
+
## Quick Start
|
|
136
149
|
|
|
137
150
|
```bash
|
|
138
|
-
#
|
|
151
|
+
# Local — free, offline (recommended)
|
|
139
152
|
ollama pull qwen2.5-coder:7b
|
|
153
|
+
npm install -g miii-cli
|
|
154
|
+
cd your-project && miii
|
|
140
155
|
|
|
141
|
-
#
|
|
156
|
+
# Anthropic Claude
|
|
142
157
|
npm install -g miii-cli
|
|
158
|
+
ANTHROPIC_API_KEY=sk-... miii
|
|
143
159
|
|
|
144
|
-
#
|
|
145
|
-
|
|
146
|
-
miii
|
|
160
|
+
# OpenAI or compatible endpoint
|
|
161
|
+
npm install -g miii-cli
|
|
162
|
+
miii # set key + base URL in /config
|
|
147
163
|
```
|
|
148
164
|
|
|
149
|
-
|
|
165
|
+
Hardware requirements are real — this runs on your machine, not a server farm.
|
|
166
|
+
|
|
167
|
+
| | Minimum | Recommended |
|
|
168
|
+
|---|---|---|
|
|
169
|
+
| RAM | 16 GB | 32 GB+ |
|
|
170
|
+
| GPU | integrated | dedicated |
|
|
171
|
+
| Storage | 10 GB | 20 GB+ |
|
|
150
172
|
|
|
151
173
|
---
|
|
152
174
|
|
|
153
|
-
##
|
|
175
|
+
## Commands
|
|
154
176
|
|
|
155
177
|
| Command | What it does |
|
|
156
178
|
|---|---|
|
|
157
|
-
| `/config` |
|
|
158
|
-
| `/
|
|
159
|
-
| `/
|
|
160
|
-
| `/index build` | Build semantic vector index
|
|
161
|
-
| `/index search <
|
|
162
|
-
| `/git review` | AI reviews
|
|
163
|
-
| `/git commit <msg>` | Stage everything
|
|
164
|
-
| `/
|
|
165
|
-
| `/
|
|
166
|
-
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
---
|
|
171
|
-
|
|
172
|
-
## Semantic Codebase Indexing
|
|
173
|
-
|
|
174
|
-
For large codebases, Miii builds and queries a local vector index — no third-party APIs, no embeddings sent anywhere.
|
|
175
|
-
|
|
176
|
-
```bash
|
|
177
|
-
# Pull an embedding model (one time)
|
|
178
|
-
ollama pull nomic-embed-text
|
|
179
|
-
|
|
180
|
-
# Index your project
|
|
181
|
-
/index build
|
|
182
|
-
|
|
183
|
-
# The agent calls search_codebase automatically when it needs to find code by concept
|
|
184
|
-
```
|
|
179
|
+
| `/config` | Interactive picker — provider, model, API key, base URL, Tavily, streaming |
|
|
180
|
+
| `/plan exec <task>` | Two-phase: plan turn (no tools) → execute with plan as context |
|
|
181
|
+
| `/think <question>` | Deep research: reads files + web, synthesizes answer |
|
|
182
|
+
| `/index build` | Build local semantic vector index |
|
|
183
|
+
| `/index search <q>` | Find code by concept, not string match |
|
|
184
|
+
| `/git review` | AI reviews current diff — bugs, risks, style |
|
|
185
|
+
| `/git commit <msg>` | Stage everything, commit in one shot |
|
|
186
|
+
| `/model <name>` | Hot-swap LLM mid-conversation |
|
|
187
|
+
| `/session <name>` | Named sessions — resume exactly where you left off |
|
|
188
|
+
| `@filename` | Inject any file into context |
|
|
189
|
+
|
|
190
|
+
Commands open in a picker — select to insert into input, Enter to run.
|
|
185
191
|
|
|
186
192
|
---
|
|
187
193
|
|
|
188
194
|
## Configuration
|
|
189
195
|
|
|
190
|
-
**Interactive
|
|
196
|
+
**Interactive:** type `/config` inside miii.
|
|
191
197
|
|
|
192
|
-
**File-based:**
|
|
198
|
+
**File-based:** `.miii.json` in project root or `~/.config/miii/config.json` globally:
|
|
193
199
|
|
|
194
200
|
```json
|
|
195
201
|
{
|
|
196
|
-
"model": "qwen2.5-coder:7b",
|
|
197
202
|
"provider": "ollama",
|
|
198
203
|
"baseUrl": "http://localhost:11434",
|
|
199
204
|
"gitContext": true,
|
|
205
|
+
"streaming": false,
|
|
200
206
|
"embedModel": "nomic-embed-text"
|
|
201
207
|
}
|
|
202
208
|
```
|
|
203
209
|
|
|
204
|
-
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## MCP — Connect Any Tool Server
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"mcpServers": {
|
|
217
|
+
"postgres": {
|
|
218
|
+
"command": "npx",
|
|
219
|
+
"args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"]
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Drop into global config. Tools discovered automatically.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Semantic Index Setup
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
ollama pull nomic-embed-text # one time
|
|
233
|
+
/index build # inside your project
|
|
234
|
+
# agent calls search_codebase automatically from here
|
|
235
|
+
```
|
|
205
236
|
|
|
206
237
|
---
|
|
207
238
|
|
|
@@ -214,27 +245,28 @@ cd miii-cli && npm install && npm run build && npm link
|
|
|
214
245
|
|
|
215
246
|
---
|
|
216
247
|
|
|
217
|
-
## Who
|
|
248
|
+
## Who This Is For
|
|
218
249
|
|
|
219
|
-
|
|
220
|
-
- **Cost-sensitive teams** — API bills compound; Ollama is $0
|
|
221
|
-
- **Air-gapped environments** — regulated industries, defense, offline infra
|
|
222
|
-
- **Model experimenters** — want to try llama3, mistral, qwen, Claude side-by-side without switching tools
|
|
250
|
+
**Privacy-conscious developers** — proprietary code stays on your machine, always.
|
|
223
251
|
|
|
224
|
-
|
|
252
|
+
**Cost-sensitive teams** — API bills compound for every developer on the team, every month.
|
|
225
253
|
|
|
226
|
-
|
|
254
|
+
**Air-gapped environments** — regulated industries, defense, offline infrastructure where cloud is not an option.
|
|
227
255
|
|
|
228
|
-
|
|
256
|
+
**Model experimenters** — benchmark Llama 3 vs Qwen vs Claude vs GPT-4o in the same workflow.
|
|
229
257
|
|
|
230
|
-
|
|
258
|
+
**Anyone who's had an AI silently rewrite something they didn't want rewritten.**
|
|
231
259
|
|
|
232
|
-
|
|
260
|
+
---
|
|
233
261
|
|
|
234
|
-
|
|
262
|
+
The AI coding tools you're paying for will raise prices, change terms, and keep reading your code. Miii won't. MIT licensed, runs locally, gets better every time Ollama ships a new model.
|
|
235
263
|
|
|
236
|
-
|
|
264
|
+
**If this is the tool you've been waiting for — [⭐ star it](https://github.com/maruakshay/miii-cli) and tell someone.**
|
|
237
265
|
|
|
238
|
-
|
|
266
|
+
> Built by [@maruakshay](https://github.com/maruakshay) — PRs, issues, and model recommendations welcome.
|
|
267
|
+
>
|
|
268
|
+
> [miii.in](https://www.miii.in)
|
|
269
|
+
|
|
270
|
+
---
|
|
239
271
|
|
|
240
272
|
MIT — do whatever you want with it.
|
package/dist/config.js
CHANGED
|
@@ -6,7 +6,7 @@ const defaults = {
|
|
|
6
6
|
provider: 'ollama',
|
|
7
7
|
baseUrl: 'http://localhost:11434',
|
|
8
8
|
};
|
|
9
|
-
const ALLOWED_KEYS = new Set(['model', 'provider', 'baseUrl', 'systemPrompt', 'apiKey', 'gitContext', 'tavilyApiKey', 'embedModel']);
|
|
9
|
+
const ALLOWED_KEYS = new Set(['model', 'provider', 'baseUrl', 'systemPrompt', 'apiKey', 'gitContext', 'streaming', 'tavilyApiKey', 'embedModel']);
|
|
10
10
|
const PROJECT_CONFIG = join(process.cwd(), '.miii.json');
|
|
11
11
|
const GLOBAL_CONFIG = join(homedir(), '.config', 'miii', 'config.json');
|
|
12
12
|
export function saveConfig(config) {
|
package/dist/init.js
CHANGED
|
@@ -5,7 +5,7 @@ import { createRequire } from 'module';
|
|
|
5
5
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
6
6
|
import { join } from 'path';
|
|
7
7
|
import { homedir } from 'os';
|
|
8
|
-
import { execSync } from 'child_process';
|
|
8
|
+
import { execSync, spawnSync } from 'child_process';
|
|
9
9
|
import { loadConfig } from './config.js';
|
|
10
10
|
import { SkillLoader } from './skills/loader.js';
|
|
11
11
|
import { InputBar } from './tui/InputBar.js';
|
|
@@ -67,6 +67,45 @@ async function checkLatestVersion(current, force = false) {
|
|
|
67
67
|
catch { }
|
|
68
68
|
return undefined;
|
|
69
69
|
}
|
|
70
|
+
function promptYN(question) {
|
|
71
|
+
return new Promise(resolve => {
|
|
72
|
+
process.stdout.write(` ${question} (y/N) `);
|
|
73
|
+
const onData = (key) => {
|
|
74
|
+
const k = key.toString();
|
|
75
|
+
process.stdin.setRawMode(false);
|
|
76
|
+
process.stdin.pause();
|
|
77
|
+
process.stdin.removeListener('data', onData);
|
|
78
|
+
process.stdout.write('\n');
|
|
79
|
+
if (k === '') {
|
|
80
|
+
process.exit(130);
|
|
81
|
+
} // ctrl+c in raw mode — exit cleanly
|
|
82
|
+
resolve(k.toLowerCase() === 'y');
|
|
83
|
+
};
|
|
84
|
+
try {
|
|
85
|
+
process.stdin.setRawMode(true);
|
|
86
|
+
process.stdin.resume();
|
|
87
|
+
process.stdin.setEncoding('utf-8');
|
|
88
|
+
process.stdin.on('data', onData);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// stdin not a TTY (piped input) — skip prompt
|
|
92
|
+
process.stdin.removeListener('data', onData);
|
|
93
|
+
process.stdout.write('\n');
|
|
94
|
+
resolve(false);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
async function runAutoUpdate(latestVersion) {
|
|
99
|
+
process.stdout.write(`\n Updating miii-cli to v${latestVersion}…\n\n`);
|
|
100
|
+
const result = spawnSync('npm', ['install', '-g', 'miii-cli'], { stdio: 'inherit', shell: true });
|
|
101
|
+
if (result.status === 0) {
|
|
102
|
+
process.stdout.write(`\n Updated to v${latestVersion}. Restart miii.\n`);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
process.stdout.write(`\n Update failed (exit ${result.status}). Run manually: npm install -g miii-cli\n`);
|
|
106
|
+
}
|
|
107
|
+
process.exit(result.status ?? 1);
|
|
108
|
+
}
|
|
70
109
|
export async function lazyInit() {
|
|
71
110
|
const argv = minimist(process.argv.slice(2), {
|
|
72
111
|
string: ['model', 'url', 'provider', 'session'],
|
|
@@ -105,7 +144,13 @@ export async function lazyInit() {
|
|
|
105
144
|
process.stderr.write(`MCP: loaded ${mcpTools.length} tool(s) from ${mcpClients.length} server(s)\n`);
|
|
106
145
|
}
|
|
107
146
|
// Print welcome banner to scrollback BEFORE Ink starts
|
|
108
|
-
welcome(
|
|
147
|
+
welcome(process.cwd(), currentVersion, updateAvailable, linked);
|
|
148
|
+
// If update available and not a linked dev install, offer auto-update
|
|
149
|
+
if (updateAvailable && !linked && process.stdin.isTTY) {
|
|
150
|
+
const doUpdate = await promptYN(`Update available: v${updateAvailable}. Auto-update now?`);
|
|
151
|
+
if (doUpdate)
|
|
152
|
+
await runAutoUpdate(updateAvailable);
|
|
153
|
+
}
|
|
109
154
|
const sessionName = argv.session || `s-${Date.now()}`;
|
|
110
155
|
const { waitUntilExit } = render(React.createElement(InputBar, { config, skills, cwd: process.cwd(), session: sessionName, version: currentVersion, mcpTools }), { exitOnCtrlC: false });
|
|
111
156
|
await waitUntilExit();
|