demian-cli 1.0.3

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 ADDED
@@ -0,0 +1,374 @@
1
+ # Demian TUI
2
+
3
+ <p>
4
+ <img src="./media/demian.svg" width="72" height="72" alt="Demian icon">
5
+ </p>
6
+
7
+ **Demian** is a local terminal coding agent for developers. It can inspect a
8
+ workspace, answer code questions, edit files, run commands with approval, keep
9
+ longer goals alive, and coordinate multiple sub agents when a task benefits
10
+ from parallel research or review.
11
+
12
+ Default language: English
13
+ Additional locale: [한국어](./docs/ko/README.md)
14
+
15
+ ## Highlights
16
+
17
+ - Interactive Ink TUI with provider, model, agent, and permission controls.
18
+ - Plain CLI mode for scripts, pipes, and terminals that cannot run the TUI.
19
+ - Local workspace tools: read, glob, grep, write, edit, bash, update plan, web
20
+ search, progress reporting, and cowork delegation.
21
+ - Goal mode with `/goal` for longer objectives that should be verified before
22
+ completion.
23
+ - Cowork mode with `/cowork` for bounded multi-agent coordination.
24
+ - Provider support for OpenAI-compatible APIs, Anthropic API, Codex,
25
+ Claude Code, Ollama, LM Studio, vLLM, llama.cpp, OpenRouter, Together, Groq,
26
+ Gemini, and Azure OpenAI-compatible endpoints.
27
+ - Permission prompts for side effects, with optional persistent "always allow"
28
+ grants.
29
+ - Project and user configuration through `.demian/config.json` or
30
+ `.demian/config.jsond`.
31
+
32
+ ## Requirements
33
+
34
+ - Node.js **22.18 or newer**.
35
+ - At least one model provider configured.
36
+ - Optional: Claude Code installed locally if you want to use the `claudecode`
37
+ provider.
38
+
39
+ ## Install
40
+
41
+ ```sh
42
+ npm install -g demian-cli
43
+ ```
44
+
45
+ Then open a project and start the TUI:
46
+
47
+ ```sh
48
+ cd ~/work/my-project
49
+ demian
50
+ ```
51
+
52
+ You can also run without installing globally:
53
+
54
+ ```sh
55
+ npx demian
56
+ ```
57
+
58
+ ## Quickstart
59
+
60
+ 1. Open your project:
61
+
62
+ ```sh
63
+ cd ~/work/my-project
64
+ demian
65
+ ```
66
+
67
+ 2. Choose a provider and model before your first message.
68
+
69
+ In the TUI:
70
+
71
+ - Press `p` to choose a provider.
72
+ - Press `m` to edit the model.
73
+ - Press `a` to choose the main agent.
74
+ - Type your request and press `Enter`.
75
+
76
+ 3. Try a first prompt:
77
+
78
+ ```text
79
+ Summarize this repository and tell me where the main entry points are.
80
+ ```
81
+
82
+ 4. When Demian asks for permission, review the requested command or file
83
+ operation:
84
+
85
+ - `y`: allow once
86
+ - `a`: always allow this grant scope
87
+ - `n` or `Enter`: deny
88
+
89
+ 5. Keep chatting. Demian keeps conversation history while the session is open.
90
+ Use `/compact` when the conversation gets long, and `/exit` when you are
91
+ done.
92
+
93
+ ## Provider Setup
94
+
95
+ Demian loads configuration from user and project locations:
96
+
97
+ 1. built-in defaults
98
+ 2. `~/.demian/config.json`
99
+ 3. `~/.demian/config.jsond`
100
+ 4. `.demian/config.json` in the working directory
101
+ 5. `.demian/config.jsond` in the working directory
102
+ 6. `--config <path>`
103
+ 7. `.demian/preferences.json`
104
+ 8. CLI flags
105
+
106
+ `.jsond` files support comments and trailing commas.
107
+
108
+ ### OpenAI-Compatible Example
109
+
110
+ Create `~/.demian/config.jsond`:
111
+
112
+ ```jsonc
113
+ {
114
+ "defaultProvider": "openai",
115
+ "providers": {
116
+ "openai": {
117
+ "type": "openai-compatible",
118
+ "baseURL": "https://api.openai.com/v1",
119
+ "apiKeyEnv": "OPENAI_API_KEY",
120
+ "model": "gpt-5.5"
121
+ }
122
+ }
123
+ }
124
+ ```
125
+
126
+ Then export your key:
127
+
128
+ ```sh
129
+ export OPENAI_API_KEY="..."
130
+ demian --provider openai --model gpt-5.5
131
+ ```
132
+
133
+ ### Local Model Example: Ollama
134
+
135
+ ```sh
136
+ brew install ollama
137
+ ollama serve
138
+ ollama pull qwen2.5-coder:latest
139
+ demian --provider ollama --model qwen2.5-coder:latest
140
+ ```
141
+
142
+ ### Anthropic API vs Claude Code
143
+
144
+ Demian has two Claude-related paths:
145
+
146
+ - `anthropic`: direct Anthropic API provider. It uses `ANTHROPIC_API_KEY` and
147
+ Anthropic API billing.
148
+ - `claudecode`: external Claude Code runtime. It uses your local Claude Code
149
+ installation and login/subscription path through the Claude Agent SDK. The
150
+ default CLI path is `~/.local/bin/claude`.
151
+
152
+ Use `anthropic` when you want direct API-key calls. Use `claudecode` when you
153
+ want Demian to coordinate Claude Code as an external agent runtime.
154
+
155
+ Example:
156
+
157
+ ```sh
158
+ demian --provider claudecode --model claude-sonnet-4-6
159
+ ```
160
+
161
+ Available Claude Code model aliases in the default config:
162
+
163
+ - `claude-sonnet-4-6`
164
+ - `claude-opus-4-7`
165
+
166
+ ## Tutorial: Ask, Edit, Verify
167
+
168
+ This is the normal Demian loop.
169
+
170
+ 1. Ask Demian to inspect the project:
171
+
172
+ ```text
173
+ Find how authentication is wired in this project.
174
+ ```
175
+
176
+ 2. Ask for a focused change:
177
+
178
+ ```text
179
+ Add a validation error when the email is missing. Keep the change minimal.
180
+ ```
181
+
182
+ 3. Review permission prompts. Demian will ask before running commands or making
183
+ side-effecting changes unless your policy already allows them.
184
+
185
+ 4. Ask Demian to verify:
186
+
187
+ ```text
188
+ Run the relevant tests and summarize what changed.
189
+ ```
190
+
191
+ 5. Use `/compact` if you want to keep the session but shrink older context.
192
+
193
+ ## Goal Mode
194
+
195
+ Use `/goal` when the task should stay active until it is verified and completed.
196
+
197
+ ```sh
198
+ demian '/goal Update the README, run the checks, and finish only after verification passes.'
199
+ ```
200
+
201
+ Inside an interactive session:
202
+
203
+ ```text
204
+ /goal Fix the flaky login test and verify it locally.
205
+ ```
206
+
207
+ Useful goal commands:
208
+
209
+ - `/goal status`: show the active goal.
210
+ - `/goal pause`: pause it.
211
+ - `/goal resume`: continue it.
212
+ - `/goal clear`: archive it.
213
+
214
+ Goal state is stored under `.demian/goals/`. Completion is accepted only when
215
+ Demian marks the goal complete after verification.
216
+
217
+ ## Cowork Mode
218
+
219
+ Use `/cowork` when Demian should coordinate multiple bounded sub agents and
220
+ synthesize their results.
221
+
222
+ ```text
223
+ /cowork Have one agent inspect the API layer and another inspect the UI flow. Compare the risks and recommend the smallest fix.
224
+ ```
225
+
226
+ Demian remains the main coordinator. Sub agents are workers with bounded tasks.
227
+ The default cowork settings allow read-only parallelism and keep writer
228
+ coordination conservative.
229
+
230
+ Cowork is most useful for:
231
+
232
+ - comparing two implementation paths
233
+ - asking one agent to inspect while another verifies
234
+ - combining Codex-style and Claude Code-style agent work
235
+ - separating planning, review, and implementation roles
236
+
237
+ ## Plain CLI
238
+
239
+ Use `demian-plain` when you need raw Markdown output, scripting, or a terminal
240
+ that cannot render the Ink TUI.
241
+
242
+ ```sh
243
+ demian-plain "Explain the project structure"
244
+ demian-plain --provider ollama --model qwen2.5-coder:latest "Review this folder"
245
+ demian-plain --image screenshot.png "What UI issue do you see?"
246
+ ```
247
+
248
+ Plain mode supports the same core provider, goal, image, sandbox, and permission
249
+ flags.
250
+
251
+ ## Common Commands
252
+
253
+ ```sh
254
+ demian # open the TUI
255
+ demian --provider openai --model gpt-5.5
256
+ demian --provider claudecode --model claude-sonnet-4-6
257
+ demian --single-agent
258
+ demian --multi-agent
259
+ demian --sandbox read-only
260
+ demian --sandbox workspace-write
261
+ demian --image screenshot.png
262
+ demian-plain "Give me a release checklist"
263
+ ```
264
+
265
+ Inside the TUI:
266
+
267
+ - `/compact`: summarize older conversation history.
268
+ - `/stop`: stop active work.
269
+ - `/exit` or `/quit`: close Demian.
270
+ - `/goal ...`: start a verified long-running objective.
271
+ - `/cowork ...`: explicitly coordinate cowork sub agents.
272
+
273
+ ## Tools and Permissions
274
+
275
+ Demian can use local tools for code work:
276
+
277
+ - `read_file`, `glob`, `grep`
278
+ - `write_file`, `edit_file`
279
+ - `bash`
280
+ - `web_search`
281
+ - `update_plan`
282
+ - `cowork`
283
+ - `delegate_agent`
284
+
285
+ Side effects are permission-controlled. The default sandbox is
286
+ `workspace-write`. You can change it per run:
287
+
288
+ ```sh
289
+ demian --sandbox read-only
290
+ demian --sandbox off
291
+ ```
292
+
293
+ "Always allow" grants are persisted by default according to Demian's grant
294
+ policy. Use this for one-off sessions:
295
+
296
+ ```sh
297
+ demian --no-persistent-grants
298
+ ```
299
+
300
+ ## Web Search
301
+
302
+ Demian supports Brave, Tavily, and Exa through the `web_search` tool.
303
+
304
+ ```jsonc
305
+ {
306
+ "webSearch": {
307
+ "defaultProvider": "brave",
308
+ "providers": {
309
+ "brave": {
310
+ "apiKeyEnv": "BRAVE_SEARCH_API_KEY"
311
+ },
312
+ "tavily": {
313
+ "apiKeyEnv": "TAVILY_API_KEY"
314
+ },
315
+ "exa": {
316
+ "apiKeyEnv": "EXA_API_KEY"
317
+ }
318
+ }
319
+ }
320
+ }
321
+ ```
322
+
323
+ Web search asks for permission because it may call paid third-party APIs.
324
+
325
+ ## Where Demian Stores Data
326
+
327
+ Demian uses both user-level and project-level storage:
328
+
329
+ - `~/.demian/config.json` or `~/.demian/config.jsond`: user config.
330
+ - `.demian/config.json` or `.demian/config.jsond`: project config.
331
+ - `.demian/preferences.json`: remembered provider/model choice for the current
332
+ workspace.
333
+ - `.demian/grants.json`: persistent permission grants.
334
+ - `.demian/goals/`: active and archived goal state.
335
+ - `.demian/`: transcripts and workspace-scoped runtime files.
336
+
337
+ Do not store API keys in shared project config. Prefer `apiKeyEnv`.
338
+
339
+ ## Troubleshooting
340
+
341
+ ### `demian` says the TUI requires an interactive terminal
342
+
343
+ Use a real terminal or run plain mode:
344
+
345
+ ```sh
346
+ demian-plain "Summarize this repository"
347
+ ```
348
+
349
+ ### A provider loads but the model fails
350
+
351
+ Check the provider's `model`, `baseURL`, and API key environment variable. You
352
+ can override the model at launch:
353
+
354
+ ```sh
355
+ demian --provider openai --model gpt-5.5
356
+ ```
357
+
358
+ ### Claude Code does not start
359
+
360
+ Check that Claude Code is installed and that the configured `cliPath` exists.
361
+ The default path is `~/.local/bin/claude`.
362
+
363
+ ```sh
364
+ ~/.local/bin/claude --version
365
+ ```
366
+
367
+ ### Permission prompts feel too frequent
368
+
369
+ Use `a` to always allow a specific grant scope, or configure a project policy.
370
+ Use `--no-persistent-grants` when you do not want "always allow" grants saved.
371
+
372
+ ## License
373
+
374
+ Apache-2.0