wave-code 1.0.10 → 1.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/bin/wave-code.js +8 -2
- package/dist/bundle/wave.mjs +3207 -0
- package/package.json +24 -25
- package/src/commands/update.ts +2 -7
- package/src/components/App.tsx +3 -7
- package/src/components/BtwDisplay.tsx +10 -1
- package/src/components/ChatInterface.tsx +21 -52
- package/src/components/ConfirmationDetails.tsx +144 -37
- package/src/components/DiffDisplay.tsx +335 -301
- package/src/components/InputBox.tsx +3 -1
- package/src/components/LoadingIndicator.tsx +16 -2
- package/src/components/MessageBlockItem.tsx +2 -4
- package/src/components/MessageList.tsx +75 -14
- package/src/components/ReasoningDisplay.tsx +2 -4
- package/src/components/SessionSelector.tsx +82 -11
- package/src/components/StatusCommand.tsx +2 -9
- package/src/components/ToolDisplay.tsx +2 -4
- package/src/contexts/useChat.tsx +156 -335
- package/src/daemon/commands.ts +57 -27
- package/src/daemon/jsonRpcClient.ts +1 -1
- package/src/daemon/socketClient.ts +2 -2
- package/src/hooks/useInputManager.ts +1 -1
- package/src/index.ts +57 -10
- package/src/managers/inputReducer.ts +186 -104
- package/src/print-cli.ts +21 -17
- package/src/reducers/selectorReducer.ts +10 -0
- package/src/session-selector-cli.tsx +269 -28
- package/src/stdio/agentBridge.ts +22 -21
- package/src/stdio/daemonServer.ts +3 -1
- package/src/utils/clipboard.ts +21 -0
- package/src/utils/highlightUtils.ts +46 -1
- package/src/utils/readPackageJson.ts +29 -0
- package/src/utils/streamingText.ts +11 -0
- package/src/utils/worktree.ts +191 -43
- package/dist/cli.d.ts +0 -6
- package/dist/cli.js +0 -53
- package/dist/commands/plugin/disable.d.ts +0 -5
- package/dist/commands/plugin/disable.js +0 -15
- package/dist/commands/plugin/enable.d.ts +0 -5
- package/dist/commands/plugin/enable.js +0 -15
- package/dist/commands/plugin/install.d.ts +0 -5
- package/dist/commands/plugin/install.js +0 -21
- package/dist/commands/plugin/list.d.ts +0 -1
- package/dist/commands/plugin/list.js +0 -31
- package/dist/commands/plugin/marketplace.d.ts +0 -10
- package/dist/commands/plugin/marketplace.js +0 -90
- package/dist/commands/plugin/uninstall.d.ts +0 -3
- package/dist/commands/plugin/uninstall.js +0 -16
- package/dist/commands/plugin/update.d.ts +0 -3
- package/dist/commands/plugin/update.js +0 -15
- package/dist/commands/update.d.ts +0 -1
- package/dist/commands/update.js +0 -97
- package/dist/components/AgentsManager.d.ts +0 -7
- package/dist/components/AgentsManager.js +0 -109
- package/dist/components/App.d.ts +0 -9
- package/dist/components/App.js +0 -76
- package/dist/components/BackgroundTaskManager.d.ts +0 -5
- package/dist/components/BackgroundTaskManager.js +0 -99
- package/dist/components/BangDisplay.d.ts +0 -8
- package/dist/components/BangDisplay.js +0 -17
- package/dist/components/BtwDisplay.d.ts +0 -7
- package/dist/components/BtwDisplay.js +0 -19
- package/dist/components/ChatInterface.d.ts +0 -2
- package/dist/components/ChatInterface.js +0 -61
- package/dist/components/CommandSelector.d.ts +0 -10
- package/dist/components/CommandSelector.js +0 -66
- package/dist/components/CompactDisplay.d.ts +0 -8
- package/dist/components/CompactDisplay.js +0 -13
- package/dist/components/ConfirmationDetails.d.ts +0 -9
- package/dist/components/ConfirmationDetails.js +0 -45
- package/dist/components/ConfirmationSelector.d.ts +0 -13
- package/dist/components/ConfirmationSelector.js +0 -127
- package/dist/components/DiffDisplay.d.ts +0 -8
- package/dist/components/DiffDisplay.js +0 -201
- package/dist/components/DiscoverView.d.ts +0 -2
- package/dist/components/DiscoverView.js +0 -37
- package/dist/components/FileSelector.d.ts +0 -11
- package/dist/components/FileSelector.js +0 -50
- package/dist/components/HelpView.d.ts +0 -7
- package/dist/components/HelpView.js +0 -74
- package/dist/components/HistorySearch.d.ts +0 -8
- package/dist/components/HistorySearch.js +0 -66
- package/dist/components/InputBox.d.ts +0 -24
- package/dist/components/InputBox.js +0 -149
- package/dist/components/InstalledView.d.ts +0 -2
- package/dist/components/InstalledView.js +0 -45
- package/dist/components/LoadingIndicator.d.ts +0 -10
- package/dist/components/LoadingIndicator.js +0 -6
- package/dist/components/LoginCommand.d.ts +0 -5
- package/dist/components/LoginCommand.js +0 -153
- package/dist/components/Markdown.d.ts +0 -5
- package/dist/components/Markdown.js +0 -127
- package/dist/components/MarketplaceAddForm.d.ts +0 -2
- package/dist/components/MarketplaceAddForm.js +0 -55
- package/dist/components/MarketplaceDetail.d.ts +0 -2
- package/dist/components/MarketplaceDetail.js +0 -74
- package/dist/components/MarketplaceList.d.ts +0 -8
- package/dist/components/MarketplaceList.js +0 -17
- package/dist/components/MarketplaceView.d.ts +0 -2
- package/dist/components/MarketplaceView.js +0 -41
- package/dist/components/McpManager.d.ts +0 -9
- package/dist/components/McpManager.js +0 -88
- package/dist/components/MessageBlockItem.d.ts +0 -8
- package/dist/components/MessageBlockItem.js +0 -15
- package/dist/components/MessageList.d.ts +0 -10
- package/dist/components/MessageList.js +0 -80
- package/dist/components/ModelSelector.d.ts +0 -8
- package/dist/components/ModelSelector.js +0 -45
- package/dist/components/Notifications.d.ts +0 -7
- package/dist/components/Notifications.js +0 -9
- package/dist/components/PlanDisplay.d.ts +0 -7
- package/dist/components/PlanDisplay.js +0 -6
- package/dist/components/PluginDetail.d.ts +0 -2
- package/dist/components/PluginDetail.js +0 -87
- package/dist/components/PluginList.d.ts +0 -13
- package/dist/components/PluginList.js +0 -15
- package/dist/components/PluginManagerShell.d.ts +0 -6
- package/dist/components/PluginManagerShell.js +0 -92
- package/dist/components/PluginManagerTypes.d.ts +0 -35
- package/dist/components/PluginManagerTypes.js +0 -1
- package/dist/components/QueuedMessageList.d.ts +0 -2
- package/dist/components/QueuedMessageList.js +0 -18
- package/dist/components/ReasoningDisplay.d.ts +0 -8
- package/dist/components/ReasoningDisplay.js +0 -13
- package/dist/components/RewindCommand.d.ts +0 -12
- package/dist/components/RewindCommand.js +0 -78
- package/dist/components/SessionSelector.d.ts +0 -12
- package/dist/components/SessionSelector.js +0 -47
- package/dist/components/StatusCommand.d.ts +0 -5
- package/dist/components/StatusCommand.js +0 -28
- package/dist/components/StatusLine.d.ts +0 -6
- package/dist/components/StatusLine.js +0 -9
- package/dist/components/TaskList.d.ts +0 -5
- package/dist/components/TaskList.js +0 -197
- package/dist/components/TaskNotificationMessage.d.ts +0 -5
- package/dist/components/TaskNotificationMessage.js +0 -12
- package/dist/components/ToolDisplay.d.ts +0 -9
- package/dist/components/ToolDisplay.js +0 -55
- package/dist/components/WorkflowManager.d.ts +0 -5
- package/dist/components/WorkflowManager.js +0 -102
- package/dist/components/WorktreeExitPrompt.d.ts +0 -12
- package/dist/components/WorktreeExitPrompt.js +0 -35
- package/dist/constants/commands.d.ts +0 -2
- package/dist/constants/commands.js +0 -92
- package/dist/contexts/PluginManagerContext.d.ts +0 -3
- package/dist/contexts/PluginManagerContext.js +0 -9
- package/dist/contexts/useAppConfig.d.ts +0 -10
- package/dist/contexts/useAppConfig.js +0 -13
- package/dist/contexts/useChat.d.ts +0 -101
- package/dist/contexts/useChat.js +0 -993
- package/dist/contracts/status.d.ts +0 -7
- package/dist/contracts/status.js +0 -1
- package/dist/daemon/commands.d.ts +0 -49
- package/dist/daemon/commands.js +0 -341
- package/dist/daemon/jsonRpcClient.d.ts +0 -38
- package/dist/daemon/jsonRpcClient.js +0 -129
- package/dist/daemon/socketClient.d.ts +0 -13
- package/dist/daemon/socketClient.js +0 -26
- package/dist/daemon-cli.d.ts +0 -10
- package/dist/daemon-cli.js +0 -15
- package/dist/hooks/useInputManager.d.ts +0 -75
- package/dist/hooks/useInputManager.js +0 -583
- package/dist/hooks/usePluginManager.d.ts +0 -4
- package/dist/hooks/usePluginManager.js +0 -265
- package/dist/hooks/useTasks.d.ts +0 -1
- package/dist/hooks/useTasks.js +0 -5
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -447
- package/dist/managers/inputHandlers.d.ts +0 -30
- package/dist/managers/inputHandlers.js +0 -625
- package/dist/managers/inputReducer.d.ts +0 -271
- package/dist/managers/inputReducer.js +0 -1121
- package/dist/plugin-manager-cli.d.ts +0 -5
- package/dist/plugin-manager-cli.js +0 -12
- package/dist/print-cli.d.ts +0 -10
- package/dist/print-cli.js +0 -209
- package/dist/reducers/agentsManagerReducer.d.ts +0 -26
- package/dist/reducers/agentsManagerReducer.js +0 -54
- package/dist/reducers/backgroundTaskManagerReducer.d.ts +0 -62
- package/dist/reducers/backgroundTaskManagerReducer.js +0 -106
- package/dist/reducers/confirmationReducer.d.ts +0 -37
- package/dist/reducers/confirmationReducer.js +0 -193
- package/dist/reducers/helpSelectorReducer.d.ts +0 -25
- package/dist/reducers/helpSelectorReducer.js +0 -52
- package/dist/reducers/marketplaceAddFormReducer.d.ts +0 -24
- package/dist/reducers/marketplaceAddFormReducer.js +0 -58
- package/dist/reducers/mcpManagerReducer.d.ts +0 -37
- package/dist/reducers/mcpManagerReducer.js +0 -74
- package/dist/reducers/pluginDetailReducer.d.ts +0 -32
- package/dist/reducers/pluginDetailReducer.js +0 -70
- package/dist/reducers/questionReducer.d.ts +0 -82
- package/dist/reducers/questionReducer.js +0 -375
- package/dist/reducers/rewindSelectorReducer.d.ts +0 -21
- package/dist/reducers/rewindSelectorReducer.js +0 -37
- package/dist/reducers/selectorReducer.d.ts +0 -23
- package/dist/reducers/selectorReducer.js +0 -42
- package/dist/reducers/workflowManagerReducer.d.ts +0 -40
- package/dist/reducers/workflowManagerReducer.js +0 -100
- package/dist/session-selector-cli.d.ts +0 -3
- package/dist/session-selector-cli.js +0 -25
- package/dist/stdio/agentBridge.d.ts +0 -139
- package/dist/stdio/agentBridge.js +0 -999
- package/dist/stdio/daemonServer.d.ts +0 -67
- package/dist/stdio/daemonServer.js +0 -191
- package/dist/stdio/index.d.ts +0 -5
- package/dist/stdio/index.js +0 -5
- package/dist/stdio/jsonRpcConnection.d.ts +0 -39
- package/dist/stdio/jsonRpcConnection.js +0 -135
- package/dist/stdio/protocol.d.ts +0 -41
- package/dist/stdio/protocol.js +0 -26
- package/dist/stdio/stdioServer.d.ts +0 -36
- package/dist/stdio/stdioServer.js +0 -51
- package/dist/stdio-cli.d.ts +0 -8
- package/dist/stdio-cli.js +0 -15
- package/dist/types.d.ts +0 -20
- package/dist/types.js +0 -1
- package/dist/utils/bracketedPaste.d.ts +0 -39
- package/dist/utils/bracketedPaste.js +0 -122
- package/dist/utils/clipboard.d.ts +0 -21
- package/dist/utils/clipboard.js +0 -347
- package/dist/utils/constants.d.ts +0 -16
- package/dist/utils/constants.js +0 -18
- package/dist/utils/highlightUtils.d.ts +0 -1
- package/dist/utils/highlightUtils.js +0 -93
- package/dist/utils/inputUtils.d.ts +0 -17
- package/dist/utils/inputUtils.js +0 -67
- package/dist/utils/logger.d.ts +0 -71
- package/dist/utils/logger.js +0 -259
- package/dist/utils/markdownTable.d.ts +0 -34
- package/dist/utils/markdownTable.js +0 -302
- package/dist/utils/rewindCheckpoints.d.ts +0 -8
- package/dist/utils/rewindCheckpoints.js +0 -17
- package/dist/utils/throttle.d.ts +0 -14
- package/dist/utils/throttle.js +0 -55
- package/dist/utils/toolParameterTransforms.d.ts +0 -18
- package/dist/utils/toolParameterTransforms.js +0 -73
- package/dist/utils/usageSummary.d.ts +0 -28
- package/dist/utils/usageSummary.js +0 -121
- package/dist/utils/version.d.ts +0 -1
- package/dist/utils/version.js +0 -4
- package/dist/utils/worktree.d.ts +0 -35
- package/dist/utils/worktree.js +0 -219
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render } from "ink";
|
|
3
|
-
import { PluginManagerShell } from "./components/PluginManagerShell.js";
|
|
4
|
-
/**
|
|
5
|
-
* Entry point for the Plugin Manager CLI.
|
|
6
|
-
* Renders the Ink component and handles the lifecycle.
|
|
7
|
-
*/
|
|
8
|
-
export async function startPluginManagerCli() {
|
|
9
|
-
const { waitUntilExit } = render(_jsx(PluginManagerShell, {}));
|
|
10
|
-
await waitUntilExit();
|
|
11
|
-
return true;
|
|
12
|
-
}
|
package/dist/print-cli.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BaseAppProps } from "./types.js";
|
|
2
|
-
export interface PrintCliOptions extends BaseAppProps {
|
|
3
|
-
restoreSessionId?: string;
|
|
4
|
-
continueLastSession?: boolean;
|
|
5
|
-
message?: string;
|
|
6
|
-
showStats?: boolean;
|
|
7
|
-
/** MCP server config parsed from --mcp-config CLI argument */
|
|
8
|
-
mcpServers?: Record<string, import("wave-agent-sdk").McpServerConfig>;
|
|
9
|
-
}
|
|
10
|
-
export declare function startPrintCli(options: PrintCliOptions): Promise<void>;
|
package/dist/print-cli.js
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { Agent, hasUncommittedChanges, hasNewCommits, getDefaultRemoteBranch, validateWorktreeRemovalPath, } from "wave-agent-sdk";
|
|
2
|
-
import { displayUsageSummary } from "./utils/usageSummary.js";
|
|
3
|
-
import { removeWorktree } from "./utils/worktree.js";
|
|
4
|
-
function displayTimingInfo(startTime, showStats) {
|
|
5
|
-
// Skip timing info in test environment or if stats are disabled
|
|
6
|
-
if (process.env.NODE_ENV === "test" || process.env.VITEST || !showStats) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
const endTime = new Date();
|
|
10
|
-
const duration = endTime.getTime() - startTime.getTime();
|
|
11
|
-
process.stdout.write(`\n\n📅 Start time: ${startTime.toISOString()}\n`);
|
|
12
|
-
process.stdout.write(`📅 End time: ${endTime.toISOString()}\n`);
|
|
13
|
-
process.stdout.write(`⏱️ Duration: ${duration}ms\n`);
|
|
14
|
-
}
|
|
15
|
-
export async function startPrintCli(options) {
|
|
16
|
-
const startTime = new Date();
|
|
17
|
-
const { restoreSessionId, continueLastSession, message, showStats = false, bypassPermissions, permissionMode, pluginDirs, additionalDirectories, tools, allowedTools, disallowedTools, worktreeSession, workdir, originalCwd, model, mcpServers, } = options;
|
|
18
|
-
if ((typeof message !== "string" || message.trim() === "") &&
|
|
19
|
-
!continueLastSession &&
|
|
20
|
-
!restoreSessionId) {
|
|
21
|
-
console.error("Print mode requires a message: use --print 'your message' or -p 'your message'");
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
let agent;
|
|
25
|
-
let isReasoning = false;
|
|
26
|
-
let isContent = false;
|
|
27
|
-
// Setup callbacks for agent
|
|
28
|
-
// Print mode only outputs the main agent's response (matching Claude Code's
|
|
29
|
-
// behavior). Subagent output is internal — the main agent incorporates
|
|
30
|
-
// relevant results in its own response.
|
|
31
|
-
const callbacks = {
|
|
32
|
-
onAssistantMessageAdded: () => {
|
|
33
|
-
isReasoning = false;
|
|
34
|
-
isContent = false;
|
|
35
|
-
},
|
|
36
|
-
onAssistantReasoningUpdated: (params) => {
|
|
37
|
-
if (!isReasoning) {
|
|
38
|
-
process.stdout.write("\n💭 Reasoning:\n");
|
|
39
|
-
isReasoning = true;
|
|
40
|
-
}
|
|
41
|
-
process.stdout.write(params.chunk);
|
|
42
|
-
},
|
|
43
|
-
onAssistantContentUpdated: (params) => {
|
|
44
|
-
if (!isContent) {
|
|
45
|
-
if (isReasoning) {
|
|
46
|
-
process.stdout.write("\n\n📝 Response:\n");
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
process.stdout.write("\n");
|
|
50
|
-
}
|
|
51
|
-
isContent = true;
|
|
52
|
-
}
|
|
53
|
-
process.stdout.write(params.chunk);
|
|
54
|
-
},
|
|
55
|
-
// Tool block callback - display tool name when tool starts
|
|
56
|
-
onToolBlockUpdated: (params) => {
|
|
57
|
-
// Print tool name only during 'running' stage (happens once per tool call)
|
|
58
|
-
if (params.stage === "running" && params.name) {
|
|
59
|
-
process.stdout.write(`\n🔧 ${params.name}`);
|
|
60
|
-
if (params.compactParams) {
|
|
61
|
-
process.stdout.write(` ${params.compactParams}`);
|
|
62
|
-
}
|
|
63
|
-
process.stdout.write(`\n`);
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
// Error block callback
|
|
67
|
-
onErrorBlockAdded: (error) => {
|
|
68
|
-
// Display error blocks with distinct formatting
|
|
69
|
-
process.stdout.write(`\n❌ Error: ${error}\n`);
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
try {
|
|
73
|
-
// Initialize agent
|
|
74
|
-
agent = await Agent.create({
|
|
75
|
-
callbacks,
|
|
76
|
-
restoreSessionId,
|
|
77
|
-
continueLastSession,
|
|
78
|
-
permissionMode: permissionMode || (bypassPermissions ? "bypassPermissions" : undefined),
|
|
79
|
-
plugins: pluginDirs?.map((path) => ({ type: "local", path })),
|
|
80
|
-
additionalDirectories,
|
|
81
|
-
tools,
|
|
82
|
-
allowedTools,
|
|
83
|
-
disallowedTools,
|
|
84
|
-
workdir,
|
|
85
|
-
worktreeName: worktreeSession?.name,
|
|
86
|
-
isNewWorktree: worktreeSession?.isNew,
|
|
87
|
-
model,
|
|
88
|
-
mcpServers,
|
|
89
|
-
// 保持流式模式以获得更好的命令行用户体验
|
|
90
|
-
});
|
|
91
|
-
// Inject worktree session into this agent's container (per-session, not global)
|
|
92
|
-
if (worktreeSession) {
|
|
93
|
-
const session = {
|
|
94
|
-
originalCwd: originalCwd ?? worktreeSession.repoRoot,
|
|
95
|
-
worktreePath: worktreeSession.path,
|
|
96
|
-
worktreeBranch: worktreeSession.branch,
|
|
97
|
-
worktreeName: worktreeSession.name,
|
|
98
|
-
isNew: worktreeSession.isNew,
|
|
99
|
-
repoRoot: worktreeSession.repoRoot,
|
|
100
|
-
};
|
|
101
|
-
agent.setWorktreeSession(session);
|
|
102
|
-
}
|
|
103
|
-
// Send message if provided and not empty
|
|
104
|
-
if (typeof message === "string" && message.trim() !== "") {
|
|
105
|
-
await agent.sendMessage(message);
|
|
106
|
-
process.stdout.write("\n");
|
|
107
|
-
}
|
|
108
|
-
// Wait for running background tasks/subagents to complete AND for the main
|
|
109
|
-
// agent to finish processing their completion notifications. The last
|
|
110
|
-
// background task flips status to "completed" before its notification is
|
|
111
|
-
// enqueued and before the main agent's follow-up turn runs, so
|
|
112
|
-
// hasRunningBackgroundWork alone becomes false while the main agent is
|
|
113
|
-
// still mid-turn — causing a TOCTOU race that aborts the final response.
|
|
114
|
-
// Including isLoading and queued notifications closes that gap.
|
|
115
|
-
while (agent.hasRunningBackgroundWork ||
|
|
116
|
-
agent.isLoading ||
|
|
117
|
-
agent.hasPendingMessages) {
|
|
118
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
119
|
-
}
|
|
120
|
-
// Display usage summary before exit
|
|
121
|
-
if (showStats) {
|
|
122
|
-
try {
|
|
123
|
-
const usages = agent.usages;
|
|
124
|
-
const sessionFilePath = agent.sessionFilePath;
|
|
125
|
-
displayUsageSummary(usages, sessionFilePath);
|
|
126
|
-
}
|
|
127
|
-
catch {
|
|
128
|
-
// Silently ignore usage summary errors
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
// Display timing information
|
|
132
|
-
displayTimingInfo(startTime, showStats);
|
|
133
|
-
// Trigger WorktreeRemove hook (before destroy — it needs a live agent) and
|
|
134
|
-
// decide whether the worktree is clean enough to remove
|
|
135
|
-
let cleanWorktree = false;
|
|
136
|
-
if (worktreeSession) {
|
|
137
|
-
const cwd = workdir || worktreeSession.path;
|
|
138
|
-
const baseBranch = getDefaultRemoteBranch(cwd);
|
|
139
|
-
const hasChanges = hasUncommittedChanges(cwd);
|
|
140
|
-
const hasCommits = hasNewCommits(cwd, baseBranch);
|
|
141
|
-
cleanWorktree = !hasChanges && !hasCommits;
|
|
142
|
-
if (cleanWorktree) {
|
|
143
|
-
await agent.triggerWorktreeRemoveHook(worktreeSession.path);
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
process.stdout.write(`\n⚠️ Worktree '${worktreeSession.name}' has changes or commits. Keeping it at: ${worktreeSession.path}\n`);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
// Destroy agent and exit after sendMessage completes
|
|
150
|
-
await agent.destroy();
|
|
151
|
-
// Handle worktree cleanup for print mode (git removal stays after destroy)
|
|
152
|
-
if (worktreeSession && cleanWorktree) {
|
|
153
|
-
try {
|
|
154
|
-
validateWorktreeRemovalPath(worktreeSession.path, worktreeSession.repoRoot);
|
|
155
|
-
await removeWorktree(worktreeSession);
|
|
156
|
-
}
|
|
157
|
-
catch (error) {
|
|
158
|
-
// Never block print-mode exit on worktree cleanup failures
|
|
159
|
-
process.stdout.write(`\n⚠️ Skipping worktree removal: ${error.message}\n`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
process.exit(0);
|
|
163
|
-
}
|
|
164
|
-
catch (error) {
|
|
165
|
-
console.error("Failed to send message:", error);
|
|
166
|
-
if (agent) {
|
|
167
|
-
// Display usage summary even on error
|
|
168
|
-
if (showStats) {
|
|
169
|
-
try {
|
|
170
|
-
const usages = agent.usages;
|
|
171
|
-
const sessionFilePath = agent.sessionFilePath;
|
|
172
|
-
displayUsageSummary(usages, sessionFilePath);
|
|
173
|
-
}
|
|
174
|
-
catch {
|
|
175
|
-
// Silently ignore usage summary errors
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
// Display timing information even on error
|
|
179
|
-
displayTimingInfo(startTime, showStats);
|
|
180
|
-
// Trigger WorktreeRemove hook (before destroy) when the worktree is clean
|
|
181
|
-
let cleanWorktree = false;
|
|
182
|
-
if (worktreeSession) {
|
|
183
|
-
const cwd = workdir || worktreeSession.path;
|
|
184
|
-
const baseBranch = getDefaultRemoteBranch(cwd);
|
|
185
|
-
const hasChanges = hasUncommittedChanges(cwd);
|
|
186
|
-
const hasCommits = hasNewCommits(cwd, baseBranch);
|
|
187
|
-
cleanWorktree = !hasChanges && !hasCommits;
|
|
188
|
-
if (cleanWorktree) {
|
|
189
|
-
await agent.triggerWorktreeRemoveHook(worktreeSession.path);
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
process.stdout.write(`\n⚠️ Worktree '${worktreeSession.name}' has changes or commits. Keeping it at: ${worktreeSession.path}\n`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
await agent.destroy();
|
|
196
|
-
// Handle worktree cleanup for print mode even on error
|
|
197
|
-
if (worktreeSession && cleanWorktree) {
|
|
198
|
-
try {
|
|
199
|
-
validateWorktreeRemovalPath(worktreeSession.path, worktreeSession.repoRoot);
|
|
200
|
-
await removeWorktree(worktreeSession);
|
|
201
|
-
}
|
|
202
|
-
catch (error) {
|
|
203
|
-
process.stdout.write(`\n⚠️ Skipping worktree removal: ${error.message}\n`);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
process.exit(1);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Key } from "ink";
|
|
2
|
-
export type PendingEffect = {
|
|
3
|
-
type: "CANCEL";
|
|
4
|
-
};
|
|
5
|
-
export interface AgentsManagerState {
|
|
6
|
-
selectedIndex: number;
|
|
7
|
-
viewMode: "list" | "detail";
|
|
8
|
-
pendingEffect: PendingEffect | null;
|
|
9
|
-
}
|
|
10
|
-
export type AgentsManagerAction = {
|
|
11
|
-
type: "MOVE_UP";
|
|
12
|
-
} | {
|
|
13
|
-
type: "MOVE_DOWN";
|
|
14
|
-
itemCount: number;
|
|
15
|
-
} | {
|
|
16
|
-
type: "SET_VIEW_MODE";
|
|
17
|
-
viewMode: "list" | "detail";
|
|
18
|
-
} | {
|
|
19
|
-
type: "HANDLE_KEY";
|
|
20
|
-
input: string;
|
|
21
|
-
key: Key;
|
|
22
|
-
itemCount: number;
|
|
23
|
-
} | {
|
|
24
|
-
type: "CLEAR_PENDING_EFFECT";
|
|
25
|
-
};
|
|
26
|
-
export declare function agentsManagerReducer(state: AgentsManagerState, action: AgentsManagerAction): AgentsManagerState;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export function agentsManagerReducer(state, action) {
|
|
2
|
-
switch (action.type) {
|
|
3
|
-
case "MOVE_UP":
|
|
4
|
-
return {
|
|
5
|
-
...state,
|
|
6
|
-
selectedIndex: Math.max(0, state.selectedIndex - 1),
|
|
7
|
-
};
|
|
8
|
-
case "MOVE_DOWN":
|
|
9
|
-
return {
|
|
10
|
-
...state,
|
|
11
|
-
selectedIndex: Math.min(Math.max(0, action.itemCount - 1), state.selectedIndex + 1),
|
|
12
|
-
};
|
|
13
|
-
case "SET_VIEW_MODE":
|
|
14
|
-
return { ...state, viewMode: action.viewMode };
|
|
15
|
-
case "HANDLE_KEY": {
|
|
16
|
-
const { key, itemCount } = action;
|
|
17
|
-
if (key.return) {
|
|
18
|
-
if (state.viewMode === "list") {
|
|
19
|
-
return { ...state, viewMode: "detail" };
|
|
20
|
-
}
|
|
21
|
-
// Aligned with Claude Code AgentDetail: Enter returns to the list.
|
|
22
|
-
return { ...state, viewMode: "list" };
|
|
23
|
-
}
|
|
24
|
-
if (key.escape) {
|
|
25
|
-
if (state.viewMode === "detail") {
|
|
26
|
-
return { ...state, viewMode: "list" };
|
|
27
|
-
}
|
|
28
|
-
return { ...state, pendingEffect: { type: "CANCEL" } };
|
|
29
|
-
}
|
|
30
|
-
// Detail view does not respond to arrow keys (aligned with CC
|
|
31
|
-
// AgentDetail, which only Esc/Enter back to the list).
|
|
32
|
-
if (state.viewMode === "detail") {
|
|
33
|
-
return state;
|
|
34
|
-
}
|
|
35
|
-
if (key.upArrow) {
|
|
36
|
-
return {
|
|
37
|
-
...state,
|
|
38
|
-
selectedIndex: Math.max(0, state.selectedIndex - 1),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
if (key.downArrow) {
|
|
42
|
-
return {
|
|
43
|
-
...state,
|
|
44
|
-
selectedIndex: Math.min(Math.max(0, itemCount - 1), state.selectedIndex + 1),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return state;
|
|
48
|
-
}
|
|
49
|
-
case "CLEAR_PENDING_EFFECT":
|
|
50
|
-
return { ...state, pendingEffect: null };
|
|
51
|
-
default:
|
|
52
|
-
return state;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Key } from "ink";
|
|
2
|
-
export interface Task {
|
|
3
|
-
id: string;
|
|
4
|
-
type: string;
|
|
5
|
-
description?: string;
|
|
6
|
-
status: "running" | "completed" | "failed" | "killed";
|
|
7
|
-
startTime: number;
|
|
8
|
-
exitCode?: number;
|
|
9
|
-
runtime?: number;
|
|
10
|
-
outputPath?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface DetailOutput {
|
|
13
|
-
stdout: string;
|
|
14
|
-
stderr: string;
|
|
15
|
-
status: string;
|
|
16
|
-
outputPath?: string;
|
|
17
|
-
}
|
|
18
|
-
export type PendingEffect = {
|
|
19
|
-
type: "CANCEL";
|
|
20
|
-
} | {
|
|
21
|
-
type: "STOP_TASK";
|
|
22
|
-
taskId: string;
|
|
23
|
-
};
|
|
24
|
-
export interface BackgroundTaskManagerState {
|
|
25
|
-
tasks: Task[];
|
|
26
|
-
selectedIndex: number;
|
|
27
|
-
viewMode: "list" | "detail";
|
|
28
|
-
detailTaskId: string | null;
|
|
29
|
-
detailOutput: DetailOutput | null;
|
|
30
|
-
pendingEffect: PendingEffect | null;
|
|
31
|
-
}
|
|
32
|
-
export type BackgroundTaskManagerAction = {
|
|
33
|
-
type: "SET_TASKS";
|
|
34
|
-
tasks: Task[];
|
|
35
|
-
} | {
|
|
36
|
-
type: "SELECT_INDEX";
|
|
37
|
-
index: number;
|
|
38
|
-
} | {
|
|
39
|
-
type: "MOVE_UP";
|
|
40
|
-
} | {
|
|
41
|
-
type: "MOVE_DOWN";
|
|
42
|
-
} | {
|
|
43
|
-
type: "SELECT_CURRENT";
|
|
44
|
-
} | {
|
|
45
|
-
type: "SET_VIEW_MODE";
|
|
46
|
-
mode: "list" | "detail";
|
|
47
|
-
} | {
|
|
48
|
-
type: "SET_DETAIL_TASK_ID";
|
|
49
|
-
id: string | null;
|
|
50
|
-
} | {
|
|
51
|
-
type: "SET_DETAIL_OUTPUT";
|
|
52
|
-
output: DetailOutput | null;
|
|
53
|
-
} | {
|
|
54
|
-
type: "RESET_DETAIL";
|
|
55
|
-
} | {
|
|
56
|
-
type: "HANDLE_KEY";
|
|
57
|
-
input: string;
|
|
58
|
-
key: Key;
|
|
59
|
-
} | {
|
|
60
|
-
type: "CLEAR_PENDING_EFFECT";
|
|
61
|
-
};
|
|
62
|
-
export declare function backgroundTaskManagerReducer(state: BackgroundTaskManagerState, action: BackgroundTaskManagerAction): BackgroundTaskManagerState;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
export function backgroundTaskManagerReducer(state, action) {
|
|
2
|
-
switch (action.type) {
|
|
3
|
-
case "SET_TASKS":
|
|
4
|
-
return { ...state, tasks: action.tasks };
|
|
5
|
-
case "SELECT_INDEX":
|
|
6
|
-
return { ...state, selectedIndex: action.index };
|
|
7
|
-
case "MOVE_UP":
|
|
8
|
-
return { ...state, selectedIndex: Math.max(0, state.selectedIndex - 1) };
|
|
9
|
-
case "MOVE_DOWN":
|
|
10
|
-
return {
|
|
11
|
-
...state,
|
|
12
|
-
selectedIndex: Math.min(state.tasks.length > 0 ? state.tasks.length - 1 : 0, state.selectedIndex + 1),
|
|
13
|
-
};
|
|
14
|
-
case "SELECT_CURRENT":
|
|
15
|
-
if (state.tasks.length > 0 && state.selectedIndex < state.tasks.length) {
|
|
16
|
-
return {
|
|
17
|
-
...state,
|
|
18
|
-
detailTaskId: state.tasks[state.selectedIndex].id,
|
|
19
|
-
viewMode: "detail",
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
return state;
|
|
23
|
-
case "SET_VIEW_MODE":
|
|
24
|
-
return { ...state, viewMode: action.mode };
|
|
25
|
-
case "SET_DETAIL_TASK_ID":
|
|
26
|
-
return { ...state, detailTaskId: action.id };
|
|
27
|
-
case "SET_DETAIL_OUTPUT":
|
|
28
|
-
return { ...state, detailOutput: action.output };
|
|
29
|
-
case "RESET_DETAIL":
|
|
30
|
-
return {
|
|
31
|
-
...state,
|
|
32
|
-
viewMode: "list",
|
|
33
|
-
detailTaskId: null,
|
|
34
|
-
detailOutput: null,
|
|
35
|
-
};
|
|
36
|
-
case "HANDLE_KEY": {
|
|
37
|
-
const { input, key } = action;
|
|
38
|
-
if (state.viewMode === "list") {
|
|
39
|
-
if (key.return) {
|
|
40
|
-
if (state.tasks.length > 0 &&
|
|
41
|
-
state.selectedIndex < state.tasks.length) {
|
|
42
|
-
return {
|
|
43
|
-
...state,
|
|
44
|
-
detailTaskId: state.tasks[state.selectedIndex].id,
|
|
45
|
-
viewMode: "detail",
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
return state;
|
|
49
|
-
}
|
|
50
|
-
if (key.escape) {
|
|
51
|
-
return { ...state, pendingEffect: { type: "CANCEL" } };
|
|
52
|
-
}
|
|
53
|
-
if (key.upArrow) {
|
|
54
|
-
return {
|
|
55
|
-
...state,
|
|
56
|
-
selectedIndex: Math.max(0, state.selectedIndex - 1),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
if (key.downArrow) {
|
|
60
|
-
return {
|
|
61
|
-
...state,
|
|
62
|
-
selectedIndex: Math.min(state.tasks.length > 0 ? state.tasks.length - 1 : 0, state.selectedIndex + 1),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
if (input === "k") {
|
|
66
|
-
if (state.tasks.length > 0 &&
|
|
67
|
-
state.selectedIndex < state.tasks.length) {
|
|
68
|
-
const selectedTask = state.tasks[state.selectedIndex];
|
|
69
|
-
if (selectedTask.status === "running") {
|
|
70
|
-
return {
|
|
71
|
-
...state,
|
|
72
|
-
pendingEffect: { type: "STOP_TASK", taskId: selectedTask.id },
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return state;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
else if (state.viewMode === "detail") {
|
|
80
|
-
if (key.escape) {
|
|
81
|
-
return {
|
|
82
|
-
...state,
|
|
83
|
-
viewMode: "list",
|
|
84
|
-
detailTaskId: null,
|
|
85
|
-
detailOutput: null,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
if (input === "k" && state.detailTaskId) {
|
|
89
|
-
const task = state.tasks.find((t) => t.id === state.detailTaskId);
|
|
90
|
-
if (task && task.status === "running") {
|
|
91
|
-
return {
|
|
92
|
-
...state,
|
|
93
|
-
pendingEffect: { type: "STOP_TASK", taskId: state.detailTaskId },
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
return state;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return state;
|
|
100
|
-
}
|
|
101
|
-
case "CLEAR_PENDING_EFFECT":
|
|
102
|
-
return { ...state, pendingEffect: null };
|
|
103
|
-
default:
|
|
104
|
-
return state;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Key } from "ink";
|
|
2
|
-
import type { PermissionDecision, PermissionMode } from "wave-agent-sdk";
|
|
3
|
-
export interface ConfirmationState {
|
|
4
|
-
selectedOption: "auto" | "bypass" | "allow" | "alternative";
|
|
5
|
-
alternativeText: string;
|
|
6
|
-
alternativeCursorPosition: number;
|
|
7
|
-
hasUserInput: boolean;
|
|
8
|
-
decision: PermissionDecision | null;
|
|
9
|
-
}
|
|
10
|
-
export type ConfirmationAction = {
|
|
11
|
-
type: "SELECT_OPTION";
|
|
12
|
-
option: ConfirmationState["selectedOption"];
|
|
13
|
-
} | {
|
|
14
|
-
type: "INSERT_TEXT";
|
|
15
|
-
text: string;
|
|
16
|
-
} | {
|
|
17
|
-
type: "BACKSPACE";
|
|
18
|
-
} | {
|
|
19
|
-
type: "MOVE_CURSOR_LEFT";
|
|
20
|
-
} | {
|
|
21
|
-
type: "MOVE_CURSOR_RIGHT";
|
|
22
|
-
} | {
|
|
23
|
-
type: "CONFIRM";
|
|
24
|
-
decision: PermissionDecision;
|
|
25
|
-
} | {
|
|
26
|
-
type: "CLEAR_DECISION";
|
|
27
|
-
} | {
|
|
28
|
-
type: "HANDLE_KEY";
|
|
29
|
-
input: string;
|
|
30
|
-
key: Key;
|
|
31
|
-
toolName: string;
|
|
32
|
-
toolInput?: Record<string, unknown>;
|
|
33
|
-
suggestedPrefix?: string;
|
|
34
|
-
hidePersistentOption?: boolean;
|
|
35
|
-
permissionMode?: PermissionMode;
|
|
36
|
-
};
|
|
37
|
-
export declare function confirmationReducer(state: ConfirmationState, action: ConfirmationAction): ConfirmationState;
|