wave-code 0.2.1 → 0.5.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 (156) hide show
  1. package/dist/commands/plugin/disable.d.ts +2 -1
  2. package/dist/commands/plugin/disable.d.ts.map +1 -1
  3. package/dist/commands/plugin/disable.js +3 -2
  4. package/dist/commands/plugin/enable.d.ts +2 -1
  5. package/dist/commands/plugin/enable.d.ts.map +1 -1
  6. package/dist/commands/plugin/enable.js +3 -2
  7. package/dist/commands/plugin/install.d.ts +2 -1
  8. package/dist/commands/plugin/install.d.ts.map +1 -1
  9. package/dist/commands/plugin/list.d.ts.map +1 -1
  10. package/dist/commands/plugin/list.js +15 -3
  11. package/dist/commands/plugin/marketplace.d.ts +3 -0
  12. package/dist/commands/plugin/marketplace.d.ts.map +1 -1
  13. package/dist/commands/plugin/marketplace.js +15 -1
  14. package/dist/commands/plugin/uninstall.d.ts +4 -0
  15. package/dist/commands/plugin/uninstall.d.ts.map +1 -0
  16. package/dist/commands/plugin/uninstall.js +29 -0
  17. package/dist/commands/plugin/update.d.ts +4 -0
  18. package/dist/commands/plugin/update.d.ts.map +1 -0
  19. package/dist/commands/plugin/update.js +15 -0
  20. package/dist/components/ChatInterface.d.ts.map +1 -1
  21. package/dist/components/ChatInterface.js +2 -2
  22. package/dist/components/CommandSelector.d.ts.map +1 -1
  23. package/dist/components/CommandSelector.js +9 -3
  24. package/dist/components/Confirmation.d.ts.map +1 -1
  25. package/dist/components/Confirmation.js +73 -20
  26. package/dist/components/DiffDisplay.d.ts +0 -1
  27. package/dist/components/DiffDisplay.d.ts.map +1 -1
  28. package/dist/components/DiffDisplay.js +38 -59
  29. package/dist/components/DiscoverView.d.ts +3 -0
  30. package/dist/components/DiscoverView.d.ts.map +1 -0
  31. package/dist/components/DiscoverView.js +25 -0
  32. package/dist/components/FileSelector.js +1 -1
  33. package/dist/components/HistorySearch.d.ts +8 -0
  34. package/dist/components/HistorySearch.d.ts.map +1 -0
  35. package/dist/components/HistorySearch.js +67 -0
  36. package/dist/components/InputBox.d.ts +1 -1
  37. package/dist/components/InputBox.d.ts.map +1 -1
  38. package/dist/components/InputBox.js +29 -19
  39. package/dist/components/InstalledView.d.ts +3 -0
  40. package/dist/components/InstalledView.d.ts.map +1 -0
  41. package/dist/components/InstalledView.js +30 -0
  42. package/dist/components/Markdown.d.ts.map +1 -1
  43. package/dist/components/Markdown.js +24 -10
  44. package/dist/components/MarketplaceAddForm.d.ts +3 -0
  45. package/dist/components/MarketplaceAddForm.d.ts.map +1 -0
  46. package/dist/components/MarketplaceAddForm.js +26 -0
  47. package/dist/components/MarketplaceDetail.d.ts +3 -0
  48. package/dist/components/MarketplaceDetail.d.ts.map +1 -0
  49. package/dist/components/MarketplaceDetail.js +38 -0
  50. package/dist/components/MarketplaceList.d.ts +9 -0
  51. package/dist/components/MarketplaceList.d.ts.map +1 -0
  52. package/dist/components/MarketplaceList.js +16 -0
  53. package/dist/components/MarketplaceView.d.ts +3 -0
  54. package/dist/components/MarketplaceView.d.ts.map +1 -0
  55. package/dist/components/MarketplaceView.js +28 -0
  56. package/dist/components/PlanDisplay.d.ts.map +1 -1
  57. package/dist/components/PlanDisplay.js +2 -2
  58. package/dist/components/PluginDetail.d.ts +3 -0
  59. package/dist/components/PluginDetail.d.ts.map +1 -0
  60. package/dist/components/PluginDetail.js +63 -0
  61. package/dist/components/PluginList.d.ts +14 -0
  62. package/dist/components/PluginList.d.ts.map +1 -0
  63. package/dist/components/PluginList.js +12 -0
  64. package/dist/components/PluginManagerShell.d.ts +5 -0
  65. package/dist/components/PluginManagerShell.d.ts.map +1 -0
  66. package/dist/components/PluginManagerShell.js +89 -0
  67. package/dist/components/PluginManagerTypes.d.ts +33 -0
  68. package/dist/components/PluginManagerTypes.d.ts.map +1 -0
  69. package/dist/components/PluginManagerTypes.js +1 -0
  70. package/dist/components/RewindCommand.d.ts +9 -0
  71. package/dist/components/RewindCommand.d.ts.map +1 -0
  72. package/dist/components/RewindCommand.js +42 -0
  73. package/dist/components/SessionSelector.d.ts +11 -0
  74. package/dist/components/SessionSelector.d.ts.map +1 -0
  75. package/dist/components/SessionSelector.js +38 -0
  76. package/dist/components/SubagentBlock.d.ts.map +1 -1
  77. package/dist/components/SubagentBlock.js +24 -1
  78. package/dist/components/TaskManager.d.ts +6 -0
  79. package/dist/components/TaskManager.d.ts.map +1 -0
  80. package/dist/components/TaskManager.js +114 -0
  81. package/dist/components/ToolResultDisplay.d.ts.map +1 -1
  82. package/dist/components/ToolResultDisplay.js +2 -1
  83. package/dist/contexts/PluginManagerContext.d.ts +4 -0
  84. package/dist/contexts/PluginManagerContext.d.ts.map +1 -0
  85. package/dist/contexts/PluginManagerContext.js +9 -0
  86. package/dist/contexts/useChat.d.ts +7 -4
  87. package/dist/contexts/useChat.d.ts.map +1 -1
  88. package/dist/contexts/useChat.js +37 -12
  89. package/dist/hooks/useInputManager.d.ts +8 -16
  90. package/dist/hooks/useInputManager.d.ts.map +1 -1
  91. package/dist/hooks/useInputManager.js +39 -55
  92. package/dist/hooks/usePluginManager.d.ts +3 -0
  93. package/dist/hooks/usePluginManager.d.ts.map +1 -0
  94. package/dist/hooks/usePluginManager.js +227 -0
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +150 -177
  97. package/dist/managers/InputManager.d.ts +18 -26
  98. package/dist/managers/InputManager.d.ts.map +1 -1
  99. package/dist/managers/InputManager.js +93 -119
  100. package/dist/plugin-manager-cli.d.ts +6 -0
  101. package/dist/plugin-manager-cli.d.ts.map +1 -0
  102. package/dist/plugin-manager-cli.js +12 -0
  103. package/dist/session-selector-cli.d.ts +2 -0
  104. package/dist/session-selector-cli.d.ts.map +1 -0
  105. package/dist/session-selector-cli.js +25 -0
  106. package/package.json +9 -5
  107. package/src/commands/plugin/disable.ts +7 -3
  108. package/src/commands/plugin/enable.ts +7 -3
  109. package/src/commands/plugin/install.ts +2 -1
  110. package/src/commands/plugin/list.ts +21 -3
  111. package/src/commands/plugin/marketplace.ts +17 -1
  112. package/src/commands/plugin/uninstall.ts +39 -0
  113. package/src/commands/plugin/update.ts +19 -0
  114. package/src/components/ChatInterface.tsx +2 -1
  115. package/src/components/CommandSelector.tsx +10 -3
  116. package/src/components/Confirmation.tsx +115 -25
  117. package/src/components/DiffDisplay.tsx +60 -106
  118. package/src/components/DiscoverView.tsx +31 -0
  119. package/src/components/FileSelector.tsx +1 -1
  120. package/src/components/HistorySearch.tsx +148 -0
  121. package/src/components/InputBox.tsx +51 -34
  122. package/src/components/InstalledView.tsx +61 -0
  123. package/src/components/Markdown.tsx +44 -28
  124. package/src/components/MarketplaceAddForm.tsx +39 -0
  125. package/src/components/MarketplaceDetail.tsx +79 -0
  126. package/src/components/MarketplaceList.tsx +52 -0
  127. package/src/components/MarketplaceView.tsx +43 -0
  128. package/src/components/PlanDisplay.tsx +14 -19
  129. package/src/components/PluginDetail.tsx +147 -0
  130. package/src/components/PluginList.tsx +51 -0
  131. package/src/components/PluginManagerShell.tsx +189 -0
  132. package/src/components/PluginManagerTypes.ts +47 -0
  133. package/src/components/RewindCommand.tsx +114 -0
  134. package/src/components/SessionSelector.tsx +127 -0
  135. package/src/components/SubagentBlock.tsx +34 -1
  136. package/src/components/{BashShellManager.tsx → TaskManager.tsx} +79 -75
  137. package/src/components/ToolResultDisplay.tsx +6 -2
  138. package/src/contexts/PluginManagerContext.ts +15 -0
  139. package/src/contexts/useChat.tsx +51 -20
  140. package/src/hooks/useInputManager.ts +39 -71
  141. package/src/hooks/usePluginManager.ts +302 -0
  142. package/src/index.ts +241 -280
  143. package/src/managers/InputManager.ts +113 -162
  144. package/src/plugin-manager-cli.tsx +13 -0
  145. package/src/session-selector-cli.tsx +37 -0
  146. package/dist/components/BashHistorySelector.d.ts +0 -11
  147. package/dist/components/BashHistorySelector.d.ts.map +0 -1
  148. package/dist/components/BashHistorySelector.js +0 -93
  149. package/dist/components/BashShellManager.d.ts +0 -6
  150. package/dist/components/BashShellManager.d.ts.map +0 -1
  151. package/dist/components/BashShellManager.js +0 -116
  152. package/dist/hooks/usePagination.d.ts +0 -20
  153. package/dist/hooks/usePagination.d.ts.map +0 -1
  154. package/dist/hooks/usePagination.js +0 -168
  155. package/src/components/BashHistorySelector.tsx +0 -181
  156. package/src/hooks/usePagination.ts +0 -203
