@visulima/vis 3.0.1 → 3.0.3
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/CHANGELOG.md +23 -0
- package/LICENSE.md +33 -22
- package/dashboard/dist/index.html +12 -12
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/packem_chunks/CONFIG_FILES.js +1 -1
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog.js +2 -2
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +168 -170
- package/dist/packem_chunks/doctor-probe.js +2 -2
- package/dist/packem_chunks/fix.js +5 -5
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler26.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler50.js +4 -4
- package/dist/packem_chunks/handler53.js +1 -1
- package/dist/packem_chunks/handler54.js +1 -1
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler58.js +1 -1
- package/dist/packem_chunks/handler59.js +1 -1
- package/dist/packem_chunks/handler6.js +5 -5
- package/dist/packem_chunks/handler60.js +1 -1
- package/dist/packem_chunks/handler61.js +7 -7
- package/dist/packem_chunks/handler62.js +1 -1
- package/dist/packem_chunks/handler63.js +1 -1
- package/dist/packem_chunks/handler64.js +2 -2
- package/dist/packem_chunks/handler65.js +2 -2
- package/dist/packem_chunks/handler66.js +1 -1
- package/dist/packem_chunks/handler67.js +25 -24
- package/dist/packem_chunks/handler68.js +153 -25
- package/dist/packem_chunks/handler69.js +10 -153
- package/dist/packem_chunks/handler70.js +22 -10
- package/dist/packem_chunks/handler71.js +4 -4
- package/dist/packem_chunks/handler72.js +3 -3
- package/dist/packem_chunks/handler73.js +6 -6
- package/dist/packem_chunks/handler74.js +1 -1
- package/dist/packem_chunks/handler75.js +1 -1
- package/dist/packem_chunks/handler76.js +1 -1
- package/dist/packem_chunks/handler77.js +40 -40
- package/dist/packem_chunks/handler78.js +20 -20
- package/dist/packem_chunks/heal.js +4 -4
- package/dist/packem_chunks/help-command.js +5 -5
- package/dist/packem_chunks/index4.js +6 -8
- package/dist/packem_chunks/index6.js +5 -5
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/prompts.js +1 -1
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/run.js +1 -1
- package/dist/packem_chunks/shell-runner.js +1 -1
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/tar.js +3 -3
- package/dist/packem_shared/{advisories-CyDqzi5j.js → advisories-0ScpWAHV.js} +1 -1
- package/dist/packem_shared/{affected-selection-DPQR-Bd3.js → affected-selection-BMoQWuHl.js} +1 -1
- package/dist/packem_shared/{ai-fix-6nXZbecQ.js → ai-fix-CKN1JGRh.js} +1 -1
- package/dist/packem_shared/{bin-wafzkjaB.js → bin-CN4heKmb.js} +1 -1
- package/dist/packem_shared/{cyclonedx-C_ezHg8b.js → cyclonedx-B1vzerwP.js} +1 -1
- package/dist/packem_shared/{docker-Br_iFmI-.js → docker-Bex05Qcn.js} +16 -16
- package/dist/packem_shared/giget-D8Kwb0kD.js +2 -0
- package/dist/packem_shared/index.server-BAjDJSEu.js +2 -0
- package/dist/packem_shared/main-BP-w-K-6.js +1 -0
- package/dist/packem_shared/{osv-bloom-5wDAoZ1e.js → osv-bloom-JYIWcH3F.js} +1 -1
- package/dist/packem_shared/{package-version-BJkg7-6H.js → package-version-CJxZ_B7G.js} +3 -3
- package/dist/packem_shared/{project-name-filter-BeREbPMI.js → project-name-filter-DsrVo0MY.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-COmP7eqr.js → resolve-explicit-DYaHAVDg.js} +1 -1
- package/dist/packem_shared/{s1ngularity-RZOHbGrE.js → s1ngularity-C8sva2SO.js} +1 -1
- package/dist/packem_shared/{scan-progress-C9nMDLis.js → scan-progress-5uTRdC1G.js} +2 -2
- package/dist/packem_shared/{spinner-CbJfWYwB.js → spinner-BM_0Bj6x.js} +1 -1
- package/dist/packem_shared/{tabs-BilwonkM.js → tabs-UDYQ3tqt.js} +1 -1
- package/dist/packem_shared/target-merge-B4No-LHM.js +4 -0
- package/dist/packem_shared/{typosquats-D8ppc5kr.js → typosquats-Cdsnf6aN.js} +1 -1
- package/dist/packem_shared/{vis-update-app-ngwL2mRv.js → vis-update-app-zqSa2clT.js} +1 -1
- package/dist/packem_shared/{vis-user-error-jhNwmkZp.js → vis-user-error-Dkc97rGY.js} +1 -1
- package/index.js +26 -26
- package/package.json +14 -14
- package/dist/packem_shared/giget-CVyyR7x8.js +0 -2
- package/dist/packem_shared/index.server-CwSgbeN7.js +0 -2
- package/dist/packem_shared/main-BjJN8kWj.js +0 -1
- package/dist/packem_shared/target-merge-D1xbylFw.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as E}from"node:module";import{
|
|
1
|
+
import{createRequire as E}from"node:module";import{b as U,j as x,F as g,X as A,J as L}from"../packem_shared/index.server-BAjDJSEu.js";import{a as O}from"../packem_shared/index-DHD8wb6Z.js";import{readLastRunSummary as G}from"@visulima/task-runner";import{a as j,r as F,b as D,c as K}from"../packem_shared/ai-fix-CKN1JGRh.js";import{p,f as H}from"./cli-main.js";let B;const P=e=>(B??=E(import.meta.url))(e),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,o]=m.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return m.getBuiltinModule(e)}return P(e)},{spawn:h}=I("node:child_process"),{readFile:M}=I("node:fs/promises"),V=e=>{if(!e)return;const t=/^refs\/pull\/(\d+)\//.exec(e);return t?Number.parseInt(t[1],10):void 0},J=async e=>{if(!e)return{prNumber:void 0,sha:void 0};try{const t=await M(e,"utf8"),o=JSON.parse(t),r=o.pull_request?.number??o.issue?.number??o.number,s=o.pull_request?.head?.sha;return{prNumber:r,sha:s}}catch{return{prNumber:void 0,sha:void 0}}},q=async e=>{const t=V(e.GITHUB_REF),{prNumber:o,sha:r}=t===void 0?await J(e.GITHUB_EVENT_PATH):{prNumber:t,sha:void 0};return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:t??o,provider:"github-actions",repo:e.GITHUB_REPOSITORY,sha:r??e.GITHUB_SHA,token:e.GITHUB_TOKEN}},z=e=>{const t=e.CI_MERGE_REQUEST_IID,o=t!==void 0&&t!==""?Number.parseInt(t,10):void 0,r=e.CI_API_V4_URL,s=e.GITLAB_TOKEN??e.CI_TOKEN;return{apiBaseUrl:r,buildId:void 0,buildNumber:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"gitlab-ci",repo:e.CI_PROJECT_ID??e.CI_PROJECT_PATH,sha:e.CI_COMMIT_SHA,token:s}},X=e=>{const t=e.BUILDKITE_PULL_REQUEST,o=t!==void 0&&t!==""&&t!=="false"?Number.parseInt(t,10):void 0,r=e.BUILDKITE_BUILD_NUMBER,s=r!==void 0&&r!==""?Number.parseInt(r,10):void 0,n=e.BUILDKITE_ORGANIZATION_SLUG,i=e.BUILDKITE_PIPELINE_SLUG,a=n!==void 0&&n!==""&&i!==void 0&&i!==""?`${n}/${i}`:void 0;return{apiBaseUrl:(e.BUILDKITE_API_BASE_URL??"https://api.buildkite.com").replace(/\/+$/,""),buildId:e.BUILDKITE_BUILD_ID,buildNumber:Number.isFinite(s)?s:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"buildkite",repo:a,sha:e.BUILDKITE_COMMIT,token:e.BUILDKITE_API_TOKEN}},Y=async(e=process.env)=>e.GITHUB_ACTIONS==="true"?await q(e):e.GITLAB_CI==="true"?z(e):e.BUILDKITE==="true"?X(e):{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:void 0,provider:"unknown",repo:void 0,sha:void 0,token:void 0},Q=(e,t,o,r)=>new Promise(s=>{const n=["pr","comment",String(t),"--body-file","-"];r&&n.push("--repo",r);const i=h(e,n,{stdio:["pipe","ignore","pipe"]});let a="";i.stderr?.setEncoding("utf8"),i.stderr?.on("data",d=>{a+=d}),i.once("error",()=>{s({exitCode:127,stderr:a})}),i.once("close",d=>{s({exitCode:d??-1,stderr:a})}),i.stdin?.on("error",()=>{}),i.stdin?.end(o)}),Z=async(e,t,o,r,s)=>{const n=`https://api.github.com/repos/${t}/issues/${String(o)}/comments`;try{const i=await e(n,{body:JSON.stringify({body:r}),headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${s}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"},method:"POST"});if(!i.ok){const a=await i.text().catch(()=>"");return{error:`GitHub REST returned ${String(i.status)}: ${a.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(i){return{error:i instanceof Error?i.message:String(i),ok:!1}}},W=async(e,t,o,r,s,n)=>{const i=encodeURIComponent(o),a=`${t.replace(/\/+$/,"")}/projects/${i}/merge_requests/${String(r)}/notes`;try{const d=await e(a,{body:JSON.stringify({body:s}),headers:{"Content-Type":"application/json","PRIVATE-TOKEN":n},method:"POST"});if(!d.ok){const c=await d.text().catch(()=>"");return{error:`GitLab REST returned ${String(d.status)}: ${c.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(d){return{error:d instanceof Error?d.message:String(d),ok:!1}}},tt=(e,t,o,r)=>new Promise(s=>{const i=h(e,["annotate","--style",o,"--context",r],{stdio:["pipe","ignore","pipe"]});let a="";i.stderr?.setEncoding("utf8"),i.stderr?.on("data",d=>{a+=d}),i.once("error",()=>{s({exitCode:127,stderr:a})}),i.once("close",d=>{s({exitCode:d??-1,stderr:a})}),i.stdin?.on("error",()=>{}),i.stdin?.end(t)}),et=async(e,t,o,r,s,n,i,a)=>{const[d,c]=o.split("/",2);if(!d||!c)return{error:`Buildkite repo identifier \`${o}\` is not in {org}/{pipeline} form.`,ok:!1};const f=`${t}/v2/organizations/${encodeURIComponent(d)}/pipelines/${encodeURIComponent(c)}/builds/${String(r)}/annotations`;try{const u=await e(f,{body:JSON.stringify({body:s,context:i,style:n}),headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},method:"POST"});if(!u.ok){const l=await u.text().catch(()=>"");return{error:`Buildkite REST returned ${String(u.status)}: ${l.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(u){return{error:u instanceof Error?u.message:String(u),ok:!1}}},ot=async(e,t,o,r)=>{const s=t.buildId?`vis-ai-heal-${t.buildId}`:"vis-ai-heal",n="info",i=await tt(o,e,n,s);if(i.exitCode===0)return{method:"buildkite-cli",posted:!0};if(!t.apiBaseUrl||!t.repo||t.buildNumber===void 0||!t.token){const d=[];return t.repo||d.push("BUILDKITE_ORGANIZATION_SLUG / BUILDKITE_PIPELINE_SLUG"),t.buildNumber===void 0&&d.push("BUILDKITE_BUILD_NUMBER"),t.token||d.push("BUILDKITE_API_TOKEN (with `write_build_annotations` scope)"),{error:`buildkite-agent annotate exited ${String(i.exitCode)} (${i.stderr.trim().slice(0,200)}); cannot fall back to REST without ${d.join(", ")}`,method:"buildkite-cli",posted:!1}}const a=await et(r,t.apiBaseUrl,t.repo,t.buildNumber,e,n,s,t.token);return a.ok?{method:"rest",posted:!0}:{error:`buildkite-agent annotate exited ${String(i.exitCode)}; REST fallback also failed: ${a.error??"unknown"}`,method:"rest",posted:!1}},rt=async(e,t,o,r)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};const s=await Q(o,t.prNumber,e,t.repo);if(s.exitCode===0)return{method:"gh-cli",posted:!0};if(!t.repo||!t.token)return{error:`gh exited ${String(s.exitCode)} (${s.stderr.trim().slice(0,200)}); cannot fall back to REST without GITHUB_REPOSITORY + GITHUB_TOKEN`,method:"gh-cli",posted:!1};const n=await Z(r,t.repo,t.prNumber,e,t.token);return n.ok?{method:"rest",posted:!0}:{error:`gh exited ${String(s.exitCode)}; REST fallback also failed: ${n.error??"unknown"}`,method:"rest",posted:!1}},it=async(e,t,o)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};if(!t.apiBaseUrl||!t.repo)return{error:"GitLab CI context is missing CI_API_V4_URL or CI_PROJECT_ID; cannot post note.",method:"rest",posted:!1};if(!t.token)return{error:"GitLab CI context has no token. CI_JOB_TOKEN cannot post MR notes — set GITLAB_TOKEN to a personal/project access token with `api` scope.",method:"rest",posted:!1};const r=await W(o,t.apiBaseUrl,t.repo,t.prNumber,e,t.token);return r.ok?{method:"rest",posted:!0}:{error:r.error,method:"rest",posted:!1}},nt=async e=>{const{body:t,buildkiteAgentBin:o="buildkite-agent",context:r,fetchImpl:s=globalThis.fetch,ghBin:n="gh"}=e;return r.provider==="github-actions"?await rt(t,r,n,s):r.provider==="gitlab-ci"?await it(t,r,s):r.provider==="buildkite"?await ot(t,r,o,s):{method:"skipped",posted:!1}},b=e=>{let t=0,o=0;for(const r of e)r.status==="applied"?t+=1:o+=1;return{applied:t,failed:o}},k=(e,t,o)=>{const r=K(e,t,o),s=O(e,r);return s===""||s.startsWith("..")?r:s},st=(e,t,o,r)=>new Promise(s=>{const n=process.argv[1];if(!n){s({exitCode:-1,stderr:"Cannot locate vis bin (process.argv[1] missing).",stdout:""});return}const i=[n,"run",o,"--projects",t,"--no-cache","--summarize","--fail-fast"],a=h(process.execPath,i,{cwd:e,env:{...process.env,NO_COLOR:"1"},stdio:["ignore","pipe","pipe"]});let d="",c="";const f=setTimeout(()=>{a.kill("SIGTERM"),setTimeout(()=>a.kill("SIGKILL"),2e3).unref()},r);a.stdout?.setEncoding("utf8"),a.stdout?.on("data",u=>{d+=u}),a.stderr?.setEncoding("utf8"),a.stderr?.on("data",u=>{c+=u}),a.once("error",u=>{clearTimeout(f),s({exitCode:-1,stderr:u.message,stdout:d})}),a.once("close",u=>{clearTimeout(f),s({exitCode:u??-1,stderr:c,stdout:d})})}),at=6e4,T=e=>{let t=0;const o=e.match(/`{3,}/g);if(o)for(const r of o)t=Math.max(t,r.length);return"`".repeat(Math.max(3,t+1))},_=(e,t,o)=>{if(e.patches.length===0)return"_No patches proposed._";const r=[];for(const[s,n]of e.patches.entries()){const i=k(t,o,n.file),a=[`**[${String(s+1)}] \`${i}\`**`];n.reason&&a.push(`_${n.reason}_`);const d=T(`${n.oldString}
|
|
2
2
|
${n.newString}`);a.push(`${d}diff`);for(const c of n.oldString.split(`
|
|
3
3
|
`))a.push(`- ${c}`);for(const c of n.newString.split(`
|
|
4
4
|
`))a.push(`+ ${c}`);a.push(d),r.push(a.join(`
|
|
@@ -6,9 +6,9 @@ ${n.newString}`);a.push(`${d}diff`);for(const c of n.oldString.split(`
|
|
|
6
6
|
|
|
7
7
|
`)},y=(e,t,o,r)=>{const s=["## vis ai heal — proposed fix","",`Failing task: \`${t.taskId}\` (provider: \`${e.provider}\`, confidence: \`${e.confidence}\`)`];r&&s.push(`Run anchored at \`${r.slice(0,7)}\`.`),s.push(""),s.push("### Root cause"),s.push(e.explanation||"_(no explanation)_"),s.push("");const n=["### Proposed patch",_(e,o,t.cwd),""],i=["### Validation",`Re-ran \`${t.taskId}\` after applying the patch on the CI runner — task **passed**.`,"","### Apply locally","```sh",`vis ai fix ${t.taskId} --apply`,"```","","---","","_Auto-generated by `vis ai heal`. Auto-commit is on the roadmap; for now the patch lives in this comment and is yours to accept or reject._"],a=[...s,...n,...i].join(`
|
|
8
8
|
`);if(Buffer.byteLength(a,"utf8")<=at)return a;const d=["### Proposed patch",`_Patch set is too large for a comment (${String(e.patches.length)} files). Run \`vis ai fix ${t.taskId} --apply\` locally to inspect and apply it._`,""];return[...s,...d,...i].join(`
|
|
9
|
-
`)},dt=(e,t,o)=>{const r=[x(`Proposal (${e.provider}, confidence: ${e.confidence})`),e.explanation||g("<no explanation>")];for(const[s,n]of e.patches.entries()){r.push(""),r.push(`[${String(s+1)}] ${
|
|
9
|
+
`)},dt=(e,t,o)=>{const r=[x(`Proposal (${e.provider}, confidence: ${e.confidence})`),e.explanation||g("<no explanation>")];for(const[s,n]of e.patches.entries()){r.push(""),r.push(`[${String(s+1)}] ${k(t,o,n.file)}`),n.reason&&r.push(g(` reason: ${n.reason}`));for(const i of n.oldString.split(`
|
|
10
10
|
`))r.push(A(` - ${i}`));for(const i of n.newString.split(`
|
|
11
11
|
`))r.push(L(` + ${i}`))}return r.join(`
|
|
12
|
-
`)},ct=async(e,t)=>{const o=t===void 0?await G(e):await H(e,t);if(o){for(const r of o.tasks)if(r.exitCode!==void 0&&r.exitCode!==0)return{project:r.target?.project,runId:o.id,target:r.target?.target,taskId:r.taskId}}},ut=1800*1e3,C=async(e,t)=>{const o=await ct(e,t);if(!o)return{outcome:"no-failed-task"};if(!o.project||!o.target)return{failedTask:o,outcome:"missing-metadata"};const r=await j(e,o.taskId,{runId:o.runId});return r?{failedTask:{project:o.project,runId:o.runId,target:o.target,taskId:o.taskId},failureContext:r,outcome:"ready"}:{failedTask:{project:o.project,runId:o.runId,target:o.target,taskId:o.taskId},outcome:"no-failure-context"}},$=async(e,t)=>{const{logger:o,options:r,visConfig:s,workspaceRoot:n}=e,i=n??process.cwd(),a=r.dryRun===!0,d=s?.ai,c=await F(t.failureContext,o,{cache:r.cache!==!1,config:d});if(!c)return{outcome:"no-proposal"};if(c.cannotFix)return{detail:c.cannotFix,outcome:"cannot-fix",proposal:c};if(c.patches.length===0)return{outcome:"empty-patches",proposal:c};if(a)return{outcome:"dry-run",proposal:c};const f=await D(i,t.failureContext.cwd,c);return
|
|
12
|
+
`)},ct=async(e,t)=>{const o=t===void 0?await G(e):await H(e,t);if(o){for(const r of o.tasks)if(r.exitCode!==void 0&&r.exitCode!==0)return{project:r.target?.project,runId:o.id,target:r.target?.target,taskId:r.taskId}}},ut=1800*1e3,C=async(e,t)=>{const o=await ct(e,t);if(!o)return{outcome:"no-failed-task"};if(!o.project||!o.target)return{failedTask:o,outcome:"missing-metadata"};const r=await j(e,o.taskId,{runId:o.runId});return r?{failedTask:{project:o.project,runId:o.runId,target:o.target,taskId:o.taskId},failureContext:r,outcome:"ready"}:{failedTask:{project:o.project,runId:o.runId,target:o.target,taskId:o.taskId},outcome:"no-failure-context"}},$=async(e,t)=>{const{logger:o,options:r,visConfig:s,workspaceRoot:n}=e,i=n??process.cwd(),a=r.dryRun===!0,d=s?.ai,c=await F(t.failureContext,o,{cache:r.cache!==!1,config:d});if(!c)return{outcome:"no-proposal"};if(c.cannotFix)return{detail:c.cannotFix,outcome:"cannot-fix",proposal:c};if(c.patches.length===0)return{outcome:"empty-patches",proposal:c};if(a)return{outcome:"dry-run",proposal:c};const f=await D(i,t.failureContext.cwd,c);return b(f).applied===0?{applyResults:f,outcome:"no-patches-applied",proposal:c}:{applyResults:f,outcome:"applied",proposal:c}},N=async(e,t,o={})=>{const r=e.workspaceRoot??process.cwd(),s=e.options.validationTimeout===void 0?ut:e.options.validationTimeout*1e3;return await(o.validate??((i,a)=>st(r,i,a,s)))(t.failedTask.project,t.failedTask.target)},v=async(e,t,o,r={})=>{const n=await(r.detectCi??Y)(),i=n.provider==="gitlab-ci"?"MR":n.provider==="buildkite"?"annotation":"PR";if(n.provider==="unknown")return{ciContext:n,outcome:"no-ci",surface:i};const a=y(t,o,e,n.sha),c=await(r.postComment??(async(f,u)=>nt({body:f,context:u})))(a,n);return c.posted?{ciContext:n,method:c.method,outcome:"posted",surface:i}:c.method==="skipped"?{ciContext:n,outcome:"no-pr",surface:i}:{ciContext:n,error:c.error,method:c.method,outcome:"post-failed",surface:i}},w=async(e,t={})=>{const{logger:o,workspaceRoot:r}=e,s=r??process.cwd(),n=await C(s,e.options.run);if(n.outcome==="no-failed-task"){p.info("No failed tasks found in the latest run summary. Nothing to heal.");return}if(n.outcome==="missing-metadata"){p.error(`Failed task ${n.failedTask.taskId} is missing project/target metadata in the run summary; cannot validate a fix.`),process.exitCode=1;return}if(n.outcome==="no-failure-context"){p.error(`No failure log or run summary found for ${n.failedTask.taskId}.`),process.exitCode=1;return}const i={failedTask:n.failedTask,failureContext:n.failureContext};p.info(`Healing ${i.failedTask.taskId} (run ${i.failedTask.runId??"unknown"})`),i.failureContext.terminalOutputCaptured||p.warn(`No captured terminal output for ${i.failedTask.taskId}; the AI proposal will be weaker without it.`);const a=await $(e,i);if(a.outcome==="no-proposal"){p.error("AI fix proposal failed or no provider available."),process.exitCode=1;return}if(a.outcome==="cannot-fix"){p.warn(`AI declined to fix: ${a.detail??"(no reason)"}`);return}if(a.outcome==="empty-patches"){p.warn("AI returned an empty patch set.");return}const d=a.proposal;if(o.info(dt(d,s,i.failureContext.cwd)),a.outcome==="dry-run"){p.info("Dry run: skipping apply, validation, and PR comment.");return}const c=a.applyResults??[],f=b(c);if(p.info(`Applied ${String(f.applied)}/${String(c.length)} patches.`),a.outcome==="no-patches-applied"){p.error("No patches could be applied (all failed validation)."),process.exitCode=1;return}p.info(`Re-running ${i.failedTask.taskId} to validate the fix...`);const u=await N(e,i,{validate:t.validate});if(u.exitCode!==0){p.error(`Validation failed (exit ${String(u.exitCode)}). Patch is not posted.`),u.stderr.trim().length>0&&(o.info(U("--- validation stderr (tail) ---")),o.info(u.stderr.split(`
|
|
13
13
|
`).slice(-20).join(`
|
|
14
|
-
`))),process.exitCode=1;return}p.success("Validation passed.");const l=await v(s,d,i.failureContext,{detectCi:t.detectCi,postComment:t.postComment});if(l.outcome==="no-ci"){p.notice("Not running in a recognised CI provider; skipping PR comment. Patch was applied + validated locally.");return}if(l.outcome==="posted"){const S=l.surface==="annotation"?`build #${String(l.ciContext.buildNumber??"?")}`:`${l.surface} #${String(l.ciContext.prNumber)}`;p.success(`Posted fix proposal to ${S} via ${l.method??"unknown"}.`);return}if(l.outcome==="no-pr"){p.notice(`No ${l.surface} number detected (push-event run); skipping comment.`);return}const R=l.surface==="annotation"?"annotation":`${l.surface} comment`;p.error(`Failed to post ${R}: ${l.error??"unknown error"}`)},pt=async e=>{await w(e)},
|
|
14
|
+
`))),process.exitCode=1;return}p.success("Validation passed.");const l=await v(s,d,i.failureContext,{detectCi:t.detectCi,postComment:t.postComment});if(l.outcome==="no-ci"){p.notice("Not running in a recognised CI provider; skipping PR comment. Patch was applied + validated locally.");return}if(l.outcome==="posted"){const S=l.surface==="annotation"?`build #${String(l.ciContext.buildNumber??"?")}`:`${l.surface} #${String(l.ciContext.prNumber)}`;p.success(`Posted fix proposal to ${S} via ${l.method??"unknown"}.`);return}if(l.outcome==="no-pr"){p.notice(`No ${l.surface} number detected (push-event run); skipping comment.`);return}const R=l.surface==="annotation"?"annotation":`${l.surface} comment`;p.error(`Failed to post ${R}: ${l.error??"unknown error"}`)},pt=async e=>{await w(e)},bt=Object.defineProperty({__proto__:null,aiHeal:pt,findHealCandidate:C,pickFenceForTesting:T,postHealComment:v,proposeAndApply:$,renderCommentBodyForTesting:y,renderProposalDiffForTesting:_,runHealForTesting:w,validateAppliedFix:N},Symbol.toStringTag,{value:"Module"});export{nt as a,Y as d,C as f,bt as h,$ as p,N as v};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{createRequire as St}from"node:module";import{w as Et,$ as It,e as Wt,
|
|
2
|
-
`)&&(r=r.replace(/(\r*\n)/g,`${n.closeStack}$1${n.openStack}`)),n.openStack+r+n.closeStack},Pt=function(t){const e=t?.level??ht,{baseColors:n,baseStyles:r,styleMethods:s}=ut(e),i={};let o=null;const a=({props:l},{close:u,open:d})=>{const p=(l?.openStack??"")+d,h=u+(l?.closeStack??""),g=(w,...y)=>Rt(w,y,g.props);return Object.setPrototypeOf(g,o),g.props={close:u,closeStack:h,open:d,openStack:p,props:l},g.open=p,g.close=h,g},c=l=>String(l);c.strip=l=>l.replaceAll(
|
|
3
|
-
`],["r","\r"],["t"," "],["v","\v"]]),pt=t=>{const e=t.startsWith("u"),n=t[1]==="{";return e&&!n&&t.length===5||t.startsWith("x")&&t.length===3?String.fromCodePoint(Number.parseInt(t.slice(1),16)):e&&n?String.fromCodePoint(Number.parseInt(t.slice(2,-1),16)):Lt.get(t)??t},Ft=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi,et=/(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi,Vt=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,Dt=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi,Ut=/\s*,\s*/,Gt=(t,e)=>{const n=[],r=e.trim().split(Ut);let s;for(const i of r){const o=Number(i);if(!Number.isNaN(o))n.push(o);else if(s=Vt.exec(i))n.push(s[2].replaceAll(Dt,(a,c,l)=>c?pt(c):l));else throw new Error(`Invalid template style argument: ${i} (in style '${t}')`)}return n},qt=t=>{et.lastIndex=0;const e=[];let n;for(;(n=et.exec(t))!==null;){const r=n[1];n[2]?e.push([r,...Gt(r,n[2])]):n[3]||n[4]?(n[3]&&e.push(["rgb",...H(n[3])]),n[4]&&e.push(["bgRgb",...H(n[4])])):e.push([r])}return e},nt=(t,e)=>{const n={};for(const s of e)for(const i of s.styles)n[i[0]]=s.inverse?void 0:i.slice(1);let r=t;for(const[s,i]of Object.entries(n))if(Array.isArray(i)){if(!(s in r))throw new Error(`Unknown style: ${s}`);r=i.length>0?r[s](...i):r[s]}return r},Ht=t=>e=>{const n=[],r=[];let s=[];if(e.replaceAll(Ft,(i,o,a,c,l,u)=>{if(o)s.push(pt(o));else if(c){const d=s.join("");s=[],r.push(n.length===0?d:nt(t,n)(d)),n.push({inverse:a,styles:qt(c)})}else if(l){if(n.length===0)throw new Error("Found extraneous } in template literal");r.push(nt(t,n)(s.join(""))),s=[],n.pop()}else s.push(u)}),r.push(s.join("")),n.length>0)throw new Error(`template literal is missing ${String(n.length)} closing bracket${n.length===1?"":"s"} (\`}\`)`);return r.join("")},zt=new Pt,Yt=Ht(zt),Jt=Tt(Yt);let Kt;const Zt=t=>(Kt??=kt(import.meta.url))(t),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:A,F=t=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[e,n]=O.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return O.getBuiltinModule(t)}return Zt(t)},A=O,{execFileSync:Qt}=F("node:child_process"),W=F("node:fs"),Xt=F("node:tty"),te=F("node:os"),ee=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],ne=12288,re=65510,oe=[12288,12288,65281,65376,65504,65510],ie=8361,se=65518,ae=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],le=32,ce=10630,de=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],ue=4352,he=262141,mt=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],k=(t,e)=>{let n=0,r=Math.floor(t.length/2)-1;for(;n<=r;){const s=Math.floor((n+r)/2),i=s*2;if(e<t[i])r=s-1;else if(e>t[i+1])n=s+1;else return!0}return!1},rt=19968,[pe,me]=fe(mt);function fe(t){let e=t[0],n=t[1];for(let r=0;r<t.length;r+=2){const s=t[r],i=t[r+1];if(rt>=s&&rt<=i)return[s,i];i-s>n-e&&(e=s,n=i)}return[e,n]}const ge=t=>t<161||t>1114109?!1:k(ee,t),we=t=>t<ne||t>re?!1:k(oe,t),be=t=>t<ie||t>se?!1:k(ae,t),ye=t=>t<le||t>ce?!1:k(de,t),$e=t=>t>=pe&&t<=me?!0:t<ue||t>he?!1:k(mt,t);function Ne(t){return ge(t)?"ambiguous":we(t)?"fullwidth":be(t)?"halfwidth":ye(t)?"narrow":$e(t)?"wide":"neutral"}function ve(t){if(!Number.isSafeInteger(t))throw new TypeError(`Expected a code point, got \`${typeof t}\`.`)}function ft(t){return ve(t),Ne(t)}const ot=new Map,Se=t=>[t.ambiguousIsNarrow?1:0,t.control,t.fullWidth,t.regular,t.wide].join("|"),Ae=t=>{const e=Se(t.width);let n=ot.get(e);return n||(n=new Map,ot.set(e,n)),n},M=new RegExp(ct.source,"y"),G=new RegExp(Bt.source,"uy"),C=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,gt=t=>t>=32&&t<=126?"latin":t===8203||t===8204||t===8205||t===8288?"zero":t<=31||t>=127&&t<=159?"control":t>=160&&t<=255||t>=9472&&t<=9599?"latin":t>=4352&&t<=4607||t>=11904&&t<=40959||t>=44032&&t<=55215||t>=63744&&t<=64255||t>=65280&&t<=65519&&!(t>=65377&&t<=65439)||t>=12352&&t<=12543?"wide":t===8230?"latin":"other",Oe=(t,e)=>{const n=Ae(e),r=Math.floor(t/65536),s=t%65536;let i=n.get(r);if(i||(i=new Map,n.set(r,i)),i.has(s))return i.get(s);let o;switch(gt(t)){case"control":{o=e.width.control;break}case"latin":{o=e.width.regular;break}case"wide":{o=e.width.wide;break}case"zero":{o=0;break}default:switch(ft(t)){case"ambiguous":{o=e.width.ambiguousIsNarrow?e.width.regular:e.width.wide;break}case"fullwidth":{o=e.width.fullWidth;break}case"wide":{o=e.width.wide;break}default:o=e.width.regular}}return i.set(s,o),o},xe=t=>t>=768&&t<=879||t>=6832&&t<=6911||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071||t>=917760&&t<=917999||t>=65024&&t<=65039||t>=3633&&t<=3642||t>=3655&&t<=3662||t>=3761&&t<=3769||t>=3771&&t<=3772||t>=3784&&t<=3789||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2500||t>=2509&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2637||t>=1611&&t<=1631||t>=1648&&t<=1648||t>=1750&&t<=1773||t>=2276&&t<=2302||t>=1425&&t<=1469||t>=1471&&t<=1471||t>=1473&&t<=1474||t>=1476&&t<=1477||t>=1479&&t<=1479||t>=3893&&t<=3893||t>=3895&&t<=3895||t>=3897&&t<=3897||t>=3953&&t<=3966||t>=3968&&t<=3972||t>=3974&&t<=3975?!0:t>=768&&t<=777||t>=803&&t<=803,Y=(t,e={})=>{if(!t||t.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const n={truncation:{countAnsiEscapeCodes:e.countAnsiEscapeCodes??!1,ellipsis:e.ellipsis??"",ellipsisWidth:e.ellipsisWidth??(e.ellipsis?Y(e.ellipsis,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:e.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:e.ambiguousIsNarrow??!1,ansi:e.ansiWidth??0,control:e.controlWidth??0,emoji:e.emojiWidth??2,fullWidth:e.fullWidth??2,halfWidth:e.halfWidth??1,regular:e.regularWidth??1,tab:e.tabWidth??8,wide:e.wideWidth??2}},r=Math.max(0,n.truncation.limit-n.truncation.ellipsisWidth),{length:s}=t,i=s>1e4;let o=0,a=0,c=s,l=!1;const u=t.includes("\x1B")||t.includes("");for(;o<s;){if(u&&(t[o]==="\x1B"||t[o]==="")){if(t.startsWith("\x1B]8;;",o)){const y="\x1B]8;;\x07",v=y.length,V=t.indexOf("\x07",o+5);if(V!==-1){const D=t.indexOf(y,V+1);if(D!==-1){const Nt=D+v,vt=t.slice(V+1,D).replace(ct,""),Z=Y(vt,{ambiguousIsNarrow:n.width.ambiguousIsNarrow,ansiWidth:n.width.ansi,controlWidth:n.width.control,countAnsiEscapeCodes:!1,ellipsis:n.truncation.ellipsis,ellipsisWidth:n.truncation.ellipsisWidth,emojiWidth:n.width.emoji,fullWidth:n.width.fullWidth,halfWidth:n.width.halfWidth,limit:Math.max(0,r-a),regularWidth:n.width.regular,tabWidth:n.width.tab,wideWidth:n.width.wide}),U=Z.width;if(Z.truncated)l=!0,c=Math.min(c,o);else if(a+U>r&&(c=Math.min(c,o),l=!0,a+U>n.truncation.limit))break;if(a+=U,o=Nt,l&&a>=n.truncation.limit)break;continue}}}if(M.lastIndex=o,M.test(t)){const y=M.lastIndex-o,v=n.truncation.countAnsiEscapeCodes?y:n.width.ansi;if(a+v>r&&(c=Math.min(c,o),a+v>n.truncation.limit)){l=!0;break}a+=v,o=M.lastIndex;continue}}const h=t.codePointAt(o);if(h===8203||h===65279||h>=8288&&h<=8292){o+=1;continue}if(h===9){if(a+n.width.tab>r&&(c=Math.min(c,o),a+n.width.tab>n.truncation.limit)){l=!0;break}a+=n.width.tab,o+=1;continue}if(C.lastIndex=o,C.test(t)){const y=(C.lastIndex-o)*n.width.regular;if(a+y>r){const v=n.width.regular>0?Math.floor((r-a)/n.width.regular):0;if(c=Math.min(c,o+v),a+y>n.truncation.limit){l=!0;break}}a+=y,o=C.lastIndex;continue}if((h<=31||h>=127&&h<=159)&&(B.lastIndex=o,B.test(t))){const y=(B.lastIndex-o)*n.width.control;if(a+y>r){const v=n.width.control>0?Math.floor((r-a)/n.width.control):0;if(c=Math.min(c,o+v),a+y>n.truncation.limit){l=!0;break}}a+=y,o=B.lastIndex;continue}if(G.lastIndex=o,G.test(t)){if(a+n.width.emoji>r&&(c=Math.min(c,o),a+n.width.emoji>n.truncation.limit)){l=!0;break}a+=n.width.emoji,o=G.lastIndex;continue}const g=t.codePointAt(o)??0;if(xe(g)){o+=g>65535?2:1;continue}let w;if(i)w=Oe(g,n);else switch(gt(g)){case"control":{w=n.width.control;break}case"latin":{w=n.width.regular;break}case"wide":{w=n.width.wide;break}case"zero":{w=0;break}default:switch(ft(g)){case"ambiguous":{w=n.width.ambiguousIsNarrow?n.width.regular:n.width.wide;break}case"fullwidth":{w=n.width.fullWidth;break}case"wide":{w=n.width.wide;break}default:w=n.width.regular}}if(a+w>r&&(c=Math.min(c,o),a+w>n.truncation.limit)){l=!0;break}a+=w,o+=g>65535?2:1}let d=a,p=!1;return l&&n.truncation.limit>=n.truncation.ellipsisWidth&&(d=n.truncation.limit,p=!0),{ellipsed:p,index:l?c:s,truncated:l,width:d}},Ee=(t,e={})=>Y(t,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,wt=80,bt=24,J=(t,e,{shell:n,env:r}={})=>Qt(t,e,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:r}).trim(),P=(t,e)=>({columns:Number.parseInt(t,10),rows:Number.parseInt(e,10)}),yt=(t,e)=>{const{columns:n,rows:r}=P(t,e);if(!(Number.isNaN(n)||Number.isNaN(r))&&!(n===wt&&r===bt))return{columns:n,rows:r}},Ie=()=>{if(A.platform!=="linux")return!0;try{const t=W.readFileSync("/proc/self/stat","utf8"),e=t.lastIndexOf(") ");if(e===-1)return!1;const n=t.slice(e+2).trim().split(/\s+/),r=Number.parseInt(n[2],10),s=Number.parseInt(n[5],10);return Number.isNaN(r)||Number.isNaN(s)||s<=0?!1:r===s}catch{return!1}};function We(){const{env:t,stdout:e,stderr:n}=A;if(e?.columns&&e?.rows)return P(e.columns,e.rows);if(n?.columns&&n?.rows)return P(n.columns,n.rows);if(t.COLUMNS&&t.LINES)return P(t.COLUMNS,t.LINES);const r={columns:wt,rows:bt};return A.platform==="win32"?q()??r:A.platform==="darwin"?it()??q()??r:it()??q()??ke()??r}const it=()=>{try{const t=A.platform==="darwin"?W.constants.O_EVTONLY|W.constants.O_NONBLOCK:W.constants.O_NONBLOCK,{columns:e,rows:n}=Xt.WriteStream(W.openSync("/dev/tty",t));return{columns:e,rows:n}}catch{}},q=()=>{try{const t=J("tput",["cols"],{env:{TERM:"dumb",...A.env}}),e=J("tput",["lines"],{env:{TERM:"dumb",...A.env}});if(t&&e)return yt(t,e)}catch{}},ke=()=>{try{if(!Ie())return;const t=J("resize",["-u"]).match(/\d+/g);if(t.length===2)return yt(t[0],t[1])}catch{}},I=new Map,Be=500,$=t=>{if(!t||t==="")return"";const e=I.get(t);if(e!==void 0)return e;let n;try{n=Jt(Object.assign([],{raw:[t]}))}catch{n=t}if(I.size>=Be){const r=I.keys().next().value;r!==void 0&&I.delete(r)}return I.set(t,n),n},T=()=>{const t=Mt().CEREBRO_TERMINAL_WIDTH;if(t===void 0)return;const e=Number.parseInt(t,10);if(!(Number.isNaN(e)||e<=0))return e};class $t{lines;constructor(){this.lines=[]}add(e){this.lines.push(e)}toString(){return this.lines.join(te.EOL)}header(e){this.add(j(e)),this.lines.push("")}}const Me=t=>t!==void 0&&t>0?t:We().columns,Ce=(t,e,n,r)=>{if(t.length===0||t.some(l=>l.length!==2))return;let s=0;for(const l of t){const u=l[0];if(u===void 0)continue;const d=Ee(u);d>s&&(s=d)}if(s===0)return;const i=n+r,o=s+i,a=20+i;if(o+a>e)return;const c=e-o;return[o,c]};class je extends $t{constructor(e){if(super(),e.header&&this.header($(e.header)),e.content){if(e.raw)if(Array.isArray(e.content)&&e.content.every(n=>typeof n=="string"))e.content.forEach(n=>{Array.isArray(n)?n.forEach(r=>{this.add($(r))}):this.add($(n))});else if(typeof e.content=="string")this.add($(e.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(e.content));this.add("")}}getContentLines(e){if(typeof e=="string"){const n=_({showHeader:!1,style:{border:R,paddingLeft:4,paddingRight:1},terminalWidth:T(),truncateOverflow:!1,wordWrap:!0});return n.addRow([$(e)]),n.toString()}if(Array.isArray(e)&&e.every(n=>typeof n=="string"||Array.isArray(n)&&n.every(r=>typeof r=="string"))){const n=Me(T()),r=a=>Array.isArray(a)?a.map(c=>$(c)):[$(a)],s=e.map(a=>r(a)),i=Ce(s,n,4,1),o=_({columnWidths:i,showHeader:!1,style:{border:R,paddingLeft:4,paddingRight:1},terminalWidth:n,truncateOverflow:!1,wordWrap:!0});return s.forEach(a=>{i!==void 0&&a.length===2?o.addRow([{content:a[0],wordWrap:!1},a[1]]):o.addRow(a)}),o.toString()}if(typeof e=="object"){const n=e;if(!n.options||!n.data)throw new Error(`Must have an "options" or "data" property
|
|
1
|
+
import{createRequire as St}from"node:module";import{w as Et,$ as It,e as Wt,j as C,P as b,q as x,J as N,b as L}from"../packem_shared/index.server-BAjDJSEu.js";import{u as ct,a as B,c as Bt}from"../packem_shared/vis-user-error-Dkc97rGY.js";import{N as _,a as R}from"../packem_shared/Table-DyORjLji-CC9cYgCG.js";import{b as Mt}from"../packem_shared/package-version-CJxZ_B7G.js";let At;const Ot=t=>(At??=St(import.meta.url))(t),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,xt=t=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[e,n]=E.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return E.getBuiltinModule(t)}return Ot(t)},{createRequire:kt}=xt("node:module"),jt=/^#?([a-f\d]{3}|[a-f\d]{6})$/i,z=t=>{let[,e]=jt.exec(t)??[];const n=e?e.length:0;if(n===3){const s=e.charAt(0),i=e.charAt(1),o=e.charAt(2);e=s+s+i+i+o+o}else if(n!==6)return globalThis.process?.env?.NODE_ENV!=="production"&&console.warn(`[@visulima/colorize] Invalid hex color "${t}"; expected a 3- or 6-digit hex string (e.g. "#96C" or "#E0115F"). Falling back to black.`),[0,0,0];const r=Number.parseInt(e,16);return[r>>16&255,r>>8&255,r&255]},dt=(t,e,n)=>t===e&&e===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/51)+6*Math.round(e/51)+Math.round(n/51),H=t=>{let e,n,r;if(t<8)return 30+t;if(t<16)return 90+(t-8);if(t>=232)e=n=r=((t-232)*10+8)/255;else{t-=16;const o=t%36;e=Math.floor(t/36)/5,n=Math.floor(o/6)/5,r=o%6/5}const s=Math.max(e,n,r)*2;if(s===0)return 30;const i=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(e));return s===2?i+60:i},Q=(t,e,n)=>H(dt(t,e,n));function Ct({onlyFirst:t=!1}={}){const e="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(e,t?void 0:"g")}const S=(t,e,n)=>e>t?e:Math.min(t,n),m=39,f=49,X=10,tt={close:"",open:""},ut=t=>{const e=t>0?(d,p)=>({close:`\x1B[${String(p)}m`,open:`\x1B[${String(d)}m`}):()=>tt,n=d=>(p,h,g)=>d(dt(Number(p),Number(h),Number(g))),r=d=>p=>{const[h,g,w]=z(p);return d(h,g,w)};let s=d=>e(`38;5;${String(d)}`,m),i=d=>e(`48;5;${String(d)}`,f),o=(d,p,h)=>e(`38;2;${String(d)};${String(p)};${String(h)}`,m),a=(d,p,h)=>e(`48;2;${String(d)};${String(p)};${String(h)}`,f);t===1?(s=d=>e(H(Number(d)),m),i=d=>e(H(Number(d))+X,f),o=(d,p,h)=>e(Q(Number(d),Number(p),Number(h)),m),a=(d,p,h)=>e(Q(Number(d),Number(p),Number(h))+X,f)):t===2&&(o=n(s),a=n(i));const c={bold:e(1,22),dim:e(2,22),hidden:e(8,28),inverse:e(7,27),italic:e(3,23),overline:e(53,55),reset:e(0,0),strike:e(9,29),strikethrough:e(9,29),underline:e(4,24),underlineCurly:e("4:3",24),underlineDashed:e("4:5",24),underlineDotted:e("4:4",24),underlineDouble:e("4:2",24),visible:tt},l={bgBlack:e(40,f),bgBlackBright:e(100,f),bgBlue:e(44,f),bgBlueBright:e(104,f),bgCyan:e(46,f),bgCyanBright:e(106,f),bgGray:e(100,f),bgGreen:e(42,f),bgGreenBright:e(102,f),bgGrey:e(100,f),bgMagenta:e(45,f),bgMagentaBright:e(105,f),bgRed:e(41,f),bgRedBright:e(101,f),bgWhite:e(47,f),bgWhiteBright:e(107,f),bgYellow:e(43,f),bgYellowBright:e(103,f),black:e(30,m),blackBright:e(90,m),blue:e(34,m),blueBright:e(94,m),cyan:e(36,m),cyanBright:e(96,m),gray:e(90,m),green:e(32,m),greenBright:e(92,m),grey:e(90,m),magenta:e(35,m),magentaBright:e(95,m),red:e(31,m),redBright:e(91,m),white:e(37,m),whiteBright:e(97,m),yellow:e(33,m),yellowBright:e(93,m)},u={bg:d=>i(S(d,0,255)),bgHex:r(a),bgRgb:(d,p,h)=>a(S(d,0,255),S(p,0,255),S(h,0,255)),fg:d=>s(S(d,0,255)),hex:r(o),rgb:(d,p,h)=>o(S(d,0,255),S(p,0,255),S(h,0,255))};return{baseColors:l,baseStyles:c,styleMethods:u}},ht=Et();It();ut(ht);const _t=(t,e,n)=>{if(e==="")return t;let r=t.indexOf(e);if(r<0)return t;const s=e.length;let i=0,o="";for(;~r;)o+=t.slice(i,r)+n,i=r+s,r=t.indexOf(e,i);return o+t.slice(i)},Rt=(t,e,n)=>{if(t==null||t==="")return"";let r;if(t.raw===void 0?r=String(t):r=String.raw(t,...e),r.includes("\x1B"))for(let s=n;s;s=s.props)r=_t(r,s.close,s.open);return r.includes(`
|
|
2
|
+
`)&&(r=r.replace(/(\r*\n)/g,`${n.closeStack}$1${n.openStack}`)),n.openStack+r+n.closeStack},Pt=function(t){const e=t?.level??ht,{baseColors:n,baseStyles:r,styleMethods:s}=ut(e),i={};let o=null;const a=({props:l},{close:u,open:d})=>{const p=(l?.openStack??"")+d,h=u+(l?.closeStack??""),g=(w,...y)=>Rt(w,y,g.props);return Object.setPrototypeOf(g,o),g.props={close:u,closeStack:h,open:d,openStack:p,props:l},g.open=p,g.close=h,g},c=l=>String(l);c.strip=l=>l.replaceAll(Ct(),"");for(const l in n)i[l]={get(){const u=a(this,n[l]);return Object.defineProperty(this,l,{value:u}),u}};for(const l in r)i[l]={get(){const u=a(this,r[l]);return Object.defineProperty(this,l,{value:u}),u}};for(const l in s)i[l]={get(){return(...u)=>a(this,s[l](...u))}};return i.ansi256=i.fg,i.bgAnsi256=i.bg,o=Object.defineProperties({},i),Object.setPrototypeOf(c,o),c},Tt=t=>(e,...n)=>{if(!Array.isArray(e)||!Array.isArray(e.raw))throw new TypeError("A tagged template literal must be provided");const r=[e.raw[0]];for(let s=1;s<e.raw.length;s+=1)r.push(String(n[s-1]).replaceAll(/[{}\\]/g,String.raw`\$&`),String(e.raw[s]));return t(r.join(""))},Lt=new Map([["0","\0"],["\\","\\"],["a","\x07"],["b","\b"],["e","\x1B"],["f","\f"],["n",`
|
|
3
|
+
`],["r","\r"],["t"," "],["v","\v"]]),pt=t=>{const e=t.startsWith("u"),n=t[1]==="{";return e&&!n&&t.length===5||t.startsWith("x")&&t.length===3?String.fromCodePoint(Number.parseInt(t.slice(1),16)):e&&n?String.fromCodePoint(Number.parseInt(t.slice(2,-1),16)):Lt.get(t)??t},Ft=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi,et=/(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi,Dt=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,Vt=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi,Ut=/\s*,\s*/,Gt=(t,e)=>{const n=[],r=e.trim().split(Ut);let s;for(const i of r){const o=Number(i);if(!Number.isNaN(o))n.push(o);else if(s=Dt.exec(i))n.push(s[2].replaceAll(Vt,(a,c,l)=>c?pt(c):l));else throw new Error(`Invalid template style argument: ${i} (in style '${t}')`)}return n},qt=t=>{et.lastIndex=0;const e=[];let n;for(;(n=et.exec(t))!==null;){const r=n[1];n[2]?e.push([r,...Gt(r,n[2])]):n[3]||n[4]?(n[3]&&e.push(["rgb",...z(n[3])]),n[4]&&e.push(["bgRgb",...z(n[4])])):e.push([r])}return e},nt=(t,e)=>{const n={};for(const s of e)for(const i of s.styles)n[i[0]]=s.inverse?void 0:i.slice(1);let r=t;for(const[s,i]of Object.entries(n))if(Array.isArray(i)){if(!(s in r))throw new Error(`Unknown style: ${s}`);r=i.length>0?r[s](...i):r[s]}return r},zt=t=>e=>{const n=[],r=[];let s=[];if(e.replaceAll(Ft,(i,o,a,c,l,u)=>{if(o)s.push(pt(o));else if(c){const d=s.join("");s=[],r.push(n.length===0?d:nt(t,n)(d)),n.push({inverse:a,styles:qt(c)})}else if(l){if(n.length===0)throw new Error("Found extraneous } in template literal");r.push(nt(t,n)(s.join(""))),s=[],n.pop()}else s.push(u)}),r.push(s.join("")),n.length>0)throw new Error(`template literal is missing ${String(n.length)} closing bracket${n.length===1?"":"s"} (\`}\`)`);return r.join("")},Ht=new Pt,Yt=zt(Ht),Jt=Tt(Yt);let Kt;const Zt=t=>(Kt??=kt(import.meta.url))(t),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:A,F=t=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[e,n]=O.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return O.getBuiltinModule(t)}return Zt(t)},A=O,{execFileSync:Qt}=F("node:child_process"),W=F("node:fs"),Xt=F("node:tty"),te=F("node:os"),ee=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],ne=12288,re=65510,oe=[12288,12288,65281,65376,65504,65510],ie=8361,se=65518,ae=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],le=32,ce=10630,de=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],ue=4352,he=262141,mt=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],k=(t,e)=>{let n=0,r=Math.floor(t.length/2)-1;for(;n<=r;){const s=Math.floor((n+r)/2),i=s*2;if(e<t[i])r=s-1;else if(e>t[i+1])n=s+1;else return!0}return!1},rt=19968,[pe,me]=fe(mt);function fe(t){let e=t[0],n=t[1];for(let r=0;r<t.length;r+=2){const s=t[r],i=t[r+1];if(rt>=s&&rt<=i)return[s,i];i-s>n-e&&(e=s,n=i)}return[e,n]}const ge=t=>t<161||t>1114109?!1:k(ee,t),we=t=>t<ne||t>re?!1:k(oe,t),be=t=>t<ie||t>se?!1:k(ae,t),ye=t=>t<le||t>ce?!1:k(de,t),$e=t=>t>=pe&&t<=me?!0:t<ue||t>he?!1:k(mt,t);function Ne(t){return ge(t)?"ambiguous":we(t)?"fullwidth":be(t)?"halfwidth":ye(t)?"narrow":$e(t)?"wide":"neutral"}function ve(t){if(!Number.isSafeInteger(t))throw new TypeError(`Expected a code point, got \`${typeof t}\`.`)}function ft(t){return ve(t),Ne(t)}const ot=new Map,Se=t=>[t.ambiguousIsNarrow?1:0,t.control,t.fullWidth,t.regular,t.wide].join("|"),Ae=t=>{const e=Se(t.width);let n=ot.get(e);return n||(n=new Map,ot.set(e,n)),n},M=new RegExp(ct.source,"y"),G=new RegExp(Bt.source,"uy"),j=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,gt=t=>t>=32&&t<=126?"latin":t===8203||t===8204||t===8205||t===8288?"zero":t<=31||t>=127&&t<=159?"control":t>=160&&t<=255||t>=9472&&t<=9599?"latin":t>=4352&&t<=4607||t>=11904&&t<=40959||t>=44032&&t<=55215||t>=63744&&t<=64255||t>=65280&&t<=65519&&!(t>=65377&&t<=65439)||t>=12352&&t<=12543?"wide":t===8230?"latin":"other",Oe=(t,e)=>{const n=Ae(e),r=Math.floor(t/65536),s=t%65536;let i=n.get(r);if(i||(i=new Map,n.set(r,i)),i.has(s))return i.get(s);let o;switch(gt(t)){case"control":{o=e.width.control;break}case"latin":{o=e.width.regular;break}case"wide":{o=e.width.wide;break}case"zero":{o=0;break}default:switch(ft(t)){case"ambiguous":{o=e.width.ambiguousIsNarrow?e.width.regular:e.width.wide;break}case"fullwidth":{o=e.width.fullWidth;break}case"wide":{o=e.width.wide;break}default:o=e.width.regular}}return i.set(s,o),o},xe=t=>t>=768&&t<=879||t>=6832&&t<=6911||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071||t>=917760&&t<=917999||t>=65024&&t<=65039||t>=3633&&t<=3642||t>=3655&&t<=3662||t>=3761&&t<=3769||t>=3771&&t<=3772||t>=3784&&t<=3789||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2500||t>=2509&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2637||t>=1611&&t<=1631||t>=1648&&t<=1648||t>=1750&&t<=1773||t>=2276&&t<=2302||t>=1425&&t<=1469||t>=1471&&t<=1471||t>=1473&&t<=1474||t>=1476&&t<=1477||t>=1479&&t<=1479||t>=3893&&t<=3893||t>=3895&&t<=3895||t>=3897&&t<=3897||t>=3953&&t<=3966||t>=3968&&t<=3972||t>=3974&&t<=3975?!0:t>=768&&t<=777||t>=803&&t<=803,Y=(t,e={})=>{if(!t||t.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const n={truncation:{countAnsiEscapeCodes:e.countAnsiEscapeCodes??!1,ellipsis:e.ellipsis??"",ellipsisWidth:e.ellipsisWidth??(e.ellipsis?Y(e.ellipsis,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:e.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:e.ambiguousIsNarrow??!1,ansi:e.ansiWidth??0,control:e.controlWidth??0,emoji:e.emojiWidth??2,fullWidth:e.fullWidth??2,halfWidth:e.halfWidth??1,regular:e.regularWidth??1,tab:e.tabWidth??8,wide:e.wideWidth??2}},r=Math.max(0,n.truncation.limit-n.truncation.ellipsisWidth),{length:s}=t,i=s>1e4;let o=0,a=0,c=s,l=!1;const u=t.includes("\x1B")||t.includes("");for(;o<s;){if(u&&(t[o]==="\x1B"||t[o]==="")){if(t.startsWith("\x1B]8;;",o)){const y="\x1B]8;;\x07",v=y.length,D=t.indexOf("\x07",o+5);if(D!==-1){const V=t.indexOf(y,D+1);if(V!==-1){const Nt=V+v,vt=t.slice(D+1,V).replace(ct,""),Z=Y(vt,{ambiguousIsNarrow:n.width.ambiguousIsNarrow,ansiWidth:n.width.ansi,controlWidth:n.width.control,countAnsiEscapeCodes:!1,ellipsis:n.truncation.ellipsis,ellipsisWidth:n.truncation.ellipsisWidth,emojiWidth:n.width.emoji,fullWidth:n.width.fullWidth,halfWidth:n.width.halfWidth,limit:Math.max(0,r-a),regularWidth:n.width.regular,tabWidth:n.width.tab,wideWidth:n.width.wide}),U=Z.width;if(Z.truncated)l=!0,c=Math.min(c,o);else if(a+U>r&&(c=Math.min(c,o),l=!0,a+U>n.truncation.limit))break;if(a+=U,o=Nt,l&&a>=n.truncation.limit)break;continue}}}if(M.lastIndex=o,M.test(t)){const y=M.lastIndex-o,v=n.truncation.countAnsiEscapeCodes?y:n.width.ansi;if(a+v>r&&(c=Math.min(c,o),a+v>n.truncation.limit)){l=!0;break}a+=v,o=M.lastIndex;continue}}const h=t.codePointAt(o);if(h===8203||h===65279||h>=8288&&h<=8292){o+=1;continue}if(h===9){if(a+n.width.tab>r&&(c=Math.min(c,o),a+n.width.tab>n.truncation.limit)){l=!0;break}a+=n.width.tab,o+=1;continue}if(j.lastIndex=o,j.test(t)){const y=(j.lastIndex-o)*n.width.regular;if(a+y>r){const v=n.width.regular>0?Math.floor((r-a)/n.width.regular):0;if(c=Math.min(c,o+v),a+y>n.truncation.limit){l=!0;break}}a+=y,o=j.lastIndex;continue}if((h<=31||h>=127&&h<=159)&&(B.lastIndex=o,B.test(t))){const y=(B.lastIndex-o)*n.width.control;if(a+y>r){const v=n.width.control>0?Math.floor((r-a)/n.width.control):0;if(c=Math.min(c,o+v),a+y>n.truncation.limit){l=!0;break}}a+=y,o=B.lastIndex;continue}if(G.lastIndex=o,G.test(t)){if(a+n.width.emoji>r&&(c=Math.min(c,o),a+n.width.emoji>n.truncation.limit)){l=!0;break}a+=n.width.emoji,o=G.lastIndex;continue}const g=t.codePointAt(o)??0;if(xe(g)){o+=g>65535?2:1;continue}let w;if(i)w=Oe(g,n);else switch(gt(g)){case"control":{w=n.width.control;break}case"latin":{w=n.width.regular;break}case"wide":{w=n.width.wide;break}case"zero":{w=0;break}default:switch(ft(g)){case"ambiguous":{w=n.width.ambiguousIsNarrow?n.width.regular:n.width.wide;break}case"fullwidth":{w=n.width.fullWidth;break}case"wide":{w=n.width.wide;break}default:w=n.width.regular}}if(a+w>r&&(c=Math.min(c,o),a+w>n.truncation.limit)){l=!0;break}a+=w,o+=g>65535?2:1}let d=a,p=!1;return l&&n.truncation.limit>=n.truncation.ellipsisWidth&&(d=n.truncation.limit,p=!0),{ellipsed:p,index:l?c:s,truncated:l,width:d}},Ee=(t,e={})=>Y(t,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,wt=80,bt=24,J=(t,e,{shell:n,env:r}={})=>Qt(t,e,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:r}).trim(),P=(t,e)=>({columns:Number.parseInt(t,10),rows:Number.parseInt(e,10)}),yt=(t,e)=>{const{columns:n,rows:r}=P(t,e);if(!(Number.isNaN(n)||Number.isNaN(r))&&!(n===wt&&r===bt))return{columns:n,rows:r}},Ie=()=>{if(A.platform!=="linux")return!0;try{const t=W.readFileSync("/proc/self/stat","utf8"),e=t.lastIndexOf(") ");if(e===-1)return!1;const n=t.slice(e+2).trim().split(/\s+/),r=Number.parseInt(n[2],10),s=Number.parseInt(n[5],10);return Number.isNaN(r)||Number.isNaN(s)||s<=0?!1:r===s}catch{return!1}};function We(){const{env:t,stdout:e,stderr:n}=A;if(e?.columns&&e?.rows)return P(e.columns,e.rows);if(n?.columns&&n?.rows)return P(n.columns,n.rows);if(t.COLUMNS&&t.LINES)return P(t.COLUMNS,t.LINES);const r={columns:wt,rows:bt};return A.platform==="win32"?q()??r:A.platform==="darwin"?it()??q()??r:it()??q()??ke()??r}const it=()=>{try{const t=A.platform==="darwin"?W.constants.O_EVTONLY|W.constants.O_NONBLOCK:W.constants.O_NONBLOCK,{columns:e,rows:n}=Xt.WriteStream(W.openSync("/dev/tty",t));return{columns:e,rows:n}}catch{}},q=()=>{try{const t=J("tput",["cols"],{env:{TERM:"dumb",...A.env}}),e=J("tput",["lines"],{env:{TERM:"dumb",...A.env}});if(t&&e)return yt(t,e)}catch{}},ke=()=>{try{if(!Ie())return;const t=J("resize",["-u"]).match(/\d+/g);if(t.length===2)return yt(t[0],t[1])}catch{}},I=new Map,Be=500,$=t=>{if(!t||t==="")return"";const e=I.get(t);if(e!==void 0)return e;let n;try{n=Jt(Object.assign([],{raw:[t]}))}catch{n=t}if(I.size>=Be){const r=I.keys().next().value;r!==void 0&&I.delete(r)}return I.set(t,n),n},T=()=>{const t=Mt().CEREBRO_TERMINAL_WIDTH;if(t===void 0)return;const e=Number.parseInt(t,10);if(!(Number.isNaN(e)||e<=0))return e};class $t{lines;constructor(){this.lines=[]}add(e){this.lines.push(e)}toString(){return this.lines.join(te.EOL)}header(e){this.add(C(e)),this.lines.push("")}}const Me=t=>t!==void 0&&t>0?t:We().columns,je=(t,e,n,r)=>{if(t.length===0||t.some(l=>l.length!==2))return;let s=0;for(const l of t){const u=l[0];if(u===void 0)continue;const d=Ee(u);d>s&&(s=d)}if(s===0)return;const i=n+r,o=s+i,a=20+i;if(o+a>e)return;const c=e-o;return[o,c]};class Ce extends $t{constructor(e){if(super(),e.header&&this.header($(e.header)),e.content){if(e.raw)if(Array.isArray(e.content)&&e.content.every(n=>typeof n=="string"))e.content.forEach(n=>{Array.isArray(n)?n.forEach(r=>{this.add($(r))}):this.add($(n))});else if(typeof e.content=="string")this.add($(e.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(e.content));this.add("")}}getContentLines(e){if(typeof e=="string"){const n=_({showHeader:!1,style:{border:R,paddingLeft:4,paddingRight:1},terminalWidth:T(),truncateOverflow:!1,wordWrap:!0});return n.addRow([$(e)]),n.toString()}if(Array.isArray(e)&&e.every(n=>typeof n=="string"||Array.isArray(n)&&n.every(r=>typeof r=="string"))){const n=Me(T()),r=a=>Array.isArray(a)?a.map(c=>$(c)):[$(a)],s=e.map(a=>r(a)),i=je(s,n,4,1),o=_({columnWidths:i,showHeader:!1,style:{border:R,paddingLeft:4,paddingRight:1},terminalWidth:n,truncateOverflow:!1,wordWrap:!0});return s.forEach(a=>{i!==void 0&&a.length===2?o.addRow([{content:a[0],wordWrap:!1},a[1]]):o.addRow(a)}),o.toString()}if(typeof e=="object"){const n=e;if(!n.options||!n.data)throw new Error(`Must have an "options" or "data" property
|
|
4
4
|
${JSON.stringify(e)}`);const r=_({showHeader:!1,style:{border:R,paddingLeft:4,paddingRight:1},terminalWidth:T(),truncateOverflow:!1,wordWrap:!0});return n.data.forEach(s=>{Array.isArray(s)?r.addRow(s.map(i=>$(i))):r.addRow([$(s)])}),r.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
|
|
5
5
|
|
|
6
|
-
${JSON.stringify(e)}`)}}class _e extends $t{constructor(e){super();let n=e.optionList??[];const r=Array.isArray(e.hide)?e.hide:[e.hide].filter(o=>typeof o=="string"),s=Array.isArray(e.group)?e.group:[e.group].filter(o=>typeof o=="string");r.length>0&&(n=n.filter(o=>!r.includes(o.name))),e.header&&this.header($(e.header)),s.length>0&&(n=n.filter(o=>{const a=o,c=s.includes("_none")&&!a.group,l=a.group,u=this.intersect(Array.isArray(l)?l:[l],s);return c||u?o:void 0}));const i=_({showHeader:!1,style:{border:R,paddingLeft:2,paddingRight:1,...e.tableOptions?.style},terminalWidth:T()??e.tableOptions?.terminalWidth,truncateOverflow:!1,wordWrap:e.tableOptions?.wordWrap??!0,...e.tableOptions});n.forEach(o=>{const a=o;i.addRow([this.getOptionNames(a,e.reverseNameOrder??!1,e.isArgument??!1),$(a.description)])}),this.add(i.toString()),this.lines.push("")}getOptionNames(e,n,r){if(!e.name)throw new TypeError("Invalid option definition, name is required.");const s=e.type?e.type.name.toLowerCase():"string",i=e.multiple||e.lazyMultiple?"[]":"",o=e.typeLabel===void 0?Wt(`${s}${i}`):$(e.typeLabel),a=r?
|
|
7
|
-
${t.map(e=>e.optionList?new _e(e).toString():new
|
|
6
|
+
${JSON.stringify(e)}`)}}class _e extends $t{constructor(e){super();let n=e.optionList??[];const r=Array.isArray(e.hide)?e.hide:[e.hide].filter(o=>typeof o=="string"),s=Array.isArray(e.group)?e.group:[e.group].filter(o=>typeof o=="string");r.length>0&&(n=n.filter(o=>!r.includes(o.name))),e.header&&this.header($(e.header)),s.length>0&&(n=n.filter(o=>{const a=o,c=s.includes("_none")&&!a.group,l=a.group,u=this.intersect(Array.isArray(l)?l:[l],s);return c||u?o:void 0}));const i=_({showHeader:!1,style:{border:R,paddingLeft:2,paddingRight:1,...e.tableOptions?.style},terminalWidth:T()??e.tableOptions?.terminalWidth,truncateOverflow:!1,wordWrap:e.tableOptions?.wordWrap??!0,...e.tableOptions});n.forEach(o=>{const a=o;i.addRow([this.getOptionNames(a,e.reverseNameOrder??!1,e.isArgument??!1),$(a.description)])}),this.add(i.toString()),this.lines.push("")}getOptionNames(e,n,r){if(!e.name)throw new TypeError("Invalid option definition, name is required.");const s=e.type?e.type.name.toLowerCase():"string",i=e.multiple||e.lazyMultiple?"[]":"",o=e.typeLabel===void 0?Wt(`${s}${i}`):$(e.typeLabel),a=r?C(e.name):C.yellow(`--${e.name}`);if(e.alias){const c=C(`-${e.alias}`);return n?`${a}, ${c} ${o}`:`${c}, ${a} ${o}`}return`${a} ${o}`}intersect(e,n){return e.some(r=>n.includes(r))}}const K=t=>(Array.isArray(t)?t:[t]).length===0?"":`
|
|
7
|
+
${t.map(e=>e.optionList?new _e(e).toString():new Ce(e).toString()).join(`
|
|
8
8
|
`)}`,Re=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}],st="__Other",at=t=>t.charAt(0).toUpperCase()+t.slice(1),Pe=(t,e,n,r)=>{t.debug("no command given, printing general help...");let s=[...new Set(n.values())].filter(a=>!a.hidden);r&&(s=s.filter(a=>a.group===r));const i=s.reduce((a,c)=>{const l=c.group??st;return a[l]??=[],a[l].push(c),a},{}),o=a=>a.map(c=>{let l="";typeof c.alias=="string"?l=c.alias:Array.isArray(c.alias)&&(l=c.alias.join(", ")),l!==""&&(l=` [${l}]`);let u=c.name;return c.commandPath&&c.commandPath.length>0&&(u=`${c.commandPath.join(" ")} ${c.name}`),[`${N(u)}${l}`,c.description??""]});(t.raw??t.log)(K([{content:`${x(e.getCliName())} ${N("<command>")} [positional arguments] ${L("[options]")}`,header:b.cyan(" Usage ")},...Object.keys(i).map(a=>{const c=r?` ${at(r)}`:"";return{content:o(i[a]),header:a===st||r?b.green(` Available${c} Commands `):` ${b.green(` ${at(a)} `)}`}}),n.has("help")?{header:b.yellow(" Command Options "),optionList:n.get("help").options?.filter(a=>!a.hidden)}:void 0,{header:b.yellow(" Global Options "),optionList:e.getGlobalOptions()},{content:Re.filter(a=>!a.hidden).map(a=>[a.name,a.description??""]),header:b.magenta(" Environment Variables ")},{content:`Run "${x(e.getCliName())} ${N("help <command>")}" or "${x(e.getCliName())} ${N("<command>")} ${L("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},lt=(t,e)=>{const n=[];for(const r of t.values()){if(r.hidden)continue;const s=r.commandPath??[];if(s.length!==e.length)continue;let i=!0;for(const[o,a]of e.entries())if(s[o]!==a){i=!1;break}i&&n.push(r)}return n},Te=(t,e,n,r)=>{const s=n.join(" "),i=[{content:`${x(e.getCliName())} ${N(s)} ${N("<subcommand>")} [positional arguments] ${L("[options]")}`,header:b.cyan(" Usage ")},{content:r.map(o=>{const a=[...o.commandPath??[],o.name].join(" ");return[N(a),o.description??""]}),header:b.green(" Subcommands ")},{header:b.yellow(" Global Options "),optionList:e.getGlobalOptions()},{content:`Run "${x(e.getCliName())} ${N(`${s} <subcommand>`)} ${L("--help")}" for help with a specific subcommand.`,raw:!0}];(t.raw??t.log)(K(i))},Le=(t,e,n,r,s)=>{let i=s??n.get(r);if(!i)for(const u of n.values()){const d=u.commandPath?[...u.commandPath,u.name]:[u.name];if(d.at(-1)===r||d.join(" ")===r){i=u;break}}if(!i){const u=r.split(" ").filter(Boolean),d=u.length>0?lt(n,u):[];if(d.length>0){Te(t,e,u,d);return}t.error(`Command "${r}" not found`);return}const o=[],a=(i.commandPath?[...i.commandPath,i.name]:[i.name]).join(" ");if(o.push({content:`${x(e.getCliName())} ${N(a)}${i.argument?" [positional arguments]":""}${i.options?" [options]":""}`,header:b.cyan(" Usage ")}),i.description&&o.push({content:i.description,header:b.green(" Description ")}),i.argument&&o.push({header:"Command Positional Arguments",isArgument:!0,optionList:[i.argument]}),Array.isArray(i.options)&&i.options.length>0&&o.push({header:b.yellow(" Command Options "),optionList:i.options.filter(u=>!u.hidden)}),o.push({header:b.yellow(" Global Options "),optionList:e.getGlobalOptions()}),Array.isArray(i.env)&&i.env.length>0){const u=i.env.filter(d=>!d.hidden);u.length>0&&o.push({content:u.map(d=>[d.name,d.description??""]),header:b.magenta(" Environment Variables ")})}if(i.alias!==void 0&&i.alias.length>0){let u=i.alias;typeof i.alias=="string"&&(u=[i.alias]),o.splice(1,0,{content:u,header:"Alias(es)"})}Array.isArray(i.examples)&&i.examples.length>0&&o.push({content:i.examples,header:"Examples"});const c=[...i.commandPath??[],i.name],l=lt(n,c);l.length>0&&o.push({content:l.map(u=>{const d=[...u.commandPath??[],u.name].join(" ");return[N(d),u.description??""]}),header:b.green(" Subcommands ")}),(t.raw??t.log)(K(o))};class qe{argument={description:"Command to show help for (subcommand path supported, e.g. `cli help docker build`)",name:"command",type:String};name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(e){this.commands=e}execute(e){const{argument:n,command:r,commandName:s,logger:i,options:o,runtime:a}=e,{footer:c,header:l}=a.getCommandSection();l&&(i.raw??i.log)($(l));const u=s==="help"&&Array.isArray(n)&&n.length>0?n.join(" "):void 0;if(s==="help"&&u===void 0)Pe(i,a,this.commands,typeof o?.group=="string"?o.group:void 0);else{const d=u!==void 0||r===void 0||r.name==="help"?void 0:r;Le(i,a,this.commands,u??s,d)}c&&(i.raw??i.log)($(c))}}export{qe as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as
|
|
1
|
+
import{createRequire as _}from"node:module";let u;const $=t=>(u??=_(import.meta.url))(t),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=t=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[i,e]=p.versions.node.split(".").map(Number);if(i>22||i===22&&e>=3||i===20&&e>=16)return p.getBuiltinModule(t)}return $(t)},f=h("node:assert");function g(t,i){return`#compdef ${t}
|
|
2
2
|
compdef _${t} ${t}
|
|
3
3
|
|
|
4
4
|
# zsh completion for ${t} -*- shell-script -*-
|
|
@@ -331,17 +331,15 @@ function __${e}_perform_completion
|
|
|
331
331
|
|
|
332
332
|
# Extract all args except the last one
|
|
333
333
|
set -l args (commandline -opc)
|
|
334
|
-
# Extract the
|
|
335
|
-
set -l lastArg (
|
|
334
|
+
# Extract the token currently being completed (may be empty on a trailing space)
|
|
335
|
+
set -l lastArg (commandline -ct)
|
|
336
336
|
|
|
337
337
|
__${e}_debug "args: $args"
|
|
338
338
|
__${e}_debug "last arg: $lastArg"
|
|
339
339
|
|
|
340
|
-
#
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
__${e}_debug "Calling $requestComp"
|
|
344
|
-
set -l results (eval $requestComp 2> /dev/null)
|
|
340
|
+
# Pass each arg as its own token (no string join/eval, which would collapse multi-segment paths); quote "$lastArg" so an empty trailing token is still sent.
|
|
341
|
+
__${e}_debug "Calling ${i} complete -- $args[2..-1] $lastArg"
|
|
342
|
+
set -l results (${i} complete -- $args[2..-1] "$lastArg" 2> /dev/null)
|
|
345
343
|
|
|
346
344
|
# Some programs may output extra empty lines after the directive.
|
|
347
345
|
# Let's ignore them or else it will break completion.
|
|
@@ -59,15 +59,15 @@ ${f}`,i),this.line=l,this.column=o,this.codeblock=f}}let v=/^((0x[0-9a-fA-F](_?[
|
|
|
59
59
|
`&&(n+=2));let t="",u=n,a=0;for(let r=n;r<e.length;r++)if(i=e[r],f&&(i===`
|
|
60
60
|
`||i==="\r"&&e[r+1]===`
|
|
61
61
|
`))a=a&&3;else{if(i<" "&&i!==" "||i==="")throw new c("control characters are not allowed in strings",{toml:e,ptr:r});if((!a||a===3)&&i===l&&(!f||e[r+1]===l&&e[r+2]===l))return f&&(e[r+3]===l&&r++,e[r+3]===l&&r++),[a?t:t+e.slice(u,r),r+(f?3:1)];if(!a)!o&&i==="\\"&&(t+=e.slice(u,u=r),a=1);else if(a===1)if(i==="x"||i==="u"||i==="U"){let d=0,y=i==="x"?2:i==="u"?4:8;for(let b=0;b<y;b++,r++){let s=e.charCodeAt(r+1),h=s>=48&&s<=57?s-48:s>=65&&s<=70?s-65+10:s>=97&&s<=102?s-97+10:-1;if(h<0)throw new c("invalid non-hex character in unicode escape",{toml:e,ptr:r+1});d=d<<4|h}if(d<0||d>1114111||d>=55296&&d<=57343)throw new c("invalid unicode escape",{toml:e,ptr:r});t+=String.fromCodePoint(d),u=r+1,a=0}else if(i===" "||i===" ")a=2;else{if(i==="b")t+="\b";else if(i==="t")t+=" ";else if(i==="n")t+=`
|
|
62
|
-
`;else if(i==="f")t+="\f";else if(i==="r")t+="\r";else if(i==="e")t+="\x1B";else if(i==='"')t+='"';else if(i==="\\")t+="\\";else throw new c("unrecognized escape sequence",{toml:e,ptr:r});u=r+1,a=0}else if(i!==" "&&i!==" "){if(a===2)throw new c("invalid escape: only line-ending whitespace may be escaped",{toml:e,ptr:u});a=!o&&i==="\\"?1:0,u=r}}throw new c("unfinished string",{toml:e,ptr:n})}function L(e,n,i,l){if(e==="true")return!0;if(e==="false")return!1;if(e==="-inf")return-1/0;if(e==="inf"||e==="+inf")return 1/0;if(e==="nan"||e==="+nan"||e==="-nan")return NaN;if(e==="-0")return l?0n:0;let o=v.test(e);if(o||A.test(e)){if(D.test(e))throw new c("leading zeroes are not allowed",{toml:n,ptr:i});e=e.replace(/_/g,"");let t=+e;if(isNaN(t))throw new c("invalid number",{toml:n,ptr:i});if(o){if((o=!Number.isSafeInteger(t))&&!l)throw new c("integer value cannot be represented losslessly",{toml:n,ptr:i});(o||l===!0)&&(t=BigInt(e))}return t}const f=new m(e);if(!f.isValid())throw new c("invalid value",{toml:n,ptr:i});return f}function
|
|
62
|
+
`;else if(i==="f")t+="\f";else if(i==="r")t+="\r";else if(i==="e")t+="\x1B";else if(i==='"')t+='"';else if(i==="\\")t+="\\";else throw new c("unrecognized escape sequence",{toml:e,ptr:r});u=r+1,a=0}else if(i!==" "&&i!==" "){if(a===2)throw new c("invalid escape: only line-ending whitespace may be escaped",{toml:e,ptr:u});a=!o&&i==="\\"?1:0,u=r}}throw new c("unfinished string",{toml:e,ptr:n})}function L(e,n,i,l){if(e==="true")return!0;if(e==="false")return!1;if(e==="-inf")return-1/0;if(e==="inf"||e==="+inf")return 1/0;if(e==="nan"||e==="+nan"||e==="-nan")return NaN;if(e==="-0")return l?0n:0;let o=v.test(e);if(o||A.test(e)){if(D.test(e))throw new c("leading zeroes are not allowed",{toml:n,ptr:i});e=e.replace(/_/g,"");let t=+e;if(isNaN(t))throw new c("invalid number",{toml:n,ptr:i});if(o){if((o=!Number.isSafeInteger(t))&&!l)throw new c("integer value cannot be represented losslessly",{toml:n,ptr:i});(o||l===!0)&&(t=BigInt(e))}return t}const f=new m(e);if(!f.isValid())throw new c("invalid value",{toml:n,ptr:i});return f}function k(e,n=0,i=e.length){let l=e.indexOf(`
|
|
63
63
|
`,n);return e[l-1]==="\r"&&l--,l<=i?l:-1}function g(e,n){for(let i=n;i<e.length;i++){let l=e[i];if(l===`
|
|
64
64
|
`)return i;if(l==="\r"&&e[i+1]===`
|
|
65
65
|
`)return i+1;if(l<" "&&l!==" "||l==="")throw new c("control characters are not allowed in comments",{toml:e,ptr:n})}return e.length}function w(e,n,i,l){let o;for(;;){for(;(o=e[n])===" "||o===" "||!i&&(o===`
|
|
66
66
|
`||o==="\r"&&e[n+1]===`
|
|
67
|
-
`);)n++;if(l||o!=="#")break;n=g(e,n)}return n}function I(e,n,i,l,o=!1){if(!l)return n=
|
|
67
|
+
`);)n++;if(l||o!=="#")break;n=g(e,n)}return n}function I(e,n,i,l,o=!1){if(!l)return n=k(e,n),n<0?e.length:n;for(let f=n;f<e.length;f++){let t=e[f];if(t==="#"){if(f=k(e,f),f<0)break}else{if(t===i)return f+1;if(t===l||o&&(t===`
|
|
68
68
|
`||t==="\r"&&e[f+1]===`
|
|
69
69
|
`))return f}}throw new c("cannot find end of structure",{toml:e,ptr:n})}function N(e,n,i){let l=e.slice(n,i),o=l.indexOf("#");return o>-1&&(g(e,o),l=l.slice(0,o)),[l.trimEnd(),o]}function O(e,n,i,l,o){if(l===0)throw new c("document contains excessively nested structures. aborting.",{toml:e,ptr:n});let f=e[n];if(f==="["||f==="{"){let[a,r]=f==="["?$(e,n,l,o):Z(e,n,l,o);if(i){if(r=w(e,r),e[r]===",")r++;else if(e[r]!==i)throw new c("expected comma or end of structure",{toml:e,ptr:r})}return[a,r]}if(f==='"'||f==="'"){let[a,r]=T(e,n);if(i){if(r=w(e,r),e[r]&&e[r]!==","&&e[r]!==i&&e[r]!==`
|
|
70
|
-
`&&e[r]!=="\r")throw new c("unexpected character encountered",{toml:e,ptr:r});e[r]===","&&r++}return[a,r]}let t=I(e,n,",",i),u=N(e,n,t-(e[t-1]===","?1:0));if(!u[0])throw new c("incomplete key-value declaration: no value specified",{toml:e,ptr:n});return i&&u[1]>-1&&(t=w(e,n+u[1]),e[t]===","&&t++),[L(u[0],e,n,o),t]}let j=/^[a-zA-Z0-9-_]+[ \t]*$/;function
|
|
71
|
-
`&&t!=="\r"){let u,a=o,r=!1,[d,y]=
|
|
72
|
-
`&&f!=="\r"){let t=O(e,n-1,"]",i-1,l);o.push(t[0]),n=t[1]}}if(!f)throw new c("unfinished array encountered",{toml:e,ptr:n});return[o,n]}function E(e,n,i,l){let o=n,f=i,t,u=!1,a;for(let r=0;r<e.length;r++){if(r){if(o=u?o[t]:o[t]={},f=(a=f[t]).c,l===0&&(a.t===1||a.t===2))return null;if(a.t===2){let d=o.length-1;o=o[d],f=f[d].c}}if(t=e[r],(u=Object.hasOwn(o,t))&&f[t]?.t===0&&f[t]?.d)return null;u||(t==="__proto__"&&(Object.defineProperty(o,t,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(f,t,{enumerable:!0,configurable:!0,writable:!0})),f[t]={t:r<e.length-1&&l===2?3:l,d:!1,i:0,c:{}})}if(a=f[t],a.t!==l&&!(l===1&&a.t===3)||(l===2&&(a.d||(a.d=!0,o[t]=[]),o[t].push(o={}),a.c[a.i++]=a={t:1,d:!1,i:0,c:{}}),a.d))return null;if(a.d=!0,l===1)o=u?o[t]:o[t]={};else if(l===0&&u)return null;return[t,o,a.c]}function C(e,{maxDepth:n=1e3,integersAsBigInt:i}={}){let l={},o={},f=l,t=o;for(let u=w(e,0);u<e.length;){if(e[u]==="["){let a=e[++u]==="[",r=
|
|
70
|
+
`&&e[r]!=="\r")throw new c("unexpected character encountered",{toml:e,ptr:r});e[r]===","&&r++}return[a,r]}let t=I(e,n,",",i),u=N(e,n,t-(e[t-1]===","?1:0));if(!u[0])throw new c("incomplete key-value declaration: no value specified",{toml:e,ptr:n});return i&&u[1]>-1&&(t=w(e,n+u[1]),e[t]===","&&t++),[L(u[0],e,n,o),t]}let j=/^[a-zA-Z0-9-_]+[ \t]*$/;function x(e,n,i="="){let l=n-1,o=[],f=e.indexOf(i,n);if(f<0)throw new c("incomplete key-value: cannot find end of key",{toml:e,ptr:n});do{let t=e[n=++l];if(t!==" "&&t!==" ")if(t==='"'||t==="'"){if(t===e[n+1]&&t===e[n+2])throw new c("multiline strings are not allowed in keys",{toml:e,ptr:n});let[u,a]=T(e,n);l=e.indexOf(".",a);let r=e.slice(a,l<0||l>f?f:l),d=k(r);if(d>-1)throw new c("newlines are not allowed in keys",{toml:e,ptr:n+l+d});if(r.trimStart())throw new c("found extra tokens after the string part",{toml:e,ptr:a});if(f<a&&(f=e.indexOf(i,a),f<0))throw new c("incomplete key-value: cannot find end of key",{toml:e,ptr:n});o.push(u)}else{l=e.indexOf(".",n);let u=e.slice(n,l<0||l>f?f:l);if(!j.test(u))throw new c("only letter, numbers, dashes and underscores are allowed in keys",{toml:e,ptr:n});o.push(u.trimEnd())}}while(l+1&&l<f);return[o,w(e,f+1,!0,!0)]}function Z(e,n,i,l){let o={},f=new Set,t;for(n++;(t=e[n++])!=="}"&&t;){if(t===",")throw new c("expected value, found comma",{toml:e,ptr:n-1});if(t==="#")n=g(e,n);else if(t!==" "&&t!==" "&&t!==`
|
|
71
|
+
`&&t!=="\r"){let u,a=o,r=!1,[d,y]=x(e,n-1);for(let h=0;h<d.length;h++){if(h&&(a=r?a[u]:a[u]={}),u=d[h],(r=Object.hasOwn(a,u))&&(typeof a[u]!="object"||f.has(a[u])))throw new c("trying to redefine an already defined value",{toml:e,ptr:n});!r&&u==="__proto__"&&Object.defineProperty(a,u,{enumerable:!0,configurable:!0,writable:!0})}if(r)throw new c("trying to redefine an already defined value",{toml:e,ptr:n});let[b,s]=O(e,y,"}",i-1,l);f.add(b),a[u]=b,n=s}}if(!t)throw new c("unfinished table encountered",{toml:e,ptr:n});return[o,n]}function $(e,n,i,l){let o=[],f;for(n++;(f=e[n++])!=="]"&&f;){if(f===",")throw new c("expected value, found comma",{toml:e,ptr:n-1});if(f==="#")n=g(e,n);else if(f!==" "&&f!==" "&&f!==`
|
|
72
|
+
`&&f!=="\r"){let t=O(e,n-1,"]",i-1,l);o.push(t[0]),n=t[1]}}if(!f)throw new c("unfinished array encountered",{toml:e,ptr:n});return[o,n]}function E(e,n,i,l){let o=n,f=i,t,u=!1,a;for(let r=0;r<e.length;r++){if(r){if(o=u?o[t]:o[t]={},f=(a=f[t]).c,l===0&&(a.t===1||a.t===2))return null;if(a.t===2){let d=o.length-1;o=o[d],f=f[d].c}}if(t=e[r],(u=Object.hasOwn(o,t))&&f[t]?.t===0&&f[t]?.d)return null;u||(t==="__proto__"&&(Object.defineProperty(o,t,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(f,t,{enumerable:!0,configurable:!0,writable:!0})),f[t]={t:r<e.length-1&&l===2?3:l,d:!1,i:0,c:{}})}if(a=f[t],a.t!==l&&!(l===1&&a.t===3)||(l===2&&(a.d||(a.d=!0,o[t]=[]),o[t].push(o={}),a.c[a.i++]=a={t:1,d:!1,i:0,c:{}}),a.d))return null;if(a.d=!0,l===1)o=u?o[t]:o[t]={};else if(l===0&&u)return null;return[t,o,a.c]}function C(e,{maxDepth:n=1e3,integersAsBigInt:i}={}){let l={},o={},f=l,t=o;for(let u=w(e,0);u<e.length;){if(e[u]==="["){let a=e[++u]==="[",r=x(e,u+=+a,"]");if(a){if(e[r[1]-1]!=="]")throw new c("expected end of table declaration",{toml:e,ptr:r[1]-1});r[1]++}let d=E(r[0],l,o,a?2:1);if(!d)throw new c("trying to redefine an already defined table or value",{toml:e,ptr:u});t=d[2],f=d[1],u=r[1]}else{let a=x(e,u),r=E(a[0],f,t,0);if(!r)throw new c("trying to redefine an already defined table or value",{toml:e,ptr:u});let d=O(e,a[1],void 0,n,i);r[1][r[0]]=d[0],u=d[1]}if(u=w(e,u,!0),e[u]&&e[u]!==`
|
|
73
73
|
`&&e[u]!=="\r")throw new c("each key-value declaration must be followed by an end-of-line",{toml:e,ptr:u});u=w(e,u)}return l}export{m as TomlDate,c as TomlError,C as parse};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{createRequire as _}from"node:module";import{
|
|
1
|
+
import{createRequire as _}from"node:module";import{x,p as t,y as R}from"./cli-main.js";import{d as P}from"../packem_shared/pm-runner-de-jCq8q.js";import{a as M}from"../packem_shared/build-scripts-pdVmqXRm.js";import{e as v}from"../packem_shared/index-DHD8wb6Z.js";import{y as k}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{p as q}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";let j;const B=c=>(j??=_(import.meta.url))(c),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=c=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[i,f]=y.versions.node.split(".").map(Number);if(i>22||i===22&&f>=3||i===20&&f>=16)return y.getBuiltinModule(c)}return B(c)},{readdirSync:S,statSync:N}=D("node:fs"),T=(c,i={})=>{const f=v(c,"node_modules");if(!k(f))return[];const l=new Map,p=new Set,b=(n,o,r)=>{const e=`${o}@${r}`;if(p.has(e))return;p.add(e);const s=r.startsWith(c)?r.slice(c.length+1):r;let u=l.get(n);u||(u=[],l.set(n,u)),u.some($=>$.name===o)||u.push({name:o,relativePath:s})},m=(n,o="")=>{let r;try{r=S(n)}catch{return}for(const e of r){const s=v(n,e);if(e.startsWith("@")){m(s,`${e}/`);continue}if(e===".pnpm"&&o===""){let a;try{a=S(s)}catch{continue}for(const d of a){const g=v(s,d,"node_modules");k(g)&&m(g)}continue}if(e.startsWith("."))continue;const u=o+e,$=v(s,"package.json");try{if(!N(s).isDirectory()||!k($))continue;const a=q($),d=typeof a.name=="string"?a.name:u;if(typeof a.bin=="string"){const w=d.includes("/")?d.split("/").pop():d;b(w,d,s)}else if(a.bin&&typeof a.bin=="object")for(const w of Object.keys(a.bin))b(w,d,s);const g=v(s,"node_modules");k(g)&&m(g)}catch{}}};m(f);const h=[];for(const[n,o]of l)o.length<2||i[n]===!0||o.every(e=>i[`${e.name}#${n}`]===!0)||h.push({bin:n,packages:o});return h.sort((n,o)=>n.bin.localeCompare(o.bin))},V=new Set(["bun","npm","pnpm","yarn"]),F=({options:c,visConfig:i,workspaceRoot:f})=>{const l=f??process.cwd(),p=P(l),b=i?.security?.policies?.installScripts?.allow??{},m=i?.security?.allowBins??{},h=i?.security?.pinVersions===!0,n=M(l,b,{pinVersions:h}),o=T(l,m),r=i&&V.has(p.name)?x(i,p.name,l):void 0;if(c.json){process.stdout.write(`${JSON.stringify({binConflicts:o,drift:r,excess:n.excess,installed:n.installed.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),packageManager:p.name,pinVersions:h,unapproved:n.unapproved.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),versionDrift:n.versionDrift},void 0,2)}
|
|
2
2
|
`);return}if(t.info(`Build-script status (${p.name}):
|
|
3
3
|
`),n.installed.length===0&&n.unapproved.length===0&&t.success(" No installed packages declare lifecycle scripts."),n.installed.length>0){t.success(` Approved (${String(n.installed.length)}):`);for(const e of n.installed)t.info(` ✓ ${e.name} — ${e.hooks.join(", ")}`)}if(n.unapproved.length>0){t.info(""),t.warn(` Unapproved (${String(n.unapproved.length)}):`);for(const e of n.unapproved)t.info(` ✗ ${e.name} — ${e.hooks.join(", ")}`);t.notice(" Run 'vis approve-builds' to review.")}if(n.excess.length>0){t.info(""),t.warn(` Stale allowlist entries (${String(n.excess.length)}):`);for(const e of n.excess)t.info(` ! ${e}`);t.notice(" Remove these from vis.config.ts security.policies.installScripts.allow.")}if(n.versionDrift.length>0){t.info(""),t.warn(` Version drift (pinVersions: true) — ${String(n.versionDrift.length)} entr${n.versionDrift.length===1?"y":"ies"} point at outdated versions:`);for(const{from:e,to:s}of n.versionDrift)t.info(` ${e} → ${s}`);t.notice(" Update vis.config.ts security.policies.installScripts.allow keys to migrate.")}if(o.length>0){t.info(""),t.warn(` Bin conflicts (${String(o.length)}) — multiple packages expose the same bin name:`);for(const e of o)t.info(` ${e.bin} ← ${e.packages.map(s=>s.name).join(", ")}`);t.notice(" Add the bin (or 'pkg#bin') to vis.config.ts security.allowBins to silence this.")}if(r?.hasDrift){t.info("");for(const e of R(r))t.warn(e)}};export{F as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as p}from"node:module";import{F as i}from"../packem_shared/index.server-
|
|
1
|
+
import{createRequire as p}from"node:module";import{F as i}from"../packem_shared/index.server-BAjDJSEu.js";let m;const d=r=>(m??=p(import.meta.url))(r),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=r=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[e,t]=c.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return c.getBuiltinModule(r)}return d(r)},{createInterface:a}=w("node:readline"),l=(r,e)=>new Promise(t=>{r.question(e,n=>{t(n.trim())})}),y=async(r,e=!0)=>{const t=a({input:process.stdin,output:process.stdout});try{const s=await l(t,`${r} ${i(e?"[Y/n]":"[y/N]")} `);return s===""?e:/^y(?:es)?$/i.test(s)}finally{t.close()}},$=async(r,e="")=>{const t=a({input:process.stdin,output:process.stdout});try{const n=e?` ${i(`(${e})`)}`:"",s=await l(t,`${r}${n} `);return s===""?e:s}finally{t.close()}},_=async(r,e)=>{if(e.length===0)throw new Error("selectPrompt called with no options.");const t=a({input:process.stdin,output:process.stdout});try{process.stdout.write(`${r}
|
|
2
2
|
`);for(const[n,s]of e.entries())process.stdout.write(` ${n+1}) ${s.label}
|
|
3
3
|
`);for(;;){const n=await l(t,i(` [1-${e.length}] `)),s=Number.parseInt(n,10);if(!Number.isNaN(s)&&s>=1&&s<=e.length)return e[s-1].value;process.stdout.write(i(` Please enter a number between 1 and ${e.length}.
|
|
4
4
|
`))}}finally{t.close()}},b=async(r,e)=>{if(e.length===0)throw new Error("multiSelectPrompt called with no options.");const t=a({input:process.stdin,output:process.stdout});try{process.stdout.write(`${r}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{p as o}from"./cli-main.js";import{r as f}from"../packem_shared/advisories-
|
|
1
|
+
import{p as o}from"./cli-main.js";import{r as f}from"../packem_shared/advisories-0ScpWAHV.js";const d=async({fs:c,logger:u,options:r,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a workspace.");const e=r.db??f(t),s=r.format==="json";if(!r.force){o.warn(`Prune is destructive. Will remove: ${e}`),o.info("Re-run with --force to proceed."),s&&process.stdout.write(`${JSON.stringify({dbPath:e,reason:"needs --force",removed:!1})}
|
|
2
2
|
`);return}const a=[e,`${e}-wal`,`${e}-shm`,`${e}-journal`],i=[];for(const n of a)try{await c.rm(n,{force:!0}),i.push(n)}catch{}if(s){process.stdout.write(`${JSON.stringify({dbPath:e,files:i,removed:!0})}
|
|
3
3
|
`);return}o.success(`Removed ${e}.`)},v=d;export{v as advisoriesPruneExecute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as s,
|
|
1
|
+
import{p as s,g as a,h as p}from"./cli-main.js";const u=({options:t,visConfig:i,workspaceRoot:c})=>{const r=c??process.cwd(),l=i?.security?.policies?.installScripts?.allow??{},e=Object.entries(l).filter(([,o])=>o).map(([o])=>o);e.length===0&&!t.rootOnly&&(s.warn("No approved packages in security.policies.installScripts.allow — nothing to run."),!t.withRoot)||(t.rootOnly||a(r,e),(t.withRoot||t.rootOnly)&&p(r))};export{u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{x as i}from"../packem_shared/main-BP-w-K-6.js";import{redactTokens as s}from"./security.js";const f=()=>({run:async(o,t,r)=>{try{const e=await i(o,[...t],{nodeOptions:{cwd:r.cwd,env:{...process.env,COREPACK_ENABLE_DOWNLOAD_PROMPT:"0",...r.env},stdio:r.silent?["ignore","pipe","pipe"]:"inherit"},throwOnError:!1});return{exitCode:typeof e.exitCode=="number"?e.exitCode:-1,stderr:s(e.stderr??""),stdout:s(e.stdout??"")}}catch(e){return{exitCode:-1,stderr:s(e.message),stdout:""}}}}),m=()=>new a;class a{handlers=[];on(t,r,e){this.handlers.push({argsPrefix:r,command:t,respond:e})}async run(t,r,e){for(const n of this.handlers){if(n.command!==t||r.length<n.argsPrefix.length)continue;if(n.argsPrefix.every((d,c)=>d===r[c]))return n.respond(e.cwd)}return{exitCode:0,stderr:"",stdout:""}}}export{a as MockRunner,m as createMockRunner,f as createShellRunner};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{b as d,F as i,J as l}from"../packem_shared/index.server-BAjDJSEu.js";import{p as a}from"./cli-main.js";import{r as y,g}from"../packem_shared/advisories-0ScpWAHV.js";const h=n=>{if(n===0)return"0 B";const r=["B","KB","MB","GB"],o=Math.min(Math.floor(Math.log(n)/Math.log(1024)),r.length-1),s=n/1024**o;return`${s.toFixed(s<10&&o>0?1:0)} ${r[o]}`},v=n=>{if(!n)return"never";const r=Date.parse(n);if(Number.isNaN(r))return n;const o=Date.now()-r;if(o<0)return n;const s=Math.floor(o/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const t=Math.floor(s/60);return t<24?`${t}h ago`:`${Math.floor(t/24)}d ago`},$=async({logger:n,options:r,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root. Run this command inside a workspace.");const s=r.db??y(o),t=await g(o,s);if(r.format==="json"){process.stdout.write(`${JSON.stringify({dbPath:s,ecosystems:t.ecosystems.map(e=>({advisoryCount:e.advisoryCount,lastSyncIso:e.lastSyncIso,manifestEtag:e.manifestEtag??null,name:e.name})),exists:t.exists,schemaVersion:t.schemaVersion,sizeBytes:t.sizeBytes},void 0,2)}
|
|
2
2
|
`);return}if(a.info(`DB: ${s}`),!t.exists){a.warn(`No advisory DB yet. Run ${d("vis advisories sync")} to populate.`);return}if(a.info(`Schema: v${t.schemaVersion} Size: ${h(t.sizeBytes)}`),t.ecosystems.length===0){a.warn("DB exists but contains no ecosystems. Run `vis advisories sync`.");return}a.info(""),a.info("Ecosystem Advisories Last sync ETag"),a.info(i("────────── ────────── ───────────────── ──────"));for(const e of t.ecosystems){const c=e.name.padEnd(10),u=e.advisoryCount.toLocaleString().padStart(10),m=`${e.lastSyncIso||"never"} (${v(e.lastSyncIso)})`.padEnd(19),f=e.manifestEtag??i("—");a.info(`${l(c)} ${u} ${m} ${f}`)}},E=$;export{E as advisoriesStatusExecute};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{F as p}from"../packem_shared/index.server-
|
|
1
|
+
import{F as p}from"../packem_shared/index.server-BAjDJSEu.js";import{p as c}from"./cli-main.js";import{s as v}from"../packem_shared/scan-progress-5uTRdC1G.js";import{D as $,s as D}from"../packem_shared/advisories-0ScpWAHV.js";const S=o=>o?.security?.audit?.advisories??{},w=o=>o?o.split(",").map(r=>r.trim()).filter(r=>r.length>0):["npm"],b=async({logger:o,options:r,visConfig:y,workspaceRoot:l})=>{if(!l)throw new Error("Could not determine workspace root. Run this command inside a workspace.");const d=r.format==="json",u=S(y),f=r.source??u.source??$,m=w(r.ecosystem),h=m.map(s=>({id:s,label:`Sync ${s} advisories`})),a=v(h,{live:!d}),i=[];try{for(const s of m){a.start(s);const e=Date.now();try{const t=await D({allowedHosts:u.allowedHosts,dbPath:r.db,ecosystem:s,force:!!r.force,source:f,workspaceRoot:l});i.push({ecosystem:s,result:t}),t.upToDate?a.finish(s,"ok",`up to date · ${g(Date.now()-e)}`):a.finish(s,"ok",`${t.advisoriesIngested.toLocaleString()} advisories · ${g(t.durationMs)}`)}catch(t){const n=t instanceof Error?t.message:String(t);i.push({ecosystem:s,error:n}),a.finish(s,"error",n)}}}finally{a.stop()}if(d){const s={ecosystems:i.map(e=>({advisoriesIngested:e.result?.advisoriesIngested??0,dbPath:e.result?.dbPath??null,durationMs:e.result?.durationMs??0,ecosystem:e.ecosystem,error:e.error??null,upToDate:e.result?.upToDate??!1})),source:f};process.stdout.write(`${JSON.stringify(s,void 0,2)}
|
|
2
2
|
`)}else{const s=i.filter(n=>n.error),e=i.filter(n=>n.result),t=e[0];t?.result?.dbPath&&c.info(p(`DB: ${t.result.dbPath}`)),s.length===0?c.success(`Synced ${e.length} ecosystem${e.length===1?"":"s"}.`):c.error(`${s.length} ecosystem${s.length===1?"":"s"} failed to sync.`)}i.some(s=>s.error)&&(process.exitCode=1)},g=o=>o>=1e3?`${(o/1e3).toFixed(1)}s`:`${Math.round(o)}ms`,C=b;export{C as advisoriesSyncExecute};
|