workspai 0.44.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +5 -1
  2. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +1368 -0
  3. package/contracts/command-capabilities.v1.json +166 -1
  4. package/contracts/extension-cli-compatibility.v1.json +2 -1
  5. package/contracts/published-contract-catalog.v1.json +5 -0
  6. package/contracts/runtime-command-surface.v1.json +1441 -1
  7. package/dist/analyze-YLV7NVLF.js +1 -0
  8. package/dist/{artifact-remediation-plan-Z7OCSME3.js → artifact-remediation-plan-WLZGROUU.js} +1 -1
  9. package/dist/autopilot-release-YBN3SWAA.js +1 -0
  10. package/dist/{chunk-UNF72FTB.js → chunk-42G2OK64.js} +1 -1
  11. package/dist/{chunk-CL6TGI4Q.js → chunk-5GNT4RJI.js} +1 -1
  12. package/dist/chunk-6AA3WWQZ.js +2 -0
  13. package/dist/{chunk-P4SWTY5X.js → chunk-6ZENXBMG.js} +1 -1
  14. package/dist/{chunk-LGP6WXS2.js → chunk-BJLE5CH7.js} +1 -1
  15. package/dist/{chunk-OW4UNG27.js → chunk-DXPU4DDV.js} +1 -1
  16. package/dist/{chunk-7EIMPQR3.js → chunk-G3H5R3RR.js} +1 -1
  17. package/dist/{chunk-JICOD2GI.js → chunk-HYJK7W3B.js} +1 -1
  18. package/dist/{chunk-TRMDODFM.js → chunk-IMUU5Q2V.js} +1 -1
  19. package/dist/{chunk-M4VITK6X.js → chunk-K63BSU56.js} +2 -2
  20. package/dist/{chunk-YUX4YFGL.js → chunk-KPPGZCUW.js} +1 -1
  21. package/dist/{chunk-B66A4TVP.js → chunk-KU4S7RCM.js} +1 -1
  22. package/dist/{chunk-V5JN4TDX.js → chunk-LCRROMRR.js} +1 -1
  23. package/dist/{chunk-JHC6SCJC.js → chunk-NHN4QXPP.js} +1 -1
  24. package/dist/{chunk-7IHLTPZ6.js → chunk-OOOPYUL2.js} +1 -1
  25. package/dist/{chunk-L3E6IRUQ.js → chunk-P7SCWJFG.js} +1 -1
  26. package/dist/{chunk-2QN6BMM7.js → chunk-QWU2CZBG.js} +1 -1
  27. package/dist/{chunk-L2Q7B2OJ.js → chunk-V2H2KRMZ.js} +1 -1
  28. package/dist/{chunk-NTXO7BMH.js → chunk-WANW4QA4.js} +1 -1
  29. package/dist/{chunk-VA5MRHKM.js → chunk-ZWO6K24C.js} +1 -1
  30. package/dist/{create-DFAWAS5C.js → create-KFR6FLRT.js} +1 -1
  31. package/dist/{doctor-PVSWDBJL.js → doctor-YJDM5XBH.js} +1 -1
  32. package/dist/index.d.ts +37 -4
  33. package/dist/index.js +180 -169
  34. package/dist/pipeline-FEDYO3IA.js +5 -0
  35. package/dist/{workspace-FQT3QIRS.js → workspace-PLXOO6ST.js} +1 -1
  36. package/dist/{workspace-agent-sync-ZYCPXTU3.js → workspace-agent-sync-G5YVI3BJ.js} +1 -1
  37. package/dist/{workspace-context-WAGGJCDL.js → workspace-context-E3UFWL5X.js} +1 -1
  38. package/dist/{workspace-contract-SEI4SNSG.js → workspace-contract-LQJDZV36.js} +1 -1
  39. package/dist/workspace-explain-G74ZIF23.js +1 -0
  40. package/dist/{workspace-feedback-RCB25NFO.js → workspace-feedback-YY6WQPWQ.js} +1 -1
  41. package/dist/{workspace-foundation-KXDL6P6X.js → workspace-foundation-3C2DLCVI.js} +1 -1
  42. package/dist/{workspace-history-M4QQBIPB.js → workspace-history-VF3CHDYQ.js} +1 -1
  43. package/dist/{workspace-intelligence-QOGD2TZS.js → workspace-intelligence-3GG7GEDQ.js} +1 -1
  44. package/dist/{workspace-mcp-serve-CEFKEMYG.js → workspace-mcp-serve-MJMUV4RY.js} +1 -1
  45. package/dist/{workspace-model-GMSRBICO.js → workspace-model-NG45SRM5.js} +1 -1
  46. package/dist/{workspace-registry-summary-S52SEJAG.js → workspace-registry-summary-JM2XY52C.js} +1 -1
  47. package/dist/workspace-run-WEQYIERE.js +1 -0
  48. package/dist/{workspace-verify-NP4GMFSV.js → workspace-verify-ZNT6JX7D.js} +1 -1
  49. package/dist/{workspace-watch-IIBH3Y25.js → workspace-watch-W47T4RX2.js} +1 -1
  50. package/docs/commands-reference.md +14 -1
  51. package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +27 -6
  52. package/package.json +2 -1
  53. package/scripts/prepack-enterprise.mjs +4 -0
  54. package/dist/analyze-6OCBM4ID.js +0 -1
  55. package/dist/autopilot-release-LI2WJCEW.js +0 -1
  56. package/dist/chunk-FWJV7CCI.js +0 -2
  57. package/dist/pipeline-ND734AJM.js +0 -5
  58. package/dist/workspace-explain-MVGGRCDN.js +0 -1
  59. package/dist/workspace-run-VC4OUPRF.js +0 -1
@@ -0,0 +1 @@
1
+ export{b as printAnalyzeReport,a as runAnalyze}from'./chunk-P7SCWJFG.js';
@@ -1,3 +1,3 @@
1
- import {a}from'./chunk-2E6WGUN6.js';import {c,g,d}from'./chunk-FWJV7CCI.js';import y from'path';import {existsSync}from'fs';import x from'fs-extra';var I=[{artifactKind:"bootstrap-compliance",cardId:"bootstrap",fileNames:["bootstrap-compliance.latest.json"]},{artifactKind:"doctor-workspace",cardId:"doctor",fileNames:["doctor-remediation-plan-last-run.json"]},{artifactKind:"analyze",cardId:"analyze",fileNames:["analyze-last-run.json"]},{artifactKind:"readiness",cardId:"readiness",fileNames:["release-readiness-last-run.json"]},{artifactKind:"pipeline",cardId:"pipeline",fileNames:["pipeline-last-run.json"]},{artifactKind:"workspace-run",cardId:"workspaceRun",fileNames:["workspace-run-last.json"]},{artifactKind:"workspace-verify",cardId:"workspaceVerify",fileNames:["workspace-verify-last-run.json"]}];function m(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function f(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0):[]}function u(e){return [...new Set(e.map(r=>r.trim()).filter(Boolean))]}function K(e,r,t){return t?r:y.relative(e,r)}function C(e){let r=e?.trim()||"npx workspai bootstrap";if(!/(?:^|\s)--ci(?:\s|$)/.test(r)&&/(?:^|\s)--json(?:\s|$)/.test(r))return r.replace(/(?:^|\s)--json(?:\s|$)/,i=>{let n=i.startsWith(" ")?" ":"",c=i.endsWith(" ")?" ":"";return `${n}--ci --json${c}`}).trim();let t=/(?:^|\s)--ci(?:\s|$)/.test(r)?r:`${r} --ci`;return /(?:^|\s)--json(?:\s|$)/.test(t)?t:`${t} --json`}function M(e){return `${JSON.stringify({schemaVersion:"rapidkit.compatibility-matrix.v1",generatedAt:e,source:"workspai workspace remediation-plan",runtimes:{},notes:["Minimal enterprise baseline. Add runtime and toolchain entries as governance matures."]},null,2)}
1
+ import {a}from'./chunk-2E6WGUN6.js';import {c,g,d}from'./chunk-6AA3WWQZ.js';import y from'path';import {existsSync}from'fs';import x from'fs-extra';var I=[{artifactKind:"bootstrap-compliance",cardId:"bootstrap",fileNames:["bootstrap-compliance.latest.json"]},{artifactKind:"doctor-workspace",cardId:"doctor",fileNames:["doctor-remediation-plan-last-run.json"]},{artifactKind:"analyze",cardId:"analyze",fileNames:["analyze-last-run.json"]},{artifactKind:"readiness",cardId:"readiness",fileNames:["release-readiness-last-run.json"]},{artifactKind:"pipeline",cardId:"pipeline",fileNames:["pipeline-last-run.json"]},{artifactKind:"workspace-run",cardId:"workspaceRun",fileNames:["workspace-run-last.json"]},{artifactKind:"workspace-verify",cardId:"workspaceVerify",fileNames:["workspace-verify-last-run.json"]}];function m(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function f(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0):[]}function u(e){return [...new Set(e.map(r=>r.trim()).filter(Boolean))]}function K(e,r,t){return t?r:y.relative(e,r)}function C(e){let r=e?.trim()||"npx workspai bootstrap";if(!/(?:^|\s)--ci(?:\s|$)/.test(r)&&/(?:^|\s)--json(?:\s|$)/.test(r))return r.replace(/(?:^|\s)--json(?:\s|$)/,i=>{let n=i.startsWith(" ")?" ":"",c=i.endsWith(" ")?" ":"";return `${n}--ci --json${c}`}).trim();let t=/(?:^|\s)--ci(?:\s|$)/.test(r)?r:`${r} --ci`;return /(?:^|\s)--json(?:\s|$)/.test(t)?t:`${t} --json`}function M(e){return `${JSON.stringify({schemaVersion:"rapidkit.compatibility-matrix.v1",generatedAt:e,source:"workspai workspace remediation-plan",runtimes:{},notes:["Minimal enterprise baseline. Add runtime and toolchain entries as governance matures."]},null,2)}
2
2
  `}function N(e){return `${JSON.stringify({schema_version:"1.0",enabled:false,strategy:"on-demand",artifacts:[],created_at:e,note:"Minimal enterprise baseline. Set enabled: true and add artifact entries to activate mirroring."},null,2)}
3
3
  `}function P(e){let r=e.payload,t=f(r.blockers),i=f(r.blockingReasons),n=f(r.failures),c=f(r.reasons),d=f(r.policyViolations),a=m(r.summary),l=f(a?.blockers);if(e.artifactKind==="analyze"){let o=(Array.isArray(r.findings)?r.findings:[]).map(s=>m(s)).filter(s=>!!s).map(s=>String(s.message??s.title??s.id??"").trim()).filter(Boolean);return u([...t,...o,...i])}if(e.artifactKind==="workspace-run"){let g=m(r.stages),o=Object.entries(g??{}).flatMap(([s,b])=>{let A=m(b);return (Array.isArray(A?.projects)?A.projects:[]).map(p=>m(p)).filter(p=>!!p).filter(p=>p.status==="failed"||p.ok===false).map(p=>`${s}: ${String(p.project??p.name??"project")} failed`)});return u([...t,...o,...i])}return u([...t,...i,...n,...c,...d,...l])}function k(e){return {id:e.id,artifactKind:e.artifactKind,cardId:e.cardId,title:e.title,order:e.order,phase:e.phase,scope:"workspace",status:e.status??"ready",mode:e.mode,risk:e.risk,requiresApproval:true,blocker:e.blocker,summary:e.summary,...e.command?{command:e.command}:{},verifyCommand:e.verifyCommand,cwd:"workspace",files:e.files??[],...e.operation?{operation:e.operation}:{},rollback:{available:!!e.operation,strategy:e.operation?"idempotent":"none"},notes:e.notes??[]}}function S(e){let r=[],t=C("npx workspai bootstrap --json");for(let i of e.blockers)i.includes("profile.enterprise.ci")&&r.push(k({id:"bootstrap.enterprise-ci",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Run bootstrap in deterministic CI mode",order:10,phase:"bootstrap-preflight",blocker:i,summary:"Enterprise bootstrap compliance requires --ci for deterministic execution.",mode:"run-command",risk:"safe",command:t,verifyCommand:t})),i.includes("profile.enterprise.compatibility-matrix")&&r.push(k({id:"bootstrap.compatibility-matrix",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Create enterprise compatibility matrix baseline",order:20,phase:"bootstrap-config",blocker:i,summary:"Create the missing compatibility matrix baseline without overwriting user data.",mode:"edit-file",risk:"safe",verifyCommand:t,files:[".workspai/compatibility-matrix.json"],operation:{type:"file-create",path:".workspai/compatibility-matrix.json",content:M(e.generatedAt),overwrite:false}})),i.includes("profile.enterprise.mirror-config")&&r.push(k({id:"bootstrap.mirror-config",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Create enterprise mirror config baseline",order:30,phase:"bootstrap-config",blocker:i,summary:"Create the missing mirror configuration baseline without enabling mirroring.",mode:"edit-file",risk:"safe",verifyCommand:t,files:[".workspai/mirror-config.json"],operation:{type:"file-create",path:".workspai/mirror-config.json",content:N(e.generatedAt),overwrite:false}}));return r}function $(e){let t={analyze:{title:"Refresh analyze evidence",phase:"analysis",command:"npx workspai analyze --strict --json",verify:"npx workspai analyze --strict --json"},readiness:{title:"Refresh release readiness",phase:"release-readiness",command:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",verify:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json"},pipeline:{title:"Rerun governance pipeline",phase:"governance-pipeline",command:"npx workspai pipeline --json --strict",verify:"npx workspai pipeline --json --strict"},"workspace-run":{title:"Rerun failed workspace stage",phase:"fleet-run",command:e.ciMode?"npx workspai workspace run test --strict --json":"npx workspai workspace run test --json",verify:e.ciMode?"npx workspai workspace run test --strict --json":"npx workspai workspace run test --json"},"workspace-verify":{title:"Refresh workspace verify gate",phase:"verification",command:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json",verify:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json"},"doctor-workspace":{title:"Use Doctor remediation plan",phase:"doctor-remediation",command:"npx workspai doctor workspace --plan --json",verify:"npx workspai doctor workspace --json"}}[e.report.artifactKind]??{title:"Refresh artifact evidence",phase:"evidence-refresh",command:"npx workspai pipeline --json --strict",verify:"npx workspai pipeline --json --strict"};return k({id:`${e.report.cardId}.refresh.${e.order}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:t.title,order:e.order,phase:t.phase,blocker:e.blocker,summary:"No deterministic file operation is available for this artifact yet; refresh the evidence and continue with the card-specific plan.",mode:e.report.artifactKind==="doctor-workspace"?"verify-before-fix":"run-command",risk:"guarded",status:e.report.artifactKind==="doctor-workspace"?"review-required":"ready",command:t.command,verifyCommand:t.verify,notes:e.report.artifactKind==="doctor-workspace"?["Read doctor-remediation-plan-last-run.json for ordered file-level steps."]:[]})}async function O(e){let r=[c(e,".workspai/reports"),d(e,".workspai/reports")],t=[],i=new Set;for(let n of I)for(let c of n.fileNames){let d=(await Promise.all(r.map(a=>y.join(a,c)))).find(a=>existsSync(a));if(!(!d||i.has(`${n.artifactKind}:${c}`))){i.add(`${n.artifactKind}:${c}`);try{let a=await x.readJSON(d),l=m(a);if(!l)continue;t.push({artifactKind:n.artifactKind,cardId:n.cardId,fileName:c,absolutePath:d,payload:l});}catch{t.push({artifactKind:n.artifactKind,cardId:n.cardId,fileName:c,absolutePath:d,payload:{blockers:[`${n.artifactKind}: report exists but could not be parsed.`]}});}}}return t}async function F(e){let r=y.resolve(e.workspacePath),t=e.includeAbsolutePaths===true,i=e.ciMode===true,n=new Date().toISOString(),c$1=c(r,".workspai/reports"),d=await O(r),a$1=[],l=1;for(let o of d){let s=P(o);if(s.length!==0){if(o.artifactKind==="bootstrap-compliance"){a$1.push(...S({blockers:s,generatedAt:n})),l=a$1.length+1;continue}for(let b of s.slice(0,8))a$1.push($({report:o,blocker:b,order:l,ciMode:i})),l+=1;}}let g={safe:a$1.filter(o=>o.risk==="safe").length,guarded:a$1.filter(o=>o.risk==="guarded").length,invasive:a$1.filter(o=>o.risk==="invasive").length};return {schemaVersion:a,generatedAt:n,workspace:{name:y.basename(r),...t?{path:r}:{}},source:{command:"workspace remediation-plan",reportsDir:K(r,c$1,t),includeAbsolutePaths:t,ciMode:i},summary:{artifactsScanned:d.length,cardsCovered:u(a$1.map(o=>o.cardId)).length,totalActions:a$1.length,executableActions:a$1.filter(o=>o.status==="ready").length,risk:g},actions:a$1}}async function W(e,r){return g(r,".workspai/reports/artifact-remediation-plan-last-run.json",e)}export{F as buildArtifactRemediationPlan,W as writeArtifactRemediationPlan};
