deepclause-sdk 0.0.69 → 0.0.71
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/README.md +24 -5
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +125 -10
- package/dist/agent.js.map +1 -1
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +64 -7
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/config.d.ts +15 -12
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +34 -5
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/default-skills.d.ts +1 -0
- package/dist/cli/default-skills.d.ts.map +1 -1
- package/dist/cli/default-skills.js +31 -0
- package/dist/cli/default-skills.js.map +1 -1
- package/dist/cli/tui.d.ts +15 -1
- package/dist/cli/tui.d.ts.map +1 -1
- package/dist/cli/tui.js +209 -7
- package/dist/cli/tui.js.map +1 -1
- package/dist/prolog/bridge.d.ts +15 -0
- package/dist/prolog/bridge.d.ts.map +1 -1
- package/dist/prolog/bridge.js +80 -1
- package/dist/prolog/bridge.js.map +1 -1
- package/dist/prolog-src/deepclause_mi.pl +135 -7
- package/dist/runner.d.ts +8 -0
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +78 -0
- package/dist/runner.js.map +1 -1
- package/dist/system/assets/docs/DML_REFERENCE.md +656 -0
- package/dist/system/assets/docs/TUI.md +11 -0
- package/dist/system/assets/index.d.ts +3 -2
- package/dist/system/assets/index.d.ts.map +1 -1
- package/dist/system/assets/index.js +5 -0
- package/dist/system/assets/index.js.map +1 -1
- package/dist/system/assets/recipes/deepclause-coding-workflow/SKILL.md +56 -1
- package/dist/system/assets/skills/plan.dml +259 -0
- package/dist/system/runtime/dml-executor.d.ts.map +1 -1
- package/dist/system/runtime/dml-executor.js +2 -14
- package/dist/system/runtime/dml-executor.js.map +1 -1
- package/dist/system/runtime/runtime-tools.d.ts +1 -0
- package/dist/system/runtime/runtime-tools.d.ts.map +1 -1
- package/dist/system/runtime/runtime-tools.js +95 -0
- package/dist/system/runtime/runtime-tools.js.map +1 -1
- package/dist/system/runtime/shell-manager.js +1 -1
- package/dist/system/runtime/shell-manager.js.map +1 -1
- package/package.json +8 -4
- package/src/prolog-src/deepclause_mi.pl +135 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/system/assets/index.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/system/assets/index.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,eAAe,GAAG,MAAM,CAAC;AAC1E,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG,eAAe,GAAG,MAAM,CAAC;AAC3E,MAAM,MAAM,wBAAwB,GAAG,2BAA2B,GAAG,wBAAwB,CAAC;AAC9F,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,eAAe,CAAC;AAU5D,UAAU,wBAAwB;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAiCD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAE1E;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,qBAAqB,GAAG,MAAM,CAE5E;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,wBAAwB,GAAG,MAAM,CAElF;AAWD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,qBAAqB,GAAG,MAAM,CAE5E;AAED,wBAAgB,0BAA0B,IAAI,MAAM,CAEnD;AAED,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEzE;AA8FD,wBAAgB,yBAAyB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG;IACjE,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;CACpB,CASA;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,oBAAoB,EAC1B,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,qBAAqB,EAC3B,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,MAAM,CAAC,CAEjB"}
|
|
@@ -15,6 +15,8 @@ function getSystemSkillFileName(name) {
|
|
|
15
15
|
return 'conductor.dml';
|
|
16
16
|
case 'skill-creator':
|
|
17
17
|
return 'skill-creator.dml';
|
|
18
|
+
case 'plan':
|
|
19
|
+
return 'plan.dml';
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
function getSystemPromptFileName(name) {
|
|
@@ -48,6 +50,8 @@ function getWorkspaceDocFileName(name) {
|
|
|
48
50
|
switch (name) {
|
|
49
51
|
case 'tui':
|
|
50
52
|
return 'TUI.md';
|
|
53
|
+
case 'dml-reference':
|
|
54
|
+
return 'DML_REFERENCE.md';
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
export function getWorkspaceDocAssetPath(name) {
|
|
@@ -131,6 +135,7 @@ export function getSystemAssetSourcePaths(workspaceRoot) {
|
|
|
131
135
|
return {
|
|
132
136
|
conductorDml: resolveSystemSkillAssetPathSync('conductor', workspaceRoot),
|
|
133
137
|
conductorPrompt: resolveSystemPromptAssetPathSync('conductor', workspaceRoot),
|
|
138
|
+
planDml: resolveSystemSkillAssetPathSync('plan', workspaceRoot),
|
|
134
139
|
skillCreatorDml: resolveSystemSkillAssetPathSync('skill-creator', workspaceRoot),
|
|
135
140
|
skillCreatorPrompt: resolveSystemPromptAssetPathSync('skill-creator', workspaceRoot),
|
|
136
141
|
taskPrompt: resolveSystemPromptAssetPathSync('task', workspaceRoot),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/system/assets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAOpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACtC,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AACzC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAC/C,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAOjD,SAAS,sBAAsB,CAAC,IAA0B;IACxD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,WAAW;YACd,OAAO,eAAe,CAAC;QACzB,KAAK,eAAe;YAClB,OAAO,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/system/assets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM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,CAAC,KAAK,UAAU,qBAAqB,CACzC,IAA2B,EAC3B,UAAoC,EAAE;IAEtC,OAAO,QAAQ,CAAC,MAAM,4BAA4B,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -3,6 +3,11 @@ name: DeepClause Coding Workflow
|
|
|
3
3
|
description: Guidance for implementing and validating local repository changes in a DeepClause workspace.
|
|
4
4
|
tags: [coding, repository, tests, docs, deepclause]
|
|
5
5
|
when_to_use:
|
|
6
|
+
- tasks that require making specific changes to repository files with clear validation steps
|
|
7
|
+
- debugging and fixing a local behavior with focused edits and tests
|
|
8
|
+
- updating documentation to reflect code changes in the same commit
|
|
9
|
+
- work that is not intended to become a reusable DML skill but is still important to track and execute in a controlled way
|
|
10
|
+
- making focused code changes with clear validation steps
|
|
6
11
|
- implementing a feature or bug fix in the current repository
|
|
7
12
|
- updating tests and documentation alongside code changes
|
|
8
13
|
- debugging a local behavior before editing files
|
|
@@ -42,4 +47,54 @@ Do not use this recipe for pure research or when the right outcome is to create
|
|
|
42
47
|
|
|
43
48
|
# Escalation
|
|
44
49
|
|
|
45
|
-
If the task repeats often or clearly represents a reusable automation, stop treating it as a one-off workflow and create a proper skill instead.
|
|
50
|
+
If the task repeats often or clearly represents a reusable automation, stop treating it as a one-off workflow and create a proper skill instead.
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# Editing Protocol
|
|
54
|
+
|
|
55
|
+
As a coding agent, you will navigate and modify files strictly using non-interactive Unix command-line utilities. You must execute edits precisely and safely, treating the filesystem as fragile. Never attempt to use interactive text editors like vim or nano.
|
|
56
|
+
|
|
57
|
+
1. Core Editing Directives
|
|
58
|
+
Context is Mandatory: Always read the target file or specific lines (using cat, head, tail, or sed -n) before applying changes. You must know exactly what you are modifying.
|
|
59
|
+
|
|
60
|
+
Precision over Broadness: Never use loose regex that might accidentally match unintended parts of a file. Target specific line numbers or highly unique strings.
|
|
61
|
+
|
|
62
|
+
Immediate Verification: Immediately verify your changes after an edit using git diff (if in a repository) or by re-reading the modified section to ensure the code didn't break.
|
|
63
|
+
|
|
64
|
+
Quote Appropriately: Always escape special characters appropriately in your bash commands to prevent syntax errors or unintended variable expansions.
|
|
65
|
+
|
|
66
|
+
2. Locating Context (grep & sed)
|
|
67
|
+
Before editing, find the exact line numbers and context.
|
|
68
|
+
|
|
69
|
+
Find line numbers: grep -n "target string" filename
|
|
70
|
+
|
|
71
|
+
View surrounding context: grep -C 3 "target string" filename (Shows 3 lines before and after).
|
|
72
|
+
|
|
73
|
+
View a specific line range: sed -n '10,25p' filename (Prints lines 10 through 25).
|
|
74
|
+
|
|
75
|
+
3. Modifying Code (sed)
|
|
76
|
+
Use sed for targeted in-place text replacement, deletion, or insertion. Always use the -i flag for in-place editing (Note: if the environment is macOS/BSD, you must use sed -i '').
|
|
77
|
+
|
|
78
|
+
Targeted substitution (by line number): sed -i '42s/old_variable/new_variable/' filename
|
|
79
|
+
|
|
80
|
+
Global substitution (with extreme caution): sed -i 's/old_string/new_string/g' filename
|
|
81
|
+
|
|
82
|
+
Delete specific lines: sed -i '42,45d' filename (Deletes lines 42 through 45).
|
|
83
|
+
|
|
84
|
+
Insert text after a specific line: sed -i '42a\ new_code_line();' filename
|
|
85
|
+
|
|
86
|
+
4. Writing and Appending (bash & Heredocs)
|
|
87
|
+
For generating new files, replacing entire files, or appending large multi-line blocks of code, avoid complex sed commands and use Bash redirects.
|
|
88
|
+
|
|
89
|
+
Append a single line: echo "export DEBUG=true" >> filename
|
|
90
|
+
|
|
91
|
+
Overwrite a file completely: echo "new content" > filename
|
|
92
|
+
|
|
93
|
+
Write multi-line blocks (Heredocs): Use quoted heredocs ('EOF') to prevent the shell from accidentally evaluating variables like $1 or $VAR inside the code block you are writing.
|
|
94
|
+
|
|
95
|
+
# Project Structure
|
|
96
|
+
|
|
97
|
+
The workspace is the current PWD. All commands must be relative to this path. You have access to all files in the workspace, but you should only read and modify files relevant to the current task. Use git commands to check the status of the repository and ensure you are not making unintended changes.
|
|
98
|
+
|
|
99
|
+
# Temporary files
|
|
100
|
+
Do not use /tmp. Instead, create temporary files in a new .deepclause.tmp folder in the current workspace with unique names to avoid conflicts.
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
% Plan skill that writes a simple runnable DML file into plans/.
|
|
2
|
+
|
|
3
|
+
tool(consult_recipes(Query, Result),
|
|
4
|
+
"Search the recipe library for workflow guidance, conventions, and reusable approaches relevant to the requested plan.") :-
|
|
5
|
+
exec(consult_recipes(query: Query, max_results: 3), Result).
|
|
6
|
+
|
|
7
|
+
tool(search_web(Query, Results),
|
|
8
|
+
"Search the web for current documentation, examples, and implementation guidance relevant to the requested plan.") :-
|
|
9
|
+
exec(web_search(query: Query), Results).
|
|
10
|
+
|
|
11
|
+
tool(fetch_url(Url, Content),
|
|
12
|
+
"Fetch the text content of a web page by URL for focused documentation research.") :-
|
|
13
|
+
exec(url_fetch(url: Url), Result),
|
|
14
|
+
get_dict(body, Result, Content).
|
|
15
|
+
|
|
16
|
+
tool(download_file(Url, FilePath, Size), "Download a file from a URL and save it to disk. Returns the file path and size.") :-
|
|
17
|
+
exec(url_fetch(url: Url, save_to: FilePath), Result),
|
|
18
|
+
get_dict(file_path, Result, FilePath),
|
|
19
|
+
get_dict(size, Result, Size).
|
|
20
|
+
|
|
21
|
+
tool(run_bash(Command, Output), "Run a shell command in the workspace.") :-
|
|
22
|
+
exec(bash(command: Command), Output).
|
|
23
|
+
|
|
24
|
+
tool(list_skills(Skills),
|
|
25
|
+
"List reusable local skills in the current workspace catalog before reinventing an existing capability.") :-
|
|
26
|
+
exec(list_skills, Skills).
|
|
27
|
+
|
|
28
|
+
tool(run_skill(Slug, Args, Result),
|
|
29
|
+
"Run an existing local child skill when it can help produce a better plan. Args is a JSON array of arguments.") :-
|
|
30
|
+
exec(run_skill(slug: Slug, args: Args), Result).
|
|
31
|
+
|
|
32
|
+
tool(ask_user(Prompt, Response),
|
|
33
|
+
"Ask the user for clarification, plan preferences, revisions, or approval during plan creation.") :-
|
|
34
|
+
exec(ask_user(prompt: Prompt), Result),
|
|
35
|
+
get_dict(user_response, Result, Response).
|
|
36
|
+
|
|
37
|
+
agent_main(Request) :-
|
|
38
|
+
load_dml_reference(DmlReference),
|
|
39
|
+
load_dml_compiler_prompt(CompilerPrompt),
|
|
40
|
+
load_coding_workflow_recipe(CodingWorkflowRecipe),
|
|
41
|
+
format(string(SystemPrompt), "You create ordered execution plans for DeepClause.
|
|
42
|
+
|
|
43
|
+
Current user request:
|
|
44
|
+
~w
|
|
45
|
+
|
|
46
|
+
- Do not write DML source.
|
|
47
|
+
- Do not write tool definitions.
|
|
48
|
+
- Before drafting the task list, consult recipes relevant to the request.
|
|
49
|
+
- First decide whether the current request is primarily a coding task, a non-coding task, or a mixed task.
|
|
50
|
+
- For coding tasks, prefer recipe guidance, existing local skills, and repository-aware implementation steps. Use web research only when the task depends on external documentation, APIs, libraries, or current behavior that is not already available locally.
|
|
51
|
+
- For non-coding tasks, prefer recipe guidance plus search_web/fetch_url for factual research, background gathering, comparison, or synthesis. Do not force code-editing steps when the request is not actually about changing code.
|
|
52
|
+
- For mixed tasks, combine both modes deliberately and keep the task list ordered so research informs the later implementation or delivery steps.
|
|
53
|
+
- Use list_skills/run_skill only when an existing local skill is clearly relevant to the request or can improve the resulting plan.
|
|
54
|
+
- Choose tools conservatively and intentionally; do not use web or child-skill tools unless they improve the plan quality.
|
|
55
|
+
- Return only an ordered list of 3 to 8 plain natural-language task strings.
|
|
56
|
+
- Each task string should describe one concrete execution step for fulfilling the user's request.
|
|
57
|
+
- Each task must be actionable, concise, and free of code, shell commands, JSON, XML, HTML, CSS, JavaScript, TypeScript, Python, DML, and Markdown fences.
|
|
58
|
+
- Plans should generally create or modify normal project files outside '.deepclause/'.
|
|
59
|
+
- Only target '.deepclause/' when the user explicitly asks for DeepClause internals, prompts, recipes, skills, or runtime configuration.
|
|
60
|
+
- Use the available recipe, research, and child-skill tools when they materially improve the task list.
|
|
61
|
+
- Consult the DML reference and compiler guidance below to understand the execution environment, but still return only the ordered list of task strings.
|
|
62
|
+
|
|
63
|
+
DML language reference loaded from .deepclause/docs/DML_REFERENCE.md:
|
|
64
|
+
|
|
65
|
+
~s
|
|
66
|
+
|
|
67
|
+
DML compiler guidance loaded from .deepclause/system/DML_COMPILER_PROMPT.md:
|
|
68
|
+
|
|
69
|
+
~s", [Request, 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.", PlanSlug),
|
|
78
|
+
|
|
79
|
+
task("Classify this request for plan execution: '{Request}'.
|
|
80
|
+
Requirements:
|
|
81
|
+
- Return exactly one label: coding, non_coding, or mixed.
|
|
82
|
+
- Use coding when the request mainly requires editing code, configuration, tests, scripts, or other project files.
|
|
83
|
+
- Use non_coding when the request is mainly research, analysis, writing, planning, or information gathering without meaningful code changes.
|
|
84
|
+
- Use mixed when the request needs both substantial research or analysis and meaningful implementation or file changes.
|
|
85
|
+
Store only the label in PlanMode.", PlanModeRaw),
|
|
86
|
+
|
|
87
|
+
normalize_plan_mode(PlanModeRaw, PlanMode),
|
|
88
|
+
|
|
89
|
+
task("Break this request into 3 to 8 smaller execution tasks for a standalone DeepClause plan: '{Request}'.
|
|
90
|
+
|
|
91
|
+
If this is a coding task:
|
|
92
|
+
- First perform a review and analysis of the current code base relative to the request
|
|
93
|
+
- Use the results fo the analysis as a basis for your plan. The plan should be very specific.
|
|
94
|
+
|
|
95
|
+
General Requirements for the plan:
|
|
96
|
+
- Consult relevant recipes before finalizing PlanTasks.
|
|
97
|
+
- Decide whether the request is primarily coding, non-coding, or mixed, and shape the task list accordingly.
|
|
98
|
+
- For coding tasks, favor repository-aware implementation, verification, and delivery steps; use web research only when external documentation is genuinely needed.
|
|
99
|
+
- For non-coding tasks, favor research, synthesis, comparison, and delivery steps; do not invent unnecessary coding work.
|
|
100
|
+
- For mixed tasks, order the plan so discovery and research steps come before implementation or delivery steps that depend on them.
|
|
101
|
+
- Use list_skills/run_skill only when an existing local skill is clearly relevant.
|
|
102
|
+
- Return only the ordered list of task descriptions in PlanTasks.
|
|
103
|
+
- Each item must be a plain natural-language execution step, not code.
|
|
104
|
+
- Do not include numbering, bullets, code, shell commands, JSON, XML, HTML, CSS, JavaScript, TypeScript, Python, DML, or Markdown fences.
|
|
105
|
+
- Each task should be specific enough that a later agent task can execute it with the available conductor-style tools.
|
|
106
|
+
- The plan should generally create or modify normal project files outside '.deepclause/'.
|
|
107
|
+
- Consult recipes, web research, fetched URLs, or child skills when they would materially improve the plan.
|
|
108
|
+
|
|
109
|
+
Store only the ordered list in PlanTasks.", list(string(PlanTasks))),
|
|
110
|
+
|
|
111
|
+
derive_plan_system_prompt(Request, PlanMode, CodingWorkflowRecipe, PlanTasks, PlanSystemPrompt),
|
|
112
|
+
|
|
113
|
+
make_directory_path('plans'),
|
|
114
|
+
format(string(FilePath), "plans/~w.dml", [PlanSlug]),
|
|
115
|
+
|
|
116
|
+
build_plan_review_message(FilePath, PlanMode, PlanTasks, PlanReviewMessage),
|
|
117
|
+
output(PlanReviewMessage),
|
|
118
|
+
|
|
119
|
+
output("Assembling the deterministic plan file..."),
|
|
120
|
+
assemble_plan_dml(PlanSystemPrompt, PlanTasks, PlanDml),
|
|
121
|
+
exec(write_file(path: FilePath, content: PlanDml), _),
|
|
122
|
+
exec(validate_dml(dml_file: FilePath), ValidationResult),
|
|
123
|
+
finish_plan_creation(FilePath, PlanSlug, ValidationResult, PlanReviewMessage).
|
|
124
|
+
|
|
125
|
+
assemble_plan_dml(PlanSystemPrompt, PlanTasks, PlanDml) :-
|
|
126
|
+
conductor_tool_definitions(ToolBlock),
|
|
127
|
+
build_task_lines(PlanTasks, TaskLines),
|
|
128
|
+
format(string(PlanDml), "% Generated DeepClause plan.~n% This file was assembled deterministically from a task list.~n~n~s~n~nagent_main :-~n system(~q),~n output(\"Starting generated plan.\"),~n~s answer(\"Plan completed.\").~n~nagent_main :-~n answer(\"Plan failed. Please try again.\").~n", [ToolBlock, PlanSystemPrompt, TaskLines]).
|
|
129
|
+
|
|
130
|
+
derive_plan_system_prompt(Request, PlanMode, CodingWorkflowRecipe, PlanTasks, PlanSystemPrompt) :-
|
|
131
|
+
task("Create a concise system prompt for the generated DeepClause plan for this request: '{Request}'.
|
|
132
|
+
Plan mode: {PlanMode}.
|
|
133
|
+
DeepClause Coding Workflow recipe content:
|
|
134
|
+
{CodingWorkflowRecipe}
|
|
135
|
+
|
|
136
|
+
Planned steps: {PlanTasks}.
|
|
137
|
+
|
|
138
|
+
What to mention in the system prompt:
|
|
139
|
+
- State that the executor is carrying out a generated DeepClause plan.
|
|
140
|
+
- Include the DeepClause Coding Workflow recipe guidance below in the final system prompt so the generated plan always carries it forward.
|
|
141
|
+
- Reflect whether the work is coding, non-coding, or mixed.
|
|
142
|
+
- Tell the executor to consult recipes before substantive action.
|
|
143
|
+
- Tell the executor to choose tools deliberately.
|
|
144
|
+
- For coding tasks, prefer repository-aware and local tools first.
|
|
145
|
+
- For non-coding tasks, prefer research tools when the work is mainly investigation or synthesis.
|
|
146
|
+
- Explicitly say that discussions, questions, and clarifications are fine, and ask_user can be used when helpful.
|
|
147
|
+
- Keep the prompt concise and actionable.
|
|
148
|
+
Store only the final system prompt text in SystemPrompt.", string(SystemPrompt)),
|
|
149
|
+
load_coding_workflow_recipe(CodingWorkflowRecipe),
|
|
150
|
+
format(string(PlanSystemPrompt), "~w\n~w\n", [SystemPrompt, CodingWorkflowRecipe]).
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
load_coding_workflow_recipe(CodingWorkflowRecipe) :-
|
|
154
|
+
exec(consult_recipes(query: 'deepclause coding workflow', max_results: 3), Result),
|
|
155
|
+
get_dict(matches, Result, Matches),
|
|
156
|
+
Matches = [FirstMatch|_],
|
|
157
|
+
get_dict(content, FirstMatch, CodingWorkflowRecipe),
|
|
158
|
+
!.
|
|
159
|
+
|
|
160
|
+
load_coding_workflow_recipe("DeepClause Coding Workflow recipe unavailable. Follow standard DeepClause coding workflow guidance.").
|
|
161
|
+
|
|
162
|
+
build_plan_review_message(FilePath, PlanMode, PlanTasks, PlanReviewMessage) :-
|
|
163
|
+
build_step_review_lines(PlanTasks, 1, StepLines),
|
|
164
|
+
format(string(PlanReviewMessage), "Proposed plan overview\n- Output file: ~w\n- Plan mode: ~w\n\nPlanned steps:\n~s", [FilePath, PlanMode, StepLines]).
|
|
165
|
+
|
|
166
|
+
build_step_review_lines([], _, "").
|
|
167
|
+
build_step_review_lines([Task|RestTasks], StepNumber, StepLines) :-
|
|
168
|
+
format(string(CurrentStep), "~w. ~w\n", [StepNumber, Task]),
|
|
169
|
+
NextStepNumber is StepNumber + 1,
|
|
170
|
+
build_step_review_lines(RestTasks, NextStepNumber, RestStepLines),
|
|
171
|
+
string_concat(CurrentStep, RestStepLines, StepLines).
|
|
172
|
+
|
|
173
|
+
build_task_lines([], "").
|
|
174
|
+
build_task_lines([Task|Rest], TaskLines) :-
|
|
175
|
+
format(string(Line), " task(~q),~n", [Task]),
|
|
176
|
+
build_task_lines(Rest, RestLines),
|
|
177
|
+
string_concat(Line, RestLines, TaskLines).
|
|
178
|
+
|
|
179
|
+
normalize_plan_mode(PlanModeRaw, PlanMode) :-
|
|
180
|
+
format(string(PlanModeString), "~w", [PlanModeRaw]),
|
|
181
|
+
normalize_plan_mode_string(PlanModeString, PlanMode).
|
|
182
|
+
|
|
183
|
+
normalize_plan_mode_string("coding", "coding").
|
|
184
|
+
normalize_plan_mode_string("Coding", "coding").
|
|
185
|
+
normalize_plan_mode_string("non_coding", "non_coding").
|
|
186
|
+
normalize_plan_mode_string("Non_coding", "non_coding").
|
|
187
|
+
normalize_plan_mode_string("non-coding", "non_coding").
|
|
188
|
+
normalize_plan_mode_string("Non-coding", "non_coding").
|
|
189
|
+
normalize_plan_mode_string("mixed", "mixed").
|
|
190
|
+
normalize_plan_mode_string("Mixed", "mixed").
|
|
191
|
+
normalize_plan_mode_string(_, "mixed").
|
|
192
|
+
|
|
193
|
+
finish_plan_creation(FilePath, PlanSlug, ValidationResult, FinalPlanReview) :-
|
|
194
|
+
get_dict(valid, ValidationResult, true),
|
|
195
|
+
output("Deterministic plan validated successfully."),
|
|
196
|
+
format(string(Message), "I've created a new plan in ~w.\n\n~s\nRun it with /run ~w or /~w.", [FilePath, FinalPlanReview, FilePath, PlanSlug]),
|
|
197
|
+
answer(Message).
|
|
198
|
+
|
|
199
|
+
finish_plan_creation(FilePath, _, ValidationResult, _) :-
|
|
200
|
+
format(string(Message), "I wrote ~w, but the deterministic template failed validation: ~w", [FilePath, ValidationResult]),
|
|
201
|
+
answer(Message).
|
|
202
|
+
|
|
203
|
+
conductor_tool_definitions(ToolBlock) :-
|
|
204
|
+
atomics_to_string([
|
|
205
|
+
'% --- Tool predicates (full tool set) ---',
|
|
206
|
+
'',
|
|
207
|
+
'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.") :-',
|
|
208
|
+
'',
|
|
209
|
+
' exec(run_skill(slug: Slug, args: Args), Result).',
|
|
210
|
+
'',
|
|
211
|
+
'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.") :-',
|
|
212
|
+
'',
|
|
213
|
+
' exec(consult_recipes(query: Query, max_results: 3), Result).',
|
|
214
|
+
'',
|
|
215
|
+
'tool(search_web(Query, Results), "Search the web for current information. Returns search results.") :-',
|
|
216
|
+
' exec(web_search(query: Query), Results).',
|
|
217
|
+
'',
|
|
218
|
+
'tool(search_news(Query, Results), "Search recent news articles. Returns news results.") :-',
|
|
219
|
+
' exec(news_search(query: Query), Results).',
|
|
220
|
+
'',
|
|
221
|
+
'tool(fetch_url(Url, Content), "Fetch the content of a web page by URL. Returns the page body as text.") :-',
|
|
222
|
+
' exec(url_fetch(url: Url), Result),',
|
|
223
|
+
' get_dict(body, Result, Content).',
|
|
224
|
+
'',
|
|
225
|
+
'tool(download_file(Url, FilePath, Size), "Download a file from a URL and save it to disk. Returns the file path and size.") :-',
|
|
226
|
+
' exec(url_fetch(url: Url, save_to: FilePath), Result),',
|
|
227
|
+
' get_dict(file_path, Result, FilePath),',
|
|
228
|
+
' get_dict(size, Result, Size).',
|
|
229
|
+
'',
|
|
230
|
+
'tool(run_bash(Command, Output), "Run a shell command in the workspace.") :-',
|
|
231
|
+
' exec(bash(command: Command), Output).',
|
|
232
|
+
'',
|
|
233
|
+
'tool(create_new_skill(Spec, Result), "Create and deploy a new reusable skill from a natural language spec.") :-',
|
|
234
|
+
' exec(create_skill(spec: Spec), Result).',
|
|
235
|
+
'',
|
|
236
|
+
'tool(ask_user(Prompt, Response), "Ask the user a clarifying question and get their response.") :-',
|
|
237
|
+
' exec(ask_user(prompt: Prompt), Result),',
|
|
238
|
+
' get_dict(user_response, Result, Response).',
|
|
239
|
+
'',
|
|
240
|
+
'tool(inform_user(Message, Result), "Send a status update or progress report to the user.") :-',
|
|
241
|
+
' output(Message),',
|
|
242
|
+
' Result = "ok".'
|
|
243
|
+
], "\n", ToolBlock).
|
|
244
|
+
|
|
245
|
+
load_dml_reference(DmlReference) :-
|
|
246
|
+
( exists_file('.deepclause/docs/DML_REFERENCE.md')
|
|
247
|
+
-> read_file('.deepclause/docs/DML_REFERENCE.md', DmlReference)
|
|
248
|
+
; DmlReference = "DML reference unavailable. Use standard DeepClause DML conventions."
|
|
249
|
+
).
|
|
250
|
+
|
|
251
|
+
load_dml_compiler_prompt(CompilerPrompt) :-
|
|
252
|
+
( exists_file('.deepclause/system/DML_COMPILER_PROMPT.md')
|
|
253
|
+
-> read_file('.deepclause/system/DML_COMPILER_PROMPT.md', CompilerPrompt)
|
|
254
|
+
; CompilerPrompt = "DML compiler guidance unavailable. Follow standard DeepClause DML conventions and keep plans simple."
|
|
255
|
+
).
|
|
256
|
+
|
|
257
|
+
agent_main(Request) :-
|
|
258
|
+
format(string(Message), "I could not create a valid plan file for this request: ~w. Try simplifying the request or being more explicit about the steps and required tools.", [Request]),
|
|
259
|
+
answer(Message).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dml-executor.d.ts","sourceRoot":"","sources":["../../../src/system/runtime/dml-executor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"dml-executor.d.ts","sourceRoot":"","sources":["../../../src/system/runtime/dml-executor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGpE,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE3E,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KA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|
import * as path from 'path';
|
|
2
2
|
import { createDeepClause } from '../../sdk.js';
|
|
3
3
|
import { applyResolvedModelConfig, resolveCompactionConfig } from '../../cli/config.js';
|
|
4
|
+
import { formatToolArgs } from '../../cli/tool-args.js';
|
|
4
5
|
import { createLocalSkillCatalogRuntime, } from './catalog-skills.js';
|
|
5
6
|
import { withCapturedConsole } from './console-capture.js';
|
|
6
7
|
import { registerLocalRuntimeTools } from './runtime-tools.js';
|
|
@@ -110,6 +111,7 @@ async function executeDmlInternal(options) {
|
|
|
110
111
|
})
|
|
111
112
|
: undefined;
|
|
112
113
|
registerLocalRuntimeTools(sdk, {
|
|
114
|
+
workspaceRoot: options.workspaceRoot,
|
|
113
115
|
workspacePath: options.workspacePath,
|
|
114
116
|
shell,
|
|
115
117
|
signal: options.signal,
|
|
@@ -176,18 +178,4 @@ function executeNestedSkill(parentOptions, child) {
|
|
|
176
178
|
: undefined,
|
|
177
179
|
});
|
|
178
180
|
}
|
|
179
|
-
function formatToolArgs(args) {
|
|
180
|
-
if (!args) {
|
|
181
|
-
return '';
|
|
182
|
-
}
|
|
183
|
-
const parts = [];
|
|
184
|
-
for (const [key, value] of Object.entries(args)) {
|
|
185
|
-
let rendered = typeof value === 'string' ? value : JSON.stringify(value);
|
|
186
|
-
if (rendered.length > 50) {
|
|
187
|
-
rendered = rendered.slice(0, 47) + '...';
|
|
188
|
-
}
|
|
189
|
-
parts.push(`${key}=${rendered}`);
|
|
190
|
-
}
|
|
191
|
-
return parts.join(', ');
|
|
192
|
-
}
|
|
193
181
|
//# sourceMappingURL=dml-executor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dml-executor.js","sourceRoot":"","sources":["../../../src/system/runtime/dml-executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAA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,MAAM,EAAE,aAAa,CAAC,MAAM;QAC5B,KAAK,EAAE,aAAa,CAAC,KAAK;QAC1B,OAAO,EAAE,aAAa,CAAC,OAAO;QAC9B,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,aAAa,CAAC,OAAO;QAC9B,MAAM,EAAE,aAAa,CAAC,MAAM;QAC5B,WAAW,EAAE,aAAa,CAAC,WAAW;YACpC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,WAAY,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACrE,CAAC,CAAC,SAAS;QACb,OAAO,EAAE,aAAa,CAAC,YAAY,EAAE,YAAY;YAC/C,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,YAAY,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC;YAC1E,CAAC,CAAC,SAAS;QACb,YAAY,EAAE,aAAa,CAAC,YAAY;YACtC,CAAC,CAAC;gBACA,aAAa,EAAE,aAAa,CAAC,YAAY,CAAC,aAAa;gBACvD,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;gBACxC,eAAe,EAAE,KAAK,CAAC,eAAe;gBACtC,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,QAAQ;gBAC7C,yBAAyB,EAAE,aAAa,CAAC,YAAY,CAAC,yBAAyB;gBAC/E,YAAY,EAAE,aAAa,CAAC,YAAY,CAAC,YAAY;aACtD;YACD,CAAC,CAAC,SAAS;KACd,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -7,6 +7,7 @@ export declare function verifyRuntimeToolsAvailable(config: Config, toolNames: s
|
|
|
7
7
|
missing: string[];
|
|
8
8
|
};
|
|
9
9
|
export declare function registerLocalRuntimeTools(sdk: DeepClauseSDK, options: {
|
|
10
|
+
workspaceRoot?: string;
|
|
10
11
|
workspacePath: string;
|
|
11
12
|
shell: ShellManager;
|
|
12
13
|
signal?: AbortSignal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-tools.d.ts","sourceRoot":"","sources":["../../../src/system/runtime/runtime-tools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-tools.d.ts","sourceRoot":"","sources":["../../../src/system/runtime/runtime-tools.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAmBvD,wBAAgB,0BAA0B,IAAI,MAAM,EAAE,CAErD;AAED,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EAAE,GAClB;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAiB3C;AAED,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE;IACP,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;IACpC,YAAY,CAAC,EAAE;QACb,UAAU,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QACnC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;KAC/D,CAAC;CACH,GACA,IAAI,CAoKN;AAED,wBAAsB,QAAQ,CAC5B,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAkClC;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAmC,GAAG;IACnG,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB,CAmBA;AAED,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWpF"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import * as fs from 'fs/promises';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import { newsSearch, webSearch } from '../../cli/search.js';
|
|
4
|
+
import { validateWithProlog } from '../../compiler.js';
|
|
5
|
+
import { listRecipeCatalog, searchRecipeCatalog } from './catalog-recipes.js';
|
|
4
6
|
import { createShellToolEventBridge } from './shell-tool-events.js';
|
|
5
7
|
const BUILT_IN_RUNTIME_TOOLS = new Set([
|
|
6
8
|
'vm_exec',
|
|
7
9
|
'bash',
|
|
10
|
+
'consult_recipes',
|
|
11
|
+
'write_file',
|
|
12
|
+
'validate_dml',
|
|
8
13
|
'web_search',
|
|
9
14
|
'news_search',
|
|
10
15
|
'url_fetch',
|
|
@@ -81,6 +86,22 @@ export function registerLocalRuntimeTools(sdk, options) {
|
|
|
81
86
|
},
|
|
82
87
|
execute: async (args) => urlFetch(options.workspacePath, args, options.signal),
|
|
83
88
|
});
|
|
89
|
+
sdk.registerTool('consult_recipes', {
|
|
90
|
+
description: 'Search the recipe library for workflow guidance, conventions, and reusable approaches.',
|
|
91
|
+
parameters: {
|
|
92
|
+
type: 'object',
|
|
93
|
+
properties: {
|
|
94
|
+
query: { type: 'string', description: 'Natural-language description of the workflow or convention you need.' },
|
|
95
|
+
max_results: { type: 'number', description: 'Optional maximum number of matching recipes to return.' },
|
|
96
|
+
},
|
|
97
|
+
required: ['query'],
|
|
98
|
+
},
|
|
99
|
+
execute: async (args) => consultRecipes({
|
|
100
|
+
workspaceRoot: options.workspaceRoot ?? options.workspacePath,
|
|
101
|
+
query: String(args.query ?? ''),
|
|
102
|
+
maxResults: typeof args.max_results === 'number' ? args.max_results : undefined,
|
|
103
|
+
}),
|
|
104
|
+
});
|
|
84
105
|
sdk.registerTool('bash', {
|
|
85
106
|
description: 'Run a shell command in the active workspace shell.',
|
|
86
107
|
parameters: {
|
|
@@ -99,6 +120,29 @@ export function registerLocalRuntimeTools(sdk, options) {
|
|
|
99
120
|
}));
|
|
100
121
|
},
|
|
101
122
|
});
|
|
123
|
+
sdk.registerTool('write_file', {
|
|
124
|
+
description: 'Write or overwrite a file inside the workspace.',
|
|
125
|
+
parameters: {
|
|
126
|
+
type: 'object',
|
|
127
|
+
properties: {
|
|
128
|
+
path: { type: 'string', description: 'Workspace-relative file path.' },
|
|
129
|
+
content: { type: 'string', description: 'Full file content.' },
|
|
130
|
+
},
|
|
131
|
+
required: ['path', 'content'],
|
|
132
|
+
},
|
|
133
|
+
execute: async (args) => writeWorkspaceFile(options.workspacePath, args),
|
|
134
|
+
});
|
|
135
|
+
sdk.registerTool('validate_dml', {
|
|
136
|
+
description: 'Validate DML code from a file path inside the workspace.',
|
|
137
|
+
parameters: {
|
|
138
|
+
type: 'object',
|
|
139
|
+
properties: {
|
|
140
|
+
dml_file: { type: 'string', description: 'Workspace-relative path to the DML file.' },
|
|
141
|
+
},
|
|
142
|
+
required: ['dml_file'],
|
|
143
|
+
},
|
|
144
|
+
execute: async (args) => validateWorkspaceDml(options.workspacePath, args),
|
|
145
|
+
});
|
|
102
146
|
sdk.registerTool('vm_exec', {
|
|
103
147
|
description: 'Execute a shell command using the active workspace shell backend.',
|
|
104
148
|
parameters: {
|
|
@@ -201,6 +245,57 @@ export function resolveWorkspacePath(workspacePath, filePath) {
|
|
|
201
245
|
}
|
|
202
246
|
return resolved;
|
|
203
247
|
}
|
|
248
|
+
async function writeWorkspaceFile(workspacePath, args) {
|
|
249
|
+
const relPath = String(args.path ?? '');
|
|
250
|
+
const content = String(args.content ?? '');
|
|
251
|
+
if (!relPath) {
|
|
252
|
+
return { success: false, error: 'path is required' };
|
|
253
|
+
}
|
|
254
|
+
const filePath = resolveWorkspacePath(workspacePath, relPath);
|
|
255
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
256
|
+
await fs.writeFile(filePath, content, 'utf8');
|
|
257
|
+
return { success: true, path: relPath, bytes: content.length };
|
|
258
|
+
}
|
|
259
|
+
async function validateWorkspaceDml(workspacePath, args) {
|
|
260
|
+
const dmlPath = resolveWorkspacePath(workspacePath, String(args.dml_file ?? ''));
|
|
261
|
+
const dml = await fs.readFile(dmlPath, 'utf8');
|
|
262
|
+
const result = await validateWithProlog(dml);
|
|
263
|
+
return {
|
|
264
|
+
valid: result.valid,
|
|
265
|
+
errors: result.errors,
|
|
266
|
+
warnings: result.warnings ?? [],
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
async function consultRecipes(options) {
|
|
270
|
+
const query = options.query.trim();
|
|
271
|
+
if (!query) {
|
|
272
|
+
throw new Error('query is required');
|
|
273
|
+
}
|
|
274
|
+
const [catalog, matches] = await Promise.all([
|
|
275
|
+
listRecipeCatalog(options.workspaceRoot),
|
|
276
|
+
searchRecipeCatalog(options.workspaceRoot, query, { maxResults: options.maxResults ?? 3 }),
|
|
277
|
+
]);
|
|
278
|
+
return {
|
|
279
|
+
success: true,
|
|
280
|
+
query,
|
|
281
|
+
total_recipes: catalog.length,
|
|
282
|
+
matches: matches.map((recipe) => ({
|
|
283
|
+
slug: recipe.slug,
|
|
284
|
+
name: recipe.name,
|
|
285
|
+
description: recipe.description,
|
|
286
|
+
tags: recipe.tags,
|
|
287
|
+
when_to_use: recipe.whenToUse,
|
|
288
|
+
when_not_to_use: recipe.whenNotToUse,
|
|
289
|
+
globs: recipe.globs,
|
|
290
|
+
priority: recipe.priority,
|
|
291
|
+
matched_on: recipe.matchedOn,
|
|
292
|
+
score: recipe.score,
|
|
293
|
+
source: recipe.source,
|
|
294
|
+
source_path: recipe.sourcePath,
|
|
295
|
+
content: recipe.content,
|
|
296
|
+
})),
|
|
297
|
+
};
|
|
298
|
+
}
|
|
204
299
|
function isStringRecord(value) {
|
|
205
300
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
206
301
|
return false;
|