deepclause-sdk 0.0.60 → 0.0.62

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.
Files changed (82) hide show
  1. package/README.md +346 -87
  2. package/dist/cli/compile.d.ts +10 -0
  3. package/dist/cli/compile.d.ts.map +1 -1
  4. package/dist/cli/compile.js +62 -11
  5. package/dist/cli/compile.js.map +1 -1
  6. package/dist/cli/config.d.ts +6 -0
  7. package/dist/cli/config.d.ts.map +1 -1
  8. package/dist/cli/config.js +72 -0
  9. package/dist/cli/config.js.map +1 -1
  10. package/dist/cli/default-skills.d.ts +9 -0
  11. package/dist/cli/default-skills.d.ts.map +1 -0
  12. package/dist/cli/default-skills.js +175 -0
  13. package/dist/cli/default-skills.js.map +1 -0
  14. package/dist/cli/index.js +134 -10
  15. package/dist/cli/index.js.map +1 -1
  16. package/dist/cli/run.d.ts +2 -0
  17. package/dist/cli/run.d.ts.map +1 -1
  18. package/dist/cli/run.js +19 -62
  19. package/dist/cli/run.js.map +1 -1
  20. package/dist/cli/tui.d.ts +52 -1
  21. package/dist/cli/tui.d.ts.map +1 -1
  22. package/dist/cli/tui.js +2326 -109
  23. package/dist/cli/tui.js.map +1 -1
  24. package/dist/compiler.d.ts +10 -0
  25. package/dist/compiler.d.ts.map +1 -1
  26. package/dist/compiler.js +27 -6
  27. package/dist/compiler.js.map +1 -1
  28. package/dist/prolog/bridge.js +1 -1
  29. package/dist/prolog/bridge.js.map +1 -1
  30. package/dist/runner.d.ts.map +1 -1
  31. package/dist/runner.js +26 -14
  32. package/dist/runner.js.map +1 -1
  33. package/dist/sdk.d.ts.map +1 -1
  34. package/dist/sdk.js +44 -0
  35. package/dist/sdk.js.map +1 -1
  36. package/dist/system/assets/docs/CONDUCTOR_PROMPT.md +30 -5
  37. package/dist/system/assets/docs/DML_COMPILER_PROMPT.md +16 -6
  38. package/dist/system/assets/docs/TUI.md +139 -0
  39. package/dist/system/assets/index.d.ts +11 -1
  40. package/dist/system/assets/index.d.ts.map +1 -1
  41. package/dist/system/assets/index.js +62 -7
  42. package/dist/system/assets/index.js.map +1 -1
  43. package/dist/system/assets/skills/skill-creator.dml +6 -2
  44. package/dist/system/runtime/agentvm-manager.d.ts +28 -1
  45. package/dist/system/runtime/agentvm-manager.d.ts.map +1 -1
  46. package/dist/system/runtime/agentvm-manager.js +18 -2
  47. package/dist/system/runtime/agentvm-manager.js.map +1 -1
  48. package/dist/system/runtime/catalog-skills.d.ts +45 -0
  49. package/dist/system/runtime/catalog-skills.d.ts.map +1 -0
  50. package/dist/system/runtime/catalog-skills.js +110 -0
  51. package/dist/system/runtime/catalog-skills.js.map +1 -0
  52. package/dist/system/runtime/conductor.d.ts +15 -1
  53. package/dist/system/runtime/conductor.d.ts.map +1 -1
  54. package/dist/system/runtime/conductor.js +19 -65
  55. package/dist/system/runtime/conductor.js.map +1 -1
  56. package/dist/system/runtime/dml-executor.d.ts +8 -0
  57. package/dist/system/runtime/dml-executor.d.ts.map +1 -1
  58. package/dist/system/runtime/dml-executor.js +106 -54
  59. package/dist/system/runtime/dml-executor.js.map +1 -1
  60. package/dist/system/runtime/dml-params.d.ts +11 -0
  61. package/dist/system/runtime/dml-params.d.ts.map +1 -0
  62. package/dist/system/runtime/dml-params.js +45 -0
  63. package/dist/system/runtime/dml-params.js.map +1 -0
  64. package/dist/system/runtime/runtime-tools.d.ts +6 -1
  65. package/dist/system/runtime/runtime-tools.d.ts.map +1 -1
  66. package/dist/system/runtime/runtime-tools.js +41 -2
  67. package/dist/system/runtime/runtime-tools.js.map +1 -1
  68. package/dist/system/runtime/shell-manager.d.ts +3 -3
  69. package/dist/system/runtime/shell-manager.d.ts.map +1 -1
  70. package/dist/system/runtime/shell-manager.js +31 -3
  71. package/dist/system/runtime/shell-manager.js.map +1 -1
  72. package/dist/system/runtime/shell-tool-events.d.ts +11 -0
  73. package/dist/system/runtime/shell-tool-events.d.ts.map +1 -0
  74. package/dist/system/runtime/shell-tool-events.js +139 -0
  75. package/dist/system/runtime/shell-tool-events.js.map +1 -0
  76. package/dist/system/runtime/skill-creator.d.ts +3 -0
  77. package/dist/system/runtime/skill-creator.d.ts.map +1 -1
  78. package/dist/system/runtime/skill-creator.js +90 -128
  79. package/dist/system/runtime/skill-creator.js.map +1 -1
  80. package/dist/types.d.ts +12 -0
  81. package/dist/types.d.ts.map +1 -1
  82. package/package.json +1 -1
