deepclause-sdk 0.0.89 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +417 -948
- package/dist/agent.d.ts +18 -2
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +74 -21
- package/dist/agent.js.map +1 -1
- package/dist/cli/config.d.ts +323 -176
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +146 -188
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/index.d.ts +3 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +61 -425
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/login.d.ts +29 -0
- package/dist/cli/login.d.ts.map +1 -0
- package/dist/cli/login.js +184 -0
- package/dist/cli/login.js.map +1 -0
- package/dist/cli/readline.d.ts +6 -0
- package/dist/cli/readline.d.ts.map +1 -0
- package/dist/cli/readline.js +15 -0
- package/dist/cli/readline.js.map +1 -0
- package/dist/cli/repl-bin.d.ts +9 -0
- package/dist/cli/repl-bin.d.ts.map +1 -0
- package/dist/cli/repl-bin.js +16 -0
- package/dist/cli/repl-bin.js.map +1 -0
- package/dist/cli/repl.d.ts +191 -0
- package/dist/cli/repl.d.ts.map +1 -0
- package/dist/cli/repl.js +1232 -0
- package/dist/cli/repl.js.map +1 -0
- package/dist/cli/run.d.ts +17 -18
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +196 -183
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/set-backend.d.ts +53 -0
- package/dist/cli/set-backend.d.ts.map +1 -0
- package/dist/cli/set-backend.js +259 -0
- package/dist/cli/set-backend.js.map +1 -0
- package/dist/cli/visualize.d.ts +38 -0
- package/dist/cli/visualize.d.ts.map +1 -0
- package/dist/cli/visualize.js +125 -0
- package/dist/cli/visualize.js.map +1 -0
- package/dist/compiler.d.ts +5 -52
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +4 -768
- package/dist/compiler.js.map +1 -1
- package/dist/index.d.ts +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 +3 -1
- package/dist/prolog/bridge.d.ts.map +1 -1
- package/dist/prolog/bridge.js +8 -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 +2245 -41
- package/dist/repl/agent.d.ts +72 -0
- package/dist/repl/agent.d.ts.map +1 -0
- package/dist/repl/agent.js +366 -0
- package/dist/repl/agent.js.map +1 -0
- package/dist/repl/auth.d.ts +45 -0
- package/dist/repl/auth.d.ts.map +1 -0
- package/dist/repl/auth.js +116 -0
- package/dist/repl/auth.js.map +1 -0
- package/dist/repl/backend.d.ts +290 -0
- package/dist/repl/backend.d.ts.map +1 -0
- package/dist/repl/backend.js +370 -0
- package/dist/repl/backend.js.map +1 -0
- package/dist/repl/compaction.d.ts +122 -0
- package/dist/repl/compaction.d.ts.map +1 -0
- package/dist/repl/compaction.js +318 -0
- package/dist/repl/compaction.js.map +1 -0
- package/dist/repl/export.d.ts +30 -0
- package/dist/repl/export.d.ts.map +1 -0
- package/dist/repl/export.js +23 -0
- package/dist/repl/export.js.map +1 -0
- package/dist/repl/frames.d.ts +21 -0
- package/dist/repl/frames.d.ts.map +1 -0
- package/dist/repl/frames.js +79 -0
- package/dist/repl/frames.js.map +1 -0
- package/dist/repl/harness-tools.d.ts +74 -0
- package/dist/repl/harness-tools.d.ts.map +1 -0
- package/dist/repl/harness-tools.js +121 -0
- package/dist/repl/harness-tools.js.map +1 -0
- package/dist/repl/highlight.d.ts +30 -0
- package/dist/repl/highlight.d.ts.map +1 -0
- package/dist/repl/highlight.js +285 -0
- package/dist/repl/highlight.js.map +1 -0
- package/dist/repl/history.d.ts +234 -0
- package/dist/repl/history.d.ts.map +1 -0
- package/dist/repl/history.js +661 -0
- package/dist/repl/history.js.map +1 -0
- package/dist/repl/index.d.ts +120 -0
- package/dist/repl/index.d.ts.map +1 -0
- package/dist/repl/index.js +107 -0
- package/dist/repl/index.js.map +1 -0
- package/dist/repl/judge.d.ts +51 -0
- package/dist/repl/judge.d.ts.map +1 -0
- package/dist/repl/judge.js +58 -0
- package/dist/repl/judge.js.map +1 -0
- package/dist/repl/markdown.d.ts +25 -0
- package/dist/repl/markdown.d.ts.map +1 -0
- package/dist/repl/markdown.js +103 -0
- package/dist/repl/markdown.js.map +1 -0
- package/dist/repl/picker.d.ts +34 -0
- package/dist/repl/picker.d.ts.map +1 -0
- package/dist/repl/picker.js +81 -0
- package/dist/repl/picker.js.map +1 -0
- package/dist/repl/project-context.d.ts +16 -0
- package/dist/repl/project-context.d.ts.map +1 -0
- package/dist/repl/project-context.js +23 -0
- package/dist/repl/project-context.js.map +1 -0
- package/dist/repl/render.d.ts +160 -0
- package/dist/repl/render.d.ts.map +1 -0
- package/dist/repl/render.js +715 -0
- package/dist/repl/render.js.map +1 -0
- package/dist/repl/session.d.ts +356 -0
- package/dist/repl/session.d.ts.map +1 -0
- package/dist/repl/session.js +1275 -0
- package/dist/repl/session.js.map +1 -0
- package/dist/repl/status.d.ts +100 -0
- package/dist/repl/status.d.ts.map +1 -0
- package/dist/repl/status.js +218 -0
- package/dist/repl/status.js.map +1 -0
- package/dist/repl/tools.d.ts +53 -0
- package/dist/repl/tools.d.ts.map +1 -0
- package/dist/repl/tools.js +307 -0
- package/dist/repl/tools.js.map +1 -0
- package/dist/repl/toolset.d.ts +32 -0
- package/dist/repl/toolset.d.ts.map +1 -0
- package/dist/repl/toolset.js +82 -0
- package/dist/repl/toolset.js.map +1 -0
- package/dist/repl/tui/editor.d.ts +17 -0
- package/dist/repl/tui/editor.d.ts.map +1 -0
- package/dist/repl/tui/editor.js +39 -0
- package/dist/repl/tui/editor.js.map +1 -0
- package/dist/repl/tui/status-bar.d.ts +26 -0
- package/dist/repl/tui/status-bar.d.ts.map +1 -0
- package/dist/repl/tui/status-bar.js +47 -0
- package/dist/repl/tui/status-bar.js.map +1 -0
- package/dist/repl/tui/theme.d.ts +30 -0
- package/dist/repl/tui/theme.d.ts.map +1 -0
- package/dist/repl/tui/theme.js +81 -0
- package/dist/repl/tui/theme.js.map +1 -0
- package/dist/repl/tui/transcript.d.ts +39 -0
- package/dist/repl/tui/transcript.d.ts.map +1 -0
- package/dist/repl/tui/transcript.js +123 -0
- package/dist/repl/tui/transcript.js.map +1 -0
- package/dist/runner.d.ts +132 -13
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +434 -277
- 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 +1373 -0
- package/dist/system/assets/docs/DML_AUTHORING.md +195 -0
- package/dist/system/assets/docs/DML_REFERENCE.md +312 -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 +80 -118
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +19 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +338 -0
- package/dist/validate.js.map +1 -0
- package/dist/visualize/index.d.ts +52 -0
- package/dist/visualize/index.d.ts.map +1 -0
- package/dist/visualize/index.js +189 -0
- package/dist/visualize/index.js.map +1 -0
- package/package.json +17 -15
- package/src/prolog-src/deepclause_analysis.pl +10 -2
- package/src/prolog-src/deepclause_mi.pl +2245 -41
- 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) {
|
|
@@ -187,339 +197,77 @@ program
|
|
|
187
197
|
}
|
|
188
198
|
});
|
|
189
199
|
// =============================================================================
|
|
190
|
-
// Compilation Commands
|
|
191
|
-
// =============================================================================
|
|
192
|
-
program
|
|
193
|
-
.command('compile <source> [output]')
|
|
194
|
-
.description('Compile Markdown task description to DML')
|
|
195
|
-
.option('-f, --force', 'Force recompilation even if source unchanged')
|
|
196
|
-
.option('--validate-only', 'Validate without saving output')
|
|
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) => {
|
|
208
|
-
try {
|
|
209
|
-
const outputDir = output || '.deepclause/tools';
|
|
210
|
-
const liveOutput = [];
|
|
211
|
-
const onEvent = (event) => {
|
|
212
|
-
switch (event.type) {
|
|
213
|
-
case 'output':
|
|
214
|
-
if (event.content) {
|
|
215
|
-
liveOutput.push(event.content);
|
|
216
|
-
if (!options.headless) {
|
|
217
|
-
process.stdout.write(`${event.content}\n`);
|
|
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
|
-
}
|
|
278
|
-
}
|
|
279
|
-
if (result.skipped) {
|
|
280
|
-
console.log(`⏭️ Skipped (unchanged): ${source}`);
|
|
281
|
-
}
|
|
282
|
-
else {
|
|
283
|
-
console.log('\n✅ Compilation successful!\n');
|
|
284
|
-
if (result.explanation) {
|
|
285
|
-
console.log(result.explanation);
|
|
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}`);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
if (!result.skipped && options.trace) {
|
|
296
|
-
console.log(`\n📊 Trace saved to: ${options.trace}`);
|
|
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);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
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
|
-
}
|
|
346
|
-
catch (error) {
|
|
347
|
-
console.error('❌ Error:', error.message);
|
|
348
|
-
process.exit(1);
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
// =============================================================================
|
|
352
200
|
// Execution Commands
|
|
353
201
|
// =============================================================================
|
|
354
202
|
program
|
|
355
203
|
.command('run [file] [args...]')
|
|
356
|
-
.description('Execute a
|
|
204
|
+
.description('Execute a DML file (one-shot)')
|
|
357
205
|
.option('--workspace <path>', 'Working directory for file operations', './')
|
|
206
|
+
.option('--backend <kind>', 'Model backend: pi (default) or env')
|
|
207
|
+
.option('--goal <dml>', 'Run this goal instead of agent_main/N')
|
|
358
208
|
.option('--verbose', 'Show debug output including tool calls')
|
|
359
|
-
.option('--stream', '
|
|
360
|
-
.option('--
|
|
209
|
+
.option('--no-stream', 'Hide streamed model text/reasoning (show only outputs and answers)')
|
|
210
|
+
.option('--show-reasoning <mode>', 'How much model reasoning to show: off|summary|full', (value) => {
|
|
211
|
+
if (value !== 'off' && value !== 'summary' && value !== 'full') {
|
|
212
|
+
throw new Error(`invalid --show-reasoning: ${value} (use off, summary, or full)`);
|
|
213
|
+
}
|
|
214
|
+
return value;
|
|
215
|
+
})
|
|
216
|
+
.option('--no-events', 'Hide task activity, tool calls, usage, and logs')
|
|
217
|
+
.option('--plain', 'No color/formatting')
|
|
218
|
+
.option('--json', 'Emit events as JSON lines')
|
|
361
219
|
.option('--sandbox', 'Run shell tools inside AgentVM instead of the local workspace shell')
|
|
362
220
|
.option('--trace <file>', 'Save execution trace to file')
|
|
363
221
|
.option('--dry-run', 'Show what would be executed without running')
|
|
364
|
-
.option('--model <model>', 'Override configured model (
|
|
222
|
+
.option('--model <model>', 'Override configured model (provider/model)')
|
|
365
223
|
.option('--provider <provider>', 'Override configured provider (openai, anthropic, google, openrouter)')
|
|
366
224
|
.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
225
|
.option('--gas-limit <number>', 'Maximum number of execution steps', parseInt)
|
|
369
226
|
.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
227
|
.option('-P, --param <key=value>', 'Pass named parameter (can be repeated)', collectParams, {})
|
|
372
228
|
.action(async (file, args, options) => {
|
|
373
229
|
try {
|
|
374
|
-
// Parse provider/model format if provided (e.g., "google/gemini-2.5-pro")
|
|
230
|
+
// Parse provider/model format if provided (e.g., "google/gemini-2.5-pro").
|
|
375
231
|
let model = options.model;
|
|
376
232
|
let provider = options.provider;
|
|
377
233
|
if (model && model.includes('/')) {
|
|
378
234
|
const [parsedProvider, ...modelParts] = model.split('/');
|
|
379
235
|
provider = provider || parsedProvider;
|
|
380
|
-
model = modelParts.join('/');
|
|
236
|
+
model = modelParts.join('/');
|
|
381
237
|
}
|
|
382
238
|
const result = await run(file, args, {
|
|
383
239
|
workspace: options.workspace,
|
|
240
|
+
backend: options.backend,
|
|
241
|
+
goal: options.goal,
|
|
384
242
|
verbose: options.verbose,
|
|
385
243
|
stream: options.stream,
|
|
386
|
-
|
|
244
|
+
events: options.events,
|
|
245
|
+
showReasoning: options.showReasoning,
|
|
246
|
+
plain: options.plain,
|
|
247
|
+
json: options.json,
|
|
387
248
|
sandbox: options.sandbox,
|
|
388
249
|
trace: options.trace,
|
|
389
250
|
dryRun: options.dryRun,
|
|
390
251
|
model,
|
|
391
252
|
provider: provider,
|
|
392
253
|
temperature: options.temperature,
|
|
393
|
-
audit: options.audit !== false,
|
|
394
254
|
gasLimit: options.gasLimit,
|
|
395
255
|
params: options.param,
|
|
396
|
-
prompt: options.prompt
|
|
397
256
|
});
|
|
398
257
|
if (options.dryRun) {
|
|
399
258
|
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);
|
|
259
|
+
return;
|
|
518
260
|
}
|
|
519
261
|
if (result.error) {
|
|
520
262
|
console.error('❌ Error:', result.error);
|
|
521
263
|
process.exit(1);
|
|
522
264
|
}
|
|
265
|
+
if (options.trace && result.trace) {
|
|
266
|
+
console.log(`\n📊 Trace saved to: ${options.trace}`);
|
|
267
|
+
}
|
|
268
|
+
else if (options.trace) {
|
|
269
|
+
console.log('\n(no execution trace was produced for this run)');
|
|
270
|
+
}
|
|
523
271
|
if (options.usage && result.usageByModel && Object.keys(result.usageByModel).length > 0) {
|
|
524
272
|
const usagePath = path.resolve(options.usage);
|
|
525
273
|
await fs.writeFile(usagePath, JSON.stringify(result.usageByModel, null, 2) + '\n', 'utf8');
|
|
@@ -537,96 +285,12 @@ program
|
|
|
537
285
|
}
|
|
538
286
|
});
|
|
539
287
|
// =============================================================================
|
|
540
|
-
//
|
|
288
|
+
// REPL Command
|
|
541
289
|
// =============================================================================
|
|
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
|
-
});
|
|
290
|
+
registerReplCommand(program);
|
|
291
|
+
registerVisualizeCommand(program);
|
|
292
|
+
registerSetBackendCommand(program);
|
|
293
|
+
registerLoginCommands(program);
|
|
630
294
|
// =============================================================================
|
|
631
295
|
// Helper Functions
|
|
632
296
|
// =============================================================================
|
|
@@ -639,45 +303,17 @@ function collectParams(value, previous) {
|
|
|
639
303
|
}
|
|
640
304
|
async function main() {
|
|
641
305
|
const argv = process.argv.slice(2);
|
|
642
|
-
const rootPrompt = readRootPrompt(argv);
|
|
643
|
-
const rootSandbox = hasRootSandbox(argv);
|
|
644
306
|
if (requiresInitializedWorkspace(argv) && !await deepClauseDirExists(process.cwd())) {
|
|
645
307
|
console.warn('⚠️ No .deepclause directory found in this workspace.');
|
|
646
308
|
console.warn(" Run 'deepclause init' first.");
|
|
647
309
|
process.exit(1);
|
|
648
310
|
}
|
|
649
|
-
if (rootPrompt && !hasSubcommand(argv)) {
|
|
650
|
-
await runPromptHeadless(rootPrompt, process.cwd(), { sandbox: rootSandbox });
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
311
|
if (argv.length === 0) {
|
|
654
|
-
|
|
655
|
-
return;
|
|
656
|
-
}
|
|
657
|
-
if (argv.length === 1 && rootSandbox) {
|
|
658
|
-
await startTui(process.cwd(), { sandbox: true });
|
|
312
|
+
program.help();
|
|
659
313
|
return;
|
|
660
314
|
}
|
|
661
315
|
await program.parseAsync(process.argv);
|
|
662
316
|
}
|
|
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
317
|
function requiresInitializedWorkspace(argv) {
|
|
682
318
|
if (argv.includes('-h') || argv.includes('--help') || argv.includes('-V') || argv.includes('--version')) {
|
|
683
319
|
return false;
|
|
@@ -686,7 +322,7 @@ function requiresInitializedWorkspace(argv) {
|
|
|
686
322
|
if (!firstPositional) {
|
|
687
323
|
return true;
|
|
688
324
|
}
|
|
689
|
-
return firstPositional !== 'init' && firstPositional !== 'help';
|
|
325
|
+
return firstPositional !== 'init' && firstPositional !== 'help' && firstPositional !== 'repl';
|
|
690
326
|
}
|
|
691
327
|
main().catch((error) => {
|
|
692
328
|
console.error('❌ Error:', error.message);
|