@@ -0,0 +1 @@
1
+ export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-5GNT4RJI.js';
@@ -1 +1 @@
1
- import {c as c$1}from'./chunk-B66A4TVP.js';import {a as a$2,b as b$2}from'./chunk-PYCJWW4B.js';import {b as b$1,c,d}from'./chunk-7IHLTPZ6.js';import {j,a as a$1,o,g as g$1,d as d$1,p,f as f$1}from'./chunk-VA5MRHKM.js';import {n,b as b$3}from'./chunk-JICOD2GI.js';import {a as a$3}from'./chunk-2QN6BMM7.js';import {f,g}from'./chunk-FWJV7CCI.js';import {a as a$4}from'./chunk-LG6RFLPZ.js';import {b,a}from'./chunk-5AKYMAIL.js';import m from'path';import v from'fs-extra';var re="rapidkit-blocker-resolution-v1";function ie(e){let t=e.blockers.map(s=>s.trim()).filter(Boolean).slice(0,12),r=e.stderrTail?.trim().slice(-400)??"";return b$3({blockers:t,exitCode:e.exitCode??null,stderrTail:r})}function me(e){let t=e.trim().toLowerCase();return t?t.includes("missing evidence")||t.includes(": missing")||t.includes("artifact missing")||t.includes("not found on disk")?"artifact-missing":t.includes("policy.")||t.includes("contract")?"config-fixable":t.includes("impact")||t.includes("untracked")||t.includes("grounding")?"semantic-attention":t.includes("failed")||t.includes("blocked")||t.includes(": fail")?"command-failed-repeat":"config-fixable":"unresolvable-without-human"}function ge(e){let t=me(e.reason),r=ie({blockers:[e.reason]}),s=t==="artifact-missing"?[{actionKind:"run-once",detail:e.sourceCommand?`Run the source command once: ${e.sourceCommand}`:"Run the mapped workspace intelligence command once to generate the missing artifact.",studioActionId:"run-analyze"}]:t==="semantic-attention"?[{actionKind:"commit-files",detail:"Review workspace-level grounding files (AGENTS.md, agent-sync outputs) and commit or refresh the impact baseline."},{actionKind:"refresh-baseline",detail:"Refresh snapshot + diff + impact before re-running verify."}]:[{actionKind:"edit-file",detail:"Apply the smallest safe file or policy fix for this blocker before re-running verification.",studioActionId:"fix-lens"}];return {schemaVersion:re,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:r,commandRetryHint:t==="artifact-missing"?"Run the source command once, then verify.":"Do not re-run the same failing command; fix the source issue first, then verify.",fixHints:s,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}}function ne(e){return Array.from(new Set(e.blockingReasons.map(r=>r.trim()).filter(Boolean))).slice(0,12).map((r,s)=>ge({reason:r,blockerId:`blocker-${s+1}`,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}))}function ke(e){let t=e.toLowerCase();return t.includes("stale")||t.includes("missing evidence")||t.includes("no projects")||t.includes("projects.empty")||t.includes("projects discovered")||t.includes("projects.missing")||t.includes("not yet run")||t.includes("doctor-last-run")||t.includes("doctor-project-last-run")||t.includes("doctor-remediation-plan-last-run")||t.includes("doctor-fix-result-last-run")||t.includes("pipeline-last-run")||t.includes("release-readiness")||t.includes("analyze-last-run")||t.includes("analyze reported")||t.includes("analyze verdict")||t.includes("analyze needs attention")||t.includes("toolchain.lock")||t.includes("not pinned")||t.includes("readiness:")||t.includes("env:")||t.includes("workspace-run-last")||t.includes("pre-project")||t.includes("before adding projects")||t.includes("workspace.projects.missing")||t.includes("no backend projects")||t.includes("index.json")||t.includes("workspace-intelligence-history")||t.includes("validation warning")||t.includes("workspace model validation")||t.includes("workspace.marker")||t.includes("no project roots")||t.includes("no infrastructure services")||t.includes("infra/overrides")||t.includes("infra dependencies")||t.includes("contract verify")||t.includes("contract inspect")||t.includes("publish verify evidence")}function he(e){return e.length===0||e.every(t=>ke(t))}function oe(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&he(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function Ge(e,t){let r=t&&t!=="ready"?` (${t.replace(/-/g," ")})`:"";return e===0?`Workspace scaffold ready${r} \u2014 add your first project to continue.`:`Workspace scaffold${r}: ${e} pre-project signal(s) \u2014 add your first project to continue.`}var ce=b.verify,T=a.verify;function ye(e,t){return m.isAbsolute(t)?t:m.join(e,t)}async function ae(e){let t=await v.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e}`);let r=t;if(r.schemaVersion!==f$1)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);a$4(t,"contracts/workspace-intelligence/workspace-impact.v1.json",`Workspace impact ${e}`);let s=r;a$4(s.diff,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Embedded workspace diff in ${e}`);let i=[];s.summary.affectedProjects!==s.affectedProjects.length&&i.push("summary.affectedProjects does not match affectedProjects.length"),s.summary.workspaceItems!==s.workspaceImpact.length&&i.push("summary.workspaceItems does not match workspaceImpact.length"),s.summary.recommendedCommands!==s.verificationPlan.length&&i.push("summary.recommendedCommands does not match verificationPlan.length"),s.summary.blastRadius.directlyAffected!==s.affectedProjects.length&&i.push("blastRadius.directlyAffected does not match affectedProjects.length"),s.summary.blastRadius.transitivelyAffected!==s.transitiveImpact.length&&i.push("blastRadius.transitivelyAffected does not match transitiveImpact.length");let n=s.transitiveImpact.reduce((a,l)=>Math.max(a,l.distance??0),0);s.summary.blastRadius.maxDistance!==n&&i.push("blastRadius.maxDistance does not match transitive impact distances");let g=s.diff.currentModel.graph?.edges.length??0;if(s.summary.blastRadius.graphEdges!==g&&i.push("blastRadius.graphEdges does not match the embedded model graph"),s.summary.changed!==s.diff.summary.changed&&i.push("summary.changed does not match embedded diff summary"),s.fromRef!==s.diff.fromRef&&i.push("fromRef does not match embedded diff fromRef"),s.workspace.name!==s.diff.currentModel.workspace.name&&i.push("workspace.name does not match the embedded model"),s.diff.toHash!==j(s.diff.currentModel)&&i.push("embedded diff current-model hash does not match toHash"),i.length>0)throw new Error(`Workspace impact semantic integrity failed: ${i.join("; ")} (${e})`);return s}function ve(e){let t=new Set,r=[];for(let s of e){let i=`${s.scope}:${s.project??""}:${s.display}`;t.has(i)||(t.add(i),r.push(s));}return r}function be(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===r}function we(e,t){if(e.id==="workspace.doctor")return m.join(t,a.doctor);if(e.id==="workspace.contract.verify")return m.join(t,a.contractVerify);if(e.id==="workspace.readiness")return m.join(t,a.readiness);if(e.id==="workspace.analyze")return m.join(t,".workspai","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return m.join(t,".workspai","reports","pipeline-last-run.json");if(e.id==="workspace.doctor-fix")return m.join(t,".workspai","reports","doctor-fix-result-last-run.json");if(e.id.startsWith("project.")&&e.id.includes("."))return m.join(t,".workspai","reports","workspace-run-last.json")}function C(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function Re(e){let t=C(e.healthScore),r=typeof t?.errors=="number"?t.errors:0,s=typeof t?.percent=="number"?t.percent:void 0;return r>0?{status:"fail",message:`Doctor evidence reports ${r} error(s).`}:typeof s=="number"&&s<70?{status:"warn",message:`Doctor health score is ${s}%.`}:{status:"pass",message:"Doctor evidence is present and healthy."}}function Ce(e){let t=typeof e.overallStatus=="string"?e.overallStatus:"unknown";return t==="fail"?{status:"fail",message:"Release readiness evidence reports blocking failures."}:t==="warn"?{status:"warn",message:"Release readiness evidence reports warnings."}:t==="pass"?{status:"pass",message:"Release readiness evidence passed."}:{status:"warn",message:`Release readiness evidence status is ${t}.`}}function We(e){let t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||t==="fail"?{status:"fail",message:"Workspace contract verify evidence failed."}:t==="passed"||t==="pass"?{status:"pass",message:"Workspace contract verify evidence passed."}:{status:"warn",message:`Workspace contract verify evidence status is ${t}.`}}function xe(e){let t=C(e.summary);if(t?.blocking===true||e.blocking===true)return {status:"fail",message:"Analyze evidence reports blocking findings."};let s=typeof t?.status=="string"?t.status:void 0;return s==="warn"||s==="warning"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is present."}}function je(e){let t=e.schemaVersion==="rapidkit-doctor-fix-result-v1"?e:e.fixResult;if(!t||typeof t!="object"||Array.isArray(t))return {status:"skipped",message:"Doctor fix result not present; run doctor workspace --fix --json to record fixes."};let r=t,s=Array.isArray(r.remainingBlockers)?r.remainingBlockers:[];if(s.length>0)return {status:"fail",message:`Doctor fix result reports ${s.length} remaining blocker(s).`};let i=Array.isArray(r.appliedFixes)?r.appliedFixes:[];return i.length===0?{status:"pass",message:"Doctor fix result recorded with no remaining blockers."}:{status:"pass",message:`Doctor fix result recorded ${i.length} applied fix(es) with no remaining blockers.`}}async function Ae(e,t){let r=await f(e,".workspai/reports/doctor-remediation-plan-last-run.json");if(!r)return false;try{let s=C(await v.readJson(r));if(!s||(Array.isArray(s.steps)?s.steps:[]).length>0)return false;let n=typeof s.generatedAt=="string"?s.generatedAt:void 0;if(!n||!t)return true;let g=Date.parse(n),a=Date.parse(t);return !Number.isFinite(g)||!Number.isFinite(a)?true:g>=a}catch{return false}}function Ee(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function Se(e){let t=C(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:r==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:r==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function Pe(e,t,r){let s=Ee(t),i=c$1(e,s??void 0);if(!i)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let n=i.stage;if(s&&n!==s)return {status:"missing",message:`Workspace run evidence is for stage "${n}", expected "${s}".`};let g=Array.isArray(i.projects)?i.projects:[],a=t.project?.toLowerCase();if(!a)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let l=g.find(d=>{let p=C(d);if(!p)return false;let c=typeof p.projectName=="string"?p.projectName.toLowerCase():"",o=["projectPath","relativePath","path"].map(f=>p[f]).filter(f=>typeof f=="string"&&f.trim().length>0).map(f=>f.replace(/\\/g,"/").toLowerCase());return c===a||o.some(f=>f.endsWith(`/${a}`)||f===a)});if(l){let d=R(i.generatedAt,r,`Workspace run evidence for ${t.project??t.id}`);if(d)return {status:"fail",message:d};let p=C(l),c=typeof p?.status=="string"?p.status:"unknown";return c==="failed"?{status:"fail",message:`Workspace run evidence failed for ${t.project}.`}:c==="passed"?{status:"pass",message:`Workspace run evidence passed for ${t.project}.`}:c==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}:{status:"warn",message:`Workspace run evidence status is ${c} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function R(e,t,r){if(!t)return null;if(typeof e!="string"||e.trim().length===0)return `${r} is stale: missing generatedAt timestamp (required after impact ${t}).`;let s=Date.parse(e),i=Date.parse(t);return Number.isFinite(s)?Number.isFinite(i)&&s<i?`${r} is stale: generated at ${e}, before impact ${t}.`:null:`${r} is stale: invalid generatedAt timestamp (required after impact ${t}).`}async function Ie(e,t,r,s){let i=we(e,t),n=i?m.relative(t,i).split(m.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!r)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"skipped",required:e.required,message:"Workspace contract is not present; contract verify skipped."};let g=i?await f(t,n??""):null;if(!i||!g)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:n,message:n?`Missing evidence report: ${n}`:"No evidence mapping exists for this command."};let a=C(await v.readJson(g));if(!a)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:n,message:"Evidence report is not a JSON object."};let l;if(e.id==="workspace.doctor"){let d=R(a.generatedAt,s,"Doctor evidence");d?l={status:"fail",message:d}:l=Re(a);}else if(e.id==="workspace.readiness"){let d=R(a.generatedAt,s,"Release readiness evidence");d?l={status:"fail",message:d}:l=Ce(a);}else if(e.id==="workspace.contract.verify"){let d=R(a.generatedAt,s,"Workspace contract verify evidence");d?l={status:"fail",message:d}:l=We(a);}else if(e.id==="workspace.analyze"){let d=R(a.generatedAt,s,"Analyze evidence");d?l={status:"fail",message:d}:l=xe(a);}else if(e.id==="workspace.pipeline"){let d=R(a.generatedAt,s,"Pipeline evidence");d?l={status:"fail",message:d}:l=Se(a);}else if(e.id==="workspace.doctor-fix"){let d=a.schemaVersion==="rapidkit-doctor-fix-result-v1"?a:a.fixResult,p=C(d),c=typeof p?.generatedAt=="string"?p.generatedAt:void 0,o=R(c,s,"Doctor fix result");o?l={status:"fail",message:o}:await Ae(t,c)?l={status:"skipped",message:"No current doctor remediation steps are pending."}:l=je(a);}else if(e.id.startsWith("project."))l=Pe(a,e,s);else {let d=R(a.generatedAt,s,"Evidence report");d?l={status:"fail",message:d}:l={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:l.status,required:e.required,evidencePath:n,message:l.message}}function Ve(e,t={blockingReasons:[],needsAttention:false}){let r=e.filter(c=>c.status==="pass").length,s=e.filter(c=>c.status==="warn").length,i=e.filter(c=>c.status==="fail").length,n=e.filter(c=>c.status==="missing").length,g=e.filter(c=>c.status==="skipped").length,a=e.filter(c=>c.required&&(c.status==="fail"||c.status==="missing")).map(c=>`${c.id}: ${c.message}`),l=e.filter(c=>c.required&&c.status==="missing").length,d="ready",p=0;return a.length>0||t.blockingReasons.length>0?(d="blocked",p=2):(s>0||l>0||t.needsAttention)&&(d="needs-attention",p=1),{verdict:d,exitCode:p,stepsPassed:r,stepsWarn:s,stepsFailed:i,stepsMissing:n,stepsSkipped:g}}function $e(e,t){let r=x(e.affectedProjects.map(o=>o.project?.name).filter(o=>typeof o=="string")),s=new Set(r.map(o=>o.toLowerCase())),i=x(e.transitiveImpact.map(o=>o.project?.name).filter(o=>typeof o=="string").filter(o=>!s.has(o.toLowerCase()))),n=new Map;for(let o of t){if(o.scope!=="project"||!o.project)continue;let f=o.project.toLowerCase(),h=n.get(f)??[];h.push(o),n.set(f,h);}let g=[],a=[],l=[],d=[],p=false,c=(o,f)=>{let h=n.get(o.toLowerCase())??[];if(h.length===0){l.push(o);return}let j=h.filter(k=>k.status==="fail"),b=h.filter(k=>k.status==="missing"),A=b.filter(k=>k.required),E=h.some(k=>k.status==="pass"||k.status==="warn");if(j.length>0){a.push(o),d.push(`graph.subgraph.${o}: ${f} has failed verification evidence (${j.map(k=>k.id).join(", ")}).`);return}if(A.length>0){a.push(o),d.push(`graph.subgraph.${o}: ${f} has missing required verification evidence (${A.map(k=>k.id).join(", ")}).`);return}if(b.length>0){a.push(o),p=true;return}if(E){g.push(o);return}l.push(o);};for(let o of r)c(o,"directly-changed");for(let o of i)c(o,"transitive dependent");return {subgraph:{totalProjects:r.length+i.length,directlyChanged:r,transitiveDependents:i,covered:x(g),uncovered:x(a),unverifiable:x(l)},blockingReasons:d,needsAttention:p}}function x(e){return [...new Set(e)].sort((t,r)=>t.localeCompare(r))}async function Fe(e){let t=m.resolve(e.workspacePath);if(e.fromImpactPath){let n=ye(t,e.fromImpactPath);return {impact:await ae(n),fromImpactRef:m.relative(t,n).split(m.sep).join("/"),impactFromDisk:true}}let r=m.join(t,g$1);if(await v.pathExists(r))return {impact:await ae(r),fromImpactRef:g$1,impactFromDisk:true};let s=m.join(t,d$1);if(await v.pathExists(s))return {impact:await p({workspacePath:t,fromPath:d$1,scope:e.scope,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),fromImpactRef:d$1,impactFromDisk:false};let i=await n({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {impact:{schemaVersion:f$1,generatedAt:(e.now??new Date).toISOString(),fromRef:"baseline",diffRef:a.diff,workspace:{name:i.workspace.name,profile:i.workspace.profile,type:i.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0,blastRadius:{directlyAffected:0,transitivelyAffected:0,maxDistance:0,graphEdges:i.graph?.edges.length??0}},affectedProjects:[],transitiveImpact:[],criticalPathHotspots:[],workspaceImpact:[],verificationPlan:[],agentBrief:{headline:"Baseline workspace verify run.",bullets:["No impact report or snapshot was available; baseline gates were evaluated."],unsafeAssumptions:["Do not claim runtime verification passed unless evidence exists."]},diff:{schemaVersion:b.diff,generatedAt:(e.now??new Date).toISOString(),fromRef:"baseline",toRef:a.model,fromHash:"baseline",toHash:"baseline",summary:{changed:false,addedProjects:0,removedProjects:0,changedProjects:0,workspaceChanges:0,validationChanges:0,gitChangedFiles:0},git:{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:[],currentModel:i}},impactFromDisk:false}}function Oe(e,t){if(t)return e.generatedAt}async function lt(e){let t=m.resolve(e.workspacePath),{impact:r,fromImpactRef:s,impactFromDisk:i}=await Fe(e),n$1=r.diff.currentModel,g=i?await n({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}):n$1,a=[];i&&j(g)!==r.diff.toHash&&a.push("workspace.impact: Impact evidence is stale because the current workspace model no longer matches the embedded model. Regenerate diff and impact.");let l=r.diff.git;if(i&&l?.available){let u=a$1(t,{ref:l.ref}),pe=r.diff.changes.filter(y=>y.type.startsWith("git.")).map(y=>`${y.type}:${y.target.replace(/^git:/,"")}`).sort(),fe=[...u.changedFiles.map(y=>`git.file.changed:${y}`),...u.untrackedFiles.map(y=>`git.untracked:${y}`),...u.deletedFiles.map(y=>`git.deleted:${y}`)].sort();(!u.available||u.commit!==l.commit||JSON.stringify(fe)!==JSON.stringify(pe))&&a.push("workspace.impact: Impact evidence is stale because Git changes no longer match the diff observation. Regenerate diff and impact.");}let d$1=Oe(r,i),p=ve([...o(),...r.verificationPlan]).filter(u=>be(e.scope,u)),c$1=[];for(let u of p)c$1.push(await Ie(u,t,n$1.contracts.exists===true,d$1));let o$1=$e(r,c$1),f=a$2(n$1.graph??{nodes:[],edges:[]}),h=b$1(n$1),j$1=await _e(t),b=c(h,j$1?.freshness?.projectHashes),A={verdict:b.verdict,baseline:b.baseline,changed:b.changed,added:b.added,removed:b.removed,projectHashes:d(h)},E=b$2(f),k=n$1.policies?.mode??"warn",V=await Be(n$1,t),$=De(k,V),W=Ve(c$1,{blockingReasons:[...o$1.blockingReasons,...E,...$.blockingReasons,...a],needsAttention:o$1.needsAttention||$.needsAttention}),de=c$1.filter(u=>u.status==="missing"&&u.evidencePath).map(u=>u.evidencePath),S=[...c$1.filter(u=>u.required&&(u.status==="fail"||u.status==="missing")).map(u=>`${u.id}: ${u.message}`),...o$1.blockingReasons,...E,...$.blockingReasons,...a],le=V.filter(u=>u.severity==="error").length,ue=n$1.summary?.projectCount??n$1.projects.length,L=oe({projectCount:ue,verdict:W.verdict,exitCode:W.exitCode,blockingReasons:S,policyErrorCount:le});W.verdict=L.verdict,W.exitCode=L.exitCode;let K=S.length>0?ne({blockingReasons:S,verifyCommand:"npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json",verifyArtifact:T}):[];return {schemaVersion:ce,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:s,scope:e.scope,impact:{changed:r.summary.changed,risk:r.summary.risk,affectedProjects:r.summary.affectedProjects,recommendedCommands:r.summary.recommendedCommands},summary:W,steps:c$1,missingEvidence:de,blockingReasons:S,...K.length>0?{resolutionHints:K}:{},verificationPlan:p,affectedSubgraph:o$1.subgraph,graphIntegrity:f,freshness:A,policyMode:k,policyViolations:V}}async function Be(e,t){let r=[];for(let i of e.validation?.issues??[])r.push({source:"model",severity:i.severity,code:i.code,message:i.message,target:i.target});let s=await f(t,a.contractVerify);try{if(s&&await v.pathExists(s)){let i=await v.readJson(s);if(Array.isArray(i.violations))for(let n of i.violations)typeof n=="string"&&n.trim().length>0&&r.push({source:"contract",severity:"error",code:"contract.violation",message:n});}}catch{}return r.sort((i,n)=>i.source!==n.source?i.source.localeCompare(n.source):i.code!==n.code?i.code.localeCompare(n.code):i.message.localeCompare(n.message))}function De(e,t){let r=t.filter(s=>s.severity==="error");return e==="enforce"&&r.length>0?{blockingReasons:r.map(s=>`policy.${s.code}: ${s.message}`),needsAttention:false}:{blockingReasons:[],needsAttention:r.length>0}}async function _e(e){let t=m.join(e,T);try{if(!await v.pathExists(t))return null;let r=await v.readJson(t);return r&&r.schemaVersion===ce?r:null}catch{return null}}async function ut(e,t){return g(t,T,a$3(e))}function Me(e,t){let r=t?.strict?"strict":"default",s=[];if(e.summary.verdict==="blocked")return s.push(...e.blockingReasons),s.length===0&&s.push("verify verdict is blocked."),{passed:false,mode:r,exitCode:2,reasons:s};if(r==="strict"){if(e.summary.verdict!=="ready"&&s.push(`verify verdict is ${e.summary.verdict} (strict requires ready).`),e.freshness.verdict==="stale"){let i=[...e.freshness.changed,...e.freshness.added].slice(0,5);s.push(`freshness is stale${i.length>0?`: ${i.join(", ")}`:""} (strict requires fresh).`);}if(s.length>0)return {passed:false,mode:r,exitCode:1,reasons:s}}return {passed:true,mode:r,exitCode:0,reasons:s}}function pt(e,t){return Me(e,t).exitCode}export{re as a,Ge as b,ce as c,T as d,$e as e,lt as f,ut as g,Me as h,pt as i};
1
+ import {c as c$1}from'./chunk-KU4S7RCM.js';import {a as a$2,b as b$2}from'./chunk-PYCJWW4B.js';import {b as b$1,c,d}from'./chunk-OOOPYUL2.js';import {j,a as a$1,o,g as g$1,d as d$1,p,f as f$1}from'./chunk-ZWO6K24C.js';import {n,b as b$3}from'./chunk-HYJK7W3B.js';import {a as a$3}from'./chunk-QWU2CZBG.js';import {f,g}from'./chunk-6AA3WWQZ.js';import {a as a$4}from'./chunk-LG6RFLPZ.js';import {b,a}from'./chunk-5AKYMAIL.js';import m from'path';import v from'fs-extra';var re="rapidkit-blocker-resolution-v1";function ie(e){let t=e.blockers.map(s=>s.trim()).filter(Boolean).slice(0,12),r=e.stderrTail?.trim().slice(-400)??"";return b$3({blockers:t,exitCode:e.exitCode??null,stderrTail:r})}function me(e){let t=e.trim().toLowerCase();return t?t.includes("missing evidence")||t.includes(": missing")||t.includes("artifact missing")||t.includes("not found on disk")?"artifact-missing":t.includes("policy.")||t.includes("contract")?"config-fixable":t.includes("impact")||t.includes("untracked")||t.includes("grounding")?"semantic-attention":t.includes("failed")||t.includes("blocked")||t.includes(": fail")?"command-failed-repeat":"config-fixable":"unresolvable-without-human"}function ge(e){let t=me(e.reason),r=ie({blockers:[e.reason]}),s=t==="artifact-missing"?[{actionKind:"run-once",detail:e.sourceCommand?`Run the source command once: ${e.sourceCommand}`:"Run the mapped workspace intelligence command once to generate the missing artifact.",studioActionId:"run-analyze"}]:t==="semantic-attention"?[{actionKind:"commit-files",detail:"Review workspace-level grounding files (AGENTS.md, agent-sync outputs) and commit or refresh the impact baseline."},{actionKind:"refresh-baseline",detail:"Refresh snapshot + diff + impact before re-running verify."}]:[{actionKind:"edit-file",detail:"Apply the smallest safe file or policy fix for this blocker before re-running verification.",studioActionId:"fix-lens"}];return {schemaVersion:re,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:r,commandRetryHint:t==="artifact-missing"?"Run the source command once, then verify.":"Do not re-run the same failing command; fix the source issue first, then verify.",fixHints:s,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}}function ne(e){return Array.from(new Set(e.blockingReasons.map(r=>r.trim()).filter(Boolean))).slice(0,12).map((r,s)=>ge({reason:r,blockerId:`blocker-${s+1}`,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}))}function ke(e){let t=e.toLowerCase();return t.includes("stale")||t.includes("missing evidence")||t.includes("no projects")||t.includes("projects.empty")||t.includes("projects discovered")||t.includes("projects.missing")||t.includes("not yet run")||t.includes("doctor-last-run")||t.includes("doctor-project-last-run")||t.includes("doctor-remediation-plan-last-run")||t.includes("doctor-fix-result-last-run")||t.includes("pipeline-last-run")||t.includes("release-readiness")||t.includes("analyze-last-run")||t.includes("analyze reported")||t.includes("analyze verdict")||t.includes("analyze needs attention")||t.includes("toolchain.lock")||t.includes("not pinned")||t.includes("readiness:")||t.includes("env:")||t.includes("workspace-run-last")||t.includes("pre-project")||t.includes("before adding projects")||t.includes("workspace.projects.missing")||t.includes("no backend projects")||t.includes("index.json")||t.includes("workspace-intelligence-history")||t.includes("validation warning")||t.includes("workspace model validation")||t.includes("workspace.marker")||t.includes("no project roots")||t.includes("no infrastructure services")||t.includes("infra/overrides")||t.includes("infra dependencies")||t.includes("contract verify")||t.includes("contract inspect")||t.includes("publish verify evidence")}function he(e){return e.length===0||e.every(t=>ke(t))}function oe(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&he(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function Ge(e,t){let r=t&&t!=="ready"?` (${t.replace(/-/g," ")})`:"";return e===0?`Workspace scaffold ready${r} \u2014 add your first project to continue.`:`Workspace scaffold${r}: ${e} pre-project signal(s) \u2014 add your first project to continue.`}var ce=b.verify,T=a.verify;function ye(e,t){return m.isAbsolute(t)?t:m.join(e,t)}async function ae(e){let t=await v.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e}`);let r=t;if(r.schemaVersion!==f$1)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);a$4(t,"contracts/workspace-intelligence/workspace-impact.v1.json",`Workspace impact ${e}`);let s=r;a$4(s.diff,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Embedded workspace diff in ${e}`);let i=[];s.summary.affectedProjects!==s.affectedProjects.length&&i.push("summary.affectedProjects does not match affectedProjects.length"),s.summary.workspaceItems!==s.workspaceImpact.length&&i.push("summary.workspaceItems does not match workspaceImpact.length"),s.summary.recommendedCommands!==s.verificationPlan.length&&i.push("summary.recommendedCommands does not match verificationPlan.length"),s.summary.blastRadius.directlyAffected!==s.affectedProjects.length&&i.push("blastRadius.directlyAffected does not match affectedProjects.length"),s.summary.blastRadius.transitivelyAffected!==s.transitiveImpact.length&&i.push("blastRadius.transitivelyAffected does not match transitiveImpact.length");let n=s.transitiveImpact.reduce((a,l)=>Math.max(a,l.distance??0),0);s.summary.blastRadius.maxDistance!==n&&i.push("blastRadius.maxDistance does not match transitive impact distances");let g=s.diff.currentModel.graph?.edges.length??0;if(s.summary.blastRadius.graphEdges!==g&&i.push("blastRadius.graphEdges does not match the embedded model graph"),s.summary.changed!==s.diff.summary.changed&&i.push("summary.changed does not match embedded diff summary"),s.fromRef!==s.diff.fromRef&&i.push("fromRef does not match embedded diff fromRef"),s.workspace.name!==s.diff.currentModel.workspace.name&&i.push("workspace.name does not match the embedded model"),s.diff.toHash!==j(s.diff.currentModel)&&i.push("embedded diff current-model hash does not match toHash"),i.length>0)throw new Error(`Workspace impact semantic integrity failed: ${i.join("; ")} (${e})`);return s}function ve(e){let t=new Set,r=[];for(let s of e){let i=`${s.scope}:${s.project??""}:${s.display}`;t.has(i)||(t.add(i),r.push(s));}return r}function be(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===r}function we(e,t){if(e.id==="workspace.doctor")return m.join(t,a.doctor);if(e.id==="workspace.contract.verify")return m.join(t,a.contractVerify);if(e.id==="workspace.readiness")return m.join(t,a.readiness);if(e.id==="workspace.analyze")return m.join(t,".workspai","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return m.join(t,".workspai","reports","pipeline-last-run.json");if(e.id==="workspace.doctor-fix")return m.join(t,".workspai","reports","doctor-fix-result-last-run.json");if(e.id.startsWith("project.")&&e.id.includes("."))return m.join(t,".workspai","reports","workspace-run-last.json")}function C(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function Re(e){let t=C(e.healthScore),r=typeof t?.errors=="number"?t.errors:0,s=typeof t?.percent=="number"?t.percent:void 0;return r>0?{status:"fail",message:`Doctor evidence reports ${r} error(s).`}:typeof s=="number"&&s<70?{status:"warn",message:`Doctor health score is ${s}%.`}:{status:"pass",message:"Doctor evidence is present and healthy."}}function Ce(e){let t=typeof e.overallStatus=="string"?e.overallStatus:"unknown";return t==="fail"?{status:"fail",message:"Release readiness evidence reports blocking failures."}:t==="warn"?{status:"warn",message:"Release readiness evidence reports warnings."}:t==="pass"?{status:"pass",message:"Release readiness evidence passed."}:{status:"warn",message:`Release readiness evidence status is ${t}.`}}function We(e){let t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||t==="fail"?{status:"fail",message:"Workspace contract verify evidence failed."}:t==="passed"||t==="pass"?{status:"pass",message:"Workspace contract verify evidence passed."}:{status:"warn",message:`Workspace contract verify evidence status is ${t}.`}}function xe(e){let t=C(e.summary);if(t?.blocking===true||e.blocking===true)return {status:"fail",message:"Analyze evidence reports blocking findings."};let s=typeof t?.status=="string"?t.status:void 0;return s==="warn"||s==="warning"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is present."}}function je(e){let t=e.schemaVersion==="rapidkit-doctor-fix-result-v1"?e:e.fixResult;if(!t||typeof t!="object"||Array.isArray(t))return {status:"skipped",message:"Doctor fix result not present; run doctor workspace --fix --json to record fixes."};let r=t,s=Array.isArray(r.remainingBlockers)?r.remainingBlockers:[];if(s.length>0)return {status:"fail",message:`Doctor fix result reports ${s.length} remaining blocker(s).`};let i=Array.isArray(r.appliedFixes)?r.appliedFixes:[];return i.length===0?{status:"pass",message:"Doctor fix result recorded with no remaining blockers."}:{status:"pass",message:`Doctor fix result recorded ${i.length} applied fix(es) with no remaining blockers.`}}async function Ae(e,t){let r=await f(e,".workspai/reports/doctor-remediation-plan-last-run.json");if(!r)return false;try{let s=C(await v.readJson(r));if(!s||(Array.isArray(s.steps)?s.steps:[]).length>0)return false;let n=typeof s.generatedAt=="string"?s.generatedAt:void 0;if(!n||!t)return true;let g=Date.parse(n),a=Date.parse(t);return !Number.isFinite(g)||!Number.isFinite(a)?true:g>=a}catch{return false}}function Ee(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function Se(e){let t=C(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:r==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:r==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function Pe(e,t,r){let s=Ee(t),i=c$1(e,s??void 0);if(!i)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let n=i.stage;if(s&&n!==s)return {status:"missing",message:`Workspace run evidence is for stage "${n}", expected "${s}".`};let g=Array.isArray(i.projects)?i.projects:[],a=t.project?.toLowerCase();if(!a)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let l=g.find(d=>{let p=C(d);if(!p)return false;let c=typeof p.projectName=="string"?p.projectName.toLowerCase():"",o=["projectPath","relativePath","path"].map(f=>p[f]).filter(f=>typeof f=="string"&&f.trim().length>0).map(f=>f.replace(/\\/g,"/").toLowerCase());return c===a||o.some(f=>f.endsWith(`/${a}`)||f===a)});if(l){let d=R(i.generatedAt,r,`Workspace run evidence for ${t.project??t.id}`);if(d)return {status:"fail",message:d};let p=C(l),c=typeof p?.status=="string"?p.status:"unknown";return c==="failed"?{status:"fail",message:`Workspace run evidence failed for ${t.project}.`}:c==="passed"?{status:"pass",message:`Workspace run evidence passed for ${t.project}.`}:c==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}:{status:"warn",message:`Workspace run evidence status is ${c} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function R(e,t,r){if(!t)return null;if(typeof e!="string"||e.trim().length===0)return `${r} is stale: missing generatedAt timestamp (required after impact ${t}).`;let s=Date.parse(e),i=Date.parse(t);return Number.isFinite(s)?Number.isFinite(i)&&s<i?`${r} is stale: generated at ${e}, before impact ${t}.`:null:`${r} is stale: invalid generatedAt timestamp (required after impact ${t}).`}async function Ie(e,t,r,s){let i=we(e,t),n=i?m.relative(t,i).split(m.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!r)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"skipped",required:e.required,message:"Workspace contract is not present; contract verify skipped."};let g=i?await f(t,n??""):null;if(!i||!g)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:n,message:n?`Missing evidence report: ${n}`:"No evidence mapping exists for this command."};let a=C(await v.readJson(g));if(!a)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:n,message:"Evidence report is not a JSON object."};let l;if(e.id==="workspace.doctor"){let d=R(a.generatedAt,s,"Doctor evidence");d?l={status:"fail",message:d}:l=Re(a);}else if(e.id==="workspace.readiness"){let d=R(a.generatedAt,s,"Release readiness evidence");d?l={status:"fail",message:d}:l=Ce(a);}else if(e.id==="workspace.contract.verify"){let d=R(a.generatedAt,s,"Workspace contract verify evidence");d?l={status:"fail",message:d}:l=We(a);}else if(e.id==="workspace.analyze"){let d=R(a.generatedAt,s,"Analyze evidence");d?l={status:"fail",message:d}:l=xe(a);}else if(e.id==="workspace.pipeline"){let d=R(a.generatedAt,s,"Pipeline evidence");d?l={status:"fail",message:d}:l=Se(a);}else if(e.id==="workspace.doctor-fix"){let d=a.schemaVersion==="rapidkit-doctor-fix-result-v1"?a:a.fixResult,p=C(d),c=typeof p?.generatedAt=="string"?p.generatedAt:void 0,o=R(c,s,"Doctor fix result");o?l={status:"fail",message:o}:await Ae(t,c)?l={status:"skipped",message:"No current doctor remediation steps are pending."}:l=je(a);}else if(e.id.startsWith("project."))l=Pe(a,e,s);else {let d=R(a.generatedAt,s,"Evidence report");d?l={status:"fail",message:d}:l={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:l.status,required:e.required,evidencePath:n,message:l.message}}function Ve(e,t={blockingReasons:[],needsAttention:false}){let r=e.filter(c=>c.status==="pass").length,s=e.filter(c=>c.status==="warn").length,i=e.filter(c=>c.status==="fail").length,n=e.filter(c=>c.status==="missing").length,g=e.filter(c=>c.status==="skipped").length,a=e.filter(c=>c.required&&(c.status==="fail"||c.status==="missing")).map(c=>`${c.id}: ${c.message}`),l=e.filter(c=>c.required&&c.status==="missing").length,d="ready",p=0;return a.length>0||t.blockingReasons.length>0?(d="blocked",p=2):(s>0||l>0||t.needsAttention)&&(d="needs-attention",p=1),{verdict:d,exitCode:p,stepsPassed:r,stepsWarn:s,stepsFailed:i,stepsMissing:n,stepsSkipped:g}}function $e(e,t){let r=x(e.affectedProjects.map(o=>o.project?.name).filter(o=>typeof o=="string")),s=new Set(r.map(o=>o.toLowerCase())),i=x(e.transitiveImpact.map(o=>o.project?.name).filter(o=>typeof o=="string").filter(o=>!s.has(o.toLowerCase()))),n=new Map;for(let o of t){if(o.scope!=="project"||!o.project)continue;let f=o.project.toLowerCase(),h=n.get(f)??[];h.push(o),n.set(f,h);}let g=[],a=[],l=[],d=[],p=false,c=(o,f)=>{let h=n.get(o.toLowerCase())??[];if(h.length===0){l.push(o);return}let j=h.filter(k=>k.status==="fail"),b=h.filter(k=>k.status==="missing"),A=b.filter(k=>k.required),E=h.some(k=>k.status==="pass"||k.status==="warn");if(j.length>0){a.push(o),d.push(`graph.subgraph.${o}: ${f} has failed verification evidence (${j.map(k=>k.id).join(", ")}).`);return}if(A.length>0){a.push(o),d.push(`graph.subgraph.${o}: ${f} has missing required verification evidence (${A.map(k=>k.id).join(", ")}).`);return}if(b.length>0){a.push(o),p=true;return}if(E){g.push(o);return}l.push(o);};for(let o of r)c(o,"directly-changed");for(let o of i)c(o,"transitive dependent");return {subgraph:{totalProjects:r.length+i.length,directlyChanged:r,transitiveDependents:i,covered:x(g),uncovered:x(a),unverifiable:x(l)},blockingReasons:d,needsAttention:p}}function x(e){return [...new Set(e)].sort((t,r)=>t.localeCompare(r))}async function Fe(e){let t=m.resolve(e.workspacePath);if(e.fromImpactPath){let n=ye(t,e.fromImpactPath);return {impact:await ae(n),fromImpactRef:m.relative(t,n).split(m.sep).join("/"),impactFromDisk:true}}let r=m.join(t,g$1);if(await v.pathExists(r))return {impact:await ae(r),fromImpactRef:g$1,impactFromDisk:true};let s=m.join(t,d$1);if(await v.pathExists(s))return {impact:await p({workspacePath:t,fromPath:d$1,scope:e.scope,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),fromImpactRef:d$1,impactFromDisk:false};let i=await n({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {impact:{schemaVersion:f$1,generatedAt:(e.now??new Date).toISOString(),fromRef:"baseline",diffRef:a.diff,workspace:{name:i.workspace.name,profile:i.workspace.profile,type:i.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0,blastRadius:{directlyAffected:0,transitivelyAffected:0,maxDistance:0,graphEdges:i.graph?.edges.length??0}},affectedProjects:[],transitiveImpact:[],criticalPathHotspots:[],workspaceImpact:[],verificationPlan:[],agentBrief:{headline:"Baseline workspace verify run.",bullets:["No impact report or snapshot was available; baseline gates were evaluated."],unsafeAssumptions:["Do not claim runtime verification passed unless evidence exists."]},diff:{schemaVersion:b.diff,generatedAt:(e.now??new Date).toISOString(),fromRef:"baseline",toRef:a.model,fromHash:"baseline",toHash:"baseline",summary:{changed:false,addedProjects:0,removedProjects:0,changedProjects:0,workspaceChanges:0,validationChanges:0,gitChangedFiles:0},git:{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:[],currentModel:i}},impactFromDisk:false}}function Oe(e,t){if(t)return e.generatedAt}async function lt(e){let t=m.resolve(e.workspacePath),{impact:r,fromImpactRef:s,impactFromDisk:i}=await Fe(e),n$1=r.diff.currentModel,g=i?await n({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}):n$1,a=[];i&&j(g)!==r.diff.toHash&&a.push("workspace.impact: Impact evidence is stale because the current workspace model no longer matches the embedded model. Regenerate diff and impact.");let l=r.diff.git;if(i&&l?.available){let u=a$1(t,{ref:l.ref}),pe=r.diff.changes.filter(y=>y.type.startsWith("git.")).map(y=>`${y.type}:${y.target.replace(/^git:/,"")}`).sort(),fe=[...u.changedFiles.map(y=>`git.file.changed:${y}`),...u.untrackedFiles.map(y=>`git.untracked:${y}`),...u.deletedFiles.map(y=>`git.deleted:${y}`)].sort();(!u.available||u.commit!==l.commit||JSON.stringify(fe)!==JSON.stringify(pe))&&a.push("workspace.impact: Impact evidence is stale because Git changes no longer match the diff observation. Regenerate diff and impact.");}let d$1=Oe(r,i),p=ve([...o(),...r.verificationPlan]).filter(u=>be(e.scope,u)),c$1=[];for(let u of p)c$1.push(await Ie(u,t,n$1.contracts.exists===true,d$1));let o$1=$e(r,c$1),f=a$2(n$1.graph??{nodes:[],edges:[]}),h=b$1(n$1),j$1=await _e(t),b=c(h,j$1?.freshness?.projectHashes),A={verdict:b.verdict,baseline:b.baseline,changed:b.changed,added:b.added,removed:b.removed,projectHashes:d(h)},E=b$2(f),k=n$1.policies?.mode??"warn",V=await Be(n$1,t),$=De(k,V),W=Ve(c$1,{blockingReasons:[...o$1.blockingReasons,...E,...$.blockingReasons,...a],needsAttention:o$1.needsAttention||$.needsAttention}),de=c$1.filter(u=>u.status==="missing"&&u.evidencePath).map(u=>u.evidencePath),S=[...c$1.filter(u=>u.required&&(u.status==="fail"||u.status==="missing")).map(u=>`${u.id}: ${u.message}`),...o$1.blockingReasons,...E,...$.blockingReasons,...a],le=V.filter(u=>u.severity==="error").length,ue=n$1.summary?.projectCount??n$1.projects.length,L=oe({projectCount:ue,verdict:W.verdict,exitCode:W.exitCode,blockingReasons:S,policyErrorCount:le});W.verdict=L.verdict,W.exitCode=L.exitCode;let K=S.length>0?ne({blockingReasons:S,verifyCommand:"npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json",verifyArtifact:T}):[];return {schemaVersion:ce,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:s,scope:e.scope,impact:{changed:r.summary.changed,risk:r.summary.risk,affectedProjects:r.summary.affectedProjects,recommendedCommands:r.summary.recommendedCommands},summary:W,steps:c$1,missingEvidence:de,blockingReasons:S,...K.length>0?{resolutionHints:K}:{},verificationPlan:p,affectedSubgraph:o$1.subgraph,graphIntegrity:f,freshness:A,policyMode:k,policyViolations:V}}async function Be(e,t){let r=[];for(let i of e.validation?.issues??[])r.push({source:"model",severity:i.severity,code:i.code,message:i.message,target:i.target});let s=await f(t,a.contractVerify);try{if(s&&await v.pathExists(s)){let i=await v.readJson(s);if(Array.isArray(i.violations))for(let n of i.violations)typeof n=="string"&&n.trim().length>0&&r.push({source:"contract",severity:"error",code:"contract.violation",message:n});}}catch{}return r.sort((i,n)=>i.source!==n.source?i.source.localeCompare(n.source):i.code!==n.code?i.code.localeCompare(n.code):i.message.localeCompare(n.message))}function De(e,t){let r=t.filter(s=>s.severity==="error");return e==="enforce"&&r.length>0?{blockingReasons:r.map(s=>`policy.${s.code}: ${s.message}`),needsAttention:false}:{blockingReasons:[],needsAttention:r.length>0}}async function _e(e){let t=m.join(e,T);try{if(!await v.pathExists(t))return null;let r=await v.readJson(t);return r&&r.schemaVersion===ce?r:null}catch{return null}}async function ut(e,t){return g(t,T,a$3(e))}function Me(e,t){let r=t?.strict?"strict":"default",s=[];if(e.summary.verdict==="blocked")return s.push(...e.blockingReasons),s.length===0&&s.push("verify verdict is blocked."),{passed:false,mode:r,exitCode:2,reasons:s};if(r==="strict"){if(e.summary.verdict!=="ready"&&s.push(`verify verdict is ${e.summary.verdict} (strict requires ready).`),e.freshness.verdict==="stale"){let i=[...e.freshness.changed,...e.freshness.added].slice(0,5);s.push(`freshness is stale${i.length>0?`: ${i.join(", ")}`:""} (strict requires fresh).`);}if(s.length>0)return {passed:false,mode:r,exitCode:1,reasons:s}}return {passed:true,mode:r,exitCode:0,reasons:s}}function pt(e,t){return Me(e,t).exitCode}export{re as a,Ge as b,ce as c,T as d,$e as e,lt as f,ut as g,Me as h,pt as i};
@@ -1,4 +1,4 @@
1
- import {a as a$1}from'./chunk-NTXO7BMH.js';import {a as a$4}from'./chunk-22DT744Z.js';import {a as a$2,e}from'./chunk-B66A4TVP.js';import {f,c,g}from'./chunk-FWJV7CCI.js';import {a}from'./chunk-5AKYMAIL.js';import a$3 from'chalk';import se from'fs';import b from'path';import {execa}from'execa';var G="autopilot-release-last-run.json",V="autopilot-release.json";function j(r){try{return JSON.parse(r)}catch{return null}}function Re(r){let e=b.resolve(r),n=a$4(e);if(!n)throw new Error("No Workspai workspace found in current directory or parents");return n}async function S(r,e){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[n,...r],{cwd:e,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function re(r){let e=r.toLowerCase();return e==="pass"?"pass":e==="warn"?"warn":e==="fail"?"fail":"warn"}function oe(r){return r.summary.failed>0||r.gates.results.some(e=>e.status==="fail")?"fail":r.gates.results.some(e=>e.status==="warn")?"warn":"pass"}function Se(r){let e=r.filter(o=>o.status!=="skipped");if(e.length===0)return 100;let n=e.reduce((o,t)=>t.status==="pass"?o+1:t.status==="warn"?o+.6:o,0);return Math.round(n/e.length*100)}function be(r){return r.executionError?["Re-run: npx workspai autopilot release --mode audit --json","Inspect .workspai/reports/autopilot-release-last-run.json for execution failure details"]:r.blockers.length>0?["Run: npx workspai doctor workspace --plan","Run: npx workspai readiness --json --strict","Run: npx workspai workspace run test --affected --strict"]:r.hasWarnings&&r.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx workspai autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function xe(r,e){await se.promises.mkdir(b.dirname(r),{recursive:true}),await se.promises.writeFile(r,`${JSON.stringify(e,null,2)}
1
+ import {a as a$1}from'./chunk-WANW4QA4.js';import {a as a$4}from'./chunk-22DT744Z.js';import {a as a$2,e}from'./chunk-KU4S7RCM.js';import {f,c,g}from'./chunk-6AA3WWQZ.js';import {a}from'./chunk-5AKYMAIL.js';import a$3 from'chalk';import se from'fs';import b from'path';import {execa}from'execa';var G="autopilot-release-last-run.json",V="autopilot-release.json";function j(r){try{return JSON.parse(r)}catch{return null}}function Re(r){let e=b.resolve(r),n=a$4(e);if(!n)throw new Error("No Workspai workspace found in current directory or parents");return n}async function S(r,e){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[n,...r],{cwd:e,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function re(r){let e=r.toLowerCase();return e==="pass"?"pass":e==="warn"?"warn":e==="fail"?"fail":"warn"}function oe(r){return r.summary.failed>0||r.gates.results.some(e=>e.status==="fail")?"fail":r.gates.results.some(e=>e.status==="warn")?"warn":"pass"}function Se(r){let e=r.filter(o=>o.status!=="skipped");if(e.length===0)return 100;let n=e.reduce((o,t)=>t.status==="pass"?o+1:t.status==="warn"?o+.6:o,0);return Math.round(n/e.length*100)}function be(r){return r.executionError?["Re-run: npx workspai autopilot release --mode audit --json","Inspect .workspai/reports/autopilot-release-last-run.json for execution failure details"]:r.blockers.length>0?["Run: npx workspai doctor workspace --plan","Run: npx workspai readiness --json --strict","Run: npx workspai workspace run test --affected --strict"]:r.hasWarnings&&r.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx workspai autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function xe(r,e){await se.promises.mkdir(b.dirname(r),{recursive:true}),await se.promises.writeFile(r,`${JSON.stringify(e,null,2)}
2
2
  `,"utf-8");}async function Me(r){let e$1=Re(r.workspacePath),n=r.mode,o=[],t=[],F,H,D,q,Q,X=0,f$1=false,T=0,L=0,N=-1,W=-1,c$1="skipped",d="skipped",ae=n==="enforce"?["doctor","workspace","--json","--strict"]:["doctor","workspace","--json","--ci"];if(r.skipPipelineStages)o.push({name:"doctor-workspace",status:"skipped",durationMs:0,summary:"doctor stage skipped (pipeline already executed)"},{name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped (pipeline already executed)"},{name:"readiness",status:"skipped",durationMs:0,summary:"readiness stage skipped (pipeline already executed)"});else {let s=Date.now(),l=await S([...ae],e$1),m=Date.now()-s;if(c$1="pass",l.crashed)c$1="fail",f$1=true,t.push(`doctor workspace execution error: ${l.stderr||"unknown error"}`);else if(l.exitCode===1)c$1="fail",t.push("doctor workspace command failed or reported errors");else if(l.exitCode===2)c$1="warn",t.push("doctor workspace reported warnings");else if(l.exitCode!==0)c$1="fail",t.push("doctor workspace command failed");else {let p=j(l.stdout),E=p&&p.healthScore&&typeof p.healthScore=="object"?p.healthScore:{},k=Number(E.errors??0),$=Number(E.warnings??0);Number.isFinite(k)&&k>0?(c$1="fail",t.push(`doctor workspace reports ${k} error(s)`)):Number.isFinite($)&&$>0&&(c$1="warn");}N=o.push({name:"doctor-workspace",status:c$1,durationMs:m,summary:c$1==="pass"?"doctor workspace passed":c$1==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors"})-1,n==="enforce"&&c$1==="warn"&&t.push("doctor workspace reported warnings under enforce mode");let g=Date.now(),w=await S(["analyze","--json"],e$1),v=Date.now()-g;H=await f(e$1,a.analyze)??c(e$1,a.analyze);let i="pass";if(w.crashed)i="fail",f$1=true,t.push(`analyze execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)i=w.exitCode===2?"warn":"fail",t.push(w.exitCode===2?"analyze reported needs-attention verdict":"analyze command failed or reported blocked verdict");else {let p=j(w.stdout),E=p&&p.summary&&typeof p.summary=="object"?p.summary:{},k=String(E.verdict??"ready");k==="blocked"?(i="fail",t.push("analyze reported blocked verdict")):k==="needs-attention"&&(i="warn");}o.push({name:"analyze",status:i,durationMs:v,summary:i==="pass"?"analyze passed":i==="warn"?"analyze reported needs-attention":"analyze reported blocked verdict"}),n==="enforce"&&i==="warn"&&t.push("analyze reported warnings under enforce mode");let P=Date.now(),h=await S(["readiness","--json"],e$1),y=Date.now()-P;if(d="fail",h.crashed)d="fail",f$1=true,t.push(`readiness execution error: ${h.stderr||"unknown error"}`);else if(h.exitCode!==0)d="fail",t.push("readiness command failed");else {let p=j(h.stdout),E=String(p?.overallStatus??"fail");if(d=re(E),typeof p?.evidencePath=="string"&&p.evidencePath.trim().length>0&&(F=p.evidencePath),d==="fail"){let k=Array.isArray(p?.blockingReasons)?p?.blockingReasons.filter($=>typeof $=="string"):[];k.length>0?t.push(...k.map($=>`readiness: ${$}`)):t.push("readiness overall status is fail");}}W=o.push({name:"readiness",status:d,durationMs:y,summary:`readiness overall status is ${d}`})-1,n==="enforce"&&d==="warn"&&t.push("readiness reported warnings under enforce mode");}let ne=Date.now(),z=await S(["doctor","workspace","--plan","--json"],e$1),ie=Date.now()-ne,R="warn";if(z.crashed)R="fail",f$1=true,t.push(`doctor remediation plan execution error: ${z.stderr||"unknown error"}`);else if(z.exitCode!==0)R="fail",t.push("doctor remediation plan command failed");else {let s=j(z.stdout),l=s&&s.remediationPlan&&typeof s.remediationPlan=="object"?s.remediationPlan:null,m=Number(l?.totalSteps??0),g=Number(l?.executableSteps??0);Number.isFinite(m)&&m>0&&(T=m),Number.isFinite(g)&&g>0&&(L=g),Number.isFinite(m)&&m===0?R="pass":R="warn";}if(o.push({name:"remediation-plan",status:R,durationMs:ie,summary:R==="pass"?"no remediation steps required":"remediation steps available"}),n==="enforce"&&R==="warn"&&t.push("remediation plan has pending steps under enforce mode"),n==="safe-fix"){let s=Date.now(),l=await S(["doctor","workspace","--apply"],e$1),m=Date.now()-s,g=l.crashed||l.exitCode!==0?"fail":"pass";if(l.crashed)f$1=true,t.push(`doctor remediation apply execution error: ${l.stderr||"unknown error"}`);else if(g==="fail")t.push("doctor remediation apply failed");else {X=L>0?L:T>0?T:1;let w=await S(["doctor","workspace","--json"],e$1);if(w.crashed)c$1="fail",f$1=true,t.push(`post-apply doctor execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)c$1="fail",t.push("post-apply doctor workspace command failed");else {let i=j(w.stdout),P=i&&i.healthScore&&typeof i.healthScore=="object"?i.healthScore:{},h=Number(P.errors??0),y=Number(P.warnings??0);Number.isFinite(h)&&h>0?(c$1="fail",t.push(`post-apply doctor reports ${h} error(s)`)):Number.isFinite(y)&&y>0?c$1="warn":c$1="pass";}N>=0&&(o[N].status=c$1,o[N].summary=`doctor workspace post-apply status is ${c$1}`);let v=await S(["readiness","--json"],e$1);if(v.crashed)d="fail",f$1=true,t.push(`post-apply readiness execution error: ${v.stderr||"unknown error"}`);else if(v.exitCode!==0)d="fail",t.push("post-apply readiness command failed");else {let i=j(v.stdout),P=String(i?.overallStatus??"fail");if(d=re(P),typeof i?.evidencePath=="string"&&i.evidencePath.trim().length>0&&(F=i.evidencePath),d==="fail"){let h=Array.isArray(i?.blockingReasons)?i?.blockingReasons.filter(y=>typeof y=="string"):[];h.length>0?t.push(...h.map(y=>`post-apply readiness: ${y}`)):t.push("post-apply readiness overall status is fail");}}W>=0&&(o[W].status=d,o[W].summary=`readiness post-apply overall status is ${d}`);}o.push({name:"remediation-apply",status:g,durationMs:m,summary:g==="pass"?"safe remediation apply completed":"safe remediation apply failed"});}else o.push({name:"remediation-apply",status:"skipped",durationMs:0,summary:"remediation apply is skipped for this mode"});let le=Date.now(),x="pass",A="workspace test/build completed for selected projects";try{let s=await a$1({workspacePath:e$1,stage:"test",affected:true,since:r.since,parallel:r.parallel,maxWorkers:r.maxWorkers,strict:true,json:true,enforceGates:false});D=c(e$1,b.join(".workspai","reports",a$2)),await e(e$1,s),q=D;let l=oe(s);if(l==="fail")x="fail",A="workspace test stage failed for selected projects",t.push("workspace run test failed for selected projects");else {l==="warn"&&(x="warn",A="workspace test stage completed with warnings",n==="enforce"&&t.push("workspace run test reported warnings under enforce mode"));let m=await a$1({workspacePath:e$1,stage:"build",affected:true,since:r.since,parallel:r.parallel,maxWorkers:r.maxWorkers,strict:true,json:true,enforceGates:false});await e(e$1,m),Q=D;let g=oe(m);g==="fail"?(x="fail",A="workspace build stage failed for selected projects",t.push("workspace run build failed for selected projects")):g==="warn"&&(x="warn",A="workspace test/build completed with warnings",n==="enforce"&&t.push("workspace run test/build reported warnings under enforce mode"));}}catch(s){x="fail",A="workspace test/build orchestration failed",f$1=true,t.push(`workspace run orchestration error: ${s instanceof Error?s.message:String(s)}`);}let ce=Date.now()-le;o.push({name:"workspace-run-test-build",status:x,durationMs:ce,summary:A});let M=o.filter(s=>s.status==="warn").length,pe=o.filter(s=>s.status==="fail").length,_=n==="enforce"?o.some(s=>s.status==="warn"||s.status==="fail"):pe>0,C=[...new Set(t)],O=f$1||_?Math.max(1,C.length):0,ue=O>0?C:[],de=O===0?C:[],fe=Se(o),me=f$1||_?"blocked":M>0?"partial":"approved",ge=f$1?3:_?1:M>0?2:0,we=be({mode:n,executionError:f$1,blockers:C,hasWarnings:M>0}),Y=c(e$1,".workspai/reports"),he=b.join(Y,G),ke=b.join(Y,V),u={schemaVersion:"autopilot-release-v1",generatedAt:new Date().toISOString(),workspacePath:e$1,mode:n,summary:{releaseScore:fe,verdict:me,blockers:O,warnings:M,safeFixesApplied:X,manualActions:C.length,exitCode:ge},stages:o,blockingReasons:ue,warningReasons:de,nextActions:we,artifacts:{reportPath:he,aliasEvidencePath:ke,analyzeEvidencePath:H,readinessEvidencePath:F,workspaceRunEvidencePath:D,workspaceRunTestPath:q,workspaceRunBuildPath:Q},enterpriseControls:{jsonReady:true,evidencePath:`.workspai/reports/${G}`,aliasEvidencePath:`.workspai/reports/${V}`}};if(await g(e$1,`.workspai/reports/${G}`,u),await g(e$1,`.workspai/reports/${V}`,u),r.output&&await xe(b.resolve(r.output),u),!r.json){console.log(a$3.bold.cyan(`
3
3
  \u{1F680} Workspai Autopilot Release
4
4
  `)),console.log(a$3.bold(`Workspace: ${a$3.cyan(b.basename(e$1))}`)),console.log(a$3.gray(`Path: ${e$1}`)),console.log(a$3.white(`Mode: ${n}`)),console.log(a$3.white(`Verdict: ${u.summary.verdict==="approved"?a$3.green("approved"):u.summary.verdict==="partial"?a$3.yellow("partial"):a$3.red("blocked")}`)),console.log(a$3.white(`Release score: ${u.summary.releaseScore}`));for(let s of u.stages){let l=s.status==="pass"?a$3.green("PASS"):s.status==="warn"?a$3.yellow("WARN"):s.status==="skipped"?a$3.gray("SKIP"):a$3.red("FAIL");console.log(` - ${s.name}: ${l} ${s.summary} (${s.durationMs}ms)`);}if(u.blockingReasons.length>0){console.log(a$3.bold.red(`
@@ -0,0 +1,2 @@
1
+ import {a as a$1}from'./chunk-LG6RFLPZ.js';import {a,c,b as b$1,f}from'./chunk-5AKYMAIL.js';import {r,s}from'./chunk-5XATWNME.js';import n from'path';import {randomUUID}from'crypto';import {open}from'fs/promises';import a$2 from'fs-extra';var N=Object.keys(a).flatMap(r=>{let t=r,e=b$1[t],o=c[t];return !e||!o?[]:[{artifactPath:a[t],schemaVersion:e,contractPath:o}]}),M=[{artifactPath:".workspai/cache/workspace-model.v1.json",schemaVersion:"workspace-model-cache.v1",contractPath:"contracts/workspace-model-cache.v1.json"},{artifactPath:".workspai/workspace-registry.v1.json",schemaVersion:"workspace-registry.v1",contractPath:"contracts/workspace-registry.v1.json"},{artifactPath:".workspai/reports/doctor-project-last-run.json",schemaVersion:"doctor-project-evidence-v1",contractPath:"contracts/doctor-project-evidence.v1.json"},{artifactPath:".workspai/reports/doctor-remediation-plan-last-run.json",schemaVersion:"doctor-remediation-plan-v2",contractPath:"contracts/doctor-remediation-plan.v2.json"},{artifactPath:".workspai/reports/artifact-remediation-plan-last-run.json",schemaVersion:"artifact-remediation-plan-v1",contractPath:"contracts/artifact-remediation-plan.v1.json"},{artifactPath:".workspai/reports/doctor-fix-result-last-run.json",schemaVersion:"rapidkit-doctor-fix-result-v1",contractPath:"contracts/workspace-intelligence/doctor-fix-result.v1.json"},{artifactPath:".workspai/reports/pipeline-last-run.json",schemaVersion:"rapidkit-pipeline-v1",contractPath:"contracts/pipeline-last-run.v1.json"},{artifactPath:".workspai/reports/autopilot-release-last-run.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json"},{artifactPath:".workspai/reports/autopilot-release.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json"},{artifactPath:".workspai/reports/workspace-run-last.json",schemaVersion:"workspace-run-v1",contractPath:"contracts/workspace-run-last.v1.json"},{artifactPath:".workspai/reports/workspai-mcp-design.json",schemaVersion:"workspai-mcp-design.v1",contractPath:"contracts/workspace-intelligence/mcp-design.v1.json"},{artifactPath:".workspai/reports/workspace-why-last-run.json",schemaVersion:b$1.explain,contractPath:c.explain},{artifactPath:".workspai/reports/workspace-trace-last-run.json",schemaVersion:b$1.explain,contractPath:c.explain},{artifactPath:".vscode/workspai-agent-hooks.json",schemaVersion:"workspai-agent-hooks.v1",contractPath:"contracts/workspace-intelligence/agent-hooks.v1.json"},{artifactPath:".workspai/reports/infra-plan.json",schemaVersion:"rapidkit.infra-plan.v1",contractPath:"contracts/infra-plan.v1.json"}],b={[a.snapshot]:[["workspace","snapshot"]],[a.history]:[["workspace","feedback","record","--json"]],".workspai/cache/workspace-model.v1.json":[["workspace","model"]],".workspai/workspace-registry.v1.json":[["workspace","sync"]],".workspai/reports/doctor-project-last-run.json":[["doctor","project"]],".workspai/reports/doctor-remediation-plan-last-run.json":[["workspace","remediation-plan"]],".workspai/reports/artifact-remediation-plan-last-run.json":[["workspace","remediation-plan"]],".workspai/reports/doctor-fix-result-last-run.json":[["doctor","workspace"]],".workspai/reports/pipeline-last-run.json":[["pipeline"]],".workspai/reports/autopilot-release-last-run.json":[["autopilot","release"]],".workspai/reports/autopilot-release.json":[["autopilot","release"]],".workspai/reports/workspace-run-last.json":[["workspace","run"]],".workspai/reports/workspace-why-last-run.json":[["workspace","why"]],".workspai/reports/workspace-trace-last-run.json":[["workspace","trace"]],".vscode/workspai-agent-hooks.json":[["workspace","agent-sync"]],".workspai/reports/infra-plan.json":[["infra","plan"]]};function O(r){let t=Object.values(f).filter(o=>o.produces.includes(r)).map(o=>[...o.command]),e=b[r]??[];return [...t,...e.map(o=>[...o])]}var $=Object.freeze(Object.fromEntries([...N,...M].map(r=>[r.artifactPath,{...r,producerCommands:O(r.artifactPath)}])));function D(r){return r.split(n.sep).join("/").replace(/^\.\//,"")}function L(r){return $[D(r)]??null}function C(r,t,e=r){let o=L(r);if(!o)return;let i=t&&typeof t=="object"&&"schemaVersion"in t?t.schemaVersion:void 0;if(i!==o.schemaVersion)throw new Error(`${e} schemaVersion is ${String(i)}, expected ${o.schemaVersion}`);a$1(t,o.contractPath,e);}function W(r,t){let e=n.resolve(r),o=t.trim();if(!o||n.isAbsolute(o))throw new Error(`Workspace artifact path must be non-empty and relative: ${t}`);let i=n.resolve(e,o),s=n.relative(e,i);if(s===".."||s.startsWith(`..${n.sep}`)||n.isAbsolute(s))throw new Error(`Workspace artifact path escapes workspace root: ${t}`);return i}function P(r$1,t){return W(r$1,r(t))}function J(r,t){return W(r,s(t))}async function I(r,t){let e=n.resolve(r);await a$2.ensureDir(e);let o=n.dirname(t);await a$2.ensureDir(o);let[i,s]=await Promise.all([a$2.realpath(e),a$2.realpath(o)]),p=n.relative(i,s);if(p===".."||p.startsWith(`..${n.sep}`)||n.isAbsolute(p))throw new Error(`Workspace artifact parent resolves outside workspace root: ${o}`)}async function K(r,t){let e=n.resolve(r),[o,i]=await Promise.all([a$2.realpath(e),a$2.realpath(t)]),s=n.relative(o,i);if(s===".."||s.startsWith(`..${n.sep}`)||n.isAbsolute(s))throw new Error(`Workspace artifact resolves outside workspace root: ${t}`)}function U(r){let t=r?.code;return process.platform==="win32"&&(t==="EPERM"||t==="EINVAL"||t==="ENOSYS")}async function S(r){try{await r.sync();}catch(t){if(!U(t))throw t}}async function G(r,t,e){await I(r,t);let o=n.dirname(t),i=`${n.basename(t)}.`,s=Date.now();for(let l of await a$2.readdir(o)){if(!l.startsWith(i)||!l.endsWith(".tmp"))continue;let f=n.join(o,l),c=await a$2.stat(f).catch(()=>null);c&&s-c.mtimeMs>3e4&&await a$2.remove(f).catch(()=>{});}let p=`${t}.${process.pid}.${randomUUID()}.tmp`;try{await e(p);let l=await open(p,"r");try{await S(l);}finally{await l.close();}let f=Number(process.env.WORKSPAI_TEST_ATOMIC_WRITE_DELAY_MS??0);Number.isFinite(f)&&f>0&&await new Promise(c=>setTimeout(c,Math.min(f,3e4)));try{await a$2.rename(p,t);}catch(c){let w=c.code;if(w!=="EEXIST"&&w!=="EPERM")throw c;await a$2.move(p,t,{overwrite:true});}}finally{await a$2.remove(p).catch(()=>{});}}async function at(r,t,e,o={}){let i=P(r,t);await I(r,i);let s=`${i}.lock`,p=o.timeoutMs??1e4,l=o.staleAfterMs??3e4,f=Date.now(),c;for(;!c;)try{c=await open(s,"wx"),await c.writeFile(`${JSON.stringify({pid:process.pid,createdAt:new Date().toISOString()})}
2
+ `),await S(c);}catch(w){if(w.code!=="EEXIST")throw c&&(await c.close().catch(()=>{}),c=void 0,await a$2.remove(s).catch(()=>{})),w;let A=await a$2.stat(s).catch(()=>null);if(A&&Date.now()-A.mtimeMs>l){let h=await a$2.readJson(s).catch(()=>null),k=Number(h?.pid),g=false;if(Number.isInteger(k)&&k>0)try{process.kill(k,0),g=true;}catch(x){g=x.code==="EPERM";}if(!g){await a$2.remove(s).catch(()=>{});continue}}if(Date.now()-f>=p)throw new Error(`Timed out waiting for workspace artifact lock: ${t}`);await new Promise(h=>setTimeout(h,20));}try{return await e()}finally{await c.close().catch(()=>{}),await a$2.remove(s).catch(()=>{});}}async function st(r,t){let e=[P(r,t),J(r,t)];for(let o of e)if(await a$2.pathExists(o))return await K(r,o),o;return null}async function nt(r,t,e){C(t,e);let o=P(r,t);return await G(r,o,i=>a$2.writeJson(i,e,{spaces:2})),o}export{L as a,C as b,P as c,J as d,at as e,st as f,nt as g};
@@ -1,4 +1,4 @@
1
- import {d as d$1,b as b$2,e,f as f$1}from'./chunk-V5JN4TDX.js';import {d as d$2}from'./chunk-UNF72FTB.js';import {b as b$1,f as f$2,j as j$1,k,h,i,l,m,n as n$1,o,p,q,r,t,v,x,s as s$1,u,w,y,z,A as A$1,B,C,D,E,F,G,a as a$2,H,I}from'./chunk-XIVFLY6G.js';import {n,k as k$1,b as b$4}from'./chunk-JICOD2GI.js';import {j}from'./chunk-2QN6BMM7.js';import {f,b as b$3,a as a$1}from'./chunk-FWJV7CCI.js';import {b,a}from'./chunk-5AKYMAIL.js';import s from'path';import f$3 from'fs-extra';var J=["Scope","Evidence","Diagnosis","Fix Plan","Run","Verify","Assumptions"];var lt="workspace-operational-skill.v1";function dt(e){if(typeof e!="string")return null;let t=e.trim();return !t||t.includes("/")||t.includes("..")?null:t}function Ke(e){let t=dt(e.skillId);if(!t)throw new Error(`Invalid skill id: ${e.skillId}`);return {schemaVersion:lt,skillId:t,canonicalPath:H(t),title:e.title,triggers:[...e.triggers].sort((r,n)=>r.localeCompare(n)),requiredReports:[...e.requiredReports].sort((r,n)=>r.localeCompare(n)),scopedProjects:[...e.scopedProjects??[]].sort((r,n)=>r.localeCompare(n)),verificationCommands:[...e.verificationCommands],answerContractSections:[...J],...e.promptStem?{promptStem:e.promptStem}:{},markdown:e.markdown}}var pt=b.skillsIndex;function qe(e){let t=[...e.skills].sort((n,l)=>n.skillId.localeCompare(l.skillId)),r=e.inputsHash??b$4({skillIds:t.map(n=>n.skillId),paths:t.map(n=>n.canonicalPath)});return {schemaVersion:pt,generatedAt:e.generatedAt,inputsHash:r,skills:t.map(n=>({skillId:n.skillId,path:n.canonicalPath,schemaVersion:n.schemaVersion,title:n.title}))}}var Ve=[a.agentIndex,d$1,d$2],ut=[{skillId:"workspai-diagnose-api-failure",title:"Diagnose API failure",triggers:["api failure","500 error","integration test failed","service unreachable"],objective:"Investigate a failing API or service using Workspai evidence before editing application code.",steps:[`Read \`${a.agentIndex}\` and identify fail/warn reports for the scoped project.`,`Read \`${a.doctor}\`, \`doctor-project-last-run.json\`, and project-scoped run evidence if present.`,"If a fix was requested, read `artifact-remediation-plan-last-run.json` for cross-artifact next steps, then `doctor-remediation-plan-last-run.json` for Doctor-specific file edits.","Map the failure to workspace vs project scope; cite exit codes and blocker messages.","Propose the smallest safe fix (config, env, dependency) with explicit verification commands."]},{skillId:"workspai-release-readiness",title:"Release readiness",triggers:["release","ship","production","readiness gate"],objective:"Assess whether this workspace is release-ready using governed Workspai gates.",steps:[`Read \`${a.readiness}\` and \`pipeline-last-run.json\`.`,`Read \`${a.verify}\` for verdict and blocking reasons.`,"Read `.workspai/reports/artifact-remediation-plan-last-run.json` when a Studio or agent repair path is needed.","List blocking gates first; never claim ready without cited report fields.","Provide one safe next command and a verification checklist."]},{skillId:"workspai-safe-schema-migration",title:"Safe schema migration",triggers:["migration","schema change","database migration","db migrate"],objective:"Plan and verify a schema migration with blast-radius awareness.",steps:["Identify affected projects from workspace model and dependency graph.","Run or review impact/verify evidence for transitive dependents.","Require project-scoped test/build commands before promoting the migration.","Document rollback and verification signals."]},{skillId:"workspai-dependency-upgrade",title:"Dependency upgrade",triggers:["upgrade dependency","bump package","security advisory","outdated deps"],objective:"Upgrade dependencies with graph-aware verification.",steps:["Scope the upgrade to the owning project from workspace model.","Check transitive dependents via workspace graph / impact reports.","Prefer workspace run test/build for affected projects.","Re-run `workspace verify` after evidence refresh."]},{skillId:"workspai-rename-contract",title:"Rename contract safely",triggers:["rename contract","rename event","breaking api","contract change"],objective:"Rename or change a shared contract with consumer awareness.",steps:["Read `.workspai/workspace.contract.json` for publishes/consumes/owns edges.","List all consumer projects before proposing renames.","Update contract file and regenerate workspace model.","Verify contract gate and integration tests for consumers."]}];function X(e){return `npx workspai ${e}`.trim()}function gt(e){let t=[`# ${e.template.title}`,"",`> Workspace: **${e.workspaceName}** \xB7 Skill: \`${e.template.skillId}\``,"","## Objective","",e.template.objective,"","## Triggers","",...e.template.triggers.map(r=>`- ${r}`),"","## Required evidence (read first)","",...Ve.map(r=>`- \`${r}\``),"","## Procedure","",...e.template.steps.map((r,n)=>`${n+1}. ${r}`),""];if(e.scopedProjects.length>0&&t.push("## Scoped projects","",...e.scopedProjects.map(r=>`- ${r}`),""),e.contractSummary&&t.push("## Contract context","",e.contractSummary,""),e.verificationCommands.length>0){t.push("## Verification commands (this workspace)","");for(let r of e.verificationCommands)t.push(`- \`${r}\``);t.push("");}return t.push("## Answer contract","","Return: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh stale evidence","","```bash",X("workspace agent-sync --write --refresh-context"),"```",""),t.join(`
1
+ import {d as d$1,b as b$2,e,f as f$1}from'./chunk-LCRROMRR.js';import {d as d$2}from'./chunk-42G2OK64.js';import {b as b$1,f as f$2,j as j$1,k,h,i,l,m,n as n$1,o,p,q,r,t,v,x,s as s$1,u,w,y,z,A as A$1,B,C,D,E,F,G,a as a$2,H,I}from'./chunk-XIVFLY6G.js';import {n,k as k$1,b as b$4}from'./chunk-HYJK7W3B.js';import {j}from'./chunk-QWU2CZBG.js';import {f,b as b$3,a as a$1}from'./chunk-6AA3WWQZ.js';import {b,a}from'./chunk-5AKYMAIL.js';import s from'path';import f$3 from'fs-extra';var J=["Scope","Evidence","Diagnosis","Fix Plan","Run","Verify","Assumptions"];var lt="workspace-operational-skill.v1";function dt(e){if(typeof e!="string")return null;let t=e.trim();return !t||t.includes("/")||t.includes("..")?null:t}function Ke(e){let t=dt(e.skillId);if(!t)throw new Error(`Invalid skill id: ${e.skillId}`);return {schemaVersion:lt,skillId:t,canonicalPath:H(t),title:e.title,triggers:[...e.triggers].sort((r,n)=>r.localeCompare(n)),requiredReports:[...e.requiredReports].sort((r,n)=>r.localeCompare(n)),scopedProjects:[...e.scopedProjects??[]].sort((r,n)=>r.localeCompare(n)),verificationCommands:[...e.verificationCommands],answerContractSections:[...J],...e.promptStem?{promptStem:e.promptStem}:{},markdown:e.markdown}}var pt=b.skillsIndex;function qe(e){let t=[...e.skills].sort((n,l)=>n.skillId.localeCompare(l.skillId)),r=e.inputsHash??b$4({skillIds:t.map(n=>n.skillId),paths:t.map(n=>n.canonicalPath)});return {schemaVersion:pt,generatedAt:e.generatedAt,inputsHash:r,skills:t.map(n=>({skillId:n.skillId,path:n.canonicalPath,schemaVersion:n.schemaVersion,title:n.title}))}}var Ve=[a.agentIndex,d$1,d$2],ut=[{skillId:"workspai-diagnose-api-failure",title:"Diagnose API failure",triggers:["api failure","500 error","integration test failed","service unreachable"],objective:"Investigate a failing API or service using Workspai evidence before editing application code.",steps:[`Read \`${a.agentIndex}\` and identify fail/warn reports for the scoped project.`,`Read \`${a.doctor}\`, \`doctor-project-last-run.json\`, and project-scoped run evidence if present.`,"If a fix was requested, read `artifact-remediation-plan-last-run.json` for cross-artifact next steps, then `doctor-remediation-plan-last-run.json` for Doctor-specific file edits.","Map the failure to workspace vs project scope; cite exit codes and blocker messages.","Propose the smallest safe fix (config, env, dependency) with explicit verification commands."]},{skillId:"workspai-release-readiness",title:"Release readiness",triggers:["release","ship","production","readiness gate"],objective:"Assess whether this workspace is release-ready using governed Workspai gates.",steps:[`Read \`${a.readiness}\` and \`pipeline-last-run.json\`.`,`Read \`${a.verify}\` for verdict and blocking reasons.`,"Read `.workspai/reports/artifact-remediation-plan-last-run.json` when a Studio or agent repair path is needed.","List blocking gates first; never claim ready without cited report fields.","Provide one safe next command and a verification checklist."]},{skillId:"workspai-safe-schema-migration",title:"Safe schema migration",triggers:["migration","schema change","database migration","db migrate"],objective:"Plan and verify a schema migration with blast-radius awareness.",steps:["Identify affected projects from workspace model and dependency graph.","Run or review impact/verify evidence for transitive dependents.","Require project-scoped test/build commands before promoting the migration.","Document rollback and verification signals."]},{skillId:"workspai-dependency-upgrade",title:"Dependency upgrade",triggers:["upgrade dependency","bump package","security advisory","outdated deps"],objective:"Upgrade dependencies with graph-aware verification.",steps:["Scope the upgrade to the owning project from workspace model.","Check transitive dependents via workspace graph / impact reports.","Prefer workspace run test/build for affected projects.","Re-run `workspace verify` after evidence refresh."]},{skillId:"workspai-rename-contract",title:"Rename contract safely",triggers:["rename contract","rename event","breaking api","contract change"],objective:"Rename or change a shared contract with consumer awareness.",steps:["Read `.workspai/workspace.contract.json` for publishes/consumes/owns edges.","List all consumer projects before proposing renames.","Update contract file and regenerate workspace model.","Verify contract gate and integration tests for consumers."]}];function X(e){return `npx workspai ${e}`.trim()}function gt(e){let t=[`# ${e.template.title}`,"",`> Workspace: **${e.workspaceName}** \xB7 Skill: \`${e.template.skillId}\``,"","## Objective","",e.template.objective,"","## Triggers","",...e.template.triggers.map(r=>`- ${r}`),"","## Required evidence (read first)","",...Ve.map(r=>`- \`${r}\``),"","## Procedure","",...e.template.steps.map((r,n)=>`${n+1}. ${r}`),""];if(e.scopedProjects.length>0&&t.push("## Scoped projects","",...e.scopedProjects.map(r=>`- ${r}`),""),e.contractSummary&&t.push("## Contract context","",e.contractSummary,""),e.verificationCommands.length>0){t.push("## Verification commands (this workspace)","");for(let r of e.verificationCommands)t.push(`- \`${r}\``);t.push("");}return t.push("## Answer contract","","Return: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh stale evidence","","```bash",X("workspace agent-sync --write --refresh-context"),"```",""),t.join(`
2
2
  `)}function mt(e){return e?.safeCommands?.length?e.safeCommands.slice(0,8).map(t=>t.display):[X("workspace verify --json"),X("doctor workspace --json")]}function kt(e){return e?.projects?.length?e.projects.slice(0,12).map(r=>{let n=r.contracts?.owns?.join(", ")||"none",l=r.contracts?.publishes?.join(", ")||"none",p=r.contracts?.consumes?.join(", ")||"none";return `- **${r.slug}**: owns \`${n}\`; publishes \`${l}\`; consumes \`${p}\``}).join(`
3
3
  `):void 0}function Ue(e){let t=e.model.workspace.name,r=e.model.projects.map(p=>p.name).sort(),n=mt(e.context??null),l=kt(e.contract??null);return ut.map(p=>{let u=gt({template:p,workspaceName:t,scopedProjects:r,verificationCommands:n,contractSummary:l});return Ke({skillId:p.skillId,title:p.title,triggers:p.triggers,requiredReports:[...Ve],scopedProjects:r,verificationCommands:n,promptStem:I[p.skillId],markdown:u})})}async function ze(e){let t=s.resolve(e.workspacePath),r=[],n=b$4({skills:e.skills.map(p=>({id:p.skillId,path:p.canonicalPath,hash:b$4({markdown:p.markdown})}))}),l=qe({generatedAt:e.generatedAt,skills:e.skills,inputsHash:n});if(e.write){for(let u of e.skills){let i=s.join(t,u.canonicalPath);await f$3.ensureDir(s.dirname(i)),await f$3.writeFile(i,u.markdown,"utf8"),r.push(u.canonicalPath);}let p=s.join(t,b$1);await f$3.ensureDir(s.dirname(p)),await f$3.writeJson(p,l,{spaces:2}),r.push(b$1);}return {skills:e.skills,index:l,writtenPaths:r}}function Fe(e){return ["## Operational skills (canonical)","","Read workspace-native playbooks from `.workspai/skills/` before generic repo scans. Legacy `.rapidkit/skills/` playbooks are read only when already present from older workspaces:","",...e.skills.map(r=>`- \`${r.path}\` \u2014 ${r.title} (\`${r.skillId}\`)`),"","Regenerate:","","```bash",X("workspace agent-sync --write --refresh-context"),"```",""].join(`
4
4
  `)}var ft={"workspai-diagnose-api-failure":p,"workspai-release-readiness":t},xe="## Workspace verification (hydrated)";function ht(e){let t=[xe,"","Verification commands for this workspace:","",...e.verificationCommands.length?e.verificationCommands.map(r=>`- \`${r}\``):["- `npx workspai workspace verify --json`"]];return e.scopedProjects.length>0&&t.push("","Scoped projects:","",...e.scopedProjects.map(r=>`- ${r}`)),t.push(""),t.join(`
@@ -1,4 +1,4 @@
1
- import {f as f$1,e}from'./chunk-T3GJ7YVG.js';import {a,b}from'./chunk-22DT744Z.js';import {c as c$1}from'./chunk-2QOWRBQD.js';import {d as d$1,e as e$1,g,f as f$2,i}from'./chunk-7UZVOYF5.js';import {b as b$2,c,g as g$1}from'./chunk-FWJV7CCI.js';import {b as b$1,a as a$1}from'./chunk-5AKYMAIL.js';import {o}from'./chunk-5XATWNME.js';import d from'chalk';import l from'fs';import p from'path';var _="workspai-cli-operation-result-v1";function ie(e,t,s){return {schemaVersion:_,operation:e,status:"success",exitCode:0,artifact:t,...s?{outputPath:s}:{}}}function oe(e){return {schemaVersion:_,operation:e.operation,status:"error",exitCode:e.exitCode??1,error:{code:e.code,message:e.message},...e.context?{context:e.context}:{},...e.examples?{examples:e.examples}:{},...e.nextActions?{nextActions:e.nextActions}:{}}}var M=a$1.readiness,q=b$1.readiness;function H(e,t){let s=p.resolve(e);if(!b(s))return s;let r=z(t,"workspace.contract.json");if(l.existsSync(r))try{let o=JSON.parse(l.readFileSync(r,"utf-8")),n=Array.isArray(o.projects)?o.projects:[];for(let a of n){let u=f(a),v=typeof u.relativePath=="string"?u.relativePath.trim():"";if(v)return p.join(t,v)}}catch{}let i=T(t),c=Array.isArray(i.payload?.projects)?i.payload.projects:[];for(let o of c){let n=f(o),a=typeof n.path=="string"?n.path.trim():"";if(a)return p.resolve(a)}return s}function K(e){let t=d$1(e);return e$1(t,e)?"go":g(t,e)?"java":f$2(t,e)?"node":i(t,e)?"python":"unknown"}function $(e,t){if(!l.existsSync(e))return null;let s=l.readdirSync(e).filter(r=>r.endsWith(".json")&&t.some(i=>i.test(r))).map(r=>p.join(e,r));return s.length===0?null:(s.sort((r,i)=>l.statSync(i).mtimeMs-l.statSync(r).mtimeMs),s[0])}function f(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function W(e){for(let t of e)if(l.existsSync(t))return t;return null}function z(e,...t){let s=o(e,...t);return W(s)??s[0]}function S(e,t){let s=c(e,`.workspai/reports/${t}`);return W([s,p.join(e,".rapidkit","reports",t)])??s}async function U(e){let{readWorkspaceRegistrySummary:t,resolveWorkspaceRegisteredProjects:s}=await import('./workspace-registry-summary-S52SEJAG.js'),r=await t(e);return r?r.projectCount:(await s(e)).summary.projectCount}function B(e,t,s){let r=z(e,"toolchain.lock");if(!l.existsSync(r))return {gate:"env",status:"fail",summary:"toolchain.lock is missing",details:["Run workspai bootstrap to pin runtime versions and generate a reproducible toolchain."],evidencePath:r};try{let i=JSON.parse(l.readFileSync(r,"utf-8")),c=f(i.runtime),n=["python","node","go","java"].filter(a=>{let u=f(c[a]);return typeof u.version=="string"&&u.version.trim().length>0});if(n.length===0)return {gate:"env",status:"fail",summary:"No runtime versions are pinned in toolchain.lock",details:["Pin at least one runtime version via workspai setup <runtime> and re-run bootstrap."],evidencePath:r};if(t!=="unknown"){let a=f(c[t]);if(typeof a.version!="string"||a.version.trim().length===0)return {gate:"env",status:"fail",summary:`${s?.hasRegisteredProjects?"Project runtime":"Workspace"} (${t}) is not pinned in toolchain.lock`,details:[`Run workspai setup ${t} and workspai bootstrap to lock ${t} for this workspace.`],evidencePath:r}}return {gate:"env",status:"pass",summary:`Pinned runtimes: ${n.join(", ")}`,details:[],evidencePath:r}}catch{return {gate:"env",status:"fail",summary:"toolchain.lock is invalid JSON",details:["Regenerate lockfile with workspai bootstrap."],evidencePath:r}}}function T(e){let t=S(e,"doctor-last-run.json");if(!l.existsSync(t))return {payload:null,path:t};try{let s=JSON.parse(l.readFileSync(t,"utf-8"));return c$1(s,"workspace")?{payload:s,path:t}:{payload:null,path:t}}catch{return {payload:null,path:t}}}function Q(e){let t=T(e);if(!t.payload)return {gate:{gate:"doctor",status:"fail",summary:"Doctor evidence is missing",details:["Run workspai doctor workspace --json before release readiness checks."],evidencePath:t.path},payload:null};let s=f(t.payload.summary),r=Number(s.totalIssues??0);return s.hasSystemErrors?{gate:{gate:"doctor",status:"fail",summary:"Doctor reported system errors",details:["Resolve system-level doctor errors before proceeding."],evidencePath:t.path},payload:t.payload}:r>0?{gate:{gate:"doctor",status:"warn",summary:`Doctor found ${r} issue(s)`,details:["Run workspai doctor workspace --fix and re-run readiness checks."],evidencePath:t.path},payload:t.payload}:{gate:{gate:"doctor",status:"pass",summary:"Doctor checks passed without issues",details:[],evidencePath:t.path},payload:t.payload}}function X(e){let t=S(e,"analyze-last-run.json");if(!l.existsSync(t))return {gate:"analyze",status:"fail",summary:"Analyze evidence is missing",details:["Run workspai analyze --json before release readiness checks."],evidencePath:t};try{let s=JSON.parse(l.readFileSync(t,"utf-8"));b$2(a$1.analyze,s,t);let r=f(s.summary),i=String(r.verdict??"").toLowerCase(),c=Number(r.score??0),o=f(r.findings),n=Number(o.fail??0);return i==="blocked"||n>0?{gate:"analyze",status:"fail",summary:`Analyze verdict is blocked (score ${c}/100)`,details:["Resolve analyze findings and regenerate analyze-last-run.json."],evidencePath:t}:i==="needs-attention"?{gate:"analyze",status:"warn",summary:`Analyze needs attention (score ${c}/100)`,details:["Review analyze warnings before release."],evidencePath:t}:{gate:"analyze",status:"pass",summary:`Analyze passed (score ${c}/100)`,details:[],evidencePath:t}}catch{return {gate:"analyze",status:"fail",summary:"Analyze evidence is invalid or violates its contract",details:["Re-run workspai analyze --json to regenerate evidence."],evidencePath:t}}}function Y(e){try{let t=JSON.parse(l.readFileSync(e,"utf-8")),s=String(t.status??"").toLowerCase(),r=f(t.summary),i=Number(r.failedChecks??0);return s==="fail"||i>0?{gate:"verify",status:"fail",summary:"Verify-pack contract reports failed checks",details:["Fix failed verify checks and regenerate verify-pack contract evidence."],evidencePath:e}:s==="pass"?{gate:"verify",status:"pass",summary:"Verify-pack contract passed",details:[],evidencePath:e}:{gate:"verify",status:"warn",summary:"Verify-pack contract status is not explicit",details:["Ensure contract status is pass/fail and keep schema aligned with v1 contract."],evidencePath:e}}catch{return {gate:"verify",status:"fail",summary:"Verify-pack contract is invalid JSON",details:["Regenerate verify-pack contract artifact."],evidencePath:e}}}async function Z(e,t){if(t.skipVerify)return {gate:"verify",status:"pass",summary:"Verify gate skipped (--skip-verify)",details:["Verification was explicitly skipped for this readiness run."]};let s=[c(e,".workspai/reports"),p.join(e,".rapidkit","reports")],r=s[0],i=s.map(n=>$(n,[/verify-pack-contract/i,/^verify.*\.json$/i])).find(n=>typeof n=="string")??null;if(i)return Y(i);let c$1=c(e,a$1.contractVerify),o=s.map(n=>$(n,[/workspace-contract-verify-last-run/i,/workspace-contract-verify/i])).find(n=>typeof n=="string")??null;if(o)try{let n=JSON.parse(l.readFileSync(o,"utf-8")),a=String(n.status??"").toLowerCase();if(a==="passed"||a==="pass")return {gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI cache)",details:[],evidencePath:o};if(a==="failed"||a==="fail")return {gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI cache)",details:(Array.isArray(n.violations)?n.violations:[]).slice(0,5),evidencePath:o}}catch{}try{let{verifyWorkspaceContract:n}=await import('./workspace-contract-SEI4SNSG.js'),a=await n({workspacePath:e}),u={schemaVersion:"v1",source:"cli",generatedAt:new Date().toISOString(),status:a.status,contractPath:a.contractPath,projectCount:a.projectCount,checks:a.checks,violations:a.violations};return await g$1(e,a$1.contractVerify,u),a.status==="failed"?{gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI)",details:a.violations.slice(0,5),evidencePath:c$1}:{gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI)",details:[],evidencePath:c$1}}catch(n){return {gate:"verify",status:"fail",summary:"No verify evidence and workspace contract verification unavailable",details:["Run workspai workspace contract verify --json or export verify-pack contract from CI.",n instanceof Error?n.message:String(n)],evidencePath:p.join(r,"*verify*.json")}}}function ee(e,t){let s=S(t,"doctor-last-run.json");if(!e)return {gate:"dependency",status:"warn",summary:"Dependency risk check skipped (doctor evidence missing)",details:["Run workspai doctor workspace --json to include dependency findings."],evidencePath:s};let r=Array.isArray(e.projects)?e.projects:[],i=r.reduce((o,n)=>{let a=Number(n.vulnerabilities??0);return Number.isFinite(a)?o+Math.max(0,a):o},0),c=r.filter(o=>o.depsInstalled===false).length;return i>0?{gate:"dependency",status:"fail",summary:`${i} dependency vulnerability(ies) reported`,details:["Resolve vulnerabilities (npm/pip/go audit pipelines) before release."],evidencePath:s}:c>0?{gate:"dependency",status:"warn",summary:`${c} project(s) report missing dependencies`,details:["Run project init/bootstrap and regenerate doctor evidence."],evidencePath:s}:{gate:"dependency",status:"pass",summary:"No dependency vulnerabilities reported",details:[],evidencePath:s}}function te(e){return e.some(t=>t.status==="fail")?"fail":e.some(t=>t.status==="warn")?"warn":"pass"}async function se(e,t){return g$1(e,M,t)}async function re(e$1={}){let t=p.resolve(e$1.startPath??process.cwd()),s=a(t)??t,r=await U(s)>0,i=r&&b(t)?s:H(t,s),c=i===s?"unknown":K(i),n=B(s,r?c:"unknown",{hasRegisteredProjects:r}),a$1=Q(s),u=X(s),v=await Z(s,{skipVerify:e$1.skipVerify}),D=ee(a$1.payload,s),k=[n,a$1.gate,u,v,D],h=te(k),m={schemaVersion:q,generatedAt:new Date().toISOString(),workspacePath:s,projectPath:i,action:e$1.action,overallStatus:h,blocking:h==="fail",blockingReasons:k.filter(y=>y.status==="fail").map(y=>`${y.gate}: ${y.summary}`),gates:k};if(e$1.writeReport!==false){let y=f$1(m,{commandId:"workspaceReadiness",exitCode:h==="fail"?2:h==="warn"?1:0,generatedAt:m.generatedAt,blockers:m.blockingReasons,runId:e()});m.evidencePath=await se(s,y);}return m}function ne(e){return e==="pass"?d.green("PASS"):e==="warn"?d.yellow("WARN"):d.red("FAIL")}function ae(e){return e==="pass"?d.green("PASS"):e==="warn"?d.yellow("WARN"):d.red("FAIL")}async function we(e){let t=await re({startPath:e.workspace,writeReport:true,skipVerify:e.skipVerify===true});if(e.json)console.log(JSON.stringify(t,null,2));else {console.log(d.bold.cyan(`
1
+ import {f as f$1,e}from'./chunk-T3GJ7YVG.js';import {a,b}from'./chunk-22DT744Z.js';import {c as c$1}from'./chunk-2QOWRBQD.js';import {d as d$1,e as e$1,g,f as f$2,i}from'./chunk-7UZVOYF5.js';import {b as b$2,c,g as g$1}from'./chunk-6AA3WWQZ.js';import {b as b$1,a as a$1}from'./chunk-5AKYMAIL.js';import {o}from'./chunk-5XATWNME.js';import d from'chalk';import l from'fs';import p from'path';var _="workspai-cli-operation-result-v1";function ie(e,t,s){return {schemaVersion:_,operation:e,status:"success",exitCode:0,artifact:t,...s?{outputPath:s}:{}}}function oe(e){return {schemaVersion:_,operation:e.operation,status:"error",exitCode:e.exitCode??1,error:{code:e.code,message:e.message},...e.context?{context:e.context}:{},...e.examples?{examples:e.examples}:{},...e.nextActions?{nextActions:e.nextActions}:{}}}var M=a$1.readiness,q=b$1.readiness;function H(e,t){let s=p.resolve(e);if(!b(s))return s;let r=z(t,"workspace.contract.json");if(l.existsSync(r))try{let o=JSON.parse(l.readFileSync(r,"utf-8")),n=Array.isArray(o.projects)?o.projects:[];for(let a of n){let u=f(a),v=typeof u.relativePath=="string"?u.relativePath.trim():"";if(v)return p.join(t,v)}}catch{}let i=T(t),c=Array.isArray(i.payload?.projects)?i.payload.projects:[];for(let o of c){let n=f(o),a=typeof n.path=="string"?n.path.trim():"";if(a)return p.resolve(a)}return s}function K(e){let t=d$1(e);return e$1(t,e)?"go":g(t,e)?"java":f$2(t,e)?"node":i(t,e)?"python":"unknown"}function $(e,t){if(!l.existsSync(e))return null;let s=l.readdirSync(e).filter(r=>r.endsWith(".json")&&t.some(i=>i.test(r))).map(r=>p.join(e,r));return s.length===0?null:(s.sort((r,i)=>l.statSync(i).mtimeMs-l.statSync(r).mtimeMs),s[0])}function f(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function W(e){for(let t of e)if(l.existsSync(t))return t;return null}function z(e,...t){let s=o(e,...t);return W(s)??s[0]}function S(e,t){let s=c(e,`.workspai/reports/${t}`);return W([s,p.join(e,".rapidkit","reports",t)])??s}async function U(e){let{readWorkspaceRegistrySummary:t,resolveWorkspaceRegisteredProjects:s}=await import('./workspace-registry-summary-JM2XY52C.js'),r=await t(e);return r?r.projectCount:(await s(e)).summary.projectCount}function B(e,t,s){let r=z(e,"toolchain.lock");if(!l.existsSync(r))return {gate:"env",status:"fail",summary:"toolchain.lock is missing",details:["Run workspai bootstrap to pin runtime versions and generate a reproducible toolchain."],evidencePath:r};try{let i=JSON.parse(l.readFileSync(r,"utf-8")),c=f(i.runtime),n=["python","node","go","java"].filter(a=>{let u=f(c[a]);return typeof u.version=="string"&&u.version.trim().length>0});if(n.length===0)return {gate:"env",status:"fail",summary:"No runtime versions are pinned in toolchain.lock",details:["Pin at least one runtime version via workspai setup <runtime> and re-run bootstrap."],evidencePath:r};if(t!=="unknown"){let a=f(c[t]);if(typeof a.version!="string"||a.version.trim().length===0)return {gate:"env",status:"fail",summary:`${s?.hasRegisteredProjects?"Project runtime":"Workspace"} (${t}) is not pinned in toolchain.lock`,details:[`Run workspai setup ${t} and workspai bootstrap to lock ${t} for this workspace.`],evidencePath:r}}return {gate:"env",status:"pass",summary:`Pinned runtimes: ${n.join(", ")}`,details:[],evidencePath:r}}catch{return {gate:"env",status:"fail",summary:"toolchain.lock is invalid JSON",details:["Regenerate lockfile with workspai bootstrap."],evidencePath:r}}}function T(e){let t=S(e,"doctor-last-run.json");if(!l.existsSync(t))return {payload:null,path:t};try{let s=JSON.parse(l.readFileSync(t,"utf-8"));return c$1(s,"workspace")?{payload:s,path:t}:{payload:null,path:t}}catch{return {payload:null,path:t}}}function Q(e){let t=T(e);if(!t.payload)return {gate:{gate:"doctor",status:"fail",summary:"Doctor evidence is missing",details:["Run workspai doctor workspace --json before release readiness checks."],evidencePath:t.path},payload:null};let s=f(t.payload.summary),r=Number(s.totalIssues??0);return s.hasSystemErrors?{gate:{gate:"doctor",status:"fail",summary:"Doctor reported system errors",details:["Resolve system-level doctor errors before proceeding."],evidencePath:t.path},payload:t.payload}:r>0?{gate:{gate:"doctor",status:"warn",summary:`Doctor found ${r} issue(s)`,details:["Run workspai doctor workspace --fix and re-run readiness checks."],evidencePath:t.path},payload:t.payload}:{gate:{gate:"doctor",status:"pass",summary:"Doctor checks passed without issues",details:[],evidencePath:t.path},payload:t.payload}}function X(e){let t=S(e,"analyze-last-run.json");if(!l.existsSync(t))return {gate:"analyze",status:"fail",summary:"Analyze evidence is missing",details:["Run workspai analyze --json before release readiness checks."],evidencePath:t};try{let s=JSON.parse(l.readFileSync(t,"utf-8"));b$2(a$1.analyze,s,t);let r=f(s.summary),i=String(r.verdict??"").toLowerCase(),c=Number(r.score??0),o=f(r.findings),n=Number(o.fail??0);return i==="blocked"||n>0?{gate:"analyze",status:"fail",summary:`Analyze verdict is blocked (score ${c}/100)`,details:["Resolve analyze findings and regenerate analyze-last-run.json."],evidencePath:t}:i==="needs-attention"?{gate:"analyze",status:"warn",summary:`Analyze needs attention (score ${c}/100)`,details:["Review analyze warnings before release."],evidencePath:t}:{gate:"analyze",status:"pass",summary:`Analyze passed (score ${c}/100)`,details:[],evidencePath:t}}catch{return {gate:"analyze",status:"fail",summary:"Analyze evidence is invalid or violates its contract",details:["Re-run workspai analyze --json to regenerate evidence."],evidencePath:t}}}function Y(e){try{let t=JSON.parse(l.readFileSync(e,"utf-8")),s=String(t.status??"").toLowerCase(),r=f(t.summary),i=Number(r.failedChecks??0);return s==="fail"||i>0?{gate:"verify",status:"fail",summary:"Verify-pack contract reports failed checks",details:["Fix failed verify checks and regenerate verify-pack contract evidence."],evidencePath:e}:s==="pass"?{gate:"verify",status:"pass",summary:"Verify-pack contract passed",details:[],evidencePath:e}:{gate:"verify",status:"warn",summary:"Verify-pack contract status is not explicit",details:["Ensure contract status is pass/fail and keep schema aligned with v1 contract."],evidencePath:e}}catch{return {gate:"verify",status:"fail",summary:"Verify-pack contract is invalid JSON",details:["Regenerate verify-pack contract artifact."],evidencePath:e}}}async function Z(e,t){if(t.skipVerify)return {gate:"verify",status:"pass",summary:"Verify gate skipped (--skip-verify)",details:["Verification was explicitly skipped for this readiness run."]};let s=[c(e,".workspai/reports"),p.join(e,".rapidkit","reports")],r=s[0],i=s.map(n=>$(n,[/verify-pack-contract/i,/^verify.*\.json$/i])).find(n=>typeof n=="string")??null;if(i)return Y(i);let c$1=c(e,a$1.contractVerify),o=s.map(n=>$(n,[/workspace-contract-verify-last-run/i,/workspace-contract-verify/i])).find(n=>typeof n=="string")??null;if(o)try{let n=JSON.parse(l.readFileSync(o,"utf-8")),a=String(n.status??"").toLowerCase();if(a==="passed"||a==="pass")return {gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI cache)",details:[],evidencePath:o};if(a==="failed"||a==="fail")return {gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI cache)",details:(Array.isArray(n.violations)?n.violations:[]).slice(0,5),evidencePath:o}}catch{}try{let{verifyWorkspaceContract:n}=await import('./workspace-contract-LQJDZV36.js'),a=await n({workspacePath:e}),u={schemaVersion:"v1",source:"cli",generatedAt:new Date().toISOString(),status:a.status,contractPath:a.contractPath,projectCount:a.projectCount,checks:a.checks,violations:a.violations};return await g$1(e,a$1.contractVerify,u),a.status==="failed"?{gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI)",details:a.violations.slice(0,5),evidencePath:c$1}:{gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI)",details:[],evidencePath:c$1}}catch(n){return {gate:"verify",status:"fail",summary:"No verify evidence and workspace contract verification unavailable",details:["Run workspai workspace contract verify --json or export verify-pack contract from CI.",n instanceof Error?n.message:String(n)],evidencePath:p.join(r,"*verify*.json")}}}function ee(e,t){let s=S(t,"doctor-last-run.json");if(!e)return {gate:"dependency",status:"warn",summary:"Dependency risk check skipped (doctor evidence missing)",details:["Run workspai doctor workspace --json to include dependency findings."],evidencePath:s};let r=Array.isArray(e.projects)?e.projects:[],i=r.reduce((o,n)=>{let a=Number(n.vulnerabilities??0);return Number.isFinite(a)?o+Math.max(0,a):o},0),c=r.filter(o=>o.depsInstalled===false).length;return i>0?{gate:"dependency",status:"fail",summary:`${i} dependency vulnerability(ies) reported`,details:["Resolve vulnerabilities (npm/pip/go audit pipelines) before release."],evidencePath:s}:c>0?{gate:"dependency",status:"warn",summary:`${c} project(s) report missing dependencies`,details:["Run project init/bootstrap and regenerate doctor evidence."],evidencePath:s}:{gate:"dependency",status:"pass",summary:"No dependency vulnerabilities reported",details:[],evidencePath:s}}function te(e){return e.some(t=>t.status==="fail")?"fail":e.some(t=>t.status==="warn")?"warn":"pass"}async function se(e,t){return g$1(e,M,t)}async function re(e$1={}){let t=p.resolve(e$1.startPath??process.cwd()),s=a(t)??t,r=await U(s)>0,i=r&&b(t)?s:H(t,s),c=i===s?"unknown":K(i),n=B(s,r?c:"unknown",{hasRegisteredProjects:r}),a$1=Q(s),u=X(s),v=await Z(s,{skipVerify:e$1.skipVerify}),D=ee(a$1.payload,s),k=[n,a$1.gate,u,v,D],h=te(k),m={schemaVersion:q,generatedAt:new Date().toISOString(),workspacePath:s,projectPath:i,action:e$1.action,overallStatus:h,blocking:h==="fail",blockingReasons:k.filter(y=>y.status==="fail").map(y=>`${y.gate}: ${y.summary}`),gates:k};if(e$1.writeReport!==false){let y=f$1(m,{commandId:"workspaceReadiness",exitCode:h==="fail"?2:h==="warn"?1:0,generatedAt:m.generatedAt,blockers:m.blockingReasons,runId:e()});m.evidencePath=await se(s,y);}return m}function ne(e){return e==="pass"?d.green("PASS"):e==="warn"?d.yellow("WARN"):d.red("FAIL")}function ae(e){return e==="pass"?d.green("PASS"):e==="warn"?d.yellow("WARN"):d.red("FAIL")}async function we(e){let t=await re({startPath:e.workspace,writeReport:true,skipVerify:e.skipVerify===true});if(e.json)console.log(JSON.stringify(t,null,2));else {console.log(d.bold.cyan(`
2
2
  \u{1F6A6} Workspai Release Readiness
3
3
  `)),console.log(d.bold(`Workspace: ${d.cyan(p.basename(t.workspacePath))}`)),console.log(d.gray(`Path: ${t.workspacePath}`)),console.log(`Overall: ${ae(t.overallStatus)}`);for(let s of t.gates){console.log(` - ${s.gate}: ${ne(s.status)} ${s.summary}`);for(let r of s.details)console.log(d.gray(` ${r}`));s.evidencePath&&console.log(d.gray(` evidence: ${s.evidencePath}`));}t.evidencePath&&console.log(d.gray(`
4
4
  Evidence saved: ${t.evidencePath}`));}e.strict&&t.overallStatus!=="pass"&&process.exit(1);}export{_ as a,ie as b,oe as c,re as d,we as e};
@@ -1,4 +1,4 @@
1
- import {f as f$1,e as e$2}from'./chunk-7EIMPQR3.js';import {b as b$2}from'./chunk-JHC6SCJC.js';import {e,g,f as f$2,b as b$4,c as c$3,d as d$3}from'./chunk-5PVEQ6CZ.js';import {d as d$1,b as b$1}from'./chunk-GSWPGELT.js';import {c}from'./chunk-Y45WZR5N.js';import {f,c as c$2,e as e$3}from'./chunk-7YHK5NM3.js';import {a as a$1}from'./chunk-TQEMLBAG.js';import {b as b$3,j,i,l,h,s}from'./chunk-2K3GYCPS.js';import {b,a,c as c$1,d as d$2}from'./chunk-5XATWNME.js';import {promises}from'fs';import*as v from'fs-extra';import d from'path';import e$1 from'chalk';import {execa}from'execa';async function V(t,o={}){let n=d.resolve(t),s=o.workspaceName??d.basename(n);try{let{registerWorkspace:a}=await import('./workspace-FQT3QIRS.js');await a(n,s);}catch(a){o.silent||console.warn(e$1.gray(`Note: Could not register workspace in shared registry: ${a?.message??a}`));}try{let{syncWorkspaceContract:a}=await import('./workspace-contract-SEI4SNSG.js'),l=await a({workspacePath:n});if(o.silent||console.log(e$1.gray(`\u2139\uFE0F Workspace intelligence synced (contract + registry summary, ${l.contract.projects.length} project(s)).`)),!o.silent&&l.verification.status!=="passed"){console.log(e$1.yellow("\u26A0\uFE0F Workspace contract verification reported issues."));for(let p of l.verification.violations)console.log(e$1.gray(` Violation: ${p}`));console.log(e$1.white(" Next: npx workspai workspace contract inspect"));}}catch(a){o.silent||console.warn(e$1.gray(`Note: Could not sync workspace intelligence layer: ${a?.message??a}`));}}function D(){return h()}async function B(t,o,n,s,a){let l=d$1(o,c(),n,a?.pythonEngine?{coreStatus:a.pythonEngine,...a.pythonEngineReason?{coreReason:a.pythonEngineReason}:{},...s?{pythonVersion:s}:{}}:void 0);s&&!a?.pythonEngine&&(l.metadata||(l.metadata={}),l.metadata.python={pythonVersion:s}),await b$1(t,l);}async function G(t){await v.outputFile(d.join(t,".gitignore"),`.venv/
1
+ import {f as f$1,e as e$2}from'./chunk-G3H5R3RR.js';import {b as b$2}from'./chunk-NHN4QXPP.js';import {e,g,f as f$2,b as b$4,c as c$3,d as d$3}from'./chunk-5PVEQ6CZ.js';import {d as d$1,b as b$1}from'./chunk-GSWPGELT.js';import {c}from'./chunk-Y45WZR5N.js';import {f,c as c$2,e as e$3}from'./chunk-7YHK5NM3.js';import {a as a$1}from'./chunk-TQEMLBAG.js';import {b as b$3,j,i,l,h,s}from'./chunk-2K3GYCPS.js';import {b,a,c as c$1,d as d$2}from'./chunk-5XATWNME.js';import {promises}from'fs';import*as v from'fs-extra';import d from'path';import e$1 from'chalk';import {execa}from'execa';async function V(t,o={}){let n=d.resolve(t),s=o.workspaceName??d.basename(n);try{let{registerWorkspace:a}=await import('./workspace-PLXOO6ST.js');await a(n,s);}catch(a){o.silent||console.warn(e$1.gray(`Note: Could not register workspace in shared registry: ${a?.message??a}`));}try{let{syncWorkspaceContract:a}=await import('./workspace-contract-LQJDZV36.js'),l=await a({workspacePath:n});if(o.silent||console.log(e$1.gray(`\u2139\uFE0F Workspace intelligence synced (contract + registry summary, ${l.contract.projects.length} project(s)).`)),!o.silent&&l.verification.status!=="passed"){console.log(e$1.yellow("\u26A0\uFE0F Workspace contract verification reported issues."));for(let p of l.verification.violations)console.log(e$1.gray(` Violation: ${p}`));console.log(e$1.white(" Next: npx workspai workspace contract inspect"));}}catch(a){o.silent||console.warn(e$1.gray(`Note: Could not sync workspace intelligence layer: ${a?.message??a}`));}}function D(){return h()}async function B(t,o,n,s,a){let l=d$1(o,c(),n,a?.pythonEngine?{coreStatus:a.pythonEngine,...a.pythonEngineReason?{coreReason:a.pythonEngineReason}:{},...s?{pythonVersion:s}:{}}:void 0);s&&!a?.pythonEngine&&(l.metadata||(l.metadata={}),l.metadata.python={pythonVersion:s}),await b$1(t,l);}async function G(t){await v.outputFile(d.join(t,".gitignore"),`.venv/
2
2
  __pycache__/
3
3
  *.pyc
4
4
  .env
@@ -1 +1 @@
1
- import {b as b$1}from'./chunk-JHC6SCJC.js';import {j as j$1}from'./chunk-5PVEQ6CZ.js';import {c}from'./chunk-P424XYHP.js';import {a}from'./chunk-Y45WZR5N.js';import {f}from'./chunk-7YHK5NM3.js';import {b}from'./chunk-RO73VVHW.js';import {h,g}from'./chunk-5XATWNME.js';import {promises}from'fs';import i from'path';import P,{homedir}from'os';import {pathToFileURL}from'url';import l from'process';function W(e){let t=e.label.indexOf(" \u2014 ");return t>=0?e.label.slice(t+3).trim():e.label.trim()}function j(){let e=c().map(t=>({value:t.id,label:W(t),hint:t.description,name:t.label})),o=j$1().map(t=>({value:t.kitId,label:t.displayName,hint:t.commandDisplay("my-app"),name:`${t.displayName} \u2014 ${t.framework}`}));return [...e,...o]}var E=".workspairc.json",D=".rapidkitrc.json",U=["workspai.config.js","workspai.config.mjs","workspai.config.cjs","rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"];function I(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function x(e,o){let t=o instanceof Error?o.message:String(o),n=e.endsWith(".js")&&/module is not defined in ES module scope/i.test(t)?' CommonJS syntax in a .js config is not valid when the project package uses "type": "module"; rename the file to .cjs or use export default.':"";return `Failed to load Workspai config at ${e}.${n} Cause: ${t}`}async function he(){for(let e of [i.join(P.homedir(),E),i.join(P.homedir(),D)])try{let o=await promises.readFile(e,"utf-8"),t=JSON.parse(o);return f.debug(`Loaded config from ${e}`),t}catch{}return f.debug("No user config found, using defaults"),{}}async function ke(e=process.cwd()){let o=e,t=i.parse(o).root;for(;o!==t;){for(let n of U){let r=i.join(o,n);try{await promises.access(r);}catch(s){if(I(s))continue;throw new Error(x(r,s))}f.debug(`Found config file: ${r}`);try{let d=await import(pathToFileURL(r).href),u=d.default||d;return f.debug(`Loaded Workspai config from ${n}`),u}catch(s){throw new Error(x(r,s))}}o=i.dirname(o);}return f.debug("No Workspai config file found, using defaults"),{}}function ye(e,o,t){return {author:t.author||o.workspace?.defaultAuthor||e.author,pythonVersion:t.pythonVersion||o.workspace?.pythonVersion||e.pythonVersion,defaultInstallMethod:t.defaultInstallMethod||o.workspace?.installMethod||e.defaultInstallMethod,defaultKit:t.defaultKit||o.projects?.defaultKit||e.defaultKit,skipGit:t.skipGit??o.projects?.skipGit??e.skipGit,license:t.license||e.license,testRapidKitPath:t.testRapidKitPath||e.testRapidKitPath}}function we(e){return a("DEV_PATH")||e.testRapidKitPath||void 0}function M(e,o){let t=e.indexOf(o);if(t>=0&&t+1<e.length)return e[t+1];let n=e.find(r=>r.startsWith(`${o}=`));if(n)return n.slice(o.length+1)}function S(e){return e.includes("--here")}function v(e,o=l.cwd()){if(S(e))return i.resolve(o);let t=M(e,"--output");if(t)return i.resolve(t)}function Fe(e,o=l.cwd()){let t=i.resolve(e),n=i.resolve(o),r=i.relative(n,t);return r.length>0&&!r.startsWith("..")&&!i.isAbsolute(r)?`cd ${r}`:`cd ${t}`}function Ee(e,o={}){let t=o.argv??[],n=o.outputParent??v(t,l.cwd());return h(e.trim(),{homeDir:o.homeDir,outputDir:n})}function De(e,o,t={}){return e?i.resolve(e)===i.resolve(o)?true:t.outputParent===void 0:false}async function Ue(e,o={}){let t=o.cwd??l.cwd(),n=o.homeDir??homedir(),r=v(e,t);if(r!==void 0)return r;let s=o.hasYes??(e.includes("--yes")||e.includes("-y"));if(!(o.interactive??(!s&&!!l.stdin.isTTY&&!b())))return;let u=g(n),{location:K}=await b$1([{type:"rawlist",name:"location",message:"Where should the workspace be created?",choices:[{value:"managed",label:"Managed home",hint:u},{value:"here",label:"Current directory",hint:t}],default:0}]);if(K==="here")return i.resolve(t)}export{j as a,he as b,ke as c,ye as d,we as e,Fe as f,Ee as g,De as h,Ue as i};
1
+ import {b as b$1}from'./chunk-NHN4QXPP.js';import {j as j$1}from'./chunk-5PVEQ6CZ.js';import {c}from'./chunk-P424XYHP.js';import {a}from'./chunk-Y45WZR5N.js';import {f}from'./chunk-7YHK5NM3.js';import {b}from'./chunk-RO73VVHW.js';import {h,g}from'./chunk-5XATWNME.js';import {promises}from'fs';import i from'path';import P,{homedir}from'os';import {pathToFileURL}from'url';import l from'process';function W(e){let t=e.label.indexOf(" \u2014 ");return t>=0?e.label.slice(t+3).trim():e.label.trim()}function j(){let e=c().map(t=>({value:t.id,label:W(t),hint:t.description,name:t.label})),o=j$1().map(t=>({value:t.kitId,label:t.displayName,hint:t.commandDisplay("my-app"),name:`${t.displayName} \u2014 ${t.framework}`}));return [...e,...o]}var E=".workspairc.json",D=".rapidkitrc.json",U=["workspai.config.js","workspai.config.mjs","workspai.config.cjs","rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"];function I(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function x(e,o){let t=o instanceof Error?o.message:String(o),n=e.endsWith(".js")&&/module is not defined in ES module scope/i.test(t)?' CommonJS syntax in a .js config is not valid when the project package uses "type": "module"; rename the file to .cjs or use export default.':"";return `Failed to load Workspai config at ${e}.${n} Cause: ${t}`}async function ge(){for(let e of [i.join(P.homedir(),E),i.join(P.homedir(),D)])try{let o=await promises.readFile(e,"utf-8"),t=JSON.parse(o);return f.debug(`Loaded config from ${e}`),t}catch{}return f.debug("No user config found, using defaults"),{}}async function he(e=process.cwd()){let o=e,t=i.parse(o).root;for(;o!==t;){for(let n of U){let r=i.join(o,n);try{await promises.access(r);}catch(s){if(I(s))continue;throw new Error(x(r,s))}f.debug(`Found config file: ${r}`);try{let d=await import(pathToFileURL(r).href),u=d.default||d;return f.debug(`Loaded Workspai config from ${n}`),u}catch(s){throw new Error(x(r,s))}}o=i.dirname(o);}return f.debug("No Workspai config file found, using defaults"),{}}function ke(e,o,t){return {author:t.author||o.workspace?.defaultAuthor||e.author,pythonVersion:t.pythonVersion||o.workspace?.pythonVersion||e.pythonVersion,defaultInstallMethod:t.defaultInstallMethod||o.workspace?.installMethod||e.defaultInstallMethod,defaultKit:t.defaultKit||o.projects?.defaultKit||e.defaultKit,skipGit:t.skipGit??o.projects?.skipGit??e.skipGit,license:t.license||e.license,testRapidKitPath:t.testRapidKitPath||e.testRapidKitPath}}function ye(e){return a("DEV_PATH")||e.testRapidKitPath||void 0}function M(e,o){let t=e.indexOf(o);if(t>=0&&t+1<e.length)return e[t+1];let n=e.find(r=>r.startsWith(`${o}=`));if(n)return n.slice(o.length+1)}function S(e){return e.includes("--here")}function v(e,o=l.cwd()){if(S(e))return i.resolve(o);let t=M(e,"--output");if(t)return i.resolve(t)}function je(e,o=l.cwd()){let t=i.resolve(e),n=i.resolve(o),r=i.relative(n,t);return r.length>0&&!r.startsWith("..")&&!i.isAbsolute(r)?`cd ${r}`:`cd ${t}`}function Fe(e,o={}){let t=o.argv??[],n=o.outputParent??v(t,l.cwd());return h(e.trim(),{homeDir:o.homeDir,outputDir:n})}function Ee(e,o,t={}){return e?i.resolve(e)===i.resolve(o)?true:t.outputParent===void 0:false}async function De(e,o={}){let t=o.cwd??l.cwd(),n=o.homeDir??homedir(),r=v(e,t);if(r!==void 0)return r;let s=o.hasYes??(e.includes("--yes")||e.includes("-y"));if(!(o.interactive??(!s&&!!l.stdin.isTTY&&!b())))return;let u=g(n),{location:K}=await b$1([{type:"rawlist",name:"location",message:"Where should the workspace be created?",choices:[{value:"managed",label:"Managed home",hint:u},{value:"here",label:"Current directory",hint:t}],default:0}]);if(K==="here")return i.resolve(t)}export{j as a,ge as b,he as c,ke as d,ye as e,je as f,Fe as g,Ee as h,De as i};