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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
3
|
import { useChat } from "../contexts/useChat.js";
|
|
4
|
+
import { Markdown } from "./Markdown.js";
|
|
4
5
|
export const SubagentBlock = ({ block }) => {
|
|
5
6
|
const { subagentMessages } = useChat();
|
|
6
7
|
// Get messages for this subagent from context
|
|
@@ -43,5 +44,23 @@ export const SubagentBlock = ({ block }) => {
|
|
|
43
44
|
return { tools: tools.reverse(), totalToolCount }; // Reverse to show oldest first, newest last
|
|
44
45
|
};
|
|
45
46
|
const { tools: lastTwoTools, totalToolCount } = getLastTwoTools();
|
|
46
|
-
|
|
47
|
+
// Get the last text message content if completed
|
|
48
|
+
const getLastTextMessage = () => {
|
|
49
|
+
if (block.status !== "completed")
|
|
50
|
+
return null;
|
|
51
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
52
|
+
const message = messages[i];
|
|
53
|
+
if (message.role === "assistant") {
|
|
54
|
+
for (let j = message.blocks.length - 1; j >= 0; j--) {
|
|
55
|
+
const messageBlock = message.blocks[j];
|
|
56
|
+
if (messageBlock.type === "text" && messageBlock.content) {
|
|
57
|
+
return messageBlock.content;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
};
|
|
64
|
+
const lastTextMessage = getLastTextMessage();
|
|
65
|
+
return (_jsxs(Box, { borderRight: false, borderTop: false, borderBottom: false, borderStyle: "classic", borderColor: "magenta", paddingX: 1, paddingY: 0, flexDirection: "column", marginBottom: 1, children: [_jsx(Box, { flexDirection: "row", gap: 1, children: _jsxs(Box, { flexDirection: "row", alignItems: "center", children: [_jsxs(Text, { color: "cyan", children: ["\uD83E\uDD16 ", block.subagentName] }), _jsxs(Text, { color: statusInfo.color, dimColor: false, children: [" ", statusInfo.icon] }), _jsxs(Text, { color: "gray", dimColor: true, children: [" ", "(", messages.length, " messages)"] })] }) }), lastTextMessage && (_jsx(Box, { marginTop: 1, children: _jsx(Markdown, { children: lastTextMessage }) })), block.status !== "completed" && lastTwoTools.length > 0 && (_jsxs(Box, { flexDirection: "column", marginTop: 1, gap: 1, children: [totalToolCount > 2 && (_jsx(Text, { color: "gray", dimColor: true, children: "..." })), lastTwoTools.map((tool, index) => (_jsxs(Box, { flexDirection: "row", children: [_jsx(Text, { color: "magenta", children: "\uD83D\uDD27 " }), _jsx(Text, { color: "white", children: tool.name }), tool.compactParams && (_jsxs(Text, { color: "gray", children: [" ", tool.compactParams] }))] }, index)))] }))] }));
|
|
47
66
|
};
|
|
@@ -49,5 +49,5 @@ export const ToolResultDisplay = ({ block, isExpanded = false, }) => {
|
|
|
49
49
|
return null;
|
|
50
50
|
};
|
|
51
51
|
const shortResult = getShortResult();
|
|
52
|
-
return (_jsxs(Box, { flexDirection: "column", gap: 1, children: [_jsxs(Box, { children: [_jsx(Text, { color: "magenta", children: "\uD83D\uDD27 " }), _jsx(Text, { color: "white", children: toolName }), !isExpanded && compactParams && (_jsxs(Text, { color: "gray", children: [" ", compactParams] })), _jsxs(Text, { color: getStatusColor(), children: [" ", getStatusText()] }), hasImages() && _jsxs(Text, { color: "blue", children: [" ", getImageIndicator()] })] }), !isExpanded && shortResult && !error && (_jsx(Box, { paddingLeft: 2, borderLeft: true, borderColor: "gray", flexDirection: "column", children: shortResult.split("\n").map((line, index) => (_jsx(Text, { color: "white", children: line }, index))) })), isExpanded && parameters && (_jsxs(Box, { paddingLeft: 2, borderLeft: true, borderColor: "gray", flexDirection: "column", children: [_jsx(Text, { color: "cyan", bold: true, children: "Parameters:" }), _jsx(Text, { color: "gray", children: parameters })] })), isExpanded && result && (_jsx(Box, { flexDirection: "column", children: _jsxs(Box, { paddingLeft: 2, borderLeft: true, borderColor: "green", flexDirection: "column", children: [_jsx(Text, { color: "cyan", bold: true, children: "Result:" }), _jsx(Text, { color: "white", children: result })] }) })), error && (_jsx(Box, { children: _jsxs(Text, { color: "red", children: ["Error: ", typeof error === "string" ? error : String(error)] }) })), stage === "end" && (_jsx(DiffDisplay, { toolName: name, parameters: parameters }))] }));
|
|
52
|
+
return (_jsxs(Box, { flexDirection: "column", gap: 1, children: [_jsxs(Box, { children: [_jsx(Text, { color: "magenta", children: "\uD83D\uDD27 " }), _jsx(Text, { color: "white", children: toolName }), !isExpanded && compactParams && (_jsxs(Text, { color: "gray", children: [" ", compactParams] })), _jsxs(Text, { color: getStatusColor(), children: [" ", getStatusText()] }), hasImages() && _jsxs(Text, { color: "blue", children: [" ", getImageIndicator()] })] }), !isExpanded && shortResult && !error && (_jsx(Box, { paddingLeft: 2, borderLeft: true, borderColor: "gray", flexDirection: "column", children: shortResult.split("\n").map((line, index) => (_jsx(Text, { color: "white", children: line }, index))) })), isExpanded && parameters && (_jsxs(Box, { paddingLeft: 2, borderLeft: true, borderColor: "gray", flexDirection: "column", children: [_jsx(Text, { color: "cyan", bold: true, children: "Parameters:" }), _jsx(Text, { color: "gray", children: parameters })] })), isExpanded && result && (_jsx(Box, { flexDirection: "column", children: _jsxs(Box, { paddingLeft: 2, borderLeft: true, borderColor: "green", flexDirection: "column", children: [_jsx(Text, { color: "cyan", bold: true, children: "Result:" }), _jsx(Text, { color: "white", children: result })] }) })), error && (_jsx(Box, { children: _jsxs(Text, { color: "red", children: ["Error: ", typeof error === "string" ? error : String(error)] }) })), stage === "end" && success && (_jsx(DiffDisplay, { toolName: name, parameters: parameters }))] }));
|
|
53
53
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PluginManagerContextType } from "../components/PluginManagerTypes.js";
|
|
2
|
+
export declare const PluginManagerContext: import("react").Context<PluginManagerContextType | null>;
|
|
3
|
+
export declare const usePluginManagerContext: () => PluginManagerContextType;
|
|
4
|
+
//# sourceMappingURL=PluginManagerContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginManagerContext.d.ts","sourceRoot":"","sources":["../../src/contexts/PluginManagerContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAE/E,eAAO,MAAM,oBAAoB,0DACqB,CAAC;AAEvD,eAAO,MAAM,uBAAuB,gCAQnC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
export const PluginManagerContext = createContext(null);
|
|
3
|
+
export const usePluginManagerContext = () => {
|
|
4
|
+
const context = useContext(PluginManagerContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error("usePluginManagerContext must be used within a PluginManagerProvider");
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
@@ -41,6 +41,8 @@ export interface ChatContextType {
|
|
|
41
41
|
hideConfirmation: () => void;
|
|
42
42
|
handleConfirmationDecision: (decision: PermissionDecision) => void;
|
|
43
43
|
handleConfirmationCancel: () => void;
|
|
44
|
+
rewindId: number;
|
|
45
|
+
handleRewindSelect: (index: number) => Promise<void>;
|
|
44
46
|
}
|
|
45
47
|
export declare const useChat: () => ChatContextType;
|
|
46
48
|
export interface ChatProviderProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChat.d.ts","sourceRoot":"","sources":["../../src/contexts/useChat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EACV,OAAO,EACP,eAAe,EACf,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACf,MAAM,gBAAgB,CAAC;AAUxB,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAE3B,UAAU,EAAE,OAAO,CAAC;IAEpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,CACX,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,KAC/C,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAE1B,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzE,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3D,mBAAmB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAE9D,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,wBAAwB,EAAE,CACxB,OAAO,EAAE,MAAM,KACZ;QAAE,MAAM,EAAE,MAAM,C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AC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAE5C,cAAc,EAAE,cAAc,CAAC;IAC/B,iBAAiB,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IAElD,qBAAqB,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE;QACf,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,oBAAoB,CAAC,EAAE,OAAO,CAAC;KAChC,CAAC;IACF,gBAAgB,EAAE,CAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,eAAe,CAAC,EAAE,MAAM,EACxB,oBAAoB,CAAC,EAAE,OAAO,KAC3B,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACjC,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,0BAA0B,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACnE,wBAAwB,EAAE,MAAM,IAAI,CAAC;IAErC,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACtD;AAID,eAAO,MAAM,OAAO,uBAMnB,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAocpD,CAAC"}
|
package/dist/contexts/useChat.js
CHANGED
|
@@ -40,6 +40,8 @@ export const ChatProvider = ({ children, bypassPermissions, pluginDirs, }) => {
|
|
|
40
40
|
const [confirmingTool, setConfirmingTool] = useState();
|
|
41
41
|
const [confirmationQueue, setConfirmationQueue] = useState([]);
|
|
42
42
|
const [currentConfirmation, setCurrentConfirmation] = useState(null);
|
|
43
|
+
// Rewind state
|
|
44
|
+
const [rewindId, setRewindId] = useState(0);
|
|
43
45
|
const agentRef = useRef(null);
|
|
44
46
|
// Permission confirmation methods with queue support
|
|
45
47
|
const showConfirmation = useCallback(async (toolName, toolInput, suggestedPrefix, hidePersistentOption) => {
|
|
@@ -93,6 +95,9 @@ export const ChatProvider = ({ children, bypassPermissions, pluginDirs, }) => {
|
|
|
93
95
|
onPermissionModeChange: (mode) => {
|
|
94
96
|
setPermissionModeState(mode);
|
|
95
97
|
},
|
|
98
|
+
onSlashCommandsChange: (commands) => {
|
|
99
|
+
setSlashCommands([...commands]);
|
|
100
|
+
},
|
|
96
101
|
};
|
|
97
102
|
try {
|
|
98
103
|
// Create the permission callback inside the try block to access showConfirmation
|
|
@@ -296,6 +301,20 @@ export const ChatProvider = ({ children, bypassPermissions, pluginDirs, }) => {
|
|
|
296
301
|
}
|
|
297
302
|
hideConfirmation();
|
|
298
303
|
}, [currentConfirmation, hideConfirmation]);
|
|
304
|
+
const handleRewindSelect = useCallback(async (index) => {
|
|
305
|
+
if (agentRef.current) {
|
|
306
|
+
try {
|
|
307
|
+
await agentRef.current.truncateHistory(index);
|
|
308
|
+
// Clear terminal screen after rewind
|
|
309
|
+
process.stdout.write("\x1Bc", () => {
|
|
310
|
+
setRewindId((prev) => prev + 1);
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
logger.error("Failed to rewind:", error);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}, []);
|
|
299
318
|
// Listen for Ctrl+O hotkey to toggle collapse/expand state and ESC to cancel confirmation
|
|
300
319
|
useInput((input, key) => {
|
|
301
320
|
if (key.ctrl && input === "o") {
|
|
@@ -341,6 +360,8 @@ export const ChatProvider = ({ children, bypassPermissions, pluginDirs, }) => {
|
|
|
341
360
|
hideConfirmation,
|
|
342
361
|
handleConfirmationDecision,
|
|
343
362
|
handleConfirmationCancel,
|
|
363
|
+
rewindId,
|
|
364
|
+
handleRewindSelect,
|
|
344
365
|
};
|
|
345
366
|
return (_jsx(ChatContext.Provider, { value: contextValue, children: children }));
|
|
346
367
|
};
|
|
@@ -12,13 +12,13 @@ export declare const useInputManager: (callbacks?: Partial<InputManagerCallbacks
|
|
|
12
12
|
showCommandSelector: boolean;
|
|
13
13
|
commandSearchQuery: string;
|
|
14
14
|
slashPosition: number;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
exclamationPosition: number;
|
|
15
|
+
showHistorySearch: boolean;
|
|
16
|
+
historySearchQuery: string;
|
|
18
17
|
showMemoryTypeSelector: boolean;
|
|
19
18
|
memoryMessage: string;
|
|
20
19
|
showBashManager: boolean;
|
|
21
20
|
showMcpManager: boolean;
|
|
21
|
+
showRewindManager: boolean;
|
|
22
22
|
permissionMode: PermissionMode;
|
|
23
23
|
attachedImages: AttachedImage[];
|
|
24
24
|
isManagerReady: boolean;
|
|
@@ -49,15 +49,8 @@ export declare const useInputManager: (callbacks?: Partial<InputManagerCallbacks
|
|
|
49
49
|
handleCancelCommandSelect: () => void;
|
|
50
50
|
updateCommandSearchQuery: (query: string) => void;
|
|
51
51
|
checkForSlashDeletion: (cursorPos: number) => boolean;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
newInput: string;
|
|
55
|
-
newCursorPosition: number;
|
|
56
|
-
};
|
|
57
|
-
handleCancelBashHistorySelect: () => void;
|
|
58
|
-
updateBashHistorySearchQuery: (query: string) => void;
|
|
59
|
-
handleBashHistoryExecute: (command: string) => string;
|
|
60
|
-
checkForExclamationDeletion: (cursorPos: number) => boolean;
|
|
52
|
+
handleHistorySearchSelect: (prompt: string) => void;
|
|
53
|
+
handleCancelHistorySearch: () => void;
|
|
61
54
|
activateMemoryTypeSelector: (message: string) => void;
|
|
62
55
|
handleMemoryTypeSelect: (type: "project" | "user") => Promise<void>;
|
|
63
56
|
handleCancelMemoryTypeSelect: () => void;
|
|
@@ -70,6 +63,7 @@ export declare const useInputManager: (callbacks?: Partial<InputManagerCallbacks
|
|
|
70
63
|
handleSpecialCharInput: (char: string) => void;
|
|
71
64
|
setShowBashManager: (show: boolean) => void;
|
|
72
65
|
setShowMcpManager: (show: boolean) => void;
|
|
66
|
+
setShowRewindManager: (show: boolean) => void;
|
|
73
67
|
setPermissionMode: (mode: PermissionMode) => void;
|
|
74
68
|
addImage: (imagePath: string, mimeType: string) => AttachedImage | undefined;
|
|
75
69
|
removeImage: (imageId: number) => void;
|
|
@@ -83,8 +77,6 @@ export declare const useInputManager: (callbacks?: Partial<InputManagerCallbacks
|
|
|
83
77
|
}>, isLoading?: boolean, isCommandRunning?: boolean) => Promise<void>;
|
|
84
78
|
expandLongTextPlaceholders: (text: string) => string;
|
|
85
79
|
clearLongTextMap: () => void;
|
|
86
|
-
handleBashHistoryExecuteAndSend: (command: string) => void;
|
|
87
|
-
handleBashHistoryDelete: (command: string, workdir?: string) => void;
|
|
88
80
|
handleInput: (input: string, key: Key, attachedImages: Array<{
|
|
89
81
|
id: number;
|
|
90
82
|
path: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInputManager.d.ts","sourceRoot":"","sources":["../../src/hooks/useInputManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,aAAa,EACd,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,eAAO,MAAM,eAAe,GAC1B,YAAW,OAAO,CAAC,qBAAqB,CAAM;;;;;;;;;;;;;;;;;;;;+
|
|
1
|
+
{"version":3,"file":"useInputManager.d.ts","sourceRoot":"","sources":["../../src/hooks/useInputManager.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I;yBAvIgB,MAAM;kCAIG,MAAM;;CA0J9D,CAAC"}
|
|
@@ -18,10 +18,9 @@ export const useInputManager = (callbacks = {}) => {
|
|
|
18
18
|
query: "",
|
|
19
19
|
position: -1,
|
|
20
20
|
});
|
|
21
|
-
const [
|
|
21
|
+
const [historySearchState, setHistorySearchState] = useState({
|
|
22
22
|
show: false,
|
|
23
23
|
query: "",
|
|
24
|
-
position: -1,
|
|
25
24
|
});
|
|
26
25
|
const [memoryTypeSelectorState, setMemoryTypeSelectorState] = useState({
|
|
27
26
|
show: false,
|
|
@@ -29,6 +28,7 @@ export const useInputManager = (callbacks = {}) => {
|
|
|
29
28
|
});
|
|
30
29
|
const [showBashManager, setShowBashManager] = useState(false);
|
|
31
30
|
const [showMcpManager, setShowMcpManager] = useState(false);
|
|
31
|
+
const [showRewindManager, setShowRewindManager] = useState(false);
|
|
32
32
|
const [permissionMode, setPermissionModeState] = useState("default");
|
|
33
33
|
const [attachedImages, setAttachedImages] = useState([]);
|
|
34
34
|
// Create InputManager on mount and update callbacks when they change
|
|
@@ -45,8 +45,8 @@ export const useInputManager = (callbacks = {}) => {
|
|
|
45
45
|
onCommandSelectorStateChange: (show, query, position) => {
|
|
46
46
|
setCommandSelectorState({ show, query, position });
|
|
47
47
|
},
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
onHistorySearchStateChange: (show, query) => {
|
|
49
|
+
setHistorySearchState({ show, query });
|
|
50
50
|
},
|
|
51
51
|
onMemoryTypeSelectorStateChange: (show, message) => {
|
|
52
52
|
setMemoryTypeSelectorState({ show, message });
|
|
@@ -57,6 +57,9 @@ export const useInputManager = (callbacks = {}) => {
|
|
|
57
57
|
onMcpManagerStateChange: (show) => {
|
|
58
58
|
setShowMcpManager(show);
|
|
59
59
|
},
|
|
60
|
+
onRewindManagerStateChange: (show) => {
|
|
61
|
+
setShowRewindManager(show);
|
|
62
|
+
},
|
|
60
63
|
onPermissionModeChange: (mode) => {
|
|
61
64
|
setPermissionModeState(mode);
|
|
62
65
|
callbacks.onPermissionModeChange?.(mode);
|
|
@@ -64,6 +67,7 @@ export const useInputManager = (callbacks = {}) => {
|
|
|
64
67
|
onImagesStateChange: setAttachedImages,
|
|
65
68
|
onShowBashManager: () => setShowBashManager(true),
|
|
66
69
|
onShowMcpManager: () => setShowMcpManager(true),
|
|
70
|
+
onShowRewindManager: () => setShowRewindManager(true),
|
|
67
71
|
...callbacks,
|
|
68
72
|
});
|
|
69
73
|
managerRef.current = manager;
|
|
@@ -81,8 +85,8 @@ export const useInputManager = (callbacks = {}) => {
|
|
|
81
85
|
onCommandSelectorStateChange: (show, query, position) => {
|
|
82
86
|
setCommandSelectorState({ show, query, position });
|
|
83
87
|
},
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
onHistorySearchStateChange: (show, query) => {
|
|
89
|
+
setHistorySearchState({ show, query });
|
|
86
90
|
},
|
|
87
91
|
onMemoryTypeSelectorStateChange: (show, message) => {
|
|
88
92
|
setMemoryTypeSelectorState({ show, message });
|
|
@@ -93,6 +97,9 @@ export const useInputManager = (callbacks = {}) => {
|
|
|
93
97
|
onMcpManagerStateChange: (show) => {
|
|
94
98
|
setShowMcpManager(show);
|
|
95
99
|
},
|
|
100
|
+
onRewindManagerStateChange: (show) => {
|
|
101
|
+
setShowRewindManager(show);
|
|
102
|
+
},
|
|
96
103
|
onPermissionModeChange: (mode) => {
|
|
97
104
|
setPermissionModeState(mode);
|
|
98
105
|
callbacks.onPermissionModeChange?.(mode);
|
|
@@ -100,6 +107,7 @@ export const useInputManager = (callbacks = {}) => {
|
|
|
100
107
|
onImagesStateChange: setAttachedImages,
|
|
101
108
|
onShowBashManager: () => setShowBashManager(true),
|
|
102
109
|
onShowMcpManager: () => setShowMcpManager(true),
|
|
110
|
+
onShowRewindManager: () => setShowRewindManager(true),
|
|
103
111
|
...callbacks,
|
|
104
112
|
});
|
|
105
113
|
}
|
|
@@ -178,27 +186,12 @@ export const useInputManager = (callbacks = {}) => {
|
|
|
178
186
|
const checkForSlashDeletion = useCallback((cursorPos) => {
|
|
179
187
|
return managerRef.current?.checkForSlashDeletion(cursorPos) || false;
|
|
180
188
|
}, []);
|
|
181
|
-
//
|
|
182
|
-
const
|
|
183
|
-
managerRef.current?.
|
|
189
|
+
// History search methods
|
|
190
|
+
const handleHistorySearchSelect = useCallback((prompt) => {
|
|
191
|
+
managerRef.current?.handleHistorySearchSelect(prompt);
|
|
184
192
|
}, []);
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
newInput: inputText,
|
|
188
|
-
newCursorPosition: cursorPosition,
|
|
189
|
-
});
|
|
190
|
-
}, [inputText, cursorPosition]);
|
|
191
|
-
const handleCancelBashHistorySelect = useCallback(() => {
|
|
192
|
-
managerRef.current?.handleCancelBashHistorySelect();
|
|
193
|
-
}, []);
|
|
194
|
-
const updateBashHistorySearchQuery = useCallback((query) => {
|
|
195
|
-
managerRef.current?.updateBashHistorySearchQuery(query);
|
|
196
|
-
}, []);
|
|
197
|
-
const handleBashHistoryExecute = useCallback((command) => {
|
|
198
|
-
return managerRef.current?.handleBashHistoryExecute(command) || command;
|
|
199
|
-
}, []);
|
|
200
|
-
const checkForExclamationDeletion = useCallback((cursorPos) => {
|
|
201
|
-
return managerRef.current?.checkForExclamationDeletion(cursorPos) || false;
|
|
193
|
+
const handleCancelHistorySearch = useCallback(() => {
|
|
194
|
+
managerRef.current?.handleCancelHistorySearch();
|
|
202
195
|
}, []);
|
|
203
196
|
// Memory type selector methods
|
|
204
197
|
const activateMemoryTypeSelector = useCallback((message) => {
|
|
@@ -235,12 +228,6 @@ export const useInputManager = (callbacks = {}) => {
|
|
|
235
228
|
managerRef.current?.setCursorPosition(position);
|
|
236
229
|
}, []);
|
|
237
230
|
// Complex handlers that combine multiple operations
|
|
238
|
-
const handleBashHistoryExecuteAndSend = useCallback((command) => {
|
|
239
|
-
managerRef.current?.handleBashHistoryExecuteAndSend(command);
|
|
240
|
-
}, []);
|
|
241
|
-
const handleBashHistoryDelete = useCallback((command, workdir) => {
|
|
242
|
-
managerRef.current?.handleBashHistoryDelete(command, workdir);
|
|
243
|
-
}, []);
|
|
244
231
|
return {
|
|
245
232
|
// State
|
|
246
233
|
inputText,
|
|
@@ -252,13 +239,13 @@ export const useInputManager = (callbacks = {}) => {
|
|
|
252
239
|
showCommandSelector: commandSelectorState.show,
|
|
253
240
|
commandSearchQuery: commandSelectorState.query,
|
|
254
241
|
slashPosition: commandSelectorState.position,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
exclamationPosition: bashHistorySelectorState.position,
|
|
242
|
+
showHistorySearch: historySearchState.show,
|
|
243
|
+
historySearchQuery: historySearchState.query,
|
|
258
244
|
showMemoryTypeSelector: memoryTypeSelectorState.show,
|
|
259
245
|
memoryMessage: memoryTypeSelectorState.message,
|
|
260
246
|
showBashManager,
|
|
261
247
|
showMcpManager,
|
|
248
|
+
showRewindManager,
|
|
262
249
|
permissionMode,
|
|
263
250
|
attachedImages,
|
|
264
251
|
isManagerReady,
|
|
@@ -283,13 +270,9 @@ export const useInputManager = (callbacks = {}) => {
|
|
|
283
270
|
handleCancelCommandSelect,
|
|
284
271
|
updateCommandSearchQuery,
|
|
285
272
|
checkForSlashDeletion,
|
|
286
|
-
//
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
handleCancelBashHistorySelect,
|
|
290
|
-
updateBashHistorySearchQuery,
|
|
291
|
-
handleBashHistoryExecute,
|
|
292
|
-
checkForExclamationDeletion,
|
|
273
|
+
// History search
|
|
274
|
+
handleHistorySearchSelect,
|
|
275
|
+
handleCancelHistorySearch,
|
|
293
276
|
// Memory type selector
|
|
294
277
|
activateMemoryTypeSelector,
|
|
295
278
|
handleMemoryTypeSelect,
|
|
@@ -307,6 +290,10 @@ export const useInputManager = (callbacks = {}) => {
|
|
|
307
290
|
setShowMcpManager: useCallback((show) => {
|
|
308
291
|
managerRef.current?.setShowMcpManager(show);
|
|
309
292
|
}, []),
|
|
293
|
+
setShowRewindManager: useCallback((show) => {
|
|
294
|
+
managerRef.current?.setShowRewindManager(show);
|
|
295
|
+
setShowRewindManager(show);
|
|
296
|
+
}, []),
|
|
310
297
|
setPermissionMode: useCallback((mode) => {
|
|
311
298
|
setPermissionModeState(mode);
|
|
312
299
|
managerRef.current?.setPermissionMode(mode);
|
|
@@ -337,9 +324,6 @@ export const useInputManager = (callbacks = {}) => {
|
|
|
337
324
|
clearLongTextMap: useCallback(() => {
|
|
338
325
|
managerRef.current?.clearLongTextMap();
|
|
339
326
|
}, []),
|
|
340
|
-
// Complex handlers combining multiple operations
|
|
341
|
-
handleBashHistoryExecuteAndSend,
|
|
342
|
-
handleBashHistoryDelete,
|
|
343
327
|
// Main input handler
|
|
344
328
|
handleInput: useCallback(async (input, key, attachedImages, isLoading = false, isCommandRunning = false, clearImages) => {
|
|
345
329
|
return ((await managerRef.current?.handleInput(input, key, attachedImages, isLoading, isCommandRunning, clearImages)) || false);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePluginManager.d.ts","sourceRoot":"","sources":["../../src/hooks/usePluginManager.ts"],"names":[],"mappings":"AAUA,OAAO,EAGL,wBAAwB,EACzB,MAAM,qCAAqC,CAAC;AAE7C,wBAAgB,gBAAgB,IAAI,wBAAwB,CAuR3D"}
|
|
@@ -0,0 +1,223 @@
|
|
|
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
|
+
await marketplaceService.installPlugin(pluginId);
|
|
153
|
+
await pluginScopeManager.enablePlugin(scope, pluginId);
|
|
154
|
+
await refresh();
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
setState((prev) => ({
|
|
158
|
+
...prev,
|
|
159
|
+
isLoading: false,
|
|
160
|
+
error: error instanceof Error ? error.message : String(error),
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
}, [marketplaceService, pluginScopeManager, refresh]);
|
|
164
|
+
const uninstallPlugin = useCallback(async (name, marketplace) => {
|
|
165
|
+
setState((prev) => ({
|
|
166
|
+
...prev,
|
|
167
|
+
isLoading: true,
|
|
168
|
+
error: null,
|
|
169
|
+
}));
|
|
170
|
+
try {
|
|
171
|
+
const pluginId = `${name}@${marketplace}`;
|
|
172
|
+
// Find the scope where it's currently enabled and remove it from there
|
|
173
|
+
const scope = pluginScopeManager.findPluginScope(pluginId);
|
|
174
|
+
if (scope) {
|
|
175
|
+
await configurationService.removeEnabledPlugin(process.cwd(), scope, pluginId);
|
|
176
|
+
}
|
|
177
|
+
await refresh();
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
setState((prev) => ({
|
|
181
|
+
...prev,
|
|
182
|
+
isLoading: false,
|
|
183
|
+
error: error instanceof Error ? error.message : String(error),
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
186
|
+
}, [configurationService, pluginScopeManager, refresh]);
|
|
187
|
+
const updatePlugin = useCallback(async (name, marketplace) => {
|
|
188
|
+
setState((prev) => ({
|
|
189
|
+
...prev,
|
|
190
|
+
isLoading: true,
|
|
191
|
+
error: null,
|
|
192
|
+
}));
|
|
193
|
+
try {
|
|
194
|
+
const pluginId = `${name}@${marketplace}`;
|
|
195
|
+
await marketplaceService.updatePlugin(pluginId);
|
|
196
|
+
await refresh();
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
setState((prev) => ({
|
|
200
|
+
...prev,
|
|
201
|
+
isLoading: false,
|
|
202
|
+
error: error instanceof Error ? error.message : String(error),
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
}, [marketplaceService, refresh]);
|
|
206
|
+
return {
|
|
207
|
+
state,
|
|
208
|
+
marketplaces,
|
|
209
|
+
installedPlugins,
|
|
210
|
+
discoverablePlugins,
|
|
211
|
+
actions: {
|
|
212
|
+
setView,
|
|
213
|
+
setSelectedId,
|
|
214
|
+
addMarketplace,
|
|
215
|
+
removeMarketplace,
|
|
216
|
+
updateMarketplace,
|
|
217
|
+
installPlugin,
|
|
218
|
+
uninstallPlugin,
|
|
219
|
+
updatePlugin,
|
|
220
|
+
refresh,
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
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"}
|