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.
Files changed (318) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +418 -914
  3. package/dist/agent.d.ts +19 -2
  4. package/dist/agent.d.ts.map +1 -1
  5. package/dist/agent.js +221 -4
  6. package/dist/agent.js.map +1 -1
  7. package/dist/cli/config.d.ts +323 -176
  8. package/dist/cli/config.d.ts.map +1 -1
  9. package/dist/cli/config.js +146 -188
  10. package/dist/cli/config.js.map +1 -1
  11. package/dist/cli/index.d.ts +3 -2
  12. package/dist/cli/index.d.ts.map +1 -1
  13. package/dist/cli/index.js +61 -425
  14. package/dist/cli/index.js.map +1 -1
  15. package/dist/cli/login.d.ts +29 -0
  16. package/dist/cli/login.d.ts.map +1 -0
  17. package/dist/cli/login.js +184 -0
  18. package/dist/cli/login.js.map +1 -0
  19. package/dist/cli/readline.d.ts +6 -0
  20. package/dist/cli/readline.d.ts.map +1 -0
  21. package/dist/cli/readline.js +15 -0
  22. package/dist/cli/readline.js.map +1 -0
  23. package/dist/cli/repl-bin.d.ts +9 -0
  24. package/dist/cli/repl-bin.d.ts.map +1 -0
  25. package/dist/cli/repl-bin.js +16 -0
  26. package/dist/cli/repl-bin.js.map +1 -0
  27. package/dist/cli/repl.d.ts +191 -0
  28. package/dist/cli/repl.d.ts.map +1 -0
  29. package/dist/cli/repl.js +1232 -0
  30. package/dist/cli/repl.js.map +1 -0
  31. package/dist/cli/run.d.ts +17 -18
  32. package/dist/cli/run.d.ts.map +1 -1
  33. package/dist/cli/run.js +196 -183
  34. package/dist/cli/run.js.map +1 -1
  35. package/dist/cli/set-backend.d.ts +53 -0
  36. package/dist/cli/set-backend.d.ts.map +1 -0
  37. package/dist/cli/set-backend.js +259 -0
  38. package/dist/cli/set-backend.js.map +1 -0
  39. package/dist/cli/visualize.d.ts +38 -0
  40. package/dist/cli/visualize.d.ts.map +1 -0
  41. package/dist/cli/visualize.js +125 -0
  42. package/dist/cli/visualize.js.map +1 -0
  43. package/dist/compiler.d.ts +5 -52
  44. package/dist/compiler.d.ts.map +1 -1
  45. package/dist/compiler.js +4 -768
  46. package/dist/compiler.js.map +1 -1
  47. package/dist/index.d.ts +29 -2
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +20 -2
  50. package/dist/index.js.map +1 -1
  51. package/dist/judge/index.d.ts +9 -0
  52. package/dist/judge/index.d.ts.map +1 -0
  53. package/dist/judge/index.js +6 -0
  54. package/dist/judge/index.js.map +1 -0
  55. package/dist/judge/jev.d.ts +21 -0
  56. package/dist/judge/jev.d.ts.map +1 -0
  57. package/dist/judge/jev.js +218 -0
  58. package/dist/judge/jev.js.map +1 -0
  59. package/dist/judge/llm.d.ts +23 -0
  60. package/dist/judge/llm.d.ts.map +1 -0
  61. package/dist/judge/llm.js +120 -0
  62. package/dist/judge/llm.js.map +1 -0
  63. package/dist/judge/marshal.d.ts +26 -0
  64. package/dist/judge/marshal.d.ts.map +1 -0
  65. package/dist/judge/marshal.js +266 -0
  66. package/dist/judge/marshal.js.map +1 -0
  67. package/dist/judge/mock.d.ts +28 -0
  68. package/dist/judge/mock.d.ts.map +1 -0
  69. package/dist/judge/mock.js +98 -0
  70. package/dist/judge/mock.js.map +1 -0
  71. package/dist/judge/types.d.ts +95 -0
  72. package/dist/judge/types.d.ts.map +1 -0
  73. package/dist/judge/types.js +23 -0
  74. package/dist/judge/types.js.map +1 -0
  75. package/dist/prolog/bridge.d.ts +5 -1
  76. package/dist/prolog/bridge.d.ts.map +1 -1
  77. package/dist/prolog/bridge.js +29 -1
  78. package/dist/prolog/bridge.js.map +1 -1
  79. package/dist/prolog-src/deepclause_analysis.pl +10 -2
  80. package/dist/prolog-src/deepclause_mi.pl +2522 -118
  81. package/dist/repl/agent.d.ts +72 -0
  82. package/dist/repl/agent.d.ts.map +1 -0
  83. package/dist/repl/agent.js +366 -0
  84. package/dist/repl/agent.js.map +1 -0
  85. package/dist/repl/auth.d.ts +45 -0
  86. package/dist/repl/auth.d.ts.map +1 -0
  87. package/dist/repl/auth.js +116 -0
  88. package/dist/repl/auth.js.map +1 -0
  89. package/dist/repl/backend.d.ts +290 -0
  90. package/dist/repl/backend.d.ts.map +1 -0
  91. package/dist/repl/backend.js +370 -0
  92. package/dist/repl/backend.js.map +1 -0
  93. package/dist/repl/compaction.d.ts +122 -0
  94. package/dist/repl/compaction.d.ts.map +1 -0
  95. package/dist/repl/compaction.js +318 -0
  96. package/dist/repl/compaction.js.map +1 -0
  97. package/dist/repl/export.d.ts +30 -0
  98. package/dist/repl/export.d.ts.map +1 -0
  99. package/dist/repl/export.js +23 -0
  100. package/dist/repl/export.js.map +1 -0
  101. package/dist/repl/frames.d.ts +21 -0
  102. package/dist/repl/frames.d.ts.map +1 -0
  103. package/dist/repl/frames.js +79 -0
  104. package/dist/repl/frames.js.map +1 -0
  105. package/dist/repl/harness-tools.d.ts +74 -0
  106. package/dist/repl/harness-tools.d.ts.map +1 -0
  107. package/dist/repl/harness-tools.js +121 -0
  108. package/dist/repl/harness-tools.js.map +1 -0
  109. package/dist/repl/highlight.d.ts +30 -0
  110. package/dist/repl/highlight.d.ts.map +1 -0
  111. package/dist/repl/highlight.js +285 -0
  112. package/dist/repl/highlight.js.map +1 -0
  113. package/dist/repl/history.d.ts +234 -0
  114. package/dist/repl/history.d.ts.map +1 -0
  115. package/dist/repl/history.js +661 -0
  116. package/dist/repl/history.js.map +1 -0
  117. package/dist/repl/index.d.ts +120 -0
  118. package/dist/repl/index.d.ts.map +1 -0
  119. package/dist/repl/index.js +107 -0
  120. package/dist/repl/index.js.map +1 -0
  121. package/dist/repl/judge.d.ts +51 -0
  122. package/dist/repl/judge.d.ts.map +1 -0
  123. package/dist/repl/judge.js +58 -0
  124. package/dist/repl/judge.js.map +1 -0
  125. package/dist/repl/markdown.d.ts +25 -0
  126. package/dist/repl/markdown.d.ts.map +1 -0
  127. package/dist/repl/markdown.js +103 -0
  128. package/dist/repl/markdown.js.map +1 -0
  129. package/dist/repl/picker.d.ts +34 -0
  130. package/dist/repl/picker.d.ts.map +1 -0
  131. package/dist/repl/picker.js +81 -0
  132. package/dist/repl/picker.js.map +1 -0
  133. package/dist/repl/project-context.d.ts +16 -0
  134. package/dist/repl/project-context.d.ts.map +1 -0
  135. package/dist/repl/project-context.js +23 -0
  136. package/dist/repl/project-context.js.map +1 -0
  137. package/dist/repl/render.d.ts +160 -0
  138. package/dist/repl/render.d.ts.map +1 -0
  139. package/dist/repl/render.js +715 -0
  140. package/dist/repl/render.js.map +1 -0
  141. package/dist/repl/session.d.ts +356 -0
  142. package/dist/repl/session.d.ts.map +1 -0
  143. package/dist/repl/session.js +1275 -0
  144. package/dist/repl/session.js.map +1 -0
  145. package/dist/repl/status.d.ts +100 -0
  146. package/dist/repl/status.d.ts.map +1 -0
  147. package/dist/repl/status.js +218 -0
  148. package/dist/repl/status.js.map +1 -0
  149. package/dist/repl/tools.d.ts +53 -0
  150. package/dist/repl/tools.d.ts.map +1 -0
  151. package/dist/repl/tools.js +307 -0
  152. package/dist/repl/tools.js.map +1 -0
  153. package/dist/repl/toolset.d.ts +32 -0
  154. package/dist/repl/toolset.d.ts.map +1 -0
  155. package/dist/repl/toolset.js +82 -0
  156. package/dist/repl/toolset.js.map +1 -0
  157. package/dist/repl/tui/editor.d.ts +17 -0
  158. package/dist/repl/tui/editor.d.ts.map +1 -0
  159. package/dist/repl/tui/editor.js +39 -0
  160. package/dist/repl/tui/editor.js.map +1 -0
  161. package/dist/repl/tui/status-bar.d.ts +26 -0
  162. package/dist/repl/tui/status-bar.d.ts.map +1 -0
  163. package/dist/repl/tui/status-bar.js +47 -0
  164. package/dist/repl/tui/status-bar.js.map +1 -0
  165. package/dist/repl/tui/theme.d.ts +30 -0
  166. package/dist/repl/tui/theme.d.ts.map +1 -0
  167. package/dist/repl/tui/theme.js +81 -0
  168. package/dist/repl/tui/theme.js.map +1 -0
  169. package/dist/repl/tui/transcript.d.ts +39 -0
  170. package/dist/repl/tui/transcript.d.ts.map +1 -0
  171. package/dist/repl/tui/transcript.js +123 -0
  172. package/dist/repl/tui/transcript.js.map +1 -0
  173. package/dist/runner.d.ts +145 -13
  174. package/dist/runner.d.ts.map +1 -1
  175. package/dist/runner.js +600 -282
  176. package/dist/runner.js.map +1 -1
  177. package/dist/sdk.d.ts.map +1 -1
  178. package/dist/sdk.js +56 -32
  179. package/dist/sdk.js.map +1 -1
  180. package/dist/system/assets/docs/AGENT_PROMPT.md +1373 -0
  181. package/dist/system/assets/docs/DML_AUTHORING.md +195 -0
  182. package/dist/system/assets/docs/DML_REFERENCE.md +393 -72
  183. package/dist/system/assets/docs/HARNESS_EXAMPLES.md +172 -0
  184. package/dist/system/assets/docs/HARNESS_PATTERNS.md +562 -0
  185. package/dist/system/assets/docs/META_PROMPT.md +68 -0
  186. package/dist/system/assets/docs/PROLOG_SNIPPETS.md +117 -0
  187. package/dist/system/assets/index.d.ts +9 -17
  188. package/dist/system/assets/index.d.ts.map +1 -1
  189. package/dist/system/assets/index.js +26 -85
  190. package/dist/system/assets/index.js.map +1 -1
  191. package/dist/system/runtime/agentvm-manager.d.ts +9 -2
  192. package/dist/system/runtime/agentvm-manager.d.ts.map +1 -1
  193. package/dist/system/runtime/agentvm-manager.js +70 -44
  194. package/dist/system/runtime/agentvm-manager.js.map +1 -1
  195. package/dist/system/runtime/media.d.ts +23 -0
  196. package/dist/system/runtime/media.d.ts.map +1 -0
  197. package/dist/system/runtime/media.js +55 -0
  198. package/dist/system/runtime/media.js.map +1 -0
  199. package/dist/system/runtime/shell-limits.d.ts +21 -0
  200. package/dist/system/runtime/shell-limits.d.ts.map +1 -0
  201. package/dist/system/runtime/shell-limits.js +39 -0
  202. package/dist/system/runtime/shell-limits.js.map +1 -0
  203. package/dist/system/runtime/shell-manager.d.ts +8 -3
  204. package/dist/system/runtime/shell-manager.d.ts.map +1 -1
  205. package/dist/system/runtime/shell-manager.js +56 -39
  206. package/dist/system/runtime/shell-manager.js.map +1 -1
  207. package/dist/system/runtime/shell-tool-events.js +5 -0
  208. package/dist/system/runtime/shell-tool-events.js.map +1 -1
  209. package/dist/system/runtime/token-usage.d.ts +2 -0
  210. package/dist/system/runtime/token-usage.d.ts.map +1 -1
  211. package/dist/system/runtime/token-usage.js +7 -0
  212. package/dist/system/runtime/token-usage.js.map +1 -1
  213. package/dist/tools.d.ts +3 -21
  214. package/dist/tools.d.ts.map +1 -1
  215. package/dist/tools.js +14 -168
  216. package/dist/tools.js.map +1 -1
  217. package/dist/types.d.ts +149 -118
  218. package/dist/types.d.ts.map +1 -1
  219. package/dist/validate.d.ts +19 -0
  220. package/dist/validate.d.ts.map +1 -0
  221. package/dist/validate.js +338 -0
  222. package/dist/validate.js.map +1 -0
  223. package/dist/visualize/index.d.ts +52 -0
  224. package/dist/visualize/index.d.ts.map +1 -0
  225. package/dist/visualize/index.js +189 -0
  226. package/dist/visualize/index.js.map +1 -0
  227. package/package.json +17 -15
  228. package/src/prolog-src/deepclause_analysis.pl +10 -2
  229. package/src/prolog-src/deepclause_mi.pl +2522 -118
  230. package/dist/cli/commands.d.ts +0 -42
  231. package/dist/cli/commands.d.ts.map +0 -1
  232. package/dist/cli/commands.js +0 -246
  233. package/dist/cli/commands.js.map +0 -1
  234. package/dist/cli/compile.d.ts +0 -99
  235. package/dist/cli/compile.d.ts.map +0 -1
  236. package/dist/cli/compile.js +0 -363
  237. package/dist/cli/compile.js.map +0 -1
  238. package/dist/cli/default-skills.d.ts +0 -10
  239. package/dist/cli/default-skills.d.ts.map +0 -1
  240. package/dist/cli/default-skills.js +0 -206
  241. package/dist/cli/default-skills.js.map +0 -1
  242. package/dist/cli/interactive.d.ts +0 -2
  243. package/dist/cli/interactive.d.ts.map +0 -1
  244. package/dist/cli/interactive.js +0 -20
  245. package/dist/cli/interactive.js.map +0 -1
  246. package/dist/cli/mcp.d.ts +0 -56
  247. package/dist/cli/mcp.d.ts.map +0 -1
  248. package/dist/cli/mcp.js +0 -138
  249. package/dist/cli/mcp.js.map +0 -1
  250. package/dist/cli/prompt.d.ts +0 -2
  251. package/dist/cli/prompt.d.ts.map +0 -1
  252. package/dist/cli/prompt.js +0 -2
  253. package/dist/cli/prompt.js.map +0 -1
  254. package/dist/cli/search.d.ts +0 -19
  255. package/dist/cli/search.d.ts.map +0 -1
  256. package/dist/cli/search.js +0 -189
  257. package/dist/cli/search.js.map +0 -1
  258. package/dist/cli/tool-args.d.ts +0 -2
  259. package/dist/cli/tool-args.d.ts.map +0 -1
  260. package/dist/cli/tool-args.js +0 -39
  261. package/dist/cli/tool-args.js.map +0 -1
  262. package/dist/cli/tools.d.ts +0 -36
  263. package/dist/cli/tools.d.ts.map +0 -1
  264. package/dist/cli/tools.js +0 -229
  265. package/dist/cli/tools.js.map +0 -1
  266. package/dist/cli/tui/index.d.ts +0 -22
  267. package/dist/cli/tui/index.d.ts.map +0 -1
  268. package/dist/cli/tui/index.js +0 -29
  269. package/dist/cli/tui/index.js.map +0 -1
  270. package/dist/cli/tui.d.ts +0 -167
  271. package/dist/cli/tui.d.ts.map +0 -1
  272. package/dist/cli/tui.js +0 -5228
  273. package/dist/cli/tui.js.map +0 -1
  274. package/dist/compiler_prompt.d.ts +0 -20
  275. package/dist/compiler_prompt.d.ts.map +0 -1
  276. package/dist/compiler_prompt.js +0 -870
  277. package/dist/compiler_prompt.js.map +0 -1
  278. package/dist/deepclause-cli.skill +0 -0
  279. package/dist/prolog-src/deepclause_mi.pl.bak +0 -570
  280. package/dist/system/assets/compactors/default-memory-compactor.dml +0 -6
  281. package/dist/system/assets/docs/CONDUCTOR_PROMPT.md +0 -105
  282. package/dist/system/assets/docs/DML_COMPILER_PROMPT.md +0 -700
  283. package/dist/system/assets/docs/TUI.md +0 -150
  284. package/dist/system/assets/recipes/deepclause-coding-workflow/SKILL.md +0 -100
  285. package/dist/system/assets/skills/conductor.dml +0 -76
  286. package/dist/system/assets/skills/deep-planner.dml +0 -412
  287. package/dist/system/assets/skills/plan.dml +0 -429
  288. package/dist/system/assets/skills/security-planner.dml +0 -337
  289. package/dist/system/assets/skills/skill-creator.dml +0 -187
  290. package/dist/system/runtime/catalog-recipes.d.ts +0 -24
  291. package/dist/system/runtime/catalog-recipes.d.ts.map +0 -1
  292. package/dist/system/runtime/catalog-recipes.js +0 -273
  293. package/dist/system/runtime/catalog-recipes.js.map +0 -1
  294. package/dist/system/runtime/catalog-skills.d.ts +0 -50
  295. package/dist/system/runtime/catalog-skills.d.ts.map +0 -1
  296. package/dist/system/runtime/catalog-skills.js +0 -152
  297. package/dist/system/runtime/catalog-skills.js.map +0 -1
  298. package/dist/system/runtime/conductor.d.ts +0 -105
  299. package/dist/system/runtime/conductor.d.ts.map +0 -1
  300. package/dist/system/runtime/conductor.js +0 -732
  301. package/dist/system/runtime/conductor.js.map +0 -1
  302. package/dist/system/runtime/console-capture.d.ts +0 -9
  303. package/dist/system/runtime/console-capture.d.ts.map +0 -1
  304. package/dist/system/runtime/console-capture.js +0 -67
  305. package/dist/system/runtime/console-capture.js.map +0 -1
  306. package/dist/system/runtime/dml-executor.d.ts +0 -52
  307. package/dist/system/runtime/dml-executor.d.ts.map +0 -1
  308. package/dist/system/runtime/dml-executor.js +0 -203
  309. package/dist/system/runtime/dml-executor.js.map +0 -1
  310. package/dist/system/runtime/runtime-tools.d.ts +0 -31
  311. package/dist/system/runtime/runtime-tools.d.ts.map +0 -1
  312. package/dist/system/runtime/runtime-tools.js +0 -312
  313. package/dist/system/runtime/runtime-tools.js.map +0 -1
  314. package/dist/system/runtime/skill-creator.d.ts +0 -38
  315. package/dist/system/runtime/skill-creator.d.ts.map +0 -1
  316. package/dist/system/runtime/skill-creator.js +0 -763
  317. package/dist/system/runtime/skill-creator.js.map +0 -1
  318. package/src/prolog-src/deepclause_mi.pl.bak +0 -570
