claudeup 6.5.1 → 6.6.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 (78) hide show
  1. package/package.json +4 -4
  2. package/src/__tests__/active-closure.test.ts +184 -0
  3. package/src/__tests__/blackbox-active-closure.test.ts +119 -0
  4. package/src/__tests__/blackbox-convergence.test.ts +334 -0
  5. package/src/__tests__/blackbox-parity.test.ts +684 -0
  6. package/src/__tests__/blackbox-plugin-state.test.ts +523 -0
  7. package/src/__tests__/blackbox-tool-state.test.ts +669 -0
  8. package/src/__tests__/cli-apply-seams.test.ts +2 -0
  9. package/src/__tests__/cli-tool-commands.test.ts +1 -1
  10. package/src/__tests__/cli-tools-adapter.test.ts +294 -0
  11. package/src/__tests__/cli-update-view.test.ts +142 -2
  12. package/src/__tests__/content-drift.test.ts +60 -0
  13. package/src/__tests__/enabled-not-installed.test.ts +1 -2
  14. package/src/__tests__/fixtures/tool-probe/brew-list-versions-tmux.txt +2 -0
  15. package/src/__tests__/fixtures/tool-probe/brew-outdated-behind-homebrew-spec.txt +29 -0
  16. package/src/__tests__/fixtures/tool-probe/brew-outdated-tmux-current.txt +7 -0
  17. package/src/__tests__/fixtures/tool-probe/brew-outdated-unknown-formula.txt +6 -0
  18. package/src/__tests__/fixtures/tool-probe/go-version-m-tmux-mcp.txt +27 -0
  19. package/src/__tests__/fixtures/tool-probe/npm-dist-tags-missing-scoped.txt +4 -0
  20. package/src/__tests__/fixtures/tool-probe/npm-dist-tags-openai-codex.txt +4 -0
  21. package/src/__tests__/fixtures/tool-probe/pypi-cowsay.txt +3 -0
  22. package/src/__tests__/fixtures/tool-probe/uv-receipt-browser-use.toml +10 -0
  23. package/src/__tests__/fixtures/tool-probe/uv-receipt-cowsay-git.toml +8 -0
  24. package/src/__tests__/fixtures/tool-probe/uv-receipt-cowsay-pinned.toml +8 -0
  25. package/src/__tests__/fixtures/tool-probe/uv-receipt-graphifyy.toml +7 -0
  26. package/src/__tests__/fixtures/tool-probe/uv-receipt-mcp.toml +6 -0
  27. package/src/__tests__/fixtures/tool-probe/uv-receipt-serena-agent.toml +9 -0
  28. package/src/__tests__/fixtures/tool-probe/uv-tool-list-outdated-pinned.txt +5 -0
  29. package/src/__tests__/fixtures/tool-probe/uv-tool-list-outdated.txt +11 -0
  30. package/src/__tests__/fixtures/tool-probe/uv-tool-list.txt +22 -0
  31. package/src/__tests__/{gitignore-prerun.test.ts → gitignore-check.test.ts} +8 -6
  32. package/src/__tests__/plugin-cli-argv.test.ts +1 -1
  33. package/src/__tests__/plugin-row-text.test.ts +336 -0
  34. package/src/__tests__/scope-action.test.ts +69 -19
  35. package/src/__tests__/shell-script-callers.test.ts +8 -8
  36. package/src/__tests__/tool-probe.test.ts +1400 -0
  37. package/src/__tests__/update-apply.test.ts +283 -1
  38. package/src/__tests__/update-plan.test.ts +773 -31
  39. package/src/__tests__/version-unknown-state.test.ts +388 -0
  40. package/src/cli/router.ts +0 -5
  41. package/src/cli/update-view.ts +92 -12
  42. package/src/cli/update.ts +114 -38
  43. package/src/services/active-closure.ts +117 -0
  44. package/src/services/catalog-cache-store.ts +6 -2
  45. package/src/services/claude-settings.ts +1 -173
  46. package/src/services/{gitignore-prerun.ts → gitignore-check.ts} +14 -10
  47. package/src/services/gitignore-fixer.ts +1 -1
  48. package/src/services/marketplace-refresh.ts +30 -0
  49. package/src/services/plugin-manager.ts +200 -283
  50. package/src/services/resolver.ts +7 -2
  51. package/src/services/tool-probe.ts +1637 -0
  52. package/src/services/toolchain.ts +97 -0
  53. package/src/services/update-engine.ts +220 -32
  54. package/src/services/update-plan.ts +640 -160
  55. package/src/services/version-snapshot.ts +1 -1
  56. package/src/types/bun.d.ts +6 -0
  57. package/src/ui/App.tsx +2 -27
  58. package/src/ui/adapters/cliToolsAdapter.ts +176 -0
  59. package/src/ui/adapters/pluginsAdapter.ts +57 -0
  60. package/src/ui/components/modals/ModalContainer.tsx +0 -26
  61. package/src/ui/hooks/index.ts +0 -1
  62. package/src/ui/hooks/useGitignoreModal.ts +2 -3
  63. package/src/ui/renderers/cliToolRenderers.tsx +108 -67
  64. package/src/ui/renderers/pluginRenderers.tsx +157 -98
  65. package/src/ui/renderers/pluginRowText.ts +70 -0
  66. package/src/ui/renderers/pluginStatusText.ts +56 -0
  67. package/src/ui/screens/CliToolsScreen.tsx +154 -280
  68. package/src/ui/screens/PluginsScreen.tsx +156 -140
  69. package/src/ui/state/types.ts +0 -7
  70. package/src/__tests__/dual-write-prevention.test.ts +0 -380
  71. package/src/__tests__/gap-fill-versions.test.ts +0 -389
  72. package/src/__tests__/plugin-version-check.test.ts +0 -762
  73. package/src/cli/claude.ts +0 -21
  74. package/src/prerunner/index.ts +0 -500
  75. package/src/services/plugin-version-check.ts +0 -360
  76. package/src/services/update-cache.ts +0 -78
  77. package/src/ui/components/modals/VersionMismatchModal.tsx +0 -138
  78. package/src/ui/hooks/useMismatchModal.ts +0 -89
