deepclause-sdk 0.0.89 → 0.1.1
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 +481 -941
- package/dist/agent.d.ts +19 -2
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +75 -21
- package/dist/agent.js.map +1 -1
- package/dist/cli/config.d.ts +385 -178
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +161 -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 +85 -411
- 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 +216 -0
- package/dist/cli/repl.d.ts.map +1 -0
- package/dist/cli/repl.js +1392 -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 +202 -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 +42 -0
- package/dist/cli/visualize.d.ts.map +1 -0
- package/dist/cli/visualize.js +150 -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 +27 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/prolog/bridge.d.ts +5 -1
- package/dist/prolog/bridge.d.ts.map +1 -1
- package/dist/prolog/bridge.js +10 -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 +2440 -49
- package/dist/repl/agent.d.ts +90 -0
- package/dist/repl/agent.d.ts.map +1 -0
- package/dist/repl/agent.js +410 -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 +321 -0
- package/dist/repl/backend.d.ts.map +1 -0
- package/dist/repl/backend.js +415 -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 +99 -0
- package/dist/repl/harness-tools.d.ts.map +1 -0
- package/dist/repl/harness-tools.js +192 -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/imagegen.d.ts +29 -0
- package/dist/repl/imagegen.d.ts.map +1 -0
- package/dist/repl/imagegen.js +84 -0
- package/dist/repl/imagegen.js.map +1 -0
- package/dist/repl/index.d.ts +130 -0
- package/dist/repl/index.d.ts.map +1 -0
- package/dist/repl/index.js +112 -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/model-resolver.d.ts +59 -0
- package/dist/repl/model-resolver.d.ts.map +1 -0
- package/dist/repl/model-resolver.js +156 -0
- package/dist/repl/model-resolver.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 +187 -0
- package/dist/repl/render.d.ts.map +1 -0
- package/dist/repl/render.js +808 -0
- package/dist/repl/render.js.map +1 -0
- package/dist/repl/session.d.ts +424 -0
- package/dist/repl/session.d.ts.map +1 -0
- package/dist/repl/session.js +1473 -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 +41 -0
- package/dist/repl/tui/transcript.d.ts.map +1 -0
- package/dist/repl/tui/transcript.js +139 -0
- package/dist/repl/tui/transcript.js.map +1 -0
- package/dist/runner.d.ts +143 -13
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +532 -290
- package/dist/runner.js.map +1 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +0 -32
- package/dist/sdk.js.map +1 -1
- package/dist/system/assets/docs/AGENT_PROMPT.md +1447 -0
- package/dist/system/assets/docs/DML_AUTHORING.md +195 -0
- package/dist/system/assets/docs/DML_REFERENCE.md +344 -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 +136 -119
- 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/ascii.d.ts +55 -0
- package/dist/visualize/ascii.d.ts.map +1 -0
- package/dist/visualize/ascii.js +242 -0
- package/dist/visualize/ascii.js.map +1 -0
- package/dist/visualize/display.d.ts +24 -0
- package/dist/visualize/display.d.ts.map +1 -0
- package/dist/visualize/display.js +29 -0
- package/dist/visualize/display.js.map +1 -0
- package/dist/visualize/graphics.d.ts +35 -0
- package/dist/visualize/graphics.d.ts.map +1 -0
- package/dist/visualize/graphics.js +96 -0
- package/dist/visualize/graphics.js.map +1 -0
- package/dist/visualize/image.d.ts +38 -0
- package/dist/visualize/image.d.ts.map +1 -0
- package/dist/visualize/image.js +95 -0
- package/dist/visualize/image.js.map +1 -0
- package/dist/visualize/index.d.ts +59 -0
- package/dist/visualize/index.d.ts.map +1 -0
- package/dist/visualize/index.js +198 -0
- package/dist/visualize/index.js.map +1 -0
- package/dist/visualize/raster.d.ts +23 -0
- package/dist/visualize/raster.d.ts.map +1 -0
- package/dist/visualize/raster.js +47 -0
- package/dist/visualize/raster.js.map +1 -0
- package/dist/visualize/svg.d.ts +39 -0
- package/dist/visualize/svg.d.ts.map +1 -0
- package/dist/visualize/svg.js +148 -0
- package/dist/visualize/svg.js.map +1 -0
- package/dist/visualize/transcode.d.ts +13 -0
- package/dist/visualize/transcode.d.ts.map +1 -0
- package/dist/visualize/transcode.js +40 -0
- package/dist/visualize/transcode.js.map +1 -0
- package/docs/images/repl.png +0 -0
- package/package.json +19 -15
- package/src/prolog-src/deepclause_analysis.pl +10 -2
- package/src/prolog-src/deepclause_mi.pl +2440 -49
- 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/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
package/dist/cli/index.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* DeepClause CLI
|
|
3
|
+
* DeepClause CLI.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Commands: init, set-model, show-model, list-models, run, repl, login,
|
|
6
|
+
* logout, set-backend.
|
|
6
7
|
*/
|
|
7
8
|
import { Command } from 'commander';
|
|
8
9
|
import * as path from 'path';
|
|
9
10
|
import * as fs from 'fs/promises';
|
|
10
|
-
import { deepClauseDirExists, initConfig, setModel, showModel } from './config.js';
|
|
11
|
-
import { compile, compileAll } from './compile.js';
|
|
11
|
+
import { deepClauseDirExists, initConfig, loadConfig, setModel, showModel } from './config.js';
|
|
12
12
|
import { run } from './run.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { runPromptHeadless, startTui } from './tui.js';
|
|
13
|
+
import { registerReplCommand } from './repl.js';
|
|
14
|
+
import { registerVisualizeCommand } from './visualize.js';
|
|
15
|
+
import { registerSetBackendCommand, setBackend } from './set-backend.js';
|
|
16
|
+
import { registerLoginCommands } from './login.js';
|
|
18
17
|
import { readFileSync } from 'fs';
|
|
19
18
|
import { fileURLToPath } from 'url';
|
|
20
19
|
import { dirname, join } from 'path';
|
|
@@ -25,13 +24,10 @@ const packageJsonPath = join(__dirname, '../../package.json');
|
|
|
25
24
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
26
25
|
const version = packageJson.version;
|
|
27
26
|
const program = new Command();
|
|
28
|
-
const CLI_SUBCOMMANDS = new Set(['init', 'set-model', 'show-model', 'list-models', 'compile', 'compile-all', 'run', 'plan', 'list-tools', 'list-commands', 'help']);
|
|
29
27
|
program
|
|
30
28
|
.name('deepclause')
|
|
31
|
-
.description('
|
|
32
|
-
.version(version)
|
|
33
|
-
.option('-p, --prompt <text>', 'Run a prompt in headless conductor mode with a fresh session')
|
|
34
|
-
.option('--sandbox', 'Run shell tools inside AgentVM instead of the local workspace shell');
|
|
29
|
+
.description('Run and build DML skills with the REPL and one-shot runner')
|
|
30
|
+
.version(version);
|
|
35
31
|
// =============================================================================
|
|
36
32
|
// Configuration Commands
|
|
37
33
|
// =============================================================================
|
|
@@ -56,9 +52,23 @@ program
|
|
|
56
52
|
.description('Set the default LLM model (format: provider:model, or just a model name to search)')
|
|
57
53
|
.option('--slot <slot>', 'Apply only to a single slot: gateway, run, or compile')
|
|
58
54
|
.option('--provider <provider>', 'Non-interactive: specify provider directly (openai, anthropic, google, openrouter, custom:name)')
|
|
55
|
+
.option('--thinking <level>', 'thinking level for reasoning models (off|minimal|low|medium|high|xhigh|max)')
|
|
59
56
|
.action(async (model, options) => {
|
|
60
57
|
try {
|
|
61
58
|
const slot = options.slot;
|
|
59
|
+
// With the pi backend the model comes from pi's catalog, so route the
|
|
60
|
+
// change through set-backend (which validates auth and persists the
|
|
61
|
+
// model + thinking level together). The env backend keeps the DB flow.
|
|
62
|
+
const config = await loadConfig(process.cwd());
|
|
63
|
+
if ((config.backend?.kind ?? 'pi') === 'pi') {
|
|
64
|
+
const result = await setBackend(process.cwd(), 'pi', {
|
|
65
|
+
model: model.includes(':') || model.includes('/') ? model.replace(':', '/') : model,
|
|
66
|
+
provider: options.provider,
|
|
67
|
+
thinking: options.thinking,
|
|
68
|
+
});
|
|
69
|
+
console.log(result.info);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
62
72
|
// If the model already has a provider prefix (contains : or is custom:), use as-is
|
|
63
73
|
const hasProviderPrefix = model.includes(':') || model.startsWith('custom:');
|
|
64
74
|
let finalModel = model;
|
|
@@ -108,7 +118,7 @@ program
|
|
|
108
118
|
if (results.length > 10) {
|
|
109
119
|
console.log(` ... and ${results.length - 10} more. Refine your search for fewer results.`);
|
|
110
120
|
}
|
|
111
|
-
const { promptUser } = await import('./
|
|
121
|
+
const { promptUser } = await import('./readline.js');
|
|
112
122
|
const answer = await promptUser(`Enter choice (1-${choices.length}) or press Enter for #1:`);
|
|
113
123
|
const choice = parseInt(answer.trim()) || 1;
|
|
114
124
|
if (choice < 1 || choice > choices.length) {
|
|
@@ -186,162 +196,38 @@ program
|
|
|
186
196
|
process.exit(1);
|
|
187
197
|
}
|
|
188
198
|
});
|
|
189
|
-
// =============================================================================
|
|
190
|
-
// Compilation Commands
|
|
191
|
-
// =============================================================================
|
|
192
199
|
program
|
|
193
|
-
.command('
|
|
194
|
-
.description('
|
|
195
|
-
.option('
|
|
196
|
-
.
|
|
197
|
-
.option('--headless', 'Plain output only, no live formatting')
|
|
198
|
-
.option('--sandbox', 'Run shell tools inside AgentVM instead of the local workspace shell')
|
|
199
|
-
.option('--trace <file>', 'Save compilation trace to file')
|
|
200
|
-
.option('--model <model>', 'Override model for compilation')
|
|
201
|
-
.option('--provider <provider>', 'Override provider for compilation (openai, anthropic, google, openrouter)')
|
|
202
|
-
.option('--temperature <number>', 'Override temperature (0.0-2.0)', parseFloat)
|
|
203
|
-
.option('--max-attempts <number>', 'Max compilation attempts (default: 3)', parseInt)
|
|
204
|
-
.option('-v, --verbose', 'Show debug output including tool calls')
|
|
205
|
-
.option('--stream', 'Stream LLM responses in real-time')
|
|
206
|
-
.option('--no-audit', 'Disable the LLM security audit (static analysis still runs)')
|
|
207
|
-
.action(async (source, output, options) => {
|
|
200
|
+
.command('image-models')
|
|
201
|
+
.description('List image-generation models for /gen and task(…, media(X))')
|
|
202
|
+
.option('--json', 'Output as JSON')
|
|
203
|
+
.action(async (options) => {
|
|
208
204
|
try {
|
|
209
|
-
const
|
|
210
|
-
const
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
break;
|
|
221
|
-
case 'stream':
|
|
222
|
-
if (options.stream && !options.headless && event.content) {
|
|
223
|
-
process.stdout.write(event.content);
|
|
224
|
-
}
|
|
225
|
-
if (options.stream && !options.headless && event.done) {
|
|
226
|
-
process.stdout.write('\n');
|
|
227
|
-
}
|
|
228
|
-
break;
|
|
229
|
-
case 'log':
|
|
230
|
-
if (options.verbose && !options.headless && event.content) {
|
|
231
|
-
process.stdout.write(`[log] ${event.content}\n`);
|
|
232
|
-
}
|
|
233
|
-
break;
|
|
234
|
-
case 'tool_call':
|
|
235
|
-
if (options.verbose && !options.headless && event.toolName) {
|
|
236
|
-
process.stdout.write(` 🔧 ${event.toolName}(${formatToolArgs(event.toolArgs)})\n`);
|
|
237
|
-
}
|
|
238
|
-
break;
|
|
239
|
-
case 'input_required':
|
|
240
|
-
if (options.verbose && !options.headless && event.prompt) {
|
|
241
|
-
process.stdout.write(`[input_required] ${event.prompt}\n`);
|
|
242
|
-
}
|
|
243
|
-
break;
|
|
244
|
-
default:
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
const result = await compile(source, outputDir, {
|
|
249
|
-
force: options.force,
|
|
250
|
-
validateOnly: options.validateOnly,
|
|
251
|
-
headless: options.headless,
|
|
252
|
-
sandbox: options.sandbox,
|
|
253
|
-
trace: options.trace,
|
|
254
|
-
model: buildModelOverride(options.model, options.provider),
|
|
255
|
-
provider: options.provider,
|
|
256
|
-
temperature: options.temperature,
|
|
257
|
-
maxAttempts: options.maxAttempts,
|
|
258
|
-
verbose: options.verbose,
|
|
259
|
-
stream: options.stream,
|
|
260
|
-
audit: options.audit !== false,
|
|
261
|
-
onEvent,
|
|
262
|
-
});
|
|
263
|
-
if (result.analysis?.warnings?.length) {
|
|
264
|
-
console.log('\n⚠️ Static Analysis Warnings:');
|
|
265
|
-
for (const warning of result.analysis.warnings) {
|
|
266
|
-
const icon = warning.level === 'critical' ? '🔴' : warning.level === 'high' ? '🟠' : warning.level === 'medium' ? '🟡' : '⚪';
|
|
267
|
-
console.log(` ${icon} [${warning.level.toUpperCase()}] ${warning.message}`);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
if (result.analysis?.auditorReport) {
|
|
271
|
-
console.log('\n🛡️ LLM Security Audit:\n');
|
|
272
|
-
console.log(result.analysis.auditorReport);
|
|
273
|
-
}
|
|
274
|
-
if (options.headless) {
|
|
275
|
-
for (const out of result.runtimeOutput ?? liveOutput) {
|
|
276
|
-
console.log(out);
|
|
277
|
-
}
|
|
205
|
+
const { openPiRuntime } = await import('../repl/backend.js');
|
|
206
|
+
const handle = await openPiRuntime({});
|
|
207
|
+
const runtime = handle.runtime;
|
|
208
|
+
const all = runtime.getModelsOfType?.('image') ?? [];
|
|
209
|
+
const available = typeof runtime.getAvailableOfType === 'function'
|
|
210
|
+
? await runtime.getAvailableOfType('image')
|
|
211
|
+
: [];
|
|
212
|
+
const ready = new Set(available.map((m) => `${m.provider}:${m.id}`));
|
|
213
|
+
const rows = all.map((m) => ({ model: `${m.provider}:${m.id}`, authenticated: ready.has(`${m.provider}:${m.id}`) }));
|
|
214
|
+
if (options.json) {
|
|
215
|
+
console.log(JSON.stringify(rows, null, 2));
|
|
278
216
|
}
|
|
279
|
-
if (
|
|
280
|
-
console.log(
|
|
217
|
+
else if (all.length === 0) {
|
|
218
|
+
console.log('No image-generation models are known. Run `deepclause login` and sign in to a provider that offers image models.');
|
|
281
219
|
}
|
|
282
220
|
else {
|
|
283
|
-
console.log(
|
|
284
|
-
|
|
285
|
-
console.log(
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
if (!result.skipped && !options.validateOnly) {
|
|
289
|
-
console.log(`\n Output: ${result.output}`);
|
|
290
|
-
console.log(` Tools: ${result.tools.join(', ') || 'none'}`);
|
|
291
|
-
if (result.attempts && result.attempts > 1) {
|
|
292
|
-
console.log(` Attempts: ${result.attempts}`);
|
|
221
|
+
console.log(`Image models (${available.length} available)\n`);
|
|
222
|
+
for (const row of rows) {
|
|
223
|
+
console.log(` ${row.model} [${row.authenticated ? 'ready' : 'needs auth'}]`);
|
|
293
224
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
catch (error) {
|
|
300
|
-
const compileError = error;
|
|
301
|
-
if (options.headless && Array.isArray(compileError.runtimeOutput)) {
|
|
302
|
-
for (const out of compileError.runtimeOutput) {
|
|
303
|
-
console.log(out);
|
|
225
|
+
const first = available[0];
|
|
226
|
+
if (first) {
|
|
227
|
+
console.log(`\nUse one with: deepclause repl --image-model ${first.provider}:${first.id}`);
|
|
228
|
+
console.log('or set "repl": { "media": { "imageModel": "' + `${first.provider}:${first.id}` + '" } } in .deepclause/config.json');
|
|
304
229
|
}
|
|
305
230
|
}
|
|
306
|
-
const message = error instanceof Error && error.message
|
|
307
|
-
? error.message
|
|
308
|
-
: String(error);
|
|
309
|
-
console.error(message.startsWith('❌') ? message : `❌ Error: ${message}`);
|
|
310
|
-
if (options.trace && compileError.trace) {
|
|
311
|
-
console.log(`\n📊 Trace saved to: ${options.trace}`);
|
|
312
|
-
}
|
|
313
|
-
if (options.verbose && error instanceof Error && error.stack) {
|
|
314
|
-
console.error(error.stack);
|
|
315
|
-
}
|
|
316
|
-
process.exit(1);
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
program
|
|
320
|
-
.command('compile-all <sourceDir> [outputDir]')
|
|
321
|
-
.description('Compile all Markdown files in a directory')
|
|
322
|
-
.option('-f, --force', 'Force recompilation of all files')
|
|
323
|
-
.option('--sandbox', 'Run shell tools inside AgentVM instead of the local workspace shell')
|
|
324
|
-
.option('--model <model>', 'Override model for compilation')
|
|
325
|
-
.option('--provider <provider>', 'Override provider for compilation (openai, anthropic, google, openrouter)')
|
|
326
|
-
.option('--temperature <number>', 'Override temperature (0.0-2.0)', parseFloat)
|
|
327
|
-
.option('--max-attempts <number>', 'Max compilation attempts per file (default: 3)', parseInt)
|
|
328
|
-
.option('--no-audit', 'Disable the LLM security audit (static analysis still runs)')
|
|
329
|
-
.action(async (sourceDir, outputDir, options) => {
|
|
330
|
-
try {
|
|
331
|
-
const out = outputDir || '.deepclause/tools';
|
|
332
|
-
const result = await compileAll(sourceDir, out, {
|
|
333
|
-
force: options.force,
|
|
334
|
-
sandbox: options.sandbox,
|
|
335
|
-
model: buildModelOverride(options.model, options.provider),
|
|
336
|
-
provider: options.provider,
|
|
337
|
-
temperature: options.temperature,
|
|
338
|
-
maxAttempts: options.maxAttempts,
|
|
339
|
-
audit: options.audit !== false,
|
|
340
|
-
});
|
|
341
|
-
console.log(`\n📊 Compilation Summary:`);
|
|
342
|
-
console.log(` Compiled: ${result.compiled}`);
|
|
343
|
-
console.log(` Skipped: ${result.skipped}`);
|
|
344
|
-
console.log(` Failed: ${result.failed}`);
|
|
345
231
|
}
|
|
346
232
|
catch (error) {
|
|
347
233
|
console.error('❌ Error:', error.message);
|
|
@@ -353,173 +239,73 @@ program
|
|
|
353
239
|
// =============================================================================
|
|
354
240
|
program
|
|
355
241
|
.command('run [file] [args...]')
|
|
356
|
-
.description('Execute a
|
|
242
|
+
.description('Execute a DML file (one-shot)')
|
|
357
243
|
.option('--workspace <path>', 'Working directory for file operations', './')
|
|
244
|
+
.option('--backend <kind>', 'Model backend: pi (default) or env')
|
|
245
|
+
.option('--goal <dml>', 'Run this goal instead of agent_main/N')
|
|
358
246
|
.option('--verbose', 'Show debug output including tool calls')
|
|
359
|
-
.option('--stream', '
|
|
360
|
-
.option('--
|
|
247
|
+
.option('--no-stream', 'Hide streamed model text/reasoning (show only outputs and answers)')
|
|
248
|
+
.option('--show-reasoning <mode>', 'How much model reasoning to show: off|summary|full', (value) => {
|
|
249
|
+
if (value !== 'off' && value !== 'summary' && value !== 'full') {
|
|
250
|
+
throw new Error(`invalid --show-reasoning: ${value} (use off, summary, or full)`);
|
|
251
|
+
}
|
|
252
|
+
return value;
|
|
253
|
+
})
|
|
254
|
+
.option('--no-events', 'Hide task activity, tool calls, usage, and logs')
|
|
255
|
+
.option('--plain', 'No color/formatting')
|
|
256
|
+
.option('--json', 'Emit events as JSON lines')
|
|
361
257
|
.option('--sandbox', 'Run shell tools inside AgentVM instead of the local workspace shell')
|
|
362
258
|
.option('--trace <file>', 'Save execution trace to file')
|
|
363
259
|
.option('--dry-run', 'Show what would be executed without running')
|
|
364
|
-
.option('--model <model>', 'Override configured model (
|
|
260
|
+
.option('--model <model>', 'Override configured model (provider/model)')
|
|
365
261
|
.option('--provider <provider>', 'Override configured provider (openai, anthropic, google, openrouter)')
|
|
366
262
|
.option('--temperature <number>', 'Override temperature (0.0-2.0)', parseFloat)
|
|
367
|
-
.option('--no-audit', 'Disable the LLM security audit for one-shot prompt compilation')
|
|
368
263
|
.option('--gas-limit <number>', 'Maximum number of execution steps', parseInt)
|
|
369
264
|
.option('--usage <file>', 'Save token usage summary to file')
|
|
370
|
-
.option('-p, --prompt <text>', 'One-shot prompt: generate and run DML from natural language')
|
|
371
265
|
.option('-P, --param <key=value>', 'Pass named parameter (can be repeated)', collectParams, {})
|
|
372
266
|
.action(async (file, args, options) => {
|
|
373
267
|
try {
|
|
374
|
-
// Parse provider/model format if provided (e.g., "google/gemini-2.5-pro")
|
|
268
|
+
// Parse provider/model format if provided (e.g., "google/gemini-2.5-pro").
|
|
375
269
|
let model = options.model;
|
|
376
270
|
let provider = options.provider;
|
|
377
271
|
if (model && model.includes('/')) {
|
|
378
272
|
const [parsedProvider, ...modelParts] = model.split('/');
|
|
379
273
|
provider = provider || parsedProvider;
|
|
380
|
-
model = modelParts.join('/');
|
|
274
|
+
model = modelParts.join('/');
|
|
381
275
|
}
|
|
382
276
|
const result = await run(file, args, {
|
|
383
277
|
workspace: options.workspace,
|
|
278
|
+
backend: options.backend,
|
|
279
|
+
goal: options.goal,
|
|
384
280
|
verbose: options.verbose,
|
|
385
281
|
stream: options.stream,
|
|
386
|
-
|
|
282
|
+
events: options.events,
|
|
283
|
+
showReasoning: options.showReasoning,
|
|
284
|
+
plain: options.plain,
|
|
285
|
+
json: options.json,
|
|
387
286
|
sandbox: options.sandbox,
|
|
388
287
|
trace: options.trace,
|
|
389
288
|
dryRun: options.dryRun,
|
|
390
289
|
model,
|
|
391
290
|
provider: provider,
|
|
392
291
|
temperature: options.temperature,
|
|
393
|
-
audit: options.audit !== false,
|
|
394
292
|
gasLimit: options.gasLimit,
|
|
395
293
|
params: options.param,
|
|
396
|
-
prompt: options.prompt
|
|
397
294
|
});
|
|
398
295
|
if (options.dryRun) {
|
|
399
296
|
console.log(result.wouldExecute);
|
|
400
|
-
|
|
401
|
-
else {
|
|
402
|
-
// Show outputs only in headless mode (in interactive mode they were already shown)
|
|
403
|
-
if (options.headless && result.output.length > 0) {
|
|
404
|
-
for (const out of result.output) {
|
|
405
|
-
console.log(out);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
// Show answer
|
|
409
|
-
if (result.answer) {
|
|
410
|
-
if (result.output.length > 0) {
|
|
411
|
-
console.log(''); // Blank line before answer
|
|
412
|
-
}
|
|
413
|
-
console.log(result.answer);
|
|
414
|
-
}
|
|
415
|
-
// Show error
|
|
416
|
-
if (result.error) {
|
|
417
|
-
console.error('❌ Error:', result.error);
|
|
418
|
-
process.exit(1);
|
|
419
|
-
}
|
|
420
|
-
// Show trace location if saved
|
|
421
|
-
if (options.trace) {
|
|
422
|
-
console.log(`\n📊 Trace saved to: ${options.trace}`);
|
|
423
|
-
}
|
|
424
|
-
// Save usage data if requested
|
|
425
|
-
if (options.usage && result.usageByModel && Object.keys(result.usageByModel).length > 0) {
|
|
426
|
-
const usagePath = path.resolve(options.usage);
|
|
427
|
-
await fs.writeFile(usagePath, JSON.stringify(result.usageByModel, null, 2) + '\n', 'utf8');
|
|
428
|
-
if (options.verbose) {
|
|
429
|
-
console.log(`📊 Usage saved to: ${usagePath}`);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
catch (error) {
|
|
435
|
-
console.error('❌ Error:', error.message);
|
|
436
|
-
if (options.verbose) {
|
|
437
|
-
console.error(error.stack);
|
|
438
|
-
}
|
|
439
|
-
process.exit(1);
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
// =============================================================================
|
|
443
|
-
// Plan Command
|
|
444
|
-
// =============================================================================
|
|
445
|
-
program
|
|
446
|
-
.command('plan [file]')
|
|
447
|
-
.description('Generate a standalone DML plan from a Markdown specification (same as /plan in the TUI)')
|
|
448
|
-
.option('--workspace <path>', 'Working directory for file operations', './')
|
|
449
|
-
.option('--verbose', 'Show debug output including tool calls')
|
|
450
|
-
.option('--stream', 'Stream LLM responses in real-time')
|
|
451
|
-
.option('--headless', 'Plain output only, no TUI formatting')
|
|
452
|
-
.option('--sandbox', 'Run shell tools inside AgentVM instead of the local workspace shell')
|
|
453
|
-
.option('--model <model>', 'Override configured model (can be provider/model format, e.g., google/gemini-2.5-pro)')
|
|
454
|
-
.option('--provider <provider>', 'Override configured provider (openai, anthropic, google, openrouter)')
|
|
455
|
-
.option('--temperature <number>', 'Override temperature (0.0-2.0)', parseFloat)
|
|
456
|
-
.option('--gas-limit <number>', 'Maximum number of execution steps', parseInt)
|
|
457
|
-
.option('--usage <file>', 'Save token usage summary to file')
|
|
458
|
-
.action(async (file, options) => {
|
|
459
|
-
try {
|
|
460
|
-
const configRoot = path.resolve(options.workspace ?? './');
|
|
461
|
-
const { getSystemAssetSourcePaths } = await import('../system/assets/index.js');
|
|
462
|
-
const planDmlPath = getSystemAssetSourcePaths(configRoot).planDml;
|
|
463
|
-
let requestContent;
|
|
464
|
-
if (file) {
|
|
465
|
-
const filePath = path.resolve(configRoot, file);
|
|
466
|
-
try {
|
|
467
|
-
requestContent = await fs.readFile(filePath, 'utf8');
|
|
468
|
-
}
|
|
469
|
-
catch {
|
|
470
|
-
console.error(`❌ Cannot read file: ${filePath}`);
|
|
471
|
-
process.exit(1);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
else if (!process.stdin.isTTY) {
|
|
475
|
-
const chunks = [];
|
|
476
|
-
for await (const chunk of process.stdin) {
|
|
477
|
-
chunks.push(chunk);
|
|
478
|
-
}
|
|
479
|
-
requestContent = Buffer.concat(chunks).toString('utf8');
|
|
480
|
-
if (!requestContent.trim()) {
|
|
481
|
-
console.error('❌ No input provided. Usage: deepclause plan <file> or cat spec.md | deepclause plan');
|
|
482
|
-
process.exit(1);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
else {
|
|
486
|
-
console.error('❌ No input provided. Usage: deepclause plan <file> or cat spec.md | deepclause plan');
|
|
487
|
-
process.exit(1);
|
|
488
|
-
}
|
|
489
|
-
let model = options.model;
|
|
490
|
-
let provider = options.provider;
|
|
491
|
-
if (model && model.includes('/')) {
|
|
492
|
-
const [parsedProvider, ...modelParts] = model.split('/');
|
|
493
|
-
provider = provider || parsedProvider;
|
|
494
|
-
model = modelParts.join('/');
|
|
495
|
-
}
|
|
496
|
-
const result = await run(planDmlPath, [requestContent], {
|
|
497
|
-
configRoot,
|
|
498
|
-
workspace: options.workspace,
|
|
499
|
-
verbose: options.verbose,
|
|
500
|
-
stream: options.stream,
|
|
501
|
-
headless: options.headless ?? true,
|
|
502
|
-
sandbox: options.sandbox,
|
|
503
|
-
model,
|
|
504
|
-
provider: provider,
|
|
505
|
-
temperature: options.temperature,
|
|
506
|
-
gasLimit: options.gasLimit,
|
|
507
|
-
});
|
|
508
|
-
if (options.headless !== false && result.output.length > 0) {
|
|
509
|
-
for (const out of result.output) {
|
|
510
|
-
console.log(out);
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
if (result.answer) {
|
|
514
|
-
if (result.output.length > 0) {
|
|
515
|
-
console.log('');
|
|
516
|
-
}
|
|
517
|
-
console.log(result.answer);
|
|
297
|
+
return;
|
|
518
298
|
}
|
|
519
299
|
if (result.error) {
|
|
520
300
|
console.error('❌ Error:', result.error);
|
|
521
301
|
process.exit(1);
|
|
522
302
|
}
|
|
303
|
+
if (options.trace && result.trace) {
|
|
304
|
+
console.log(`\n📊 Trace saved to: ${options.trace}`);
|
|
305
|
+
}
|
|
306
|
+
else if (options.trace) {
|
|
307
|
+
console.log('\n(no execution trace was produced for this run)');
|
|
308
|
+
}
|
|
523
309
|
if (options.usage && result.usageByModel && Object.keys(result.usageByModel).length > 0) {
|
|
524
310
|
const usagePath = path.resolve(options.usage);
|
|
525
311
|
await fs.writeFile(usagePath, JSON.stringify(result.usageByModel, null, 2) + '\n', 'utf8');
|
|
@@ -537,96 +323,12 @@ program
|
|
|
537
323
|
}
|
|
538
324
|
});
|
|
539
325
|
// =============================================================================
|
|
540
|
-
//
|
|
326
|
+
// REPL Command
|
|
541
327
|
// =============================================================================
|
|
542
|
-
program
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
.action(async (options) => {
|
|
547
|
-
try {
|
|
548
|
-
const tools = await listTools(process.cwd(), { json: options.json });
|
|
549
|
-
if (options.json) {
|
|
550
|
-
console.log(tools);
|
|
551
|
-
}
|
|
552
|
-
else {
|
|
553
|
-
console.log('Available Tools:\n');
|
|
554
|
-
console.log(tools);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
catch (error) {
|
|
558
|
-
console.error('❌ Error:', error.message);
|
|
559
|
-
process.exit(1);
|
|
560
|
-
}
|
|
561
|
-
});
|
|
562
|
-
program
|
|
563
|
-
.command('list-commands')
|
|
564
|
-
.description('List all compiled DML commands')
|
|
565
|
-
.option('--json', 'Output as JSON')
|
|
566
|
-
.option('--detailed', 'Show parameters and tool dependencies')
|
|
567
|
-
.action(async (options) => {
|
|
568
|
-
try {
|
|
569
|
-
const commands = await listCommands(process.cwd(), {
|
|
570
|
-
json: options.json,
|
|
571
|
-
detailed: options.detailed
|
|
572
|
-
});
|
|
573
|
-
if (options.json) {
|
|
574
|
-
console.log(JSON.stringify(commands, null, 2));
|
|
575
|
-
}
|
|
576
|
-
else {
|
|
577
|
-
console.log('Compiled Commands:\n');
|
|
578
|
-
for (const cmd of commands) {
|
|
579
|
-
const label = cmd.displayName && cmd.displayName !== cmd.name
|
|
580
|
-
? `${cmd.displayName} (${cmd.name})`
|
|
581
|
-
: cmd.name;
|
|
582
|
-
console.log(`📋 ${label}`);
|
|
583
|
-
console.log(` ${cmd.description}`);
|
|
584
|
-
console.log(` Usage: ${cmd.usage}`);
|
|
585
|
-
if (options.detailed) {
|
|
586
|
-
if (cmd.triggerPhrases?.length) {
|
|
587
|
-
console.log(' Trigger Phrases:');
|
|
588
|
-
for (const phrase of cmd.triggerPhrases) {
|
|
589
|
-
console.log(` • ${phrase}`);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
if (cmd.parameters?.length) {
|
|
593
|
-
console.log(' Arguments:');
|
|
594
|
-
for (const p of cmd.parameters) {
|
|
595
|
-
const status = p.required === false
|
|
596
|
-
? (p.default !== undefined ? `optional, default: ${p.default}` : 'optional')
|
|
597
|
-
: 'required';
|
|
598
|
-
const description = p.description ? ` - ${p.description}` : '';
|
|
599
|
-
console.log(` • ${p.name} (${status})${description}`);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
if (cmd.capabilities?.length) {
|
|
603
|
-
console.log(' Capabilities:');
|
|
604
|
-
for (const capability of cmd.capabilities) {
|
|
605
|
-
console.log(` • ${capability}`);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
if (cmd.tools?.length) {
|
|
609
|
-
console.log(' Tool Dependencies:');
|
|
610
|
-
for (const t of cmd.tools) {
|
|
611
|
-
console.log(` • ${t}`);
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
if (cmd.model) {
|
|
615
|
-
console.log(` Model: ${cmd.model}`);
|
|
616
|
-
}
|
|
617
|
-
if (cmd.compiledAt) {
|
|
618
|
-
console.log(` Compiled: ${cmd.compiledAt}`);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
console.log('');
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
catch (error) {
|
|
626
|
-
console.error('❌ Error:', error.message);
|
|
627
|
-
process.exit(1);
|
|
628
|
-
}
|
|
629
|
-
});
|
|
328
|
+
registerReplCommand(program);
|
|
329
|
+
registerVisualizeCommand(program);
|
|
330
|
+
registerSetBackendCommand(program);
|
|
331
|
+
registerLoginCommands(program);
|
|
630
332
|
// =============================================================================
|
|
631
333
|
// Helper Functions
|
|
632
334
|
// =============================================================================
|
|
@@ -639,45 +341,17 @@ function collectParams(value, previous) {
|
|
|
639
341
|
}
|
|
640
342
|
async function main() {
|
|
641
343
|
const argv = process.argv.slice(2);
|
|
642
|
-
const rootPrompt = readRootPrompt(argv);
|
|
643
|
-
const rootSandbox = hasRootSandbox(argv);
|
|
644
344
|
if (requiresInitializedWorkspace(argv) && !await deepClauseDirExists(process.cwd())) {
|
|
645
345
|
console.warn('⚠️ No .deepclause directory found in this workspace.');
|
|
646
346
|
console.warn(" Run 'deepclause init' first.");
|
|
647
347
|
process.exit(1);
|
|
648
348
|
}
|
|
649
|
-
if (rootPrompt && !hasSubcommand(argv)) {
|
|
650
|
-
await runPromptHeadless(rootPrompt, process.cwd(), { sandbox: rootSandbox });
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
349
|
if (argv.length === 0) {
|
|
654
|
-
|
|
655
|
-
return;
|
|
656
|
-
}
|
|
657
|
-
if (argv.length === 1 && rootSandbox) {
|
|
658
|
-
await startTui(process.cwd(), { sandbox: true });
|
|
350
|
+
program.help();
|
|
659
351
|
return;
|
|
660
352
|
}
|
|
661
353
|
await program.parseAsync(process.argv);
|
|
662
354
|
}
|
|
663
|
-
function hasSubcommand(argv) {
|
|
664
|
-
return argv.some((arg) => !arg.startsWith('-') && CLI_SUBCOMMANDS.has(arg));
|
|
665
|
-
}
|
|
666
|
-
function readRootPrompt(argv) {
|
|
667
|
-
for (let index = 0; index < argv.length; index++) {
|
|
668
|
-
const arg = argv[index];
|
|
669
|
-
if (arg === '-p' || arg === '--prompt') {
|
|
670
|
-
return argv[index + 1];
|
|
671
|
-
}
|
|
672
|
-
if (arg.startsWith('--prompt=')) {
|
|
673
|
-
return arg.slice('--prompt='.length);
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
return undefined;
|
|
677
|
-
}
|
|
678
|
-
function hasRootSandbox(argv) {
|
|
679
|
-
return argv.includes('--sandbox');
|
|
680
|
-
}
|
|
681
355
|
function requiresInitializedWorkspace(argv) {
|
|
682
356
|
if (argv.includes('-h') || argv.includes('--help') || argv.includes('-V') || argv.includes('--version')) {
|
|
683
357
|
return false;
|
|
@@ -686,7 +360,7 @@ function requiresInitializedWorkspace(argv) {
|
|
|
686
360
|
if (!firstPositional) {
|
|
687
361
|
return true;
|
|
688
362
|
}
|
|
689
|
-
return firstPositional !== 'init' && firstPositional !== 'help';
|
|
363
|
+
return firstPositional !== 'init' && firstPositional !== 'help' && firstPositional !== 'repl';
|
|
690
364
|
}
|
|
691
365
|
main().catch((error) => {
|
|
692
366
|
console.error('❌ Error:', error.message);
|