workspai 0.43.0 → 0.43.1

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 (87) hide show
  1. package/README.md +3 -3
  2. package/contracts/extension-cli-compatibility.v1.json +1 -1
  3. package/dist/{artifact-remediation-plan-5GJWPPRS.js → artifact-remediation-plan-244S5K6I.js} +3 -3
  4. package/dist/autopilot-release-45YVOBQO.js +1 -0
  5. package/dist/chunk-3QVTWKUI.js +4 -0
  6. package/dist/{chunk-T6OR6YOI.js → chunk-7UZVOYF5.js} +1 -1
  7. package/dist/{chunk-CVTCPPEF.js → chunk-AMDKXXLP.js} +1 -1
  8. package/dist/{chunk-EWYYLJQY.js → chunk-CDE4Q77U.js} +1 -1
  9. package/dist/{chunk-AFSZHLQT.js → chunk-DOCPUNWS.js} +1 -1
  10. package/dist/{chunk-OJEWQO3Z.js → chunk-EMTQ6OKI.js} +17 -17
  11. package/dist/{chunk-RE773WOX.js → chunk-FDDDQMJ2.js} +5 -5
  12. package/dist/{chunk-5SWNSJGW.js → chunk-FHSMY75W.js} +1 -1
  13. package/dist/chunk-FM7GMFZA.js +2 -0
  14. package/dist/{chunk-54XJNLYC.js → chunk-HV5ZFXAZ.js} +1 -1
  15. package/dist/{chunk-LO4C4VXR.js → chunk-LRW2SAGL.js} +1 -1
  16. package/dist/{chunk-PI5KUXDA.js → chunk-LTWYYP6E.js} +1 -1
  17. package/dist/{chunk-VRDF2J46.js → chunk-ONU457VN.js} +17 -17
  18. package/dist/{chunk-LUP4U6EE.js → chunk-P424XYHP.js} +1 -1
  19. package/dist/{chunk-LPZFK3Y6.js → chunk-PPHTYJ7G.js} +61 -61
  20. package/dist/{chunk-XEJD4KCV.js → chunk-TH5Y3EMA.js} +1 -1
  21. package/dist/chunk-TQEMLBAG.js +1 -0
  22. package/dist/{chunk-3KXW53QI.js → chunk-U6AXYUQY.js} +1 -1
  23. package/dist/{chunk-AAKUNWPR.js → chunk-UQKCCWUL.js} +43 -43
  24. package/dist/{chunk-VZKSNUEE.js → chunk-XNGANEXM.js} +1 -1
  25. package/dist/{create-WRZO4HK2.js → create-42RTNLH2.js} +1 -1
  26. package/dist/demo-kit-DZ7TPG7K.js +149 -0
  27. package/dist/doctor-DK4BON3N.js +1 -0
  28. package/dist/{dotnet-webapi-clean-IPY3MCGQ.js → dotnet-webapi-clean-BYUUHX5Y.js} +20 -20
  29. package/dist/{gofiber-standard-N5N3QGH3.js → gofiber-standard-B6UK5GR7.js} +31 -31
  30. package/dist/{gogin-standard-LAWQTBWL.js → gogin-standard-BXU44VEM.js} +31 -31
  31. package/dist/index.js +222 -185
  32. package/dist/pipeline-HQ57V6OZ.js +5 -0
  33. package/dist/{pythonRapidkitExec-3L3XJBSY.js → pythonRapidkitExec-GCQ3M46E.js} +1 -1
  34. package/dist/{springboot-standard-OZYF7ZM7.js → springboot-standard-PEHDKH2L.js} +27 -27
  35. package/dist/{workspace-PR6VZRBG.js → workspace-DZHWB7BV.js} +1 -1
  36. package/dist/{workspace-agent-sync-KTYF3HQR.js → workspace-agent-sync-5ADIQS7B.js} +1 -1
  37. package/dist/{workspace-context-QUTOP2XV.js → workspace-context-GEXDHA7A.js} +1 -1
  38. package/dist/{workspace-contract-XUGMCUSQ.js → workspace-contract-2TA27LGT.js} +1 -1
  39. package/dist/workspace-explain-D5NNL3NG.js +1 -0
  40. package/dist/{workspace-foundation-KGSV4E6D.js → workspace-foundation-FQWHPQGX.js} +1 -1
  41. package/dist/{workspace-intelligence-QJGVL37U.js → workspace-intelligence-BEM6WGCZ.js} +1 -1
  42. package/dist/{workspace-mcp-serve-AK4MYEHQ.js → workspace-mcp-serve-OMBA5V3C.js} +1 -1
  43. package/dist/{workspace-model-PNXXOGPO.js → workspace-model-F3B75TYT.js} +1 -1
  44. package/dist/workspace-registry-summary-6MFBRWDS.js +1 -0
  45. package/dist/workspace-run-3WJXIQKR.js +1 -0
  46. package/dist/{workspace-verify-WSDUUTR5.js → workspace-verify-OAATQV5T.js} +1 -1
  47. package/dist/{workspace-watch-AGPOJ74Q.js → workspace-watch-HU2OTQ52.js} +1 -1
  48. package/package.json +12 -2
  49. package/templates/kits/fastapi-ddd/.gitignore.j2 +11 -0
  50. package/templates/kits/fastapi-ddd/README.md.j2 +23 -18
  51. package/templates/kits/fastapi-ddd/common/env.example.j2 +2 -2
  52. package/templates/kits/fastapi-ddd/pyproject.toml.j2 +7 -7
  53. package/templates/kits/fastapi-ddd/src/app/config/__init__.py.j2 +1 -1
  54. package/templates/kits/fastapi-ddd/src/cli.py.j2 +6 -9
  55. package/templates/kits/fastapi-ddd/src/main.py.j2 +1 -1
  56. package/templates/kits/fastapi-standard/.gitignore.j2 +11 -0
  57. package/templates/kits/fastapi-standard/README.md.j2 +35 -30
  58. package/templates/kits/fastapi-standard/common/env.example.j2 +2 -2
  59. package/templates/kits/fastapi-standard/pyproject.toml.j2 +7 -7
  60. package/templates/kits/fastapi-standard/src/cli.py.j2 +7 -10
  61. package/templates/kits/fastapi-standard/src/main.py.j2 +1 -1
  62. package/templates/kits/fastapi-standard/src/routing/examples.py.j2 +1 -1
  63. package/templates/kits/fastapi-standard/tests/test_examples.py.j2 +1 -1
  64. package/templates/kits/nestjs-standard/.dockerignore.j2 +11 -0
  65. package/templates/kits/nestjs-standard/.eslintrc.js.j2 +25 -0
  66. package/templates/kits/nestjs-standard/.gitignore.j2 +22 -0
  67. package/templates/kits/nestjs-standard/.node-version.j2 +1 -0
  68. package/templates/kits/nestjs-standard/.nvmrc.j2 +1 -0
  69. package/templates/kits/nestjs-standard/.prettierrc.j2 +7 -0
  70. package/templates/kits/nestjs-standard/README.md.j2 +23 -18
  71. package/templates/kits/nestjs-standard/docs/README.md.j2 +2 -2
  72. package/templates/kits/nestjs-standard/jest.config.ts.j2 +1 -7
  73. package/templates/kits/nestjs-standard/package.json.j2 +1 -1
  74. package/templates/kits/nestjs-standard/src/config/configuration.ts.j2 +4 -4
  75. package/templates/kits/nestjs-standard/src/main.ts.j2 +1 -1
  76. package/templates/kits/nestjs-standard/src/modules/index.ts.j2 +1 -1
  77. package/templates/kits/nestjs-standard/tsconfig.build.json.j2 +1 -1
  78. package/templates/kits/nestjs-standard/tsconfig.json.j2 +1 -1
  79. package/dist/autopilot-release-QYUOVB26.js +0 -1
  80. package/dist/chunk-LYC6AIF2.js +0 -2
  81. package/dist/chunk-WU4ZRRA5.js +0 -4
  82. package/dist/demo-kit-AJ5LIM5G.js +0 -149
  83. package/dist/doctor-MF3M3FS3.js +0 -1
  84. package/dist/pipeline-QCUHFWDY.js +0 -5
  85. package/dist/workspace-explain-JEONEGZZ.js +0 -1
  86. package/dist/workspace-registry-summary-RUJE6RPH.js +0 -1
  87. package/dist/workspace-run-Y7YMUIHX.js +0 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Workspai
1
+ # Workspai CLI
2
2
 
3
3
  ## Open-Source Workspace Intelligence for Software Systems
4
4
 
@@ -30,7 +30,7 @@ npm install -g workspai
30
30
  For short `npx` workflows, use the separate alias package:
31
31
 
32
32
  ```bash
33
- npx wsai --help
33
+ npx wspai --help
34
34
  ```
35
35
 
36
36
  ### CLI help
@@ -598,7 +598,7 @@ The extension invokes this npm CLI. For the latest `adopt` and frontend generato
598
598
 
599
599
  ```bash
600
600
  npm ci && npm run build && npm run test
601
- npm run install:local # link CLI globally for manual testing
601
+ npm run install:local # link workspai and wspai globally for manual testing
602
602
  ```
603
603
 
604
604
  Contributors: [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md), [docs/ci-workflows.md](docs/ci-workflows.md).
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": "rapidkit-extension-cli-compatibility.v1",
3
3
  "cli": "workspai",
