claudeup 3.7.1 → 3.8.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 (46) hide show
  1. package/package.json +1 -1
  2. package/src/data/settings-catalog.js +612 -0
  3. package/src/data/settings-catalog.ts +689 -0
  4. package/src/prerunner/index.js +2 -1
  5. package/src/prerunner/index.ts +2 -0
  6. package/src/services/plugin-manager.js +2 -0
  7. package/src/services/plugin-manager.ts +3 -0
  8. package/src/services/profiles.js +161 -0
  9. package/src/services/profiles.ts +225 -0
  10. package/src/services/settings-manager.js +108 -0
  11. package/src/services/settings-manager.ts +140 -0
  12. package/src/types/index.ts +34 -0
  13. package/src/ui/App.js +17 -18
  14. package/src/ui/App.tsx +21 -23
  15. package/src/ui/components/TabBar.js +8 -8
  16. package/src/ui/components/TabBar.tsx +14 -19
  17. package/src/ui/components/layout/ScreenLayout.js +8 -14
  18. package/src/ui/components/layout/ScreenLayout.tsx +51 -58
  19. package/src/ui/components/modals/ModalContainer.js +43 -11
  20. package/src/ui/components/modals/ModalContainer.tsx +44 -12
  21. package/src/ui/components/modals/SelectModal.js +4 -18
  22. package/src/ui/components/modals/SelectModal.tsx +10 -21
  23. package/src/ui/screens/CliToolsScreen.js +2 -2
  24. package/src/ui/screens/CliToolsScreen.tsx +8 -8
  25. package/src/ui/screens/EnvVarsScreen.js +248 -116
  26. package/src/ui/screens/EnvVarsScreen.tsx +419 -184
  27. package/src/ui/screens/McpRegistryScreen.tsx +18 -6
  28. package/src/ui/screens/McpScreen.js +1 -1
  29. package/src/ui/screens/McpScreen.tsx +15 -5
  30. package/src/ui/screens/ModelSelectorScreen.js +3 -5
  31. package/src/ui/screens/ModelSelectorScreen.tsx +12 -16
  32. package/src/ui/screens/PluginsScreen.js +181 -65
  33. package/src/ui/screens/PluginsScreen.tsx +308 -91
  34. package/src/ui/screens/ProfilesScreen.js +255 -0
  35. package/src/ui/screens/ProfilesScreen.tsx +487 -0
  36. package/src/ui/screens/StatusLineScreen.js +2 -2
  37. package/src/ui/screens/StatusLineScreen.tsx +10 -12
  38. package/src/ui/screens/index.js +2 -2
  39. package/src/ui/screens/index.ts +2 -2
  40. package/src/ui/state/AppContext.js +2 -1
  41. package/src/ui/state/AppContext.tsx +2 -0
  42. package/src/ui/state/reducer.js +63 -19
  43. package/src/ui/state/reducer.ts +68 -19
  44. package/src/ui/state/types.ts +33 -14
  45. package/src/utils/clipboard.js +56 -0
  46. package/src/utils/clipboard.ts +58 -0
