workspai 0.44.0 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/README.md +243 -513
  2. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +1372 -0
  3. package/contracts/command-capabilities.v1.json +166 -1
  4. package/contracts/extension-cli-compatibility.v1.json +4 -2
  5. package/contracts/published-contract-catalog.v1.json +12 -1
  6. package/contracts/runtime-command-surface.v1.json +1478 -3
  7. package/contracts/workspace-archive-capabilities.v1.json +17 -6
  8. package/contracts/workspace-intelligence/studio-blocker-handoff.v1.json +4 -0
  9. package/contracts/workspace-intelligence/workspace-intelligence-run.v1.json +207 -0
  10. package/contracts/workspace-intelligence-architecture.v1.json +1 -1
  11. package/contracts/workspace-intelligence-chain.v1.json +37 -1
  12. package/dist/analyze-BEBEZSZK.js +1 -0
  13. package/dist/{artifact-remediation-plan-Z7OCSME3.js → artifact-remediation-plan-FFQSESAM.js} +1 -1
  14. package/dist/autopilot-release-WUR4CQIT.js +1 -0
  15. package/dist/chunk-2G7FASAO.js +2 -0
  16. package/dist/{chunk-CL6TGI4Q.js → chunk-4EPHWD27.js} +1 -1
  17. package/dist/{chunk-J4AICQFB.js → chunk-4LGXSBCN.js} +1 -1
  18. package/dist/chunk-52PBRX7F.js +1 -0
  19. package/dist/{chunk-2QOWRBQD.js → chunk-6IIZJQLV.js} +1 -1
  20. package/dist/{chunk-JICOD2GI.js → chunk-CVHMUSRX.js} +1 -1
  21. package/dist/{chunk-7UZVOYF5.js → chunk-DIPD72H4.js} +1 -1
  22. package/dist/chunk-EFYHGCGX.js +2 -0
  23. package/dist/chunk-EYJ2CQSK.js +1 -0
  24. package/dist/chunk-FPJNWPKU.js +1 -0
  25. package/dist/{chunk-JP25YL3J.js → chunk-FTY7GGXJ.js} +2 -2
  26. package/dist/chunk-FWRXA435.js +2 -0
  27. package/dist/chunk-FXQJX34Z.js +1 -0
  28. package/dist/chunk-HDURFXW5.js +2 -0
  29. package/dist/chunk-HMUKBW2S.js +4 -0
  30. package/dist/{chunk-OW4UNG27.js → chunk-J5PIZCAU.js} +92 -78
  31. package/dist/{chunk-P4SWTY5X.js → chunk-K4WNYXKK.js} +7 -7
  32. package/dist/chunk-MER6ZBN2.js +13 -0
  33. package/dist/chunk-N7DV5L7C.js +1 -0
  34. package/dist/{chunk-JHC6SCJC.js → chunk-NHN4QXPP.js} +1 -1
  35. package/dist/{chunk-P424XYHP.js → chunk-PRBVYW3T.js} +1 -1
  36. package/dist/{chunk-NTXO7BMH.js → chunk-QA5BGEQW.js} +1 -1
  37. package/dist/chunk-QZLIURER.js +13 -0
  38. package/dist/{chunk-L3E6IRUQ.js → chunk-RIEF2DDX.js} +1 -1
  39. package/dist/{chunk-L2Q7B2OJ.js → chunk-SXMTSV5M.js} +1 -1
  40. package/dist/chunk-SXPY523X.js +1 -0
  41. package/dist/{chunk-XIVFLY6G.js → chunk-UQWOVV6V.js} +1 -1
  42. package/dist/chunk-V3LRQZ36.js +1 -0
  43. package/dist/chunk-VFDM65IE.js +80 -0
  44. package/dist/{chunk-B66A4TVP.js → chunk-WPEEC5BX.js} +1 -1
  45. package/dist/chunk-WYFPXTTS.js +2 -0
  46. package/dist/{chunk-M4VITK6X.js → chunk-YUATNVOT.js} +62 -51
  47. package/dist/{chunk-7IHLTPZ6.js → chunk-ZKAI3PJE.js} +1 -1
  48. package/dist/{create-DFAWAS5C.js → create-WCV3L6XH.js} +1 -1
  49. package/dist/doctor-5BWM2EMJ.js +1 -0
  50. package/dist/{dotnet-webapi-clean-BYUUHX5Y.js → dotnet-webapi-clean-6TVFBTVI.js} +20 -20
  51. package/dist/{gofiber-standard-B6UK5GR7.js → gofiber-standard-2BL7GWZB.js} +1 -1
  52. package/dist/{gogin-standard-BXU44VEM.js → gogin-standard-XGP3KBXA.js} +1 -1
  53. package/dist/index.d.ts +123 -15
  54. package/dist/index.js +337 -323
  55. package/dist/pipeline-ORIWVVYM.js +5 -0
  56. package/dist/{platform-capabilities-YICBF4FA.js → platform-capabilities-2B4QMZXE.js} +1 -1
  57. package/dist/{pythonRapidkitExec-UJYIB6FL.js → pythonRapidkitExec-CVCIK225.js} +1 -1
  58. package/dist/{springboot-standard-PEHDKH2L.js → springboot-standard-JJNUID6M.js} +6 -6
  59. package/dist/workspace-7OXW5YTJ.js +1 -0
  60. package/dist/{workspace-agent-sync-ZYCPXTU3.js → workspace-agent-sync-O4IA6VOA.js} +1 -1
  61. package/dist/workspace-archive-H74NBBNW.js +10 -0
  62. package/dist/{workspace-context-WAGGJCDL.js → workspace-context-R7IPUBPG.js} +1 -1
  63. package/dist/workspace-contract-HKCMOMFE.js +1 -0
  64. package/dist/workspace-explain-GOPQYTPQ.js +1 -0
  65. package/dist/workspace-explain-contract-SVFJAAEI.js +1 -0
  66. package/dist/{workspace-feedback-RCB25NFO.js → workspace-feedback-REOS36ZZ.js} +1 -1
  67. package/dist/{workspace-foundation-KXDL6P6X.js → workspace-foundation-KXT4QI5O.js} +1 -1
  68. package/dist/{workspace-history-M4QQBIPB.js → workspace-history-OGOVSKZG.js} +1 -1
  69. package/dist/{workspace-intelligence-QOGD2TZS.js → workspace-intelligence-7IESQSXY.js} +1 -1
  70. package/dist/workspace-intelligence-runner-6GJ5M4HB.js +1 -0
  71. package/dist/{workspace-mcp-serve-CEFKEMYG.js → workspace-mcp-serve-FRVWBO36.js} +1 -1
  72. package/dist/{workspace-model-GMSRBICO.js → workspace-model-PPYX7B4S.js} +1 -1
  73. package/dist/workspace-python-engine-state-2MLKJYQG.js +2 -0
  74. package/dist/workspace-registry-summary-SZ46R5PD.js +1 -0
  75. package/dist/workspace-run-V3KKHTVF.js +1 -0
  76. package/dist/{workspace-verify-NP4GMFSV.js → workspace-verify-MFQ7IXGD.js} +1 -1
  77. package/dist/{workspace-watch-IIBH3Y25.js → workspace-watch-SOPZHRWA.js} +1 -1
  78. package/docs/AI_DYNAMIC_INTEGRATION.md +29 -33
  79. package/docs/AI_FEATURES.md +18 -27
  80. package/docs/AI_QUICKSTART.md +7 -4
  81. package/docs/DEVELOPMENT.md +5 -5
  82. package/docs/From Code to Shared Understanding.png +0 -0
  83. package/docs/OPEN_SOURCE_USER_SCENARIOS.md +23 -2
  84. package/docs/OPTIMIZATION_GUIDE.md +19 -51
  85. package/docs/PACKAGE_MANAGER_POLICY.md +4 -1
  86. package/docs/README.md +30 -3
  87. package/docs/SECURITY.md +13 -6
  88. package/docs/SETUP.md +6 -3
  89. package/docs/UTILITIES.md +8 -20
  90. package/docs/WORKSPACE_MARKER_SPEC.md +27 -20
  91. package/docs/ci-workflows.md +19 -5
  92. package/docs/commands-reference.md +51 -10
  93. package/docs/config-file-guide.md +64 -247
  94. package/docs/contracts/ARTIFACT_CATALOG.md +14 -2
  95. package/docs/contracts/CLI_LOG_EVENT_STREAM.md +1 -1
  96. package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +27 -6
  97. package/docs/contracts/README.md +5 -2
  98. package/docs/contracts/RUNTIME_ACCEPTANCE_MATRIX.md +4 -4
  99. package/docs/contracts/RUNTIME_SUPPORT_MATRIX.md +14 -10
  100. package/docs/creating-workspaces-and-projects.md +649 -0
  101. package/docs/doctor-command.md +5 -4
  102. package/docs/examples/ci-agent-grounding.yml +16 -10
  103. package/docs/from-code-to-shared-understanding.md +69 -38
  104. package/docs/workspace-intelligence-runner.md +186 -0
  105. package/docs/workspace-operations.md +29 -11
  106. package/docs/workspace-run.md +4 -1
  107. package/package.json +10 -8
  108. package/rapidkit.config.example.cjs +5 -5
  109. package/scripts/enforce-package-manager.cjs +1 -1
  110. package/scripts/prepack-enterprise.mjs +8 -0
  111. package/workspai.config.example.cjs +12 -47
  112. package/dist/analyze-6OCBM4ID.js +0 -1
  113. package/dist/autopilot-release-LI2WJCEW.js +0 -1
  114. package/dist/chunk-2K3GYCPS.js +0 -1
  115. package/dist/chunk-2QN6BMM7.js +0 -2
  116. package/dist/chunk-5AKYMAIL.js +0 -1
  117. package/dist/chunk-5PVEQ6CZ.js +0 -13
  118. package/dist/chunk-7EIMPQR3.js +0 -1
  119. package/dist/chunk-7RIWU5TZ.js +0 -1
  120. package/dist/chunk-FWJV7CCI.js +0 -2
  121. package/dist/chunk-LGP6WXS2.js +0 -4
  122. package/dist/chunk-TRMDODFM.js +0 -13
  123. package/dist/chunk-UNF72FTB.js +0 -1
  124. package/dist/chunk-V5JN4TDX.js +0 -2
  125. package/dist/chunk-VA5MRHKM.js +0 -2
  126. package/dist/chunk-XZGVNGRB.js +0 -1
  127. package/dist/chunk-YUX4YFGL.js +0 -78
  128. package/dist/doctor-PVSWDBJL.js +0 -1
  129. package/dist/imported-projects-registry-FOIE27WT.js +0 -1
  130. package/dist/pipeline-ND734AJM.js +0 -5
  131. package/dist/workspace-FQT3QIRS.js +0 -1
  132. package/dist/workspace-archive-EEGLHZDW.js +0 -10
  133. package/dist/workspace-contract-SEI4SNSG.js +0 -1
  134. package/dist/workspace-explain-MVGGRCDN.js +0 -1
  135. package/dist/workspace-explain-contract-KT757JGQ.js +0 -1
  136. package/dist/workspace-python-engine-state-MTWIIZPY.js +0 -2
  137. package/dist/workspace-registry-summary-S52SEJAG.js +0 -1
  138. package/dist/workspace-run-VC4OUPRF.js +0 -1