package/README.md CHANGED
@@ -1,8 +1,9 @@
1
- # DeepClause CLI and SDK
1
+ # DeepClause TUI Agent, CLI and SDK
2
2
 
3
- Compile markdown specs into executable logic programs. Guaranteed execution semantics for agentic workflows.
3
+ Compile markdown specs into executable logic programs. Guaranteed execution semantics for agentic workflows. Comes with a minimal coding agent incl. a nostalgic Borland-style TUI.
4
4
 
5
5
  ![docs/overview.png](docs/overview.png)
6
+ ![docs/tui.png](docs/tui.png)
6
7
 
7
8
 
8
9
  ## What This Is
@@ -16,6 +17,283 @@ DeepClause takes a different approach: **compile task descriptions into DML prog
16
17
  Markdown description → compile → Logic program → run → Output
17
18
  ```
18
19
 
20
+ ## Install and Run
21
+
22
+ DeepClause requires Node.js 18+.
23
+
24
+ ### Global install
25
+
26
+ ```bash
27
+ npm install -g deepclause-sdk
28
+
29
+ # Pick one provider and export its API key
30
+ export OPENAI_API_KEY="sk-..."
31
+ # or: export ANTHROPIC_API_KEY="..."
32
+ # or: export GOOGLE_GENERATIVE_AI_API_KEY="..."
33
+ # or: export OPENROUTER_API_KEY="..."
34
+
35
+ # Initialize the current workspace
36
+ deepclause init --model openai:gpt-4o
37
+
38
+ # Inspect the configured slots
39
+ deepclause show-model
40
+
41
+ # Start the fullscreen conductor TUI
42
+ deepclause
43
+
44
+ # Or run one headless conductor turn
45
+ deepclause -p "Summarize the repository architecture"
46
+ ```
47
+
48
+ ### One-off usage with npx
49
+
50
+ ```bash
51
+ npx deepclause-sdk@latest init --model openai:gpt-4o
52
+ npx deepclause-sdk@latest show-model
53
+ npx deepclause-sdk@latest
54
+ ```
55
+
56
+ All commands except `init`, `help`, `--help`, `--version`, and `-V` expect a `.deepclause/` directory in the current workspace.
57
+
58
+ `deepclause init` creates:
59
+
60
+ - `.deepclause/config.json`
61
+ - `.deepclause/tools/`
62
+ - `.deepclause/system/`
63
+ - `.deepclause/.gitignore`
64
+ - seeded local skills: `deep-research` and `research-search-reader`
65
+ - editable system overrides:
66
+ - `conductor.dml`
67
+ - `skill-creator.dml`
68
+ - `CONDUCTOR_PROMPT.md`
69
+ - `DML_COMPILER_PROMPT.md`
70
+
71
+ ## TUI Agent
72
+
73
+ Running `deepclause` with no subcommand starts the fullscreen TUI.
74
+
75
+ - Session list on the left
76
+ - Messages in the center
77
+ - Execution log and context summary on the right
78
+ - Slash commands such as `/new`, `/sessions`, `/set-model <model> [--slot <slot>]`, `/compile <spec>`, `/skill-creator <spec>`, `/cancel`, and `/<skill> [args]`
79
+ - Direct shell commands with `!<command>`, streamed live in the execution pane and cancelled with `/cancel`
80
+
81
+ For non-interactive use, `deepclause -p "..."` runs a single headless conductor turn with a fresh session.
82
+
83
+ ### Basic Structure
84
+
85
+ The TUI is the interface around a single built-in agent: the conductor.
86
+
87
+ - The TUI itself is just the UI shell: session browser, messages pane, execution log, and context view.
88
+ - The conductor is the actual agent that receives your prompt each turn and decides what to do.
89
+ - The conductor is implemented as a system DML skill plus a system prompt.
90
+ - The conductor can answer directly, call an existing local skill, invoke the skill creator to make a new skill, use shell tools, or do web research.
91
+
92
+ Conceptually, a TUI turn works like this:
93
+
94
+ 1. Load the current session from `.deepclause/sessions/<session-id>/`.
95
+ 2. Build the conductor prompt from the resolved conductor prompt template, the current skill catalog, assistant memory, task memory, and session transcript.
96
+ 3. Run the conductor DML with the `gateway` model slot.
97
+ 4. Stream the conductor's own activity and any child-skill events into the execution log on the right.
98
+ 5. Persist the final user/assistant messages and updated usage counters back into the session directory.
99
+
100
+ The conductor is the router and orchestrator for the CLI runtime. Normal compiled skills are the workers it delegates to. When the conductor launches a normal skill, that skill runs with the `run` model slot. When it launches the skill creator, that child run uses the `compile` model slot instead.
101
+
102
+ ### Memory Tools
103
+
104
+ The memory tools are there so the conductor can keep durable technical notes across turns instead of re-deriving everything from scratch every time.
105
+
106
+ - `messages.jsonl` is the conversation transcript. This is the raw history of user and assistant messages.
107
+ - `assistant-memory.md` is long-lived assistant context that gets injected into the conductor prompt each turn.
108
+ - `task-memory.md` is technical working memory: commands that worked, failure modes, local architecture notes, repair strategies, and other distilled learnings.
109
+
110
+ In the conductor DML, the LLM-facing tool is `save_memory`. That tool does not write arbitrary files directly. Instead, it calls the runtime tool `update_memory`, which replaces `task-memory.md` with the complete updated memory contents.
111
+
112
+ That distinction matters:
113
+
114
+ - use the transcript for exact conversation history
115
+ - use task memory for compressed technical learnings that should help future turns
116
+ - use assistant memory for stable higher-level context, tone, or persistent instructions
117
+
118
+ In the current CLI runtime, task memory is the main writable memory channel exposed to the conductor. Assistant memory is loaded and shown in the TUI, but it is not automatically updated by a built-in conductor tool in the same way.
119
+
120
+ ### Session and Memory Files
121
+
122
+ Each TUI session lives under `.deepclause/sessions/<session-id>/`:
123
+
124
+ ```text
125
+ .deepclause/
126
+ sessions/
127
+ <session-id>/
128
+ session.json
129
+ messages.jsonl
130
+ assistant-memory.md
131
+ task-memory.md
132
+ usage.json
133
+ specs/
134
+ ```
135
+
136
+ - `session.json` stores the session title and timestamps.
137
+ - `messages.jsonl` is the append-only user/assistant transcript that gets replayed into future conductor turns.
138
+ - `assistant-memory.md` is loaded into the conductor prompt as stable assistant context.
139
+ - `task-memory.md` is loaded into the conductor prompt as technical working memory.
140
+ - `usage.json` stores token usage summaries by model.
141
+ - `specs/` is used when the conductor invokes the skill creator and saves generated spec drafts for that session.
142
+
143
+ In the CLI runtime today, task memory is the actively updated memory channel: the conductor can call `save_memory`, which persists through `update_memory` into `task-memory.md`. `assistant-memory.md` is still loaded every turn, but it is primarily something you inspect or edit manually unless you build additional tooling around it.
144
+
145
+ ### Hacking the Conductor and Skill Creator
146
+
147
+ There are two levels of customization.
148
+
149
+ #### 1. Workspace-local system overrides
150
+
151
+ If you want to customize behavior for one workspace without modifying the package, place override files here:
152
+
153
+ - `.deepclause/system/conductor.dml`
154
+ - `.deepclause/system/skill-creator.dml`
155
+ - `.deepclause/system/CONDUCTOR_PROMPT.md`
156
+ - `.deepclause/system/DML_COMPILER_PROMPT.md`
157
+
158
+ When present, the CLI runtime prefers those files over the packaged system DML and system prompt markdown.
159
+
160
+ #### 2. Source-level hacking in this repository
161
+
162
+ If you are developing DeepClause itself, these are the main files to edit:
163
+
164
+ - `src/system/assets/skills/conductor.dml` - the conductor's DML logic
165
+ - `src/system/assets/skills/skill-creator.dml` - the skill creator's DML logic
166
+ - `src/system/assets/docs/CONDUCTOR_PROMPT.md` - the conductor system prompt template
167
+ - `src/system/assets/docs/DML_COMPILER_PROMPT.md` - the skill creator/compiler system prompt template
168
+ - `src/system/runtime/conductor.ts` - session loading, memory injection, tool registration, child-skill routing
169
+ - `src/system/runtime/skill-creator.ts` - compile-slot execution, skill-creator tool registration, validation/testing/deploy flow
170
+
171
+ Notes:
172
+
173
+ - The conductor uses the `gateway` model slot.
174
+ - Normal compiled skills use the `run` model slot.
175
+ - The skill creator uses the `compile` model slot.
176
+ - The TUI context pane shows the resolved source paths for the conductor DML/prompt and skill creator DML/prompt.
177
+ - Changes to those `.deepclause/system/` files are picked up on the next conductor turn or skill-creator run; a dedicated TUI reload is not required.
178
+
179
+ After source-level changes, rebuild the package:
180
+
181
+ ```bash
182
+ npm install
183
+ npm run build
184
+ ```
185
+
186
+ If you want to run the CLI from a source checkout while hacking on it:
187
+
188
+ ```bash
189
+ npm install
190
+ npm run build
191
+ npm run cli -- init
192
+ npm run cli --
193
+ ```
194
+
195
+ ## Model and Provider Configuration
196
+
197
+ DeepClause separates model choice into three slots:
198
+
199
+ - `gateway` - conductor and orchestration turns
200
+ - `run` - compiled skill execution
201
+ - `compile` - skill compilation and `_skill-creator`
202
+
203
+ The canonical model id format is `provider:model`, but the CLI also accepts `provider/model` and, for common built-ins, bare model names that it can infer.
204
+
205
+ Example `.deepclause/config.json`:
206
+
207
+ ```json
208
+ {
209
+ "models": {
210
+ "gateway": "openai:gpt-4o",
211
+ "run": "openrouter:google/gemini-2.5-flash",
212
+ "compile": "anthropic:claude-sonnet-4-20250514"
213
+ },
214
+ "temperatures": {
215
+ "gateway": 0.7,
216
+ "run": 0.7,
217
+ "compile": 0.4
218
+ },
219
+ "providers": {
220
+ "openai": {
221
+ "apiKey": "${OPENAI_API_KEY}"
222
+ },
223
+ "anthropic": {
224
+ "apiKey": "${ANTHROPIC_API_KEY}"
225
+ },
226
+ "google": {
227
+ "apiKey": "${GOOGLE_GENERATIVE_AI_API_KEY}"
228
+ },
229
+ "openrouter": {
230
+ "apiKey": "${OPENROUTER_API_KEY}",
231
+ "baseUrl": "https://openrouter.ai/api/v1"
232
+ }
233
+ },
234
+ "agentvm": {
235
+ "network": false
236
+ },
237
+ "workspace": "./workspace",
238
+ "dmlBase": ".deepclause/tools"
239
+ }
240
+ ```
241
+
242
+ Configuration values support `${ENV_VAR}` and `$ENV_VAR` interpolation.
243
+
244
+ ### Setting Models from the CLI
245
+
246
+ ```bash
247
+ # Update all three slots
248
+ deepclause set-model openai:gpt-4o
249
+
250
+ # Only change the compile slot
251
+ deepclause set-model anthropic:claude-sonnet-4-20250514 --slot compile
252
+
253
+ # Use OpenRouter for the conductor only
254
+ deepclause set-model openrouter:google/gemini-2.5-flash --slot gateway
255
+
256
+ # Inspect the resolved slot values
257
+ deepclause show-model
258
+ ```
259
+
260
+ ### Provider Notes
261
+
262
+ | Provider | Canonical example | API key env var | Notes |
263
+ |----------|-------------------|-----------------|-------|
264
+ | OpenAI | `openai:gpt-4o` | `OPENAI_API_KEY` | You can also set `providers.openai.baseUrl` for an OpenAI-compatible endpoint. |
265
+ | Anthropic | `anthropic:claude-sonnet-4-20250514` | `ANTHROPIC_API_KEY` | Native Anthropic adapter. |
266
+ | Google | `google:gemini-2.5-flash` | `GOOGLE_GENERATIVE_AI_API_KEY` | Native Google Generative AI adapter. |
267
+ | OpenRouter | `openrouter:anthropic/claude-sonnet-4` | `OPENROUTER_API_KEY` | Use any OpenRouter model path. |
268
+ | Custom | `custom:local:qwen3-32b` | `LLM_PROVIDER_LOCAL_API_KEY` | Uses the OpenAI-compatible transport with a custom base URL. |
269
+
270
+ ### Custom Provider
271
+
272
+ `custom:` is for OpenAI-compatible endpoints that you want to name explicitly instead of pretending they are one of the built-in providers.
273
+
274
+ Format:
275
+
276
+ ```text
277
+ custom:<provider-name>:<model-name>
278
+ ```
279
+
280
+ Example:
281
+
282
+ ```bash
283
+ export LLM_PROVIDER_LOCAL_BASE_URL="http://localhost:11434/v1"
284
+ export LLM_PROVIDER_LOCAL_API_KEY="dummy"
285
+
286
+ deepclause set-model custom:local:qwen3-32b --slot run
287
+ deepclause show-model
288
+ ```
289
+
290
+ Notes:
291
+
292
+ - `custom:local:qwen3-32b` reads `LLM_PROVIDER_LOCAL_BASE_URL` and `LLM_PROVIDER_LOCAL_API_KEY`.
293
+ - The provider name is uppercased and normalized when constructing env vars, so `custom:my-lab:model-x` becomes `LLM_PROVIDER_MY_LAB_BASE_URL` and `LLM_PROVIDER_MY_LAB_API_KEY`.
294
+ - `custom:` providers are not configured under the `providers` object in `config.json`; they are resolved from env vars.
295
+ - Internally, `custom:` uses the OpenAI-compatible transport, so your endpoint must speak an OpenAI-style chat/completions API.
296
+
19
297
  ## Runtime Model
20
298
 
21
299
  DeepClause executes DML in a local CLI runtime:
@@ -88,24 +366,9 @@ agent_main(SpecUrl) :-
88
366
 
89
367
  Unlike traditional SDD where specs guide but don't control, DeepClause specs **become** the executable. The spec *is* the code—just at a higher abstraction level.
90
368
 
91
- ## Quick Start
369
+ ## Compile and Run a Skill
92
370
 
93
371
  ```bash
