wave-code 1.2.0 → 1.4.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.
Files changed (64) hide show
  1. package/dist/bundle/wave.mjs +1738 -893
  2. package/package.json +6 -3
  3. package/src/cli.tsx +9 -0
  4. package/src/commands/plugin/install.ts +6 -7
  5. package/src/commands/plugin/uninstall.ts +11 -5
  6. package/src/commands/update.ts +62 -22
  7. package/src/components/BackgroundTaskManager.tsx +76 -54
  8. package/src/components/ChatInterface.tsx +1 -0
  9. package/src/components/ConfirmationDetails.tsx +51 -16
  10. package/src/components/ConfirmationSelector.tsx +39 -0
  11. package/src/components/InputBox.tsx +41 -2
  12. package/src/components/Markdown.tsx +21 -8
  13. package/src/components/MarketplaceDetail.tsx +10 -27
  14. package/src/components/MarketplaceView.tsx +17 -3
  15. package/src/components/MessageBlockItem.tsx +0 -6
  16. package/src/components/Notifications.tsx +7 -0
  17. package/src/components/PlanView.tsx +22 -17
  18. package/src/components/PluginManagerShell.tsx +3 -3
  19. package/src/components/PluginManagerTypes.ts +2 -1
  20. package/src/components/ResumeCommand.tsx +84 -0
  21. package/src/components/ScrolledContent.tsx +71 -0
  22. package/src/components/SessionSelector.tsx +184 -6
  23. package/src/components/SessionSelectorFlow.tsx +246 -0
  24. package/src/components/WorkflowManager.tsx +38 -138
  25. package/src/components/WorkflowRunDetail.tsx +193 -0
  26. package/src/constants/commands.ts +24 -0
  27. package/src/contexts/useChat.tsx +517 -155
  28. package/src/daemon/commands.ts +582 -50
  29. package/src/daemon-cli.ts +12 -1
  30. package/src/hooks/useInputManager.ts +20 -0
  31. package/src/hooks/usePluginManager.ts +104 -78
  32. package/src/hooks/useRemoteControl.ts +324 -0
  33. package/src/index.ts +97 -8
  34. package/src/managers/inputHandlers.ts +16 -9
  35. package/src/managers/inputReducer.ts +30 -9
  36. package/src/print-cli.ts +5 -0
  37. package/src/reducers/confirmationReducer.ts +20 -1
  38. package/src/reducers/selectorReducer.ts +3 -0
  39. package/src/reducers/workflowManagerReducer.ts +21 -2
  40. package/src/remote/frameBudget.ts +45 -0
  41. package/src/remote/hostIdentity.ts +128 -0
  42. package/src/remote/messageWindow.ts +97 -0
  43. package/src/remote/notificationCoalescer.ts +174 -0
  44. package/src/remote/relayClient.ts +668 -0
  45. package/src/remote/remoteControlCliHost.ts +391 -0
  46. package/src/remote/remoteControlCommands.ts +197 -0
  47. package/src/remote/remoteControlConfig.ts +334 -0
  48. package/src/remote/remoteControlService.ts +799 -0
  49. package/src/remote/remoteControlSink.ts +77 -0
  50. package/src/remote/remoteNotifications.ts +194 -0
  51. package/src/session-selector-cli.tsx +9 -255
  52. package/src/stdio/agentBridge.ts +1001 -165
  53. package/src/stdio/daemonServer.ts +30 -0
  54. package/src/stdio/jsonRpcConnection.ts +11 -2
  55. package/src/stdio/protocol.ts +14 -106
  56. package/src/stdio/stdioServer.ts +33 -2
  57. package/src/stdio-cli.ts +16 -1
  58. package/src/utils/gitCredentialHelper.ts +106 -0
  59. package/src/utils/logger.ts +5 -2
  60. package/src/utils/rewindCheckpoints.ts +2 -4
  61. package/src/utils/sessionOwnership.ts +62 -0
  62. package/src/utils/workspaceDiff.ts +620 -0
  63. package/src/utils/worktree.ts +97 -0
  64. package/src/components/PlanDisplay.tsx +0 -18
package/src/daemon-cli.ts CHANGED
@@ -8,10 +8,21 @@
8
8
  * keeps the process alive — there is no stdin to wait on.
9
9
  */
10
10
 
11
+ import { ensureRuntimeDeps } from "wave-agent-sdk";
11
12
  import { DaemonServer } from "./stdio/daemonServer.js";
13
+ import { createRemoteControlSinkFactory } from "./remote/remoteControlSink.js";
12
14
 