@@ -0,0 +1,255 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "@opentui/react/jsx-runtime";
2
+ import { useEffect, useCallback } from "react";
3
+ import { useApp, useModal } from "../state/AppContext.js";
4
+ import { useDimensions } from "../state/DimensionsContext.js";
5
+ import { useKeyboard } from "../hooks/useKeyboard.js";
6
+ import { ScreenLayout } from "../components/layout/index.js";
7
+ import { ScrollableList } from "../components/ScrollableList.js";
8
+ import { listProfiles, applyProfile, renameProfile, deleteProfile, exportProfileToJson, importProfileFromJson, } from "../../services/profiles.js";
9
+ import { writeClipboard, readClipboard, ClipboardUnavailableError, } from "../../utils/clipboard.js";
10
+ export function ProfilesScreen() {
11
+ const { state, dispatch } = useApp();
12
+ const { profiles: profilesState } = state;
13
+ const modal = useModal();
14
+ const dimensions = useDimensions();
15
+ // Fetch data
16
+ const fetchData = useCallback(async () => {
17
+ dispatch({ type: "PROFILES_DATA_LOADING" });
18
+ try {
19
+ const entries = await listProfiles(state.projectPath);
20
+ dispatch({ type: "PROFILES_DATA_SUCCESS", profiles: entries });
21
+ }
22
+ catch (error) {
23
+ dispatch({
24
+ type: "PROFILES_DATA_ERROR",
25
+ error: error instanceof Error ? error : new Error(String(error)),
26
+ });
27
+ }
28
+ }, [dispatch, state.projectPath]);
29
+ useEffect(() => {
30
+ fetchData();
31
+ }, [fetchData, state.dataRefreshVersion]);
32
+ const profileList = profilesState.profiles.status === "success"
33
+ ? profilesState.profiles.data
34
+ : [];
35
+ const selectedProfile = profileList[profilesState.selectedIndex];
36
+ // Keyboard handling
37
+ useKeyboard((event) => {
38
+ if (state.isSearching || state.modal)
39
+ return;
40
+ if (event.name === "up" || event.name === "k") {
41
+ const newIndex = Math.max(0, profilesState.selectedIndex - 1);
42
+ dispatch({ type: "PROFILES_SELECT", index: newIndex });
43
+ }
44
+ else if (event.name === "down" || event.name === "j") {
45
+ const newIndex = Math.min(Math.max(0, profileList.length - 1), profilesState.selectedIndex + 1);
46
+ dispatch({ type: "PROFILES_SELECT", index: newIndex });
47
+ }
48
+ else if (event.name === "enter" || event.name === "a") {
49
+ handleApply();
50
+ }
51
+ else if (event.name === "r") {
52
+ handleRename();
53
+ }
54
+ else if (event.name === "d") {
55
+ handleDelete();
56
+ }
57
+ else if (event.name === "c") {
58
+ handleCopy();
59
+ }
60
+ else if (event.name === "i") {
61
+ handleImport();
62
+ }
63
+ });
64
+ const handleApply = async () => {
65
+ if (!selectedProfile)
66
+ return;
67
+ const scopeChoice = await modal.select("Apply Profile", `Apply "${selectedProfile.name}" to which scope?`, [
68
+ { label: "User — ~/.claude/settings.json (global)", value: "user" },
69
+ {
70
+ label: "Project — .claude/settings.json (this project)",
71
+ value: "project",
72
+ },
73
+ ]);
74
+ if (scopeChoice === null)
75
+ return;
76
+ const targetScope = scopeChoice;
77
+ const scopeLabel = targetScope === "user"
78
+ ? "~/.claude/settings.json"
79
+ : ".claude/settings.json";
80
+ const pluginCount = Object.keys(selectedProfile.plugins).length;
81
+ const emptyWarning = pluginCount === 0
82
+ ? "\n\nWARNING: This profile has no plugins — applying will disable all plugins."
83
+ : "";
84
+ const confirmed = await modal.confirm("Confirm Apply", `This will REPLACE all enabledPlugins in ${scopeLabel}.${emptyWarning}\n\nContinue?`);
85
+ if (!confirmed)
86
+ return;
87
+ modal.loading(`Applying "${selectedProfile.name}"...`);
88
+ try {
89
+ await applyProfile(selectedProfile.id, selectedProfile.scope, targetScope, state.projectPath);
90
+ modal.hideModal();
91
+ // Trigger PluginsScreen to refetch
92
+ dispatch({ type: "DATA_REFRESH_COMPLETE" });
93
+ await modal.message("Applied", `Profile "${selectedProfile.name}" applied to ${scopeLabel}.`, "success");
94
+ }
95
+ catch (error) {
96
+ modal.hideModal();
97
+ await modal.message("Error", `Failed to apply profile: ${error}`, "error");
98
+ }
99
+ };
100
+ const handleRename = async () => {
101
+ if (!selectedProfile)
102
+ return;
103
+ const newName = await modal.input("Rename Profile", "New name:", selectedProfile.name);
104
+ if (newName === null || !newName.trim())
105
+ return;
106
+ modal.loading("Renaming...");
107
+ try {
108
+ await renameProfile(selectedProfile.id, newName.trim(), selectedProfile.scope, state.projectPath);
109
+ modal.hideModal();
110
+ await fetchData();
111
+ await modal.message("Renamed", `Profile renamed to "${newName.trim()}".`, "success");
112
+ }
113
+ catch (error) {
114
+ modal.hideModal();
115
+ await modal.message("Error", `Failed to rename: ${error}`, "error");
116
+ }
117
+ };
118
+ const handleDelete = async () => {
119
+ if (!selectedProfile)
120
+ return;
121
+ const confirmed = await modal.confirm(`Delete "${selectedProfile.name}"?`, "This will permanently remove the profile.");
122
+ if (!confirmed)
123
+ return;
124
+ modal.loading("Deleting...");
125
+ try {
126
+ await deleteProfile(selectedProfile.id, selectedProfile.scope, state.projectPath);
127
+ modal.hideModal();
128
+ // Adjust selection if we deleted the last item
129
+ const newIndex = Math.max(0, Math.min(profilesState.selectedIndex, profileList.length - 2));
130
+ dispatch({ type: "PROFILES_SELECT", index: newIndex });
131
+ await fetchData();
132
+ await modal.message("Deleted", "Profile deleted.", "success");
133
+ }
134
+ catch (error) {
135
+ modal.hideModal();
136
+ await modal.message("Error", `Failed to delete: ${error}`, "error");
137
+ }
138
+ };
139
+ const handleCopy = async () => {
140
+ if (!selectedProfile)
141
+ return;
142
+ modal.loading("Exporting...");
143
+ try {
144
+ const json = await exportProfileToJson(selectedProfile.id, selectedProfile.scope, state.projectPath);
145
+ modal.hideModal();
146
+ try {
147
+ await writeClipboard(json);
148
+ await modal.message("Copied", `Profile JSON copied to clipboard.\nShare it with teammates to import.`, "success");
149
+ }
150
+ catch (err) {
151
+ if (err instanceof ClipboardUnavailableError) {
152
+ // Fallback: show JSON in modal for manual copy
153
+ await modal.message("Profile JSON (copy manually)", json, "info");
154
+ }
155
+ else {
156
+ throw err;
157
+ }
158
+ }
159
+ }
160
+ catch (error) {
161
+ modal.hideModal();
162
+ await modal.message("Error", `Failed to export: ${error}`, "error");
163
+ }
164
+ };
165
+ const handleImport = async () => {
166
+ let json = null;
167
+ // Try to read from clipboard first
168
+ try {
169
+ json = await readClipboard();
170
+ }
171
+ catch (err) {
172
+ if (err instanceof ClipboardUnavailableError) {
173
+ // Fallback: ask user to paste JSON manually
174
+ json = await modal.input("Import Profile", "Paste profile JSON:");
175
+ }
176
+ else {
177
+ await modal.message("Error", `Clipboard error: ${err}`, "error");
178
+ return;
179
+ }
180
+ }
181
+ if (json === null || !json.trim())
182
+ return;
183
+ const scopeChoice = await modal.select("Import Profile", "Save imported profile to which scope?", [
184
+ { label: "User — ~/.claude/profiles.json (global)", value: "user" },
185
+ {
186
+ label: "Project — .claude/profiles.json (this project)",
187
+ value: "project",
188
+ },
189
+ ]);
190
+ if (scopeChoice === null)
191
+ return;
192
+ const targetScope = scopeChoice;
193
+ modal.loading("Importing...");
194
+ try {
195
+ const id = await importProfileFromJson(json, targetScope, state.projectPath);
196
+ modal.hideModal();
197
+ await fetchData();
198
+ await modal.message("Imported", `Profile imported successfully (id: ${id}).`, "success");
199
+ }
200
+ catch (error) {
201
+ modal.hideModal();
202
+ await modal.message("Error", `Failed to import: ${error}`, "error");
203
+ }
204
+ };
205
+ const formatDate = (iso) => {
206
+ try {
207
+ const d = new Date(iso);
208
+ return d.toLocaleDateString("en-US", {
209
+ month: "short",
210
+ day: "numeric",
211
+ year: "numeric",
212
+ });
213
+ }
214
+ catch {
215
+ return iso;
216
+ }
217
+ };
218
+ const renderListItem = (entry, _idx, isSelected) => {
219
+ const pluginCount = Object.keys(entry.plugins).length;
220
+ const dateStr = formatDate(entry.updatedAt);
221
+ const scopeColor = entry.scope === "user" ? "cyan" : "green";
222
+ const scopeLabel = entry.scope === "user" ? "[user]" : "[proj]";
223
+ if (isSelected) {
224
+ return (_jsxs("text", { bg: "magenta", fg: "white", children: [" ", scopeLabel, " ", entry.name, " \u2014 ", pluginCount, " plugin", pluginCount !== 1 ? "s" : "", " \u00B7 ", dateStr, " "] }));
225
+ }
226
+ return (_jsxs("text", { children: [_jsx("span", { fg: scopeColor, children: scopeLabel }), _jsx("span", { children: " " }), _jsx("span", { fg: "white", children: entry.name }), _jsxs("span", { fg: "gray", children: [" ", "\u2014 ", pluginCount, " plugin", pluginCount !== 1 ? "s" : "", " \u00B7 ", dateStr] })] }));
227
+ };
228
+ const renderDetail = () => {
229
+ if (profilesState.profiles.status === "loading") {
230
+ return _jsx("text", { fg: "gray", children: "Loading profiles..." });
231
+ }
232
+ if (profilesState.profiles.status === "error") {
233
+ return (_jsxs("text", { fg: "red", children: ["Error: ", profilesState.profiles.error.message] }));
234
+ }
235
+ if (profileList.length === 0) {
236
+ return (_jsxs("box", { flexDirection: "column", children: [_jsx("text", { fg: "gray", children: "No profiles yet." }), _jsx("box", { marginTop: 1, children: _jsx("text", { fg: "green", children: "Press 's' in the Plugins screen to save the current selection as a profile." }) })] }));
237
+ }
238
+ if (!selectedProfile) {
239
+ return _jsx("text", { fg: "gray", children: "Select a profile to see details" });
240
+ }
241
+ const plugins = Object.keys(selectedProfile.plugins);
242
+ const scopeColor = selectedProfile.scope === "user" ? "cyan" : "green";
243
+ const scopeLabel = selectedProfile.scope === "user"
244
+ ? "User (~/.claude/profiles.json)"
245
+ : "Project (.claude/profiles.json — committed to git)";
246
+ return (_jsxs("box", { flexDirection: "column", children: [_jsx("text", { fg: "cyan", children: _jsx("strong", { children: selectedProfile.name }) }), _jsxs("box", { marginTop: 1, children: [_jsx("text", { fg: "gray", children: "Scope: " }), _jsx("text", { fg: scopeColor, children: scopeLabel })] }), _jsx("box", { marginTop: 1, children: _jsxs("text", { fg: "gray", children: ["Created: ", formatDate(selectedProfile.createdAt), " \u00B7 Updated:", " ", formatDate(selectedProfile.updatedAt)] }) }), _jsxs("box", { marginTop: 1, flexDirection: "column", children: [_jsxs("text", { fg: "gray", children: ["Plugins (", plugins.length, plugins.length === 0 ? " — applying will disable all plugins" : "", "):"] }), plugins.length === 0 ? (_jsx("text", { fg: "yellow", children: " (none)" })) : (plugins.map((p) => (_jsx("box", { children: _jsxs("text", { fg: "white", children: [" ", p] }) }, p))))] }), _jsxs("box", { marginTop: 2, flexDirection: "column", children: [_jsxs("box", { children: [_jsxs("text", { bg: "magenta", fg: "white", children: [" ", "Enter/a", " "] }), _jsx("text", { fg: "gray", children: " Apply profile" })] }), _jsxs("box", { marginTop: 1, children: [_jsxs("text", { bg: "#333333", fg: "white", children: [" ", "r", " "] }), _jsx("text", { fg: "gray", children: " Rename" })] }), _jsxs("box", { marginTop: 1, children: [_jsxs("text", { bg: "red", fg: "white", children: [" ", "d", " "] }), _jsx("text", { fg: "gray", children: " Delete" })] }), _jsxs("box", { marginTop: 1, children: [_jsxs("text", { bg: "blue", fg: "white", children: [" ", "c", " "] }), _jsx("text", { fg: "gray", children: " Copy JSON to clipboard" })] }), _jsxs("box", { marginTop: 1, children: [_jsxs("text", { bg: "green", fg: "white", children: [" ", "i", " "] }), _jsx("text", { fg: "gray", children: " Import from clipboard" })] })] })] }));
247
+ };
248
+ const profileCount = profileList.length;
249
+ const userCount = profileList.filter((p) => p.scope === "user").length;
250
+ const projCount = profileList.filter((p) => p.scope === "project").length;
251
+ const statusContent = (_jsxs("text", { children: [_jsx("span", { fg: "gray", children: "Profiles: " }), _jsxs("span", { fg: "cyan", children: [userCount, " user"] }), _jsx("span", { fg: "gray", children: " + " }), _jsxs("span", { fg: "green", children: [projCount, " project"] }), _jsx("span", { fg: "gray", children: " = " }), _jsxs("span", { fg: "white", children: [profileCount, " total"] })] }));
252
+ return (_jsx(ScreenLayout, { title: "claudeup Plugin Profiles", currentScreen: "profiles", statusLine: statusContent, footerHints: "\u2191\u2193:nav \u2502 Enter/a:apply \u2502 r:rename \u2502 d:delete \u2502 c:copy \u2502 i:import", listPanel: profileList.length === 0 &&
253
+ profilesState.profiles.status !== "loading" ? (_jsxs("box", { flexDirection: "column", children: [_jsx("text", { fg: "gray", children: "No profiles yet." }), _jsx("box", { marginTop: 1, children: _jsx("text", { fg: "green", children: "Go to Plugins (1) and press 's' to save a profile." }) })] })) : (_jsx(ScrollableList, { items: profileList, selectedIndex: profilesState.selectedIndex, renderItem: renderListItem, maxHeight: dimensions.listPanelHeight })), detailPanel: renderDetail() }));
254
+ }
255
+ export default ProfilesScreen;