@calliopelabs/cli 0.8.20 → 2.0.2
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/agents/agent-config-loader.d.ts +60 -0
- package/dist/agents/agent-config-loader.d.ts.map +1 -0
- package/dist/agents/agent-config-loader.js +402 -0
- package/dist/agents/agent-config-loader.js.map +1 -0
- package/dist/agents/agent-config-presets.d.ts +10 -0
- package/dist/agents/agent-config-presets.d.ts.map +1 -0
- package/dist/agents/agent-config-presets.js +940 -0
- package/dist/agents/agent-config-presets.js.map +1 -0
- package/dist/agents/agent-config-types.d.ts +145 -0
- package/dist/agents/agent-config-types.d.ts.map +1 -0
- package/dist/agents/agent-config-types.js +12 -0
- package/dist/agents/agent-config-types.js.map +1 -0
- package/dist/{agterm → agents}/agent-detection.d.ts +1 -1
- package/dist/{agterm → agents}/agent-detection.d.ts.map +1 -1
- package/dist/{agterm → agents}/agent-detection.js +21 -5
- package/dist/agents/agent-detection.js.map +1 -0
- package/dist/agents/aggregator.d.ts +19 -0
- package/dist/agents/aggregator.d.ts.map +1 -0
- package/dist/agents/aggregator.js +141 -0
- package/dist/agents/aggregator.js.map +1 -0
- package/dist/{agterm → agents}/cli-backend.d.ts +1 -1
- package/dist/{agterm → agents}/cli-backend.d.ts.map +1 -1
- package/dist/{agterm → agents}/cli-backend.js +90 -12
- package/dist/agents/cli-backend.js.map +1 -0
- package/dist/agents/council-types.d.ts +113 -0
- package/dist/agents/council-types.d.ts.map +1 -0
- package/dist/agents/council-types.js +81 -0
- package/dist/agents/council-types.js.map +1 -0
- package/dist/agents/council.d.ts +107 -0
- package/dist/agents/council.d.ts.map +1 -0
- package/dist/agents/council.js +586 -0
- package/dist/agents/council.js.map +1 -0
- package/dist/agents/decomposer.d.ts +33 -0
- package/dist/agents/decomposer.d.ts.map +1 -0
- package/dist/agents/decomposer.js +138 -0
- package/dist/agents/decomposer.js.map +1 -0
- package/dist/agents/dynamic-tools.d.ts +52 -0
- package/dist/agents/dynamic-tools.d.ts.map +1 -0
- package/dist/agents/dynamic-tools.js +395 -0
- package/dist/agents/dynamic-tools.js.map +1 -0
- package/dist/agents/index.d.ts +29 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +29 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/installer.d.ts +39 -0
- package/dist/agents/installer.d.ts.map +1 -0
- package/dist/agents/installer.js +205 -0
- package/dist/agents/installer.js.map +1 -0
- package/dist/{agterm → agents}/orchestrator.d.ts +7 -2
- package/dist/agents/orchestrator.d.ts.map +1 -0
- package/dist/{agterm → agents}/orchestrator.js +22 -2
- package/dist/agents/orchestrator.js.map +1 -0
- package/dist/agents/sdk-backend.d.ts +63 -0
- package/dist/agents/sdk-backend.d.ts.map +1 -0
- package/dist/agents/sdk-backend.js +489 -0
- package/dist/agents/sdk-backend.js.map +1 -0
- package/dist/agents/swarm-types.d.ts +83 -0
- package/dist/agents/swarm-types.d.ts.map +1 -0
- package/dist/agents/swarm-types.js +20 -0
- package/dist/agents/swarm-types.js.map +1 -0
- package/dist/agents/swarm.d.ts +74 -0
- package/dist/agents/swarm.d.ts.map +1 -0
- package/dist/agents/swarm.js +307 -0
- package/dist/agents/swarm.js.map +1 -0
- package/dist/{agterm → agents}/tools.d.ts +7 -5
- package/dist/agents/tools.d.ts.map +1 -0
- package/dist/agents/tools.js +776 -0
- package/dist/agents/tools.js.map +1 -0
- package/dist/{agterm → agents}/types.d.ts +14 -2
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/{agterm → agents}/types.js +2 -2
- package/dist/agents/types.js.map +1 -0
- package/dist/api-server.d.ts +26 -0
- package/dist/api-server.d.ts.map +1 -0
- package/dist/api-server.js +230 -0
- package/dist/api-server.js.map +1 -0
- package/dist/auto-checkpoint.d.ts +35 -0
- package/dist/auto-checkpoint.d.ts.map +1 -0
- package/dist/auto-checkpoint.js +143 -0
- package/dist/auto-checkpoint.js.map +1 -0
- package/dist/auto-compressor.d.ts +44 -0
- package/dist/auto-compressor.d.ts.map +1 -0
- package/dist/auto-compressor.js +145 -0
- package/dist/auto-compressor.js.map +1 -0
- package/dist/background-jobs.d.ts +45 -0
- package/dist/background-jobs.d.ts.map +1 -0
- package/dist/background-jobs.js +122 -0
- package/dist/background-jobs.js.map +1 -0
- package/dist/bin.d.ts +6 -2
- package/dist/bin.d.ts.map +1 -1
- package/dist/bin.js +127 -24
- package/dist/bin.js.map +1 -1
- package/dist/checkpoint.d.ts +49 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +219 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/circuit-breaker/breaker.d.ts +80 -0
- package/dist/circuit-breaker/breaker.d.ts.map +1 -0
- package/dist/circuit-breaker/breaker.js +408 -0
- package/dist/circuit-breaker/breaker.js.map +1 -0
- package/dist/circuit-breaker/defaults.d.ts +8 -0
- package/dist/circuit-breaker/defaults.d.ts.map +1 -0
- package/dist/circuit-breaker/defaults.js +35 -0
- package/dist/circuit-breaker/defaults.js.map +1 -0
- package/dist/circuit-breaker/index.d.ts +9 -0
- package/dist/circuit-breaker/index.d.ts.map +1 -0
- package/dist/circuit-breaker/index.js +8 -0
- package/dist/circuit-breaker/index.js.map +1 -0
- package/dist/circuit-breaker/types.d.ts +77 -0
- package/dist/circuit-breaker/types.d.ts.map +1 -0
- package/dist/circuit-breaker/types.js +8 -0
- package/dist/circuit-breaker/types.js.map +1 -0
- package/dist/circuit-breaker.d.ts +8 -0
- package/dist/circuit-breaker.d.ts.map +1 -0
- package/dist/circuit-breaker.js +7 -0
- package/dist/circuit-breaker.js.map +1 -0
- package/dist/cli/agent.d.ts +9 -0
- package/dist/cli/agent.d.ts.map +1 -0
- package/dist/cli/agent.js +262 -0
- package/dist/cli/agent.js.map +1 -0
- package/dist/cli/commands.d.ts +12 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/{cli.js → cli/commands.js} +285 -422
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +222 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/types.d.ts +30 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +20 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/companions.d.ts +54 -0
- package/dist/companions.d.ts.map +1 -0
- package/dist/companions.js +440 -0
- package/dist/companions.js.map +1 -0
- package/dist/config.d.ts +23 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +95 -22
- package/dist/config.js.map +1 -1
- package/dist/diff.d.ts +27 -0
- package/dist/diff.d.ts.map +1 -1
- package/dist/diff.js +415 -10
- package/dist/diff.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +20 -11
- package/dist/errors.js.map +1 -1
- package/dist/git-status.d.ts +23 -0
- package/dist/git-status.d.ts.map +1 -0
- package/dist/git-status.js +92 -0
- package/dist/git-status.js.map +1 -0
- package/dist/headless.d.ts +25 -0
- package/dist/headless.d.ts.map +1 -0
- package/dist/headless.js +182 -0
- package/dist/headless.js.map +1 -0
- package/dist/hud/api.d.ts +35 -0
- package/dist/hud/api.d.ts.map +1 -0
- package/dist/hud/api.js +448 -0
- package/dist/hud/api.js.map +1 -0
- package/dist/hud/palettes.d.ts +9 -0
- package/dist/hud/palettes.d.ts.map +1 -0
- package/dist/hud/palettes.js +280 -0
- package/dist/hud/palettes.js.map +1 -0
- package/dist/hud/skins.d.ts +12 -0
- package/dist/hud/skins.d.ts.map +1 -0
- package/dist/hud/skins.js +365 -0
- package/dist/hud/skins.js.map +1 -0
- package/dist/hud/theme-packs/api.d.ts +51 -0
- package/dist/hud/theme-packs/api.d.ts.map +1 -0
- package/dist/hud/theme-packs/api.js +145 -0
- package/dist/hud/theme-packs/api.js.map +1 -0
- package/dist/hud/theme-packs/index.d.ts +18 -0
- package/dist/hud/theme-packs/index.d.ts.map +1 -0
- package/dist/hud/theme-packs/index.js +38 -0
- package/dist/hud/theme-packs/index.js.map +1 -0
- package/dist/hud/theme-packs/types.d.ts +29 -0
- package/dist/hud/theme-packs/types.d.ts.map +1 -0
- package/dist/hud/theme-packs/types.js +9 -0
- package/dist/hud/theme-packs/types.js.map +1 -0
- package/dist/hud/types.d.ts +182 -0
- package/dist/hud/types.d.ts.map +1 -0
- package/dist/hud/types.js +7 -0
- package/dist/hud/types.js.map +1 -0
- package/dist/idle-eviction.d.ts +34 -0
- package/dist/idle-eviction.d.ts.map +1 -0
- package/dist/idle-eviction.js +78 -0
- package/dist/idle-eviction.js.map +1 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/iteration-ledger.d.ts +105 -0
- package/dist/iteration-ledger.d.ts.map +1 -0
- package/dist/iteration-ledger.js +237 -0
- package/dist/iteration-ledger.js.map +1 -0
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +1 -27
- package/dist/markdown.js.map +1 -1
- package/dist/mcp.d.ts +35 -0
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +291 -7
- package/dist/mcp.js.map +1 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +12 -2
- package/dist/memory.js.map +1 -1
- package/dist/model-detection.d.ts +5 -0
- package/dist/model-detection.d.ts.map +1 -1
- package/dist/model-detection.js +278 -10
- package/dist/model-detection.js.map +1 -1
- package/dist/model-router.d.ts.map +1 -1
- package/dist/model-router.js +33 -11
- package/dist/model-router.js.map +1 -1
- package/dist/plugins.d.ts +8 -0
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +97 -6
- package/dist/plugins.js.map +1 -1
- package/dist/providers/anthropic.d.ts +10 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +221 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/bedrock.d.ts +17 -0
- package/dist/providers/bedrock.d.ts.map +1 -0
- package/dist/providers/bedrock.js +574 -0
- package/dist/providers/bedrock.js.map +1 -0
- package/dist/providers/compat.d.ts +13 -0
- package/dist/providers/compat.d.ts.map +1 -0
- package/dist/providers/compat.js +202 -0
- package/dist/providers/compat.js.map +1 -0
- package/dist/providers/google.d.ts +10 -0
- package/dist/providers/google.d.ts.map +1 -0
- package/dist/providers/google.js +203 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/index.d.ts +23 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +145 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/ollama.d.ts +17 -0
- package/dist/providers/ollama.d.ts.map +1 -0
- package/dist/providers/ollama.js +289 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openai.d.ts +121 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +485 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/types.d.ts +63 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +164 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/sandbox-native.d.ts +59 -0
- package/dist/sandbox-native.d.ts.map +1 -0
- package/dist/sandbox-native.js +292 -0
- package/dist/sandbox-native.js.map +1 -0
- package/dist/sandbox.d.ts +2 -2
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +59 -13
- package/dist/sandbox.js.map +1 -1
- package/dist/scope.d.ts +3 -1
- package/dist/scope.d.ts.map +1 -1
- package/dist/scope.js +13 -1
- package/dist/scope.js.map +1 -1
- package/dist/session-timeout.d.ts +31 -0
- package/dist/session-timeout.d.ts.map +1 -0
- package/dist/session-timeout.js +100 -0
- package/dist/session-timeout.js.map +1 -0
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +29 -17
- package/dist/setup.js.map +1 -1
- package/dist/smart-router.d.ts +73 -0
- package/dist/smart-router.d.ts.map +1 -0
- package/dist/smart-router.js +332 -0
- package/dist/smart-router.js.map +1 -0
- package/dist/storage.d.ts +19 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +164 -1
- package/dist/storage.js.map +1 -1
- package/dist/streaming.d.ts +4 -0
- package/dist/streaming.d.ts.map +1 -1
- package/dist/streaming.js +12 -0
- package/dist/streaming.js.map +1 -1
- package/dist/styles.d.ts +32 -0
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +91 -0
- package/dist/styles.js.map +1 -1
- package/dist/summarization.d.ts +1 -1
- package/dist/summarization.js +4 -4
- package/dist/summarization.js.map +1 -1
- package/dist/terminal-image.d.ts +115 -0
- package/dist/terminal-image.d.ts.map +1 -0
- package/dist/terminal-image.js +766 -0
- package/dist/terminal-image.js.map +1 -0
- package/dist/terminal-recording.d.ts +55 -0
- package/dist/terminal-recording.d.ts.map +1 -0
- package/dist/terminal-recording.js +182 -0
- package/dist/terminal-recording.js.map +1 -0
- package/dist/themes.d.ts +19 -35
- package/dist/themes.d.ts.map +1 -1
- package/dist/themes.js +101 -210
- package/dist/themes.js.map +1 -1
- package/dist/tmux.d.ts +35 -0
- package/dist/tmux.d.ts.map +1 -0
- package/dist/tmux.js +106 -0
- package/dist/tmux.js.map +1 -0
- package/dist/tools.d.ts +3 -3
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +587 -45
- package/dist/tools.js.map +1 -1
- package/dist/trust.d.ts +53 -0
- package/dist/trust.d.ts.map +1 -0
- package/dist/trust.js +154 -0
- package/dist/trust.js.map +1 -0
- package/dist/types.d.ts +7 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +70 -32
- package/dist/types.js.map +1 -1
- package/dist/ui/agent.d.ts +61 -0
- package/dist/ui/agent.d.ts.map +1 -0
- package/dist/ui/agent.js +768 -0
- package/dist/ui/agent.js.map +1 -0
- package/dist/ui/chat-input.d.ts +32 -0
- package/dist/ui/chat-input.d.ts.map +1 -0
- package/dist/ui/chat-input.js +355 -0
- package/dist/ui/chat-input.js.map +1 -0
- package/dist/ui/commands.d.ts +92 -0
- package/dist/ui/commands.d.ts.map +1 -0
- package/dist/ui/commands.js +3006 -0
- package/dist/ui/commands.js.map +1 -0
- package/dist/ui/completions.d.ts +22 -0
- package/dist/ui/completions.d.ts.map +1 -0
- package/dist/ui/completions.js +215 -0
- package/dist/ui/completions.js.map +1 -0
- package/dist/ui/components.d.ts +38 -0
- package/dist/ui/components.d.ts.map +1 -0
- package/dist/ui/components.js +422 -0
- package/dist/ui/components.js.map +1 -0
- package/dist/ui/context.d.ts +12 -0
- package/dist/ui/context.d.ts.map +1 -0
- package/dist/ui/context.js +102 -0
- package/dist/ui/context.js.map +1 -0
- package/dist/ui/error-boundary.d.ts +33 -0
- package/dist/ui/error-boundary.d.ts.map +1 -0
- package/dist/ui/error-boundary.js +94 -0
- package/dist/ui/error-boundary.js.map +1 -0
- package/dist/ui/frame.d.ts +13 -0
- package/dist/ui/frame.d.ts.map +1 -0
- package/dist/ui/frame.js +89 -0
- package/dist/ui/frame.js.map +1 -0
- package/dist/ui/index.d.ts +12 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +928 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/messages.d.ts +19 -0
- package/dist/ui/messages.d.ts.map +1 -0
- package/dist/ui/messages.js +181 -0
- package/dist/ui/messages.js.map +1 -0
- package/dist/ui/modals.d.ts +52 -0
- package/dist/ui/modals.d.ts.map +1 -0
- package/dist/ui/modals.js +204 -0
- package/dist/ui/modals.js.map +1 -0
- package/dist/ui/pack-picker.d.ts +12 -0
- package/dist/ui/pack-picker.d.ts.map +1 -0
- package/dist/ui/pack-picker.js +101 -0
- package/dist/ui/pack-picker.js.map +1 -0
- package/dist/ui/status-bar.d.ts +20 -0
- package/dist/ui/status-bar.d.ts.map +1 -0
- package/dist/ui/status-bar.js +41 -0
- package/dist/ui/status-bar.js.map +1 -0
- package/dist/ui/theme-picker.d.ts +24 -0
- package/dist/ui/theme-picker.d.ts.map +1 -0
- package/dist/ui/theme-picker.js +190 -0
- package/dist/ui/theme-picker.js.map +1 -0
- package/dist/ui/types.d.ts +62 -0
- package/dist/ui/types.d.ts.map +1 -0
- package/dist/ui/types.js +7 -0
- package/dist/ui/types.js.map +1 -0
- package/dist/version-check.d.ts.map +1 -1
- package/dist/version-check.js +1 -9
- package/dist/version-check.js.map +1 -1
- package/package.json +8 -3
- package/dist/agterm/agent-detection.js.map +0 -1
- package/dist/agterm/cli-backend.js.map +0 -1
- package/dist/agterm/index.d.ts +0 -12
- package/dist/agterm/index.d.ts.map +0 -1
- package/dist/agterm/index.js +0 -15
- package/dist/agterm/index.js.map +0 -1
- package/dist/agterm/orchestrator.d.ts.map +0 -1
- package/dist/agterm/orchestrator.js.map +0 -1
- package/dist/agterm/tools.d.ts.map +0 -1
- package/dist/agterm/tools.js +0 -278
- package/dist/agterm/tools.js.map +0 -1
- package/dist/agterm/types.d.ts.map +0 -1
- package/dist/agterm/types.js.map +0 -1
- package/dist/cli.d.ts +0 -14
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/providers.d.ts +0 -51
- package/dist/providers.d.ts.map +0 -1
- package/dist/providers.js +0 -1146
- package/dist/providers.js.map +0 -1
- package/dist/ui-cli.d.ts +0 -17
- package/dist/ui-cli.d.ts.map +0 -1
- package/dist/ui-cli.js +0 -3730
- package/dist/ui-cli.js.map +0 -1
|
@@ -1,210 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* CLI Command Handlers
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Slash command processing, help text, and upgrade flow.
|
|
5
5
|
*/
|
|
6
|
-
import * as readline from 'readline';
|
|
7
6
|
import * as path from 'path';
|
|
8
|
-
import * as config from '
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import * as
|
|
15
|
-
import * as
|
|
16
|
-
import * as
|
|
17
|
-
import * as
|
|
18
|
-
import * as
|
|
19
|
-
import * as
|
|
20
|
-
import * as
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
7
|
+
import * as config from '../config.js';
|
|
8
|
+
import { getAvailableProviders, selectProvider } from '../providers/index.js';
|
|
9
|
+
import { getSystemPrompt, DEFAULT_MODELS, MODE_CONFIG } from '../types.js';
|
|
10
|
+
import { getVersion, getLatestVersion, performUpgrade } from '../version-check.js';
|
|
11
|
+
import { selectModelInteractively } from '../model-detection.js';
|
|
12
|
+
import * as memory from '../memory.js';
|
|
13
|
+
import * as hooks from '../hooks.js';
|
|
14
|
+
import * as modelRouter from '../model-router.js';
|
|
15
|
+
import * as summarization from '../summarization.js';
|
|
16
|
+
import * as themes from '../themes.js';
|
|
17
|
+
import * as branching from '../branching.js';
|
|
18
|
+
import * as fuzzySearch from '../fuzzy-search.js';
|
|
19
|
+
import * as storage from '../storage.js';
|
|
20
|
+
import { addToScope, removeFromScope, getScopeSummary, getScopeDetails, resetScope } from '../scope.js';
|
|
21
|
+
import { color } from '../styles.js';
|
|
22
|
+
import { getCurrentSkin, getCurrentPalette, applySkin, applyPalette, listSkins, listPalettes } from '../hud/api.js';
|
|
23
|
+
import { getCurrentCompanion, applyCompanion, listCompanions, getMoodText } from '../companions.js';
|
|
24
|
+
import { applyThemePack, listThemePacks, getCurrentPack, getCompanionMode, setCompanionMode } from '../hud/theme-packs/api.js';
|
|
25
|
+
import { isDockerAvailable } from '../sandbox.js';
|
|
26
|
+
import { getSandboxStatus } from '../sandbox-native.js';
|
|
27
|
+
// Forward declaration — injected by index.ts to avoid circular imports
|
|
28
|
+
let _startLoop;
|
|
29
|
+
export function setStartLoop(fn) {
|
|
30
|
+
_startLoop = fn;
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
const c = {
|
|
32
|
-
reset: '\x1b[0m',
|
|
33
|
-
bold: '\x1b[1m',
|
|
34
|
-
dim: '\x1b[2m',
|
|
35
|
-
cyan: '\x1b[36m',
|
|
36
|
-
green: '\x1b[32m',
|
|
37
|
-
yellow: '\x1b[33m',
|
|
38
|
-
red: '\x1b[31m',
|
|
39
|
-
blue: '\x1b[34m',
|
|
40
|
-
magenta: '\x1b[35m',
|
|
41
|
-
brightCyan: '\x1b[96m',
|
|
42
|
-
};
|
|
43
|
-
function color(text, style) {
|
|
44
|
-
return `${c[style]}${text}${c.reset}`;
|
|
45
|
-
}
|
|
46
|
-
// Spinner frames
|
|
47
|
-
const SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
48
|
-
const BANNER = `
|
|
49
|
-
${color(' ██████╗ █████╗ ██╗ ██╗ ██╗ ██████╗ ██████╗ ███████╗', 'brightCyan')}
|
|
50
|
-
${color('██╔════╝██╔══██╗██║ ██║ ██║██╔═══██╗██╔══██╗██╔════╝', 'brightCyan')}
|
|
51
|
-
${color('██║ ███████║██║ ██║ ██║██║ ██║██████╔╝█████╗ ', 'cyan')}
|
|
52
|
-
${color('██║ ██╔══██║██║ ██║ ██║██║ ██║██╔═══╝ ██╔══╝ ', 'cyan')}
|
|
53
|
-
${color('╚██████╗██║ ██║███████╗███████╗██║╚██████╔╝██║ ███████╗', 'brightCyan')}
|
|
54
|
-
${color(' ╚═════╝╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚══════╝', 'cyan')}
|
|
55
|
-
|
|
56
|
-
${color('The Muse of Digital Eloquence', 'dim')}
|
|
57
|
-
`;
|
|
58
|
-
// Slash commands
|
|
59
|
-
const COMMANDS = [
|
|
60
|
-
'/help', '/h', '/provider', '/p', '/model', '/m', '/models', '/persona',
|
|
61
|
-
'/clear', '/c', '/status', '/s', '/loop', '/cancel-loop',
|
|
62
|
-
'/setup', '/config', '/upgrade', '/exit', '/quit', '/q',
|
|
63
|
-
'/memory', '/hooks', '/route', '/summarize', '/theme', '/branch', '/find', '/search',
|
|
64
|
-
'/mode', '/work', '/plan', '/debug', '/set', '/confirm',
|
|
65
|
-
'/scope', '/add-dir', '/remove-dir', '/cost', '/costs', '/session', '/context',
|
|
66
|
-
];
|
|
67
|
-
/**
|
|
68
|
-
* Start the CLI
|
|
69
|
-
*/
|
|
70
|
-
export async function startCLI(options = {}) {
|
|
71
|
-
const state = {
|
|
72
|
-
provider: config.get('defaultProvider'),
|
|
73
|
-
model: config.get('defaultModel'),
|
|
74
|
-
persona: config.get('persona'),
|
|
75
|
-
messages: [],
|
|
76
|
-
cwd: process.cwd(),
|
|
77
|
-
running: true,
|
|
78
|
-
skipPermissions: options.skipPermissions ?? false,
|
|
79
|
-
loopActive: false,
|
|
80
|
-
loopPrompt: '',
|
|
81
|
-
loopIteration: 0,
|
|
82
|
-
loopMaxIterations: 50,
|
|
83
|
-
autoRoute: false,
|
|
84
|
-
currentBranch: 'main',
|
|
85
|
-
mode: 'hybrid',
|
|
86
|
-
confirmMode: true,
|
|
87
|
-
debugEnabled: process.env.CALLIOPE_DEBUG === '1',
|
|
88
|
-
sessionCost: 0,
|
|
89
|
-
};
|
|
90
|
-
// Add system message with memory context
|
|
91
|
-
const systemPrompt = getSystemPrompt(state.persona);
|
|
92
|
-
const memoryContext = memory.buildMemoryContext(process.cwd());
|
|
93
|
-
const fullPrompt = memoryContext.trim()
|
|
94
|
-
? systemPrompt + '\n\n--- Project Context ---\n' + memoryContext
|
|
95
|
-
: systemPrompt;
|
|
96
|
-
state.messages.push({
|
|
97
|
-
role: 'system',
|
|
98
|
-
content: fullPrompt,
|
|
99
|
-
});
|
|
100
|
-
// Execute session start hooks
|
|
101
|
-
hooks.executeHooks('session-start', {}).catch((err) => {
|
|
102
|
-
debugLog('session-start hook failed:', err instanceof Error ? err.message : err);
|
|
103
|
-
});
|
|
104
|
-
// Setup readline
|
|
105
|
-
const rl = readline.createInterface({
|
|
106
|
-
input: process.stdin,
|
|
107
|
-
output: process.stdout,
|
|
108
|
-
terminal: true,
|
|
109
|
-
completer: (line) => {
|
|
110
|
-
if (line.startsWith('/')) {
|
|
111
|
-
const hits = COMMANDS.filter(cmd => cmd.startsWith(line));
|
|
112
|
-
return [hits.length ? hits : COMMANDS, line];
|
|
113
|
-
}
|
|
114
|
-
return [[], line];
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
// Check for updates (do this early, it's cached)
|
|
118
|
-
let hasUpdate = false;
|
|
119
|
-
// Print welcome
|
|
120
|
-
if (config.get('fancyOutput')) {
|
|
121
|
-
console.log(BANNER);
|
|
122
|
-
const actualProvider = selectProvider(state.provider);
|
|
123
|
-
const model = state.model || DEFAULT_MODELS[actualProvider];
|
|
124
|
-
console.log(` ${color('v' + getVersion(), 'dim')}`);
|
|
125
|
-
console.log();
|
|
126
|
-
console.log(` ${color('Provider:', 'dim')} ${color(actualProvider, 'cyan')} (${color(model, 'dim')})`);
|
|
127
|
-
console.log(` ${color('Persona:', 'dim')} ${color(state.persona, 'cyan')}`);
|
|
128
|
-
console.log(` ${color('Directory:', 'dim')} ${color(state.cwd, 'dim')}`);
|
|
129
|
-
// Check for updates
|
|
130
|
-
hasUpdate = await checkForUpdates().catch(() => false);
|
|
131
|
-
console.log(color(' ─────────────────────────────────────────────────────────────────', 'dim'));
|
|
132
|
-
console.log(` ${color('TAB', 'cyan')} ${color('autocomplete', 'dim')} ${color('│', 'dim')} ${color('/help', 'cyan')} ${color('│', 'dim')} ${color('/loop', 'cyan')} ${color('│', 'dim')} ${color('/provider', 'cyan')} ${color('│', 'dim')} ${color('ESC', 'cyan')} ${color('stop', 'dim')}`);
|
|
133
|
-
console.log(color(' ─────────────────────────────────────────────────────────────────', 'dim'));
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
console.log('Calliope CLI');
|
|
137
|
-
console.log(`Provider: ${selectProvider(state.provider)}`);
|
|
138
|
-
console.log('/help for commands');
|
|
139
|
-
hasUpdate = await checkForUpdates(true).catch(() => false); // silent in non-fancy mode
|
|
140
|
-
}
|
|
141
|
-
console.log();
|
|
142
|
-
// Prompt function
|
|
143
|
-
const promptUser = () => {
|
|
144
|
-
const promptStr = `${color('calliope', 'cyan')}${color('>', 'dim')} `;
|
|
145
|
-
rl.question(promptStr, async (input) => {
|
|
146
|
-
input = input.trim();
|
|
147
|
-
if (!input) {
|
|
148
|
-
promptUser();
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
// Handle commands
|
|
152
|
-
if (input.startsWith('/')) {
|
|
153
|
-
await handleCommand(input, state, rl);
|
|
154
|
-
if (state.running)
|
|
155
|
-
promptUser();
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
// Run agent
|
|
159
|
-
await runAgent(input, state);
|
|
160
|
-
if (state.running)
|
|
161
|
-
promptUser();
|
|
162
|
-
});
|
|
163
|
-
};
|
|
164
|
-
// Handle Ctrl+C
|
|
165
|
-
rl.on('close', () => {
|
|
166
|
-
console.log();
|
|
167
|
-
console.log(color(' Farewell...', 'cyan'));
|
|
168
|
-
console.log();
|
|
169
|
-
process.exit(0);
|
|
170
|
-
});
|
|
171
|
-
// If update available and autoUpgrade enabled, prompt user
|
|
172
|
-
if (hasUpdate && config.get('autoUpgrade')) {
|
|
173
|
-
rl.question(`${color('Upgrade now? (y/N/never)', 'cyan')} `, async (answer) => {
|
|
174
|
-
const a = answer.toLowerCase().trim();
|
|
175
|
-
if (a === 'y' || a === 'yes') {
|
|
176
|
-
const success = await performUpgrade();
|
|
177
|
-
if (success) {
|
|
178
|
-
console.log();
|
|
179
|
-
console.log(color('Upgrade complete! Restarting...', 'green'));
|
|
180
|
-
const { spawn } = await import('child_process');
|
|
181
|
-
const child = spawn(process.argv[0], process.argv.slice(1), {
|
|
182
|
-
stdio: 'inherit',
|
|
183
|
-
detached: true,
|
|
184
|
-
});
|
|
185
|
-
child.unref();
|
|
186
|
-
process.exit(0);
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
console.log(color('Upgrade failed. Use /upgrade to try again.', 'red'));
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
else if (a === 'never') {
|
|
193
|
-
config.set('autoUpgrade', false);
|
|
194
|
-
console.log(color('Auto-upgrade disabled. Use /upgrade to update manually.', 'dim'));
|
|
195
|
-
}
|
|
196
|
-
console.log();
|
|
197
|
-
promptUser();
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
promptUser();
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Handle slash commands
|
|
206
|
-
*/
|
|
207
|
-
async function handleCommand(input, state, rl) {
|
|
32
|
+
export async function handleCommand(input, state, rl) {
|
|
208
33
|
const parts = input.split(/\s+/);
|
|
209
34
|
const cmd = parts[0].toLowerCase();
|
|
210
35
|
switch (cmd) {
|
|
@@ -215,7 +40,7 @@ async function handleCommand(input, state, rl) {
|
|
|
215
40
|
case '/provider':
|
|
216
41
|
case '/p':
|
|
217
42
|
if (parts[1]) {
|
|
218
|
-
const validProviders = ['anthropic', 'google', 'openai', 'together', 'openrouter', 'groq', 'fireworks', 'mistral', 'ollama', 'ai21', 'huggingface', 'litellm', 'auto'];
|
|
43
|
+
const validProviders = ['anthropic', 'google', 'openai', 'together', 'openrouter', 'groq', 'fireworks', 'mistral', 'ollama', 'ai21', 'huggingface', 'litellm', 'bedrock', 'auto'];
|
|
219
44
|
const requested = parts[1].toLowerCase();
|
|
220
45
|
if (validProviders.includes(requested)) {
|
|
221
46
|
state.provider = requested;
|
|
@@ -241,7 +66,6 @@ async function handleCommand(input, state, rl) {
|
|
|
241
66
|
console.log();
|
|
242
67
|
}
|
|
243
68
|
else {
|
|
244
|
-
// Interactive model selection
|
|
245
69
|
const actualProvider = selectProvider(state.provider);
|
|
246
70
|
console.log(`Current model: ${color(state.model || DEFAULT_MODELS[actualProvider], 'cyan')}`);
|
|
247
71
|
console.log();
|
|
@@ -267,14 +91,14 @@ async function handleCommand(input, state, rl) {
|
|
|
267
91
|
}
|
|
268
92
|
break;
|
|
269
93
|
case '/persona':
|
|
270
|
-
if (parts[1] && ['calliope', '
|
|
94
|
+
if (parts[1] && ['calliope', 'muse', 'minimal'].includes(parts[1])) {
|
|
271
95
|
state.persona = parts[1];
|
|
272
96
|
state.messages = [{ role: 'system', content: getSystemPrompt(state.persona) }];
|
|
273
97
|
console.log(color(`Persona set to: ${parts[1]}`, 'green'));
|
|
274
98
|
}
|
|
275
99
|
else {
|
|
276
100
|
console.log(`Current: ${color(state.persona, 'magenta')}`);
|
|
277
|
-
console.log('Options: calliope,
|
|
101
|
+
console.log('Options: calliope, muse, minimal');
|
|
278
102
|
}
|
|
279
103
|
console.log();
|
|
280
104
|
break;
|
|
@@ -294,7 +118,7 @@ async function handleCommand(input, state, rl) {
|
|
|
294
118
|
console.log();
|
|
295
119
|
break;
|
|
296
120
|
case '/loop':
|
|
297
|
-
await
|
|
121
|
+
await _startLoop(parts.slice(1).join(' '), state);
|
|
298
122
|
break;
|
|
299
123
|
case '/cancel-loop':
|
|
300
124
|
if (state.loopActive) {
|
|
@@ -307,7 +131,7 @@ async function handleCommand(input, state, rl) {
|
|
|
307
131
|
console.log();
|
|
308
132
|
break;
|
|
309
133
|
case '/setup':
|
|
310
|
-
const { reconfigure } = await import('
|
|
134
|
+
const { reconfigure } = await import('../setup.js');
|
|
311
135
|
await reconfigure();
|
|
312
136
|
break;
|
|
313
137
|
case '/config':
|
|
@@ -428,9 +252,193 @@ async function handleCommand(input, state, rl) {
|
|
|
428
252
|
}
|
|
429
253
|
console.log();
|
|
430
254
|
break;
|
|
255
|
+
case '/skin':
|
|
256
|
+
if (parts[1] === 'list' || !parts[1]) {
|
|
257
|
+
const skins = listSkins();
|
|
258
|
+
const currentSkin = getCurrentSkin();
|
|
259
|
+
console.log(`Skins: ${skins.map(s => s.name === currentSkin.name ? color(s.name, 'green') : s.name).join(', ')}`);
|
|
260
|
+
if (!parts[1])
|
|
261
|
+
console.log(`Current: ${color(currentSkin.name, 'cyan')} — ${currentSkin.description}`);
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
applySkin(parts[1]);
|
|
265
|
+
const newSkin = getCurrentSkin();
|
|
266
|
+
if (newSkin.name === parts[1]) {
|
|
267
|
+
config.set('activeSkin', parts[1]);
|
|
268
|
+
console.log(color(`Skin set to: ${parts[1]}`, 'green'));
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
console.log(color(`Skin not found: ${parts[1]}. Using: ${newSkin.name}`, 'yellow'));
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
console.log();
|
|
275
|
+
break;
|
|
276
|
+
case '/palette':
|
|
277
|
+
if (parts[1] === 'list' || !parts[1]) {
|
|
278
|
+
const palettes = listPalettes();
|
|
279
|
+
const currentPal = getCurrentPalette();
|
|
280
|
+
console.log(`Palettes: ${palettes.map(p => p.name === currentPal.name ? color(p.name, 'green') : p.name).join(', ')}`);
|
|
281
|
+
if (!parts[1])
|
|
282
|
+
console.log(`Current: ${color(currentPal.name, 'cyan')} — ${currentPal.description}`);
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
applyPalette(parts[1]);
|
|
286
|
+
const newPal = getCurrentPalette();
|
|
287
|
+
if (newPal.name === parts[1]) {
|
|
288
|
+
config.set('activePalette', parts[1]);
|
|
289
|
+
console.log(color(`Palette set to: ${parts[1]}`, 'green'));
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
console.log(color(`Palette not found: ${parts[1]}. Using: ${newPal.name}`, 'yellow'));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
console.log();
|
|
296
|
+
break;
|
|
297
|
+
case '/companion':
|
|
298
|
+
if (parts[1] === 'list' || !parts[1]) {
|
|
299
|
+
const companions = listCompanions();
|
|
300
|
+
const currentComp = getCurrentCompanion();
|
|
301
|
+
console.log(`Companions: ${companions.map(comp => comp.name === currentComp.name ? color(comp.name, 'green') : comp.name).join(', ')}`);
|
|
302
|
+
if (!parts[1])
|
|
303
|
+
console.log(`Current: ${color(currentComp.name, 'cyan')} — ${currentComp.description}`);
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
applyCompanion(parts[1]);
|
|
307
|
+
const newComp = getCurrentCompanion();
|
|
308
|
+
if (newComp.name === parts[1]) {
|
|
309
|
+
config.set('activeCompanion', parts[1]);
|
|
310
|
+
state.messages = [{ role: 'system', content: getSystemPrompt(state.persona) }];
|
|
311
|
+
console.log(color(`Companion set to: ${parts[1]}`, 'green'));
|
|
312
|
+
console.log(color(` "${newComp.greeting}"`, 'dim'));
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
console.log(color(`Companion not found: ${parts[1]}. Using: ${newComp.name}`, 'yellow'));
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
console.log();
|
|
319
|
+
break;
|
|
320
|
+
case '/hud':
|
|
321
|
+
{
|
|
322
|
+
const hudSkin = getCurrentSkin();
|
|
323
|
+
const hudPalette = getCurrentPalette();
|
|
324
|
+
const hudCompanion = getCurrentCompanion();
|
|
325
|
+
const hudPack = getCurrentPack();
|
|
326
|
+
const hudIntensity = getCompanionMode();
|
|
327
|
+
console.log(color('HUD Configuration', 'bold'));
|
|
328
|
+
if (hudPack)
|
|
329
|
+
console.log(` Pack: ${color(hudPack.name, 'cyan')} — ${hudPack.description}`);
|
|
330
|
+
console.log(` Skin: ${color(hudSkin.name, 'cyan')} — ${hudSkin.description}`);
|
|
331
|
+
console.log(` Palette: ${color(hudPalette.name, 'cyan')} — ${hudPalette.description}`);
|
|
332
|
+
console.log(` Companion: ${color(hudCompanion.name, 'cyan')} — ${hudCompanion.description}`);
|
|
333
|
+
console.log(` Intensity: ${hudIntensity}`);
|
|
334
|
+
console.log(` Emojis: ${config.get('useEmojis') !== false ? 'ON' : 'OFF'}`);
|
|
335
|
+
console.log(` Mood: ${getMoodText()}`);
|
|
336
|
+
console.log();
|
|
337
|
+
console.log(color(' /pack <name> /intensity <pro|immersive> /emoji [on|off]', 'dim'));
|
|
338
|
+
console.log(color(' /skin <name> /palette <name> /companion <name>', 'dim'));
|
|
339
|
+
}
|
|
340
|
+
console.log();
|
|
341
|
+
break;
|
|
342
|
+
case '/pack':
|
|
343
|
+
if (parts[1] === 'list' || !parts[1]) {
|
|
344
|
+
const category = parts[2];
|
|
345
|
+
const packs = listThemePacks(category || undefined);
|
|
346
|
+
const currentP = getCurrentPack();
|
|
347
|
+
const grouped = new Map();
|
|
348
|
+
for (const p of packs) {
|
|
349
|
+
const group = grouped.get(p.category) || [];
|
|
350
|
+
group.push(p);
|
|
351
|
+
grouped.set(p.category, group);
|
|
352
|
+
}
|
|
353
|
+
console.log(color('Theme Packs:', 'bold'));
|
|
354
|
+
for (const [cat, catPacks] of grouped) {
|
|
355
|
+
console.log(color(`\n [${cat}]`, 'dim'));
|
|
356
|
+
for (const p of catPacks) {
|
|
357
|
+
const marker = currentP && p.name === currentP.name ? color(' *', 'green') : '';
|
|
358
|
+
console.log(` ${p.name}${marker} — ${p.description}`);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
console.log(color('\n /pack <name>', 'dim'));
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
const success = applyThemePack(parts[1], getCompanionMode());
|
|
365
|
+
if (success) {
|
|
366
|
+
const pack = getCurrentPack();
|
|
367
|
+
config.set('activeThemePack', parts[1]);
|
|
368
|
+
config.set('activeSkin', pack.skin.name);
|
|
369
|
+
config.set('activePalette', pack.palette.name);
|
|
370
|
+
const companion = getCompanionMode() === 'professional'
|
|
371
|
+
? pack.companions.professional
|
|
372
|
+
: pack.companions.immersive;
|
|
373
|
+
config.set('activeCompanion', companion.name);
|
|
374
|
+
// Reset system prompt to use the companion's persona
|
|
375
|
+
state.messages = [{ role: 'system', content: getSystemPrompt(state.persona) }];
|
|
376
|
+
console.log(color(`Theme pack: ${parts[1]}`, 'green'));
|
|
377
|
+
console.log(color(` "${companion.greeting}"`, 'dim'));
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
console.log(color(`Theme pack not found: ${parts[1]}`, 'yellow'));
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
console.log();
|
|
384
|
+
break;
|
|
385
|
+
case '/intensity':
|
|
386
|
+
if (parts[1] === 'professional' || parts[1] === 'pro') {
|
|
387
|
+
const success = setCompanionMode('professional');
|
|
388
|
+
if (success) {
|
|
389
|
+
const pack = getCurrentPack();
|
|
390
|
+
config.set('companionIntensity', 'professional');
|
|
391
|
+
config.set('activeCompanion', pack.companions.professional.name);
|
|
392
|
+
state.messages = [{ role: 'system', content: getSystemPrompt(state.persona) }];
|
|
393
|
+
console.log(color(`Switched to professional mode`, 'green'));
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
console.log(color('No theme pack active. Use /pack <name> first.', 'yellow'));
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
else if (parts[1] === 'immersive' || parts[1] === 'imm') {
|
|
400
|
+
const success = setCompanionMode('immersive');
|
|
401
|
+
if (success) {
|
|
402
|
+
const pack = getCurrentPack();
|
|
403
|
+
config.set('companionIntensity', 'immersive');
|
|
404
|
+
config.set('activeCompanion', pack.companions.immersive.name);
|
|
405
|
+
state.messages = [{ role: 'system', content: getSystemPrompt(state.persona) }];
|
|
406
|
+
console.log(color(`Switched to immersive mode`, 'green'));
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
console.log(color('No theme pack active. Use /pack <name> first.', 'yellow'));
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
console.log(`Intensity: ${getCompanionMode()}`);
|
|
414
|
+
console.log(color('Options: /intensity professional (pro), /intensity immersive (imm)', 'dim'));
|
|
415
|
+
}
|
|
416
|
+
console.log();
|
|
417
|
+
break;
|
|
418
|
+
case '/emoji': {
|
|
419
|
+
const emojiArg = parts[1];
|
|
420
|
+
const emojiCurrent = config.get('useEmojis') !== false;
|
|
421
|
+
if (emojiArg === 'on') {
|
|
422
|
+
config.set('useEmojis', true);
|
|
423
|
+
console.log(color('Emojis enabled', 'green'));
|
|
424
|
+
}
|
|
425
|
+
else if (emojiArg === 'off') {
|
|
426
|
+
config.set('useEmojis', false);
|
|
427
|
+
console.log(color('Emojis disabled — text fallbacks will be used', 'green'));
|
|
428
|
+
}
|
|
429
|
+
else if (emojiArg === 'toggle') {
|
|
430
|
+
config.set('useEmojis', !emojiCurrent);
|
|
431
|
+
console.log(color(`Emojis ${!emojiCurrent ? 'enabled' : 'disabled'}`, 'green'));
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
console.log(`Emojis: ${emojiCurrent ? 'ON' : 'OFF'}`);
|
|
435
|
+
console.log(color('Usage: /emoji [on|off|toggle]', 'dim'));
|
|
436
|
+
}
|
|
437
|
+
console.log();
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
431
440
|
case '/branch':
|
|
432
441
|
{
|
|
433
|
-
// Use a simple session ID for the legacy CLI
|
|
434
442
|
const sessionId = 'default-session';
|
|
435
443
|
if (parts[1] === 'list') {
|
|
436
444
|
const branches = branching.listBranches(sessionId);
|
|
@@ -638,11 +646,68 @@ async function handleCommand(input, state, rl) {
|
|
|
638
646
|
}
|
|
639
647
|
console.log();
|
|
640
648
|
break;
|
|
649
|
+
case '/sandbox':
|
|
650
|
+
{
|
|
651
|
+
const sandboxArg = parts[1];
|
|
652
|
+
const validModes = ['auto', 'native', 'docker', 'off'];
|
|
653
|
+
if (sandboxArg && validModes.includes(sandboxArg)) {
|
|
654
|
+
config.set('sandboxMode', sandboxArg);
|
|
655
|
+
console.log(color(`Sandbox mode set to: ${sandboxArg}`, 'green'));
|
|
656
|
+
}
|
|
657
|
+
else if (sandboxArg && !validModes.includes(sandboxArg)) {
|
|
658
|
+
console.log(color(`Invalid sandbox mode: ${sandboxArg}`, 'red'));
|
|
659
|
+
console.log(`Available modes: ${validModes.join(', ')}`);
|
|
660
|
+
}
|
|
661
|
+
else {
|
|
662
|
+
// Show sandbox status
|
|
663
|
+
const currentMode = config.get('sandboxMode') || 'auto';
|
|
664
|
+
const nativeStatus = getSandboxStatus();
|
|
665
|
+
const dockerReady = isDockerAvailable();
|
|
666
|
+
console.log(color('Sandbox Configuration', 'bold'));
|
|
667
|
+
console.log(` Mode: ${color(currentMode, 'cyan')}`);
|
|
668
|
+
console.log();
|
|
669
|
+
console.log(color(' Backends:', 'bold'));
|
|
670
|
+
console.log(` Docker: ${dockerReady ? color('available', 'green') : color('not available', 'dim')}`);
|
|
671
|
+
console.log(` Native: ${nativeStatus.available ? color('available', 'green') : color('not available', 'dim')}`);
|
|
672
|
+
if (nativeStatus.available) {
|
|
673
|
+
console.log(` ${nativeStatus.description}`);
|
|
674
|
+
}
|
|
675
|
+
console.log(` Platform: ${nativeStatus.platform}`);
|
|
676
|
+
console.log();
|
|
677
|
+
// Show effective behaviour
|
|
678
|
+
let effective;
|
|
679
|
+
switch (currentMode) {
|
|
680
|
+
case 'auto':
|
|
681
|
+
if (nativeStatus.available)
|
|
682
|
+
effective = `native (${nativeStatus.backend}) for shell commands`;
|
|
683
|
+
else
|
|
684
|
+
effective = 'unsandboxed (no native backend available)';
|
|
685
|
+
if (dockerReady)
|
|
686
|
+
effective += ', Docker for code execution';
|
|
687
|
+
break;
|
|
688
|
+
case 'native':
|
|
689
|
+
effective = nativeStatus.available ? `${nativeStatus.backend}` : 'ERROR: native not available';
|
|
690
|
+
break;
|
|
691
|
+
case 'docker':
|
|
692
|
+
effective = dockerReady ? 'Docker' : 'ERROR: Docker not available';
|
|
693
|
+
break;
|
|
694
|
+
case 'off':
|
|
695
|
+
effective = 'all sandboxing disabled';
|
|
696
|
+
break;
|
|
697
|
+
default:
|
|
698
|
+
effective = 'unknown';
|
|
699
|
+
}
|
|
700
|
+
console.log(` Effective: ${effective}`);
|
|
701
|
+
console.log();
|
|
702
|
+
console.log(color(' /sandbox <auto|native|docker|off>', 'dim'));
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
console.log();
|
|
706
|
+
break;
|
|
641
707
|
case '/exit':
|
|
642
708
|
case '/quit':
|
|
643
|
-
case '/q':
|
|
644
709
|
console.log();
|
|
645
|
-
console.log(color(
|
|
710
|
+
console.log(color(` ${getCurrentCompanion().farewell}`, 'cyan'));
|
|
646
711
|
console.log();
|
|
647
712
|
state.running = false;
|
|
648
713
|
rl.close();
|
|
@@ -653,9 +718,6 @@ async function handleCommand(input, state, rl) {
|
|
|
653
718
|
console.log();
|
|
654
719
|
}
|
|
655
720
|
}
|
|
656
|
-
/**
|
|
657
|
-
* Handle upgrade command
|
|
658
|
-
*/
|
|
659
721
|
async function handleUpgrade(rl) {
|
|
660
722
|
console.log();
|
|
661
723
|
console.log(color('Checking for updates...', 'cyan'));
|
|
@@ -685,7 +747,6 @@ async function handleUpgrade(rl) {
|
|
|
685
747
|
console.log();
|
|
686
748
|
console.log(`${color('Update available:', 'yellow')} v${currentVersion} → ${color('v' + latestVersion, 'green')}`);
|
|
687
749
|
console.log();
|
|
688
|
-
// Prompt for confirmation
|
|
689
750
|
rl.question(`${color('Upgrade now? (y/N)', 'cyan')} `, async (answer) => {
|
|
690
751
|
if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
|
|
691
752
|
console.log();
|
|
@@ -695,7 +756,6 @@ async function handleUpgrade(rl) {
|
|
|
695
756
|
console.log(color('Upgrade complete!', 'green'));
|
|
696
757
|
console.log(color('Restarting Calliope...', 'dim'));
|
|
697
758
|
console.log();
|
|
698
|
-
// Restart the CLI
|
|
699
759
|
const { spawn } = await import('child_process');
|
|
700
760
|
const child = spawn(process.argv[0], process.argv.slice(1), {
|
|
701
761
|
stdio: 'inherit',
|
|
@@ -717,9 +777,6 @@ async function handleUpgrade(rl) {
|
|
|
717
777
|
}
|
|
718
778
|
});
|
|
719
779
|
}
|
|
720
|
-
/**
|
|
721
|
-
* Print help
|
|
722
|
-
*/
|
|
723
780
|
function printHelp() {
|
|
724
781
|
console.log();
|
|
725
782
|
console.log(color('Commands:', 'bold'));
|
|
@@ -750,6 +807,7 @@ function printHelp() {
|
|
|
750
807
|
console.log(' /scope [details|reset] Show/manage file access scope');
|
|
751
808
|
console.log(' /add-dir <path> Add directory to scope');
|
|
752
809
|
console.log(' /remove-dir <path> Remove directory from scope');
|
|
810
|
+
console.log(' /sandbox [mode] Sandbox status or set mode (auto|native|docker|off)');
|
|
753
811
|
console.log();
|
|
754
812
|
console.log(color('Navigation:', 'bold'));
|
|
755
813
|
console.log(' /find <pattern> Fuzzy file search');
|
|
@@ -759,7 +817,13 @@ function printHelp() {
|
|
|
759
817
|
console.log(' /hooks [init|list] Pre/post tool hooks');
|
|
760
818
|
console.log(' /theme [name|list] Color themes');
|
|
761
819
|
console.log();
|
|
762
|
-
console.log(color('
|
|
820
|
+
console.log(color('HUD:', 'bold'));
|
|
821
|
+
console.log(' /skin [name|list] Switch visual skin');
|
|
822
|
+
console.log(' /palette [name|list] Switch color palette');
|
|
823
|
+
console.log(' /companion [name|list] Switch AI companion');
|
|
824
|
+
console.log(' /hud Show HUD status');
|
|
825
|
+
console.log();
|
|
826
|
+
console.log(color('Agent Loop:', 'bold'));
|
|
763
827
|
console.log(' /loop "<prompt>" Start autonomous loop');
|
|
764
828
|
console.log(' --max-iterations N');
|
|
765
829
|
console.log(' --completion-promise "text"');
|
|
@@ -774,205 +838,4 @@ function printHelp() {
|
|
|
774
838
|
console.log(' /exit Exit');
|
|
775
839
|
console.log();
|
|
776
840
|
}
|
|
777
|
-
|
|
778
|
-
* Run the agent with a prompt
|
|
779
|
-
*/
|
|
780
|
-
async function runAgent(prompt, state) {
|
|
781
|
-
// Add user message
|
|
782
|
-
state.messages.push({ role: 'user', content: prompt });
|
|
783
|
-
// Spinner setup
|
|
784
|
-
let spinnerIdx = 0;
|
|
785
|
-
const spinnerInterval = setInterval(() => {
|
|
786
|
-
process.stdout.write(`\r${color(SPINNER[spinnerIdx], 'cyan')} ${color('Thinking...', 'dim')}`);
|
|
787
|
-
spinnerIdx = (spinnerIdx + 1) % SPINNER.length;
|
|
788
|
-
}, 80);
|
|
789
|
-
// Helper to clean up spinner
|
|
790
|
-
const clearSpinner = () => {
|
|
791
|
-
clearInterval(spinnerInterval);
|
|
792
|
-
process.stdout.write('\r\x1b[K'); // Clear line
|
|
793
|
-
};
|
|
794
|
-
try {
|
|
795
|
-
const maxIterations = config.get('maxIterations');
|
|
796
|
-
let iteration = 0;
|
|
797
|
-
let finalResponse = '';
|
|
798
|
-
while (iteration < maxIterations) {
|
|
799
|
-
iteration++;
|
|
800
|
-
// Call LLM
|
|
801
|
-
const response = await chat(state.provider, state.messages, TOOLS, state.model);
|
|
802
|
-
// Handle tool calls
|
|
803
|
-
if (response.toolCalls && response.toolCalls.length > 0) {
|
|
804
|
-
clearSpinner();
|
|
805
|
-
// Add assistant message with tool calls
|
|
806
|
-
state.messages.push({
|
|
807
|
-
role: 'assistant',
|
|
808
|
-
content: response.content,
|
|
809
|
-
toolCalls: response.toolCalls,
|
|
810
|
-
});
|
|
811
|
-
// Execute tools
|
|
812
|
-
for (const toolCall of response.toolCalls) {
|
|
813
|
-
// Execute pre-tool hooks
|
|
814
|
-
const preHookResult = await hooks.checkHooksAllow('pre-tool', {
|
|
815
|
-
tool: toolCall.name,
|
|
816
|
-
toolArgs: toolCall.arguments,
|
|
817
|
-
});
|
|
818
|
-
if (!preHookResult.allowed) {
|
|
819
|
-
console.log(`${color('│', 'dim')} ${color(`Blocked by hook: ${preHookResult.reason}`, 'red')}`);
|
|
820
|
-
state.messages.push({
|
|
821
|
-
role: 'tool',
|
|
822
|
-
content: `[Blocked by hook: ${preHookResult.reason}]`,
|
|
823
|
-
toolCallId: toolCall.id,
|
|
824
|
-
});
|
|
825
|
-
continue;
|
|
826
|
-
}
|
|
827
|
-
printToolCall(toolCall);
|
|
828
|
-
const result = await executeTool(toolCall, state.cwd);
|
|
829
|
-
printToolResult(toolCall.name, result.result);
|
|
830
|
-
// Execute post-tool hooks
|
|
831
|
-
hooks.executeHooks('post-tool', {
|
|
832
|
-
tool: toolCall.name,
|
|
833
|
-
toolArgs: toolCall.arguments,
|
|
834
|
-
toolResult: result.result,
|
|
835
|
-
}).catch((err) => {
|
|
836
|
-
debugLog(`post-tool hook failed for ${toolCall.name}:`, err instanceof Error ? err.message : err);
|
|
837
|
-
});
|
|
838
|
-
state.messages.push({
|
|
839
|
-
role: 'tool',
|
|
840
|
-
content: result.result,
|
|
841
|
-
toolCallId: toolCall.id,
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
// Continue loop for next response
|
|
845
|
-
continue;
|
|
846
|
-
}
|
|
847
|
-
// No tool calls - final response
|
|
848
|
-
clearSpinner();
|
|
849
|
-
state.messages.push({
|
|
850
|
-
role: 'assistant',
|
|
851
|
-
content: response.content,
|
|
852
|
-
});
|
|
853
|
-
finalResponse = response.content;
|
|
854
|
-
console.log();
|
|
855
|
-
console.log(`${color('✧', 'cyan')} ${color('Calliope:', 'dim')}`);
|
|
856
|
-
console.log();
|
|
857
|
-
printOutput(response.content);
|
|
858
|
-
console.log();
|
|
859
|
-
break;
|
|
860
|
-
}
|
|
861
|
-
return finalResponse;
|
|
862
|
-
}
|
|
863
|
-
catch (error) {
|
|
864
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
865
|
-
console.log();
|
|
866
|
-
console.log(`${color('✗', 'red')} ${color(`Error: ${msg}`, 'red')}`);
|
|
867
|
-
console.log();
|
|
868
|
-
return '';
|
|
869
|
-
}
|
|
870
|
-
finally {
|
|
871
|
-
// Ensure spinner is always cleaned up
|
|
872
|
-
clearInterval(spinnerInterval);
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
/**
|
|
876
|
-
* Start an autonomous loop
|
|
877
|
-
*/
|
|
878
|
-
async function startLoop(args, state) {
|
|
879
|
-
// Parse args
|
|
880
|
-
const maxIterMatch = args.match(/--max-iterations\s+(\d+)/);
|
|
881
|
-
const completionMatch = args.match(/--completion-promise\s+"([^"]+)"/);
|
|
882
|
-
let prompt = args
|
|
883
|
-
.replace(/--max-iterations\s+\d+/, '')
|
|
884
|
-
.replace(/--completion-promise\s+"[^"]+"/, '')
|
|
885
|
-
.trim();
|
|
886
|
-
const quotedMatch = prompt.match(/^"([^"]+)"$/);
|
|
887
|
-
if (quotedMatch)
|
|
888
|
-
prompt = quotedMatch[1];
|
|
889
|
-
if (!prompt) {
|
|
890
|
-
console.log(color('Usage: /loop "<prompt>" [--max-iterations N] [--completion-promise "text"]', 'red'));
|
|
891
|
-
console.log();
|
|
892
|
-
return;
|
|
893
|
-
}
|
|
894
|
-
state.loopActive = true;
|
|
895
|
-
state.loopPrompt = prompt;
|
|
896
|
-
state.loopIteration = 0;
|
|
897
|
-
state.loopMaxIterations = maxIterMatch ? parseInt(maxIterMatch[1], 10) : 50;
|
|
898
|
-
state.loopCompletionPromise = completionMatch ? completionMatch[1] : undefined;
|
|
899
|
-
console.log();
|
|
900
|
-
console.log(`${color('╭─', 'dim')} ${color('🔄 Ralph Loop Started', 'bold')}`);
|
|
901
|
-
console.log(`${color('│', 'dim')} ${color('Max:', 'dim')} ${color(String(state.loopMaxIterations), 'cyan')}`);
|
|
902
|
-
if (state.loopCompletionPromise) {
|
|
903
|
-
console.log(`${color('│', 'dim')} ${color('Promise:', 'dim')} ${color(state.loopCompletionPromise, 'green')}`);
|
|
904
|
-
}
|
|
905
|
-
console.log(`${color('╰─', 'dim')} ${color('/cancel-loop to stop', 'dim')}`);
|
|
906
|
-
console.log();
|
|
907
|
-
// Run loop
|
|
908
|
-
while (state.loopActive && state.loopIteration < state.loopMaxIterations) {
|
|
909
|
-
state.loopIteration++;
|
|
910
|
-
console.log(`${color('╭─', 'cyan')} ${color(`Iteration ${state.loopIteration}/${state.loopMaxIterations}`, 'bold')}`);
|
|
911
|
-
const result = await runAgent(state.loopPrompt, state);
|
|
912
|
-
// Check completion promise
|
|
913
|
-
if (state.loopCompletionPromise && result.includes(state.loopCompletionPromise)) {
|
|
914
|
-
console.log(`${color('🎉 Completion promise detected!', 'green')}`);
|
|
915
|
-
state.loopActive = false;
|
|
916
|
-
break;
|
|
917
|
-
}
|
|
918
|
-
if (!state.loopActive)
|
|
919
|
-
break;
|
|
920
|
-
// Delay between iterations
|
|
921
|
-
await new Promise(r => setTimeout(r, 1000));
|
|
922
|
-
}
|
|
923
|
-
if (state.loopIteration >= state.loopMaxIterations) {
|
|
924
|
-
console.log(`${color('⚠️ Max iterations reached', 'yellow')}`);
|
|
925
|
-
}
|
|
926
|
-
state.loopActive = false;
|
|
927
|
-
console.log();
|
|
928
|
-
}
|
|
929
|
-
/**
|
|
930
|
-
* Print tool call
|
|
931
|
-
*/
|
|
932
|
-
function printToolCall(toolCall) {
|
|
933
|
-
const icons = {
|
|
934
|
-
shell: '⚡',
|
|
935
|
-
read_file: '📄',
|
|
936
|
-
write_file: '✍️',
|
|
937
|
-
list_files: '📁',
|
|
938
|
-
think: '💭',
|
|
939
|
-
};
|
|
940
|
-
console.log();
|
|
941
|
-
console.log(`${color('╭─', 'dim')} ${icons[toolCall.name] || '⚙️'} ${color(toolCall.name, 'yellow')}`);
|
|
942
|
-
if (toolCall.name === 'shell' && toolCall.arguments.command) {
|
|
943
|
-
console.log(`${color('│', 'dim')} ${color('$', 'green')} ${toolCall.arguments.command}`);
|
|
944
|
-
}
|
|
945
|
-
else if (toolCall.name === 'think' && toolCall.arguments.thought) {
|
|
946
|
-
const thought = String(toolCall.arguments.thought);
|
|
947
|
-
const preview = thought.length > 80 ? thought.substring(0, 80) + '...' : thought;
|
|
948
|
-
console.log(`${color('│', 'dim')} ${color(preview, 'dim')}`);
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
/**
|
|
952
|
-
* Print tool result
|
|
953
|
-
*/
|
|
954
|
-
function printToolResult(name, result) {
|
|
955
|
-
if (name === 'think') {
|
|
956
|
-
console.log(`${color('╰─', 'dim')} ${color('✓', 'green')}`);
|
|
957
|
-
return;
|
|
958
|
-
}
|
|
959
|
-
const lines = result.split('\n').slice(0, 10);
|
|
960
|
-
for (const line of lines) {
|
|
961
|
-
console.log(`${color('│', 'dim')} ${color(line.substring(0, 100), 'dim')}`);
|
|
962
|
-
}
|
|
963
|
-
if (result.split('\n').length > 10) {
|
|
964
|
-
console.log(`${color('│', 'dim')} ${color(`... (${result.split('\n').length - 10} more lines)`, 'dim')}`);
|
|
965
|
-
}
|
|
966
|
-
const success = !result.toLowerCase().includes('error');
|
|
967
|
-
console.log(`${color('╰─', 'dim')} ${success ? color('✓', 'green') : color('✗', 'red')}`);
|
|
968
|
-
}
|
|
969
|
-
/**
|
|
970
|
-
* Print output with indentation
|
|
971
|
-
*/
|
|
972
|
-
function printOutput(text) {
|
|
973
|
-
const lines = text.split('\n');
|
|
974
|
-
for (const line of lines) {
|
|
975
|
-
console.log(`${color('│', 'blue')} ${line}`);
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
//# sourceMappingURL=cli.js.map
|
|
841
|
+
//# sourceMappingURL=commands.js.map
|