@@ -0,0 +1,227 @@
1
+ import { useState, useCallback, useEffect, useMemo } from "react";
2
+ import { MarketplaceService, PluginScopeManager, ConfigurationService, PluginManager, } from "wave-agent-sdk";
3
+ export function usePluginManager() {
4
+ const [state, setState] = useState({
5
+ currentView: "DISCOVER",
6
+ selectedId: null,
7
+ isLoading: true,
8
+ error: null,
9
+ searchQuery: "",
10
+ });
11
+ const [marketplaces, setMarketplaces] = useState([]);
12
+ const [installedPlugins, setInstalledPlugins] = useState([]);
13
+ const [discoverablePlugins, setDiscoverablePlugins] = useState([]);
14
+ const marketplaceService = useMemo(() => new MarketplaceService(), []);
15
+ const configurationService = useMemo(() => new ConfigurationService(), []);
16
+ const pluginManager = useMemo(() => new PluginManager({
17
+ workdir: process.cwd(),
18
+ configurationService,
19
+ }), [configurationService]);
20
+ const pluginScopeManager = useMemo(() => new PluginScopeManager({
21
+ workdir: process.cwd(),
22
+ configurationService,
23
+ pluginManager,
24
+ }), [configurationService, pluginManager]);
25
+ const refresh = useCallback(async () => {
26
+ setState((prev) => ({
27
+ ...prev,
28
+ isLoading: true,
29
+ error: null,
30
+ }));
31
+ try {
32
+ const [mks, installed, enabledMap] = await Promise.all([
33
+ marketplaceService.listMarketplaces(),
34
+ marketplaceService.getInstalledPlugins(),
35
+ Promise.resolve(pluginScopeManager.getMergedEnabledPlugins()),
36
+ ]);
37
+ setMarketplaces(mks);
38
+ const allInstalledWithEnabled = installed.plugins.map((p) => {
39
+ const pluginId = `${p.name}@${p.marketplace}`;
40
+ return {
41
+ ...p,
42
+ enabled: !!enabledMap[pluginId],
43
+ scope: pluginScopeManager.findPluginScope(pluginId) || undefined,
44
+ };
45
+ });
46
+ // Only show enabled plugins in the "Installed" view
47
+ setInstalledPlugins(allInstalledWithEnabled.filter((p) => p.enabled));
48
+ const allDiscoverable = [];
49
+ for (const mk of mks) {
50
+ try {
51
+ const manifest = await marketplaceService.loadMarketplaceManifest(marketplaceService.getMarketplacePath(mk));
52
+ manifest.plugins.forEach((p) => {
53
+ const pluginId = `${p.name}@${mk.name}`;
54
+ const isInstalled = installed.plugins.find((ip) => ip.name === p.name && ip.marketplace === mk.name);
55
+ const isEnabled = !!enabledMap[pluginId];
56
+ // Show in Discover if not installed OR if installed but not enabled in current scope
57
+ if (!isInstalled || !isEnabled) {
58
+ allDiscoverable.push({
59
+ ...p,
60
+ marketplace: mk.name,
61
+ installed: !!isInstalled,
62
+ });
63
+ }
64
+ });
65
+ }
66
+ catch {
67
+ // Skip marketplaces that fail to load
68
+ }
69
+ }
70
+ setDiscoverablePlugins(allDiscoverable);
71
+ setState((prev) => ({ ...prev, isLoading: false }));
72
+ }
73
+ catch (error) {
74
+ setState((prev) => ({
75
+ ...prev,
76
+ isLoading: false,
77
+ error: error instanceof Error ? error.message : String(error),
78
+ }));
79
+ }
80
+ }, [marketplaceService, pluginScopeManager]);
81
+ useEffect(() => {
82
+ refresh();
83
+ }, [refresh]);
84
+ const setView = useCallback((view) => {
85
+ setState((prev) => ({ ...prev, currentView: view }));
86
+ }, []);
87
+ const setSelectedId = useCallback((id) => {
88
+ setState((prev) => ({ ...prev, selectedId: id }));
89
+ }, []);
90
+ const addMarketplace = useCallback(async (source) => {
91
+ setState((prev) => ({
92
+ ...prev,
93
+ isLoading: true,
94
+ error: null,
95
+ }));
96
+ try {
97
+ await marketplaceService.addMarketplace(source);
98
+ await refresh();
99
+ }
100
+ catch (error) {
101
+ setState((prev) => ({
102
+ ...prev,
103
+ isLoading: false,
104
+ error: error instanceof Error ? error.message : String(error),
105
+ }));
106
+ }
107
+ }, [marketplaceService, refresh]);
108
+ const removeMarketplace = useCallback(async (name) => {
109
+ setState((prev) => ({
110
+ ...prev,
111
+ isLoading: true,
112
+ error: null,
113
+ }));
114
+ try {
115
+ await marketplaceService.removeMarketplace(name);
116
+ await refresh();
117
+ }
118
+ catch (error) {
119
+ setState((prev) => ({
120
+ ...prev,
121
+ isLoading: false,
122
+ error: error instanceof Error ? error.message : String(error),
123
+ }));
124
+ }
125
+ }, [marketplaceService, refresh]);
126
+ const updateMarketplace = useCallback(async (name) => {
127
+ setState((prev) => ({
128
+ ...prev,
129
+ isLoading: true,
130
+ error: null,
131
+ }));
132
+ try {
133
+ await marketplaceService.updateMarketplace(name);
134
+ await refresh();
135
+ }
136
+ catch (error) {
137
+ setState((prev) => ({
138
+ ...prev,
139
+ isLoading: false,
140
+ error: error instanceof Error ? error.message : String(error),
141
+ }));
142
+ }
143
+ }, [marketplaceService, refresh]);
144
+ const installPlugin = useCallback(async (name, marketplace, scope = "project") => {
145
+ setState((prev) => ({
146
+ ...prev,
147
+ isLoading: true,
148
+ error: null,
149
+ }));
150
+ try {
151
+ const pluginId = `${name}@${marketplace}`;
152
+ const workdir = process.cwd();
153
+ await marketplaceService.installPlugin(pluginId, workdir);
154
+ await pluginScopeManager.enablePlugin(scope, pluginId);
155
+ await refresh();
156
+ }
157
+ catch (error) {
158
+ setState((prev) => ({
159
+ ...prev,
160
+ isLoading: false,
161
+ error: error instanceof Error ? error.message : String(error),
162
+ }));
163
+ }
164
+ }, [marketplaceService, pluginScopeManager, refresh]);
165
+ const uninstallPlugin = useCallback(async (name, marketplace) => {
166
+ setState((prev) => ({
167
+ ...prev,
168
+ isLoading: true,
169
+ error: null,
170
+ }));
171
+ try {
172
+ const pluginId = `${name}@${marketplace}`;
173
+ const workdir = process.cwd();
174
+ // 1. Remove from global registry and potentially clean up cache
175
+ await marketplaceService.uninstallPlugin(pluginId, workdir);
176
+ // 2. Find the scope where it's currently enabled and remove it from there
177
+ const scope = pluginScopeManager.findPluginScope(pluginId);
178
+ if (scope) {
179
+ await configurationService.removeEnabledPlugin(workdir, scope, pluginId);
180
+ }
181
+ await refresh();
182
+ }
183
+ catch (error) {
184
+ setState((prev) => ({
185
+ ...prev,
186
+ isLoading: false,
187
+ error: error instanceof Error ? error.message : String(error),
188
+ }));
189
+ }
190
+ }, [configurationService, marketplaceService, pluginScopeManager, refresh]);
191
+ const updatePlugin = useCallback(async (name, marketplace) => {
192
+ setState((prev) => ({
193
+ ...prev,
194
+ isLoading: true,
195
+ error: null,
196
+ }));
197
+ try {
198
+ const pluginId = `${name}@${marketplace}`;
199
+ await marketplaceService.updatePlugin(pluginId);
200
+ await refresh();
201
+ }
202
+ catch (error) {
203
+ setState((prev) => ({
204
+ ...prev,
205
+ isLoading: false,
206
+ error: error instanceof Error ? error.message : String(error),
207
+ }));
208
+ }
209
+ }, [marketplaceService, refresh]);
210
+ return {
211
+ state,
212
+ marketplaces,
213
+ installedPlugins,
214
+ discoverablePlugins,
215
+ actions: {
216
+ setView,
217
+ setSelectedId,
218
+ addMarketplace,
219
+ removeMarketplace,
220
+ updateMarketplace,
221
+ installPlugin,
222
+ uninstallPlugin,
223
+ updatePlugin,
224
+ refresh,
225
+ },
226
+ };
227
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,wBAAsB,IAAI,kBAqSzB;AAGD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,oBAAoB,GAC1B,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,wBAAsB,IAAI,kBAkQzB;AAGD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,oBAAoB,GAC1B,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -1,208 +1,181 @@
1
1
  import yargs from "yargs";
2
2
  import { hideBin } from "yargs/helpers";
3
3
  import { startCli } from "./cli.js";
4
- import { listSessions, getSessionFilePath, getFirstMessageContent, } from "wave-agent-sdk";
5
4
  // Export main function for external use
6
5
  export async function main() {
7
- const argv = await yargs(hideBin(process.argv))
8
- .option("restore", {
9
- alias: "r",
10
- description: "Restore session by ID",
11
- type: "string",
12
- global: false,
13
- })
14
- .option("continue", {
15
- alias: "c",
16
- description: "Continue from last session",
17
- type: "boolean",
18
- global: false,
19
- })
20
- .option("print", {
21
- alias: "p",
22
- description: "Print response without interactive mode",
23
- type: "string",
24
- global: false,
25
- })
26
- .option("show-stats", {
27
- description: "Show timing and usage statistics in print mode",
28
- type: "boolean",
29
- global: false,
30
- })
31
- .option("list-sessions", {
32
- description: "List all available sessions",
33
- type: "boolean",
34
- global: false,
35
- })
36
- .option("dangerously-skip-permissions", {
37
- description: "Skip all permission checks (dangerous)",
38
- type: "boolean",
39
- default: false,
40
- global: false,
41
- })
42
- .option("plugin-dir", {
43
- description: "Load a plugin from a specific directory",
44
- type: "array",
45
- string: true,
46
- global: false,
47
- })
48
- .command("plugin", "Manage plugins and marketplaces", (yargs) => {
49
- return yargs
50
- .help()
51
- .command("marketplace", "Manage plugin marketplaces", (yargs) => {
6
+ try {
7
+ const argv = await yargs(hideBin(process.argv))
8
+ .option("restore", {
9
+ alias: "r",
10
+ description: "Restore session by ID (or list sessions if no ID provided)",
11
+ type: "string",
12
+ global: false,
13
+ })
14
+ .option("continue", {
15
+ alias: "c",
16
+ description: "Continue from last session",
17
+ type: "boolean",
18
+ global: false,
19
+ })
20
+ .option("print", {
21
+ alias: "p",
22
+ description: "Print response without interactive mode",
23
+ type: "string",
24
+ global: false,
25
+ })
26
+ .option("show-stats", {
27
+ description: "Show timing and usage statistics in print mode",
28
+ type: "boolean",
29
+ global: false,
30
+ })
31
+ .option("dangerously-skip-permissions", {
32
+ description: "Skip all permission checks (dangerous)",
33
+ type: "boolean",
34
+ default: false,
35
+ global: false,
36
+ })
37
+ .option("plugin-dir", {
38
+ description: "Load a plugin from a specific directory",
39
+ type: "array",
40
+ string: true,
41
+ global: false,
42
+ })
43
+ .command("plugin", "Manage plugins and marketplaces", (yargs) => {
52
44
  return yargs
53
45
  .help()
54
- .command("add <input>", "Add a plugin marketplace (local path, owner/repo, or Git URL)", (yargs) => {
55
- return yargs.positional("input", {
56
- describe: "Path to local marketplace, GitHub owner/repo, or full Git URL (with optional #ref)",
46
+ .command("ui", "Open interactive plugin manager UI", {}, async () => {
47
+ const { startPluginManagerCli } = await import("./plugin-manager-cli.js");
48
+ const shouldExit = await startPluginManagerCli();
49
+ if (shouldExit) {
50
+ process.exit(0);
51
+ }
52
+ })
53
+ .command("marketplace", "Manage plugin marketplaces", (yargs) => {
54
+ return yargs
55
+ .help()
56
+ .command("add <input>", "Add a plugin marketplace (local path, owner/repo, or Git URL)", (yargs) => {
57
+ return yargs.positional("input", {
58
+ describe: "Path to local marketplace, GitHub owner/repo, or full Git URL (with optional #ref)",
59
+ type: "string",
60
+ });
61
+ }, async (argv) => {
62
+ const { addMarketplaceCommand } = await import("./commands/plugin/marketplace.js");
63
+ await addMarketplaceCommand(argv);
64
+ })
65
+ .command("update [name]", "Update registered marketplace(s)", (yargs) => {
66
+ return yargs.positional("name", {
67
+ describe: "Name of the marketplace to update",
68
+ type: "string",
69
+ });
70
+ }, async (argv) => {
71
+ const { updateMarketplaceCommand } = await import("./commands/plugin/marketplace.js");
72
+ await updateMarketplaceCommand(argv);
73
+ })
74
+ .command("list", "List registered marketplaces", {}, async () => {
75
+ const { listMarketplacesCommand } = await import("./commands/plugin/marketplace.js");
76
+ await listMarketplacesCommand();
77
+ })
78
+ .demandCommand(1, "Please specify a marketplace subcommand");
79
+ }, () => { })
80
+ .command("install <plugin>", "Install a plugin from a marketplace", (yargs) => {
81
+ return yargs
82
+ .positional("plugin", {
83
+ describe: "Plugin to install (format: name@marketplace)",
84
+ type: "string",
85
+ })
86
+ .option("scope", {
87
+ alias: "s",
88
+ describe: "Scope to enable the plugin in",
89
+ choices: ["user", "project", "local"],
57
90
  type: "string",
58
91
  });
59
92
  }, async (argv) => {
60
- const { addMarketplaceCommand } = await import("./commands/plugin/marketplace.js");
61
- await addMarketplaceCommand(argv);
93
+ const { installPluginCommand } = await import("./commands/plugin/install.js");
94
+ await installPluginCommand(argv);
95
+ })
96
+ .command("list", "List all available plugins from marketplaces", {}, async () => {
97
+ const { listPluginsCommand } = await import("./commands/plugin/list.js");
98
+ await listPluginsCommand();
62
99
  })
63
- .command("update [name]", "Update registered marketplace(s)", (yargs) => {
64
- return yargs.positional("name", {
65
- describe: "Name of the marketplace to update",
100
+ .command("uninstall <plugin>", "Uninstall a plugin", (yargs) => {
101
+ return yargs.positional("plugin", {
102
+ describe: "Plugin to uninstall (format: name@marketplace)",
66
103
  type: "string",
67
104
  });
68
105
  }, async (argv) => {
69
- const { updateMarketplaceCommand } = await import("./commands/plugin/marketplace.js");
70
- await updateMarketplaceCommand(argv);
106
+ const { uninstallPluginCommand } = await import("./commands/plugin/uninstall.js");
107
+ await uninstallPluginCommand(argv);
71
108
  })
72
- .command("list", "List registered marketplaces", {}, async () => {
73
- const { listMarketplacesCommand } = await import("./commands/plugin/marketplace.js");
74
- await listMarketplacesCommand();
75
- })
76
- .demandCommand(1, "Please specify a marketplace subcommand");
77
- }, () => { })
78
- .command("install <plugin>", "Install a plugin from a marketplace", (yargs) => {
79
- return yargs
80
- .positional("plugin", {
81
- describe: "Plugin to install (format: name@marketplace)",
82
- type: "string",
83
- })
84
- .option("scope", {
85
- alias: "s",
86
- describe: "Scope to enable the plugin in",
87
- choices: ["user", "project", "local"],
88
- default: "user",
89
- type: "string",
90
- });
91
- }, async (argv) => {
92
- const { installPluginCommand } = await import("./commands/plugin/install.js");
93
- await installPluginCommand(argv);
94
- })
95
- .command("list", "List all available plugins from marketplaces", {}, async () => {
96
- const { listPluginsCommand } = await import("./commands/plugin/list.js");
97
- await listPluginsCommand();
98
- })
99
- .command("enable <plugin>", "Enable a plugin in a specific scope", (yargs) => {
100
- return yargs
101
- .positional("plugin", {
102
- describe: "Plugin ID (format: name@marketplace)",
103
- type: "string",
104
- })
105
- .option("scope", {
106
- alias: "s",
107
- describe: "Scope to enable the plugin in",
108
- choices: ["user", "project", "local"],
109
- default: "user",
110
- type: "string",
111
- });
112
- }, async (argv) => {
113
- const { enablePluginCommand } = await import("./commands/plugin/enable.js");
114
- await enablePluginCommand(argv);
115
- })
116
- .command("disable <plugin>", "Disable a plugin in a specific scope", (yargs) => {
117
- return yargs
118
- .positional("plugin", {
119
- describe: "Plugin ID (format: name@marketplace)",
120
- type: "string",
121
- })
122
- .option("scope", {
123
- alias: "s",
124
- describe: "Scope to disable the plugin in",
125
- choices: ["user", "project", "local"],
126
- default: "user",
127
- type: "string",
109
+ .command("update <plugin>", "Update a plugin (uninstall followed by install)", (yargs) => {
110
+ return yargs.positional("plugin", {
111
+ describe: "Plugin to update (format: name@marketplace)",
112
+ type: "string",
113
+ });
114
+ }, async (argv) => {
115
+ const { updatePluginCommand } = await import("./commands/plugin/update.js");
116
+ await updatePluginCommand(argv);
128
117
  });
129
118
  }, async (argv) => {
130
- const { disablePluginCommand } = await import("./commands/plugin/disable.js");
131
- await disablePluginCommand(argv);
132
- })
133
- .demandCommand(1, "Please specify a plugin subcommand");
134
- }, () => { })
135
- .version()
136
- .alias("v", "version")
137
- .example("$0", "Start CLI with default settings")
138
- .example("$0 --restore session_123", "Restore specific session")
139
- .example("$0 --continue", "Continue from last session")
140
- .example("$0 --print 'Hello'", "Send message in print mode")
141
- .example("$0 -p 'Hello' --show-stats", "Send message in print mode with statistics")
142
- .example("$0 --list-sessions", "List all available sessions")
143
- .help("h")
144
- .recommendCommands()
145
- .strict()
146
- .parseAsync();
147
- // Handle list sessions command
148
- if (argv.listSessions) {
149
- try {
150
- const currentWorkdir = process.cwd();
151
- const sessions = await listSessions(currentWorkdir);
152
- if (sessions.length === 0) {
153
- console.log(`No sessions found for workdir: ${currentWorkdir}`);
154
- return;
155
- }
156
- console.log(`Available sessions for: ${currentWorkdir}`);
157
- console.log("==========================================");
158
- // Get last 5 sessions
159
- const lastSessions = sessions.slice(0, 5);
160
- for (const session of lastSessions) {
161
- const lastActiveAt = new Date(session.lastActiveAt).toLocaleString();
162
- const filePath = await getSessionFilePath(session.id, session.workdir);
163
- // Get first message content
164
- const firstMessageContent = await getFirstMessageContent(session.id, session.workdir);
165
- // Truncate content if too long
166
- let truncatedContent = firstMessageContent || "No first message content";
167
- if (truncatedContent.length > 30) {
168
- truncatedContent = truncatedContent.substring(0, 30) + "...";
119
+ // If no subcommand is provided, launch the UI
120
+ if (argv._.length === 1 && argv._[0] === "plugin") {
121
+ const { startPluginManagerCli } = await import("./plugin-manager-cli.js");
122
+ const shouldExit = await startPluginManagerCli();
123
+ if (shouldExit) {
124
+ process.exit(0);
169
125
  }
170
- console.log(`ID: ${session.id}`);
171
- console.log(` Workdir: ${session.workdir}`);
172
- console.log(` File Path: ${filePath}`);
173
- console.log(` Last Active: ${lastActiveAt}`);
174
- console.log(` Last Message Tokens: ${session.latestTotalTokens}`);
175
- console.log(` First Message: ${truncatedContent}`);
176
- console.log("");
177
126
  }
178
- if (sessions.length > 5) {
179
- console.log(`... and ${sessions.length - 5} more sessions`);
127
+ })
128
+ .version()
129
+ .alias("v", "version")
130
+ .example("$0", "Start CLI with default settings")
131
+ .example("$0 --restore session_123", "Restore specific session")
132
+ .example("$0 --continue", "Continue from last session")
133
+ .example("$0 --print 'Hello'", "Send message in print mode")
134
+ .example("$0 -p 'Hello' --show-stats", "Send message in print mode with statistics")
135
+ .help("h")
136
+ .recommendCommands()
137
+ .strict()
138
+ .parseAsync();
139
+ // Handle restore session command
140
+ if (argv.restore === "" ||
141
+ (process.argv.includes("-r") && argv.restore === undefined) ||
142
+ (process.argv.includes("--restore") && argv.restore === undefined)) {
143
+ // Interactive session selection
144
+ const { startSessionSelectorCli } = await import("./session-selector-cli.js");
145
+ const selectedSessionId = await startSessionSelectorCli();
146
+ if (!selectedSessionId) {
147
+ return;
180
148
  }
181
- return;
149
+ // Continue with the selected session
150
+ return startCli({
151
+ restoreSessionId: selectedSessionId,
152
+ bypassPermissions: argv.dangerouslySkipPermissions,
153
+ pluginDirs: argv.pluginDir,
154
+ });
182
155
  }
183
- catch (error) {
184
- console.error("Failed to list sessions:", error);
185
- process.exit(1);
156
+ // Handle print mode directly
157
+ if (argv.print !== undefined) {
158
+ const { startPrintCli } = await import("./print-cli.js");
159
+ return startPrintCli({
160
+ restoreSessionId: argv.restore,
161
+ continueLastSession: argv.continue,
162
+ message: argv.print,
163
+ showStats: argv.showStats,
164
+ bypassPermissions: argv.dangerouslySkipPermissions,
165
+ pluginDirs: argv.pluginDir,
166
+ });
186
167
  }
187
- }
188
- // Handle print mode directly
189
- if (argv.print !== undefined) {
190
- const { startPrintCli } = await import("./print-cli.js");
191
- return startPrintCli({
168
+ await startCli({
192
169
  restoreSessionId: argv.restore,
193
170
  continueLastSession: argv.continue,
194
- message: argv.print,
195
- showStats: argv.showStats,
196
171
  bypassPermissions: argv.dangerouslySkipPermissions,
197
172
  pluginDirs: argv.pluginDir,
198
173
  });
199
174
  }
200
- await startCli({
201
- restoreSessionId: argv.restore,
202
- continueLastSession: argv.continue,
203
- bypassPermissions: argv.dangerouslySkipPermissions,
204
- pluginDirs: argv.pluginDir,
205
- });
175
+ catch (error) {
176
+ console.error("Failed to start WAVE Code:", error);
177
+ process.exit(1);
178
+ }
206
179
  }
207
180
  // Export CLI function
208
181
  export { startCli } from "./cli.js";