94
- # Install
95
- npm install -g deepclause-sdk
96
-
97
- # Set API key (or ANTHROPIC_API_KEY, GOOGLE_API_KEY, etc.)
98
- export OPENAI_API_KEY="sk-..."
99
-
100
- # Initialize in your project
101
- deepclause init
102
-
103
- # Configure all model slots
104
- deepclause set-model openai:gpt-4o
105
-
106
- # Start the interactive conductor TUI
107
- deepclause
108
-
109
372
  # Create a task description
110
373
  cat > .deepclause/tools/explain.md << 'EOF'
111
374
  # Code Explainer
@@ -127,20 +390,21 @@ deepclause compile .deepclause/tools/explain.md
127
390
  # Run it
128
391
  deepclause run .deepclause/tools/explain.dml "function fib(n) { return n < 2 ? n : fib(n-1) + fib(n-2) }"
129
392
 
130
- # Or run the conductor headlessly for a single prompt
131
- deepclause -p "Summarize the repository architecture"
393
+ # Or trigger skill creation directly from the TUI with:
394
+ # /compile <spec>
395
+ # /skill-creator <spec>
396
+ # Or update the configured model selection from the TUI with:
397
+ # /set-model openai:gpt-4.1 --slot run
398
+ # Or run a direct workspace shell command with:
399
+ # !npm test
132
400
  ```
133
401
 
134
- ## CLI Modes
402
+ Compilation now runs two security-oriented checks on the generated DML:
135
403
 
136
- `deepclause` with no subcommand starts the fullscreen conductor TUI.
404
+ - Prolog static analysis for taint flow, dangerous tool usage, and capability extraction
405
+ - An LLM security audit that reviews the generated DML and returns a short Markdown report
137
406
 
138
- - Session list on the left
139
- - Messages in the center
140
- - Execution log and context summary on the right
141
- - Slash commands such as `/new`, `/sessions`, `/cancel`, and `/<skill> [args]`
142
-
143
- For non-interactive use, `deepclause -p "..."` runs a single headless conductor turn with a fresh session.
407
+ The LLM audit runs by default for `deepclause compile`, `deepclause compile-all`, and one-shot `deepclause run -p ...`. Use `--no-audit` if you want to skip only the LLM review. Static analysis still runs either way.
144
408
 
145
409
  ## Use Cases
146
410
 
@@ -245,22 +509,22 @@ Analyze a CSV file and describe its contents.
245
509
 
246
510
  ## Available Tools
247
511
 
248
- Skills can use these built-in tools:
512
+ Common built-in runtime tools:
249
513
 
250
514
  | Tool | Description |
251
515
  |------|-------------|
252
- | `web_search` | Search the web (requires `BRAVE_API_KEY`) |
516
+ | `web_search` | Search the web using Brave Search (requires `BRAVE_API_KEY`) |
253
517
  | `news_search` | Search recent news |
254
518
  | `url_fetch` | Fetch a URL or save it into the workspace |
255
519
  | `bash` | Run shell commands in the active workspace shell |
256
520
  | `vm_exec` | Alias of `bash`; with `--sandbox`, runs in AgentVM |
257
- | `ask_user` | Prompt the user for input |
258
521
 
259
- Additional tools can come from configured MCP servers.
522
+ Some tools are runtime-role specific rather than globally available to every skill. For example:
260
523
 
261
- Configure runtime behavior in `.deepclause/config.json`.
524
+ - the conductor adds tools such as `run_skill`, `create_skill`, and `update_memory`
525
+ - the skill creator adds tools such as `list_skills`, `write_file`, `validate_dml`, `test_dml`, and `deploy_skill`
262
526
 
263
- MCP support is on the roadmap.
527
+ Additional tools can come from configured MCP servers. Use `deepclause list-tools` to see the built-ins plus anything exposed by your configured MCP servers.
264
528
 
265
529
  ## CLI Reference
266
530
 
@@ -281,73 +545,68 @@ deepclause set-model <model> # Change all slots or one slot with --slot
281
545
 
282
546
  ```bash
