wave-code 0.2.0 → 0.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.
- package/dist/commands/plugin/disable.d.ts +2 -1
- package/dist/commands/plugin/disable.d.ts.map +1 -1
- package/dist/commands/plugin/disable.js +3 -2
- package/dist/commands/plugin/enable.d.ts +2 -1
- package/dist/commands/plugin/enable.d.ts.map +1 -1
- package/dist/commands/plugin/enable.js +3 -2
- package/dist/commands/plugin/install.d.ts +2 -1
- package/dist/commands/plugin/install.d.ts.map +1 -1
- package/dist/commands/plugin/list.d.ts.map +1 -1
- package/dist/commands/plugin/list.js +15 -3
- package/dist/commands/plugin/marketplace.d.ts +3 -0
- package/dist/commands/plugin/marketplace.d.ts.map +1 -1
- package/dist/commands/plugin/marketplace.js +15 -1
- package/dist/commands/plugin/uninstall.d.ts +4 -0
- package/dist/commands/plugin/uninstall.d.ts.map +1 -0
- package/dist/commands/plugin/uninstall.js +29 -0
- package/dist/commands/plugin/update.d.ts +4 -0
- package/dist/commands/plugin/update.d.ts.map +1 -0
- package/dist/commands/plugin/update.js +15 -0
- package/dist/components/ChatInterface.d.ts.map +1 -1
- package/dist/components/ChatInterface.js +2 -2
- package/dist/components/CommandSelector.d.ts.map +1 -1
- package/dist/components/CommandSelector.js +6 -0
- package/dist/components/Confirmation.js +1 -1
- package/dist/components/DiscoverView.d.ts +3 -0
- package/dist/components/DiscoverView.d.ts.map +1 -0
- package/dist/components/DiscoverView.js +25 -0
- package/dist/components/FileSelector.js +1 -1
- package/dist/components/HistorySearch.d.ts +8 -0
- package/dist/components/HistorySearch.d.ts.map +1 -0
- package/dist/components/HistorySearch.js +67 -0
- package/dist/components/InputBox.d.ts +1 -1
- package/dist/components/InputBox.d.ts.map +1 -1
- package/dist/components/InputBox.js +26 -17
- package/dist/components/InstalledView.d.ts +3 -0
- package/dist/components/InstalledView.d.ts.map +1 -0
- package/dist/components/InstalledView.js +30 -0
- package/dist/components/Markdown.d.ts.map +1 -1
- package/dist/components/Markdown.js +22 -9
- package/dist/components/MarketplaceAddForm.d.ts +3 -0
- package/dist/components/MarketplaceAddForm.d.ts.map +1 -0
- package/dist/components/MarketplaceAddForm.js +26 -0
- package/dist/components/MarketplaceDetail.d.ts +3 -0
- package/dist/components/MarketplaceDetail.d.ts.map +1 -0
- package/dist/components/MarketplaceDetail.js +38 -0
- package/dist/components/MarketplaceList.d.ts +9 -0
- package/dist/components/MarketplaceList.d.ts.map +1 -0
- package/dist/components/MarketplaceList.js +16 -0
- package/dist/components/MarketplaceView.d.ts +3 -0
- package/dist/components/MarketplaceView.d.ts.map +1 -0
- package/dist/components/MarketplaceView.js +28 -0
- package/dist/components/PluginDetail.d.ts +3 -0
- package/dist/components/PluginDetail.d.ts.map +1 -0
- package/dist/components/PluginDetail.js +63 -0
- package/dist/components/PluginList.d.ts +14 -0
- package/dist/components/PluginList.d.ts.map +1 -0
- package/dist/components/PluginList.js +12 -0
- package/dist/components/PluginManagerShell.d.ts +5 -0
- package/dist/components/PluginManagerShell.d.ts.map +1 -0
- package/dist/components/PluginManagerShell.js +89 -0
- package/dist/components/PluginManagerTypes.d.ts +33 -0
- package/dist/components/PluginManagerTypes.d.ts.map +1 -0
- package/dist/components/PluginManagerTypes.js +1 -0
- package/dist/components/RewindCommand.d.ts +9 -0
- package/dist/components/RewindCommand.d.ts.map +1 -0
- package/dist/components/RewindCommand.js +42 -0
- package/dist/components/SessionSelector.d.ts +11 -0
- package/dist/components/SessionSelector.d.ts.map +1 -0
- package/dist/components/SessionSelector.js +38 -0
- package/dist/components/SubagentBlock.d.ts.map +1 -1
- package/dist/components/SubagentBlock.js +20 -1
- package/dist/components/ToolResultDisplay.js +1 -1
- package/dist/contexts/PluginManagerContext.d.ts +4 -0
- package/dist/contexts/PluginManagerContext.d.ts.map +1 -0
- package/dist/contexts/PluginManagerContext.js +9 -0
- package/dist/contexts/useChat.d.ts +2 -0
- package/dist/contexts/useChat.d.ts.map +1 -1
- package/dist/contexts/useChat.js +21 -0
- package/dist/hooks/useInputManager.d.ts +6 -14
- package/dist/hooks/useInputManager.d.ts.map +1 -1
- package/dist/hooks/useInputManager.js +29 -45
- package/dist/hooks/usePluginManager.d.ts +3 -0
- package/dist/hooks/usePluginManager.d.ts.map +1 -0
- package/dist/hooks/usePluginManager.js +223 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +150 -177
- package/dist/managers/InputManager.d.ts +12 -21
- package/dist/managers/InputManager.d.ts.map +1 -1
- package/dist/managers/InputManager.js +77 -108
- package/dist/plugin-manager-cli.d.ts +6 -0
- package/dist/plugin-manager-cli.d.ts.map +1 -0
- package/dist/plugin-manager-cli.js +12 -0
- package/dist/session-selector-cli.d.ts +2 -0
- package/dist/session-selector-cli.d.ts.map +1 -0
- package/dist/session-selector-cli.js +25 -0
- package/package.json +7 -3
- package/src/commands/plugin/disable.ts +7 -3
- package/src/commands/plugin/enable.ts +7 -3
- package/src/commands/plugin/install.ts +2 -1
- package/src/commands/plugin/list.ts +21 -3
- package/src/commands/plugin/marketplace.ts +17 -1
- package/src/commands/plugin/uninstall.ts +39 -0
- package/src/commands/plugin/update.ts +19 -0
- package/src/components/ChatInterface.tsx +2 -1
- package/src/components/CommandSelector.tsx +7 -0
- package/src/components/Confirmation.tsx +1 -1
- package/src/components/DiscoverView.tsx +31 -0
- package/src/components/FileSelector.tsx +1 -1
- package/src/components/HistorySearch.tsx +148 -0
- package/src/components/InputBox.tsx +43 -28
- package/src/components/InstalledView.tsx +61 -0
- package/src/components/Markdown.tsx +37 -26
- package/src/components/MarketplaceAddForm.tsx +39 -0
- package/src/components/MarketplaceDetail.tsx +79 -0
- package/src/components/MarketplaceList.tsx +52 -0
- package/src/components/MarketplaceView.tsx +43 -0
- package/src/components/PluginDetail.tsx +147 -0
- package/src/components/PluginList.tsx +51 -0
- package/src/components/PluginManagerShell.tsx +189 -0
- package/src/components/PluginManagerTypes.ts +47 -0
- package/src/components/RewindCommand.tsx +114 -0
- package/src/components/SessionSelector.tsx +127 -0
- package/src/components/SubagentBlock.tsx +29 -1
- package/src/components/ToolResultDisplay.tsx +2 -2
- package/src/contexts/PluginManagerContext.ts +15 -0
- package/src/contexts/useChat.tsx +26 -0
- package/src/hooks/useInputManager.ts +29 -61
- package/src/hooks/usePluginManager.ts +296 -0
- package/src/index.ts +241 -280
- package/src/managers/InputManager.ts +93 -149
- package/src/plugin-manager-cli.tsx +13 -0
- package/src/session-selector-cli.tsx +37 -0
- package/dist/components/BashHistorySelector.d.ts +0 -11
- package/dist/components/BashHistorySelector.d.ts.map +0 -1
- package/dist/components/BashHistorySelector.js +0 -93
- package/dist/hooks/usePagination.d.ts +0 -20
- package/dist/hooks/usePagination.d.ts.map +0 -1
- package/dist/hooks/usePagination.js +0 -168
- package/src/components/BashHistorySelector.tsx +0 -181
- package/src/hooks/usePagination.ts +0 -203
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { useState, useCallback, useEffect, useMemo } from "react";
|
|
2
|
+
import {
|
|
3
|
+
MarketplaceService,
|
|
4
|
+
PluginScopeManager,
|
|
5
|
+
ConfigurationService,
|
|
6
|
+
PluginManager,
|
|
7
|
+
KnownMarketplace,
|
|
8
|
+
InstalledPlugin,
|
|
9
|
+
MarketplacePluginEntry,
|
|
10
|
+
} from "wave-agent-sdk";
|
|
11
|
+
import {
|
|
12
|
+
PluginManagerState,
|
|
13
|
+
ViewType,
|
|
14
|
+
PluginManagerContextType,
|
|
15
|
+
} from "../components/PluginManagerTypes.js";
|
|
16
|
+
|
|
17
|
+
export function usePluginManager(): PluginManagerContextType {
|
|
18
|
+
const [state, setState] = useState<PluginManagerState>({
|
|
19
|
+
currentView: "DISCOVER",
|
|
20
|
+
selectedId: null,
|
|
21
|
+
isLoading: true,
|
|
22
|
+
error: null,
|
|
23
|
+
searchQuery: "",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const [marketplaces, setMarketplaces] = useState<KnownMarketplace[]>([]);
|
|
27
|
+
const [installedPlugins, setInstalledPlugins] = useState<
|
|
28
|
+
(InstalledPlugin & { enabled: boolean })[]
|
|
29
|
+
>([]);
|
|
30
|
+
const [discoverablePlugins, setDiscoverablePlugins] = useState<
|
|
31
|
+
(MarketplacePluginEntry & {
|
|
32
|
+
marketplace: string;
|
|
33
|
+
installed: boolean;
|
|
34
|
+
version?: string;
|
|
35
|
+
})[]
|
|
36
|
+
>([]);
|
|
37
|
+
|
|
38
|
+
const marketplaceService = useMemo(() => new MarketplaceService(), []);
|
|
39
|
+
const configurationService = useMemo(() => new ConfigurationService(), []);
|
|
40
|
+
const pluginManager = useMemo(
|
|
41
|
+
() =>
|
|
42
|
+
new PluginManager({
|
|
43
|
+
workdir: process.cwd(),
|
|
44
|
+
configurationService,
|
|
45
|
+
}),
|
|
46
|
+
[configurationService],
|
|
47
|
+
);
|
|
48
|
+
const pluginScopeManager = useMemo(
|
|
49
|
+
() =>
|
|
50
|
+
new PluginScopeManager({
|
|
51
|
+
workdir: process.cwd(),
|
|
52
|
+
configurationService,
|
|
53
|
+
pluginManager,
|
|
54
|
+
}),
|
|
55
|
+
[configurationService, pluginManager],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const refresh = useCallback(async () => {
|
|
59
|
+
setState((prev: PluginManagerState) => ({
|
|
60
|
+
...prev,
|
|
61
|
+
isLoading: true,
|
|
62
|
+
error: null,
|
|
63
|
+
}));
|
|
64
|
+
try {
|
|
65
|
+
const [mks, installed, enabledMap] = await Promise.all([
|
|
66
|
+
marketplaceService.listMarketplaces(),
|
|
67
|
+
marketplaceService.getInstalledPlugins(),
|
|
68
|
+
Promise.resolve(pluginScopeManager.getMergedEnabledPlugins()),
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
setMarketplaces(mks);
|
|
72
|
+
const allInstalledWithEnabled = installed.plugins.map((p) => {
|
|
73
|
+
const pluginId = `${p.name}@${p.marketplace}`;
|
|
74
|
+
return {
|
|
75
|
+
...p,
|
|
76
|
+
enabled: !!enabledMap[pluginId],
|
|
77
|
+
scope: pluginScopeManager.findPluginScope(pluginId) || undefined,
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Only show enabled plugins in the "Installed" view
|
|
82
|
+
setInstalledPlugins(allInstalledWithEnabled.filter((p) => p.enabled));
|
|
83
|
+
|
|
84
|
+
const allDiscoverable: (MarketplacePluginEntry & {
|
|
85
|
+
marketplace: string;
|
|
86
|
+
installed: boolean;
|
|
87
|
+
version?: string;
|
|
88
|
+
})[] = [];
|
|
89
|
+
for (const mk of mks) {
|
|
90
|
+
try {
|
|
91
|
+
const manifest = await marketplaceService.loadMarketplaceManifest(
|
|
92
|
+
marketplaceService.getMarketplacePath(mk),
|
|
93
|
+
);
|
|
94
|
+
manifest.plugins.forEach((p) => {
|
|
95
|
+
const pluginId = `${p.name}@${mk.name}`;
|
|
96
|
+
const isInstalled = installed.plugins.find(
|
|
97
|
+
(ip) => ip.name === p.name && ip.marketplace === mk.name,
|
|
98
|
+
);
|
|
99
|
+
const isEnabled = !!enabledMap[pluginId];
|
|
100
|
+
|
|
101
|
+
// Show in Discover if not installed OR if installed but not enabled in current scope
|
|
102
|
+
if (!isInstalled || !isEnabled) {
|
|
103
|
+
allDiscoverable.push({
|
|
104
|
+
...p,
|
|
105
|
+
marketplace: mk.name,
|
|
106
|
+
installed: !!isInstalled,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
} catch {
|
|
111
|
+
// Skip marketplaces that fail to load
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
setDiscoverablePlugins(allDiscoverable);
|
|
115
|
+
setState((prev: PluginManagerState) => ({ ...prev, isLoading: false }));
|
|
116
|
+
} catch (error) {
|
|
117
|
+
setState((prev: PluginManagerState) => ({
|
|
118
|
+
...prev,
|
|
119
|
+
isLoading: false,
|
|
120
|
+
error: error instanceof Error ? error.message : String(error),
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
}, [marketplaceService, pluginScopeManager]);
|
|
124
|
+
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
refresh();
|
|
127
|
+
}, [refresh]);
|
|
128
|
+
|
|
129
|
+
const setView = useCallback((view: ViewType) => {
|
|
130
|
+
setState((prev: PluginManagerState) => ({ ...prev, currentView: view }));
|
|
131
|
+
}, []);
|
|
132
|
+
|
|
133
|
+
const setSelectedId = useCallback((id: string | null) => {
|
|
134
|
+
setState((prev: PluginManagerState) => ({ ...prev, selectedId: id }));
|
|
135
|
+
}, []);
|
|
136
|
+
|
|
137
|
+
const addMarketplace = useCallback(
|
|
138
|
+
async (source: string) => {
|
|
139
|
+
setState((prev: PluginManagerState) => ({
|
|
140
|
+
...prev,
|
|
141
|
+
isLoading: true,
|
|
142
|
+
error: null,
|
|
143
|
+
}));
|
|
144
|
+
try {
|
|
145
|
+
await marketplaceService.addMarketplace(source);
|
|
146
|
+
await refresh();
|
|
147
|
+
} catch (error) {
|
|
148
|
+
setState((prev: PluginManagerState) => ({
|
|
149
|
+
...prev,
|
|
150
|
+
isLoading: false,
|
|
151
|
+
error: error instanceof Error ? error.message : String(error),
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
[marketplaceService, refresh],
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const removeMarketplace = useCallback(
|
|
159
|
+
async (name: string) => {
|
|
160
|
+
setState((prev: PluginManagerState) => ({
|
|
161
|
+
...prev,
|
|
162
|
+
isLoading: true,
|
|
163
|
+
error: null,
|
|
164
|
+
}));
|
|
165
|
+
try {
|
|
166
|
+
await marketplaceService.removeMarketplace(name);
|
|
167
|
+
await refresh();
|
|
168
|
+
} catch (error) {
|
|
169
|
+
setState((prev: PluginManagerState) => ({
|
|
170
|
+
...prev,
|
|
171
|
+
isLoading: false,
|
|
172
|
+
error: error instanceof Error ? error.message : String(error),
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
[marketplaceService, refresh],
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
const updateMarketplace = useCallback(
|
|
180
|
+
async (name: string) => {
|
|
181
|
+
setState((prev: PluginManagerState) => ({
|
|
182
|
+
...prev,
|
|
183
|
+
isLoading: true,
|
|
184
|
+
error: null,
|
|
185
|
+
}));
|
|
186
|
+
try {
|
|
187
|
+
await marketplaceService.updateMarketplace(name);
|
|
188
|
+
await refresh();
|
|
189
|
+
} catch (error) {
|
|
190
|
+
setState((prev: PluginManagerState) => ({
|
|
191
|
+
...prev,
|
|
192
|
+
isLoading: false,
|
|
193
|
+
error: error instanceof Error ? error.message : String(error),
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
[marketplaceService, refresh],
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
const installPlugin = useCallback(
|
|
201
|
+
async (
|
|
202
|
+
name: string,
|
|
203
|
+
marketplace: string,
|
|
204
|
+
scope: "user" | "project" | "local" = "project",
|
|
205
|
+
) => {
|
|
206
|
+
setState((prev: PluginManagerState) => ({
|
|
207
|
+
...prev,
|
|
208
|
+
isLoading: true,
|
|
209
|
+
error: null,
|
|
210
|
+
}));
|
|
211
|
+
try {
|
|
212
|
+
const pluginId = `${name}@${marketplace}`;
|
|
213
|
+
await marketplaceService.installPlugin(pluginId);
|
|
214
|
+
await pluginScopeManager.enablePlugin(scope, pluginId);
|
|
215
|
+
await refresh();
|
|
216
|
+
} catch (error) {
|
|
217
|
+
setState((prev: PluginManagerState) => ({
|
|
218
|
+
...prev,
|
|
219
|
+
isLoading: false,
|
|
220
|
+
error: error instanceof Error ? error.message : String(error),
|
|
221
|
+
}));
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
[marketplaceService, pluginScopeManager, refresh],
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
const uninstallPlugin = useCallback(
|
|
228
|
+
async (name: string, marketplace: string) => {
|
|
229
|
+
setState((prev: PluginManagerState) => ({
|
|
230
|
+
...prev,
|
|
231
|
+
isLoading: true,
|
|
232
|
+
error: null,
|
|
233
|
+
}));
|
|
234
|
+
try {
|
|
235
|
+
const pluginId = `${name}@${marketplace}`;
|
|
236
|
+
// Find the scope where it's currently enabled and remove it from there
|
|
237
|
+
const scope = pluginScopeManager.findPluginScope(pluginId);
|
|
238
|
+
if (scope) {
|
|
239
|
+
await configurationService.removeEnabledPlugin(
|
|
240
|
+
process.cwd(),
|
|
241
|
+
scope,
|
|
242
|
+
pluginId,
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
await refresh();
|
|
246
|
+
} catch (error) {
|
|
247
|
+
setState((prev: PluginManagerState) => ({
|
|
248
|
+
...prev,
|
|
249
|
+
isLoading: false,
|
|
250
|
+
error: error instanceof Error ? error.message : String(error),
|
|
251
|
+
}));
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
[configurationService, pluginScopeManager, refresh],
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
const updatePlugin = useCallback(
|
|
258
|
+
async (name: string, marketplace: string) => {
|
|
259
|
+
setState((prev: PluginManagerState) => ({
|
|
260
|
+
...prev,
|
|
261
|
+
isLoading: true,
|
|
262
|
+
error: null,
|
|
263
|
+
}));
|
|
264
|
+
try {
|
|
265
|
+
const pluginId = `${name}@${marketplace}`;
|
|
266
|
+
await marketplaceService.updatePlugin(pluginId);
|
|
267
|
+
await refresh();
|
|
268
|
+
} catch (error) {
|
|
269
|
+
setState((prev: PluginManagerState) => ({
|
|
270
|
+
...prev,
|
|
271
|
+
isLoading: false,
|
|
272
|
+
error: error instanceof Error ? error.message : String(error),
|
|
273
|
+
}));
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
[marketplaceService, refresh],
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
state,
|
|
281
|
+
marketplaces,
|
|
282
|
+
installedPlugins,
|
|
283
|
+
discoverablePlugins,
|
|
284
|
+
actions: {
|
|
285
|
+
setView,
|
|
286
|
+
setSelectedId,
|
|
287
|
+
addMarketplace,
|
|
288
|
+
removeMarketplace,
|
|
289
|
+
updateMarketplace,
|
|
290
|
+
installPlugin,
|
|
291
|
+
uninstallPlugin,
|
|
292
|
+
updatePlugin,
|
|
293
|
+
refresh,
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
}
|