magus-cli 7.7.0 → 7.9.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 (140) hide show
  1. package/README.md +1 -1
  2. package/package.json +4 -4
  3. package/src/__tests__/blackbox-parity.test.ts +45 -26
  4. package/src/__tests__/blackbox-plugin-state.test.ts +25 -6
  5. package/src/__tests__/blind/plugin-deps/doctor.test.ts +622 -0
  6. package/src/__tests__/blind/plugin-deps/helpers.ts +340 -0
  7. package/src/__tests__/blind/plugin-deps/hook.test.ts +328 -0
  8. package/src/__tests__/blind/plugin-deps/probe.test.ts +694 -0
  9. package/src/__tests__/blind/plugin-deps/read-only.test.ts +96 -0
  10. package/src/__tests__/blind/plugin-deps/schema.test.ts +390 -0
  11. package/src/__tests__/blind-780-cli-tools.test.ts +796 -0
  12. package/src/__tests__/blind-780-deprecated.test.ts +631 -0
  13. package/src/__tests__/blind-780-failure-reasons.test.ts +1004 -0
  14. package/src/__tests__/blind-780-plugin-resolution.test.ts +431 -0
  15. package/src/__tests__/blind-780-review2.test.ts +1178 -0
  16. package/src/__tests__/cli-apply-seams.test.ts +2 -67
  17. package/src/__tests__/cli-tool-commands.test.ts +131 -6
  18. package/src/__tests__/cli-tools-adapter.test.ts +52 -2
  19. package/src/__tests__/cli-tools-plugin-managed.test.tsx +83 -0
  20. package/src/__tests__/cli-update-view.test.ts +3 -3
  21. package/src/__tests__/deprecated-remove.test.ts +827 -0
  22. package/src/__tests__/deps-adapter.test.ts +191 -0
  23. package/src/__tests__/deps-check-hook.test.ts +220 -0
  24. package/src/__tests__/deps-plan.test.ts +896 -0
  25. package/src/__tests__/deps-report.test.ts +197 -0
  26. package/src/__tests__/doctor-bins.test.ts +134 -36
  27. package/src/__tests__/doctor-json.test.ts +261 -0
  28. package/src/__tests__/doctor.test.ts +159 -1
  29. package/src/__tests__/failure-popup-review2.test.tsx +896 -0
  30. package/src/__tests__/failure-popup.test.tsx +419 -0
  31. package/src/__tests__/final-fixes-780.test.tsx +740 -0
  32. package/src/__tests__/fixtures/bins.ts +55 -0
  33. package/src/__tests__/format-update-outcome.test.ts +6 -32
  34. package/src/__tests__/gitignore-profile.test.ts +1 -9
  35. package/src/__tests__/install-plan.test.ts +15 -1
  36. package/src/__tests__/marketplace-refresh.test.ts +9 -3
  37. package/src/__tests__/models-screen-state.test.ts +18 -40
  38. package/src/__tests__/no-shell-spawn.test.ts +77 -0
  39. package/src/__tests__/npm-package-name.test.ts +6 -9
  40. package/src/__tests__/plugin-requires.test.ts +138 -153
  41. package/src/__tests__/plugin-resolution.test.ts +52 -13
  42. package/src/__tests__/plugin-row-text.test.ts +30 -37
  43. package/src/__tests__/profile-dependencies.test.ts +7 -0
  44. package/src/__tests__/profile-startup-old-format.test.ts +0 -3
  45. package/src/__tests__/profile-startup.test.ts +40 -12
  46. package/src/__tests__/requires-probe.test.ts +858 -0
  47. package/src/__tests__/resolver.test.ts +129 -52
  48. package/src/__tests__/run.test.ts +108 -0
  49. package/src/__tests__/stale-load-repair.test.ts +31 -23
  50. package/src/__tests__/tool-probe.test.ts +1 -1
  51. package/src/__tests__/toolchain.test.ts +123 -52
  52. package/src/__tests__/update-apply.test.ts +13 -29
  53. package/src/__tests__/update-plan.test.ts +24 -18
  54. package/src/__tests__/useStaleLoadModal.test.ts +1 -57
  55. package/src/__tests__/version-unknown-state.test.ts +15 -17
  56. package/src/cli/ansi.ts +2 -7
  57. package/src/cli/deps-view.ts +213 -0
  58. package/src/cli/doctor.ts +320 -54
  59. package/src/cli/install.ts +55 -71
  60. package/src/cli/profile.ts +20 -2
  61. package/src/cli/router.ts +6 -2
  62. package/src/cli/update-view.ts +58 -15
  63. package/src/cli/update.ts +55 -12
  64. package/src/data/cli-tools.ts +24 -9
  65. package/src/services/active-closure.ts +3 -3
  66. package/src/services/catalog-cache-store.ts +8 -6
  67. package/src/services/claude-cli.ts +106 -19
  68. package/src/services/claude-settings.ts +88 -384
  69. package/src/services/cli-tool-commands.ts +104 -3
  70. package/src/services/deps-plan.ts +962 -0
  71. package/src/services/deps-report.ts +265 -0
  72. package/src/services/doctor-bins.ts +115 -43
  73. package/src/services/install-plan.ts +11 -1
  74. package/src/services/local-marketplace.ts +12 -206
  75. package/src/services/marketplace-refresh.ts +4 -4
  76. package/src/services/plugin-env-needs.ts +69 -0
  77. package/src/services/plugin-manager.ts +35 -37
  78. package/src/services/plugin-requires.ts +93 -162
  79. package/src/services/plugin-resolution.ts +34 -42
  80. package/src/services/profile-activate.ts +1 -2
  81. package/src/services/profile-startup.ts +18 -43
  82. package/src/services/profile-state.ts +72 -2
  83. package/src/services/resolver.ts +263 -59
  84. package/src/services/tool-probe.ts +18 -25
  85. package/src/services/toolchain.ts +117 -111
  86. package/src/services/update-engine.ts +345 -45
  87. package/src/services/update-plan.ts +296 -36
  88. package/src/shared/plugin/hooks/bun-missing.sh +39 -0
  89. package/src/shared/plugin/hooks/deps-check.ts +224 -0
  90. package/src/shared/plugin/hooks/lib/requires-probe.ts +1183 -0
  91. package/src/types/index.ts +60 -16
  92. package/src/ui/App.tsx +81 -171
  93. package/src/ui/adapters/cliToolsAdapter.ts +252 -12
  94. package/src/ui/adapters/depsAdapter.ts +129 -0
  95. package/src/ui/adapters/failureReport.ts +137 -0
  96. package/src/ui/adapters/pluginsAdapter.ts +297 -45
  97. package/src/ui/adapters/startupReports.ts +260 -0
  98. package/src/ui/components/modals/FailureListModal.tsx +231 -0
  99. package/src/ui/components/modals/MessageModal.tsx +7 -12
  100. package/src/ui/components/modals/ModalContainer.tsx +10 -5
  101. package/src/ui/components/modals/index.ts +1 -0
  102. package/src/ui/hooks/startupQueue.ts +56 -0
  103. package/src/ui/hooks/useGitignoreModal.ts +30 -52
  104. package/src/ui/hooks/useProfileStartupModal.ts +119 -142
  105. package/src/ui/hooks/useStaleLoadModal.ts +35 -65
  106. package/src/ui/keymap.ts +14 -1
  107. package/src/ui/renderers/cliToolRenderers.tsx +135 -2
  108. package/src/ui/renderers/mcpRenderers.tsx +110 -3
  109. package/src/ui/renderers/pluginRenderers.tsx +77 -6
  110. package/src/ui/renderers/pluginRowText.ts +25 -25
  111. package/src/ui/renderers/pluginStatusText.ts +18 -1
  112. package/src/ui/screens/AliasScreen.tsx +38 -45
  113. package/src/ui/screens/CliToolsScreen.tsx +199 -98
  114. package/src/ui/screens/EnvVarsScreen.tsx +17 -5
  115. package/src/ui/screens/GitignoreScreen.tsx +48 -67
  116. package/src/ui/screens/McpRegistryScreen.tsx +67 -38
  117. package/src/ui/screens/McpScreen.tsx +46 -19
  118. package/src/ui/screens/ModelsScreen.tsx +46 -86
  119. package/src/ui/screens/PluginsScreen.tsx +315 -259
  120. package/src/ui/screens/ProfilesScreen.tsx +79 -40
  121. package/src/ui/screens/SkillsScreen.tsx +83 -80
  122. package/src/ui/screens/StylesScreen.tsx +211 -275
  123. package/src/ui/state/AppContext.tsx +66 -44
  124. package/src/ui/state/DimensionsContext.tsx +3 -22
  125. package/src/ui/state/reducer.ts +12 -100
  126. package/src/ui/state/types.ts +48 -69
  127. package/src/utils/command-utils.ts +4 -5
  128. package/src/utils/run.ts +123 -52
  129. package/src/utils/string-utils.ts +9 -0
  130. package/src/utils/user-path.ts +60 -0
  131. package/src/__tests__/go-module.test.ts +0 -43
  132. package/src/__tests__/notices-rules.test.ts +0 -476
  133. package/src/__tests__/notices.test.tsx +0 -604
  134. package/src/__tests__/plugin-setup.test.ts +0 -1016
  135. package/src/__tests__/shell-script-callers.test.ts +0 -92
  136. package/src/__tests__/styles-status-line.test.ts +0 -72
  137. package/src/__tests__/version-snapshot.test.ts +0 -212
  138. package/src/services/plugin-setup.ts +0 -965
  139. package/src/services/version-snapshot.ts +0 -189
  140. package/src/utils/go-module.ts +0 -36