@@ -1,389 +0,0 @@
1
- /**
2
- * Tests for gapFillInstalledPluginVersions()
3
- *
4
- * This function ensures global installedPluginVersions is at least as high as
5
- * the highest version found across project and local scopes. When a plugin is
6
- * updated at project scope (e.g. by `claude plugin marketplace update` in a
7
- * project directory), global may lag behind, causing Claude Code to resolve
8
- * stale cache paths.
9
- *
10
- * Each test uses a real temp filesystem with mocked os.homedir() to exercise
11
- * the actual read/write paths in claude-settings.ts.
12
- */
13
-
14
- import {
15
- afterAll,
16
- afterEach,
17
- beforeEach,
18
- describe,
19
- expect,
20
- it,
21
- mock,
22
- } from "bun:test";
23
- import path from "node:path";
24
- import fs from "fs-extra";
25
-
26
- // We need real os functions (tmpdir, etc.) but must mock homedir().
27
- // Since mock.module is hoisted and replaces the module for ALL consumers,
28
- // we grab the real os module via require before the mock takes effect.
29
- const realOs = await import("node:os");
30
- const realTmpdir = realOs.tmpdir();
31
- const realHomedir = realOs.homedir();
32
-
33
- // ---------------------------------------------------------------------------
34
- // Temp directory helpers
35
- // ---------------------------------------------------------------------------
36
-
37
- // Initialize tmpHome eagerly so module-level os.homedir() calls in
38
- // claude-settings.ts (for INSTALLED_PLUGINS_FILE, KNOWN_MARKETPLACES_FILE)
39
- // get a valid path during import. The mock closure reads this variable.
40
- const initTmpHome = fs.mkdtempSync(path.join(realTmpdir, "gfill-init-"));
41
- let tmpHome: string = initTmpHome;
42
- let tmpProject: string;
43
-
44
- /** Write a global settings file at <tmpHome>/.claude/settings.json */
45
- async function writeGlobalSettings(settings: Record<string, unknown>) {
46
- const dir = path.join(tmpHome, ".claude");
47
- await fs.ensureDir(dir);
48
- await fs.writeJson(path.join(dir, "settings.json"), settings, { spaces: 2 });
49
- }
50
-
51
- /** Read back global settings after function execution */
52
- async function readGlobalSettingsFromDisk(): Promise<Record<string, unknown>> {
53
- const p = path.join(tmpHome, ".claude", "settings.json");
54
- if (await fs.pathExists(p)) {
55
- return fs.readJson(p);
56
- }
57
- return {};
58
- }
59
-
60
- /** Write project settings at <tmpProject>/.claude/settings.json */
61
- async function writeProjectSettings(settings: Record<string, unknown>) {
62
- const dir = path.join(tmpProject, ".claude");
63
- await fs.ensureDir(dir);
64
- await fs.writeJson(path.join(dir, "settings.json"), settings, { spaces: 2 });
65
- }
66
-
67
- /** Write local settings at <tmpProject>/.claude/settings.local.json */
68
- async function writeLocalSettings(settings: Record<string, unknown>) {
69
- const dir = path.join(tmpProject, ".claude");
70
- await fs.ensureDir(dir);
71
- await fs.writeJson(path.join(dir, "settings.local.json"), settings, {
72
- spaces: 2,
73
- });
74
- }
75
-
76
- // ---------------------------------------------------------------------------
77
- // Mock os.homedir() so getGlobalClaudeDir() points to our temp dir.
78
- //
79
- // Bun hoists mock.module() calls, so this must come before the import of the
80
- // module under test.
81
- // ---------------------------------------------------------------------------
82
-
83
- mock.module("node:os", () => {
84
- // Build a proxy that preserves all real os functions but overrides homedir
85
- const mocked = { ...realOs, homedir: () => tmpHome };
86
- return {
87
- ...mocked,
88
- default: mocked,
89
- };
90
- });
91
-
92
- // Import function under test AFTER mock registration
93
- const { gapFillInstalledPluginVersions } = await import(
94
- "../services/claude-settings.js"
95
- );
96
-
97
- // ---------------------------------------------------------------------------
98
- // Test suite
99
- // ---------------------------------------------------------------------------
100
-
101
- describe("gapFillInstalledPluginVersions", () => {
102
- beforeEach(async () => {
103
- // Create isolated temp dirs for each test
104
- tmpHome = await fs.mkdtemp(path.join(realTmpdir, "gfill-home-"));
105
- tmpProject = await fs.mkdtemp(path.join(realTmpdir, "gfill-proj-"));
106
- // Ensure the global .claude dir exists
107
- await fs.ensureDir(path.join(tmpHome, ".claude"));
108
- });
109
-
110
- afterEach(async () => {
111
- await fs.remove(tmpHome);
112
- await fs.remove(tmpProject);
113
- });
114
-
115
- afterAll(async () => {
116
- // Clean up the initial temp home created for module-level evaluation
117
- await fs.remove(initTmpHome).catch(() => {});
118
- });
119
-
120
- // Scenario 1: "The stale-global bug" — project has newer version, global is stale
121
- it("bumps global when project has a newer version (the stale-global bug)", async () => {
122
- await writeGlobalSettings({
123
- installedPluginVersions: { "designer@magus": "1.0.0" },
124
- });
125
- await writeProjectSettings({
126
- installedPluginVersions: { "designer@magus": "1.3.0" },
127
- });
128
-
129
- const result = await gapFillInstalledPluginVersions(tmpProject);
130
-
131
- expect(result).toEqual([
132
- {
133
- pluginId: "designer@magus",
134
- oldVersion: "1.0.0",
135
- newVersion: "1.3.0",
136
- },
137
- ]);
138
-
139
- // Verify the file was actually updated
140
- const global = await readGlobalSettingsFromDisk();
141
- expect((global as any).installedPluginVersions["designer@magus"]).toBe(
142
- "1.3.0",
143
- );
144
- });
145
-
146
- // Scenario 2: Global is already current — no changes needed
147
- it("returns empty array when global is already at the highest version", async () => {
148
- await writeGlobalSettings({
149
- installedPluginVersions: { "designer@magus": "1.3.0" },
150
- });
151
- await writeProjectSettings({
152
- installedPluginVersions: { "designer@magus": "1.3.0" },
153
- });
154
-
155
- const result = await gapFillInstalledPluginVersions(tmpProject);
156
-
157
- expect(result).toEqual([]);
158
-
159
- // Verify global was NOT rewritten (check original content is intact)
160
- const global = await readGlobalSettingsFromDisk();
161
- expect((global as any).installedPluginVersions["designer@magus"]).toBe(
162
- "1.3.0",
163
- );
164
- });
165
-
166
- // Scenario 3: Multiple plugins with mixed staleness
167
- it("handles multiple plugins with mixed staleness correctly", async () => {
168
- await writeGlobalSettings({
169
- installedPluginVersions: {
170
- "a@mp": "1.0.0",
171
- "b@mp": "2.0.0",
172
- },
173
- });
174
- await writeProjectSettings({
175
- installedPluginVersions: {
176
- "a@mp": "2.0.0",
177
- "b@mp": "2.0.0",
178
- "c@mp": "1.0.0",
179
- },
180
- });
181
-
182
- const result = await gapFillInstalledPluginVersions(tmpProject);
183
-
184
- // a@mp should be bumped, b@mp unchanged, c@mp added (missing from global)
185
- const bumped = result.map((r) => r.pluginId).sort();
186
- expect(bumped).toEqual(["a@mp", "c@mp"]);
187
-
188
- const aEntry = result.find((r) => r.pluginId === "a@mp");
189
- expect(aEntry).toEqual({
190
- pluginId: "a@mp",
191
- oldVersion: "1.0.0",
192
- newVersion: "2.0.0",
193
- });
194
-
195
- const cEntry = result.find((r) => r.pluginId === "c@mp");
196
- expect(cEntry).toEqual({
197
- pluginId: "c@mp",
198
- oldVersion: "(missing)",
199
- newVersion: "1.0.0",
200
- });
201
-
202
- // Verify file state
203
- const global = await readGlobalSettingsFromDisk();
204
- const versions = (global as any).installedPluginVersions;
205
- expect(versions["a@mp"]).toBe("2.0.0");
206
- expect(versions["b@mp"]).toBe("2.0.0");
207
- expect(versions["c@mp"]).toBe("1.0.0");
208
- });
209
-
210
- // Scenario 4: Local scope has the highest version
211
- it("uses the highest version across all 3 scopes (local wins)", async () => {
212
- await writeGlobalSettings({
213
- installedPluginVersions: { "x@mp": "1.0.0" },
214
- });
215
- await writeProjectSettings({
216
- installedPluginVersions: { "x@mp": "1.5.0" },
217
- });
218
- await writeLocalSettings({
219
- installedPluginVersions: { "x@mp": "2.0.0" },
220
- });
221
-
222
- const result = await gapFillInstalledPluginVersions(tmpProject);
223
-
224
- expect(result).toEqual([
225
- {
226
- pluginId: "x@mp",
227
- oldVersion: "1.0.0",
228
- newVersion: "2.0.0",
229
- },
230
- ]);
231
-
232
- const global = await readGlobalSettingsFromDisk();
233
- expect((global as any).installedPluginVersions["x@mp"]).toBe("2.0.0");
234
- });
235
-
236
- // Scenario 5: No project path — only global scope
237
- it("returns empty array when called with no projectPath", async () => {
238
- await writeGlobalSettings({
239
- installedPluginVersions: { "a@mp": "1.0.0" },
240
- });
241
-
242
- const result = await gapFillInstalledPluginVersions();
243
-
244
- expect(result).toEqual([]);
245
- });
246
-
247
- // Scenario 6: Idempotency — running twice is a no-op
248
- it("is idempotent — second call returns empty array", async () => {
249
- await writeGlobalSettings({
250
- installedPluginVersions: { "a@mp": "1.0.0" },
251
- });
252
- await writeProjectSettings({
253
- installedPluginVersions: { "a@mp": "2.0.0" },
254
- });
255
-
256
- // First call: should bump
257
- const first = await gapFillInstalledPluginVersions(tmpProject);
258
- expect(first).toHaveLength(1);
259
- expect(first[0].newVersion).toBe("2.0.0");
260
-
261
- // Second call: global is now at 2.0.0, so nothing to do
262
- const second = await gapFillInstalledPluginVersions(tmpProject);
263
- expect(second).toEqual([]);
264
- });
265
-
266
- // Scenario 7: Invalid semver versions are skipped
267
- it("skips invalid semver versions in project scope", async () => {
268
- await writeGlobalSettings({
269
- installedPluginVersions: { "a@mp": "1.0.0" },
270
- });
271
- await writeProjectSettings({
272
- installedPluginVersions: { "a@mp": "not-a-version" },
273
- });
274
-
275
- const result = await gapFillInstalledPluginVersions(tmpProject);
276
-
277
- expect(result).toEqual([]);
278
-
279
- // Global should remain unchanged
280
- const global = await readGlobalSettingsFromDisk();
281
- expect((global as any).installedPluginVersions["a@mp"]).toBe("1.0.0");
282
- });
283
-
284
- // Scenario 8: Project settings file doesn't exist (new project)
285
- it("returns empty array when project settings file does not exist", async () => {
286
- await writeGlobalSettings({
287
- installedPluginVersions: { "a@mp": "1.0.0" },
288
- });
289
-
290
- // Use a path that doesn't have any .claude directory
291
- const nonExistentProject = path.join(tmpProject, "no-such-project");
292
-
293
- const result = await gapFillInstalledPluginVersions(nonExistentProject);
294
-
295
- expect(result).toEqual([]);
296
- });
297
-
298
- // Scenario 9: Global version is higher than project — no downgrade
299
- it("does not downgrade global when global is higher than project", async () => {
300
- await writeGlobalSettings({
301
- installedPluginVersions: { "designer@magus": "2.0.0" },
302
- });
303
- await writeProjectSettings({
304
- installedPluginVersions: { "designer@magus": "1.0.0" },
305
- });
306
-
307
- const result = await gapFillInstalledPluginVersions(tmpProject);
308
-
309
- expect(result).toEqual([]);
310
-
311
- // Verify global was NOT downgraded
312
- const global = await readGlobalSettingsFromDisk();
313
- expect((global as any).installedPluginVersions["designer@magus"]).toBe(
314
- "2.0.0",
315
- );
316
- });
317
-
318
- // Scenario 10: Preserves unrelated settings fields during write
319
- it("preserves other global settings fields when bumping versions", async () => {
320
- await writeGlobalSettings({
321
- enabledPlugins: { "designer@magus": true, "dev@magus": true },
322
- env: { SOME_VAR: "value" },
323
- installedPluginVersions: { "designer@magus": "1.0.0" },
324
- });
325
- await writeProjectSettings({
326
- installedPluginVersions: { "designer@magus": "2.0.0" },
327
- });
328
-
329
- const result = await gapFillInstalledPluginVersions(tmpProject);
330
-
331
- expect(result).toHaveLength(1);
332
-
333
- // Verify other fields are preserved
334
- const global = await readGlobalSettingsFromDisk();
335
- expect((global as any).enabledPlugins).toEqual({
336
- "designer@magus": true,
337
- "dev@magus": true,
338
- });
339
- expect((global as any).env).toEqual({ SOME_VAR: "value" });
340
- expect((global as any).installedPluginVersions["designer@magus"]).toBe(
341
- "2.0.0",
342
- );
343
- });
344
-
345
- // Scenario 11: Invalid semver in GLOBAL scope gets overwritten
346
- it("overwrites corrupted global version when project has valid semver", async () => {
347
- await writeGlobalSettings({
348
- installedPluginVersions: { "designer@magus": "not-a-version" },
349
- });
350
- await writeProjectSettings({
351
- installedPluginVersions: { "designer@magus": "1.3.0" },
352
- });
353
-
354
- const result = await gapFillInstalledPluginVersions(tmpProject);
355
-
356
- expect(result).toEqual([
357
- {
358
- pluginId: "designer@magus",
359
- oldVersion: "not-a-version",
360
- newVersion: "1.3.0",
361
- },
362
- ]);
363
-
364
- const global = await readGlobalSettingsFromDisk();
365
- expect((global as any).installedPluginVersions["designer@magus"]).toBe(
366
- "1.3.0",
367
- );
368
- });
369
-
370
- // Scenario 12: Both global and project have invalid semver — no crash, no change
371
- it("does nothing when all versions are invalid semver", async () => {
372
- await writeGlobalSettings({
373
- installedPluginVersions: { "designer@magus": "broken" },
374
- });
375
- await writeProjectSettings({
376
- installedPluginVersions: { "designer@magus": "also-broken" },
377
- });
378
-
379
- const result = await gapFillInstalledPluginVersions(tmpProject);
380
-
381
- expect(result).toEqual([]);
382
-
383
- // Global unchanged
384
- const global = await readGlobalSettingsFromDisk();
385
- expect((global as any).installedPluginVersions["designer@magus"]).toBe(
386
- "broken",
387
- );
388
- });
389
- });