claudeup 4.35.0 → 4.36.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/package.json +4 -4
- package/src/__tests__/git-worktree.test.ts +108 -0
- package/src/__tests__/scope-squares.test.tsx +165 -0
- package/src/__tests__/theme-adaptive-colors.test.ts +307 -0
- package/src/__tests__/uppercase-keybindings.test.ts +101 -0
- package/src/__tests__/worktree-registry-resolution.test.ts +107 -0
- package/src/main.tsx +21 -5
- package/src/opentui.d.ts +21 -12
- package/src/services/claude-settings.ts +37 -7
- package/src/services/git-worktree.ts +129 -0
- package/src/services/plugin-manager.ts +10 -1
- package/src/ui/App.tsx +19 -12
- package/src/ui/adapters/pluginsAdapter.ts +174 -168
- package/src/ui/adapters/settingsAdapter.ts +119 -116
- package/src/ui/adapters/skillsAdapter.ts +203 -196
- package/src/ui/components/CategoryHeader.tsx +9 -8
- package/src/ui/components/EmptyFilterState.tsx +10 -5
- package/src/ui/components/FlagDetailEditor.tsx +0 -0
- package/src/ui/components/ScopeIndicator.tsx +10 -6
- package/src/ui/components/ScrollableList.tsx +3 -2
- package/src/ui/components/SearchInput.tsx +2 -1
- package/src/ui/components/StyledText.tsx +5 -4
- package/src/ui/components/TabBar.tsx +4 -3
- package/src/ui/components/layout/FooterHints.tsx +37 -30
- package/src/ui/components/layout/Panel.tsx +6 -5
- package/src/ui/components/layout/ProgressBar.tsx +7 -6
- package/src/ui/components/layout/ScopeTabs.tsx +6 -5
- package/src/ui/components/layout/ScreenLayout.tsx +27 -24
- package/src/ui/components/layout/index.ts +3 -3
- package/src/ui/components/modals/ConfirmModal.tsx +12 -11
- package/src/ui/components/modals/InputModal.tsx +14 -6
- package/src/ui/components/modals/LoadingModal.tsx +6 -5
- package/src/ui/components/modals/MessageModal.tsx +9 -8
- package/src/ui/components/modals/SelectModal.tsx +11 -7
- package/src/ui/components/modals/VersionMismatchModal.tsx +14 -16
- package/src/ui/components/primitives/ActionHints.tsx +26 -26
- package/src/ui/components/primitives/DetailSection.tsx +13 -12
- package/src/ui/components/primitives/KeyValueLine.tsx +9 -8
- package/src/ui/components/primitives/ListCategoryRow.tsx +25 -27
- package/src/ui/components/primitives/MetaText.tsx +3 -3
- package/src/ui/components/primitives/ScopeDetail.tsx +48 -48
- package/src/ui/components/primitives/ScopeSquares.tsx +47 -22
- package/src/ui/components/primitives/SelectableRow.tsx +22 -16
- package/src/ui/hooks/useGitignoreModal.ts +78 -74
- package/src/ui/registry.ts +11 -11
- package/src/ui/renderers/cliToolRenderers.tsx +260 -203
- package/src/ui/renderers/gitignoreRenderers.tsx +43 -42
- package/src/ui/renderers/mcpRenderers.tsx +121 -117
- package/src/ui/renderers/pluginRenderers.tsx +528 -471
- package/src/ui/renderers/profileRenderers.tsx +346 -300
- package/src/ui/renderers/settingsRenderers.tsx +183 -176
- package/src/ui/renderers/skillRenderers.tsx +410 -326
- package/src/ui/screens/AliasScreen.tsx +1336 -1309
- package/src/ui/screens/CliToolsScreen.tsx +92 -40
- package/src/ui/screens/EnvVarsScreen.tsx +19 -13
- package/src/ui/screens/GitignoreScreen.tsx +510 -493
- package/src/ui/screens/McpRegistryScreen.tsx +28 -21
- package/src/ui/screens/McpScreen.tsx +12 -3
- package/src/ui/screens/PluginsScreen.tsx +17 -7
- package/src/ui/screens/ProfilesScreen.tsx +39 -23
- package/src/ui/screens/SkillsScreen.tsx +832 -688
- package/src/ui/theme-mode.ts +73 -0
- package/src/ui/theme.ts +147 -53
|
@@ -6,539 +6,556 @@ import { useApp, useModal } from "../state/AppContext.js";
|
|
|
6
6
|
import { useKeyboardHandler } from "../hooks/useKeyboardHandler.js";
|
|
7
7
|
import { ScreenLayout } from "../components/layout/index.js";
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
loadGitignoreState,
|
|
10
|
+
applyDestructiveFix,
|
|
11
|
+
ensureProjectManifestForEdit,
|
|
12
|
+
applyTemplate,
|
|
13
|
+
type GitignoreState,
|
|
14
14
|
} from "../../services/gitignore-service.js";
|
|
15
15
|
import { BUILTIN_TEMPLATES } from "../../data/gitignore-templates.js";
|
|
16
16
|
import { getGitignoreRuleReason } from "../../data/gitignore-reasons.js";
|
|
17
17
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
renderRuleRow,
|
|
19
|
+
type RuleRow,
|
|
20
20
|
} from "../renderers/gitignoreRenderers.js";
|
|
21
21
|
import type { ResolvedRule, Tier, Violation } from "../../types/gitignore.js";
|
|
22
|
+
import { theme } from "../theme.js";
|
|
22
23
|
|
|
23
24
|
// Clean rows are grouped by the manifest that defined them. Order = display
|
|
24
25
|
// order, top to bottom. "Default" is the user-facing name for the built-in
|
|
25
26
|
// rules. Each label names where you'd go to change that group's rules.
|
|
26
27
|
const SOURCE_ORDER: Tier[] = ["project", "global", "profile", "builtin"];
|
|
27
28
|
const SOURCE_LABELS: Record<Tier, string> = {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
project: "Project · .claude/gitignore.json",
|
|
30
|
+
global: "Global · ~/.claude/gitignore.json",
|
|
31
|
+
profile: "Profile",
|
|
32
|
+
builtin: "Default · built into claudeup",
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
export function GitignoreScreen() {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
36
|
+
const { state } = useApp();
|
|
37
|
+
const modal = useModal();
|
|
38
|
+
const renderer = useRenderer();
|
|
39
|
+
const cwd = state.projectPath;
|
|
40
|
+
|
|
41
|
+
const [data, setData] = useState<GitignoreState | null>(null);
|
|
42
|
+
const [loading, setLoading] = useState(true);
|
|
43
|
+
const [error, setError] = useState<string | null>(null);
|
|
44
|
+
const [selectedIdx, setSelectedIdx] = useState(0);
|
|
45
|
+
|
|
46
|
+
const reload = useCallback(async () => {
|
|
47
|
+
setLoading(true);
|
|
48
|
+
setError(null);
|
|
49
|
+
try {
|
|
50
|
+
const s = await loadGitignoreState(cwd);
|
|
51
|
+
setData(s);
|
|
52
|
+
} catch (err) {
|
|
53
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
54
|
+
} finally {
|
|
55
|
+
setLoading(false);
|
|
56
|
+
}
|
|
57
|
+
}, [cwd]);
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
void reload();
|
|
61
|
+
}, [reload]);
|
|
62
|
+
|
|
63
|
+
// Build the managed list: every desired gitignore rule, with all matching
|
|
64
|
+
// violations grouped under the rule that owns them.
|
|
65
|
+
const rows: RuleRow[] = useMemo(() => {
|
|
66
|
+
if (!data) return [];
|
|
67
|
+
|
|
68
|
+
const annotated: RuleRow[] = data.resolved.rules.map((rule) => {
|
|
69
|
+
const violations = data.violations.filter((v) =>
|
|
70
|
+
violationMatchesRule(rule, v),
|
|
71
|
+
);
|
|
72
|
+
return { rule, violations };
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Display order = flat index order (the keyboard handler walks this array),
|
|
76
|
+
// so the on-screen layout must match this sort exactly:
|
|
77
|
+
// 1. violations first (most violations first)
|
|
78
|
+
// 2. then clean rows grouped by source manifest (SOURCE_ORDER)
|
|
79
|
+
// 3. alphabetical within each group
|
|
80
|
+
const sourceRank = (tier: ResolvedRule["source"]): number => {
|
|
81
|
+
const i = SOURCE_ORDER.indexOf(tier);
|
|
82
|
+
return i === -1 ? SOURCE_ORDER.length : i;
|
|
83
|
+
};
|
|
84
|
+
return annotated.sort((a, b) => {
|
|
85
|
+
const aViol = a.violations.length > 0;
|
|
86
|
+
const bViol = b.violations.length > 0;
|
|
87
|
+
if (aViol !== bViol) return aViol ? -1 : 1;
|
|
88
|
+
if (aViol && bViol && a.violations.length !== b.violations.length) {
|
|
89
|
+
return b.violations.length - a.violations.length;
|
|
90
|
+
}
|
|
91
|
+
if (!aViol) {
|
|
92
|
+
const sr = sourceRank(a.rule.source) - sourceRank(b.rule.source);
|
|
93
|
+
if (sr !== 0) return sr;
|
|
94
|
+
}
|
|
95
|
+
return a.rule.pattern.localeCompare(b.rule.pattern);
|
|
96
|
+
});
|
|
97
|
+
}, [data]);
|
|
98
|
+
|
|
99
|
+
// Clamp selection when rows shrink.
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (selectedIdx >= rows.length) {
|
|
102
|
+
setSelectedIdx(Math.max(0, rows.length - 1));
|
|
103
|
+
}
|
|
104
|
+
}, [rows.length, selectedIdx]);
|
|
105
|
+
|
|
106
|
+
const selectedRow = rows[selectedIdx];
|
|
107
|
+
const ignoreRuleCount =
|
|
108
|
+
data?.resolved.rules.filter((rule) => rule.action === "ignore").length ?? 0;
|
|
109
|
+
const trackRuleCount =
|
|
110
|
+
data?.resolved.rules.filter((rule) => rule.action === "track").length ?? 0;
|
|
111
|
+
const toFixCount = data?.violations.length ?? 0;
|
|
112
|
+
|
|
113
|
+
// Group rows for display while preserving each row's flat index in `rows`
|
|
114
|
+
// (the keyboard handler walks `rows` by index, so the highlight must track
|
|
115
|
+
// the original index, not the position within a rendered group).
|
|
116
|
+
const indexed = rows.map((row, index) => ({ row, index }));
|
|
117
|
+
const toFixRows = indexed.filter((r) => r.row.violations.length > 0);
|
|
118
|
+
// Clean rows grouped by which manifest defined them. Sections render only
|
|
119
|
+
// when non-empty, so e.g. the Profile group stays hidden until profiles
|
|
120
|
+
// actually contribute rules.
|
|
121
|
+
const cleanIndexed = indexed.filter((r) => r.row.violations.length === 0);
|
|
122
|
+
const sourceGroups = SOURCE_ORDER.map((tier) => ({
|
|
123
|
+
tier,
|
|
124
|
+
label: SOURCE_LABELS[tier],
|
|
125
|
+
items: cleanIndexed.filter((r) => r.row.rule.source === tier),
|
|
126
|
+
})).filter((g) => g.items.length > 0);
|
|
127
|
+
const cleanCount = cleanIndexed.length;
|
|
128
|
+
|
|
129
|
+
// ── Action handlers ───────────────────────────────────────────────────
|
|
130
|
+
|
|
131
|
+
// Fix every out-of-sync row. Iterates the grouped rows (not the flat
|
|
132
|
+
// violation list) so each .gitignore entry uses the rule's pattern/glob,
|
|
133
|
+
// not one specific path under it — same association handleApplyOne relies on.
|
|
134
|
+
const handleFixAll = useCallback(async () => {
|
|
135
|
+
if (!data || toFixRows.length === 0) return;
|
|
136
|
+
try {
|
|
137
|
+
const messages: string[] = [];
|
|
138
|
+
const failures: string[] = [];
|
|
139
|
+
for (const { row } of toFixRows) {
|
|
140
|
+
for (const v of row.violations) {
|
|
141
|
+
const r = await applyDestructiveFix(cwd, v, row.rule.pattern);
|
|
142
|
+
(r.applied ? messages : failures).push(r.message);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
await reload();
|
|
146
|
+
if (failures.length > 0) {
|
|
147
|
+
await modal.message(
|
|
148
|
+
"Some fixes didn't apply",
|
|
149
|
+
[...failures, ...messages].join("\n"),
|
|
150
|
+
"error",
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
} catch (err) {
|
|
154
|
+
await modal.message(
|
|
155
|
+
"Fix failed",
|
|
156
|
+
err instanceof Error ? err.message : String(err),
|
|
157
|
+
"error",
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}, [cwd, data, toFixRows, reload, modal]);
|
|
161
|
+
|
|
162
|
+
// Fix just the highlighted row.
|
|
163
|
+
const handleFixOne = useCallback(async () => {
|
|
164
|
+
if (!selectedRow) {
|
|
165
|
+
await modal.message(
|
|
166
|
+
"No row selected",
|
|
167
|
+
"Use ↑↓ to highlight a row that needs fixing, then press f.",
|
|
168
|
+
"info",
|
|
169
|
+
);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (selectedRow.violations.length === 0) {
|
|
173
|
+
await modal.message(
|
|
174
|
+
"Nothing to fix",
|
|
175
|
+
`${selectedRow.rule.pattern} already matches. f only applies to rows that need fixing.`,
|
|
176
|
+
"info",
|
|
177
|
+
);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
const results: Array<{ applied: boolean; message: string }> = [];
|
|
183
|
+
for (const v of selectedRow.violations) {
|
|
184
|
+
results.push(
|
|
185
|
+
await applyDestructiveFix(cwd, v, selectedRow.rule.pattern),
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
const failed = results.filter((r) => !r.applied);
|
|
189
|
+
await reload();
|
|
190
|
+
// Success is silent — the reload removes the fixed row. Only surface a
|
|
191
|
+
// modal when something didn't apply.
|
|
192
|
+
if (failed.length > 0) {
|
|
193
|
+
await modal.message(
|
|
194
|
+
"Some fixes didn't apply",
|
|
195
|
+
results.map((r) => r.message).join("\n"),
|
|
196
|
+
"error",
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
} catch (err) {
|
|
200
|
+
await modal.message(
|
|
201
|
+
"Fix failed",
|
|
202
|
+
err instanceof Error ? err.message : String(err),
|
|
203
|
+
"error",
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
}, [selectedRow, modal, cwd, reload]);
|
|
207
|
+
|
|
208
|
+
const handleApplyTemplate = useCallback(async () => {
|
|
209
|
+
const names = Object.keys(BUILTIN_TEMPLATES);
|
|
210
|
+
if (names.length === 0) {
|
|
211
|
+
await modal.message(
|
|
212
|
+
"No templates",
|
|
213
|
+
"No built-in templates available.",
|
|
214
|
+
"info",
|
|
215
|
+
);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const selected = await modal.select(
|
|
219
|
+
"Apply template",
|
|
220
|
+
"Merge the template into the project manifest at .claude/gitignore.json.",
|
|
221
|
+
names.map((n) => ({ label: n, value: n })),
|
|
222
|
+
);
|
|
223
|
+
if (!selected) return;
|
|
224
|
+
try {
|
|
225
|
+
const r = await applyTemplate(cwd, selected);
|
|
226
|
+
const conflictNote =
|
|
227
|
+
r.conflicts.length > 0
|
|
228
|
+
? `\n\nSkipped due to conflicts: ${r.conflicts.join(", ")}`
|
|
229
|
+
: "";
|
|
230
|
+
await modal.message(
|
|
231
|
+
"Template applied",
|
|
232
|
+
`Wrote ${r.appliedTo}\n\n` +
|
|
233
|
+
`Added ${r.added.ignore.length} ignore + ${r.added.track.length} track entries.` +
|
|
234
|
+
conflictNote,
|
|
235
|
+
"success",
|
|
236
|
+
);
|
|
237
|
+
} catch (err) {
|
|
238
|
+
await modal.message(
|
|
239
|
+
"Template failed",
|
|
240
|
+
err instanceof Error ? err.message : String(err),
|
|
241
|
+
"error",
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
await reload();
|
|
245
|
+
}, [cwd, modal, reload]);
|
|
246
|
+
|
|
247
|
+
const handleEditManifest = useCallback(async () => {
|
|
248
|
+
const current = data ?? (await loadGitignoreState(cwd));
|
|
249
|
+
const projectManifest = await ensureProjectManifestForEdit(
|
|
250
|
+
cwd,
|
|
251
|
+
current.resolved,
|
|
252
|
+
);
|
|
253
|
+
const editor = process.env.EDITOR ?? process.env.VISUAL ?? "vi";
|
|
254
|
+
renderer.suspend();
|
|
255
|
+
try {
|
|
256
|
+
await new Promise<void>((resolveEdit) => {
|
|
257
|
+
const child = spawn(editor, [projectManifest], { stdio: "inherit" });
|
|
258
|
+
child.on("exit", () => resolveEdit());
|
|
259
|
+
child.on("error", () => resolveEdit());
|
|
260
|
+
});
|
|
261
|
+
} finally {
|
|
262
|
+
renderer.resume();
|
|
263
|
+
}
|
|
264
|
+
await reload();
|
|
265
|
+
renderer.requestRender();
|
|
266
|
+
}, [cwd, data, reload, renderer]);
|
|
267
|
+
|
|
268
|
+
useKeyboardHandler((input, key) => {
|
|
269
|
+
if (process.env.CLAUDEUP_DEBUG_KEYS === "1") {
|
|
270
|
+
try {
|
|
271
|
+
appendFileSync(
|
|
272
|
+
"/tmp/claudeup-keys.log",
|
|
273
|
+
`${new Date().toISOString()} screen=gitignore input=${JSON.stringify(input)} name=${JSON.stringify(key.name)} shift=${key.shift} ctrl=${key.ctrl} meta=${key.meta}\n`,
|
|
274
|
+
);
|
|
275
|
+
} catch {
|
|
276
|
+
// best-effort logging — never break the UI
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (state.modal) return;
|
|
280
|
+
if (input === "j" || key.downArrow) {
|
|
281
|
+
setSelectedIdx((i) => Math.min(i + 1, Math.max(0, rows.length - 1)));
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (input === "k" || key.upArrow) {
|
|
285
|
+
setSelectedIdx((i) => Math.max(i - 1, 0));
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
// F = fix everything out of sync; f = fix just the selected row.
|
|
289
|
+
if (input === "F" || (input === "f" && key.shift)) {
|
|
290
|
+
void handleFixAll();
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
if (input === "f") {
|
|
294
|
+
void handleFixOne();
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (input === "t") {
|
|
298
|
+
void handleApplyTemplate();
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (input === "e") {
|
|
302
|
+
void handleEditManifest();
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (input === "r") {
|
|
306
|
+
void reload();
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
// ── Rendering ─────────────────────────────────────────────────────────
|
|
311
|
+
|
|
312
|
+
const summary = data
|
|
313
|
+
? renderSummary(rows.length, ignoreRuleCount, trackRuleCount, toFixCount)
|
|
314
|
+
: null;
|
|
315
|
+
|
|
316
|
+
const listBody = loading ? (
|
|
317
|
+
<text fg={theme.colors.muted}>Loading...</text>
|
|
318
|
+
) : error ? (
|
|
319
|
+
<text fg={theme.colors.danger}>Error: {error}</text>
|
|
320
|
+
) : rows.length === 0 ? (
|
|
321
|
+
<text fg={theme.colors.muted}>No rules resolved.</text>
|
|
322
|
+
) : (
|
|
323
|
+
<box flexDirection="column">
|
|
324
|
+
{toFixRows.length > 0 && (
|
|
325
|
+
<box flexDirection="column">
|
|
326
|
+
<text
|
|
327
|
+
fg={theme.colors.danger}
|
|
328
|
+
>{`Needs fixing (${toFixRows.length})`}</text>
|
|
329
|
+
{toFixRows
|
|
330
|
+
.slice(0, 100)
|
|
331
|
+
.map(({ row, index }) => renderRuleRow(row, index === selectedIdx))}
|
|
332
|
+
<text fg={theme.colors.text}> </text>
|
|
333
|
+
</box>
|
|
334
|
+
)}
|
|
335
|
+
<text fg={theme.colors.muted}>{`Managed items (${cleanCount})`}</text>
|
|
336
|
+
{/* One section per manifest source (Default / Global / Project /
|
|
332
337
|
Profile). Empty sources are dropped, so headers only appear when
|
|
333
338
|
they have rows. The header names where you'd change those rules. */}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
339
|
+
{sourceGroups.map((group, gi) => (
|
|
340
|
+
<box flexDirection="column" key={group.tier}>
|
|
341
|
+
{gi > 0 && <text fg={theme.colors.text}> </text>}
|
|
342
|
+
<text fg={theme.colors.muted}>{` ${group.label}`}</text>
|
|
343
|
+
{group.items.map(({ row, index }) =>
|
|
344
|
+
renderRuleRow(row, index === selectedIdx),
|
|
345
|
+
)}
|
|
346
|
+
</box>
|
|
347
|
+
))}
|
|
348
|
+
</box>
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
const listPanel = (
|
|
352
|
+
<box flexDirection="column">
|
|
353
|
+
{summary}
|
|
354
|
+
<text fg={theme.colors.text}> </text>
|
|
355
|
+
{listBody}
|
|
356
|
+
</box>
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
const detailPanel = renderDetail(selectedRow, data?.warnings ?? []);
|
|
360
|
+
|
|
361
|
+
const subtitle = data
|
|
362
|
+
? toFixCount === 0
|
|
363
|
+
? `${rows.length} managed`
|
|
364
|
+
: `${toFixCount} to fix`
|
|
365
|
+
: "";
|
|
366
|
+
|
|
367
|
+
return (
|
|
368
|
+
<ScreenLayout
|
|
369
|
+
title="Managed Git State"
|
|
370
|
+
subtitle={subtitle}
|
|
371
|
+
currentScreen="gitignore"
|
|
372
|
+
footerHints={[
|
|
373
|
+
{ keys: ["↑", "↓"], label: "move" },
|
|
374
|
+
{ keys: ["f"], label: "fix selected" },
|
|
375
|
+
{ keys: ["F"], label: "fix all" },
|
|
376
|
+
{ keys: ["t"], label: "template" },
|
|
377
|
+
{ keys: ["e"], label: "edit" },
|
|
378
|
+
{ keys: ["r"], label: "reload" },
|
|
379
|
+
]}
|
|
380
|
+
listPanel={listPanel}
|
|
381
|
+
detailPanel={detailPanel}
|
|
382
|
+
/>
|
|
383
|
+
);
|
|
379
384
|
}
|
|
380
385
|
|
|
381
386
|
function violationMatchesRule(
|
|
382
|
-
|
|
383
|
-
|
|
387
|
+
rule: ResolvedRule,
|
|
388
|
+
violation: Violation,
|
|
384
389
|
): boolean {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
390
|
+
if (violation.path === rule.pattern) return true;
|
|
391
|
+
if (!rule.pattern.endsWith("/") && !rule.pattern.includes("*")) return false;
|
|
392
|
+
const prefix = rule.pattern.replace(/\*+$/, "");
|
|
393
|
+
return violation.path.startsWith(prefix);
|
|
389
394
|
}
|
|
390
395
|
|
|
391
396
|
function renderSummary(
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
397
|
+
rules: number,
|
|
398
|
+
ignoreRules: number,
|
|
399
|
+
trackRules: number,
|
|
400
|
+
toFix: number,
|
|
396
401
|
): React.ReactNode {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
402
|
+
return (
|
|
403
|
+
<box flexDirection="column">
|
|
404
|
+
<text fg={theme.colors.text}>
|
|
405
|
+
<span
|
|
406
|
+
fg={theme.colors.text}
|
|
407
|
+
>{`${rules} managed item${rules === 1 ? "" : "s"}`}</span>
|
|
408
|
+
</text>
|
|
409
|
+
<text fg={theme.colors.text}>
|
|
410
|
+
<span
|
|
411
|
+
fg={theme.colors.muted}
|
|
412
|
+
>{`${ignoreRules} ignored ${trackRules} tracked`}</span>
|
|
413
|
+
</text>
|
|
414
|
+
{toFix === 0 ? (
|
|
415
|
+
<text fg={theme.colors.success}>
|
|
416
|
+
Everything matches — nothing to fix.
|
|
417
|
+
</text>
|
|
418
|
+
) : (
|
|
419
|
+
<text
|
|
420
|
+
fg={theme.colors.warning}
|
|
421
|
+
>{`${toFix} need${toFix === 1 ? "s" : ""} fixing — f one, F all`}</text>
|
|
422
|
+
)}
|
|
423
|
+
</box>
|
|
424
|
+
);
|
|
412
425
|
}
|
|
413
426
|
|
|
414
427
|
function renderDetail(
|
|
415
|
-
|
|
416
|
-
|
|
428
|
+
row: RuleRow | undefined,
|
|
429
|
+
warnings: string[],
|
|
417
430
|
): React.ReactNode {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
431
|
+
if (!row) {
|
|
432
|
+
return (
|
|
433
|
+
<box flexDirection="column">
|
|
434
|
+
<text fg={theme.colors.muted}>No rule selected.</text>
|
|
435
|
+
{warnings.length > 0 && (
|
|
436
|
+
<box flexDirection="column" marginTop={1}>
|
|
437
|
+
<text fg={theme.colors.warning}>Warnings:</text>
|
|
438
|
+
{warnings.map((w, i) => (
|
|
439
|
+
<text fg={theme.colors.muted} key={i}>
|
|
440
|
+
{w}
|
|
441
|
+
</text>
|
|
442
|
+
))}
|
|
443
|
+
</box>
|
|
444
|
+
)}
|
|
445
|
+
</box>
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const { rule, violations } = row;
|
|
450
|
+
const reason = getGitignoreRuleReason(rule.action, rule.pattern);
|
|
451
|
+
|
|
452
|
+
const setIn = sourceName(rule.source);
|
|
453
|
+
|
|
454
|
+
if (violations.length === 0) {
|
|
455
|
+
return (
|
|
456
|
+
<box flexDirection="column">
|
|
457
|
+
<text fg={theme.colors.text}>
|
|
458
|
+
<strong>{rule.pattern}</strong>
|
|
459
|
+
</text>
|
|
460
|
+
<text fg={theme.colors.text}> </text>
|
|
461
|
+
<text
|
|
462
|
+
fg={theme.colors.success}
|
|
463
|
+
>{`✓ Already ${rule.action === "ignore" ? "ignored" : "tracked"} — nothing to do.`}</text>
|
|
464
|
+
<text fg={theme.colors.text}> </text>
|
|
465
|
+
<text fg={theme.colors.muted}>{reason}</text>
|
|
466
|
+
<text fg={theme.colors.text}> </text>
|
|
467
|
+
<text fg={theme.colors.muted}>{`Set in: ${setIn}`}</text>
|
|
468
|
+
{renderWarnings(warnings)}
|
|
469
|
+
</box>
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
return (
|
|
474
|
+
<box flexDirection="column">
|
|
475
|
+
<text fg={theme.colors.text}>
|
|
476
|
+
<strong>{rule.pattern}</strong>
|
|
477
|
+
</text>
|
|
478
|
+
<text fg={theme.colors.text}> </text>
|
|
479
|
+
<text fg={theme.colors.text}>
|
|
480
|
+
<span fg={theme.colors.muted}>Should be: </span>
|
|
481
|
+
<span fg={theme.colors.text}>
|
|
482
|
+
{rule.action === "ignore" ? "ignored by git" : "tracked by git"}
|
|
483
|
+
</span>
|
|
484
|
+
</text>
|
|
485
|
+
<text fg={theme.colors.muted}>{reason}</text>
|
|
486
|
+
<text fg={theme.colors.muted}>{`Set in: ${setIn}`}</text>
|
|
487
|
+
<text fg={theme.colors.text}> </text>
|
|
488
|
+
<text
|
|
489
|
+
fg={theme.colors.warning}
|
|
490
|
+
>{`Needs fixing (${violations.length}):`}</text>
|
|
491
|
+
{violations.map((v, i) => (
|
|
492
|
+
<box
|
|
493
|
+
key={`${v.kind}:${v.path}:${i}`}
|
|
494
|
+
flexDirection="column"
|
|
495
|
+
marginTop={i === 0 ? 0 : 1}
|
|
496
|
+
>
|
|
497
|
+
<text fg={theme.colors.text}>{v.path}</text>
|
|
498
|
+
<text fg={theme.colors.muted}>{describeKind(v.kind)}</text>
|
|
499
|
+
<text fg={v.severity === "safe" ? "cyan" : "red"}>
|
|
500
|
+
{actionHint(v.kind)}
|
|
501
|
+
</text>
|
|
502
|
+
</box>
|
|
503
|
+
))}
|
|
504
|
+
{renderWarnings(warnings)}
|
|
505
|
+
</box>
|
|
506
|
+
);
|
|
490
507
|
}
|
|
491
508
|
|
|
492
509
|
/** Friendly, where-to-change-it name for a rule's source manifest. */
|
|
493
510
|
function sourceName(source: ResolvedRule["source"]): string {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
511
|
+
switch (source) {
|
|
512
|
+
case "project":
|
|
513
|
+
return "Project (.claude/gitignore.json)";
|
|
514
|
+
case "global":
|
|
515
|
+
return "Global (~/.claude/gitignore.json)";
|
|
516
|
+
case "profile":
|
|
517
|
+
return "Profile";
|
|
518
|
+
case "builtin":
|
|
519
|
+
return "Default (built into claudeup)";
|
|
520
|
+
}
|
|
504
521
|
}
|
|
505
522
|
|
|
506
523
|
function describeKind(kind: Violation["kind"]): string {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
524
|
+
switch (kind) {
|
|
525
|
+
case "tracked-but-should-ignore":
|
|
526
|
+
return "Git is tracking it, but it should be ignored.";
|
|
527
|
+
case "ignored-but-should-track":
|
|
528
|
+
return "A .gitignore rule hides it, but it should be in git.";
|
|
529
|
+
case "untracked-and-should-track":
|
|
530
|
+
return "It's on disk but git isn't tracking it yet.";
|
|
531
|
+
case "missing-from-gitignore":
|
|
532
|
+
return "It should be ignored, but nothing in .gitignore covers it.";
|
|
533
|
+
}
|
|
517
534
|
}
|
|
518
535
|
|
|
519
536
|
function actionHint(kind: Violation["kind"]): string {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
537
|
+
switch (kind) {
|
|
538
|
+
case "tracked-but-should-ignore":
|
|
539
|
+
return "Press f to stop tracking it and add it to .gitignore.";
|
|
540
|
+
case "ignored-but-should-track":
|
|
541
|
+
return "Press f to remove the .gitignore line and add it to git.";
|
|
542
|
+
case "untracked-and-should-track":
|
|
543
|
+
return "Press f to add it to git.";
|
|
544
|
+
case "missing-from-gitignore":
|
|
545
|
+
return "Press f to add it to .gitignore (F to fix all).";
|
|
546
|
+
}
|
|
530
547
|
}
|
|
531
548
|
|
|
532
549
|
function renderWarnings(warnings: string[]): React.ReactNode {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
550
|
+
if (warnings.length === 0) return null;
|
|
551
|
+
return (
|
|
552
|
+
<box flexDirection="column" marginTop={1}>
|
|
553
|
+
<text fg={theme.colors.warning}>Warnings:</text>
|
|
554
|
+
{warnings.map((w, i) => (
|
|
555
|
+
<text fg={theme.colors.muted} key={i}>
|
|
556
|
+
{w}
|
|
557
|
+
</text>
|
|
558
|
+
))}
|
|
559
|
+
</box>
|
|
560
|
+
);
|
|
544
561
|
}
|