4
- "minimumVerifiedCliVersion": "0.42.0",
4
+ "minimumVerifiedCliVersion": "0.43.1",
5
5
  "publishedContractSchemas": {
6
6
  "runtimeCommandSurface": "rapidkit-runtime-command-surface-v1",
7
7
  "cliLogEvent": "cli-log-event-v1",
@@ -1,3 +1,3 @@
1
- import {a as a$1}from'./chunk-2E6WGUN6.js';import {a,d,b}from'./chunk-NAAQMSO3.js';import y from'path';import j from'fs-extra';var x=[{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 I(e,r,t){return t?r:y.relative(e,r)}function K(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 C(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
- `}function M(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
- `}function N(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 h=m(b);return (Array.isArray(h?.projects)?h.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 P(e){let r=[],t=K("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:C(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:M(e.generatedAt),overwrite:false}}));return r}function S(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 $(e){let r=[a(e,".workspai/reports"),b(e,".workspai/reports")],t=[],i=new Set;for(let n of x)for(let c of n.fileNames){let d=(await Promise.all(r.map(a=>y.join(a,c)))).find(a=>j.pathExistsSync(a));if(!(!d||i.has(`${n.artifactKind}:${c}`))){i.add(`${n.artifactKind}:${c}`);try{let a=await j.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 V(e){let r=y.resolve(e.workspacePath),t=e.includeAbsolutePaths===true,i=e.ciMode===true,n=new Date().toISOString(),c=a(r,".workspai/reports"),d=await $(r),a$2=[],l=1;for(let o of d){let s=N(o);if(s.length!==0){if(o.artifactKind==="bootstrap-compliance"){a$2.push(...P({blockers:s,generatedAt:n})),l=a$2.length+1;continue}for(let b of s.slice(0,8))a$2.push(S({report:o,blocker:b,order:l,ciMode:i})),l+=1;}}let g={safe:a$2.filter(o=>o.risk==="safe").length,guarded:a$2.filter(o=>o.risk==="guarded").length,invasive:a$2.filter(o=>o.risk==="invasive").length};return {schemaVersion:a$1,generatedAt:n,workspace:{name:y.basename(r),...t?{path:r}:{}},source:{command:"workspace remediation-plan",reportsDir:I(r,c,t),includeAbsolutePaths:t,ciMode:i},summary:{artifactsScanned:d.length,cardsCovered:u(a$2.map(o=>o.cardId)).length,totalActions:a$2.length,executableActions:a$2.filter(o=>o.status==="ready").length,risk:g},actions:a$2}}async function q(e,r){return d(r,".workspai/reports/artifact-remediation-plan-last-run.json",e)}export{V as buildArtifactRemediationPlan,q as writeArtifactRemediationPlan};
1
+ import {a as a$1}from'./chunk-2E6WGUN6.js';import {a,d,b}from'./chunk-NAAQMSO3.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
+ `}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
+ `}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=[a(e,".workspai/reports"),b(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=a(r,".workspai/reports"),d=await O(r),a$2=[],l=1;for(let o of d){let s=P(o);if(s.length!==0){if(o.artifactKind==="bootstrap-compliance"){a$2.push(...S({blockers:s,generatedAt:n})),l=a$2.length+1;continue}for(let b of s.slice(0,8))a$2.push($({report:o,blocker:b,order:l,ciMode:i})),l+=1;}}let g={safe:a$2.filter(o=>o.risk==="safe").length,guarded:a$2.filter(o=>o.risk==="guarded").length,invasive:a$2.filter(o=>o.risk==="invasive").length};return {schemaVersion:a$1,generatedAt:n,workspace:{name:y.basename(r),...t?{path:r}:{}},source:{command:"workspace remediation-plan",reportsDir:K(r,c,t),includeAbsolutePaths:t,ciMode:i},summary:{artifactsScanned:d.length,cardsCovered:u(a$2.map(o=>o.cardId)).length,totalActions:a$2.length,executableActions:a$2.filter(o=>o.status==="ready").length,risk:g},actions:a$2}}async function W(e,r){return d(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-LTWYYP6E.js';
@@ -0,0 +1,4 @@
1
+ import {d,b as b$1,e}from'./chunk-753LOKFZ.js';import {j,q as q$1,n}from'./chunk-7UZVOYF5.js';import {h,i,f,e as e$1}from'./chunk-4KUIFXHM.js';import {d as d$1}from'./chunk-S5KTATOU.js';import {c}from'./chunk-NAAQMSO3.js';import {a}from'./chunk-GZTYAEWX.js';import {a as a$1}from'./chunk-TQEMLBAG.js';import {e as e$2,g}from'./chunk-LZQNVH7D.js';import {p,l,o}from'./chunk-5XATWNME.js';import _ from'fs';import b from'path';import E from'chalk';import {execa}from'execa';function Se(e){return _.existsSync(b.join(e,"bun.lock"))||_.existsSync(b.join(e,"bunfig.toml"))?"bun":_.existsSync(b.join(e,"pnpm-lock.yaml"))?"pnpm":_.existsSync(b.join(e,"yarn.lock"))?"yarn":(_.existsSync(b.join(e,"package-lock.json")),"npm")}function Ee(e,t,r=Se(e)){return r==="npm"?`npm run ${t}`:`${r} run ${t}`}function Ce(e,t=Se(e)){return `${t} install`}var Ge={"python-fastapi":{runtime:"python",framework:"FastAPI",markers:["pyproject.toml","fastapi"],commands:{init:"python -m pip install -e .",test:"pytest",build:"python -m build",start:"uvicorn main:app --reload"},errorPatterns:{setup:["ModuleNotFoundError","No module named","pip: command not found"],"test-failure":["FAILED","ERROR","test session started"],dependency:["ImportError","missing.*dependency"],runtime:["TypeError","AttributeError","ValueError"],timeout:["timeout","Timeout","timed out"],unknown:[]},healthCheck:{stage:"start",type:"http",value:"http://localhost:8000/docs"},validation:{command:"python -m pip list | grep fastapi",error:"FastAPI not installed"}},"python-django":{runtime:"python",framework:"Django",markers:["manage.py","django"],commands:{init:"python manage.py migrate",test:"python manage.py test",build:"python manage.py collectstatic --noinput",start:"python manage.py runserver 0.0.0.0:8000"},errorPatterns:{setup:["ModuleNotFoundError","ProgrammingError.*migrate"],"test-failure":["FAILED","ERROR","Ran.*test"],dependency:["ImportError","missing.*dependency"],runtime:["DatabaseError","ImproperlyConfigured"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"node-nestjs":{runtime:"node",framework:"NestJS",markers:["package.json","@nestjs/core"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm run start"},errorPatterns:{setup:["npm ERR!","ENOENT","not found"],"test-failure":["Tests.*failed","FAIL","fail.*test"],dependency:["Cannot find module","ERR_MODULE_NOT_FOUND"],runtime:["TypeError","Error: ","ReferenceError"],timeout:["timeout","TIMEOUT"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3}},"node-express":{runtime:"node",framework:"Express",markers:["package.json","express"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm start"},errorPatterns:{setup:["npm ERR!","ENOENT"],"test-failure":["failed","FAIL"],dependency:["Cannot find module"],runtime:["Error","TypeError"],timeout:["timeout"],unknown:[]}},"go-fiber":{runtime:"go",framework:"Fiber",markers:["go.mod","fiber"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found","cannot find","go mod tidy"],"test-failure":["FAIL","--- FAIL"],dependency:["missing.*module"],runtime:["panic","fatal","Error"],timeout:["timeout","context deadline"],unknown:[]},dependencies:["init"]},"go-gin":{runtime:"go",framework:"Gin",markers:["go.mod","gin-gonic"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found"],"test-failure":["FAIL"],dependency:["missing.*module"],runtime:["panic"],timeout:["timeout"],unknown:[]}},"java-springboot":{runtime:"java",framework:"Spring Boot",markers:["pom.xml","build.gradle","spring-boot"],commands:{init:"mvn dependency:go-offline",test:"mvn test",build:"mvn package -DskipTests",start:"mvn spring-boot:run"},errorPatterns:{setup:["\\[ERROR\\]","BUILD FAILURE","missing dependencies"],"test-failure":["\\[ERROR\\] Tests run:","BUILD FAILURE"],dependency:["missing.*dependency"],runtime:["Exception","Error","NullPointerException"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8080}},"php-laravel":{runtime:"php",framework:"Laravel",markers:["composer.json","artisan","app/Models"],commands:{init:"composer install && php artisan migrate:fresh --seed",test:"php artisan test",build:"php artisan config:cache && php artisan route:cache && php artisan view:cache",start:"php artisan serve --host=0.0.0.0 --port=8000"},errorPatterns:{setup:["Composer.*lock","Fatal error","Class.*not found"],"test-failure":["FAILED","Tests.*failed"],dependency:["Class.*not found","require.*failed"],runtime:["Fatal error","Exception","Error"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"php-symfony":{runtime:"php",framework:"Symfony",markers:["composer.json","symfony.lock","bin/console"],commands:{init:"composer install && php bin/console doctrine:database:create",test:"php bin/phpunit",build:"php bin/console cache:clear --env=prod",start:"symfony serve --no-tls"},errorPatterns:{setup:["Composer.*error","Fatal error"],"test-failure":["FAILED","failure"],dependency:["Class.*not found"],runtime:["Fatal error","Exception"],timeout:["timeout"],unknown:[]},dependencies:["init"]},"rust-actix":{runtime:"rust",framework:"Actix-web",markers:["Cargo.toml","actix"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find","failed.*download"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E","thread.*panicked"],timeout:["timeout"],unknown:[]},validation:{command:"cargo --version",error:"Rust/Cargo not installed"}},"rust-axum":{runtime:"rust",framework:"Axum",markers:["Cargo.toml","axum"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"rust-rocket":{runtime:"rust",framework:"Rocket",markers:["Cargo.toml","rocket"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["FAILED"],dependency:["can.t find"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"dotnet-aspnetcore":{runtime:"dotnet",framework:"ASP.NET Core",markers:[".csproj",".sln","Program.cs"],commands:{init:"dotnet restore",test:"dotnet test",build:"dotnet build -c Release",start:"dotnet run"},errorPatterns:{setup:["error CS","CSPROJ.*not found","NuGet.*restore"],"test-failure":["Failed:.*test","FAILED"],dependency:["error NU1101"],runtime:["error CS","Exception"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:5e3}},"elixir-phoenix":{runtime:"elixir",framework:"Phoenix",markers:["mix.exs","phoenix"],commands:{init:"mix setup",test:"mix test",build:"mix compile --all-warnings",start:"mix phx.server"},errorPatterns:{setup:["\\*\\* \\(.*Error\\)","Mix.InstallError"],"test-failure":["\\d+\\sfailed","FAILED"],dependency:["dependencies are not available"],runtime:["\\*\\* \\(","RuntimeError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:4e3},dependencies:["init"]},"ruby-rails":{runtime:"ruby",framework:"Rails",markers:["Gemfile","config/application.rb","bin/rails"],commands:{init:"bundle install && rails db:prepare",test:"rails test",build:"rails assets:precompile",start:"rails server --binding=0.0.0.0 --port=3000"},errorPatterns:{setup:["Bundler::.*Error","Gem::.*Error"],"test-failure":["failures,","error,","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","Exception","NoMethodError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3},dependencies:["init"]},"ruby-sinatra":{runtime:"ruby",framework:"Sinatra",markers:["Gemfile","app.rb","sinatra"],commands:{init:"bundle install",test:"rspec",build:`echo "Sinatra apps don't require build"`,start:"ruby app.rb"},errorPatterns:{setup:["Bundler.*Error","Gem.*Error"],"test-failure":["failure","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","NoMethodError"],timeout:["timeout"],unknown:[]}}},Be={init:{python:["pip install -e .","poetry install","pip install -r requirements.txt"],node:["npm install","pnpm install","yarn install"],go:["go mod download && go mod tidy","go get ./..."],java:["mvn dependency:go-offline","gradle dependencies"],php:["composer install"],rust:["cargo fetch"],dotnet:["dotnet restore"],elixir:["mix deps.get"],ruby:["bundle install"],"jvm-generic":["mvn dependency:go-offline","gradle dependencies"],unknown:[]},test:{python:["pytest","python -m unittest","python -m pytest"],node:["npm test","npm run test"],go:["go test ./...","make test"],java:["mvn test","gradle test"],php:["php artisan test","phpunit","pest"],rust:["cargo test"],dotnet:["dotnet test"],elixir:["mix test"],ruby:["rspec","ruby -m minitest"],"jvm-generic":["mvn test","gradle test"],unknown:[]},build:{python:["python -m build","python setup.py build"],node:["npm run build"],go:["go build -o app .","go build ./..."],java:["mvn package -DskipTests","gradle build -x test"],php:['echo "PHP build: typically no build step"'],rust:["cargo build --release"],dotnet:["dotnet build -c Release"],elixir:["mix compile"],ruby:["gem build *.gemspec"],"jvm-generic":["mvn package -DskipTests","gradle build"],unknown:[]},start:{python:["python app.py","python main.py","uvicorn main:app --reload"],node:["npm start","node index.js","node src/index.js"],go:["./app","go run main.go","go run ./..."],java:["mvn spring-boot:run","gradle bootRun","java -jar target/*.jar"],php:["php -S 0.0.0.0:8000","php artisan serve"],rust:["cargo run --release","./target/release/app"],dotnet:["dotnet run"],elixir:["mix phx.server","iex -S mix"],ruby:["rails server","ruby app.rb","bundle exec puma"],"jvm-generic":["java -jar *.jar","gradle run"],unknown:[]}};function se(e,t){if(t){let r=t.trim().toLowerCase().replace(/[_.\s]+/g,"-"),n=e$1(t),s=`${e}-${n==="gofiber"?"fiber":n==="gogin"?"gin":n==="dotnet"?"aspnetcore":n!=="unknown"?n:r==="fiber"?"fiber":r==="aspnetcore"||r==="asp-net-core"?"aspnetcore":r}`;return Ge[s]}}function Pe(e,t,r){if(t){let n=se(e,t);if(n&&n.commands[r])return n.commands[r]}if(["init","test","build","start"].includes(r)){let n=Be[r]?.[e]??[];return n.length>0?n[0]:void 0}}var ze={test:"test",build:"build",start:"start"};function ae(e){if(e.stage==="init")return e.runtime==="node"?Ce(e.projectPath):Pe(e.runtime,e.framework,e.stage);if(e.runtime==="node"){let t=ze[e.stage];if(t){let r=n(e.projectPath,t,{framework:e.framework});if(r)return Ee(e.projectPath,r.scriptName)}}return Pe(e.runtime,e.framework,e.stage)}function Ke(e){let t=h(e).map(r=>r==="python"?"python":r==="node"||r==="bun"?"node":r==="go"?"go":r==="java"?"java":r==="php"?"php":r==="rust"?"rust":r==="dotnet"?"dotnet":r==="elixir"?"elixir":r==="ruby"?"ruby":r==="clojure"||r==="scala"||r==="kotlin"?"jvm-generic":null).filter(r=>r!==null).filter((r,n,o)=>o.indexOf(r)===n);return {primary:t.length>0?t[0]:"unknown",secondary:t.slice(1)}}function Fe(e){return Ke(e).primary}function ie(e,t){if(!e)return "unknown";t||(t={setup:["ModuleNotFoundError","No module named","npm ERR!","error:","not found"],"test-failure":["FAILED","FAIL","failed"],dependency:["cannot find module","import.*error"],runtime:["Exception","Error:","panic","TypeError"],timeout:["timeout","Timeout","deadline exceeded"],unknown:[]});for(let[r,n]of Object.entries(t))for(let o of n)if(new RegExp(o,"i").test(e))return r;return "unknown"}async function q(e){let t=e.split(/[&|;]\s*/)[0].trim().split(/\s+/)[0];if(["echo","cd","pwd","test","true","false","exit"].includes(t))return {valid:true};try{let n=process.platform==="win32"?"where":"which";if((await execa(n,[t],{reject:false})).exitCode===0)return {valid:true}}catch{}return {valid:false,reason:`Command '${t}' not found or not executable`}}function Ae(e,t,r){if(!t)return e;let n=typeof t=="object"&&!Array.isArray(t)&&("dev"in t||"staging"in t||"prod"in t||"default"in t)&&!Object.keys(t).some(o=>["init","test","build","start"].includes(o))?t:{};return r&&typeof n[r]=="string"?n[r]:typeof n.default=="string"?n.default:e}var Ne={init:"init",test:"test",build:"build",start:"start"};function Ve(e){return e in Ne?Ne[e]:null}function He(e,t){let n=j(e)?.contextJson?.commands;if(!n||typeof n!="object"||Array.isArray(n))return;let o=n[t];if(typeof o=="string"&&o.trim().length>0)return o.trim();if(o&&typeof o=="object"&&!Array.isArray(o)){let s=o,c=s.default??s.dev;if(typeof c=="string"&&c.trim().length>0)return c.trim()}}function Oe(e,t,r=q$1(e)){let n=Ve(t);if(!n)return He(e,t)?{supported:true}:{supported:false,reason:`Workspace stage "${t}" is not part of the Workspai fleet contract.`};if(!r.projectRoot)return {supported:false,reason:"No Workspai project metadata was detected for this target."};let o=r.commandMap[n];if(!o||o.status!=="supported"){let s=r.runtimeSupportTier==="observed"||r.frameworkSupportTier==="observed";return {supported:false,reason:o?.reason??`Command "${n}" is not supported for this project runtime/framework.`,shouldFail:!s}}return {supported:true}}var Ue=new Set(["init","test","build","start"]),Je=new Set([".git","node_modules",".workspai",".rapidkit",".venv","dist","build","coverage","htmlcov"]);async function I(e){try{return await _.promises.access(e,_.constants.F_OK),true}catch{return false}}async function qe(e){for(let t of e)if(await I(t))return true;return false}async function Ye(e,t,r){if(t==="python"){let o=[b.join(e,".workspai","cli.py"),b.join(e,".rapidkit","cli.py")];for(let s of o)if(await I(s))return {valid:true};return {valid:false,reason:"Project-local .workspai/cli.py is missing. Run `workspai init` in this project first."}}let n=r.trim().split(/\s+/)[0];if(n&&["npm","npx","pnpm","yarn"].includes(n)){let o=e$2(n);if((await execa(o.command,[...o.prefixArgs,"--version"],{reject:false,env:g()})).exitCode===0)return {valid:true}}return q(r)}async function ue(e){let t=await _.promises.readFile(e,"utf-8");return JSON.parse(t)}function N(e){return e.replace(/\\/g,"/")}function Qe(e){let t=e?.trim();return t?t.startsWith("project:")?t.slice(8).trim()||null:t:null}async function Xe(e){return a(e,{skipDirs:Je,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:async(t,r)=>await qe([...p(t,"context.json"),...p(t,"project.json")])?true:b.resolve(t)===b.resolve(r)?false:h(t).length>0})}async function Ze(e){for(let t of [b.join(".workspai","project.json"),b.join(".workspai","context.json"),b.join(".rapidkit","project.json"),b.join(".rapidkit","context.json")]){let r=b.join(e,t);if(await I(r))try{let n=await ue(r),o=n.name??n.projectName??n.slug;if(typeof o=="string"&&o.trim())return o.trim()}catch{}}return null}async function et(e,t,r){let n=Qe(r);if(!n)return {projects:t,normalizedScope:null};let o=N(n).toLowerCase(),s=[];for(let c of t){let u=N(b.relative(e,c)),p=b.basename(c),m=await Ze(c);[u,p,m].filter(a=>typeof a=="string"&&a.length>0).map(a=>N(a).toLowerCase()).includes(o)&&s.push(c);}if(s.length===0)throw new Error(`Workspace run scope did not match any project: ${r}`);return {projects:s,normalizedScope:n}}async function tt(e,t,r){let n=await execa("git",["diff","--name-only",`${r}...HEAD`],{cwd:e,reject:false,env:a$1()});if(n.exitCode!==0)return new Set(t);let o=n.stdout.split(/\r?\n/).map(c=>c.trim()).filter(c=>c.length>0).map(c=>N(c));if(o.length===0)return new Set;let s=new Set;for(let c of t){let u=N(b.relative(e,c));if(!u||u===".")continue;let p=`${u}/`;o.some(m=>m===u||m.startsWith(p))&&s.add(c);}return s}async function rt(e,t,r){let n=await c(e,".workspai/workspace.contract.json")??l(e,"workspace.contract.json");if(await I(n))try{let g=await nt(e,t,r,n);if(g.graphStatus!=="missing")return g}catch{return {expanded:r,graphStatus:"invalid",expansionDepth:0}}let o=await c(e,".workspai/workspace-dependency-graph.json")??l(e,"workspace-dependency-graph.json");if(!await I(o))return {expanded:r,graphStatus:"missing",expansionDepth:0};let s;try{s=await ue(o);}catch{return {expanded:r,graphStatus:"invalid",expansionDepth:0}}let c$1=new Set(t.map(g=>b.resolve(g))),u=new Map;if(!s||typeof s!="object"||Array.isArray(s))return {expanded:r,graphStatus:"invalid",expansionDepth:0};let p=Array.isArray(s.projects)?s.projects:[];for(let g of p){if(!g||typeof g!="object"||Array.isArray(g))continue;let a=g,d=typeof a.path=="string"?a.path:"",y=b.resolve(e,d);if(!c$1.has(y))continue;let h=Array.isArray(a.dependsOn)?a.dependsOn.filter(w=>typeof w=="string"):[];for(let w of h){let x=b.resolve(e,w);c$1.has(x)&&(u.has(x)||u.set(x,new Set),u.get(x)?.add(y));}}let m=d$1(u,r);return {expanded:m.reached,graphStatus:"loaded",expansionDepth:m.added}}async function nt(e,t,r,n){let o=await ue(n);if(!o||typeof o!="object"||Array.isArray(o))return {expanded:r,graphStatus:"invalid",expansionDepth:0};let s=o,c=Array.isArray(s.projects)?s.projects:null;if(!c)return {expanded:r,graphStatus:"invalid",expansionDepth:0};let u=new Map,p=new Map;for(let y of t){let h=N(b.relative(e,y));p.set(h,b.resolve(y));}let m=new Map,g=new Map,a=new Map;for(let y of c){if(!y||typeof y!="object"||Array.isArray(y))continue;let h=y,w=typeof h.slug=="string"?h.slug:"",x=typeof h.relativePath=="string"?N(h.relativePath):w,R=p.get(x);!w||!R||u.set(w,R);}for(let y of c){if(!y||typeof y!="object"||Array.isArray(y))continue;let h=y,w=typeof h.slug=="string"?h.slug:"",x=u.get(w);if(!x)continue;let R=h.contracts&&typeof h.contracts=="object"&&!Array.isArray(h.contracts)?h.contracts:{},j=Array.isArray(R.dependsOn)?R.dependsOn.filter(v=>typeof v=="string"):[],O=Array.isArray(R.publishes)?R.publishes.filter(v=>typeof v=="string"):[],W=Array.isArray(R.consumes)?R.consumes.filter(v=>typeof v=="string"):[];for(let v of j){let S=u.get(v);S&&(a.has(S)||a.set(S,new Set),a.get(S)?.add(x));}for(let v of O)m.has(v)||m.set(v,new Set),m.get(v)?.add(x);for(let v of W)g.has(v)||g.set(v,new Set),g.get(v)?.add(x);}for(let[y,h]of m.entries()){let w=g.get(y);if(w)for(let x of h){a.has(x)||a.set(x,new Set);for(let R of w)R!==x&&a.get(x)?.add(R);}}let d=d$1(a,r);return {expanded:d.reached,graphStatus:"loaded",expansionDepth:d.added}}async function ot(e,t){if(typeof t=="boolean")return t;let r=o(e,"policies.yml").find(s=>_.existsSync(s))??l(e,"policies.yml");if(!await I(r))return true;let n="";try{n=await _.promises.readFile(r,"utf-8");}catch{return true}let o$1=n.match(/^[\t ]*rules\.enforce_workspace_run_gates:\s*(true|false)\s*(?:#.*)?$/m);return o$1?o$1[1]==="true":true}function st(e){let t=process.env.RAPIDKIT_WORKSPACE_RUN_STAGE_TIMEOUT_MS;if(t){let r=Number.parseInt(t,10);if(Number.isFinite(r)&&r>0)return r}return e==="init"?12e4:9e4}async function ce(e,t,r){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for nested workspace-run execution."};try{let o=await execa(process.execPath,[n,...e],{cwd:t,reject:false,timeout:r,env:{...process.env,RAPIDKIT_WORKSPACE_RUN_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr}}catch(o){return {exitCode:typeof o=="object"&&o!==null&&"timedOut"in o&&!!o.timedOut?124:1,stdout:typeof o=="object"&&o!==null&&"stdout"in o?String(o.stdout??""):"",stderr:typeof o=="object"&&o!==null&&"stderr"in o?String(o.stderr??""):o instanceof Error?o.message:String(o)}}}function at(e){return e==="node"||e==="go"||e==="java"||e==="python"||e==="dotnet"}function it(){return process.env.VITEST==="true"||process.env.VITEST==="1"||process.env.NODE_ENV==="test"}async function ct(e){let t=process.cwd();try{process.chdir(e);let{handleInitCommand:r}=await import('./index.js');return {exitCode:await r(["init"]),stdout:"",stderr:""}}finally{process.chdir(t);}}async function ut(e){let t=a=>{let d=f(a);return d==="node"||d==="bun"?"node":d==="python"?"python":d==="go"?"go":d==="java"?"java":d==="php"?"php":d==="ruby"?"ruby":d==="rust"?"rust":d==="dotnet"?"dotnet":d==="elixir"?"elixir":d==="clojure"||d==="scala"||d==="kotlin"?"jvm-generic":Fe(e)},r=a=>{if(!a)return;let d=e$1(a);if(new Set(["fastapi","django","flask","nestjs","express","fastify","koa","gofiber","gogin","echo","springboot","laravel","symfony","rails","sinatra","dotnet","actix","axum","rocket","phoenix"]).has(d))return d},n=j(e),o=n?.detection??i(e,n?.projectJson??null),s=n?.contextJson,c=t(o.runtime),u=r(o.key),p={},m=new Set(["init","test","build","start"]);if(s?.commands&&typeof s.commands=="object")for(let[a,d]of Object.entries(s.commands))typeof d=="string"&&m.has(a)&&(p[a]=d);let g;if(s?.commandEnvironments&&typeof s.commandEnvironments=="object"){let a=s.commandEnvironments;g={dev:typeof a.dev=="string"?a.dev:void 0,staging:typeof a.staging=="string"?a.staging:void 0,prod:typeof a.prod=="string"?a.prod:void 0,default:typeof a.default=="string"?a.default:void 0};}return {runtime:c,framework:u,commandOverrides:Object.keys(p).length>0?p:void 0,environmentCommandVariants:g,environment:typeof s?.environment=="string"?s.environment:void 0}}async function dt(e,t,r,n,o,s,c){let u=!o?.[t]&&at(r),p;if(o&&o[t]?p=o[t]:u?p=`rapidkit ${t}`:p=ae({projectPath:e,runtime:r,framework:n,stage:t}),!p)return {exitCode:127,command:`<stage not supported for ${r}>`,message:`No stage command found for runtime '${r}' and framework '${n||"unknown"}'`,errorCategory:"runtime"};let m=Ae(p,s,c);if(!m)return {exitCode:127,command:p,message:"Failed to resolve stage command",errorCategory:"runtime"};let g=ae({projectPath:e,runtime:r,framework:n,stage:t});if(u){if(g){let f=u?await Ye(e,r,g):await q(g);if(!f.valid)return {exitCode:127,command:m,message:f.reason||"Command not available",errorCategory:"setup"}}}else {let f=await q(m);if(!f.valid)return {exitCode:127,command:m,message:f.reason||"Command not available",errorCategory:"setup"}}let a=0,d="",y="",h,w=st(t),x=Date.now();try{let f=u?t==="init"&&it()?await ct(e):await ce([t],e,w):await execa(m,[],{cwd:e,reject:false,shell:true,timeout:w});if(a=Number(f.exitCode??0),d=f.stdout,y=f.stderr,a!==0){let C=`${d}
2
+ ${y}`,z=Date.now()-x;h=a===124||ie(C)==="timeout"||a===143&&z>=Math.floor(w*.8)?"timeout":ie(C);}}catch(f){let C=typeof f=="object"&&f!==null&&"timedOut"in f&&!!f.timedOut;return {exitCode:C?124:1,command:m,message:C?`Stage timed out after ${w}ms`:f instanceof Error?f.message:"Command execution failed",errorCategory:C?"timeout":"runtime"}}let R,j=`${d}
3
+ ${y}`.split(/\r?\n/).map(f=>f.trim()).filter(Boolean),O=j.slice(0,6).join(`
4
+ `),W=Date.now()-x,v=a===124||h==="timeout"||a===143&&W>=Math.floor(w*.8),S=a===0?void 0:v?"timeout":h,T=a===0||!S?void 0:{category:S,exitCode:a,command:m,timedOut:v,timeoutMs:w,...O?{outputExcerpt:O}:{}};return {exitCode:a,command:m,errorCategory:S,healthStatus:R,failureDiagnostic:T,message:v?`Stage timed out after ${w}ms`:a!==0?O?`Stage failed with exit code ${a}: ${j[0]}`:`Stage failed with exit code ${a}`:void 0}}function De(e){try{return JSON.parse(e)}catch{return null}}function lt(e){switch(e){case "dotnet":return "Install .NET 8+ SDK, then rerun `npx workspai setup dotnet` or `npx workspai init`.";case "go":return "Install Go 1.21+, then rerun `npx workspai setup go` or `npx workspai init`.";case "java":case "jvm-generic":return "Install Java 21+ and Maven/Gradle, then rerun `npx workspai setup java` or `npx workspai init`.";case "node":return "Install Node.js LTS and npm/pnpm/yarn, then rerun `npx workspai setup node` or `npx workspai init`.";case "python":return "Install Python 3.10+ and pip/Poetry, then rerun `npx workspai setup python` or `npx workspai init`.";default:return null}}async function pt(e){let t=[],r=await ce(["doctor","workspace","--json"],e);if(r.exitCode!==0)t.push({gate:"doctor-workspace",status:"fail",summary:"doctor workspace command failed"});else {let s=De(r.stdout)?.healthScore,c=Number(s?.errors??0);Number.isFinite(c)&&c>0?t.push({gate:"doctor-workspace",status:"fail",summary:`doctor workspace reports ${c} error(s)`}):t.push({gate:"doctor-workspace",status:"pass",summary:"doctor workspace passed"});}let n=await ce(["readiness","--json"],e);if(n.exitCode!==0)t.push({gate:"readiness",status:"fail",summary:"readiness command failed"});else {let o=De(n.stdout),s=String(o?.overallStatus??"").toLowerCase();s==="fail"?t.push({gate:"readiness",status:"fail",summary:"readiness overall status is fail"}):s==="warn"?t.push({gate:"readiness",status:"warn",summary:"readiness overall status is warn"}):t.push({gate:"readiness",status:"pass",summary:"readiness overall status is pass"});}return t}var mt=new Set(["dev","stop"]);function ft(e){let t=e.trim();return !t||mt.has(t.toLowerCase())?false:Ue.has(t)?true:/^[a-z][a-z0-9_-]*$/i.test(t)}function Te(e,t,r){let n=N(b.relative(r,t));return (Array.isArray(e.projects)?e.projects:[]).some(s=>{if(!s||typeof s!="object")return false;let c=s,u=[c.relativePath,c.path].filter(p=>typeof p=="string"&&p.length>0).map(p=>N(p));return c.status==="passed"&&(u.includes(n)||u.some(p=>p.endsWith(`/${n}`)))})}function gt(e,t){return se(e,t)?.dependencies??[]}function yt(e,t){let r=Math.max(1,Math.min(4,t)),n=Number(e??r);return Number.isFinite(n)?Math.max(1,Math.min(16,Math.trunc(n))):r}async function Xt(e$1){if(!ft(e$1.stage))throw new Error(`Unsupported workspace run stage: ${e$1.stage}`);let t=Date.now(),r=b.resolve(e$1.workspacePath),n=await d(r),o=await Xe(r),{projects:s,normalizedScope:c}=await et(r,o,e$1.scope),u=e$1.affected===true,p=e$1.blastRadius===true,m=e$1.since?.trim()||"HEAD~1",g=u?await tt(r,s,m):new Set(s),a,d$1="not-applicable",y=0,h="all";if(u&&p){let l=await rt(r,o,g);a=l.expanded,d$1=l.graphStatus,y=l.expansionDepth,h="affected+blast-radius";}else u?(a=g,h="affected"):(a=g,h="all");let w=e$1.stage==="init"?false:await ot(r,e$1.enforceGates),x=w?await pt(r):[{gate:"doctor-workspace",status:"skipped",summary:"workspace run gates disabled"},{gate:"readiness",status:"skipped",summary:"workspace run gates disabled"}],R=x.find(l=>l.status==="fail"),j=s.filter(l=>a.has(l)),O=e$1.continueOnError===true||e$1.stage==="init",W=e$1.parallel===true,v=yt(e$1.maxWorkers,j.length),S=j.length,T=0;e$1.json||console.log(E.gray(`Workspace run (${e$1.stage}) started: ${S} target(s), ${W?`parallel x${v}`:"sequential"}`));let f=new Map;for(let l of o){let k=N(b.relative(r,l)),i=s.includes(l),F=i&&a.has(l);f.set(l,{path:l,relativePath:k,projectName:b.basename(k)||b.basename(l),selected:F,affected:F,status:"skipped",exitCode:null,durationMs:0,reason:F?void 0:i?"not affected":"outside scope",framework:void 0,runtimeDetected:void 0,executionCommand:void 0});}if(R)for(let l of j){let k=f.get(l);k&&(k.status="skipped",k.reason=`blocked by ${R.gate}`);}else {let l=async k=>{let i=f.get(k);if(!i)return;let F=N(b.relative(r,k));e$1.json||console.log(E.gray(`\u23F3 [${T}/${S}] ${e$1.stage} ${F}`)),i.selected=true,i.affected=true;let A=Date.now(),{runtime:P,framework:D,commandOverrides:$e,environmentCommandVariants:Ie,environment:Le}=await ut(k);i.runtimeDetected=P,i.framework=D;let Q=Oe(k,e$1.stage);if(!Q.supported){i.status=Q.shouldFail===false?"skipped":"failed",i.reason=Q.reason??`stage "${e$1.stage}" unsupported for project`,i.durationMs=Date.now()-A,i.exitCode=i.status==="failed"?127:null,i.status==="failed"&&(i.errorCategory="setup",i.errorMessage=i.reason),T+=1;return}if(e$1.reusePassed&&n){let $=n.stages[e$1.stage]??n.stages[e$1.stage];if($&&Te($,k,r)){i.status="passed",i.reason="reused passed result from workspace-run-last.json",i.durationMs=Date.now()-A,i.exitCode=0,T+=1,e$1.json||console.log(E.gray(`\u21BA reused passed cache for ${F}`));return}}let me=gt(P,D);if(me.length>0&&n){let $=me.find(X=>{let L=n.stages[X];return !L||!Te(L,k,r)});if($){i.status="skipped",i.reason=`dependency stage "${$}" not satisfied in workspace-run-last.json`,i.durationMs=Date.now()-A,i.exitCode=null,T+=1;return}}let M=await dt(k,e$1.stage,P,D,$e,Ie,Le);if(i.executionCommand=M.command,i.errorCategory=M.errorCategory,i.healthStatus=M.healthStatus,i.failureDiagnostic=M.failureDiagnostic,i.durationMs=Date.now()-A,i.exitCode=M.exitCode,M.exitCode===0?(i.status="passed",i.reason=void 0):(i.status="failed",i.reason=M.message||"stage command failed",i.errorMessage=M.message),T+=1,!e$1.json){let $=S>0?Math.round(T/S*100):100,X=i.status==="passed"?E.green("\u2705"):E.red("\u274C");if(console.log(E.gray(`${X} [${T}/${S}] (${$}%) ${F} ${i.durationMs}ms`)),i.status==="failed"){i.reason&&console.log(E.red(` Reason: ${i.reason}`)),i.executionCommand&&console.log(E.gray(` Command: ${i.executionCommand}`));let L=lt(i.runtimeDetected);L&&i.errorCategory==="setup"&&console.log(E.gray(` Hint: ${L}`));}}};if(W&&j.length>1){let k=0,i=false,F=new Array(v).fill(null).map(async()=>{for(;k<j.length;){if(i&&!O)return;let A=k;k+=1;let P=j[A];await l(P),f.get(P)?.status==="failed"&&(i=true);}});if(await Promise.all(F),!O&&i){let A=false;for(let P of j){let D=f.get(P);if(D){if(D.status==="failed"){A=true;continue}A&&D.status==="skipped"&&(D.reason=D.reason||"stopped after failure");}}}}else for(let k of j){await l(k);let i=f.get(k);if(!O&&i?.status==="failed"){let F=j.slice(j.indexOf(k)+1);for(let A of F){let P=f.get(A);P&&(P.status="skipped",P.reason="stopped after failure");}break}}}let C=[];for(let l of o){let k=f.get(l);k&&C.push(k);}let z=C.filter(l=>l.status==="passed").length,K=C.filter(l=>l.status==="failed").length,de=C.filter(l=>l.status==="skipped").length,le=e$1.strict===true,Me=K>0||le&&x.some(l=>l.status==="fail"||l.status==="warn")?1:0,pe={schemaVersion:"1.0",workspacePath:r,stage:e$1.stage,generatedAt:new Date().toISOString(),durationMs:Date.now()-t,options:{affected:u,blastRadius:p,since:u?m:null,parallel:W,maxWorkers:v,continueOnError:O,strict:le,enforceGates:w,scope:c,reusePassed:e$1.reusePassed===true},selection:{mode:h,since:u?m:null,scope:c,graphStatus:d$1,expansionDepth:y},gates:{enforced:w,results:x,blocked:!!R,blockingGate:R?.gate},summary:{projectCount:o.length,selectedCount:j.length,passed:z,failed:K,skipped:de,exitCode:Me},projects:C,enterpriseControls:{jsonReady:true,evidencePath:b$1}},We=b.join(r,b$1);return await e(r,pe),e$1.json||(R&&(console.log(E.red(`\u274C Workspace run blocked by ${R.gate}`)),console.log(E.gray(` ${R.summary}`))),console.log(E.cyan(`Workspace run (${e$1.stage}) => passed: ${z}, failed: ${K}, skipped: ${de}`)),console.log(E.gray(`Report: ${We}`))),pe}export{Xt as a};
@@ -1,2 +1,2 @@
1
- import {a as a$1,c as c$1,i,g as g$1,h}from'./chunk-4KUIFXHM.js';import {a as a$2}from'./chunk-LUP4U6EE.js';import {p}from'./chunk-5XATWNME.js';import _ from'fs';import a from'path';var g=["init","dev","start","build","test","lint","format","help"],J={python:{runtime:"python",displayName:"Python",tier:"first-class",scaffoldSupport:true,importSupport:true,lifecycleCommands:g,moduleCommands:true,doctorSupport:"full",notes:["Core-backed Python projects support RapidKit Core modules and lifecycle commands."]},node:{runtime:"node",displayName:"Node.js",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:g,moduleCommands:true,doctorSupport:"full",notes:["Node projects support npm-owned lifecycle commands; NestJS is the first-class Node framework."]},go:{runtime:"go",displayName:"Go",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:g,moduleCommands:false,doctorSupport:"readiness",notes:["Go projects support workspace governance and lifecycle commands via Go tooling."]},java:{runtime:"java",displayName:"Java / Spring Boot",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:g,moduleCommands:false,doctorSupport:"readiness",notes:["Java projects support Maven/Gradle lifecycle commands and workspace governance."]},dotnet:{runtime:"dotnet",displayName:".NET / ASP.NET Core",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:g,moduleCommands:false,doctorSupport:"readiness",notes:[".NET projects support dotnet CLI lifecycle commands and workspace governance."]},php:{runtime:"php",displayName:"PHP",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["PHP projects are importable and governed as observed projects until a kit exists."]},ruby:{runtime:"ruby",displayName:"Ruby",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Ruby projects are importable and governed as observed projects until a kit exists."]},rust:{runtime:"rust",displayName:"Rust",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Rust projects are importable and governed as observed projects until a kit exists."]},elixir:{runtime:"elixir",displayName:"Elixir",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Elixir projects are importable and governed as observed projects until a kit exists."]},clojure:{runtime:"clojure",displayName:"Clojure",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Clojure projects are importable and governed as observed projects until a kit exists."]},scala:{runtime:"scala",displayName:"Scala",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Scala projects are importable and governed as observed projects until a kit exists."]},kotlin:{runtime:"kotlin",displayName:"Kotlin",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Kotlin projects are importable and governed as observed projects until a kit exists."]},deno:{runtime:"deno",displayName:"Deno",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Deno projects are importable and governed as observed projects until a kit exists."]},bun:{runtime:"bun",displayName:"Bun",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Bun projects are importable and governed as observed projects until a kit exists."]},unknown:{runtime:"unknown",displayName:"Unknown",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Unknown projects are tracked safely but require manual command configuration."]}},me=["fastapi","nestjs"],ue=["django","flask","nextjs","remix","nuxt","react","vite","vue","sveltekit","svelte","angular","astro","solid","express","fastify","koa","echo","gofiber","gogin","springboot","dotnet","laravel","symfony","rails","sinatra","actix","axum","rocket","phoenix","clojure","scala","kotlin","deno","bun"];function S(e){return J[e||"unknown"]??J.unknown}function q(e){return me.includes(e)?"first-class":ue.includes(e)?"extended":"observed"}function Y(e){let t=S(e.runtime);return {lifecycleCommands:t.lifecycleCommands,moduleCommands:e.moduleSupport&&t.moduleCommands,unsupportedLifecycleCommands:g.filter(n=>!t.lifecycleCommands.includes(n))}}var ce=["python","node","go","java","dotnet"];function b(e){return !!e&&ce.includes(e)}function N(e,t){return t!=="lint"&&t!=="format"&&t!=="docs"?false:e==="python"}function H(e){let t=S(e),n=b(t.runtime),r=le[t.runtime]??[],i=de[t.runtime]??[];return {runtime:t.runtime,displayName:t.displayName,lifecycleCommands:t.lifecycleCommands,hasExecutor:n,packageManagers:r,primaryFiles:i,notes:t.notes}}var le={python:["poetry","pip","uv"],node:["npm","pnpm","yarn","bun"],go:["go"],java:["maven","gradle"],dotnet:["dotnet"],php:["composer"],ruby:["bundle"],rust:["cargo"],elixir:["mix"],kotlin:["gradle"],deno:["deno"],bun:["bun"]},de={python:["pyproject.toml","requirements.txt","requirements.in"],node:["package.json"],go:["go.mod"],java:["pom.xml","build.gradle","build.gradle.kts"],dotnet:["*.csproj","*.sln"],php:["composer.json"],ruby:["Gemfile"],rust:["Cargo.toml"],elixir:["mix.exs"],kotlin:["settings.gradle.kts"],deno:["deno.json","deno.jsonc"],bun:["package.json","bunfig.toml"]};function x(e,t){let n=g$1({runtime:typeof e?.runtime=="string"?e.runtime:void 0,framework:typeof e?.framework=="string"?e.framework:void 0,kitName:typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:void 0});return n.runtime!=="unknown"?n.runtime:i(t,e).runtime}function X(e){let t=e;for(;;){for(let r of p(t,"project.json"))if(_.existsSync(r))try{return JSON.parse(_.readFileSync(r,"utf8"))}catch{return null}let n=a.dirname(t);if(n===t)break;t=n;}return null}function Ve(e,t){return x(e,t)==="go"}function Xe(e,t){return x(e,t)==="node"}function ze(e,t){return x(e,t)==="java"}function Qe(e,t){return x(e,t)==="dotnet"}function Ze(e,t){return x(e,t)==="python"}function ye(e){for(let t of p(e,"context.json"))if(_.existsSync(t))try{return JSON.parse(_.readFileSync(t,"utf8"))}catch{return null}return null}function Ce(e){let t=e?.engine;return t==="npm"||t==="pip"||t==="python"?t:"unknown"}function ge(e,t){if(e?.module_support===false||t?.module_support===false||!e&&t)return false;let n=typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:typeof t?.kit=="string"?t.kit:void 0,r=n?a$2(n):void 0;return r?.owner==="core"&&r.moduleSupport===true}function be(e,t,n){let r=g$1({runtime:typeof t?.runtime=="string"?t.runtime:typeof n?.runtime=="string"?n.runtime:void 0,framework:typeof t?.framework=="string"?t.framework:typeof n?.framework=="string"?n.framework:void 0,kitName:typeof t?.kit_name=="string"?t.kit_name:typeof t?.kit=="string"?t.kit:typeof n?.kit=="string"?n.kit:void 0});return r.key!=="unknown"?r:i(e,t)}function z(e){let t=a.resolve(e);if(![...p(t,"project.json"),...p(t,"context.json")].some(k=>_.existsSync(k)))return null;let r=X(t),i=ye(t),m=be(t,r,i);return {projectRoot:t,projectJson:r,contextJson:i,detection:m,moduleSupport:ge(r,i),engine:Ce(i)}}var ke=["build","dev","start","test","lint","format"],A=["init","test","build","start"],ct=["lint","format","docs"];function lt(e){return !!e&&ke.includes(e)}var Se={dev:["dev","start:dev"],start:["start","start:prod","preview"],build:["build"],test:["test","test:unit","test:ci"],lint:["lint"],format:["format","prettier"]},Z={nestjs:{dev:["dev","start:dev"],start:["start","start:prod"],build:["build"],test:["test","test:e2e"],lint:["lint"],format:["format"]},express:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},fastify:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},koa:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]}};function xe(e){let t=a.join(e,"package.json");if(!_.existsSync(t))return {};try{let r=JSON.parse(_.readFileSync(t,"utf8")).scripts??{};return Object.fromEntries(Object.entries(r).filter(i=>typeof i[1]=="string"))}catch{return {}}}function je(e,t){let n=t?c$1(t):"unknown",r=n!=="unknown"?a$1(n,e):[],i=t?Z[t]?.[e]??[]:[],m=Se[e]??[],k=[...r,...i,...m];return [...new Set(k)]}function ee(e,t,n){let r=xe(e),i=new Set(Object.keys(r));if(i.has(t))return {scriptName:t,source:"package.json"};for(let m of je(t,n?.framework))if(i.has(m))return {scriptName:m,source:a$1(c$1(n?.framework??"unknown"),t).includes(m)||Z[n?.framework??""]?.[t]?.includes(m)?"framework-candidate":"generic-candidate"};return null}function F(e){return _.existsSync(a.join(e,"package.json"))}function te(e){let t=H(e);return t.runtime==="unknown"&&e!=="unknown"?null:{runtime:t.runtime,displayName:t.displayName,supportedCommands:t.lifecycleCommands,packageManagers:t.packageManagers,primaryFiles:t.primaryFiles,notes:t.notes,hasExecutor:t.hasExecutor}}function s(e){try{return _.existsSync(e)}catch{return false}}function f(e){try{return s(e)?_.readFileSync(e,"utf8"):""}catch{return ""}}function c(e,t){let n=f(a.join(e,"Makefile"));return n?new RegExp(`^${t}\\s*:`).test(n):false}function Re(e){let t=[e];for(;t.length>0;){let n=t.shift();if(!n)break;let r=[];try{r=_.readdirSync(n,{withFileTypes:true});}catch{continue}for(let i of r){if(i.name==="node_modules"||i.name===".git"||i.name==="dist")continue;let m=a.join(n,i.name);if(i.isFile()&&i.name.endsWith(".csproj"))return true;i.isDirectory()&&t.push(m);}}return false}function ne(e,t){let n=s(a.join(e,"pyproject.toml")),r=s(a.join(e,"requirements.txt"))||s(a.join(e,"requirements.in")),i=s(a.join(e,"manage.py"));switch(t){case "init":return n||r;case "dev":case "start":return n||i||r;case "test":return n||r||s(a.join(e,"tests"));case "build":return n||r;case "lint":case "format":return n||r||i||s(a.join(e,"setup.py"))||s(a.join(e,"setup.cfg"));default:return false}}function he(e,t){if(!s(a.join(e,"go.mod")))return false;switch(t){case "init":return true;case "dev":return c(e,"run")||s(a.join(e,"main.go"));case "test":return true;case "build":return true;case "start":return c(e,"run")||s(a.join(e,"main.go"))||s(a.join(e,"cmd"));case "lint":return s(a.join(e,".golangci.yml"))||s(a.join(e,".golangci.yaml"))||c(e,"lint");case "format":return c(e,"fmt")||c(e,"format");default:return false}}function Ne(e,t){let n=s(a.join(e,"pom.xml")),r=s(a.join(e,"build.gradle"))||s(a.join(e,"build.gradle.kts"));if(!n&&!r)return false;switch(t){case "init":case "test":case "build":case "dev":case "start":return true;case "lint":return c(e,"lint")||f(a.join(e,"pom.xml")).includes("checkstyle")||f(a.join(e,"build.gradle")).includes("checkstyle")||f(a.join(e,"build.gradle.kts")).includes("checkstyle");case "format":return c(e,"format")||f(a.join(e,"build.gradle")).includes("spotless")||f(a.join(e,"build.gradle.kts")).includes("spotless");default:return false}}function ve(e,t){if(!Re(e))return false;switch(t){case "init":case "dev":case "test":case "build":case "start":return true;case "lint":return c(e,"lint")||f(a.join(e,"Directory.Build.props")).includes("EnforceCodeStyleInBuild");case "format":return c(e,"format")||s(a.join(e,".editorconfig"));default:return false}}function Ee(e,t,n){return t==="init"?F(e):ee(e,t,{framework:n})!==null}function Pe(e,t,n){switch(t){case "php":return n==="init"&&s(a.join(e,"composer.json"));case "ruby":return n==="init"&&s(a.join(e,"Gemfile"));case "rust":return s(a.join(e,"Cargo.toml"))?n==="init"||n==="test"||n==="build"||n==="start":false;case "elixir":return n==="init"&&s(a.join(e,"mix.exs"));case "deno":return s(a.join(e,"deno.json"))||s(a.join(e,"deno.jsonc"))?n==="init"||n==="dev"||n==="test"||n==="start":n==="init"&&s(a.join(e,"package.json"));case "bun":return s(a.join(e,"bunfig.toml"))||s(a.join(e,"bun.lock"))?n==="init"||n==="dev"||n==="test"||n==="build"||n==="start":n==="init"&&s(a.join(e,"package.json"));default:return false}}function v(e,t,n,r){if(N(t,n))return ne(e,n);if(!b(t))return Pe(e,t,n);switch(t){case "node":return Ee(e,n,r);case "python":return ne(e,n);case "go":return he(e,n);case "java":return Ne(e,n);case "dotnet":return ve(e,n);default:return false}}function we(e,t,n){return ["init","dev","start","build","test","lint","format"].filter(i=>v(e,t,i,n))}function re(e){let t=Y({runtime:e.runtime,moduleSupport:e.moduleSupport});if(!e.projectPath)return t;let n=we(e.projectPath,e.runtime,e.framework),r=new Set(["help"]);for(let m of n)t.lifecycleCommands.includes(m)&&r.add(m);e.runtime==="node"&&F(e.projectPath)&&r.add("init");let i=[...r].sort();return {lifecycleCommands:i,moduleCommands:t.moduleCommands,unsupportedLifecycleCommands:t.lifecycleCommands.filter(m=>!i.includes(m)).sort()}}var T=["version","commands","doctor","project","help"],E=["init","dev","start","build","test","lint","format"],B=["add","modules","upgrade","diff","merge","reconcile","rollback","uninstall","checkpoint","snapshot","optimize"],I=["create","list","info","frameworks","license"];T.filter(e=>e!=="help");function _e(e){let t=a.resolve(e);for(;;){if([...p(t,"project.json"),...p(t,"context.json")].some(i=>_.existsSync(i)))return t;let r=a.dirname(t);if(r===t)break;t=r;}return null}function j(e,t){return {command:e,...t}}var Ae=new Set(["dev","lint","format"]),Le=new Set(A);function Fe(e,t){return t?Le.has(e)?{executionScope:"fleet",fleetEligible:true}:Ae.has(e)?{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}}function Oe(e,t){return N(t.runtime,e)?"core":"runtime"}function De(e,t,n,r){return !e||!r.lifecycleCommands.includes(t)?false:v(e,n.runtime,t,n.key)}function Te(e,t){let n=!!e&&(t.runtime==="python"||b(t.runtime)&&v(e,t.runtime,"build",t.key));return j("docs",{owner:t.runtime==="python"?"core":"runtime",status:n?"supported":"unsupported",reason:n?t.runtime==="python"?"Documentation generation is delegated to Python Core for this project.":"Project documentation commands are available through the npm wrapper for this runtime.":"Documentation commands require a supported Python or npm-executor project manifest."})}function Be(e){let t=a.resolve(e),n=_e(e);return n||(h(t).length>0?t:null)}function Ie(e=process.cwd()){let t=Be(e),n=t?z(t):null,r=n?.detection??i(e,n?.projectJson??null),i$1=n?.moduleSupport??false,m=n?.engine??"unknown",k=te(r.runtime),U=S(r.runtime),ie=re({runtime:r.runtime,moduleSupport:i$1,projectPath:t??void 0,framework:r.key}),p={};for(let o of T)p[o]=j(o,{owner:o==="project"?"core":"npm",status:"supported",reason:o==="project"?"Project detection is a Core contract; workspace project lifecycle remains npm-owned.":o==="help"?"Help is available for every Workspai project through the npm CLI.":"Universal command available across Workspai project types."});for(let o of E){let y=De(t,o,r,ie),G=Oe(o,r),P=Fe(o,y);p[o]=j(o,{owner:G,status:y?"supported":"unsupported",executionScope:P.executionScope,fleetEligible:P.fleetEligible,reason:y?G==="core"?`Delegated to Python Core for ${r.displayName} projects.`:P.fleetEligible?`Handled by runtime adapter and eligible for workspace fleet stages (${o}).`:o==="dev"?"Local development command only; workspace fleet excludes dev by design.":r.runtime==="node"?`Handled by npm/pnpm/yarn via the resolved ${o} script in package.json.`:`Handled by the ${k?.displayName??r.displayName} runtime adapter for local project execution.`:t?r.runtime==="node"?`No ${o} script was found in package.json for this ${r.displayName} project.`:b(r.runtime)?`The ${r.displayName} runtime is tracked, but ${o} is not available from detected project manifests.`:`${r.displayName} is tracked as an observed runtime; ${o} requires project manifests or explicit scripts.`:"No Workspai project was detected."});}p.docs=Te(t,r);for(let o of B)p[o]=j(o,{owner:i$1?"core":"none",status:i$1?"supported":"unsupported",reason:i$1?"Core module/template command supported for this project.":`Core module/template commands are not available for ${r.displayName} projects.`});for(let o of I)p[o]=j(o,{owner:o==="create"?"npm":"core",status:"global",reason:o==="create"?"Create is orchestrated by npm for multi-language workspace support.":"Engine catalog command; not specific to the selected project runtime."});let R=Object.values(p),K=R.filter(o=>E.includes(o.command)).filter(o=>o.status==="supported"),ae=A.filter(o=>K.some(y=>y.fleetEligible===true&&y.command===o)),se=K.filter(o=>o.executionScope==="local-only").map(o=>o.command).sort();return {schemaVersion:1,scope:"project",projectRoot:t,engine:m,runtime:r.runtime,framework:r.key,frameworkDisplayName:r.displayName,frameworkConfidence:r.confidence,frameworkSupportTier:q(r.key),runtimeSupportTier:U.tier,runtimeDoctorSupport:U.doctorSupport,moduleSupport:i$1,fleetStages:ae,localOnlyCommands:se,commandMap:p,supportedCommands:R.filter(o=>o.status==="supported").map(o=>o.command).sort(),unsupportedCommands:R.filter(o=>o.status==="unsupported").map(o=>o.command).sort(),globalCommands:R.filter(o=>o.status==="global").map(o=>o.command).sort()}}function Jt(e,t=process.cwd()){let n=e[0];return n?Ie(t).commandMap[n]??null:null}function qt(e){if(e[0]==="project"&&e[1]==="commands")return true;if(e[0]==="commands"&&e.includes("--scope")){let t=e.indexOf("--scope");return e[t+1]==="project"}return e.some(t=>t==="--scope=project")&&e[0]==="commands"}function Yt(e,t){return [`Workspai command not supported for this project: ${e.command}`,"",`Project: ${t.projectRoot??"not detected"}`,`Runtime: ${t.runtime}`,`Framework: ${t.frameworkDisplayName}`,`Reason: ${e.reason??"Unsupported for this project type."}`,"","Run `workspai project commands` to inspect supported commands for this project."].join(`
1
+ import {a as a$1,c as c$1,i,g as g$1,h}from'./chunk-4KUIFXHM.js';import {a as a$2}from'./chunk-P424XYHP.js';import {p}from'./chunk-5XATWNME.js';import _ from'fs';import a from'path';var g=["init","dev","start","build","test","lint","format","help"],J={python:{runtime:"python",displayName:"Python",tier:"first-class",scaffoldSupport:true,importSupport:true,lifecycleCommands:g,moduleCommands:true,doctorSupport:"full",notes:["Core-backed Python projects support RapidKit Core modules and lifecycle commands."]},node:{runtime:"node",displayName:"Node.js",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:g,moduleCommands:true,doctorSupport:"full",notes:["Node projects support npm-owned lifecycle commands; NestJS is the first-class Node framework."]},go:{runtime:"go",displayName:"Go",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:g,moduleCommands:false,doctorSupport:"readiness",notes:["Go projects support workspace governance and lifecycle commands via Go tooling."]},java:{runtime:"java",displayName:"Java / Spring Boot",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:g,moduleCommands:false,doctorSupport:"readiness",notes:["Java projects support Maven/Gradle lifecycle commands and workspace governance."]},dotnet:{runtime:"dotnet",displayName:".NET / ASP.NET Core",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:g,moduleCommands:false,doctorSupport:"readiness",notes:[".NET projects support dotnet CLI lifecycle commands and workspace governance."]},php:{runtime:"php",displayName:"PHP",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["PHP projects are importable and governed as observed projects until a kit exists."]},ruby:{runtime:"ruby",displayName:"Ruby",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Ruby projects are importable and governed as observed projects until a kit exists."]},rust:{runtime:"rust",displayName:"Rust",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Rust projects are importable and governed as observed projects until a kit exists."]},elixir:{runtime:"elixir",displayName:"Elixir",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Elixir projects are importable and governed as observed projects until a kit exists."]},clojure:{runtime:"clojure",displayName:"Clojure",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Clojure projects are importable and governed as observed projects until a kit exists."]},scala:{runtime:"scala",displayName:"Scala",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Scala projects are importable and governed as observed projects until a kit exists."]},kotlin:{runtime:"kotlin",displayName:"Kotlin",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Kotlin projects are importable and governed as observed projects until a kit exists."]},deno:{runtime:"deno",displayName:"Deno",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Deno projects are importable and governed as observed projects until a kit exists."]},bun:{runtime:"bun",displayName:"Bun",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Bun projects are importable and governed as observed projects until a kit exists."]},unknown:{runtime:"unknown",displayName:"Unknown",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Unknown projects are tracked safely but require manual command configuration."]}},me=["fastapi","nestjs"],ue=["django","flask","nextjs","remix","nuxt","react","vite","vue","sveltekit","svelte","angular","astro","solid","express","fastify","koa","echo","gofiber","gogin","springboot","dotnet","laravel","symfony","rails","sinatra","actix","axum","rocket","phoenix","clojure","scala","kotlin","deno","bun"];function S(e){return J[e||"unknown"]??J.unknown}function q(e){return me.includes(e)?"first-class":ue.includes(e)?"extended":"observed"}function Y(e){let t=S(e.runtime);return {lifecycleCommands:t.lifecycleCommands,moduleCommands:e.moduleSupport&&t.moduleCommands,unsupportedLifecycleCommands:g.filter(n=>!t.lifecycleCommands.includes(n))}}var ce=["python","node","go","java","dotnet"];function b(e){return !!e&&ce.includes(e)}function N(e,t){return t!=="lint"&&t!=="format"&&t!=="docs"?false:e==="python"}function H(e){let t=S(e),n=b(t.runtime),r=le[t.runtime]??[],i=de[t.runtime]??[];return {runtime:t.runtime,displayName:t.displayName,lifecycleCommands:t.lifecycleCommands,hasExecutor:n,packageManagers:r,primaryFiles:i,notes:t.notes}}var le={python:["poetry","pip","uv"],node:["npm","pnpm","yarn","bun"],go:["go"],java:["maven","gradle"],dotnet:["dotnet"],php:["composer"],ruby:["bundle"],rust:["cargo"],elixir:["mix"],kotlin:["gradle"],deno:["deno"],bun:["bun"]},de={python:["pyproject.toml","requirements.txt","requirements.in"],node:["package.json"],go:["go.mod"],java:["pom.xml","build.gradle","build.gradle.kts"],dotnet:["*.csproj","*.sln"],php:["composer.json"],ruby:["Gemfile"],rust:["Cargo.toml"],elixir:["mix.exs"],kotlin:["settings.gradle.kts"],deno:["deno.json","deno.jsonc"],bun:["package.json","bunfig.toml"]};function x(e,t){let n=g$1({runtime:typeof e?.runtime=="string"?e.runtime:void 0,framework:typeof e?.framework=="string"?e.framework:void 0,kitName:typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:void 0});return n.runtime!=="unknown"?n.runtime:i(t,e).runtime}function X(e){let t=e;for(;;){for(let r of p(t,"project.json"))if(_.existsSync(r))try{return JSON.parse(_.readFileSync(r,"utf8"))}catch{return null}let n=a.dirname(t);if(n===t)break;t=n;}return null}function Ve(e,t){return x(e,t)==="go"}function Xe(e,t){return x(e,t)==="node"}function ze(e,t){return x(e,t)==="java"}function Qe(e,t){return x(e,t)==="dotnet"}function Ze(e,t){return x(e,t)==="python"}function ye(e){for(let t of p(e,"context.json"))if(_.existsSync(t))try{return JSON.parse(_.readFileSync(t,"utf8"))}catch{return null}return null}function Ce(e){let t=e?.engine;return t==="npm"||t==="pip"||t==="python"?t:"unknown"}function ge(e,t){if(e?.module_support===false||t?.module_support===false||!e&&t)return false;let n=typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:typeof t?.kit=="string"?t.kit:void 0,r=n?a$2(n):void 0;return r?.owner==="core"&&r.moduleSupport===true}function be(e,t,n){let r=g$1({runtime:typeof t?.runtime=="string"?t.runtime:typeof n?.runtime=="string"?n.runtime:void 0,framework:typeof t?.framework=="string"?t.framework:typeof n?.framework=="string"?n.framework:void 0,kitName:typeof t?.kit_name=="string"?t.kit_name:typeof t?.kit=="string"?t.kit:typeof n?.kit=="string"?n.kit:void 0});return r.key!=="unknown"?r:i(e,t)}function z(e){let t=a.resolve(e);if(![...p(t,"project.json"),...p(t,"context.json")].some(k=>_.existsSync(k)))return null;let r=X(t),i=ye(t),m=be(t,r,i);return {projectRoot:t,projectJson:r,contextJson:i,detection:m,moduleSupport:ge(r,i),engine:Ce(i)}}var ke=["build","dev","start","test","lint","format"],A=["init","test","build","start"],ct=["lint","format","docs"];function lt(e){return !!e&&ke.includes(e)}var Se={dev:["dev","start:dev"],start:["start","start:prod","preview"],build:["build"],test:["test","test:unit","test:ci"],lint:["lint"],format:["format","prettier"]},Z={nestjs:{dev:["dev","start:dev"],start:["start","start:prod"],build:["build"],test:["test","test:e2e"],lint:["lint"],format:["format"]},express:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},fastify:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},koa:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]}};function xe(e){let t=a.join(e,"package.json");if(!_.existsSync(t))return {};try{let r=JSON.parse(_.readFileSync(t,"utf8")).scripts??{};return Object.fromEntries(Object.entries(r).filter(i=>typeof i[1]=="string"))}catch{return {}}}function je(e,t){let n=t?c$1(t):"unknown",r=n!=="unknown"?a$1(n,e):[],i=t?Z[t]?.[e]??[]:[],m=Se[e]??[],k=[...r,...i,...m];return [...new Set(k)]}function ee(e,t,n){let r=xe(e),i=new Set(Object.keys(r));if(i.has(t))return {scriptName:t,source:"package.json"};for(let m of je(t,n?.framework))if(i.has(m))return {scriptName:m,source:a$1(c$1(n?.framework??"unknown"),t).includes(m)||Z[n?.framework??""]?.[t]?.includes(m)?"framework-candidate":"generic-candidate"};return null}function F(e){return _.existsSync(a.join(e,"package.json"))}function te(e){let t=H(e);return t.runtime==="unknown"&&e!=="unknown"?null:{runtime:t.runtime,displayName:t.displayName,supportedCommands:t.lifecycleCommands,packageManagers:t.packageManagers,primaryFiles:t.primaryFiles,notes:t.notes,hasExecutor:t.hasExecutor}}function s(e){try{return _.existsSync(e)}catch{return false}}function f(e){try{return s(e)?_.readFileSync(e,"utf8"):""}catch{return ""}}function c(e,t){let n=f(a.join(e,"Makefile"));return n?new RegExp(`^${t}\\s*:`).test(n):false}function Re(e){let t=[e];for(;t.length>0;){let n=t.shift();if(!n)break;let r=[];try{r=_.readdirSync(n,{withFileTypes:true});}catch{continue}for(let i of r){if(i.name==="node_modules"||i.name===".git"||i.name==="dist")continue;let m=a.join(n,i.name);if(i.isFile()&&i.name.endsWith(".csproj"))return true;i.isDirectory()&&t.push(m);}}return false}function ne(e,t){let n=s(a.join(e,"pyproject.toml")),r=s(a.join(e,"requirements.txt"))||s(a.join(e,"requirements.in")),i=s(a.join(e,"manage.py"));switch(t){case "init":return n||r;case "dev":case "start":return n||i||r;case "test":return n||r||s(a.join(e,"tests"));case "build":return n||r;case "lint":case "format":return n||r||i||s(a.join(e,"setup.py"))||s(a.join(e,"setup.cfg"));default:return false}}function he(e,t){if(!s(a.join(e,"go.mod")))return false;switch(t){case "init":return true;case "dev":return c(e,"run")||s(a.join(e,"main.go"));case "test":return true;case "build":return true;case "start":return c(e,"run")||s(a.join(e,"main.go"))||s(a.join(e,"cmd"));case "lint":return s(a.join(e,".golangci.yml"))||s(a.join(e,".golangci.yaml"))||c(e,"lint");case "format":return c(e,"fmt")||c(e,"format");default:return false}}function Ne(e,t){let n=s(a.join(e,"pom.xml")),r=s(a.join(e,"build.gradle"))||s(a.join(e,"build.gradle.kts"));if(!n&&!r)return false;switch(t){case "init":case "test":case "build":case "dev":case "start":return true;case "lint":return c(e,"lint")||f(a.join(e,"pom.xml")).includes("checkstyle")||f(a.join(e,"build.gradle")).includes("checkstyle")||f(a.join(e,"build.gradle.kts")).includes("checkstyle");case "format":return c(e,"format")||f(a.join(e,"build.gradle")).includes("spotless")||f(a.join(e,"build.gradle.kts")).includes("spotless");default:return false}}function ve(e,t){if(!Re(e))return false;switch(t){case "init":case "dev":case "test":case "build":case "start":return true;case "lint":return c(e,"lint")||f(a.join(e,"Directory.Build.props")).includes("EnforceCodeStyleInBuild");case "format":return c(e,"format")||s(a.join(e,".editorconfig"));default:return false}}function Ee(e,t,n){return t==="init"?F(e):ee(e,t,{framework:n})!==null}function Pe(e,t,n){switch(t){case "php":return n==="init"&&s(a.join(e,"composer.json"));case "ruby":return n==="init"&&s(a.join(e,"Gemfile"));case "rust":return s(a.join(e,"Cargo.toml"))?n==="init"||n==="test"||n==="build"||n==="start":false;case "elixir":return n==="init"&&s(a.join(e,"mix.exs"));case "deno":return s(a.join(e,"deno.json"))||s(a.join(e,"deno.jsonc"))?n==="init"||n==="dev"||n==="test"||n==="start":n==="init"&&s(a.join(e,"package.json"));case "bun":return s(a.join(e,"bunfig.toml"))||s(a.join(e,"bun.lock"))?n==="init"||n==="dev"||n==="test"||n==="build"||n==="start":n==="init"&&s(a.join(e,"package.json"));default:return false}}function v(e,t,n,r){if(N(t,n))return ne(e,n);if(!b(t))return Pe(e,t,n);switch(t){case "node":return Ee(e,n,r);case "python":return ne(e,n);case "go":return he(e,n);case "java":return Ne(e,n);case "dotnet":return ve(e,n);default:return false}}function we(e,t,n){return ["init","dev","start","build","test","lint","format"].filter(i=>v(e,t,i,n))}function re(e){let t=Y({runtime:e.runtime,moduleSupport:e.moduleSupport});if(!e.projectPath)return t;let n=we(e.projectPath,e.runtime,e.framework),r=new Set(["help"]);for(let m of n)t.lifecycleCommands.includes(m)&&r.add(m);e.runtime==="node"&&F(e.projectPath)&&r.add("init");let i=[...r].sort();return {lifecycleCommands:i,moduleCommands:t.moduleCommands,unsupportedLifecycleCommands:t.lifecycleCommands.filter(m=>!i.includes(m)).sort()}}var T=["version","commands","doctor","project","help"],E=["init","dev","start","build","test","lint","format"],B=["add","modules","upgrade","diff","merge","reconcile","rollback","uninstall","checkpoint","snapshot","optimize"],I=["create","list","info","frameworks","license"];T.filter(e=>e!=="help");function _e(e){let t=a.resolve(e);for(;;){if([...p(t,"project.json"),...p(t,"context.json")].some(i=>_.existsSync(i)))return t;let r=a.dirname(t);if(r===t)break;t=r;}return null}function j(e,t){return {command:e,...t}}var Ae=new Set(["dev","lint","format"]),Le=new Set(A);function Fe(e,t){return t?Le.has(e)?{executionScope:"fleet",fleetEligible:true}:Ae.has(e)?{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}}function Oe(e,t){return N(t.runtime,e)?"core":"runtime"}function De(e,t,n,r){return !e||!r.lifecycleCommands.includes(t)?false:v(e,n.runtime,t,n.key)}function Te(e,t){let n=!!e&&(t.runtime==="python"||b(t.runtime)&&v(e,t.runtime,"build",t.key));return j("docs",{owner:t.runtime==="python"?"core":"runtime",status:n?"supported":"unsupported",reason:n?t.runtime==="python"?"Documentation generation is delegated to Python Core for this project.":"Project documentation commands are available through the npm wrapper for this runtime.":"Documentation commands require a supported Python or npm-executor project manifest."})}function Be(e){let t=a.resolve(e),n=_e(e);return n||(h(t).length>0?t:null)}function Ie(e=process.cwd()){let t=Be(e),n=t?z(t):null,r=n?.detection??i(e,n?.projectJson??null),i$1=n?.moduleSupport??false,m=n?.engine??"unknown",k=te(r.runtime),U=S(r.runtime),ie=re({runtime:r.runtime,moduleSupport:i$1,projectPath:t??void 0,framework:r.key}),p={};for(let o of T)p[o]=j(o,{owner:o==="project"?"core":"npm",status:"supported",reason:o==="project"?"Project detection is a Core contract; workspace project lifecycle remains npm-owned.":o==="help"?"Help is available for every Workspai project through the npm CLI.":"Universal command available across Workspai project types."});for(let o of E){let y=De(t,o,r,ie),G=Oe(o,r),P=Fe(o,y);p[o]=j(o,{owner:G,status:y?"supported":"unsupported",executionScope:P.executionScope,fleetEligible:P.fleetEligible,reason:y?G==="core"?`Delegated to Python Core for ${r.displayName} projects.`:P.fleetEligible?`Handled by runtime adapter and eligible for workspace fleet stages (${o}).`:o==="dev"?"Local development command only; workspace fleet excludes dev by design.":r.runtime==="node"?`Handled by npm/pnpm/yarn via the resolved ${o} script in package.json.`:`Handled by the ${k?.displayName??r.displayName} runtime adapter for local project execution.`:t?r.runtime==="node"?`No ${o} script was found in package.json for this ${r.displayName} project.`:b(r.runtime)?`The ${r.displayName} runtime is tracked, but ${o} is not available from detected project manifests.`:`${r.displayName} is tracked as an observed runtime; ${o} requires project manifests or explicit scripts.`:"No Workspai project was detected."});}p.docs=Te(t,r);for(let o of B)p[o]=j(o,{owner:i$1?"core":"none",status:i$1?"supported":"unsupported",reason:i$1?"Core module/template command supported for this project.":`Core module/template commands are not available for ${r.displayName} projects.`});for(let o of I)p[o]=j(o,{owner:o==="create"?"npm":"core",status:"global",reason:o==="create"?"Create is orchestrated by npm for multi-language workspace support.":"Engine catalog command; not specific to the selected project runtime."});let R=Object.values(p),K=R.filter(o=>E.includes(o.command)).filter(o=>o.status==="supported"),ae=A.filter(o=>K.some(y=>y.fleetEligible===true&&y.command===o)),se=K.filter(o=>o.executionScope==="local-only").map(o=>o.command).sort();return {schemaVersion:1,scope:"project",projectRoot:t,engine:m,runtime:r.runtime,framework:r.key,frameworkDisplayName:r.displayName,frameworkConfidence:r.confidence,frameworkSupportTier:q(r.key),runtimeSupportTier:U.tier,runtimeDoctorSupport:U.doctorSupport,moduleSupport:i$1,fleetStages:ae,localOnlyCommands:se,commandMap:p,supportedCommands:R.filter(o=>o.status==="supported").map(o=>o.command).sort(),unsupportedCommands:R.filter(o=>o.status==="unsupported").map(o=>o.command).sort(),globalCommands:R.filter(o=>o.status==="global").map(o=>o.command).sort()}}function Jt(e,t=process.cwd()){let n=e[0];return n?Ie(t).commandMap[n]??null:null}function qt(e){if(e[0]==="project"&&e[1]==="commands")return true;if(e[0]==="commands"&&e.includes("--scope")){let t=e.indexOf("--scope");return e[t+1]==="project"}return e.some(t=>t==="--scope=project")&&e[0]==="commands"}function Yt(e,t){return [`Workspai command not supported for this project: ${e.command}`,"",`Project: ${t.projectRoot??"not detected"}`,`Runtime: ${t.runtime}`,`Framework: ${t.frameworkDisplayName}`,`Reason: ${e.reason??"Unsupported for this project type."}`,"","Run `workspai project commands` to inspect supported commands for this project."].join(`
2
2
  `)}export{S as a,q as b,b as c,X as d,Ve as e,Xe as f,ze as g,Qe as h,Ze as i,z as j,ke as k,ct as l,lt as m,ee as n,re as o,_e as p,Ie as q,Jt as r,qt as s,Yt as t};
@@ -1 +1 @@
1
- import {c as c$3}from'./chunk-753LOKFZ.js';import {a,b as b$2}from'./chunk-PYCJWW4B.js';import {b as b$1,c,d}from'./chunk-3KXW53QI.js';import {m,f as f$1,c as c$2,n,e}from'./chunk-LYC6AIF2.js';import {n as n$1,b as b$3}from'./chunk-5SWNSJGW.js';import {a as a$1}from'./chunk-VZKSNUEE.js';import {c as c$1}from'./chunk-NAAQMSO3.js';import f from'path';import y from'fs-extra';var J="rapidkit-blocker-resolution-v1";function U(e){let t=e.blockers.map(r=>r.trim()).filter(Boolean).slice(0,12),s=e.stderrTail?.trim().slice(-400)??"";return b$3({blockers:t,exitCode:e.exitCode??null,stderrTail:s})}function se(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 re(e){let t=se(e.reason),s=U({blockers:[e.reason]}),r=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:J,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:s,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:r,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}}function G(e){return Array.from(new Set(e.blockingReasons.map(s=>s.trim()).filter(Boolean))).slice(0,12).map((s,r)=>re({reason:s,blockerId:`blocker-${r+1}`,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}))}function ne(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 ie(e){return e.length===0||e.every(t=>ne(t))}function Y(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&ie(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function Fe(e,t){let s=t&&t!=="ready"?` (${t.replace(/-/g," ")})`:"";return e===0?`Workspace scaffold ready${s} \u2014 add your first project to continue.`:`Workspace scaffold${s}: ${e} pre-project signal(s) \u2014 add your first project to continue.`}var Q="workspace-verify.v1",$=".workspai/reports/workspace-verify-last-run.json";function oe(e,t){return f.isAbsolute(t)?t:f.join(e,t)}async function X(e$1){let t=await y.readJson(e$1);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e$1}`);let s=t;if(s.schemaVersion!==e)throw new Error(`Unsupported workspace impact schema: ${String(s.schemaVersion)}`);return s}function ae(e){let t=new Set,s=[];for(let r of e){let n=`${r.scope}:${r.project??""}:${r.display}`;t.has(n)||(t.add(n),s.push(r));}return s}function ce(e,t){if(!e||e==="workspace")return true;let s=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===s}function le(e,t){if(e.id==="workspace.doctor")return f.join(t,".workspai","reports","doctor-last-run.json");if(e.id==="workspace.contract.verify")return f.join(t,".workspai","reports","workspace-contract-verify-last-run.json");if(e.id==="workspace.readiness")return f.join(t,".workspai","reports","release-readiness-last-run.json");if(e.id==="workspace.analyze")return f.join(t,".workspai","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return f.join(t,".workspai","reports","pipeline-last-run.json");if(e.id==="workspace.doctor-fix")return f.join(t,".workspai","reports","doctor-fix-result-last-run.json");if(e.id.startsWith("project.")&&e.id.includes("."))return f.join(t,".workspai","reports","workspace-run-last.json")}function b(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function ue(e){let t=b(e.healthScore),s=typeof t?.errors=="number"?t.errors:0,r=typeof t?.percent=="number"?t.percent:void 0;return s>0?{status:"fail",message:`Doctor evidence reports ${s} error(s).`}:typeof r=="number"&&r<70?{status:"warn",message:`Doctor health score is ${r}%.`}:{status:"pass",message:"Doctor evidence is present and healthy."}}function de(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 pe(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 fe(e){let t=b(e.summary);if(t?.blocking===true||e.blocking===true)return {status:"fail",message:"Analyze evidence reports blocking findings."};let r=typeof t?.status=="string"?t.status:void 0;return r==="warn"||r==="warning"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is present."}}function ge(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 s=t,r=Array.isArray(s.remainingBlockers)?s.remainingBlockers:[];if(r.length>0)return {status:"fail",message:`Doctor fix result reports ${r.length} remaining blocker(s).`};let n=Array.isArray(s.appliedFixes)?s.appliedFixes:[];return n.length===0?{status:"pass",message:"Doctor fix result recorded with no remaining blockers."}:{status:"pass",message:`Doctor fix result recorded ${n.length} applied fix(es) with no remaining blockers.`}}async function me(e,t){let s=await c$1(e,".workspai/reports/doctor-remediation-plan-last-run.json");if(!s)return false;try{let r=b(await y.readJson(s));if(!r||(Array.isArray(r.steps)?r.steps:[]).length>0)return false;let i=typeof r.generatedAt=="string"?r.generatedAt:void 0;if(!i||!t)return true;let k=Date.parse(i),c=Date.parse(t);return !Number.isFinite(k)||!Number.isFinite(c)?true:k>=c}catch{return false}}function ke(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function ye(e){let t=b(e.summary),s=typeof t?.verdict=="string"?t.verdict:void 0;return s==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:s==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:s==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function he(e,t,s){let r=ke(t),n=c$3(e,r??void 0);if(!n)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let i=n.stage;if(r&&i!==r)return {status:"missing",message:`Workspace run evidence is for stage "${i}", expected "${r}".`};let k=Array.isArray(n.projects)?n.projects:[],c=t.project?.toLowerCase();if(!c)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let u=k.find(o=>{let p=b(o);if(!p)return false;let l=typeof p.projectName=="string"?p.projectName.toLowerCase():"",a=["projectPath","relativePath","path"].map(d=>p[d]).filter(d=>typeof d=="string"&&d.trim().length>0).map(d=>d.replace(/\\/g,"/").toLowerCase());return l===c||a.some(d=>d.endsWith(`/${c}`)||d===c)});if(u){let o=v(n.generatedAt,s,`Workspace run evidence for ${t.project??t.id}`);if(o)return {status:"fail",message:o};let p=b(u),l=typeof p?.status=="string"?p.status:"unknown";return l==="failed"?{status:"fail",message:`Workspace run evidence failed for ${t.project}.`}:l==="passed"?{status:"pass",message:`Workspace run evidence passed for ${t.project}.`}:l==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}:{status:"warn",message:`Workspace run evidence status is ${l} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function v(e,t,s){if(!t)return null;if(typeof e!="string"||e.trim().length===0)return `${s} is stale: missing generatedAt timestamp (required after impact ${t}).`;let r=Date.parse(e),n=Date.parse(t);return Number.isFinite(r)?Number.isFinite(n)&&r<n?`${s} is stale: generated at ${e}, before impact ${t}.`:null:`${s} is stale: invalid generatedAt timestamp (required after impact ${t}).`}async function ve(e,t,s,r){let n=le(e,t),i=n?f.relative(t,n).split(f.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!s)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 k=n?await c$1(t,i??""):null;if(!n||!k)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:i,message:i?`Missing evidence report: ${i}`:"No evidence mapping exists for this command."};let c=b(await y.readJson(k));if(!c)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:i,message:"Evidence report is not a JSON object."};let u;if(e.id==="workspace.doctor"){let o=v(c.generatedAt,r,"Doctor evidence");o?u={status:"fail",message:o}:u=ue(c);}else if(e.id==="workspace.readiness"){let o=v(c.generatedAt,r,"Release readiness evidence");o?u={status:"fail",message:o}:u=de(c);}else if(e.id==="workspace.contract.verify"){let o=v(c.generatedAt,r,"Workspace contract verify evidence");o?u={status:"fail",message:o}:u=pe(c);}else if(e.id==="workspace.analyze"){let o=v(c.generatedAt,r,"Analyze evidence");o?u={status:"fail",message:o}:u=fe(c);}else if(e.id==="workspace.pipeline"){let o=v(c.generatedAt,r,"Pipeline evidence");o?u={status:"fail",message:o}:u=ye(c);}else if(e.id==="workspace.doctor-fix"){let o=c.schemaVersion==="rapidkit-doctor-fix-result-v1"?c:c.fixResult,p=b(o),l=typeof p?.generatedAt=="string"?p.generatedAt:void 0,a=v(l,r,"Doctor fix result");a?u={status:"fail",message:a}:await me(t,l)?u={status:"skipped",message:"No current doctor remediation steps are pending."}:u=ge(c);}else if(e.id.startsWith("project."))u=he(c,e,r);else {let o=v(c.generatedAt,r,"Evidence report");o?u={status:"fail",message:o}:u={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:u.status,required:e.required,evidencePath:i,message:u.message}}function be(e,t={blockingReasons:[],needsAttention:false}){let s=e.filter(l=>l.status==="pass").length,r=e.filter(l=>l.status==="warn").length,n=e.filter(l=>l.status==="fail").length,i=e.filter(l=>l.status==="missing").length,k=e.filter(l=>l.status==="skipped").length,c=e.filter(l=>l.required&&(l.status==="fail"||l.status==="missing")).map(l=>`${l.id}: ${l.message}`),u=e.filter(l=>l.required&&l.status==="missing").length,o="ready",p=0;return c.length>0||t.blockingReasons.length>0?(o="blocked",p=2):(r>0||u>0||t.needsAttention)&&(o="needs-attention",p=1),{verdict:o,exitCode:p,stepsPassed:s,stepsWarn:r,stepsFailed:n,stepsMissing:i,stepsSkipped:k}}function we(e,t){let s=W(e.affectedProjects.map(a=>a.project?.name).filter(a=>typeof a=="string")),r=new Set(s.map(a=>a.toLowerCase())),n=W(e.transitiveImpact.map(a=>a.project?.name).filter(a=>typeof a=="string").filter(a=>!r.has(a.toLowerCase()))),i=new Map;for(let a of t){if(a.scope!=="project"||!a.project)continue;let d=a.project.toLowerCase(),h=i.get(d)??[];h.push(a),i.set(d,h);}let k=[],c=[],u=[],o=[],p=false,l=(a,d)=>{let h=i.get(a.toLowerCase())??[];if(h.length===0){u.push(a);return}let R=h.filter(g=>g.status==="fail"),C=h.filter(g=>g.status==="missing"),w=C.filter(g=>g.required),j=h.some(g=>g.status==="pass"||g.status==="warn");if(R.length>0){c.push(a),o.push(`graph.subgraph.${a}: ${d} has failed verification evidence (${R.map(g=>g.id).join(", ")}).`);return}if(w.length>0){c.push(a),o.push(`graph.subgraph.${a}: ${d} has missing required verification evidence (${w.map(g=>g.id).join(", ")}).`);return}if(C.length>0){c.push(a),p=true;return}if(j){k.push(a);return}u.push(a);};for(let a of s)l(a,"directly-changed");for(let a of n)l(a,"transitive dependent");return {subgraph:{totalProjects:s.length+n.length,directlyChanged:s,transitiveDependents:n,covered:W(k),uncovered:W(c),unverifiable:W(u)},blockingReasons:o,needsAttention:p}}function W(e){return [...new Set(e)].sort((t,s)=>t.localeCompare(s))}async function Re(e$1){let t=f.resolve(e$1.workspacePath);if(e$1.fromImpactPath){let i=oe(t,e$1.fromImpactPath);return {impact:await X(i),fromImpactRef:f.relative(t,i).split(f.sep).join("/"),impactFromDisk:true}}let s=f.join(t,f$1);if(await y.pathExists(s))return {impact:await X(s),fromImpactRef:f$1,impactFromDisk:true};let r=f.join(t,c$2);if(await y.pathExists(r))return {impact:await n({workspacePath:t,fromPath:c$2,scope:e$1.scope,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),fromImpactRef:c$2,impactFromDisk:false};let n$2=await n$1({workspacePath:t,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now});return {impact:{schemaVersion:e,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",diffRef:".workspai/reports/workspace-model-diff-last-run.json",workspace:{name:n$2.workspace.name,profile:n$2.workspace.profile,type:n$2.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0,blastRadius:{directlyAffected:0,transitivelyAffected:0,maxDistance:0,graphEdges:n$2.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:"workspace-model-diff.v1",generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",toRef:".workspai/reports/workspace-model.json",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:n$2}},impactFromDisk:false}}function Ce(e,t){if(t)return e.generatedAt}async function Ge(e){let t=f.resolve(e.workspacePath),{impact:s,fromImpactRef:r,impactFromDisk:n}=await Re(e),i=s.diff.currentModel,k=Ce(s,n),c$1=ae([...m(),...s.verificationPlan]).filter(m=>ce(e.scope,m)),u=[];for(let m of c$1)u.push(await ve(m,t,i.contracts.exists===true,k));let o=we(s,u),p=a(i.graph??{nodes:[],edges:[]}),l=b$1(i),a$1=await xe(t),d$1=c(l,a$1?.freshness?.projectHashes),h={verdict:d$1.verdict,baseline:d$1.baseline,changed:d$1.changed,added:d$1.added,removed:d$1.removed,projectHashes:d(l)},R=b$2(p),C=i.policies?.mode??"warn",w=await je(i,t),j=We(C,w),g=be(u,{blockingReasons:[...o.blockingReasons,...R,...j.blockingReasons],needsAttention:o.needsAttention||j.needsAttention}),Z=u.filter(m=>m.status==="missing"&&m.evidencePath).map(m=>m.evidencePath),x=[...u.filter(m=>m.required&&(m.status==="fail"||m.status==="missing")).map(m=>`${m.id}: ${m.message}`),...o.blockingReasons,...R,...j.blockingReasons],ee=w.filter(m=>m.severity==="error").length,te=i.summary?.projectCount??i.projects.length,B=Y({projectCount:te,verdict:g.verdict,exitCode:g.exitCode,blockingReasons:x,policyErrorCount:ee});g.verdict=B.verdict,g.exitCode=B.exitCode;let F=x.length>0?G({blockingReasons:x,verifyCommand:"npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json",verifyArtifact:$}):[];return {schemaVersion:Q,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:r,scope:e.scope,impact:{changed:s.summary.changed,risk:s.summary.risk,affectedProjects:s.summary.affectedProjects,recommendedCommands:s.summary.recommendedCommands},summary:g,steps:u,missingEvidence:Z,blockingReasons:x,...F.length>0?{resolutionHints:F}:{},verificationPlan:c$1,affectedSubgraph:o.subgraph,graphIntegrity:p,freshness:h,policyMode:C,policyViolations:w}}async function je(e,t){let s=[];for(let n of e.validation?.issues??[])s.push({source:"model",severity:n.severity,code:n.code,message:n.message,target:n.target});let r=await c$1(t,".workspai/reports/workspace-contract-verify-last-run.json");try{if(r&&await y.pathExists(r)){let n=await y.readJson(r);if(Array.isArray(n.violations))for(let i of n.violations)typeof i=="string"&&i.trim().length>0&&s.push({source:"contract",severity:"error",code:"contract.violation",message:i});}}catch{}return s.sort((n,i)=>n.source!==i.source?n.source.localeCompare(i.source):n.code!==i.code?n.code.localeCompare(i.code):n.message.localeCompare(i.message))}function We(e,t){let s=t.filter(r=>r.severity==="error");return e==="enforce"&&s.length>0?{blockingReasons:s.map(r=>`policy.${r.code}: ${r.message}`),needsAttention:false}:{blockingReasons:[],needsAttention:s.length>0}}async function xe(e){let t=f.join(e,$);try{if(!await y.pathExists(t))return null;let s=await y.readJson(t);return s&&s.schemaVersion===Q?s:null}catch{return null}}async function Ye(e,t){let s=f.join(t,$);return await y.ensureDir(f.dirname(s)),await y.writeJson(s,a$1(e),{spaces:2}),s}function Se(e,t){let s=t?.strict?"strict":"default",r=[];if(e.summary.verdict==="blocked")return r.push(...e.blockingReasons),r.length===0&&r.push("verify verdict is blocked."),{passed:false,mode:s,exitCode:2,reasons:r};if(s==="strict"){if(e.summary.verdict!=="ready"&&r.push(`verify verdict is ${e.summary.verdict} (strict requires ready).`),e.freshness.verdict==="stale"){let n=[...e.freshness.changed,...e.freshness.added].slice(0,5);r.push(`freshness is stale${n.length>0?`: ${n.join(", ")}`:""} (strict requires fresh).`);}if(r.length>0)return {passed:false,mode:s,exitCode:1,reasons:r}}return {passed:true,mode:s,exitCode:0,reasons:r}}function Xe(e,t){return Se(e,t).exitCode}export{J as a,Fe as b,Q as c,$ as d,we as e,Ge as f,Ye as g,Se as h,Xe as i};
1
+ import {c as c$3}from'./chunk-753LOKFZ.js';import {a,b as b$2}from'./chunk-PYCJWW4B.js';import {b as b$1,c,d}from'./chunk-U6AXYUQY.js';import {m,f as f$1,c as c$2,n,e}from'./chunk-FM7GMFZA.js';import {n as n$1,b as b$3}from'./chunk-FHSMY75W.js';import {a as a$1}from'./chunk-XNGANEXM.js';import {c as c$1}from'./chunk-NAAQMSO3.js';import f from'path';import y from'fs-extra';var J="rapidkit-blocker-resolution-v1";function U(e){let t=e.blockers.map(r=>r.trim()).filter(Boolean).slice(0,12),s=e.stderrTail?.trim().slice(-400)??"";return b$3({blockers:t,exitCode:e.exitCode??null,stderrTail:s})}function se(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 re(e){let t=se(e.reason),s=U({blockers:[e.reason]}),r=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:J,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:s,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:r,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}}function G(e){return Array.from(new Set(e.blockingReasons.map(s=>s.trim()).filter(Boolean))).slice(0,12).map((s,r)=>re({reason:s,blockerId:`blocker-${r+1}`,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}))}function ne(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 ie(e){return e.length===0||e.every(t=>ne(t))}function Y(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&ie(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function Fe(e,t){let s=t&&t!=="ready"?` (${t.replace(/-/g," ")})`:"";return e===0?`Workspace scaffold ready${s} \u2014 add your first project to continue.`:`Workspace scaffold${s}: ${e} pre-project signal(s) \u2014 add your first project to continue.`}var Q="workspace-verify.v1",$=".workspai/reports/workspace-verify-last-run.json";function oe(e,t){return f.isAbsolute(t)?t:f.join(e,t)}async function X(e$1){let t=await y.readJson(e$1);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e$1}`);let s=t;if(s.schemaVersion!==e)throw new Error(`Unsupported workspace impact schema: ${String(s.schemaVersion)}`);return s}function ae(e){let t=new Set,s=[];for(let r of e){let n=`${r.scope}:${r.project??""}:${r.display}`;t.has(n)||(t.add(n),s.push(r));}return s}function ce(e,t){if(!e||e==="workspace")return true;let s=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===s}function le(e,t){if(e.id==="workspace.doctor")return f.join(t,".workspai","reports","doctor-last-run.json");if(e.id==="workspace.contract.verify")return f.join(t,".workspai","reports","workspace-contract-verify-last-run.json");if(e.id==="workspace.readiness")return f.join(t,".workspai","reports","release-readiness-last-run.json");if(e.id==="workspace.analyze")return f.join(t,".workspai","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return f.join(t,".workspai","reports","pipeline-last-run.json");if(e.id==="workspace.doctor-fix")return f.join(t,".workspai","reports","doctor-fix-result-last-run.json");if(e.id.startsWith("project.")&&e.id.includes("."))return f.join(t,".workspai","reports","workspace-run-last.json")}function b(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function ue(e){let t=b(e.healthScore),s=typeof t?.errors=="number"?t.errors:0,r=typeof t?.percent=="number"?t.percent:void 0;return s>0?{status:"fail",message:`Doctor evidence reports ${s} error(s).`}:typeof r=="number"&&r<70?{status:"warn",message:`Doctor health score is ${r}%.`}:{status:"pass",message:"Doctor evidence is present and healthy."}}function de(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 pe(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 fe(e){let t=b(e.summary);if(t?.blocking===true||e.blocking===true)return {status:"fail",message:"Analyze evidence reports blocking findings."};let r=typeof t?.status=="string"?t.status:void 0;return r==="warn"||r==="warning"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is present."}}function ge(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 s=t,r=Array.isArray(s.remainingBlockers)?s.remainingBlockers:[];if(r.length>0)return {status:"fail",message:`Doctor fix result reports ${r.length} remaining blocker(s).`};let n=Array.isArray(s.appliedFixes)?s.appliedFixes:[];return n.length===0?{status:"pass",message:"Doctor fix result recorded with no remaining blockers."}:{status:"pass",message:`Doctor fix result recorded ${n.length} applied fix(es) with no remaining blockers.`}}async function me(e,t){let s=await c$1(e,".workspai/reports/doctor-remediation-plan-last-run.json");if(!s)return false;try{let r=b(await y.readJson(s));if(!r||(Array.isArray(r.steps)?r.steps:[]).length>0)return false;let i=typeof r.generatedAt=="string"?r.generatedAt:void 0;if(!i||!t)return true;let k=Date.parse(i),c=Date.parse(t);return !Number.isFinite(k)||!Number.isFinite(c)?true:k>=c}catch{return false}}function ke(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function ye(e){let t=b(e.summary),s=typeof t?.verdict=="string"?t.verdict:void 0;return s==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:s==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:s==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function he(e,t,s){let r=ke(t),n=c$3(e,r??void 0);if(!n)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let i=n.stage;if(r&&i!==r)return {status:"missing",message:`Workspace run evidence is for stage "${i}", expected "${r}".`};let k=Array.isArray(n.projects)?n.projects:[],c=t.project?.toLowerCase();if(!c)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let u=k.find(o=>{let p=b(o);if(!p)return false;let l=typeof p.projectName=="string"?p.projectName.toLowerCase():"",a=["projectPath","relativePath","path"].map(d=>p[d]).filter(d=>typeof d=="string"&&d.trim().length>0).map(d=>d.replace(/\\/g,"/").toLowerCase());return l===c||a.some(d=>d.endsWith(`/${c}`)||d===c)});if(u){let o=v(n.generatedAt,s,`Workspace run evidence for ${t.project??t.id}`);if(o)return {status:"fail",message:o};let p=b(u),l=typeof p?.status=="string"?p.status:"unknown";return l==="failed"?{status:"fail",message:`Workspace run evidence failed for ${t.project}.`}:l==="passed"?{status:"pass",message:`Workspace run evidence passed for ${t.project}.`}:l==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}:{status:"warn",message:`Workspace run evidence status is ${l} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function v(e,t,s){if(!t)return null;if(typeof e!="string"||e.trim().length===0)return `${s} is stale: missing generatedAt timestamp (required after impact ${t}).`;let r=Date.parse(e),n=Date.parse(t);return Number.isFinite(r)?Number.isFinite(n)&&r<n?`${s} is stale: generated at ${e}, before impact ${t}.`:null:`${s} is stale: invalid generatedAt timestamp (required after impact ${t}).`}async function ve(e,t,s,r){let n=le(e,t),i=n?f.relative(t,n).split(f.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!s)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 k=n?await c$1(t,i??""):null;if(!n||!k)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:i,message:i?`Missing evidence report: ${i}`:"No evidence mapping exists for this command."};let c=b(await y.readJson(k));if(!c)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:i,message:"Evidence report is not a JSON object."};let u;if(e.id==="workspace.doctor"){let o=v(c.generatedAt,r,"Doctor evidence");o?u={status:"fail",message:o}:u=ue(c);}else if(e.id==="workspace.readiness"){let o=v(c.generatedAt,r,"Release readiness evidence");o?u={status:"fail",message:o}:u=de(c);}else if(e.id==="workspace.contract.verify"){let o=v(c.generatedAt,r,"Workspace contract verify evidence");o?u={status:"fail",message:o}:u=pe(c);}else if(e.id==="workspace.analyze"){let o=v(c.generatedAt,r,"Analyze evidence");o?u={status:"fail",message:o}:u=fe(c);}else if(e.id==="workspace.pipeline"){let o=v(c.generatedAt,r,"Pipeline evidence");o?u={status:"fail",message:o}:u=ye(c);}else if(e.id==="workspace.doctor-fix"){let o=c.schemaVersion==="rapidkit-doctor-fix-result-v1"?c:c.fixResult,p=b(o),l=typeof p?.generatedAt=="string"?p.generatedAt:void 0,a=v(l,r,"Doctor fix result");a?u={status:"fail",message:a}:await me(t,l)?u={status:"skipped",message:"No current doctor remediation steps are pending."}:u=ge(c);}else if(e.id.startsWith("project."))u=he(c,e,r);else {let o=v(c.generatedAt,r,"Evidence report");o?u={status:"fail",message:o}:u={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:u.status,required:e.required,evidencePath:i,message:u.message}}function be(e,t={blockingReasons:[],needsAttention:false}){let s=e.filter(l=>l.status==="pass").length,r=e.filter(l=>l.status==="warn").length,n=e.filter(l=>l.status==="fail").length,i=e.filter(l=>l.status==="missing").length,k=e.filter(l=>l.status==="skipped").length,c=e.filter(l=>l.required&&(l.status==="fail"||l.status==="missing")).map(l=>`${l.id}: ${l.message}`),u=e.filter(l=>l.required&&l.status==="missing").length,o="ready",p=0;return c.length>0||t.blockingReasons.length>0?(o="blocked",p=2):(r>0||u>0||t.needsAttention)&&(o="needs-attention",p=1),{verdict:o,exitCode:p,stepsPassed:s,stepsWarn:r,stepsFailed:n,stepsMissing:i,stepsSkipped:k}}function we(e,t){let s=W(e.affectedProjects.map(a=>a.project?.name).filter(a=>typeof a=="string")),r=new Set(s.map(a=>a.toLowerCase())),n=W(e.transitiveImpact.map(a=>a.project?.name).filter(a=>typeof a=="string").filter(a=>!r.has(a.toLowerCase()))),i=new Map;for(let a of t){if(a.scope!=="project"||!a.project)continue;let d=a.project.toLowerCase(),h=i.get(d)??[];h.push(a),i.set(d,h);}let k=[],c=[],u=[],o=[],p=false,l=(a,d)=>{let h=i.get(a.toLowerCase())??[];if(h.length===0){u.push(a);return}let R=h.filter(g=>g.status==="fail"),C=h.filter(g=>g.status==="missing"),w=C.filter(g=>g.required),j=h.some(g=>g.status==="pass"||g.status==="warn");if(R.length>0){c.push(a),o.push(`graph.subgraph.${a}: ${d} has failed verification evidence (${R.map(g=>g.id).join(", ")}).`);return}if(w.length>0){c.push(a),o.push(`graph.subgraph.${a}: ${d} has missing required verification evidence (${w.map(g=>g.id).join(", ")}).`);return}if(C.length>0){c.push(a),p=true;return}if(j){k.push(a);return}u.push(a);};for(let a of s)l(a,"directly-changed");for(let a of n)l(a,"transitive dependent");return {subgraph:{totalProjects:s.length+n.length,directlyChanged:s,transitiveDependents:n,covered:W(k),uncovered:W(c),unverifiable:W(u)},blockingReasons:o,needsAttention:p}}function W(e){return [...new Set(e)].sort((t,s)=>t.localeCompare(s))}async function Re(e$1){let t=f.resolve(e$1.workspacePath);if(e$1.fromImpactPath){let i=oe(t,e$1.fromImpactPath);return {impact:await X(i),fromImpactRef:f.relative(t,i).split(f.sep).join("/"),impactFromDisk:true}}let s=f.join(t,f$1);if(await y.pathExists(s))return {impact:await X(s),fromImpactRef:f$1,impactFromDisk:true};let r=f.join(t,c$2);if(await y.pathExists(r))return {impact:await n({workspacePath:t,fromPath:c$2,scope:e$1.scope,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),fromImpactRef:c$2,impactFromDisk:false};let n$2=await n$1({workspacePath:t,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now});return {impact:{schemaVersion:e,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",diffRef:".workspai/reports/workspace-model-diff-last-run.json",workspace:{name:n$2.workspace.name,profile:n$2.workspace.profile,type:n$2.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0,blastRadius:{directlyAffected:0,transitivelyAffected:0,maxDistance:0,graphEdges:n$2.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:"workspace-model-diff.v1",generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",toRef:".workspai/reports/workspace-model.json",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:n$2}},impactFromDisk:false}}function Ce(e,t){if(t)return e.generatedAt}async function Ge(e){let t=f.resolve(e.workspacePath),{impact:s,fromImpactRef:r,impactFromDisk:n}=await Re(e),i=s.diff.currentModel,k=Ce(s,n),c$1=ae([...m(),...s.verificationPlan]).filter(m=>ce(e.scope,m)),u=[];for(let m of c$1)u.push(await ve(m,t,i.contracts.exists===true,k));let o=we(s,u),p=a(i.graph??{nodes:[],edges:[]}),l=b$1(i),a$1=await xe(t),d$1=c(l,a$1?.freshness?.projectHashes),h={verdict:d$1.verdict,baseline:d$1.baseline,changed:d$1.changed,added:d$1.added,removed:d$1.removed,projectHashes:d(l)},R=b$2(p),C=i.policies?.mode??"warn",w=await je(i,t),j=We(C,w),g=be(u,{blockingReasons:[...o.blockingReasons,...R,...j.blockingReasons],needsAttention:o.needsAttention||j.needsAttention}),Z=u.filter(m=>m.status==="missing"&&m.evidencePath).map(m=>m.evidencePath),x=[...u.filter(m=>m.required&&(m.status==="fail"||m.status==="missing")).map(m=>`${m.id}: ${m.message}`),...o.blockingReasons,...R,...j.blockingReasons],ee=w.filter(m=>m.severity==="error").length,te=i.summary?.projectCount??i.projects.length,B=Y({projectCount:te,verdict:g.verdict,exitCode:g.exitCode,blockingReasons:x,policyErrorCount:ee});g.verdict=B.verdict,g.exitCode=B.exitCode;let F=x.length>0?G({blockingReasons:x,verifyCommand:"npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json",verifyArtifact:$}):[];return {schemaVersion:Q,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:r,scope:e.scope,impact:{changed:s.summary.changed,risk:s.summary.risk,affectedProjects:s.summary.affectedProjects,recommendedCommands:s.summary.recommendedCommands},summary:g,steps:u,missingEvidence:Z,blockingReasons:x,...F.length>0?{resolutionHints:F}:{},verificationPlan:c$1,affectedSubgraph:o.subgraph,graphIntegrity:p,freshness:h,policyMode:C,policyViolations:w}}async function je(e,t){let s=[];for(let n of e.validation?.issues??[])s.push({source:"model",severity:n.severity,code:n.code,message:n.message,target:n.target});let r=await c$1(t,".workspai/reports/workspace-contract-verify-last-run.json");try{if(r&&await y.pathExists(r)){let n=await y.readJson(r);if(Array.isArray(n.violations))for(let i of n.violations)typeof i=="string"&&i.trim().length>0&&s.push({source:"contract",severity:"error",code:"contract.violation",message:i});}}catch{}return s.sort((n,i)=>n.source!==i.source?n.source.localeCompare(i.source):n.code!==i.code?n.code.localeCompare(i.code):n.message.localeCompare(i.message))}function We(e,t){let s=t.filter(r=>r.severity==="error");return e==="enforce"&&s.length>0?{blockingReasons:s.map(r=>`policy.${r.code}: ${r.message}`),needsAttention:false}:{blockingReasons:[],needsAttention:s.length>0}}async function xe(e){let t=f.join(e,$);try{if(!await y.pathExists(t))return null;let s=await y.readJson(t);return s&&s.schemaVersion===Q?s:null}catch{return null}}async function Ye(e,t){let s=f.join(t,$);return await y.ensureDir(f.dirname(s)),await y.writeJson(s,a$1(e),{spaces:2}),s}function Se(e,t){let s=t?.strict?"strict":"default",r=[];if(e.summary.verdict==="blocked")return r.push(...e.blockingReasons),r.length===0&&r.push("verify verdict is blocked."),{passed:false,mode:s,exitCode:2,reasons:r};if(s==="strict"){if(e.summary.verdict!=="ready"&&r.push(`verify verdict is ${e.summary.verdict} (strict requires ready).`),e.freshness.verdict==="stale"){let n=[...e.freshness.changed,...e.freshness.added].slice(0,5);r.push(`freshness is stale${n.length>0?`: ${n.join(", ")}`:""} (strict requires fresh).`);}if(r.length>0)return {passed:false,mode:s,exitCode:1,reasons:r}}return {passed:true,mode:s,exitCode:0,reasons:r}}function Xe(e,t){return Se(e,t).exitCode}export{J as a,Fe as b,Q as c,$ as d,we as e,Ge as f,Ye as g,Se as h,Xe as i};
@@ -1,2 +1,2 @@
1
- import {n,d,e}from'./chunk-5SWNSJGW.js';import {a}from'./chunk-VZKSNUEE.js';import u from'path';import v from'fs-extra';var $="workspace-context.v1",M=".workspai/reports/workspace-context-agent.json";function F(e){if(typeof e!="string"||!e.trim()||e==="true")return "generic";let t=e.trim().toLowerCase();return t==="codex"||t==="claude"||t==="cursor"||t==="orca"?t:"generic"}function x(e){return `npx --yes --package workspai workspai ${e}`.trim()}function C(e){return `npx workspai ${e}`.trim()}function i(e){return {id:e.id,scope:e.scope,display:C(e.args),execute:x(e.args),description:e.description,...e.project?{project:e.project}:{},freshness:d({id:`command.${e.id}`,label:`${e.id} command`,scope:"command",value:{display:C(e.args),execute:x(e.args)},...e.project?{project:e.project}:{},freshness:{kind:"derived",category:"structure",generatedAt:e.generatedAt,now:e.now,sourceArtifact:".workspai/reports/workspace-model.json",sourcePath:`safeCommands.${e.id}`,reason:"Safe command surfaces are derived from workspace model command capabilities."}}).freshness}}function W(e,t){return `workspace run ${t} --scope project:${e.name}`}function R(e){return (e.startsWith("project:")?e.slice(8):e).trim().toLowerCase()}function E(e){return [e.name,e.path,u.basename(e.path),e.absolutePath].filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim().toLowerCase())}function T(e,t,o){let r={generatedAt:e.generatedAt,now:o},a=[i({id:"workspace.model",scope:"workspace",args:"workspace model --json",description:"Read the canonical workspace intelligence model.",...r}),i({id:"workspace.doctor",scope:"workspace",args:"doctor workspace --json",description:"Check workspace health before claiming verification.",...r}),i({id:"workspace.pipeline",scope:"workspace",args:"pipeline --json",description:"Run the governed sync, doctor, analyze, readiness, and autopilot loop.",...r}),i({id:"workspace.contract.verify",scope:"workspace",args:"workspace contract verify --json",description:"Verify workspace contract and dependency edges.",...r}),i({id:"workspace.verify",scope:"workspace",args:"workspace verify --json",description:"Evaluate evidence freshness and verification gates before release decisions.",...r})],c=t?[t]:e.projects;for(let n of c)n.commands.fleetStages.includes("test")&&a.push(i({id:`project.${n.name}.test`,scope:"project",project:n.name,args:W(n,"test"),description:`Run tests for ${n.name} through workspace orchestration.`,...r})),n.commands.fleetStages.includes("build")&&a.push(i({id:`project.${n.name}.build`,scope:"project",project:n.name,args:W(n,"build"),description:`Build ${n.name} through workspace orchestration.`,...r}));return a}function O(e){return e.commands.fleetStages.filter(t=>t==="test"||t==="build").map(t=>`workspace run ${t}`)}function D(e,t){if(!t?.startsWith("project:"))return;let o=R(t);if(o)return e.projects.find(r=>E(r).includes(o))}function V(e,t,o){let r=[...e.validation?.issues??[]];t?.startsWith("project:")&&!o&&r.push({severity:"error",code:"context.scope.project.missing",message:`Requested project scope was not found: ${t}`,target:t});let a=r.filter(n=>n.severity==="error").length,c=r.filter(n=>n.severity==="warning").length;return {status:a>0?"failed":c>0?"warning":"passed",errors:a,warnings:c,issues:r}}function I(e){let t=[],o=[];for(let[r,a]of Object.entries(e.evidence))a?.exists?t.push(`${r}: ${a.path}`):o.push(r);return {available:t.sort(),missing:o.sort()}}function N(e){let t=e.summary.projectCount,o=e.summary.runtimes.length?e.summary.runtimes.join(", "):"no runtime",r=e.identity.surfaces.length?e.identity.surfaces.join(", "):"no detected surfaces";return `${e.workspace.name} is a ${e.identity.workspaceType} with ${t} project${t===1?"":"s"}, ${o} runtime coverage, and ${r}.`}function _(e){let t=["Do not claim a command passed unless a report or command output proves it.","Do not infer secrets or environment values from file names.","Do not change project scope without checking the selected project."];return e.contracts.exists||t.push("Workspace contract is missing; dependency and API edges may be incomplete."),e.summary.observedProjects>0&&t.push("Some projects are observed rather than first-class; command support may be partial."),t}async function L(e$1){let t=e$1.model??await n({workspacePath:e$1.workspacePath,includeEvidence:e$1.includeEvidence===true,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),o=F(e$1.agent),r=D(t,e$1.scope),a=V(t,e$1.scope,r);if(e$1.strict===true&&a.status!=="passed"){let s=a.issues.map(p=>`${p.severity}:${p.code}:${p.target}`).join(", ");throw new Error(`Workspace context strict validation failed: ${s}`)}let c=e$1.now??new Date,n$1=t.facts??[],b=new Set((r?[r]:t.projects).map(s=>s.name)),g=n$1.filter(s=>s.project?b.has(s.project):true),S=(r?[r]:t.projects).map(s=>{let p=g.filter(P=>P.project===s.name);return {name:s.name,path:s.path,kind:s.kind,runtime:s.runtime,framework:s.frameworkDisplayName,...s.generator?{generator:s.generator}:{},createCapability:s.createCapability,supportTier:s.supportTier,safeCommands:O(s),importantFiles:s.importantFiles,facts:p}}),d$1=I(t),f=N(t),k=T(t,r,c),A=k.map(s=>d({id:`context.command.${s.id}`,label:`${s.id} safe command`,scope:"command",value:{display:s.display,execute:s.execute,scope:s.scope},...s.project?{project:s.project}:{},freshness:{kind:"derived",category:"structure",generatedAt:t.generatedAt,now:c,sourceArtifact:".workspai/reports/workspace-context-agent.json",sourcePath:`safeCommands.${s.id}`,reason:"Context safe commands are derived from workspace model command capabilities."}})),h=[...g,...A],m=e({facts:h,generatedAt:c.toISOString(),now:c});return {schemaVersion:$,generatedAt:c.toISOString(),agent:o,workspaceSummary:f,modelRef:".workspai/reports/workspace-model.json",workspace:{name:t.workspace.name,root:t.workspace.root,type:t.identity.workspaceType,...t.workspace.profile?{profile:t.workspace.profile}:{}},scope:{requested:e$1.scope??"workspace",...r?{activeProject:r.name}:{}},projects:S,safeCommands:k,facts:h,factFreshness:m,evidence:d$1,policies:{mode:t.policies.mode,source:t.policies.source},contracts:{exists:t.contracts.exists,path:t.contracts.workspaceContractPath},validation:a,agentInstructions:["Read `.workspai/reports/INDEX.json` first, then this context pack and linked evidence reports.","Use this context as the workspace source of truth before inspecting random files.","Prefer workspace-level evidence over generic framework assumptions.","Use `display` commands when explaining steps to a human.","Use `execute` commands when launching commands from automation or tooling.","Treat `facts[].freshness.verifyBeforeUse` as a hard refresh requirement before using that fact in advice, fixes, or release decisions.","Do not carry extracted facts beyond their freshness contract; re-read or regenerate evidence when the contract says stale, unknown, live, or verify-before-use.","Keep project-scoped advice tied to the active project scope.","Regenerate stale grounding with `npx workspai workspace agent-sync --write --refresh-context`."],unsafeAssumptions:[..._(t),...m.verifyBeforeUseFacts>0?[`${m.verifyBeforeUseFacts} fact(s) require verification before use; do not treat them as durable workspace structure.`]:[]],humanSummary:[f,`Evidence available: ${d$1.available.length}. Missing evidence groups: ${d$1.missing.join(", ")||"none"}.`,r?`Active project scope: ${r.name} (${r.frameworkDisplayName}).`:"Scope: whole workspace."].join(`
1
+ import {n,d,e}from'./chunk-FHSMY75W.js';import {a}from'./chunk-XNGANEXM.js';import u from'path';import v from'fs-extra';var $="workspace-context.v1",M=".workspai/reports/workspace-context-agent.json";function F(e){if(typeof e!="string"||!e.trim()||e==="true")return "generic";let t=e.trim().toLowerCase();return t==="codex"||t==="claude"||t==="cursor"||t==="orca"?t:"generic"}function x(e){return `npx --yes --package workspai workspai ${e}`.trim()}function C(e){return `npx workspai ${e}`.trim()}function i(e){return {id:e.id,scope:e.scope,display:C(e.args),execute:x(e.args),description:e.description,...e.project?{project:e.project}:{},freshness:d({id:`command.${e.id}`,label:`${e.id} command`,scope:"command",value:{display:C(e.args),execute:x(e.args)},...e.project?{project:e.project}:{},freshness:{kind:"derived",category:"structure",generatedAt:e.generatedAt,now:e.now,sourceArtifact:".workspai/reports/workspace-model.json",sourcePath:`safeCommands.${e.id}`,reason:"Safe command surfaces are derived from workspace model command capabilities."}}).freshness}}function W(e,t){return `workspace run ${t} --scope project:${e.name}`}function R(e){return (e.startsWith("project:")?e.slice(8):e).trim().toLowerCase()}function E(e){return [e.name,e.path,u.basename(e.path),e.absolutePath].filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim().toLowerCase())}function T(e,t,o){let r={generatedAt:e.generatedAt,now:o},a=[i({id:"workspace.model",scope:"workspace",args:"workspace model --json",description:"Read the canonical workspace intelligence model.",...r}),i({id:"workspace.doctor",scope:"workspace",args:"doctor workspace --json",description:"Check workspace health before claiming verification.",...r}),i({id:"workspace.pipeline",scope:"workspace",args:"pipeline --json",description:"Run the governed sync, doctor, analyze, readiness, and autopilot loop.",...r}),i({id:"workspace.contract.verify",scope:"workspace",args:"workspace contract verify --json",description:"Verify workspace contract and dependency edges.",...r}),i({id:"workspace.verify",scope:"workspace",args:"workspace verify --json",description:"Evaluate evidence freshness and verification gates before release decisions.",...r})],c=t?[t]:e.projects;for(let n of c)n.commands.fleetStages.includes("test")&&a.push(i({id:`project.${n.name}.test`,scope:"project",project:n.name,args:W(n,"test"),description:`Run tests for ${n.name} through workspace orchestration.`,...r})),n.commands.fleetStages.includes("build")&&a.push(i({id:`project.${n.name}.build`,scope:"project",project:n.name,args:W(n,"build"),description:`Build ${n.name} through workspace orchestration.`,...r}));return a}function O(e){return e.commands.fleetStages.filter(t=>t==="test"||t==="build").map(t=>`workspace run ${t}`)}function D(e,t){if(!t?.startsWith("project:"))return;let o=R(t);if(o)return e.projects.find(r=>E(r).includes(o))}function V(e,t,o){let r=[...e.validation?.issues??[]];t?.startsWith("project:")&&!o&&r.push({severity:"error",code:"context.scope.project.missing",message:`Requested project scope was not found: ${t}`,target:t});let a=r.filter(n=>n.severity==="error").length,c=r.filter(n=>n.severity==="warning").length;return {status:a>0?"failed":c>0?"warning":"passed",errors:a,warnings:c,issues:r}}function I(e){let t=[],o=[];for(let[r,a]of Object.entries(e.evidence))a?.exists?t.push(`${r}: ${a.path}`):o.push(r);return {available:t.sort(),missing:o.sort()}}function N(e){let t=e.summary.projectCount,o=e.summary.runtimes.length?e.summary.runtimes.join(", "):"no runtime",r=e.identity.surfaces.length?e.identity.surfaces.join(", "):"no detected surfaces";return `${e.workspace.name} is a ${e.identity.workspaceType} with ${t} project${t===1?"":"s"}, ${o} runtime coverage, and ${r}.`}function _(e){let t=["Do not claim a command passed unless a report or command output proves it.","Do not infer secrets or environment values from file names.","Do not change project scope without checking the selected project."];return e.contracts.exists||t.push("Workspace contract is missing; dependency and API edges may be incomplete."),e.summary.observedProjects>0&&t.push("Some projects are observed rather than first-class; command support may be partial."),t}async function L(e$1){let t=e$1.model??await n({workspacePath:e$1.workspacePath,includeEvidence:e$1.includeEvidence===true,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),o=F(e$1.agent),r=D(t,e$1.scope),a=V(t,e$1.scope,r);if(e$1.strict===true&&a.status!=="passed"){let s=a.issues.map(p=>`${p.severity}:${p.code}:${p.target}`).join(", ");throw new Error(`Workspace context strict validation failed: ${s}`)}let c=e$1.now??new Date,n$1=t.facts??[],b=new Set((r?[r]:t.projects).map(s=>s.name)),g=n$1.filter(s=>s.project?b.has(s.project):true),S=(r?[r]:t.projects).map(s=>{let p=g.filter(P=>P.project===s.name);return {name:s.name,path:s.path,kind:s.kind,runtime:s.runtime,framework:s.frameworkDisplayName,...s.generator?{generator:s.generator}:{},createCapability:s.createCapability,supportTier:s.supportTier,safeCommands:O(s),importantFiles:s.importantFiles,facts:p}}),d$1=I(t),f=N(t),k=T(t,r,c),A=k.map(s=>d({id:`context.command.${s.id}`,label:`${s.id} safe command`,scope:"command",value:{display:s.display,execute:s.execute,scope:s.scope},...s.project?{project:s.project}:{},freshness:{kind:"derived",category:"structure",generatedAt:t.generatedAt,now:c,sourceArtifact:".workspai/reports/workspace-context-agent.json",sourcePath:`safeCommands.${s.id}`,reason:"Context safe commands are derived from workspace model command capabilities."}})),h=[...g,...A],m=e({facts:h,generatedAt:c.toISOString(),now:c});return {schemaVersion:$,generatedAt:c.toISOString(),agent:o,workspaceSummary:f,modelRef:".workspai/reports/workspace-model.json",workspace:{name:t.workspace.name,root:t.workspace.root,type:t.identity.workspaceType,...t.workspace.profile?{profile:t.workspace.profile}:{}},scope:{requested:e$1.scope??"workspace",...r?{activeProject:r.name}:{}},projects:S,safeCommands:k,facts:h,factFreshness:m,evidence:d$1,policies:{mode:t.policies.mode,source:t.policies.source},contracts:{exists:t.contracts.exists,path:t.contracts.workspaceContractPath},validation:a,agentInstructions:["Read `.workspai/reports/INDEX.json` first, then this context pack and linked evidence reports.","Use this context as the workspace source of truth before inspecting random files.","Prefer workspace-level evidence over generic framework assumptions.","Use `display` commands when explaining steps to a human.","Use `execute` commands when launching commands from automation or tooling.","Treat `facts[].freshness.verifyBeforeUse` as a hard refresh requirement before using that fact in advice, fixes, or release decisions.","Do not carry extracted facts beyond their freshness contract; re-read or regenerate evidence when the contract says stale, unknown, live, or verify-before-use.","Keep project-scoped advice tied to the active project scope.","Regenerate stale grounding with `npx workspai workspace agent-sync --write --refresh-context`."],unsafeAssumptions:[..._(t),...m.verifyBeforeUseFacts>0?[`${m.verifyBeforeUseFacts} fact(s) require verification before use; do not treat them as durable workspace structure.`]:[]],humanSummary:[f,`Evidence available: ${d$1.available.length}. Missing evidence groups: ${d$1.missing.join(", ")||"none"}.`,r?`Active project scope: ${r.name} (${r.frameworkDisplayName}).`:"Scope: whole workspace."].join(`
2
2
  `)}}async function G(e,t){let o=u.join(t,M);return await v.ensureDir(u.dirname(o)),await v.writeJSON(o,a(e),{spaces:2}),o}export{$ as a,M as b,L as c,G as d};
@@ -1 +1 @@
1
- import {b as b$1}from'./chunk-JHC6SCJC.js';import {j as j$1}from'./chunk-RE773WOX.js';import {c}from'./chunk-LUP4U6EE.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-JHC6SCJC.js';import {j as j$1}from'./chunk-FDDDQMJ2.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};