13
15
  export async function startDaemonCli(socketPath: string): Promise<void> {
14
- const server = new DaemonServer({ socketPath });
16
+ // Install the on-demand runtime dependencies (image codec + ripgrep) before
17
+ // serving (see cli.tsx). The daemon serves turns on a remote host, so the
18
+ // install belongs here — and it must land before the first client attaches,
19
+ // since the host reports "daemon ready" on this socket.
20
+ await ensureRuntimeDeps();
21
+
22
+ // The resident daemon owns the remote sessions, so it is the process that
23
+ // serves a paired phone. Off (undefined) unless the switch says otherwise.
24
+ const createRemoteSink = createRemoteControlSinkFactory(process.cwd());
25
+ const server = new DaemonServer({ socketPath, createRemoteSink });
15
26
  await server.start();
16
27
  // Ready — any error that follows goes to the daemon log via stderr.
17
28
  }
@@ -61,7 +61,10 @@ export const useInputManager = (
61
61
  onRecallQueuedMessage,
62
62
  onClearMessages,
63
63
  onCompact,
64
+ onReloadPlugins,
64
65
  onAddDir,
66
+ onRenameSession,
67
+ onRemoteControlCommand,
65
68
  onPlanCommand,
66
69
  isIdle: isIdleProp,
67
70
  } = callbacks;
@@ -247,6 +250,8 @@ export const useInputManager = (
247
250
  dispatch({ type: "SET_SHOW_AGENTS_MANAGER", payload: true });
248
251
  } else if (command === "rewind") {
249
252
  dispatch({ type: "SET_SHOW_REWIND_MANAGER", payload: true });
253
+ } else if (command === "resume") {
254
+ dispatch({ type: "SET_SHOW_RESUME_SELECTOR", payload: true });
250
255
  } else if (command === "help") {
251
256
  dispatch({ type: "SET_SHOW_HELP", payload: true });
252
257
  } else if (command === "status") {
@@ -280,8 +285,14 @@ export const useInputManager = (
280
285
  await onClearMessages?.();
281
286
  } else if (command === "compact") {
282
287
  await onCompact?.(effect.args);
288
+ } else if (command === "reload-plugins") {
289
+ await onReloadPlugins?.();
283
290
  } else if (command === "add-dir") {
284
291
  await onAddDir?.(effect.args);
292
+ } else if (command === "rename") {
293
+ await onRenameSession?.(effect.args);
294
+ } else if (command === "remote-control") {
295
+ await onRemoteControlCommand?.(effect.args);
285
296
  } else if (command === "plan") {
286
297
  await onPlanCommand?.(effect.args);
287
298
  }
@@ -312,7 +323,10 @@ export const useInputManager = (
312
323
  onRecallQueuedMessage,
313
324
  onClearMessages,
314
325
  onCompact,
326
+ onReloadPlugins,
315
327
  onAddDir,
328
+ onRenameSession,
329
+ onRemoteControlCommand,
316
330
  onPlanCommand,
317
331
  ]);
318
332
 
@@ -511,6 +525,10 @@ export const useInputManager = (
511
525
  dispatch({ type: "SET_SHOW_REWIND_MANAGER", payload: show });
512
526
  }, []);
513
527
 
528
+ const setShowResumeSelector = useCallback((show: boolean) => {
529
+ dispatch({ type: "SET_SHOW_RESUME_SELECTOR", payload: show });
530
+ }, []);
531
+
514
532
  const setShowHelp = useCallback((show: boolean) => {
515
533
  dispatch({ type: "SET_SHOW_HELP", payload: show });
516
534
  }, []);
