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
|
@@ -1,412 +0,0 @@
|
|
|
1
|
-
% Deep planner — generates a multi-strategy DML plan with k agent_main clauses.
|
|
2
|
-
% Prolog backtracking tries strategies one by one; answer/1 commits on success.
|
|
3
|
-
|
|
4
|
-
tool(consult_recipes(Query, Result),
|
|
5
|
-
"Search the recipe library for workflow guidance, conventions, and reusable approaches relevant to the requested plan.") :-
|
|
6
|
-
exec(consult_recipes(query: Query, max_results: 3), Result).
|
|
7
|
-
|
|
8
|
-
tool(search_web(Query, Results),
|
|
9
|
-
"Search the web for current documentation, examples, and implementation guidance relevant to the requested plan.") :-
|
|
10
|
-
exec(web_search(query: Query), Results).
|
|
11
|
-
|
|
12
|
-
tool(fetch_url(Url, Content),
|
|
13
|
-
"Fetch the text content of a web page by URL for focused documentation research.") :-
|
|
14
|
-
exec(url_fetch(url: Url), Result),
|
|
15
|
-
get_dict(body, Result, Content).
|
|
16
|
-
|
|
17
|
-
tool(download_file(Url, FilePath, Size), "Download a file from a URL and save it to disk. Returns the file path and size.") :-
|
|
18
|
-
exec(url_fetch(url: Url, save_to: FilePath), Result),
|
|
19
|
-
get_dict(file_path, Result, FilePath),
|
|
20
|
-
get_dict(size, Result, Size).
|
|
21
|
-
|
|
22
|
-
tool(run_bash(Command, Output), "Run a shell command in the workspace.") :-
|
|
23
|
-
exec(bash(command: Command), Output).
|
|
24
|
-
|
|
25
|
-
tool(list_skills(Skills),
|
|
26
|
-
"List reusable local skills in the current workspace catalog before reinventing an existing capability.") :-
|
|
27
|
-
exec(list_skills, Skills).
|
|
28
|
-
|
|
29
|
-
tool(run_skill(Slug, Args, Result),
|
|
30
|
-
"Run an existing local child skill when it can help produce a better plan. Args is a JSON array of arguments.") :-
|
|
31
|
-
exec(run_skill(slug: Slug, args: Args), Result).
|
|
32
|
-
|
|
33
|
-
tool(ask_user(Prompt, Response),
|
|
34
|
-
"Ask the user for clarification, plan preferences, revisions, or approval during plan creation.") :-
|
|
35
|
-
exec(ask_user(prompt: Prompt), Result),
|
|
36
|
-
get_dict(user_response, Result, Response).
|
|
37
|
-
|
|
38
|
-
agent_main(Request) :-
|
|
39
|
-
load_dml_reference(DmlReference),
|
|
40
|
-
load_dml_compiler_prompt(CompilerPrompt),
|
|
41
|
-
load_coding_workflow_recipe(CodingWorkflowRecipe),
|
|
42
|
-
resolve_model_info(ModelId, Complexity, Reasoning, TaskCount),
|
|
43
|
-
format(string(SystemPrompt), "You create multi-strategy execution plans for DeepClause.
|
|
44
|
-
|
|
45
|
-
Current user request:
|
|
46
|
-
~w
|
|
47
|
-
|
|
48
|
-
A multi-strategy plan contains multiple agent_main clauses. Prolog tries them in order — if the first strategy's tasks fail, it backtracks and tries the next strategy. answer/1 commits on success.
|
|
49
|
-
|
|
50
|
-
Your job:
|
|
51
|
-
1. Generate a short slug for the plan file.
|
|
52
|
-
2. Generate ~w fundamentally different strategies for the request.
|
|
53
|
-
3. For each strategy, generate a task list with tool assignments, reasoning effort, and recipe queries.
|
|
54
|
-
4. The assembler will create a DML file with one agent_main clause per strategy, plus a fallback.
|
|
55
|
-
|
|
56
|
-
Rules:
|
|
57
|
-
- Each strategy must use a genuinely different approach or architecture.
|
|
58
|
-
- Each strategy needs 3 to 8 focused tasks.
|
|
59
|
-
- Tasks should be plain natural-language execution steps, not code.
|
|
60
|
-
- If the model supports reasoning, assign reasoning effort per task.
|
|
61
|
-
- The generated plan uses with_tools, with_reasoning, and with_recipe for scoping.
|
|
62
|
-
|
|
63
|
-
DML language reference:
|
|
64
|
-
|
|
65
|
-
~s
|
|
66
|
-
|
|
67
|
-
DML compiler guidance:
|
|
68
|
-
|
|
69
|
-
~s", [Request, TaskCount, DmlReference, CompilerPrompt]),
|
|
70
|
-
system(SystemPrompt),
|
|
71
|
-
|
|
72
|
-
task("Create a short file-safe slug for this request: '{Request}'.
|
|
73
|
-
Requirements:
|
|
74
|
-
- lowercase letters, digits, and underscores only
|
|
75
|
-
- 2 to 6 words when possible
|
|
76
|
-
- no file extension
|
|
77
|
-
Store only the slug in PlanSlug.", string(PlanSlug)),
|
|
78
|
-
|
|
79
|
-
generate_strategies(Request, TaskCount, Strategies),
|
|
80
|
-
|
|
81
|
-
generate_all_strategy_tasks(Request, Strategies, StrategyPlans),
|
|
82
|
-
|
|
83
|
-
make_directory_path('plans'),
|
|
84
|
-
format(string(FilePath), "plans/~w.dml", [PlanSlug]),
|
|
85
|
-
|
|
86
|
-
build_review_message(FilePath, StrategyPlans, ReviewMessage),
|
|
87
|
-
output(ReviewMessage),
|
|
88
|
-
|
|
89
|
-
output("Assembling multi-strategy plan file..."),
|
|
90
|
-
assemble_multi_strategy_dml(StrategyPlans, CodingWorkflowRecipe, PlanDml),
|
|
91
|
-
exec(write_file(path: FilePath, content: PlanDml), _),
|
|
92
|
-
exec(validate_dml(dml_file: FilePath), ValidationResult),
|
|
93
|
-
finish_plan_creation(FilePath, PlanSlug, ValidationResult, ReviewMessage).
|
|
94
|
-
|
|
95
|
-
%% resolve_model_info(-ModelId, -Complexity, -Reasoning, -TaskCount)
|
|
96
|
-
resolve_model_info(ModelId, Complexity, Reasoning, TaskCount) :-
|
|
97
|
-
( catch(
|
|
98
|
-
( param(model_info, ModelInfo),
|
|
99
|
-
is_dict(ModelInfo),
|
|
100
|
-
get_dict(modelId, ModelInfo, ModelId),
|
|
101
|
-
( get_dict(complexity, ModelInfo, C) -> Complexity = C ; Complexity = medium ),
|
|
102
|
-
( get_dict(reasoning, ModelInfo, R), R == true -> Reasoning = true ; Reasoning = false )
|
|
103
|
-
),
|
|
104
|
-
_,
|
|
105
|
-
fail
|
|
106
|
-
)
|
|
107
|
-
-> true
|
|
108
|
-
; ModelId = "unknown",
|
|
109
|
-
Complexity = medium,
|
|
110
|
-
Reasoning = false
|
|
111
|
-
),
|
|
112
|
-
task_count_for_complexity(Complexity, TaskCount).
|
|
113
|
-
|
|
114
|
-
task_count_for_complexity("high", "3").
|
|
115
|
-
task_count_for_complexity("medium", "3").
|
|
116
|
-
task_count_for_complexity("low", "3").
|
|
117
|
-
task_count_for_complexity(high, "3").
|
|
118
|
-
task_count_for_complexity(medium, "3").
|
|
119
|
-
task_count_for_complexity(low, "3").
|
|
120
|
-
|
|
121
|
-
%% generate_strategies(+Request, +TaskCount, -Strategies)
|
|
122
|
-
%% Generates k strategy descriptions as a list of strings.
|
|
123
|
-
generate_strategies(Request, TaskCount, Strategies) :-
|
|
124
|
-
task("Generate {TaskCount} fundamentally different strategies for this request:
|
|
125
|
-
|
|
126
|
-
'{Request}'
|
|
127
|
-
|
|
128
|
-
Requirements:
|
|
129
|
-
- Each strategy must use a genuinely different approach, architecture, or methodology.
|
|
130
|
-
- For coding tasks: different tech stacks, patterns, or libraries.
|
|
131
|
-
- For non-coding tasks: different analytical frameworks, data sources, or presentation formats.
|
|
132
|
-
- Each strategy should be plausibly capable of solving the request.
|
|
133
|
-
- Return each strategy as a single string: a short name, then a colon, then a brief approach description.
|
|
134
|
-
- One strategy per line.
|
|
135
|
-
|
|
136
|
-
Store the list of strategy strings in Strategies.", list(string(Strategies))).
|
|
137
|
-
|
|
138
|
-
%% generate_all_strategy_tasks(+Request, +Strategies, -StrategyPlans)
|
|
139
|
-
%% For each strategy, generates a task list with tool/reasoning/recipe assignments.
|
|
140
|
-
generate_all_strategy_tasks(_Request, [], []).
|
|
141
|
-
generate_all_strategy_tasks(Request, [Strategy|RestStrategies], [plan{strategy: Strategy, steps: Steps}|RestPlans]) :-
|
|
142
|
-
generate_strategy_tasks(Request, Strategy, Steps),
|
|
143
|
-
generate_all_strategy_tasks(Request, RestStrategies, RestPlans).
|
|
144
|
-
|
|
145
|
-
%% generate_strategy_tasks(+Request, +Strategy, -Steps)
|
|
146
|
-
%% Generates tasks for a single strategy with tool assignments.
|
|
147
|
-
generate_strategy_tasks(Request, Strategy, Steps) :-
|
|
148
|
-
( param(model_info, ModelInfo)
|
|
149
|
-
-> ( get_dict(reasoning, ModelInfo, R), R == true
|
|
150
|
-
-> ReasoningNote = "The execution model supports reasoning. Assign reasoning effort per task: none, low, medium, or high."
|
|
151
|
-
; ReasoningNote = "The execution model does not support reasoning. Set reasoning to 'none' for all tasks."
|
|
152
|
-
)
|
|
153
|
-
; ReasoningNote = "Set reasoning to 'none' for all tasks."
|
|
154
|
-
),
|
|
155
|
-
task("Break this strategy into 3 to 8 focused execution tasks.
|
|
156
|
-
|
|
157
|
-
Request: {Request}
|
|
158
|
-
Strategy: {Strategy}
|
|
159
|
-
|
|
160
|
-
Available tools (use ONLY these exact names):
|
|
161
|
-
- run_bash: Run a shell command (file I/O, tests, git, etc.)
|
|
162
|
-
- run_skill: Run an existing local skill
|
|
163
|
-
- consult_recipes: Search recipe library for workflow guidance
|
|
164
|
-
- search_web: Search the web for documentation or examples
|
|
165
|
-
- search_news: Search recent news
|
|
166
|
-
- fetch_url: Fetch a web page by URL
|
|
167
|
-
- download_file: Download a file from a URL
|
|
168
|
-
- create_new_skill: Create a new reusable skill
|
|
169
|
-
- ask_user: Ask the user a clarifying question
|
|
170
|
-
- inform_user: Send a status update
|
|
171
|
-
|
|
172
|
-
Note: There is no separate save_file or read_file tool. File operations go through run_bash.
|
|
173
|
-
|
|
174
|
-
{ReasoningNote}
|
|
175
|
-
|
|
176
|
-
Also specify a recipe query for each task if relevant (NONE otherwise).
|
|
177
|
-
|
|
178
|
-
Return four ordered lists aligned 1:1:
|
|
179
|
-
- TaskDescriptions: plain task descriptions.
|
|
180
|
-
- ToolSpecs: each item must be either ALL or a comma-separated list of exact tool names from the available tools list above.
|
|
181
|
-
- ReasoningSpecs: each item must be exactly one of none, low, medium, high.
|
|
182
|
-
- RecipeSpecs: each item must be either NONE or a recipe query string.
|
|
183
|
-
|
|
184
|
-
Store the ordered task descriptions in TaskDescriptions.
|
|
185
|
-
Store the ordered tool specs in ToolSpecs.
|
|
186
|
-
Store the ordered reasoning specs in ReasoningSpecs.
|
|
187
|
-
Store the ordered recipe specs in RecipeSpecs.", list(string(TaskDescriptions)), list(string(ToolSpecs)), list(string(ReasoningSpecs)), list(string(RecipeSpecs))),
|
|
188
|
-
( build_plan_steps_from_specs(TaskDescriptions, ToolSpecs, ReasoningSpecs, RecipeSpecs, Steps)
|
|
189
|
-
-> true
|
|
190
|
-
; fallback_plan_steps_from_strategy(Strategy, Steps)
|
|
191
|
-
).
|
|
192
|
-
|
|
193
|
-
%% Valid tool names that exist in conductor_tool_definitions
|
|
194
|
-
valid_plan_tool(run_bash).
|
|
195
|
-
valid_plan_tool(run_skill).
|
|
196
|
-
valid_plan_tool(consult_recipes).
|
|
197
|
-
valid_plan_tool(search_web).
|
|
198
|
-
valid_plan_tool(search_news).
|
|
199
|
-
valid_plan_tool(fetch_url).
|
|
200
|
-
valid_plan_tool(download_file).
|
|
201
|
-
valid_plan_tool(create_new_skill).
|
|
202
|
-
valid_plan_tool(ask_user).
|
|
203
|
-
valid_plan_tool(inform_user).
|
|
204
|
-
|
|
205
|
-
default_plan_tools([run_bash, run_skill, consult_recipes, search_web, search_news, fetch_url, download_file, create_new_skill, ask_user, inform_user]).
|
|
206
|
-
|
|
207
|
-
build_plan_steps_from_specs([], [], [], [], []).
|
|
208
|
-
build_plan_steps_from_specs([Desc|RestDesc], [ToolSpec|RestTools], [ReasoningSpec|RestReasoning], [RecipeSpec|RestRecipes], [plan_step{description: Desc, tools: Tools, reasoning: Reasoning, recipe: Recipe}|RestSteps]) :-
|
|
209
|
-
normalize_tools_spec(ToolSpec, Tools),
|
|
210
|
-
normalize_reasoning_spec(ReasoningSpec, Reasoning),
|
|
211
|
-
normalize_recipe_spec(RecipeSpec, Recipe),
|
|
212
|
-
build_plan_steps_from_specs(RestDesc, RestTools, RestReasoning, RestRecipes, RestSteps).
|
|
213
|
-
|
|
214
|
-
normalize_tools_spec(Raw, Tools) :-
|
|
215
|
-
format(string(Text), "~w", [Raw]),
|
|
216
|
-
string_lower(Text, Lower),
|
|
217
|
-
( Lower = "all"
|
|
218
|
-
-> default_plan_tools(Tools)
|
|
219
|
-
; split_string(Text, ",", " []\t\n", Parts0),
|
|
220
|
-
include(non_empty_string, Parts0, Parts),
|
|
221
|
-
findall(ToolAtom,
|
|
222
|
-
( member(Part, Parts),
|
|
223
|
-
tool_name_string_to_atom(Part, ToolAtom),
|
|
224
|
-
valid_plan_tool(ToolAtom)
|
|
225
|
-
),
|
|
226
|
-
ValidTools),
|
|
227
|
-
( ValidTools = []
|
|
228
|
-
-> default_plan_tools(Tools)
|
|
229
|
-
; Tools = ValidTools
|
|
230
|
-
)
|
|
231
|
-
).
|
|
232
|
-
|
|
233
|
-
normalize_reasoning_spec(Raw, Reasoning) :-
|
|
234
|
-
format(string(Text), "~w", [Raw]),
|
|
235
|
-
string_lower(Text, Lower),
|
|
236
|
-
normalize_reasoning_label(Lower, Reasoning).
|
|
237
|
-
|
|
238
|
-
normalize_reasoning_label("high", "high").
|
|
239
|
-
normalize_reasoning_label("medium", "medium").
|
|
240
|
-
normalize_reasoning_label("low", "low").
|
|
241
|
-
normalize_reasoning_label("none", "none").
|
|
242
|
-
normalize_reasoning_label(_, "none").
|
|
243
|
-
|
|
244
|
-
normalize_recipe_spec(Raw, Recipe) :-
|
|
245
|
-
format(string(Text0), "~w", [Raw]),
|
|
246
|
-
normalize_space(string(Text), Text0),
|
|
247
|
-
string_lower(Text, Lower),
|
|
248
|
-
( Lower = ""
|
|
249
|
-
-> Recipe = "none"
|
|
250
|
-
; Lower = "none"
|
|
251
|
-
-> Recipe = "none"
|
|
252
|
-
; Recipe = Text
|
|
253
|
-
).
|
|
254
|
-
|
|
255
|
-
tool_name_string_to_atom(Text, Atom) :-
|
|
256
|
-
string_lower(Text, Lower),
|
|
257
|
-
atom_string(Atom, Lower).
|
|
258
|
-
|
|
259
|
-
non_empty_string(Text) :-
|
|
260
|
-
Text \= "".
|
|
261
|
-
|
|
262
|
-
%% fallback_plan_steps_from_strategy(+Strategy, -Steps)
|
|
263
|
-
fallback_plan_steps_from_strategy(Strategy, [plan_step{description: Strategy, tools: Tools, reasoning: "none", recipe: "none"}]) :-
|
|
264
|
-
default_plan_tools(Tools).
|
|
265
|
-
|
|
266
|
-
%% assemble_multi_strategy_dml(+StrategyPlans, +CodingWorkflowRecipe, -PlanDml)
|
|
267
|
-
assemble_multi_strategy_dml(StrategyPlans, CodingWorkflowRecipe, PlanDml) :-
|
|
268
|
-
conductor_tool_definitions(ToolBlock),
|
|
269
|
-
build_strategy_clauses(StrategyPlans, CodingWorkflowRecipe, Clauses),
|
|
270
|
-
format(string(PlanDml), "% Generated DeepClause multi-strategy plan.~n% Prolog tries strategies in order; answer/1 commits on success.~n~n~s~n~n~s~nagent_main :-~n answer(\"All strategies failed.\").~n", [ToolBlock, Clauses]).
|
|
271
|
-
|
|
272
|
-
%% build_strategy_clauses(+StrategyPlans, +CodingWorkflowRecipe, -Clauses)
|
|
273
|
-
build_strategy_clauses([], _, "").
|
|
274
|
-
build_strategy_clauses([Plan|Rest], CodingWorkflowRecipe, Clauses) :-
|
|
275
|
-
Strategy = Plan.strategy,
|
|
276
|
-
Steps = Plan.steps,
|
|
277
|
-
build_system_prompt_for_strategy(Strategy, CodingWorkflowRecipe, SystemPrompt),
|
|
278
|
-
build_task_lines(Steps, TaskLines),
|
|
279
|
-
format(string(StratOutput), "Starting strategy: ~w", [Strategy]),
|
|
280
|
-
format(string(StratAnswer), "Completed via strategy: ~w", [Strategy]),
|
|
281
|
-
format(string(Clause), "agent_main :-~n system(~q),~n output(~q),~n~s answer(~q).~n~n", [SystemPrompt, StratOutput, TaskLines, StratAnswer]),
|
|
282
|
-
build_strategy_clauses(Rest, CodingWorkflowRecipe, RestClauses),
|
|
283
|
-
string_concat(Clause, RestClauses, Clauses).
|
|
284
|
-
|
|
285
|
-
%% build_system_prompt_for_strategy(+Strategy, +CodingWorkflowRecipe, -SystemPrompt)
|
|
286
|
-
build_system_prompt_for_strategy(Strategy, CodingWorkflowRecipe, SystemPrompt) :-
|
|
287
|
-
format(string(SystemPrompt), "You are executing a generated DeepClause plan using this strategy:~n~nStrategy: ~w~n~nFollow the DeepClause Coding Workflow:~n- Start from a concrete anchor (file, command, or implementation surface)~n- Read only enough context to form one falsifiable hypothesis~n- Prefer the smallest edit that tests that hypothesis~n- Run the narrowest validation before widening scope~n- If validation fails, repair the same slice before opening new work~n~n~w~n~nScratchpad:~n- Use run_bash to write important findings to .deepclause.tmp/scratchpad.md (append with >>).~n- Record: environment details, what worked, what failed, file paths created, dependencies installed, error messages.~n- If this strategy fails, a different strategy will be tried automatically. The next strategy can read the scratchpad to learn from your attempt.~n- Read the scratchpad at the start: run_bash('cat .deepclause.tmp/scratchpad.md 2>/dev/null || echo empty').~n- Use tools deliberately and consult recipes when relevant.", [Strategy, CodingWorkflowRecipe]).
|
|
288
|
-
|
|
289
|
-
%% build_task_lines(+PlanSteps, -TaskLines)
|
|
290
|
-
build_task_lines([], "").
|
|
291
|
-
build_task_lines([Step|Rest], TaskLines) :-
|
|
292
|
-
build_single_task_line(Step, Line),
|
|
293
|
-
build_task_lines(Rest, RestLines),
|
|
294
|
-
string_concat(Line, RestLines, TaskLines).
|
|
295
|
-
|
|
296
|
-
build_single_task_line(Step, Line) :-
|
|
297
|
-
Desc = Step.description,
|
|
298
|
-
Tools = Step.tools,
|
|
299
|
-
Reasoning = Step.reasoning,
|
|
300
|
-
Recipe = Step.recipe,
|
|
301
|
-
|
|
302
|
-
format(string(InnerTask), "with_tools(~w, task(~q))", [Tools, Desc]),
|
|
303
|
-
|
|
304
|
-
( Reasoning \= "none"
|
|
305
|
-
-> format(string(WithReasoning), "with_reasoning(~n ~w~n , ~w)", [InnerTask, Reasoning])
|
|
306
|
-
; WithReasoning = InnerTask
|
|
307
|
-
),
|
|
308
|
-
|
|
309
|
-
( Recipe \= "none"
|
|
310
|
-
-> format(string(Line), " with_recipe(~n ~w~n , '~w'),~n", [WithReasoning, Recipe])
|
|
311
|
-
; format(string(Line), " ~w,~n", [WithReasoning])
|
|
312
|
-
).
|
|
313
|
-
|
|
314
|
-
%% build_review_message(+FilePath, +StrategyPlans, -ReviewMessage)
|
|
315
|
-
build_review_message(FilePath, StrategyPlans, ReviewMessage) :-
|
|
316
|
-
length(StrategyPlans, Count),
|
|
317
|
-
build_strategy_review_lines(StrategyPlans, 1, StrategyLines),
|
|
318
|
-
format(string(ReviewMessage), "Proposed multi-strategy plan~n- Output file: ~w~n- Strategies: ~w~n~n~s", [FilePath, Count, StrategyLines]).
|
|
319
|
-
|
|
320
|
-
build_strategy_review_lines([], _, "").
|
|
321
|
-
build_strategy_review_lines([Plan|Rest], Num, Lines) :-
|
|
322
|
-
Strategy = Plan.strategy,
|
|
323
|
-
Steps = Plan.steps,
|
|
324
|
-
length(Steps, StepCount),
|
|
325
|
-
format(string(Current), "~w. ~w (~w tasks)~n", [Num, Strategy, StepCount]),
|
|
326
|
-
NextNum is Num + 1,
|
|
327
|
-
build_strategy_review_lines(Rest, NextNum, RestLines),
|
|
328
|
-
string_concat(Current, RestLines, Lines).
|
|
329
|
-
|
|
330
|
-
finish_plan_creation(FilePath, PlanSlug, ValidationResult, FinalPlanReview) :-
|
|
331
|
-
get_dict(valid, ValidationResult, true),
|
|
332
|
-
output("Multi-strategy plan validated successfully."),
|
|
333
|
-
format(string(Message), "I've created a multi-strategy plan in ~w.\n\n~s\nRun it with /run ~w or /~w.", [FilePath, FinalPlanReview, FilePath, PlanSlug]),
|
|
334
|
-
answer(Message).
|
|
335
|
-
|
|
336
|
-
finish_plan_creation(FilePath, _, ValidationResult, _) :-
|
|
337
|
-
format(string(Message), "I wrote ~w, but the plan failed validation: ~w", [FilePath, ValidationResult]),
|
|
338
|
-
answer(Message).
|
|
339
|
-
|
|
340
|
-
conductor_tool_definitions(ToolBlock) :-
|
|
341
|
-
atomics_to_string([
|
|
342
|
-
'% --- Tool predicates (full tool set) ---',
|
|
343
|
-
'',
|
|
344
|
-
'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.") :-',
|
|
345
|
-
'',
|
|
346
|
-
' exec(run_skill(slug: Slug, args: Args), Result).',
|
|
347
|
-
'',
|
|
348
|
-
'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.") :-',
|
|
349
|
-
'',
|
|
350
|
-
' exec(consult_recipes(query: Query, max_results: 3), Result).',
|
|
351
|
-
'',
|
|
352
|
-
'tool(search_web(Query, Results), "Search the web for current information. Returns search results.") :-',
|
|
353
|
-
'',
|
|
354
|
-
' exec(web_search(query: Query), Results).',
|
|
355
|
-
'',
|
|
356
|
-
'tool(search_news(Query, Results), "Search recent news articles. Returns news results.") :-',
|
|
357
|
-
'',
|
|
358
|
-
' exec(news_search(query: Query), Results).',
|
|
359
|
-
'',
|
|
360
|
-
'tool(fetch_url(Url, Content), "Fetch the content of a web page by URL. Returns the page body as text.") :-',
|
|
361
|
-
'',
|
|
362
|
-
' exec(url_fetch(url: Url), Result),',
|
|
363
|
-
' get_dict(body, Result, Content).',
|
|
364
|
-
'',
|
|
365
|
-
'tool(download_file(Url, FilePath, Size), "Download a file from a URL and save it to disk. Returns the file path and size.") :-',
|
|
366
|
-
'',
|
|
367
|
-
' exec(url_fetch(url: Url, save_to: FilePath), Result),',
|
|
368
|
-
' get_dict(file_path, Result, FilePath),',
|
|
369
|
-
' get_dict(size, Result, Size).',
|
|
370
|
-
'',
|
|
371
|
-
'tool(run_bash(Command, Output), "Run a shell command in the workspace.") :-',
|
|
372
|
-
'',
|
|
373
|
-
' exec(bash(command: Command), Output).',
|
|
374
|
-
'',
|
|
375
|
-
'tool(create_new_skill(Spec, Result), "Create and deploy a new reusable skill from a natural language spec.") :-',
|
|
376
|
-
'',
|
|
377
|
-
' exec(create_skill(spec: Spec), Result).',
|
|
378
|
-
'',
|
|
379
|
-
'tool(ask_user(Prompt, Response), "Ask the user a clarifying question and get their response.") :-',
|
|
380
|
-
'',
|
|
381
|
-
' exec(ask_user(prompt: Prompt), Result),',
|
|
382
|
-
' get_dict(user_response, Result, Response).',
|
|
383
|
-
'',
|
|
384
|
-
'tool(inform_user(Message, Result), "Send a status update or progress report to the user.") :-',
|
|
385
|
-
' output(Message),',
|
|
386
|
-
' Result = "ok".'
|
|
387
|
-
], "\n", ToolBlock).
|
|
388
|
-
|
|
389
|
-
load_dml_reference(DmlReference) :-
|
|
390
|
-
( exists_file('.deepclause/docs/DML_REFERENCE.md')
|
|
391
|
-
-> read_file('.deepclause/docs/DML_REFERENCE.md', DmlReference)
|
|
392
|
-
; DmlReference = "DML reference unavailable. Use standard DeepClause DML conventions."
|
|
393
|
-
).
|
|
394
|
-
|
|
395
|
-
load_dml_compiler_prompt(CompilerPrompt) :-
|
|
396
|
-
( exists_file('.deepclause/system/DML_COMPILER_PROMPT.md')
|
|
397
|
-
-> read_file('.deepclause/system/DML_COMPILER_PROMPT.md', CompilerPrompt)
|
|
398
|
-
; CompilerPrompt = "DML compiler guidance unavailable. Follow standard DeepClause DML conventions and keep plans simple."
|
|
399
|
-
).
|
|
400
|
-
|
|
401
|
-
load_coding_workflow_recipe(CodingWorkflowRecipe) :-
|
|
402
|
-
exec(consult_recipes(query: 'deepclause coding workflow', max_results: 3), Result),
|
|
403
|
-
get_dict(matches, Result, Matches),
|
|
404
|
-
Matches = [FirstMatch|_],
|
|
405
|
-
get_dict(content, FirstMatch, CodingWorkflowRecipe),
|
|
406
|
-
!.
|
|
407
|
-
|
|
408
|
-
load_coding_workflow_recipe("DeepClause Coding Workflow recipe unavailable. Follow standard DeepClause coding workflow guidance.").
|
|
409
|
-
|
|
410
|
-
agent_main(Request) :-
|
|
411
|
-
format(string(Message), "I could not create a valid multi-strategy plan for this request: ~w. Try simplifying the request or being more explicit about the steps and required tools.", [Request]),
|
|
412
|
-
answer(Message).
|