deepclause-sdk 0.0.88 → 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/LICENSE +21 -0
- package/README.md +418 -914
- package/dist/agent.d.ts +19 -2
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +221 -4
- package/dist/agent.js.map +1 -1
- package/dist/cli/config.d.ts +323 -176
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +146 -188
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/index.d.ts +3 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +61 -425
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/login.d.ts +29 -0
- package/dist/cli/login.d.ts.map +1 -0
- package/dist/cli/login.js +184 -0
- package/dist/cli/login.js.map +1 -0
- package/dist/cli/readline.d.ts +6 -0
- package/dist/cli/readline.d.ts.map +1 -0
- package/dist/cli/readline.js +15 -0
- package/dist/cli/readline.js.map +1 -0
- package/dist/cli/repl-bin.d.ts +9 -0
- package/dist/cli/repl-bin.d.ts.map +1 -0
- package/dist/cli/repl-bin.js +16 -0
- package/dist/cli/repl-bin.js.map +1 -0
- package/dist/cli/repl.d.ts +191 -0
- package/dist/cli/repl.d.ts.map +1 -0
- package/dist/cli/repl.js +1232 -0
- package/dist/cli/repl.js.map +1 -0
- package/dist/cli/run.d.ts +17 -18
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +196 -183
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/set-backend.d.ts +53 -0
- package/dist/cli/set-backend.d.ts.map +1 -0
- package/dist/cli/set-backend.js +259 -0
- package/dist/cli/set-backend.js.map +1 -0
- package/dist/cli/visualize.d.ts +38 -0
- package/dist/cli/visualize.d.ts.map +1 -0
- package/dist/cli/visualize.js +125 -0
- package/dist/cli/visualize.js.map +1 -0
- package/dist/compiler.d.ts +5 -52
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +4 -768
- package/dist/compiler.js.map +1 -1
- package/dist/index.d.ts +29 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -2
- package/dist/index.js.map +1 -1
- package/dist/judge/index.d.ts +9 -0
- package/dist/judge/index.d.ts.map +1 -0
- package/dist/judge/index.js +6 -0
- package/dist/judge/index.js.map +1 -0
- package/dist/judge/jev.d.ts +21 -0
- package/dist/judge/jev.d.ts.map +1 -0
- package/dist/judge/jev.js +218 -0
- package/dist/judge/jev.js.map +1 -0
- package/dist/judge/llm.d.ts +23 -0
- package/dist/judge/llm.d.ts.map +1 -0
- package/dist/judge/llm.js +120 -0
- package/dist/judge/llm.js.map +1 -0
- package/dist/judge/marshal.d.ts +26 -0
- package/dist/judge/marshal.d.ts.map +1 -0
- package/dist/judge/marshal.js +266 -0
- package/dist/judge/marshal.js.map +1 -0
- package/dist/judge/mock.d.ts +28 -0
- package/dist/judge/mock.d.ts.map +1 -0
- package/dist/judge/mock.js +98 -0
- package/dist/judge/mock.js.map +1 -0
- package/dist/judge/types.d.ts +95 -0
- package/dist/judge/types.d.ts.map +1 -0
- package/dist/judge/types.js +23 -0
- package/dist/judge/types.js.map +1 -0
- package/dist/prolog/bridge.d.ts +5 -1
- package/dist/prolog/bridge.d.ts.map +1 -1
- package/dist/prolog/bridge.js +29 -1
- package/dist/prolog/bridge.js.map +1 -1
- package/dist/prolog-src/deepclause_analysis.pl +10 -2
- package/dist/prolog-src/deepclause_mi.pl +2522 -118
- package/dist/repl/agent.d.ts +72 -0
- package/dist/repl/agent.d.ts.map +1 -0
- package/dist/repl/agent.js +366 -0
- package/dist/repl/agent.js.map +1 -0
- package/dist/repl/auth.d.ts +45 -0
- package/dist/repl/auth.d.ts.map +1 -0
- package/dist/repl/auth.js +116 -0
- package/dist/repl/auth.js.map +1 -0
- package/dist/repl/backend.d.ts +290 -0
- package/dist/repl/backend.d.ts.map +1 -0
- package/dist/repl/backend.js +370 -0
- package/dist/repl/backend.js.map +1 -0
- package/dist/repl/compaction.d.ts +122 -0
- package/dist/repl/compaction.d.ts.map +1 -0
- package/dist/repl/compaction.js +318 -0
- package/dist/repl/compaction.js.map +1 -0
- package/dist/repl/export.d.ts +30 -0
- package/dist/repl/export.d.ts.map +1 -0
- package/dist/repl/export.js +23 -0
- package/dist/repl/export.js.map +1 -0
- package/dist/repl/frames.d.ts +21 -0
- package/dist/repl/frames.d.ts.map +1 -0
- package/dist/repl/frames.js +79 -0
- package/dist/repl/frames.js.map +1 -0
- package/dist/repl/harness-tools.d.ts +74 -0
- package/dist/repl/harness-tools.d.ts.map +1 -0
- package/dist/repl/harness-tools.js +121 -0
- package/dist/repl/harness-tools.js.map +1 -0
- package/dist/repl/highlight.d.ts +30 -0
- package/dist/repl/highlight.d.ts.map +1 -0
- package/dist/repl/highlight.js +285 -0
- package/dist/repl/highlight.js.map +1 -0
- package/dist/repl/history.d.ts +234 -0
- package/dist/repl/history.d.ts.map +1 -0
- package/dist/repl/history.js +661 -0
- package/dist/repl/history.js.map +1 -0
- package/dist/repl/index.d.ts +120 -0
- package/dist/repl/index.d.ts.map +1 -0
- package/dist/repl/index.js +107 -0
- package/dist/repl/index.js.map +1 -0
- package/dist/repl/judge.d.ts +51 -0
- package/dist/repl/judge.d.ts.map +1 -0
- package/dist/repl/judge.js +58 -0
- package/dist/repl/judge.js.map +1 -0
- package/dist/repl/markdown.d.ts +25 -0
- package/dist/repl/markdown.d.ts.map +1 -0
- package/dist/repl/markdown.js +103 -0
- package/dist/repl/markdown.js.map +1 -0
- package/dist/repl/picker.d.ts +34 -0
- package/dist/repl/picker.d.ts.map +1 -0
- package/dist/repl/picker.js +81 -0
- package/dist/repl/picker.js.map +1 -0
- package/dist/repl/project-context.d.ts +16 -0
- package/dist/repl/project-context.d.ts.map +1 -0
- package/dist/repl/project-context.js +23 -0
- package/dist/repl/project-context.js.map +1 -0
- package/dist/repl/render.d.ts +160 -0
- package/dist/repl/render.d.ts.map +1 -0
- package/dist/repl/render.js +715 -0
- package/dist/repl/render.js.map +1 -0
- package/dist/repl/session.d.ts +356 -0
- package/dist/repl/session.d.ts.map +1 -0
- package/dist/repl/session.js +1275 -0
- package/dist/repl/session.js.map +1 -0
- package/dist/repl/status.d.ts +100 -0
- package/dist/repl/status.d.ts.map +1 -0
- package/dist/repl/status.js +218 -0
- package/dist/repl/status.js.map +1 -0
- package/dist/repl/tools.d.ts +53 -0
- package/dist/repl/tools.d.ts.map +1 -0
- package/dist/repl/tools.js +307 -0
- package/dist/repl/tools.js.map +1 -0
- package/dist/repl/toolset.d.ts +32 -0
- package/dist/repl/toolset.d.ts.map +1 -0
- package/dist/repl/toolset.js +82 -0
- package/dist/repl/toolset.js.map +1 -0
- package/dist/repl/tui/editor.d.ts +17 -0
- package/dist/repl/tui/editor.d.ts.map +1 -0
- package/dist/repl/tui/editor.js +39 -0
- package/dist/repl/tui/editor.js.map +1 -0
- package/dist/repl/tui/status-bar.d.ts +26 -0
- package/dist/repl/tui/status-bar.d.ts.map +1 -0
- package/dist/repl/tui/status-bar.js +47 -0
- package/dist/repl/tui/status-bar.js.map +1 -0
- package/dist/repl/tui/theme.d.ts +30 -0
- package/dist/repl/tui/theme.d.ts.map +1 -0
- package/dist/repl/tui/theme.js +81 -0
- package/dist/repl/tui/theme.js.map +1 -0
- package/dist/repl/tui/transcript.d.ts +39 -0
- package/dist/repl/tui/transcript.d.ts.map +1 -0
- package/dist/repl/tui/transcript.js +123 -0
- package/dist/repl/tui/transcript.js.map +1 -0
- package/dist/runner.d.ts +145 -13
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +600 -282
- package/dist/runner.js.map +1 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +56 -32
- package/dist/sdk.js.map +1 -1
- package/dist/system/assets/docs/AGENT_PROMPT.md +1373 -0
- package/dist/system/assets/docs/DML_AUTHORING.md +195 -0
- package/dist/system/assets/docs/DML_REFERENCE.md +393 -72
- package/dist/system/assets/docs/HARNESS_EXAMPLES.md +172 -0
- package/dist/system/assets/docs/HARNESS_PATTERNS.md +562 -0
- package/dist/system/assets/docs/META_PROMPT.md +68 -0
- package/dist/system/assets/docs/PROLOG_SNIPPETS.md +117 -0
- package/dist/system/assets/index.d.ts +9 -17
- package/dist/system/assets/index.d.ts.map +1 -1
- package/dist/system/assets/index.js +26 -85
- package/dist/system/assets/index.js.map +1 -1
- package/dist/system/runtime/agentvm-manager.d.ts +9 -2
- package/dist/system/runtime/agentvm-manager.d.ts.map +1 -1
- package/dist/system/runtime/agentvm-manager.js +70 -44
- package/dist/system/runtime/agentvm-manager.js.map +1 -1
- package/dist/system/runtime/media.d.ts +23 -0
- package/dist/system/runtime/media.d.ts.map +1 -0
- package/dist/system/runtime/media.js +55 -0
- package/dist/system/runtime/media.js.map +1 -0
- package/dist/system/runtime/shell-limits.d.ts +21 -0
- package/dist/system/runtime/shell-limits.d.ts.map +1 -0
- package/dist/system/runtime/shell-limits.js +39 -0
- package/dist/system/runtime/shell-limits.js.map +1 -0
- package/dist/system/runtime/shell-manager.d.ts +8 -3
- package/dist/system/runtime/shell-manager.d.ts.map +1 -1
- package/dist/system/runtime/shell-manager.js +56 -39
- package/dist/system/runtime/shell-manager.js.map +1 -1
- package/dist/system/runtime/shell-tool-events.js +5 -0
- package/dist/system/runtime/shell-tool-events.js.map +1 -1
- package/dist/system/runtime/token-usage.d.ts +2 -0
- package/dist/system/runtime/token-usage.d.ts.map +1 -1
- package/dist/system/runtime/token-usage.js +7 -0
- package/dist/system/runtime/token-usage.js.map +1 -1
- package/dist/tools.d.ts +3 -21
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +14 -168
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +149 -118
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +19 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +338 -0
- package/dist/validate.js.map +1 -0
- package/dist/visualize/index.d.ts +52 -0
- package/dist/visualize/index.d.ts.map +1 -0
- package/dist/visualize/index.js +189 -0
- package/dist/visualize/index.js.map +1 -0
- package/package.json +17 -15
- package/src/prolog-src/deepclause_analysis.pl +10 -2
- package/src/prolog-src/deepclause_mi.pl +2522 -118
- package/dist/cli/commands.d.ts +0 -42
- package/dist/cli/commands.d.ts.map +0 -1
- package/dist/cli/commands.js +0 -246
- package/dist/cli/commands.js.map +0 -1
- package/dist/cli/compile.d.ts +0 -99
- package/dist/cli/compile.d.ts.map +0 -1
- package/dist/cli/compile.js +0 -363
- package/dist/cli/compile.js.map +0 -1
- package/dist/cli/default-skills.d.ts +0 -10
- package/dist/cli/default-skills.d.ts.map +0 -1
- package/dist/cli/default-skills.js +0 -206
- package/dist/cli/default-skills.js.map +0 -1
- package/dist/cli/interactive.d.ts +0 -2
- package/dist/cli/interactive.d.ts.map +0 -1
- package/dist/cli/interactive.js +0 -20
- package/dist/cli/interactive.js.map +0 -1
- package/dist/cli/mcp.d.ts +0 -56
- package/dist/cli/mcp.d.ts.map +0 -1
- package/dist/cli/mcp.js +0 -138
- package/dist/cli/mcp.js.map +0 -1
- package/dist/cli/prompt.d.ts +0 -2
- package/dist/cli/prompt.d.ts.map +0 -1
- package/dist/cli/prompt.js +0 -2
- package/dist/cli/prompt.js.map +0 -1
- package/dist/cli/search.d.ts +0 -19
- package/dist/cli/search.d.ts.map +0 -1
- package/dist/cli/search.js +0 -189
- package/dist/cli/search.js.map +0 -1
- package/dist/cli/tool-args.d.ts +0 -2
- package/dist/cli/tool-args.d.ts.map +0 -1
- package/dist/cli/tool-args.js +0 -39
- package/dist/cli/tool-args.js.map +0 -1
- package/dist/cli/tools.d.ts +0 -36
- package/dist/cli/tools.d.ts.map +0 -1
- package/dist/cli/tools.js +0 -229
- package/dist/cli/tools.js.map +0 -1
- package/dist/cli/tui/index.d.ts +0 -22
- package/dist/cli/tui/index.d.ts.map +0 -1
- package/dist/cli/tui/index.js +0 -29
- package/dist/cli/tui/index.js.map +0 -1
- package/dist/cli/tui.d.ts +0 -167
- package/dist/cli/tui.d.ts.map +0 -1
- package/dist/cli/tui.js +0 -5228
- package/dist/cli/tui.js.map +0 -1
- package/dist/compiler_prompt.d.ts +0 -20
- package/dist/compiler_prompt.d.ts.map +0 -1
- package/dist/compiler_prompt.js +0 -870
- package/dist/compiler_prompt.js.map +0 -1
- package/dist/deepclause-cli.skill +0 -0
- package/dist/prolog-src/deepclause_mi.pl.bak +0 -570
- package/dist/system/assets/compactors/default-memory-compactor.dml +0 -6
- package/dist/system/assets/docs/CONDUCTOR_PROMPT.md +0 -105
- package/dist/system/assets/docs/DML_COMPILER_PROMPT.md +0 -700
- package/dist/system/assets/docs/TUI.md +0 -150
- package/dist/system/assets/recipes/deepclause-coding-workflow/SKILL.md +0 -100
- package/dist/system/assets/skills/conductor.dml +0 -76
- package/dist/system/assets/skills/deep-planner.dml +0 -412
- package/dist/system/assets/skills/plan.dml +0 -429
- package/dist/system/assets/skills/security-planner.dml +0 -337
- package/dist/system/assets/skills/skill-creator.dml +0 -187
- package/dist/system/runtime/catalog-recipes.d.ts +0 -24
- package/dist/system/runtime/catalog-recipes.d.ts.map +0 -1
- package/dist/system/runtime/catalog-recipes.js +0 -273
- package/dist/system/runtime/catalog-recipes.js.map +0 -1
- package/dist/system/runtime/catalog-skills.d.ts +0 -50
- package/dist/system/runtime/catalog-skills.d.ts.map +0 -1
- package/dist/system/runtime/catalog-skills.js +0 -152
- package/dist/system/runtime/catalog-skills.js.map +0 -1
- package/dist/system/runtime/conductor.d.ts +0 -105
- package/dist/system/runtime/conductor.d.ts.map +0 -1
- package/dist/system/runtime/conductor.js +0 -732
- package/dist/system/runtime/conductor.js.map +0 -1
- package/dist/system/runtime/console-capture.d.ts +0 -9
- package/dist/system/runtime/console-capture.d.ts.map +0 -1
- package/dist/system/runtime/console-capture.js +0 -67
- package/dist/system/runtime/console-capture.js.map +0 -1
- package/dist/system/runtime/dml-executor.d.ts +0 -52
- package/dist/system/runtime/dml-executor.d.ts.map +0 -1
- package/dist/system/runtime/dml-executor.js +0 -203
- package/dist/system/runtime/dml-executor.js.map +0 -1
- package/dist/system/runtime/runtime-tools.d.ts +0 -31
- package/dist/system/runtime/runtime-tools.d.ts.map +0 -1
- package/dist/system/runtime/runtime-tools.js +0 -312
- package/dist/system/runtime/runtime-tools.js.map +0 -1
- package/dist/system/runtime/skill-creator.d.ts +0 -38
- package/dist/system/runtime/skill-creator.d.ts.map +0 -1
- package/dist/system/runtime/skill-creator.js +0 -763
- package/dist/system/runtime/skill-creator.js.map +0 -1
- package/src/prolog-src/deepclause_mi.pl.bak +0 -570
package/README.md
CHANGED
|
@@ -1,1062 +1,566 @@
|
|
|
1
|
-
# DeepClause
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
The plan-execute variant runs in two phases. In the **plan phase**, a stronger model (qwen3.6-plus) analyzes the travel request and generates a self-contained DML file: it derives a system prompt, decomposes the request into 3-6 focused gathering tasks, and assembles DML program that includes all tool definitions and the execution logic. In the **execute phase**, a cheaper model (qwen3.6-35b-a3b) runs the generated DML.
|
|
74
|
-
|
|
75
|
-
Example for a generated plan:
|
|
1
|
+
# DeepClause SDK
|
|
2
|
+
|
|
3
|
+
DeepClause is a **Prolog-based runtime for self-modifying agent harnesses**. A
|
|
4
|
+
harness created with DeepClause is a self contained library in the form of a **DML** module. DML (DeepClause Meta Language) is a Prolog DSL with added functionality for LLM model calls, semantic
|
|
5
|
+
judgments (Jev-type models), and constraints. An LLM agent embedded in the runtime reads, extends, and tests code in a live module a turn by
|
|
6
|
+
turn. You drive it from an interactive **REPL**. Using the REPL once can successively build a custom harness that is optimized for a specific use case.
|
|
7
|
+
|
|
8
|
+
DML runs on **SWI-Prolog compiled to WebAssembly** — the whole language runtime
|
|
9
|
+
is in-process and portable, with no native Prolog to install.
|
|
10
|
+
|
|
11
|
+
Most agent stacks contain a lot of separate moving parts: tools in one place,
|
|
12
|
+
prompts in another, memory in a third, and the workflow as a graph or a chain
|
|
13
|
+
somewhere else. DML folds them into one idea — a **predicate**. A skill is a
|
|
14
|
+
clause, a tool is a clause, memory and state are clauses, control flow and
|
|
15
|
+
retries are clause order and backtracking, and a workflow is simply predicates
|
|
16
|
+
calling predicates. Because it is one language in one self-contained file, the
|
|
17
|
+
parts can read, reuse, and extend one another, and a whole harness can be
|
|
18
|
+
inspected, versioned, and moved as a unit.
|
|
19
|
+
|
|
20
|
+
## Dependencies and acknowledgements
|
|
21
|
+
|
|
22
|
+
DeepClause stands on other people's work, and is grateful for it:
|
|
23
|
+
|
|
24
|
+
- **[Pi](https://pi.dev)** (`@earendil-works/pi-coding-agent` and
|
|
25
|
+
`@earendil-works/pi-ai`) — the `pi` backend reuses Pi's model catalog,
|
|
26
|
+
credential store, streaming, cancellation, and usage accounting, and the
|
|
27
|
+
interactive REPL TUI is built on Pi's terminal UI library
|
|
28
|
+
(`@earendil-works/pi-tui`). Thanks to the **Pi developers** for building and
|
|
29
|
+
sharing it.
|
|
30
|
+
- **[SWI-Prolog](https://www.swi-prolog.org/)** — the Prolog engine that DML
|
|
31
|
+
runs on, compiled to WebAssembly so the whole runtime is in-process and
|
|
32
|
+
portable. SWI-Prolog is created and maintained by **Jan Wielemaker** and the
|
|
33
|
+
SWI-Prolog community.
|
|
34
|
+
- **[Markus Triska](https://www.metalevel.at/)** — his work on
|
|
35
|
+
meta-interpreters, constraint logic programming, and the
|
|
36
|
+
`library(clpfd)`/`library(clpq)` libraries underpins DML's executable
|
|
37
|
+
meta-interpreter and constraint layer.
|
|
38
|
+
|
|
39
|
+
DML, the REPL, and the SDK are original work; these projects are used as
|
|
40
|
+
dependencies and as conceptual foundations.
|
|
41
|
+
|
|
42
|
+
## Why would I use this?
|
|
43
|
+
|
|
44
|
+
- **Reproducibility.** Control flow, retries, and validation are Prolog clauses
|
|
45
|
+
you can read and re-run, so a DML harness tends to produce the same result shape
|
|
46
|
+
across sessions and machines. The model is consulted only at the points you
|
|
47
|
+
choose, and its outputs are typed where that helps.
|
|
48
|
+
- **Auditability.** Each turn is a transaction: the module is snapshotted, the
|
|
49
|
+
change is committed replace-by-predicate, and the session, event trace, and
|
|
50
|
+
harness versions are recorded and remain queryable. It is possible to see what
|
|
51
|
+
changed, when, and in response to what.
|
|
52
|
+
- **Regulated and high-stakes settings.** Where a workflow has to be reviewed,
|
|
53
|
+
versioned, and reproduced — and where it helps to keep deterministic logic
|
|
54
|
+
separate from model judgment — a small, inspectable harness is easier to
|
|
55
|
+
scrutinise than a prompt. The transaction record and `rollback.` are meant to
|
|
56
|
+
support that kind of review, not replace it.
|
|
57
|
+
- **Research in neurosymbolic AI.** DML offers a concrete substrate for
|
|
58
|
+
combining symbolic reasoning (Prolog, CLP, backtracking) with LLM calls and
|
|
59
|
+
semantic judgments in one program, and for studying how such a system behaves
|
|
60
|
+
as an agent edits it over time (transactions, history, rollback).
|
|
61
|
+
|
|
62
|
+
It is likely not worth it when a single prompt or a short script is enough, or
|
|
63
|
+
when there is no structure you would want to reuse, review, or reproduce.
|
|
64
|
+
|
|
65
|
+
## The REPL: a living, self-modifying harness
|
|
66
|
+
|
|
67
|
+
The REPL keeps a persistent DML module ("the harness"). You talk to it in two ways:
|
|
68
|
+
|
|
69
|
+
| Input | Mode |
|
|
70
|
+
|---|---|
|
|
71
|
+
| `<plain English>` (default) | **author** — the agent writes, tests, and commits DML |
|
|
72
|
+
| `/goal <dml>` | **run** — query the current harness |
|
|
76
73
|
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
run_tool(ToolName, ArgsDict, Result) :-
|
|
83
|
-
param(db_path, DbPath),
|
|
84
|
-
param(bridge_dir, BridgeDir),
|
|
85
|
-
param(bench_dir, BenchDir),
|
|
86
|
-
param(python_path, PythonPath),
|
|
87
|
-
(var(PythonPath) -> PythonPath = 'python3' ; true),
|
|
88
|
-
atom_json_dict(ArgsJson, ArgsDict, []),
|
|
89
|
-
format(string(ArgsFile), ".dc_bridge_~w.json", [ToolName]),
|
|
90
|
-
exec(write_file(path: ArgsFile, content: ArgsJson), _),
|
|
91
|
-
format(string(Cmd), "~w '~w/python-bridge.py' --domain travel --db-path '~w' --bench-dir '~w' --tool ~w --args-file '~w'", [PythonPath, BridgeDir, DbPath, BenchDir, ToolName, ArgsFile]),
|
|
92
|
-
exec(bash(command: Cmd), Raw),
|
|
93
|
-
parse_bridge_result(Raw, Result).
|
|
94
|
-
|
|
95
|
-
tool(query_train_info(Origin, Dest, Date, Result),
|
|
96
|
-
"Search for train tickets between two cities on a given date. Returns train number, times, stations, duration, seat class, remaining seats, price.") :-
|
|
97
|
-
run_tool(query_train_info, _{origin: Origin, destination: Dest, depDate: Date}, Result).
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
[ ... more tool definitions ...]
|
|
101
|
-
|
|
102
|
-
agent_main(Request) :-
|
|
103
|
-
system("You are a travel planning agent creating a detailed itinerary for 4 travelers from Zhengzhou to Quanzhou (Nov 12-15, 2025). Execute the planned gathering steps autonomously without asking for user input.\n\nRULES:\n- All information must come from tool results — never fabricate names, prices, or details\n- Restaurant names must be EXACT matches from recommend_restaurants/query_restaurant_details results\n- Use recommend_restaurants with attraction/hotel coordinates passed as STRINGS, not restaurant coordinates\n- Current City on intercity travel days must use 'from CityA to CityB' format (literal 'from' and 'to')\n- Budget: all prices are per-unit; multiply by number of travelers/rooms in the final summary\n- Schedule times must be continuous with no gaps; do not schedule breakfast; full days require lunch+dinner\n- Last day (Nov 15) must end at the departure airport/station for the return journey\n- Select the shortest-duration direct outbound flight, a 4-star hotel with free parking, the 3 highest-rated attractions, and the cheapest restaurant in Donghai Bay area\n\nProceed through all gathering steps, then compile the complete itinerary with continuous daily schedules, exact venue names, and accurate budget calculations."),
|
|
104
|
-
user(Request),
|
|
105
|
-
task("Search for direct flights from Zhengzhou to Quanzhou on November 12, 2025, and return flights from Quanzhou to Zhengzhou on November 15, 2025, for 4 passengers, identif
|
|
106
|
-
ying the shortest-duration direct flight option for the outbound journey."),
|
|
107
|
-
task("Search for four-star hotels in Quanzhou with free parking available for check-in on November 12, 2025 and check-out on November 15, 2025, accommodating 4 guests."),
|
|
108
|
-
task("Search for and recommend top-rated attractions in Quanzhou, then retrieve details to identify the three highest-rated attractions."),
|
|
109
|
-
task("Search for restaurants in the Donghai Bay area of Quanzhou and find the one with the lowest average spending per person."),
|
|
110
|
-
task('Based on all gathered information, generate the complete travel itinerary inside <plan></plan> tags. Include day-by-day schedule with times, Current City, attractions,
|
|
111
|
-
meals with EXACT restaurant names from tool results, transport details, and a budget summary where per-unit costs are multiplied by number of travelers/rooms.', string(DraftPlan)
|
|
112
|
-
),
|
|
113
|
-
task('Review this travel plan for errors and fix them. Check ALL of the following:
|
|
114
|
-
1. BUDGET: Is total cost (per-person costs * travelers, per-room costs * rooms) within budget?
|
|
115
|
-
2. TIME CONTINUITY: Are times continuous with no gaps or overlaps? Each activity end time = next start time.
|
|
116
|
-
3. MEAL RULES: Full sightseeing days need lunch AND dinner. No breakfast. Meals 1-2 hours. At least 2 hours between lunch and dinner.
|
|
117
|
-
4. DAILY STRUCTURE: Every day except last ends at hotel. Last day ends at departure airport/station.
|
|
118
|
-
5. GEOSPATIAL: No teleportation — travel_city between different locations.
|
|
119
|
-
6. DIVERSITY: No repeating restaurants or attractions across days.
|
|
120
|
-
7. NAMES: All names EXACTLY match tool results — no abbreviations or renames.
|
|
121
|
-
8. CURRENT CITY: Intercity days must say "from CityA to CityB".
|
|
122
|
-
|
|
123
|
-
Plan to review:
|
|
124
|
-
{DraftPlan}
|
|
125
|
-
|
|
126
|
-
If the plan has errors, output the CORRECTED plan inside <plan></plan> tags. If it is already correct, output it unchanged inside <plan></plan> tags. Store the final verified plan in VerifiedPlan.', string(VerifiedPlan)),
|
|
127
|
-
answer(VerifiedPlan).
|
|
128
|
-
|
|
129
|
-
agent_main(Request) :-
|
|
130
|
-
system('You are a travel planning assistant. Create a travel plan using the available tools. Output inside <plan></plan> tags with budget summary.'),
|
|
131
|
-
user(Request),
|
|
132
|
-
task('Create a complete travel plan using all available tools. Output inside <plan></plan> tags.', string(Plan)),
|
|
133
|
-
answer(Plan).
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
## Install and Run
|
|
139
|
-
|
|
140
|
-
DeepClause requires Node.js 18+.
|
|
141
|
-
|
|
142
|
-
### Global install
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
npm install -g deepclause-sdk
|
|
146
|
-
|
|
147
|
-
# Pick one provider and export its API key
|
|
148
|
-
export OPENAI_API_KEY="sk-..."
|
|
149
|
-
# or: export ANTHROPIC_API_KEY="..."
|
|
150
|
-
# or: export GOOGLE_GENERATIVE_AI_API_KEY="..."
|
|
151
|
-
# or: export OPENROUTER_API_KEY="..."
|
|
152
|
-
|
|
153
|
-
# Initialize the current workspace
|
|
154
|
-
deepclause init --model openai:gpt-4o
|
|
155
|
-
|
|
156
|
-
# Inspect the configured slots
|
|
157
|
-
deepclause show-model
|
|
158
|
-
|
|
159
|
-
# Start the fullscreen conductor TUI
|
|
160
|
-
deepclause
|
|
74
|
+
```text
|
|
75
|
+
dml> add a research(Question, Answer) skill that answers with task/2 and cites sources
|
|
76
|
+
dml> run research on "why is the sky blue?"
|
|
77
|
+
A = "Rayleigh scattering scatters short wavelengths more strongly..."
|
|
161
78
|
|
|
162
|
-
|
|
163
|
-
deepclause -p "Summarize the repository architecture"
|
|
79
|
+
dml> /goal research("why is the sky blue?", A). % the same skill, run directly
|
|
164
80
|
```
|
|
165
81
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
npx deepclause-sdk@latest show-model
|
|
171
|
-
npx deepclause-sdk@latest
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
All commands except `init`, `help`, `--help`, `--version`, and `-V` expect a `.deepclause/` directory in the current workspace.
|
|
175
|
-
|
|
176
|
-
`deepclause init` creates:
|
|
177
|
-
|
|
178
|
-
- `.deepclause/config.json`
|
|
179
|
-
- `.deepclause/tools/`
|
|
180
|
-
- `.deepclause/docs/`
|
|
181
|
-
- `.deepclause/docs/TUI.md`
|
|
182
|
-
- `.deepclause/system/`
|
|
183
|
-
- `.deepclause/system/recipes/`
|
|
184
|
-
- `.deepclause/.gitignore`
|
|
185
|
-
- seeded local skills: `deep-research` and `research-search-reader`
|
|
186
|
-
- seeded example recipe: `deepclause-coding-workflow`
|
|
187
|
-
- editable system overrides:
|
|
188
|
-
- `conductor.dml`
|
|
189
|
-
- `skill-creator.dml`
|
|
190
|
-
- `CONDUCTOR_PROMPT.md`
|
|
191
|
-
- `DML_COMPILER_PROMPT.md`
|
|
192
|
-
- `TASK_PROMPT.md`
|
|
193
|
-
|
|
194
|
-
The default recipe is created at `.deepclause/system/recipes/deepclause-coding-workflow/SKILL.md`. It is a real example, not a placeholder: it teaches the conductor how to approach local repository changes with small edits and focused validation. You can edit it, remove it, or add your own recipes next to it.
|
|
195
|
-
|
|
196
|
-
Recipes are plain markdown guidance, not executable DML. If you want to add or update one, edit `.deepclause/system/recipes/<slug>/SKILL.md` directly. The conductor can search those recipe files on future turns via `consult_recipes`.
|
|
82
|
+
The default mode is the interesting one: describe what you want and the
|
|
83
|
+
authoring agent edits the module for you through tools, testing as it goes. Ask
|
|
84
|
+
for anything — add a skill, add a tool, change existing logic, run or test code
|
|
85
|
+
in the living module, or just ask a question about the harness.
|
|
197
86
|
|
|
198
|
-
|
|
87
|
+
### A worked session
|
|
199
88
|
|
|
200
|
-
|
|
89
|
+
A full pass: create a skill, watch the transaction, run it, export it, and load
|
|
90
|
+
it again as a new harness.
|
|
201
91
|
|
|
202
|
-
|
|
203
|
-
- Messages in the center
|
|
204
|
-
- Execution log and context summary on the right
|
|
205
|
-
- Slash commands such as `/new`, `/sessions`, `/set-model <model> [--slot <slot>]`, `/compile <spec>`, `/skill-creator <spec>`, `/cancel`, and `/<skill> [args]`
|
|
206
|
-
- Direct shell commands with `!<command>`, streamed live in the execution pane and cancelled with `/cancel`
|
|
207
|
-
- Persistent shell commands with `!!<command>`, which also append the command and its output to the active session transcript so the conductor can see them on the next turn
|
|
208
|
-
|
|
209
|
-
Use `!<command>` when you just want an ephemeral shell escape in the execution pane. Use `!!<command>` when the shell result should become part of the conversation state for later conductor turns.
|
|
210
|
-
|
|
211
|
-
For non-interactive use, `deepclause -p "..."` runs a single headless conductor turn with a fresh session.
|
|
212
|
-
|
|
213
|
-
### Basic Structure
|
|
214
|
-
|
|
215
|
-
The TUI is the interface around a single built-in agent: the conductor.
|
|
216
|
-
|
|
217
|
-
- The TUI itself is just the UI shell: session browser, messages pane, execution log, and context view.
|
|
218
|
-
- The conductor is the actual agent that receives your prompt each turn and decides what to do.
|
|
219
|
-
- The conductor is implemented as a system DML skill plus a system prompt.
|
|
220
|
-
- The conductor can answer directly, call an existing local skill, consult the recipe library for workflow guidance, invoke the skill creator to make a new skill, use shell tools, or do web research.
|
|
221
|
-
|
|
222
|
-
Conceptually, a TUI turn works like this:
|
|
223
|
-
|
|
224
|
-
1. Load the current session from `.deepclause/sessions/<session-id>/`.
|
|
225
|
-
2. Build the conductor prompt from the resolved conductor prompt template, the current skill catalog, the recipe library, assistant memory, task memory, and session transcript.
|
|
226
|
-
3. Run the conductor DML with the `gateway` model slot.
|
|
227
|
-
4. Stream the conductor's own activity and any child-skill events into the execution log on the right.
|
|
228
|
-
5. Persist the final user/assistant messages, structured `execution-log.jsonl`, and updated usage counters back into the session directory.
|
|
229
|
-
|
|
230
|
-
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.
|
|
231
|
-
|
|
232
|
-
### Skills, Recipes, and the Conductor
|
|
233
|
-
|
|
234
|
-
DeepClause separates three things that other agent systems often collapse into one prompt surface.
|
|
235
|
-
|
|
236
|
-
- **Conductor**: the built-in router. It owns the conversation, inspects the workspace context, and decides whether to solve directly, run a skill, consult a recipe, or create a new skill.
|
|
237
|
-
- **Skills**: executable DML workers stored in `.deepclause/tools/`. These are compiled programs with explicit tool calls, branching, retries, recursion, and parameters.
|
|
238
|
-
- **Recipes**: markdown guidance stored in `.deepclause/system/recipes/`. These are instruction packs for workflows, conventions, checklists, and examples. They are searched via `consult_recipes`, not executed as child workers.
|
|
239
|
-
- **Skill creator**: the built-in compiler/orchestrator that turns a natural-language spec into a tested local skill.
|
|
240
|
-
|
|
241
|
-
That distinction matters in practice:
|
|
242
|
-
|
|
243
|
-
- Use a **recipe** when you need to know how to approach a task.
|
|
244
|
-
- Use a **skill** when you need a reusable automation that should actually execute.
|
|
245
|
-
- Use the **conductor** when you want the system to choose between those options for the current turn.
|
|
246
|
-
|
|
247
|
-
If the task is to create or refine workflow guidance itself, add or edit a recipe markdown file under `.deepclause/system/recipes/<slug>/SKILL.md`. Do not send recipe authoring through `deepclause compile` unless you actually want an executable skill instead of a guidance document.
|
|
248
|
-
|
|
249
|
-
Minimal recipe example:
|
|
250
|
-
|
|
251
|
-
```md
|
|
252
|
-
---
|
|
253
|
-
name: DeepClause Coding Workflow
|
|
254
|
-
description: Guidance for implementing and validating local repository changes.
|
|
255
|
-
tags: [coding, tests, docs]
|
|
256
|
-
when_to_use:
|
|
257
|
-
- implementing a feature or bug fix in the current repository
|
|
258
|
-
priority: high
|
|
259
|
-
---
|
|
260
|
-
|
|
261
|
-
# Workflow
|
|
262
|
-
|
|
263
|
-
1. Start from a concrete anchor.
|
|
264
|
-
2. Make the smallest grounded edit.
|
|
265
|
-
3. Run the narrowest validation that can falsify it.
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
Minimal skill example:
|
|
92
|
+
**1. Create (one transaction)**
|
|
269
93
|
|
|
270
94
|
```text
|
|
271
|
-
|
|
272
|
-
deepclause run .deepclause/tools/fix-imports.dml src/index.ts
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
The recipe is guidance. The skill is an executable worker.
|
|
95
|
+
dml> add a research(Question, Answer) skill that answers with task/2
|
|
276
96
|
|
|
277
|
-
|
|
97
|
+
⚙ begin_turn
|
|
98
|
+
✔ begin_turn · 2ms
|
|
99
|
+
⚙ assert_many(clauses=module_doc("…"), research(Question, Answer) :- task(…), doc(research/2, …))
|
|
100
|
+
✔ assert_many · 11ms
|
|
101
|
+
⚙ execute
|
|
102
|
+
research("Why is the sky blue?", A).
|
|
103
|
+
▸ Task Answer this research question: Why is the sky blue?
|
|
104
|
+
✔ Task done
|
|
105
|
+
A = "Rayleigh scattering…"
|
|
106
|
+
✔ execute · 3.7s
|
|
107
|
+
⚙ end_turn(summary=Add research/2)
|
|
108
|
+
✔ end_turn · 4ms — {"committed":true,"changed":["+research/2","+module_doc/1","+doc/2"]}
|
|
278
109
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
How it works:
|
|
282
|
-
|
|
283
|
-
1. You provide a request, for example from the TUI as `/plan ...` or through the command listing interface.
|
|
284
|
-
2. DeepClause uses the packaged or workspace-overridden `src/system/assets/skills/plan.dml` implementation to classify the request, collect any needed recipe guidance, and draft a numbered task list.
|
|
285
|
-
3. The plan generator derives a system prompt for the resulting plan, includes the DeepClause coding workflow recipe, and assembles a deterministic `.dml` file.
|
|
286
|
-
4. The generated file is written to `plans/<name>.dml`, validated, and then available to run like any other plan or skill.
|
|
287
|
-
5. In the TUI, `/<plan> [args]` runs a plan from `plans/` when no compiled skill with the same name exists.
|
|
288
|
-
|
|
289
|
-
The important design point is that `plan` does not try to invent a whole new agent architecture each time. It produces a small executable plan file from the request, with the runtime and recipes providing the reusable behavior.
|
|
290
|
-
|
|
291
|
-
### How This Differs From Other Agent Systems
|
|
292
|
-
|
|
293
|
-
Systems like `AGENTS.md`, Cursor rules, Claude Skills, or other instruction-pack formats are mostly about giving the model reusable context. DeepClause supports that same need through **recipes**, but it does not stop there.
|
|
294
|
-
|
|
295
|
-
What is different here:
|
|
296
|
-
|
|
297
|
-
- DeepClause keeps **guidance** and **execution** separate. Recipes are markdown guidance; skills are compiled programs.
|
|
298
|
-
- A DeepClause skill is not just a saved prompt. It is a DML program that the runtime executes with Prolog semantics.
|
|
299
|
-
- The conductor can decide between **consulting a recipe**, **running a compiled skill**, or **creating a new skill**.
|
|
300
|
-
- Model choice is split by role: `gateway` for orchestration, `run` for worker execution, and `compile` for skill creation.
|
|
301
|
-
- The compiled `.dml` is inspectable and versionable, so the automation logic is explicit instead of hidden in a long prompt.
|
|
110
|
+
Added research/2 — a one-call task/2 research skill.
|
|
111
|
+
```
|
|
302
112
|
|
|
303
|
-
|
|
113
|
+
The agent opened a transaction (`begin_turn`), wrote the predicates
|
|
114
|
+
(`assert_many`), tested them with `execute`, and committed with `end_turn` — which
|
|
115
|
+
printed the predicates it changed and recorded a version. Had the turn failed,
|
|
116
|
+
the host would have rolled the module back to exactly its prior state.
|
|
304
117
|
|
|
305
|
-
|
|
118
|
+
**2. Inspect, run, undo**
|
|
306
119
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
120
|
+
```text
|
|
121
|
+
dml> /listing
|
|
122
|
+
skill: Research a question and return a written answer.
|
|
310
123
|
|
|
311
|
-
|
|
124
|
+
doc/2
|
|
125
|
+
doc(research/2,"Answer a question in one model call. research(+Question, -Answer). …").
|
|
312
126
|
|
|
313
|
-
|
|
314
|
-
|
|
127
|
+
module_doc/1
|
|
128
|
+
module_doc("Research a question and return a written answer. …").
|
|
315
129
|
|
|
316
|
-
|
|
130
|
+
research/2
|
|
131
|
+
research(A,B) :-
|
|
132
|
+
task("Answer this question: {A}",B).
|
|
317
133
|
|
|
318
|
-
|
|
134
|
+
dml> /goal research("Why is the sky blue?", A).
|
|
135
|
+
A = "Rayleigh scattering…"
|
|
319
136
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
- use assistant memory for stable higher-level context, tone, or persistent instructions
|
|
137
|
+
dml> /rollback
|
|
138
|
+
rolled back harness: version 1 → 0
|
|
323
139
|
|
|
324
|
-
|
|
140
|
+
dml> /goal research("Why is the sky blue?", A).
|
|
141
|
+
false. % the skill is gone
|
|
142
|
+
```
|
|
325
143
|
|
|
326
|
-
|
|
144
|
+
`end_turn` is the only commit point, and `/rollback` moves the harness back one
|
|
145
|
+
committed version (here, to the baseline) — so nothing is committed silently.
|
|
327
146
|
|
|
328
|
-
|
|
147
|
+
**3. Export**
|
|
329
148
|
|
|
330
149
|
```text
|
|
331
|
-
.
|
|
332
|
-
|
|
333
|
-
<session-id>/
|
|
334
|
-
session.json
|
|
335
|
-
messages.jsonl
|
|
336
|
-
execution-log.jsonl
|
|
337
|
-
assistant-memory.md
|
|
338
|
-
task-memory.md
|
|
339
|
-
usage.json
|
|
340
|
-
specs/
|
|
150
|
+
dml> /export research.dml
|
|
151
|
+
exported 3 clauses, 0 tools, 0 scripts → research.dml
|
|
341
152
|
```
|
|
342
153
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
- `execution-log.jsonl` stores structured JSONL records for conductor turns, direct `/skill` runs, direct `/skill-creator` runs, child-skill events, tool calls, streamed model output, errors, and completion summaries.
|
|
346
|
-
- `assistant-memory.md` is loaded into the conductor prompt as stable assistant context.
|
|
347
|
-
- `task-memory.md` is loaded into the conductor prompt as technical working memory.
|
|
348
|
-
- `usage.json` stores token usage summaries by model.
|
|
349
|
-
- `specs/` is used when the conductor invokes the skill creator and saves generated spec drafts for that session.
|
|
350
|
-
|
|
351
|
-
When a task fails, looks stuck, or needs to be retried, `execution-log.jsonl` is the first file to inspect. It gives you the concrete failing tool call, streamed model behavior, and any successful prior pattern in the same session instead of forcing you to guess from the final transcript alone.
|
|
352
|
-
|
|
353
|
-
In the CLI runtime today, task memory is the actively updated memory channel: the conductor can emit a `MemoryUpdate`, 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.
|
|
354
|
-
|
|
355
|
-
### Hacking the Conductor and Skill Creator
|
|
356
|
-
|
|
357
|
-
There are two levels of customization.
|
|
358
|
-
|
|
359
|
-
#### 1. Workspace-local system overrides
|
|
360
|
-
|
|
361
|
-
If you want to customize behavior for one workspace without modifying the package, place override files here:
|
|
362
|
-
|
|
363
|
-
- `.deepclause/system/conductor.dml`
|
|
364
|
-
- `.deepclause/system/skill-creator.dml`
|
|
365
|
-
- `.deepclause/system/CONDUCTOR_PROMPT.md`
|
|
366
|
-
- `.deepclause/system/DML_COMPILER_PROMPT.md`
|
|
367
|
-
- `.deepclause/system/TASK_PROMPT.md`
|
|
368
|
-
- `.deepclause/system/recipes/<recipe-slug>/SKILL.md`
|
|
369
|
-
|
|
370
|
-
When present, the CLI runtime prefers those files over the packaged system DML and system prompt markdown. For recipes, workspace files override packaged recipes with the same slug.
|
|
371
|
-
|
|
372
|
-
`.deepclause/system/TASK_PROMPT.md` is the markdown template used for `task(...)` and `prompt(...)` harness calls. `deepclause init` seeds it into the workspace, and the runtime resolves that workspace copy before falling back to the packaged default.
|
|
373
|
-
|
|
374
|
-
#### 2. Source-level hacking in this repository
|
|
375
|
-
|
|
376
|
-
If you are developing DeepClause itself, these are the main files to edit:
|
|
377
|
-
|
|
378
|
-
- `src/system/assets/skills/conductor.dml` - the conductor's DML logic
|
|
379
|
-
- `src/system/assets/skills/skill-creator.dml` - the skill creator's DML logic
|
|
380
|
-
- `src/system/assets/docs/CONDUCTOR_PROMPT.md` - the conductor system prompt template
|
|
381
|
-
- `src/system/assets/docs/DML_COMPILER_PROMPT.md` - the skill creator/compiler system prompt template
|
|
382
|
-
- `src/system/assets/docs/TASK_PROMPT.md` - the `task(...)` / `prompt(...)` harness template
|
|
383
|
-
- `src/system/assets/recipes/` - packaged default recipes copied into new workspaces
|
|
384
|
-
- `src/system/runtime/conductor.ts` - session loading, memory injection, tool registration, child-skill routing
|
|
385
|
-
- `src/system/runtime/skill-creator.ts` - compile-slot execution, skill-creator tool registration, validation/testing/deploy flow
|
|
386
|
-
- `src/system/runtime/catalog-recipes.ts` - recipe discovery, frontmatter parsing, and query matching
|
|
154
|
+
`research.dml` is a plain DML file: commit it, diff it, mail it. Use a `.zip`
|
|
155
|
+
target to bundle linked `script_file/2` scripts.
|
|
387
156
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
- The conductor uses the `gateway` model slot.
|
|
391
|
-
- Normal compiled skills use the `run` model slot.
|
|
392
|
-
- The skill creator uses the `compile` model slot.
|
|
393
|
-
- The TUI context pane shows the resolved source paths for the conductor DML/prompt, skill creator DML/prompt, and task prompt template.
|
|
394
|
-
- Changes to those `.deepclause/system/` files are picked up on the next conductor turn, skill-creator run, or `task(...)` / `prompt(...)` execution; a dedicated TUI reload is not required.
|
|
395
|
-
|
|
396
|
-
After source-level changes, rebuild the package:
|
|
157
|
+
**4. Load it elsewhere (a harness from somewhere else)**
|
|
397
158
|
|
|
398
159
|
```bash
|
|
399
|
-
|
|
400
|
-
npm run build
|
|
160
|
+
deepclause repl -l research.dml
|
|
401
161
|
```
|
|
402
162
|
|
|
403
|
-
|
|
163
|
+
Loading a file targets the harness named after it (`research`), creating it if
|
|
164
|
+
needed. The file becomes that harness's **baseline**, so it works with no prior
|
|
165
|
+
history: `/rollback` floors at the loaded file, never at empty.
|
|
166
|
+
|
|
167
|
+
**5. Several harnesses in one project**
|
|
404
168
|
|
|
405
169
|
```bash
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
npm run cli --
|
|
170
|
+
deepclause repl # harness `main`
|
|
171
|
+
deepclause repl --harness support # harness `support`
|
|
172
|
+
deepclause repl -l research.dml # harness `research`
|
|
410
173
|
```
|
|
411
174
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
175
|
+
Each harness has its own content and version history under
|
|
176
|
+
`.deepclause/repl/harnesses/<name>/`. A fresh session loads its harness's current
|
|
177
|
+
content (the agent continues what is there instead of re-creating it), and
|
|
178
|
+
`/rollback` never crosses harnesses.
|
|
415
179
|
|
|
416
|
-
|
|
417
|
-
- `run` - compiled skill execution
|
|
418
|
-
- `compile` - skill compilation and `_skill-creator`
|
|
180
|
+
### Example: build a coding agent
|
|
419
181
|
|
|
420
|
-
|
|
182
|
+
You can ask for a whole **capability**, not just a one-off answer:
|
|
421
183
|
|
|
422
|
-
|
|
184
|
+
```text
|
|
185
|
+
dml> build me a coding agent harness for this repo
|
|
186
|
+
|
|
187
|
+
⚙ listing
|
|
188
|
+
✔ listing · 1ms
|
|
189
|
+
⚙ begin_turn
|
|
190
|
+
✔ begin_turn · 2ms
|
|
191
|
+
⚙ define(head=run_shell(Command, Output), clauses=run_shell(Command, Output) :- exec(bash(…), Result), …)
|
|
192
|
+
✔ define · 31ms
|
|
193
|
+
⚙ define(head=fs_read(Path, Text), clauses=fs_read(Path, Text) :- read_file(Path, Text).)
|
|
194
|
+
✔ define · 6ms
|
|
195
|
+
⚙ define(head=fs_write(Path, Content), clauses=fs_write(Path, Content) :- write_file(Path, Content).)
|
|
196
|
+
✔ define · 5ms
|
|
197
|
+
⚙ define(head=fs_grep(Pattern, Path, Matches), clauses=fs_grep(Pattern, Path, Matches) :- …)
|
|
198
|
+
✔ define · 7ms
|
|
199
|
+
⚙ assert_many(clauses=tool(run_shell(…)) :- run_shell(…). tool(fs_read(…)) :- …. …)
|
|
200
|
+
✔ assert_many · 4ms
|
|
201
|
+
⚙ define(head=explain(Question, Answer), clauses=explain(Question, Answer) :- system(…), with_tools(…).)
|
|
202
|
+
✔ define · 8ms
|
|
203
|
+
⚙ define(head=patch(File, Issue, Summary), clauses=patch(File, Issue, Summary) :- system(…), with_tools(…).)
|
|
204
|
+
✔ define · 9ms
|
|
205
|
+
⚙ execute
|
|
206
|
+
fs_read("package.json", T), run_shell("npm test", R).
|
|
207
|
+
✔ execute · 1.4s
|
|
208
|
+
⚙ end_turn(summary=Add coding-agent skills: run_shell/fs_read/fs_write/fs_grep + explain/patch)
|
|
209
|
+
✔ end_turn · 12ms — {"committed":true,"changed":["+run_shell/2","+fs_read/2","+fs_write/2","+fs_grep/3","+explain/2","+patch/3"]}
|
|
210
|
+
|
|
211
|
+
A coding-agent harness is ready: a small shell/file toolset exposed to `task/N`, plus
|
|
212
|
+
`explain/2` and `patch/3` skills that scope those tools per task.
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
The harness it built (trimmed):
|
|
423
216
|
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
"models": {
|
|
427
|
-
"gateway": "openai:gpt-4o",
|
|
428
|
-
"run": "openrouter:google/gemini-2.5-flash",
|
|
429
|
-
"compile": "anthropic:claude-sonnet-4-20250514"
|
|
430
|
-
},
|
|
431
|
-
"temperatures": {
|
|
432
|
-
"gateway": 0.7,
|
|
433
|
-
"run": 0.7,
|
|
434
|
-
"compile": 0.4
|
|
435
|
-
},
|
|
436
|
-
"providers": {
|
|
437
|
-
"openai": {
|
|
438
|
-
"apiKey": "${OPENAI_API_KEY}"
|
|
439
|
-
},
|
|
440
|
-
"anthropic": {
|
|
441
|
-
"apiKey": "${ANTHROPIC_API_KEY}"
|
|
442
|
-
},
|
|
443
|
-
"google": {
|
|
444
|
-
"apiKey": "${GOOGLE_GENERATIVE_AI_API_KEY}"
|
|
445
|
-
},
|
|
446
|
-
"openrouter": {
|
|
447
|
-
"apiKey": "${OPENROUTER_API_KEY}",
|
|
448
|
-
"baseUrl": "https://openrouter.ai/api/v1"
|
|
449
|
-
}
|
|
450
|
-
},
|
|
451
|
-
"agentvm": {
|
|
452
|
-
"network": false
|
|
453
|
-
},
|
|
454
|
-
"workspace": "./workspace",
|
|
455
|
-
"dmlBase": ".deepclause/tools"
|
|
456
|
-
}
|
|
457
|
-
```
|
|
217
|
+
```prolog
|
|
218
|
+
module_doc("Coding agent: read, search, and edit a repository and run its tests.").
|
|
458
219
|
|
|
459
|
-
|
|
220
|
+
run_shell(Command, Output) :-
|
|
221
|
+
exec(bash(command: Command), Result),
|
|
222
|
+
( get_dict(stdout, Result, Out) -> Output = Out ; Output = "" ).
|
|
460
223
|
|
|
461
|
-
|
|
224
|
+
fs_read(Path, Text) :- read_file(Path, Text).
|
|
225
|
+
fs_write(Path, Content) :- write_file(Path, Content).
|
|
462
226
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
227
|
+
fs_grep(Pattern, Path, Matches) :-
|
|
228
|
+
format(atom(Cmd), "grep -rn -- ~w ~w", [Pattern, Path]),
|
|
229
|
+
exec(bash(command: Cmd), Result),
|
|
230
|
+
( get_dict(stdout, Result, Out) -> Matches = Out ; Matches = "" ).
|
|
466
231
|
|
|
467
|
-
|
|
468
|
-
|
|
232
|
+
% `tool/2` only exposes the predicates above to the nested agent in task/N.
|
|
233
|
+
tool(run_shell(Command, Output), "Run a shell command; returns stdout.") :- run_shell(Command, Output).
|
|
234
|
+
tool(fs_read(Path, Text), "Read a workspace file.") :- fs_read(Path, Text).
|
|
235
|
+
tool(fs_write(Path, Content), "Write a workspace file.") :- fs_write(Path, Content).
|
|
236
|
+
tool(fs_grep(Pattern, Path, Matches), "Search a path; returns matching lines.") :- fs_grep(Pattern, Path, Matches).
|
|
469
237
|
|
|
470
|
-
|
|
471
|
-
|
|
238
|
+
doc(explain/2, "Explain code relevant to a question. explain(+Question, -Answer).").
|
|
239
|
+
explain(Question, Answer) :-
|
|
240
|
+
system("You are a coding assistant working in a repository. Cite file paths and line numbers."),
|
|
241
|
+
with_tools([run_shell, fs_read, fs_grep],
|
|
242
|
+
task("Answer this question about the repository: {Question}", Answer)).
|
|
472
243
|
|
|
473
|
-
|
|
474
|
-
|
|
244
|
+
doc(patch/3, "Apply a minimal fix and run the tests. patch(+File, +Issue, -Summary).").
|
|
245
|
+
patch(File, Issue, Summary) :-
|
|
246
|
+
system("Make the smallest change that fixes the issue. Run the project's tests and report the result."),
|
|
247
|
+
with_tools([run_shell, fs_read, fs_write, fs_grep],
|
|
248
|
+
task("Fix this issue in {File}: {Issue}. Then run the tests and report what changed.", Summary)).
|
|
475
249
|
```
|
|
476
250
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
| Provider | Canonical example | API key env var | Notes |
|
|
480
|
-
|----------|-------------------|-----------------|-------|
|
|
481
|
-
| OpenAI | `openai:gpt-4o` | `OPENAI_API_KEY` | You can also set `providers.openai.baseUrl` for an OpenAI-compatible endpoint. |
|
|
482
|
-
| Anthropic | `anthropic:claude-sonnet-4-20250514` | `ANTHROPIC_API_KEY` | Native Anthropic adapter. |
|
|
483
|
-
| Google | `google:gemini-2.5-flash` | `GOOGLE_GENERATIVE_AI_API_KEY` | Native Google Generative AI adapter. |
|
|
484
|
-
| OpenRouter | `openrouter:anthropic/claude-sonnet-4` | `OPENROUTER_API_KEY` | Use any OpenRouter model path. |
|
|
485
|
-
| Custom | `custom:local:qwen3-32b` | `LLM_PROVIDER_LOCAL_API_KEY` | Uses the OpenAI-compatible transport with a custom base URL. |
|
|
486
|
-
|
|
487
|
-
### Custom Provider
|
|
251
|
+
Use it:
|
|
488
252
|
|
|
489
|
-
|
|
253
|
+
```text
|
|
254
|
+
dml> /goal explain("where are the CLI entry points?", A).
|
|
255
|
+
A = "…"
|
|
490
256
|
|
|
491
|
-
|
|
257
|
+
dml> /goal patch("src/cli.ts", "the --help flag is missing", S).
|
|
258
|
+
S = "…"
|
|
492
259
|
|
|
493
|
-
|
|
494
|
-
custom:<provider-name>:<model-name>
|
|
260
|
+
dml> /export coding_agent.dml
|
|
495
261
|
```
|
|
496
262
|
|
|
497
|
-
Example:
|
|
498
|
-
|
|
499
263
|
```bash
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
deepclause set-model custom:local:qwen3-32b --slot run
|
|
504
|
-
deepclause show-model
|
|
264
|
+
deepclause repl -l coding_agent.dml # harness `coding_agent`
|
|
265
|
+
deepclause run coding_agent.dml --goal 'explain("…", A)' # one-shot
|
|
505
266
|
```
|
|
506
267
|
|
|
507
268
|
Notes:
|
|
508
269
|
|
|
509
|
-
- `
|
|
510
|
-
|
|
511
|
-
- `
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
DeepClause executes DML in a local CLI runtime:
|
|
517
|
-
|
|
518
|
-
- **Prolog runtime in WASM**: The DML logic engine runs in SWI-Prolog compiled to WebAssembly.
|
|
519
|
-
- **Host shell by default**: Shell tools run in the active local workspace shell.
|
|
520
|
-
- **AgentVM on demand**: Pass `--sandbox` when you want shell tools to run inside [AgentVM](https://github.com/deepclause/agentvm) instead.
|
|
521
|
-
|
|
522
|
-
This keeps the default workflow simple for local development while still supporting an isolated shell backend when needed.
|
|
270
|
+
- `tool/2` is only an annotation; the *capabilities* are the predicates above, so
|
|
271
|
+
they are reachable from `execute` / `/goal` **and** from `task/N`.
|
|
272
|
+
- `with_tools/2` scopes which tools a `task/N` turn may call — `explain` cannot
|
|
273
|
+
edit files, `patch` can.
|
|
274
|
+
- Because a `task/N` turn can call these tools (and itself), the module is an
|
|
275
|
+
RLM-style harness, not a fixed script.
|
|
523
276
|
|
|
524
|
-
|
|
277
|
+
### Sessions
|
|
525
278
|
|
|
526
|
-
|
|
279
|
+
The REPL also records sessions, turns, and harness versions under
|
|
280
|
+
`.deepclause/repl/`, so you can pick a conversation back up later. Its harness,
|
|
281
|
+
conversation memory, and turn count are restored:
|
|
527
282
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
Linux note: when `bubblewrap` is available, DeepClause will prefer it for host-shell isolation. On some Ubuntu/AppArmor systems, `kernel.apparmor_restrict_unprivileged_userns=1` blocks the unprivileged user-namespace path that `bwrap` needs, which surfaces as `bwrap: setting up uid map: Permission denied`. In that case DeepClause correctly falls back to the clean-room host shell. If you want `bwrap` on those hosts, you need a permitted AppArmor/userns configuration, a setuid-capable `bwrap` install, or `--sandbox` with AgentVM instead.
|
|
534
|
-
|
|
535
|
-
## Beyond Markdown: Why Logic Programming?
|
|
283
|
+
```bash
|
|
284
|
+
deepclause repl --session last # resume the most recent session
|
|
285
|
+
deepclause repl --session repl_m9x1_1 # …or one by id
|
|
286
|
+
```
|
|
536
287
|
|
|
537
|
-
|
|
288
|
+
### Why Prolog/DML for a self-modifying harness
|
|
538
289
|
|
|
539
|
-
-
|
|
540
|
-
|
|
541
|
-
- **State management** - Isolate context between sub-tasks
|
|
542
|
-
- **Error recovery** - Handle failures gracefully
|
|
543
|
-
- **Composition** - Build complex skills from simpler ones
|
|
290
|
+
An RLM-style harness works best when the harness *is* the program the model
|
|
291
|
+
edits. DML makes that literal:
|
|
544
292
|
|
|
545
|
-
|
|
293
|
+
- **The harness is data = code.** Skills are predicates, data is facts
|
|
294
|
+
(`city(ch, "Zürich").`). The model reads it (`listing`), queries it
|
|
295
|
+
(`/goal`), extends it, and reuses it — no separate plugin format and no
|
|
296
|
+
recompile step.
|
|
297
|
+
- **One language for logic and language.** Recursion, backtracking, and CLP
|
|
298
|
+
constraints sit next to LLM calls (`task/N`) and typed semantic judgments
|
|
299
|
+
(`choose`, `verify`, `rate`, `probability`) in the same clause.
|
|
300
|
+
- **Composable skills.** A `task/N` call runs a bounded agentic turn that may
|
|
301
|
+
itself call other skills, so the library grows by composition and reuse.
|
|
302
|
+
- **Small and inspectable.** Everything a harness can do is visible in the
|
|
303
|
+
module and the host tool catalog (by default `bash`, plus the human-in-the-loop
|
|
304
|
+
`ask_user` / `input/2`).
|
|
546
305
|
|
|
547
|
-
|
|
306
|
+
### Transactions
|
|
548
307
|
|
|
308
|
+
A prompt turn is an **edit transaction**:
|
|
549
309
|
|
|
310
|
+
1. the living module is snapshotted;
|
|
311
|
+
2. the authoring agent edits predicates with tools (`define`/`assert`/`assert_many`/
|
|
312
|
+
`retract`/`delete`) and tests them with `execute`;
|
|
313
|
+
3. `end_turn` validates and commits the change, recording a version;
|
|
314
|
+
4. `rollback` — or a failed turn — restores the harness unchanged.
|
|
550
315
|
|
|
551
|
-
|
|
316
|
+
For anything larger than a couple of predicates the agent is instructed to commit
|
|
317
|
+
working pieces as it goes (`execute` → `end_turn` → `begin_turn`), so a late
|
|
318
|
+
failure does not lose earlier progress.
|
|
552
319
|
|
|
553
|
-
|
|
320
|
+
### Auditability
|
|
554
321
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
## Arguments
|
|
564
|
-
- SpecUrl: URL to an OpenAPI/Swagger JSON specification
|
|
565
|
-
|
|
566
|
-
## Behavior
|
|
567
|
-
- Fetch the OpenAPI spec from SpecUrl
|
|
568
|
-
- Extract endpoints and types
|
|
569
|
-
- Generate typed client code
|
|
570
|
-
- Write to output file
|
|
571
|
-
EOF
|
|
572
|
-
|
|
573
|
-
# Compile it once
|
|
574
|
-
deepclause compile api-client.md
|
|
575
|
-
|
|
576
|
-
# Run it deterministically, forever
|
|
577
|
-
deepclause run api-client.dml "https://api.example.com/openapi.json"
|
|
578
|
-
```
|
|
579
|
-
|
|
580
|
-
The compiled `.dml` is inspectable logic—you can see exactly what it does:
|
|
322
|
+
Every session, turn, event trace, and harness version is written under
|
|
323
|
+
`.deepclause/repl/` — per harness under `harnesses/<name>/` (`harness.dml`,
|
|
324
|
+
`baseline.dml`, `HEAD.json`, `changes.jsonl`, `versions/`) — and exposed to DML
|
|
325
|
+
as queryable `harness_*` facts (`harness_session/5`, `harness_turn/5`,
|
|
326
|
+
`harness_change/5`, `harness_changed/4`, `harness_head/4`, `harness_trace/3`).
|
|
327
|
+
`rollback.` restores the previous version, step by step, and a harness can query
|
|
328
|
+
its own past:
|
|
581
329
|
|
|
582
330
|
```prolog
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
agent_main(SpecUrl) :-
|
|
587
|
-
system("You are an API client generator..."),
|
|
588
|
-
fetch_spec(SpecUrl, Spec),
|
|
589
|
-
task("Extract endpoints from: {Spec}", Endpoints),
|
|
590
|
-
task("Generate TypeScript client for: {Endpoints}", Code),
|
|
591
|
-
exec(vm_exec(command: "cat > client.ts"), Code),
|
|
592
|
-
answer("Generated client.ts").
|
|
593
|
-
```
|
|
594
|
-
|
|
595
|
-
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.
|
|
596
|
-
|
|
597
|
-
## Compile and Run a Skill
|
|
598
|
-
|
|
599
|
-
```bash
|
|
600
|
-
# Create a task description
|
|
601
|
-
cat > .deepclause/tools/explain.md << 'EOF'
|
|
602
|
-
# Code Explainer
|
|
603
|
-
|
|
604
|
-
Explain what a piece of code does in plain English.
|
|
605
|
-
|
|
606
|
-
## Arguments
|
|
607
|
-
- Code: The source code to explain
|
|
608
|
-
|
|
609
|
-
## Behavior
|
|
610
|
-
- Break down the code into logical sections
|
|
611
|
-
- Explain each section's purpose
|
|
612
|
-
- Note any potential issues
|
|
613
|
-
EOF
|
|
614
|
-
|
|
615
|
-
# Compile to executable DML
|
|
616
|
-
deepclause compile .deepclause/tools/explain.md
|
|
617
|
-
|
|
618
|
-
# Run it
|
|
619
|
-
deepclause run .deepclause/tools/explain.dml "function fib(n) { return n < 2 ? n : fib(n-1) + fib(n-2) }"
|
|
620
|
-
|
|
621
|
-
# Or trigger skill creation directly from the TUI with:
|
|
622
|
-
# /compile <spec>
|
|
623
|
-
# /skill-creator <spec>
|
|
624
|
-
# Or update the configured model selection from the TUI with:
|
|
625
|
-
# /set-model openai:gpt-4.1 --slot run
|
|
626
|
-
# Or run a direct workspace shell command with:
|
|
627
|
-
# !npm test
|
|
331
|
+
recent_changes(N, Changes) :-
|
|
332
|
+
findall(Version-Timestamp, harness_change(Version, Timestamp, commit, _, _), All),
|
|
333
|
+
last_n(All, N, Changes).
|
|
628
334
|
```
|
|
629
335
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
- Prolog static analysis for taint flow, dangerous tool usage, and capability extraction
|
|
633
|
-
- An LLM security audit that reviews the generated DML and returns a short Markdown report
|
|
336
|
+
See [`docs/REPL.md`](docs/REPL.md) and
|
|
337
|
+
[`docs/DML_REPL_SESSION_HISTORY.md`](docs/DML_REPL_SESSION_HISTORY.md).
|
|
634
338
|
|
|
635
|
-
|
|
339
|
+
### Commands
|
|
636
340
|
|
|
637
|
-
|
|
341
|
+
`/goal <dml>`, `/listing [filter]`, `/help`, `/reset`, `/rollback`,
|
|
342
|
+
`/compact [notes]`, `/export [file]`, `/model [id]`, `/freeze`/`/unfreeze`,
|
|
343
|
+
`/params`, `/trace`/`/notrace`, `/halt` (aliases `/exit`, `/quit`). The legacy
|
|
344
|
+
`goal:`/`listing.` dotted forms still work.
|
|
638
345
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
Give your AI coding assistant more deterministic, inspectable tools instead of hoping prompts work:
|
|
346
|
+
## Install
|
|
642
347
|
|
|
643
348
|
```bash
|
|
644
|
-
|
|
645
|
-
cat > .deepclause/tools/api-docs.md << 'EOF'
|
|
646
|
-
# API Documentation Lookup
|
|
647
|
-
Search for API documentation and summarize usage patterns.
|
|
648
|
-
|
|
649
|
-
## Arguments
|
|
650
|
-
- Query: The API or library name to look up
|
|
651
|
-
|
|
652
|
-
## Tools needed
|
|
653
|
-
- web_search
|
|
654
|
-
|
|
655
|
-
## Behavior
|
|
656
|
-
- Search for official documentation
|
|
657
|
-
- Summarize usage patterns and examples
|
|
658
|
-
EOF
|
|
659
|
-
|
|
660
|
-
# Compile it once
|
|
661
|
-
deepclause compile .deepclause/tools/api-docs.md
|
|
662
|
-
|
|
663
|
-
# Now your coding agent can run it reliably
|
|
664
|
-
deepclause run .deepclause/tools/api-docs.dml "Stripe PaymentIntent"
|
|
349
|
+
npm install deepclause-sdk
|
|
665
350
|
```
|
|
666
351
|
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
### Automation pipelines
|
|
670
|
-
|
|
671
|
-
Chain compiled programs together:
|
|
352
|
+
## Quick start
|
|
672
353
|
|
|
673
354
|
```bash
|
|
674
|
-
deepclause
|
|
675
|
-
deepclause
|
|
355
|
+
deepclause init # write .deepclause/config.json
|
|
356
|
+
deepclause login # sign in to provider, then pick a model
|
|
357
|
+
deepclause repl # interactive
|
|
358
|
+
deepclause repl --session last # resume the most recent session
|
|
359
|
+
deepclause run skill.dml "arg" # one-shot
|
|
676
360
|
```
|
|
677
361
|
|
|
678
|
-
###
|
|
362
|
+
### Backends
|
|
679
363
|
|
|
680
|
-
|
|
364
|
+
`pi` is the default: it reuses pi's model catalog and credential store. `env`
|
|
365
|
+
uses the SDK's own provider/API keys.
|
|
681
366
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
#
|
|
687
|
-
Search the web and synthesize findings into a report.
|
|
688
|
-
|
|
689
|
-
## Arguments
|
|
690
|
-
- Question: The research question to investigate
|
|
691
|
-
|
|
692
|
-
## Tools needed
|
|
693
|
-
- web_search
|
|
694
|
-
|
|
695
|
-
## Behavior
|
|
696
|
-
- Search for 3-5 authoritative sources on the Question
|
|
697
|
-
- Extract key findings from each
|
|
698
|
-
- Write a summary with inline citations
|
|
699
|
-
```
|
|
700
|
-
|
|
701
|
-
### Code Review
|
|
702
|
-
```markdown
|
|
703
|
-
# Code Review
|
|
704
|
-
Review code for bugs, security issues, and style.
|
|
705
|
-
|
|
706
|
-
## Arguments
|
|
707
|
-
- FilePath: Path to the file to review
|
|
708
|
-
|
|
709
|
-
## Tools needed
|
|
710
|
-
- vm_exec (to read files)
|
|
711
|
-
|
|
712
|
-
## Behavior
|
|
713
|
-
- Read the file at FilePath
|
|
714
|
-
- Check for common bugs and anti-patterns
|
|
715
|
-
- Identify security concerns
|
|
716
|
-
- Suggest improvements
|
|
717
|
-
- Be concise and actionable
|
|
718
|
-
```
|
|
719
|
-
|
|
720
|
-
### Data Analysis
|
|
721
|
-
```markdown
|
|
722
|
-
# CSV Analyzer
|
|
723
|
-
Analyze a CSV file and describe its contents.
|
|
724
|
-
|
|
725
|
-
## Arguments
|
|
726
|
-
- FilePath: Path to the CSV file to analyze
|
|
727
|
-
|
|
728
|
-
## Tools needed
|
|
729
|
-
- vm_exec (to run Python)
|
|
730
|
-
|
|
731
|
-
## Behavior
|
|
732
|
-
- Load the CSV at FilePath with pandas
|
|
733
|
-
- Describe the schema (columns, types, row count)
|
|
734
|
-
- Identify interesting patterns
|
|
735
|
-
- Generate summary statistics
|
|
367
|
+
```bash
|
|
368
|
+
deepclause login [--provider <id>] [--api-key <key>|--oauth] [--model provider/model] [--thinking <level>]
|
|
369
|
+
deepclause logout [provider]
|
|
370
|
+
deepclause set-backend status
|
|
371
|
+
deepclause set-backend env # switch to provider API keys
|
|
736
372
|
```
|
|
737
373
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
| Tool | Description |
|
|
743
|
-
|------|-------------|
|
|
744
|
-
| `web_search` | Search the web using Brave Search (requires `BRAVE_API_KEY`) |
|
|
745
|
-
| `news_search` | Search recent news |
|
|
746
|
-
| `url_fetch` | Fetch a URL or save it into the workspace |
|
|
747
|
-
| `bash` | Run shell commands in the active workspace shell |
|
|
748
|
-
| `vm_exec` | Alias of `bash`; with `--sandbox`, runs in AgentVM |
|
|
374
|
+
For reasoning-capable models, `deepclause login`/`set-backend`/`set-model` prompt
|
|
375
|
+
for a thinking level (`off|minimal|low|medium|high|xhigh|max`); pass `--thinking`
|
|
376
|
+
to skip the picker. It is stored as `backend.thinkingLevel` and forwarded to pi
|
|
377
|
+
only for models that support it.
|
|
749
378
|
|
|
750
|
-
|
|
379
|
+
Credentials live in pi's agent dir (`~/.pi/agent`) unless `backend.agentDir`
|
|
380
|
+
overrides it. Existing pi installations stay untouched.
|
|
751
381
|
|
|
752
|
-
|
|
753
|
-
- the skill creator adds tools such as `list_skills`, `write_file`, `validate_dml`, `test_dml`, and `deploy_skill`
|
|
382
|
+
## run
|
|
754
383
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
384
|
+
`run` uses the **same engine as the REPL**: it opens a module, loads the
|
|
385
|
+
DML file (`.dml` or a `.zip` bundle), runs one entry, and renders events through
|
|
386
|
+
the REPL renderer. The entry is `agent_main/N` (chosen by the number of
|
|
387
|
+
positional arguments) or an explicit `--goal`.
|
|
758
388
|
|
|
759
389
|
```bash
|
|
760
|
-
deepclause
|
|
761
|
-
deepclause
|
|
762
|
-
deepclause
|
|
763
|
-
deepclause run <file.dml>
|
|
764
|
-
deepclause
|
|
765
|
-
deepclause -p <text> # Run one headless conductor turn
|
|
766
|
-
deepclause list-commands # List available compiled skills
|
|
767
|
-
deepclause list-tools # Show available tools
|
|
768
|
-
deepclause show-model # Show gateway/run/compile slots
|
|
769
|
-
deepclause set-model <model> # Change all slots or one slot with --slot
|
|
390
|
+
deepclause run <file.dml> [args...] # call agent_main/N
|
|
391
|
+
deepclause run <file.dml> --goal '<dml>' # explicit entry goal
|
|
392
|
+
deepclause run <file.dml> --dry-run # print the resolved entry
|
|
393
|
+
deepclause run <file.dml> --trace t.json --usage u.json
|
|
394
|
+
deepclause run <file.dml> --no-stream --no-events # only outputs/answers
|
|
770
395
|
```
|
|
771
396
|
|
|
772
|
-
|
|
397
|
+
## Runtime and sandboxing
|
|
773
398
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
--workspace ./data \ # Set working directory
|
|
780
|
-
--sandbox # Use AgentVM instead of the local shell
|
|
781
|
-
```
|
|
399
|
+
**Engine.** DML is executed by **SWI-Prolog compiled to WebAssembly**
|
|
400
|
+
(`vendor/swipl-wasm`, loaded through `src/prolog/`). It runs in-process — no
|
|
401
|
+
native Prolog install, no external server — with the standard SWI libraries
|
|
402
|
+
available (constraint solving via `clpfd`, `clpq`, `clpr`; plus regex, dicts,
|
|
403
|
+
and DCGs). Validation runs on the same engine.
|
|
782
404
|
|
|
783
|
-
|
|
405
|
+
**Workspace confinement.** DML file predicates and `bash` all run against the
|
|
406
|
+
active **workspace** (`.` or `--workspace <path>`) using workspace-relative
|
|
407
|
+
paths; harness paths cannot escape it.
|
|
784
408
|
|
|
785
|
-
|
|
409
|
+
**Shell execution.** `bash` is the only capability tool, with two backends:
|
|
786
410
|
|
|
787
|
-
|
|
411
|
+
| Backend | When | Notes |
|
|
412
|
+
|---|---|---|
|
|
413
|
+
| host shell | default | isolated by a wrapper: `clean-room`, `bwrap` (bubblewrap), or `sandbox-exec` (macOS); `auto` picks the best available |
|
|
414
|
+
| AgentVM | `--sandbox` | WASM micro-VM; network disabled by default |
|
|
788
415
|
|
|
789
|
-
|
|
416
|
+
Network access is **off by default** (`agentvm.network: false`), and `bwrap`
|
|
417
|
+
with `shell.strictIsolation: true` also disables it. `--no-tools` registers no
|
|
418
|
+
capability tool at all; `ask_user` / `input/2` remain the human-in-the-loop
|
|
419
|
+
channel.
|
|
790
420
|
|
|
791
421
|
```bash
|
|
792
|
-
deepclause
|
|
793
|
-
|
|
794
|
-
--provider anthropic \
|
|
795
|
-
--temperature 0.2 \
|
|
796
|
-
--max-attempts 4
|
|
797
|
-
|
|
798
|
-
deepclause compile-all ./specs \
|
|
799
|
-
--model claude-sonnet-4-20250514 \
|
|
800
|
-
--provider anthropic \
|
|
801
|
-
--no-audit
|
|
422
|
+
deepclause repl --sandbox # run bash inside the AgentVM micro-VM
|
|
423
|
+
deepclause repl --no-tools # no capability host tools
|
|
802
424
|
```
|
|
803
425
|
|
|
804
|
-
## Configuration
|
|
805
|
-
|
|
806
|
-
The main configuration surface is `.deepclause/config.json`.
|
|
807
|
-
|
|
808
|
-
The most important fields are covered above in:
|
|
809
|
-
|
|
810
|
-
- [Install and Run](#install-and-run)
|
|
811
|
-
- [TUI Conductor](#tui-conductor)
|
|
812
|
-
- [Model and Provider Configuration](#model-and-provider-configuration)
|
|
813
|
-
|
|
814
|
-
Other useful config fields:
|
|
815
|
-
|
|
816
426
|
```json
|
|
817
427
|
{
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
},
|
|
821
|
-
"shell": {
|
|
822
|
-
"wrapper": "auto",
|
|
823
|
-
"strictIsolation": false
|
|
824
|
-
},
|
|
825
|
-
"compaction": {
|
|
826
|
-
"enabled": true,
|
|
827
|
-
"bindings": [
|
|
828
|
-
{
|
|
829
|
-
"name": "default-session",
|
|
830
|
-
"scope": "session",
|
|
831
|
-
"trigger": "before_user_message",
|
|
832
|
-
"compactor": {
|
|
833
|
-
"source": ".deepclause/system/default-session-compactor.dml",
|
|
834
|
-
"sourceType": "file",
|
|
835
|
-
"timeoutMs": 15000,
|
|
836
|
-
"inheritTools": false
|
|
837
|
-
}
|
|
838
|
-
},
|
|
839
|
-
{
|
|
840
|
-
"name": "default-loop",
|
|
841
|
-
"scope": "loop",
|
|
842
|
-
"trigger": "before_model_call",
|
|
843
|
-
"compactor": {
|
|
844
|
-
"source": ".deepclause/system/default-loop-compactor.dml",
|
|
845
|
-
"sourceType": "file",
|
|
846
|
-
"timeoutMs": 15000,
|
|
847
|
-
"inheritTools": false
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
]
|
|
851
|
-
},
|
|
852
|
-
"workspace": "./workspace",
|
|
853
|
-
"dmlBase": ".deepclause/tools",
|
|
854
|
-
"mcp": {
|
|
855
|
-
"servers": {
|
|
856
|
-
"filesystem": {
|
|
857
|
-
"command": "npx",
|
|
858
|
-
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
}
|
|
428
|
+
"agentvm": { "network": false },
|
|
429
|
+
"shell": { "wrapper": "auto", "strictIsolation": false }
|
|
862
430
|
}
|
|
863
431
|
```
|
|
864
432
|
|
|
865
|
-
|
|
866
|
-
- `shell.wrapper` chooses the host-shell isolation backend: `auto`, `clean-room`, `bwrap`, or `sandbox-exec`.
|
|
867
|
-
- `shell.strictIsolation` requests stricter host execution. On Linux with `bwrap`, that disables network access with a separate network namespace.
|
|
868
|
-
- `compaction.enabled` toggles the compaction system for session and loop memory.
|
|
869
|
-
- `compaction.bindings` attaches DML compactors to runtime hook points such as `before_user_message` and `before_model_call`.
|
|
870
|
-
- `workspace` sets the default working directory used by shell/file tools.
|
|
871
|
-
- `dmlBase` changes where compiled local skills are written.
|
|
872
|
-
- `mcp.servers` registers MCP servers that then appear in `deepclause list-tools`.
|
|
873
|
-
|
|
874
|
-
### Compaction Is Hackable
|
|
875
|
-
|
|
876
|
-
The default compaction bindings point at seeded DML files in `.deepclause/system/default-session-compactor.dml` and `.deepclause/system/default-loop-compactor.dml`. Those are ordinary workspace files, so you can edit them directly instead of treating compaction as a black box.
|
|
433
|
+
## visualize
|
|
877
434
|
|
|
878
|
-
|
|
435
|
+
Turn a harness into a diagram: `visualize` reads the harness `listing`
|
|
436
|
+
(source + `doc/2` annotations) and asks the active model for a Mermaid chart of
|
|
437
|
+
one entry, then renders it.
|
|
879
438
|
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
should_skip_session_compaction(_MessageCount, EstimatedTokens) :-
|
|
884
|
-
EstimatedTokens < 50000.
|
|
439
|
+
```bash
|
|
440
|
+
deepclause visualize skill.dml -g router/2 --presentation -o router.png
|
|
441
|
+
deepclause visualize skill.dml -g router/2 --spec -o router.spec.png
|
|
885
442
|
```
|
|
886
443
|
|
|
887
|
-
|
|
444
|
+
`-g/--goal` names the entry predicate to document. `--presentation` (default) is
|
|
445
|
+
an audience-facing overview (inputs, steps, answer); `--spec` shows engineering
|
|
446
|
+
detail (decisions, `task`/`exec` calls, branches, fallbacks). A `.mmd` output
|
|
447
|
+
writes the Mermaid source; a `.png`/`.svg` output renders it via
|
|
448
|
+
`@mermaid-js/mermaid-cli` (fetched with `npx` on first use) and always writes the
|
|
449
|
+
`.mmd` beside the image.
|
|
888
450
|
|
|
889
|
-
|
|
890
|
-
- Repoint `compaction.bindings` in `.deepclause/config.json` to a different file, an inline compactor, or a binding with its own `model`, `provider`, `gasLimit`, `timeoutMs`, `inheritTools`, or `toolPolicy` settings.
|
|
451
|
+
## Media (images)
|
|
891
452
|
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
453
|
+
Images are workspace files referenced by a `media(Path, Mime)` term; the bytes
|
|
454
|
+
never enter Prolog or conversation memory. Read a reference and attach it, and the
|
|
455
|
+
next `task/N` sends it to a vision-capable model:
|
|
895
456
|
|
|
896
457
|
```prolog
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
system("You are a research assistant..."),
|
|
903
|
-
task("Research {Topic} and summarize findings."),
|
|
904
|
-
answer("Done").
|
|
458
|
+
agent_main :-
|
|
459
|
+
read_media("photos/fox.png", Image),
|
|
460
|
+
attach_media(Image),
|
|
461
|
+
task("Describe the image in one sentence.", Description),
|
|
462
|
+
answer(Description).
|
|
905
463
|
```
|
|
906
464
|
|
|
907
|
-
|
|
908
|
-
|
|
465
|
+
Only PNG/JPEG/GIF/WebP are accepted, and judgments stay text-only. Image
|
|
466
|
+
generation and video are not implemented — see [`docs/DML_MEDIA.md`](docs/DML_MEDIA.md).
|
|
909
467
|
|
|
910
|
-
|
|
468
|
+
## TypeScript SDK
|
|
911
469
|
|
|
912
|
-
|
|
470
|
+
```ts
|
|
471
|
+
import { createDeepClause } from 'deepclause-sdk';
|
|
913
472
|
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
validate_answer, % Fails if answer is inadequate
|
|
920
|
-
answer("Done").
|
|
921
|
-
|
|
922
|
-
agent_main(Question) :-
|
|
923
|
-
system("Be thorough and detailed."),
|
|
924
|
-
task("Research and answer: {Question}"),
|
|
925
|
-
answer("Done").
|
|
473
|
+
const dc = await createDeepClause({ model: 'gpt-4o', provider: 'openai' });
|
|
474
|
+
for await (const event of dc.runDML(dmlSource, { args: ['topic'] })) {
|
|
475
|
+
if (event.type === 'answer') console.log(event.answer ?? event.content);
|
|
476
|
+
}
|
|
477
|
+
await dc.dispose();
|
|
926
478
|
```
|
|
927
479
|
|
|
928
|
-
|
|
480
|
+
To reuse pi's model and credentials from a host, pass an injected `LLMBackend`
|
|
481
|
+
(`createPiBackend`) and judgment backends (`createLLMJudgeBackend`,
|
|
482
|
+
`createJevJudgeBackend`).
|
|
929
483
|
|
|
930
|
-
|
|
484
|
+
The REPL is embeddable too:
|
|
931
485
|
|
|
932
|
-
|
|
486
|
+
```ts
|
|
487
|
+
import { createHarnessRepl } from 'deepclause-sdk';
|
|
933
488
|
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
process_files(Rest).
|
|
940
|
-
|
|
941
|
-
agent_main(Files) :-
|
|
942
|
-
process_files(Files),
|
|
943
|
-
answer("All files reviewed.").
|
|
489
|
+
const repl = await createHarnessRepl({ model: 'gpt-4o', provider: 'openai' });
|
|
490
|
+
for await (const event of repl.query('fact(5, F)')) {
|
|
491
|
+
if (event.type === 'solution') console.log(event.solution?.bindings);
|
|
492
|
+
}
|
|
493
|
+
await repl.dispose();
|
|
944
494
|
```
|
|
945
495
|
|
|
946
|
-
|
|
496
|
+
## Validation
|
|
947
497
|
|
|
948
|
-
|
|
498
|
+
```ts
|
|
499
|
+
import { validateWithProlog } from 'deepclause-sdk/validate';
|
|
949
500
|
|
|
950
|
-
|
|
951
|
-
agent_main(Topic) :-
|
|
952
|
-
system("You are a researcher."),
|
|
953
|
-
task("Research {Topic} deeply.", Findings),
|
|
954
|
-
|
|
955
|
-
% Independent critique - fresh context, no bias from main research
|
|
956
|
-
prompt("As a skeptic, critique: {Findings}", Critique),
|
|
957
|
-
|
|
958
|
-
% Back to main context
|
|
959
|
-
task("Address this critique: {Critique}"),
|
|
960
|
-
answer("Done").
|
|
501
|
+
const { valid, errors, warnings } = await validateWithProlog(dmlSource);
|
|
961
502
|
```
|
|
962
503
|
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
Limit what tools are available to specific sub-tasks:
|
|
966
|
-
|
|
967
|
-
```prolog
|
|
968
|
-
tool(dangerous_action(X, Result), "Do something risky") :-
|
|
969
|
-
exec(vm_exec(command: X), Result).
|
|
970
|
-
|
|
971
|
-
agent_main(Task) :-
|
|
972
|
-
% Main task has all tools
|
|
973
|
-
task("Plan how to: {Task}", Plan),
|
|
974
|
-
|
|
975
|
-
% Execute with restricted tools - no dangerous_action allowed
|
|
976
|
-
without_tools([dangerous_action], (
|
|
977
|
-
task("Execute this plan safely: {Plan}")
|
|
978
|
-
)),
|
|
979
|
-
answer("Done").
|
|
980
|
-
```
|
|
981
|
-
|
|
982
|
-
### Composition: Building Blocks
|
|
504
|
+
## Configuration
|
|
983
505
|
|
|
984
|
-
|
|
506
|
+
`.deepclause/config.json` (created by `init`):
|
|
985
507
|
|
|
986
|
-
```
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
508
|
+
```json
|
|
509
|
+
{
|
|
510
|
+
"backend": { "kind": "pi", "model": "anthropic/claude-sonnet-4" },
|
|
511
|
+
"temperatures": { "run": 0.7 },
|
|
512
|
+
"providers": { "openai": { "apiKey": "..." } },
|
|
513
|
+
"agentvm": { "network": false },
|
|
514
|
+
"shell": { "wrapper": "auto", "strictIsolation": false, "timeoutMs": 0, "idleTimeoutMs": 180000 },
|
|
515
|
+
"repl": {
|
|
516
|
+
"tui": "auto",
|
|
517
|
+
"harness": "main",
|
|
518
|
+
"showReasoning": "summary",
|
|
519
|
+
"maxModelCalls": 100,
|
|
520
|
+
"compaction": { "enabled": true, "auto": true },
|
|
521
|
+
"history": { "enabled": true, "dir": ".deepclause/repl", "trace": "summary" }
|
|
522
|
+
},
|
|
523
|
+
"judgment": { "default": "llm", "jev": { "enabled": false } }
|
|
524
|
+
}
|
|
1001
525
|
```
|
|
1002
526
|
|
|
1003
|
-
|
|
527
|
+
## Repository layout
|
|
1004
528
|
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
529
|
+
```text
|
|
530
|
+
src/
|
|
531
|
+
├── repl/ # the living-module REPL (session, frames, renderer, auth, history)
|
|
532
|
+
├── cli/ # init, run, repl, login, set-backend
|
|
533
|
+
├── system/ # shell/AgentVM, config, bundled docs
|
|
534
|
+
├── judge/ # semantic judgment backends (llm, jev, mock)
|
|
535
|
+
├── prolog/ # SWI-Prolog-WASM loader/bridge
|
|
536
|
+
├── prolog-src/ # deepclause_mi.pl, deepclause_analysis.pl, …
|
|
537
|
+
├── agent.ts # task/agent loop
|
|
538
|
+
├── runner.ts # DML execution
|
|
539
|
+
├── sdk.ts # createDeepClause
|
|
540
|
+
└── validate.ts # DML validation/linting
|
|
1017
541
|
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
:- use_module(library(lists)).
|
|
1021
|
-
:- use_module(library(clpfd)).
|
|
1022
|
-
:- consult('.deepclause/tools/repo-review/helpers/search_helpers.dml').
|
|
1023
|
-
|
|
1024
|
-
agent_main(Topic) :-
|
|
1025
|
-
search_and_summarize(Topic, Summary),
|
|
1026
|
-
answer(Summary).
|
|
542
|
+
vendor/
|
|
543
|
+
└── swipl-wasm/ # SWI-Prolog compiled to WebAssembly (the DML engine)
|
|
1027
544
|
```
|
|
1028
545
|
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
546
|
+
Bundled prompt assets: `AGENT_PROMPT.md` (the authoring agent's contract),
|
|
547
|
+
`DML_REFERENCE.md` (language), `DML_AUTHORING.md` (guide),
|
|
548
|
+
`HARNESS_EXAMPLES.md` (idiomatic shapes), `HARNESS_PATTERNS.md` (harness shapes
|
|
549
|
+
by use case), `PROLOG_SNIPPETS.md` (tested building blocks).
|
|
1033
550
|
|
|
1034
|
-
##
|
|
551
|
+
## Development
|
|
1035
552
|
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
const dc = await createDeepClause({
|
|
1042
|
-
model: 'gpt-4o',
|
|
1043
|
-
apiKey: process.env.OPENAI_API_KEY,
|
|
1044
|
-
});
|
|
1045
|
-
|
|
1046
|
-
for await (const event of dc.runDML(code)) {
|
|
1047
|
-
console.log(event.type, event.content);
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
await dc.dispose();
|
|
553
|
+
```bash
|
|
554
|
+
npm run build # tsc + copy prolog + assets
|
|
555
|
+
npm test # vitest
|
|
556
|
+
npm run repl # deepclause repl via tsx
|
|
1051
557
|
```
|
|
1052
558
|
|
|
1053
|
-
See [
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
- [Examples](./dml-examples/) - Sample DML programs
|
|
1059
|
-
- [Architecture](./ARCHITECTURE.md) - How it works
|
|
559
|
+
See [`docs/`](docs/): [`STATUS.md`](docs/STATUS.md) (current state),
|
|
560
|
+
[`REPL.md`](docs/REPL.md),
|
|
561
|
+
[`DML_REPL_PROPOSAL.md`](docs/DML_REPL_PROPOSAL.md),
|
|
562
|
+
[`DML_REPL_SESSION_HISTORY.md`](docs/DML_REPL_SESSION_HISTORY.md),
|
|
563
|
+
[`JUDGMENT_BACKENDS.md`](docs/JUDGMENT_BACKENDS.md).
|
|
1060
564
|
|
|
1061
565
|
## License
|
|
1062
566
|
|