@@ -1,8 +1,7 @@
1
1
  /**
2
- * Tests for the three progress seams the animated report depends on.
2
+ * Tests for the progress seams the animated report depends on.
3
3
  *
4
- * All three shipped untested: `ApplyReporter`, `checkBinaries`'s `onProbe`, and
5
- * the coupling between the apply meter's denominator and the items the apply
4
+ * Both shipped untested: `ApplyReporter`, and the coupling between the apply meter's denominator and the items the apply
6
5
  * loop actually touches. A review found that last one hand-duplicated
7
6
  * `applyPlugins`'s skip conditions and replicated only one of the two, so a
8
7
  * plan containing an actionable plugin with no scopes would leave the bar stuck
@@ -13,7 +12,6 @@
13
12
  import { describe, expect, mock, test } from "bun:test";
14
13
  import { parseArgs } from "../cli/update.js";
15
14
  import type { PluginScope } from "../services/claude-cli.js";
16
- import { checkBinaries } from "../services/doctor-bins.js";
17
15
  import {
18
16
  type ApplyReporter,
19
17
  type PluginApplyDeps,
@@ -22,7 +20,6 @@ import {
22
20
  pluginNeedsWork,
23
21
  } from "../services/update-engine.js";
24
22
  import type { PluginUpdateItem } from "../services/update-plan.js";
25
- import type { ResolvedBin } from "../types/index.js";
26
23
 
27
24
  const PROJECT = "/tmp/project";
28
25
 
@@ -224,65 +221,3 @@ describe("installPluginInScope — the scope-targeted path", () => {
224
221
  expect(saved).toEqual([]);
225
222
  });
226
223
  });
227
-
228
- describe("checkBinaries onProbe", () => {
229
- const bins: ResolvedBin[] = [
230
- { name: "tmux", via: "brew", sources: [] } as unknown as ResolvedBin,
231
- { name: "tmux-mcp", via: "bun", sources: [] } as unknown as ResolvedBin,
232
- { name: "jq", via: "brew", sources: [] } as unknown as ResolvedBin,
233
- ];
234
-
235
- test("fires once per binary, before its probe, with a stable total", async () => {
236
- // Before the probe matters: the point is to name the binary the command
237
- // is currently blocked on, not the one it just finished.
238
- const seen: Array<[string, number, number]> = [];
239
- const order: string[] = [];
240
- await checkBinaries(
241
- bins,
242
- async (name) => {
243
- order.push(`probe:${name}`);
244
- return true;
245
- },
246
- (name, index, total) => {
247
- order.push(`announce:${name}`);
248
- seen.push([name, index, total]);
249
- },
250
- );
251
-
252
- expect(seen).toEqual([
253
- ["tmux", 0, 3],
254
- ["tmux-mcp", 1, 3],
255
- ["jq", 2, 3],
256
- ]);
257
- expect(order.slice(0, 2)).toEqual(["announce:tmux", "probe:tmux"]);
258
- });
259
-
260
- test("the index is 0-based, so done/total needs index+1", async () => {
261
- // A meter fed the raw index reads 0/3 while the first probe runs, which
262
- // is correct — it has finished none of them.
263
- const first: number[] = [];
264
- await checkBinaries(
265
- bins,
266
- async () => true,
267
- (_n, index) => first.push(index),
268
- );
269
- expect(first[0]).toBe(0);
270
- expect(first.at(-1)).toBe(bins.length - 1);
271
- });
272
-
273
- test("no callback means no behaviour change", async () => {
274
- const results = await checkBinaries(bins, async () => false);
275
- expect(results.map((r) => r.present)).toEqual([false, false, false]);
276
- });
277
-
278
- test("an empty bin list announces nothing", async () => {
279
- const seen: string[] = [];
280
- const results = await checkBinaries(
281
- [],
282
- async () => true,
283
- (n) => seen.push(n),
284
- );
285
- expect(results).toEqual([]);
286
- expect(seen).toEqual([]);
287
- });
288
- });
@@ -25,12 +25,18 @@
25
25
  */
