@pentoshi/clai 3.6.0 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/compaction-summary.d.ts +17 -0
- package/dist/agent/compaction-summary.js +64 -0
- package/dist/agent/compaction-summary.js.map +1 -0
- package/dist/agent/confirm-port.d.ts +3 -1
- package/dist/agent/confirm-port.js +5 -1
- package/dist/agent/confirm-port.js.map +1 -1
- package/dist/agent/context-manager.js +45 -22
- package/dist/agent/context-manager.js.map +1 -1
- package/dist/agent/events.d.ts +6 -0
- package/dist/agent/evidence-governor.d.ts +37 -0
- package/dist/agent/evidence-governor.js +70 -0
- package/dist/agent/evidence-governor.js.map +1 -0
- package/dist/agent/loop-guard.d.ts +29 -11
- package/dist/agent/loop-guard.js +93 -39
- package/dist/agent/loop-guard.js.map +1 -1
- package/dist/agent/must-continue.d.ts +56 -0
- package/dist/agent/must-continue.js +240 -0
- package/dist/agent/must-continue.js.map +1 -0
- package/dist/agent/outcomes.d.ts +101 -0
- package/dist/agent/outcomes.js +359 -0
- package/dist/agent/outcomes.js.map +1 -0
- package/dist/agent/plan-decision.d.ts +33 -0
- package/dist/agent/plan-decision.js +104 -0
- package/dist/agent/plan-decision.js.map +1 -0
- package/dist/agent/plan-tool.d.ts +12 -0
- package/dist/agent/plan-tool.js +312 -104
- package/dist/agent/plan-tool.js.map +1 -1
- package/dist/agent/project-root.js +3 -0
- package/dist/agent/project-root.js.map +1 -1
- package/dist/agent/prompt-composer.d.ts +21 -0
- package/dist/agent/prompt-composer.js +46 -0
- package/dist/agent/prompt-composer.js.map +1 -0
- package/dist/agent/runner.d.ts +11 -1
- package/dist/agent/runner.js +1226 -971
- package/dist/agent/runner.js.map +1 -1
- package/dist/agent/scope-context.d.ts +3 -0
- package/dist/agent/scope-context.js +24 -0
- package/dist/agent/scope-context.js.map +1 -0
- package/dist/agent/scratch-write.d.ts +4 -0
- package/dist/agent/scratch-write.js +54 -0
- package/dist/agent/scratch-write.js.map +1 -0
- package/dist/agent/session-policy.d.ts +7 -0
- package/dist/agent/session-policy.js +61 -0
- package/dist/agent/session-policy.js.map +1 -1
- package/dist/agent/session-state.d.ts +41 -0
- package/dist/agent/session-state.js +107 -0
- package/dist/agent/session-state.js.map +1 -0
- package/dist/agent/step-budget.d.ts +14 -0
- package/dist/agent/step-budget.js +26 -0
- package/dist/agent/step-budget.js.map +1 -0
- package/dist/agent/task-analyzer.d.ts +12 -3
- package/dist/agent/task-analyzer.js +263 -23
- package/dist/agent/task-analyzer.js.map +1 -1
- package/dist/agent/task-evidence.d.ts +111 -29
- package/dist/agent/task-evidence.js +519 -91
- package/dist/agent/task-evidence.js.map +1 -1
- package/dist/agent/task-plan.d.ts +57 -0
- package/dist/agent/task-plan.js +147 -1
- package/dist/agent/task-plan.js.map +1 -1
- package/dist/agent/tool-call-parser.d.ts +4 -12
- package/dist/agent/tool-call-parser.js +34 -67
- package/dist/agent/tool-call-parser.js.map +1 -1
- package/dist/agent/tool-history.d.ts +7 -0
- package/dist/agent/tool-history.js +50 -0
- package/dist/agent/tool-history.js.map +1 -1
- package/dist/agent/tool-output-formatting.d.ts +13 -1
- package/dist/agent/tool-output-formatting.js +75 -22
- package/dist/agent/tool-output-formatting.js.map +1 -1
- package/dist/agent/turn-outcome.d.ts +11 -0
- package/dist/agent/turn-outcome.js +17 -0
- package/dist/agent/turn-outcome.js.map +1 -0
- package/dist/agent/turn-state.d.ts +11 -0
- package/dist/agent/turn-state.js +28 -0
- package/dist/agent/turn-state.js.map +1 -0
- package/dist/agent/workspace-orient.d.ts +11 -0
- package/dist/agent/workspace-orient.js +103 -12
- package/dist/agent/workspace-orient.js.map +1 -1
- package/dist/app/adapters/agent-event-adapter.d.ts +2 -13
- package/dist/app/adapters/agent-event-adapter.js +63 -25
- package/dist/app/adapters/agent-event-adapter.js.map +1 -1
- package/dist/app/adapters/current-agent-adapter.d.ts +0 -5
- package/dist/app/adapters/current-agent-adapter.js +4 -7
- package/dist/app/adapters/current-agent-adapter.js.map +1 -1
- package/dist/app/adapters/current-jobs-adapter.js +1 -0
- package/dist/app/adapters/current-jobs-adapter.js.map +1 -1
- package/dist/app/adapters/current-terminal-adapter.d.ts +0 -7
- package/dist/app/adapters/current-terminal-adapter.js +0 -7
- package/dist/app/adapters/current-terminal-adapter.js.map +1 -1
- package/dist/app/adapters/current-updates-adapter.d.ts +0 -5
- package/dist/app/adapters/current-updates-adapter.js +0 -5
- package/dist/app/adapters/current-updates-adapter.js.map +1 -1
- package/dist/app/adapters/in-memory-clipboard-adapter.d.ts +0 -5
- package/dist/app/adapters/in-memory-clipboard-adapter.js +0 -5
- package/dist/app/adapters/in-memory-clipboard-adapter.js.map +1 -1
- package/dist/app/commands/command.d.ts +0 -5
- package/dist/app/commands/command.js.map +1 -1
- package/dist/app/commands/registry.d.ts +0 -14
- package/dist/app/commands/registry.js +0 -20
- package/dist/app/commands/registry.js.map +1 -1
- package/dist/app/controllers/disposable.d.ts +0 -5
- package/dist/app/controllers/disposable.js +0 -5
- package/dist/app/controllers/disposable.js.map +1 -1
- package/dist/app/controllers/job-controller.d.ts +1 -5
- package/dist/app/controllers/job-controller.js +0 -4
- package/dist/app/controllers/job-controller.js.map +1 -1
- package/dist/app/controllers/plan-controller.d.ts +5 -8
- package/dist/app/controllers/plan-controller.js +30 -12
- package/dist/app/controllers/plan-controller.js.map +1 -1
- package/dist/app/controllers/session-controller.d.ts +17 -32
- package/dist/app/controllers/session-controller.js +56 -35
- package/dist/app/controllers/session-controller.js.map +1 -1
- package/dist/app/controllers/turn-controller.d.ts +2 -6
- package/dist/app/controllers/turn-controller.js +8 -8
- package/dist/app/controllers/turn-controller.js.map +1 -1
- package/dist/app/events/app-event.d.ts +4 -7
- package/dist/app/events/app-event.js +0 -6
- package/dist/app/events/app-event.js.map +1 -1
- package/dist/app/events/event-buffer.d.ts +6 -17
- package/dist/app/events/event-buffer.js +27 -24
- package/dist/app/events/event-buffer.js.map +1 -1
- package/dist/app/events/sequencer.d.ts +0 -9
- package/dist/app/events/sequencer.js +0 -4
- package/dist/app/events/sequencer.js.map +1 -1
- package/dist/app/ports/agent-port.d.ts +13 -3
- package/dist/app/ports/clipboard-port.d.ts +0 -5
- package/dist/app/ports/confirm-port.d.ts +0 -7
- package/dist/app/ports/jobs-port.d.ts +2 -5
- package/dist/app/ports/persistence-port.d.ts +0 -4
- package/dist/app/ports/secret-port.d.ts +0 -5
- package/dist/app/ports/terminal-port.d.ts +0 -6
- package/dist/app/ports/updates-port.d.ts +0 -4
- package/dist/attachments/service.d.ts +29 -0
- package/dist/attachments/service.js +47 -0
- package/dist/attachments/service.js.map +1 -0
- package/dist/commands/providers.js +0 -3
- package/dist/commands/providers.js.map +1 -1
- package/dist/commands/search-providers.d.ts +0 -33
- package/dist/commands/search-providers.js +0 -33
- package/dist/commands/search-providers.js.map +1 -1
- package/dist/commands/update.js +1 -9
- package/dist/commands/update.js.map +1 -1
- package/dist/index.js +22 -42
- package/dist/index.js.map +1 -1
- package/dist/llm/adapters/ollama-tools.d.ts +0 -4
- package/dist/llm/adapters/ollama-tools.js +0 -4
- package/dist/llm/adapters/ollama-tools.js.map +1 -1
- package/dist/llm/capabilities.d.ts +10 -10
- package/dist/llm/capabilities.js +43 -17
- package/dist/llm/capabilities.js.map +1 -1
- package/dist/llm/groq.js +0 -6
- package/dist/llm/groq.js.map +1 -1
- package/dist/llm/http.d.ts +0 -17
- package/dist/llm/http.js +0 -45
- package/dist/llm/http.js.map +1 -1
- package/dist/llm/router.d.ts +0 -6
- package/dist/llm/router.js +0 -15
- package/dist/llm/router.js.map +1 -1
- package/dist/llm/tool-protocol.d.ts +0 -6
- package/dist/llm/tool-protocol.js +3 -7
- package/dist/llm/tool-protocol.js.map +1 -1
- package/dist/modes/agent.d.ts +2 -1
- package/dist/modes/agent.js +4 -2
- package/dist/modes/agent.js.map +1 -1
- package/dist/modes/ask.d.ts +0 -18
- package/dist/modes/ask.js +0 -49
- package/dist/modes/ask.js.map +1 -1
- package/dist/os/cwd.d.ts +0 -21
- package/dist/os/cwd.js +0 -24
- package/dist/os/cwd.js.map +1 -1
- package/dist/os/pkgmgr.js +0 -6
- package/dist/os/pkgmgr.js.map +1 -1
- package/dist/prompts/embedded.d.ts +1 -0
- package/dist/prompts/embedded.js +9 -0
- package/dist/prompts/embedded.js.map +1 -0
- package/dist/prompts/index.d.ts +6 -18
- package/dist/prompts/index.js +104 -293
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/system.agent.md +228 -0
- package/dist/prompts/system.ask.md +56 -0
- package/dist/repl/prompt-line.js +0 -36
- package/dist/repl/prompt-line.js.map +1 -1
- package/dist/repl/slash-commands.d.ts +0 -9
- package/dist/repl/slash-commands.js +2 -23
- package/dist/repl/slash-commands.js.map +1 -1
- package/dist/repl.d.ts +5 -0
- package/dist/repl.js +169 -55
- package/dist/repl.js.map +1 -1
- package/dist/safety/classifier.js +17 -9
- package/dist/safety/classifier.js.map +1 -1
- package/dist/safety/engagement-policy.d.ts +46 -0
- package/dist/safety/engagement-policy.js +198 -0
- package/dist/safety/engagement-policy.js.map +1 -0
- package/dist/store/engagement.d.ts +115 -0
- package/dist/store/engagement.js +278 -0
- package/dist/store/engagement.js.map +1 -0
- package/dist/store/logs.d.ts +5 -0
- package/dist/store/logs.js +52 -2
- package/dist/store/logs.js.map +1 -1
- package/dist/store/plan.d.ts +57 -5
- package/dist/store/plan.js +182 -8
- package/dist/store/plan.js.map +1 -1
- package/dist/store/scope.d.ts +4 -1
- package/dist/store/scope.js +2 -2
- package/dist/store/scope.js.map +1 -1
- package/dist/tools/definitions.js +70 -1
- package/dist/tools/definitions.js.map +1 -1
- package/dist/tools/elevated-shell.d.ts +60 -0
- package/dist/tools/elevated-shell.js +233 -0
- package/dist/tools/elevated-shell.js.map +1 -0
- package/dist/tools/file-diff.d.ts +125 -0
- package/dist/tools/file-diff.js +495 -0
- package/dist/tools/file-diff.js.map +1 -0
- package/dist/tools/fs.d.ts +11 -13
- package/dist/tools/fs.js +269 -78
- package/dist/tools/fs.js.map +1 -1
- package/dist/tools/http.d.ts +15 -0
- package/dist/tools/http.js +202 -61
- package/dist/tools/http.js.map +1 -1
- package/dist/tools/jobs.d.ts +71 -10
- package/dist/tools/jobs.js +403 -124
- package/dist/tools/jobs.js.map +1 -1
- package/dist/tools/nmap-runner.d.ts +11 -0
- package/dist/tools/nmap-runner.js +115 -74
- package/dist/tools/nmap-runner.js.map +1 -1
- package/dist/tools/pentest-workflows.d.ts +8 -0
- package/dist/tools/pentest-workflows.js +71 -0
- package/dist/tools/pentest-workflows.js.map +1 -0
- package/dist/tools/registry.d.ts +9 -0
- package/dist/tools/registry.js +244 -57
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/shell.d.ts +3 -0
- package/dist/tools/shell.js +35 -13
- package/dist/tools/shell.js.map +1 -1
- package/dist/tools/tool-types.d.ts +11 -0
- package/dist/tools/web/fetch-core.d.ts +7 -0
- package/dist/tools/web/fetch-core.js +40 -1
- package/dist/tools/web/fetch-core.js.map +1 -1
- package/dist/tools/web/fetch.js +8 -1
- package/dist/tools/web/fetch.js.map +1 -1
- package/dist/tui-v2/app/App.js +34 -41
- package/dist/tui-v2/app/App.js.map +1 -1
- package/dist/tui-v2/app/command-handlers.js +20 -1
- package/dist/tui-v2/app/command-handlers.js.map +1 -1
- package/dist/tui-v2/app/commands/picker-commands.js +3 -0
- package/dist/tui-v2/app/commands/picker-commands.js.map +1 -1
- package/dist/tui-v2/app/commands/session-commands.js +5 -0
- package/dist/tui-v2/app/commands/session-commands.js.map +1 -1
- package/dist/tui-v2/app/plan-lifecycle.d.ts +25 -3
- package/dist/tui-v2/app/plan-lifecycle.js +87 -24
- package/dist/tui-v2/app/plan-lifecycle.js.map +1 -1
- package/dist/tui-v2/bootstrap/patch-opentui-text.d.ts +6 -0
- package/dist/tui-v2/bootstrap/patch-opentui-text.js +53 -0
- package/dist/tui-v2/bootstrap/patch-opentui-text.js.map +1 -0
- package/dist/tui-v2/bootstrap/start-tui-v2.js +7 -0
- package/dist/tui-v2/bootstrap/start-tui-v2.js.map +1 -1
- package/dist/tui-v2/components/jobs/jobs-panel.js +23 -14
- package/dist/tui-v2/components/jobs/jobs-panel.js.map +1 -1
- package/dist/tui-v2/components/modal/confirm-modal.d.ts +1 -1
- package/dist/tui-v2/components/modal/confirm-modal.js +18 -7
- package/dist/tui-v2/components/modal/confirm-modal.js.map +1 -1
- package/dist/tui-v2/components/overlay/overlay-host.js +1 -1
- package/dist/tui-v2/components/overlay/overlay-host.js.map +1 -1
- package/dist/tui-v2/components/pager/pager.d.ts +6 -0
- package/dist/tui-v2/components/pager/pager.js +313 -67
- package/dist/tui-v2/components/pager/pager.js.map +1 -1
- package/dist/tui-v2/components/status/status-line.d.ts +9 -0
- package/dist/tui-v2/components/status/status-line.js +17 -3
- package/dist/tui-v2/components/status/status-line.js.map +1 -1
- package/dist/tui-v2/components/transcript/assistant-message.js +1 -1
- package/dist/tui-v2/components/transcript/assistant-message.js.map +1 -1
- package/dist/tui-v2/components/transcript/compacted-row.js +1 -1
- package/dist/tui-v2/components/transcript/compacted-row.js.map +1 -1
- package/dist/tui-v2/components/transcript/tool-card.d.ts +9 -1
- package/dist/tui-v2/components/transcript/tool-card.js +114 -9
- package/dist/tui-v2/components/transcript/tool-card.js.map +1 -1
- package/dist/tui-v2/components/transcript/transcript-row.js +2 -2
- package/dist/tui-v2/components/transcript/transcript-row.js.map +1 -1
- package/dist/tui-v2/composer/composer-editor.js +16 -0
- package/dist/tui-v2/composer/composer-editor.js.map +1 -1
- package/dist/tui-v2/controllers/overlay-controller.d.ts +16 -2
- package/dist/tui-v2/controllers/overlay-controller.js +92 -12
- package/dist/tui-v2/controllers/overlay-controller.js.map +1 -1
- package/dist/tui-v2/rendering/artifact-pager-source.d.ts +19 -0
- package/dist/tui-v2/rendering/artifact-pager-source.js +103 -0
- package/dist/tui-v2/rendering/artifact-pager-source.js.map +1 -0
- package/dist/tui-v2/rendering/file-diff-view.d.ts +63 -0
- package/dist/tui-v2/rendering/file-diff-view.js +263 -0
- package/dist/tui-v2/rendering/file-diff-view.js.map +1 -0
- package/dist/tui-v2/rendering/open-tool-output.d.ts +9 -1
- package/dist/tui-v2/rendering/open-tool-output.js +65 -12
- package/dist/tui-v2/rendering/open-tool-output.js.map +1 -1
- package/dist/tui-v2/rendering/pager-chrome.d.ts +12 -0
- package/dist/tui-v2/rendering/pager-chrome.js +56 -0
- package/dist/tui-v2/rendering/pager-chrome.js.map +1 -0
- package/dist/tui-v2/rendering/plan-view.js +1 -1
- package/dist/tui-v2/rendering/plan-view.js.map +1 -1
- package/dist/tui-v2/rendering/syntax-highlight.d.ts +37 -0
- package/dist/tui-v2/rendering/syntax-highlight.js +1303 -0
- package/dist/tui-v2/rendering/syntax-highlight.js.map +1 -0
- package/dist/tui-v2/rendering/theme.d.ts +28 -0
- package/dist/tui-v2/rendering/theme.js +28 -0
- package/dist/tui-v2/rendering/theme.js.map +1 -1
- package/dist/tui-v2/rendering/tool-presenter.d.ts +5 -0
- package/dist/tui-v2/rendering/tool-presenter.js +35 -3
- package/dist/tui-v2/rendering/tool-presenter.js.map +1 -1
- package/dist/tui-v2/state/transcript-hydrate.js +5 -0
- package/dist/tui-v2/state/transcript-hydrate.js.map +1 -1
- package/dist/tui-v2/state/transcript-reducer.js +12 -2
- package/dist/tui-v2/state/transcript-reducer.js.map +1 -1
- package/dist/tui-v2/state/transcript-store.d.ts +7 -0
- package/dist/tui-v2/state/transcript-store.js +46 -0
- package/dist/tui-v2/state/transcript-store.js.map +1 -1
- package/dist/tui-v2/state/transcript-types.d.ts +12 -0
- package/dist/tui-v2/state/transcript-types.js +9 -0
- package/dist/tui-v2/state/transcript-types.js.map +1 -1
- package/dist/types.d.ts +17 -1
- package/dist/ui/mentions.d.ts +6 -0
- package/dist/ui/mentions.js +50 -12
- package/dist/ui/mentions.js.map +1 -1
- package/dist/ui/plan-pane.js +1 -1
- package/dist/ui/plan-pane.js.map +1 -1
- package/package.json +18 -12
package/dist/repl.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Mode, ProviderId } from "./types.js";
|
|
2
|
+
import { type SessionPolicy } from "./modes/agent.js";
|
|
2
3
|
export { slashCommands, knownModels, getKnownModels, inferProviderForModel, looksLikeSlashCommand, getSlashCommandSuggestions, isKnownSlashCommand, type SlashCommand, } from "./repl/slash-commands.js";
|
|
3
4
|
export { renderSlashCommandMenu, renderFileMentionMenu, } from "./repl/prompt-line.js";
|
|
4
5
|
export interface ReplOptions {
|
|
@@ -7,4 +8,8 @@ export interface ReplOptions {
|
|
|
7
8
|
model?: string | undefined;
|
|
8
9
|
noHistory?: boolean | undefined;
|
|
9
10
|
}
|
|
11
|
+
/** Reset process-global project routing and rotate/adopt classic session identity together. */
|
|
12
|
+
export declare function resetClassicSessionContext(state: {
|
|
13
|
+
session: SessionPolicy;
|
|
14
|
+
}, sessionId?: string): void;
|
|
10
15
|
export declare function startRepl(options?: ReplOptions): Promise<void>;
|
package/dist/repl.js
CHANGED
|
@@ -3,12 +3,14 @@ import { stdin as input, stdout as output } from "node:process";
|
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import { confirm } from "@inquirer/prompts";
|
|
5
5
|
import { runAskStream } from "./modes/ask.js";
|
|
6
|
+
import { resolveTurnInput, shouldRunImageOcr } from "./attachments/service.js";
|
|
6
7
|
import { runAgent, createSessionPolicy, } from "./modes/agent.js";
|
|
7
8
|
import { attachClassicRenderer } from "./agent/classic-renderer.js";
|
|
9
|
+
import { clearActiveProjectRoot } from "./agent/project-root.js";
|
|
8
10
|
import { providerSwitcher, printProviderKeys, setKeyPicker, unsetKeyPicker, } from "./commands/providers.js";
|
|
9
11
|
import { printSearchProviderKeys, useSearchProvider, } from "./commands/search-providers.js";
|
|
10
12
|
import { getConfig, getProviderModel, setDefaultMode, setProviderModel, setThinking, updateConfig, } from "./store/config.js";
|
|
11
|
-
import { listSessions,
|
|
13
|
+
import { listSessions, upsertSession, clearAllHistory, getSession, } from "./store/history.js";
|
|
12
14
|
import { assertProvider, defaultModels, getProviderInfoText } from "./llm/provider.js";
|
|
13
15
|
import { getProvider, providerAuth } from "./llm/router.js";
|
|
14
16
|
import { clearTextOnlyModels } from "./llm/tool-protocol.js";
|
|
@@ -18,15 +20,16 @@ import { renderIntroCard } from "./ui/intro-card.js";
|
|
|
18
20
|
import { clearThinking, createThinkingStreamParser, getLastThinking, rememberThinkingFromText, renderAllThinking, renderThinkingSummary, renderThinkingToggleMessage, } from "./ui/thinking.js";
|
|
19
21
|
import { createMarkdownStreamWriter, renderMarkdown } from "./ui/markdown.js";
|
|
20
22
|
import { startThinkingSpinner } from "./ui/spinner.js";
|
|
21
|
-
import { modelSupportsThinking, modelSupportsVision,
|
|
23
|
+
import { modelSupportsThinking, modelSupportsVision, } from "./llm/capabilities.js";
|
|
22
24
|
import { clearViewports, getLastViewport, getViewport, isPagerActive, listViewports, openPager, openViewportPager, toggleViewport, } from "./ui/output-pane.js";
|
|
23
25
|
import { loadPlan, savePlan, deletePlan } from "./store/plan.js";
|
|
24
26
|
import { renderPlanDocument, renderPlanChecklist } from "./ui/plan-pane.js";
|
|
25
27
|
import { safeCwd, cwdIsBroken, recoverCwd } from "./os/cwd.js";
|
|
26
28
|
import { compactMessages, estimateMessagesTokens, } from "./agent/context-manager.js";
|
|
27
29
|
import { isCtrlC, isCtrlO, isCtrlP, isCtrlT, isEscape } from "./ui/keys.js";
|
|
28
|
-
import {
|
|
30
|
+
import { imageAttachmentPaths, } from "./ui/mentions.js";
|
|
29
31
|
import { imageOcr } from "./tools/image.js";
|
|
32
|
+
import { handleDraftPlanDecision, IMPLEMENT_DIRECTIVE, } from "./agent/plan-decision.js";
|
|
30
33
|
import { readPromptLine, stripAnsi, isPrintableSequence, } from "./repl/prompt-line.js";
|
|
31
34
|
import { slashCommands, knownModels, looksLikeSlashCommand, slashCommandLabel, } from "./repl/slash-commands.js";
|
|
32
35
|
// Re-exported so existing imports of these names from "./repl.js" keep
|
|
@@ -34,6 +37,11 @@ import { slashCommands, knownModels, looksLikeSlashCommand, slashCommandLabel, }
|
|
|
34
37
|
// editor now live in their own modules under "./repl/".
|
|
35
38
|
export { slashCommands, knownModels, getKnownModels, inferProviderForModel, looksLikeSlashCommand, getSlashCommandSuggestions, isKnownSlashCommand, } from "./repl/slash-commands.js";
|
|
36
39
|
export { renderSlashCommandMenu, renderFileMentionMenu, } from "./repl/prompt-line.js";
|
|
40
|
+
/** Reset process-global project routing and rotate/adopt classic session identity together. */
|
|
41
|
+
export function resetClassicSessionContext(state, sessionId) {
|
|
42
|
+
clearActiveProjectRoot();
|
|
43
|
+
state.session = createSessionPolicy(sessionId);
|
|
44
|
+
}
|
|
37
45
|
function splitCommand(line) {
|
|
38
46
|
return (line
|
|
39
47
|
.match(/(?:[^\s"]+|"[^"]*")+/g)
|
|
@@ -584,11 +592,8 @@ async function offerAgentSwitch(info, state, requestModel, images) {
|
|
|
584
592
|
* that same row instead of minting a fresh, unnamed duplicate.
|
|
585
593
|
*/
|
|
586
594
|
async function persistSession(state, name) {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
const record = await saveSession(state.messages, name);
|
|
595
|
+
const id = state.historyId ?? state.session.sessionId;
|
|
596
|
+
const record = await upsertSession(id, state.messages, name);
|
|
592
597
|
state.historyId = record.id;
|
|
593
598
|
}
|
|
594
599
|
async function handleSlash(line, state) {
|
|
@@ -789,6 +794,7 @@ async function handleSlash(line, state) {
|
|
|
789
794
|
console.log(chalk.dim(" current session saved"));
|
|
790
795
|
}
|
|
791
796
|
}
|
|
797
|
+
resetClassicSessionContext(state);
|
|
792
798
|
state.messages.length = 0;
|
|
793
799
|
state.resumedMessageCount = 0;
|
|
794
800
|
state.historyId = undefined;
|
|
@@ -833,6 +839,7 @@ async function handleSlash(line, state) {
|
|
|
833
839
|
console.log(chalk.dim(" cancelled"));
|
|
834
840
|
return true;
|
|
835
841
|
}
|
|
842
|
+
clearActiveProjectRoot();
|
|
836
843
|
// Load the selected session
|
|
837
844
|
const session = await getSession(selectedId);
|
|
838
845
|
if (!session) {
|
|
@@ -845,6 +852,7 @@ async function handleSlash(line, state) {
|
|
|
845
852
|
await persistSession(state);
|
|
846
853
|
}
|
|
847
854
|
}
|
|
855
|
+
resetClassicSessionContext(state, session.id);
|
|
848
856
|
// Replay messages
|
|
849
857
|
console.log(chalk.dim(`\n ── resuming session ──\n`));
|
|
850
858
|
for (const msg of session.messages) {
|
|
@@ -872,7 +880,7 @@ async function handleSlash(line, state) {
|
|
|
872
880
|
console.log(chalk.dim(` saved session ${state.historyId}`));
|
|
873
881
|
return true;
|
|
874
882
|
}
|
|
875
|
-
const record = await
|
|
883
|
+
const record = await upsertSession(state.session.sessionId, state.messages, name);
|
|
876
884
|
state.historyId = record.id;
|
|
877
885
|
console.log(chalk.dim(` saved session ${record.id}`));
|
|
878
886
|
return true;
|
|
@@ -950,20 +958,38 @@ async function handleSlash(line, state) {
|
|
|
950
958
|
return true;
|
|
951
959
|
}
|
|
952
960
|
case "/plan": {
|
|
953
|
-
const
|
|
954
|
-
if (!
|
|
955
|
-
|
|
961
|
+
const sub = (args[0] ?? "").toLowerCase();
|
|
962
|
+
if (!sub || sub === "mode" || sub === "on" || sub === "enter") {
|
|
963
|
+
state.mode = "plan";
|
|
964
|
+
setDefaultMode("plan");
|
|
965
|
+
console.log(renderModeSwitch("plan"));
|
|
966
|
+
console.log(chalk.dim(" plan mode on — describe the multi-step task you want to plan.\n"));
|
|
956
967
|
return true;
|
|
957
968
|
}
|
|
958
|
-
if (
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
969
|
+
if (sub === "off" || sub === "agent") {
|
|
970
|
+
state.mode = "agent";
|
|
971
|
+
setDefaultMode("agent");
|
|
972
|
+
console.log(renderModeSwitch("agent"));
|
|
973
|
+
return true;
|
|
963
974
|
}
|
|
964
|
-
|
|
965
|
-
|
|
975
|
+
if (sub === "view" || sub === "show") {
|
|
976
|
+
const plan = await loadPlan(state.session.sessionId).catch(() => undefined);
|
|
977
|
+
if (!plan) {
|
|
978
|
+
console.log(chalk.dim(" no active plan to view"));
|
|
979
|
+
return true;
|
|
980
|
+
}
|
|
981
|
+
if (process.stdout.isTTY && input.isTTY) {
|
|
982
|
+
await openPager({
|
|
983
|
+
title: `plan · ${plan.goal}`,
|
|
984
|
+
body: renderPlanDocument(plan),
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
else {
|
|
988
|
+
console.log(renderPlanDocument(plan));
|
|
989
|
+
}
|
|
990
|
+
return true;
|
|
966
991
|
}
|
|
992
|
+
console.log(chalk.dim(" usage: /plan [view|off]"));
|
|
967
993
|
return true;
|
|
968
994
|
}
|
|
969
995
|
case "/discard": {
|
|
@@ -1478,15 +1504,12 @@ export async function startRepl(options = {}) {
|
|
|
1478
1504
|
console.log(chalk.cyan(" ✦ plan approved — clai will now execute it\n"));
|
|
1479
1505
|
console.log(renderPlanChecklist(plan) + "\n");
|
|
1480
1506
|
implementApproved = true;
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
"Build the project for real with fs.writeMany (create all files in as few calls as possible). " +
|
|
1488
|
-
"Do NOT call web.search — you already know everything needed. " +
|
|
1489
|
-
"Run real commands (installs, servers, verification) — do not claim anything ran without a successful tool call.";
|
|
1507
|
+
if (state.mode === "plan") {
|
|
1508
|
+
state.mode = "agent";
|
|
1509
|
+
setDefaultMode("agent");
|
|
1510
|
+
console.log(renderModeSwitch("agent"));
|
|
1511
|
+
}
|
|
1512
|
+
effectiveLine = IMPLEMENT_DIRECTIVE;
|
|
1490
1513
|
}
|
|
1491
1514
|
// Continuation detection
|
|
1492
1515
|
// When the user types "continue" after the agent paused at a step limit,
|
|
@@ -1531,37 +1554,36 @@ export async function startRepl(options = {}) {
|
|
|
1531
1554
|
// Expand @file mentions and drag-and-dropped paths into real context.
|
|
1532
1555
|
// The user-visible `line` stays readable in history; the model gets
|
|
1533
1556
|
// the line plus an appended block of file contents / path notes.
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
}
|
|
1557
|
+
const resolvedInput = resolveTurnInput({
|
|
1558
|
+
prompt: effectiveLine,
|
|
1559
|
+
mode: state.mode,
|
|
1560
|
+
provider: state.provider,
|
|
1561
|
+
model: state.model,
|
|
1562
|
+
baseDir: safeCwd(),
|
|
1563
|
+
});
|
|
1564
|
+
const requestModel = resolvedInput.model;
|
|
1565
|
+
const visionCapable = modelSupportsVision(state.provider, requestModel);
|
|
1566
|
+
const expansion = { attachments: resolvedInput.attachments };
|
|
1567
|
+
const images = [...resolvedInput.images];
|
|
1568
|
+
if (resolvedInput.fallbackReason) {
|
|
1569
|
+
console.log(chalk.dim(` ↳ ${resolvedInput.fallbackReason}`));
|
|
1548
1570
|
}
|
|
1549
|
-
const
|
|
1550
|
-
? loadImageAttachments(effectiveLine, safeCwd())
|
|
1551
|
-
: [];
|
|
1571
|
+
const hasImageAttachment = expansion.attachments.some((att) => att.kind === "image");
|
|
1552
1572
|
const sentImagePaths = new Set(images.map((img) => img.path).filter((p) => Boolean(p)));
|
|
1553
|
-
//
|
|
1554
|
-
//
|
|
1555
|
-
//
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1573
|
+
// Vision is authoritative for visual analysis. OCR is opt-in when the
|
|
1574
|
+
// selected model cannot see the image and the user specifically asks
|
|
1575
|
+
// for text extraction; it is never treated as layout/color evidence.
|
|
1576
|
+
const shouldOcr = shouldRunImageOcr({
|
|
1577
|
+
hasImage: hasImageAttachment,
|
|
1578
|
+
visionCapable,
|
|
1579
|
+
prompt: effectiveLine,
|
|
1580
|
+
});
|
|
1581
|
+
const ocrGrounding = shouldOcr
|
|
1559
1582
|
? await buildImageOcrGrounding(effectiveLine, safeCwd())
|
|
1560
1583
|
: "";
|
|
1561
|
-
const
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
: effectiveLine;
|
|
1584
|
+
const modelInput = ocrGrounding
|
|
1585
|
+
? `${resolvedInput.prompt}\n\n${ocrGrounding}`
|
|
1586
|
+
: resolvedInput.prompt;
|
|
1565
1587
|
if (expansion.attachments.length > 0) {
|
|
1566
1588
|
for (const att of expansion.attachments) {
|
|
1567
1589
|
const tag = att.kind === "text"
|
|
@@ -1612,6 +1634,7 @@ export async function startRepl(options = {}) {
|
|
|
1612
1634
|
signal,
|
|
1613
1635
|
session: state.session,
|
|
1614
1636
|
images,
|
|
1637
|
+
mode: state.mode === "plan" ? "plan" : "agent",
|
|
1615
1638
|
onEvent: classicRenderer.onEvent,
|
|
1616
1639
|
}));
|
|
1617
1640
|
}
|
|
@@ -1626,6 +1649,97 @@ export async function startRepl(options = {}) {
|
|
|
1626
1649
|
role: "assistant",
|
|
1627
1650
|
content: assistantContent,
|
|
1628
1651
|
});
|
|
1652
|
+
// After plan mode (or any draft plan), offer Accept / Discard / View / Suggest.
|
|
1653
|
+
if (state.mode === "plan" || !state.session.planApproved.value) {
|
|
1654
|
+
const draft = await loadPlan(state.session.sessionId).catch(() => undefined);
|
|
1655
|
+
if (draft && draft.status === "draft") {
|
|
1656
|
+
input.pause();
|
|
1657
|
+
if (input.isTTY)
|
|
1658
|
+
input.setRawMode(false);
|
|
1659
|
+
try {
|
|
1660
|
+
const decision = await handleDraftPlanDecision({
|
|
1661
|
+
plan: draft,
|
|
1662
|
+
sessionId: state.session.sessionId,
|
|
1663
|
+
planApproved: state.session.planApproved,
|
|
1664
|
+
setModeAgent: () => {
|
|
1665
|
+
state.mode = "agent";
|
|
1666
|
+
setDefaultMode("agent");
|
|
1667
|
+
console.log(renderModeSwitch("agent"));
|
|
1668
|
+
},
|
|
1669
|
+
});
|
|
1670
|
+
if (decision.action === "implement") {
|
|
1671
|
+
const classicRenderer = attachClassicRenderer();
|
|
1672
|
+
const followUp = await withAbortableInput(async (signal) => runAgent(decision.line, {
|
|
1673
|
+
provider: state.provider,
|
|
1674
|
+
model: requestModel,
|
|
1675
|
+
history: state.messages,
|
|
1676
|
+
signal,
|
|
1677
|
+
session: state.session,
|
|
1678
|
+
mode: "agent",
|
|
1679
|
+
onEvent: classicRenderer.onEvent,
|
|
1680
|
+
}));
|
|
1681
|
+
console.log();
|
|
1682
|
+
state.messages.push({ role: "user", content: decision.line }, { role: "assistant", content: followUp });
|
|
1683
|
+
}
|
|
1684
|
+
else if (decision.action === "suggest") {
|
|
1685
|
+
state.mode = "plan";
|
|
1686
|
+
setDefaultMode("plan");
|
|
1687
|
+
const classicRenderer = attachClassicRenderer();
|
|
1688
|
+
const revision = await withAbortableInput(async (signal) => runAgent(decision.line, {
|
|
1689
|
+
provider: state.provider,
|
|
1690
|
+
model: requestModel,
|
|
1691
|
+
history: state.messages,
|
|
1692
|
+
signal,
|
|
1693
|
+
session: state.session,
|
|
1694
|
+
mode: "plan",
|
|
1695
|
+
onEvent: classicRenderer.onEvent,
|
|
1696
|
+
}));
|
|
1697
|
+
console.log();
|
|
1698
|
+
state.messages.push({ role: "user", content: decision.line }, { role: "assistant", content: revision });
|
|
1699
|
+
// Re-prompt if a new draft exists
|
|
1700
|
+
const revised = await loadPlan(state.session.sessionId).catch(() => undefined);
|
|
1701
|
+
if (revised && revised.status === "draft") {
|
|
1702
|
+
const again = await handleDraftPlanDecision({
|
|
1703
|
+
plan: revised,
|
|
1704
|
+
sessionId: state.session.sessionId,
|
|
1705
|
+
planApproved: state.session.planApproved,
|
|
1706
|
+
setModeAgent: () => {
|
|
1707
|
+
state.mode = "agent";
|
|
1708
|
+
setDefaultMode("agent");
|
|
1709
|
+
console.log(renderModeSwitch("agent"));
|
|
1710
|
+
},
|
|
1711
|
+
});
|
|
1712
|
+
if (again.action === "implement") {
|
|
1713
|
+
const classicRenderer2 = attachClassicRenderer();
|
|
1714
|
+
const followUp2 = await withAbortableInput(async (signal) => runAgent(again.line, {
|
|
1715
|
+
provider: state.provider,
|
|
1716
|
+
model: requestModel,
|
|
1717
|
+
history: state.messages,
|
|
1718
|
+
signal,
|
|
1719
|
+
session: state.session,
|
|
1720
|
+
mode: "agent",
|
|
1721
|
+
onEvent: classicRenderer2.onEvent,
|
|
1722
|
+
}));
|
|
1723
|
+
console.log();
|
|
1724
|
+
state.messages.push({ role: "user", content: again.line }, { role: "assistant", content: followUp2 });
|
|
1725
|
+
}
|
|
1726
|
+
else if (again.action === "suggest") {
|
|
1727
|
+
// Leave feedback in chat; next turn continues plan mode
|
|
1728
|
+
state.messages.push({
|
|
1729
|
+
role: "user",
|
|
1730
|
+
content: again.line,
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
finally {
|
|
1737
|
+
if (input.isTTY)
|
|
1738
|
+
input.setRawMode(true);
|
|
1739
|
+
input.resume();
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1629
1743
|
}
|
|
1630
1744
|
catch (error) {
|
|
1631
1745
|
if (error instanceof AbortRunError) {
|