@visulima/vis 1.0.0-alpha.11 → 1.0.0-alpha.13

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 (116) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/LICENSE.md +559 -186
  3. package/README.md +18 -0
  4. package/dist/bin.js +1 -9
  5. package/dist/config/index.d.ts +477 -556
  6. package/dist/config/index.js +1 -2
  7. package/dist/generate/index.js +1 -3
  8. package/dist/packem_chunks/applyDefaults.js +2 -336
  9. package/dist/packem_chunks/bin.js +234 -9552
  10. package/dist/packem_chunks/doctor-probe.js +2 -112
  11. package/dist/packem_chunks/fix.js +11 -234
  12. package/dist/packem_chunks/handler.js +1 -99
  13. package/dist/packem_chunks/handler10.js +2 -53
  14. package/dist/packem_chunks/handler11.js +1 -32
  15. package/dist/packem_chunks/handler12.js +5 -100
  16. package/dist/packem_chunks/handler13.js +1 -25
  17. package/dist/packem_chunks/handler14.js +18 -916
  18. package/dist/packem_chunks/handler15.js +15 -201
  19. package/dist/packem_chunks/handler16.js +1 -124
  20. package/dist/packem_chunks/handler17.js +1 -13
  21. package/dist/packem_chunks/handler18.js +1 -106
  22. package/dist/packem_chunks/handler19.js +1 -19
  23. package/dist/packem_chunks/handler2.js +2 -75
  24. package/dist/packem_chunks/handler20.js +5 -29
  25. package/dist/packem_chunks/handler21.js +1 -222
  26. package/dist/packem_chunks/handler22.js +1 -237
  27. package/dist/packem_chunks/handler23.js +5 -101
  28. package/dist/packem_chunks/handler24.js +1 -110
  29. package/dist/packem_chunks/handler25.js +3 -402
  30. package/dist/packem_chunks/handler26.js +1 -13
  31. package/dist/packem_chunks/handler27.js +1 -63
  32. package/dist/packem_chunks/handler28.js +7 -34
  33. package/dist/packem_chunks/handler29.js +21 -456
  34. package/dist/packem_chunks/handler3.js +4 -95
  35. package/dist/packem_chunks/handler30.js +3 -170
  36. package/dist/packem_chunks/handler31.js +1 -530
  37. package/dist/packem_chunks/handler32.js +2 -214
  38. package/dist/packem_chunks/handler33.js +25 -119
  39. package/dist/packem_chunks/handler34.js +2 -630
  40. package/dist/packem_chunks/handler35.js +3 -283
  41. package/dist/packem_chunks/handler36.js +22 -542
  42. package/dist/packem_chunks/handler37.js +410 -744
  43. package/dist/packem_chunks/handler38.js +22 -989
  44. package/dist/packem_chunks/handler39.js +22 -574
  45. package/dist/packem_chunks/handler4.js +2 -90
  46. package/dist/packem_chunks/handler40.js +22 -1685
  47. package/dist/packem_chunks/handler41.js +6 -1088
  48. package/dist/packem_chunks/handler42.js +5 -797
  49. package/dist/packem_chunks/handler43.js +10 -2658
  50. package/dist/packem_chunks/handler44.js +51 -3784
  51. package/dist/packem_chunks/handler45.js +25 -2574
  52. package/dist/packem_chunks/handler46.js +3 -3769
  53. package/dist/packem_chunks/handler47.js +21 -1485
  54. package/dist/packem_chunks/handler48.js +42 -0
  55. package/dist/packem_chunks/handler5.js +8 -174
  56. package/dist/packem_chunks/handler6.js +1 -95
  57. package/dist/packem_chunks/handler7.js +1 -115
  58. package/dist/packem_chunks/handler8.js +1 -12
  59. package/dist/packem_chunks/handler9.js +1 -29
  60. package/dist/packem_chunks/heal-accept.js +10 -522
  61. package/dist/packem_chunks/heal.js +14 -673
  62. package/dist/packem_chunks/index.js +7 -873
  63. package/dist/packem_chunks/loader.js +1 -23
  64. package/dist/packem_chunks/tar.js +3 -0
  65. package/dist/packem_shared/ai-analysis-hm8d2W7z.js +67 -0
  66. package/dist/packem_shared/ai-cache-DoiF80AR.js +1 -0
  67. package/dist/packem_shared/ai-fix-nn4zOE95.js +43 -0
  68. package/dist/packem_shared/cache-directory-CwHlJhgx.js +1 -0
  69. package/dist/packem_shared/dependency-scan-COr5n63B.js +2 -0
  70. package/dist/packem_shared/docker-D6OGr5_S.js +2 -0
  71. package/dist/packem_shared/failure-log-iUVLf6ts.js +2 -0
  72. package/dist/packem_shared/flakiness-D9wf0t56.js +1 -0
  73. package/dist/packem_shared/giget-CcEy_Elm.js +2 -0
  74. package/dist/packem_shared/index-DH-5hsrC.js +1 -0
  75. package/dist/packem_shared/otel-DxDUPJJH.js +6 -0
  76. package/dist/packem_shared/otelPlugin-CQq6poq8.js +1 -0
  77. package/dist/packem_shared/registry-CkubDdiY.js +2 -0
  78. package/dist/packem_shared/run-summary-utils-BfBvjzhY.js +1 -0
  79. package/dist/packem_shared/runtime-check-BXZ43CBW.js +1 -0
  80. package/dist/packem_shared/selectors-BylODRiM.js +3 -0
  81. package/dist/packem_shared/symbols-CQmER5MT.js +1 -0
  82. package/dist/packem_shared/toolchain-BgBOUHII.js +5 -0
  83. package/dist/packem_shared/typosquats-CcZl99B1.js +1 -0
  84. package/dist/packem_shared/use-measured-height-DjYgUOKk.js +1 -0
  85. package/dist/packem_shared/utils-DrNg0XTR.js +1 -0
  86. package/dist/packem_shared/verify-Baj5mFJ7.js +1 -0
  87. package/dist/packem_shared/vis-update-app-D1jl0UZZ.js +1 -0
  88. package/dist/packem_shared/xxh3-DrAUNq4n.js +1 -0
  89. package/index.js +556 -727
  90. package/package.json +19 -29
  91. package/schemas/project.schema.json +739 -297
  92. package/schemas/vis-config.schema.json +3365 -384
  93. package/templates/buildkite-ci/template.yml +20 -20
  94. package/dist/packem_shared/VisUpdateApp-D-Yz_wvg.js +0 -1316
  95. package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +0 -5
  96. package/dist/packem_shared/ai-analysis-CHeB1joD.js +0 -367
  97. package/dist/packem_shared/ai-cache-Be_jexe4.js +0 -142
  98. package/dist/packem_shared/ai-fix-B9iQVcD2.js +0 -379
  99. package/dist/packem_shared/cache-directory-2qvs4goY.js +0 -98
  100. package/dist/packem_shared/catalog-BJTtyi-O.js +0 -1371
  101. package/dist/packem_shared/dependency-scan-A0KSklpG.js +0 -188
  102. package/dist/packem_shared/docker-2iZzc280.js +0 -181
  103. package/dist/packem_shared/failure-log-Cz3Z4SKL.js +0 -100
  104. package/dist/packem_shared/flakiness-goTxXuCX.js +0 -180
  105. package/dist/packem_shared/otel-DCvqCTz_.js +0 -158
  106. package/dist/packem_shared/otelPlugin-DFaLDvJf.js +0 -3
  107. package/dist/packem_shared/registry-CbqXI0rc.js +0 -272
  108. package/dist/packem_shared/run-summary-utils-PVMl4aIh.js +0 -130
  109. package/dist/packem_shared/runtime-check-Cobi3p6l.js +0 -127
  110. package/dist/packem_shared/selectors-SM69TfqC.js +0 -194
  111. package/dist/packem_shared/symbols-Ta7g2nU-.js +0 -14
  112. package/dist/packem_shared/toolchain-BdZd9eBi.js +0 -975
  113. package/dist/packem_shared/typosquats-C-bCh3PX.js +0 -1210
  114. package/dist/packem_shared/use-measured-height-CNP0vT4M.js +0 -20
  115. package/dist/packem_shared/utils-CthVdBPS.js +0 -40
  116. package/dist/packem_shared/xxh3-Ck8mXNg1.js +0 -239
