deepclause-sdk 0.0.69 → 0.0.70
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/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 +68 -0
- 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 +4 -3
- package/src/prolog-src/deepclause_mi.pl +135 -7
package/dist/cli/tui.js
CHANGED
|
@@ -12,7 +12,7 @@ import { getSystemAssetSourcePaths } from '../system/assets/index.js';
|
|
|
12
12
|
import { createShellManager, describeShellExecutionBackend, } from '../system/runtime/shell-manager.js';
|
|
13
13
|
import { buildToolCompletionEvent, buildToolFailureEvent, buildToolStartEvent, createShellToolEventBridge, } from '../system/runtime/shell-tool-events.js';
|
|
14
14
|
const IGNORED_LIVE_LOG_TOOLS = new Set(['set_result', 'update_memory']);
|
|
15
|
-
const BUILTIN_SLASH_COMMANDS = ['new', 'sessions', 'help', 'compile', 'skill-creator', 'set-model', 'cancel', 'exit', 'quit'];
|
|
15
|
+
const BUILTIN_SLASH_COMMANDS = ['new', 'sessions', 'help', 'run', 'compile', 'skill-creator', 'set-model', 'cancel', 'exit', 'quit'];
|
|
16
16
|
const MODEL_SLOTS = ['gateway', 'run', 'compile'];
|
|
17
17
|
const CHILD_EVENT_INDENT = '\t';
|
|
18
18
|
const CHILD_EVENT_TAB_WIDTH = 4;
|
|
@@ -829,6 +829,9 @@ class FullscreenTui {
|
|
|
829
829
|
this.requestRender();
|
|
830
830
|
return;
|
|
831
831
|
}
|
|
832
|
+
case 'run':
|
|
833
|
+
await this.executeRunFile(parsed.args);
|
|
834
|
+
return;
|
|
832
835
|
case 'compile':
|
|
833
836
|
case 'skill-creator':
|
|
834
837
|
await this.executeSkillCreator(parsed.name, parsed.rawArgs);
|
|
@@ -924,7 +927,7 @@ class FullscreenTui {
|
|
|
924
927
|
this.statusLine = `Running /${skillName}...`;
|
|
925
928
|
this.requestRender();
|
|
926
929
|
try {
|
|
927
|
-
const result = await
|
|
930
|
+
const result = await runSlashCommand(this.workspaceRoot, skillName, args, {
|
|
928
931
|
sessionId: this.selectedSessionId || undefined,
|
|
929
932
|
sandbox: this.options.sandbox,
|
|
930
933
|
signal: this.currentAbortController.signal,
|
|
@@ -963,6 +966,68 @@ class FullscreenTui {
|
|
|
963
966
|
}
|
|
964
967
|
}
|
|
965
968
|
}
|
|
969
|
+
async executeRunFile(args) {
|
|
970
|
+
if (args.length === 0) {
|
|
971
|
+
this.statusLine = 'Provide a DML file after /run.';
|
|
972
|
+
this.requestRender();
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
975
|
+
const [fileSpec, ...runArgs] = args;
|
|
976
|
+
const sessionId = this.selectedSessionId || 'global';
|
|
977
|
+
const activity = this.activityFor(sessionId);
|
|
978
|
+
const commandText = `/run ${args.join(' ')}`;
|
|
979
|
+
const previewTag = path.basename(fileSpec, path.extname(fileSpec)) || 'run';
|
|
980
|
+
this.lastSubmittedInput = { kind: 'builtin', name: 'run', rawArgs: args.join(' '), args: [...args] };
|
|
981
|
+
this.focusedPane = 'messages';
|
|
982
|
+
this.paneScroll.messages = 0;
|
|
983
|
+
this.paneScroll.process = 0;
|
|
984
|
+
this.beginExecutionPreview(sessionId, 'skill', { role: 'system', content: commandText }, previewTag);
|
|
985
|
+
activity.pushLine(`run ${commandText}`);
|
|
986
|
+
this.busy = true;
|
|
987
|
+
this.currentAbortController = new AbortController();
|
|
988
|
+
this.startAnimation();
|
|
989
|
+
this.statusLine = `Running ${commandText}...`;
|
|
990
|
+
this.requestRender();
|
|
991
|
+
try {
|
|
992
|
+
const result = await runFileCommand(this.workspaceRoot, fileSpec, runArgs, {
|
|
993
|
+
sessionId: this.selectedSessionId || undefined,
|
|
994
|
+
sandbox: this.options.sandbox,
|
|
995
|
+
signal: this.currentAbortController.signal,
|
|
996
|
+
onUserInput: (question) => this.requestClarification(question),
|
|
997
|
+
onEvent: (event) => {
|
|
998
|
+
activity.handle(event);
|
|
999
|
+
this.updatePreviewFromEvent(event);
|
|
1000
|
+
this.requestRender();
|
|
1001
|
+
},
|
|
1002
|
+
});
|
|
1003
|
+
activity.finish();
|
|
1004
|
+
await this.refreshCommands();
|
|
1005
|
+
this.finishExecutionPreview({
|
|
1006
|
+
persist: true,
|
|
1007
|
+
finalText: result.answer || summarizeRunResult(result),
|
|
1008
|
+
error: result.error,
|
|
1009
|
+
});
|
|
1010
|
+
this.statusLine = result.error ? `${commandText} failed.` : `${commandText} finished.`;
|
|
1011
|
+
}
|
|
1012
|
+
catch (error) {
|
|
1013
|
+
activity.finish();
|
|
1014
|
+
const message = error.message;
|
|
1015
|
+
activity.pushLine(`[run] error ${message}`);
|
|
1016
|
+
this.finishExecutionPreview({ persist: true, error: message });
|
|
1017
|
+
this.statusLine = `${commandText} failed.`;
|
|
1018
|
+
}
|
|
1019
|
+
finally {
|
|
1020
|
+
this.busy = false;
|
|
1021
|
+
this.currentAbortController = null;
|
|
1022
|
+
this.stopAnimation();
|
|
1023
|
+
if (this.exitRequested) {
|
|
1024
|
+
this.close();
|
|
1025
|
+
}
|
|
1026
|
+
else {
|
|
1027
|
+
this.requestRender();
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
966
1031
|
async executeSkillCreator(commandName, specText) {
|
|
967
1032
|
const trimmedSpec = specText.trim();
|
|
968
1033
|
if (!trimmedSpec) {
|
|
@@ -2589,6 +2654,7 @@ class FullscreenTui {
|
|
|
2589
2654
|
'System Asset Sources',
|
|
2590
2655
|
`Conductor DML ${formatSystemAssetSourcePath(this.workspaceRoot, systemAssetSources.conductorDml)}`,
|
|
2591
2656
|
`Conductor Prompt ${formatSystemAssetSourcePath(this.workspaceRoot, systemAssetSources.conductorPrompt)}`,
|
|
2657
|
+
`Plan DML ${formatSystemAssetSourcePath(this.workspaceRoot, systemAssetSources.planDml)}`,
|
|
2592
2658
|
`Skill Creator DML ${formatSystemAssetSourcePath(this.workspaceRoot, systemAssetSources.skillCreatorDml)}`,
|
|
2593
2659
|
`Skill Creator Prompt ${formatSystemAssetSourcePath(this.workspaceRoot, systemAssetSources.skillCreatorPrompt)}`,
|
|
2594
2660
|
`Task Prompt ${formatSystemAssetSourcePath(this.workspaceRoot, systemAssetSources.taskPrompt)}`,
|
|
@@ -2900,6 +2966,38 @@ async function startLineTui(workspaceRoot = process.cwd(), options = {}) {
|
|
|
2900
2966
|
console.log(helpLine);
|
|
2901
2967
|
}
|
|
2902
2968
|
continue;
|
|
2969
|
+
case 'run':
|
|
2970
|
+
if (parsed.args.length === 0) {
|
|
2971
|
+
console.log('Provide a DML file after /run.');
|
|
2972
|
+
continue;
|
|
2973
|
+
}
|
|
2974
|
+
console.log(divider('-'));
|
|
2975
|
+
console.log(`${paint('run', ANSI.dim)} /run ${parsed.args.join(' ')}`);
|
|
2976
|
+
console.log(divider('-'));
|
|
2977
|
+
{
|
|
2978
|
+
const printer = new LiveExecutionPrinter();
|
|
2979
|
+
try {
|
|
2980
|
+
await runFileCommand(workspaceRoot, parsed.args[0], parsed.args.slice(1), {
|
|
2981
|
+
sessionId: session.id,
|
|
2982
|
+
sandbox: options.sandbox,
|
|
2983
|
+
onUserInput: async (question) => {
|
|
2984
|
+
printer.finish();
|
|
2985
|
+
console.log(`${paint('clarify', ANSI.yellow)} ${question}`);
|
|
2986
|
+
return (await rl.question('> ')).trim();
|
|
2987
|
+
},
|
|
2988
|
+
onEvent: (event) => printer.handle(event),
|
|
2989
|
+
});
|
|
2990
|
+
}
|
|
2991
|
+
catch (error) {
|
|
2992
|
+
printer.finish();
|
|
2993
|
+
console.log(`${paint('error', ANSI.red)} ${error.message}`);
|
|
2994
|
+
}
|
|
2995
|
+
printer.finish();
|
|
2996
|
+
}
|
|
2997
|
+
console.log('');
|
|
2998
|
+
console.log(divider('-'));
|
|
2999
|
+
console.log('');
|
|
3000
|
+
continue;
|
|
2903
3001
|
case 'compile':
|
|
2904
3002
|
case 'skill-creator':
|
|
2905
3003
|
if (!parsed.rawArgs.trim()) {
|
|
@@ -2977,7 +3075,7 @@ async function startLineTui(workspaceRoot = process.cwd(), options = {}) {
|
|
|
2977
3075
|
console.log(divider('-'));
|
|
2978
3076
|
const printer = new LiveExecutionPrinter();
|
|
2979
3077
|
try {
|
|
2980
|
-
await
|
|
3078
|
+
await runSlashCommand(workspaceRoot, parsed.name, parsed.args, {
|
|
2981
3079
|
sessionId: session.id,
|
|
2982
3080
|
sandbox: options.sandbox,
|
|
2983
3081
|
onUserInput: async (question) => {
|
|
@@ -3059,13 +3157,57 @@ export async function runSkillCommand(workspaceRoot, skillName, args, options =
|
|
|
3059
3157
|
if (!command) {
|
|
3060
3158
|
throw new Error(`Unknown skill: ${skillName}`);
|
|
3061
3159
|
}
|
|
3160
|
+
return executeRunnableCommand(workspaceRoot, {
|
|
3161
|
+
inputText: `/${skillName}${args.length > 0 ? ` ${args.join(' ')}` : ''}`,
|
|
3162
|
+
runPath: command.path,
|
|
3163
|
+
childSlug: skillName,
|
|
3164
|
+
skillName,
|
|
3165
|
+
}, args, options);
|
|
3166
|
+
}
|
|
3167
|
+
export async function runSlashCommand(workspaceRoot, name, args, options = {}) {
|
|
3168
|
+
const commands = await listCommands(workspaceRoot);
|
|
3169
|
+
const command = commands.find((entry) => entry.name === name);
|
|
3170
|
+
if (command) {
|
|
3171
|
+
return executeRunnableCommand(workspaceRoot, {
|
|
3172
|
+
inputText: `/${name}${args.length > 0 ? ` ${args.join(' ')}` : ''}`,
|
|
3173
|
+
runPath: command.path,
|
|
3174
|
+
childSlug: name,
|
|
3175
|
+
skillName: name,
|
|
3176
|
+
}, args, options);
|
|
3177
|
+
}
|
|
3178
|
+
const resolvedPlanPath = await resolveWorkspaceDmlPath(workspaceRoot, name, { mode: 'plans-only' });
|
|
3179
|
+
if (!resolvedPlanPath) {
|
|
3180
|
+
throw new Error(`Unknown skill or plan: ${name}`);
|
|
3181
|
+
}
|
|
3182
|
+
const childSlug = path.basename(resolvedPlanPath, path.extname(resolvedPlanPath)) || name;
|
|
3183
|
+
return executeRunnableCommand(workspaceRoot, {
|
|
3184
|
+
inputText: `/${name}${args.length > 0 ? ` ${args.join(' ')}` : ''}`,
|
|
3185
|
+
runPath: resolvedPlanPath,
|
|
3186
|
+
childSlug,
|
|
3187
|
+
skillName: childSlug,
|
|
3188
|
+
}, args, options);
|
|
3189
|
+
}
|
|
3190
|
+
export async function runFileCommand(workspaceRoot, fileSpec, args, options = {}) {
|
|
3191
|
+
const resolvedPath = await resolveWorkspaceDmlPath(workspaceRoot, fileSpec, { mode: 'direct' });
|
|
3192
|
+
if (!resolvedPath) {
|
|
3193
|
+
throw new Error(`DML file not found: ${fileSpec}`);
|
|
3194
|
+
}
|
|
3195
|
+
const childSlug = path.basename(resolvedPath, path.extname(resolvedPath)) || 'run';
|
|
3196
|
+
return executeRunnableCommand(workspaceRoot, {
|
|
3197
|
+
inputText: `/run ${[fileSpec, ...args].join(' ')}`.trim(),
|
|
3198
|
+
runPath: resolvedPath,
|
|
3199
|
+
childSlug,
|
|
3200
|
+
skillName: childSlug,
|
|
3201
|
+
}, args, options);
|
|
3202
|
+
}
|
|
3203
|
+
async function executeRunnableCommand(workspaceRoot, target, args, options = {}) {
|
|
3062
3204
|
const executionLog = options.sessionId
|
|
3063
3205
|
? createSessionExecutionLogWriter({
|
|
3064
3206
|
workspaceRoot,
|
|
3065
3207
|
sessionId: options.sessionId,
|
|
3066
3208
|
executionKind: 'skill',
|
|
3067
|
-
inputText:
|
|
3068
|
-
skillName,
|
|
3209
|
+
inputText: target.inputText,
|
|
3210
|
+
skillName: target.skillName,
|
|
3069
3211
|
args,
|
|
3070
3212
|
})
|
|
3071
3213
|
: null;
|
|
@@ -3074,14 +3216,14 @@ export async function runSkillCommand(workspaceRoot, skillName, args, options =
|
|
|
3074
3216
|
options.onEvent?.(event);
|
|
3075
3217
|
};
|
|
3076
3218
|
try {
|
|
3077
|
-
const result = await run(
|
|
3219
|
+
const result = await run(target.runPath, args, {
|
|
3078
3220
|
configRoot: workspaceRoot,
|
|
3079
3221
|
headless: true,
|
|
3080
3222
|
stream: true,
|
|
3081
3223
|
sandbox: options.sandbox,
|
|
3082
3224
|
signal: options.signal,
|
|
3083
3225
|
onUserInput: options.onUserInput,
|
|
3084
|
-
onEvent: (event) => emitLogEvent({ scope: 'child', childSlug:
|
|
3226
|
+
onEvent: (event) => emitLogEvent({ scope: 'child', childSlug: target.childSlug, event }),
|
|
3085
3227
|
onChildEvent: (childSlug, event) => emitLogEvent({ scope: 'child', childSlug, event }),
|
|
3086
3228
|
});
|
|
3087
3229
|
await executionLog?.finish({
|
|
@@ -3100,6 +3242,64 @@ export async function runSkillCommand(workspaceRoot, skillName, args, options =
|
|
|
3100
3242
|
throw error;
|
|
3101
3243
|
}
|
|
3102
3244
|
}
|
|
3245
|
+
async function resolveWorkspaceDmlPath(workspaceRoot, fileSpec, options) {
|
|
3246
|
+
const trimmed = fileSpec.trim();
|
|
3247
|
+
if (!trimmed) {
|
|
3248
|
+
return null;
|
|
3249
|
+
}
|
|
3250
|
+
const candidates = options.mode === 'plans-only'
|
|
3251
|
+
? buildPlanOnlyCandidates(workspaceRoot, trimmed)
|
|
3252
|
+
: buildDirectDmlCandidates(workspaceRoot, trimmed);
|
|
3253
|
+
for (const candidate of candidates) {
|
|
3254
|
+
if (await fileExists(candidate)) {
|
|
3255
|
+
return candidate;
|
|
3256
|
+
}
|
|
3257
|
+
}
|
|
3258
|
+
return null;
|
|
3259
|
+
}
|
|
3260
|
+
function buildDirectDmlCandidates(workspaceRoot, fileSpec) {
|
|
3261
|
+
const trimmed = fileSpec.trim();
|
|
3262
|
+
const candidates = new Set();
|
|
3263
|
+
const directPath = path.resolve(workspaceRoot, trimmed);
|
|
3264
|
+
candidates.add(directPath);
|
|
3265
|
+
if (!trimmed.endsWith('.dml')) {
|
|
3266
|
+
candidates.add(path.resolve(workspaceRoot, `${trimmed}.dml`));
|
|
3267
|
+
}
|
|
3268
|
+
const normalized = trimLeadingPathSeparators(trimmed).replace(/\\/g, '/');
|
|
3269
|
+
const planRelative = normalized.startsWith('plans/') ? normalized : path.posix.join('plans', normalized);
|
|
3270
|
+
candidates.add(path.resolve(workspaceRoot, planRelative));
|
|
3271
|
+
if (!planRelative.endsWith('.dml')) {
|
|
3272
|
+
candidates.add(path.resolve(workspaceRoot, `${planRelative}.dml`));
|
|
3273
|
+
}
|
|
3274
|
+
return Array.from(candidates);
|
|
3275
|
+
}
|
|
3276
|
+
function buildPlanOnlyCandidates(workspaceRoot, fileSpec) {
|
|
3277
|
+
const normalized = trimLeadingPathSeparators(fileSpec.trim()).replace(/\\/g, '/');
|
|
3278
|
+
const planRelative = normalized.startsWith('plans/') ? normalized : path.posix.join('plans', normalized);
|
|
3279
|
+
const plansRoot = path.resolve(workspaceRoot, 'plans');
|
|
3280
|
+
const candidates = [
|
|
3281
|
+
path.resolve(workspaceRoot, planRelative),
|
|
3282
|
+
...(planRelative.endsWith('.dml') ? [] : [path.resolve(workspaceRoot, `${planRelative}.dml`)]),
|
|
3283
|
+
];
|
|
3284
|
+
return candidates.filter((candidate, index, all) => {
|
|
3285
|
+
if (all.indexOf(candidate) !== index) {
|
|
3286
|
+
return false;
|
|
3287
|
+
}
|
|
3288
|
+
return candidate === plansRoot || candidate.startsWith(`${plansRoot}${path.sep}`);
|
|
3289
|
+
});
|
|
3290
|
+
}
|
|
3291
|
+
function trimLeadingPathSeparators(value) {
|
|
3292
|
+
return value.replace(/^[/\\]+/, '');
|
|
3293
|
+
}
|
|
3294
|
+
async function fileExists(filePath) {
|
|
3295
|
+
try {
|
|
3296
|
+
await fs.access(filePath);
|
|
3297
|
+
return true;
|
|
3298
|
+
}
|
|
3299
|
+
catch {
|
|
3300
|
+
return false;
|
|
3301
|
+
}
|
|
3302
|
+
}
|
|
3103
3303
|
async function runSkillCreatorCommand(workspaceRoot, sessionId, spec, options = {}) {
|
|
3104
3304
|
const trimmedSpec = spec.trim();
|
|
3105
3305
|
if (!trimmedSpec) {
|
|
@@ -3682,6 +3882,7 @@ function buildHelpLines() {
|
|
|
3682
3882
|
'commands',
|
|
3683
3883
|
'/new [title] create a new conductor session',
|
|
3684
3884
|
'/sessions refresh or choose sessions',
|
|
3885
|
+
'/run <file> [args] run a workspace DML file directly',
|
|
3685
3886
|
'/compile <spec> compile and publish a new local skill',
|
|
3686
3887
|
'/skill-creator <spec> alias for /compile',
|
|
3687
3888
|
'/set-model <model> [--slot <slot>] update the configured model selection',
|
|
@@ -3689,6 +3890,7 @@ function buildHelpLines() {
|
|
|
3689
3890
|
'/help show this help',
|
|
3690
3891
|
'/quit exit the TUI',
|
|
3691
3892
|
'/<skill> [args] run a compiled skill directly',
|
|
3893
|
+
'/<plan> [args] run plans/<plan>.dml when no compiled skill matches',
|
|
3692
3894
|
'!<command> run a shell command directly in the workspace shell',
|
|
3693
3895
|
'!!<command> run a shell command and add its result to the session transcript',
|
|
3694
3896
|
'keys',
|