@@ -681,6 +699,7 @@ export const useInputManager = (
681
699
  showMcpManager: state.showMcpManager,
682
700
  showAgentsManager: state.showAgentsManager,
683
701
  showRewindManager: state.showRewindManager,
702
+ showResumeSelector: state.showResumeSelector,
684
703
  showHelp: state.showHelp,
685
704
  showStatusCommand: state.showStatusCommand,
686
705
  showLoginCommand: state.showLoginCommand,
@@ -735,6 +754,7 @@ export const useInputManager = (
735
754
  setShowPluginManager,
736
755
  setShowModelSelector,
737
756
  setShowWorkflowManager,
757
+ setShowResumeSelector,
738
758
  setShowSkillsManager,
739
759
  setShowHooksManager,
740
760
  setPermissionMode,
@@ -12,7 +12,11 @@ import {
12
12
  } from "../components/PluginManagerTypes.js";
13
13
 
14
14
  export function usePluginManager(options?: {
15
- onPluginInstalled?: () => void;
15
+ /**
16
+ * 插件变更落盘后的回调:宿主据此置「待应用」信号并提示一次,**不重建会话**
17
+ * (docs/specs/ecosystem/plugin.md「插件变更的就地重载」)。
18
+ */
19
+ onPluginChanged?: () => void;
16
20
  }): PluginManagerContextType {
17
21
  const [state, setState] = useState<PluginManagerState>({
18
22
  currentView: "DISCOVER",
@@ -24,6 +28,7 @@ export function usePluginManager(options?: {
24
28
  });
25
29
 
26
30
  const [marketplaces, setMarketplaces] = useState<KnownMarketplace[]>([]);
31
+ const [checkingForUpdates, setCheckingForUpdates] = useState(false);
27
32
  const [installedPlugins, setInstalledPlugins] = useState<
28
33
  (InstalledPlugin & { enabled: boolean })[]
29
34
  >([]);
@@ -63,21 +68,26 @@ export function usePluginManager(options?: {
63
68
  [setState],
64
69
  );
65
70
 
66
- const refresh = useCallback(async () => {
67
- clearPluginFeedback();
68
- setState((prev: PluginManagerState) => ({
69
- ...prev,
70
- isLoading: true,
71
- }));
72
- try {
73
- const [mks, installed, enabledMap] = await Promise.all([
74
- pluginCore.listMarketplaces(),
75
- pluginCore.getInstalledPlugins(),
76
- Promise.resolve(pluginCore.getMergedEnabledPlugins()),
77
- ]);
71
+ /** 读取市场清单 + 已安装插件 + 可发现插件(不碰 isLoading,供后台刷新后重读)。 */
72
+ const loadLists = useCallback(async () => {
73
+ const [mks, installed, enabledMap] = await Promise.all([
74
+ pluginCore.listMarketplaces(),
75
+ pluginCore.getInstalledPlugins(),
76
+ Promise.resolve(pluginCore.getMergedEnabledPlugins()),
77
+ ]);
78
78
 
79
- setMarketplaces(mks);
80
- const allInstalledWithEnabled = installed.plugins.map((p) => {
79
+ setMarketplaces(mks);
80
+ // 同一插件在本机可能有多条安装记录(各作用域/各项目一条,spec plugin A-015);
81
+ // 「已安装」列表按插件去重,否则同一个插件会重复成行。
82
+ const listedPlugins = new Set<string>();
83
+ const allInstalledWithEnabled = installed.plugins
84
+ .filter((p) => {
85
+ const pluginId = `${p.name}@${p.marketplace}`;
86
+ if (listedPlugins.has(pluginId)) return false;
87
+ listedPlugins.add(pluginId);
88
+ return true;
89
+ })
90
+ .map((p) => {
81
91
  const pluginId = `${p.name}@${p.marketplace}`;
82
92
  return {
83
93
  ...p,
@@ -86,40 +96,50 @@ export function usePluginManager(options?: {
86
96
  };
87
97
  });
88
98
 
89
- // Only show enabled plugins in the "Installed" view
90
- setInstalledPlugins(allInstalledWithEnabled.filter((p) => p.enabled));
99
+ // Only show enabled plugins in the "Installed" view
100
+ setInstalledPlugins(allInstalledWithEnabled.filter((p) => p.enabled));
91
101
 
92
- const allDiscoverable: (MarketplacePluginEntry & {
93
- marketplace: string;
94
- installed: boolean;
95
- version?: string;
96
- })[] = [];
97
- for (const mk of mks) {
98
- try {
99
- const manifest = await pluginCore.loadMarketplaceManifest(
100
- pluginCore.getMarketplacePath(mk),
102
+ const allDiscoverable: (MarketplacePluginEntry & {
103
+ marketplace: string;
104
+ installed: boolean;
105
+ version?: string;
106
+ })[] = [];
107
+ for (const mk of mks) {
108
+ try {
109
+ const manifest = await pluginCore.loadMarketplaceManifest(
110
+ pluginCore.getMarketplacePath(mk),
111
+ );
112
+ manifest.plugins.forEach((p) => {
113
+ const pluginId = `${p.name}@${mk.name}`;
114
+ const isInstalled = installed.plugins.find(
115
+ (ip) => ip.name === p.name && ip.marketplace === mk.name,
101
116
  );
102
- manifest.plugins.forEach((p) => {
103
- const pluginId = `${p.name}@${mk.name}`;
104
- const isInstalled = installed.plugins.find(
105
- (ip) => ip.name === p.name && ip.marketplace === mk.name,
106
- );
107
- const isEnabled = !!enabledMap[pluginId];
117
+ const isEnabled = !!enabledMap[pluginId];
108
118
 
109
- // Show in Discover if not installed OR if installed but not enabled in current scope
110
- if (!isInstalled || !isEnabled) {
111
- allDiscoverable.push({
112
- ...p,
113
- marketplace: mk.name,
114
- installed: !!isInstalled,
115
- });
116
- }
117
- });
118
- } catch {
119
- // Skip marketplaces that fail to load
120
- }
119
+ // Show in Discover if not installed OR if installed but not enabled in current scope
120
+ if (!isInstalled || !isEnabled) {
121
+ allDiscoverable.push({
122
+ ...p,
123
+ marketplace: mk.name,
124
+ installed: !!isInstalled,
125
+ });
126
+ }
127
+ });
128
+ } catch {
129
+ // Skip marketplaces that fail to load
121
130
  }
122
- setDiscoverablePlugins(allDiscoverable);
131
+ }
132
+ setDiscoverablePlugins(allDiscoverable);
133
+ }, [pluginCore]);
134
+
135
+ const refresh = useCallback(async () => {
136
+ clearPluginFeedback();
137
+ setState((prev: PluginManagerState) => ({
138
+ ...prev,
139
+ isLoading: true,
140
+ }));
141
+ try {
142
+ await loadLists();
123
143
  setState((prev: PluginManagerState) => ({ ...prev, isLoading: false }));
124
144
  } catch (error) {
125
145
  setState((prev: PluginManagerState) => ({
@@ -128,12 +148,31 @@ export function usePluginManager(options?: {
128
148
  error: error instanceof Error ? error.message : String(error),
129
149
  }));
130
150
  }
131
- }, [pluginCore, clearPluginFeedback]);
151
+ }, [loadLists, clearPluginFeedback]);
132
152
 
133
153
  useEffect(() => {
134
- refresh();
154
+ void refresh();
135
155
  }, [refresh]);
136
156
 
157
+ // 打开插件管理器即后台刷新各市场检出(只拉清单、不升级任何插件;spec
158
+ // ecosystem/plugin 场景 5/11):刷新与列表加载并行、不阻塞界面,完成后重读
159
+ // 列表呈现最新清单(场景 12)。失败静默——界面仍以刷新前的清单展示(场景 9)。
160
+ useEffect(() => {
161
+ let cancelled = false;
162
+ setCheckingForUpdates(true);
163
+ pluginCore
164
+ .refreshMarketplaces()
165
+ .catch(() => {})
166
+ .then(async () => {
167
+ if (cancelled) return;
168
+ setCheckingForUpdates(false);
169
+ await loadLists().catch(() => {});
170
+ });
171
+ return () => {
172
+ cancelled = true;
173
+ };
174
+ }, [pluginCore, loadLists]);
175
+
137
176
  const setView = useCallback((view: ViewType) => {
138
177
  setState((prev: PluginManagerState) => ({ ...prev, currentView: view }));
139
178
  }, []);
@@ -150,11 +189,15 @@ export function usePluginManager(options?: {
150
189
  isLoading: true,
151
190
  }));
152
191
  try {
153
- await pluginCore.addMarketplace(source, scope);
192
+ const marketplace = await pluginCore.addMarketplace(source, scope);
154
193
  await refresh();
155
194
  setSuccessMessage(`Marketplace added successfully (${scope} scope)`);
195
+ // 焦点落到新加的市场(spec plugin「管理市场」场景 5):刷新会把市场列表的
196
+ // 选中项归零,这里用 addMarketplace 的返回值(市场名由市场自身清单决定,
197
+ // 调用方事先不知道)把选中项设为新市场;失败路径不设置,保持原选中不变。
156
198
  setState((prev: PluginManagerState) => ({
157
199
  ...prev,
200
+ selectedId: marketplace.name,
158
201
  currentView: "MARKETPLACES",
159
202
  }));
160
203
  } catch (error) {
@@ -194,6 +237,8 @@ export function usePluginManager(options?: {
194
237
  [pluginCore, refresh, clearPluginFeedback, setSuccessMessage],
195
238
  );
196
239
 
240
+ // 市场详情的「批量更新插件」项:按当前清单批量升级该市场内已装插件,不拉检出
241
+ // ——检出已由打开插件管理器时的后台刷新处理(spec ecosystem/plugin A-013 场景 14)。
197
242
  const updateMarketplace = useCallback(
198
243
  async (name: string) => {
199
244
  clearPluginFeedback();
@@ -202,9 +247,12 @@ export function usePluginManager(options?: {
202
247
  isLoading: true,
203
248
  }));
204
249
  try {
205
- await pluginCore.updateMarketplace(name);
250
+ const updated = await pluginCore.updateMarketplacePlugins(name);
206
251
  await refresh();
207
252
  setSuccessMessage(`Marketplace '${name}' updated successfully`);
253
+ // 批量更新同属插件变更:真的升级了插件时才产生「待应用」提示
254
+ // (spec plugin「插件变更的就地重载」场景 1)。
255
+ if (updated > 0) options?.onPluginChanged?.();
208
256
  } catch (error) {
209
257
  setState((prev: PluginManagerState) => ({
210
258
  ...prev,
@@ -213,7 +261,7 @@ export function usePluginManager(options?: {
213
261
  }));
214
262
  }
215
263
  },
216
- [pluginCore, refresh, clearPluginFeedback, setSuccessMessage],
264
+ [pluginCore, refresh, clearPluginFeedback, setSuccessMessage, options],
217
265
  );
218
266
 
219
267
  const installPlugin = useCallback(
@@ -232,7 +280,7 @@ export function usePluginManager(options?: {
232
280
  await pluginCore.installPlugin(pluginId, scope);
233
281
  await refresh();
234
282
  setSuccessMessage(`Plugin '${name}' installed successfully`);
235
- options?.onPluginInstalled?.();
283
+ options?.onPluginChanged?.();
236
284
  } catch (error) {
237
285
  setState((prev: PluginManagerState) => ({
238
286
  ...prev,
@@ -256,6 +304,7 @@ export function usePluginManager(options?: {
256
304
  await pluginCore.uninstallPlugin(pluginId);
257
305
  await refresh();
258
306
  setSuccessMessage(`Plugin '${name}' uninstalled successfully`);
307
+ options?.onPluginChanged?.();
259
308
  } catch (error) {
260
309
  setState((prev: PluginManagerState) => ({
261
310
  ...prev,
@@ -264,7 +313,7 @@ export function usePluginManager(options?: {
264
313
  }));
265
314
  }
266
315
  },
267
- [pluginCore, refresh, clearPluginFeedback, setSuccessMessage],
316
+ [pluginCore, refresh, clearPluginFeedback, setSuccessMessage, options],
268
317
  );
269
318
 
270
319
  const updatePlugin = useCallback(
@@ -279,6 +328,7 @@ export function usePluginManager(options?: {
279
328
  await pluginCore.updatePlugin(pluginId);
280
329
  await refresh();
281
330
  setSuccessMessage(`Plugin '${name}' updated successfully`);
331
+ options?.onPluginChanged?.();
282
332
  } catch (error) {
283
333
  setState((prev: PluginManagerState) => ({
284
334
  ...prev,
@@ -287,36 +337,13 @@ export function usePluginManager(options?: {
287
337
  }));
288
338
  }
289
339
  },
290
- [pluginCore, refresh, clearPluginFeedback, setSuccessMessage],
291
- );
292
-
293
- const toggleAutoUpdate = useCallback(
294
- async (name: string, enabled: boolean) => {
295
- clearPluginFeedback();
296
- setState((prev: PluginManagerState) => ({
297
- ...prev,
298
- isLoading: true,
299
- }));
300
- try {
301
- await pluginCore.toggleAutoUpdate(name, enabled);
302
- await refresh();
303
- setSuccessMessage(
304
- `Auto-update for '${name}' ${enabled ? "enabled" : "disabled"}`,
305
- );
306
- } catch (error) {
307
- setState((prev: PluginManagerState) => ({
308
- ...prev,
309
- isLoading: false,
310
- error: error instanceof Error ? error.message : String(error),
311
- }));
312
- }
313
- },
314
- [pluginCore, refresh, clearPluginFeedback, setSuccessMessage],
340
+ [pluginCore, refresh, clearPluginFeedback, setSuccessMessage, options],
315
341
  );
316
342
 
317
343
  return {
318
344
  state,
319
345
  marketplaces,
346
+ checkingForUpdates,
320
347
  installedPlugins,
321
348
  discoverablePlugins,
322
349
  actions: {
@@ -328,7 +355,6 @@ export function usePluginManager(options?: {
328
355
  installPlugin,
329
356
  uninstallPlugin,
330
357
  updatePlugin,
331
- toggleAutoUpdate,
332
358
  refresh,
333
359
  clearPluginFeedback,
334
360
  },