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,337 +0,0 @@
|
|
|
1
|
-
% Security planner — generates a multi-strategy DML plan for finding bugs and vulnerabilities.
|
|
2
|
-
% The planner itself does NOT analyze code. It only generates strategies and task descriptions.
|
|
3
|
-
% Analysis happens when the generated plan is executed.
|
|
4
|
-
|
|
5
|
-
tool(consult_recipes(Query, Result),
|
|
6
|
-
"Search the recipe library for workflow guidance and conventions.") :-
|
|
7
|
-
exec(consult_recipes(query: Query, max_results: 3), Result).
|
|
8
|
-
|
|
9
|
-
tool(search_web(Query, Results),
|
|
10
|
-
"Search the web for context about the target project or technology stack.") :-
|
|
11
|
-
exec(web_search(query: Query), Results).
|
|
12
|
-
|
|
13
|
-
tool(ask_user(Prompt, Response),
|
|
14
|
-
"Ask the user for clarification about scope, severity thresholds, or context.") :-
|
|
15
|
-
exec(ask_user(prompt: Prompt), Result),
|
|
16
|
-
get_dict(user_response, Result, Response).
|
|
17
|
-
|
|
18
|
-
agent_main(Request) :-
|
|
19
|
-
load_dml_reference(DmlReference),
|
|
20
|
-
resolve_model_info(ModelId, Complexity, Reasoning, TaskCount),
|
|
21
|
-
format(string(SystemPrompt), "You are a SECURITY PLAN GENERATOR. You do NOT analyze code yourself. You only create plans for other agents to execute.~n~nTarget: ~w~n~nYour job:~n1. Generate a short slug for the plan file.~n2. Generate ~w fundamentally different strategies for finding bugs and vulnerabilities.~n3. For each strategy, generate a task list with tool assignments and reasoning effort.~n4. The assembler creates a DML file with one agent_main clause per strategy.~n~nRules:~n- Do NOT run shell commands, read files, or examine the codebase. That is the job of the generated plan.~n- Generate strategies based on the target description and your knowledge of common vulnerability patterns.~n- Each strategy must use a different analysis approach (static patterns, data flow, dependency audit, config review, input validation, auth review, etc.).~n- Each strategy gets 3 to 7 analysis tasks plus a final verification task (added automatically).~n- The final task in each strategy asks the model to write findings to a file if vulnerabilities are found, or fail if nothing is found.~n~nDML language reference:~n~n~s", [Request, TaskCount, DmlReference]),
|
|
22
|
-
system(SystemPrompt),
|
|
23
|
-
|
|
24
|
-
task("Create a short file-safe slug for this security analysis target: '{Request}'.~nRequirements:~n- lowercase letters, digits, and underscores only~n- 2 to 6 words when possible~n- no file extension~n- prefix with 'audit_' if not already present~nStore only the slug in PlanSlug.", string(PlanSlug)),
|
|
25
|
-
|
|
26
|
-
generate_strategies(Request, TaskCount, Strategies),
|
|
27
|
-
|
|
28
|
-
generate_all_strategy_tasks(Request, Strategies, StrategyPlans),
|
|
29
|
-
|
|
30
|
-
make_directory_path('plans'),
|
|
31
|
-
format(string(FilePath), "plans/~w.dml", [PlanSlug]),
|
|
32
|
-
|
|
33
|
-
build_review_message(FilePath, StrategyPlans, ReviewMessage),
|
|
34
|
-
output(ReviewMessage),
|
|
35
|
-
|
|
36
|
-
output("Assembling multi-strategy security plan file..."),
|
|
37
|
-
assemble_multi_strategy_dml(StrategyPlans, PlanDml),
|
|
38
|
-
exec(write_file(path: FilePath, content: PlanDml), _),
|
|
39
|
-
exec(validate_dml(dml_file: FilePath), ValidationResult),
|
|
40
|
-
finish_plan_creation(FilePath, PlanSlug, ValidationResult, ReviewMessage).
|
|
41
|
-
|
|
42
|
-
%% resolve_model_info(-ModelId, -Complexity, -Reasoning, -TaskCount)
|
|
43
|
-
resolve_model_info(ModelId, Complexity, Reasoning, TaskCount) :-
|
|
44
|
-
( catch(
|
|
45
|
-
( param(model_info, ModelInfo),
|
|
46
|
-
is_dict(ModelInfo),
|
|
47
|
-
get_dict(modelId, ModelInfo, ModelId),
|
|
48
|
-
( get_dict(complexity, ModelInfo, C) -> Complexity = C ; Complexity = medium ),
|
|
49
|
-
( get_dict(reasoning, ModelInfo, R), R == true -> Reasoning = true ; Reasoning = false )
|
|
50
|
-
),
|
|
51
|
-
_,
|
|
52
|
-
fail
|
|
53
|
-
)
|
|
54
|
-
-> true
|
|
55
|
-
; ModelId = "unknown",
|
|
56
|
-
Complexity = medium,
|
|
57
|
-
Reasoning = false
|
|
58
|
-
),
|
|
59
|
-
task_count_for_complexity(Complexity, TaskCount).
|
|
60
|
-
|
|
61
|
-
task_count_for_complexity("high", "3").
|
|
62
|
-
task_count_for_complexity("medium", "3").
|
|
63
|
-
task_count_for_complexity("low", "3").
|
|
64
|
-
task_count_for_complexity(high, "3").
|
|
65
|
-
task_count_for_complexity(medium, "3").
|
|
66
|
-
task_count_for_complexity(low, "3").
|
|
67
|
-
|
|
68
|
-
%% generate_strategies(+Request, +TaskCount, -Strategies)
|
|
69
|
-
generate_strategies(Request, TaskCount, Strategies) :-
|
|
70
|
-
task("Generate {TaskCount} fundamentally different security analysis strategies for this target:
|
|
71
|
-
|
|
72
|
-
'{Request}'
|
|
73
|
-
|
|
74
|
-
Each strategy must use a different analysis approach:
|
|
75
|
-
- Different tooling (grep vs static analyzer vs dependency scanner vs manual review)
|
|
76
|
-
- Different vulnerability classes (injection vs auth vs config vs crypto vs deps)
|
|
77
|
-
- Different code perspectives (input paths vs output paths vs state management vs error handling)
|
|
78
|
-
|
|
79
|
-
For each strategy provide:
|
|
80
|
-
- A short name identifying the approach
|
|
81
|
-
- A colon
|
|
82
|
-
- A brief description of what it looks for and how
|
|
83
|
-
|
|
84
|
-
One strategy per line. Each strategy should be independently capable of finding real issues.
|
|
85
|
-
|
|
86
|
-
Store the list of strategy strings in Strategies.", list(string(Strategies))).
|
|
87
|
-
|
|
88
|
-
%% generate_all_strategy_tasks(+Request, +Strategies, -StrategyPlans)
|
|
89
|
-
generate_all_strategy_tasks(_Request, [], []).
|
|
90
|
-
generate_all_strategy_tasks(Request, [Strategy|RestStrategies], [plan{strategy: Strategy, steps: Steps}|RestPlans]) :-
|
|
91
|
-
generate_strategy_tasks(Request, Strategy, Steps),
|
|
92
|
-
generate_all_strategy_tasks(Request, RestStrategies, RestPlans).
|
|
93
|
-
|
|
94
|
-
%% generate_strategy_tasks(+Request, +Strategy, -Steps)
|
|
95
|
-
generate_strategy_tasks(Request, Strategy, Steps) :-
|
|
96
|
-
( param(model_info, ModelInfo)
|
|
97
|
-
-> ( get_dict(reasoning, ModelInfo, R), R == true
|
|
98
|
-
-> ReasoningNote = "The execution model supports reasoning. Assign reasoning effort per task: none, low, medium, or high."
|
|
99
|
-
; ReasoningNote = "The execution model does not support reasoning. Set reasoning to 'none' for all tasks."
|
|
100
|
-
)
|
|
101
|
-
; ReasoningNote = "Set reasoning to 'none' for all tasks."
|
|
102
|
-
),
|
|
103
|
-
task("List 3 to 7 focused execution tasks for this security analysis strategy.
|
|
104
|
-
|
|
105
|
-
Target: {Request}
|
|
106
|
-
Strategy: {Strategy}
|
|
107
|
-
|
|
108
|
-
Each task should be one concrete analysis step. Be specific about what to look for and which files to examine.
|
|
109
|
-
|
|
110
|
-
Available tools (use ONLY these exact names):
|
|
111
|
-
- consult_recipes: Search recipe guidance and conventions
|
|
112
|
-
- search_web: Search the web for advisories, docs, and references
|
|
113
|
-
- search_news: Search recent news for relevant incidents or advisories
|
|
114
|
-
- fetch_url: Fetch a specific advisory or documentation page
|
|
115
|
-
- run_bash: Run grep, find, test, and scanner commands in the workspace
|
|
116
|
-
- ask_user: Ask the user to narrow scope or clarify assumptions
|
|
117
|
-
- inform_user: Send a status update
|
|
118
|
-
|
|
119
|
-
{ReasoningNote}
|
|
120
|
-
|
|
121
|
-
Also specify a recipe query for each task if relevant (NONE otherwise).
|
|
122
|
-
|
|
123
|
-
Return four ordered lists aligned 1:1:
|
|
124
|
-
- TaskDescriptions: plain task descriptions.
|
|
125
|
-
- ToolSpecs: each item must be either ALL or a comma-separated list of exact tool names from the available tools list above.
|
|
126
|
-
- ReasoningSpecs: each item must be exactly one of none, low, medium, high.
|
|
127
|
-
- RecipeSpecs: each item must be either NONE or a recipe query string.
|
|
128
|
-
|
|
129
|
-
Store the ordered task descriptions in TaskDescriptions.
|
|
130
|
-
Store the ordered tool specs in ToolSpecs.
|
|
131
|
-
Store the ordered reasoning specs in ReasoningSpecs.
|
|
132
|
-
Store the ordered recipe specs in RecipeSpecs.", list(string(TaskDescriptions)), list(string(ToolSpecs)), list(string(ReasoningSpecs)), list(string(RecipeSpecs))),
|
|
133
|
-
( build_steps_from_specs(TaskDescriptions, ToolSpecs, ReasoningSpecs, RecipeSpecs, Steps)
|
|
134
|
-
-> true
|
|
135
|
-
; fallback_plan_steps_from_strategy(Strategy, Steps)
|
|
136
|
-
).
|
|
137
|
-
|
|
138
|
-
valid_plan_tool(consult_recipes).
|
|
139
|
-
valid_plan_tool(search_web).
|
|
140
|
-
valid_plan_tool(search_news).
|
|
141
|
-
valid_plan_tool(fetch_url).
|
|
142
|
-
valid_plan_tool(run_bash).
|
|
143
|
-
valid_plan_tool(ask_user).
|
|
144
|
-
valid_plan_tool(inform_user).
|
|
145
|
-
|
|
146
|
-
default_plan_tools([consult_recipes, search_web, search_news, fetch_url, run_bash, ask_user, inform_user]).
|
|
147
|
-
|
|
148
|
-
build_steps_from_specs([], [], [], [], []).
|
|
149
|
-
build_steps_from_specs([Desc|RestDesc], [ToolSpec|RestTools], [ReasoningSpec|RestReasoning], [RecipeSpec|RestRecipes], [plan_step{description: Desc, tools: Tools, reasoning: Reasoning, recipe: Recipe}|RestSteps]) :-
|
|
150
|
-
normalize_tools_spec(ToolSpec, Tools),
|
|
151
|
-
normalize_reasoning_spec(ReasoningSpec, Reasoning),
|
|
152
|
-
normalize_recipe_spec(RecipeSpec, Recipe),
|
|
153
|
-
build_steps_from_specs(RestDesc, RestTools, RestReasoning, RestRecipes, RestSteps).
|
|
154
|
-
|
|
155
|
-
normalize_tools_spec(Raw, Tools) :-
|
|
156
|
-
format(string(Text), "~w", [Raw]),
|
|
157
|
-
string_lower(Text, Lower),
|
|
158
|
-
( Lower = "all"
|
|
159
|
-
-> default_plan_tools(Tools)
|
|
160
|
-
; split_string(Text, ",", " []\t\n", Parts0),
|
|
161
|
-
include(non_empty_string, Parts0, Parts),
|
|
162
|
-
findall(ToolAtom,
|
|
163
|
-
( member(Part, Parts),
|
|
164
|
-
tool_name_string_to_atom(Part, ToolAtom),
|
|
165
|
-
valid_plan_tool(ToolAtom)
|
|
166
|
-
),
|
|
167
|
-
ValidTools),
|
|
168
|
-
( ValidTools = []
|
|
169
|
-
-> default_plan_tools(Tools)
|
|
170
|
-
; Tools = ValidTools
|
|
171
|
-
)
|
|
172
|
-
).
|
|
173
|
-
|
|
174
|
-
normalize_reasoning_spec(Raw, Reasoning) :-
|
|
175
|
-
format(string(Text), "~w", [Raw]),
|
|
176
|
-
string_lower(Text, Lower),
|
|
177
|
-
normalize_reasoning_label(Lower, Reasoning).
|
|
178
|
-
|
|
179
|
-
normalize_reasoning_label("high", "high").
|
|
180
|
-
normalize_reasoning_label("medium", "medium").
|
|
181
|
-
normalize_reasoning_label("low", "low").
|
|
182
|
-
normalize_reasoning_label("none", "none").
|
|
183
|
-
normalize_reasoning_label(_, "none").
|
|
184
|
-
|
|
185
|
-
normalize_recipe_spec(Raw, Recipe) :-
|
|
186
|
-
format(string(Text0), "~w", [Raw]),
|
|
187
|
-
normalize_space(string(Text), Text0),
|
|
188
|
-
string_lower(Text, Lower),
|
|
189
|
-
( Lower = ""
|
|
190
|
-
-> Recipe = "none"
|
|
191
|
-
; Lower = "none"
|
|
192
|
-
-> Recipe = "none"
|
|
193
|
-
; Recipe = Text
|
|
194
|
-
).
|
|
195
|
-
|
|
196
|
-
tool_name_string_to_atom(Text, Atom) :-
|
|
197
|
-
string_lower(Text, Lower),
|
|
198
|
-
atom_string(Atom, Lower).
|
|
199
|
-
|
|
200
|
-
non_empty_string(Text) :-
|
|
201
|
-
Text \= "".
|
|
202
|
-
|
|
203
|
-
fallback_plan_steps_from_strategy(Strategy, [plan_step{description: Strategy, tools: Tools, reasoning: "none", recipe: "none"}]) :-
|
|
204
|
-
default_plan_tools(Tools).
|
|
205
|
-
|
|
206
|
-
%% assemble_multi_strategy_dml(+StrategyPlans, -PlanDml)
|
|
207
|
-
assemble_multi_strategy_dml(StrategyPlans, PlanDml) :-
|
|
208
|
-
conductor_tool_definitions(ToolBlock),
|
|
209
|
-
build_strategy_clauses(StrategyPlans, Clauses),
|
|
210
|
-
format(string(PlanDml), "% Generated DeepClause security analysis plan.~n% Prolog tries strategies in order; answer/1 commits on success.~n~n~s~n~n~s~nagent_main :-~n answer(\"No vulnerabilities found by any strategy.\").~n", [ToolBlock, Clauses]).
|
|
211
|
-
|
|
212
|
-
%% build_strategy_clauses(+StrategyPlans, -Clauses)
|
|
213
|
-
build_strategy_clauses([], "").
|
|
214
|
-
build_strategy_clauses([Plan|Rest], Clauses) :-
|
|
215
|
-
Strategy = Plan.strategy,
|
|
216
|
-
Steps = Plan.steps,
|
|
217
|
-
build_system_prompt_for_strategy(Strategy, SystemPrompt),
|
|
218
|
-
build_task_lines(Steps, TaskLines, LastSumVar),
|
|
219
|
-
format(string(StratOutput), "Starting strategy: ~w", [Strategy]),
|
|
220
|
-
format(string(StratAnswer), "Vulnerabilities found and reported via strategy: ~w. See .deepclause.tmp/findings.md for details.", [Strategy]),
|
|
221
|
-
( LastSumVar = ""
|
|
222
|
-
-> format(string(VerifyTask), " task(\"If vulnerabilities were found, write a findings report to .deepclause.tmp/findings.md and succeed. If no vulnerabilities were found, fail this task.\"),~n", [])
|
|
223
|
-
; format(string(VerifyTask), " task(\"Based on the analysis summary: {~w}. If vulnerabilities were found, write a findings report to .deepclause.tmp/findings.md and succeed. If no vulnerabilities were found, fail this task.\"),~n", [LastSumVar])
|
|
224
|
-
),
|
|
225
|
-
format(string(Clause), "agent_main :-~n system(~q),~n output(~q),~n~s~s answer(~q).~n~n", [SystemPrompt, StratOutput, TaskLines, VerifyTask, StratAnswer]),
|
|
226
|
-
build_strategy_clauses(Rest, RestClauses),
|
|
227
|
-
string_concat(Clause, RestClauses, Clauses).
|
|
228
|
-
|
|
229
|
-
%% build_system_prompt_for_strategy(+Strategy, -SystemPrompt)
|
|
230
|
-
build_system_prompt_for_strategy(Strategy, SystemPrompt) :-
|
|
231
|
-
format(string(SystemPrompt), "You are a security analyst executing a generated DeepClause plan using this strategy:~n~nStrategy: ~w~n~nWorkflow:~n- Start by understanding the codebase structure and identifying the relevant files~n- Read source files and configuration to understand the attack surface~n- Apply the strategy's analysis approach systematically~n- For each finding, record: severity (critical/high/medium/low/info), file path, line number (if applicable), description, and recommendation~n- Write findings to .deepclause.tmp/scratchpad.md (append with >>) so other strategies can see them~n- Read the scratchpad at the start: run_bash('cat .deepclause.tmp/scratchpad.md 2>/dev/null || echo empty')~n- A final verification task runs automatically after your analysis tasks: it asks you to write .deepclause.tmp/findings.md if vulnerabilities were found~n- If no vulnerabilities are found, the findings file is NOT written and this strategy fails — a different strategy is tried automatically~n- Be thorough but avoid false positives — verify each finding before reporting", [Strategy]).
|
|
232
|
-
|
|
233
|
-
%% build_task_lines(+PlanSteps, -TaskLines, -LastSumVar)
|
|
234
|
-
build_task_lines(Steps, TaskLines, LastSumVar) :-
|
|
235
|
-
length(Steps, Count),
|
|
236
|
-
( Count > 0
|
|
237
|
-
-> format(string(LastSumVar), "Sum~w", [Count])
|
|
238
|
-
; LastSumVar = ""
|
|
239
|
-
),
|
|
240
|
-
build_task_lines(Steps, 1, "", TaskLines).
|
|
241
|
-
|
|
242
|
-
build_task_lines([], _, _, "").
|
|
243
|
-
build_task_lines([Step|Rest], Num, PrevSum, TaskLines) :-
|
|
244
|
-
build_single_task_line(Step, Num, PrevSum, Line),
|
|
245
|
-
NextNum is Num + 1,
|
|
246
|
-
format(string(VarName), "Sum~w", [Num]),
|
|
247
|
-
build_task_lines(Rest, NextNum, VarName, RestLines),
|
|
248
|
-
string_concat(Line, RestLines, TaskLines).
|
|
249
|
-
|
|
250
|
-
build_single_task_line(Step, Num, PrevSum, Line) :-
|
|
251
|
-
Desc = Step.description,
|
|
252
|
-
format(string(VarName), "Sum~w", [Num]),
|
|
253
|
-
format(string(DescWithCtx), "~w. Store your findings summary in ~w.", [Desc, VarName]),
|
|
254
|
-
Tools = Step.tools,
|
|
255
|
-
Reasoning = Step.reasoning,
|
|
256
|
-
Recipe = Step.recipe,
|
|
257
|
-
format(string(BaseTask), "task(~q, string(~w))", [DescWithCtx, VarName]),
|
|
258
|
-
format(string(WithTools), "with_tools(~w, ~w)", [Tools, BaseTask]),
|
|
259
|
-
( Reasoning \= "none"
|
|
260
|
-
-> format(string(WithReasoning), "with_reasoning(~n ~w~n , ~w)", [WithTools, Reasoning])
|
|
261
|
-
; WithReasoning = WithTools
|
|
262
|
-
),
|
|
263
|
-
( Recipe \= "none"
|
|
264
|
-
-> format(string(Line), " with_recipe(~n ~w~n , '~w'),~n", [WithReasoning, Recipe])
|
|
265
|
-
; format(string(Line), " ~w,~n", [WithReasoning])
|
|
266
|
-
).
|
|
267
|
-
|
|
268
|
-
%% build_review_message(+FilePath, +StrategyPlans, -ReviewMessage)
|
|
269
|
-
build_review_message(FilePath, StrategyPlans, ReviewMessage) :-
|
|
270
|
-
length(StrategyPlans, Count),
|
|
271
|
-
build_strategy_review_lines(StrategyPlans, 1, StrategyLines),
|
|
272
|
-
format(string(ReviewMessage), "Proposed security analysis plan~n- Output file: ~w~n- Strategies: ~w~n~n~s", [FilePath, Count, StrategyLines]).
|
|
273
|
-
|
|
274
|
-
build_strategy_review_lines([], _, "").
|
|
275
|
-
build_strategy_review_lines([Plan|Rest], Num, Lines) :-
|
|
276
|
-
Strategy = Plan.strategy,
|
|
277
|
-
Steps = Plan.steps,
|
|
278
|
-
length(Steps, StepCount),
|
|
279
|
-
format(string(Current), "~w. ~w (~w tasks)~n", [Num, Strategy, StepCount]),
|
|
280
|
-
NextNum is Num + 1,
|
|
281
|
-
build_strategy_review_lines(Rest, NextNum, RestLines),
|
|
282
|
-
string_concat(Current, RestLines, Lines).
|
|
283
|
-
|
|
284
|
-
finish_plan_creation(FilePath, PlanSlug, ValidationResult, FinalPlanReview) :-
|
|
285
|
-
get_dict(valid, ValidationResult, true),
|
|
286
|
-
output("Security plan validated successfully."),
|
|
287
|
-
format(string(Message), "I've created a security analysis plan in ~w.\n\n~s\nRun it with /run ~w or /~w.", [FilePath, FinalPlanReview, FilePath, PlanSlug]),
|
|
288
|
-
answer(Message).
|
|
289
|
-
|
|
290
|
-
finish_plan_creation(FilePath, _, ValidationResult, _) :-
|
|
291
|
-
format(string(Message), "I wrote ~w, but the plan failed validation: ~w", [FilePath, ValidationResult]),
|
|
292
|
-
answer(Message).
|
|
293
|
-
|
|
294
|
-
conductor_tool_definitions(ToolBlock) :-
|
|
295
|
-
atomics_to_string([
|
|
296
|
-
'% --- Tool predicates ---',
|
|
297
|
-
'',
|
|
298
|
-
'tool(consult_recipes(Query, Result), "Search the recipe library for workflow guidance and conventions.") :-',
|
|
299
|
-
'',
|
|
300
|
-
' exec(consult_recipes(query: Query, max_results: 3), Result).',
|
|
301
|
-
'',
|
|
302
|
-
'tool(search_web(Query, Results), "Search the web for CVEs, security advisories, and documentation.") :-',
|
|
303
|
-
'',
|
|
304
|
-
' exec(web_search(query: Query), Results).',
|
|
305
|
-
'',
|
|
306
|
-
'tool(search_news(Query, Results), "Search recent news for security advisories.") :-',
|
|
307
|
-
'',
|
|
308
|
-
' exec(news_search(query: Query), Results).',
|
|
309
|
-
'',
|
|
310
|
-
'tool(fetch_url(Url, Content), "Fetch a web page for security documentation or advisory details.") :-',
|
|
311
|
-
'',
|
|
312
|
-
' exec(url_fetch(url: Url), Result),',
|
|
313
|
-
' get_dict(body, Result, Content).',
|
|
314
|
-
'',
|
|
315
|
-
'tool(run_bash(Command, Output), "Run a shell command. Use for grep, find, cat, static analyzers, etc.") :-',
|
|
316
|
-
'',
|
|
317
|
-
' exec(bash(command: Command), Output).',
|
|
318
|
-
'',
|
|
319
|
-
'tool(ask_user(Prompt, Response), "Ask the user for clarification about scope or severity thresholds.") :-',
|
|
320
|
-
'',
|
|
321
|
-
' exec(ask_user(prompt: Prompt), Result),',
|
|
322
|
-
' get_dict(user_response, Result, Response).',
|
|
323
|
-
'',
|
|
324
|
-
'tool(inform_user(Message, Result), "Send a status update.") :-',
|
|
325
|
-
' output(Message),',
|
|
326
|
-
' Result = "ok".'
|
|
327
|
-
], "\n", ToolBlock).
|
|
328
|
-
|
|
329
|
-
load_dml_reference(DmlReference) :-
|
|
330
|
-
( exists_file('.deepclause/docs/DML_REFERENCE.md')
|
|
331
|
-
-> read_file('.deepclause/docs/DML_REFERENCE.md', DmlReference)
|
|
332
|
-
; DmlReference = "DML reference unavailable. Use standard DeepClause DML conventions."
|
|
333
|
-
).
|
|
334
|
-
|
|
335
|
-
agent_main(Request) :-
|
|
336
|
-
format(string(Message), "I could not create a valid security analysis plan for this target: ~w. Try specifying the target more precisely (e.g., a directory path, file pattern, or specific concern).", [Request]),
|
|
337
|
-
answer(Message).
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
% ============================================================================
|
|
2
|
-
% _skill-creator v4 - Creates, tests, and deploys DML skills.
|
|
3
|
-
%
|
|
4
|
-
% Four-phase pipeline matching the DML Compiler Prompt role definition:
|
|
5
|
-
% Phase 1 - Understand & Research
|
|
6
|
-
% Clarify requirements, research dependencies, understand APIs.
|
|
7
|
-
% Phase 2 - Environment Setup
|
|
8
|
-
% Install packages, create/test helper scripts via bash.
|
|
9
|
-
% Phase 3 - DML Implementation
|
|
10
|
-
% Write DML, validate syntax, run tests - iterate until passing.
|
|
11
|
-
% Phase 4 - Deploy
|
|
12
|
-
% Ask user for permission, then deploy.
|
|
13
|
-
%
|
|
14
|
-
% System tools: validate_dml, test_dml, deploy_skill, write_file, bash
|
|
15
|
-
% Proxied tools: web_search, news_search, url_fetch
|
|
16
|
-
% Auto-augmented: ask_user
|
|
17
|
-
%
|
|
18
|
-
% agent_main(SpecMarkdown) - create new skill
|
|
19
|
-
% agent_main(SpecMarkdown, EditSlug) - edit existing skill
|
|
20
|
-
% ============================================================================
|
|
21
|
-
|
|
22
|
-
% -- Tools available to the LLM during task() calls --------------------------
|
|
23
|
-
|
|
24
|
-
tool(search(Query, Results),
|
|
25
|
-
"Search the web for information. Returns titles, URLs, and snippets.") :-
|
|
26
|
-
exec(web_search(query: Query), Results).
|
|
27
|
-
|
|
28
|
-
tool(search_news(Query, Results),
|
|
29
|
-
"Search for recent news articles.") :-
|
|
30
|
-
exec(news_search(query: Query), Results).
|
|
31
|
-
|
|
32
|
-
tool(fetch(Url, Content),
|
|
33
|
-
"Fetch a URL and return its body. Use for documentation pages, README files, API references.") :-
|
|
34
|
-
exec(url_fetch(url: Url), Result),
|
|
35
|
-
get_dict(body, Result, Content).
|
|
36
|
-
|
|
37
|
-
tool(list_skills(Skills),
|
|
38
|
-
"List reusable local skills in the current workspace catalog. Use this before re-implementing a capability that might already exist.") :-
|
|
39
|
-
exec(list_skills, Skills).
|
|
40
|
-
|
|
41
|
-
tool(shell(Command, Result),
|
|
42
|
-
"Run a shell command on the VM. Returns dict with: success (boolean), stdout (string), stderr (string), exitCode (integer), summary (string). Use for package installation, environment checks, and helper script creation/testing. Always check the 'success' field.") :-
|
|
43
|
-
exec(bash(command: Command), Result).
|
|
44
|
-
|
|
45
|
-
tool(write(Path, Content, Result),
|
|
46
|
-
"Write (or overwrite) a file in the workspace. Content is passed as a JSON string so there are NO shell escaping issues - ALWAYS use this instead of bash heredocs for writing DML and other code files. Returns dict with: success (boolean), path (string), bytes (number).") :-
|
|
47
|
-
exec(write_file(path: Path, content: Content), Result).
|
|
48
|
-
|
|
49
|
-
tool(validate(DmlFile, Result),
|
|
50
|
-
"Validate DML code from a .dml file using the Prolog parser. You MUST write the DML to a file first with write(), then pass the file path. Returns dict with: valid (boolean), errors (list), warnings (list).") :-
|
|
51
|
-
exec(validate_dml(dml_file: DmlFile), Result).
|
|
52
|
-
|
|
53
|
-
tool(test_run(DmlFile, Input, Result),
|
|
54
|
-
"Run a DML program from a .dml file with test input(s) to verify it works. You MUST write the DML to a file first with write(), then pass the file path. Input can be a single string (for agent_main/1) or a JSON array string like '[\"arg1\", \"arg2\"]' for multi-arg agent_main. Returns dict with: success (boolean), status (string: ok/error/completed_no_answer/failed_silently), answer (string), outputs (list), errors (list), trace (list).") :-
|
|
55
|
-
exec(test_dml(dml_file: DmlFile, test_args: Input), Result).
|
|
56
|
-
|
|
57
|
-
tool(deploy(DmlFile, Spec, MetaJSON, Result),
|
|
58
|
-
"Publish a new skill to the local runtime catalog. IMPORTANT ARG ORDER: deploy(<dml file path>, <original spec markdown>, <metadata json>). The SECOND argument is the original specification text. The THIRD argument is the metadata JSON string with keys: slug, name, description, trigger_phrases (array of 3-5 phrases). Never pass a version number or boolean flag here. Returns dict with: ok (boolean), slug (string), version (number), or error (string).") :-
|
|
59
|
-
exec(deploy_skill(dml_file: DmlFile, spec_markdown: Spec, metadata_json: MetaJSON), Result).
|
|
60
|
-
|
|
61
|
-
tool(deploy_update(DmlFile, Spec, MetaJSON, Slug, Result),
|
|
62
|
-
"Update an existing skill. IMPORTANT ARG ORDER: deploy_update(<dml file path>, <updated spec markdown>, <metadata json>, <existing slug>). The THIRD argument is metadata JSON; the FOURTH argument is the slug override. Never pass a version number or boolean flag. Returns dict with: ok (boolean), slug (string), version (number), or error (string).") :-
|
|
63
|
-
exec(deploy_skill(dml_file: DmlFile, spec_markdown: Spec, metadata_json: MetaJSON, slug_override: Slug), Result).
|
|
64
|
-
|
|
65
|
-
tool(ask_user(Prompt, Response), "Ask the user a clarifying question or for confirmation and get their response.") :-
|
|
66
|
-
exec(ask_user(prompt: Prompt), Result),
|
|
67
|
-
get_dict(user_response, Result, Response).
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
% -- Create new skill --------------------------------------------------------
|
|
71
|
-
|
|
72
|
-
agent_main(SpecMarkdown) :-
|
|
73
|
-
param(system_prompt, "System prompt with DML reference", SysPrompt),
|
|
74
|
-
system(SysPrompt),
|
|
75
|
-
output("📋 Starting skill creation..."),
|
|
76
|
-
|
|
77
|
-
% -- Phase 1: Understand & Research --------------------------------------
|
|
78
|
-
output("Phase 1/4: Understanding requirements and researching dependencies..."),
|
|
79
|
-
format(string(ResearchTask),
|
|
80
|
-
"You are starting to build a DML skill from the specification below.\n\nYour job in this phase:\n1. Read the specification carefully. If anything is ambiguous or missing, use ask_user to clarify before proceeding.\n2. Call list_skills if an existing local skill might already cover part of the requested functionality.\n3. Identify all external dependencies (Python packages, Node modules, system tools, APIs, CLI tools).\n4. For each dependency, use search or fetch to look up installation instructions, API docs, or usage examples if you are not already familiar with them.\n5. Summarise: what the skill does, whether any existing skills should be reused, its inputs/outputs, all dependencies found, and any tricky parts.\n\nSpecification:\n---\n~w\n---\n\nStore your findings in ResearchSummary.",
|
|
81
|
-
[SpecMarkdown]),
|
|
82
|
-
task(ResearchTask, string(ResearchSummary)),
|
|
83
|
-
output(ResearchSummary),
|
|
84
|
-
|
|
85
|
-
% -- Phase 2: Environment Setup -------------------------------------------
|
|
86
|
-
output("Phase 2/4: Setting up the environment..."),
|
|
87
|
-
format(string(EnvTask),
|
|
88
|
-
"Set up the execution environment for the skill you are about to build.\n\nBased on your research:\n~w\n\nYour job in this phase:\n1. Use shell() to check what is already installed (python --version, node --version, which <tool>, pip show <pkg>, etc.).\n2. Install ALL missing packages and tools: pip install, apt-get install (always use sudo and -y), npm install -g.\n3. If the skill needs helper scripts (Python, Shell, etc.), create and smoke-test them now with shell().\n4. When you encounter errors during setup, diagnose the root cause (version mismatch, missing system lib, permissions, ...) and resolve it.\n5. Prefer the simplest approach with the fewest new dependencies when the spec does not specify.\n6. Do NOT install anything inside the DML skill itself - the skill must assume everything is pre-installed.\n\nStore a short environment summary (what was installed, what exists) in EnvSummary.",
|
|
89
|
-
[ResearchSummary]),
|
|
90
|
-
|
|
91
|
-
task(EnvTask, string(EnvSummary)),
|
|
92
|
-
output(EnvSummary),
|
|
93
|
-
|
|
94
|
-
% -- Phase 3: Implement, Validate, Test ----------------------------------
|
|
95
|
-
output("Phase 3/4: Writing DML, validating, and testing..."),
|
|
96
|
-
format(string(ImplTask),
|
|
97
|
-
"Write, validate, and test the DML skill.\n\nBackground:\n- Research: ~w\n- Environment: ~w\n- Original specification: ~w\n\nYour job in this phase:\n1. Write a complete DML implementation plan (tool definitions, agent_main structure, fallback clause).\n2. If you reuse an existing local skill, prefer a narrow wrapper tool predicate that internally calls exec(run_skill(...)) for that specific child skill. Do NOT expose a generic tool(run_skill(...)) predicate unless the user explicitly asked for an orchestration skill.\n3. Write the full DML code to a .dml file using write(). NEVER use bash heredocs for DML - they mangle backslashes and special Prolog characters. NEVER pass DML as an inline string to validate or test_run.\n4. Call validate('my-skill.dml') - if there are syntax errors, fix the code using write() and re-validate until valid.\n5. Call test_run('my-skill.dml', ...) with a realistic test input - if it fails, analyse the error/trace, fix the code with write(), and re-test until passing.\n6. Keep iterating on validate -> test until the skill works correctly.\n\nStore the final .dml file path in FinalDML.",
|
|
98
|
-
[ResearchSummary, EnvSummary, SpecMarkdown]),
|
|
99
|
-
task(ImplTask, string(FinalDML)),
|
|
100
|
-
output("✅ DML implementation ready."),
|
|
101
|
-
|
|
102
|
-
% -- Phase 4: Deploy ------------------------------------------------------
|
|
103
|
-
( param(auto_deploy, "Automatic publish mode", true)
|
|
104
|
-
-> output("Phase 4/4: Publishing skill..."),
|
|
105
|
-
param(deployment_metadata_json, "Exact metadata JSON for automatic publishing", DeploymentMetaJSON),
|
|
106
|
-
format(string(DeployTask),
|
|
107
|
-
"You are ready to publish the skill automatically. Here is the final DML file path:\n\n~w\n\nOriginal specification:\n~w\n\nUse EXACTLY this metadata JSON string and do not modify it:\n\n~w\n\nYour job:\n1. Do NOT call ask_user. Automatic publish mode already serves as deployment approval.\n2. Call deploy() exactly once with the DML file path, the original specification, and the exact metadata JSON string shown above.\n3. Do not add, remove, or rename metadata keys.\n4. After a successful publish, end your response with a structured summary in EXACTLY this format:\n\nDEPLOY_RESULT:\n- name: <skill name>\n- slug: <skill slug>\n- trigger_phrases: <comma-separated list>\n- test_status: passed\n- deploy_status: success",
|
|
108
|
-
[FinalDML, SpecMarkdown, DeploymentMetaJSON]),
|
|
109
|
-
system("Automatic publish mode is enabled. Do not ask the user for permission. Use deployment_metadata_json exactly as provided."),
|
|
110
|
-
system("When you publish, use EXACTLY this argument order: deploy(FinalDMLPath, OriginalSpecMarkdown, MetadataJSONString). MetadataJSONString must be deployment_metadata_json without edits."),
|
|
111
|
-
task(DeployTask, string(DeployResult))
|
|
112
|
-
; output("Phase 4/4: Requesting deployment permission..."),
|
|
113
|
-
format(string(DeployTask),
|
|
114
|
-
"You are ready to deploy the skill. Here is the final DML file path:\n\n~w\n\nOriginal specification:\n~w\n\nYour job:\n1. Use ask_user to present a short summary of the skill (name, slug, what it does, trigger phrases you intend to use) and ask the user for permission to deploy.\n2. If the user approves (yes / ok / go ahead / etc.), call deploy() with the DML file path, the original specification, and a metadata JSON string containing: slug, name, description, trigger_phrases (3-5 phrases).\n3. If the user declines, answer with a message that the skill is ready but was not deployed, and that they can ask to deploy it later.\n4. After a successful deploy, end your response with a structured summary in EXACTLY this format:\n\nDEPLOY_RESULT:\n- name: <skill name>\n- slug: <skill slug>\n- trigger_phrases: <comma-separated list>\n- test_status: passed\n- deploy_status: success",
|
|
115
|
-
[FinalDML, SpecMarkdown]),
|
|
116
|
-
system("When you deploy, use EXACTLY this argument order: deploy(FinalDMLPath, OriginalSpecMarkdown, MetadataJSONString). Do not pass a version number, edit flag, or boolean in place of MetadataJSONString."),
|
|
117
|
-
task(DeployTask, string(DeployResult))
|
|
118
|
-
),
|
|
119
|
-
|
|
120
|
-
format(string(Summary), "✅ Skill creation complete!\n\n~w\n\nYou can trigger this skill using one of the trigger phrases shown above.", [DeployResult]),
|
|
121
|
-
answer(Summary).
|
|
122
|
-
|
|
123
|
-
% -- Fallback for create -----------------------------------------------------
|
|
124
|
-
|
|
125
|
-
agent_main(SpecMarkdown) :-
|
|
126
|
-
format(string(Msg), "❌ Skill creation failed.\n\nThe skill could not be compiled, tested, or deployed from the specification provided. This can happen when:\n- The specification is ambiguous or incomplete\n- Required APIs or tools are not available\n- The DML code could not pass validation or testing after multiple attempts\n\nPlease try:\n1. Simplifying the specification\n2. Being more explicit about inputs, outputs, and logic\n3. Breaking into smaller, focused skills\n\nOriginal spec (first 200 chars): ~w", [SpecMarkdown]),
|
|
127
|
-
answer(Msg).
|
|
128
|
-
|
|
129
|
-
% -- Edit existing skill -----------------------------------------------------
|
|
130
|
-
|
|
131
|
-
agent_main(SpecMarkdown, EditSlug) :-
|
|
132
|
-
param(system_prompt, "System prompt with DML reference", SysPrompt),
|
|
133
|
-
system(SysPrompt),
|
|
134
|
-
format(string(Ctx), "You are editing the existing skill '~w'.", [EditSlug]),
|
|
135
|
-
system(Ctx),
|
|
136
|
-
output("📋 Starting skill update..."),
|
|
137
|
-
|
|
138
|
-
% -- Phase 1: Understand changes ------------------------------------------
|
|
139
|
-
output("Phase 1/4: Understanding required changes and dependencies..."),
|
|
140
|
-
format(string(ResearchTask),
|
|
141
|
-
"You are updating the existing DML skill '~w' from the specification below.\n\nYour job in this phase:\n1. Read the updated specification. If anything is ambiguous, use ask_user to clarify.\n2. Identify what is changing and any new dependencies introduced by the changes.\n3. Research new dependencies if needed (search, fetch).\n4. Summarise: what is changing, new dependencies if any, and any tricky parts.\n\nUpdated specification:\n---\n~w\n---\n\nStore your findings in ResearchSummary.",
|
|
142
|
-
[EditSlug, SpecMarkdown]),
|
|
143
|
-
task(ResearchTask, string(ResearchSummary)),
|
|
144
|
-
output(ResearchSummary),
|
|
145
|
-
|
|
146
|
-
% -- Phase 2: Environment Setup -------------------------------------------
|
|
147
|
-
output("Phase 2/4: Updating the environment if needed..."),
|
|
148
|
-
format(string(EnvTask),
|
|
149
|
-
"Review and update the execution environment for the skill changes.\n\nBased on your analysis:\n~w\n\nYour job:\n1. Check whether any new packages or tools need to be installed for the changes.\n2. Install anything missing via shell().\n3. Create or update any helper scripts if needed.\n4. If no environment changes are needed, confirm that with a brief note.\n\nStore an environment summary in EnvSummary.",
|
|
150
|
-
[ResearchSummary]),
|
|
151
|
-
task(EnvTask, string(EnvSummary)),
|
|
152
|
-
output(EnvSummary),
|
|
153
|
-
|
|
154
|
-
% -- Phase 3: Implement, Validate, Test ----------------------------------
|
|
155
|
-
output("Phase 3/4: Writing updated DML, validating, and testing..."),
|
|
156
|
-
format(string(ImplTask),
|
|
157
|
-
"Write, validate, and test the updated DML skill.\n\nBackground:\n- Changes summary: ~w\n- Environment: ~w\n- Updated specification: ~w\n\nYour job:\n1. Write the complete updated DML code to a .dml file using write(). NEVER use bash heredocs for DML - they mangle backslashes and special Prolog characters.\n2. Call validate('my-skill.dml') - fix any syntax errors by rewriting the file with write().\n3. Call test_run('my-skill.dml', ...) - fix any runtime failures by rewriting with write().\n4. Iterate until both validation and testing pass.\n\nStore the final .dml file path in FinalDML.",
|
|
158
|
-
[ResearchSummary, EnvSummary, SpecMarkdown]),
|
|
159
|
-
task(ImplTask, string(FinalDML)),
|
|
160
|
-
output("✅ Updated DML implementation ready."),
|
|
161
|
-
|
|
162
|
-
% -- Phase 4: Deploy -------------------------------------------------------
|
|
163
|
-
( param(auto_deploy, "Automatic publish mode", true)
|
|
164
|
-
-> output("Phase 4/4: Publishing update..."),
|
|
165
|
-
param(deployment_metadata_json, "Exact metadata JSON for automatic publishing", DeploymentMetaJSON),
|
|
166
|
-
format(string(DeployTask),
|
|
167
|
-
"You are ready to publish the updated skill '~w' automatically. Here is the final DML file path:\n\n~w\n\nUpdated specification:\n~w\n\nUse EXACTLY this metadata JSON string and do not modify it:\n\n~w\n\nYour job:\n1. Do NOT call ask_user. Automatic publish mode already serves as deployment approval.\n2. Call deploy_update() exactly once with the DML file path, updated specification, the exact metadata JSON shown above, and slug override '~w'.\n3. Do not add, remove, or rename metadata keys.\n4. After a successful publish, end your response with a structured summary in EXACTLY this format:\n\nDEPLOY_RESULT:\n- name: <skill name>\n- slug: ~w\n- changes: <brief summary of what changed>\n- test_status: passed\n- deploy_status: success",
|
|
168
|
-
[EditSlug, FinalDML, SpecMarkdown, DeploymentMetaJSON, EditSlug, EditSlug]),
|
|
169
|
-
system("Automatic publish mode is enabled. Do not ask the user for permission. Use deployment_metadata_json exactly as provided."),
|
|
170
|
-
system("When you publish an update, use EXACTLY this argument order: deploy_update(FinalDMLPath, UpdatedSpecMarkdown, MetadataJSONString, ExistingSlug). MetadataJSONString must be deployment_metadata_json without edits."),
|
|
171
|
-
task(DeployTask, string(DeployResult))
|
|
172
|
-
; output("Phase 4/4: Requesting deployment permission..."),
|
|
173
|
-
format(string(DeployTask),
|
|
174
|
-
"You are ready to deploy the updated skill '~w'. Here is the final DML file path:\n\n~w\n\nUpdated specification:\n~w\n\nYour job:\n1. Use ask_user to summarise what changed and ask the user for permission to deploy.\n2. If approved, call deploy_update() with the DML file path, spec, a metadata JSON (name, description, trigger_phrases), and slug override '~w'.\n3. If declined, answer that the update is ready but not deployed, and they can ask to deploy later.\n4. After a successful deploy, end your response with a structured summary in EXACTLY this format:\n\nDEPLOY_RESULT:\n- name: <skill name>\n- slug: ~w\n- changes: <brief summary of what changed>\n- test_status: passed\n- deploy_status: success",
|
|
175
|
-
[EditSlug, FinalDML, SpecMarkdown, EditSlug, EditSlug]),
|
|
176
|
-
system("When you deploy an update, use EXACTLY this argument order: deploy_update(FinalDMLPath, UpdatedSpecMarkdown, MetadataJSONString, ExistingSlug). Do not pass a version number or boolean flag."),
|
|
177
|
-
task(DeployTask, string(DeployResult))
|
|
178
|
-
),
|
|
179
|
-
|
|
180
|
-
format(string(Summary), "✅ Skill '~w' updated and deployed!\n\n~w", [EditSlug, DeployResult]),
|
|
181
|
-
answer(Summary).
|
|
182
|
-
|
|
183
|
-
% -- Fallback for edit --------------------------------------------------------
|
|
184
|
-
|
|
185
|
-
agent_main(SpecMarkdown, EditSlug) :-
|
|
186
|
-
format(string(Msg), "❌ Skill update failed for '~w'.\n\nThe skill could not be updated from the specification provided. Please try:\n1. Simplifying the changes\n2. Providing the full updated specification\n3. Checking if the skill slug '~w' exists\n\nSpec (first 200 chars): ~w", [EditSlug, EditSlug, SpecMarkdown]),
|
|
187
|
-
answer(Msg).
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
type RecipePriority = 'low' | 'normal' | 'high';
|
|
2
|
-
export interface RecipeCatalogEntry {
|
|
3
|
-
slug: string;
|
|
4
|
-
name: string;
|
|
5
|
-
description: string;
|
|
6
|
-
tags: string[];
|
|
7
|
-
whenToUse: string[];
|
|
8
|
-
whenNotToUse: string[];
|
|
9
|
-
globs: string[];
|
|
10
|
-
priority: RecipePriority;
|
|
11
|
-
content: string;
|
|
12
|
-
sourcePath: string;
|
|
13
|
-
source: 'packaged' | 'workspace';
|
|
14
|
-
}
|
|
15
|
-
export interface RecipeCatalogMatch extends RecipeCatalogEntry {
|
|
16
|
-
score: number;
|
|
17
|
-
matchedOn: string[];
|
|
18
|
-
}
|
|
19
|
-
export declare function listRecipeCatalog(workspaceRoot: string): Promise<RecipeCatalogEntry[]>;
|
|
20
|
-
export declare function searchRecipeCatalog(workspaceRoot: string, query: string, options?: {
|
|
21
|
-
maxResults?: number;
|
|
22
|
-
}): Promise<RecipeCatalogMatch[]>;
|
|
23
|
-
export {};
|
|
24
|
-
//# sourceMappingURL=catalog-recipes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"catalog-recipes.d.ts","sourceRoot":"","sources":["../../../src/system/runtime/catalog-recipes.ts"],"names":[],"mappings":"AAQA,KAAK,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAYhD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,UAAU,GAAG,WAAW,CAAC;CAClC;AAED,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,wBAAsB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAa5F;AAED,wBAAsB,mBAAmB,CACvC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GACpC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAmB/B"}
|