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.
- package/README.md +1 -1
- package/package.json +4 -4
- package/src/__tests__/blackbox-parity.test.ts +45 -26
- package/src/__tests__/blackbox-plugin-state.test.ts +25 -6
- package/src/__tests__/blind/plugin-deps/doctor.test.ts +622 -0
- package/src/__tests__/blind/plugin-deps/helpers.ts +340 -0
- package/src/__tests__/blind/plugin-deps/hook.test.ts +328 -0
- package/src/__tests__/blind/plugin-deps/probe.test.ts +694 -0
- package/src/__tests__/blind/plugin-deps/read-only.test.ts +96 -0
- package/src/__tests__/blind/plugin-deps/schema.test.ts +390 -0
- package/src/__tests__/blind-780-cli-tools.test.ts +796 -0
- package/src/__tests__/blind-780-deprecated.test.ts +631 -0
- package/src/__tests__/blind-780-failure-reasons.test.ts +1004 -0
- package/src/__tests__/blind-780-plugin-resolution.test.ts +431 -0
- package/src/__tests__/blind-780-review2.test.ts +1178 -0
- package/src/__tests__/cli-apply-seams.test.ts +2 -67
- package/src/__tests__/cli-tool-commands.test.ts +131 -6
- package/src/__tests__/cli-tools-adapter.test.ts +52 -2
- package/src/__tests__/cli-tools-plugin-managed.test.tsx +83 -0
- package/src/__tests__/cli-update-view.test.ts +3 -3
- package/src/__tests__/deprecated-remove.test.ts +827 -0
- package/src/__tests__/deps-adapter.test.ts +191 -0
- package/src/__tests__/deps-check-hook.test.ts +220 -0
- package/src/__tests__/deps-plan.test.ts +896 -0
- package/src/__tests__/deps-report.test.ts +197 -0
- package/src/__tests__/doctor-bins.test.ts +134 -36
- package/src/__tests__/doctor-json.test.ts +261 -0
- package/src/__tests__/doctor.test.ts +159 -1
- package/src/__tests__/failure-popup-review2.test.tsx +896 -0
- package/src/__tests__/failure-popup.test.tsx +419 -0
- package/src/__tests__/final-fixes-780.test.tsx +740 -0
- package/src/__tests__/fixtures/bins.ts +55 -0
- package/src/__tests__/format-update-outcome.test.ts +6 -32
- package/src/__tests__/gitignore-profile.test.ts +1 -9
- package/src/__tests__/install-plan.test.ts +15 -1
- package/src/__tests__/marketplace-refresh.test.ts +9 -3
- package/src/__tests__/models-screen-state.test.ts +18 -40
- package/src/__tests__/no-shell-spawn.test.ts +77 -0
- package/src/__tests__/npm-package-name.test.ts +6 -9
- package/src/__tests__/plugin-requires.test.ts +138 -153
- package/src/__tests__/plugin-resolution.test.ts +52 -13
- package/src/__tests__/plugin-row-text.test.ts +30 -37
- package/src/__tests__/profile-dependencies.test.ts +7 -0
- package/src/__tests__/profile-startup-old-format.test.ts +0 -3
- package/src/__tests__/profile-startup.test.ts +40 -12
- package/src/__tests__/requires-probe.test.ts +858 -0
- package/src/__tests__/resolver.test.ts +129 -52
- package/src/__tests__/run.test.ts +108 -0
- package/src/__tests__/stale-load-repair.test.ts +31 -23
- package/src/__tests__/tool-probe.test.ts +1 -1
- package/src/__tests__/toolchain.test.ts +123 -52
- package/src/__tests__/update-apply.test.ts +13 -29
- package/src/__tests__/update-plan.test.ts +24 -18
- package/src/__tests__/useStaleLoadModal.test.ts +1 -57
- package/src/__tests__/version-unknown-state.test.ts +15 -17
- package/src/cli/ansi.ts +2 -7
- package/src/cli/deps-view.ts +213 -0
- package/src/cli/doctor.ts +320 -54
- package/src/cli/install.ts +55 -71
- package/src/cli/profile.ts +20 -2
- package/src/cli/router.ts +6 -2
- package/src/cli/update-view.ts +58 -15
- package/src/cli/update.ts +55 -12
- package/src/data/cli-tools.ts +24 -9
- package/src/services/active-closure.ts +3 -3
- package/src/services/catalog-cache-store.ts +8 -6
- package/src/services/claude-cli.ts +106 -19
- package/src/services/claude-settings.ts +88 -384
- package/src/services/cli-tool-commands.ts +104 -3
- package/src/services/deps-plan.ts +962 -0
- package/src/services/deps-report.ts +265 -0
- package/src/services/doctor-bins.ts +115 -43
- package/src/services/install-plan.ts +11 -1
- package/src/services/local-marketplace.ts +12 -206
- package/src/services/marketplace-refresh.ts +4 -4
- package/src/services/plugin-env-needs.ts +69 -0
- package/src/services/plugin-manager.ts +35 -37
- package/src/services/plugin-requires.ts +93 -162
- package/src/services/plugin-resolution.ts +34 -42
- package/src/services/profile-activate.ts +1 -2
- package/src/services/profile-startup.ts +18 -43
- package/src/services/profile-state.ts +72 -2
- package/src/services/resolver.ts +263 -59
- package/src/services/tool-probe.ts +18 -25
- package/src/services/toolchain.ts +117 -111
- package/src/services/update-engine.ts +345 -45
- package/src/services/update-plan.ts +296 -36
- package/src/shared/plugin/hooks/bun-missing.sh +39 -0
- package/src/shared/plugin/hooks/deps-check.ts +224 -0
- package/src/shared/plugin/hooks/lib/requires-probe.ts +1183 -0
- package/src/types/index.ts +60 -16
- package/src/ui/App.tsx +81 -171
- package/src/ui/adapters/cliToolsAdapter.ts +252 -12
- package/src/ui/adapters/depsAdapter.ts +129 -0
- package/src/ui/adapters/failureReport.ts +137 -0
- package/src/ui/adapters/pluginsAdapter.ts +297 -45
- package/src/ui/adapters/startupReports.ts +260 -0
- package/src/ui/components/modals/FailureListModal.tsx +231 -0
- package/src/ui/components/modals/MessageModal.tsx +7 -12
- package/src/ui/components/modals/ModalContainer.tsx +10 -5
- package/src/ui/components/modals/index.ts +1 -0
- package/src/ui/hooks/startupQueue.ts +56 -0
- package/src/ui/hooks/useGitignoreModal.ts +30 -52
- package/src/ui/hooks/useProfileStartupModal.ts +119 -142
- package/src/ui/hooks/useStaleLoadModal.ts +35 -65
- package/src/ui/keymap.ts +14 -1
- package/src/ui/renderers/cliToolRenderers.tsx +135 -2
- package/src/ui/renderers/mcpRenderers.tsx +110 -3
- package/src/ui/renderers/pluginRenderers.tsx +77 -6
- package/src/ui/renderers/pluginRowText.ts +25 -25
- package/src/ui/renderers/pluginStatusText.ts +18 -1
- package/src/ui/screens/AliasScreen.tsx +38 -45
- package/src/ui/screens/CliToolsScreen.tsx +199 -98
- package/src/ui/screens/EnvVarsScreen.tsx +17 -5
- package/src/ui/screens/GitignoreScreen.tsx +48 -67
- package/src/ui/screens/McpRegistryScreen.tsx +67 -38
- package/src/ui/screens/McpScreen.tsx +46 -19
- package/src/ui/screens/ModelsScreen.tsx +46 -86
- package/src/ui/screens/PluginsScreen.tsx +315 -259
- package/src/ui/screens/ProfilesScreen.tsx +79 -40
- package/src/ui/screens/SkillsScreen.tsx +83 -80
- package/src/ui/screens/StylesScreen.tsx +211 -275
- package/src/ui/state/AppContext.tsx +66 -44
- package/src/ui/state/DimensionsContext.tsx +3 -22
- package/src/ui/state/reducer.ts +12 -100
- package/src/ui/state/types.ts +48 -69
- package/src/utils/command-utils.ts +4 -5
- package/src/utils/run.ts +123 -52
- package/src/utils/string-utils.ts +9 -0
- package/src/utils/user-path.ts +60 -0
- package/src/__tests__/go-module.test.ts +0 -43
- package/src/__tests__/notices-rules.test.ts +0 -476
- package/src/__tests__/notices.test.tsx +0 -604
- package/src/__tests__/plugin-setup.test.ts +0 -1016
- package/src/__tests__/shell-script-callers.test.ts +0 -92
- package/src/__tests__/styles-status-line.test.ts +0 -72
- package/src/__tests__/version-snapshot.test.ts +0 -212
- package/src/services/plugin-setup.ts +0 -965
- package/src/services/version-snapshot.ts +0 -189
- package/src/utils/go-module.ts +0 -36
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* The commands that install, upgrade, pin and remove a version-managed tool
|
|
3
|
+
* (bun, brew, npm, pip, go), and the bridge between a requirement and that
|
|
4
|
+
* version-managed view.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* is treated as a bootstrappable toolchain exactly like brew.
|
|
6
|
+
* Installing a requirement goes through requires-probe's `renderInstall` and
|
|
7
|
+
* the deps executor (`services/deps-plan.ts`); this module builds only what
|
|
8
|
+
* `magus update` and the CLI Tools screen run beyond a first install.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import
|
|
11
|
+
import {
|
|
12
|
+
type InstallOption,
|
|
13
|
+
assertNever,
|
|
14
|
+
currentPlatform,
|
|
15
|
+
renderInstall,
|
|
16
|
+
} from "../shared/plugin/hooks/lib/requires-probe.js";
|
|
17
|
+
import type {
|
|
18
|
+
BinInstaller,
|
|
19
|
+
ManagedBin,
|
|
20
|
+
ManagedTool,
|
|
21
|
+
ResolvedBin,
|
|
22
|
+
SelectedBin,
|
|
23
|
+
} from "../types/index.js";
|
|
12
24
|
import type { Command } from "../utils/command-utils.js";
|
|
13
|
-
import {
|
|
25
|
+
import { whichSync } from "../utils/command-utils.js";
|
|
14
26
|
|
|
15
27
|
// -- Python CLI applications -------------------------------------------------
|
|
16
28
|
|
|
@@ -160,125 +172,119 @@ export function resetPythonCliInstallerMemo(): void {
|
|
|
160
172
|
}
|
|
161
173
|
|
|
162
174
|
// ----------------------------------------------------------------------------
|
|
175
|
+
//
|
|
176
|
+
// The version-managed view of a requirement.
|
|
177
|
+
//
|
|
178
|
+
// A requirement (plugin `requires`, or a profile cliTool mapped onto the
|
|
179
|
+
// profile-only kinds) is installed by requires-probe's `renderInstall` and the
|
|
180
|
+
// deps executor. `magus update` and the CLI Tools screen additionally track
|
|
181
|
+
// the installed VERSION of the kinds that have one — bun, brew, npm, pip, go —
|
|
182
|
+
// and they work in the {@link ManagedTool} shape. These functions are the one
|
|
183
|
+
// bridge between the two, in both directions.
|
|
163
184
|
|
|
164
|
-
|
|
165
|
-
* The executable that proves a toolchain is installed.
|
|
166
|
-
*
|
|
167
|
-
* `pip` is deliberately absent: which executable proves it depends on the
|
|
168
|
-
* machine, so it is resolved by {@link resolvePythonCliInstaller} instead.
|
|
169
|
-
*/
|
|
170
|
-
const TOOLCHAIN_PROBE: Record<Exclude<BinInstaller, "pip">, string> = {
|
|
171
|
-
bun: "bun",
|
|
172
|
-
brew: "brew",
|
|
173
|
-
npm: "npm",
|
|
174
|
-
go: "go",
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
/** The executable whose presence proves `name` is usable. */
|
|
178
|
-
function toolchainProbe(name: BinInstaller): string {
|
|
179
|
-
return name === "pip"
|
|
180
|
-
? resolvePythonCliInstaller().probe
|
|
181
|
-
: TOOLCHAIN_PROBE[name];
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/** Official one-line bootstrap for the toolchains magus will install. */
|
|
185
|
-
export const TOOLCHAIN_BOOTSTRAP: Partial<Record<BinInstaller, string>> = {
|
|
186
|
-
bun: "curl -fsSL https://bun.sh/install | bash",
|
|
187
|
-
brew: '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"',
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
export interface ToolchainStatus {
|
|
191
|
-
name: BinInstaller;
|
|
192
|
-
present: boolean;
|
|
193
|
-
/** Binary names in the closure that need this toolchain. */
|
|
194
|
-
requiredBy: string[];
|
|
195
|
-
/** Bootstrap command, when magus can install this toolchain itself. */
|
|
196
|
-
bootstrap?: string;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/** Is a given toolchain available on PATH? */
|
|
200
|
-
export async function isToolchainPresent(name: BinInstaller): Promise<boolean> {
|
|
201
|
-
return (await which(toolchainProbe(name))) !== null;
|
|
202
|
-
}
|
|
185
|
+
const pinned = (version: string | undefined) => (version ? { version } : {});
|
|
203
186
|
|
|
204
187
|
/**
|
|
205
|
-
*
|
|
206
|
-
*
|
|
188
|
+
* The version-managed view of a selected requirement, or null when its chosen
|
|
189
|
+
* option is not one of the {@link BinInstaller} kinds (apt, release,
|
|
190
|
+
* bootstrap, uv-script, uv-module: their version is the declaration's, and
|
|
191
|
+
* `magus doctor --fix` installs them).
|
|
207
192
|
*/
|
|
208
|
-
export
|
|
209
|
-
|
|
210
|
-
)
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
193
|
+
export function managedTool(bin: SelectedBin): ManagedTool | null {
|
|
194
|
+
const option = bin.chosen;
|
|
195
|
+
if (!option) return null;
|
|
196
|
+
const check = bin.check.join(" ");
|
|
197
|
+
switch (option.via) {
|
|
198
|
+
case "bun":
|
|
199
|
+
case "npm":
|
|
200
|
+
case "pip":
|
|
201
|
+
return {
|
|
202
|
+
name: bin.name,
|
|
203
|
+
via: option.via,
|
|
204
|
+
package: option.package,
|
|
205
|
+
check,
|
|
206
|
+
...pinned(option.version),
|
|
207
|
+
};
|
|
208
|
+
case "go":
|
|
209
|
+
return {
|
|
210
|
+
name: bin.name,
|
|
211
|
+
via: "go",
|
|
212
|
+
module: option.package,
|
|
213
|
+
check,
|
|
214
|
+
...pinned(option.version),
|
|
215
|
+
};
|
|
216
|
+
case "brew":
|
|
217
|
+
// A cask is installed, upgraded and removed with `--cask`, which the
|
|
218
|
+
// version-managed view does not speak: its declaration manages it.
|
|
219
|
+
return option.cask !== undefined
|
|
220
|
+
? null
|
|
221
|
+
: { name: bin.name, via: "brew", formula: option.formula, check };
|
|
222
|
+
case "apt":
|
|
223
|
+
case "release":
|
|
224
|
+
case "bootstrap":
|
|
225
|
+
case "uv-script":
|
|
226
|
+
case "uv-module":
|
|
227
|
+
return null;
|
|
228
|
+
default:
|
|
229
|
+
return assertNever(option);
|
|
216
230
|
}
|
|
231
|
+
}
|
|
217
232
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
bootstrap: TOOLCHAIN_BOOTSTRAP[name],
|
|
225
|
-
});
|
|
233
|
+
/** {@link managedTool} over a closure's bins, keeping each one's provenance. */
|
|
234
|
+
export function managedBins(bins: readonly ResolvedBin[]): ManagedBin[] {
|
|
235
|
+
const out: ManagedBin[] = [];
|
|
236
|
+
for (const bin of bins) {
|
|
237
|
+
const tool = managedTool(bin);
|
|
238
|
+
if (tool) out.push({ ...tool, sources: [...bin.sources] });
|
|
226
239
|
}
|
|
227
|
-
|
|
228
|
-
const order: BinInstaller[] = ["bun", "brew", "npm", "pip", "go"];
|
|
229
|
-
statuses.sort((a, b) => order.indexOf(a.name) - order.indexOf(b.name));
|
|
230
|
-
return statuses;
|
|
240
|
+
return out;
|
|
231
241
|
}
|
|
232
242
|
|
|
233
|
-
/**
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
* `pkg@version` and `pkg==version` are each ONE argv token. That join is
|
|
241
|
-
* precisely where a string was dangerous: `bin.package` is hand-authored
|
|
242
|
-
* profile/marketplace data, and under a shell a space or a `;` in it would have
|
|
243
|
-
* become extra words. Here it cannot.
|
|
244
|
-
*/
|
|
245
|
-
export function binInstallCommand(
|
|
246
|
-
bin: {
|
|
247
|
-
name: string;
|
|
248
|
-
via: BinInstaller;
|
|
249
|
-
package?: string;
|
|
250
|
-
formula?: string;
|
|
251
|
-
module?: string;
|
|
252
|
-
version?: string;
|
|
253
|
-
},
|
|
254
|
-
python: PythonCliInstaller = resolvePythonCliInstaller(),
|
|
255
|
-
): Command {
|
|
256
|
-
const pkg = bin.package ?? bin.name;
|
|
257
|
-
const at = bin.version ? `@${bin.version}` : "";
|
|
258
|
-
switch (bin.via) {
|
|
243
|
+
/** The install option a {@link ManagedTool} stands for. */
|
|
244
|
+
export function managedOption(t: ManagedTool): InstallOption {
|
|
245
|
+
switch (t.via) {
|
|
246
|
+
case "brew":
|
|
247
|
+
return { via: "brew", formula: t.formula ?? t.name };
|
|
248
|
+
case "go":
|
|
249
|
+
return { via: "go", package: t.module ?? t.name, ...pinned(t.version) };
|
|
259
250
|
case "bun":
|
|
260
|
-
return { cmd: "bun", args: ["install", "-g", `${pkg}${at}`] };
|
|
261
251
|
case "npm":
|
|
262
|
-
return { cmd: "npm", args: ["install", "-g", `${pkg}${at}`] };
|
|
263
252
|
case "pip":
|
|
264
|
-
return python.install(pkg, bin.version);
|
|
265
|
-
case "brew":
|
|
266
|
-
return { cmd: "brew", args: ["install", bin.formula ?? bin.name] };
|
|
267
|
-
case "go":
|
|
268
253
|
return {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
`${bin.module ?? bin.name}@${bin.version ?? "latest"}`,
|
|
273
|
-
],
|
|
254
|
+
via: t.via,
|
|
255
|
+
package: t.package ?? t.name,
|
|
256
|
+
...pinned(t.version),
|
|
274
257
|
};
|
|
258
|
+
default:
|
|
259
|
+
return assertNever(t.via);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* The command that installs a {@link ManagedTool}, rendered by requires-probe's
|
|
265
|
+
* `renderInstall` — the one renderer every install goes through — so the pin
|
|
266
|
+
* travels in the same token (`pkg@version`, `pkg==version`) it does there.
|
|
267
|
+
*/
|
|
268
|
+
export function managedInstallCommand(t: ManagedTool): Command {
|
|
269
|
+
const step = renderInstall(
|
|
270
|
+
{ name: t.name, check: [], install: [] },
|
|
271
|
+
managedOption(t),
|
|
272
|
+
{
|
|
273
|
+
...(currentPlatform() ?? { os: "linux", arch: "amd64" }),
|
|
274
|
+
pluginRoot: "",
|
|
275
|
+
},
|
|
276
|
+
);
|
|
277
|
+
if (step.kind !== "argv") {
|
|
278
|
+
throw new Error(`${t.via} renders a ${step.kind} step, not a command`);
|
|
275
279
|
}
|
|
280
|
+
const [cmd = "", ...args] = step.argv;
|
|
281
|
+
return { cmd, args };
|
|
276
282
|
}
|
|
277
283
|
|
|
278
284
|
/**
|
|
279
285
|
* The command that advances an ALREADY-INSTALLED binary to the newest version.
|
|
280
286
|
*
|
|
281
|
-
* Distinct from {@link
|
|
287
|
+
* Distinct from {@link managedInstallCommand} because two of the five installers
|
|
282
288
|
* treat "install" as a no-op once the package is present: `brew install` on an
|
|
283
289
|
* installed formula prints "already installed" and changes nothing, and `pip
|
|
284
290
|
* install` without `--upgrade` does the same. Reusing the install command for
|
|
@@ -363,7 +369,7 @@ export function claudeNativeUpgradeCommand(pin?: string): Command {
|
|
|
363
369
|
* {@link binUpgradeCommand} goes to the newest version, past the pin, and a
|
|
364
370
|
* plain `uv tool install pkg==v` is a no-op once any version is installed.
|
|
365
371
|
*
|
|
366
|
-
* bun, npm and go take the version in the same token `
|
|
372
|
+
* bun, npm and go take the version in the same token `managedInstallCommand` builds
|
|
367
373
|
* (`pkg@v`), and each replaces an installed version with it. pip goes through
|
|
368
374
|
* the resolved installer's own `pin`. brew installs only its newest version, so
|
|
369
375
|
* there is nothing to return — the planner never asks for it (a brew pin below
|
|
@@ -387,7 +393,7 @@ export function binPinCommand(
|
|
|
387
393
|
case "bun":
|
|
388
394
|
case "npm":
|
|
389
395
|
case "go":
|
|
390
|
-
return
|
|
396
|
+
return managedInstallCommand(bin);
|
|
391
397
|
case "pip":
|
|
392
398
|
return python.pin(bin.package ?? bin.name, bin.version);
|
|
393
399
|
case "brew":
|
|
@@ -405,7 +411,7 @@ export function binPinCommand(
|
|
|
405
411
|
* `bun install -g pkg@latest` and left the tool permanently ahead of its pin,
|
|
406
412
|
* a state magus cannot leave. Both now come through here.
|
|
407
413
|
*
|
|
408
|
-
* `install` → {@link
|
|
414
|
+
* `install` → {@link managedInstallCommand} (which appends the pin, when there is
|
|
409
415
|
* one). An upgrade whose target IS the pin → {@link binPinCommand}, because
|
|
410
416
|
* {@link binUpgradeCommand} would overshoot it. Any other upgrade → the newest
|
|
411
417
|
* version.
|
|
@@ -426,7 +432,7 @@ export function binCommandForState(
|
|
|
426
432
|
},
|
|
427
433
|
python: PythonCliInstaller = resolvePythonCliInstaller(),
|
|
428
434
|
): Command | null {
|
|
429
|
-
if (state === "install") return
|
|
435
|
+
if (state === "install") return managedInstallCommand(bin);
|
|
430
436
|
if (bin.version && target === bin.version) return binPinCommand(bin, python);
|
|
431
437
|
return binUpgradeCommand(bin, python);
|
|
432
438
|
}
|