workspai 0.45.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.
- package/README.md +242 -516
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +4 -0
- package/contracts/extension-cli-compatibility.v1.json +3 -2
- package/contracts/published-contract-catalog.v1.json +7 -1
- package/contracts/runtime-command-surface.v1.json +41 -6
- package/contracts/workspace-archive-capabilities.v1.json +17 -6
- package/contracts/workspace-intelligence/studio-blocker-handoff.v1.json +4 -0
- package/contracts/workspace-intelligence/workspace-intelligence-run.v1.json +207 -0
- package/contracts/workspace-intelligence-architecture.v1.json +1 -1
- package/contracts/workspace-intelligence-chain.v1.json +37 -1
- package/dist/analyze-BEBEZSZK.js +1 -0
- package/dist/{artifact-remediation-plan-WLZGROUU.js → artifact-remediation-plan-FFQSESAM.js} +1 -1
- package/dist/autopilot-release-WUR4CQIT.js +1 -0
- package/dist/chunk-2G7FASAO.js +2 -0
- package/dist/{chunk-5GNT4RJI.js → chunk-4EPHWD27.js} +1 -1
- package/dist/{chunk-J4AICQFB.js → chunk-4LGXSBCN.js} +1 -1
- package/dist/chunk-52PBRX7F.js +1 -0
- package/dist/{chunk-2QOWRBQD.js → chunk-6IIZJQLV.js} +1 -1
- package/dist/{chunk-HYJK7W3B.js → chunk-CVHMUSRX.js} +1 -1
- package/dist/{chunk-7UZVOYF5.js → chunk-DIPD72H4.js} +1 -1
- package/dist/chunk-EFYHGCGX.js +2 -0
- package/dist/chunk-EYJ2CQSK.js +1 -0
- package/dist/chunk-FPJNWPKU.js +1 -0
- package/dist/{chunk-JP25YL3J.js → chunk-FTY7GGXJ.js} +2 -2
- package/dist/chunk-FWRXA435.js +2 -0
- package/dist/chunk-FXQJX34Z.js +1 -0
- package/dist/chunk-HDURFXW5.js +2 -0
- package/dist/chunk-HMUKBW2S.js +4 -0
- package/dist/{chunk-DXPU4DDV.js → chunk-J5PIZCAU.js} +92 -78
- package/dist/{chunk-6ZENXBMG.js → chunk-K4WNYXKK.js} +7 -7
- package/dist/chunk-MER6ZBN2.js +13 -0
- package/dist/chunk-N7DV5L7C.js +1 -0
- package/dist/{chunk-P424XYHP.js → chunk-PRBVYW3T.js} +1 -1
- package/dist/{chunk-WANW4QA4.js → chunk-QA5BGEQW.js} +1 -1
- package/dist/chunk-QZLIURER.js +13 -0
- package/dist/{chunk-P7SCWJFG.js → chunk-RIEF2DDX.js} +1 -1
- package/dist/{chunk-V2H2KRMZ.js → chunk-SXMTSV5M.js} +1 -1
- package/dist/chunk-SXPY523X.js +1 -0
- package/dist/{chunk-XIVFLY6G.js → chunk-UQWOVV6V.js} +1 -1
- package/dist/chunk-V3LRQZ36.js +1 -0
- package/dist/chunk-VFDM65IE.js +80 -0
- package/dist/{chunk-KU4S7RCM.js → chunk-WPEEC5BX.js} +1 -1
- package/dist/chunk-WYFPXTTS.js +2 -0
- package/dist/{chunk-K63BSU56.js → chunk-YUATNVOT.js} +62 -51
- package/dist/{chunk-OOOPYUL2.js → chunk-ZKAI3PJE.js} +1 -1
- package/dist/{create-KFR6FLRT.js → create-WCV3L6XH.js} +1 -1
- package/dist/doctor-5BWM2EMJ.js +1 -0
- package/dist/{dotnet-webapi-clean-BYUUHX5Y.js → dotnet-webapi-clean-6TVFBTVI.js} +20 -20
- package/dist/{gofiber-standard-B6UK5GR7.js → gofiber-standard-2BL7GWZB.js} +1 -1
- package/dist/{gogin-standard-BXU44VEM.js → gogin-standard-XGP3KBXA.js} +1 -1
- package/dist/index.d.ts +88 -13
- package/dist/index.js +327 -324
- package/dist/pipeline-ORIWVVYM.js +5 -0
- package/dist/{platform-capabilities-YICBF4FA.js → platform-capabilities-2B4QMZXE.js} +1 -1
- package/dist/{pythonRapidkitExec-UJYIB6FL.js → pythonRapidkitExec-CVCIK225.js} +1 -1
- package/dist/{springboot-standard-PEHDKH2L.js → springboot-standard-JJNUID6M.js} +6 -6
- package/dist/workspace-7OXW5YTJ.js +1 -0
- package/dist/{workspace-agent-sync-G5YVI3BJ.js → workspace-agent-sync-O4IA6VOA.js} +1 -1
- package/dist/workspace-archive-H74NBBNW.js +10 -0
- package/dist/{workspace-context-E3UFWL5X.js → workspace-context-R7IPUBPG.js} +1 -1
- package/dist/workspace-contract-HKCMOMFE.js +1 -0
- package/dist/workspace-explain-GOPQYTPQ.js +1 -0
- package/dist/workspace-explain-contract-SVFJAAEI.js +1 -0
- package/dist/{workspace-feedback-YY6WQPWQ.js → workspace-feedback-REOS36ZZ.js} +1 -1
- package/dist/{workspace-foundation-3C2DLCVI.js → workspace-foundation-KXT4QI5O.js} +1 -1
- package/dist/{workspace-history-VF3CHDYQ.js → workspace-history-OGOVSKZG.js} +1 -1
- package/dist/{workspace-intelligence-3GG7GEDQ.js → workspace-intelligence-7IESQSXY.js} +1 -1
- package/dist/workspace-intelligence-runner-6GJ5M4HB.js +1 -0
- package/dist/{workspace-mcp-serve-MJMUV4RY.js → workspace-mcp-serve-FRVWBO36.js} +1 -1
- package/dist/{workspace-model-NG45SRM5.js → workspace-model-PPYX7B4S.js} +1 -1
- package/dist/workspace-python-engine-state-2MLKJYQG.js +2 -0
- package/dist/workspace-registry-summary-SZ46R5PD.js +1 -0
- package/dist/workspace-run-V3KKHTVF.js +1 -0
- package/dist/{workspace-verify-ZNT6JX7D.js → workspace-verify-MFQ7IXGD.js} +1 -1
- package/dist/{workspace-watch-W47T4RX2.js → workspace-watch-SOPZHRWA.js} +1 -1
- package/docs/AI_DYNAMIC_INTEGRATION.md +29 -33
- package/docs/AI_FEATURES.md +18 -27
- package/docs/AI_QUICKSTART.md +7 -4
- package/docs/DEVELOPMENT.md +5 -5
- package/docs/From Code to Shared Understanding.png +0 -0
- package/docs/OPEN_SOURCE_USER_SCENARIOS.md +23 -2
- package/docs/OPTIMIZATION_GUIDE.md +19 -51
- package/docs/PACKAGE_MANAGER_POLICY.md +4 -1
- package/docs/README.md +30 -3
- package/docs/SECURITY.md +13 -6
- package/docs/SETUP.md +6 -3
- package/docs/UTILITIES.md +8 -20
- package/docs/WORKSPACE_MARKER_SPEC.md +27 -20
- package/docs/ci-workflows.md +19 -5
- package/docs/commands-reference.md +37 -9
- package/docs/config-file-guide.md +64 -247
- package/docs/contracts/ARTIFACT_CATALOG.md +14 -2
- package/docs/contracts/CLI_LOG_EVENT_STREAM.md +1 -1
- package/docs/contracts/README.md +5 -2
- package/docs/contracts/RUNTIME_ACCEPTANCE_MATRIX.md +4 -4
- package/docs/contracts/RUNTIME_SUPPORT_MATRIX.md +14 -10
- package/docs/creating-workspaces-and-projects.md +649 -0
- package/docs/doctor-command.md +5 -4
- package/docs/examples/ci-agent-grounding.yml +16 -10
- package/docs/from-code-to-shared-understanding.md +69 -38
- package/docs/workspace-intelligence-runner.md +186 -0
- package/docs/workspace-operations.md +29 -11
- package/docs/workspace-run.md +4 -1
- package/package.json +9 -8
- package/rapidkit.config.example.cjs +5 -5
- package/scripts/enforce-package-manager.cjs +1 -1
- package/scripts/prepack-enterprise.mjs +4 -0
- package/workspai.config.example.cjs +12 -47
- package/dist/analyze-YLV7NVLF.js +0 -1
- package/dist/autopilot-release-YBN3SWAA.js +0 -1
- package/dist/chunk-2K3GYCPS.js +0 -1
- package/dist/chunk-42G2OK64.js +0 -1
- package/dist/chunk-5AKYMAIL.js +0 -1
- package/dist/chunk-5PVEQ6CZ.js +0 -13
- package/dist/chunk-6AA3WWQZ.js +0 -2
- package/dist/chunk-7RIWU5TZ.js +0 -1
- package/dist/chunk-BJLE5CH7.js +0 -4
- package/dist/chunk-G3H5R3RR.js +0 -1
- package/dist/chunk-IMUU5Q2V.js +0 -13
- package/dist/chunk-KPPGZCUW.js +0 -78
- package/dist/chunk-LCRROMRR.js +0 -2
- package/dist/chunk-QWU2CZBG.js +0 -2
- package/dist/chunk-XZGVNGRB.js +0 -1
- package/dist/chunk-ZWO6K24C.js +0 -2
- package/dist/doctor-YJDM5XBH.js +0 -1
- package/dist/imported-projects-registry-FOIE27WT.js +0 -1
- package/dist/pipeline-FEDYO3IA.js +0 -5
- package/dist/workspace-PLXOO6ST.js +0 -1
- package/dist/workspace-archive-EEGLHZDW.js +0 -10
- package/dist/workspace-contract-LQJDZV36.js +0 -1
- package/dist/workspace-explain-G74ZIF23.js +0 -1
- package/dist/workspace-explain-contract-KT757JGQ.js +0 -1
- package/dist/workspace-python-engine-state-MTWIIZPY.js +0 -2
- package/dist/workspace-registry-summary-JM2XY52C.js +0 -1
- package/dist/workspace-run-WEQYIERE.js +0 -1
package/dist/chunk-ZWO6K24C.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {n,k,j}from'./chunk-HYJK7W3B.js';import {a as a$2}from'./chunk-HTYMXMQM.js';import {c}from'./chunk-S5KTATOU.js';import {a as a$1}from'./chunk-QWU2CZBG.js';import {g as g$1}from'./chunk-6AA3WWQZ.js';import {a as a$3}from'./chunk-LG6RFLPZ.js';import {b,a}from'./chunk-5AKYMAIL.js';import ke from'crypto';import k$1 from'path';import L from'fs-extra';import {spawnSync}from'child_process';function fe(){let e={...process.env};return delete e.GIT_DIR,delete e.GIT_WORK_TREE,delete e.GIT_INDEX_FILE,delete e.GIT_PREFIX,e}function F(e,t){let o=spawnSync("git",t,{cwd:e,env:fe(),encoding:"utf8",stdio:["ignore","pipe","ignore"]});return o.status!==0?{ok:false,stdout:""}:{ok:true,stdout:(o.stdout??"").trim()}}function ue(e){let t=e.replace(/\\/g,"/").replace(/^\.\//,"");return [".workspai/reports/",".workspai/cache/",".rapidkit/reports/",".rapidkit/cache/"].some(o=>t.startsWith(o))}function ge(e){let t=[],o=[],r=[];for(let l of e.split(`
|
|
2
|
-
`)){if(!l.trim())continue;let a=l.slice(0,2),i=l.slice(3).trim();if(i&&!ue(i)){if(a==="??"){o.push(i);continue}a.includes("D")&&r.push(i),t.push(i);}}return {changedFiles:[...new Set(t)].sort(),untrackedFiles:[...new Set(o)].sort(),deletedFiles:[...new Set(r)].sort()}}function Y(e,t){let o={available:false,dirty:false,changedFiles:[],untrackedFiles:[],deletedFiles:[]},r=F(e,["rev-parse","--is-inside-work-tree"]);if(!r.ok||r.stdout!=="true")return o;let l=F(e,["rev-parse","--abbrev-ref","HEAD"]),a=F(e,["rev-parse","HEAD"]),i=F(e,["status","--porcelain=v1","--untracked-files=all"]),c=ge(i.stdout),m=c.changedFiles.length>0||c.untrackedFiles.length>0||c.deletedFiles.length>0;return {available:true,branch:l.ok?l.stdout:void 0,commit:a.ok?a.stdout:void 0,ref:t?.ref,dirty:m,changedFiles:c.changedFiles,untrackedFiles:c.untrackedFiles,deletedFiles:c.deletedFiles}}var re=b.snapshot,K=b.diff,T=a.snapshot,oe=a.diff,he=b.impact,we=a.impact;function ne(e){let t=e.trim().toLowerCase();return t==="git"||t.startsWith("git:")}function ye(e){let t=e.trim();return t.toLowerCase()==="git"?"HEAD":t.toLowerCase().startsWith("git:")&&t.slice(4).trim()||"HEAD"}function V(e){if(Array.isArray(e))return e.map(t=>V(t));if(e&&typeof e=="object"){let t={};for(let o of Object.keys(e).sort())t[o]=V(e[o]);return t}return e}function g(e){return JSON.stringify(V(e))}function I(e){let{runId:t,evidence:o,facts:r,factFreshness:l,projects:a,...i}=e,c=a.map(p=>{let{evidence:f,...h}=p;return h}),m={...i,generatedAt:"<ignored>",projects:c,graph:e.graph?{...e.graph,generatedAt:"<ignored>"}:void 0,validation:e.validation?{...e.validation,issues:e.validation.issues.map(p=>({...p})).sort((p,f)=>{let h=`${p.severity}:${p.code}:${p.target}:${p.message}`,b=`${f.severity}:${f.code}:${f.target}:${f.message}`;return h.localeCompare(b)})}:void 0};return ke.createHash("sha256").update(g(m)).digest("hex")}function Xe(e){return I(e)}function ae(e,t){return k$1.isAbsolute(t)?t:k$1.join(e,t)}async function We(e){let t=await L.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace model input is not a JSON object: ${e}`);let o=t;if(o.schemaVersion===re){a$3(t,"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",`Workspace model snapshot ${e}`);let r=o;if(!r.model||r.model.schemaVersion!==j)throw new Error(`Invalid workspace model snapshot: ${e}`);let l=I(r.model);if(r.modelHash!==l)throw new Error(`Workspace model snapshot hash mismatch: ${e}`);return {model:r.model,hash:r.modelHash}}if(o.schemaVersion===j){a$3(t,"contracts/workspace-intelligence/workspace-model.v1.json",`Workspace model ${e}`);let r=o;return {model:r,hash:I(r)}}throw o.schemaVersion===K?new Error(`workspace diff --from received a diff report (${k$1.basename(e)}). Use a workspace model snapshot or model report as baseline, e.g. ${T}. To analyze an existing diff report, run: npx workspai workspace impact --from ${k$1.basename(e)} --json`):new Error(`Unsupported workspace model input schema: ${String(o.schemaVersion)}`)}async function ve(e){let t=await L.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace diff input is not a JSON object: ${e}`);let o=t;if(o.schemaVersion!==K)return null;a$3(t,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Workspace model diff ${e}`);let r=o;if(!r.currentModel||r.currentModel.schemaVersion!==j||!r.summary||!Array.isArray(r.changes))throw new Error(`Invalid workspace model diff report: ${e}`);if(r.toHash!==I(r.currentModel))throw new Error(`Workspace model diff current-model hash mismatch: ${e}`);return r}async function Ye(e){let t=e.model??await n({workspacePath:e.workspacePath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {schemaVersion:re,generatedAt:(e.now??new Date).toISOString(),modelHash:I(t),modelRef:k,model:t}}async function Qe(e,t){return g$1(t,T,a$1(e))}function x(e){return {name:e.name,path:e.path,kind:e.kind,runtime:e.runtime,framework:e.framework,generator:e.generator,supportTier:e.supportTier,commands:e.commands,importantFiles:e.importantFiles}}function w(e,t){e.push(t);}function be(e,t){let o=[],r=["name","profile","type"],l=["workspaceType","surfaces","runtimeFamilies","businessCapabilities"];for(let a of r){let i=e.workspace[a],c=t.workspace[a];g(i)!==g(c)&&w(o,{type:"workspace.changed",severity:"info",target:`workspace.${a}`,message:`Workspace metadata field changed: ${String(a)}`,before:i,after:c});}for(let a of l){let i=e.identity[a],c=t.identity[a];g(i)!==g(c)&&w(o,{type:"workspace.changed",severity:"info",target:`identity.${a}`,message:`Workspace identity field changed: ${String(a)}`,before:i,after:c});}return g(e.policies)!==g(t.policies)&&w(o,{type:"workspace.changed",severity:"warning",target:"policies",message:"Workspace policy summary changed.",before:e.policies,after:t.policies}),g(e.evidence)!==g(t.evidence)&&w(o,{type:"workspace.changed",severity:"info",target:"evidence",message:"Workspace evidence summary changed.",before:e.evidence,after:t.evidence}),g(e.discovery)!==g(t.discovery)&&w(o,{type:"workspace.changed",severity:"info",target:"discovery",message:"Workspace discovery settings changed.",before:e.discovery,after:t.discovery}),e.contracts.exists!==t.contracts.exists&&w(o,{type:"workspace.changed",severity:t.contracts.exists?"info":"warning",target:t.contracts.workspaceContractPath,message:"Workspace contract presence changed.",before:e.contracts.exists,after:t.contracts.exists}),o}function je(e,t){let o=e.validation??null,r=t.validation??null;return g(o)===g(r)?[]:[{type:"validation.changed",severity:r?.status==="failed"?"critical":"warning",target:"validation",message:"Workspace model validation changed.",before:o,after:r}]}function Me(e,t){let o=[],r=new Map(e.projects.map(a=>[a.path,a])),l=new Map(t.projects.map(a=>[a.path,a]));for(let[a,i]of l.entries()){let c=r.get(a);if(!c){w(o,{type:"project.added",severity:"info",target:a,message:`Project added: ${i.name}`,after:x(i)});continue}let m=x(c),p=x(i);if(g(m)!==g(p)){let f=c.runtime!==i.runtime||c.framework!==i.framework;w(o,{type:"project.changed",severity:f?"warning":"info",target:a,message:`Project changed: ${i.name}`,before:m,after:p});}}for(let[a,i]of r.entries())l.has(a)||w(o,{type:"project.removed",severity:"warning",target:a,message:`Project removed: ${i.name}`,before:x(i)});return o.sort((a,i)=>`${a.type}:${a.target}`.localeCompare(`${i.type}:${i.target}`))}async function Ie(e){let t=k$1.resolve(e.workspacePath),o=ne(e.fromPath),r=o?ye(e.fromPath):void 0,l=e.fromPath;if(o){let u=k$1.join(t,T);if(!await L.pathExists(u))throw new Error("Git-aware workspace diff requires an existing snapshot at .workspai/reports/workspace-model-snapshot.json. Run: npx workspai workspace snapshot --json");l=T;}let a=ae(t,l),i=await We(a),c=e.model??await n({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),m=I(c),p=[...be(i.model,c),...Me(i.model,c),...je(i.model,c)],f;e.includeGitObservation!==false&&(f=e.gitObservation??Y(t,{ref:r}),f.available&&Ee(p,f,c));let h=p.filter(u=>u.type.startsWith("git.")).length,b=i.hash!==m,W=o?`git:${r??"HEAD"}`:k$1.relative(t,a).split(k$1.sep).join("/");return {schemaVersion:K,generatedAt:(e.now??new Date).toISOString(),fromRef:W,toRef:k,fromHash:i.hash,toHash:m,summary:{changed:b||h>0,addedProjects:p.filter(u=>u.type==="project.added").length,removedProjects:p.filter(u=>u.type==="project.removed").length,changedProjects:p.filter(u=>u.type==="project.changed").length,workspaceChanges:p.filter(u=>u.type==="workspace.changed").length,validationChanges:p.filter(u=>u.type==="validation.changed").length,gitChangedFiles:h},git:f?.available?Se(f,r):{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:p,currentModel:c}}async function Ze(e,t){return g$1(t,oe,a$1(e))}function P(e){return {none:0,low:1,medium:2,high:3,critical:4}[e]}function Q(e){return e.reduce((t,o)=>P(o)>P(t)?o:t,"none")}var N=["none","low","medium","high","critical"];function Pe(e){let t=Math.max(1,P(e)-1);return N[t]}function Re(e){let t=Math.min(N.length-1,P(e)+1);return N[t]}function Z(e){return e.join(" ")}function y(e,t,o,r){return {id:e,label:t,scope:r.scope,project:r.project,display:Z(["npx","workspai",...o]),execute:Z(["npx","--yes","--package","workspai","workspai",...o]),required:r.required!==false}}function ee(e){let t=`project:${e.name}`,o=e.commands.fleetStages;return [y(`project.${e.name}.init`,`Run init for ${e.name}`,["workspace","run","init","--scope",t,"--json"],{scope:"project",project:e.name,required:o.includes("init")}),y(`project.${e.name}.test`,`Run tests for ${e.name}`,["workspace","run","test","--scope",t,"--json"],{scope:"project",project:e.name,required:o.includes("test")}),y(`project.${e.name}.build`,`Run build for ${e.name}`,["workspace","run","build","--scope",t,"--json"],{scope:"project",project:e.name,required:o.includes("build")}),y(`project.${e.name}.start`,`Run start for ${e.name}`,["workspace","run","start","--scope",t,"--json"],{scope:"project",project:e.name,required:o.includes("start")})]}function _(){return [y("workspace.doctor","Run workspace doctor",["doctor","workspace","--json"],{scope:"workspace"}),y("workspace.contract.verify","Verify workspace contract",["workspace","contract","verify","--json"],{scope:"workspace"}),y("workspace.readiness","Run release readiness",["readiness","--json"],{scope:"workspace"}),y("workspace.analyze","Run workspace analyze",["analyze","--json"],{scope:"workspace",required:false}),y("workspace.pipeline","Run governance pipeline",["pipeline","--json"],{scope:"workspace",required:false}),y("workspace.doctor-fix","Verify doctor fix result",["doctor","workspace","--fix","--json"],{scope:"workspace",required:false})]}function Ce(e,t){let o=t.split(k$1.sep).join("/");return e.projects.filter(l=>{let a=l.path.split(k$1.sep).join("/");return o===a||o.startsWith(`${a}/`)}).sort((l,a)=>a.path.length-l.path.length)[0]}function Ee(e,t,o){let r=new Set(e.map(a=>a.target)),l=(a,i)=>{let c=i.split(k$1.sep).join("/"),m=`git:${c}`;if(r.has(m))return;let p=Ce(o,c),f=p?`${p.name} (${p.path})`:"workspace";w(e,{type:a,severity:a==="git.deleted"?"warning":"info",target:m,message:`Git ${a==="git.untracked"?"untracked":a==="git.deleted"?"deleted":"changed"} file affects ${f}: ${c}`,after:{path:c,project:p?.name,projectPath:p?.path}}),r.add(m);};for(let a of t.changedFiles)l("git.file.changed",a);for(let a of t.untrackedFiles)l("git.untracked",a);for(let a of t.deletedFiles)l("git.deleted",a);}function Se(e,t){return {available:true,ref:t??e.ref,branch:e.branch,commit:e.commit,dirty:e.dirty,changedFiles:e.changedFiles.length,untrackedFiles:e.untrackedFiles.length,deletedFiles:e.deletedFiles.length}}function Oe(e){let t=new Set,o=[];for(let r of e){let l=`${r.scope}:${r.project??""}:${r.display}`;t.has(l)||(t.add(l),o.push(r));}return o}function Ae(e){return e.type==="project.removed"?"high":e.severity==="critical"?"critical":e.severity==="warning"?"high":("medium")}function $e(e,t){return e.severity==="critical"?"critical":e.target==="policies"||e.target.includes("contract")?"high":e.type==="validation.changed"?(t?.projectCount??0)===0?"low":"high":e.target==="evidence"?"low":e.severity==="warning"?"medium":"low"}function De(e){return e.affectedProjects>0||e.projectCount>0||!e.changes.every(o=>o.severity==="critical"?false:o.type.startsWith("git.")||o.type==="validation.changed")?e.risk:P(e.risk)>=P("high")||e.risk==="medium"?"low":e.risk}function te(e,t){if(!e||e==="workspace")return true;let o=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return [t.name,t.path,k$1.basename(t.path),t.absolutePath].filter(r=>typeof r=="string"&&r.trim().length>0).map(r=>r.trim().toLowerCase()).includes(o)}function Fe(e){if(!e.changed)return {headline:"No workspace model impact detected.",bullets:["The current workspace model matches the provided snapshot/report."],unsafeAssumptions:["Do not claim runtime verification passed unless a report exists."]};let t=e.affectedProjects.map(o=>o.project?.name??o.target);return {headline:`Workspace impact risk: ${e.risk}.`,bullets:[`Affected projects: ${t.length?t.join(", "):"none"}.`,`Workspace-level items: ${e.workspaceImpact.length}.`,"Use the verification plan before recommending apply, rollback, or release actions."],unsafeAssumptions:["Do not infer test/build success from impact alone.","Do not apply fixes without project scope and verification evidence.","Use display commands for users and execute commands for automation."]}}async function et(e){let t=k$1.resolve(e.workspacePath),o=ne(e.fromPath),r=e.diff;if(!r&&!o){let n=ae(t,e.fromPath);r=await ve(n)??void 0;}r||(r=await Ie({workspacePath:t,fromPath:e.fromPath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,includeGitObservation:e.includeGitObservation,gitObservation:e.gitObservation,now:e.now,model:e.model}));let l=new Map(r.currentModel.projects.map(n=>[n.path,n])),a=new Map(r.currentModel.projects.map(n=>[n.name,n])),i=r.changes.filter(n=>n.type.startsWith("project.")),c$1=new Map;for(let n of i){let d=(l.get(n.target)??(typeof n.before?.name=="string"?a.get(n.before.name):void 0))?.path??n.target,v=c$1.get(d)??[];v.push(n),c$1.set(d,v);}let m=[];for(let[n,s]of c$1.entries()){let d=l.get(n);if(d&&!te(e.scope,d))continue;let v=Q(s.map(Ae)),C=d?.name??(typeof s[0]?.before?.name=="string"?String(s[0].before.name):n);m.push({id:`project:${C}`,scope:"project",target:n,title:`Project impact: ${C}`,summary:s.map(j=>j.message).join(" "),risk:v,reasons:s.map(j=>`${j.type}: ${j.message}`),project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?ee(d):_()});}let p=r.currentModel.graph,f=p?a$2(p):void 0,h=new Set(m.map(n=>n.project?.name).filter(n=>typeof n=="string")),b=new Map;for(let n of m)if(n.project?.name){let s=f?.byId.get(n.project.name);s&&(n.centrality={fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness,isHotspot:s.isHotspot},s.isHotspot&&(n.risk=Re(n.risk),n.reasons=[...n.reasons,`graph.hotspot: critical-path project with ${s.reach} transitive dependent(s); risk escalated.`])),n.origin="direct",n.distance=0,b.set(n.project.name,n.risk);}let W=[],u=0;if(p&&h.size>0){let n=c(p,h);for(let s of n.values()){if(s.distance===0||h.has(s.id))continue;let d=a.get(s.id);if(d&&!te(e.scope,d))continue;let v=s.path[0],C=s.path[s.path.length-2]??v,j=b.get(v)??"medium",pe=Pe(j),M=f?.byId.get(s.id);u=Math.max(u,s.distance),W.push({id:`transitive:${s.id}`,scope:"project",target:d?.path??s.id,title:`Transitive impact: ${s.id}`,summary:`Depends on changed project ${v}${s.via?` via ${s.via}`:""} (distance ${s.distance}).`,risk:pe,reasons:[`graph.dependent: depends on ${C}${s.via?` via ${s.via}`:""} (path ${s.path.join(" -> ")})`],project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?ee(d):_(),origin:"transitive",distance:s.distance,path:s.path,via:s.via,...M?{centrality:{fanIn:M.fanIn,fanOut:M.fanOut,reach:M.reach,betweenness:M.betweenness,isHotspot:M.isHotspot}}:{}});}}W.sort((n,s)=>n.target.localeCompare(s.target));let se=f?f.hotspots.flatMap(n=>{let s=f.byId.get(n);return s?[{project:n,fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness}]:[]}):[],ie=r.changes.filter(n=>!n.type.startsWith("project.")),B=r.currentModel.summary?.projectCount??r.currentModel.projects.length,R=ie.map(n=>({id:`workspace:${n.target}`,scope:"workspace",target:n.target,title:`Workspace impact: ${n.target}`,summary:n.message,risk:$e(n,{projectCount:B}),reasons:[`${n.type}: ${n.message}`],verification:_()})),q=Oe([...m.flatMap(n=>n.verification),...W.flatMap(n=>n.verification),...R.flatMap(n=>n.verification),...r.summary.changed?_():[]]).filter(n=>n.required),ce=Q([...m.map(n=>n.risk),...W.map(n=>n.risk),...R.map(n=>n.risk)]),z=De({risk:ce,affectedProjects:m.length,projectCount:B,changes:r.changes}),J={changed:r.summary.changed,risk:z,affectedProjects:m.length,workspaceItems:R.length,recommendedCommands:q.length,blastRadius:{directlyAffected:m.length,transitivelyAffected:W.length,maxDistance:u,graphEdges:p?.edges.length??0}};return {schemaVersion:he,generatedAt:(e.now??new Date).toISOString(),fromRef:r.fromRef,diffRef:oe,workspace:{name:r.currentModel.workspace.name,profile:r.currentModel.workspace.profile,type:r.currentModel.workspace.type},summary:J,affectedProjects:m.sort((n,s)=>n.target.localeCompare(s.target)),transitiveImpact:W,criticalPathHotspots:se,workspaceImpact:R.sort((n,s)=>n.target.localeCompare(s.target)),verificationPlan:q,agentBrief:Fe({changed:J.changed,risk:z,affectedProjects:m,workspaceImpact:R}),diff:r}}async function tt(e,t){return g$1(t,we,a$1(e))}export{Y as a,re as b,K as c,T as d,oe as e,he as f,we as g,ne as h,ye as i,Xe as j,Ye as k,Qe as l,Ie as m,Ze as n,_ as o,et as p,tt as q};
|
package/dist/doctor-YJDM5XBH.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as DOCTOR_WORKSPACE_REPORT_PATH,d as computeDoctorFixAwareExitCode,c as computeDoctorGateExitCode,b as resolveDoctorPolicyProfile,e as runDoctor}from'./chunk-KPPGZCUW.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as readImportedProjectsRegistry,c as removeImportedProjectsRegistryEntries,b as upsertImportedProjectsRegistry}from'./chunk-XZGVNGRB.js';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import {a as a$2}from'./chunk-P7SCWJFG.js';import {c as c$1}from'./chunk-5GNT4RJI.js';import {e}from'./chunk-KPPGZCUW.js';import {b}from'./chunk-K63BSU56.js';import {d,c as c$2}from'./chunk-BJLE5CH7.js';import {f as f$1,e as e$1}from'./chunk-T3GJ7YVG.js';import {a}from'./chunk-22DT744Z.js';import {f,c,g}from'./chunk-6AA3WWQZ.js';import {a as a$1}from'./chunk-5AKYMAIL.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 b(a,true),i=false;try{let{syncWorkspaceContract:t}=await import('./workspace-contract-LQJDZV36.js');await t({workspacePath:a}),i=true;}catch{i=false;}return {sync:r,contractSynced:i}}async function V(a$3={}){let r=p.resolve(a$3.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$1,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$1=await e({workspace:true,json:true,quiet:true,strict:a$3.strict===true,ci:a$3.strict!==true}),s=G(e$1),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$1,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$3.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$3.strict===true});d$1=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$1}),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 d({startPath:i,writeReport:true,skipVerify:a$3.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$3.skipAutopilot)t.push({name:"autopilot",status:"skipped",durationMs:0,summary:"autopilot stage skipped"});else {let e=Date.now(),s=a$3.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$1,readinessEvidencePath:f$2,autopilotEvidencePath:m}};if(a$3.writeReport!==false){let e=f$1(u,{commandId:"workspacePipeline",exitCode:k,generatedAt:u.generatedAt,blockers:u.blockingReasons,runId:e$1()});await g(i,".workspai/reports/pipeline-last-run.json",e);}if(a$3.writeReport!==false&&a$3.noAgentSync!==true&&process.env.RAPIDKIT_NO_AGENT_SYNC!=="1"&&a$3.agentSync!==false)try{let{syncWorkspaceAgentGrounding:e}=await import('./workspace-agent-sync-G5YVI3BJ.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 +0,0 @@
|
|
|
1
|
-
export{e as createProject,d as createWorkspace,g as createWorkspaceShareBundle,f as listWorkspaces,c as registerProjectInWorkspace,a as registerWorkspace,b as syncWorkspaceProjects}from'./chunk-K63BSU56.js';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import {e,c,b as b$1,d}from'./chunk-7RIWU5TZ.js';import {a}from'./chunk-LG6RFLPZ.js';import {f as f$1,o,l,r}from'./chunk-5XATWNME.js';import x from'crypto';import U from'os';import f from'path';import {once}from'events';import {createWriteStream,createReadStream}from'fs';import*as L from'readline';import {Transform,Readable}from'stream';import {pipeline}from'stream/promises';import h from'fs-extra';import*as K from'yauzl';import*as Z from'yazl';var P=".workspai/archive-manifest.json",S=".rapidkit/archive-manifest.json",ie="workspai.workspace.archive",se=1800*1e3,ne=256*1024*1024,oe=new Set(["__pycache__",".venv","venv","node_modules",".git","dist","build","target",".pytest_cache",".mypy_cache",".ruff_cache","htmlcov",".next",".turbo",".cache"]),ce=new Set([".DS_Store","Thumbs.db",".coverage","npm-debug.log","yarn-error.log","pnpm-debug.log"]),he=[/^\.env$/i,/^\.env\.(?!example$|sample$|template$).+/i,/^.*\.pem$/i,/^.*\.key$/i,/^id_rsa$/i,/^id_ed25519$/i];function R(e){return e.replace(/\\/g,"/")}function J(e){return e.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(e){let t=R(e).trim();if(!t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0"))return false;let r=t.split("/").filter(Boolean);return r.length>0&&!r.some(a=>a===".."||a===".")}function G(e){if(!q(e))throw new Error(`Archive contains an unsafe path: ${e}`)}function fe(e,t){let r=f.relative(t,e);return r===""||!!r&&!r.startsWith("..")&&!f.isAbsolute(r)}function le(e,t){let a=R(e).split("/").filter(Boolean);if((a[0]===".workspai"||a[0]===".rapidkit")&&["cache","reports"].includes(a[1]||"")||a.some(s=>oe.has(s)))return true;let i=a[a.length-1]||"";return ce.has(i)||/\.(?:workspai|rapidkit)-archive\.zip$/i.test(i)||!t?.includeEnv&&he.some(s=>s.test(i))?true:i.endsWith(".pyc")||i.endsWith(".log")}async function*X(e,t,r){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(e,s));if(!(!n||le(n,r))){if(i.isDirectory()){yield*X(e,s,r);continue}i.isFile()&&(yield {relativePath:n,fullPath:s});}}}async function pe(e){for(let t of o(e,"workspace.json"))try{let r=await h.readJson(t);if(typeof r.workspace_name=="string"&&r.workspace_name.trim())return r.workspace_name.trim();if(typeof r.name=="string"&&r.name.trim())return r.name.trim()}catch{}return f.basename(f.resolve(e))}async function me(e){let t=await h.stat(e.fullPath),r=x.createHash("sha256"),a=0;for await(let s of createReadStream(e.fullPath)){let n=Buffer.isBuffer(s)?s:Buffer.from(s);a+=n.length,r.update(n);}let i=await h.stat(e.fullPath);if(t.size!==i.size||t.mtimeMs!==i.mtimeMs||a!==i.size)throw new Error(`Workspace file changed while preparing archive: ${e.relativePath}`);return {...e,size:a,mtimeMs:i.mtimeMs,sha256:r.digest("hex")}}async function k(e,t){e.write(t)||await once(e,"drain");}async function Y(e){await new Promise((t,r)=>{e.once("error",r),e.end(t);});}async function*b(e){let t=L.createInterface({input:createReadStream(e),crlfDelay:1/0});for await(let r of t){let a=r.trim();a&&(yield JSON.parse(a));}}async function ue(e){let t=createWriteStream(e.manifestPath,{flags:"wx"});try{await k(t,`{
|
|
2
|
-
`);for(let[a,i]of Object.entries(e.manifestBase))await k(t,` ${JSON.stringify(a)}: ${JSON.stringify(i,null,2)},
|
|
3
|
-
`);await k(t,` "files": [
|
|
4
|
-
`);let r=true;for await(let a of b(e.spoolPath)){let{mtimeMs:i,...s}=a;await k(t,`${r?"":`,
|
|
5
|
-
`} ${JSON.stringify(s)}`),r=false;}await k(t,`
|
|
6
|
-
]
|
|
7
|
-
}
|
|
8
|
-
`),await Y(t);}catch(r){throw t.destroy(),await h.remove(e.manifestPath).catch(()=>{}),r}}async function de(e,t){let r=[];for await(let a of b(t)){let{mtimeMs:i,...s}=a;r.push(s);}return {...e,files:r}}async function ve(e,t){try{await h.rename(e,t);}catch(r){let a=r.code;if(a!=="EEXIST"&&a!=="EPERM")throw r;await h.move(e,t,{overwrite:true});}}async function Fe(e){let t=f.resolve(e.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 r=await pe(t),a=f.resolve(e.outputPath||`${J(r)}.workspai-archive.zip`),i={schemaVersion:b$1,version:1,kind:ie,workspaceName:r,exportedAt:(e.now??new Date).toISOString(),exportedBy:"workspai",archiveFormat:e.compression==="deflate"?"zip-deflate":"zip-store",containerFormat:"zip64",compression:e.compression==="deflate"?"deflate":"store",streaming:true,security:{envFilesIncluded:e.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}.${x.randomUUID()}.tmp`,o=await h.mkdtemp(f.join(U.tmpdir(),"workspai-archive-export-")),l=f.join(o,"manifest-files.jsonl"),m=f.join(o,"archive-manifest.json"),d=new Z.ZipFile,y=e.now??new Date,c$1=e.compression==="deflate";try{let p=createWriteStream(l,{flags:"wx"});try{for await(let u of X(t,t,{includeEnv:e.includeEnv===true})){if(f.resolve(u.fullPath)===s)continue;let v=await me(u),E={path:v.relativePath,size:v.size,sha256:v.sha256,mtimeMs:v.mtimeMs};await k(p,`${JSON.stringify(E)}
|
|
9
|
-
`);}await Y(p);}catch(u){throw p.destroy(),u}await ue({manifestBase:i,spoolPath:l,manifestPath:m});for await(let u of b(l)){let v=f.join(t,...u.path.split("/"));d.addFile(v,u.path,{compress:c$1,forceZip64Format:u.size>=4294967295,mtime:y});}d.addFile(m,P,{compress:c$1,mtime:y}),d.end({forceZip64Format:true,comment:""}),await pipeline(d.outputStream,createWriteStream(n,{flags:"wx"}));for await(let u of b(l)){let v=f.join(t,...u.path.split("/")),E=await h.stat(v);if(E.size!==u.size||E.mtimeMs!==u.mtimeMs)throw new Error(`Workspace file changed while writing archive: ${u.path}`)}let w=await h.stat(n);await ve(n,a);let g=await de(i,l);return _({schemaVersion:c,operation:"export",status:"passed",archivePath:a,manifest:g,bytesWritten:w.size})}finally{await h.remove(o).catch(()=>{}),await h.remove(n).catch(()=>{});}}async function Q(e,t={}){if(/^https?:\/\//i.test(e)){let r=await h.mkdtemp(f.join(U.tmpdir(),"workspai-workspace-archive-")),a=f.join(r,"workspace.workspai-archive.zip"),i=new AbortController,s=t.downloadTimeoutMs??se,n=s>0?setTimeout(()=>i.abort(new Error("Download timed out")),s):null;try{let o=await fetch(e,{signal:i.signal});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 l=Number(o.headers.get("content-length"));if(t.maxDownloadBytes!==void 0&&Number.isFinite(l)&&l>t.maxDownloadBytes)throw new Error(`Workspace archive download exceeds configured limit (${l} > ${t.maxDownloadBytes} bytes).`);let m=0,d=new Transform({transform(c,p,w){if(m+=c.length,t.maxDownloadBytes!==void 0&&m>t.maxDownloadBytes){w(new Error(`Workspace archive download exceeds configured limit (${t.maxDownloadBytes} bytes).`));return}w(null,c);}}),y=Readable.fromWeb(o.body);return await pipeline(y,d,createWriteStream(a,{flags:"wx"})),{archivePath:a,cleanup:r}}catch(o){throw await h.remove(r).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(e)}}function we(e){return new Promise((t,r)=>{K.open(e,{autoClose:false,lazyEntries:true,decodeStrings:true,validateEntrySizes:true,strictFileNames:true},(a,i)=>{a||!i?r(a??new Error("Failed to open workspace archive.")):t(i);});})}function ye(e){return new Promise((t,r)=>{let a=[],i=s=>r(s);e.once("error",i),e.on("entry",s=>{try{if(G(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}),e.readEntry();}catch(n){r(n);}}),e.once("end",()=>{e.removeListener("error",i),t(a);}),e.readEntry();})}function N(e,t){return new Promise((r,a)=>{e.openReadStream(t,(i,s)=>{i||!s?a(i??new Error(`Failed to read ${t.fileName}.`)):r(s);});})}async function ge(e,t,r=ne){if(t.size>r)throw new Error(`Workspace archive manifest exceeds ${r} bytes.`);let a=[],i=0,s=await N(e,t.entry);for await(let n of s){let o=Buffer.isBuffer(n)?n:Buffer.from(n);if(i+=o.length,i>r)throw s.destroy(),new Error(`Workspace archive manifest exceeds ${r} bytes.`);a.push(o);}return Buffer.concat(a,i)}function Ee(e){let t=JSON.parse(e.toString("utf-8"));a(t,d,"Workspace archive manifest");let r=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(r.has(a.path))throw new Error(`Workspace archive manifest contains duplicate path: ${a.path}`);r.add(a.path);}return t}function _(e$1){return a(e$1,e,"Workspace archive operation result"),e$1}function Ae(e){return r(R(e))}function ke(e){let t=new Map;for(let r of e){if(r.name===P||r.name===S)continue;let a=Ae(r.name),i=t.get(a);if(!i){t.set(a,{...r,sourceName:r.name,targetName:a});continue}let s=r.name===a,n=i.sourceName===i.targetName;if(s&&!n){t.set(a,{...r,sourceName:r.name,targetName:a});continue}if(!(i.size===r.size&&i.crc32===r.crc32)&&!n)throw new Error(`Workspace archive contains conflicting entries for ${a}: ${i.sourceName}, ${r.name}`)}return [...t.values()].sort((r,a)=>r.targetName.localeCompare(a.targetName))}async function C(e,t={}){let r=await Q(e,t),a;try{a=await we(r.archivePath);let i=await ye(a),s=i.reduce((l,m)=>l+m.size,0);if(t.maxExpandedBytes!==void 0&&s>t.maxExpandedBytes)throw new Error(`Workspace archive payload exceeds configured limit (${s} > ${t.maxExpandedBytes} bytes).`);let n=i.find(l=>l.name===P||l.name===S);if(!n)throw new Error(`Workspace archive is missing ${l("","archive-manifest.json").replace(/^\//,"")}.`);let o=Ee(await ge(a,n));return {archivePath:r.archivePath,entries:i,manifest:o,zipFile:a,cleanup:r.cleanup}}catch(i){throw a?.close(),r.cleanup&&await h.remove(r.cleanup).catch(()=>{}),i}}async function M(e){e.zipFile?.close(),e.cleanup&&await h.remove(e.cleanup).catch(()=>{});}async function Pe(e){let t=await C(e.archivePathOrUrl,e.safety);try{let r=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:r.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 M(t);}}async function ee(e){let t=await C(e.archivePathOrUrl,e.safety);try{let r=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=[...r.keys()].filter(c=>!a.has(c)).sort(),s=[],n=[],o=[],l=0;for(let c of t.manifest.files){G(c.path);let p=r.get(c.path);if(!p){s.push(c.path);continue}let w=x.createHash("sha256"),g=0,u=await N(t.zipFile,p.entry);for await(let E of u){let $=Buffer.isBuffer(E)?E:Buffer.from(E);g+=$.length,w.update($);}let v={size:g,sha256:w.digest("hex")};if(g!==p.size||g!==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}l+=1;}let m=e.requireChecksums===true&&n.length>0,d=s.length>0||o.length>0||m||i.length>0,y=n.length>0;return _({schemaVersion:c,operation:"verify",archivePath:t.archivePath,manifest:t.manifest,status:d?"failed":y?"warning":"passed",fileCount:t.manifest.files.length,totalBytes:t.manifest.files.reduce((c,p)=>c+p.size,0),verifiedFiles:l,missingChecksumFiles:n,missingArchiveEntries:s,extraArchiveEntries:i,mismatches:o})}finally{await M(t);}}async function Ve(e){let t=await Q(e.archivePathOrUrl,e.safety);try{return await We({archivePath:t.archivePath,strict:e.strict})}finally{t.cleanup&&await h.remove(t.cleanup).catch(()=>{});}}async function We(e){let t=await Pe({archivePathOrUrl:e.archivePath}),r=await ee({archivePathOrUrl:e.archivePath,requireChecksums:e.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:r.status,message:r.status==="passed"?`Verified ${r.verifiedFiles}/${r.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."),r.missingChecksumFiles.length>0&&i.push("Re-export the archive with the latest RapidKit/Workspai tooling."),r.mismatches.length>0&&i.push("Reject this archive and request a fresh export from the owner."),(r.extraArchiveEntries.length>0||r.missingArchiveEntries.length>0)&&i.push("Regenerate the archive so ZIP entries and manifest entries match."),e.strict===true&&r.status!=="passed"&&i.push("Do not hydrate this archive in strict or production workflows.");let n=a.some(l=>l.status==="failed"),o=a.some(l=>l.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 Se(e,t){let r=await h.lstat(e).catch(i=>{if(i.code==="ENOENT")return null;throw i});if(!r)return false;if(r.isSymbolicLink())throw new Error(`Output directory must not be a symbolic link: ${e}`);if(!r.isDirectory())throw new Error(`Output path is not a directory: ${e}`);if((await h.readdir(e)).length>0&&!t)throw new Error(`Output directory is not empty: ${e}. Use --force to overwrite.`);return true}async function De(e){let t=await C(e.archivePathOrUrl,e.safety);try{let r=await ee({archivePathOrUrl:t.archivePath,requireChecksums:e.strict===true});if(r.status==="failed"){let o=[r.missingArchiveEntries.length?`missing entries: ${r.missingArchiveEntries.join(", ")}`:"",r.extraArchiveEntries.length?`unexpected entries: ${r.extraArchiveEntries.join(", ")}`:"",r.mismatches.length?`checksum/size mismatches: ${r.mismatches.map(l=>l.path).join(", ")}`:"",r.missingChecksumFiles.length&&e.strict===true?`missing checksums: ${r.missingChecksumFiles.join(", ")}`:""].filter(Boolean).join("; ");throw new Error(`Workspace archive verification failed${o?` (${o})`:""}.`)}if(r.status==="warning"&&e.strict===true)throw new Error(`Workspace archive verification requires checksums for every file: ${r.missingChecksumFiles.join(", ")}`);let a=ke(t.entries),i=t.manifest,s=f.resolve(e.outputPath||J(i.workspaceName||"imported-workspace")),n=await Se(s,e.force===true);if(!e.dryRun){let o=f.dirname(s),l=`${process.pid}-${x.randomUUID()}`,m=f.join(o,`.${f.basename(s)}.hydrate-${l}.tmp`),d=f.join(o,`.${f.basename(s)}.hydrate-${l}.backup`),y=false,c=false;await h.ensureDir(o);try{await h.ensureDir(m);for(let p of a){let w=f.resolve(m,p.targetName);if(!fe(w,m))throw new Error(`Archive entry escapes output directory: ${p.targetName}`);await h.ensureDir(f.dirname(w));let g=await N(t.zipFile,p.entry);await pipeline(g,createWriteStream(w,{flags:"wx"}));}n&&(await h.rename(s,d),y=true),await h.rename(m,s),c=true,y&&await h.remove(d).catch(()=>{});}catch(p){throw y&&!await h.pathExists(s)&&await h.rename(d,s).catch(()=>{}),p}finally{await h.remove(m).catch(()=>{}),c&&await h.remove(d).catch(()=>{});}}return _({schemaVersion:c,operation:"hydrate",status:"passed",archivePath:t.archivePath,outputPath:s,dryRun:e.dryRun===true,manifest:i,files:a.map(o=>({path:o.targetName,size:o.size}))})}finally{await M(t);}}
|
|
10
|
-
export{ie as WORKSPACE_ARCHIVE_KIND,P as WORKSPACE_ARCHIVE_MANIFEST_PATH,Ve as doctorWorkspaceArchive,Fe as exportWorkspaceArchive,De as hydrateWorkspaceArchive,Pe as inspectWorkspaceArchive,q as isSafeArchiveEntryName,J as sanitizeWorkspaceArchiveName,le as shouldExcludeWorkspaceArchivePath,ee as verifyWorkspaceArchive};
|
|
@@ -1 +0,0 @@
|
|
|
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,g as buildWorkspaceContract,k as buildWorkspaceContractGraph,f as discoverProjectJsonFiles,j as readWorkspaceContract,i as syncWorkspaceContract,l as verifyWorkspaceContract,h as writeWorkspaceContract,m as writeWorkspaceContractVerifyEvidence}from'./chunk-QWU2CZBG.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{b as buildWorkspaceExplain,a as resolveWorkspaceExplainArtifactPath,c as writeWorkspaceExplainReport}from'./chunk-IMUU5Q2V.js';export{e as WORKSPACE_MODEL_DIFF_REPORT_PATH}from'./chunk-ZWO6K24C.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-XIVFLY6G.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as WORKSPACE_EXPLAIN_SCHEMA_VERSION,b as WORKSPACE_EXPLAIN_TARGETS,e as isWorkspaceExplainReport,c as parseWorkspaceExplainTarget,d as resolveWorkspaceTraceTarget}from'./chunk-J4AICQFB.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-XIVFLY6G.js';
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {a,b}from'./chunk-GSWPGELT.js';import {o}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){if(!await l.pathExists(n))return false;let o=c(await l.readJson(n));return await l.outputJson(n,e(o),{spaces:2}),await l.appendFile(n,`
|
|
2
|
-
`,"utf-8"),true}async function f(n,e){let o$1=e.now??new Date().toISOString(),d=e.installMethod==="pip"?"venv":e.installMethod;for(let r of o(n,"workspace.json"))await m(r,a=>{let s=c(a.engine),i=c(s.python_core);return delete a.bootstrap_note,delete i.reason,{...a,engine:{...s,install_method:d,python_version:e.pythonVersion??s.python_version??null,python_core:{...i,status:"installed",installed_at:o$1,...e.coreVersion?{version:e.coreVersion}:{}}}}});for(let r of o(n,"toolchain.lock"))await m(r,a=>{let s=c(a.runtime),i=c(s.python),h=c(i.core);return delete h.reason,{...a,generated_at:o$1,runtime:{...s,python:{...i,version:e.pythonVersion??i.version??null,install_method:d,core:{...h,status:"installed",installed_at:o$1,...e.coreVersion?{version:e.coreVersion}:{}}}}}});let t=await a(n);if(t){let r={...t.metadata?.python??{}};delete r.coreReason,t.metadata={...t.metadata,python:{...r,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:d,lastUsedAt:o$1}},await b(n,t);}}export{f as markWorkspacePythonEngineInstalled};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a}from'./chunk-A5FBGRJA.js';import {b as b$1,j}from'./chunk-QWU2CZBG.js';import {f,g}from'./chunk-6AA3WWQZ.js';import {r,p}from'./chunk-2K3GYCPS.js';import {o}from'./chunk-5XATWNME.js';import n from'path';import {existsSync}from'fs';import y from'fs-extra';var k=".workspai/workspace-registry.v1.json",w="workspace-registry.v1";function C(t){return {slug:t.slug,relativePath:t.relativePath,framework:t.framework,kit:t.kit,source:t.source}}async function x(t){let r=o(t,"workspace.json").find(e=>existsSync(e));if(!r)return {exists:false,legacyProjectCount:0};try{let e=await y.readJson(r),s=Array.isArray(e.projects)?e.projects.length:0,o=typeof e.workspace_name=="string"&&e.workspace_name.trim()||typeof e.name=="string"&&e.name.trim()||n.basename(t);return {exists:true,manifestPath:r,workspaceName:o,profile:typeof e.profile=="string"?e.profile:void 0,legacyProjectCount:s}}catch{return {exists:true,manifestPath:r,legacyProjectCount:0,workspaceName:n.basename(t)}}}async function A(t){let r$1=a(t);for(let e of r())if(await y.pathExists(e))try{let o=((await y.readJson(e)).workspaces||[]).find(a$1=>a(a$1.path)===r$1);if(o)return {exists:true,projectCount:Array.isArray(o.projects)?o.projects.length:0,registryPath:e}}catch{continue}return {exists:false,projectCount:0,registryPath:n.join(p(),"workspaces.json")}}async function b(t){let r=n.resolve(t),e=await f(r,b$1),s=await x(r),o=await A(r),a=!!e,c=[];if(a)try{let{contract:S}=await j({workspacePath:r});c=S.projects||[];}catch{c=[];}let W={contract:{exists:a,projectCount:c.length,path:b$1},globalRegistry:{exists:o.exists,projectCount:o.projectCount,path:o.registryPath},legacyWorkspaceJson:{exists:s.exists,projectCount:s.legacyProjectCount,path:s.manifestPath?n.relative(r,s.manifestPath):void 0}},i="none",u=[],p=0;return a?(i="workspace.contract.json",u=c.map(C),p=u.length):o.projectCount>0?(i="global-registry",p=o.projectCount):s.legacyProjectCount>0&&(i="legacy-workspace.json",p=s.legacyProjectCount),{contractExists:a,summary:{schemaVersion:w,kind:"rapidkit.workspace.registry",workspacePath:r,workspaceName:s.workspaceName||n.basename(r),profile:s.profile,projectCount:p,authority:i,contractPath:b$1,projects:u,sources:W}}}async function J(t){let r=await f(t,k);if(!r)return null;try{let e=await y.readJson(r);return e?.schemaVersion!==w?null:e}catch{return null}}async function V(t,r){let s={...(await b(t)).summary,generatedAt:(r?.now??new Date).toISOString(),registrySummaryPath:k};return await g(t,k,s),s}function Y(t,r=""){return t.projectCount>0?t.authority==="workspace.contract.json"?`${t.projectCount} project(s) registered in workspace contract${r}.`:t.authority==="global-registry"?`${t.projectCount} project(s) registered in global workspace registry${r}.`:`${t.projectCount} project(s) registered in legacy workspace manifest${r}.`:`Workspace state exists, but no projects are registered yet${r}.`}export{k as WORKSPACE_REGISTRY_SUMMARY_RELATIVE_PATH,w as WORKSPACE_REGISTRY_SUMMARY_SCHEMA_VERSION,Y as formatWorkspaceRegistrySyncSummary,V as publishWorkspaceRegistrySummary,J as readWorkspaceRegistrySummary,b as resolveWorkspaceRegisteredProjects};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as runWorkspaceStage}from'./chunk-WANW4QA4.js';export{a as WORKSPACE_RUN_LAST_REPORT_FILENAME}from'./chunk-KU4S7RCM.js';
|