@@ -1,110 +1 @@
1
- import { createTaskGraph } from '@visulima/task-runner';
2
- import { d as discoverWorkspace, b as buildProjectGraph } from './bin.js';
3
-
4
- const findShortestPathToRoot = (graph, target) => {
5
- const reverse = /* @__PURE__ */ new Map();
6
- for (const [parent, deps] of Object.entries(graph.dependencies)) {
7
- for (const dep of deps) {
8
- const list = reverse.get(dep) ?? [];
9
- list.push(parent);
10
- reverse.set(dep, list);
11
- }
12
- }
13
- if (!graph.tasks[target]) {
14
- return void 0;
15
- }
16
- const visited = /* @__PURE__ */ new Set([target]);
17
- const queue = [{ node: target, path: [target] }];
18
- while (queue.length > 0) {
19
- const current = queue.shift();
20
- if (graph.roots.includes(current.node)) {
21
- return current.path;
22
- }
23
- for (const parent of reverse.get(current.node) ?? []) {
24
- if (visited.has(parent)) {
25
- continue;
26
- }
27
- visited.add(parent);
28
- queue.push({ node: parent, path: [parent, ...current.path] });
29
- }
30
- }
31
- return [target];
32
- };
33
- const collectParents = (graph, target) => {
34
- const parents = [];
35
- for (const [parent, deps] of Object.entries(graph.dependencies)) {
36
- if (deps.includes(target)) {
37
- parents.push(parent);
38
- }
39
- }
40
- return parents.sort();
41
- };
42
- const execute = async ({ argument, logger, visConfig, workspaceRoot: wsRoot }) => {
43
- if (!wsRoot) {
44
- throw new Error("Could not determine workspace root.");
45
- }
46
- const taskId = argument[0];
47
- if (!taskId) {
48
- throw new Error("No task ID specified. Usage: vis task-why <project>:<target>");
49
- }
50
- if (!taskId.includes(":")) {
51
- throw new Error(`Invalid task ID "${taskId}" — expected format "project:target".`);
52
- }
53
- const { packageJsons, workspace } = discoverWorkspace(wsRoot, visConfig);
54
- const projectGraph = buildProjectGraph(wsRoot, workspace, packageJsons);
55
- const [projectName, targetName] = taskId.split(":", 2);
56
- const project = workspace.projects[projectName];
57
- if (!project) {
58
- throw new Error(`Unknown project "${projectName}".`);
59
- }
60
- if (!project.targets?.[targetName]) {
61
- throw new Error(`Project "${projectName}" has no target "${targetName}".`);
62
- }
63
- const allInitialTasks = Object.entries(workspace.projects).flatMap(
64
- ([name, proj]) => Object.keys(proj.targets ?? {}).map((t) => {
65
- return {
66
- id: `${name}:${t}`,
67
- outputs: [],
68
- overrides: {},
69
- target: { project: name, target: t }
70
- };
71
- })
72
- );
73
- const graph = createTaskGraph(allInitialTasks, { projectGraph, workspace });
74
- if (!graph.tasks[taskId]) {
75
- throw new Error(`Task "${taskId}" is not reachable in the graph.`);
76
- }
77
- const path = findShortestPathToRoot(graph, taskId);
78
- const parents = collectParents(graph, taskId);
79
- logger.info("");
80
- logger.info(`Why ${taskId}?`);
81
- logger.info("");
82
- if (path && path.length > 1) {
83
- logger.info("Shortest path from a root to this task:");
84
- for (const [index, node] of path.entries()) {
85
- const prefix = index === 0 ? " " : `${" ".repeat(index + 1)}└─ `;
86
- logger.info(`${prefix}${node}`);
87
- }
88
- logger.info("");
89
- } else {
90
- logger.info(" This task is itself a root — nothing upstream depends on it.");
91
- logger.info("");
92
- }
93
- if (parents.length > 0) {
94
- logger.info(`Directly depended on by ${parents.length} task(s):`);
95
- for (const parent of parents) {
96
- logger.info(` - ${parent}`);
97
- }
98
- logger.info("");
99
- }
100
- const directDeps = graph.dependencies[taskId] ?? [];
101
- if (directDeps.length > 0) {
102
- logger.info(`This task depends on ${directDeps.length} task(s):`);
103
- for (const dep of [...directDeps].sort()) {
104
- logger.info(` - ${dep}`);
105
- }
106
- logger.info("");
107
- }
108
- };
109
-
110
- export { execute as default };
1
+ var p=Object.defineProperty;var c=(e,o)=>p(e,"name",{value:o,configurable:!0});import{m as f,o as g}from"./bin.js";var u=Object.defineProperty,d=c((e,o)=>u(e,"name",{value:o,configurable:!0}),"t");const v=d(async({argument:e,logger:o,options:n,visConfig:a,workspaceRoot:t})=>{const i=e||[],r=t??process.cwd(),l=f(r,{configBackend:a?.install?.backend,configCorepack:a?.install?.corepack}),s=g(l,i,n.recursive||!1,r,o);s!==0&&(process.exitCode=s)},"execute");export{v as default};
@@ -1,402 +1,3 @@
1
- import { createRequire as __cjs_createRequire } from "node:module";
2
-
3
- const __cjs_require = __cjs_createRequire(import.meta.url);
4
-
5
- const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
-
7
- const __cjs_getBuiltinModule = (module) => {
8
- // Check if we're in Node.js and version supports getBuiltinModule
9
- if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
- const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
- // Node.js 20.16.0+ and 22.3.0+
12
- if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
- return __cjs_getProcess.getBuiltinModule(module);
14
- }
15
- }
16
- // Fallback to createRequire
17
- return __cjs_require(module);
18
- };
19
-
20
- const {
21
- spawnSync
22
- } = __cjs_getBuiltinModule("node:child_process");
23
- const {
24
- writeFileSync
25
- } = __cjs_getBuiltinModule("node:fs");
26
- import { dim, green, red, yellow } from '@visulima/colorize';
27
- import { join } from '@visulima/path';
28
- import { p as pail } from './bin.js';
29
- import { f as findInstalledManagers, a as resolveManagerFor, b as resolveToolBinary, c as findOnPathByAlias, p as parseUseArgument, S as SUPPORTED_MANAGERS, d as buildUseInvocation, w as writePackageManagerField, u as updateEnginesField, g as getToolchainStatus, e as buildInstallInvocation, h as pickPrimaryManager } from '../packem_shared/toolchain-BdZd9eBi.js';
30
-
31
- const KNOWN_TOOLS = ["bun", "deno", "go", "node", "npm", "pnpm", "python", "ruby", "rust", "yarn"];
32
- const isKnownTool = (value) => KNOWN_TOOLS.includes(value);
33
- const icon = (ok) => ok ? green("✓") : red("✗");
34
- const warnIcon = yellow("⚠");
35
- const renderManagerLine = (manager) => {
36
- if (manager.installed) {
37
- const ver = manager.version ? ` v${manager.version}` : "";
38
- const cfg = manager.configFiles.length > 0 ? ` (${manager.configFiles.join(", ")})` : "";
39
- return `${icon(true)} ${manager.name}${ver}${cfg}`;
40
- }
41
- return `${warnIcon} ${manager.name} — referenced by ${manager.configFiles.join(", ")} but not installed`;
42
- };
43
- const renderToolManager = (tool) => {
44
- if (tool.matches) {
45
- return "";
46
- }
47
- const { manager } = tool;
48
- if (manager.name === "none") {
49
- return dim("→ (no manager)");
50
- }
51
- if (manager.name === "self-activate") {
52
- return "";
53
- }
54
- return manager.installed ? dim(`→ ${manager.name}`) : dim(`→ ${manager.name} (missing)`);
55
- };
56
- const toolIcon = (tool) => {
57
- if (tool.matches) {
58
- return icon(true);
59
- }
60
- return tool.actual ? warnIcon : icon(false);
61
- };
62
- const printStatus = (status) => {
63
- pail.info("");
64
- pail.info(dim("── Toolchain ───────────────────────"));
65
- if (status.detected.length === 0) {
66
- pail.info(` ${icon(false)} No version manager detected`);
67
- pail.notice(` Install one of: ${SUPPORTED_MANAGERS.join(", ")}`);
68
- } else {
69
- for (const manager of status.detected) {
70
- pail.info(` ${renderManagerLine(manager)}`);
71
- }
72
- }
73
- pail.info("");
74
- if (status.tools.length === 0) {
75
- pail.info(` ${dim("No tool pins found — add engines.node, .nvmrc, or a manager config file.")}`);
76
- return;
77
- }
78
- pail.info(dim("── Tools ───────────────────────────"));
79
- for (const tool of status.tools) {
80
- const expected = `${tool.expected.tool} ${tool.expected.version}`;
81
- const actualText = tool.actual ? `actual ${tool.actual}` : "not installed";
82
- const source = tool.matches ? "" : dim(` [${tool.expected.source}]`);
83
- const managerText = renderToolManager(tool);
84
- const suffix = managerText === "" ? "" : ` ${managerText}`;
85
- pail.info(` ${toolIcon(tool)} ${expected} — ${actualText}${source}${suffix}`);
86
- if (tool.manager.note) {
87
- pail.notice(` ${tool.manager.note}`);
88
- }
89
- }
90
- };
91
- const executeStatus = (workspaceRoot, toolchainConfig, options) => {
92
- const status = getToolchainStatus(workspaceRoot, toolchainConfig);
93
- if (options.json) {
94
- process.stdout.write(
95
- `${JSON.stringify(
96
- {
97
- detected: status.detected.map((m) => {
98
- return {
99
- binPath: m.binPath ?? null,
100
- configFiles: m.configFiles,
101
- installed: m.installed,
102
- name: m.name,
103
- version: m.version ?? null
104
- };
105
- }),
106
- tools: status.tools.map((t) => {
107
- return {
108
- actual: t.actual ?? null,
109
- expected: t.expected.version,
110
- manager: t.manager.name,
111
- managerInstalled: t.manager.installed,
112
- matches: t.matches,
113
- note: t.manager.note ?? null,
114
- source: t.expected.source,
115
- tool: t.expected.tool
116
- };
117
- })
118
- },
119
- void 0,
120
- 2
121
- )}
122
- `
123
- );
124
- return;
125
- }
126
- printStatus(status);
127
- const mismatches = status.tools.filter((t) => !t.matches);
128
- if (mismatches.length > 0) {
129
- pail.info("");
130
- pail.notice(" Run `vis toolchain install` to install pinned versions.");
131
- }
132
- if (options.exitCode && mismatches.length > 0) {
133
- process.exitCode = 1;
134
- }
135
- };
136
- const groupByManager = (tools) => {
137
- const groups = /* @__PURE__ */ new Map();
138
- for (const tool of tools) {
139
- const bucket = groups.get(tool.manager.name);
140
- if (bucket) {
141
- bucket.push(tool);
142
- } else {
143
- groups.set(tool.manager.name, [tool]);
144
- }
145
- }
146
- return groups;
147
- };
148
- const runInvocation = (bin, args, cwd) => {
149
- const result = spawnSync(bin, args, { cwd, stdio: "inherit" });
150
- return result.status ?? 1;
151
- };
152
- const executeInstall = (workspaceRoot, toolchainConfig, options) => {
153
- const status = getToolchainStatus(workspaceRoot, toolchainConfig);
154
- const mismatches = status.tools.filter((t) => !t.matches);
155
- if (mismatches.length === 0) {
156
- pail.success("Everything already matches — nothing to install.");
157
- return;
158
- }
159
- const needsRealManager = mismatches.some((m) => m.manager.name !== "self-activate" && m.manager.name !== "none");
160
- if (status.detected.length === 0 && needsRealManager) {
161
- pail.error(`No version manager detected. Install one of: ${SUPPORTED_MANAGERS.join(", ")}.`);
162
- process.exitCode = 1;
163
- return;
164
- }
165
- const groups = groupByManager(mismatches);
166
- let ranAnything = false;
167
- let exitCode = 0;
168
- for (const [managerName, tools] of groups) {
169
- if (managerName === "self-activate") {
170
- for (const { expected } of tools) {
171
- if (expected.source === "packageManager") {
172
- pail.info(`${dim("$")} (${expected.tool} will self-activate from packageManager on next invocation)`);
173
- } else {
174
- pail.info(`${dim("$")} Writing packageManager=${expected.tool}@${expected.version}`);
175
- if (options.dryRun) {
176
- ranAnything = true;
177
- } else {
178
- try {
179
- writePackageManagerField(workspaceRoot, expected);
180
- ranAnything = true;
181
- } catch (error) {
182
- pail.error(error.message);
183
- exitCode = 1;
184
- }
185
- }
186
- }
187
- pail.notice(` ${expected.tool} ${expected.version} — no install needed`);
188
- }
189
- continue;
190
- }
191
- if (managerName === "none") {
192
- for (const { expected } of tools) {
193
- pail.warn(`Cannot install ${expected.tool} ${expected.version} — no manager can handle it.`);
194
- }
195
- exitCode = 1;
196
- continue;
197
- }
198
- const manager = status.detected.find((d) => d.name === managerName);
199
- if (!manager?.installed) {
200
- pail.error(`${managerName} is referenced but not on PATH — install it first, then rerun \`vis toolchain install\`.`);
201
- exitCode = 1;
202
- continue;
203
- }
204
- const invocations = tools.map((t) => buildInstallInvocation(managerName, t.expected)).filter(Boolean);
205
- for (const invocation of invocations) {
206
- if (!invocation) {
207
- continue;
208
- }
209
- if (invocation.bin === "nvm" && invocation.args.length === 0) {
210
- pail.error("nvm is a shell function — run `nvm install` in your shell, then rerun `vis toolchain install`.");
211
- if (invocation.hint) {
212
- pail.notice(` ${invocation.hint}`);
213
- }
214
- exitCode = 1;
215
- continue;
216
- }
217
- pail.info(`${dim("$")} ${invocation.bin} ${invocation.args.join(" ")}`);
218
- if (invocation.hint) {
219
- pail.notice(` ${invocation.hint}`);
220
- }
221
- if (options.dryRun) {
222
- ranAnything = true;
223
- continue;
224
- }
225
- const status_ = runInvocation(invocation.bin, invocation.args, workspaceRoot);
226
- ranAnything = true;
227
- if (status_ !== 0) {
228
- exitCode = status_;
229
- break;
230
- }
231
- }
232
- }
233
- if (exitCode !== 0) {
234
- process.exitCode = exitCode;
235
- return;
236
- }
237
- if (ranAnything) {
238
- pail.success("Toolchain installed.");
239
- }
240
- };
241
- const executeUse = (workspaceRoot, toolchainConfig, rawSpec, options) => {
242
- if (!rawSpec) {
243
- throw new Error("Usage: vis toolchain use <tool>@<version> (e.g. vis toolchain use node@22.13.0)");
244
- }
245
- const spec = parseUseArgument(rawSpec);
246
- if (!spec) {
247
- throw new Error(`Could not parse "${rawSpec}". Expected "<tool>@<version>" where <tool> is one of ${KNOWN_TOOLS.join(", ")}.`);
248
- }
249
- const detected = findInstalledManagers(workspaceRoot);
250
- const manager = resolveManagerFor(spec, detected, toolchainConfig);
251
- if (manager.name === "none") {
252
- pail.error(`No manager can pin ${spec.tool}. Install one of: ${SUPPORTED_MANAGERS.join(", ")}.`);
253
- process.exitCode = 1;
254
- return;
255
- }
256
- if (!manager.installed) {
257
- pail.error(`The best manager for ${spec.tool} (${manager.name}) is not on PATH. ${manager.note ?? ""}`);
258
- process.exitCode = 1;
259
- return;
260
- }
261
- const invocation = buildUseInvocation(manager.name, spec);
262
- if (!invocation) {
263
- pail.error(`${manager.name} cannot pin ${spec.tool}. Use a different manager, or set \`toolchain.tools.${spec.tool}\` in vis.config.ts.`);
264
- process.exitCode = 1;
265
- return;
266
- }
267
- if (manager.name === "self-activate") {
268
- pail.info(`${dim("→")} Writing packageManager field to package.json...`);
269
- if (options.dryRun) {
270
- pail.notice(` Would set packageManager: "${spec.tool}@${spec.version}"`);
271
- return;
272
- }
273
- try {
274
- const written = writePackageManagerField(workspaceRoot, spec);
275
- if (!written) {
276
- pail.error(`Refusing to pin non-package-manager tool ${spec.tool} via the packageManager field.`);
277
- process.exitCode = 1;
278
- return;
279
- }
280
- pail.success(`Set packageManager: "${written}" — ${spec.tool} will activate this version on next invocation.`);
281
- if (options.engines !== false) {
282
- const updated = updateEnginesField(workspaceRoot, spec);
283
- if (updated) {
284
- pail.success(`Updated package.json engines.${spec.tool} → ${updated}.`);
285
- }
286
- }
287
- } catch (error) {
288
- pail.error(error.message);
289
- process.exitCode = 1;
290
- }
291
- return;
292
- }
293
- if (invocation.args.length === 0 && manager.name === "nvm" && spec.tool === "node") {
294
- const nvmrcPath = join(workspaceRoot, ".nvmrc");
295
- pail.info(`${dim("→")} Writing ${nvmrcPath}...`);
296
- if (options.dryRun) {
297
- pail.notice(` Would write ${spec.version} to .nvmrc`);
298
- return;
299
- }
300
- try {
301
- writeFileSync(nvmrcPath, `${spec.version}
302
- `);
303
- } catch (error) {
304
- pail.error(`Failed to write .nvmrc: ${error.message}`);
305
- process.exitCode = 1;
306
- return;
307
- }
308
- pail.success(`Wrote ${spec.version} to .nvmrc.`);
309
- pail.notice(" nvm is a shell function — run `nvm use` to activate it in this shell.");
310
- return;
311
- }
312
- if (invocation.args.length === 0) {
313
- pail.error(`${manager.name} cannot pin ${spec.tool} from a subprocess. ${invocation.configChange?.hint ?? ""}`);
314
- if (invocation.configChange) {
315
- pail.notice(` Edit ${invocation.configChange.file} by hand and rerun \`vis toolchain status\` to verify.`);
316
- }
317
- process.exitCode = 1;
318
- return;
319
- }
320
- pail.info(`${dim("$")} ${invocation.bin} ${invocation.args.join(" ")}`);
321
- if (invocation.configChange) {
322
- pail.notice(` Will update ${invocation.configChange.file} — ${invocation.configChange.hint}`);
323
- }
324
- if (options.dryRun) {
325
- return;
326
- }
327
- const status_ = runInvocation(invocation.bin, invocation.args, workspaceRoot);
328
- if (status_ !== 0) {
329
- process.exitCode = status_;
330
- return;
331
- }
332
- pail.success(`Pinned ${spec.tool} to ${spec.version}.`);
333
- if (options.engines !== false) {
334
- try {
335
- const updated = updateEnginesField(workspaceRoot, spec);
336
- if (updated) {
337
- pail.success(`Updated package.json engines.${spec.tool} → ${updated}.`);
338
- }
339
- } catch (error) {
340
- pail.warn(`Could not update engines.${spec.tool}: ${error.message}`);
341
- }
342
- }
343
- };
344
- const executeWhich = (workspaceRoot, toolchainConfig, rawTool) => {
345
- if (!rawTool) {
346
- throw new Error("Usage: vis toolchain which <tool> (e.g. vis toolchain which node)");
347
- }
348
- const normalized = rawTool.toLowerCase();
349
- if (!isKnownTool(normalized)) {
350
- throw new Error(`Unknown tool "${rawTool}". Known: ${KNOWN_TOOLS.join(", ")}.`);
351
- }
352
- const detected = findInstalledManagers(workspaceRoot);
353
- const resolved = resolveManagerFor({ source: "vis.config.ts", tool: normalized, version: "*" }, detected, toolchainConfig);
354
- const manager = resolved.installed && resolved.name !== "self-activate" && resolved.name !== "none" ? detected.find((d) => d.name === resolved.name) : void 0;
355
- const binary = manager ? resolveToolBinary(manager, normalized) : findOnPathByAlias(normalized);
356
- if (!binary) {
357
- pail.error(`${rawTool} not found in PATH${manager ? ` or via ${manager.name}` : ""}.`);
358
- process.exitCode = 1;
359
- return;
360
- }
361
- process.stdout.write(`${binary}
362
- `);
363
- };
364
- const executeDetect = (workspaceRoot, toolchainConfig) => {
365
- const primary = pickPrimaryManager(workspaceRoot, toolchainConfig);
366
- process.stdout.write(`${primary.name}
367
- `);
368
- };
369
- const execute = async ({ argument, options, visConfig, workspaceRoot: wsRoot }) => {
370
- if (!wsRoot) {
371
- throw new Error("Could not determine workspace root. Run inside a monorepo.");
372
- }
373
- const action = argument[0] ?? "status";
374
- const toolchainConfig = visConfig?.toolchain;
375
- switch (action) {
376
- case "detect": {
377
- executeDetect(wsRoot, toolchainConfig);
378
- return;
379
- }
380
- case "install": {
381
- executeInstall(wsRoot, toolchainConfig, options);
382
- return;
383
- }
384
- case "status": {
385
- executeStatus(wsRoot, toolchainConfig, options);
386
- return;
387
- }
388
- case "use": {
389
- executeUse(wsRoot, toolchainConfig, argument[1], options);
390
- return;
391
- }
392
- case "which": {
393
- executeWhich(wsRoot, toolchainConfig, argument[1]);
394
- return;
395
- }
396
- default: {
397
- throw new Error(`Unknown toolchain action "${action}". Known: status, detect, install, use, which.`);
398
- }
399
- }
400
- };
401
-
402
- export { execute as default };
1
+ var a=Object.defineProperty;var s=(n,e)=>a(n,"name",{value:e,configurable:!0});import{createRequire as f}from"node:module";import{q as v}from"./bin.js";const d=f(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=s(n=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[e,r]=t.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return t.getBuiltinModule(n)}return d(n)},"__cjs_getBuiltinModule"),{execSync:p,spawnSync:m}=l("node:child_process");var g=Object.defineProperty,y=s((n,e)=>g(n,"name",{value:e,configurable:!0}),"r");const w=y(async({argument:n,logger:e,options:r})=>{const c=n?.[0];e.info("info: checking for updates...");const o=v.version;let i;try{const u=p("npm view @visulima/vis version",{encoding:"utf8"}).trim();i=c??u}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(o===i&&!r.force){e.info(`
2
+ ✓ Already up to date (${o})`);return}if(r.check){o===i?e.info(`✓ Already up to date (${o})`):e.info(`info: found @visulima/vis@${i} (current: ${o})`);return}if(e.info(`info: found @visulima/vis@${i} (current: ${o})`),e.info("info: installing..."),m("npm",["install","-g",`@visulima/vis@${i}`],{encoding:"utf8",stdio:"inherit"}).status!==0)throw new Error("Failed to update. Try running with sudo or fix npm permissions.");e.info(`
3
+ Updated @visulima/vis from ${o} → ${i}`)},"execute");export{w as default};
@@ -1,13 +1 @@
1
- import { r as resolveInstaller, B as runUnlink } from './bin.js';
2
-
3
- const execute = async ({ argument, logger, options, visConfig, workspaceRoot: wsRoot }) => {
4
- const packages = argument || [];
5
- const cwd = wsRoot ?? process.cwd();
6
- const pm = resolveInstaller(cwd, { configBackend: visConfig?.install?.backend });
7
- const code = runUnlink(pm, packages, options.recursive || false, cwd, logger);
8
- if (code !== 0) {
9
- process.exitCode = code;
10
- }
11
- };
12
-
13
- export { execute as default };
1
+ var p=Object.defineProperty;var t=(o,a)=>p(o,"name",{value:a,configurable:!0});import{m as f,C as d}from"./bin.js";import{o as g}from"../packem_shared/utils-DrNg0XTR.js";var v=Object.defineProperty,m=t((o,a)=>v(o,"name",{value:a,configurable:!0}),"n");const h=m(async({argument:o,logger:a,options:e,visConfig:l,workspaceRoot:i})=>{const s=o;if(!s||s.length===0)throw new Error("No packages specified. Usage: vis why <package...>");const n=i??process.cwd(),c=f(n,{configBackend:l?.install?.backend,configCorepack:l?.install?.corepack}),r=d(c,{depth:e.depth===void 0?void 0:Number(e.depth),dev:e.dev||!1,filter:g(e.filter),global:e.global||!1,json:e.json||!1,long:e.long||!1,noOptional:e.noOptional||!1,packages:s,parseable:e.parseable||!1,prod:e.prod||!1,recursive:e.recursive||!1},n,a);r!==0&&r!==1&&(process.exitCode=r)},"execute");export{h as default};
@@ -1,63 +1 @@
1
- import { createRequire as __cjs_createRequire } from "node:module";
2
-
3
- const __cjs_require = __cjs_createRequire(import.meta.url);
4
-
5
- const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
-
7
- const __cjs_getBuiltinModule = (module) => {
8
- // Check if we're in Node.js and version supports getBuiltinModule
9
- if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
- const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
- // Node.js 20.16.0+ and 22.3.0+
12
- if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
- return __cjs_getProcess.getBuiltinModule(module);
14
- }
15
- }
16
- // Fallback to createRequire
17
- return __cjs_require(module);
18
- };
19
-
20
- const {
21
- execSync,
22
- spawnSync
23
- } = __cjs_getBuiltinModule("node:child_process");
24
- import { C as pkg } from './bin.js';
25
-
26
- const execute = async ({ argument, logger, options }) => {
27
- const targetVersion = argument?.[0];
28
- logger.info("info: checking for updates...");
29
- const currentVersion = pkg.version;
30
- let latestVersion;
31
- try {
32
- const result2 = execSync("npm view @visulima/vis version", { encoding: "utf8" }).trim();
33
- latestVersion = targetVersion ?? result2;
34
- } catch {
35
- throw new Error("Failed to query npm registry. Check your network connection.");
36
- }
37
- if (currentVersion === latestVersion && !options.force) {
38
- logger.info(`
39
- ✓ Already up to date (${currentVersion})`);
40
- return;
41
- }
42
- if (options.check) {
43
- if (currentVersion === latestVersion) {
44
- logger.info(`✓ Already up to date (${currentVersion})`);
45
- } else {
46
- logger.info(`info: found @visulima/vis@${latestVersion} (current: ${currentVersion})`);
47
- }
48
- return;
49
- }
50
- logger.info(`info: found @visulima/vis@${latestVersion} (current: ${currentVersion})`);
51
- logger.info("info: installing...");
52
- const result = spawnSync("npm", ["install", "-g", `@visulima/vis@${latestVersion}`], {
53
- encoding: "utf8",
54
- stdio: "inherit"
55
- });
56
- if (result.status !== 0) {
57
- throw new Error("Failed to update. Try running with sudo or fix npm permissions.");
58
- }
59
- logger.info(`
60
- ✓ Updated @visulima/vis from ${currentVersion} → ${latestVersion}`);
61
- };
62
-
63
- export { execute as default };
1
+ var q=Object.defineProperty;var $=(t,r)=>q(t,"name",{value:r,configurable:!0});import{createRequire as A}from"node:module";import{dim as M,red as N,yellow as z,green as T}from"@visulima/colorize";import{readJsonSync as B,writeJsonSync as I}from"@visulima/fs";import{findPackageManagerSync as J}from"@visulima/package";import{join as U}from"@visulima/path";import{B as V,r as b,t as G,p as g,N as j,R as Q,Q as W,w as Y,U as Z,k as H,g as K,z as X,h as ee,V as oe,F as te,m as se,G as ne}from"./bin.js";import{r as re}from"../packem_shared/typosquats-CcZl99B1.js";import{d as C,o as R}from"../packem_shared/utils-DrNg0XTR.js";const O=A(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=$(t=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[r,e]=v.versions.node.split(".").map(Number);if(r>22||r===22&&e>=3||r===20&&e>=16)return v.getBuiltinModule(t)}return O(t)},"__cjs_getBuiltinModule"),{createInterface:F}=L("node:readline");var ae=Object.defineProperty,h=$((t,r)=>ae(t,"name",{value:r,configurable:!0}),"c");const P=h(t=>t==="default"?"catalog:":`catalog:${t}`,"buildCatalogRef"),S=h(t=>t==="default"?"default catalog":`catalog "${t}"`,"labelForCatalog"),ie=h((t,r)=>{const e=[];for(const[o,n]of r)o.includes(":")||n.has(t)&&e.push(o);if(e.length===0)return;if(e.length===1){const[o]=e;return{source:S(o),spec:P(o)}}const a=e.find(o=>o==="default")??e[0],i=e.filter(o=>o!==a);return{candidates:[...e],conflict:!0,source:`${S(a)} (also in: ${i.map(o=>S(o)).join(", ")})`,spec:P(a)}},"resolveFromCatalogs"),ce=h((t,r)=>{const e=new Map;for(const[l,p]of r){if(!l.includes(":"))continue;const f=p.get(t);f!==void 0&&e.set(f,(e.get(f)??0)+1)}if(e.size===0)return;const a=[...e.entries()],i=a.reduce((l,[,p])=>l+p,0);if(a.length===1){const[[l]]=a;return{source:`siblings (${String(i)} pkg${i===1?"":"s"} on ${l})`,spec:l}}const o=[...a].sort((l,p)=>p[1]-l[1]),[n,s]=o[0],c=o.slice(1).map(([l,p])=>`${l} (×${String(p)})`);return{candidates:o.map(([l])=>l),conflict:!0,source:`siblings (most common: ${n} ×${String(s)}; conflicts: ${c.join(", ")})`,spec:n}},"resolveFromSiblings"),le=h((t,r)=>ie(t,r)||ce(t,r),"conformToCatalog");var pe=Object.defineProperty,d=$((t,r)=>pe(t,"name",{value:r,configurable:!0}),"m");const _=d(async(t,r=1e4)=>{const e=new Map,a=new AbortController,i=setTimeout(()=>{a.abort()},r);try{const o=t.map(async n=>{try{const s=await fetch(`https://registry.npmjs.org/${n}/latest`,{headers:{Accept:"application/json"},signal:a.signal});if(s.ok){const c=await s.json();c.version&&e.set(n,c.version)}}catch{}});await Promise.all(o)}finally{clearTimeout(i)}return e},"resolveLatestVersions"),fe=d((t,r,e)=>{const a=[];for(const i of t.values()){const{overall:o}=i.score,n=V(o),s=`${String(Math.round(o*100))}%`,c=i.alerts.length,l=b(i),p=G(l,i.version,e),f=n==="red"?N:n==="yellow"?z:T;if(p?g.info(` ${f(s)} ${j(i)} ${M(`[accepted: ${p.reason}]`)}`):g.info(` ${f(s)} ${j(i)}`),c>0){const u=i.alerts.filter(m=>m.severity==="critical"||m.severity==="high").length;u>0&&g.warn(` ${String(u)} critical/high alert${u===1?"":"s"}`)}o<r&&!p&&a.push(i)}return a},"displaySecurityReports"),ge=d(async(t,r)=>{const e=F({input:process.stdin,output:process.stdout}),a=d(s=>new Promise(c=>{e.question(s,l=>{c(l.trim())})}),"ask"),i=String(Math.round(r*100));g.warn(""),g.warn(`${String(t.length)} package${t.length===1?"":"s"} scored below the minimum threshold (${i}%):`);for(const s of t){const c=b(s),l=`${String(Math.round(s.score.overall*100))}%`;g.warn(` • ${c}@${s.version} — score: ${l} (${Q(s.score.overall)})`)}g.warn("");const o=await a("Continue adding these packages? [y/N] ");if(o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes")return e.close(),!1;const n=await a("Remember this decision? (prints config snippet) [y/N] ");if(e.close(),n.toLowerCase()==="y"||n.toLowerCase()==="yes"){g.notice(""),g.notice("Add the following to security.socket.acceptedRisks in vis.config.ts:"),g.notice("");for(const s of t){const c=b(s),l=W(c,s.version,s.score.overall,"Reviewed and accepted");g.notice(l)}g.notice("")}return!0},"confirmLowScorePackages"),ue=d(async(t,r,e,a)=>{const i=t.map(f=>C(f)),o=new Map;for(const f of i)if(f.versionSpec){const u=Y.coerce(f.versionSpec);u&&o.set(f.name,u.version)}const n=i.filter(f=>!o.has(f.name)).map(f=>f.name),s=n.length>0?await _(n):new Map,c=[];for(const f of i){const u=o.get(f.name)??s.get(f.name);u&&c.push({name:f.name,version:u})}if(c.length===0)return!0;g.info(""),g.info("Socket.dev security check:");const l=await Z(c,r);if(l.size===0)return g.info(" Could not fetch security data. Proceeding."),!0;const p=fe(l,e,a);return p.length===0?(g.info(""),!0):process.stdin.isTTY?ge(p,e):(g.warn(`Aborting: ${String(p.length)} package${p.length===1?"":"s"} below minimum score. Use --no-socket-check to skip.`),!1)},"runSocketPreCheck"),de=["dependencies","devDependencies","peerDependencies","optionalDependencies"],me=d(t=>t.savePeer?"peerDependencies":t.saveOptional?"optionalDependencies":t.saveDev?"devDependencies":"dependencies","pickDepSection"),D=d((t,r)=>t.startsWith("catalog:")||!r?t:t.replace(/^[\^~]/,""),"applyExactPrefix"),ke=d(async(t,r)=>{const e=[];for(const o of t){const{name:n,versionSpec:s}=C(o);if(!n)continue;if(s!==void 0){e.push({explicit:s,name:n});continue}const c=le(n,r);if(c){c.conflict&&g.warn(`${n}: ambiguous constraint — picking ${c.spec} (${c.source}). Pass ${n}@<version> to override.`),e.push({entry:{name:n,source:c.source,spec:c.spec},kind:"resolved",name:n});continue}e.push({kind:"missing",name:n})}const a=e.filter(o=>"kind"in o&&o.kind==="missing").map(o=>o.name),i=a.length>0?await _(a):new Map;return e.map(o=>{if("explicit"in o)return{name:o.name,source:"explicit",spec:o.explicit};if(o.kind==="resolved")return o.entry;const n=i.get(o.name);if(n===void 0)throw new Error(`--to: cannot resolve a version for "${o.name}" (not in any catalog or sibling, and registry lookup failed). Pass ${o.name}@<version> explicitly.`);const s=`^${n}`;return g.info(`${o.name}: no existing constraint — using registry latest (${s}). Add to a catalog to share this version across workspace packages.`),{name:o.name,source:"registry latest",spec:s}})},"planConformedSpecs"),we=d((t,r,e,a)=>{for(const{name:i,spec:o}of r){const n=D(o,a);for(const c of de){if(c===e)continue;const l=t[c];l?.[i]!==void 0&&(delete l[i],Object.keys(l).length===0&&delete t[c])}let s=t[e];s===void 0&&(s={},t[e]=s),s[i]=n}},"applyPlannedSpecsToPackageJson"),ve=d(async({ignoreScripts:t,logger:r,options:e,packages:a,pm:i,target:o,visConfig:n,workspaceRoot:s})=>{const{workspace:c}=H(s,n??{}),l=c.projects[o];if(!l){const k=Object.keys(c.projects).sort();throw new Error(`--to: workspace package "${o}" not found. Available: ${k.length>0?k.slice(0,10).join(", "):"(none)"}${k.length>10?`, ... (${String(k.length-10)} more)`:""}.`)}const p=U(s,l.root,"package.json"),{packageManager:f}=J(s),u=K(s,f),m=me(e),w=e.exact??!1,y=await ke(a,u);if(y.length===0)return 0;const x=B(p);we(x,y,m,w),I(p,x,{indent:X(p,{useEditorconfig:n?.editorconfig??!0}),overwrite:!0});for(const k of y){const E=D(k.spec,w);g.info(`${T("+")} ${k.name}@${E} → ${o}/${m} (${M(k.source)})`)}return ee(i,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:t,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},s,r)},"applyConformedAdd"),Pe=d(async({argument:t,logger:r,options:e,visConfig:a,workspaceRoot:i})=>{let o=t;if(!o||o.length===0)throw new Error("No packages specified. Usage: vis add <packages...>");if(!e.noTyposquatCheck){const p=o.map(u=>C(u)),f=await re(p.map(u=>u.name),a?.security?.typosquatAllowlist);if(!f.ok){process.exitCode=1;return}o=p.map((u,m)=>{const w=f.packages[m];return w!==u.name?u.versionSpec?`${w}@${u.versionSpec}`:w??"":o[m]??""})}if(!e.noSocketCheck){const p=oe(a?.security?.socket);if(p){const f=p.minimumScore??te;if(!await ue(o,p,f,a?.security?.socket?.acceptedRisks)){process.exitCode=1;return}}}const n=process.cwd(),s=se(i??n,{configBackend:a?.install?.backend,configCorepack:a?.install?.corepack}),c=!e.runScripts;if(e.to){if(e.global||e.workspaceRoot)throw new Error("--to is incompatible with --global / --workspace-root.");if(e.filter&&R(e.filter).length>0)throw new Error("--to and --filter are mutually exclusive — --to already targets one package.");if(!i)throw new Error("--to requires a monorepo workspace. Run from inside a pnpm/bun/yarn/npm workspace.");const p=await ve({ignoreScripts:c,logger:r,options:e,packages:o,pm:s,target:e.to,visConfig:a,workspaceRoot:i});p!==0&&(process.exitCode=p);return}const l=ne(s,{exact:e.exact||!1,filter:R(e.filter),global:e.global||!1,optional:e.saveOptional||!1,packages:o,peer:e.savePeer||!1,saveDev:e.saveDev||!1,workspace:e.workspace||!1,workspaceRoot:e.workspaceRoot||!1},n,r,{autoInstallPeers:e.autoInstallPeers||!1,ignoreScripts:c});l!==0&&(process.exitCode=l)},"execute");export{Pe as default};
@@ -1,34 +1,7 @@
1
- import { r as resolveInstaller, E as runWhy } from './bin.js';
2
- import { t as toStringArray } from '../packem_shared/utils-CthVdBPS.js';
3
-
4
- const execute = async ({ argument, logger, options, visConfig, workspaceRoot: wsRoot }) => {
5
- const packages = argument;
6
- if (!packages || packages.length === 0) {
7
- throw new Error("No packages specified. Usage: vis why <package...>");
8
- }
9
- const cwd = wsRoot ?? process.cwd();
10
- const pm = resolveInstaller(cwd, { configBackend: visConfig?.install?.backend });
11
- const code = runWhy(
12
- pm,
13
- {
14
- depth: options.depth === void 0 ? void 0 : Number(options.depth),
15
- dev: options.dev || false,
16
- filter: toStringArray(options.filter),
17
- global: options.global || false,
18
- json: options.json || false,
19
- long: options.long || false,
20
- noOptional: options.noOptional || false,
21
- packages,
22
- parseable: options.parseable || false,
23
- prod: options.prod || false,
24
- recursive: options.recursive || false
25
- },
26
- cwd,
27
- logger
28
- );
29
- if (code !== 0 && code !== 1) {
30
- process.exitCode = code;
31
- }
32
- };
33
-
34
- export { execute as default };
1
+ var x=Object.defineProperty;var l=(e,o)=>x(e,"name",{value:o,configurable:!0});import{runProvider as S,detectAllProviders as w}from"@visulima/find-ai-runner";import{renderToString as E,Table as P}from"@visulima/tui";import D from"react";import{b as g,R as v}from"../packem_shared/ai-analysis-hm8d2W7z.js";import{bold as I,dim as d,cyan as N,green as O,yellow as T}from"@visulima/colorize";var j=Object.defineProperty,u=l((e,o)=>j(e,"name",{value:o,configurable:!0}),"s");const f={command:"ai",description:"AI-assisted commands: provider detection, cache management, and failure-fix proposals."},A=u(e=>{if(typeof e!="function")return String(e);const{name:o}=e;return o==="Boolean"?"boolean":o==="Number"?"number":o==="String"?"string":o??"unknown"},"typeName"),R=u(e=>{const o=[...e.commandPath??[],e.name].join(" "),a=(e.examples??[]).map(([t,s])=>({command:t??"",description:s??""})),i=(e.options??[]).map(t=>({defaultValue:t.defaultValue,description:t.description,name:t.name,type:A(t.type)}));return{argument:e.argument?{description:e.argument.description,name:e.argument.name}:void 0,description:e.description??"",examples:a,name:e.name,options:i,path:o}},"buildSubcommand"),y=u((e,o=f)=>({command:o.command,description:o.description,subcommands:e.map(a=>R(a))}),"buildDiscoveryPayload"),C=u((e,o=f)=>`${JSON.stringify(y(e,o),void 0,2)}
2
+ `,"renderDiscoveryJson"),J=u((e,o=f)=>{const a=y(e,o),i=[I(`vis ${a.command} — ${a.description}`),"",d("Subcommands:")];for(const t of a.subcommands){const s=t.argument?` ${N(`<${t.argument.name}>`)}`:"";if(i.push(""),i.push(` ${O(`vis ${t.path}`)}${s}`),t.description&&i.push(` ${t.description}`),t.options.length>0){const n=t.options.map(c=>`--${c.name}${c.type==="boolean"?"":`=<${c.type}>`}`).join(", ");i.push(d(` options: ${n}`))}if(t.examples.length>0){i.push(d(" examples:"));for(const n of t.examples){const c=n.description?d(` — ${n.description}`):"";i.push(` ${T(n.command)}${c}`)}}}return i.push(""),i.push(d(`Run \`vis ${a.command} discover-help\` for the machine-readable JSON catalogue (designed for AI agents).`)),i.push(d(`Run \`vis ${a.command} <subcommand> --help\` for full usage of a specific subcommand.`)),`${i.join(`
3
+ `)}
4
+ `},"renderDiscoveryText");var F=Object.defineProperty,p=l((e,o)=>F(e,"name",{value:o,configurable:!0}),"r");const h=p(async()=>{const{default:e}=await import("./bin.js").then(o=>o.aO);return e.filter(o=>o.name!=="ai")},"loadDiscoverableSubcommands"),L=p(async()=>{const e=await h();process.stderr.write(J(e))},"aiRootExecute"),q=p(async()=>{const e=await h();process.stdout.write(C(e))},"aiDiscoverHelpExecute"),z=p(async({logger:e,visConfig:o})=>{const a=o?.ai,i=g(a);if(!i){e.error("No AI provider available to test."),process.exitCode=1;return}e.info(`Testing ${i.name}...`);try{const t=await S(i,"Reply with exactly: OK",{timeoutMs:3e4});e.info(`Provider ${i.name} responded: ${t.stdout.trim().slice(0,200)}`)}catch(t){const s=t instanceof Error?t.message:String(t);e.error(`Provider ${i.name} failed: ${s}`),process.exitCode=1}},"aiTestExecute"),G=p(({logger:e,options:o,visConfig:a})=>{const i=o.format??"table",t=a?.ai,s=w(),n=g(t);if(i==="json"){const r=s.map(m=>({available:m.available,method:m.detectionMethod,name:m.name,path:m.path,priority:v[m.name]??0,selected:m.name===n?.name,version:m.version}));process.stdout.write(`${JSON.stringify(r,void 0,2)}
5
+ `);return}const c=s.map(r=>({method:r.detectionMethod??"-",path:r.path??"-",priority:String(v[r.name]??0),provider:r.name,selected:r.name===n?.name?">>>":"",status:r.available?"available":"not found",version:r.version??"-"})),b=process.stdout.columns||80,$=E(D.createElement(P,{data:c}),{columns:b});e.info($),n?e.info(`
6
+ Selected provider: ${n.name} (priority ${String(v[n.name]??0)})`):e.info(`
7
+ No AI provider available. Install one of the supported AI CLI tools.`)},"aiProvidersExecute"),Q=p(async e=>{const{aiFix:o}=await import("./fix.js");await o(e)},"aiFixExecute");export{q as aiDiscoverHelpExecute,Q as aiFixExecute,G as aiProvidersExecute,L as aiRootExecute,z as aiTestExecute};