@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,112 +1,2 @@
1
- import { green, red, bold, dim, cyan, yellow } from '@visulima/colorize';
2
- import { ReapiRemoteCache } from '@visulima/task-runner';
3
- import { p as pail } from './bin.js';
4
-
5
- const inferBackend = (url, override) => {
6
- if (override === "http" || override === "reapi") {
7
- return override;
8
- }
9
- if (url.startsWith("grpc://") || url.startsWith("grpcs://")) {
10
- return "reapi";
11
- }
12
- return "http";
13
- };
14
- const probeHttp = async (url, timeoutMs) => {
15
- const startedAt = Date.now();
16
- const controller = new AbortController();
17
- const timer = setTimeout(() => {
18
- controller.abort();
19
- }, timeoutMs);
20
- try {
21
- const response = await fetch(url, { method: "HEAD", signal: controller.signal });
22
- return {
23
- backend: "http",
24
- durationMs: Date.now() - startedAt,
25
- httpStatus: response.status,
26
- ok: true,
27
- url
28
- };
29
- } catch (error) {
30
- return {
31
- backend: "http",
32
- durationMs: Date.now() - startedAt,
33
- error: error instanceof Error ? error.message : String(error),
34
- ok: false,
35
- url
36
- };
37
- } finally {
38
- clearTimeout(timer);
39
- }
40
- };
41
- const probeReapi = async (options, timeoutMs) => {
42
- const startedAt = Date.now();
43
- const cache = new ReapiRemoteCache({ ...options, timeout: timeoutMs });
44
- try {
45
- const capabilities = await cache.probeCapabilities();
46
- return {
47
- backend: "reapi",
48
- capabilities,
49
- durationMs: Date.now() - startedAt,
50
- ok: true,
51
- url: options.url
52
- };
53
- } catch (error) {
54
- return {
55
- backend: "reapi",
56
- durationMs: Date.now() - startedAt,
57
- error: error instanceof Error ? error.message : String(error),
58
- ok: false,
59
- url: options.url
60
- };
61
- } finally {
62
- try {
63
- await cache.close();
64
- } catch {
65
- }
66
- }
67
- };
68
- const formatTable = (result) => {
69
- const lines = [];
70
- const status = result.ok ? green("OK") : red("FAIL");
71
- lines.push(`${bold("Remote cache")} ${status}`);
72
- lines.push(` ${dim("URL:")} ${cyan(result.url)}`);
73
- lines.push(` ${dim("Backend:")} ${result.backend}`);
74
- lines.push(` ${dim("Latency:")} ${String(result.durationMs)}ms`);
75
- if (result.httpStatus !== void 0) {
76
- lines.push(` ${dim("Status:")} ${String(result.httpStatus)}`);
77
- }
78
- if (result.capabilities) {
79
- const digestFunctions = result.capabilities.digestFunctions.length > 0 ? result.capabilities.digestFunctions.join(", ") : yellow("(none advertised)");
80
- lines.push(` ${dim("Digests:")} ${digestFunctions}`);
81
- lines.push(` ${dim("Batch:")} ${String(result.capabilities.maxBatchTotalSizeBytes)} bytes`);
82
- }
83
- if (result.error) {
84
- lines.push(` ${dim("Error:")} ${red(result.error)}`);
85
- }
86
- return lines.join("\n");
87
- };
88
- const cacheDoctorExecute = async ({ logger, options, visConfig }) => {
89
- const cfg = visConfig ?? {};
90
- const configRemoteCache = cfg.taskRunnerOptions?.remoteCache;
91
- const cliUrl = options.url;
92
- const url = cliUrl ?? configRemoteCache?.url;
93
- const format = options.format ?? "table";
94
- const timeoutMs = options.timeout ?? 5e3;
95
- if (!url) {
96
- pail.error("No remote cache configured. Set taskRunnerOptions.remoteCache.url in vis.config.ts or pass --url=...");
97
- process.exitCode = 1;
98
- return;
99
- }
100
- const backend = inferBackend(url, options.backend);
101
- const result = backend === "reapi" ? await probeReapi({ ...configRemoteCache ?? { url }, backend: "reapi", url }, timeoutMs) : await probeHttp(url, timeoutMs);
102
- if (format === "json") {
103
- logger.log(JSON.stringify(result, null, 2));
104
- } else {
105
- logger.log(formatTable(result));
106
- }
107
- if (!result.ok) {
108
- process.exitCode = 1;
109
- }
110
- };
111
-
112
- export { cacheDoctorExecute };
1
+ var h=Object.defineProperty;var p=(e,t)=>h(e,"name",{value:t,configurable:!0});import{green as d,red as l,bold as g,dim as n,cyan as m,yellow as b}from"@visulima/colorize";import{ReapiRemoteCache as f}from"@visulima/task-runner";import{p as k}from"./bin.js";var $=Object.defineProperty,s=p((e,t)=>$(e,"name",{value:t,configurable:!0}),"s");const w=s((e,t)=>t==="http"||t==="reapi"?t:e.startsWith("grpc://")||e.startsWith("grpcs://")?"reapi":"http","inferBackend"),y=s(async(e,t)=>{const o=Date.now(),a=new AbortController,r=setTimeout(()=>{a.abort()},t);try{const i=await fetch(e,{method:"HEAD",signal:a.signal});return{backend:"http",durationMs:Date.now()-o,httpStatus:i.status,ok:!0,url:e}}catch(i){return{backend:"http",durationMs:Date.now()-o,error:i instanceof Error?i.message:String(i),ok:!1,url:e}}finally{clearTimeout(r)}},"probeHttp"),S=s(async(e,t)=>{const o=Date.now(),a=new f({...e,timeout:t});try{return{backend:"reapi",capabilities:await a.probeCapabilities(),durationMs:Date.now()-o,ok:!0,url:e.url}}catch(r){return{backend:"reapi",durationMs:Date.now()-o,error:r instanceof Error?r.message:String(r),ok:!1,url:e.url}}finally{try{await a.close()}catch{}}},"probeReapi"),D=s(e=>{const t=[],o=e.ok?d("OK"):l("FAIL");if(t.push(`${g("Remote cache")} ${o}`),t.push(` ${n("URL:")} ${m(e.url)}`),t.push(` ${n("Backend:")} ${e.backend}`),t.push(` ${n("Latency:")} ${String(e.durationMs)}ms`),e.httpStatus!==void 0&&t.push(` ${n("Status:")} ${String(e.httpStatus)}`),e.capabilities){const a=e.capabilities.digestFunctions.length>0?e.capabilities.digestFunctions.join(", "):b("(none advertised)");t.push(` ${n("Digests:")} ${a}`),t.push(` ${n("Batch:")} ${String(e.capabilities.maxBatchTotalSizeBytes)} bytes`)}return e.error&&t.push(` ${n("Error:")} ${l(e.error)}`),t.join(`
2
+ `)},"formatTable"),E=s(async({logger:e,options:t,visConfig:o})=>{const a=(o??{}).taskRunnerOptions?.remoteCache,r=t.url??a?.url,i=t.format??"table",u=t.timeout??5e3;if(!r){k.error("No remote cache configured. Set taskRunnerOptions.remoteCache.url in vis.config.ts or pass --url=..."),process.exitCode=1;return}const c=w(r,t.backend)==="reapi"?await S({...a??{url:r},backend:"reapi",url:r},u):await y(r,u);i==="json"?e.log(JSON.stringify(c,null,2)):e.log(D(c)),c.ok||(process.exitCode=1)},"cacheDoctorExecute");export{E as cacheDoctorExecute};
@@ -1,234 +1,11 @@
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
- createInterface
22
- } = __cjs_getBuiltinModule("node:readline");
23
- import { bold, dim, yellow, cyan, red, green } from '@visulima/colorize';
24
- import { relative } from '@visulima/path';
25
- import { a as aggregateFailureContext, r as runFixAnalysis, b as applyFixProposal, c as resolvePatchPath } from '../packem_shared/ai-fix-B9iQVcD2.js';
26
- import { p as pail } from './bin.js';
27
- import { l as listFailureLogs } from '../packem_shared/failure-log-Cz3Z4SKL.js';
28
-
29
- const PATCH_STATUS_LABEL = {
30
- "ambiguous-match": "ambiguous match",
31
- applied: "applied",
32
- error: "error",
33
- "missing-file": "missing file",
34
- "no-match": "no match",
35
- "outside-workspace": "outside workspace"
36
- };
37
- const formatDisplayPath = (workspaceRoot, cwd, file) => {
38
- const absolute = resolvePatchPath(workspaceRoot, cwd, file);
39
- const rel = relative(workspaceRoot, absolute);
40
- return rel === "" || rel.startsWith("..") ? absolute : rel;
41
- };
42
- const formatProposalText = (proposal, workspaceRoot, cwd) => {
43
- const lines = [];
44
- lines.push(bold(`Fix proposal (${proposal.provider}, confidence: ${proposal.confidence})`));
45
- lines.push("");
46
- lines.push(proposal.explanation || dim("<no explanation>"));
47
- if (proposal.cannotFix) {
48
- lines.push("");
49
- lines.push(yellow(`Cannot fix automatically: ${proposal.cannotFix}`));
50
- return lines.join("\n");
51
- }
52
- if (proposal.patches.length === 0) {
53
- lines.push("");
54
- lines.push(yellow("No patches were proposed."));
55
- return lines.join("\n");
56
- }
57
- lines.push("");
58
- lines.push(bold(`Patches (${String(proposal.patches.length)}):`));
59
- for (const [index, patch] of proposal.patches.entries()) {
60
- const displayPath = formatDisplayPath(workspaceRoot, cwd, patch.file);
61
- lines.push("");
62
- lines.push(cyan(`[${String(index + 1)}] ${displayPath}`));
63
- if (patch.reason) {
64
- lines.push(dim(` reason: ${patch.reason}`));
65
- }
66
- for (const line of patch.oldString.split("\n")) {
67
- lines.push(red(` - ${line}`));
68
- }
69
- for (const line of patch.newString.split("\n")) {
70
- lines.push(green(` + ${line}`));
71
- }
72
- }
73
- return lines.join("\n");
74
- };
75
- const formatPatchResultsText = (results, workspaceRoot, cwd) => {
76
- const lines = [];
77
- for (const result of results) {
78
- const displayPath = result.absolutePath ? relative(workspaceRoot, result.absolutePath) || result.absolutePath : formatDisplayPath(workspaceRoot, cwd, result.patch.file);
79
- const label = PATCH_STATUS_LABEL[result.status];
80
- if (result.status === "applied") {
81
- lines.push(green(` ✓ ${displayPath}: ${label}`));
82
- } else {
83
- lines.push(red(` ✗ ${displayPath}: ${label}${result.error ? ` (${result.error})` : ""}`));
84
- }
85
- }
86
- return lines.join("\n");
87
- };
88
- const summarizePatchResults = (results) => {
89
- let applied = 0;
90
- let failed = 0;
91
- for (const result of results) {
92
- if (result.status === "applied") {
93
- applied += 1;
94
- } else {
95
- failed += 1;
96
- }
97
- }
98
- return { applied, failed };
99
- };
100
- const confirmPrompt = (question) => new Promise((resolvePromise) => {
101
- const rl = createInterface({ input: process.stdin, output: process.stderr });
102
- rl.question(`${question} (y/N) `, (answer) => {
103
- rl.close();
104
- const trimmed = answer.trim().toLowerCase();
105
- resolvePromise(trimmed === "y" || trimmed === "yes");
106
- });
107
- });
108
- const resolveWorkspaceRoot = (workspaceRoot) => workspaceRoot ?? process.cwd();
109
- const aiFix = async ({ argument, logger, options, visConfig, workspaceRoot: wsRoot }) => {
110
- const taskId = argument[0];
111
- const workspaceRoot = resolveWorkspaceRoot(wsRoot);
112
- const format = options.format ?? "text";
113
- const isJson = format === "json";
114
- if (!taskId) {
115
- if (isJson) {
116
- const available = listFailureLogs(workspaceRoot);
117
- process.stdout.write(`${JSON.stringify({ availableTasks: available, error: "No task ID specified" }, void 0, 2)}
118
- `);
119
- } else {
120
- pail.error("No task ID specified. Usage: vis ai fix <project>:<target>");
121
- const available = listFailureLogs(workspaceRoot);
122
- if (available.length > 0) {
123
- pail.info("Tasks with captured failure logs:");
124
- for (const id of available) {
125
- pail.info(` - ${id}`);
126
- }
127
- } else {
128
- pail.notice("No failure logs found. Re-run a failing task with `vis run` to capture logs.");
129
- }
130
- }
131
- process.exitCode = 1;
132
- return;
133
- }
134
- const failureContext = await aggregateFailureContext(workspaceRoot, taskId, { runId: options.run });
135
- if (!failureContext) {
136
- if (isJson) {
137
- process.stdout.write(`${JSON.stringify({ error: "No failure log or run summary found", taskId }, void 0, 2)}
138
- `);
139
- } else {
140
- pail.error(`No failure log or run summary found for task "${taskId}".`);
141
- pail.notice("Re-run the task with `vis run` so its terminal output and run metadata are captured.");
142
- }
143
- process.exitCode = 1;
144
- return;
145
- }
146
- if (!failureContext.terminalOutputCaptured) {
147
- pail.warn(`No captured terminal output for "${taskId}". Re-run with \`vis run\` for a better fix proposal.`);
148
- }
149
- const aiConfig = visConfig?.ai;
150
- const proposal = await runFixAnalysis(failureContext, logger, {
151
- cache: options.noCache !== true,
152
- config: aiConfig
153
- });
154
- if (!proposal) {
155
- if (isJson) {
156
- process.stdout.write(`${JSON.stringify({ error: "AI fix proposal failed or no provider available", taskId }, void 0, 2)}
157
- `);
158
- }
159
- process.exitCode = 1;
160
- return;
161
- }
162
- const apply = options.apply === true;
163
- if (isJson) {
164
- const dryRunResults2 = apply ? void 0 : await applyFixProposal(workspaceRoot, failureContext.cwd, proposal, { dryRun: true });
165
- const appliedResults = apply ? await applyFixProposal(workspaceRoot, failureContext.cwd, proposal) : void 0;
166
- process.stdout.write(
167
- `${JSON.stringify(
168
- {
169
- appliedResults,
170
- dryRunResults: dryRunResults2,
171
- failureContext: {
172
- cwd: failureContext.cwd,
173
- hash: failureContext.hash,
174
- runId: failureContext.runId,
175
- taskId: failureContext.taskId,
176
- terminalOutputCaptured: failureContext.terminalOutputCaptured
177
- },
178
- proposal
179
- },
180
- void 0,
181
- 2
182
- )}
183
- `
184
- );
185
- if (apply && appliedResults) {
186
- const { failed } = summarizePatchResults(appliedResults);
187
- if (failed > 0) {
188
- process.exitCode = 1;
189
- }
190
- }
191
- return;
192
- }
193
- logger.info(formatProposalText(proposal, workspaceRoot, failureContext.cwd));
194
- if (proposal.cannotFix || proposal.patches.length === 0) {
195
- return;
196
- }
197
- const dryRunResults = await applyFixProposal(workspaceRoot, failureContext.cwd, proposal, { dryRun: true });
198
- const dryRunSummary = summarizePatchResults(dryRunResults);
199
- logger.info("");
200
- logger.info(bold("Patch validation:"));
201
- logger.info(formatPatchResultsText(dryRunResults, workspaceRoot, failureContext.cwd));
202
- if (!apply) {
203
- logger.info("");
204
- pail.info("Re-run with --apply to write these patches to disk.");
205
- return;
206
- }
207
- if (dryRunSummary.applied === 0) {
208
- pail.error("No patches can be applied (every patch failed validation).");
209
- process.exitCode = 1;
210
- return;
211
- }
212
- if (options.yes !== true) {
213
- logger.info("");
214
- const confirmed = await confirmPrompt(`Apply ${String(dryRunSummary.applied)} patch${dryRunSummary.applied === 1 ? "" : "es"} to disk?`);
215
- if (!confirmed) {
216
- pail.notice("Aborted. Nothing written.");
217
- return;
218
- }
219
- }
220
- const applyResults = await applyFixProposal(workspaceRoot, failureContext.cwd, proposal);
221
- const applySummary = summarizePatchResults(applyResults);
222
- logger.info("");
223
- logger.info(bold("Apply results:"));
224
- logger.info(formatPatchResultsText(applyResults, workspaceRoot, failureContext.cwd));
225
- logger.info("");
226
- if (applySummary.failed === 0) {
227
- pail.success(`Applied ${String(applySummary.applied)} patch${applySummary.applied === 1 ? "" : "es"}.`);
228
- } else {
229
- pail.warn(`${String(applySummary.applied)} applied, ${String(applySummary.failed)} failed.`);
230
- process.exitCode = 1;
231
- }
232
- };
233
-
234
- export { aiFix };
1
+ var T=Object.defineProperty;var v=(e,t)=>T(e,"name",{value:t,configurable:!0});import{createRequire as A}from"node:module";import{bold as y,dim as P,yellow as C,cyan as W,red as S,green as _}from"@visulima/colorize";import{relative as j}from"@visulima/path";import{r as B,a as L,b as M,c as w}from"../packem_shared/ai-fix-nn4zOE95.js";import{p}from"./bin.js";import{l as N}from"../packem_shared/failure-log-iUVLf6ts.js";const q=A(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,J=v(e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,r]=m.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return m.getBuiltinModule(e)}return q(e)},"__cjs_getBuiltinModule"),{createInterface:D}=J("node:readline");var U=Object.defineProperty,l=v((e,t)=>U(e,"name",{value:t,configurable:!0}),"c");const z={"ambiguous-match":"ambiguous match",applied:"applied",error:"error","missing-file":"missing file","no-match":"no match","outside-workspace":"outside workspace"},I=l((e,t,r)=>{const o=B(e,t,r),s=j(e,o);return s===""||s.startsWith("..")?o:s},"formatDisplayPath"),E=l((e,t,r)=>{const o=[y(`Fix proposal (${e.provider}, confidence: ${e.confidence})`),"",e.explanation||P("<no explanation>")];if(e.cannotFix)return o.push(""),o.push(C(`Cannot fix automatically: ${e.cannotFix}`)),o.join(`
2
+ `);if(e.patches.length===0)return o.push(""),o.push(C("No patches were proposed.")),o.join(`
3
+ `);o.push(""),o.push(y(`Patches (${String(e.patches.length)}):`));for(const[s,i]of e.patches.entries()){const a=I(t,r,i.file);o.push(""),o.push(W(`[${String(s+1)}] ${a}`)),i.reason&&o.push(P(` reason: ${i.reason}`));for(const c of i.oldString.split(`
4
+ `))o.push(S(` - ${c}`));for(const c of i.newString.split(`
5
+ `))o.push(_(` + ${c}`))}return o.join(`
6
+ `)},"formatProposalText"),R=l((e,t,r)=>{const o=[];for(const s of e){const i=s.absolutePath?j(t,s.absolutePath)||s.absolutePath:I(t,r,s.patch.file),a=z[s.status];s.status==="applied"?o.push(_(` ✓ ${i}: ${a}`)):o.push(S(` ✗ ${i}: ${a}${s.error?` (${s.error})`:""}`))}return o.join(`
7
+ `)},"formatPatchResultsText"),x=l(e=>{let t=0,r=0;for(const o of e)o.status==="applied"?t+=1:r+=1;return{applied:t,failed:r}},"summarizePatchResults"),G=l(e=>new Promise(t=>{const r=D({input:process.stdin,output:process.stderr});r.question(`${e} (y/N) `,o=>{r.close();const s=o.trim().toLowerCase();t(s==="y"||s==="yes")})}),"confirmPrompt"),H=l(e=>e??process.cwd(),"resolveWorkspaceRoot"),et=l(async({argument:e,logger:t,options:r,visConfig:o,workspaceRoot:s})=>{const i=e[0],a=H(s),c=(r.format??"text")==="json";if(!i){if(c){const d=N(a);process.stdout.write(`${JSON.stringify({availableTasks:d,error:"No task ID specified"},void 0,2)}
8
+ `)}else{p.error("No task ID specified. Usage: vis ai fix <project>:<target>");const d=N(a);if(d.length>0){p.info("Tasks with captured failure logs:");for(const h of d)p.info(` - ${h}`)}else p.notice("No failure logs found. Re-run a failing task with `vis run` to capture logs.")}process.exitCode=1;return}const n=await L(a,i,{runId:r.run});if(!n){c?process.stdout.write(`${JSON.stringify({error:"No failure log or run summary found",taskId:i},void 0,2)}
9
+ `):(p.error(`No failure log or run summary found for task "${i}".`),p.notice("Re-run the task with `vis run` so its terminal output and run metadata are captured.")),process.exitCode=1;return}n.terminalOutputCaptured||p.warn(`No captured terminal output for "${i}". Re-run with \`vis run\` for a better fix proposal.`);const F=o?.ai,u=await M(n,t,{cache:r.noCache!==!0,config:F});if(!u){c&&process.stdout.write(`${JSON.stringify({error:"AI fix proposal failed or no provider available",taskId:i},void 0,2)}
10
+ `),process.exitCode=1;return}const g=r.apply===!0;if(c){const d=g?void 0:await w(a,n.cwd,u,{dryRun:!0}),h=g?await w(a,n.cwd,u):void 0;if(process.stdout.write(`${JSON.stringify({appliedResults:h,dryRunResults:d,failureContext:{cwd:n.cwd,hash:n.hash,runId:n.runId,taskId:n.taskId,terminalOutputCaptured:n.terminalOutputCaptured},proposal:u},void 0,2)}
11
+ `),g&&h){const{failed:O}=x(h);O>0&&(process.exitCode=1)}return}if(t.info(E(u,a,n.cwd)),u.cannotFix||u.patches.length===0)return;const b=await w(a,n.cwd,u,{dryRun:!0}),$=x(b);if(t.info(""),t.info(y("Patch validation:")),t.info(R(b,a,n.cwd)),!g){t.info(""),p.info("Re-run with --apply to write these patches to disk.");return}if($.applied===0){p.error("No patches can be applied (every patch failed validation)."),process.exitCode=1;return}if(r.yes!==!0&&(t.info(""),!await G(`Apply ${String($.applied)} patch${$.applied===1?"":"es"} to disk?`))){p.notice("Aborted. Nothing written.");return}const k=await w(a,n.cwd,u),f=x(k);t.info(""),t.info(y("Apply results:")),t.info(R(k,a,n.cwd)),t.info(""),f.failed===0?p.success(`Applied ${String(f.applied)} patch${f.applied===1?"":"es"}.`):(p.warn(`${String(f.applied)} applied, ${String(f.failed)} failed.`),process.exitCode=1)},"aiFix");export{et as aiFix};
@@ -1,99 +1 @@
1
- import { createTaskGraph } from '@visulima/task-runner';
2
- import { d as discoverWorkspace, b as buildProjectGraph } from './bin.js';
3
- import { r as resolveSelector, f as filterProjectsByQuery } from '../packem_shared/selectors-SM69TfqC.js';
4
-
5
- const renderPlan = (roots, dependencies, tasks) => {
6
- const lines = [];
7
- const visited = /* @__PURE__ */ new Set();
8
- const walk = (id, depth) => {
9
- if (visited.has(id)) {
10
- return;
11
- }
12
- visited.add(id);
13
- const deps = dependencies[id] ?? [];
14
- for (const dep of deps) {
15
- walk(dep, depth + 1);
16
- }
17
- const task = tasks[id];
18
- const indent = " ".repeat(depth);
19
- lines.push(`${indent}${id}${task?.cache === false ? " (no-cache)" : ""}`);
20
- };
21
- for (const root of roots) {
22
- walk(root, 0);
23
- }
24
- return lines;
25
- };
26
- const toJson = (roots, dependencies, tasks) => {
27
- return {
28
- roots,
29
- tasks: Object.fromEntries(
30
- Object.entries(tasks).map(([id, task]) => [
31
- id,
32
- {
33
- cache: task.cache,
34
- dependsOn: dependencies[id] ?? [],
35
- outputs: task.outputs,
36
- parallelism: task.parallelism,
37
- projectRoot: task.projectRoot,
38
- target: task.target
39
- }
40
- ])
41
- )
42
- };
43
- };
44
- const execute = async ({ argument, logger, options, visConfig, workspaceRoot: wsRoot }) => {
45
- const rawSelector = argument[0];
46
- if (!rawSelector) {
47
- throw new Error("Missing selector. Usage: vis action-graph <selector>");
48
- }
49
- if (!wsRoot) {
50
- throw new Error("Could not determine workspace root. Run inside a monorepo.");
51
- }
52
- const { config, packageJsons, workspace } = discoverWorkspace(wsRoot, visConfig);
53
- const projectGraph = buildProjectGraph(wsRoot, workspace, packageJsons);
54
- const selectorResult = await resolveSelector(rawSelector, workspace, process.cwd(), wsRoot);
55
- const { target } = selectorResult;
56
- let projectNames = selectorResult.projects;
57
- if (options.query) {
58
- projectNames = filterProjectsByQuery(projectNames, workspace, options.query);
59
- }
60
- const candidates = projectNames.filter((name) => {
61
- const project = workspace.projects[name];
62
- return project?.targets?.[target] !== void 0;
63
- });
64
- if (candidates.length === 0) {
65
- logger.info(`No projects have a "${target}" target.`);
66
- return;
67
- }
68
- const initialTasks = candidates.map((projectName) => {
69
- const project = workspace.projects[projectName];
70
- const targetConfig = project.targets?.[target];
71
- const taskTarget = { project: projectName, target };
72
- return {
73
- cache: targetConfig?.cache,
74
- id: `${projectName}:${target}`,
75
- outputs: targetConfig?.outputs ?? [],
76
- overrides: { command: targetConfig?.command },
77
- parallelism: targetConfig?.parallelism,
78
- projectRoot: project.root,
79
- target: taskTarget
80
- };
81
- });
82
- const taskGraph = createTaskGraph(initialTasks, {
83
- projectGraph,
84
- targetDefaults: config.targetDefaults,
85
- workspace
86
- });
87
- if (options.json) {
88
- logger.info(JSON.stringify(toJson(taskGraph.roots, taskGraph.dependencies, taskGraph.tasks), null, 2));
89
- return;
90
- }
91
- const lines = renderPlan(taskGraph.roots, taskGraph.dependencies, taskGraph.tasks);
92
- logger.info(`Execution plan (${Object.keys(taskGraph.tasks).length} task(s), ${taskGraph.roots.length} root(s)):`);
93
- logger.info("");
94
- for (const line of lines) {
95
- logger.info(line);
96
- }
97
- };
98
-
99
- export { execute as default };
1
+ var O=Object.defineProperty;var w=(o,e)=>O(o,"name",{value:e,configurable:!0});import{createTaskGraph as b}from"@visulima/task-runner";import{k as E,y as R}from"./bin.js";import{r as x,f as G}from"../packem_shared/selectors-BylODRiM.js";var J=Object.defineProperty,m=w((o,e)=>J(o,"name",{value:e,configurable:!0}),"u");const P=m((o,e,n)=>{const c=[],t=new Set,l=m((r,f)=>{if(t.has(r))return;t.add(r);const s=e[r]??[];for(const i of s)l(i,f+1);const d=n[r],u=" ".repeat(f);c.push(`${u}${r}${d?.cache===!1?" (no-cache)":""}`)},"walk");for(const r of o)l(r,0);return c},"renderPlan"),S=m((o,e,n)=>({roots:o,tasks:Object.fromEntries(Object.entries(n).map(([c,t])=>[c,{cache:t.cache,dependsOn:e[c]??[],outputs:t.outputs,parallelism:t.parallelism,projectRoot:t.projectRoot,target:t.target}]))}),"toJson"),T=m(async({argument:o,logger:e,options:n,visConfig:c,workspaceRoot:t})=>{const l=o[0];if(!l)throw new Error("Missing selector. Usage: vis action-graph <selector>");if(!t)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{config:r,packageJsons:f,workspace:s}=E(t,c),d=R(t,s,f),u=await x(l,s,process.cwd(),t),{target:i}=u;let h=u.projects;n.query&&(h=G(h,s,n.query));const j=h.filter(p=>s.projects[p]?.targets?.[i]!==void 0);if(j.length===0){e.info(`No projects have a "${i}" target.`);return}const y=j.map(p=>{const k=s.projects[p],g=k.targets?.[i],$={project:p,target:i};return{cache:g?.cache,id:`${p}:${i}`,outputs:g?.outputs??[],overrides:{command:g?.command},parallelism:g?.parallelism,projectRoot:k.root,target:$}}),a=b(y,{projectGraph:d,targetDefaults:r.targetDefaults,workspace:s});if(n.json){e.info(JSON.stringify(S(a.roots,a.dependencies,a.tasks),null,2));return}const v=P(a.roots,a.dependencies,a.tasks);e.info(`Execution plan (${Object.keys(a.tasks).length} task(s), ${a.roots.length} root(s)):`),e.info("");for(const p of v)e.info(p)},"execute");export{T as default};
@@ -1,53 +1,2 @@
1
- import { join } from '@visulima/path';
2
- import { d as discoverWorkspace, b as buildProjectGraph } from './bin.js';
3
- import { s as scaffoldDockerContext, p as pruneDockerContext } from '../packem_shared/docker-2iZzc280.js';
4
-
5
- const execute = async ({ argument, logger, options, visConfig, workspaceRoot: wsRoot }) => {
6
- const subcommand = argument[0];
7
- if (!subcommand) {
8
- throw new Error("Missing subcommand. Usage: vis docker <scaffold|prune>");
9
- }
10
- if (!wsRoot) {
11
- throw new Error("Could not determine workspace root. Run inside a monorepo.");
12
- }
13
- const { packageJsons, workspace } = discoverWorkspace(wsRoot, visConfig);
14
- if (subcommand === "scaffold") {
15
- const projectGraph = buildProjectGraph(wsRoot, workspace, packageJsons);
16
- const focusRaw = options.focus;
17
- if (!focusRaw) {
18
- throw new Error("Missing --focus. Pass one or more project names, comma-separated.");
19
- }
20
- const focus = focusRaw.split(",").map((name) => name.trim()).filter(Boolean);
21
- if (focus.length === 0) {
22
- throw new Error("--focus resolved to an empty list. Provide at least one project name.");
23
- }
24
- const outDir = join(wsRoot, options.out ?? ".vis/docker");
25
- const { projects } = scaffoldDockerContext({
26
- focus,
27
- includeSources: Boolean(options.includeSources),
28
- outDir,
29
- projectGraph,
30
- workspace,
31
- workspaceRoot: wsRoot
32
- });
33
- logger.info(`Scaffolded ${projects.length} project(s) into ${outDir}`);
34
- logger.info(`Focus closure: ${projects.sort().join(", ")}`);
35
- return;
36
- }
37
- if (subcommand === "prune") {
38
- const contextRoot = join(wsRoot, options.context ?? ".vis/docker");
39
- const { removed } = pruneDockerContext({
40
- contextRoot,
41
- workspace,
42
- workspaceRoot: wsRoot
43
- });
44
- logger.info(`Pruned ${removed.length} unfocused project(s)`);
45
- if (removed.length > 0) {
46
- logger.debug?.(removed.join("\n"));
47
- }
48
- return;
49
- }
50
- throw new Error(`Unknown subcommand: "${subcommand}". Expected scaffold or prune.`);
51
- };
52
-
53
- export { execute as default };
1
+ var k=Object.defineProperty;var p=(t,o)=>k(t,"name",{value:o,configurable:!0});import{join as d}from"@visulima/path";import{k as g,y as v}from"./bin.js";import{s as h,p as j}from"../packem_shared/docker-D6OGr5_S.js";var x=Object.defineProperty,E=p((t,o)=>x(t,"name",{value:o,configurable:!0}),"f");const C=E(async({argument:t,logger:o,options:s,visConfig:l,workspaceRoot:e})=>{const n=t[0];if(!n)throw new Error("Missing subcommand. Usage: vis docker <scaffold|prune>");if(!e)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{packageJsons:m,workspace:c}=g(e,l);if(n==="scaffold"){const a=v(e,c,m),r=s.focus;if(!r)throw new Error("Missing --focus. Pass one or more project names, comma-separated.");const i=r.split(",").map(w=>w.trim()).filter(Boolean);if(i.length===0)throw new Error("--focus resolved to an empty list. Provide at least one project name.");const f=d(e,s.out??".vis/docker"),{projects:u}=h({focus:i,includeSources:!!s.includeSources,outDir:f,projectGraph:a,workspace:c,workspaceRoot:e});o.info(`Scaffolded ${u.length} project(s) into ${f}`),o.info(`Focus closure: ${u.toSorted().join(", ")}`);return}if(n==="prune"){const a=d(e,s.context??".vis/docker"),{removed:r}=j({contextRoot:a,workspace:c,workspaceRoot:e});o.info(`Pruned ${r.length} unfocused project(s)`),r.length>0&&o.debug?.(r.join(`
2
+ `));return}throw new Error(`Unknown subcommand: "${n}". Expected scaffold or prune.`)},"execute");export{C as default};
@@ -1,32 +1 @@
1
- import { r as resolveInstaller, m as runExec } 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 args = argument;
6
- if (!args || args.length === 0) {
7
- throw new Error("No command specified. Usage: vis exec <command> [args...]");
8
- }
9
- const [command, ...rest] = args;
10
- const cwd = wsRoot ?? process.cwd();
11
- const pm = resolveInstaller(cwd, { configBackend: visConfig?.install?.backend });
12
- const code = runExec(
13
- pm,
14
- {
15
- args: rest,
16
- command,
17
- filter: toStringArray(options.filter),
18
- parallel: options.parallel || false,
19
- recursive: options.recursive || false,
20
- reverse: options.reverse || false,
21
- shellMode: options.shellMode || false,
22
- workspaceRoot: options.workspaceRoot || false
23
- },
24
- cwd,
25
- logger
26
- );
27
- if (code !== 0) {
28
- process.exitCode = code;
29
- }
30
- };
31
-
32
- export { execute as default };
1
+ var m=Object.defineProperty;var t=(o,r)=>m(o,"name",{value:r,configurable:!0});import{m as d,P as g}from"./bin.js";import{o as u}from"../packem_shared/utils-DrNg0XTR.js";var v=Object.defineProperty,k=t((o,r)=>v(o,"name",{value:r,configurable:!0}),"t");const b=k(async({argument:o,logger:r,options:e,visConfig:s,workspaceRoot:n})=>{const a=o;if(!a||a.length===0)throw new Error("No command specified. Usage: vis exec <command> [args...]");const[i,...f]=a,l=n??process.cwd(),p=d(l,{configBackend:s?.install?.backend,configCorepack:s?.install?.corepack}),c=g(p,{args:f,command:i,filter:u(e.filter),parallel:e.parallel||!1,recursive:e.recursive||!1,reverse:e.reverse||!1,shellMode:e.shellMode||!1,workspaceRoot:e.workspaceRoot||!1},l,r);c!==0&&(process.exitCode=c)},"execute");export{b as default};