26
26
 
27
27
  import { describe, expect, test } from "bun:test";
28
- import { cliTools } from "../data/cli-tools.js";
28
+ import { readFileSync, readdirSync } from "node:fs";
29
+ import { join } from "node:path";
30
+ import { cliTools as catalogue, isOwnedEntry } from "../data/cli-tools.js";
29
31
  import {
30
32
  type InstallMethod,
31
33
  cliToolInstall,
32
34
  cliToolUninstall,
33
35
  cliToolUpdate,
36
+ isPluginManagedItem,
37
+ ownedCliTool,
38
+ resolveCatalogue,
39
+ unownedCatalogue,
34
40
  } from "../services/cli-tool-commands.js";
35
41
  import { versionFromPypiJson } from "../services/tool-probe.js";
36
42
  import {
@@ -38,6 +44,7 @@ import {
38
44
  type PythonCliInstaller,
39
45
  resolvePythonCliInstaller,
40
46
  } from "../services/toolchain.js";
47
+ import { parseRequires } from "../shared/plugin/hooks/lib/requires-probe.js";
41
48
  import { type Command, formatCommand } from "../utils/command-utils.js";
42
49
 
43
50
  const byProbe = (probe: string): PythonCliInstaller => {
@@ -47,10 +54,129 @@ const byProbe = (probe: string): PythonCliInstaller => {
47
54
  };
48
55
  const PYTHON_PROBES = PYTHON_CLI_INSTALLERS.map((i) => i.probe);
49
56
 
57
+ /** The catalogue entries that carry their own installer (no plugin owns them). */
58
+ const cliTools = unownedCatalogue().map((c) => c.tool);
59
+
60
+ /** Every requirement the repo's plugins declare, by name → the plugins declaring it. */
61
+ function declaredRequirements(): Map<string, string[]> {
62
+ const pluginsDir = join(import.meta.dir, "..", "..", "..", "..", "plugins");
63
+ const out = new Map<string, string[]>();
64
+ for (const plugin of readdirSync(pluginsDir)) {
65
+ let manifest: unknown;
66
+ try {
67
+ manifest = JSON.parse(
68
+ readFileSync(
69
+ join(pluginsDir, plugin, ".claude-plugin", "plugin.json"),
70
+ "utf8",
71
+ ),
72
+ );
73
+ } catch {
74
+ continue;
75
+ }
76
+ const parsed = parseRequires(manifest);
77
+ if (!parsed.ok) continue;
78
+ for (const r of parsed.requirements) {
79
+ out.set(r.name, [...(out.get(r.name) ?? []), plugin]);
80
+ }
81
+ }
82
+ return out;
83
+ }
84
+
50
85
  /** The methods the resolver models, i.e. the ones that reach toolchain.ts. */
51
86
  const RESOLVED_METHODS: InstallMethod[] = ["npm", "bun", "brew", "pip"];
52
87
 
53
88
  describe("the catalogue is well-formed", () => {
89
+ test("no catalogue entry restates a requirement a plugin declares", () => {
90
+ // A tool a plugin declares is owned by that plugin: the catalogue keeps its
91
+ // display fields and `ownedBy`, and its check and installer come from the
92
+ // declaration. A second copy here is what drifted before.
93
+ const declared = declaredRequirements();
94
+ expect(declared.size).toBeGreaterThan(0);
95
+ for (const entry of catalogue) {
96
+ if (isOwnedEntry(entry)) {
97
+ const [plugin] = entry.ownedBy.split("@");
98
+ expect(declared.get(entry.name) ?? []).toContain(plugin);
99
+ expect("packageName" in entry).toBe(false);
100
+ expect("checkCommand" in entry).toBe(false);
101
+ } else {
102
+ expect(declared.has(entry.name)).toBe(false);
103
+ }
104
+ }
105
+ expect(catalogue.some(isOwnedEntry)).toBe(true);
106
+ });
107
+
108
+ test("an owned row takes its check and installer from the plugin's declaration", async () => {
109
+ const owned = await resolveCatalogue(
110
+ "/nonexistent",
111
+ async (pluginId, name) =>
112
+ pluginId === "claudish@magus"
113
+ ? {
114
+ name,
115
+ check: [name, "--version"],
116
+ install: [{ via: "bun", package: name }],
117
+ chosen: { via: "bun", package: name },
118
+ }
119
+ : null,
120
+ );
121
+ const claudish = owned.find(
122
+ (c) => !isPluginManagedItem(c) && c.tool.name === "claudish",
123
+ );
124
+ expect(
125
+ claudish && !isPluginManagedItem(claudish) && claudish.tool,
126
+ ).toMatchObject({
127
+ checkCommand: "claudish --version",
128
+ packageManager: "bun",
129
+ packageName: "claudish",
130
+ });
131
+ expect(claudish?.owned?.sources).toEqual(["plugin:claudish@magus"]);
132
+ // An owned entry whose declaration cannot be read here is left out.
133
+ const names = owned.map((c) =>
134
+ isPluginManagedItem(c) ? c.entry.name : c.tool.name,
135
+ );
136
+ expect(names).not.toContain("mnemex");
137
+ // One whose chosen install is not version-managed cannot be a row.
138
+ const entry = catalogue.find((e) => e.name === "claudish");
139
+ expect(
140
+ entry &&
141
+ ownedCliTool(entry, {
142
+ name: "claudish",
143
+ check: ["claudish"],
144
+ install: [],
145
+ chosen: { via: "apt", packages: ["claudish"] },
146
+ }),
147
+ ).toBeNull();
148
+ });
149
+
150
+ test("an owned tool its plugin installs from a release is a plugin-managed row, in catalogue order", async () => {
151
+ const release = {
152
+ via: "release" as const,
153
+ repo: "MadAppGang/claudish",
154
+ tag: "v10.3.0",
155
+ asset: "claudish-{os}-{arch}",
156
+ binary: "claudish",
157
+ sha256: { linux_amd64: "a".repeat(64) },
158
+ };
159
+ const items = await resolveCatalogue("/nonexistent", async (_id, name) => ({
160
+ name,
161
+ check: [name, "--version"],
162
+ install: [release],
163
+ chosen: release,
164
+ }));
165
+ const names = items.map((c) =>
166
+ isPluginManagedItem(c) ? c.entry.name : c.tool.name,
167
+ );
168
+ // Nothing dropped: the catalogue, in its own order.
169
+ expect(names).toEqual(catalogue.map((e) => e.name));
170
+ const managed = items.filter(isPluginManagedItem);
171
+ expect(managed.map((m) => [m.entry.name, m.entry.ownedBy])).toEqual(
172
+ catalogue.filter(isOwnedEntry).map((e) => [e.name, e.ownedBy]),
173
+ );
174
+ for (const m of managed) {
175
+ expect(m.owned.chosen).toEqual(release);
176
+ expect(m.owned.sources).toEqual([`plugin:${m.entry.ownedBy}`]);
177
+ }
178
+ });
179
+
54
180
  test("it has entries, and each names a package manager and a package", () => {
55
181
  // Guard: every assertion below iterates the catalogue, so an empty or
56
182
  // malformed one would make them all pass vacuously.
@@ -71,11 +197,10 @@ describe("no builder ever emits a bare `pip`", () => {
71
197
  const cmd = cliToolInstall(tool);
72
198
  expect(cmd.cmd).not.toBe("pip");
73
199
  if (tool.packageManager === "pip") {
74
- // Whatever the machine running this resolved to, it must be one of
75
- // the three modelled installers — and `cmd` must BE that probe,
76
- // since that is the executable the syscall looks up.
77
- expect(PYTHON_PROBES).toContain(cmd.cmd);
78
- expect(cmd.cmd).toBe(resolvePythonCliInstaller().probe);
200
+ // requires-probe renders the profile-only pip kind as a uv tool
201
+ // install: the package gets its own env, immune to PEP 668.
202
+ expect(cmd.cmd).toBe("uv");
203
+ expect(cmd.args.slice(0, 2)).toEqual(["tool", "install"]);
79
204
  }
80
205
  }
81
206
  });
@@ -7,7 +7,6 @@
7
7
  */
8
8
 
9
9
  import { describe, expect, test } from "bun:test";
10
- import { cliTools } from "../data/cli-tools.js";
11
10
  import { cliToolInstall } from "../services/cli-tool-commands.js";
12
11
  import {
13
12
  type ToolFacts,
@@ -18,13 +17,17 @@ import { binCommandFor } from "../services/update-engine.js";
18
17
  import { planBinUpdates } from "../services/update-plan.js";
19
18
  import type { ResolvedBin } from "../types/index.js";
20
19
  import {
20
+ type PluginManagedRow,
21
21
  buildToolRow,
22
22
  cliToolStatusText,
23
23
  countToolRows,
24
+ isPluginManagedRow,
25
+ rowName,
24
26
  } from "../ui/adapters/cliToolsAdapter.js";
27
+ import { testCatalogue } from "./fixtures/bins.js";
25
28
 
26
29
  const catalogue = (name: string) => {
27
- const tool = cliTools.find((t) => t.name === name);
30
+ const tool = testCatalogue().find((t) => t.name === name);
28
31
  if (!tool) throw new Error(`no catalogue tool ${name}`);
29
32
  return tool;
30
33
  };
@@ -294,4 +297,51 @@ describe("countToolRows — header counts from states", () => {
294
297
  unverified: 1,
295
298
  });
296
299
  });
300
+
301
+ test("a plugin-managed row counts from its probe answer, and never as an update", () => {
302
+ const managed = (
303
+ presence: PluginManagedRow["presence"],
304
+ ): PluginManagedRow => ({
305
+ managedBy: "claudish@magus",
306
+ entry: {
307
+ name: "claudish",
308
+ displayName: "Claudish",
309
+ description: "",
310
+ website: "",
311
+ category: "ai-coding",
312
+ ownedBy: "claudish@magus",
313
+ },
314
+ owned: {
315
+ name: "claudish",
316
+ check: ["claudish", "--version"],
317
+ install: [],
318
+ chosen: null,
319
+ sources: ["plugin:claudish@magus"],
320
+ },
321
+ presence,
322
+ installText: "",
323
+ });
324
+ const rows = [
325
+ managed({ name: "claudish", status: "present" }),
326
+ managed({ name: "claudish", status: "off-path", prefix: "~/.local/bin" }),
327
+ managed({ name: "claudish", status: "missing" }),
328
+ managed({ name: "claudish", status: "unknown", reason: "slow" }),
329
+ managed(null),
330
+ ];
331
+ expect(countToolRows(rows)).toEqual({
332
+ installed: 2,
333
+ updates: 0,
334
+ unverified: 1,
335
+ });
336
+ expect(rows.every(isPluginManagedRow)).toBe(true);
337
+ expect(rowName(rows[0] as PluginManagedRow)).toBe("claudish");
338
+ const tool = catalogue("mnemex");
339
+ const tracked = buildToolRow(
340
+ tool,
341
+ specForCatalogTool(tool, null, undefined),
342
+ undefined,
343
+ );
344
+ expect(isPluginManagedRow(tracked)).toBe(false);
345
+ expect(rowName(tracked)).toBe("mnemex");
346
+ });
297
347
  });
@@ -0,0 +1,83 @@
1
+ /**
2
+ * A catalogue tool its plugin installs without a version magus can track
3
+ * (claudish and mnemex from their releases off Homebrew) is drawn read-only:
4
+ * the row says which plugin manages it, the detail pane says it cannot be
5
+ * acted on here, and no Enter action is drawn. Rendered through OpenTUI's
6
+ * test renderer; no IO.
7
+ */
8
+
9
+ import { describe, expect, test } from "bun:test";
10
+ import { testRender } from "@opentui/react/test-utils";
11
+ import { act } from "react";
12
+ import type { PluginManagedRow } from "../ui/adapters/cliToolsAdapter.js";
13
+ import {
14
+ renderCliToolDetail,
15
+ renderCliToolRow,
16
+ } from "../ui/renderers/cliToolRenderers.js";
17
+
18
+ function row(presence: PluginManagedRow["presence"]): PluginManagedRow {
19
+ return {
20
+ managedBy: "claudish@magus",
21
+ entry: {
22
+ name: "claudish",
23
+ displayName: "Claudish",
24
+ description: "Run Claude Code with any model",
25
+ website: "https://github.com/MadAppGang/claudish",
26
+ category: "ai-coding",
27
+ ownedBy: "claudish@magus",
28
+ },
29
+ owned: {
30
+ name: "claudish",
31
+ check: ["claudish", "--version"],
32
+ install: [],
33
+ chosen: null,
34
+ sources: ["plugin:claudish@magus"],
35
+ },
36
+ presence,
37
+ installText: "cd $(mktemp -d) && curl -fsSLO https://example/claudish",
38
+ };
39
+ }
40
+
41
+ async function frame(node: React.ReactNode, width = 80): Promise<string> {
42
+ const { captureCharFrame, renderOnce, renderer } = await testRender(
43
+ <box flexDirection="column">{node}</box>,
44
+ { width, height: 20 },
45
+ );
46
+ await act(async () => {
47
+ await renderOnce();
48
+ await renderOnce();
49
+ });
50
+ const out = captureCharFrame();
51
+ await act(async () => renderer.destroy());
52
+ return out;
53
+ }
54
+
55
+ describe("a plugin-managed CLI tool row", () => {
56
+ test("the row names the plugin that manages it", async () => {
57
+ const out = await frame(
58
+ renderCliToolRow(row({ name: "claudish", status: "present" }), 0, false),
59
+ );
60
+ expect(out).toContain("● Claudish · managed by claudish@magus");
61
+ });
62
+
63
+ test("missing: the detail says so, shows the plugin's install, and offers no Enter", async () => {
64
+ const out = await frame(
65
+ renderCliToolDetail(row({ name: "claudish", status: "missing" }), 70),
66
+ 70,
67
+ );
68
+ expect(out).toContain("Status ○ Not installed");
69
+ expect(out).toContain("Managed by claudish@magus");
70
+ expect(out).toContain("Install cd $(mktemp -d)");
71
+ // The note wraps at the pane's width; read it as prose.
72
+ const prose = out.replace(/\s+/g, " ");
73
+ expect(prose).toContain(
74
+ "claudish@magus installs claudish and decides its version; it cannot be installed, updated or removed from here. magus doctor --fix installs it when it is missing.",
75
+ );
76
+ expect(out).not.toContain("Enter");
77
+ });
78
+
79
+ test("while it is being checked, the row says so", async () => {
80
+ const out = await frame(renderCliToolRow(row(null), 0, false));
81
+ expect(out).toContain("○ Claudish ...");
82
+ });
83
+ });
@@ -362,7 +362,7 @@ describe("sections", () => {
362
362
  : [];
363
363
  });
364
364
  // This fixture has one of each except Deprecated, whose row would need a
365
- // `not-offered` reason. `designer@magus` is unknown with a note, so it is
365
+ // `remove` action. `designer@magus` is unknown with a note, so it is
366
366
  // Unverified — NOT Current, which would claim a failed check succeeded.
367
367
  expect(headings.map((h) => h.group)).toEqual([
368
368
  "Update",
@@ -390,8 +390,8 @@ describe("sections", () => {
390
390
  installed: null,
391
391
  available: null,
392
392
  target: null,
393
- action: "unknown",
394
- reason: "not-offered",
393
+ action: "remove",
394
+ reason: "deprecated",
395
395
  scopes: [],
396
396
  },
397
397
  ...p.plugins,