283
547
  deepclause run skill.dml "input" \
284
- --model google/gemini-2.5-flash \ # Override the run model for this execution
285
- --stream \ # Stream output
286
- --verbose \ # Show tool calls
287
- --workspace ./data \ # Set working directory
288
- --sandbox # Use AgentVM instead of the local shell
548
+ --model google:gemini-2.5-flash \ # Override the run model for this execution
549
+ --stream \ # Stream output
550
+ --verbose \ # Show tool calls
551
+ --workspace ./data \ # Set working directory
552
+ --sandbox # Use AgentVM instead of the local shell
289
553
  ```
290
554
 
291
- ## Configuration
555
+ ### Compile Options
292
556
 
293
- `.deepclause/config.json`:
294
- ```json
295
- {
296
- "models": {
297
- "gateway": "openai:gpt-4o",
298
- "run": "openai:gpt-4o",
299
- "compile": "openai:gpt-4o"
300
- },
301
- "temperatures": {
302
- "gateway": 0.7,
303
- "run": 0.7,
304
- "compile": 0.4
305
- },
306
- "agentvm": { "network": true }
307
- }
308
- ```
557
+ `deepclause compile` and `deepclause compile-all` use the `compile` model slot. They accept `--model`, `--provider`, `--temperature`, `--max-attempts`, `--sandbox`, and `--no-audit`.
309
558
 
310
- ### System Overrides
559
+ Static analysis always runs. `--no-audit` disables only the LLM security audit.
311
560
 
312
- If you place system DML files in `.deepclause/system`, the CLI runtime will prefer them over the packaged defaults.
561
+ One-shot prompt mode uses the same compile pipeline before execution, so `deepclause run -p "..." --no-audit` disables the LLM audit there as well.
313
562
 
314
- - `.deepclause/system/conductor.dml`
315
- - `.deepclause/system/skill-creator.dml`
563
+ ```bash
564
+ deepclause compile skill.md \
565
+ --model claude-sonnet-4-20250514 \
566
+ --provider anthropic \
567
+ --temperature 0.2 \
568
+ --max-attempts 4
569
+
570
+ deepclause compile-all ./specs \
571
+ --model claude-sonnet-4-20250514 \
572
+ --provider anthropic \
573
+ --no-audit
574
+ ```
316
575
 
317
- ### Model at Compile Time vs Run Time
576
+ ## Configuration
318
577
 
319
- DeepClause separates model selection into three slots:
578
+ The main configuration surface is `.deepclause/config.json`.
320
579
 
321
- - `gateway`: conductor and orchestration turns
322
- - `run`: compiled skill execution
323
- - `compile`: skill compilation
580
+ The most important fields are covered above in:
324
581
 
325
- At execution time, you can still override the run model for a single command:
582
+ - [Install and Run](#install-and-run)
583
+ - [TUI Conductor](#tui-conductor)
584
+ - [Model and Provider Configuration](#model-and-provider-configuration)
326
585
 
327
- ```bash
328
- # Set all slots
329
- deepclause set-model openai:gpt-4o
586
+ Other useful config fields:
330
587
 