@@ -1,429 +0,0 @@
1
- % Plan skill that writes a simple runnable DML file into plans/.
2
-
3
- tool(consult_recipes(Query, Result),
4
- "Search the recipe library for workflow guidance, conventions, and reusable approaches relevant to the requested plan.") :-
5
- exec(consult_recipes(query: Query, max_results: 3), Result).
6
-
7
- tool(search_web(Query, Results),
8
- "Search the web for current documentation, examples, and implementation guidance relevant to the requested plan.") :-
9
- exec(web_search(query: Query), Results).
10
-
11
- tool(fetch_url(Url, Content),
12
- "Fetch the text content of a web page by URL for focused documentation research.") :-
13
- exec(url_fetch(url: Url), Result),
14
- get_dict(body, Result, Content).
15
-
16
- tool(download_file(Url, FilePath, Size), "Download a file from a URL and save it to disk. Returns the file path and size.") :-
17
- exec(url_fetch(url: Url, save_to: FilePath), Result),
18
- get_dict(file_path, Result, FilePath),
19
- get_dict(size, Result, Size).
20
-
21
- tool(run_bash(Command, Output), "Run a shell command in the workspace.") :-
22
- exec(bash(command: Command), Output).
23
-
24
- tool(list_skills(Skills),
25
- "List reusable local skills in the current workspace catalog before reinventing an existing capability.") :-
26
- exec(list_skills, Skills).
27
-
28
- tool(run_skill(Slug, Args, Result),
29
- "Run an existing local child skill when it can help produce a better plan. Args is a JSON array of arguments.") :-
30
- exec(run_skill(slug: Slug, args: Args), Result).
31
-
32
- tool(ask_user(Prompt, Response),
33
- "Ask the user for clarification, plan preferences, revisions, or approval during plan creation.") :-
34
- exec(ask_user(prompt: Prompt), Result),
35
- get_dict(user_response, Result, Response).
36
-
37
- agent_main(Request) :-
38
- load_coding_workflow_recipe(CodingWorkflowRecipe),
39
- resolve_model_info(ModelId, Complexity, Reasoning, TaskCount),
40
- output("DEBUG: model info resolved"),
41
- format(string(SystemPrompt), "You create ordered execution plans for DeepClause.
42
-
43
- Current user request:
44
- ~w
45
-
46
- - Do not write DML source.
47
- - Do not write tool definitions.
48
- - Before drafting the task list, consult recipes relevant to the request.
49
- - First decide whether the current request is primarily a coding task, a non-coding task, or a mixed task.
50
- - For coding tasks, prefer recipe guidance, existing local skills, and repository-aware implementation steps. Use web research only when the task depends on external documentation, APIs, libraries, or current behavior that is not already available locally.
51
- - For non-coding tasks, prefer recipe guidance plus search_web/fetch_url for factual research, background gathering, comparison, or synthesis. Do not force code-editing steps when the request is not actually about changing code.
52
- - For mixed tasks, combine both modes deliberately and keep the task list ordered so research informs the later implementation or delivery steps.
53
- - Use list_skills/run_skill only when an existing local skill is clearly relevant to the request or can improve the resulting plan.
54
- - Choose tools conservatively and intentionally; do not use web or child-skill tools unless they improve the plan quality.
55
- - Return only an ordered list of ~w plain natural-language task strings.
56
- - Each task string should describe one concrete execution step for fulfilling the user's request.
57
- - Each task must be actionable, concise, and free of code, shell commands, JSON, XML, HTML, CSS, JavaScript, TypeScript, Python, DML, and Markdown fences.
58
- - Plans should generally create or modify normal project files outside '.deepclause/'.
59
- - Only target '.deepclause/' when the user explicitly asks for DeepClause internals, prompts, recipes, skills, or runtime configuration.
60
- - Use the available recipe, research, and child-skill tools when they materially improve the task list.
61
- - Consult the DML reference and compiler guidance below to understand the execution environment, but still return only the ordered list of task strings.
62
- ", [Request, TaskCount]),
63
- system(SystemPrompt),
64
-
65
- task("Create a short file-safe slug for this request: '{Request}'.
66
- Requirements:
67
- - lowercase letters, digits, and underscores only
68
- - 2 to 6 words when possible
69
- - no file extension
70
- Store only the slug in PlanSlug.", string(PlanSlug)),
71
-
72
- task("Classify this request for plan execution: '{Request}'.
73
- Requirements:
74
- - Return exactly one label: coding, non_coding, or mixed.
75
- - Use coding when the request mainly requires editing code, configuration, tests, scripts, or other project files.
76
- - Use non_coding when the request is mainly research, analysis, writing, planning, or information gathering without meaningful code changes.
77
- - Use mixed when the request needs both substantial research or analysis and meaningful implementation or file changes.
78
- Store only the label in PlanMode.", string(PlanModeRaw)),
79
-
80
- normalize_plan_mode(PlanModeRaw, PlanMode),
81
-
82
- task("Break this request into {TaskCount} smaller execution tasks for a standalone DeepClause plan: '{Request}'.
83
-
84
- If this is a coding task:
85
- - First perform a review and analysis of the current code base relative to the request
86
- - Use the results of the analysis as a basis for your plan. The plan should be very specific.
87
-
88
- General Requirements for the plan:
89
- - Consult relevant recipes before finalizing PlanTasks.
90
- - Decide whether the request is primarily coding, non-coding, or mixed, and shape the task list accordingly.
91
- - For coding tasks, favor repository-aware implementation, verification, and delivery steps; use web research only when external documentation is genuinely needed.
92
- - For non-coding tasks, favor research, synthesis, comparison, and delivery steps; do not invent unnecessary coding work.
93
- - For mixed tasks, order the plan so discovery and research steps come before implementation or delivery steps that depend on them.
94
- - Use list_skills/run_skill only when an existing local skill is clearly relevant.
95
- - Return only the ordered list of task descriptions in PlanTasks.
96
- - Each item must be a plain natural-language execution step, not code.
97
- - Do not include numbering, bullets, code, shell commands, JSON, XML, HTML, CSS, JavaScript, TypeScript, Python, DML, or Markdown fences.
98
- - Each task should be specific enough that a later agent task can execute it with the available conductor-style tools.
99
- - The plan should generally create or modify normal project files outside '.deepclause/'.
100
- - Consult recipes, web research, fetched URLs, or child skills when they would materially improve the plan.
101
-
102
- Store only the ordered list in PlanTasks.", list(string(PlanTasks))),
103
-
104
- derive_plan_system_prompt(Request, PlanMode, CodingWorkflowRecipe, PlanTasks, PlanSystemPrompt),
105
- derive_tool_and_reasoning_assignments(Request, PlanTasks, ModelId, Complexity, Reasoning, PlanSteps),
106
-
107
- make_directory_path('plans'),
108
- format(string(FilePath), "plans/~w.dml", [PlanSlug]),
109
-
110
- build_plan_review_message(FilePath, PlanMode, PlanSteps, PlanReviewMessage),
111
- output(PlanReviewMessage),
112
-
113
- output("Assembling the deterministic plan file..."),
114
- assemble_plan_dml(PlanSystemPrompt, PlanSteps, PlanDml),
115
- exec(write_file(path: FilePath, content: PlanDml), _),
116
- exec(validate_dml(dml_file: FilePath), ValidationResult),
117
- finish_plan_creation(FilePath, PlanSlug, ValidationResult, PlanReviewMessage).
118
-
119
- %% resolve_model_info(-ModelId, -Complexity, -Reasoning, -TaskCount)
120
- %% Reads model info from params (injected by runtime) and derives task count.
121
- resolve_model_info(ModelId, Complexity, Reasoning, TaskCount) :-
122
- ( catch(
123
- ( param(model_info, ModelInfo),
124
- is_dict(ModelInfo),
125
- get_dict(modelId, ModelInfo, ModelId),
126
- ( get_dict(complexity, ModelInfo, C) -> Complexity = C ; Complexity = medium ),
127
- ( get_dict(reasoning, ModelInfo, R), R == true -> Reasoning = true ; Reasoning = false )
128
- ),
129
- _,
130
- fail
131
- )
132
- -> true
133
- ; ModelId = "unknown",
134
- Complexity = medium,
135
- Reasoning = false
136
- ),
137
- task_count_for_complexity(Complexity, TaskCount).
138
-
139
- task_count_for_complexity("high", "3 to 5").
140
- task_count_for_complexity("medium", "4 to 6").
141
- task_count_for_complexity("low", "6 to 10").
142
- task_count_for_complexity(high, "3 to 5").
143
- task_count_for_complexity(medium, "4 to 6").
144
- task_count_for_complexity(low, "6 to 10").
145
-
146
- %% derive_tool_and_reasoning_assignments(+Request, +PlanTasks, +ModelId, +Complexity, +Reasoning, -PlanSteps)
147
- %% Asks the LLM to assign tools, reasoning effort, and recipe queries per task.
148
- derive_tool_and_reasoning_assignments(Request, PlanTasks, ModelId, Complexity, Reasoning, PlanSteps) :-
149
- ( Reasoning == true
150
- -> ReasoningNote = "The execution model supports reasoning. Assign reasoning effort per task: none, low, medium, or high. Use 'high' for complex analysis/debugging, 'medium' for standard implementation, 'low' for boilerplate, 'none' for trivial tasks."
151
- ; ReasoningNote = "The execution model does not support reasoning. Set reasoning to 'none' for all tasks."
152
- ),
153
- task("For each task in this plan, decide which tools it needs, a reasoning effort level, and an optional recipe query.
154
-
155
- Request: {Request}
156
- Tasks: {PlanTasks}
157
- Execution model: {ModelId} ({Complexity} complexity)
158
-
159
- Available tools (use ONLY these exact names):
160
- - run_bash: Run a shell command (use for file I/O, running tests, installing deps, git, etc.)
161
- - run_skill: Run an existing local skill
162
- - consult_recipes: Search recipe library for workflow guidance
163
- - search_web: Search the web for documentation or examples
164
- - search_news: Search recent news
165
- - fetch_url: Fetch a web page by URL
166
- - download_file: Download a file from a URL
167
- - create_new_skill: Create a new reusable skill
168
- - ask_user: Ask the user a clarifying question
169
- - inform_user: Send a status update
170
-
171
- Note: There is no separate save_file or read_file tool. File operations go through run_bash (e.g. cat, echo, heredoc).
172
-
173
- {ReasoningNote}
174
-
175
- Also specify a recipe query for each task if relevant (NONE otherwise). Use natural language queries like 'testing patterns' or 'codebase analysis'.
176
-
177
- Return three ordered lists aligned 1:1 with Tasks:
178
- - ToolSpecs: each item must be either ALL or a comma-separated list of exact tool names from the available tools list above.
179
- - ReasoningSpecs: each item must be exactly one of none, low, medium, high.
180
- - RecipeSpecs: each item must be either NONE or a recipe query string.
181
-
182
- Store the ordered tool specs in ToolSpecs.
183
- Store the ordered reasoning specs in ReasoningSpecs.
184
- Store the ordered recipe specs in RecipeSpecs.", list(string(ToolSpecs)), list(string(ReasoningSpecs)), list(string(RecipeSpecs))),
185
- ( build_plan_steps_from_specs(PlanTasks, ToolSpecs, ReasoningSpecs, RecipeSpecs, PlanSteps)
186
- -> true
187
- ; % Fallback: no tool/reasoning/recipe assignments
188
- fallback_plan_steps(PlanTasks, PlanSteps)
189
- ).
190
-
191
- %% Valid tool names that exist in conductor_tool_definitions
192
- valid_plan_tool(run_bash).
193
- valid_plan_tool(run_skill).
194
- valid_plan_tool(consult_recipes).
195
- valid_plan_tool(search_web).
196
- valid_plan_tool(search_news).
197
- valid_plan_tool(fetch_url).
198
- valid_plan_tool(download_file).
199
- valid_plan_tool(create_new_skill).
200
- valid_plan_tool(ask_user).
201
- valid_plan_tool(inform_user).
202
-
203
- default_plan_tools([run_bash, run_skill, consult_recipes, search_web, search_news, fetch_url, download_file, create_new_skill, ask_user, inform_user]).
204
-
205
- build_plan_steps_from_specs([], [], [], [], []).
206
- build_plan_steps_from_specs([Desc|RestDesc], [ToolSpec|RestTools], [ReasoningSpec|RestReasoning], [RecipeSpec|RestRecipes], [plan_step{description: Desc, tools: Tools, reasoning: Reasoning, recipe: Recipe}|RestSteps]) :-
207
- normalize_tools_spec(ToolSpec, Tools),
208
- normalize_reasoning_spec(ReasoningSpec, Reasoning),
209
- normalize_recipe_spec(RecipeSpec, Recipe),
210
- build_plan_steps_from_specs(RestDesc, RestTools, RestReasoning, RestRecipes, RestSteps).
211
-
212
- normalize_tools_spec(Raw, Tools) :-
213
- format(string(Text), "~w", [Raw]),
214
- string_lower(Text, Lower),
215
- ( Lower = "all"
216
- -> default_plan_tools(Tools)
217
- ; split_string(Text, ",", " []\t\n", Parts0),
218
- include(non_empty_string, Parts0, Parts),
219
- findall(ToolAtom,
220
- ( member(Part, Parts),
221
- tool_name_string_to_atom(Part, ToolAtom),
222
- valid_plan_tool(ToolAtom)
223
- ),
224
- ValidTools),
225
- ( ValidTools = []
226
- -> default_plan_tools(Tools)
227
- ; Tools = ValidTools
228
- )
229
- ).
230
-
231
- normalize_reasoning_spec(Raw, Reasoning) :-
232
- format(string(Text), "~w", [Raw]),
233
- string_lower(Text, Lower),
234
- normalize_reasoning_label(Lower, Reasoning).
235
-
236
- normalize_reasoning_label("high", "high").
237
- normalize_reasoning_label("medium", "medium").
238
- normalize_reasoning_label("low", "low").
239
- normalize_reasoning_label("none", "none").
240
- normalize_reasoning_label(_, "none").
241
-
242
- normalize_recipe_spec(Raw, Recipe) :-
243
- format(string(Text0), "~w", [Raw]),
244
- normalize_space(string(Text), Text0),
245
- string_lower(Text, Lower),
246
- ( Lower = ""
247
- -> Recipe = "none"
248
- ; Lower = "none"
249
- -> Recipe = "none"
250
- ; Recipe = Text
251
- ).
252
-
253
- tool_name_string_to_atom(Text, Atom) :-
254
- string_lower(Text, Lower),
255
- atom_string(Atom, Lower).
256
-
257
- non_empty_string(Text) :-
258
- Text \= "".
259
-
260
- %% fallback_plan_steps(+PlanTasks, -PlanSteps)
261
- %% When JSON parsing fails, create steps with all tools and no reasoning/recipe.
262
- fallback_plan_steps([], []).
263
- fallback_plan_steps([Desc|Rest], [plan_step{description: Desc, tools: Tools, reasoning: "none", recipe: "none"}|RestSteps]) :-
264
- default_plan_tools(Tools),
265
- fallback_plan_steps(Rest, RestSteps).
266
-
267
- assemble_plan_dml(PlanSystemPrompt, PlanSteps, PlanDml) :-
268
- conductor_tool_definitions(ToolBlock),
269
- build_task_lines(PlanSteps, TaskLines),
270
- format(string(PlanDml), "% Generated DeepClause plan.~n% This file was assembled deterministically from a task list.~n~n~s~n~nagent_main :-~n system(~q),~n output(\"Starting generated plan.\"),~n~s answer(\"Plan completed.\").~n~nagent_main :-~n answer(\"Plan failed. Please try again.\").~n", [ToolBlock, PlanSystemPrompt, TaskLines]).
271
-
272
- derive_plan_system_prompt(Request, PlanMode, CodingWorkflowRecipe, PlanTasks, PlanSystemPrompt) :-
273
- task("Create a concise system prompt for the generated DeepClause plan for this request: '{Request}'.
274
- Plan mode: {PlanMode}.
275
- DeepClause Coding Workflow recipe content:
276
- {CodingWorkflowRecipe}
277
-
278
- Planned steps: {PlanTasks}.
279
-
280
- What to mention in the system prompt:
281
- - State that the executor is carrying out a generated DeepClause plan.
282
- - Include the DeepClause Coding Workflow recipe guidance below in the final system prompt so the generated plan always carries it forward.
283
- - Reflect whether the work is coding, non-coding, or mixed.
284
- - Tell the executor to consult recipes before substantive action.
285
- - Tell the executor to choose tools deliberately.
286
- - For coding tasks, prefer repository-aware and local tools first.
287
- - For non-coding tasks, prefer research tools when the work is mainly investigation or synthesis.
288
- - Explicitly say that discussions, questions, and clarifications are fine, and ask_user can be used when helpful.
289
- - Keep the prompt concise and actionable.
290
- Store only the final system prompt text in SystemPrompt.", string(SystemPrompt)),
291
- load_coding_workflow_recipe(CodingWorkflowRecipe),
292
- format(string(PlanSystemPrompt), "~w\n~w\n", [SystemPrompt, CodingWorkflowRecipe]).
293
-
294
-
295
- load_coding_workflow_recipe(CodingWorkflowRecipe) :-
296
- exec(consult_recipes(query: 'deepclause coding workflow', max_results: 3), Result),
297
- get_dict(matches, Result, Matches),
298
- Matches = [FirstMatch|_],
299
- get_dict(content, FirstMatch, CodingWorkflowRecipe),
300
- !.
301
-
302
- load_coding_workflow_recipe("DeepClause Coding Workflow recipe unavailable. Follow standard DeepClause coding workflow guidance.").
303
-
304
- build_plan_review_message(FilePath, PlanMode, PlanSteps, PlanReviewMessage) :-
305
- build_step_review_lines(PlanSteps, 1, StepLines),
306
- format(string(PlanReviewMessage), "Proposed plan overview\n- Output file: ~w\n- Plan mode: ~w\n\nPlanned steps:\n~s", [FilePath, PlanMode, StepLines]).
307
-
308
- build_step_review_lines([], _, "").
309
- build_step_review_lines([Step|RestSteps], StepNumber, StepLines) :-
310
- Desc = Step.description,
311
- Tools = Step.tools,
312
- Reasoning = Step.reasoning,
313
- format(string(CurrentStep), "~w. ~w [tools: ~w, ~w]\n", [StepNumber, Desc, Tools, Reasoning]),
314
- NextStepNumber is StepNumber + 1,
315
- build_step_review_lines(RestSteps, NextStepNumber, RestStepLines),
316
- string_concat(CurrentStep, RestStepLines, StepLines).
317
-
318
- build_task_lines([], "").
319
- build_task_lines([Step|Rest], TaskLines) :-
320
- build_single_task_line(Step, Line),
321
- build_task_lines(Rest, RestLines),
322
- string_concat(Line, RestLines, TaskLines).
323
-
324
- build_single_task_line(Step, Line) :-
325
- Desc = Step.description,
326
- Tools = Step.tools,
327
- Reasoning = Step.reasoning,
328
- Recipe = Step.recipe,
329
-
330
- format(string(InnerTask), "with_tools(~w, task(~q))", [Tools, Desc]),
331
-
332
- ( Reasoning \= "none"
333
- -> format(string(WithReasoning), "with_reasoning(~n ~w~n , ~w)", [InnerTask, Reasoning])
334
- ; WithReasoning = InnerTask
335
- ),
336
-
337
- ( Recipe \= "none"
338
- -> format(string(Line), " with_recipe(~n ~w~n , '~w'),~n", [WithReasoning, Recipe])
339
- ; format(string(Line), " ~w,~n", [WithReasoning])
340
- ).
341
-
342
- normalize_plan_mode(PlanModeRaw, PlanMode) :-
343
- format(string(PlanModeString), "~w", [PlanModeRaw]),
344
- normalize_plan_mode_string(PlanModeString, PlanMode).
345
-
346
- normalize_plan_mode_string("coding", "coding").
347
- normalize_plan_mode_string("Coding", "coding").
348
- normalize_plan_mode_string("non_coding", "non_coding").
349
- normalize_plan_mode_string("Non_coding", "non_coding").
350
- normalize_plan_mode_string("non-coding", "non_coding").
351
- normalize_plan_mode_string("Non-coding", "non_coding").
352
- normalize_plan_mode_string("mixed", "mixed").
353
- normalize_plan_mode_string("Mixed", "mixed").
354
- normalize_plan_mode_string(_, "mixed").
355
-
356
- finish_plan_creation(FilePath, PlanSlug, ValidationResult, FinalPlanReview) :-
357
- get_dict(valid, ValidationResult, true),
358
- output("Deterministic plan validated successfully."),
359
- format(string(Message), "I've created a new plan in ~w.\n\n~s\nRun it with /run ~w or /~w.", [FilePath, FinalPlanReview, FilePath, PlanSlug]),
360
- answer(Message).
361
-
362
- finish_plan_creation(FilePath, _, ValidationResult, _) :-
363
- format(string(Message), "I wrote ~w, but the deterministic template failed validation: ~w", [FilePath, ValidationResult]),
364
- answer(Message).
365
-
366
- conductor_tool_definitions(ToolBlock) :-
367
- atomics_to_string([
368
- '% --- Tool predicates (full tool set) ---',
369
- '',
370
- 'tool(run_skill(Slug, Args, Result), "Run an existing skill. Slug is the skill slug (e.g. ''deep-research''). Args is a JSON array of string arguments. Returns the skill result.") :-',
371
- '',
372
- ' exec(run_skill(slug: Slug, args: Args), Result).',
373
- '',
374
- 'tool(consult_recipes(Query, Result), "Search the recipe library for workflow guidance and conventions. Query is a natural-language description. Returns matching recipe metadata and content.") :-',
375
- '',
376
- ' exec(consult_recipes(query: Query, max_results: 3), Result).',
377
- '',
378
- 'tool(search_web(Query, Results), "Search the web for current information. Returns search results.") :-',
379
- '',
380
- ' exec(web_search(query: Query), Results).',
381
- '',
382
- 'tool(search_news(Query, Results), "Search recent news articles. Returns news results.") :-',
383
- '',
384
- ' exec(news_search(query: Query), Results).',
385
- '',
386
- 'tool(fetch_url(Url, Content), "Fetch the content of a web page by URL. Returns the page body as text.") :-',
387
- '',
388
- ' exec(url_fetch(url: Url), Result),',
389
- ' get_dict(body, Result, Content).',
390
- '',
391
- 'tool(download_file(Url, FilePath, Size), "Download a file from a URL and save it to disk. Returns the file path and size.") :-',
392
- '',
393
- ' exec(url_fetch(url: Url, save_to: FilePath), Result),',
394
- ' get_dict(file_path, Result, FilePath),',
395
- ' get_dict(size, Result, Size).',
396
- '',
397
- 'tool(run_bash(Command, Output), "Run a shell command in the workspace.") :-',
398
- '',
399
- ' exec(bash(command: Command), Output).',
400
- '',
401
- 'tool(create_new_skill(Spec, Result), "Create and deploy a new reusable skill from a natural language spec.") :-',
402
- '',
403
- ' exec(create_skill(spec: Spec), Result).',
404
- '',
405
- 'tool(ask_user(Prompt, Response), "Ask the user a clarifying question and get their response.") :-',
406
- '',
407
- ' exec(ask_user(prompt: Prompt), Result),',
408
- ' get_dict(user_response, Result, Response).',
409
- '',
410
- 'tool(inform_user(Message, Result), "Send a status update or progress report to the user.") :-',
411
- ' output(Message),',
412
- ' Result = "ok".'
413
- ], "\n", ToolBlock).
414
-
415
- load_dml_reference(DmlReference) :-
416
- ( exists_file('.deepclause/docs/DML_REFERENCE.md')
417
- -> read_file('.deepclause/docs/DML_REFERENCE.md', DmlReference)
418
- ; DmlReference = "DML reference unavailable. Use standard DeepClause DML conventions."
419
- ).
420
-
421
- load_dml_compiler_prompt(CompilerPrompt) :-
422
- ( exists_file('.deepclause/system/DML_COMPILER_PROMPT.md')
423
- -> read_file('.deepclause/system/DML_COMPILER_PROMPT.md', CompilerPrompt)
424
- ; CompilerPrompt = "DML compiler guidance unavailable. Follow standard DeepClause DML conventions and keep plans simple."
425
- ).
426
-
427
- agent_main(Request) :-
428
- format(string(Message), "I could not create a valid plan file for this request: ~w. Try simplifying the request or being more explicit about the steps and required tools.", [Request]),
429
- answer(Message).