@@ -0,0 +1,5 @@
1
+ import {c as c$1}from'./chunk-4EPHWD27.js';import {a as a$2}from'./chunk-RIEF2DDX.js';import {q}from'./chunk-VFDM65IE.js';import {d}from'./chunk-YUATNVOT.js';import {c as c$2}from'./chunk-FPJNWPKU.js';import {a as a$3}from'./chunk-HMUKBW2S.js';import {f as f$1,e}from'./chunk-T3GJ7YVG.js';import {a}from'./chunk-22DT744Z.js';import {f,c,g}from'./chunk-HDURFXW5.js';import {a as a$1}from'./chunk-N7DV5L7C.js';import c$3 from'chalk';import p from'path';function G(a){return a===0?"pass":a===2?"warn":"fail"}function I(a){return a.some(r=>r.status==="fail")?"blocked":a.some(r=>r.status==="warn")?"needs-attention":"ready"}function j(a,r){if(r)return 3;let i=a.some(o=>o.status==="fail"),t=a.some(o=>o.status==="warn");return i?1:t?2:0}function N(a,r){return a===2&&!r?0:a}async function O(a){let r=await d(a,true),i=false;try{let{syncWorkspaceContract:t}=await import('./workspace-contract-HKCMOMFE.js');await t({workspacePath:a}),i=true;}catch{i=false;}return {sync:r,contractSynced:i}}async function V(a$4={}){let r=p.resolve(a$4.workspacePath??process.cwd()),i=a(r);if(!i)throw new Error("No Workspai workspace found in current directory or parents");let t=[],o=[],l=false,d,f$2,m,y=Date.now();try{let{sync:e,contractSynced:s}=await O(i),n=e.workspaceFound&&(e.added.length>0||e.skipped>=0)||e.workspaceFound?"pass":"warn";t.push({name:"sync",status:n,durationMs:Date.now()-y,summary:e.workspaceFound?`registry sync complete (${e.added.length} added, ${e.skipped} existing)${s?", contract synced":""}`:"workspace not registered in global registry; contract sync attempted"}),e.workspaceFound||o.push("workspace registry entry missing \u2014 run workspai create workspace or register manually");}catch(e){l=true,t.push({name:"sync",status:"fail",durationMs:Date.now()-y,summary:`sync failed: ${e instanceof Error?e.message:String(e)}`}),o.push("workspace sync stage failed");}let w=Date.now();try{let e=await q({workspace:true,json:true,quiet:true,strict:a$4.strict===true,ci:a$4.strict!==true}),s=G(e),n=await f(i,a$1.doctor)??c(i,a$1.doctor);t.push({name:"doctor",status:s,durationMs:Date.now()-w,summary:s==="pass"?"doctor workspace passed":s==="warn"?"doctor workspace reported warnings":"doctor workspace did not pass",exitCode:e,evidencePath:n}),s==="fail"?o.push("doctor workspace gate failed"):s==="warn"&&o.push("doctor workspace reported warnings");}catch(e){l=true,t.push({name:"doctor",status:"fail",durationMs:Date.now()-w,summary:`doctor failed: ${e instanceof Error?e.message:String(e)}`}),o.push("doctor workspace stage failed");}if(a$4.skipAnalyze)t.push({name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped"});else {let e=Date.now();try{let s=await a$2({workspacePath:i,json:true,strict:a$4.strict===true});d=p.isAbsolute(s.enterpriseControls.evidencePath)?s.enterpriseControls.evidencePath:p.join(i,s.enterpriseControls.evidencePath);let n=s.summary.verdict==="blocked"?"fail":s.summary.verdict==="needs-attention"?"warn":"pass";t.push({name:"analyze",status:n,durationMs:Date.now()-e,summary:`analyze verdict: ${s.summary.verdict} (score ${s.summary.score}/100)`,evidencePath:d}),n==="fail"?o.push("analyze reported blocked verdict"):n==="warn"&&o.push("analyze reported needs-attention verdict");}catch(s){l=true,t.push({name:"analyze",status:"fail",durationMs:Date.now()-e,summary:`analyze failed: ${s instanceof Error?s.message:String(s)}`}),o.push("analyze stage failed");}}let h=Date.now();try{let e=await a$3({startPath:i,writeReport:true,skipVerify:a$4.skipVerify===true});f$2=e.evidencePath;let s=e.overallStatus==="pass"?"pass":e.overallStatus==="warn"?"warn":"fail";t.push({name:"readiness",status:s,durationMs:Date.now()-h,summary:`readiness overall: ${e.overallStatus}`,evidencePath:e.evidencePath}),s==="fail"?o.push(...e.blockingReasons.map(n=>`readiness: ${n}`)):s==="warn"&&o.push(...e.gates.filter(n=>n.status==="warn").map(n=>`readiness warn: ${n.gate}: ${n.summary}`));}catch(e){l=true,t.push({name:"readiness",status:"fail",durationMs:Date.now()-h,summary:`readiness failed: ${e instanceof Error?e.message:String(e)}`}),o.push("readiness stage failed");}if(a$4.skipAutopilot)t.push({name:"autopilot",status:"skipped",durationMs:0,summary:"autopilot stage skipped"});else {let e=Date.now(),s=a$4.autopilotMode??"audit";try{let n=await c$1({workspacePath:i,mode:s,json:true,skipPipelineStages:true});m=n.artifacts.reportPath;let P=n.summary.verdict==="approved"?"pass":n.summary.verdict==="partial"?"warn":"fail";t.push({name:"autopilot",status:P,durationMs:Date.now()-e,summary:`autopilot ${s}: ${n.summary.verdict}`,exitCode:n.summary.exitCode,evidencePath:m}),P!=="pass"&&o.push(...n.blockingReasons.slice(0,5));}catch(n){l=true,t.push({name:"autopilot",status:"fail",durationMs:Date.now()-e,summary:`autopilot failed: ${n instanceof Error?n.message:String(n)}`}),o.push("autopilot release stage failed");}}let M=I(t),k=j(t,l),F=p.join(i,".workspai","reports","pipeline-last-run.json"),u={schemaVersion:"rapidkit-pipeline-v1",generatedAt:new Date().toISOString(),workspacePath:i,summary:{verdict:M,exitCode:k,stagesPassed:t.filter(e=>e.status==="pass").length,stagesWarn:t.filter(e=>e.status==="warn").length,stagesFailed:t.filter(e=>e.status==="fail").length},stages:t,blockingReasons:[...new Set(o)],artifacts:{reportPath:F,analyzeEvidencePath:d,readinessEvidencePath:f$2,autopilotEvidencePath:m}};if(a$4.writeReport!==false){let e$1=f$1(u,{commandId:"workspacePipeline",exitCode:k,generatedAt:u.generatedAt,blockers:u.blockingReasons,runId:e()});await g(i,".workspai/reports/pipeline-last-run.json",e$1);}if(a$4.writeReport!==false&&a$4.noAgentSync!==true&&process.env.RAPIDKIT_NO_AGENT_SYNC!=="1"&&a$4.agentSync!==false)try{let{syncWorkspaceAgentGrounding:e}=await import('./workspace-agent-sync-O4IA6VOA.js'),s=await e({workspacePath:i,write:true,refreshContext:true,strict:false});u.agentGrounding={indexPath:s.indexPath,writtenFiles:s.writtenFiles,blockers:s.blockers};}catch{}return u}async function ae(a){let r;try{r=await V(a);}catch(t){let o=t instanceof Error?t.message:String(t);a.json?console.log(JSON.stringify(c$2({operation:"pipeline",code:"pipeline.failed",message:o}),null,2)):console.log(c$3.red(`Pipeline failed: ${o}`)),process.exit(1);}if(a.json)console.log(JSON.stringify(r,null,2));else {console.log(c$3.bold.cyan(`
2
+ \u{1F517} Workspai Governance Pipeline
3
+ `)),console.log(c$3.bold(`Workspace: ${c$3.cyan(p.basename(r.workspacePath))}`)),console.log(c$3.gray(`Path: ${r.workspacePath}`)),console.log(c$3.white(`Verdict: ${r.summary.verdict} Exit: ${r.summary.exitCode} (${r.summary.stagesPassed} pass / ${r.summary.stagesWarn} warn / ${r.summary.stagesFailed} fail)`));for(let t of r.stages){let o=t.status==="pass"?c$3.green("PASS"):t.status==="warn"?c$3.yellow("WARN"):t.status==="skipped"?c$3.gray("SKIP"):c$3.red("FAIL");console.log(` - ${t.name}: ${o} ${t.summary}`);}if(r.blockingReasons.length>0){console.log(c$3.bold(`
4
+ Blocking reasons:`));for(let t of r.blockingReasons.slice(0,8))console.log(c$3.gray(` \u2022 ${t}`));}console.log(c$3.gray(`
5
+ Evidence: ${r.artifacts.reportPath}`)),r.agentGrounding?.writtenFiles.length&&console.log(c$3.gray(`Agent grounding: ${r.agentGrounding.writtenFiles.length} file(s) synced (INDEX + AGENTS.md + Copilot/Cursor/Claude hooks)`));}let i=N(r.summary.exitCode,a.strict===true);i!==0&&process.exit(i);}export{N as pipelineProcessExitCode,V as runPipeline,ae as runPipelineCommand};
@@ -1 +1 @@
1
- export{f as augmentPathWithNodeBin,g as buildPackageRunnerSubprocessEnv,a as detectPlatformKind,h as getDefaultPythonCommand,q as getLegacyWorkspaceRegistryDirectory,i as getPythonCommandCandidates,j as getPythonVersionProbeCandidates,o as getRapidkitLocalScriptCandidates,s as getUserLocalBinCandidates,n as getVenvActivateScriptPath,k as getVenvBinDirectory,l as getVenvPythonPath,m as getVenvRapidkitPath,p as getWorkspaceRegistryDirectory,r as getWorkspaceRegistryFileCandidates,b as isWindowsPlatform,d as resolvePackageRunnerExecutable,e as resolvePackageRunnerInvocation,c as shouldUseShellExecution}from'./chunk-2K3GYCPS.js';
1
+ export{f as augmentPathWithNodeBin,g as buildPackageRunnerSubprocessEnv,a as detectPlatformKind,h as getDefaultPythonCommand,q as getLegacyWorkspaceRegistryDirectory,i as getPythonCommandCandidates,j as getPythonVersionProbeCandidates,o as getRapidkitLocalScriptCandidates,s as getUserLocalBinCandidates,n as getVenvActivateScriptPath,k as getVenvBinDirectory,l as getVenvPythonPath,m as getVenvRapidkitPath,p as getWorkspaceRegistryDirectory,r as getWorkspaceRegistryFileCandidates,b as isWindowsPlatform,d as resolvePackageRunnerExecutable,e as resolvePackageRunnerInvocation,c as shouldUseShellExecution}from'./chunk-EYJ2CQSK.js';
@@ -1 +1 @@
1
- export{k as __test__,b as checkRapidkitCoreAvailable,c as checkRapidkitCoreVersionCompatible,i as getCachedCoreTopLevelCommands,h as getCoreTopLevelCommands,j as getModulesCatalog,d as resolveRapidkitPython,e as runCoreRapidkit,g as runCoreRapidkitCapture,f as runCoreRapidkitStreamed}from'./chunk-JP25YL3J.js';
1
+ export{k as __test__,b as checkRapidkitCoreAvailable,c as checkRapidkitCoreVersionCompatible,i as getCachedCoreTopLevelCommands,h as getCoreTopLevelCommands,j as getModulesCatalog,d as resolveRapidkitPython,e as runCoreRapidkit,g as runCoreRapidkitCapture,f as runCoreRapidkitStreamed}from'./chunk-FTY7GGXJ.js';
@@ -1,4 +1,4 @@
1
- import {b,c as c$1}from'./chunk-IBJEQHJR.js';import {c}from'./chunk-Y45WZR5N.js';import {b as b$1,a}from'./chunk-TQEMLBAG.js';import {promises}from'fs';import g from'path';import i from'chalk';import $ from'ora';import {execa}from'execa';var x="21",j="3.5.0",M="2.8.9";function f(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,".").replace(/^\.+|\.+$/g,"").replace(/\.{2,}/g,".").split(".").map(p=>p.replace(/^[^a-z]+/,"").replace(/[^a-z0-9]/g,"")).filter(Boolean).join(".")}function h(e,t){return e.replace(/[\r\n\t]+/g," ").trim()||t}function E(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(/-{2,}/g,"-")}function T(e,t){let s=f(e)||"com.workspai.apps",p=f(t)||"service";return `${s}.${p}`}function A(e){return e.replace(/\./g,"/")}function P(){return JSON.stringify({engine:"npm",runtime:"java"},null,2)}function C(e,t){return JSON.stringify({kit_name:"springboot.standard",runtime:"java",module_support:false,project_name:e.project_name,artifact_id:e.artifact_id,group_id:e.group_id,package_name:e.package_name,app_version:e.app_version,created_by:"workspai",workspai_version:t,rapidkit_version:t,created_at:new Date().toISOString()},null,2)}function D(e){return `<?xml version="1.0" encoding="UTF-8"?>
1
+ import {b,c as c$1}from'./chunk-IBJEQHJR.js';import {c}from'./chunk-Y45WZR5N.js';import {b as b$1,a}from'./chunk-TQEMLBAG.js';import {promises}from'fs';import g from'path';import i from'chalk';import R from'ora';import {execa}from'execa';var x="21",j="3.5.0",M="2.8.9";function f(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,".").replace(/^\.+|\.+$/g,"").replace(/\.{2,}/g,".").split(".").map(p=>p.replace(/^[^a-z]+/,"").replace(/[^a-z0-9]/g,"")).filter(Boolean).join(".")}function h(e,t){return e.replace(/[\r\n\t]+/g," ").trim()||t}function E(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(/-{2,}/g,"-")}function T(e,t){let s=f(e)||"com.workspai.apps",p=f(t)||"service";return `${s}.${p}`}function A(e){return e.replace(/\./g,"/")}function P(){return JSON.stringify({engine:"npm",runtime:"java"},null,2)}function C(e,t){return JSON.stringify({kit_name:"springboot.standard",runtime:"java",module_support:false,project_name:e.project_name,artifact_id:e.artifact_id,group_id:e.group_id,package_name:e.package_name,app_version:e.app_version,created_by:"workspai",workspai_version:t,rapidkit_version:t,created_at:new Date().toISOString()},null,2)}function D(e){return `<?xml version="1.0" encoding="UTF-8"?>
2
2
  <project xmlns="http://maven.apache.org/POM/4.0.0"
3
3
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
4
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -344,7 +344,7 @@ management:
344
344
  SPRING_PROFILES_ACTIVE=local
345
345
  API_BASE_PATH=/api/v1
346
346
  JAVA_OPTS=-Xms256m -Xmx512m
347
- `}function H(){return `FROM maven:3.9.9-eclipse-temurin-21 AS build
347
+ `}function H(e){return `FROM maven:3.9.9-eclipse-temurin-${e.java_version} AS build
348
348
  WORKDIR /workspace
349
349
 
350
350
  COPY pom.xml ./
@@ -353,12 +353,12 @@ RUN mvn -B -q -DskipTests dependency:go-offline
353
353
  COPY src ./src
354
354
  RUN mvn -B -DskipTests package
355
355
 
356
- FROM eclipse-temurin:21-jre
356
+ FROM eclipse-temurin:${e.java_version}-jre
357
357
  WORKDIR /app
358
358
 
359
359
  COPY --from=build /workspace/target/*.jar /app/app.jar
360
360
 
361
- EXPOSE 8080
361
+ EXPOSE ${e.port}
362
362
  ENV JAVA_OPTS=""
363
363
 
364
364
  ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar /app/app.jar"]
@@ -368,7 +368,7 @@ ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar /app/app.jar"]
368
368
  context: .
369
369
  dockerfile: Dockerfile
370
370
  ports:
371
- - "${e.port}:8080"
371
+ - "${e.port}:${e.port}"
372
372
  env_file:
373
373
  - .env
374
374
  environment:
@@ -689,7 +689,7 @@ class ServiceRuntimeE2ETest {
689
689
  }
690
690
  `}async function oe(e){try{await execa("mvn",["-N","wrapper:wrapper","-Dmaven=3.9.9"],{cwd:e,timeout:12e4});let t=g.join(e,"mvnw");return await promises.stat(t).then(()=>true).catch(()=>false)&&await promises.chmod(t,493),true}catch{return false}}async function ve(e,t){let s=E(t.artifact_id||t.project_name)||"service",p=f(t.group_id||"com.workspai.apps")||"com.workspai.apps",S=f(t.package_name||T(p,s))||"com.workspai.apps.service",r={project_name:t.project_name,artifact_id:s,group_id:p,package_name:S,author:h(t.author||"","Workspai User"),description:h(t.description||"",`Spring Boot service generated with Workspai - ${t.project_name}`),java_version:t.java_version||x,spring_boot_version:t.spring_boot_version||j,springdoc_version:t.springdoc_version||M,app_version:t.app_version||"0.1.0",port:t.port||"8080",skipGit:t.skipGit??false,skipInstall:t.skipInstall??false},b$2=c(),l=`${b(r.project_name)}Application`,o=A(r.package_name);try{await execa("mvn",["-version"],{timeout:3e3});}catch{console.log(i.yellow(`
691
691
  \u26A0 Maven not found in PATH - project will be scaffolded, but init/build commands require Maven 3.9+`)),console.log(i.gray(` Install: https://maven.apache.org/install.html
692
- `));}let c$2=$(`Generating Spring Boot project: ${r.project_name}...`).start();try{let n=(d,v)=>c$1(g.join(e,d),v),y=g.join(e,"rapidkit"),R=g.join(e,"rapidkit.cmd");if(await Promise.all([n("pom.xml",D(r)),n(".gitignore",Y()),n(".editorconfig",X()),n(".env.example",U(r)),n(".dockerignore",z()),n("Dockerfile",H()),n("docker-compose.yml",F(r)),n(".github/workflows/ci.yml",K(r)),n("README.md",Q(r)),n("src/main/resources/application.yml",J(r)),n("src/test/resources/application.yml",G()),n(`src/main/java/${o}/${l}.java`,B(r,l)),n(`src/main/java/${o}/config/ApplicationInfoProperties.java`,V(r)),n(`src/main/java/${o}/config/OpenApiConfiguration.java`,O(r)),n(`src/main/java/${o}/application/SystemInfoService.java`,q(r)),n(`src/main/java/${o}/api/http/dto/SystemInfoResponse.java`,L(r)),n(`src/main/java/${o}/api/http/SystemInfoController.java`,N(r)),n(`src/main/java/${o}/api/http/ApiExceptionHandler.java`,W(r)),n(`src/test/java/${o}/${l}Tests.java`,ne(r,l)),n(`src/test/java/${o}/api/http/SystemInfoControllerTest.java`,re(r)),n(`src/test/java/${o}/ServiceRuntimeE2ETest.java`,ie(r)),n("scripts/perf-smoke.sh",Z(r)),n(".workspai/project.json",C(r,b$2)),n(".workspai/context.json",P()),n("rapidkit",ee(r)),n("rapidkit.cmd",te())]),await promises.chmod(y,493),await promises.chmod(R,493),await promises.chmod(g.join(e,"scripts","perf-smoke.sh"),493),r.skipInstall||await oe(e)||console.log(i.yellow("\u26A0 Maven Wrapper could not be generated automatically. Run `mvn -N wrapper:wrapper -Dmaven=3.9.9` inside the project.")),c$2.succeed(i.green(`Project created at ${e}`)),r.skipInstall)c$2.info(i.gray("Skipped Maven dependency warm-up (--skip-install)."));else try{c$2.start("Resolving Maven dependencies...");let d=g.join(e,process.platform==="win32"?"mvnw.cmd":"mvnw"),v=await promises.stat(d).then(()=>d).catch(()=>"mvn");await execa(v,["-B","-q","-DskipTests","dependency:go-offline"],{cwd:e,timeout:18e4}),c$2.succeed(i.gray("\u2713 maven dependency warm-up completed"));}catch{c$2.warn(i.yellow("\u26A0 Maven dependency warm-up failed - run manually: mvn -B -DskipTests dependency:go-offline"));}if(!r.skipGit)try{await b$1(e)?console.log(i.gray("\u26A0 git init skipped (target is inside an existing git worktree)")):(await execa("git",["init"],{cwd:e,env:a()}),await execa("git",["add","-A"],{cwd:e,env:a()}),await execa("git",["commit","-m","chore: initial scaffold (rapidkit springboot.standard)"],{cwd:e,env:a()}));}catch{console.log(i.yellow("\u26A0 Git initialization failed - continuing without initial commit"));}console.log(i.green(`
692
+ `));}let c$2=R(`Generating Spring Boot project: ${r.project_name}...`).start();try{let n=(d,v)=>c$1(g.join(e,d),v),$=g.join(e,"rapidkit"),y=g.join(e,"rapidkit.cmd");if(await Promise.all([n("pom.xml",D(r)),n(".gitignore",Y()),n(".editorconfig",X()),n(".env.example",U(r)),n(".dockerignore",z()),n("Dockerfile",H(r)),n("docker-compose.yml",F(r)),n(".github/workflows/ci.yml",K(r)),n("README.md",Q(r)),n("src/main/resources/application.yml",J(r)),n("src/test/resources/application.yml",G()),n(`src/main/java/${o}/${l}.java`,B(r,l)),n(`src/main/java/${o}/config/ApplicationInfoProperties.java`,V(r)),n(`src/main/java/${o}/config/OpenApiConfiguration.java`,O(r)),n(`src/main/java/${o}/application/SystemInfoService.java`,q(r)),n(`src/main/java/${o}/api/http/dto/SystemInfoResponse.java`,L(r)),n(`src/main/java/${o}/api/http/SystemInfoController.java`,N(r)),n(`src/main/java/${o}/api/http/ApiExceptionHandler.java`,W(r)),n(`src/test/java/${o}/${l}Tests.java`,ne(r,l)),n(`src/test/java/${o}/api/http/SystemInfoControllerTest.java`,re(r)),n(`src/test/java/${o}/ServiceRuntimeE2ETest.java`,ie(r)),n("scripts/perf-smoke.sh",Z(r)),n(".workspai/project.json",C(r,b$2)),n(".workspai/context.json",P()),n("rapidkit",ee(r)),n("rapidkit.cmd",te())]),await promises.chmod($,493),await promises.chmod(y,493),await promises.chmod(g.join(e,"scripts","perf-smoke.sh"),493),r.skipInstall||await oe(e)||console.log(i.yellow("\u26A0 Maven Wrapper could not be generated automatically. Run `mvn -N wrapper:wrapper -Dmaven=3.9.9` inside the project.")),c$2.succeed(i.green(`Project created at ${e}`)),r.skipInstall)c$2.info(i.gray("Skipped Maven dependency warm-up (--skip-install)."));else try{c$2.start("Resolving Maven dependencies...");let d=g.join(e,process.platform==="win32"?"mvnw.cmd":"mvnw"),v=await promises.stat(d).then(()=>d).catch(()=>"mvn");await execa(v,["-B","-q","-DskipTests","dependency:go-offline"],{cwd:e,timeout:18e4}),c$2.succeed(i.gray("\u2713 maven dependency warm-up completed"));}catch{c$2.warn(i.yellow("\u26A0 Maven dependency warm-up failed - run manually: mvn -B -DskipTests dependency:go-offline"));}if(!r.skipGit)try{await b$1(e)?console.log(i.gray("\u26A0 git init skipped (target is inside an existing git worktree)")):(await execa("git",["init"],{cwd:e,env:a()}),await execa("git",["add","-A"],{cwd:e,env:a()}),await execa("git",["commit","-m","chore: initial scaffold (rapidkit springboot.standard)"],{cwd:e,env:a()}));}catch{console.log(i.yellow("\u26A0 Git initialization failed - continuing without initial commit"));}console.log(i.green(`
693
693
  \u2728 Spring Boot project created successfully!
694
694
  `)),console.log(i.cyan("\u{1F4C2} Location:"),i.white(e)),console.log(i.cyan(`
695
695
  \u{1F680} Get started:
@@ -0,0 +1 @@
1
+ export{h as createProject,g as createWorkspace,j as createWorkspaceShareBundle,i as listWorkspaces,a as normalizeWorkspaceEntry,f as registerProjectInWorkspace,e as registerProjectInWorkspaceStrict,c as registerWorkspace,b as registerWorkspaceStrict,d as syncWorkspaceProjects}from'./chunk-YUATNVOT.js';
@@ -1 +1 @@
1
- export{f as AGENT_CUSTOMIZATION_PACK_REPORT_PATH,d as AGENT_CUSTOMIZATION_PACK_SCHEMA,e as AGENT_REPORTS_INDEX_PATH,c as AGENT_REPORTS_INDEX_SCHEMA,g as AGENT_REPORT_CATALOG,h as buildCanonicalAgentReportReadOrder,i as buildWorkspaceAgentReportsIndex,j as parseAgentGroundingTargets,k as syncWorkspaceAgentGrounding}from'./chunk-P4SWTY5X.js';export{f as AGENT_GROUNDING_DOC_PATH,g as LEGACY_AGENT_GROUNDING_DOC_PATH,A as LEGACY_COPILOT_GROUNDING_SKILL_PATH,m as LEGACY_COPILOT_WORKSPACE_INSTRUCTIONS_PATH,C as LEGACY_COPILOT_WORKSPACE_INTELLIGENCE_SKILL_PATH,i as LEGACY_CURSOR_GROUNDING_RULE_PATH,E as LEGACY_MCP_DESIGN_REPORT_PATH,G as LEGACY_VSCODE_AGENT_HOOKS_PATH,z as WORKSPAI_COPILOT_GROUNDING_SKILL_PATH,l as WORKSPAI_COPILOT_WORKSPACE_INSTRUCTIONS_PATH,B as WORKSPAI_COPILOT_WORKSPACE_INTELLIGENCE_SKILL_PATH,h as WORKSPAI_CURSOR_GROUNDING_RULE_PATH,D as WORKSPAI_MCP_DESIGN_REPORT_PATH,F as WORKSPAI_VSCODE_AGENT_HOOKS_PATH}from'./chunk-XIVFLY6G.js';
1
+ export{f as AGENT_CUSTOMIZATION_PACK_REPORT_PATH,d as AGENT_CUSTOMIZATION_PACK_SCHEMA,e as AGENT_REPORTS_INDEX_PATH,c as AGENT_REPORTS_INDEX_SCHEMA,g as AGENT_REPORT_CATALOG,h as buildCanonicalAgentReportReadOrder,i as buildWorkspaceAgentReportsIndex,j as parseAgentGroundingTargets,k as syncWorkspaceAgentGrounding}from'./chunk-K4WNYXKK.js';export{f as AGENT_GROUNDING_DOC_PATH,g as LEGACY_AGENT_GROUNDING_DOC_PATH,A as LEGACY_COPILOT_GROUNDING_SKILL_PATH,m as LEGACY_COPILOT_WORKSPACE_INSTRUCTIONS_PATH,C as LEGACY_COPILOT_WORKSPACE_INTELLIGENCE_SKILL_PATH,i as LEGACY_CURSOR_GROUNDING_RULE_PATH,E as LEGACY_MCP_DESIGN_REPORT_PATH,G as LEGACY_VSCODE_AGENT_HOOKS_PATH,z as WORKSPAI_COPILOT_GROUNDING_SKILL_PATH,l as WORKSPAI_COPILOT_WORKSPACE_INSTRUCTIONS_PATH,B as WORKSPAI_COPILOT_WORKSPACE_INTELLIGENCE_SKILL_PATH,h as WORKSPAI_CURSOR_GROUNDING_RULE_PATH,D as WORKSPAI_MCP_DESIGN_REPORT_PATH,F as WORKSPAI_VSCODE_AGENT_HOOKS_PATH}from'./chunk-UQWOVV6V.js';
@@ -0,0 +1,10 @@
1
+ import {e,c,b as b$1,d}from'./chunk-52PBRX7F.js';import {a}from'./chunk-LG6RFLPZ.js';import {f as f$1,o,l,r}from'./chunk-5XATWNME.js';import z from'crypto';import Z from'os';import f from'path';import {once}from'events';import {createWriteStream,createReadStream}from'fs';import*as X from'readline';import {Transform,Readable}from'stream';import {pipeline}from'stream/promises';import {lookup}from'dns/promises';import N from'net';import h from'fs-extra';import*as q from'yauzl';import*as Y from'yazl';var P=".workspai/archive-manifest.json",S=".rapidkit/archive-manifest.json",he="workspai.workspace.archive",fe=300*1e3,le=5*1024*1024*1024,pe=20*1024*1024*1024,j=2e5,me=5*1024*1024*1024,ue=1e3,O=5,de=64*1024*1024;function ve(r){let t=r.toLowerCase().split("%")[0];if(N.isIPv4(t)){let e=t.split(".").map(Number);return e[0]===0||e[0]===10||e[0]===127||e[0]===169&&e[1]===254||e[0]===172&&e[1]>=16&&e[1]<=31||e[0]===192&&e[1]===168||e[0]===100&&e[1]>=64&&e[1]<=127||e[0]>=224}return N.isIPv6(t)?t==="::"||t==="::1"||t.startsWith("fc")||t.startsWith("fd")||/^fe[89ab]/.test(t)||t.startsWith("ff")||t.startsWith("::ffff:127.")||t.startsWith("::ffff:10.")||t.startsWith("::ffff:192.168."):true}async function K(r,t){let e=new URL(r);if(e.protocol!=="https:"&&e.protocol!=="http:")throw new Error(`Workspace archive URL protocol is not supported: ${e.protocol}`);if(e.protocol!=="https:"&&!t)throw new Error("Remote workspace archives require HTTPS unless private-network access is explicitly enabled.");if(e.username||e.password)throw new Error("Workspace archive URL must not contain embedded credentials.");if(t)return e;let a=e.hostname.replace(/^\[|\]$/g,"").toLowerCase();if(a==="localhost"||a.endsWith(".localhost"))throw new Error("Workspace archive URL resolves to a private or local network address.");let i=N.isIP(a)?[{address:a}]:await lookup(a,{all:true,verbatim:true});if(i.length===0||i.some(({address:s})=>ve(s)))throw new Error("Workspace archive URL resolves to a private or local network address.");return e}async function we(r,t,e){let a=await K(r,e);for(let i=0;i<=O;i+=1){let s=await fetch(a,{signal:t,redirect:"manual",credentials:"omit"});if(![301,302,303,307,308].includes(s.status))return s;let n=s.headers.get("location");if(await s.body?.cancel(),!n)throw new Error("Workspace archive redirect is missing a Location header.");if(i===O)throw new Error(`Workspace archive download exceeded ${O} redirects.`);a=await K(new URL(n,a).href,e);}throw new Error("Workspace archive redirect policy failed.")}var ye=new Set(["__pycache__",".venv","venv","node_modules",".git","dist","build","target",".pytest_cache",".mypy_cache",".ruff_cache","htmlcov",".next",".turbo",".cache"]),ge=new Set([".DS_Store","Thumbs.db",".coverage","npm-debug.log","yarn-error.log","pnpm-debug.log"]),Ee=[/^\.env$/i,/^\.env\.(?!example$|sample$|template$).+/i,/^.*\.pem$/i,/^.*\.key$/i,/^id_rsa$/i,/^id_ed25519$/i];function R(r){return r.replace(/\\/g,"/")}function G(r){return r.trim().replace(/\.workspai-archive\.zip$/i,"").replace(/\.rapidkit-archive\.zip$/i,"").replace(/\.zip$/i,"").trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,64)||"imported-workspace"}function Q(r){let t=R(r).trim();if(!t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0"))return false;let e=t.split("/").filter(Boolean);return e.length>0&&!e.some(a=>a===".."||a===".")}function ee(r){if(!Q(r))throw new Error(`Archive contains an unsafe path: ${r}`)}function Ae(r,t){let e=f.relative(t,r);return e===""||!!e&&!e.startsWith("..")&&!f.isAbsolute(e)}function ke(r,t){let a=R(r).split("/").filter(Boolean);if((a[0]===".workspai"||a[0]===".rapidkit")&&["cache","reports"].includes(a[1]||"")||a.some(s=>ye.has(s)))return true;let i=a[a.length-1]||"";return ge.has(i)||/\.(?:workspai|rapidkit)-archive\.zip$/i.test(i)||!t?.includeEnv&&Ee.some(s=>s.test(i))?true:i.endsWith(".pyc")||i.endsWith(".log")}async function*te(r,t,e){let a=(await h.readdir(t,{withFileTypes:true})).sort((i,s)=>i.name.localeCompare(s.name));for(let i of a){let s=f.join(t,i.name),n=R(f.relative(r,s));if(!(!n||ke(n,e))){if(i.isDirectory()){yield*te(r,s,e);continue}i.isFile()&&(yield {relativePath:n,fullPath:s});}}}async function Pe(r){for(let t of o(r,"workspace.json"))try{let e=await h.readJson(t);if(typeof e.workspace_name=="string"&&e.workspace_name.trim())return e.workspace_name.trim();if(typeof e.name=="string"&&e.name.trim())return e.name.trim()}catch{}return f.basename(f.resolve(r))}async function We(r){let t=await h.stat(r.fullPath),e=z.createHash("sha256"),a=0;for await(let s of createReadStream(r.fullPath)){let n=Buffer.isBuffer(s)?s:Buffer.from(s);a+=n.length,e.update(n);}let i=await h.stat(r.fullPath);if(t.size!==i.size||t.mtimeMs!==i.mtimeMs||a!==i.size)throw new Error(`Workspace file changed while preparing archive: ${r.relativePath}`);return {...r,size:a,mtimeMs:i.mtimeMs,sha256:e.digest("hex")}}async function k(r,t){r.write(t)||await once(r,"drain");}async function re(r){await new Promise((t,e)=>{r.once("error",e),r.end(t);});}async function*b(r){let t=X.createInterface({input:createReadStream(r),crlfDelay:1/0});for await(let e of t){let a=e.trim();a&&(yield JSON.parse(a));}}async function Se(r){let t=createWriteStream(r.manifestPath,{flags:"wx"});try{await k(t,`{
2
+ `);for(let[a,i]of Object.entries(r.manifestBase))await k(t,` ${JSON.stringify(a)}: ${JSON.stringify(i,null,2)},
3
+ `);await k(t,` "files": [
4
+ `);let e=true;for await(let a of b(r.spoolPath)){let{mtimeMs:i,...s}=a;await k(t,`${e?"":`,
5
+ `} ${JSON.stringify(s)}`),e=false;}await k(t,`
6
+ ]
7
+ }
8
+ `),await re(t);}catch(e){throw t.destroy(),await h.remove(r.manifestPath).catch(()=>{}),e}}async function Re(r,t){let e=[];for await(let a of b(t)){let{mtimeMs:i,...s}=a;e.push(s);}return {...r,files:e}}async function _e(r,t){try{await h.rename(r,t);}catch(e){let a=e.code;if(a!=="EEXIST"&&a!=="EPERM")throw e;await h.move(r,t,{overwrite:true});}}async function Ge(r){let t=f.resolve(r.workspacePath);if(!f$1(t))throw new Error("Workspace export requires a Workspai workspace root with .workspai-workspace or a legacy .rapidkit-workspace marker.");let e=await Pe(t),a=f.resolve(r.outputPath||`${G(e)}.workspai-archive.zip`),i={schemaVersion:b$1,version:1,kind:he,workspaceName:e,exportedAt:(r.now??new Date).toISOString(),exportedBy:"workspai",archiveFormat:r.compression==="deflate"?"zip-deflate":"zip-store",containerFormat:"zip64",compression:r.compression==="deflate"?"deflate":"store",streaming:true,security:{envFilesIncluded:r.includeEnv===true,excludedByDefault:[".git","node_modules",".venv","dist","build","target",".env","*.pem","*.key","*.log"]}},s=f.resolve(a);await h.ensureDir(f.dirname(a));let n=`${a}.${process.pid}.${z.randomUUID()}.tmp`,o=await h.mkdtemp(f.join(Z.tmpdir(),"workspai-archive-export-")),p=f.join(o,"manifest-files.jsonl"),l=f.join(o,"archive-manifest.json"),u=new Y.ZipFile,y=r.now??new Date,c$1=r.compression==="deflate";try{let m=createWriteStream(p,{flags:"wx"});try{for await(let d of te(t,t,{includeEnv:r.includeEnv===true})){if(f.resolve(d.fullPath)===s)continue;let v=await We(d),E={path:v.relativePath,size:v.size,sha256:v.sha256,mtimeMs:v.mtimeMs};await k(m,`${JSON.stringify(E)}
9
+ `);}await re(m);}catch(d){throw m.destroy(),d}await Se({manifestBase:i,spoolPath:p,manifestPath:l});for await(let d of b(p)){let v=f.join(t,...d.path.split("/"));u.addFile(v,d.path,{compress:c$1,forceZip64Format:d.size>=4294967295,mtime:y});}u.addFile(l,P,{compress:c$1,mtime:y}),u.end({forceZip64Format:true,comment:""}),await pipeline(u.outputStream,createWriteStream(n,{flags:"wx"}));for await(let d of b(p)){let v=f.join(t,...d.path.split("/")),E=await h.stat(v);if(E.size!==d.size||E.mtimeMs!==d.mtimeMs)throw new Error(`Workspace file changed while writing archive: ${d.path}`)}let g=await h.stat(n);await _e(n,a);let w=await Re(i,p);return _({schemaVersion:c,operation:"export",status:"passed",archivePath:a,manifest:w,bytesWritten:g.size})}finally{await h.remove(o).catch(()=>{}),await h.remove(n).catch(()=>{});}}async function ae(r,t={}){if(/^https?:\/\//i.test(r)){let e=await h.mkdtemp(f.join(Z.tmpdir(),"workspai-workspace-archive-")),a=f.join(e,"workspace.workspai-archive.zip"),i=new AbortController,s=t.downloadTimeoutMs??fe,n=s>0?setTimeout(()=>i.abort(new Error("Download timed out")),s):null;try{let o=await we(r,i.signal,t.allowPrivateNetwork===true);if(!o.ok)throw new Error(`Failed to download workspace archive: HTTP ${o.status}`);if(!o.body)throw new Error("Failed to download workspace archive: response body is empty.");let p=t.maxDownloadBytes??le,l=Number(o.headers.get("content-length"));if(Number.isFinite(l)&&l>p)throw new Error(`Workspace archive download exceeds configured limit (${l} > ${p} bytes).`);let u=0,y=new Transform({transform(m,g,w){if(u+=m.length,u>p){w(new Error(`Workspace archive download exceeds configured limit (${p} bytes).`));return}w(null,m);}}),c=Readable.fromWeb(o.body);return await pipeline(c,y,createWriteStream(a,{flags:"wx"})),{archivePath:a,cleanup:e}}catch(o){throw await h.remove(e).catch(()=>{}),i.signal.aborted?new Error(`Workspace archive download timed out after ${s}ms.`,{cause:o}):o}finally{n&&clearTimeout(n);}}return {archivePath:f.resolve(r)}}function be(r){return new Promise((t,e)=>{q.open(r,{autoClose:false,lazyEntries:true,decodeStrings:true,validateEntrySizes:true,strictFileNames:true},(a,i)=>{a||!i?e(a??new Error("Failed to open workspace archive.")):t(i);});})}function ze(r){return new Promise((t,e)=>{let a=[],i=s=>e(s);r.once("error",i),r.on("entry",s=>{try{if(ee(s.fileName),s.isEncrypted())throw new Error(`Encrypted workspace archive entries are not supported: ${s.fileName}`);s.fileName.endsWith("/")||a.push({name:s.fileName,size:s.uncompressedSize,compressedSize:s.compressedSize,crc32:s.crc32,entry:s}),r.readEntry();}catch(n){e(n);}}),r.once("end",()=>{r.removeListener("error",i),t(a);}),r.readEntry();})}function M(r,t){return new Promise((e,a)=>{r.openReadStream(t,(i,s)=>{i||!s?a(i??new Error(`Failed to read ${t.fileName}.`)):e(s);});})}async function xe(r,t,e=de){if(t.size>e)throw new Error(`Workspace archive manifest exceeds ${e} bytes.`);let a=[],i=0,s=await M(r,t.entry);for await(let n of s){let o=Buffer.isBuffer(n)?n:Buffer.from(n);if(i+=o.length,i>e)throw s.destroy(),new Error(`Workspace archive manifest exceeds ${e} bytes.`);a.push(o);}return Buffer.concat(a,i)}function Oe(r){let t=JSON.parse(r.toString("utf-8"));a(t,d,"Workspace archive manifest");let e=new Set;for(let a of t.files){if(!Q(a.path)||R(a.path)!==a.path)throw new Error(`Workspace archive manifest contains an unsafe path: ${a.path}`);if(a.path===P||a.path===S)throw new Error(`Workspace archive manifest cannot inventory itself: ${a.path}`);if(e.has(a.path))throw new Error(`Workspace archive manifest contains duplicate path: ${a.path}`);e.add(a.path);}return t}function _(r){return a(r,e,"Workspace archive operation result"),r}function Ne(r$1){return r(R(r$1))}function Ce(r){let t=new Map;for(let e of r){if(e.name===P||e.name===S)continue;let a=Ne(e.name),i=t.get(a);if(!i){t.set(a,{...e,sourceName:e.name,targetName:a});continue}let s=e.name===a,n=i.sourceName===i.targetName;if(s&&!n){t.set(a,{...e,sourceName:e.name,targetName:a});continue}if(!(i.size===e.size&&i.crc32===e.crc32)&&!n)throw new Error(`Workspace archive contains conflicting entries for ${a}: ${i.sourceName}, ${e.name}`)}return [...t.values()].sort((e,a)=>e.targetName.localeCompare(a.targetName))}async function $(r,t={}){let e=await ae(r,t),a;try{a=await be(e.archivePath);let i=await ze(a);if(i.length>j)throw new Error(`Workspace archive contains too many entries (${i.length} > ${j}).`);for(let l of i){if(l.size>me)throw new Error(`Workspace archive entry is too large: ${l.name}`);if(l.size/Math.max(1,l.compressedSize)>ue)throw new Error(`Workspace archive entry has an unsafe compression ratio: ${l.name}`)}let s=i.reduce((l,u)=>l+u.size,0),n=t.maxExpandedBytes??pe;if(s>n)throw new Error(`Workspace archive payload exceeds configured limit (${s} > ${n} bytes).`);let o=i.find(l=>l.name===P||l.name===S);if(!o)throw new Error(`Workspace archive is missing ${l("","archive-manifest.json").replace(/^\//,"")}.`);let p=Oe(await xe(a,o));return {archivePath:e.archivePath,entries:i,manifest:p,zipFile:a,cleanup:e.cleanup}}catch(i){throw a?.close(),e.cleanup&&await h.remove(e.cleanup).catch(()=>{}),i}}async function T(r){r.zipFile?.close(),r.cleanup&&await h.remove(r.cleanup).catch(()=>{});}async function Me(r){let t=await $(r.archivePathOrUrl,r.safety);try{let e=new Map(t.entries.filter(i=>i.name!==P&&i.name!==S).map(i=>[i.name,i])),a=t.manifest.files.map(i=>({path:i.path,size:e.get(i.path)?.size??i.size,hasChecksum:typeof i.sha256=="string"&&i.sha256.length>0}));return _({schemaVersion:c,operation:"inspect",status:"passed",archivePath:t.archivePath,manifest:t.manifest,fileCount:a.length,totalBytes:a.reduce((i,s)=>i+s.size,0),entries:a})}finally{await T(t);}}async function ie(r){let t=await $(r.archivePathOrUrl,r.safety);try{let e=new Map(t.entries.filter(c=>c.name!==P&&c.name!==S).map(c=>[c.name,c])),a=new Set(t.manifest.files.map(c=>c.path)),i=[...e.keys()].filter(c=>!a.has(c)).sort(),s=[],n=[],o=[],p=0;for(let c of t.manifest.files){ee(c.path);let m=e.get(c.path);if(!m){s.push(c.path);continue}let g=z.createHash("sha256"),w=0,d=await M(t.zipFile,m.entry);for await(let E of d){let I=Buffer.isBuffer(E)?E:Buffer.from(E);w+=I.length,g.update(I);}let v={size:w,sha256:g.digest("hex")};if(w!==m.size||w!==c.size){o.push({path:c.path,expected:{size:c.size,sha256:c.sha256},actual:v});continue}if(!c.sha256){n.push(c.path);continue}if(v.sha256!==c.sha256){o.push({path:c.path,expected:{size:c.size,sha256:c.sha256},actual:v});continue}p+=1;}let l=r.requireChecksums===true&&n.length>0,u=s.length>0||o.length>0||l||i.length>0,y=n.length>0;return _({schemaVersion:c,operation:"verify",archivePath:t.archivePath,manifest:t.manifest,status:u?"failed":y?"warning":"passed",fileCount:t.manifest.files.length,totalBytes:t.manifest.files.reduce((c,m)=>c+m.size,0),verifiedFiles:p,missingChecksumFiles:n,missingArchiveEntries:s,extraArchiveEntries:i,mismatches:o})}finally{await T(t);}}async function Qe(r){let t=await ae(r.archivePathOrUrl,r.safety);try{return await $e({archivePath:t.archivePath,strict:r.strict})}finally{t.cleanup&&await h.remove(t.cleanup).catch(()=>{});}}async function $e(r){let t=await Me({archivePathOrUrl:r.archivePath}),e=await ie({archivePathOrUrl:r.archivePath,requireChecksums:r.strict===true}),a=[],i=[];a.push({id:"manifest-present",status:"passed",message:`Archive manifest found for workspace "${t.manifest.workspaceName}".`}),a.push({id:"integrity",status:e.status,message:e.status==="passed"?`Verified ${e.verifiedFiles}/${e.fileCount} files.`:"Archive integrity verification did not fully pass."});let s=t.manifest.security?.envFilesIncluded===true;a.push({id:"secrets-policy",status:s?"warning":"passed",message:s?"Archive manifest says environment/private files were intentionally included.":"Archive manifest excludes environment/private files by default."}),s&&i.push("Share this archive only through trusted internal channels."),e.missingChecksumFiles.length>0&&i.push("Re-export the archive with the latest RapidKit/Workspai tooling."),e.mismatches.length>0&&i.push("Reject this archive and request a fresh export from the owner."),(e.extraArchiveEntries.length>0||e.missingArchiveEntries.length>0)&&i.push("Regenerate the archive so ZIP entries and manifest entries match."),r.strict===true&&e.status!=="passed"&&i.push("Do not hydrate this archive in strict or production workflows.");let n=a.some(p=>p.status==="failed"),o=a.some(p=>p.status==="warning");return _({schemaVersion:c,operation:"doctor",archivePath:t.archivePath,status:n?"failed":o?"warning":"passed",workspaceName:t.manifest.workspaceName,fileCount:t.fileCount,totalBytes:t.totalBytes,checks:a,recommendedActions:i})}async function Te(r,t){let e=await h.lstat(r).catch(i=>{if(i.code==="ENOENT")return null;throw i});if(!e)return false;if(e.isSymbolicLink())throw new Error(`Output directory must not be a symbolic link: ${r}`);if(!e.isDirectory())throw new Error(`Output path is not a directory: ${r}`);if((await h.readdir(r)).length>0&&!t)throw new Error(`Output directory is not empty: ${r}. Use --force to overwrite.`);return true}async function et(r){let t=await $(r.archivePathOrUrl,r.safety);try{let e=await ie({archivePathOrUrl:t.archivePath,requireChecksums:r.strict===true});if(e.status==="failed"){let o=[e.missingArchiveEntries.length?`missing entries: ${e.missingArchiveEntries.join(", ")}`:"",e.extraArchiveEntries.length?`unexpected entries: ${e.extraArchiveEntries.join(", ")}`:"",e.mismatches.length?`checksum/size mismatches: ${e.mismatches.map(p=>p.path).join(", ")}`:"",e.missingChecksumFiles.length&&r.strict===true?`missing checksums: ${e.missingChecksumFiles.join(", ")}`:""].filter(Boolean).join("; ");throw new Error(`Workspace archive verification failed${o?` (${o})`:""}.`)}if(e.status==="warning"&&r.strict===true)throw new Error(`Workspace archive verification requires checksums for every file: ${e.missingChecksumFiles.join(", ")}`);let a=Ce(t.entries),i=t.manifest,s=f.resolve(r.outputPath||G(i.workspaceName||"imported-workspace")),n=await Te(s,r.force===true);if(!r.dryRun){let o=f.dirname(s),p=`${process.pid}-${z.randomUUID()}`,l=f.join(o,`.${f.basename(s)}.hydrate-${p}.tmp`),u=f.join(o,`.${f.basename(s)}.hydrate-${p}.backup`),y=false,c=false;await h.ensureDir(o);try{await h.ensureDir(l);for(let m of a){let g=f.resolve(l,m.targetName);if(!Ae(g,l))throw new Error(`Archive entry escapes output directory: ${m.targetName}`);await h.ensureDir(f.dirname(g));let w=await M(t.zipFile,m.entry);await pipeline(w,createWriteStream(g,{flags:"wx"}));}n&&(await h.rename(s,u),y=true),await h.rename(l,s),c=true,y&&await h.remove(u).catch(()=>{});}catch(m){throw y&&!await h.pathExists(s)&&await h.rename(u,s).catch(()=>{}),m}finally{await h.remove(l).catch(()=>{}),c&&await h.remove(u).catch(()=>{});}}return _({schemaVersion:c,operation:"hydrate",status:"passed",archivePath:t.archivePath,outputPath:s,dryRun:r.dryRun===true,manifest:i,files:a.map(o=>({path:o.targetName,size:o.size}))})}finally{await T(t);}}
10
+ export{he as WORKSPACE_ARCHIVE_KIND,P as WORKSPACE_ARCHIVE_MANIFEST_PATH,K as assertSafeRemoteArchiveUrl,Qe as doctorWorkspaceArchive,Ge as exportWorkspaceArchive,et as hydrateWorkspaceArchive,Me as inspectWorkspaceArchive,ve as isPrivateAddress,Q as isSafeArchiveEntryName,G as sanitizeWorkspaceArchiveName,ke as shouldExcludeWorkspaceArchivePath,ie as verifyWorkspaceArchive};
@@ -1 +1 @@
1
- export{d as WORKSPACE_CONTEXT_AGENT_REPORT_PATH,c as WORKSPACE_CONTEXT_SCHEMA_VERSION,e as buildWorkspaceAgentContext,f as writeWorkspaceAgentContext}from'./chunk-V5JN4TDX.js';
1
+ export{d as WORKSPACE_CONTEXT_AGENT_REPORT_PATH,c as WORKSPACE_CONTEXT_SCHEMA_VERSION,e as buildWorkspaceAgentContext,f as writeWorkspaceAgentContext}from'./chunk-EFYHGCGX.js';
@@ -0,0 +1 @@
1
+ export{b as WORKSPACE_CONTRACT_PATH,d as WORKSPACE_CONTRACT_SCHEMA_VERSION,c as WORKSPACE_CONTRACT_VERIFY_REPORT_PATH,e as WORKSPACE_CONTRACT_VERIFY_SCHEMA_VERSION,f as WorkspaceContractVerificationError,h as buildWorkspaceContract,l as buildWorkspaceContractGraph,g as discoverProjectJsonFiles,k as readWorkspaceContract,j as syncWorkspaceContract,m as verifyWorkspaceContract,i as writeWorkspaceContract,n as writeWorkspaceContractVerifyEvidence}from'./chunk-WYFPXTTS.js';
@@ -0,0 +1 @@
1
+ export{b as buildWorkspaceExplain,a as resolveWorkspaceExplainArtifactPath,c as writeWorkspaceExplainReport}from'./chunk-QZLIURER.js';export{e as WORKSPACE_MODEL_DIFF_REPORT_PATH}from'./chunk-FWRXA435.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-UQWOVV6V.js';
@@ -0,0 +1 @@
1
+ export{a as WORKSPACE_EXPLAIN_SCHEMA_VERSION,b as WORKSPACE_EXPLAIN_TARGETS,e as isWorkspaceExplainReport,c as parseWorkspaceExplainTarget,d as resolveWorkspaceTraceTarget}from'./chunk-4LGXSBCN.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-UQWOVV6V.js';
@@ -1 +1 @@
1
- import {b}from'./chunk-ICGWHIMK.js';import {b as b$1,f,j}from'./chunk-L2Q7B2OJ.js';import o from'path';async function m(r){let t=o.resolve(r.workspacePath),n=b(r.payload);if(!n)return {ok:false,error:"Invalid agent-action-outcome payload",historyPath:o.join(t,b$1)};let c=f(n),p=o.join(t,b$1);return await j(t,c,{retention:r.retention}),{ok:true,entry:c,historyPath:p}}function l(r){let t=r.trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}async function h(){let r=[];for await(let t of process.stdin)r.push(typeof t=="string"?Buffer.from(t):t);return Buffer.concat(r).toString("utf8")}export{l as parseFeedbackStdinPayload,h as readStdinAll,m as recordWorkspaceFeedback};
1
+ import {b}from'./chunk-ICGWHIMK.js';import {b as b$1,f,j}from'./chunk-SXMTSV5M.js';import o from'path';async function m(r){let t=o.resolve(r.workspacePath),n=b(r.payload);if(!n)return {ok:false,error:"Invalid agent-action-outcome payload",historyPath:o.join(t,b$1)};let c=f(n),p=o.join(t,b$1);return await j(t,c,{retention:r.retention}),{ok:true,entry:c,historyPath:p}}function l(r){let t=r.trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}async function h(){let r=[];for await(let t of process.stdin)r.push(typeof t=="string"?Buffer.from(t):t);return Buffer.concat(r).toString("utf8")}export{l as parseFeedbackStdinPayload,h as readStdinAll,m as recordWorkspaceFeedback};
@@ -1 +1 @@
1
- import {b}from'./chunk-OW4UNG27.js';import {a}from'./chunk-GSWPGELT.js';import c from'path';import u from'fs-extra';async function W(t,r){let o=await a(t),d=o?.name||c.basename(t),n,i=c.join(t,".python-version");if(await u.pathExists(i)){let a=(await u.readFile(i,"utf-8")).trim();a&&(n=a);}let e=r?.profile||"polyglot",m=e==="python-only"||e==="polyglot"||e==="enterprise",f=r?.installMethod||o?.metadata?.npm?.installMethod||(m?"poetry":"venv"),s=await b(t,{workspaceName:d,installMethod:f,pythonVersion:n,profile:e,writeMarker:true,writeGitignore:true,onlyIfMissing:!r?.force}),{publishWorkspaceRegistrySummary:y}=await import('./workspace-registry-summary-S52SEJAG.js');return await y(t),{workspacePath:t,created:s,status:s.length>0?"passed":"skipped"}}export{W as ensureWorkspaceFoundation};
1
+ import {b}from'./chunk-J5PIZCAU.js';import {a}from'./chunk-GSWPGELT.js';import c from'path';import u from'fs-extra';async function W(t,r){let o=await a(t),d=o?.name||c.basename(t),n,i=c.join(t,".python-version");if(await u.pathExists(i)){let a=(await u.readFile(i,"utf-8")).trim();a&&(n=a);}let e=r?.profile||"polyglot",m=e==="python-only"||e==="polyglot"||e==="enterprise",f=r?.installMethod||o?.metadata?.npm?.installMethod||(m?"poetry":"venv"),s=await b(t,{workspaceName:d,installMethod:f,pythonVersion:n,profile:e,writeMarker:true,writeGitignore:true,onlyIfMissing:!r?.force}),{publishWorkspaceRegistrySummary:y}=await import('./workspace-registry-summary-SZ46R5PD.js');return await y(t),{workspacePath:t,created:s,status:s.length>0?"passed":"skipped"}}export{W as ensureWorkspaceFoundation};
@@ -1 +1 @@
1
- export{c as DEFAULT_HISTORY_RETENTION,b as WORKSPACE_HISTORY_PATH,a as WORKSPACE_HISTORY_SCHEMA_VERSION,i as appendHistoryEntry,f as historyEntryFromAgentAction,g as historyEntryFromDoctorFixResult,e as historyEntryFromVerify,d as normalizeHistoryEntry,h as readWorkspaceHistory,j as recordWorkspaceHistory}from'./chunk-L2Q7B2OJ.js';
1
+ export{c as DEFAULT_HISTORY_RETENTION,b as WORKSPACE_HISTORY_PATH,a as WORKSPACE_HISTORY_SCHEMA_VERSION,i as appendHistoryEntry,f as historyEntryFromAgentAction,g as historyEntryFromDoctorFixResult,e as historyEntryFromVerify,d as normalizeHistoryEntry,h as readWorkspaceHistory,j as recordWorkspaceHistory}from'./chunk-SXMTSV5M.js';
@@ -1 +1 @@
1
- export{g as WORKSPACE_IMPACT_REPORT_PATH,f as WORKSPACE_IMPACT_SCHEMA_VERSION,e as WORKSPACE_MODEL_DIFF_REPORT_PATH,c as WORKSPACE_MODEL_DIFF_SCHEMA_VERSION,d as WORKSPACE_MODEL_SNAPSHOT_REPORT_PATH,b as WORKSPACE_MODEL_SNAPSHOT_SCHEMA_VERSION,p as buildWorkspaceImpact,k as buildWorkspaceModelSnapshot,m as diffWorkspaceModel,j as hashWorkspaceModel,h as isGitDiffSource,i as parseGitDiffRef,o as workspaceVerificationPlan,q as writeWorkspaceImpact,n as writeWorkspaceModelDiff,l as writeWorkspaceModelSnapshot}from'./chunk-VA5MRHKM.js';
1
+ export{g as WORKSPACE_IMPACT_REPORT_PATH,f as WORKSPACE_IMPACT_SCHEMA_VERSION,e as WORKSPACE_MODEL_DIFF_REPORT_PATH,c as WORKSPACE_MODEL_DIFF_SCHEMA_VERSION,d as WORKSPACE_MODEL_SNAPSHOT_REPORT_PATH,b as WORKSPACE_MODEL_SNAPSHOT_SCHEMA_VERSION,p as buildWorkspaceImpact,k as buildWorkspaceModelSnapshot,m as diffWorkspaceModel,j as hashWorkspaceModel,h as isGitDiffSource,i as parseGitDiffRef,o as workspaceVerificationPlan,q as writeWorkspaceImpact,n as writeWorkspaceModelDiff,l as writeWorkspaceModelSnapshot}from'./chunk-FWRXA435.js';
@@ -0,0 +1 @@
1
+ import {a as a$2}from'./chunk-RIEF2DDX.js';import {q as q$2}from'./chunk-VFDM65IE.js';import {b as b$1,c}from'./chunk-QZLIURER.js';import {d}from'./chunk-YUATNVOT.js';import {a as a$3}from'./chunk-HMUKBW2S.js';import {k as k$1}from'./chunk-K4WNYXKK.js';import {f,g as g$1,h as h$1}from'./chunk-V3LRQZ36.js';import {k,l,m,n as n$1,p,q as q$1}from'./chunk-FWRXA435.js';import {j as j$1,e}from'./chunk-SXMTSV5M.js';import {a as a$1,e as e$1,f as f$1}from'./chunk-EFYHGCGX.js';import {n,q}from'./chunk-CVHMUSRX.js';import {j,m as m$1,n as n$2}from'./chunk-WYFPXTTS.js';import {g,b as b$2}from'./chunk-HDURFXW5.js';import {a,b,h,i,g as g$2,f as f$2}from'./chunk-N7DV5L7C.js';import se from'path';import ce from'fs-extra';function r(a,t){if(!a)throw new Error(`Workspace Intelligence run semantic violation: ${t}`)}function ee(a,t){return a.length===t.length&&a.every((d,l)=>d===t[l])}function te(a$2){b$2(a.intelligenceRun,a$2,"Workspace Intelligence run report"),r(a$2.chainSchemaVersion===a$1,`chainSchemaVersion must be ${a$1}`),r(a$2.artifactPath===a.intelligenceRun,`artifactPath must be ${a.intelligenceRun}`),r(a$2.preflight.length===g$2.length,`preflight must contain exactly ${g$2.length} entries`);for(let[o,i]of g$2.entries()){let s=a$2.preflight[o];r(s?.id===i,`preflight[${o}].id must be ${i}`),r(ee(s.artifacts,h[i]),`${i} preflight artifacts must match the runtime registry`),i==="sync"?r(s.status==="passed"&&s.result==="synchronized"||s.status==="failed"&&s.result==="failed","sync preflight status and result are incoherent"):r(s.status==="passed"&&(s.result==="created"||s.result==="reused")||s.status==="failed"&&s.result==="failed"||s.status==="skipped"&&s.result==="skipped","baseline preflight status and result are incoherent");}let t=a$2.preflight[1];r(a$2.baselineCreated===(t?.result==="created"),"baselineCreated must match the baseline preflight result"),r(a$2.stages.length===f$2.length,`stages must contain exactly ${f$2.length} canonical steps`);let d=a$2.preflight[0],l=d?.status==="failed";for(let[o,i$1]of f$2.entries()){let s=a$2.stages[o];r(s?.id===i$1,`stages[${o}].id must be ${i$1}`),r(ee(s.artifacts,i[i$1].produces),`${i$1} artifacts must match the runtime registry`),l&&r(s.status==="skipped",`${i$1} must be skipped after a hard failure`),s.status==="passed"?r(s.exitCode===0,`${i$1} passed stage must have exitCode 0`):s.status==="blocked"?r(s.exitCode!==0,`${i$1} blocked stage must have a non-zero exitCode`):s.status==="failed"?(r(s.exitCode===1,`${i$1} failed stage must have exitCode 1`),l=true):(r(s.exitCode===0,`${i$1} skipped stage must have exitCode 0`),r(s.durationMs===0,`${i$1} skipped stage must have durationMs 0`)),o===0&&((d?.status==="failed"||s.status==="failed")&&r(t?.status==="skipped","baseline must be skipped when sync or model fails"),t?.status==="skipped"&&r(d?.status==="failed"||s.status==="failed"||s.status==="skipped","baseline may be skipped only after an upstream failure"),t?.status!=="passed"&&(l=true));}let m=a$2.preflight.some(o=>o.status==="failed")||a$2.stages.some(o=>o.status==="failed"),E=a$2.stages.some(o=>o.status==="blocked"),n=m?"failed":E?"blocked":"passed",u=n==="failed"?1:n==="blocked"?2:0;r(a$2.status===n,`status must be ${n}`),r(a$2.exitCode===u,`exitCode must be ${u}`);}var le=a.intelligenceRun,de=b.intelligenceRun,ae=le;async function $e(a$4){let t=se.resolve(a$4.workspacePath),d$1=[],l$1=[],m$2=false,E=async(e,p)=>{let f=[...h[e]];if(m$2){d$1.push({id:e,status:"skipped",result:"skipped",durationMs:0,artifacts:f,message:"skipped because a required upstream operation failed"});return}let k=Date.now();try{let c=await p();d$1.push({id:e,status:"passed",result:c.result,durationMs:Date.now()-k,artifacts:f,message:c.message});}catch(c){m$2=true,d$1.push({id:e,status:"failed",result:"failed",durationMs:Date.now()-k,artifacts:f,message:c instanceof Error?c.message:String(c)});}},n$3=async(e,p)=>{let f=[...i[e].produces];if(m$2){l$1.push({id:e,status:"skipped",durationMs:0,artifacts:f,exitCode:0,message:"skipped because a required upstream stage failed"});return}let k=Date.now();try{let c=await p(),b=c.exitCode??0;l$1.push({id:e,status:c.blocked||b!==0?"blocked":"passed",durationMs:Date.now()-k,artifacts:f,exitCode:b,message:c.message});}catch(c){m$2=true,l$1.push({id:e,status:"failed",durationMs:Date.now()-k,artifacts:f,exitCode:1,message:c instanceof Error?c.message:String(c)});}};await E("sync",async()=>{let e=await d(t,true),p=await j({workspacePath:t});return {result:"synchronized",message:`registry ${e.added.length} added/${e.skipped} existing; contract ${p.contract.projects.length} projects`}});let u,o=()=>{if(!u)throw new Error("canonical workspace model is unavailable");return u};await n$3("model",async()=>(u=await n({workspacePath:t,includeEvidence:true}),await q(u,t),{message:`${u.summary.projectCount} projects modeled`}));let i$1=se.join(t,a.snapshot),s=false;await E("baseline",async()=>{if(!await ce.pathExists(i$1)){let e=await k({workspacePath:t,model:o()});return await l(e,t),s=true,{result:"created",message:"initial structural baseline created"}}return {result:"reused",message:"existing structural baseline reused"}}),await n$3("diff",async()=>{let e=await m({workspacePath:t,fromPath:a.snapshot,model:o()});return await n$1(e,t),{message:e.summary.changed?"workspace changes detected":"no workspace changes"}}),await n$3("impact",async()=>{let e=await p({workspacePath:t,fromPath:a.diff});return await q$1(e,t),{message:`${e.summary.risk} risk; ${e.summary.affectedProjects} affected`}}),await n$3("doctor-evidence",async()=>{let e=await q$2({workspace:t,json:true,quiet:true});return {exitCode:e,blocked:e!==0,message:`doctor exit ${e}`}}),await n$3("contract-evidence",async()=>{let e=await m$1({workspacePath:t,strict:true});return await n$2({workspacePath:t,result:e}),{exitCode:e.status==="passed"?0:1,blocked:e.status!=="passed",message:`contract ${e.status}`}}),await n$3("analyze-evidence",async()=>{let e=await a$2({workspacePath:t,json:true,strict:false});return {blocked:e.summary.verdict==="blocked"||a$4.strict===true&&e.summary.verdict==="needs-attention",exitCode:e.summary.verdict==="blocked"||a$4.strict===true&&e.summary.verdict==="needs-attention"?1:0,message:`analyze ${e.summary.verdict} (${e.summary.score}/100)`}}),await n$3("readiness-evidence",async()=>{let e=await a$3({startPath:t,writeReport:true,skipVerify:true});return {blocked:e.overallStatus==="fail"||a$4.strict===true&&e.overallStatus==="warn",exitCode:e.overallStatus==="fail"||a$4.strict===true&&e.overallStatus==="warn"?1:0,message:`pre-verify readiness ${e.overallStatus}`}}),await n$3("verify",async()=>{let e$1=await f({workspacePath:t,fromImpactPath:a.impact});await g$1(e$1,t);let p=h$1(e$1,{strict:a$4.strict===true});return await j$1(t,e(e$1,p.passed)),{blocked:!p.passed,exitCode:p.exitCode,message:`${e$1.summary.verdict}; gate ${p.passed?"passed":"blocked"}`}}),await n$3("context",async()=>{u=await n({workspacePath:t,includeEvidence:true});let e=await e$1({workspacePath:t,model:u,agent:a$4.agent??"generic",includeEvidence:true});return await f$1(e,t),{message:`context grounded for ${e.agent}`}}),await n$3("agent-sync",async()=>({message:`${(await k$1({workspacePath:t,agent:a$4.agent??"generic",write:true,refreshContext:false,strict:false,preset:"enterprise"})).writtenFiles.length} grounding files written`})),await n$3("explain",async()=>{let e=await b$1({workspacePath:t,target:{kind:"release-blocked"}});return await c(e,t),{message:e.summary}});let re=l$1.some(e=>e.status==="blocked"),W=m$2?"failed":re?"blocked":"passed",ie=m$2?1:W==="blocked"?2:0,R={schemaVersion:de,chainSchemaVersion:a$1,generatedAt:new Date().toISOString(),workspacePath:t,baselineCreated:s,preflight:d$1,status:W,exitCode:ie,stages:l$1,artifactPath:ae};return te(R),await g(t,ae,R),R}export{le as WORKSPACE_INTELLIGENCE_RUN_REPORT_PATH,de as WORKSPACE_INTELLIGENCE_RUN_SCHEMA_VERSION,$e as runWorkspaceIntelligenceChain};
@@ -1,3 +1,3 @@
1
- import {b}from'./chunk-TRMDODFM.js';import {d}from'./chunk-V5JN4TDX.js';import {d as d$1}from'./chunk-UNF72FTB.js';import {c as c$1,e}from'./chunk-J4AICQFB.js';import {c as c$2,b as b$2}from'./chunk-XIVFLY6G.js';import {k}from'./chunk-JICOD2GI.js';import {c as c$3}from'./chunk-2QN6BMM7.js';import {f}from'./chunk-FWJV7CCI.js';import {a as a$1}from'./chunk-LG6RFLPZ.js';import {a,c}from'./chunk-5AKYMAIL.js';import {r}from'./chunk-5XATWNME.js';import m from'path';import v from'readline';import b$1 from'fs-extra';var W=a.agentIndex,I=new Map(Object.keys(a).flatMap(e=>{let t=c[e];return t?[[a[e],t]]:[]}));function N(e,t){return e.kind!==t.kind?false:e.kind==="project"&&t.kind==="project"?e.project.toLowerCase()===t.project.toLowerCase():e.kind==="blocker"&&t.kind==="blocker"?e.blockerId===t.blockerId:e.kind==="trace"&&t.kind==="trace"?e.diffRef===t.diffRef:true}var L=[{name:"getWorkspaceModel",description:"Read workspace-model.json",inputSchema:{type:"object",properties:{}}},{name:"getEvidenceIndex",description:"Read agent reports INDEX.json",inputSchema:{type:"object",properties:{}}},{name:"getBlockers",description:"Aggregate blocking reasons from verify, explain, and contract-verify reports",inputSchema:{type:"object",properties:{}}},{name:"getSafeCommands",description:"Read safe commands from workspace-context-agent.json",inputSchema:{type:"object",properties:{}}},{name:"getProjectContext",description:"Read scoped project context from workspace-context-agent.json",inputSchema:{type:"object",properties:{project:{type:"string",description:"Optional project name; defaults to active scope"}}}},{name:"getArtifact",description:"Read one workspace-relative artifact path",inputSchema:{type:"object",properties:{relativePath:{type:"string"}},required:["relativePath"]}},{name:"listOperationalSkills",description:"Read workspace-skills-index.json",inputSchema:{type:"object",properties:{}}},{name:"getWorkspaceExplain",description:"Build or read workspace explain report",inputSchema:{type:"object",properties:{target:{type:"string",description:"release-blocked | project:<name> | blocker:<id> | trace:<diffRef> | <project>"}}}}];function M(e){let t=e.trim().replace(/\\/g,"/");return t.length>0&&!m.isAbsolute(t)&&!t.split("/").includes("..")&&(t.startsWith(".workspai/")||t.startsWith(".rapidkit/"))}async function l(e,t){if(!M(t))throw new Error(`Unsafe artifact path: ${t}`);let i=await f(e,t)??m.join(e,t);if(!await b$1.pathExists(i))return null;let r$1=await b$1.readJson(i),s=r(t),a=I.get(s);return a&&a$1(r$1,a,`MCP artifact ${s}`),r$1}async function J(e$1){let t=[],i=new Set,s=((await l(e$1,d$1))?.blockingReasons??[]).filter(n=>typeof n=="string"&&n.trim().length>0);if(s.length>0){t.push({artifact:d$1,reasons:s});for(let n of s)i.add(n);}let a=await l(e$1,c$2);if(e(a)){let n=(a.blockingReasons??[]).filter(o=>typeof o=="string"&&o.trim().length>0);if(n.length>0){t.push({artifact:c$2,reasons:n});for(let o of n)i.add(o);}}let c=await l(e$1,c$3),p=(c?.violations??[]).filter(n=>typeof n=="string"&&n.trim().length>0);if(p.length>0||String(c?.status??"").toLowerCase()==="failed"){let n=p.length>0?p:["Workspace contract verification failed"];t.push({artifact:c$3,reasons:n});for(let o of n)i.add(o);}return {blockingReasons:[...i],sources:t}}async function O(e$1,t,i){switch(t){case "getWorkspaceModel":return l(e$1,k);case "getEvidenceIndex":return l(e$1,W);case "getBlockers":return J(e$1);case "getSafeCommands":return {safeCommands:(await l(e$1,d))?.safeCommands??[]};case "getProjectContext":{let r=await l(e$1,d);if(!r)return null;let s=String(i.project??"").trim(),a=r.scope?.activeProject??void 0,c=s||a,p=Array.isArray(r.projects)?r.projects:[],n=c&&p.find(o=>typeof o.name=="string"&&o.name.toLowerCase()===c.toLowerCase());return {workspace:r.workspace??null,scope:r.scope??null,validation:r.validation??null,project:n??null,safeCommands:r.safeCommands??[]}}case "getArtifact":{let r=String(i.relativePath??"").trim();return l(e$1,r)}case "listOperationalSkills":return l(e$1,b$2);case "getWorkspaceExplain":{let r=String(i.target??"release-blocked").trim(),s=c$1(r);if(!s)throw new Error(`Invalid explain target: ${r}`);let a=await l(e$1,c$2);return e(a)&&N(a.target,s)?a:b({workspacePath:e$1,target:s})}default:throw new Error(`Unknown tool: ${t}`)}}function E(e,t){process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id:e??null,result:t})}
1
+ import {b}from'./chunk-QZLIURER.js';import {d as d$1}from'./chunk-V3LRQZ36.js';import {c as c$1,e}from'./chunk-4LGXSBCN.js';import {c as c$2,b as b$2}from'./chunk-UQWOVV6V.js';import {d}from'./chunk-EFYHGCGX.js';import {k}from'./chunk-CVHMUSRX.js';import {c as c$3}from'./chunk-WYFPXTTS.js';import {f}from'./chunk-HDURFXW5.js';import {a as a$1}from'./chunk-LG6RFLPZ.js';import {a,c}from'./chunk-N7DV5L7C.js';import {r}from'./chunk-5XATWNME.js';import m from'path';import v from'readline';import b$1 from'fs-extra';var W=a.agentIndex,I=new Map(Object.keys(a).flatMap(e=>{let t=c[e];return t?[[a[e],t]]:[]}));function N(e,t){return e.kind!==t.kind?false:e.kind==="project"&&t.kind==="project"?e.project.toLowerCase()===t.project.toLowerCase():e.kind==="blocker"&&t.kind==="blocker"?e.blockerId===t.blockerId:e.kind==="trace"&&t.kind==="trace"?e.diffRef===t.diffRef:true}var L=[{name:"getWorkspaceModel",description:"Read workspace-model.json",inputSchema:{type:"object",properties:{}}},{name:"getEvidenceIndex",description:"Read agent reports INDEX.json",inputSchema:{type:"object",properties:{}}},{name:"getBlockers",description:"Aggregate blocking reasons from verify, explain, and contract-verify reports",inputSchema:{type:"object",properties:{}}},{name:"getSafeCommands",description:"Read safe commands from workspace-context-agent.json",inputSchema:{type:"object",properties:{}}},{name:"getProjectContext",description:"Read scoped project context from workspace-context-agent.json",inputSchema:{type:"object",properties:{project:{type:"string",description:"Optional project name; defaults to active scope"}}}},{name:"getArtifact",description:"Read one workspace-relative artifact path",inputSchema:{type:"object",properties:{relativePath:{type:"string"}},required:["relativePath"]}},{name:"listOperationalSkills",description:"Read workspace-skills-index.json",inputSchema:{type:"object",properties:{}}},{name:"getWorkspaceExplain",description:"Build or read workspace explain report",inputSchema:{type:"object",properties:{target:{type:"string",description:"release-blocked | project:<name> | blocker:<id> | trace:<diffRef> | <project>"}}}}];function M(e){let t=e.trim().replace(/\\/g,"/");return t.length>0&&!m.isAbsolute(t)&&!t.split("/").includes("..")&&(t.startsWith(".workspai/")||t.startsWith(".rapidkit/"))}async function l(e,t){if(!M(t))throw new Error(`Unsafe artifact path: ${t}`);let i=await f(e,t)??m.join(e,t);if(!await b$1.pathExists(i))return null;let r$1=await b$1.readJson(i),s=r(t),a=I.get(s);return a&&a$1(r$1,a,`MCP artifact ${s}`),r$1}async function J(e$1){let t=[],i=new Set,s=((await l(e$1,d$1))?.blockingReasons??[]).filter(n=>typeof n=="string"&&n.trim().length>0);if(s.length>0){t.push({artifact:d$1,reasons:s});for(let n of s)i.add(n);}let a=await l(e$1,c$2);if(e(a)){let n=(a.blockingReasons??[]).filter(o=>typeof o=="string"&&o.trim().length>0);if(n.length>0){t.push({artifact:c$2,reasons:n});for(let o of n)i.add(o);}}let c=await l(e$1,c$3),p=(c?.violations??[]).filter(n=>typeof n=="string"&&n.trim().length>0);if(p.length>0||String(c?.status??"").toLowerCase()==="failed"){let n=p.length>0?p:["Workspace contract verification failed"];t.push({artifact:c$3,reasons:n});for(let o of n)i.add(o);}return {blockingReasons:[...i],sources:t}}async function O(e$1,t,i){switch(t){case "getWorkspaceModel":return l(e$1,k);case "getEvidenceIndex":return l(e$1,W);case "getBlockers":return J(e$1);case "getSafeCommands":return {safeCommands:(await l(e$1,d))?.safeCommands??[]};case "getProjectContext":{let r=await l(e$1,d);if(!r)return null;let s=String(i.project??"").trim(),a=r.scope?.activeProject??void 0,c=s||a,p=Array.isArray(r.projects)?r.projects:[],n=c&&p.find(o=>typeof o.name=="string"&&o.name.toLowerCase()===c.toLowerCase());return {workspace:r.workspace??null,scope:r.scope??null,validation:r.validation??null,project:n??null,safeCommands:r.safeCommands??[]}}case "getArtifact":{let r=String(i.relativePath??"").trim();return l(e$1,r)}case "listOperationalSkills":return l(e$1,b$2);case "getWorkspaceExplain":{let r=String(i.target??"release-blocked").trim(),s=c$1(r);if(!s)throw new Error(`Invalid explain target: ${r}`);let a=await l(e$1,c$2);return e(a)&&N(a.target,s)?a:b({workspacePath:e$1,target:s})}default:throw new Error(`Unknown tool: ${t}`)}}function E(e,t){process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id:e??null,result:t})}
2
2
  `);}function w(e,t){process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id:e??null,error:{code:-32e3,message:t}})}
3
3
  `);}async function et(e){let t=m.resolve(e.workspacePath),i=v.createInterface({input:process.stdin,terminal:false});for await(let r of i){let s=r.trim();if(!s)continue;let a;try{a=JSON.parse(s);}catch{w(null,"Invalid JSON-RPC request");continue}let{id:c,method:p,params:n}=a;try{if(p==="initialize"){E(c,{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:{name:"workspai-workspace-mcp",version:"0.1.0"}});continue}if(p==="notifications/initialized")continue;if(p==="tools/list"){E(c,{tools:L.map(o=>({name:o.name,description:o.description,inputSchema:o.inputSchema}))});continue}if(p==="tools/call"){let o=String(n?.name??""),h=n?.arguments&&typeof n.arguments=="object"?n.arguments:{},A=await O(t,o,h);E(c,{content:[{type:"text",text:JSON.stringify(A,null,2)}],isError:A==null});continue}w(c,`Unsupported method: ${p??"unknown"}`);}catch(o){w(c,o instanceof Error?o.message:String(o));}}}async function nt(e,t,i={}){return O(m.resolve(e),t,i)}export{L as WORKSPACE_MCP_READ_TOOLS,nt as invokeMcpToolForTest,et as runWorkspaceMcpServe};
@@ -1 +1 @@
1
- export{k as WORKSPACE_MODEL_REPORT_PATH,j as WORKSPACE_MODEL_SCHEMA_VERSION,n as buildWorkspaceModel,o as buildWorkspaceModelCached,m as buildWorkspaceModelFacts,p as buildWorkspaceModelIncremental,l as validateWorkspaceModelStrict,q as writeWorkspaceModel}from'./chunk-JICOD2GI.js';
1
+ export{k as WORKSPACE_MODEL_REPORT_PATH,j as WORKSPACE_MODEL_SCHEMA_VERSION,n as buildWorkspaceModel,o as buildWorkspaceModelCached,m as buildWorkspaceModelFacts,p as buildWorkspaceModelIncremental,l as validateWorkspaceModelStrict,q as writeWorkspaceModel}from'./chunk-CVHMUSRX.js';
@@ -0,0 +1,2 @@
1
+ import {a,b}from'./chunk-GSWPGELT.js';import {o,l as l$1}from'./chunk-5XATWNME.js';import l from'fs-extra';function c(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:{}}async function m(n,e,o$1){let s=(await Promise.all(o(n,e).map(async r=>({candidate:r,exists:await l.pathExists(r)})))).find(({exists:r})=>r)?.candidate;if(!s)return false;let t=l$1(n,e),a=c(await l.readJson(s));return await l.outputJson(t,o$1(a),{spaces:2}),await l.appendFile(t,`
2
+ `,"utf-8"),true}async function M(n,e){let o=e.now??new Date().toISOString(),s=e.installMethod==="pip"?"venv":e.installMethod;await m(n,"workspace.json",a=>{let r=c(a.engine),i=c(r.python_core);return delete a.bootstrap_note,delete i.reason,{...a,engine:{...r,install_method:s,python_version:e.pythonVersion??r.python_version??null,python_core:{...i,status:"installed",installed_at:o,...e.coreVersion?{version:e.coreVersion}:{}}}}}),await m(n,"toolchain.lock",a=>{let r=c(a.runtime),i=c(r.python),d=c(i.core);return delete d.reason,{...a,generated_at:o,runtime:{...r,python:{...i,version:e.pythonVersion??i.version??null,install_method:s,core:{...d,status:"installed",installed_at:o,...e.coreVersion?{version:e.coreVersion}:{}}}}}});let t=await a(n);if(t){let a={...t.metadata?.python??{}};delete a.coreReason,t.metadata={...t.metadata,python:{...a,coreStatus:"installed",...e.coreVersion?{coreVersion:e.coreVersion}:{},...e.pythonVersion?{pythonVersion:e.pythonVersion}:{},...e.venvPath?{venvPath:e.venvPath}:{}},npm:{...t.metadata?.npm??{},packageVersion:t.metadata?.npm?.packageVersion??t.version,installMethod:s,lastUsedAt:o}},await b(n,t);}}export{M as markWorkspacePythonEngineInstalled};
@@ -0,0 +1 @@
1
+ export{a as WORKSPACE_REGISTRY_SUMMARY_RELATIVE_PATH,b as WORKSPACE_REGISTRY_SUMMARY_SCHEMA_VERSION,f as buildWorkspaceRegistrySummary,g as formatWorkspaceRegistrySyncSummary,e as publishWorkspaceRegistrySummary,d as readWorkspaceRegistrySummary,c as resolveWorkspaceRegisteredProjects}from'./chunk-SXPY523X.js';
@@ -0,0 +1 @@
1
+ export{a as runWorkspaceStage}from'./chunk-QA5BGEQW.js';export{a as WORKSPACE_RUN_LAST_REPORT_FILENAME}from'./chunk-WPEEC5BX.js';
@@ -1 +1 @@
1
- export{d as WORKSPACE_VERIFY_REPORT_PATH,c as WORKSPACE_VERIFY_SCHEMA_VERSION,f as buildWorkspaceVerify,e as computeAffectedSubgraphGate,h as evaluateWorkspaceVerifyGate,i as workspaceVerifyExitCode,g as writeWorkspaceVerify}from'./chunk-UNF72FTB.js';
1
+ export{d as WORKSPACE_VERIFY_REPORT_PATH,c as WORKSPACE_VERIFY_SCHEMA_VERSION,f as buildWorkspaceVerify,e as computeAffectedSubgraphGate,h as evaluateWorkspaceVerifyGate,i as workspaceVerifyExitCode,g as writeWorkspaceVerify}from'./chunk-V3LRQZ36.js';
@@ -1 +1 @@
1
- import {a}from'./chunk-7IHLTPZ6.js';import {b as b$1,p}from'./chunk-JICOD2GI.js';import {a as a$1}from'./chunk-LG6RFLPZ.js';import P from'fs';var w="workspace-watch-event.v1";function b(t){return a$1(t,"contracts/workspace-watch-event.v1.json","Workspace watch event"),t}function g(t){return `${t.from}\0${t.to}\0${t.kind}`}function f(t){return (t.graph?.edges??[]).map(r=>({from:r.from,to:r.to,kind:r.kind}))}function m(t){let o=[...a(t).entries()].sort((a,n)=>a[0].localeCompare(n[0])).map(([a,n])=>({id:a,hash:n})),c=f(t).map(g).sort((a,n)=>a.localeCompare(n));return b$1({projects:o,edges:c})}function R(t,r){let o=a(r),c=t?a(t):new Map,a$1=[],n=[];for(let[e,s]of o.entries())c.has(e)?c.get(e)!==s&&a$1.push(e):n.push(e);let d=[];for(let e of c.keys())o.has(e)||d.push(e);let i=new Map(t?f(t).map(e=>[g(e),e]):[]),l=new Map(f(r).map(e=>[g(e),e])),p=[];for(let[e,s]of l.entries())i.has(e)||p.push(s);let h=[];for(let[e,s]of i.entries())l.has(e)||h.push(s);let u=(e,s)=>g(e).localeCompare(g(s));return a$1.sort((e,s)=>e.localeCompare(s)),n.sort((e,s)=>e.localeCompare(s)),d.sort((e,s)=>e.localeCompare(s)),p.sort(u),h.sort(u),{changedProjects:a$1,addedProjects:n,removedProjects:d,edgesAdded:p,edgesRemoved:h}}var k=class{model=null;sequence=0;rebuild;now;constructor(r,o){this.rebuild=o?.rebuild??(()=>p({...r})),this.now=o?.now??(()=>new Date);}get currentModel(){return this.model}async start(){let r=Date.now(),{model:o}=await this.rebuild();return this.model=o,this.buildEvent("ready","initial",null,o,Date.now()-r)}async pulse(){let r=Date.now(),o=this.model,{model:c,mode:a}=await this.rebuild(),n=this.buildEvent(this.hasStructuralChange(o,c)?"changed":"unchanged",a,o,c,Date.now()-r);return this.model=c,n}hasStructuralChange(r,o){return r?m(r)!==m(o):true}buildEvent(r,o,c,a,n){let d=R(c,a),i=m(a),l=c?m(c)!==i:true;return b({schemaVersion:w,kind:r,sequence:this.sequence++,timestamp:this.now().toISOString(),mode:o,modelHash:i,modelHashChanged:l,changedProjects:d.changedProjects,addedProjects:d.addedProjects,removedProjects:d.removedProjects,graph:{nodeCount:a.graph?.nodes.length??0,edgeCount:a.graph?.edges.length??0,edgesAdded:d.edgesAdded,edgesRemoved:d.edgesRemoved},durationMs:n})}},C=new Set([".git",".hg",".svn","node_modules",".venv","venv","dist","build","out","target","coverage","htmlcov",".next",".turbo",".cache"]),y=new Set(["reports","cache","tmp",".cache"]);function S(t){if(!t)return false;let r=t.split(/[\\/]/).filter(Boolean);if(r.some(o=>C.has(o)))return false;for(let o=0;o<r.length-1;o+=1)if((r[o]===".workspai"||r[o]===".rapidkit")&&y.has(r[o+1]))return false;return true}async function I(t){let r=new k(t.buildOptions,t.engineOptions),o=await r.start();if(t.emit(o),t.once)return;let c=t.debounceMs??250,a=t.selfWriteSuppressionMs??Math.max(400,c+150),n=null,d=false,i=false,l=0,p=async()=>{if(d){i=true;return}d=true;try{let e=await r.pulse();t.emit(e);}catch(e){t.emit(b({schemaVersion:w,kind:"error",sequence:-1,timestamp:new Date().toISOString(),mode:"full",modelHash:r.currentModel?m(r.currentModel):"",modelHashChanged:false,changedProjects:[],addedProjects:[],removedProjects:[],graph:{nodeCount:0,edgeCount:0,edgesAdded:[],edgesRemoved:[]},durationMs:0,error:e instanceof Error?e.message:String(e)}));}finally{d=false,l=Date.now()+a,i&&(i=false,p());}},h=e=>{S(e)&&(d||Date.now()<l||(n&&clearTimeout(n),n=setTimeout(()=>{n=null,p();},c)));};t.onProgress?.(`Watching ${t.workspacePath} for changes (Ctrl+C to stop).`);let u=P.watch(t.workspacePath,{recursive:true},(e,s)=>{typeof s=="string"?h(s):s&&h(Buffer.from(s).toString("utf8"));});await new Promise(e=>{let s=()=>{n&&clearTimeout(n),u.close(),e();};if(t.signal){if(t.signal.aborted){s();return}t.signal.addEventListener("abort",s,{once:true});}u.on("error",()=>s());});}export{w as WORKSPACE_WATCH_EVENT_SCHEMA_VERSION,k as WorkspaceWatchEngine,m as computeWatchModelHash,R as diffWatchModels,S as isWatchRelevantPath,I as runWorkspaceWatch};
1
+ import {a}from'./chunk-ZKAI3PJE.js';import {b as b$1,p}from'./chunk-CVHMUSRX.js';import {a as a$1}from'./chunk-LG6RFLPZ.js';import P from'fs';var w="workspace-watch-event.v1";function b(t){return a$1(t,"contracts/workspace-watch-event.v1.json","Workspace watch event"),t}function g(t){return `${t.from}\0${t.to}\0${t.kind}`}function f(t){return (t.graph?.edges??[]).map(r=>({from:r.from,to:r.to,kind:r.kind}))}function m(t){let o=[...a(t).entries()].sort((a,n)=>a[0].localeCompare(n[0])).map(([a,n])=>({id:a,hash:n})),c=f(t).map(g).sort((a,n)=>a.localeCompare(n));return b$1({projects:o,edges:c})}function R(t,r){let o=a(r),c=t?a(t):new Map,a$1=[],n=[];for(let[e,s]of o.entries())c.has(e)?c.get(e)!==s&&a$1.push(e):n.push(e);let d=[];for(let e of c.keys())o.has(e)||d.push(e);let i=new Map(t?f(t).map(e=>[g(e),e]):[]),l=new Map(f(r).map(e=>[g(e),e])),p=[];for(let[e,s]of l.entries())i.has(e)||p.push(s);let h=[];for(let[e,s]of i.entries())l.has(e)||h.push(s);let u=(e,s)=>g(e).localeCompare(g(s));return a$1.sort((e,s)=>e.localeCompare(s)),n.sort((e,s)=>e.localeCompare(s)),d.sort((e,s)=>e.localeCompare(s)),p.sort(u),h.sort(u),{changedProjects:a$1,addedProjects:n,removedProjects:d,edgesAdded:p,edgesRemoved:h}}var k=class{model=null;sequence=0;rebuild;now;constructor(r,o){this.rebuild=o?.rebuild??(()=>p({...r})),this.now=o?.now??(()=>new Date);}get currentModel(){return this.model}async start(){let r=Date.now(),{model:o}=await this.rebuild();return this.model=o,this.buildEvent("ready","initial",null,o,Date.now()-r)}async pulse(){let r=Date.now(),o=this.model,{model:c,mode:a}=await this.rebuild(),n=this.buildEvent(this.hasStructuralChange(o,c)?"changed":"unchanged",a,o,c,Date.now()-r);return this.model=c,n}hasStructuralChange(r,o){return r?m(r)!==m(o):true}buildEvent(r,o,c,a,n){let d=R(c,a),i=m(a),l=c?m(c)!==i:true;return b({schemaVersion:w,kind:r,sequence:this.sequence++,timestamp:this.now().toISOString(),mode:o,modelHash:i,modelHashChanged:l,changedProjects:d.changedProjects,addedProjects:d.addedProjects,removedProjects:d.removedProjects,graph:{nodeCount:a.graph?.nodes.length??0,edgeCount:a.graph?.edges.length??0,edgesAdded:d.edgesAdded,edgesRemoved:d.edgesRemoved},durationMs:n})}},C=new Set([".git",".hg",".svn","node_modules",".venv","venv","dist","build","out","target","coverage","htmlcov",".next",".turbo",".cache"]),y=new Set(["reports","cache","tmp",".cache"]);function S(t){if(!t)return false;let r=t.split(/[\\/]/).filter(Boolean);if(r.some(o=>C.has(o)))return false;for(let o=0;o<r.length-1;o+=1)if((r[o]===".workspai"||r[o]===".rapidkit")&&y.has(r[o+1]))return false;return true}async function I(t){let r=new k(t.buildOptions,t.engineOptions),o=await r.start();if(t.emit(o),t.once)return;let c=t.debounceMs??250,a=t.selfWriteSuppressionMs??Math.max(400,c+150),n=null,d=false,i=false,l=0,p=async()=>{if(d){i=true;return}d=true;try{let e=await r.pulse();t.emit(e);}catch(e){t.emit(b({schemaVersion:w,kind:"error",sequence:-1,timestamp:new Date().toISOString(),mode:"full",modelHash:r.currentModel?m(r.currentModel):"",modelHashChanged:false,changedProjects:[],addedProjects:[],removedProjects:[],graph:{nodeCount:0,edgeCount:0,edgesAdded:[],edgesRemoved:[]},durationMs:0,error:e instanceof Error?e.message:String(e)}));}finally{d=false,l=Date.now()+a,i&&(i=false,p());}},h=e=>{S(e)&&(d||Date.now()<l||(n&&clearTimeout(n),n=setTimeout(()=>{n=null,p();},c)));};t.onProgress?.(`Watching ${t.workspacePath} for changes (Ctrl+C to stop).`);let u=P.watch(t.workspacePath,{recursive:true},(e,s)=>{typeof s=="string"?h(s):s&&h(Buffer.from(s).toString("utf8"));});await new Promise(e=>{let s=()=>{n&&clearTimeout(n),u.close(),e();};if(t.signal){if(t.signal.aborted){s();return}t.signal.addEventListener("abort",s,{once:true});}u.on("error",()=>s());});}export{w as WORKSPACE_WATCH_EVENT_SCHEMA_VERSION,k as WorkspaceWatchEngine,m as computeWatchModelHash,R as diffWatchModels,S as isWatchRelevantPath,I as runWorkspaceWatch};
@@ -22,10 +22,13 @@ export const MODULE_CATALOG = [
22
22
  ### After (Dynamic):
23
23
 
24
24
  ```typescript
25
- // Fetches from Python Core
25
+ // Fetches through the validated Core bridge
26
26
  export async function getModuleCatalog() {
27
- const result = await exec('rapidkit modules list --json');
28
- return parseModules(result);
27
+ const result = await runCoreRapidkitCapture(
28
+ ['modules', 'list', '--json-schema', '1'],
29
+ { preferWorkspaceVenv: true }
30
+ );
31
+ return parseModules(result.stdout);
29
32
  }
30
33
  ```
31
34
 
@@ -42,7 +45,7 @@ AI Recommender
42
45
 
43
46
  getModuleCatalog()
44
47
 
45
- ├─ Try: rapidkit modules list --json
48
+ ├─ Try through Core bridge: modules list --json-schema 1
46
49
  │ └─ Success: Return Python modules (runtime count)
47
50
  │ └─ Fail: Return fallback catalog (baseline subset)
48
51
 
@@ -61,10 +64,10 @@ Return Top Recommendations
61
64
 
62
65
  **Features:**
63
66
 
64
- - Calls `rapidkit modules list --json`
67
+ - Calls the Core bridge with `modules list --json-schema 1`
65
68
  - ✅ 5-minute cache (reduces Python calls)
66
69
  - ✅ Fallback to hardcoded catalog if Python not available
67
- - Automatic retry and error handling
70
+ - Validates the bridge result and falls back on failure
68
71
  - ✅ Category and framework mapping
69
72
 
70
73
  **Code:**
@@ -78,8 +81,11 @@ export async function getModuleCatalog(): Promise<ModuleMetadata[]> {
78
81
 
79
82
  // Fetch from Python Core
80
83
  try {
81
- const { stdout } = await execAsync('rapidkit modules list --json');
82
- const modules = parseModules(stdout);
84
+ const result = await runCoreRapidkitCapture(
85
+ ['modules', 'list', '--json-schema', '1'],
86
+ { preferWorkspaceVenv: true }
87
+ );
88
+ const modules = parseModules(result.stdout);
83
89
  cachedModules = modules;
84
90
  return modules;
85
91
  } catch (error) {
@@ -126,13 +132,13 @@ Python Category → TypeScript Type
126
132
 
127
133
  ```
128
134
  First call:
129
- ├─ Fetch from Python (10s)
135
+ ├─ Fetch from Python Core (duration depends on environment)
130
136
  ├─ Cache result
131
137
  └─ Return
132
138
 
133
139
  Subsequent calls (within 5 min):
134
140
  ├─ Return cached
135
- └─ Instant response
141
+ └─ Avoid another Core bridge invocation
136
142
 
137
143
  After 5 min:
138
144
  ├─ Re-fetch from Python
@@ -141,9 +147,9 @@ After 5 min:
141
147
 
142
148
  **Benefits:**
143
149
 
144
- - Fast responses (cached)
145
- - Always up-to-date (5min refresh)
146
- - Reduces Python CLI calls
150
+ - Cached responses avoid repeated bridge calls
151
+ - Runtime catalog refreshes after five minutes
152
+ - Provider and Core latency remain environment-dependent
147
153
 
148
154
  ---
149
155
 
@@ -209,7 +215,7 @@ npx tsx src/ai/generate-embeddings.ts
209
215
  $ workspai ai recommend "I need user authentication"
210
216
 
211
217
  # Behind the scenes:
212
- # 1. Calls: rapidkit modules list --json
218
+ # 1. Calls the Core bridge: modules list --json-schema 1
213
219
  # 2. Gets runtime module catalog from Python Core
214
220
  # 3. Generates query embedding
215
221
  # 4. Compares with catalog embeddings
@@ -294,15 +300,11 @@ If Python unavailable:
294
300
  └─ Can upgrade to Python later
295
301
  ```
296
302
 
297
- ### Performance
303
+ ### Cache behavior
298
304
 
299
- ```
300
- Cache Strategy:
301
- ├─ First call: 10s (Python fetch)
302
- ├─ Cached calls: <100ms (instant)
303
- ├─ Cache refresh: Every 5 minutes
304
- └─ Optimal balance
305
- ```
305
+ The in-process catalog cache refreshes every five minutes. No fixed response-time
306
+ or throughput guarantee is made; Core startup, provider latency, and catalog size
307
+ vary by environment.
306
308
 
307
309
  ---
308
310
 
@@ -311,12 +313,6 @@ Cache Strategy:
311
313
  ### Environment Variables
312
314
 
313
315
  ```bash
314
- # Optional: Force fallback mode (testing)
315
- export RAPIDKIT_AI_FALLBACK=true
316
-
317
- # Optional: Cache TTL (default: 5 minutes)
318
- export RAPIDKIT_CACHE_TTL=600000 # milliseconds
319
-
320
316
  # Optional: Python command/interpreter override (if python3/python is not the right one)
321
317
  export RAPIDKIT_PYTHON_CMD=/path/to/python
322
318
  ```
@@ -352,15 +348,15 @@ workspai ai recommend "authentication"
352
348
  ### Test 3: Cache Behavior
353
349
 
354
350
  ```bash
355
- # First call (cold cache)
356
- time workspai ai recommend "auth" # ~10 seconds
351
+ # First call (cold cache; duration is environment-dependent)
352
+ time workspai ai recommend "auth"
357
353
 
358
- # Second call (warm cache)
359
- time workspai ai recommend "database" # <1 second
354
+ # Second call (warm catalog cache; still includes provider latency)
355
+ time workspai ai recommend "database"
360
356
 
361
357
  # Wait 6 minutes, try again
362
358
  sleep 360
363
- time workspai ai recommend "payment" # ~10 seconds (cache expired)
359
+ time workspai ai recommend "payment"
364
360
  ```
365
361
 
366
362
  ---
@@ -4,12 +4,14 @@ AI-powered module recommendations using OpenAI embeddings to help you build fast
4
4
 
5
5
  ## 🚀 Quick Start
6
6
 
7
- ### Option 1: Automatic Setup (Recommended)
7
+ ### Option 1: Bundled embeddings (Recommended)
8
8
 
9
- Just use AI recommendations - it will guide you through setup automatically!
9
+ Published packages normally include bundled module embeddings. Configure an API
10
+ key for query embeddings, then run a recommendation. The missing-embeddings
11
+ prompt below is a recovery path, not the normal first-run path.
10
12
 
11
13
  ```bash
12
- # First time - AI will detect missing embeddings and offer to generate them
14
+ # If bundled embeddings are missing, AI offers to regenerate them
13
15
  npx workspai ai recommend "user authentication with social login"
14
16
 
15
17
  # Output:
@@ -172,7 +174,7 @@ npx workspai config ai disable
172
174
 
173
175
 
174
176
  ┌─────────────────┐
175
- │ Module Catalog │ 27+ modules with pre-generated embeddings
177
+ │ Module Catalog │ Runtime-dependent modules and bundled embeddings
176
178
  │ (Dynamic) │ Fetched from RapidKit Python Core
177
179
  └────────┬────────┘
178
180
 
@@ -191,14 +193,14 @@ npx workspai config ai disable
191
193
  ### Technical Details
192
194
 
193
195
  1. **Module Catalog**:
194
- - 27+ production-ready modules (dynamic from Python Core)
195
- - Fallback to 11 hardcoded modules if Python unavailable
196
+ - Runtime catalog from Python Core when available
197
+ - Bundled fallback catalog when Python is unavailable
196
198
  - 5-minute cache for performance
197
199
 
198
200
  2. **Embeddings**:
199
201
  - AI converts module descriptions to 1536-dimensional vectors
200
202
  - Generated once, reused for all queries
201
- - Stored in `data/modules-embeddings.json` (508KB)
203
+ - Stored in `data/modules-embeddings.json`; size depends on catalog and model
202
204
 
203
205
  3. **Semantic Search**:
204
206
  - User query → embedding vector
@@ -215,14 +217,11 @@ npx workspai config ai disable
215
217
 
216
218
  - Model: `text-embedding-3-small` (OpenAI)
217
219
  - Dimension: 1536 vectors
218
- - Accuracy: 92%+ match scores
220
+ - Match scores are similarity estimates, not a versioned accuracy benchmark
219
221
  - Cost: provider-dependent (check current provider pricing)
220
222
 
221
- **Performance:**
222
-
223
- - First query: ~200ms (embedding generation)
224
- - Subsequent queries: ~50ms (cached embeddings)
225
- - Catalog refresh: Every 5 minutes
223
+ Performance depends on provider latency, machine state, catalog size, and cache
224
+ state. The runtime catalog uses a five-minute in-process cache.
226
225
 
227
226
  ## 🎯 Use Cases
228
227
 
@@ -343,7 +342,7 @@ npx workspai config show
343
342
  pip install -e /path/to/rapidkit-core
344
343
 
345
344
  # Verify installation
346
- rapidkit modules list --json
345
+ rapidkit modules list --json-schema 1
347
346
  ```
348
347
 
349
348
  **Note:** Fallback still provides good results with core modules!
@@ -406,10 +405,10 @@ npx workspai config show
406
405
 
407
406
  ### Still Having Issues?
408
407
 
409
- 1. **Enable debug logging:**
408
+ 1. **Enable CLI debug logging where supported:**
410
409
 
411
410
  ```bash
412
- DEBUG=rapidkit:* npx workspai ai recommend "auth"
411
+ npx workspai --debug ai recommend "auth"
413
412
  ```
414
413
 
415
414
  2. **Check for updates:**
@@ -432,8 +431,7 @@ npx workspai config show
432
431
  | `workspai ai recommend [query]` | Get module recommendations | `workspai ai recommend "auth"` |
433
432
  | `workspai ai recommend [query] -n <N>` | Get top N recommendations | `workspai ai recommend "database" -n 3` |
434
433
  | `workspai ai recommend [query] --json` | Get JSON output | `workspai ai recommend "auth" --json` |
435
- | `workspai ai generate-embeddings` | Generate embeddings (one-time) | `workspai ai generate-embeddings` |
436
- | `workspai ai generate-embeddings --force` | Force regenerate embeddings | `workspai ai generate-embeddings --force` |
434
+ | `workspai ai generate-embeddings` | Generate or refresh embeddings | `workspai ai generate-embeddings` |
437
435
  | `workspai ai update-embeddings` | Update with latest modules | `workspai ai update-embeddings` |
438
436
  | `workspai ai info` | Show AI features info | `workspai ai info` |
439
437
 
@@ -458,15 +456,8 @@ Options:
458
456
  -h, --help Display help
459
457
  ```
460
458
 
461
- ### Generate-Embeddings Command Options
462
-
463
- ```bash
464
- workspai ai generate-embeddings [options]
465
-
466
- Options:
467
- --force Force regeneration even if embeddings exist
468
- -h, --help Display help
469
- ```
459
+ `generate-embeddings` currently regenerates when invoked. The accepted `--force`
460
+ flag does not alter that behavior and should not be used as a workflow branch.
470
461
 
471
462
  ## 🚀 Planned Workspace Intelligence Extensions
472
463
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Get started with Workspai AI recommendations in 60 seconds!
4
4
 
5
- ## Option 1: Zero-Config Start (Recommended) ⚡
5
+ ## Option 1: Use the bundled catalog (Recommended) ⚡
6
6
 
7
7
  Just run it - AI will guide you through everything:
8
8
 
@@ -10,7 +10,9 @@ Just run it - AI will guide you through everything:
10
10
  npx workspai ai recommend "user authentication"
11
11
  ```
12
12
 
13
- **First time?** You'll see this:
13
+ Published Workspai packages normally include `data/modules-embeddings.json`, so
14
+ recommendations can use the bundled catalog after an API key is configured.
15
+ If that file is missing, the CLI offers this recovery flow:
14
16
 
15
17
  ```
16
18
  ⚠️ Module embeddings not found
@@ -22,7 +24,7 @@ AI recommendations require embeddings to be generated.
22
24
  ❌ Cancel
23
25
  ```
24
26
 
25
- Select option 1, provide your OpenAI API key, and you're done! 🎉
27
+ Select option 1 to rebuild the missing data, or use the manual refresh flow below.
26
28
 
27
29
  ## Option 2: Manual Setup (For Advanced Users)
28
30
 
@@ -62,7 +64,8 @@ You'll see:
62
64
  ? Generate embeddings now? Yes
63
65
  ```
64
66
 
65
- **This is a ONE-TIME cost!** Embeddings last forever.
67
+ Embeddings are reusable until the module catalog, embedding model, or desired
68
+ coverage changes.
66
69
 
67
70
  ### Step 4: Use It! (Instant)
68
71