331
- # Or tune a single slot
332
- deepclause set-model anthropic:claude-sonnet-4-20250514 --slot compile
333
-
334
- # Compile with the compile slot
335
- deepclause compile research.md
336
-
337
- # Run with a different one-off model override
338
- deepclause run research.dml "quantum computing" --model google/gemini-2.5-flash
588
+ ```json
589
+ {
590
+ "agentvm": {
591
+ "network": false
592
+ },
593
+ "workspace": "./workspace",
594
+ "dmlBase": ".deepclause/tools",
595
+ "mcp": {
596
+ "servers": {
597
+ "filesystem": {
598
+ "command": "npx",
599
+ "args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
600
+ }
601
+ }
602
+ }
603
+ }
339
604
  ```
340
605
 
341
- This lets you keep different defaults for orchestration, skill execution, and compilation without constantly editing prompts or code.
342
-
343
- ### Supported Models
344
-
345
- | Provider | Models |
346
- |----------|--------|
347
- | OpenAI | `gpt-4o`, `gpt-4o-mini`, `o1`, `o3-mini` |
348
- | Anthropic | `claude-sonnet-4-20250514`, `claude-3-5-sonnet-20241022` |
349
- | Google | `gemini-2.5-pro`, `gemini-2.5-flash` |
350
- | OpenRouter | Any model via `openrouter/provider/model` |
606
+ - `agentvm.network` controls whether shell commands in `--sandbox` mode get outbound network access.
607
+ - `workspace` sets the default working directory used by shell/file tools.
608
+ - `dmlBase` changes where compiled local skills are written.
609
+ - `mcp.servers` registers MCP servers that then appear in `deepclause list-tools`.
351
610
 
