workspai 0.47.0 → 0.49.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 +247 -136
- package/contracts/agent-customization-pack.v1.json +5 -0
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +4 -0
- package/contracts/extension-cli-compatibility.v1.json +8 -2
- package/contracts/published-contract-catalog.v1.json +33 -1
- package/contracts/runtime-command-surface.v1.json +163 -3
- package/contracts/workspace-intelligence/model-usage-event.v1.json +82 -0
- package/contracts/workspace-intelligence/workspace-graph-stream.v1.json +262 -0
- package/contracts/workspace-intelligence/workspace-intelligence-evaluation-comparison.v1.json +53 -0
- package/contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json +120 -0
- package/contracts/workspace-intelligence-architecture.v1.json +31 -2
- package/contracts/workspace-intelligence-chain.v1.json +44 -3
- package/dist/analyze-EEEU3MIF.js +1 -0
- package/dist/{artifact-remediation-plan-EPALZ2LC.js → artifact-remediation-plan-SPOUHMK5.js} +1 -1
- package/dist/autopilot-release-R4XRTWEM.js +1 -0
- package/dist/{chunk-2TEDAKP6.js → chunk-32OJDBIG.js} +1 -1
- package/dist/{chunk-ZDN7RHXJ.js → chunk-37CVKXBD.js} +1 -1
- package/dist/{chunk-YCL3I2JO.js → chunk-3NU32T4A.js} +1 -1
- package/dist/chunk-3VFA7D5T.js +1 -0
- package/dist/{chunk-CW7PGBIQ.js → chunk-4HDYADHT.js} +1 -1
- package/dist/{chunk-PBHP6JNY.js → chunk-54EP5CEV.js} +1 -1
- package/dist/{chunk-NOFM7MNA.js → chunk-AFL3ACCR.js} +1 -1
- package/dist/{chunk-MEMHNE7Y.js → chunk-BFLJ2R4D.js} +1 -1
- package/dist/{chunk-6SWRNA47.js → chunk-BGPXQQNY.js} +1 -1
- package/dist/chunk-BMWFQXGW.js +1 -0
- package/dist/{chunk-2GHUZDYA.js → chunk-CRHYBQI3.js} +1 -1
- package/dist/{chunk-KZZ36CK5.js → chunk-E2KJ5QWY.js} +1 -1
- package/dist/{chunk-BSRVO52Y.js → chunk-EKZLUMCS.js} +2 -2
- package/dist/{chunk-76YOPAOT.js → chunk-ESLPI3XZ.js} +1 -1
- package/dist/{chunk-DV6GJD4K.js → chunk-HDXNIN4N.js} +1 -1
- package/dist/{chunk-TNQI5VCW.js → chunk-HZDXO65G.js} +14 -14
- package/dist/{chunk-COARSXRC.js → chunk-J5ENLXDF.js} +1 -1
- package/dist/{chunk-QDWYIRHR.js → chunk-K4X3DM7R.js} +1 -1
- package/dist/chunk-LHOZXC2M.js +2 -0
- package/dist/{chunk-RWRLFSKW.js → chunk-NAJCUQ4X.js} +1 -1
- package/dist/{chunk-ZM5NQ5Z2.js → chunk-OW42TZFB.js} +1 -1
- package/dist/{chunk-SK6XRKGG.js → chunk-P3D5YQB2.js} +1 -1
- package/dist/{chunk-TWNFECMN.js → chunk-PHXQR6PX.js} +1 -1
- package/dist/{chunk-ITCAMC2E.js → chunk-PRTR2DQ2.js} +1 -1
- package/dist/{chunk-7VLCK5JW.js → chunk-RHQW3DTP.js} +1 -1
- package/dist/{chunk-22NJ2ZMG.js → chunk-T4YR4RAI.js} +1 -1
- package/dist/{chunk-VBSQ7MF6.js → chunk-TIE2XMGH.js} +20 -20
- package/dist/{chunk-HSGFUKCN.js → chunk-VU7NZHPM.js} +1 -1
- package/dist/{chunk-U5EZHZBX.js → chunk-YJZOMRAS.js} +1 -1
- package/dist/{create-7JKJDAQV.js → create-S64IWHAP.js} +1 -1
- package/dist/{doctor-PGPNIS76.js → doctor-4NNUDNGZ.js} +1 -1
- package/dist/{dotnet-webapi-clean-6TVFBTVI.js → dotnet-webapi-clean-A6MVDYXX.js} +4 -4
- package/dist/{gofiber-standard-2BL7GWZB.js → gofiber-standard-I5YPQG5V.js} +1 -1
- package/dist/{gogin-standard-XGP3KBXA.js → gogin-standard-VY2L4QT5.js} +1 -1
- package/dist/index.d.ts +35 -11
- package/dist/index.js +138 -136
- package/dist/{pipeline-IB6ILJSV.js → pipeline-LHTPE3DR.js} +1 -1
- package/dist/{springboot-standard-JJNUID6M.js → springboot-standard-55XKCBIZ.js} +4 -4
- package/dist/{workspace-H3QXBFGB.js → workspace-PJPRBUMQ.js} +1 -1
- package/dist/{workspace-agent-sync-C7SG2Z5W.js → workspace-agent-sync-662QHXGF.js} +1 -1
- package/dist/{workspace-context-BKQBKA4C.js → workspace-context-23YYCUCP.js} +1 -1
- package/dist/{workspace-contract-RPQQBQXR.js → workspace-contract-TU2I7GC2.js} +1 -1
- package/dist/{workspace-dependency-graph-23BI2HG7.js → workspace-dependency-graph-BP4EXYQ5.js} +1 -1
- package/dist/workspace-explain-MWUEN643.js +1 -0
- package/dist/workspace-explain-contract-ZPI3JXJU.js +1 -0
- package/dist/{workspace-feedback-WAID3IOE.js → workspace-feedback-SUVH2LUJ.js} +1 -1
- package/dist/{workspace-foundation-5OOJEO2D.js → workspace-foundation-WPLD7OEO.js} +1 -1
- package/dist/workspace-graph-stream-KAGGQPJT.js +1 -0
- package/dist/{workspace-history-C6OP3IAQ.js → workspace-history-BANOJRQ2.js} +1 -1
- package/dist/{workspace-intelligence-VKDL3H2J.js → workspace-intelligence-MFJE7W67.js} +1 -1
- package/dist/workspace-intelligence-evaluation-IPH7M3WV.js +1 -0
- package/dist/{workspace-intelligence-runner-LVALAZY7.js → workspace-intelligence-runner-OTYTHV6B.js} +1 -1
- package/dist/{workspace-knowledge-graph-FE2NTZKV.js → workspace-knowledge-graph-ARDC6HHG.js} +1 -1
- package/dist/workspace-knowledge-graph-export-UYAYFTWX.js +10 -0
- package/dist/workspace-mcp-serve-EZR6O76D.js +3 -0
- package/dist/{workspace-model-S33CIB2R.js → workspace-model-7OU2M3LE.js} +1 -1
- package/dist/{workspace-registry-summary-A3YDL63D.js → workspace-registry-summary-ORDK7A36.js} +1 -1
- package/dist/workspace-run-QND2SIYA.js +1 -0
- package/dist/{workspace-verify-ZGH3NXAH.js → workspace-verify-EBVL7FWT.js} +1 -1
- package/dist/workspace-watch-7HWGA5TF.js +1 -0
- package/docs/GLOSSARY.md +28 -24
- package/docs/OPEN_SOURCE_USER_SCENARIOS.md +11 -8
- package/docs/README.md +62 -23
- package/docs/README_CONTENT_CONTRACT.md +154 -0
- package/docs/ci-workflows.md +3 -3
- package/docs/commands-reference.md +16 -3
- package/docs/contracts/ARTIFACT_CATALOG.md +35 -20
- package/docs/contracts/README.md +3 -0
- package/docs/creating-workspaces-and-projects.md +16 -12
- package/docs/doctor-command.md +30 -28
- package/docs/examples/ci-agent-grounding.yml +1 -1
- package/docs/from-code-to-shared-understanding.md +2 -2
- package/docs/graph-benchmark-methodology.md +2 -2
- package/docs/workspace-intelligence-evaluation.md +149 -0
- package/docs/workspace-intelligence-runner.md +17 -6
- package/docs/workspace-knowledge-graph.md +31 -10
- package/docs/workspace-operations.md +13 -5
- package/package.json +9 -4
- package/templates/kits/fastapi-ddd/README.md.j2 +1 -1
- package/dist/analyze-UVXPRGYZ.js +0 -1
- package/dist/autopilot-release-5BQ6F5L2.js +0 -1
- package/dist/chunk-LNRAB7UY.js +0 -1
- package/dist/chunk-NRYS4CLR.js +0 -2
- package/dist/workspace-explain-WVN7JH3U.js +0 -1
- package/dist/workspace-explain-contract-SEFTVF6J.js +0 -1
- package/dist/workspace-mcp-serve-KT2I676Z.js +0 -3
- package/dist/workspace-run-M4LNJILC.js +0 -1
- package/dist/workspace-watch-EVBJTMV7.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {f as f$2,e}from'./chunk-T3GJ7YVG.js';import {a as a$1,b as b$2}from'./chunk-22DT744Z.js';import {h,i}from'./chunk-4KUIFXHM.js';import {e as e$1}from'./chunk-
|
|
1
|
+
import {f as f$2,e}from'./chunk-T3GJ7YVG.js';import {a as a$1,b as b$2}from'./chunk-22DT744Z.js';import {h,i}from'./chunk-4KUIFXHM.js';import {e as e$1}from'./chunk-32OJDBIG.js';import {a as a$2}from'./chunk-GZTYAEWX.js';import {a,b as b$1}from'./chunk-BMWFQXGW.js';import {f as f$1,o as o$1,p as p$1}from'./chunk-5XATWNME.js';import b from'fs';import p from'path';import o from'chalk';var H=new Set([".git",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function D(e){try{return await b.promises.access(e,b.constants.F_OK),true}catch{return false}}async function P(e){try{let n=JSON.parse(await b.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function L(e){try{return await b.promises.readFile(e,"utf-8")}catch{return ""}}function K(e){return a$1(e)}async function B(e,n){return await N([...p$1(e,"project.json"),...p$1(e,"context.json")])?true:b$2(e)?false:p.resolve(e)===p.resolve(n)?h(e).length>0:h(e).length>0}async function U(e){let n=await a$2(e,{skipDirs:H,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:B});return n.length>0?n:b$2(e)?[]:h(e).length>0?[e]:[]}function V(e,n){return p.relative(e,n).replace(/\\/g,"/")||"."}async function A(e,n){for(let t of n)if(await D(p.join(e,t)))return true;return false}async function N(e){for(let n of e)if(await D(n))return true;return false}async function M(e){for(let n of e){let t=await P(n);if(t)return t}return null}async function q(e){return A(e,["health","health.ts","health.js","health.py","health.go","health.kt","health.rb","health.php","healthcheck","health-check","src/health.ts","src/health.js","src/health.py","src/health.go","src/health.kt","src/health.rb","src/health.php","src/healthcheck.ts","src/healthcheck.js","src/liveness.ts","src/readiness.ts","src/ping.ts"])}async function Q(e){if(await A(e,["tests","test","__tests__","src/__tests__","pytest.ini","vitest.config.ts","jest.config.ts"]))return true;let t=await P(p.join(e,"package.json")),r=t?.scripts&&typeof t.scripts=="object"?t.scripts:{};return typeof r.test=="string"&&r.test.trim().length>0}async function X(e){let n=await P(p.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function f(e,n,t,r,s,a){return {id:e,severity:n,target:t,title:r,detail:s,remediation:a}}function Y(e){let n=e.reduce((t,r)=>r.severity==="fail"?t+28:r.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function Z(e,n){let t=await M(p$1(n,"project.json")),r=i(n,t),s=h(n),a=r.runtime==="unknown"?s[0]||"unknown":r.runtime,i$1=V(e,n),l=i$1,u=await X(n),g=await N([...p$1(n,"project.json"),...p$1(n,"context.json")]),d=await Q(n),h$1=await A(n,["Dockerfile","dockerfile"]),k=await A(n,[".env.example","env.example","config/env.example"]),z=await A(n,[".github/workflows/ci.yml",".github/workflows/ci.yaml",".github/workflows/main.yml",".github/workflows/build.yml",".github/workflows/test.yml",".github/workflows/deploy.yml",".gitlab-ci.yml",".circleci/config.yml","azure-pipelines.yml","bitbucket-pipelines.yml","cloudbuild.yaml"]),C=await q(n),m=[];return r.key==="unknown"&&m.push(f("project.stack.unknown","fail",l,"Project stack is unknown","Workspai cannot confidently classify this backend project.","Add .workspai/project.json metadata or import the project with `workspai import`.")),g||m.push(f("project.marker.missing","warn",l,"Workspai marker is missing","The project can be detected by files, but it is not registered with Workspai metadata.","Run `workspai import <path>` from a workspace or create the project through Workspai.")),d||m.push(f("project.tests.missing","warn",l,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `workspai workspace run test --affected` can gate changes.")),k||m.push(f("project.env.example.missing","info",l,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.")),z||m.push(f("project.ci.missing","warn",l,"Continuous integration is missing","No recognized CI/CD configuration file was detected for this project.","Add CI configuration so tests and checks run automatically for every change.")),C||m.push(f("project.health.missing","info",l,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),h$1||m.push(f("project.container.missing","info",l,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.")),{name:p.basename(n),path:n,relativePath:i$1,runtime:a,framework:r.key,confidence:r.confidence,supportTier:r.supportTier,hasRapidKitMarker:g,hasTests:d,hasDockerfile:h$1,hasEnvExample:k,hasCiConfig:z,hasHealthEndpoint:C,scripts:u,findings:m,score:Y(m)}}function ee(e){return e.name.toLowerCase()}async function ne(e){let n=new Map(e.map(s=>[ee(s),s])),t=[];for(let s of e){let a=await P(p.join(s.path,"package.json")),i={...a?.dependencies??{},...a?.devDependencies??{},...a?.peerDependencies??{}};for(let u of Object.keys(i)){let g=u.replace(/^@[^/]+\//,"").toLowerCase(),d=n.get(g);d&&d.relativePath!==s.relativePath&&t.push({from:s.relativePath,to:d.relativePath,kind:"package"});}let l=await L(p.join(s.path,"pyproject.toml"));for(let u of e)u.relativePath!==s.relativePath&&l.includes(u.name)&&t.push({from:s.relativePath,to:u.relativePath,kind:"workspace-reference"});}let r=new Set;return t.filter(s=>{let a=`${s.from}\0${s.to}\0${s.kind}`;return r.has(a)?false:(r.add(a),true)})}function te(e,n){let t=new Map;for(let r of e)t.set(r.relativePath,{project:r.relativePath,directDependents:0,directDependencies:0});for(let r of n){let s=t.get(r.from),a=t.get(r.to);s&&(s.directDependencies+=1),a&&(a.directDependents+=1);}return Array.from(t.values()).sort((r,s)=>s.directDependents-r.directDependents||s.directDependencies-r.directDependencies)}async function re(e){let n=await M(o$1(e,"workspace.json"));return typeof n?.profile=="string"?n.profile:null}function se(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function oe(e){if(e.projectCount===0)return e.workspaceDetected?["Add your first project: npx workspai create project <name> --kit <kit>","Import an existing service: npx workspai import <path>"]:["Create a Workspai workspace: npx workspai create workspace my-workspace --profile polyglot","Import an existing service: npx workspai import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `workspai bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `workspai import <path>` or recreate them via `workspai create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `workspai workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasGraph||n.push("Create `.workspai/workspace-dependency-graph.json` or use analyze output as the first graph seed."),n.push("Run `workspai autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function ke(e$2={}){let n=p.resolve(e$2.workspacePath||process.cwd());if(!await D(n))throw new Error(`Workspace path does not exist: ${n}`);let t=K(n)??n,r=f$1(t),s=await re(t),a$1=await U(t),i=await Promise.all(a$1.map(c=>Z(t,c))),l=await ne(i),u=te(i,l),g=[];r||g.push(f("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered Workspai workspace.","Run `workspai create workspace` or `workspai bootstrap --profile polyglot` in a workspace root.")),i.length===0&&g.push(f("workspace.projects.missing","warn",".","No backend projects detected","Workspai did not find runtime markers or project metadata under this root.","Create a project with `workspai create project` or import one with `workspai import <path>`."));let d=[...g,...i.flatMap(c=>c.findings)],h=se(d),k={};for(let c of i)k[c.runtime]=(k[c.runtime]||0)+1;let z=i.length>0?Math.round(i.reduce((c,y)=>c+y.score,0)/i.length):0,C=g.reduce((c,y)=>c+(y.severity==="fail"?20:y.severity==="warn"?8:2),0),m=Math.max(0,z-C),O=i.length===0&&h.fail===0&&d.length>0&&d.every(c=>c.id==="workspace.projects.missing"&&c.severity==="warn"),J=h.fail>0||e$2.strict&&h.warn>0&&!O?"blocked":h.warn>0?"needs-attention":"ready",w={schemaVersion:b$1.analyze,generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:r,profile:s,summary:{score:m,verdict:J,projectCount:i.length,runtimeCount:Object.keys(k).length,findings:h},runtimes:k,projects:i,dependencyGraph:{status:l.length>0?"generated":"empty",edges:l,topImpactedProjects:u.slice(0,5)},findings:d,nextActions:oe({findings:d,projectCount:i.length,hasGraph:l.length>0,workspaceDetected:r}),enterpriseControls:{jsonReady:true,ciGateCommand:"workspai analyze --json --strict",releaseGateCommand:"workspai autopilot release --mode enforce --json",evidencePath:a.analyze}};if(e$2.output&&(await b.promises.mkdir(p.dirname(p.resolve(e$2.output)),{recursive:true}),await b.promises.writeFile(p.resolve(e$2.output),`${JSON.stringify(w,null,2)}
|
|
2
2
|
`)),!e$2.output&&r){let c=f$2(w,{commandId:"workspaceAnalyze",exitCode:w.summary.verdict==="blocked"?2:w.summary.verdict==="needs-attention"?1:0,generatedAt:w.generatedAt,blockers:w.findings.filter(y=>y.severity==="fail").map(y=>y.title).slice(0,12),runId:e()});await e$1(t,a.analyze,c);}return w}function we(e){let n=e.summary.verdict==="ready"?o.green:e.summary.verdict==="needs-attention"?o.yellow:o.red;if(console.log(o.bold(`
|
|
3
3
|
Workspai Workspace Analysis
|
|
4
4
|
`)),console.log(o.cyan("Workspace:"),e.workspacePath),console.log(o.cyan("Profile:"),e.profile||"not configured"),console.log(o.cyan("Score:"),`${e.summary.score}/100`),console.log(o.cyan("Verdict:"),n(e.summary.verdict)),console.log(o.gray(`Projects: ${e.summary.projectCount}, runtimes: ${e.summary.runtimeCount}, findings: ${e.summary.findings.fail} fail / ${e.summary.findings.warn} warn / ${e.summary.findings.info} info`)),e.projects.length>0){console.log(o.bold(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {k,h as h$1,g}from'./chunk-
|
|
1
|
+
import {k,h as h$1,g}from'./chunk-37CVKXBD.js';import {a as a$2}from'./chunk-HTYMXMQM.js';import {c}from'./chunk-S5KTATOU.js';import {d,b as b$1}from'./chunk-OA537ZQ5.js';import {a as a$1}from'./chunk-T4YR4RAI.js';import {e}from'./chunk-32OJDBIG.js';import {a as a$3}from'./chunk-KB44JP4M.js';import {b,a}from'./chunk-BMWFQXGW.js';import k$1 from'path';import V from'fs-extra';import {spawnSync}from'child_process';function me(){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,a){let r=spawnSync("git",t,{cwd:e,env:me(),encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(r.status!==0)return {ok:false,stdout:""};let c=r.stdout??"";return {ok:true,stdout:a?.preserveWhitespace?c:c.trim()}}function fe(e){let t=e.replace(/\\/g,"/").replace(/^\.\//,"");return t===".workspai/AGENT-GROUNDING.md"?true:[".workspai/reports/",".workspai/cache/",".rapidkit/reports/",".rapidkit/cache/"].some(a=>t.startsWith(a))}function ue(e){let t=[],a=[],r=[];for(let c of e.split(`
|
|
2
2
|
`)){if(!c.trim())continue;let n=c.slice(0,2),i=c.slice(3).trim();if(i&&!fe(i)){if(n==="??"){a.push(i);continue}n.includes("D")&&r.push(i),t.push(i);}}return {changedFiles:[...new Set(t)].sort(),untrackedFiles:[...new Set(a)].sort(),deletedFiles:[...new Set(r)].sort()}}function X(e,t){let a={available:false,dirty:false,changedFiles:[],untrackedFiles:[],deletedFiles:[]},r=F(e,["rev-parse","--is-inside-work-tree"]);if(!r.ok||r.stdout!=="true")return a;let c=F(e,["rev-parse","--abbrev-ref","HEAD"]),n=F(e,["rev-parse","HEAD"]),i=F(e,["status","--porcelain=v1","--untracked-files=all"],{preserveWhitespace:true}),p=ue(i.stdout),m=p.changedFiles.length>0||p.untrackedFiles.length>0||p.deletedFiles.length>0;return {available:true,branch:c.ok?c.stdout:void 0,commit:n.ok?n.stdout:void 0,ref:t?.ref,dirty:m,changedFiles:p.changedFiles,untrackedFiles:p.untrackedFiles,deletedFiles:p.deletedFiles}}var te=b.snapshot,L=b.diff,T=a.snapshot,re=a.diff,ge=b.impact,ke=a.impact;function oe(e){let t=e.trim().toLowerCase();return t==="git"||t.startsWith("git:")}function he(e){let t=e.trim();return t.toLowerCase()==="git"?"HEAD":t.toLowerCase().startsWith("git:")&&t.slice(4).trim()||"HEAD"}function ae(e,t){return k$1.isAbsolute(t)?t:k$1.join(e,t)}async function we(e){let t=await V.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace model input is not a JSON object: ${e}`);let a=t;if(a.schemaVersion===te){a$3(t,"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",`Workspace model snapshot ${e}`);let r=a;if(!r.model||r.model.schemaVersion!==g)throw new Error(`Invalid workspace model snapshot: ${e}`);let c=d(r.model);if(r.modelHash!==c)throw new Error(`Workspace model snapshot hash mismatch: ${e}`);return {model:r.model,hash:r.modelHash}}if(a.schemaVersion===g){a$3(t,"contracts/workspace-intelligence/workspace-model.v1.json",`Workspace model ${e}`);let r=a;return {model:r,hash:d(r)}}throw a.schemaVersion===L?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(a.schemaVersion)}`)}async function ye(e){let t=await V.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace diff input is not a JSON object: ${e}`);let a=t;if(a.schemaVersion!==L)return null;a$3(t,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Workspace model diff ${e}`);let r=a;if(!r.currentModel||r.currentModel.schemaVersion!==g||!r.summary||!Array.isArray(r.changes))throw new Error(`Invalid workspace model diff report: ${e}`);if(r.toHash!==d(r.currentModel))throw new Error(`Workspace model diff current-model hash mismatch: ${e}`);return r}async function Je(e){let t=e.model??await k({workspacePath:e.workspacePath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {schemaVersion:te,generatedAt:(e.now??new Date).toISOString(),modelHash:d(t),modelRef:h$1,model:t}}async function Ue(e$1,t){return e(t,T,a$1(e$1))}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 We(e,t){let a=[],r=["name","profile","type"],c=["workspaceType","surfaces","runtimeFamilies","businessCapabilities"];for(let n of r){let i=e.workspace[n],p=t.workspace[n];b$1(i)!==b$1(p)&&w(a,{type:"workspace.changed",severity:"info",target:`workspace.${n}`,message:`Workspace metadata field changed: ${String(n)}`,before:i,after:p});}for(let n of c){let i=e.identity[n],p=t.identity[n];b$1(i)!==b$1(p)&&w(a,{type:"workspace.changed",severity:"info",target:`identity.${n}`,message:`Workspace identity field changed: ${String(n)}`,before:i,after:p});}return b$1(e.policies)!==b$1(t.policies)&&w(a,{type:"workspace.changed",severity:"warning",target:"policies",message:"Workspace policy summary changed.",before:e.policies,after:t.policies}),b$1(e.discovery)!==b$1(t.discovery)&&w(a,{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(a,{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}),a}function be(e,t){let a=e.validation??null,r=t.validation??null;return b$1(a)===b$1(r)?[]:[{type:"validation.changed",severity:r?.status==="failed"?"critical":"warning",target:"validation",message:"Workspace model validation changed.",before:a,after:r}]}function ve(e,t){let a=[],r=new Map(e.projects.map(n=>[n.path,n])),c=new Map(t.projects.map(n=>[n.path,n]));for(let[n,i]of c.entries()){let p=r.get(n);if(!p){w(a,{type:"project.added",severity:"info",target:n,message:`Project added: ${i.name}`,after:x(i)});continue}let m=x(p),l=x(i);if(b$1(m)!==b$1(l)){let u=p.runtime!==i.runtime||p.framework!==i.framework;w(a,{type:"project.changed",severity:u?"warning":"info",target:n,message:`Project changed: ${i.name}`,before:m,after:l});}}for(let[n,i]of r.entries())c.has(n)||w(a,{type:"project.removed",severity:"warning",target:n,message:`Project removed: ${i.name}`,before:x(i)});return a.sort((n,i)=>`${n.type}:${n.target}`.localeCompare(`${i.type}:${i.target}`))}async function je(e){let t=k$1.resolve(e.workspacePath),a=oe(e.fromPath),r=a?he(e.fromPath):void 0,c=e.fromPath;if(a){let f=k$1.join(t,T);if(!await V.pathExists(f))throw new Error("Git-aware workspace diff requires an existing snapshot at .workspai/reports/workspace-model-snapshot.json. Run: npx workspai workspace snapshot --json");c=T;}let n=ae(t,c),i=await we(n),p=e.model??await k({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),m=d(p),l=[...We(i.model,p),...ve(i.model,p),...be(i.model,p)],u;e.includeGitObservation!==false&&(u=e.gitObservation??X(t,{ref:r}),u.available&&Re(l,u,p));let v=l.filter(f=>f.type.startsWith("git.")).length,R=i.hash!==m,y=a?`git:${r??"HEAD"}`:k$1.relative(t,n).split(k$1.sep).join("/");return {schemaVersion:L,generatedAt:(e.now??new Date).toISOString(),fromRef:y,toRef:h$1,fromHash:i.hash,toHash:m,summary:{changed:R||v>0,addedProjects:l.filter(f=>f.type==="project.added").length,removedProjects:l.filter(f=>f.type==="project.removed").length,changedProjects:l.filter(f=>f.type==="project.changed").length,workspaceChanges:l.filter(f=>f.type==="workspace.changed").length,validationChanges:l.filter(f=>f.type==="validation.changed").length,gitChangedFiles:v},git:u?.available?Ce(u,r):{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:l,currentModel:p}}async function Xe(e$1,t){return e(t,re,a$1(e$1))}function I(e){return {none:0,low:1,medium:2,high:3,critical:4}[e]}function Y(e){return e.reduce((t,a)=>I(a)>I(t)?a:t,"none")}var N=["none","low","medium","high","critical"];function Me(e){let t=Math.max(1,I(e)-1);return N[t]}function Ie(e){let t=Math.min(N.length-1,I(e)+1);return N[t]}function Q(e){return e.join(" ")}function h(e,t,a,r){return {id:e,label:t,scope:r.scope,project:r.project,display:Q(["npx","workspai",...a]),execute:Q(["npx","--yes","--package","workspai","workspai",...a]),required:r.required!==false}}function Z(e){let t=`project:${e.name}`,a=e.commands.fleetStages;return [h(`project.${e.name}.init`,`Run init for ${e.name}`,["workspace","run","init","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("init")}),h(`project.${e.name}.test`,`Run tests for ${e.name}`,["workspace","run","test","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("test")}),h(`project.${e.name}.build`,`Run build for ${e.name}`,["workspace","run","build","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("build")}),h(`project.${e.name}.start`,`Run start for ${e.name}`,["workspace","run","start","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("start")})]}function _(){return [h("workspace.doctor","Run workspace doctor",["doctor","workspace","--json"],{scope:"workspace"}),h("workspace.contract.verify","Verify workspace contract",["workspace","contract","verify","--json"],{scope:"workspace"}),h("workspace.readiness","Run release readiness",["readiness","--json"],{scope:"workspace"}),h("workspace.analyze","Run workspace analyze",["analyze","--json"],{scope:"workspace",required:false}),h("workspace.pipeline","Run governance pipeline",["pipeline","--json"],{scope:"workspace",required:false}),h("workspace.doctor-fix","Verify doctor fix result",["doctor","workspace","--fix","--json"],{scope:"workspace",required:false})]}function Pe(e,t){let a=t.split(k$1.sep).join("/");return e.projects.filter(c=>{let n=c.path.split(k$1.sep).join("/");return a===n||a.startsWith(`${n}/`)}).sort((c,n)=>n.path.length-c.path.length)[0]}function Re(e,t,a){let r=new Set(e.map(n=>n.target)),c=(n,i)=>{let p=i.split(k$1.sep).join("/"),m=`git:${p}`;if(r.has(m))return;let l=Pe(a,p),u=l?`${l.name} (${l.path})`:"workspace";w(e,{type:n,severity:n==="git.deleted"?"warning":"info",target:m,message:`Git ${n==="git.untracked"?"untracked":n==="git.deleted"?"deleted":"changed"} file affects ${u}: ${p}`,after:{path:p,project:l?.name,projectPath:l?.path}}),r.add(m);};for(let n of t.changedFiles)c("git.file.changed",n);for(let n of t.untrackedFiles)c("git.untracked",n);for(let n of t.deletedFiles)c("git.deleted",n);}function Ce(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 Ee(e){let t=new Set,a=[];for(let r of e){let c=`${r.scope}:${r.project??""}:${r.display}`;t.has(c)||(t.add(c),a.push(r));}return a}function Oe(e){return e.type==="project.removed"?"high":e.severity==="critical"?"critical":e.severity==="warning"?"high":("medium")}function Se(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 Ae(e){return e.affectedProjects>0||e.projectCount>0||!e.changes.every(a=>a.severity==="critical"?false:a.type.startsWith("git.")||a.type==="validation.changed")?e.risk:I(e.risk)>=I("high")||e.risk==="medium"?"low":e.risk}function ee(e,t){if(!e||e==="workspace")return true;let a=(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(a)}function De(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(a=>a.project?.name??a.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 Ye(e){let t=k$1.resolve(e.workspacePath),a=oe(e.fromPath),r=e.diff;if(!r&&!a){let o=ae(t,e.fromPath);r=await ye(o)??void 0;}r||(r=await je({workspacePath:t,fromPath:e.fromPath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,includeGitObservation:e.includeGitObservation,gitObservation:e.gitObservation,now:e.now,model:e.model}));let c$1=new Map(r.currentModel.projects.map(o=>[o.path,o])),n=new Map(r.currentModel.projects.map(o=>[o.name,o])),i=r.changes.filter(o=>o.type.startsWith("project.")),p=new Map;for(let o of i){let d=(c$1.get(o.target)??(typeof o.before?.name=="string"?n.get(o.before.name):void 0))?.path??o.target,W=p.get(d)??[];W.push(o),p.set(d,W);}let m=[];for(let[o,s]of p.entries()){let d=c$1.get(o);if(d&&!ee(e.scope,d))continue;let W=Y(s.map(Oe)),C=d?.name??(typeof s[0]?.before?.name=="string"?String(s[0].before.name):o);m.push({id:`project:${C}`,scope:"project",target:o,title:`Project impact: ${C}`,summary:s.map(j=>j.message).join(" "),risk:W,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?Z(d):_()});}let l=r.currentModel.graph,u=l?a$2(l):void 0,v=new Set(m.map(o=>o.project?.name).filter(o=>typeof o=="string")),R=new Map;for(let o of m)if(o.project?.name){let s=u?.byId.get(o.project.name);s&&(o.centrality={fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness,isHotspot:s.isHotspot},s.isHotspot&&(o.risk=Ie(o.risk),o.reasons=[...o.reasons,`graph.hotspot: critical-path project with ${s.reach} transitive dependent(s); risk escalated.`])),o.origin="direct",o.distance=0,R.set(o.project.name,o.risk);}let y=[],f=0;if(l&&v.size>0){let o=c(l,v);for(let s of o.values()){if(s.distance===0||v.has(s.id))continue;let d=n.get(s.id);if(d&&!ee(e.scope,d))continue;let W=s.path[0],C=s.path[s.path.length-2]??W,j=R.get(W)??"medium",ce=Me(j),M=u?.byId.get(s.id);f=Math.max(f,s.distance),y.push({id:`transitive:${s.id}`,scope:"project",target:d?.path??s.id,title:`Transitive impact: ${s.id}`,summary:`Depends on changed project ${W}${s.via?` via ${s.via}`:""} (distance ${s.distance}).`,risk:ce,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?Z(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}}:{}});}}y.sort((o,s)=>o.target.localeCompare(s.target));let ne=u?u.hotspots.flatMap(o=>{let s=u.byId.get(o);return s?[{project:o,fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness}]:[]}):[],se=r.changes.filter(o=>!o.type.startsWith("project.")),K=r.currentModel.summary?.projectCount??r.currentModel.projects.length,P=se.map(o=>({id:`workspace:${o.target}`,scope:"workspace",target:o.target,title:`Workspace impact: ${o.target}`,summary:o.message,risk:Se(o,{projectCount:K}),reasons:[`${o.type}: ${o.message}`],verification:_()})),B=Ee([...m.flatMap(o=>o.verification),...y.flatMap(o=>o.verification),...P.flatMap(o=>o.verification),...r.summary.changed?_():[]]).filter(o=>o.required),ie=Y([...m.map(o=>o.risk),...y.map(o=>o.risk),...P.map(o=>o.risk)]),q=Ae({risk:ie,affectedProjects:m.length,projectCount:K,changes:r.changes}),z={changed:r.summary.changed,risk:q,affectedProjects:m.length,workspaceItems:P.length,recommendedCommands:B.length,blastRadius:{directlyAffected:m.length,transitivelyAffected:y.length,maxDistance:f,graphEdges:l?.edges.length??0}};return {schemaVersion:ge,generatedAt:(e.now??new Date).toISOString(),fromRef:r.fromRef,diffRef:re,workspace:{name:r.currentModel.workspace.name,profile:r.currentModel.workspace.profile,type:r.currentModel.workspace.type},summary:z,affectedProjects:m.sort((o,s)=>o.target.localeCompare(s.target)),transitiveImpact:y,criticalPathHotspots:ne,workspaceImpact:P.sort((o,s)=>o.target.localeCompare(s.target)),verificationPlan:B,agentBrief:De({changed:z.changed,risk:q,affectedProjects:m,workspaceImpact:P}),diff:r}}async function Qe(e$1,t){return e(t,ke,a$1(e$1))}export{X as a,te as b,L as c,T as d,re as e,ge as f,ke as g,oe as h,he as i,Je as j,Ue as k,je as l,Xe as m,_ as n,Ye as o,Qe as p};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {c as c$1,b}from'./chunk-3ZK2GU7C.js';import {f as f$2,e as e$1}from'./chunk-T3GJ7YVG.js';import {b as b$2}from'./chunk-22DT744Z.js';import {j,g}from'./chunk-76YOPAOT.js';import {b as b$1}from'./chunk-NHN4QXPP.js';import {a as a$2}from'./chunk-FXQJX34Z.js';import {w}from'./chunk-TWNFECMN.js';import {i,d as d$1,b as b$5,a as a$8}from'./chunk-4KUIFXHM.js';import {d,e}from'./chunk-2TEDAKP6.js';import {a as a$1}from'./chunk-GSWPGELT.js';import {c as c$3,a as a$6,b as b$4}from'./chunk-U5EZHZBX.js';import {a as a$3}from'./chunk-GZTYAEWX.js';import {a as a$4}from'./chunk-KB44JP4M.js';import {a}from'./chunk-LNRAB7UY.js';import {f}from'./chunk-7YHK5NM3.js';import {a as a$5}from'./chunk-TQEMLBAG.js';import {o,f as f$1,p as p$1}from'./chunk-5XATWNME.js';import {c as c$2,b as b$3,i as i$1,l as l$1,s,m,o as o$1}from'./chunk-EYJ2CQSK.js';import {a as a$7}from'./chunk-2FIX2MDC.js';import p from'chalk';import {createHash}from'crypto';import {execa}from'execa';import l from'fs-extra';import c from'path';import {existsSync}from'fs';function tt(e){return `"${e.replace(/"/g,'\\"')}"`}function Kt(e){let t=`scripts.${e.scriptName}=${e.scriptValue}`;return `cd ${tt(e.projectPath)} && npm pkg set ${tt(t)}`}function Oe(e){return `rapidkit:doctor:repair ${Buffer.from(JSON.stringify(e),"utf8").toString("base64url")}`}function it(e){let t=c.join(e.projectPath,e.relativePath),r={type:"file-create",path:t,content:e.content,overwrite:false};return {id:`${e.issueId}.file-create`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-create",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t],command:Oe(r),operation:r,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Vt(e){let t=c.join(e.projectPath,e.relativePath),r={type:"file-append",path:t,lines:e.lines,ensureNewline:true};return {id:`${e.issueId}.file-append`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-append",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t],command:Oe(r),operation:r,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Jt(e){let t=c.join(e.projectPath,e.sourceRelativePath),r=c.join(e.projectPath,e.targetRelativePath),n={type:"file-copy",sourcePath:t,path:r,overwrite:false};return {id:`${e.issueId}.file-copy`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-copy",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t,r],command:Oe(n),operation:n,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Lt(e){return e.lint&&e.lint.trim().length>0?"npm run lint":e.build&&e.build.trim().length>0?"npm run build":null}function Ut(e){let t=`frontend-script-${e.scriptName}`,r=c.join(e.projectPath,"package.json"),n=["npx workspai doctor project --json","npx workspai workspace verify --json"];return e.scriptValue?{id:`${t}.package-json-script`,issueId:t,title:`Add package.json ${e.scriptName} script`,status:"available",fixKind:"package-json-script",risk:"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:false,files:[r],command:Kt({projectPath:e.projectPath,scriptName:e.scriptName,scriptValue:e.scriptValue}),operation:{type:"package-json-script",path:r,scriptName:e.scriptName,scriptValue:e.scriptValue},verifyCommand:"npx workspai doctor project --json",refreshCommands:n,reason:`Reuse the existing ${e.scriptValue} validation path as the ${e.scriptName} gate for ${e.frameworkDisplayName}.`}:{id:`${t}.manual`,issueId:t,title:`Define ${e.scriptName} script`,status:"manual",fixKind:"manual",risk:"guarded",canAutoFix:false,canEditFiles:false,requiresApproval:true,requiresReview:true,files:[r],refreshCommands:n,reason:`No safe ${e.frameworkDisplayName} fallback script could be inferred from existing package.json scripts.`,limitations:["Add a real test/lint/build command that matches the project quality gate before release."]}}function zt(e){let t=c.join(e.projectPath,"package.json");return {id:`${e.issueId}.package-json-script`,issueId:e.issueId,title:e.title,status:"available",fixKind:"package-json-script",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t],command:Kt({projectPath:e.projectPath,scriptName:e.scriptName,scriptValue:e.scriptValue}),operation:{type:"package-json-script",path:t,scriptName:e.scriptName,scriptValue:e.scriptValue},verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Yt(e){let t=c.join(e.projectPath,"Makefile"),r={type:"makefile-target",path:t,target:e.targetName,command:e.command,phony:true};return {id:`${e.issueId}.makefile-target`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-append",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??true,files:[t],command:Oe(r),operation:r,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function ot(e){return {id:`${e.issueId}.command`,issueId:e.issueId,title:e.title,status:"available",fixKind:e.fixKind??"command",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:false,requiresApproval:true,requiresReview:e.requiresReview??true,files:e.files.map(t=>c.join(e.projectPath,t)),command:`cd ${tt(e.projectPath)} && ${e.command}`,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}var $n=[".eslintrc.js",".eslintrc.cjs",".eslintrc.json",".eslintrc.yaml",".eslintrc.yml","eslint.config.js","eslint.config.mjs","eslint.config.cjs"],Fn=["tests","test","src/test","__tests__","e2e","playwright","cypress"],Nn=["vitest.config.ts","vitest.config.js","vitest.config.mjs","jest.config.js","jest.config.ts","jest.config.mjs","playwright.config.ts","playwright.config.js","cypress.config.js","cypress.config.ts"],In=["src","app","pages"],An=["dev","build","test","lint"];function Qt(e){let t=e?.scripts;if(!t||typeof t!="object"||Array.isArray(t))return {};let r={};for(let[n,i]of Object.entries(t))typeof i=="string"&&i.trim().length>0&&(r[n]=i);return r}async function Xt(e,t){for(let i of $n)if(await l.pathExists(c.join(e,i)))return true;let r=t??(await l.pathExists(c.join(e,"package.json"))?await l.readJson(c.join(e,"package.json")):null);if(!r)return false;if(r.eslintConfig)return true;let n={...r.dependencies??{},...r.devDependencies??{}};return !!(n.eslint||n["@eslint/js"]||n["@eslint/eslintrc"])}async function Zt(e,t){for(let i of Fn)if(await l.pathExists(c.join(e,i)))return true;for(let i of Nn)if(await l.pathExists(c.join(e,i)))return true;let r=Qt(t);if(r.test||r["test:unit"]||r["test:e2e"]||r["test:ci"]||r["test:watch"])return true;let n={...t?.dependencies??{},...t?.devDependencies??{}};return n.vitest||n.jest||n["@playwright/test"]||n.cypress?true:await On(e)}async function On(e){let t=["src","app","pages","components"],r=/\.(test|spec)\.(tsx?|jsx?|vue|svelte)$/i,i=new Set(["node_modules",".git","dist","build",".next","coverage",".turbo"]);for(let s of t){let o=c.join(e,s);if(!await l.pathExists(o))continue;let a=[{dir:o,depth:0}];for(;a.length>0;){let d=a.shift();if(!d)break;let u=[];try{u=await l.readdir(d.dir);}catch{continue}for(let g of u){let y=c.join(d.dir,g);if(r.test(g))return true;if(!(d.depth>=3||i.has(g)||g.startsWith(".")))try{(await l.stat(y)).isDirectory()&&a.push({dir:y,depth:d.depth+1});}catch{continue}}}}return false}async function at(e){for(let t of In){let r=c.join(e,t);if(await l.pathExists(r))try{if((await l.readdir(r)).some(i=>!i.startsWith(".")))return true}catch{continue}}return false}function Mn(e){let t=e.key;return b$5(t).key}function Tn(e,t,r){return a$8(t,r).some(i=>!!e[i])}async function en(e){let{projectPath:t,detection:r,packageJsonData:n}=e,i=Mn(r),s=b$5(i),o=Qt(n),a=[],d=await l.pathExists(c.join(t,"package-lock.json"))||await l.pathExists(c.join(t,"pnpm-lock.yaml"))||await l.pathExists(c.join(t,"yarn.lock"))||await l.pathExists(c.join(t,"bun.lockb"));a.push({id:"frontend-lockfile-integrity",label:"Frontend lockfile integrity",status:d?"pass":"warn",severity:"warn",scope:"project-scoped",reason:d?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml/bun.lockb).",recommendation:d?void 0:"Commit a lockfile for deterministic installs and CI parity."});let u=await l.pathExists(c.join(t,"tsconfig.json")),g=await l.pathExists(c.join(t,"jsconfig.json")),y=u||g;a.push({id:"frontend-typescript-surface",label:"TypeScript project surface",status:y?"pass":"warn",severity:"warn",scope:"project-scoped",reason:y?u?"tsconfig.json detected.":"jsconfig.json detected.":"No tsconfig.json or jsconfig.json detected.",recommendation:y?void 0:"Add tsconfig.json (or jsconfig.json) for typed frontend builds and IDE parity."});let w=s.fileHints.length>0&&s.fileHints.some(f=>existsSync(c.join(t,f)));a.push({id:"frontend-framework-config",label:`${s.displayName} config surface`,status:w?"pass":"warn",severity:"warn",scope:"project-scoped",reason:w?`${s.displayName} configuration artifacts detected.`:`No ${s.displayName} config markers detected (${s.fileHints.join(", ")||"n/a"}).`,recommendation:w?void 0:"Keep framework config files in-repo for reproducible dev/build behavior."});for(let f of An){let b=Tn(o,i,f),j=f==="dev"||f==="build",h=!b&&f==="test"?Ut({projectPath:t,frameworkDisplayName:s.displayName,scriptName:f,scriptValue:Lt(o)}):void 0;a.push({id:`frontend-script-${f}`,label:`${f} script surface`,status:b?"pass":j?"fail":"warn",severity:j?"error":"warn",scope:"project-scoped",reason:b?`package.json exposes a ${f} script for ${s.displayName}.`:`No ${f} script detected for ${s.displayName}.`,recommendation:b?void 0:`Add a "${a$8(i,f)[0]??f}" script to package.json.`,repairCapability:h});}let k=await at(t);return a.push({id:"frontend-source-tree",label:"Frontend source tree",status:k?"pass":"warn",severity:"warn",scope:"project-scoped",reason:k?"Application source directories detected (src/app/pages).":"No frontend source directories detected under src/, app/, or pages/.",recommendation:k?void 0:"Ensure the scaffolded application tree exists before running lifecycle commands."}),a}var Hn={node:["package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb"],deno:["deno.lock"],bun:["bun.lock","bun.lockb"],python:["uv.lock","poetry.lock","requirements.txt","requirements.lock"],go:["go.sum"],java:["gradle.lockfile","gradle/libs.versions.toml"],rust:["Cargo.lock"],elixir:["mix.lock"],clojure:["deps.edn","project.clj"],php:["composer.lock"],ruby:["Gemfile.lock"],dotnet:["packages.lock.json","Directory.Packages.props"],unknown:[]},Bn={node:["package.json"],deno:["deno.json","deno.jsonc"],bun:["package.json","bunfig.toml"],python:["pyproject.toml","requirements.txt","setup.py"],go:["go.mod"],java:["pom.xml","build.gradle","build.gradle.kts"],rust:["Cargo.toml"],elixir:["mix.exs"],clojure:["deps.edn","project.clj"],php:["composer.json"],ruby:["Gemfile"],dotnet:["*.csproj","*.sln"],unknown:[]},_n=["node_modules",".git",".workspai/reports",".venv","dist","build","coverage",".env",".env.*","!.env.example"].join(`
|
|
1
|
+
import {c as c$1,b}from'./chunk-3ZK2GU7C.js';import {f as f$2,e as e$1}from'./chunk-T3GJ7YVG.js';import {b as b$2}from'./chunk-22DT744Z.js';import {j,g}from'./chunk-ESLPI3XZ.js';import {b as b$1}from'./chunk-NHN4QXPP.js';import {a as a$2}from'./chunk-FXQJX34Z.js';import {w}from'./chunk-PHXQR6PX.js';import {i,d as d$1,b as b$5,a as a$8}from'./chunk-4KUIFXHM.js';import {d,e}from'./chunk-32OJDBIG.js';import {a as a$1}from'./chunk-GSWPGELT.js';import {c as c$3,a as a$6,b as b$4}from'./chunk-YJZOMRAS.js';import {a as a$3}from'./chunk-GZTYAEWX.js';import {a as a$4}from'./chunk-KB44JP4M.js';import {a}from'./chunk-BMWFQXGW.js';import {f}from'./chunk-7YHK5NM3.js';import {a as a$5}from'./chunk-TQEMLBAG.js';import {o,f as f$1,p as p$1}from'./chunk-5XATWNME.js';import {c as c$2,b as b$3,i as i$1,l as l$1,s,m,o as o$1}from'./chunk-EYJ2CQSK.js';import {a as a$7}from'./chunk-2FIX2MDC.js';import p from'chalk';import {createHash}from'crypto';import {execa}from'execa';import l from'fs-extra';import c from'path';import {existsSync}from'fs';function tt(e){return `"${e.replace(/"/g,'\\"')}"`}function Kt(e){let t=`scripts.${e.scriptName}=${e.scriptValue}`;return `cd ${tt(e.projectPath)} && npm pkg set ${tt(t)}`}function Oe(e){return `rapidkit:doctor:repair ${Buffer.from(JSON.stringify(e),"utf8").toString("base64url")}`}function it(e){let t=c.join(e.projectPath,e.relativePath),r={type:"file-create",path:t,content:e.content,overwrite:false};return {id:`${e.issueId}.file-create`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-create",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t],command:Oe(r),operation:r,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Vt(e){let t=c.join(e.projectPath,e.relativePath),r={type:"file-append",path:t,lines:e.lines,ensureNewline:true};return {id:`${e.issueId}.file-append`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-append",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t],command:Oe(r),operation:r,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Jt(e){let t=c.join(e.projectPath,e.sourceRelativePath),r=c.join(e.projectPath,e.targetRelativePath),n={type:"file-copy",sourcePath:t,path:r,overwrite:false};return {id:`${e.issueId}.file-copy`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-copy",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t,r],command:Oe(n),operation:n,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Lt(e){return e.lint&&e.lint.trim().length>0?"npm run lint":e.build&&e.build.trim().length>0?"npm run build":null}function Ut(e){let t=`frontend-script-${e.scriptName}`,r=c.join(e.projectPath,"package.json"),n=["npx workspai doctor project --json","npx workspai workspace verify --json"];return e.scriptValue?{id:`${t}.package-json-script`,issueId:t,title:`Add package.json ${e.scriptName} script`,status:"available",fixKind:"package-json-script",risk:"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:false,files:[r],command:Kt({projectPath:e.projectPath,scriptName:e.scriptName,scriptValue:e.scriptValue}),operation:{type:"package-json-script",path:r,scriptName:e.scriptName,scriptValue:e.scriptValue},verifyCommand:"npx workspai doctor project --json",refreshCommands:n,reason:`Reuse the existing ${e.scriptValue} validation path as the ${e.scriptName} gate for ${e.frameworkDisplayName}.`}:{id:`${t}.manual`,issueId:t,title:`Define ${e.scriptName} script`,status:"manual",fixKind:"manual",risk:"guarded",canAutoFix:false,canEditFiles:false,requiresApproval:true,requiresReview:true,files:[r],refreshCommands:n,reason:`No safe ${e.frameworkDisplayName} fallback script could be inferred from existing package.json scripts.`,limitations:["Add a real test/lint/build command that matches the project quality gate before release."]}}function zt(e){let t=c.join(e.projectPath,"package.json");return {id:`${e.issueId}.package-json-script`,issueId:e.issueId,title:e.title,status:"available",fixKind:"package-json-script",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t],command:Kt({projectPath:e.projectPath,scriptName:e.scriptName,scriptValue:e.scriptValue}),operation:{type:"package-json-script",path:t,scriptName:e.scriptName,scriptValue:e.scriptValue},verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Yt(e){let t=c.join(e.projectPath,"Makefile"),r={type:"makefile-target",path:t,target:e.targetName,command:e.command,phony:true};return {id:`${e.issueId}.makefile-target`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-append",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??true,files:[t],command:Oe(r),operation:r,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function ot(e){return {id:`${e.issueId}.command`,issueId:e.issueId,title:e.title,status:"available",fixKind:e.fixKind??"command",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:false,requiresApproval:true,requiresReview:e.requiresReview??true,files:e.files.map(t=>c.join(e.projectPath,t)),command:`cd ${tt(e.projectPath)} && ${e.command}`,verifyCommand:"npx workspai doctor project --json",refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}var $n=[".eslintrc.js",".eslintrc.cjs",".eslintrc.json",".eslintrc.yaml",".eslintrc.yml","eslint.config.js","eslint.config.mjs","eslint.config.cjs"],Fn=["tests","test","src/test","__tests__","e2e","playwright","cypress"],Nn=["vitest.config.ts","vitest.config.js","vitest.config.mjs","jest.config.js","jest.config.ts","jest.config.mjs","playwright.config.ts","playwright.config.js","cypress.config.js","cypress.config.ts"],In=["src","app","pages"],An=["dev","build","test","lint"];function Qt(e){let t=e?.scripts;if(!t||typeof t!="object"||Array.isArray(t))return {};let r={};for(let[n,i]of Object.entries(t))typeof i=="string"&&i.trim().length>0&&(r[n]=i);return r}async function Xt(e,t){for(let i of $n)if(await l.pathExists(c.join(e,i)))return true;let r=t??(await l.pathExists(c.join(e,"package.json"))?await l.readJson(c.join(e,"package.json")):null);if(!r)return false;if(r.eslintConfig)return true;let n={...r.dependencies??{},...r.devDependencies??{}};return !!(n.eslint||n["@eslint/js"]||n["@eslint/eslintrc"])}async function Zt(e,t){for(let i of Fn)if(await l.pathExists(c.join(e,i)))return true;for(let i of Nn)if(await l.pathExists(c.join(e,i)))return true;let r=Qt(t);if(r.test||r["test:unit"]||r["test:e2e"]||r["test:ci"]||r["test:watch"])return true;let n={...t?.dependencies??{},...t?.devDependencies??{}};return n.vitest||n.jest||n["@playwright/test"]||n.cypress?true:await On(e)}async function On(e){let t=["src","app","pages","components"],r=/\.(test|spec)\.(tsx?|jsx?|vue|svelte)$/i,i=new Set(["node_modules",".git","dist","build",".next","coverage",".turbo"]);for(let s of t){let o=c.join(e,s);if(!await l.pathExists(o))continue;let a=[{dir:o,depth:0}];for(;a.length>0;){let d=a.shift();if(!d)break;let u=[];try{u=await l.readdir(d.dir);}catch{continue}for(let g of u){let y=c.join(d.dir,g);if(r.test(g))return true;if(!(d.depth>=3||i.has(g)||g.startsWith(".")))try{(await l.stat(y)).isDirectory()&&a.push({dir:y,depth:d.depth+1});}catch{continue}}}}return false}async function at(e){for(let t of In){let r=c.join(e,t);if(await l.pathExists(r))try{if((await l.readdir(r)).some(i=>!i.startsWith(".")))return true}catch{continue}}return false}function Mn(e){let t=e.key;return b$5(t).key}function Tn(e,t,r){return a$8(t,r).some(i=>!!e[i])}async function en(e){let{projectPath:t,detection:r,packageJsonData:n}=e,i=Mn(r),s=b$5(i),o=Qt(n),a=[],d=await l.pathExists(c.join(t,"package-lock.json"))||await l.pathExists(c.join(t,"pnpm-lock.yaml"))||await l.pathExists(c.join(t,"yarn.lock"))||await l.pathExists(c.join(t,"bun.lockb"));a.push({id:"frontend-lockfile-integrity",label:"Frontend lockfile integrity",status:d?"pass":"warn",severity:"warn",scope:"project-scoped",reason:d?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml/bun.lockb).",recommendation:d?void 0:"Commit a lockfile for deterministic installs and CI parity."});let u=await l.pathExists(c.join(t,"tsconfig.json")),g=await l.pathExists(c.join(t,"jsconfig.json")),y=u||g;a.push({id:"frontend-typescript-surface",label:"TypeScript project surface",status:y?"pass":"warn",severity:"warn",scope:"project-scoped",reason:y?u?"tsconfig.json detected.":"jsconfig.json detected.":"No tsconfig.json or jsconfig.json detected.",recommendation:y?void 0:"Add tsconfig.json (or jsconfig.json) for typed frontend builds and IDE parity."});let w=s.fileHints.length>0&&s.fileHints.some(f=>existsSync(c.join(t,f)));a.push({id:"frontend-framework-config",label:`${s.displayName} config surface`,status:w?"pass":"warn",severity:"warn",scope:"project-scoped",reason:w?`${s.displayName} configuration artifacts detected.`:`No ${s.displayName} config markers detected (${s.fileHints.join(", ")||"n/a"}).`,recommendation:w?void 0:"Keep framework config files in-repo for reproducible dev/build behavior."});for(let f of An){let b=Tn(o,i,f),j=f==="dev"||f==="build",h=!b&&f==="test"?Ut({projectPath:t,frameworkDisplayName:s.displayName,scriptName:f,scriptValue:Lt(o)}):void 0;a.push({id:`frontend-script-${f}`,label:`${f} script surface`,status:b?"pass":j?"fail":"warn",severity:j?"error":"warn",scope:"project-scoped",reason:b?`package.json exposes a ${f} script for ${s.displayName}.`:`No ${f} script detected for ${s.displayName}.`,recommendation:b?void 0:`Add a "${a$8(i,f)[0]??f}" script to package.json.`,repairCapability:h});}let k=await at(t);return a.push({id:"frontend-source-tree",label:"Frontend source tree",status:k?"pass":"warn",severity:"warn",scope:"project-scoped",reason:k?"Application source directories detected (src/app/pages).":"No frontend source directories detected under src/, app/, or pages/.",recommendation:k?void 0:"Ensure the scaffolded application tree exists before running lifecycle commands."}),a}var Hn={node:["package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb"],deno:["deno.lock"],bun:["bun.lock","bun.lockb"],python:["uv.lock","poetry.lock","requirements.txt","requirements.lock"],go:["go.sum"],java:["gradle.lockfile","gradle/libs.versions.toml"],rust:["Cargo.lock"],elixir:["mix.lock"],clojure:["deps.edn","project.clj"],php:["composer.lock"],ruby:["Gemfile.lock"],dotnet:["packages.lock.json","Directory.Packages.props"],unknown:[]},Bn={node:["package.json"],deno:["deno.json","deno.jsonc"],bun:["package.json","bunfig.toml"],python:["pyproject.toml","requirements.txt","setup.py"],go:["go.mod"],java:["pom.xml","build.gradle","build.gradle.kts"],rust:["Cargo.toml"],elixir:["mix.exs"],clojure:["deps.edn","project.clj"],php:["composer.json"],ruby:["Gemfile"],dotnet:["*.csproj","*.sln"],unknown:[]},_n=["node_modules",".git",".workspai/reports",".venv","dist","build","coverage",".env",".env.*","!.env.example"].join(`
|
|
2
2
|
`),st=[".env",".env.*","!.env.example"];function ke(e){return e?e==="bun"?"node":e==="python"||e==="node"||e==="go"||e==="java"||e==="rust"||e==="elixir"||e==="clojure"||e==="deno"||e==="php"||e==="ruby"||e==="dotnet"?e:"unknown":"unknown"}async function Me(e,t){for(let r of t){if(r.includes("*")){let n=r.replace("*","");if(await qn(e,n,2))return true;continue}if(await l.pathExists(c.join(e,r)))return true}return false}async function qn(e,t,r){let n=[{dir:e,depth:0}],i=new Set(["node_modules",".git",".workspai",".rapidkit","dist","build","coverage"]);for(;n.length>0;){let s=n.shift();if(!s)break;let o=[];try{o=await l.readdir(s.dir,{withFileTypes:true});}catch{continue}for(let a of o){if(i.has(a.name))continue;let d=c.join(s.dir,a.name);if(a.isFile()&&a.name.endsWith(t))return true;a.isDirectory()&&s.depth<r&&!a.name.startsWith(".")&&n.push({dir:d,depth:s.depth+1});}}return false}async function Te(e){try{return await l.pathExists(e)?await l.readFile(e,"utf8"):""}catch{return ""}}async function ct(e,t){let r=[];for(let n of t){let i=await Te(c.join(e,n));i&&r.push(i);}return r.join(`
|
|
3
3
|
`)}async function Gn(e){if(e.runtime==="node"){let t=typeof e.packageJsonData?.packageManager=="string"?e.packageJsonData.packageManager.split("@")[0]:null;return {command:t==="pnpm"?"pnpm install":t==="yarn"?"yarn install":t==="bun"?"bun install":"npm install",title:"Generate Node dependency lockfile",files:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock"],limitations:["Review dependency and lockfile changes before committing."]}}if(e.runtime==="go"&&await l.pathExists(c.join(e.projectPath,"go.mod")))return {command:"go mod tidy",title:"Reconcile Go module graph",files:["go.mod","go.sum"],limitations:["Review go.mod/go.sum changes before committing."]};if(e.runtime==="java"){let t=await l.pathExists(c.join(e.projectPath,"pom.xml")),r=await l.pathExists(c.join(e.projectPath,"mvnw"))||await l.pathExists(c.join(e.projectPath,"mvnw.cmd")),n=await l.pathExists(c.join(e.projectPath,"gradlew"))||await l.pathExists(c.join(e.projectPath,"gradlew.bat"));return {command:t?r?process.platform==="win32"?".\\mvnw.cmd -B -DskipTests dependency:go-offline":"./mvnw -B -DskipTests dependency:go-offline":"mvn -B -DskipTests dependency:go-offline":n?process.platform==="win32"?".\\gradlew.bat dependencies":"./gradlew dependencies":"gradle dependencies",title:"Prepare Java dependency baseline",files:["pom.xml","build.gradle","build.gradle.kts","gradle.lockfile"],limitations:["Review resolved dependency and lockfile changes before committing."]}}if(e.runtime==="rust")return {command:"cargo fetch",title:"Generate Rust dependency baseline",files:["Cargo.toml","Cargo.lock"],limitations:["Review Cargo.lock changes before committing."]};if(e.runtime==="php")return {command:"composer install",title:"Generate Composer lockfile",files:["composer.json","composer.lock"],limitations:["Review composer.lock changes before committing."]};if(e.runtime==="ruby")return {command:"bundle install",title:"Generate Bundler lockfile",files:["Gemfile","Gemfile.lock"],limitations:["Review Gemfile.lock changes before committing."]};if(e.runtime==="dotnet")return {command:"dotnet restore",title:".NET dependency restore",files:["*.sln","*.csproj","packages.lock.json","Directory.Packages.props"],limitations:["Enable NuGet lock files in the project when release policy requires deterministic restore."]};if(e.runtime==="elixir")return {command:"mix deps.get",title:"Generate Elixir dependency lockfile",files:["mix.exs","mix.lock"],limitations:["Review mix.lock changes before committing."]};if(e.runtime==="clojure")return {command:"clojure -P",title:"Prepare Clojure dependency baseline",files:["deps.edn","project.clj"],limitations:["Review dependency cache and CI restore policy before release."]};if(e.runtime==="python"){let t=await Te(c.join(e.projectPath,"pyproject.toml"));if(/\[tool\.poetry\]/.test(t))return {command:"poetry install --no-root",title:"Install Poetry dependency baseline",files:["pyproject.toml","poetry.lock"],limitations:["Review poetry.lock changes before committing when Poetry resolves or updates the lockfile."]};if(/\[tool\.uv\]|\[project\]/.test(t))return {command:"uv lock",title:"Generate uv lockfile",files:["pyproject.toml","uv.lock"],limitations:["Review uv.lock changes before committing."]}}return null}function lt(e){let t=e?.scripts;if(!t||typeof t!="object"||Array.isArray(t))return {};let r={};for(let[n,i]of Object.entries(t))typeof i=="string"&&i.trim().length>0&&(r[n]=i);return r}function Wn(e){if(e.runtime==="node"){let r=lt(e.packageJsonData);if(!e.packageJsonData)return null;if(e.kind==="test"){let n=r.lint?"npm run lint":r.build?"npm run build":null;return n?{command:n,title:"Define Node test script",targetName:"test",files:["package.json"],limitations:["Replace this fallback with real tests when product coverage is required."]}:null}return e.kind==="security"?{command:"npm audit --audit-level=moderate",title:"Define Node security audit script",targetName:"audit",files:["package.json"]}:null}return {python:{test:{command:"python -m pytest",title:"Define Python test command",targetName:"test",files:["Makefile","pyproject.toml"]},quality:{command:"python -m ruff check .",title:"Define Python quality command",targetName:"quality",files:["Makefile","pyproject.toml"],limitations:["Ensure ruff is declared in project dev dependencies before enforcing in CI."]},security:{command:"python -m pip_audit",title:"Define Python security audit command",targetName:"security",files:["Makefile","pyproject.toml"],limitations:["Ensure pip-audit is available in the project toolchain before enforcing in CI."]}},go:{test:{command:"go test ./...",title:"Define Go test command",targetName:"test",files:["Makefile","go.mod"]},quality:{command:"gofmt -w .",title:"Define Go formatting command",targetName:"quality",files:["Makefile","go.mod"],limitations:["Use CI-specific check mode if formatting should not mutate files in pipelines."]},security:{command:"govulncheck ./...",title:"Define Go vulnerability scan command",targetName:"security",files:["Makefile","go.mod"],limitations:["Ensure govulncheck is installed or provisioned by CI before enforcing."]}},rust:{test:{command:"cargo test",title:"Define Rust test command",targetName:"test",files:["Makefile","Cargo.toml"]},quality:{command:"cargo fmt -- --check && cargo clippy --all-targets -- -D warnings",title:"Define Rust quality command",targetName:"quality",files:["Makefile","Cargo.toml"]},security:{command:"cargo audit",title:"Define Rust security audit command",targetName:"security",files:["Makefile","Cargo.toml"],limitations:["Ensure cargo-audit is installed or provisioned by CI before enforcing."]}},php:{test:{command:"vendor/bin/phpunit",title:"Define PHP test command",targetName:"test",files:["Makefile","composer.json"]},quality:{command:"vendor/bin/phpstan analyse",title:"Define PHP static analysis command",targetName:"quality",files:["Makefile","composer.json"],limitations:["Ensure phpstan is declared in require-dev before enforcing in CI."]},security:{command:"composer audit",title:"Define Composer security audit command",targetName:"security",files:["Makefile","composer.json"]}},ruby:{test:{command:"bundle exec rspec",title:"Define Ruby test command",targetName:"test",files:["Makefile","Gemfile"],limitations:["Use bundle exec ruby -Itest when the project uses minitest instead of RSpec."]},quality:{command:"bundle exec rubocop",title:"Define Ruby quality command",targetName:"quality",files:["Makefile","Gemfile"]},security:{command:"bundle exec bundler-audit check",title:"Define Ruby security audit command",targetName:"security",files:["Makefile","Gemfile"],limitations:["Ensure bundler-audit is installed or provisioned by CI before enforcing."]}},dotnet:{test:{command:"dotnet test",title:"Define .NET test command",targetName:"test",files:["Makefile","*.sln","*.csproj"]},quality:{command:"dotnet format --verify-no-changes",title:"Define .NET formatting gate",targetName:"quality",files:["Makefile","*.sln","*.csproj"]},security:{command:"dotnet list package --vulnerable",title:"Define .NET package vulnerability check",targetName:"security",files:["Makefile","*.sln","*.csproj"]}},java:{test:{command:"mvn test",title:"Define Java test command",targetName:"test",files:["Makefile","pom.xml","build.gradle","build.gradle.kts"],limitations:["Use ./gradlew test when the project is Gradle-first."]},quality:{command:"mvn verify",title:"Define Java verification command",targetName:"quality",files:["Makefile","pom.xml","build.gradle","build.gradle.kts"],limitations:["Use ./gradlew check when the project is Gradle-first."]},security:{command:"mvn org.owasp:dependency-check-maven:check",title:"Define Java dependency vulnerability check",targetName:"security",files:["Makefile","pom.xml"],limitations:["Review OWASP dependency-check policy and cache behavior before enforcing in CI."]}}}[e.runtime]?.[e.kind]??null}async function Kn(e){return Yt({issueId:e.issueId,title:e.contract.title,projectPath:e.projectPath,targetName:e.contract.targetName,command:e.contract.command,reason:e.reason,risk:"guarded",requiresReview:true,limitations:e.contract.limitations})}async function dt(e){let t=Wn({runtime:e.runtime,kind:e.kind,packageJsonData:e.packageJsonData});if(t)return e.runtime==="node"&&e.packageJsonData?zt({issueId:e.issueId,title:t.title,projectPath:e.projectPath,scriptName:t.targetName,scriptValue:t.command,reason:e.reason,risk:"guarded",limitations:t.limitations}):Kn({issueId:e.issueId,projectPath:e.projectPath,contract:t,reason:e.reason})}function Re(e){return {id:`${e.issueId}.manual`,issueId:e.issueId,title:e.title,status:"manual",fixKind:"manual",risk:"guarded",canAutoFix:false,canEditFiles:false,requiresApproval:true,requiresReview:true,files:e.files.map(t=>c.join(e.projectPath,t)),refreshCommands:["npx workspai doctor project --json","npx workspai workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Vn(e){return it({issueId:"surface-dockerignore",title:"Create .dockerignore",projectPath:e,relativePath:".dockerignore",content:`${_n}
|
|
4
4
|
`,reason:"Create a Docker build ignore baseline to keep secrets, dependencies, and reports out of container contexts."})}async function Jn(e){if(!await l.pathExists(c.join(e,".gitignore")))return it({issueId:"surface-security-hygiene",title:"Create .gitignore secret baseline",projectPath:e,relativePath:".gitignore",content:`${st.join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {f as f$1,e}from'./chunk-T3GJ7YVG.js';import {a,b}from'./chunk-22DT744Z.js';import {i,j,l as l$1,k,n}from'./chunk-TWNFECMN.js';import {a as a$2,e as e$1}from'./chunk-2TEDAKP6.js';import {c}from'./chunk-U5EZHZBX.js';import {b as b$2}from'./chunk-YCL3I2JO.js';import {b as b$1,a as a$1}from'./chunk-LNRAB7UY.js';import {o}from'./chunk-5XATWNME.js';import d from'chalk';import l from'fs';import p from'path';var J=a$1.readiness,F=b$1.readiness;function M(t,e){let a=p.resolve(t);if(!b(a))return a;let s=z(e,"workspace.contract.json");if(l.existsSync(s))try{let o=JSON.parse(l.readFileSync(s,"utf-8")),n=Array.isArray(o.projects)?o.projects:[];for(let r of n){let u=f(r),v=typeof u.relativePath=="string"?u.relativePath.trim():"";if(v)return p.join(e,v)}}catch{}let i=D(e),c=Array.isArray(i.payload?.projects)?i.payload.projects:[];for(let o of c){let n=f(o),r=typeof n.path=="string"?n.path.trim():"";if(r)return p.resolve(r)}return a}function T(t){let e=i(t);return j(e,t)?"go":l$1(e,t)?"java":k(e,t)?"node":n(e,t)?"python":"unknown"}function W(t,e){if(!l.existsSync(t))return null;let a=l.readdirSync(t).filter(s=>s.endsWith(".json")&&e.some(i=>i.test(s))).map(s=>p.join(t,s));return a.length===0?null:(a.sort((s,i)=>l.statSync(i).mtimeMs-l.statSync(s).mtimeMs),a[0])}function f(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function L(t){for(let e of t)if(l.existsSync(e))return e;return null}function z(t,...e){let a=o(t,...e);return L(a)??a[0]}function S(t,e){let a=a$2(t,`.workspai/reports/${e}`);return L([a,p.join(t,".rapidkit","reports",e)])??a}async function H(t){let{readWorkspaceRegistrySummary:e,resolveWorkspaceRegisteredProjects:a}=await import('./workspace-registry-summary-A3YDL63D.js'),s=await e(t);return s?s.projectCount:(await a(t)).summary.projectCount}function K(t,e,a){let s=z(t,"toolchain.lock");if(!l.existsSync(s))return {gate:"env",status:"fail",summary:"toolchain.lock is missing",details:["Run workspai bootstrap to pin runtime versions and generate a reproducible toolchain."],evidencePath:s};try{let i=JSON.parse(l.readFileSync(s,"utf-8")),c=f(i.runtime),n=["python","node","go","java"].filter(r=>{let u=f(c[r]);return typeof u.version=="string"&&u.version.trim().length>0});if(n.length===0)return {gate:"env",status:"fail",summary:"No runtime versions are pinned in toolchain.lock",details:["Pin at least one runtime version via workspai setup <runtime> and re-run bootstrap."],evidencePath:s};if(e!=="unknown"){let r=f(c[e]);if(typeof r.version!="string"||r.version.trim().length===0)return {gate:"env",status:"fail",summary:`${a?.hasRegisteredProjects?"Project runtime":"Workspace"} (${e}) is not pinned in toolchain.lock`,details:[`Run workspai setup ${e} and workspai bootstrap to lock ${e} for this workspace.`],evidencePath:s}}return {gate:"env",status:"pass",summary:`Pinned runtimes: ${n.join(", ")}`,details:[],evidencePath:s}}catch{return {gate:"env",status:"fail",summary:"toolchain.lock is invalid JSON",details:["Regenerate lockfile with workspai bootstrap."],evidencePath:s}}}function D(t){let e=S(t,"doctor-last-run.json");if(!l.existsSync(e))return {payload:null,path:e};try{let a=JSON.parse(l.readFileSync(e,"utf-8"));return c(a,"workspace")?{payload:a,path:e}:{payload:null,path:e}}catch{return {payload:null,path:e}}}function B(t){let e=D(t);if(!e.payload)return {gate:{gate:"doctor",status:"fail",summary:"Doctor evidence is missing",details:["Run workspai doctor workspace --json before release readiness checks."],evidencePath:e.path},payload:null};let a=f(e.payload.summary),s=Number(a.totalIssues??0);return a.hasSystemErrors?{gate:{gate:"doctor",status:"fail",summary:"Doctor reported system errors",details:["Resolve system-level doctor errors before proceeding."],evidencePath:e.path},payload:e.payload}:s>0?{gate:{gate:"doctor",status:"warn",summary:`Doctor found ${s} issue(s)`,details:["Run workspai doctor workspace --fix and re-run readiness checks."],evidencePath:e.path},payload:e.payload}:{gate:{gate:"doctor",status:"pass",summary:"Doctor checks passed without issues",details:[],evidencePath:e.path},payload:e.payload}}function U(t){let e=S(t,"analyze-last-run.json");if(!l.existsSync(e))return {gate:"analyze",status:"fail",summary:"Analyze evidence is missing",details:["Run workspai analyze --json before release readiness checks."],evidencePath:e};try{let a=JSON.parse(l.readFileSync(e,"utf-8"));b$2(a$1.analyze,a,e);let s=f(a.summary),i=String(s.verdict??"").toLowerCase(),c=Number(s.score??0),o=f(s.findings),n=Number(o.fail??0);return i==="blocked"||n>0?{gate:"analyze",status:"fail",summary:`Analyze verdict is blocked (score ${c}/100)`,details:["Resolve analyze findings and regenerate analyze-last-run.json."],evidencePath:e}:i==="needs-attention"?{gate:"analyze",status:"warn",summary:`Analyze needs attention (score ${c}/100)`,details:["Review analyze warnings before release."],evidencePath:e}:{gate:"analyze",status:"pass",summary:`Analyze passed (score ${c}/100)`,details:[],evidencePath:e}}catch{return {gate:"analyze",status:"fail",summary:"Analyze evidence is invalid or violates its contract",details:["Re-run workspai analyze --json to regenerate evidence."],evidencePath:e}}}function q(t){try{let e=JSON.parse(l.readFileSync(t,"utf-8")),a=String(e.status??"").toLowerCase(),s=f(e.summary),i=Number(s.failedChecks??0);return a==="fail"||i>0?{gate:"verify",status:"fail",summary:"Verify-pack contract reports failed checks",details:["Fix failed verify checks and regenerate verify-pack contract evidence."],evidencePath:t}:a==="pass"?{gate:"verify",status:"pass",summary:"Verify-pack contract passed",details:[],evidencePath:t}:{gate:"verify",status:"warn",summary:"Verify-pack contract status is not explicit",details:["Ensure contract status is pass/fail and keep schema aligned with v1 contract."],evidencePath:t}}catch{return {gate:"verify",status:"fail",summary:"Verify-pack contract is invalid JSON",details:["Regenerate verify-pack contract artifact."],evidencePath:t}}}async function Q(t,e){if(e.skipVerify)return {gate:"verify",status:"pass",summary:"Verify gate skipped (--skip-verify)",details:["Verification was explicitly skipped for this readiness run."]};let a=[a$2(t,".workspai/reports"),p.join(t,".rapidkit","reports")],s=a[0],i=a.map(n=>W(n,[/verify-pack-contract/i,/^verify.*\.json$/i])).find(n=>typeof n=="string")??null;if(i)return q(i);let c=a$2(t,a$1.contractVerify),o=a.map(n=>W(n,[/workspace-contract-verify-last-run/i,/workspace-contract-verify/i])).find(n=>typeof n=="string")??null;if(o)try{let n=JSON.parse(l.readFileSync(o,"utf-8")),r=String(n.status??"").toLowerCase();if(r==="passed"||r==="pass")return {gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI cache)",details:[],evidencePath:o};if(r==="failed"||r==="fail")return {gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI cache)",details:(Array.isArray(n.violations)?n.violations:[]).slice(0,5),evidencePath:o}}catch{}try{let{verifyWorkspaceContract:n}=await import('./workspace-contract-RPQQBQXR.js'),r=await n({workspacePath:t}),u={schemaVersion:"v1",source:"cli",generatedAt:new Date().toISOString(),status:r.status,contractPath:r.contractPath,projectCount:r.projectCount,checks:r.checks,violations:r.violations};return await e$1(t,a$1.contractVerify,u),r.status==="failed"?{gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI)",details:r.violations.slice(0,5),evidencePath:c}:{gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI)",details:[],evidencePath:c}}catch(n){return {gate:"verify",status:"fail",summary:"No verify evidence and workspace contract verification unavailable",details:["Run workspai workspace contract verify --json or export verify-pack contract from CI.",n instanceof Error?n.message:String(n)],evidencePath:p.join(s,"*verify*.json")}}}function X(t,e){let a=S(e,"doctor-last-run.json");if(!t)return {gate:"dependency",status:"warn",summary:"Dependency risk check skipped (doctor evidence missing)",details:["Run workspai doctor workspace --json to include dependency findings."],evidencePath:a};let s=Array.isArray(t.projects)?t.projects:[],i=s.reduce((o,n)=>{let r=Number(n.vulnerabilities??0);return Number.isFinite(r)?o+Math.max(0,r):o},0),c=s.filter(o=>o.depsInstalled===false).length;return i>0?{gate:"dependency",status:"fail",summary:`${i} dependency vulnerability(ies) reported`,details:["Resolve vulnerabilities (npm/pip/go audit pipelines) before release."],evidencePath:a}:c>0?{gate:"dependency",status:"warn",summary:`${c} project(s) report missing dependencies`,details:["Run project init/bootstrap and regenerate doctor evidence."],evidencePath:a}:{gate:"dependency",status:"pass",summary:"No dependency vulnerabilities reported",details:[],evidencePath:a}}function Y(t){return t.some(e=>e.status==="fail")?"fail":t.some(e=>e.status==="warn")?"warn":"pass"}async function Z(t,e){return e$1(t,J,e)}async function ee(t={}){let e$1=p.resolve(t.startPath??process.cwd()),a$1=a(e$1)??e$1,s=await H(a$1)>0,i=s&&b(e$1)?a$1:M(e$1,a$1),c=i===a$1?"unknown":T(i),n=K(a$1,s?c:"unknown",{hasRegisteredProjects:s}),r=B(a$1),u=U(a$1),v=await Q(a$1,{skipVerify:t.skipVerify}),_=X(r.payload,a$1),R=[n,r.gate,u,v,_],k=Y(R),g={schemaVersion:F,generatedAt:new Date().toISOString(),workspacePath:a$1,projectPath:i,action:t.action,overallStatus:k,blocking:k==="fail",blockingReasons:R.filter(y=>y.status==="fail").map(y=>`${y.gate}: ${y.summary}`),gates:R};if(t.writeReport!==false){let y=f$1(g,{commandId:"workspaceReadiness",exitCode:k==="fail"?2:k==="warn"?1:0,generatedAt:g.generatedAt,blockers:g.blockingReasons,runId:e()});g.evidencePath=await Z(a$1,y);}return g}function te(t){return t==="pass"?d.green("PASS"):t==="warn"?d.yellow("WARN"):d.red("FAIL")}function ae(t){return t==="pass"?d.green("PASS"):t==="warn"?d.yellow("WARN"):d.red("FAIL")}async function me(t){let e=await ee({startPath:t.workspace,writeReport:true,skipVerify:t.skipVerify===true});if(t.json)console.log(JSON.stringify(e,null,2));else {console.log(d.bold.cyan(`
|
|
1
|
+
import {f as f$1,e}from'./chunk-T3GJ7YVG.js';import {a,b}from'./chunk-22DT744Z.js';import {i,j,l as l$1,k,n}from'./chunk-PHXQR6PX.js';import {a as a$2,e as e$1}from'./chunk-32OJDBIG.js';import {c}from'./chunk-YJZOMRAS.js';import {b as b$2}from'./chunk-3NU32T4A.js';import {b as b$1,a as a$1}from'./chunk-BMWFQXGW.js';import {o}from'./chunk-5XATWNME.js';import d from'chalk';import l from'fs';import p from'path';var J=a$1.readiness,F=b$1.readiness;function M(t,e){let a=p.resolve(t);if(!b(a))return a;let s=z(e,"workspace.contract.json");if(l.existsSync(s))try{let o=JSON.parse(l.readFileSync(s,"utf-8")),n=Array.isArray(o.projects)?o.projects:[];for(let r of n){let u=f(r),v=typeof u.relativePath=="string"?u.relativePath.trim():"";if(v)return p.join(e,v)}}catch{}let i=D(e),c=Array.isArray(i.payload?.projects)?i.payload.projects:[];for(let o of c){let n=f(o),r=typeof n.path=="string"?n.path.trim():"";if(r)return p.resolve(r)}return a}function T(t){let e=i(t);return j(e,t)?"go":l$1(e,t)?"java":k(e,t)?"node":n(e,t)?"python":"unknown"}function W(t,e){if(!l.existsSync(t))return null;let a=l.readdirSync(t).filter(s=>s.endsWith(".json")&&e.some(i=>i.test(s))).map(s=>p.join(t,s));return a.length===0?null:(a.sort((s,i)=>l.statSync(i).mtimeMs-l.statSync(s).mtimeMs),a[0])}function f(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function L(t){for(let e of t)if(l.existsSync(e))return e;return null}function z(t,...e){let a=o(t,...e);return L(a)??a[0]}function S(t,e){let a=a$2(t,`.workspai/reports/${e}`);return L([a,p.join(t,".rapidkit","reports",e)])??a}async function H(t){let{readWorkspaceRegistrySummary:e,resolveWorkspaceRegisteredProjects:a}=await import('./workspace-registry-summary-ORDK7A36.js'),s=await e(t);return s?s.projectCount:(await a(t)).summary.projectCount}function K(t,e,a){let s=z(t,"toolchain.lock");if(!l.existsSync(s))return {gate:"env",status:"fail",summary:"toolchain.lock is missing",details:["Run workspai bootstrap to pin runtime versions and generate a reproducible toolchain."],evidencePath:s};try{let i=JSON.parse(l.readFileSync(s,"utf-8")),c=f(i.runtime),n=["python","node","go","java"].filter(r=>{let u=f(c[r]);return typeof u.version=="string"&&u.version.trim().length>0});if(n.length===0)return {gate:"env",status:"fail",summary:"No runtime versions are pinned in toolchain.lock",details:["Pin at least one runtime version via workspai setup <runtime> and re-run bootstrap."],evidencePath:s};if(e!=="unknown"){let r=f(c[e]);if(typeof r.version!="string"||r.version.trim().length===0)return {gate:"env",status:"fail",summary:`${a?.hasRegisteredProjects?"Project runtime":"Workspace"} (${e}) is not pinned in toolchain.lock`,details:[`Run workspai setup ${e} and workspai bootstrap to lock ${e} for this workspace.`],evidencePath:s}}return {gate:"env",status:"pass",summary:`Pinned runtimes: ${n.join(", ")}`,details:[],evidencePath:s}}catch{return {gate:"env",status:"fail",summary:"toolchain.lock is invalid JSON",details:["Regenerate lockfile with workspai bootstrap."],evidencePath:s}}}function D(t){let e=S(t,"doctor-last-run.json");if(!l.existsSync(e))return {payload:null,path:e};try{let a=JSON.parse(l.readFileSync(e,"utf-8"));return c(a,"workspace")?{payload:a,path:e}:{payload:null,path:e}}catch{return {payload:null,path:e}}}function B(t){let e=D(t);if(!e.payload)return {gate:{gate:"doctor",status:"fail",summary:"Doctor evidence is missing",details:["Run workspai doctor workspace --json before release readiness checks."],evidencePath:e.path},payload:null};let a=f(e.payload.summary),s=Number(a.totalIssues??0);return a.hasSystemErrors?{gate:{gate:"doctor",status:"fail",summary:"Doctor reported system errors",details:["Resolve system-level doctor errors before proceeding."],evidencePath:e.path},payload:e.payload}:s>0?{gate:{gate:"doctor",status:"warn",summary:`Doctor found ${s} issue(s)`,details:["Run workspai doctor workspace --fix and re-run readiness checks."],evidencePath:e.path},payload:e.payload}:{gate:{gate:"doctor",status:"pass",summary:"Doctor checks passed without issues",details:[],evidencePath:e.path},payload:e.payload}}function U(t){let e=S(t,"analyze-last-run.json");if(!l.existsSync(e))return {gate:"analyze",status:"fail",summary:"Analyze evidence is missing",details:["Run workspai analyze --json before release readiness checks."],evidencePath:e};try{let a=JSON.parse(l.readFileSync(e,"utf-8"));b$2(a$1.analyze,a,e);let s=f(a.summary),i=String(s.verdict??"").toLowerCase(),c=Number(s.score??0),o=f(s.findings),n=Number(o.fail??0);return i==="blocked"||n>0?{gate:"analyze",status:"fail",summary:`Analyze verdict is blocked (score ${c}/100)`,details:["Resolve analyze findings and regenerate analyze-last-run.json."],evidencePath:e}:i==="needs-attention"?{gate:"analyze",status:"warn",summary:`Analyze needs attention (score ${c}/100)`,details:["Review analyze warnings before release."],evidencePath:e}:{gate:"analyze",status:"pass",summary:`Analyze passed (score ${c}/100)`,details:[],evidencePath:e}}catch{return {gate:"analyze",status:"fail",summary:"Analyze evidence is invalid or violates its contract",details:["Re-run workspai analyze --json to regenerate evidence."],evidencePath:e}}}function q(t){try{let e=JSON.parse(l.readFileSync(t,"utf-8")),a=String(e.status??"").toLowerCase(),s=f(e.summary),i=Number(s.failedChecks??0);return a==="fail"||i>0?{gate:"verify",status:"fail",summary:"Verify-pack contract reports failed checks",details:["Fix failed verify checks and regenerate verify-pack contract evidence."],evidencePath:t}:a==="pass"?{gate:"verify",status:"pass",summary:"Verify-pack contract passed",details:[],evidencePath:t}:{gate:"verify",status:"warn",summary:"Verify-pack contract status is not explicit",details:["Ensure contract status is pass/fail and keep schema aligned with v1 contract."],evidencePath:t}}catch{return {gate:"verify",status:"fail",summary:"Verify-pack contract is invalid JSON",details:["Regenerate verify-pack contract artifact."],evidencePath:t}}}async function Q(t,e){if(e.skipVerify)return {gate:"verify",status:"pass",summary:"Verify gate skipped (--skip-verify)",details:["Verification was explicitly skipped for this readiness run."]};let a=[a$2(t,".workspai/reports"),p.join(t,".rapidkit","reports")],s=a[0],i=a.map(n=>W(n,[/verify-pack-contract/i,/^verify.*\.json$/i])).find(n=>typeof n=="string")??null;if(i)return q(i);let c=a$2(t,a$1.contractVerify),o=a.map(n=>W(n,[/workspace-contract-verify-last-run/i,/workspace-contract-verify/i])).find(n=>typeof n=="string")??null;if(o)try{let n=JSON.parse(l.readFileSync(o,"utf-8")),r=String(n.status??"").toLowerCase();if(r==="passed"||r==="pass")return {gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI cache)",details:[],evidencePath:o};if(r==="failed"||r==="fail")return {gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI cache)",details:(Array.isArray(n.violations)?n.violations:[]).slice(0,5),evidencePath:o}}catch{}try{let{verifyWorkspaceContract:n}=await import('./workspace-contract-TU2I7GC2.js'),r=await n({workspacePath:t}),u={schemaVersion:"v1",source:"cli",generatedAt:new Date().toISOString(),status:r.status,contractPath:r.contractPath,projectCount:r.projectCount,checks:r.checks,violations:r.violations};return await e$1(t,a$1.contractVerify,u),r.status==="failed"?{gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI)",details:r.violations.slice(0,5),evidencePath:c}:{gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI)",details:[],evidencePath:c}}catch(n){return {gate:"verify",status:"fail",summary:"No verify evidence and workspace contract verification unavailable",details:["Run workspai workspace contract verify --json or export verify-pack contract from CI.",n instanceof Error?n.message:String(n)],evidencePath:p.join(s,"*verify*.json")}}}function X(t,e){let a=S(e,"doctor-last-run.json");if(!t)return {gate:"dependency",status:"warn",summary:"Dependency risk check skipped (doctor evidence missing)",details:["Run workspai doctor workspace --json to include dependency findings."],evidencePath:a};let s=Array.isArray(t.projects)?t.projects:[],i=s.reduce((o,n)=>{let r=Number(n.vulnerabilities??0);return Number.isFinite(r)?o+Math.max(0,r):o},0),c=s.filter(o=>o.depsInstalled===false).length;return i>0?{gate:"dependency",status:"fail",summary:`${i} dependency vulnerability(ies) reported`,details:["Resolve vulnerabilities (npm/pip/go audit pipelines) before release."],evidencePath:a}:c>0?{gate:"dependency",status:"warn",summary:`${c} project(s) report missing dependencies`,details:["Run project init/bootstrap and regenerate doctor evidence."],evidencePath:a}:{gate:"dependency",status:"pass",summary:"No dependency vulnerabilities reported",details:[],evidencePath:a}}function Y(t){return t.some(e=>e.status==="fail")?"fail":t.some(e=>e.status==="warn")?"warn":"pass"}async function Z(t,e){return e$1(t,J,e)}async function ee(t={}){let e$1=p.resolve(t.startPath??process.cwd()),a$1=a(e$1)??e$1,s=await H(a$1)>0,i=s&&b(e$1)?a$1:M(e$1,a$1),c=i===a$1?"unknown":T(i),n=K(a$1,s?c:"unknown",{hasRegisteredProjects:s}),r=B(a$1),u=U(a$1),v=await Q(a$1,{skipVerify:t.skipVerify}),_=X(r.payload,a$1),R=[n,r.gate,u,v,_],k=Y(R),g={schemaVersion:F,generatedAt:new Date().toISOString(),workspacePath:a$1,projectPath:i,action:t.action,overallStatus:k,blocking:k==="fail",blockingReasons:R.filter(y=>y.status==="fail").map(y=>`${y.gate}: ${y.summary}`),gates:R};if(t.writeReport!==false){let y=f$1(g,{commandId:"workspaceReadiness",exitCode:k==="fail"?2:k==="warn"?1:0,generatedAt:g.generatedAt,blockers:g.blockingReasons,runId:e()});g.evidencePath=await Z(a$1,y);}return g}function te(t){return t==="pass"?d.green("PASS"):t==="warn"?d.yellow("WARN"):d.red("FAIL")}function ae(t){return t==="pass"?d.green("PASS"):t==="warn"?d.yellow("WARN"):d.red("FAIL")}async function me(t){let e=await ee({startPath:t.workspace,writeReport:true,skipVerify:t.skipVerify===true});if(t.json)console.log(JSON.stringify(e,null,2));else {console.log(d.bold.cyan(`
|
|
2
2
|
\u{1F6A6} Workspai Release Readiness
|
|
3
3
|
`)),console.log(d.bold(`Workspace: ${d.cyan(p.basename(e.workspacePath))}`)),console.log(d.gray(`Path: ${e.workspacePath}`)),console.log(`Overall: ${ae(e.overallStatus)}`);for(let a of e.gates){console.log(` - ${a.gate}: ${te(a.status)} ${a.summary}`);for(let s of a.details)console.log(d.gray(` ${s}`));a.evidencePath&&console.log(d.gray(` evidence: ${a.evidencePath}`));}e.evidencePath&&console.log(d.gray(`
|
|
4
4
|
Evidence saved: ${e.evidencePath}`));}t.strict&&e.overallStatus!=="pass"&&process.exit(1);}export{ee as a,me as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o={model:".workspai/reports/workspace-model.json",knowledgeGraph:".workspai/reports/workspace-knowledge-graph.json",snapshot:".workspai/reports/workspace-model-snapshot.json",diff:".workspai/reports/workspace-model-diff-last-run.json",impact:".workspai/reports/workspace-impact-last-run.json",analyze:".workspai/reports/analyze-last-run.json",doctor:".workspai/reports/doctor-last-run.json",contractVerify:".workspai/reports/workspace-contract-verify-last-run.json",readiness:".workspai/reports/release-readiness-last-run.json",verify:".workspai/reports/workspace-verify-last-run.json",history:".workspai/reports/workspace-intelligence-history.json",agentContext:".workspai/reports/workspace-context-agent.json",agentIndex:".workspai/reports/INDEX.json",agentCustomizationPack:".workspai/reports/agent-customization-pack.json",skillsIndex:".workspai/reports/workspace-skills-index.json",agents:"AGENTS.md",explain:".workspai/reports/workspace-explain-last-run.json",intelligenceRun:".workspai/reports/workspace-intelligence-run-last-run.json",evaluationLive:".workspai/reports/workspace-intelligence-evaluation-live.json",evaluationLastRun:".workspai/reports/workspace-intelligence-evaluation-last-run.json"},t={model:"workspace-model.v1",knowledgeGraph:"workspace-knowledge-graph.v1",snapshot:"workspace-model-snapshot.v1",diff:"workspace-model-diff.v1",impact:"workspace-impact.v1",analyze:"rapidkit-analyze-v1",doctor:"doctor-workspace-evidence-v1",contractVerify:"workspace-contract-verify.v1",readiness:"release-readiness-v1",verify:"workspace-verify.v1",history:"workspace-intelligence-history.v1",agentContext:"workspace-context.v1",agentIndex:"rapidkit-agent-reports-index.v1",agentCustomizationPack:"rapidkit-agent-customization-pack.v1",skillsIndex:"workspace-skills-index.v1",agents:null,explain:"workspace-explain.v1",intelligenceRun:"workspace-intelligence-run.v1",evaluationLive:"workspace-intelligence-evaluation.v1",evaluationLastRun:"workspace-intelligence-evaluation.v1"},a={model:"contracts/workspace-intelligence/workspace-model.v1.json",knowledgeGraph:"contracts/workspace-intelligence/workspace-knowledge-graph.v1.json",snapshot:"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",diff:"contracts/workspace-intelligence/workspace-model-diff.v1.json",impact:"contracts/workspace-intelligence/workspace-impact.v1.json",analyze:"contracts/analyze-last-run.v1.json",doctor:"contracts/doctor-workspace-evidence.v1.json",contractVerify:"contracts/workspace-intelligence/workspace-contract-verify.v1.json",readiness:"contracts/release-readiness.v1.json",verify:"contracts/workspace-intelligence/workspace-verify.v1.json",history:"contracts/workspace-intelligence/workspace-intelligence-history.v1.json",agentContext:"contracts/workspace-intelligence/workspace-context.v1.json",agentIndex:"contracts/workspace-intelligence/agent-reports-index.v1.json",agentCustomizationPack:"contracts/workspace-intelligence/agent-customization-pack-report.v1.json",skillsIndex:"contracts/workspace-intelligence/workspace-skills-index.v1.json",agents:null,explain:"contracts/workspace-intelligence/workspace-explain.v1.json",intelligenceRun:"contracts/workspace-intelligence/workspace-intelligence-run.v1.json",evaluationLive:"contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",evaluationLastRun:"contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json"},r={analyze:"analyze",workspace:"workspace <action> [subaction] [key] [value]",doctor:"doctor [scope]",readiness:"readiness"},c=["analyze","readiness","doctor","workspace"],i=["model","diff","impact","doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence","verify","context","agent-sync","explain"],p=["sync","baseline"],l={sync:[".workspai/workspace.contract.json",".workspai/workspace-registry.v1.json"],baseline:[o.snapshot]},e=o,k={model:{command:["workspace","model","--json","--write"],produces:[e.model,e.knowledgeGraph]},diff:{command:["workspace","diff","--from",e.snapshot,"--json"],produces:[e.diff]},impact:{command:["workspace","impact","--from",e.diff,"--json"],produces:[e.impact]},"doctor-evidence":{command:["doctor","workspace","--json"],produces:[e.doctor]},"contract-evidence":{command:["workspace","contract","verify","--strict","--json"],produces:[e.contractVerify]},"analyze-evidence":{command:["analyze","--json"],produces:[e.analyze]},"readiness-evidence":{command:["readiness","--json","--skip-verify"],produces:[e.readiness]},verify:{command:["workspace","verify","--from-impact",e.impact,"--json"],produces:[e.verify,e.history]},context:{command:["workspace","context","--for-agent","--json","--write","--no-agent-sync"],produces:[e.agentContext]},"agent-sync":{command:["workspace","agent-sync","--write","--json","--preset","enterprise"],produces:[e.agentIndex,e.agentCustomizationPack,e.skillsIndex,e.agents]},explain:{command:["workspace","explain","release-blocked","--json","--write"],produces:[e.explain]}};export{o as a,t as b,a as c,r as d,c as e,i as f,p as g,l as h,k as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-BMWFQXGW.js';var r=".workspai/skills";var e=a$1.skillsIndex,a=a$1.explain,_=".workspai/reports/workspace-why-last-run.json",c=".workspai/reports/workspace-trace-last-run.json",O=".workspai/AGENT-GROUNDING.md",P=".rapidkit/AGENT-GROUNDING.md",I=".cursor/rules/workspai-grounding.mdc",A=".cursor/rules/rapidkit-grounding.mdc",T=".claude/rules/workspai-evidence.md",E=".claude/rules/rapidkit-evidence.md",R=".github/instructions/workspai-workspace.instructions.md",L=".github/instructions/rapidkit-workspace.instructions.md",d=".github/instructions/workspai-evidence.instructions.md",S=".github/instructions/rapidkit-evidence.instructions.md",C=".github/prompts/workspai-diagnose.prompt.md",k=".github/prompts/rapidkit-diagnose.prompt.md",l=".github/prompts/workspai-repair.prompt.md",m=".github/prompts/rapidkit-repair.prompt.md",N=".github/prompts/workspai-release-readiness.prompt.md",u=".github/prompts/rapidkit-release-readiness.prompt.md",g=".github/prompts/workspai-project-onboard.prompt.md",K=".github/prompts/rapidkit-project-onboard.prompt.md",G=".github/prompts/workspai-adopt-project.prompt.md",w=".github/prompts/rapidkit-adopt-project.prompt.md",x=".github/skills/workspai-grounding/SKILL.md",H=".github/skills/rapidkit-grounding/SKILL.md",D=".github/skills/workspai-workspace-intelligence/SKILL.md",W=".github/skills/rapidkit-workspace-intelligence/SKILL.md",h=".workspai/reports/workspai-mcp-design.json",U=".workspai/reports/rapidkit-mcp-design.json",b=".vscode/workspai-agent-hooks.json",Y=".vscode/rapidkit-agent-hooks.json";function M(t){let s=t.trim();if(!s||s.includes("..")||s.includes("/"))throw new Error(`Invalid operational skill id: ${t}`);return `${r}/${s}.md`}var f={"workspai-diagnose-api-failure":"workspai-diagnose","workspai-release-readiness":"workspai-release-readiness","workspai-safe-schema-migration":"workspai-safe-schema-migration","workspai-dependency-upgrade":"workspai-dependency-upgrade","workspai-rename-contract":"workspai-rename-contract"};export{H as A,D as B,W as C,h as D,U as E,b as F,Y as G,M as H,f as I,r as a,e as b,a as c,_ as d,c as e,O as f,P as g,I as h,A as i,T as j,E as k,R as l,L as m,d as n,S as o,C as p,k as q,l as r,m as s,N as t,u,g as v,K as w,G as x,w as y,x as z};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {d,b as b$1,e}from'./chunk-DV6GJD4K.js';import {d as d$2}from'./chunk-S5KTATOU.js';import {p as p$1,w,t}from'./chunk-TWNFECMN.js';import {h,i,f,e as e$1}from'./chunk-4KUIFXHM.js';import {d as d$1}from'./chunk-2TEDAKP6.js';import {a}from'./chunk-GZTYAEWX.js';import {a as a$1}from'./chunk-TQEMLBAG.js';import {p,l,o}from'./chunk-5XATWNME.js';import {e as e$2,g}from'./chunk-EYJ2CQSK.js';import _ from'fs';import b from'path';import E from'chalk';import {execa}from'execa';function Se(e){return _.existsSync(b.join(e,"bun.lock"))||_.existsSync(b.join(e,"bunfig.toml"))?"bun":_.existsSync(b.join(e,"pnpm-lock.yaml"))?"pnpm":_.existsSync(b.join(e,"yarn.lock"))?"yarn":(_.existsSync(b.join(e,"package-lock.json")),"npm")}function Ee(e,t,r=Se(e)){return r==="npm"?`npm run ${t}`:`${r} run ${t}`}function Ce(e,t=Se(e)){return `${t} install`}var Ge={"python-fastapi":{runtime:"python",framework:"FastAPI",markers:["pyproject.toml","fastapi"],commands:{init:"python -m pip install -e .",test:"pytest",build:"python -m build",start:"uvicorn main:app --reload"},errorPatterns:{setup:["ModuleNotFoundError","No module named","pip: command not found"],"test-failure":["FAILED","ERROR","test session started"],dependency:["ImportError","missing.*dependency"],runtime:["TypeError","AttributeError","ValueError"],timeout:["timeout","Timeout","timed out"],unknown:[]},healthCheck:{stage:"start",type:"http",value:"http://localhost:8000/docs"},validation:{command:"python -m pip list | grep fastapi",error:"FastAPI not installed"}},"python-django":{runtime:"python",framework:"Django",markers:["manage.py","django"],commands:{init:"python manage.py migrate",test:"python manage.py test",build:"python manage.py collectstatic --noinput",start:"python manage.py runserver 0.0.0.0:8000"},errorPatterns:{setup:["ModuleNotFoundError","ProgrammingError.*migrate"],"test-failure":["FAILED","ERROR","Ran.*test"],dependency:["ImportError","missing.*dependency"],runtime:["DatabaseError","ImproperlyConfigured"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"node-nestjs":{runtime:"node",framework:"NestJS",markers:["package.json","@nestjs/core"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm run start"},errorPatterns:{setup:["npm ERR!","ENOENT","not found"],"test-failure":["Tests.*failed","FAIL","fail.*test"],dependency:["Cannot find module","ERR_MODULE_NOT_FOUND"],runtime:["TypeError","Error: ","ReferenceError"],timeout:["timeout","TIMEOUT"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3}},"node-express":{runtime:"node",framework:"Express",markers:["package.json","express"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm start"},errorPatterns:{setup:["npm ERR!","ENOENT"],"test-failure":["failed","FAIL"],dependency:["Cannot find module"],runtime:["Error","TypeError"],timeout:["timeout"],unknown:[]}},"go-fiber":{runtime:"go",framework:"Fiber",markers:["go.mod","fiber"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found","cannot find","go mod tidy"],"test-failure":["FAIL","--- FAIL"],dependency:["missing.*module"],runtime:["panic","fatal","Error"],timeout:["timeout","context deadline"],unknown:[]},dependencies:["init"]},"go-gin":{runtime:"go",framework:"Gin",markers:["go.mod","gin-gonic"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found"],"test-failure":["FAIL"],dependency:["missing.*module"],runtime:["panic"],timeout:["timeout"],unknown:[]}},"java-springboot":{runtime:"java",framework:"Spring Boot",markers:["pom.xml","build.gradle","spring-boot"],commands:{init:"mvn dependency:go-offline",test:"mvn test",build:"mvn package -DskipTests",start:"mvn spring-boot:run"},errorPatterns:{setup:["\\[ERROR\\]","BUILD FAILURE","missing dependencies"],"test-failure":["\\[ERROR\\] Tests run:","BUILD FAILURE"],dependency:["missing.*dependency"],runtime:["Exception","Error","NullPointerException"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8080}},"php-laravel":{runtime:"php",framework:"Laravel",markers:["composer.json","artisan","app/Models"],commands:{init:"composer install && php artisan migrate:fresh --seed",test:"php artisan test",build:"php artisan config:cache && php artisan route:cache && php artisan view:cache",start:"php artisan serve --host=0.0.0.0 --port=8000"},errorPatterns:{setup:["Composer.*lock","Fatal error","Class.*not found"],"test-failure":["FAILED","Tests.*failed"],dependency:["Class.*not found","require.*failed"],runtime:["Fatal error","Exception","Error"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"php-symfony":{runtime:"php",framework:"Symfony",markers:["composer.json","symfony.lock","bin/console"],commands:{init:"composer install && php bin/console doctrine:database:create",test:"php bin/phpunit",build:"php bin/console cache:clear --env=prod",start:"symfony serve --no-tls"},errorPatterns:{setup:["Composer.*error","Fatal error"],"test-failure":["FAILED","failure"],dependency:["Class.*not found"],runtime:["Fatal error","Exception"],timeout:["timeout"],unknown:[]},dependencies:["init"]},"rust-actix":{runtime:"rust",framework:"Actix-web",markers:["Cargo.toml","actix"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find","failed.*download"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E","thread.*panicked"],timeout:["timeout"],unknown:[]},validation:{command:"cargo --version",error:"Rust/Cargo not installed"}},"rust-axum":{runtime:"rust",framework:"Axum",markers:["Cargo.toml","axum"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"rust-rocket":{runtime:"rust",framework:"Rocket",markers:["Cargo.toml","rocket"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["FAILED"],dependency:["can.t find"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"dotnet-aspnetcore":{runtime:"dotnet",framework:"ASP.NET Core",markers:[".csproj",".sln","Program.cs"],commands:{init:"dotnet restore",test:"dotnet test",build:"dotnet build -c Release",start:"dotnet run"},errorPatterns:{setup:["error CS","CSPROJ.*not found","NuGet.*restore"],"test-failure":["Failed:.*test","FAILED"],dependency:["error NU1101"],runtime:["error CS","Exception"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:5e3}},"elixir-phoenix":{runtime:"elixir",framework:"Phoenix",markers:["mix.exs","phoenix"],commands:{init:"mix setup",test:"mix test",build:"mix compile --all-warnings",start:"mix phx.server"},errorPatterns:{setup:["\\*\\* \\(.*Error\\)","Mix.InstallError"],"test-failure":["\\d+\\sfailed","FAILED"],dependency:["dependencies are not available"],runtime:["\\*\\* \\(","RuntimeError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:4e3},dependencies:["init"]},"ruby-rails":{runtime:"ruby",framework:"Rails",markers:["Gemfile","config/application.rb","bin/rails"],commands:{init:"bundle install && rails db:prepare",test:"rails test",build:"rails assets:precompile",start:"rails server --binding=0.0.0.0 --port=3000"},errorPatterns:{setup:["Bundler::.*Error","Gem::.*Error"],"test-failure":["failures,","error,","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","Exception","NoMethodError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3},dependencies:["init"]},"ruby-sinatra":{runtime:"ruby",framework:"Sinatra",markers:["Gemfile","app.rb","sinatra"],commands:{init:"bundle install",test:"rspec",build:`echo "Sinatra apps don't require build"`,start:"ruby app.rb"},errorPatterns:{setup:["Bundler.*Error","Gem.*Error"],"test-failure":["failure","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","NoMethodError"],timeout:["timeout"],unknown:[]}}},Be={init:{python:["pip install -e .","poetry install","pip install -r requirements.txt"],node:["npm install","pnpm install","yarn install"],go:["go mod download && go mod tidy","go get ./..."],java:["mvn dependency:go-offline","gradle dependencies"],php:["composer install"],rust:["cargo fetch"],dotnet:["dotnet restore"],elixir:["mix deps.get"],ruby:["bundle install"],"jvm-generic":["mvn dependency:go-offline","gradle dependencies"],unknown:[]},test:{python:["pytest","python -m unittest","python -m pytest"],node:["npm test","npm run test"],go:["go test ./...","make test"],java:["mvn test","gradle test"],php:["php artisan test","phpunit","pest"],rust:["cargo test"],dotnet:["dotnet test"],elixir:["mix test"],ruby:["rspec","ruby -m minitest"],"jvm-generic":["mvn test","gradle test"],unknown:[]},build:{python:["python -m build","python setup.py build"],node:["npm run build"],go:["go build -o app .","go build ./..."],java:["mvn package -DskipTests","gradle build -x test"],php:['echo "PHP build: typically no build step"'],rust:["cargo build --release"],dotnet:["dotnet build -c Release"],elixir:["mix compile"],ruby:["gem build *.gemspec"],"jvm-generic":["mvn package -DskipTests","gradle build"],unknown:[]},start:{python:["python app.py","python main.py","uvicorn main:app --reload"],node:["npm start","node index.js","node src/index.js"],go:["./app","go run main.go","go run ./..."],java:["mvn spring-boot:run","gradle bootRun","java -jar target/*.jar"],php:["php -S 0.0.0.0:8000","php artisan serve"],rust:["cargo run --release","./target/release/app"],dotnet:["dotnet run"],elixir:["mix phx.server","iex -S mix"],ruby:["rails server","ruby app.rb","bundle exec puma"],"jvm-generic":["java -jar *.jar","gradle run"],unknown:[]}};function se(e,t){if(t){let r=t.trim().toLowerCase().replace(/[_.\s]+/g,"-"),n=e$1(t),s=`${e}-${n==="gofiber"?"fiber":n==="gogin"?"gin":n==="dotnet"?"aspnetcore":n!=="unknown"?n:r==="fiber"?"fiber":r==="aspnetcore"||r==="asp-net-core"?"aspnetcore":r}`;return Ge[s]}}function Pe(e,t,r){if(t){let n=se(e,t);if(n&&n.commands[r])return n.commands[r]}if(["init","test","build","start"].includes(r)){let n=Be[r]?.[e]??[];return n.length>0?n[0]:void 0}}var ze={test:"test",build:"build",start:"start"};function ae(e){if(e.stage==="init")return e.runtime==="node"?Ce(e.projectPath):Pe(e.runtime,e.framework,e.stage);if(e.runtime==="node"){let t$1=ze[e.stage];if(t$1){let r=t(e.projectPath,t$1,{framework:e.framework});if(r)return Ee(e.projectPath,r.scriptName)}}return Pe(e.runtime,e.framework,e.stage)}function Ke(e){let t=h(e).map(r=>r==="python"?"python":r==="node"||r==="bun"?"node":r==="go"?"go":r==="java"?"java":r==="php"?"php":r==="rust"?"rust":r==="dotnet"?"dotnet":r==="elixir"?"elixir":r==="ruby"?"ruby":r==="clojure"||r==="scala"||r==="kotlin"?"jvm-generic":null).filter(r=>r!==null).filter((r,n,o)=>o.indexOf(r)===n);return {primary:t.length>0?t[0]:"unknown",secondary:t.slice(1)}}function Fe(e){return Ke(e).primary}function ie(e,t){if(!e)return "unknown";t||(t={setup:["ModuleNotFoundError","No module named","npm ERR!","error:","not found"],"test-failure":["FAILED","FAIL","failed"],dependency:["cannot find module","import.*error"],runtime:["Exception","Error:","panic","TypeError"],timeout:["timeout","Timeout","deadline exceeded"],unknown:[]});for(let[r,n]of Object.entries(t))for(let o of n)if(new RegExp(o,"i").test(e))return r;return "unknown"}async function q(e){let t=e.split(/[&|;]\s*/)[0].trim().split(/\s+/)[0];if(["echo","cd","pwd","test","true","false","exit"].includes(t))return {valid:true};try{let n=process.platform==="win32"?"where":"which";if((await execa(n,[t],{reject:false})).exitCode===0)return {valid:true}}catch{}return {valid:false,reason:`Command '${t}' not found or not executable`}}function Ae(e,t,r){if(!t)return e;let n=typeof t=="object"&&!Array.isArray(t)&&("dev"in t||"staging"in t||"prod"in t||"default"in t)&&!Object.keys(t).some(o=>["init","test","build","start"].includes(o))?t:{};return r&&typeof n[r]=="string"?n[r]:typeof n.default=="string"?n.default:e}var Ne={init:"init",test:"test",build:"build",start:"start"};function Ve(e){return e in Ne?Ne[e]:null}function He(e,t){let n=p$1(e)?.contextJson?.commands;if(!n||typeof n!="object"||Array.isArray(n))return;let o=n[t];if(typeof o=="string"&&o.trim().length>0)return o.trim();if(o&&typeof o=="object"&&!Array.isArray(o)){let s=o,c=s.default??s.dev;if(typeof c=="string"&&c.trim().length>0)return c.trim()}}function Oe(e,t,r=w(e)){let n=Ve(t);if(!n)return He(e,t)?{supported:true}:{supported:false,reason:`Workspace stage "${t}" is not part of the Workspai fleet contract.`};if(!r.projectRoot)return {supported:false,reason:"No Workspai project metadata was detected for this target."};let o=r.commandMap[n];if(!o||o.status!=="supported"){let s=r.runtimeSupportTier==="observed"||r.frameworkSupportTier==="observed";return {supported:false,reason:o?.reason??`Command "${n}" is not supported for this project runtime/framework.`,shouldFail:!s}}return {supported:true}}var Ue=new Set(["init","test","build","start"]),Je=new Set([".git","node_modules",".workspai",".rapidkit",".venv","dist","build","coverage","htmlcov"]);async function I(e){try{return await _.promises.access(e,_.constants.F_OK),true}catch{return false}}async function qe(e){for(let t of e)if(await I(t))return true;return false}async function Ye(e,t,r){if(t==="python"){let o=[b.join(e,".workspai","cli.py"),b.join(e,".rapidkit","cli.py")];for(let s of o)if(await I(s))return {valid:true};return {valid:false,reason:"Project-local .workspai/cli.py is missing. Run `workspai init` in this project first."}}let n=r.trim().split(/\s+/)[0];if(n&&["npm","npx","pnpm","yarn"].includes(n)){let o=e$2(n);if((await execa(o.command,[...o.prefixArgs,"--version"],{reject:false,env:g()})).exitCode===0)return {valid:true}}return q(r)}async function ue(e){let t=await _.promises.readFile(e,"utf-8");return JSON.parse(t)}function N(e){return e.replace(/\\/g,"/")}function Qe(e){let t=e?.trim();return t?t.startsWith("project:")?t.slice(8).trim()||null:t:null}async function Xe(e){return a(e,{skipDirs:Je,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:async(t,r)=>await qe([...p(t,"context.json"),...p(t,"project.json")])?true:b.resolve(t)===b.resolve(r)?false:h(t).length>0})}async function Ze(e){for(let t of [b.join(".workspai","project.json"),b.join(".workspai","context.json"),b.join(".rapidkit","project.json"),b.join(".rapidkit","context.json")]){let r=b.join(e,t);if(await I(r))try{let n=await ue(r),o=n.name??n.projectName??n.slug;if(typeof o=="string"&&o.trim())return o.trim()}catch{}}return null}async function et(e,t,r){let n=Qe(r);if(!n)return {projects:t,normalizedScope:null};let o=N(n).toLowerCase(),s=[];for(let c of t){let u=N(b.relative(e,c)),p=b.basename(c),m=await Ze(c);[u,p,m].filter(a=>typeof a=="string"&&a.length>0).map(a=>N(a).toLowerCase()).includes(o)&&s.push(c);}if(s.length===0)throw new Error(`Workspace run scope did not match any project: ${r}`);return {projects:s,normalizedScope:n}}async function tt(e,t,r){let n=await execa("git",["diff","--name-only",`${r}...HEAD`],{cwd:e,reject:false,env:a$1()});if(n.exitCode!==0)return new Set(t);let o=n.stdout.split(/\r?\n/).map(c=>c.trim()).filter(c=>c.length>0).map(c=>N(c));if(o.length===0)return new Set;let s=new Set;for(let c of t){let u=N(b.relative(e,c));if(!u||u===".")continue;let p=`${u}/`;o.some(m=>m===u||m.startsWith(p))&&s.add(c);}return s}async function rt(e,t,r){let n=await d$1(e,".workspai/workspace.contract.json")??l(e,"workspace.contract.json");if(await I(n))try{let g=await nt(e,t,r,n);if(g.graphStatus!=="missing")return g}catch{return {expanded:r,graphStatus:"invalid",expansionDepth:0}}let o=await d$1(e,".workspai/workspace-dependency-graph.json")??l(e,"workspace-dependency-graph.json");if(!await I(o))return {expanded:r,graphStatus:"missing",expansionDepth:0};let s;try{s=await ue(o);}catch{return {expanded:r,graphStatus:"invalid",expansionDepth:0}}let c=new Set(t.map(g=>b.resolve(g))),u=new Map;if(!s||typeof s!="object"||Array.isArray(s))return {expanded:r,graphStatus:"invalid",expansionDepth:0};let p=Array.isArray(s.projects)?s.projects:[];for(let g of p){if(!g||typeof g!="object"||Array.isArray(g))continue;let a=g,d=typeof a.path=="string"?a.path:"",y=b.resolve(e,d);if(!c.has(y))continue;let h=Array.isArray(a.dependsOn)?a.dependsOn.filter(w=>typeof w=="string"):[];for(let w of h){let x=b.resolve(e,w);c.has(x)&&(u.has(x)||u.set(x,new Set),u.get(x)?.add(y));}}let m=d$2(u,r);return {expanded:m.reached,graphStatus:"loaded",expansionDepth:m.added}}async function nt(e,t,r,n){let o=await ue(n);if(!o||typeof o!="object"||Array.isArray(o))return {expanded:r,graphStatus:"invalid",expansionDepth:0};let s=o,c=Array.isArray(s.projects)?s.projects:null;if(!c)return {expanded:r,graphStatus:"invalid",expansionDepth:0};let u=new Map,p=new Map;for(let y of t){let h=N(b.relative(e,y));p.set(h,b.resolve(y));}let m=new Map,g=new Map,a=new Map;for(let y of c){if(!y||typeof y!="object"||Array.isArray(y))continue;let h=y,w=typeof h.slug=="string"?h.slug:"",x=typeof h.relativePath=="string"?N(h.relativePath):w,R=p.get(x);!w||!R||u.set(w,R);}for(let y of c){if(!y||typeof y!="object"||Array.isArray(y))continue;let h=y,w=typeof h.slug=="string"?h.slug:"",x=u.get(w);if(!x)continue;let R=h.contracts&&typeof h.contracts=="object"&&!Array.isArray(h.contracts)?h.contracts:{},j=Array.isArray(R.dependsOn)?R.dependsOn.filter(v=>typeof v=="string"):[],O=Array.isArray(R.publishes)?R.publishes.filter(v=>typeof v=="string"):[],W=Array.isArray(R.consumes)?R.consumes.filter(v=>typeof v=="string"):[];for(let v of j){let S=u.get(v);S&&(a.has(S)||a.set(S,new Set),a.get(S)?.add(x));}for(let v of O)m.has(v)||m.set(v,new Set),m.get(v)?.add(x);for(let v of W)g.has(v)||g.set(v,new Set),g.get(v)?.add(x);}for(let[y,h]of m.entries()){let w=g.get(y);if(w)for(let x of h){a.has(x)||a.set(x,new Set);for(let R of w)R!==x&&a.get(x)?.add(R);}}let d=d$2(a,r);return {expanded:d.reached,graphStatus:"loaded",expansionDepth:d.added}}async function ot(e,t){if(typeof t=="boolean")return t;let r=o(e,"policies.yml").find(s=>_.existsSync(s))??l(e,"policies.yml");if(!await I(r))return true;let n="";try{n=await _.promises.readFile(r,"utf-8");}catch{return true}let o$1=n.match(/^[\t ]*rules\.enforce_workspace_run_gates:\s*(true|false)\s*(?:#.*)?$/m);return o$1?o$1[1]==="true":true}function st(e){let t=process.env.RAPIDKIT_WORKSPACE_RUN_STAGE_TIMEOUT_MS;if(t){let r=Number.parseInt(t,10);if(Number.isFinite(r)&&r>0)return r}return e==="init"?12e4:9e4}async function ce(e,t,r){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for nested workspace-run execution."};try{let o=await execa(process.execPath,[n,...e],{cwd:t,reject:false,timeout:r,env:{...process.env,RAPIDKIT_WORKSPACE_RUN_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr}}catch(o){return {exitCode:typeof o=="object"&&o!==null&&"timedOut"in o&&!!o.timedOut?124:1,stdout:typeof o=="object"&&o!==null&&"stdout"in o?String(o.stdout??""):"",stderr:typeof o=="object"&&o!==null&&"stderr"in o?String(o.stderr??""):o instanceof Error?o.message:String(o)}}}function at(e){return e==="node"||e==="go"||e==="java"||e==="python"||e==="dotnet"}function it(){return process.env.VITEST==="true"||process.env.VITEST==="1"||process.env.NODE_ENV==="test"}async function ct(e){let t=process.cwd();try{process.chdir(e);let{handleInitCommand:r}=await import('./index.js');return {exitCode:await r(["init"]),stdout:"",stderr:""}}finally{process.chdir(t);}}async function ut(e){let t=a=>{let d=f(a);return d==="node"||d==="bun"?"node":d==="python"?"python":d==="go"?"go":d==="java"?"java":d==="php"?"php":d==="ruby"?"ruby":d==="rust"?"rust":d==="dotnet"?"dotnet":d==="elixir"?"elixir":d==="clojure"||d==="scala"||d==="kotlin"?"jvm-generic":Fe(e)},r=a=>{if(!a)return;let d=e$1(a);if(new Set(["fastapi","django","flask","nestjs","express","fastify","koa","gofiber","gogin","echo","springboot","laravel","symfony","rails","sinatra","dotnet","actix","axum","rocket","phoenix"]).has(d))return d},n=p$1(e),o=n?.detection??i(e,n?.projectJson??null),s=n?.contextJson,c=t(o.runtime),u=r(o.key),p={},m=new Set(["init","test","build","start"]);if(s?.commands&&typeof s.commands=="object")for(let[a,d]of Object.entries(s.commands))typeof d=="string"&&m.has(a)&&(p[a]=d);let g;if(s?.commandEnvironments&&typeof s.commandEnvironments=="object"){let a=s.commandEnvironments;g={dev:typeof a.dev=="string"?a.dev:void 0,staging:typeof a.staging=="string"?a.staging:void 0,prod:typeof a.prod=="string"?a.prod:void 0,default:typeof a.default=="string"?a.default:void 0};}return {runtime:c,framework:u,commandOverrides:Object.keys(p).length>0?p:void 0,environmentCommandVariants:g,environment:typeof s?.environment=="string"?s.environment:void 0}}async function dt(e,t,r,n,o,s,c){let u=!o?.[t]&&at(r),p;if(o&&o[t]?p=o[t]:u?p=`rapidkit ${t}`:p=ae({projectPath:e,runtime:r,framework:n,stage:t}),!p)return {exitCode:127,command:`<stage not supported for ${r}>`,message:`No stage command found for runtime '${r}' and framework '${n||"unknown"}'`,errorCategory:"runtime"};let m=Ae(p,s,c);if(!m)return {exitCode:127,command:p,message:"Failed to resolve stage command",errorCategory:"runtime"};let g=ae({projectPath:e,runtime:r,framework:n,stage:t});if(u){if(g){let f=u?await Ye(e,r,g):await q(g);if(!f.valid)return {exitCode:127,command:m,message:f.reason||"Command not available",errorCategory:"setup"}}}else {let f=await q(m);if(!f.valid)return {exitCode:127,command:m,message:f.reason||"Command not available",errorCategory:"setup"}}let a=0,d="",y="",h,w=st(t),x=Date.now();try{let f=u?t==="init"&&it()?await ct(e):await ce([t],e,w):await execa(m,[],{cwd:e,reject:false,shell:true,timeout:w});if(a=Number(f.exitCode??0),d=f.stdout,y=f.stderr,a!==0){let C=`${d}
|
|
1
|
+
import {d,b as b$1,e}from'./chunk-HDXNIN4N.js';import {d as d$2}from'./chunk-S5KTATOU.js';import {p as p$1,w,t}from'./chunk-PHXQR6PX.js';import {h,i,f,e as e$1}from'./chunk-4KUIFXHM.js';import {d as d$1}from'./chunk-32OJDBIG.js';import {a}from'./chunk-GZTYAEWX.js';import {a as a$1}from'./chunk-TQEMLBAG.js';import {p,l,o}from'./chunk-5XATWNME.js';import {e as e$2,g}from'./chunk-EYJ2CQSK.js';import _ from'fs';import b from'path';import E from'chalk';import {execa}from'execa';function Se(e){return _.existsSync(b.join(e,"bun.lock"))||_.existsSync(b.join(e,"bunfig.toml"))?"bun":_.existsSync(b.join(e,"pnpm-lock.yaml"))?"pnpm":_.existsSync(b.join(e,"yarn.lock"))?"yarn":(_.existsSync(b.join(e,"package-lock.json")),"npm")}function Ee(e,t,r=Se(e)){return r==="npm"?`npm run ${t}`:`${r} run ${t}`}function Ce(e,t=Se(e)){return `${t} install`}var Ge={"python-fastapi":{runtime:"python",framework:"FastAPI",markers:["pyproject.toml","fastapi"],commands:{init:"python -m pip install -e .",test:"pytest",build:"python -m build",start:"uvicorn main:app --reload"},errorPatterns:{setup:["ModuleNotFoundError","No module named","pip: command not found"],"test-failure":["FAILED","ERROR","test session started"],dependency:["ImportError","missing.*dependency"],runtime:["TypeError","AttributeError","ValueError"],timeout:["timeout","Timeout","timed out"],unknown:[]},healthCheck:{stage:"start",type:"http",value:"http://localhost:8000/docs"},validation:{command:"python -m pip list | grep fastapi",error:"FastAPI not installed"}},"python-django":{runtime:"python",framework:"Django",markers:["manage.py","django"],commands:{init:"python manage.py migrate",test:"python manage.py test",build:"python manage.py collectstatic --noinput",start:"python manage.py runserver 0.0.0.0:8000"},errorPatterns:{setup:["ModuleNotFoundError","ProgrammingError.*migrate"],"test-failure":["FAILED","ERROR","Ran.*test"],dependency:["ImportError","missing.*dependency"],runtime:["DatabaseError","ImproperlyConfigured"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"node-nestjs":{runtime:"node",framework:"NestJS",markers:["package.json","@nestjs/core"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm run start"},errorPatterns:{setup:["npm ERR!","ENOENT","not found"],"test-failure":["Tests.*failed","FAIL","fail.*test"],dependency:["Cannot find module","ERR_MODULE_NOT_FOUND"],runtime:["TypeError","Error: ","ReferenceError"],timeout:["timeout","TIMEOUT"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3}},"node-express":{runtime:"node",framework:"Express",markers:["package.json","express"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm start"},errorPatterns:{setup:["npm ERR!","ENOENT"],"test-failure":["failed","FAIL"],dependency:["Cannot find module"],runtime:["Error","TypeError"],timeout:["timeout"],unknown:[]}},"go-fiber":{runtime:"go",framework:"Fiber",markers:["go.mod","fiber"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found","cannot find","go mod tidy"],"test-failure":["FAIL","--- FAIL"],dependency:["missing.*module"],runtime:["panic","fatal","Error"],timeout:["timeout","context deadline"],unknown:[]},dependencies:["init"]},"go-gin":{runtime:"go",framework:"Gin",markers:["go.mod","gin-gonic"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found"],"test-failure":["FAIL"],dependency:["missing.*module"],runtime:["panic"],timeout:["timeout"],unknown:[]}},"java-springboot":{runtime:"java",framework:"Spring Boot",markers:["pom.xml","build.gradle","spring-boot"],commands:{init:"mvn dependency:go-offline",test:"mvn test",build:"mvn package -DskipTests",start:"mvn spring-boot:run"},errorPatterns:{setup:["\\[ERROR\\]","BUILD FAILURE","missing dependencies"],"test-failure":["\\[ERROR\\] Tests run:","BUILD FAILURE"],dependency:["missing.*dependency"],runtime:["Exception","Error","NullPointerException"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8080}},"php-laravel":{runtime:"php",framework:"Laravel",markers:["composer.json","artisan","app/Models"],commands:{init:"composer install && php artisan migrate:fresh --seed",test:"php artisan test",build:"php artisan config:cache && php artisan route:cache && php artisan view:cache",start:"php artisan serve --host=0.0.0.0 --port=8000"},errorPatterns:{setup:["Composer.*lock","Fatal error","Class.*not found"],"test-failure":["FAILED","Tests.*failed"],dependency:["Class.*not found","require.*failed"],runtime:["Fatal error","Exception","Error"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"php-symfony":{runtime:"php",framework:"Symfony",markers:["composer.json","symfony.lock","bin/console"],commands:{init:"composer install && php bin/console doctrine:database:create",test:"php bin/phpunit",build:"php bin/console cache:clear --env=prod",start:"symfony serve --no-tls"},errorPatterns:{setup:["Composer.*error","Fatal error"],"test-failure":["FAILED","failure"],dependency:["Class.*not found"],runtime:["Fatal error","Exception"],timeout:["timeout"],unknown:[]},dependencies:["init"]},"rust-actix":{runtime:"rust",framework:"Actix-web",markers:["Cargo.toml","actix"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find","failed.*download"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E","thread.*panicked"],timeout:["timeout"],unknown:[]},validation:{command:"cargo --version",error:"Rust/Cargo not installed"}},"rust-axum":{runtime:"rust",framework:"Axum",markers:["Cargo.toml","axum"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"rust-rocket":{runtime:"rust",framework:"Rocket",markers:["Cargo.toml","rocket"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["FAILED"],dependency:["can.t find"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"dotnet-aspnetcore":{runtime:"dotnet",framework:"ASP.NET Core",markers:[".csproj",".sln","Program.cs"],commands:{init:"dotnet restore",test:"dotnet test",build:"dotnet build -c Release",start:"dotnet run"},errorPatterns:{setup:["error CS","CSPROJ.*not found","NuGet.*restore"],"test-failure":["Failed:.*test","FAILED"],dependency:["error NU1101"],runtime:["error CS","Exception"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:5e3}},"elixir-phoenix":{runtime:"elixir",framework:"Phoenix",markers:["mix.exs","phoenix"],commands:{init:"mix setup",test:"mix test",build:"mix compile --all-warnings",start:"mix phx.server"},errorPatterns:{setup:["\\*\\* \\(.*Error\\)","Mix.InstallError"],"test-failure":["\\d+\\sfailed","FAILED"],dependency:["dependencies are not available"],runtime:["\\*\\* \\(","RuntimeError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:4e3},dependencies:["init"]},"ruby-rails":{runtime:"ruby",framework:"Rails",markers:["Gemfile","config/application.rb","bin/rails"],commands:{init:"bundle install && rails db:prepare",test:"rails test",build:"rails assets:precompile",start:"rails server --binding=0.0.0.0 --port=3000"},errorPatterns:{setup:["Bundler::.*Error","Gem::.*Error"],"test-failure":["failures,","error,","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","Exception","NoMethodError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3},dependencies:["init"]},"ruby-sinatra":{runtime:"ruby",framework:"Sinatra",markers:["Gemfile","app.rb","sinatra"],commands:{init:"bundle install",test:"rspec",build:`echo "Sinatra apps don't require build"`,start:"ruby app.rb"},errorPatterns:{setup:["Bundler.*Error","Gem.*Error"],"test-failure":["failure","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","NoMethodError"],timeout:["timeout"],unknown:[]}}},Be={init:{python:["pip install -e .","poetry install","pip install -r requirements.txt"],node:["npm install","pnpm install","yarn install"],go:["go mod download && go mod tidy","go get ./..."],java:["mvn dependency:go-offline","gradle dependencies"],php:["composer install"],rust:["cargo fetch"],dotnet:["dotnet restore"],elixir:["mix deps.get"],ruby:["bundle install"],"jvm-generic":["mvn dependency:go-offline","gradle dependencies"],unknown:[]},test:{python:["pytest","python -m unittest","python -m pytest"],node:["npm test","npm run test"],go:["go test ./...","make test"],java:["mvn test","gradle test"],php:["php artisan test","phpunit","pest"],rust:["cargo test"],dotnet:["dotnet test"],elixir:["mix test"],ruby:["rspec","ruby -m minitest"],"jvm-generic":["mvn test","gradle test"],unknown:[]},build:{python:["python -m build","python setup.py build"],node:["npm run build"],go:["go build -o app .","go build ./..."],java:["mvn package -DskipTests","gradle build -x test"],php:['echo "PHP build: typically no build step"'],rust:["cargo build --release"],dotnet:["dotnet build -c Release"],elixir:["mix compile"],ruby:["gem build *.gemspec"],"jvm-generic":["mvn package -DskipTests","gradle build"],unknown:[]},start:{python:["python app.py","python main.py","uvicorn main:app --reload"],node:["npm start","node index.js","node src/index.js"],go:["./app","go run main.go","go run ./..."],java:["mvn spring-boot:run","gradle bootRun","java -jar target/*.jar"],php:["php -S 0.0.0.0:8000","php artisan serve"],rust:["cargo run --release","./target/release/app"],dotnet:["dotnet run"],elixir:["mix phx.server","iex -S mix"],ruby:["rails server","ruby app.rb","bundle exec puma"],"jvm-generic":["java -jar *.jar","gradle run"],unknown:[]}};function se(e,t){if(t){let r=t.trim().toLowerCase().replace(/[_.\s]+/g,"-"),n=e$1(t),s=`${e}-${n==="gofiber"?"fiber":n==="gogin"?"gin":n==="dotnet"?"aspnetcore":n!=="unknown"?n:r==="fiber"?"fiber":r==="aspnetcore"||r==="asp-net-core"?"aspnetcore":r}`;return Ge[s]}}function Pe(e,t,r){if(t){let n=se(e,t);if(n&&n.commands[r])return n.commands[r]}if(["init","test","build","start"].includes(r)){let n=Be[r]?.[e]??[];return n.length>0?n[0]:void 0}}var ze={test:"test",build:"build",start:"start"};function ae(e){if(e.stage==="init")return e.runtime==="node"?Ce(e.projectPath):Pe(e.runtime,e.framework,e.stage);if(e.runtime==="node"){let t$1=ze[e.stage];if(t$1){let r=t(e.projectPath,t$1,{framework:e.framework});if(r)return Ee(e.projectPath,r.scriptName)}}return Pe(e.runtime,e.framework,e.stage)}function Ke(e){let t=h(e).map(r=>r==="python"?"python":r==="node"||r==="bun"?"node":r==="go"?"go":r==="java"?"java":r==="php"?"php":r==="rust"?"rust":r==="dotnet"?"dotnet":r==="elixir"?"elixir":r==="ruby"?"ruby":r==="clojure"||r==="scala"||r==="kotlin"?"jvm-generic":null).filter(r=>r!==null).filter((r,n,o)=>o.indexOf(r)===n);return {primary:t.length>0?t[0]:"unknown",secondary:t.slice(1)}}function Fe(e){return Ke(e).primary}function ie(e,t){if(!e)return "unknown";t||(t={setup:["ModuleNotFoundError","No module named","npm ERR!","error:","not found"],"test-failure":["FAILED","FAIL","failed"],dependency:["cannot find module","import.*error"],runtime:["Exception","Error:","panic","TypeError"],timeout:["timeout","Timeout","deadline exceeded"],unknown:[]});for(let[r,n]of Object.entries(t))for(let o of n)if(new RegExp(o,"i").test(e))return r;return "unknown"}async function q(e){let t=e.split(/[&|;]\s*/)[0].trim().split(/\s+/)[0];if(["echo","cd","pwd","test","true","false","exit"].includes(t))return {valid:true};try{let n=process.platform==="win32"?"where":"which";if((await execa(n,[t],{reject:false})).exitCode===0)return {valid:true}}catch{}return {valid:false,reason:`Command '${t}' not found or not executable`}}function Ae(e,t,r){if(!t)return e;let n=typeof t=="object"&&!Array.isArray(t)&&("dev"in t||"staging"in t||"prod"in t||"default"in t)&&!Object.keys(t).some(o=>["init","test","build","start"].includes(o))?t:{};return r&&typeof n[r]=="string"?n[r]:typeof n.default=="string"?n.default:e}var Ne={init:"init",test:"test",build:"build",start:"start"};function Ve(e){return e in Ne?Ne[e]:null}function He(e,t){let n=p$1(e)?.contextJson?.commands;if(!n||typeof n!="object"||Array.isArray(n))return;let o=n[t];if(typeof o=="string"&&o.trim().length>0)return o.trim();if(o&&typeof o=="object"&&!Array.isArray(o)){let s=o,c=s.default??s.dev;if(typeof c=="string"&&c.trim().length>0)return c.trim()}}function Oe(e,t,r=w(e)){let n=Ve(t);if(!n)return He(e,t)?{supported:true}:{supported:false,reason:`Workspace stage "${t}" is not part of the Workspai fleet contract.`};if(!r.projectRoot)return {supported:false,reason:"No Workspai project metadata was detected for this target."};let o=r.commandMap[n];if(!o||o.status!=="supported"){let s=r.runtimeSupportTier==="observed"||r.frameworkSupportTier==="observed";return {supported:false,reason:o?.reason??`Command "${n}" is not supported for this project runtime/framework.`,shouldFail:!s}}return {supported:true}}var Ue=new Set(["init","test","build","start"]),Je=new Set([".git","node_modules",".workspai",".rapidkit",".venv","dist","build","coverage","htmlcov"]);async function I(e){try{return await _.promises.access(e,_.constants.F_OK),true}catch{return false}}async function qe(e){for(let t of e)if(await I(t))return true;return false}async function Ye(e,t,r){if(t==="python"){let o=[b.join(e,".workspai","cli.py"),b.join(e,".rapidkit","cli.py")];for(let s of o)if(await I(s))return {valid:true};return {valid:false,reason:"Project-local .workspai/cli.py is missing. Run `workspai init` in this project first."}}let n=r.trim().split(/\s+/)[0];if(n&&["npm","npx","pnpm","yarn"].includes(n)){let o=e$2(n);if((await execa(o.command,[...o.prefixArgs,"--version"],{reject:false,env:g()})).exitCode===0)return {valid:true}}return q(r)}async function ue(e){let t=await _.promises.readFile(e,"utf-8");return JSON.parse(t)}function N(e){return e.replace(/\\/g,"/")}function Qe(e){let t=e?.trim();return t?t.startsWith("project:")?t.slice(8).trim()||null:t:null}async function Xe(e){return a(e,{skipDirs:Je,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:async(t,r)=>await qe([...p(t,"context.json"),...p(t,"project.json")])?true:b.resolve(t)===b.resolve(r)?false:h(t).length>0})}async function Ze(e){for(let t of [b.join(".workspai","project.json"),b.join(".workspai","context.json"),b.join(".rapidkit","project.json"),b.join(".rapidkit","context.json")]){let r=b.join(e,t);if(await I(r))try{let n=await ue(r),o=n.name??n.projectName??n.slug;if(typeof o=="string"&&o.trim())return o.trim()}catch{}}return null}async function et(e,t,r){let n=Qe(r);if(!n)return {projects:t,normalizedScope:null};let o=N(n).toLowerCase(),s=[];for(let c of t){let u=N(b.relative(e,c)),p=b.basename(c),m=await Ze(c);[u,p,m].filter(a=>typeof a=="string"&&a.length>0).map(a=>N(a).toLowerCase()).includes(o)&&s.push(c);}if(s.length===0)throw new Error(`Workspace run scope did not match any project: ${r}`);return {projects:s,normalizedScope:n}}async function tt(e,t,r){let n=await execa("git",["diff","--name-only",`${r}...HEAD`],{cwd:e,reject:false,env:a$1()});if(n.exitCode!==0)return new Set(t);let o=n.stdout.split(/\r?\n/).map(c=>c.trim()).filter(c=>c.length>0).map(c=>N(c));if(o.length===0)return new Set;let s=new Set;for(let c of t){let u=N(b.relative(e,c));if(!u||u===".")continue;let p=`${u}/`;o.some(m=>m===u||m.startsWith(p))&&s.add(c);}return s}async function rt(e,t,r){let n=await d$1(e,".workspai/workspace.contract.json")??l(e,"workspace.contract.json");if(await I(n))try{let g=await nt(e,t,r,n);if(g.graphStatus!=="missing")return g}catch{return {expanded:r,graphStatus:"invalid",expansionDepth:0}}let o=await d$1(e,".workspai/workspace-dependency-graph.json")??l(e,"workspace-dependency-graph.json");if(!await I(o))return {expanded:r,graphStatus:"missing",expansionDepth:0};let s;try{s=await ue(o);}catch{return {expanded:r,graphStatus:"invalid",expansionDepth:0}}let c=new Set(t.map(g=>b.resolve(g))),u=new Map;if(!s||typeof s!="object"||Array.isArray(s))return {expanded:r,graphStatus:"invalid",expansionDepth:0};let p=Array.isArray(s.projects)?s.projects:[];for(let g of p){if(!g||typeof g!="object"||Array.isArray(g))continue;let a=g,d=typeof a.path=="string"?a.path:"",y=b.resolve(e,d);if(!c.has(y))continue;let h=Array.isArray(a.dependsOn)?a.dependsOn.filter(w=>typeof w=="string"):[];for(let w of h){let x=b.resolve(e,w);c.has(x)&&(u.has(x)||u.set(x,new Set),u.get(x)?.add(y));}}let m=d$2(u,r);return {expanded:m.reached,graphStatus:"loaded",expansionDepth:m.added}}async function nt(e,t,r,n){let o=await ue(n);if(!o||typeof o!="object"||Array.isArray(o))return {expanded:r,graphStatus:"invalid",expansionDepth:0};let s=o,c=Array.isArray(s.projects)?s.projects:null;if(!c)return {expanded:r,graphStatus:"invalid",expansionDepth:0};let u=new Map,p=new Map;for(let y of t){let h=N(b.relative(e,y));p.set(h,b.resolve(y));}let m=new Map,g=new Map,a=new Map;for(let y of c){if(!y||typeof y!="object"||Array.isArray(y))continue;let h=y,w=typeof h.slug=="string"?h.slug:"",x=typeof h.relativePath=="string"?N(h.relativePath):w,R=p.get(x);!w||!R||u.set(w,R);}for(let y of c){if(!y||typeof y!="object"||Array.isArray(y))continue;let h=y,w=typeof h.slug=="string"?h.slug:"",x=u.get(w);if(!x)continue;let R=h.contracts&&typeof h.contracts=="object"&&!Array.isArray(h.contracts)?h.contracts:{},j=Array.isArray(R.dependsOn)?R.dependsOn.filter(v=>typeof v=="string"):[],O=Array.isArray(R.publishes)?R.publishes.filter(v=>typeof v=="string"):[],W=Array.isArray(R.consumes)?R.consumes.filter(v=>typeof v=="string"):[];for(let v of j){let S=u.get(v);S&&(a.has(S)||a.set(S,new Set),a.get(S)?.add(x));}for(let v of O)m.has(v)||m.set(v,new Set),m.get(v)?.add(x);for(let v of W)g.has(v)||g.set(v,new Set),g.get(v)?.add(x);}for(let[y,h]of m.entries()){let w=g.get(y);if(w)for(let x of h){a.has(x)||a.set(x,new Set);for(let R of w)R!==x&&a.get(x)?.add(R);}}let d=d$2(a,r);return {expanded:d.reached,graphStatus:"loaded",expansionDepth:d.added}}async function ot(e,t){if(typeof t=="boolean")return t;let r=o(e,"policies.yml").find(s=>_.existsSync(s))??l(e,"policies.yml");if(!await I(r))return true;let n="";try{n=await _.promises.readFile(r,"utf-8");}catch{return true}let o$1=n.match(/^[\t ]*rules\.enforce_workspace_run_gates:\s*(true|false)\s*(?:#.*)?$/m);return o$1?o$1[1]==="true":true}function st(e){let t=process.env.RAPIDKIT_WORKSPACE_RUN_STAGE_TIMEOUT_MS;if(t){let r=Number.parseInt(t,10);if(Number.isFinite(r)&&r>0)return r}return e==="init"?12e4:9e4}async function ce(e,t,r){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for nested workspace-run execution."};try{let o=await execa(process.execPath,[n,...e],{cwd:t,reject:false,timeout:r,env:{...process.env,RAPIDKIT_WORKSPACE_RUN_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr}}catch(o){return {exitCode:typeof o=="object"&&o!==null&&"timedOut"in o&&!!o.timedOut?124:1,stdout:typeof o=="object"&&o!==null&&"stdout"in o?String(o.stdout??""):"",stderr:typeof o=="object"&&o!==null&&"stderr"in o?String(o.stderr??""):o instanceof Error?o.message:String(o)}}}function at(e){return e==="node"||e==="go"||e==="java"||e==="python"||e==="dotnet"}function it(){return process.env.VITEST==="true"||process.env.VITEST==="1"||process.env.NODE_ENV==="test"}async function ct(e){let t=process.cwd();try{process.chdir(e);let{handleInitCommand:r}=await import('./index.js');return {exitCode:await r(["init"]),stdout:"",stderr:""}}finally{process.chdir(t);}}async function ut(e){let t=a=>{let d=f(a);return d==="node"||d==="bun"?"node":d==="python"?"python":d==="go"?"go":d==="java"?"java":d==="php"?"php":d==="ruby"?"ruby":d==="rust"?"rust":d==="dotnet"?"dotnet":d==="elixir"?"elixir":d==="clojure"||d==="scala"||d==="kotlin"?"jvm-generic":Fe(e)},r=a=>{if(!a)return;let d=e$1(a);if(new Set(["fastapi","django","flask","nestjs","express","fastify","koa","gofiber","gogin","echo","springboot","laravel","symfony","rails","sinatra","dotnet","actix","axum","rocket","phoenix"]).has(d))return d},n=p$1(e),o=n?.detection??i(e,n?.projectJson??null),s=n?.contextJson,c=t(o.runtime),u=r(o.key),p={},m=new Set(["init","test","build","start"]);if(s?.commands&&typeof s.commands=="object")for(let[a,d]of Object.entries(s.commands))typeof d=="string"&&m.has(a)&&(p[a]=d);let g;if(s?.commandEnvironments&&typeof s.commandEnvironments=="object"){let a=s.commandEnvironments;g={dev:typeof a.dev=="string"?a.dev:void 0,staging:typeof a.staging=="string"?a.staging:void 0,prod:typeof a.prod=="string"?a.prod:void 0,default:typeof a.default=="string"?a.default:void 0};}return {runtime:c,framework:u,commandOverrides:Object.keys(p).length>0?p:void 0,environmentCommandVariants:g,environment:typeof s?.environment=="string"?s.environment:void 0}}async function dt(e,t,r,n,o,s,c){let u=!o?.[t]&&at(r),p;if(o&&o[t]?p=o[t]:u?p=`rapidkit ${t}`:p=ae({projectPath:e,runtime:r,framework:n,stage:t}),!p)return {exitCode:127,command:`<stage not supported for ${r}>`,message:`No stage command found for runtime '${r}' and framework '${n||"unknown"}'`,errorCategory:"runtime"};let m=Ae(p,s,c);if(!m)return {exitCode:127,command:p,message:"Failed to resolve stage command",errorCategory:"runtime"};let g=ae({projectPath:e,runtime:r,framework:n,stage:t});if(u){if(g){let f=u?await Ye(e,r,g):await q(g);if(!f.valid)return {exitCode:127,command:m,message:f.reason||"Command not available",errorCategory:"setup"}}}else {let f=await q(m);if(!f.valid)return {exitCode:127,command:m,message:f.reason||"Command not available",errorCategory:"setup"}}let a=0,d="",y="",h,w=st(t),x=Date.now();try{let f=u?t==="init"&&it()?await ct(e):await ce([t],e,w):await execa(m,[],{cwd:e,reject:false,shell:true,timeout:w});if(a=Number(f.exitCode??0),d=f.stdout,y=f.stderr,a!==0){let C=`${d}
|
|
2
2
|
${y}`,z=Date.now()-x;h=a===124||ie(C)==="timeout"||a===143&&z>=Math.floor(w*.8)?"timeout":ie(C);}}catch(f){let C=typeof f=="object"&&f!==null&&"timedOut"in f&&!!f.timedOut;return {exitCode:C?124:1,command:m,message:C?`Stage timed out after ${w}ms`:f instanceof Error?f.message:"Command execution failed",errorCategory:C?"timeout":"runtime"}}let R,j=`${d}
|
|
3
3
|
${y}`.split(/\r?\n/).map(f=>f.trim()).filter(Boolean),O=j.slice(0,6).join(`
|
|
4
4
|
`),W=Date.now()-x,v=a===124||h==="timeout"||a===143&&W>=Math.floor(w*.8),S=a===0?void 0:v?"timeout":h,T=a===0||!S?void 0:{category:S,exitCode:a,command:m,timedOut:v,timeoutMs:w,...O?{outputExcerpt:O}:{}};return {exitCode:a,command:m,errorCategory:S,healthStatus:R,failureDiagnostic:T,message:v?`Stage timed out after ${w}ms`:a!==0?O?`Stage failed with exit code ${a}: ${j[0]}`:`Stage failed with exit code ${a}`:void 0}}function De(e){try{return JSON.parse(e)}catch{return null}}function lt(e){switch(e){case "dotnet":return "Install .NET 8+ SDK, then rerun `npx workspai setup dotnet` or `npx workspai init`.";case "go":return "Install Go 1.21+, then rerun `npx workspai setup go` or `npx workspai init`.";case "java":case "jvm-generic":return "Install Java 21+ and Maven/Gradle, then rerun `npx workspai setup java` or `npx workspai init`.";case "node":return "Install Node.js LTS and npm/pnpm/yarn, then rerun `npx workspai setup node` or `npx workspai init`.";case "python":return "Install Python 3.10+ and pip/Poetry, then rerun `npx workspai setup python` or `npx workspai init`.";default:return null}}async function pt(e){let t=[],r=await ce(["doctor","workspace","--json"],e);if(r.exitCode!==0)t.push({gate:"doctor-workspace",status:"fail",summary:"doctor workspace command failed"});else {let s=De(r.stdout)?.healthScore,c=Number(s?.errors??0);Number.isFinite(c)&&c>0?t.push({gate:"doctor-workspace",status:"fail",summary:`doctor workspace reports ${c} error(s)`}):t.push({gate:"doctor-workspace",status:"pass",summary:"doctor workspace passed"});}let n=await ce(["readiness","--json"],e);if(n.exitCode!==0)t.push({gate:"readiness",status:"fail",summary:"readiness command failed"});else {let o=De(n.stdout),s=String(o?.overallStatus??"").toLowerCase();s==="fail"?t.push({gate:"readiness",status:"fail",summary:"readiness overall status is fail"}):s==="warn"?t.push({gate:"readiness",status:"warn",summary:"readiness overall status is warn"}):t.push({gate:"readiness",status:"pass",summary:"readiness overall status is pass"});}return t}var mt=new Set(["dev","stop"]);function ft(e){let t=e.trim();return !t||mt.has(t.toLowerCase())?false:Ue.has(t)?true:/^[a-z][a-z0-9_-]*$/i.test(t)}function Te(e,t,r){let n=N(b.relative(r,t));return (Array.isArray(e.projects)?e.projects:[]).some(s=>{if(!s||typeof s!="object")return false;let c=s,u=[c.relativePath,c.path].filter(p=>typeof p=="string"&&p.length>0).map(p=>N(p));return c.status==="passed"&&(u.includes(n)||u.some(p=>p.endsWith(`/${n}`)))})}function gt(e,t){return se(e,t)?.dependencies??[]}function yt(e,t){let r=Math.max(1,Math.min(4,t)),n=Number(e??r);return Number.isFinite(n)?Math.max(1,Math.min(16,Math.trunc(n))):r}async function Xt(e$1){if(!ft(e$1.stage))throw new Error(`Unsupported workspace run stage: ${e$1.stage}`);let t=Date.now(),r=b.resolve(e$1.workspacePath),n=await d(r),o=await Xe(r),{projects:s,normalizedScope:c}=await et(r,o,e$1.scope),u=e$1.affected===true,p=e$1.blastRadius===true,m=e$1.since?.trim()||"HEAD~1",g=u?await tt(r,s,m):new Set(s),a,d$1="not-applicable",y=0,h="all";if(u&&p){let l=await rt(r,o,g);a=l.expanded,d$1=l.graphStatus,y=l.expansionDepth,h="affected+blast-radius";}else u?(a=g,h="affected"):(a=g,h="all");let w=e$1.stage==="init"?false:await ot(r,e$1.enforceGates),x=w?await pt(r):[{gate:"doctor-workspace",status:"skipped",summary:"workspace run gates disabled"},{gate:"readiness",status:"skipped",summary:"workspace run gates disabled"}],R=x.find(l=>l.status==="fail"),j=s.filter(l=>a.has(l)),O=e$1.continueOnError===true||e$1.stage==="init",W=e$1.parallel===true,v=yt(e$1.maxWorkers,j.length),S=j.length,T=0;e$1.json||console.log(E.gray(`Workspace run (${e$1.stage}) started: ${S} target(s), ${W?`parallel x${v}`:"sequential"}`));let f=new Map;for(let l of o){let k=N(b.relative(r,l)),i=s.includes(l),F=i&&a.has(l);f.set(l,{path:l,relativePath:k,projectName:b.basename(k)||b.basename(l),selected:F,affected:F,status:"skipped",exitCode:null,durationMs:0,reason:F?void 0:i?"not affected":"outside scope",framework:void 0,runtimeDetected:void 0,executionCommand:void 0});}if(R)for(let l of j){let k=f.get(l);k&&(k.status="skipped",k.reason=`blocked by ${R.gate}`);}else {let l=async k=>{let i=f.get(k);if(!i)return;let F=N(b.relative(r,k));e$1.json||console.log(E.gray(`\u23F3 [${T}/${S}] ${e$1.stage} ${F}`)),i.selected=true,i.affected=true;let A=Date.now(),{runtime:P,framework:D,commandOverrides:$e,environmentCommandVariants:Ie,environment:Le}=await ut(k);i.runtimeDetected=P,i.framework=D;let Q=Oe(k,e$1.stage);if(!Q.supported){i.status=Q.shouldFail===false?"skipped":"failed",i.reason=Q.reason??`stage "${e$1.stage}" unsupported for project`,i.durationMs=Date.now()-A,i.exitCode=i.status==="failed"?127:null,i.status==="failed"&&(i.errorCategory="setup",i.errorMessage=i.reason),T+=1;return}if(e$1.reusePassed&&n){let $=n.stages[e$1.stage]??n.stages[e$1.stage];if($&&Te($,k,r)){i.status="passed",i.reason="reused passed result from workspace-run-last.json",i.durationMs=Date.now()-A,i.exitCode=0,T+=1,e$1.json||console.log(E.gray(`\u21BA reused passed cache for ${F}`));return}}let me=gt(P,D);if(me.length>0&&n){let $=me.find(X=>{let L=n.stages[X];return !L||!Te(L,k,r)});if($){i.status="skipped",i.reason=`dependency stage "${$}" not satisfied in workspace-run-last.json`,i.durationMs=Date.now()-A,i.exitCode=null,T+=1;return}}let M=await dt(k,e$1.stage,P,D,$e,Ie,Le);if(i.executionCommand=M.command,i.errorCategory=M.errorCategory,i.healthStatus=M.healthStatus,i.failureDiagnostic=M.failureDiagnostic,i.durationMs=Date.now()-A,i.exitCode=M.exitCode,M.exitCode===0?(i.status="passed",i.reason=void 0):(i.status="failed",i.reason=M.message||"stage command failed",i.errorMessage=M.message),T+=1,!e$1.json){let $=S>0?Math.round(T/S*100):100,X=i.status==="passed"?E.green("\u2705"):E.red("\u274C");if(console.log(E.gray(`${X} [${T}/${S}] (${$}%) ${F} ${i.durationMs}ms`)),i.status==="failed"){i.reason&&console.log(E.red(` Reason: ${i.reason}`)),i.executionCommand&&console.log(E.gray(` Command: ${i.executionCommand}`));let L=lt(i.runtimeDetected);L&&i.errorCategory==="setup"&&console.log(E.gray(` Hint: ${L}`));}}};if(W&&j.length>1){let k=0,i=false,F=new Array(v).fill(null).map(async()=>{for(;k<j.length;){if(i&&!O)return;let A=k;k+=1;let P=j[A];await l(P),f.get(P)?.status==="failed"&&(i=true);}});if(await Promise.all(F),!O&&i){let A=false;for(let P of j){let D=f.get(P);if(D){if(D.status==="failed"){A=true;continue}A&&D.status==="skipped"&&(D.reason=D.reason||"stopped after failure");}}}}else for(let k of j){await l(k);let i=f.get(k);if(!O&&i?.status==="failed"){let F=j.slice(j.indexOf(k)+1);for(let A of F){let P=f.get(A);P&&(P.status="skipped",P.reason="stopped after failure");}break}}}let C=[];for(let l of o){let k=f.get(l);k&&C.push(k);}let z=C.filter(l=>l.status==="passed").length,K=C.filter(l=>l.status==="failed").length,de=C.filter(l=>l.status==="skipped").length,le=e$1.strict===true,Me=K>0||le&&x.some(l=>l.status==="fail"||l.status==="warn")?1:0,pe={schemaVersion:"1.0",workspacePath:r,stage:e$1.stage,generatedAt:new Date().toISOString(),durationMs:Date.now()-t,options:{affected:u,blastRadius:p,since:u?m:null,parallel:W,maxWorkers:v,continueOnError:O,strict:le,enforceGates:w,scope:c,reusePassed:e$1.reusePassed===true},selection:{mode:h,since:u?m:null,scope:c,graphStatus:d$1,expansionDepth:y},gates:{enforced:w,results:x,blocked:!!R,blockingGate:R?.gate},summary:{projectCount:o.length,selectedCount:j.length,passed:z,failed:K,skipped:de,exitCode:Me},projects:C,enterpriseControls:{jsonReady:true,evidencePath:b$1}},We=b.join(r,b$1);return await e(r,pe),e$1.json||(R&&(console.log(E.red(`\u274C Workspace run blocked by ${R.gate}`)),console.log(E.gray(` ${R.summary}`))),console.log(E.cyan(`Workspace run (${e$1.stage}) => passed: ${z}, failed: ${K}, skipped: ${de}`)),console.log(E.gray(`Report: ${We}`))),pe}export{Xt as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {f as f$1,e as e$2}from'./chunk-
|
|
1
|
+
import {f as f$1,e as e$2}from'./chunk-P3D5YQB2.js';import {b as b$3}from'./chunk-NHN4QXPP.js';import {b as b$6,a as a$3}from'./chunk-THIOE2PB.js';import {e,g,f as f$2,b as b$5,c as c$3,d as d$2}from'./chunk-MER6ZBN2.js';import {a as a$2}from'./chunk-RHQW3DTP.js';import {d as d$3}from'./chunk-T4YR4RAI.js';import {d,b as b$2}from'./chunk-GSWPGELT.js';import {c}from'./chunk-Y45WZR5N.js';import {f,c as c$2,e as e$3}from'./chunk-7YHK5NM3.js';import {a as a$1}from'./chunk-TQEMLBAG.js';import {b as b$1,a,c as c$1,d as d$1}from'./chunk-5XATWNME.js';import {b as b$4,j,i,l,h,s,r,p as p$1}from'./chunk-EYJ2CQSK.js';import {promises}from'fs';import*as b from'fs-extra';import p from'path';import e$1 from'chalk';import {execa}from'execa';async function G(t,o={}){let n=p.resolve(t),s=o.workspaceName??p.basename(n),{registerWorkspaceStrict:a}=await import('./workspace-PJPRBUMQ.js');await a(n,s);let{syncWorkspaceContract:l}=await import('./workspace-contract-TU2I7GC2.js'),d=await l({workspacePath:n,strict:true});o.silent||console.log(e$1.gray(`\u2139\uFE0F Workspace intelligence synced (contract + registry summary, ${d.contract.projects.length} project(s)).`));}function N(){return h()}var st="transactions";function lt(){return p.join(p$1(),st)}async function Fe(){let t=lt();return await b$6(t),a$3({journalDirectory:t})}async function Le(t){for(let o of r())await t.captureFile(o);}async function ie(t){let o=await Fe();try{return await Le(o),await o.captureOwnedTree(t),o}catch(n){return F(o,n)}}async function ct(t){let o=await Fe();try{await Le(o),await o.captureOwnedTree(p.join(t,a)),await o.captureOwnedTree(p.join(t,".venv"));let n=[c$1,".gitignore",p.join(a,"workspace.json"),p.join(a,"toolchain.lock"),p.join(a,"policies.yml"),p.join(a,"cache-config.yml"),d$3,a$2,"pyproject.toml","poetry.toml","poetry.lock","rapidkit","rapidkit.cmd","README.md",".rapidkit-global"];for(let s of n)await o.captureFile(p.join(t,s));return o}catch(n){return F(o,n)}}async function B(t){await t.commit(),t.journalPath&&await promises.rm(p.dirname(t.journalPath),{recursive:true,force:true}).catch(o=>f.debug(`Could not remove committed lifecycle journal: ${o}`));}async function F(t,o){try{await t.rollback();}catch(n){throw new AggregateError([o,n],"Workspace lifecycle failed and rollback was incomplete.")}throw o}async function J(t,o,n,s,a){let l=d(o,c(),n,a?.pythonEngine?{coreStatus:a.pythonEngine,...a.pythonEngineReason?{coreReason:a.pythonEngineReason}:{},...s?{pythonVersion:s}:{}}:void 0);s&&!a?.pythonEngine&&(l.metadata||(l.metadata={}),l.metadata.python={pythonVersion:s}),await b$2(t,l);}async function U(t){await b.outputFile(p.join(t,".gitignore"),`.venv/
|
|
2
2
|
__pycache__/
|
|
3
3
|
*.pyc
|
|
4
4
|
.env
|
|
@@ -903,7 +903,7 @@ ${o}/
|
|
|
903
903
|
|
|
904
904
|
---
|
|
905
905
|
|
|
906
|
-
**Generated with Workspai** | [GitHub](https://github.com/
|
|
906
|
+
**Generated with Workspai** | [GitHub](https://github.com/chistiq/workspai)
|
|
907
907
|
`;if(await promises.writeFile(p.join(t,"README.md"),d,"utf-8"),s.succeed("Demo workspace setup complete"),!n)if(await Ve(t))s.warn("Git initialization skipped because target is already inside a git worktree");else {s.start("Initializing git repository");try{await execa("git",["init"],{cwd:t,env:a$1()}),await b.outputFile(p.join(t,".gitignore"),`# Dependencies
|
|
908
908
|
node_modules/
|
|
909
909
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {d as d$1,c,e}from'./chunk-
|
|
1
|
+
import {d as d$1,c,e}from'./chunk-32OJDBIG.js';import {b,a as a$1}from'./chunk-BMWFQXGW.js';import k from'fs-extra';var y=b.history,a=a$1.history,d=50;function A(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return typeof e.generatedAt!="string"?null:e.kind==="agent-action"?typeof e.actionId!="string"||typeof e.summary!="string"||e.outcome!=="ok"&&e.outcome!=="failed"?null:{kind:"agent-action",generatedAt:e.generatedAt,actionId:e.actionId,scope:typeof e.scope=="string"?e.scope:"workspace",summary:e.summary,outcome:e.outcome,...typeof e.evidenceSha256=="string"?{evidenceSha256:e.evidenceSha256}:{}}:e.kind==="doctor-fix"?e.scope!=="workspace"&&e.scope!=="project"||typeof e.summary!="string"||e.outcome!=="ok"&&e.outcome!=="failed"?null:{kind:"doctor-fix",generatedAt:e.generatedAt,scope:e.scope,summary:e.summary,outcome:e.outcome,applied:typeof e.applied=="number"?e.applied:0,failed:typeof e.failed=="number"?e.failed:0,skipped:typeof e.skipped=="number"?e.skipped:0,remainingBlockers:typeof e.remainingBlockers=="number"?e.remainingBlockers:0}:typeof e.verdict!="string"||typeof e.risk!="string"||typeof e.gatePassed!="boolean"?null:{kind:"verify",generatedAt:e.generatedAt,verdict:e.verdict,risk:String(e.risk),affectedProjects:typeof e.affectedProjects=="number"?e.affectedProjects:0,freshness:e.freshness??"unknown",gatePassed:e.gatePassed,blockingReasons:typeof e.blockingReasons=="number"?e.blockingReasons:0,policyViolations:typeof e.policyViolations=="number"?e.policyViolations:0}}function S(t,e){return {kind:"verify",generatedAt:t.generatedAt,verdict:t.summary.verdict,risk:t.impact.risk,affectedProjects:t.impact.affectedProjects,freshness:t.freshness.verdict,gatePassed:e,blockingReasons:t.blockingReasons.length,policyViolations:t.policyViolations.length}}function F(t){return {kind:"agent-action",generatedAt:t.generatedAt,actionId:t.actionId,scope:t.scope,summary:t.summary,outcome:t.outcome,...t.evidenceSha256?{evidenceSha256:t.evidenceSha256}:{}}}function V(t,e){let o=t.appliedFixes.filter(i=>i.outcome==="applied").length,r=t.appliedFixes.filter(i=>i.outcome==="failed").length,n=t.appliedFixes.filter(i=>i.outcome==="skipped").length,s=t.appliedFixes.filter(i=>i.outcome==="guidance").length,c=t.remainingBlockers.length,g=r>0||c>0?"failed":"ok";return {kind:"doctor-fix",generatedAt:t.generatedAt,scope:e,summary:`${o} applied, ${r} failed, ${n} skipped, ${s} guidance, ${c} blocker(s) remaining`,outcome:g,applied:o,failed:r,skipped:n,remainingBlockers:c}}async function E(t){let e=await d$1(t,a);try{if(!e||!await k.pathExists(e))return null;let o=await k.readJson(e);return o?.schemaVersion!==y||!Array.isArray(o.entries)?null:{schemaVersion:y,retention:typeof o.retention=="number"?o.retention:d,entries:o.entries.map(r=>A(r)).filter(r=>r!=null)}}catch{return null}}function x(t,e,o=d){let r=Math.max(1,Math.floor(o)),n=[...t?.entries??[],e],s=n.slice(Math.max(0,n.length-r));return {schemaVersion:y,retention:r,entries:s}}async function v(t,e$1,o){return c(t,a,async()=>{let r=await d$1(t,a),n=await E(t);if(r&&!n)throw new Error(`Workspace history is unreadable or invalid; refusing to overwrite: ${r}`);let s=x(n,e$1,o?.retention??d);return await e(t,a,s),s})}export{y as a,a as b,d as c,A as d,S as e,F as f,V as g,E as h,x as i,v as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {c,e}from'./chunk-
|
|
1
|
+
import {c,e}from'./chunk-32OJDBIG.js';import {o as o$1}from'./chunk-5XATWNME.js';import u from'fs';import d from'path';var a="workspace-run-v1",p="workspace-run-last.json",o=`.workspai/reports/${p}`;var m=new Set(["init","test","build","start"]);function A(e){return m.has(e)}async function w(e){try{return await u.promises.access(e,u.constants.F_OK),true}catch{return false}}async function W(e){try{let r=await u.promises.readFile(e,"utf-8");return JSON.parse(r)}catch{return null}}function S(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function P(e){let r=e.stage;return typeof r!="string"||r.trim().length===0||!Array.isArray(e.projects)?false:A(r)||/^[a-z][a-z0-9_-]*$/i.test(r)}function _(e){let r=S(e);return !r||r.schemaVersion===a?false:P(r)}function h(e){let r=S(e);return r?r.schemaVersion===a&&r.stages!=null:false}function R(e){if(h(e))return e;if(_(e)){let r=e.stage;return {schemaVersion:a,generatedAt:e.generatedAt,workspacePath:e.workspacePath,latestStage:r,stages:{[r]:e},enterpriseControls:e.enterpriseControls??{jsonReady:true,evidencePath:o}}}return null}function x(e,r){let n=R(e);if(!n)return null;let t=r??n.latestStage;return n.stages[t]??null}async function L(e){let r=(await Promise.all(o$1(d.resolve(e),"reports",p).map(async t=>await w(t)?t:null))).find(t=>typeof t=="string");if(!r)return null;let n=await W(r);return R(n)}async function I(e$1,r){let n=d.resolve(e$1);return c(n,o,async()=>{let t=(await Promise.all(o$1(n,"reports",p).map(async s=>await w(s)?s:null))).find(s=>typeof s=="string"),l=t?await W(t):null,i=R(l);if(t&&!i)throw new Error(`Workspace run evidence is unreadable or invalid; refusing to overwrite: ${t}`);let g=i?{...i.stages}:{};g[r.stage]=r;let k={schemaVersion:a,generatedAt:r.generatedAt,workspacePath:r.workspacePath,latestStage:r.stage,stages:g,enterpriseControls:{jsonReady:true,evidencePath:o}};return await e(n,o,k),k})}export{p as a,o as b,x as c,L as d,I as e};
|