352
611
  ## Understanding DML
353
612
 
@@ -5,7 +5,9 @@
5
5
  * with LLM generation and Prolog validation.
6
6
  */
7
7
  import { type Provider } from './config.js';
8
+ import type { DMLEvent } from '../types.js';
8
9
  import { extractDescription as extractDescriptionFromCompiler, extractParameters as extractParametersFromCompiler, extractToolDependencies as extractToolDependenciesFromCompiler } from '../compiler.js';
10
+ import type { AnalysisResult } from '../types.js';
9
11
  export interface CompileOptions {
10
12
  force?: boolean;
11
13
  validateOnly?: boolean;
@@ -17,6 +19,10 @@ export interface CompileOptions {
17
19
  verbose?: boolean;
18
20
  stream?: boolean;
19
21
  audit?: boolean;
22
+ headless?: boolean;
23
+ trace?: string;
24
+ signal?: AbortSignal;
25
+ onEvent?: (event: DMLEvent) => void;
20
26
  }
21
27
  export interface CompileResult {
22
28
  output: string;
@@ -27,6 +33,10 @@ export interface CompileResult {
27
33
  meta?: MetaFile;
28
34
  explanation?: string;
29
35
  attempts?: number;
36
+ analysis?: AnalysisResult;
37
+ runtimeOutput?: string[];
38
+ trace?: object;
39
+ events?: DMLEvent[];
30
40
  }
31
41
  export interface CompileAllResult {
32
42
  compiled: number;
@@ -1 +1 @@
1
- {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/cli/compile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OA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AAS,EAAE,MAAM,EACjB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CA2KxB;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,gBAAgB,CAAC,CA+C3B;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA8B3C;AAyBD,eAAO,MAAM,uBAAuB,4CAAsC,CAAC;AAC3E,eAAO,MAAM,iBAAiB,sCAAgC,CAAC;AAC/D,eAAO,MAAM,kBAAkB,uCAAiC,CAAC;AAEjE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAqCnF"}
@@ -70,7 +70,8 @@ class StatusIndicator {
70
70
  export async function compile(sourcePath, outputDir, options = {}) {
71
71
  const maxAttempts = options.maxAttempts ?? 3;
72
72
  const verbose = options.verbose ?? false;
73
- const shouldStream = options.stream ?? true;
73
+ const shouldStream = options.stream ?? false;
74
+ const shouldAudit = options.audit !== false;
74
75
  // Resolve paths
75
76
  const absoluteSource = path.resolve(sourcePath);
76
77
  const absoluteOutputDir = path.resolve(outputDir);
@@ -126,9 +127,28 @@ export async function compile(sourcePath, outputDir, options = {}) {
126
127
  });
127
128
  applyResolvedModelConfig(compileSelection);
128
129
  const runSelection = resolveModelSlot(config, 'run');
129
- // Status indicator
130
- const status = new StatusIndicator(verbose || shouldStream);
131
- status.start(`Compiling...`);
130
+ const runtimeOutput = [];
131
+ const events = [];
132
+ let executionTrace;
133
+ const captureEvents = (options.headless
134
+ || shouldStream
135
+ || verbose
136
+ || !!options.trace
137
+ || !!options.onEvent);
138
+ const status = new StatusIndicator(!captureEvents);
139
+ if (!captureEvents) {
140
+ status.start('Compiling...');
141
+ }
142
+ const handleEvent = (event) => {
143
+ events.push(event);
144
+ if (event.type === 'output' && event.content) {
145
+ runtimeOutput.push(event.content);
146
+ }
147
+ if ((event.type === 'finished' || event.type === 'error') && event.trace) {
148
+ executionTrace = event.trace;
149
+ }
150
+ options.onEvent?.(event);
151
+ };
132
152
  try {
133
153
  const result = await compileWithSkillCreator(markdown, {
134
154
  sourcePath: absoluteSource,
@@ -143,18 +163,31 @@ export async function compile(sourcePath, outputDir, options = {}) {
143
163
  validateOnly: options.validateOnly,
144
164
  maxAttempts,
145
165
  verbose,
166
+ stream: shouldStream,
167
+ trace: !!options.trace,
168
+ audit: shouldAudit,
146
169
  onUserInput: promptUser,
170
+ signal: options.signal,
171
+ onEvent: handleEvent,
147
172
  });
148
- status.stop();
149
- if (result.analysis.warnings.length > 0) {
173
+ if (!captureEvents) {
174
+ status.stop();
175
+ }
176
+ if (options.trace && executionTrace) {
177
+ const tracePath = path.resolve(options.trace);
178
+ await fs.writeFile(tracePath, JSON.stringify(executionTrace, null, 2) + '\n');
179
+ }
180
+ if (!options.onEvent && !options.headless && result.analysis.warnings.length > 0) {
150
181
  console.log('\n⚠️ Static Analysis Warnings:');
151
182
  for (const warning of result.analysis.warnings) {
152
183
  const icon = warning.level === 'critical' ? '🔴' : warning.level === 'high' ? '🟠' : warning.level === 'medium' ? '🟡' : '⚪';
153
184
  console.log(` ${icon} [${warning.level.toUpperCase()}] ${warning.message}`);
154
185
  }
155
186
  }
156
- console.log('\n✅ Compilation successful!\n');
157
- console.log(result.explanation);
187
+ if (!options.onEvent && !options.headless) {
188
+ console.log('\n✅ Compilation successful!\n');
189
+ console.log(result.explanation);
190
+ }
158
191
  return {
159
192
  output: dmlPath,
160
193
  tools: result.tools,
@@ -164,11 +197,27 @@ export async function compile(sourcePath, outputDir, options = {}) {
164
197
  meta: result.meta,
165
198
  explanation: result.explanation,
166
199
  attempts: 1,
200
+ analysis: result.analysis,
201
+ runtimeOutput,
202
+ trace: executionTrace,
203
+ events,
167
204
  };
168
205
  }
169
206
  catch (error) {
170
- status.stop();
171
- throw error;
207
+ if (!captureEvents) {
208
+ status.stop();
209
+ }
210
+ if (options.trace && executionTrace) {
211
+ const tracePath = path.resolve(options.trace);
212
+ await fs.writeFile(tracePath, JSON.stringify(executionTrace, null, 2) + '\n');
213
+ }
214
+ const compileError = error instanceof Error
215
+ ? error
216
+ : new Error(String(error));
217
+ compileError.runtimeOutput = runtimeOutput;
218
+ compileError.trace = executionTrace;
219
+ compileError.events = events;
220
+ throw compileError;
172
221
  }
173
222
  }
174
223
  /**
@@ -199,7 +248,8 @@ export async function compileAll(sourceDir, outputDir, options = {}) {
199
248
  const compileResult = await compile(sourcePath, absoluteOutputDir, {
200
249
  ...options,
201
250
  stream: false, // Don't stream when batch compiling
202
- verbose: false
251
+ verbose: false,
252
+ headless: true,
203
253
  });
204
254
  if (compileResult.skipped) {
205
255
  result.skipped++;
@@ -242,6 +292,7 @@ export async function compilePrompt(prompt, options = {}) {
242
292
  validateOnly: true,
243
293
  maxAttempts: options.maxAttempts,
244
294
  verbose: options.verbose,
295
+ audit: options.audit !== false,
245
296
  onUserInput: promptUser,
246
297
  });
247
298
  return {