workspai 0.51.0 → 0.52.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 +1 -0
- package/contracts/artifact-remediation-plan.v1.json +87 -0
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +24 -0
- package/contracts/doctor-project-evidence.v1.json +46 -0
- package/contracts/doctor-remediation-plan.v1.json +82 -0
- package/contracts/doctor-workspace-evidence.v1.json +46 -0
- package/contracts/extension-cli-compatibility.v1.json +6 -2
- package/contracts/published-contract-catalog.v1.json +22 -1
- package/contracts/runtime-command-surface.v1.json +104 -0
- package/contracts/workspace-intelligence/doctor-dependency-repair-transaction.v1.json +66 -0
- package/contracts/workspace-intelligence/studio-blocker-handoff.v1.json +5 -0
- package/contracts/workspace-intelligence/verified-goal-status.v1.json +27 -0
- package/contracts/workspace-intelligence/verified-goal.v1.json +163 -0
- package/contracts/workspace-intelligence-chain.v1.json +6 -0
- package/dist/analyze-J7VNZMDH.js +1 -0
- package/dist/artifact-remediation-plan-2UKY4TKO.js +3 -0
- package/dist/autopilot-release-UG23AWVH.js +1 -0
- package/dist/chunk-27UR373Z.js +1 -0
- package/dist/chunk-2PY65U6X.js +5 -0
- package/dist/{chunk-DQ3PI7EP.js → chunk-3D3PFPP5.js} +1 -1
- package/dist/chunk-4D7DIGAB.js +1 -0
- package/dist/{chunk-IND3TUVU.js → chunk-4UVGTFOX.js} +1 -1
- package/dist/{chunk-U2QL5733.js → chunk-5XJRCP3D.js} +24 -24
- package/dist/chunk-62K2H72S.js +1 -0
- package/dist/chunk-6AXRIAP2.js +86 -0
- package/dist/{chunk-TROHVI2V.js → chunk-6HJJHEL6.js} +1 -1
- package/dist/{chunk-BHYTI3RH.js → chunk-6PBSAAS5.js} +1 -1
- package/dist/{chunk-MVLIONQD.js → chunk-7MQZQ4UU.js} +1 -1
- package/dist/chunk-7RLGOEWV.js +1 -0
- package/dist/chunk-B4CPDK6J.js +2 -0
- package/dist/{chunk-SHXJ2GDR.js → chunk-DZ4VKAXB.js} +1 -1
- package/dist/{chunk-FKWB66NQ.js → chunk-F4KBYFZ5.js} +1 -1
- package/dist/{chunk-Q6TKQVKQ.js → chunk-FRJYAJH6.js} +1 -1
- package/dist/chunk-FUPHQOJB.js +1 -0
- package/dist/{chunk-BG4FWJJ3.js → chunk-GHB6QMQH.js} +1 -1
- package/dist/chunk-GR6442P7.js +1 -0
- package/dist/{chunk-DLM6C7FU.js → chunk-HPWLSLMC.js} +1 -1
- package/dist/{chunk-HMGPELXS.js → chunk-ICLYL3N5.js} +1 -1
- package/dist/{chunk-MAF3LLGK.js → chunk-IO54DFWR.js} +1 -1
- package/dist/{chunk-FZ76CF2W.js → chunk-KHEJO3JU.js} +1 -1
- package/dist/{chunk-U2LR73E2.js → chunk-LOCPNNSK.js} +1 -1
- package/dist/{chunk-EPVFKJF4.js → chunk-LPCL4U4L.js} +1 -1
- package/dist/{chunk-4WJC5QCD.js → chunk-M5ICGR55.js} +1 -1
- package/dist/{chunk-XBM2P45G.js → chunk-MBRU3VWJ.js} +1 -1
- package/dist/{chunk-VCW5HSPC.js → chunk-MZFSINY7.js} +3 -3
- package/dist/{chunk-E3CT7TYT.js → chunk-OTDGTAZJ.js} +1 -1
- package/dist/chunk-P4OSLAVD.js +3 -0
- package/dist/{chunk-GBAO4GSW.js → chunk-PTTZPDLX.js} +1 -1
- package/dist/chunk-Q6CUJ3WF.js +10 -0
- package/dist/{chunk-6HLPTJZ3.js → chunk-QURMI7ID.js} +1 -1
- package/dist/{chunk-RVQLMTTI.js → chunk-ULR66OJR.js} +1 -1
- package/dist/{chunk-HSZCINFX.js → chunk-WJY7ZXVJ.js} +1 -1
- package/dist/{chunk-VU2BKKMB.js → chunk-XHRHNVCZ.js} +1 -1
- package/dist/chunk-ZTKIBREF.js +1 -0
- package/dist/{chunk-HE4PUMU4.js → chunk-ZVOEPWQM.js} +1 -1
- package/dist/{create-SBFBFXKN.js → create-ESK3CQPK.js} +1 -1
- package/dist/{doctor-OPCMTBJB.js → doctor-DLEBZSF7.js} +1 -1
- package/dist/index.d.ts +26 -11
- package/dist/index.js +240 -240
- package/dist/{pipeline-7BUXAFS2.js → pipeline-NT6AYYWM.js} +1 -1
- package/dist/{project-intelligence-lens-BKKVPCLC.js → project-intelligence-lens-Q4SZDI2N.js} +1 -1
- package/dist/project-test-coverage-A677ZLW3.js +1 -0
- package/dist/verified-goal-MJNZROS5.js +1 -0
- package/dist/{workspace-U6ZQLELX.js → workspace-LSOZM2CG.js} +1 -1
- package/dist/{workspace-agent-sync-L4SY7B4Q.js → workspace-agent-sync-RZBQXCNJ.js} +1 -1
- package/dist/{workspace-archive-4JNT4S7N.js → workspace-archive-ZOWQXWJ6.js} +1 -1
- package/dist/{workspace-context-KOBSLZTI.js → workspace-context-IYJKO5BN.js} +1 -1
- package/dist/{workspace-contract-SOD3OOVF.js → workspace-contract-AZFISDLS.js} +1 -1
- package/dist/workspace-explain-26UGV7L4.js +1 -0
- package/dist/workspace-explain-contract-GIWPCCEF.js +1 -0
- package/dist/{workspace-feedback-ZZ4HPW2T.js → workspace-feedback-LIHEWTNV.js} +1 -1
- package/dist/{workspace-foundation-PUIYBQUF.js → workspace-foundation-H5UTAUXQ.js} +1 -1
- package/dist/{workspace-graph-stream-BLKIC7VN.js → workspace-graph-stream-KUDOZE73.js} +1 -1
- package/dist/{workspace-history-SPKNRHIX.js → workspace-history-HULG5EFN.js} +1 -1
- package/dist/{workspace-intelligence-I3ABOH2F.js → workspace-intelligence-A4UE4DZK.js} +1 -1
- package/dist/{workspace-intelligence-evaluation-7CABG5Y6.js → workspace-intelligence-evaluation-AOLGHYHC.js} +1 -1
- package/dist/workspace-intelligence-runner-42QI5RYA.js +1 -0
- package/dist/{workspace-intelligence-runtime-registry-ZZ3GRAL2.js → workspace-intelligence-runtime-registry-YOQ5GFFJ.js} +1 -1
- package/dist/{workspace-knowledge-graph-5MKEI4Z5.js → workspace-knowledge-graph-LEM6X5CM.js} +1 -1
- package/dist/{workspace-mcp-serve-ETNUA72W.js → workspace-mcp-serve-N2QPR7VJ.js} +1 -1
- package/dist/{workspace-model-HHA37SNH.js → workspace-model-FJXX3NET.js} +1 -1
- package/dist/{workspace-onboarding-ELHZABJE.js → workspace-onboarding-IKFISWWY.js} +1 -1
- package/dist/{workspace-readme-HGGZ4AZB.js → workspace-readme-E2M35RJH.js} +1 -1
- package/dist/{workspace-registry-summary-D2QM5JF6.js → workspace-registry-summary-HOQ3OBNT.js} +1 -1
- package/dist/workspace-run-GOZTUGJS.js +1 -0
- package/dist/{workspace-verify-4WJTLXRA.js → workspace-verify-32AWCJQG.js} +1 -1
- package/dist/workspace-watch-4WVNB26E.js +1 -0
- package/docs/README.md +1 -0
- package/docs/ci-workflows.md +40 -11
- package/docs/commands-reference.md +12 -0
- package/docs/doctor-command.md +16 -0
- package/docs/workspace-intelligence-runner.md +48 -0
- package/package.json +4 -2
- package/dist/analyze-4H33PAUB.js +0 -1
- package/dist/artifact-remediation-plan-TQ6KTTXD.js +0 -3
- package/dist/autopilot-release-BHZYM5KX.js +0 -1
- package/dist/chunk-2D4UOYOJ.js +0 -1
- package/dist/chunk-3D2PAIRH.js +0 -3
- package/dist/chunk-AHLMIL2T.js +0 -1
- package/dist/chunk-BBGNDMRU.js +0 -2
- package/dist/chunk-BYTFXQ6G.js +0 -1
- package/dist/chunk-GQRWRHSR.js +0 -86
- package/dist/chunk-L2E2Z4OE.js +0 -5
- package/dist/chunk-TDTCMZK7.js +0 -10
- package/dist/project-test-coverage-BALEHHTT.js +0 -1
- package/dist/workspace-explain-2CTMW2YW.js +0 -1
- package/dist/workspace-explain-contract-H7O26QJU.js +0 -1
- package/dist/workspace-intelligence-runner-Q2XSR3ZL.js +0 -1
- package/dist/workspace-run-DAAZBCN7.js +0 -1
- package/dist/workspace-watch-2PIFTQ6B.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a,c,j,g as g$1,h as h$1}from'./chunk-L2E2Z4OE.js';import {t,u as u$1}from'./chunk-MOSXTVPU.js';import T from'fs';import i from'path';import C from'fs-extra';var V=[{id:"fastapi.standard",aliases:["fastapi","fastapi.standard"],label:"fastapi \u2014 FastAPI Standard Kit",description:"Core-backed FastAPI service scaffold.",owner:"core",runtime:"python",framework:"fastapi",category:"backend",moduleSupport:true,stability:"stable",versionPolicy:"tested-baseline"},{id:"fastapi.ddd",aliases:["fastapi.ddd","fastapi-ddd"],label:"fastapi \u2014 FastAPI DDD Kit",description:"Core-backed FastAPI DDD service scaffold.",owner:"core",runtime:"python",framework:"fastapi",category:"backend",moduleSupport:true,stability:"stable",versionPolicy:"tested-baseline"},{id:"nestjs.standard",aliases:["nestjs","nest","nestjs.standard"],label:"nestjs \u2014 NestJS Standard Kit",description:"Core-backed NestJS service scaffold.",owner:"core",runtime:"node",framework:"nestjs",category:"backend",moduleSupport:true,stability:"stable",versionPolicy:"tested-baseline"},{id:"springboot.standard",aliases:["spring","springboot","springboot.standard","java"],label:"spring \u2014 Spring Boot Standard Kit",description:"npm-backed Spring Boot service scaffold.",owner:"npm",runtime:"java",framework:"springboot",category:"backend",moduleSupport:false,stability:"stable",versionPolicy:"tested-baseline",generator:"springboot",createUsage:"workspai create project springboot.standard <name> [--java-version <major>] [--spring-boot-version <semver>] [--group-id <com.example>] [--package-name <com.example.app>] [--port <number>]"},{id:"gofiber.standard",aliases:["go","go.standard","fiber","gofiber","gofiber.standard","go/fiber"],label:"go/fiber \u2014 Go Fiber Standard Kit",description:"npm-backed Go Fiber service scaffold.",owner:"npm",runtime:"go",framework:"gofiber",category:"backend",moduleSupport:false,stability:"stable",versionPolicy:"tested-baseline",generator:"gofiber",createUsage:"workspai create project gofiber.standard <name> [--output <dir>]"},{id:"gogin.standard",aliases:["gin","gogin","gogin.standard","go/gin"],label:"go/gin \u2014 Go Gin Standard Kit",description:"npm-backed Go Gin service scaffold.",owner:"npm",runtime:"go",framework:"gogin",category:"backend",moduleSupport:false,stability:"stable",versionPolicy:"tested-baseline",generator:"gogin",createUsage:"workspai create project gogin.standard <name> [--output <dir>]"},{id:"dotnet.webapi.clean",aliases:["dotnet","dotnet.webapi","dotnet.webapi.clean","aspnet","aspnetcore","asp.net","asp.net-core","csharp","c#"],label:"dotnet \u2014 ASP.NET Core Clean Web API",description:"npm-backed ASP.NET Core Web API with clean architecture boundaries.",owner:"npm",runtime:"dotnet",framework:"dotnet",category:"backend",moduleSupport:false,stability:"preview",versionPolicy:"tested-baseline",generator:"dotnet-webapi-clean",createUsage:"workspai create project dotnet.webapi.clean <name> [--target-framework net8.0] [--root-namespace <Company.Product>] [--port <number>]"},{id:"rust.axum",aliases:["rust.axum","axum","rust-axum"],label:"rust/axum \u2014 Rust Axum API",description:"Workspai-owned Axum service with health, tests, CI, and container baseline.",owner:"npm",runtime:"rust",framework:"axum",category:"backend",moduleSupport:false,stability:"preview",versionPolicy:"tested-baseline",generator:"rust-axum",createUsage:"workspai create project rust.axum <name> [--port <number>] [--output <dir>] [--skip-git]"}],O=new Map;for(let e of V){O.set(e.id.toLowerCase(),e);for(let t of e.aliases)O.set(t.toLowerCase(),e);}function R(e){return e?O.get(e.trim().toLowerCase())??null:null}function ze(e){return R(e)?.id??e}function Ve(){return V.filter(e=>e.owner==="core"||e.generator)}function Xe(e){return R(e)?.owner==="npm"}async function Qe(e,t){if(!e.generator)throw new Error(`Kit is not backed by an npm generator: ${e.id}`);if(e.generator==="gofiber"){let{generateGoFiberKit:r}=await import('./gofiber-standard-AQGSC7ON.js');await r(t.projectPath,{project_name:t.projectName,module_path:t.projectName,skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="gogin"){let{generateGoGinKit:r}=await import('./gogin-standard-7DU3OCBX.js');await r(t.projectPath,{project_name:t.projectName,module_path:t.projectName,skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="springboot"){let{generateSpringBootKit:r}=await import('./springboot-standard-EK6GYN5T.js');await r(t.projectPath,{project_name:t.projectName,artifact_id:t.projectName,java_version:m(t.args,"--java-version")?.trim(),spring_boot_version:m(t.args,"--spring-boot-version")?.trim(),springdoc_version:m(t.args,"--springdoc-version")?.trim(),group_id:m(t.args,"--group-id")?.trim(),package_name:m(t.args,"--package-name")?.trim(),description:m(t.args,"--description")?.trim(),port:m(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="dotnet-webapi-clean"){let{generateDotnetWebApiCleanKit:r}=await import('./dotnet-webapi-clean-VXEF4SHM.js');await r(t.projectPath,{project_name:t.projectName,target_framework:m(t.args,"--target-framework")?.trim(),root_namespace:m(t.args,"--root-namespace")?.trim(),description:m(t.args,"--description")?.trim(),port:m(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="rust-axum"){let{generateRustAxumKit:r}=await import('./rust-axum-4HXDICIB.js');await r(t.projectPath,{project_name:t.projectName,description:m(t.args,"--description")?.trim(),port:m(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}throw new Error(`Unhandled npm kit generator: ${e.generator}`)}function m(e,t){let r=e.indexOf(t);if(r>=0&&r+1<e.length)return e[r+1];let n=e.find(a=>a.startsWith(`${t}=`));return n?n.slice(t.length+1):void 0}var f=["init","dev","start","build","test","lint","format","help"],X={python:{runtime:"python",displayName:"Python",tier:"first-class",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:true,doctorSupport:"full",notes:["Core-backed Python projects support RapidKit Core modules and lifecycle commands."]},node:{runtime:"node",displayName:"Node.js",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:true,doctorSupport:"full",notes:["Node projects support npm-owned lifecycle commands; NestJS is the first-class Node framework."]},go:{runtime:"go",displayName:"Go",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Go projects support workspace governance and lifecycle commands via Go tooling."]},java:{runtime:"java",displayName:"Java / Spring Boot",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Java projects support Maven/Gradle lifecycle commands and workspace governance."]},dotnet:{runtime:"dotnet",displayName:".NET / ASP.NET Core",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:[".NET projects support dotnet CLI lifecycle commands and workspace governance."]},php:{runtime:"php",displayName:"PHP",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Laravel projects use the official Composer generator and PHP/Composer lifecycle adapter."]},ruby:{runtime:"ruby",displayName:"Ruby",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Ruby projects are importable and governed as observed projects until a kit exists."]},rust:{runtime:"rust",displayName:"Rust",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Rust projects support Axum and Tauri scaffolding plus Cargo lifecycle commands."]},elixir:{runtime:"elixir",displayName:"Elixir",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Elixir projects are importable and governed as observed projects until a kit exists."]},clojure:{runtime:"clojure",displayName:"Clojure",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Clojure projects are importable and governed as observed projects until a kit exists."]},scala:{runtime:"scala",displayName:"Scala",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Scala projects are importable and governed as observed projects until a kit exists."]},kotlin:{runtime:"kotlin",displayName:"Kotlin",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Kotlin projects are importable and governed as observed projects until a kit exists."]},deno:{runtime:"deno",displayName:"Deno",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Deno projects are importable and governed as observed projects until a kit exists."]},bun:{runtime:"bun",displayName:"Bun",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Bun projects are importable and governed as observed projects until a kit exists."]},c:{runtime:"c",displayName:"C",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["C projects are importable and receive manifest, test, quality, security, and coverage evidence without assuming a package manager."]},cpp:{runtime:"cpp",displayName:"C++",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["C++ projects are importable and receive manifest, test, quality, security, and coverage evidence without assuming a package manager."]},unknown:{runtime:"unknown",displayName:"Unknown",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Unknown projects are tracked safely but require manual command configuration."]}},fe=["fastapi","nestjs"],ge=["django","flask","nextjs","remix","nuxt","react","vite","vue","sveltekit","svelte","angular","astro","solid","express","fastify","koa","echo","gofiber","gogin","springboot","dotnet","laravel","symfony","rails","sinatra","actix","axum","rocket","phoenix","clojure","scala","kotlin","deno","bun","tauri","electron","vscode-extension","c","cpp"];function x(e){return X[e||"unknown"]??X.unknown}function Q(e){return fe.includes(e)?"first-class":ge.includes(e)?"extended":"observed"}function Z(e){let t=x(e.runtime);return {lifecycleCommands:t.lifecycleCommands,moduleCommands:e.moduleSupport&&t.moduleCommands,unsupportedLifecycleCommands:f.filter(r=>!t.lifecycleCommands.includes(r))}}var ye=["python","node","go","java","dotnet","rust","php"];function w(e){return !!e&&ye.includes(e)}function E(e,t){return t!=="lint"&&t!=="format"&&t!=="docs"?false:e==="python"}function ee(e){let t=x(e),r=w(t.runtime),n=be[t.runtime]??[],a=Ce[t.runtime]??[];return {runtime:t.runtime,displayName:t.displayName,lifecycleCommands:t.lifecycleCommands,hasExecutor:r,packageManagers:n,primaryFiles:a,notes:t.notes}}var be={python:["poetry","pip","uv"],node:["npm","pnpm","yarn","bun"],go:["go"],java:["maven","gradle"],dotnet:["dotnet"],php:["composer"],ruby:["bundle"],rust:["cargo"],elixir:["mix"],kotlin:["gradle"],deno:["deno"],bun:["bun"]},Ce={python:["pyproject.toml","requirements.txt","requirements.in"],node:["package.json"],go:["go.mod"],java:["pom.xml","build.gradle","build.gradle.kts"],dotnet:["*.csproj","*.sln"],php:["composer.json"],ruby:["Gemfile"],rust:["Cargo.toml"],elixir:["mix.exs"],kotlin:["settings.gradle.kts"],deno:["deno.json","deno.jsonc"],bun:["package.json","bunfig.toml"]};function h(e,t){let r=g$1({runtime:typeof e?.runtime=="string"?e.runtime:void 0,framework:typeof e?.framework=="string"?e.framework:void 0,kitName:typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:void 0});return r.runtime!=="unknown"?r.runtime:j(t,e).runtime}function re(e){let t$1=e;for(;;){for(let n of t(t$1,"project.json"))if(T.existsSync(n))try{return JSON.parse(T.readFileSync(n,"utf8"))}catch{return null}let r=i.dirname(t$1);if(r===t$1)break;t$1=r;}return null}function pt(e,t){return h(e,t)==="go"}function lt(e,t){return h(e,t)==="node"}function dt(e,t){return h(e,t)==="java"}function ut(e,t){return h(e,t)==="dotnet"}function ft(e,t){return h(e,t)==="python"}var Se=["project.json","context.json","file-hashes.json"];async function ht(e){let t=i.resolve(e),r=[];for(let n of Se){let a=u$1(t,n);if(await C.pathExists(a))continue;let c=i.join(t,".rapidkit",n);if(!await C.pathExists(c))continue;let y=await C.readJson(c);await C.ensureDir(i.dirname(a));let k=`${a}.${process.pid}.${Date.now()}.tmp`;try{await C.writeJson(k,y,{spaces:2}),await C.move(k,a,{overwrite:false}),r.push(a);}finally{await C.remove(k).catch(()=>{});}}return r}function je(e){for(let t$1 of t(e,"context.json"))if(T.existsSync(t$1))try{return JSON.parse(T.readFileSync(t$1,"utf8"))}catch{return null}return null}function we(e){let t=e?.engine;return t==="npm"||t==="pip"||t==="python"?t:"unknown"}function xe(e,t){if(e?.module_support===false||t?.module_support===false||!e&&t)return false;let r=typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:typeof t?.kit=="string"?t.kit:void 0,n=r?R(r):void 0;return n?.owner==="core"&&n.moduleSupport===true}function he(e,t,r){let n=g$1({runtime:typeof t?.runtime=="string"?t.runtime:typeof r?.runtime=="string"?r.runtime:void 0,framework:typeof t?.framework=="string"?t.framework:typeof r?.framework=="string"?r.framework:void 0,kitName:typeof t?.kit_name=="string"?t.kit_name:typeof t?.kit=="string"?t.kit:typeof r?.kit=="string"?r.kit:void 0});return n.key!=="unknown"?n:j(e,t)}function ne(e){let t$1=i.resolve(e);if(![...t(t$1,"project.json"),...t(t$1,"context.json")].some(y=>T.existsSync(y)))return null;let n=re(t$1),a=je(t$1),c=he(t$1,n,a);return {projectRoot:t$1,projectJson:n,contextJson:a,detection:c,moduleSupport:xe(n,a),engine:we(a)}}var ve=["build","dev","start","test","lint","format"],I=["init","test","build","start"],Pt=["lint","format","docs"];function Rt(e){return !!e&&ve.includes(e)}var Ne={dev:["dev","start:dev"],start:["start","start:prod","preview"],build:["build"],test:["test","test:unit","test:ci"],lint:["lint"],format:["format","prettier"]},ae={nestjs:{dev:["dev","start:dev"],start:["start","start:prod"],build:["build"],test:["test","test:e2e"],lint:["lint"],format:["format"]},express:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},fastify:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},koa:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]}};function Pe(e){let t=i.join(e,"package.json");if(!T.existsSync(t))return {};try{let n=JSON.parse(T.readFileSync(t,"utf8")).scripts??{};return Object.fromEntries(Object.entries(n).filter(a=>typeof a[1]=="string"))}catch{return {}}}function Re(e,t){let r=t?c(t):"unknown",n=r!=="unknown"?a(r,e):[],a$1=t?ae[t]?.[e]??[]:[],c$1=Ne[e]??[],y=[...n,...a$1,...c$1];return [...new Set(y)]}function ie(e,t,r){let n=Pe(e),a$1=new Set(Object.keys(n));if(a$1.has(t))return {scriptName:t,source:"package.json"};for(let c$1 of Re(t,r?.framework))if(a$1.has(c$1))return {scriptName:c$1,source:a(c(r?.framework??"unknown"),t).includes(c$1)||ae[r?.framework??""]?.[t]?.includes(c$1)?"framework-candidate":"generic-candidate"};return null}function B(e){return T.existsSync(i.join(e,"package.json"))}function se(e){let t=ee(e);return t.runtime==="unknown"&&e!=="unknown"?null:{runtime:t.runtime,displayName:t.displayName,supportedCommands:t.lifecycleCommands,packageManagers:t.packageManagers,primaryFiles:t.primaryFiles,notes:t.notes,hasExecutor:t.hasExecutor}}function s(e){try{return T.existsSync(e)}catch{return false}}function g(e){try{return s(e)?T.readFileSync(e,"utf8"):""}catch{return ""}}function u(e,t){let r=g(i.join(e,"Makefile"));return r?new RegExp(`^${t}\\s*:`).test(r):false}function Ee(e){let t=[e];for(;t.length>0;){let r=t.shift();if(!r)break;let n=[];try{n=T.readdirSync(r,{withFileTypes:true});}catch{continue}for(let a of n){if(a.name==="node_modules"||a.name===".git"||a.name==="dist")continue;let c=i.join(r,a.name);if(a.isFile()&&a.name.endsWith(".csproj"))return true;a.isDirectory()&&t.push(c);}}return false}function ce(e,t){let r=s(i.join(e,"pyproject.toml")),n=s(i.join(e,"requirements.txt"))||s(i.join(e,"requirements.in")),a=s(i.join(e,"manage.py"));switch(t){case "init":return r||n;case "dev":case "start":return r||a||n;case "test":return r||n||s(i.join(e,"tests"));case "build":return r||n;case "lint":case "format":return r||n||a||s(i.join(e,"setup.py"))||s(i.join(e,"setup.cfg"));default:return false}}function Me(e,t){if(!s(i.join(e,"go.mod")))return false;switch(t){case "init":return true;case "dev":return u(e,"run")||s(i.join(e,"main.go"));case "test":return true;case "build":return true;case "start":return u(e,"run")||s(i.join(e,"main.go"))||s(i.join(e,"cmd"));case "lint":return s(i.join(e,".golangci.yml"))||s(i.join(e,".golangci.yaml"))||u(e,"lint");case "format":return u(e,"fmt")||u(e,"format");default:return false}}function _e(e,t){let r=s(i.join(e,"pom.xml")),n=s(i.join(e,"build.gradle"))||s(i.join(e,"build.gradle.kts"));if(!r&&!n)return false;switch(t){case "init":case "test":case "build":case "dev":case "start":return true;case "lint":return u(e,"lint")||g(i.join(e,"pom.xml")).includes("checkstyle")||g(i.join(e,"build.gradle")).includes("checkstyle")||g(i.join(e,"build.gradle.kts")).includes("checkstyle");case "format":return u(e,"format")||g(i.join(e,"build.gradle")).includes("spotless")||g(i.join(e,"build.gradle.kts")).includes("spotless");default:return false}}function Ae(e,t){if(!Ee(e))return false;switch(t){case "init":case "dev":case "test":case "build":case "start":return true;case "lint":return u(e,"lint")||g(i.join(e,"Directory.Build.props")).includes("EnforceCodeStyleInBuild");case "format":return u(e,"format")||s(i.join(e,".editorconfig"));default:return false}}function Fe(e,t,r){return t==="init"?B(e):ie(e,t,{framework:r})!==null}function Le(e,t,r){switch(t){case "php":return r==="init"&&s(i.join(e,"composer.json"));case "ruby":return r==="init"&&s(i.join(e,"Gemfile"));case "rust":return s(i.join(e,"Cargo.toml"))?r==="init"||r==="test"||r==="build"||r==="start":false;case "elixir":return r==="init"&&s(i.join(e,"mix.exs"));case "deno":return s(i.join(e,"deno.json"))||s(i.join(e,"deno.jsonc"))?r==="init"||r==="dev"||r==="test"||r==="start":r==="init"&&s(i.join(e,"package.json"));case "bun":return s(i.join(e,"bunfig.toml"))||s(i.join(e,"bun.lock"))?r==="init"||r==="dev"||r==="test"||r==="build"||r==="start":r==="init"&&s(i.join(e,"package.json"));default:return false}}function De(e){try{let t=JSON.parse(g(i.join(e,"composer.json")));return new Set(Object.keys(t.scripts??{}))}catch{return new Set}}function Oe(e,t){if(!s(i.join(e,"composer.json")))return false;let r=De(e),n=s(i.join(e,"artisan"));switch(t){case "init":return true;case "dev":return n||r.has("dev");case "start":return n||r.has("start");case "test":return n||r.has("test");case "build":return r.has("build");case "lint":return r.has("lint")||r.has("analyse")||r.has("analyze");case "format":return r.has("format")||r.has("fmt")||s(i.join(e,"pint.json"))||s(i.join(e,"vendor","bin","pint"));default:return false}}function Te(e,t){return s(i.join(e,"Cargo.toml"))?t==="init"||t==="dev"||t==="start"||t==="build"||t==="test"||t==="lint"||t==="format":false}function _(e,t,r,n){if(E(t,r))return ce(e,r);if(!w(t))return Le(e,t,r);switch(t){case "node":return Fe(e,r,n);case "python":return ce(e,r);case "go":return Me(e,r);case "java":return _e(e,r);case "dotnet":return Ae(e,r);case "rust":return Te(e,r);case "php":return Oe(e,r);default:return false}}function Ie(e,t,r){return ["init","dev","start","build","test","lint","format"].filter(a=>_(e,t,a,r))}function me(e){let t=Z({runtime:e.runtime,moduleSupport:e.moduleSupport});if(!e.projectPath)return t;let r=Ie(e.projectPath,e.runtime,e.framework),n=new Set(["help"]);for(let c of r)t.lifecycleCommands.includes(c)&&n.add(c);e.runtime==="node"&&B(e.projectPath)&&n.add("init");let a=[...n].sort();return {lifecycleCommands:a,moduleCommands:t.moduleCommands,unsupportedLifecycleCommands:t.lifecycleCommands.filter(c=>!a.includes(c)).sort()}}var W=["version","commands","doctor","project","help"],A=["init","dev","start","build","test","lint","format"],$=["add","modules","upgrade","diff","merge","reconcile","rollback","uninstall","checkpoint","snapshot","optimize"],J=["create","list","info","frameworks","license"];W.filter(e=>e!=="help");function Be(e){let t$1=i.resolve(e);for(;;){if([...t(t$1,"project.json"),...t(t$1,"context.json")].some(a=>T.existsSync(a)))return t$1;let n=i.dirname(t$1);if(n===t$1)break;t$1=n;}return null}function v(e,t){return {command:e,...t}}var Ge=new Set(["dev","lint","format"]),Ue=new Set(I);function We(e,t){return t?Ue.has(e)?{executionScope:"fleet",fleetEligible:true}:Ge.has(e)?{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}}function $e(e,t){return E(t.runtime,e)?"core":"runtime"}function Je(e,t,r,n){return !e||!n.lifecycleCommands.includes(t)?false:_(e,r.runtime,t,r.key)}function qe(e,t){let r=!!e&&(t.runtime==="python"||w(t.runtime)&&_(e,t.runtime,"build",t.key));return v("docs",{owner:t.runtime==="python"?"core":"runtime",status:r?"supported":"unsupported",reason:r?t.runtime==="python"?"Documentation generation is delegated to Python Core for this project.":"Project documentation commands are available through the npm wrapper for this runtime.":"Documentation commands require a supported Python or npm-executor project manifest."})}function Ye(e){let t=i.resolve(e),r=Be(e);return r||(h$1(t).length>0?t:null)}function He(e=process.cwd()){let t=Ye(e),r=t?ne(t):null,n=r?.detection??j(e,r?.projectJson??null),a=r?.moduleSupport??false,c=r?.engine??"unknown",y=se(n.runtime),k=x(n.runtime),le=me({runtime:n.runtime,moduleSupport:a,projectPath:t??void 0,framework:n.key}),b={};for(let o of W)b[o]=v(o,{owner:o==="project"?"core":"npm",status:"supported",reason:o==="project"?"Project detection is a Core contract; workspace project lifecycle remains npm-owned.":o==="help"?"Help is available for every Workspai project through the npm CLI.":"Universal command available across Workspai project types."});for(let o of A){let S=Je(t,o,n,le),Y=$e(o,n),F=We(o,S);b[o]=v(o,{owner:Y,status:S?"supported":"unsupported",executionScope:F.executionScope,fleetEligible:F.fleetEligible,reason:S?Y==="core"?`Delegated to Python Core for ${n.displayName} projects.`:F.fleetEligible?`Handled by runtime adapter and eligible for workspace fleet stages (${o}).`:o==="dev"?"Local development command only; workspace fleet excludes dev by design.":n.runtime==="node"?`Handled by npm/pnpm/yarn via the resolved ${o} script in package.json.`:`Handled by the ${y?.displayName??n.displayName} runtime adapter for local project execution.`:t?n.runtime==="node"?`No ${o} script was found in package.json for this ${n.displayName} project.`:w(n.runtime)?`The ${n.displayName} runtime is tracked, but ${o} is not available from detected project manifests.`:`${n.displayName} is tracked as an observed runtime; ${o} requires project manifests or explicit scripts.`:"No Workspai project was detected."});}b.docs=qe(t,n);for(let o of $)b[o]=v(o,{owner:a?"core":"none",status:a?"supported":"unsupported",reason:a?"Core module/template command supported for this project.":`Core module/template commands are not available for ${n.displayName} projects.`});for(let o of J)b[o]=v(o,{owner:o==="create"?"npm":"core",status:"global",reason:o==="create"?"Create is orchestrated by npm for multi-language workspace support.":"Engine catalog command; not specific to the selected project runtime."});let N=Object.values(b),q=N.filter(o=>A.includes(o.command)).filter(o=>o.status==="supported"),de=I.filter(o=>q.some(S=>S.fleetEligible===true&&S.command===o)),ue=q.filter(o=>o.executionScope==="local-only").map(o=>o.command).sort();return {schemaVersion:1,scope:"project",projectRoot:t,engine:c,runtime:n.runtime,framework:n.key,frameworkDisplayName:n.displayName,frameworkConfidence:n.confidence,frameworkSupportTier:Q(n.key),runtimeSupportTier:k.tier,runtimeDoctorSupport:k.doctorSupport,moduleSupport:a,fleetStages:de,localOnlyCommands:ue,commandMap:b,supportedCommands:N.filter(o=>o.status==="supported").map(o=>o.command).sort(),unsupportedCommands:N.filter(o=>o.status==="unsupported").map(o=>o.command).sort(),globalCommands:N.filter(o=>o.status==="global").map(o=>o.command).sort()}}function cr(e,t=process.cwd()){let r=e[0];return r?He(t).commandMap[r]??null:null}function mr(e){if(e[0]==="project"&&e[1]==="commands")return true;if(e[0]==="commands"&&e.includes("--scope")){let t=e.indexOf("--scope");return e[t+1]==="project"}return e.some(t=>t==="--scope=project")&&e[0]==="commands"}function pr(e,t){return [`Workspai command not supported for this project: ${e.command}`,"",`Project: ${t.projectRoot??"not detected"}`,`Runtime: ${t.runtime}`,`Framework: ${t.frameworkDisplayName}`,`Reason: ${e.reason??"Unsupported for this project type."}`,"","Run `workspai project commands` to inspect supported commands for this project."].join(`
|
|
1
|
+
import {a,c,j,g as g$1,h as h$1}from'./chunk-2PY65U6X.js';import {t,u as u$1}from'./chunk-MOSXTVPU.js';import T from'fs';import i from'path';import C from'fs-extra';var V=[{id:"fastapi.standard",aliases:["fastapi","fastapi.standard"],label:"fastapi \u2014 FastAPI Standard Kit",description:"Core-backed FastAPI service scaffold.",owner:"core",runtime:"python",framework:"fastapi",category:"backend",moduleSupport:true,stability:"stable",versionPolicy:"tested-baseline"},{id:"fastapi.ddd",aliases:["fastapi.ddd","fastapi-ddd"],label:"fastapi \u2014 FastAPI DDD Kit",description:"Core-backed FastAPI DDD service scaffold.",owner:"core",runtime:"python",framework:"fastapi",category:"backend",moduleSupport:true,stability:"stable",versionPolicy:"tested-baseline"},{id:"nestjs.standard",aliases:["nestjs","nest","nestjs.standard"],label:"nestjs \u2014 NestJS Standard Kit",description:"Core-backed NestJS service scaffold.",owner:"core",runtime:"node",framework:"nestjs",category:"backend",moduleSupport:true,stability:"stable",versionPolicy:"tested-baseline"},{id:"springboot.standard",aliases:["spring","springboot","springboot.standard","java"],label:"spring \u2014 Spring Boot Standard Kit",description:"npm-backed Spring Boot service scaffold.",owner:"npm",runtime:"java",framework:"springboot",category:"backend",moduleSupport:false,stability:"stable",versionPolicy:"tested-baseline",generator:"springboot",createUsage:"workspai create project springboot.standard <name> [--java-version <major>] [--spring-boot-version <semver>] [--group-id <com.example>] [--package-name <com.example.app>] [--port <number>]"},{id:"gofiber.standard",aliases:["go","go.standard","fiber","gofiber","gofiber.standard","go/fiber"],label:"go/fiber \u2014 Go Fiber Standard Kit",description:"npm-backed Go Fiber service scaffold.",owner:"npm",runtime:"go",framework:"gofiber",category:"backend",moduleSupport:false,stability:"stable",versionPolicy:"tested-baseline",generator:"gofiber",createUsage:"workspai create project gofiber.standard <name> [--output <dir>]"},{id:"gogin.standard",aliases:["gin","gogin","gogin.standard","go/gin"],label:"go/gin \u2014 Go Gin Standard Kit",description:"npm-backed Go Gin service scaffold.",owner:"npm",runtime:"go",framework:"gogin",category:"backend",moduleSupport:false,stability:"stable",versionPolicy:"tested-baseline",generator:"gogin",createUsage:"workspai create project gogin.standard <name> [--output <dir>]"},{id:"dotnet.webapi.clean",aliases:["dotnet","dotnet.webapi","dotnet.webapi.clean","aspnet","aspnetcore","asp.net","asp.net-core","csharp","c#"],label:"dotnet \u2014 ASP.NET Core Clean Web API",description:"npm-backed ASP.NET Core Web API with clean architecture boundaries.",owner:"npm",runtime:"dotnet",framework:"dotnet",category:"backend",moduleSupport:false,stability:"preview",versionPolicy:"tested-baseline",generator:"dotnet-webapi-clean",createUsage:"workspai create project dotnet.webapi.clean <name> [--target-framework net8.0] [--root-namespace <Company.Product>] [--port <number>]"},{id:"rust.axum",aliases:["rust.axum","axum","rust-axum"],label:"rust/axum \u2014 Rust Axum API",description:"Workspai-owned Axum service with health, tests, CI, and container baseline.",owner:"npm",runtime:"rust",framework:"axum",category:"backend",moduleSupport:false,stability:"preview",versionPolicy:"tested-baseline",generator:"rust-axum",createUsage:"workspai create project rust.axum <name> [--port <number>] [--output <dir>] [--skip-git]"}],O=new Map;for(let e of V){O.set(e.id.toLowerCase(),e);for(let t of e.aliases)O.set(t.toLowerCase(),e);}function R(e){return e?O.get(e.trim().toLowerCase())??null:null}function ze(e){return R(e)?.id??e}function Ve(){return V.filter(e=>e.owner==="core"||e.generator)}function Xe(e){return R(e)?.owner==="npm"}async function Qe(e,t){if(!e.generator)throw new Error(`Kit is not backed by an npm generator: ${e.id}`);if(e.generator==="gofiber"){let{generateGoFiberKit:r}=await import('./gofiber-standard-AQGSC7ON.js');await r(t.projectPath,{project_name:t.projectName,module_path:t.projectName,skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="gogin"){let{generateGoGinKit:r}=await import('./gogin-standard-7DU3OCBX.js');await r(t.projectPath,{project_name:t.projectName,module_path:t.projectName,skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="springboot"){let{generateSpringBootKit:r}=await import('./springboot-standard-EK6GYN5T.js');await r(t.projectPath,{project_name:t.projectName,artifact_id:t.projectName,java_version:m(t.args,"--java-version")?.trim(),spring_boot_version:m(t.args,"--spring-boot-version")?.trim(),springdoc_version:m(t.args,"--springdoc-version")?.trim(),group_id:m(t.args,"--group-id")?.trim(),package_name:m(t.args,"--package-name")?.trim(),description:m(t.args,"--description")?.trim(),port:m(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="dotnet-webapi-clean"){let{generateDotnetWebApiCleanKit:r}=await import('./dotnet-webapi-clean-VXEF4SHM.js');await r(t.projectPath,{project_name:t.projectName,target_framework:m(t.args,"--target-framework")?.trim(),root_namespace:m(t.args,"--root-namespace")?.trim(),description:m(t.args,"--description")?.trim(),port:m(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="rust-axum"){let{generateRustAxumKit:r}=await import('./rust-axum-4HXDICIB.js');await r(t.projectPath,{project_name:t.projectName,description:m(t.args,"--description")?.trim(),port:m(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}throw new Error(`Unhandled npm kit generator: ${e.generator}`)}function m(e,t){let r=e.indexOf(t);if(r>=0&&r+1<e.length)return e[r+1];let n=e.find(a=>a.startsWith(`${t}=`));return n?n.slice(t.length+1):void 0}var f=["init","dev","start","build","test","lint","format","help"],X={python:{runtime:"python",displayName:"Python",tier:"first-class",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:true,doctorSupport:"full",notes:["Core-backed Python projects support RapidKit Core modules and lifecycle commands."]},node:{runtime:"node",displayName:"Node.js",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:true,doctorSupport:"full",notes:["Node projects support npm-owned lifecycle commands; NestJS is the first-class Node framework."]},go:{runtime:"go",displayName:"Go",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Go projects support workspace governance and lifecycle commands via Go tooling."]},java:{runtime:"java",displayName:"Java / Spring Boot",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Java projects support Maven/Gradle lifecycle commands and workspace governance."]},dotnet:{runtime:"dotnet",displayName:".NET / ASP.NET Core",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:[".NET projects support dotnet CLI lifecycle commands and workspace governance."]},php:{runtime:"php",displayName:"PHP",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Laravel projects use the official Composer generator and PHP/Composer lifecycle adapter."]},ruby:{runtime:"ruby",displayName:"Ruby",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Ruby projects are importable and governed as observed projects until a kit exists."]},rust:{runtime:"rust",displayName:"Rust",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:f,moduleCommands:false,doctorSupport:"readiness",notes:["Rust projects support Axum and Tauri scaffolding plus Cargo lifecycle commands."]},elixir:{runtime:"elixir",displayName:"Elixir",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Elixir projects are importable and governed as observed projects until a kit exists."]},clojure:{runtime:"clojure",displayName:"Clojure",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Clojure projects are importable and governed as observed projects until a kit exists."]},scala:{runtime:"scala",displayName:"Scala",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Scala projects are importable and governed as observed projects until a kit exists."]},kotlin:{runtime:"kotlin",displayName:"Kotlin",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Kotlin projects are importable and governed as observed projects until a kit exists."]},deno:{runtime:"deno",displayName:"Deno",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Deno projects are importable and governed as observed projects until a kit exists."]},bun:{runtime:"bun",displayName:"Bun",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Bun projects are importable and governed as observed projects until a kit exists."]},c:{runtime:"c",displayName:"C",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["C projects are importable and receive manifest, test, quality, security, and coverage evidence without assuming a package manager."]},cpp:{runtime:"cpp",displayName:"C++",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["C++ projects are importable and receive manifest, test, quality, security, and coverage evidence without assuming a package manager."]},unknown:{runtime:"unknown",displayName:"Unknown",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Unknown projects are tracked safely but require manual command configuration."]}},fe=["fastapi","nestjs"],ge=["django","flask","nextjs","remix","nuxt","react","vite","vue","sveltekit","svelte","angular","astro","solid","express","fastify","koa","echo","gofiber","gogin","springboot","dotnet","laravel","symfony","rails","sinatra","actix","axum","rocket","phoenix","clojure","scala","kotlin","deno","bun","tauri","electron","vscode-extension","c","cpp"];function x(e){return X[e||"unknown"]??X.unknown}function Q(e){return fe.includes(e)?"first-class":ge.includes(e)?"extended":"observed"}function Z(e){let t=x(e.runtime);return {lifecycleCommands:t.lifecycleCommands,moduleCommands:e.moduleSupport&&t.moduleCommands,unsupportedLifecycleCommands:f.filter(r=>!t.lifecycleCommands.includes(r))}}var ye=["python","node","go","java","dotnet","rust","php"];function w(e){return !!e&&ye.includes(e)}function E(e,t){return t!=="lint"&&t!=="format"&&t!=="docs"?false:e==="python"}function ee(e){let t=x(e),r=w(t.runtime),n=be[t.runtime]??[],a=Ce[t.runtime]??[];return {runtime:t.runtime,displayName:t.displayName,lifecycleCommands:t.lifecycleCommands,hasExecutor:r,packageManagers:n,primaryFiles:a,notes:t.notes}}var be={python:["poetry","pip","uv"],node:["npm","pnpm","yarn","bun"],go:["go"],java:["maven","gradle"],dotnet:["dotnet"],php:["composer"],ruby:["bundle"],rust:["cargo"],elixir:["mix"],kotlin:["gradle"],deno:["deno"],bun:["bun"]},Ce={python:["pyproject.toml","requirements.txt","requirements.in"],node:["package.json"],go:["go.mod"],java:["pom.xml","build.gradle","build.gradle.kts"],dotnet:["*.csproj","*.sln"],php:["composer.json"],ruby:["Gemfile"],rust:["Cargo.toml"],elixir:["mix.exs"],kotlin:["settings.gradle.kts"],deno:["deno.json","deno.jsonc"],bun:["package.json","bunfig.toml"]};function h(e,t){let r=g$1({runtime:typeof e?.runtime=="string"?e.runtime:void 0,framework:typeof e?.framework=="string"?e.framework:void 0,kitName:typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:void 0});return r.runtime!=="unknown"?r.runtime:j(t,e).runtime}function re(e){let t$1=e;for(;;){for(let n of t(t$1,"project.json"))if(T.existsSync(n))try{return JSON.parse(T.readFileSync(n,"utf8"))}catch{return null}let r=i.dirname(t$1);if(r===t$1)break;t$1=r;}return null}function pt(e,t){return h(e,t)==="go"}function lt(e,t){return h(e,t)==="node"}function dt(e,t){return h(e,t)==="java"}function ut(e,t){return h(e,t)==="dotnet"}function ft(e,t){return h(e,t)==="python"}var Se=["project.json","context.json","file-hashes.json"];async function ht(e){let t=i.resolve(e),r=[];for(let n of Se){let a=u$1(t,n);if(await C.pathExists(a))continue;let c=i.join(t,".rapidkit",n);if(!await C.pathExists(c))continue;let y=await C.readJson(c);await C.ensureDir(i.dirname(a));let k=`${a}.${process.pid}.${Date.now()}.tmp`;try{await C.writeJson(k,y,{spaces:2}),await C.move(k,a,{overwrite:false}),r.push(a);}finally{await C.remove(k).catch(()=>{});}}return r}function je(e){for(let t$1 of t(e,"context.json"))if(T.existsSync(t$1))try{return JSON.parse(T.readFileSync(t$1,"utf8"))}catch{return null}return null}function we(e){let t=e?.engine;return t==="npm"||t==="pip"||t==="python"?t:"unknown"}function xe(e,t){if(e?.module_support===false||t?.module_support===false||!e&&t)return false;let r=typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:typeof t?.kit=="string"?t.kit:void 0,n=r?R(r):void 0;return n?.owner==="core"&&n.moduleSupport===true}function he(e,t,r){let n=g$1({runtime:typeof t?.runtime=="string"?t.runtime:typeof r?.runtime=="string"?r.runtime:void 0,framework:typeof t?.framework=="string"?t.framework:typeof r?.framework=="string"?r.framework:void 0,kitName:typeof t?.kit_name=="string"?t.kit_name:typeof t?.kit=="string"?t.kit:typeof r?.kit=="string"?r.kit:void 0});return n.key!=="unknown"?n:j(e,t)}function ne(e){let t$1=i.resolve(e);if(![...t(t$1,"project.json"),...t(t$1,"context.json")].some(y=>T.existsSync(y)))return null;let n=re(t$1),a=je(t$1),c=he(t$1,n,a);return {projectRoot:t$1,projectJson:n,contextJson:a,detection:c,moduleSupport:xe(n,a),engine:we(a)}}var ve=["build","dev","start","test","lint","format"],I=["init","test","build","start"],Pt=["lint","format","docs"];function Rt(e){return !!e&&ve.includes(e)}var Ne={dev:["dev","start:dev"],start:["start","start:prod","preview"],build:["build"],test:["test","test:unit","test:ci"],lint:["lint"],format:["format","prettier"]},ae={nestjs:{dev:["dev","start:dev"],start:["start","start:prod"],build:["build"],test:["test","test:e2e"],lint:["lint"],format:["format"]},express:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},fastify:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},koa:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]}};function Pe(e){let t=i.join(e,"package.json");if(!T.existsSync(t))return {};try{let n=JSON.parse(T.readFileSync(t,"utf8")).scripts??{};return Object.fromEntries(Object.entries(n).filter(a=>typeof a[1]=="string"))}catch{return {}}}function Re(e,t){let r=t?c(t):"unknown",n=r!=="unknown"?a(r,e):[],a$1=t?ae[t]?.[e]??[]:[],c$1=Ne[e]??[],y=[...n,...a$1,...c$1];return [...new Set(y)]}function ie(e,t,r){let n=Pe(e),a$1=new Set(Object.keys(n));if(a$1.has(t))return {scriptName:t,source:"package.json"};for(let c$1 of Re(t,r?.framework))if(a$1.has(c$1))return {scriptName:c$1,source:a(c(r?.framework??"unknown"),t).includes(c$1)||ae[r?.framework??""]?.[t]?.includes(c$1)?"framework-candidate":"generic-candidate"};return null}function B(e){return T.existsSync(i.join(e,"package.json"))}function se(e){let t=ee(e);return t.runtime==="unknown"&&e!=="unknown"?null:{runtime:t.runtime,displayName:t.displayName,supportedCommands:t.lifecycleCommands,packageManagers:t.packageManagers,primaryFiles:t.primaryFiles,notes:t.notes,hasExecutor:t.hasExecutor}}function s(e){try{return T.existsSync(e)}catch{return false}}function g(e){try{return s(e)?T.readFileSync(e,"utf8"):""}catch{return ""}}function u(e,t){let r=g(i.join(e,"Makefile"));return r?new RegExp(`^${t}\\s*:`).test(r):false}function Ee(e){let t=[e];for(;t.length>0;){let r=t.shift();if(!r)break;let n=[];try{n=T.readdirSync(r,{withFileTypes:true});}catch{continue}for(let a of n){if(a.name==="node_modules"||a.name===".git"||a.name==="dist")continue;let c=i.join(r,a.name);if(a.isFile()&&a.name.endsWith(".csproj"))return true;a.isDirectory()&&t.push(c);}}return false}function ce(e,t){let r=s(i.join(e,"pyproject.toml")),n=s(i.join(e,"requirements.txt"))||s(i.join(e,"requirements.in")),a=s(i.join(e,"manage.py"));switch(t){case "init":return r||n;case "dev":case "start":return r||a||n;case "test":return r||n||s(i.join(e,"tests"));case "build":return r||n;case "lint":case "format":return r||n||a||s(i.join(e,"setup.py"))||s(i.join(e,"setup.cfg"));default:return false}}function Me(e,t){if(!s(i.join(e,"go.mod")))return false;switch(t){case "init":return true;case "dev":return u(e,"run")||s(i.join(e,"main.go"));case "test":return true;case "build":return true;case "start":return u(e,"run")||s(i.join(e,"main.go"))||s(i.join(e,"cmd"));case "lint":return s(i.join(e,".golangci.yml"))||s(i.join(e,".golangci.yaml"))||u(e,"lint");case "format":return u(e,"fmt")||u(e,"format");default:return false}}function _e(e,t){let r=s(i.join(e,"pom.xml")),n=s(i.join(e,"build.gradle"))||s(i.join(e,"build.gradle.kts"));if(!r&&!n)return false;switch(t){case "init":case "test":case "build":case "dev":case "start":return true;case "lint":return u(e,"lint")||g(i.join(e,"pom.xml")).includes("checkstyle")||g(i.join(e,"build.gradle")).includes("checkstyle")||g(i.join(e,"build.gradle.kts")).includes("checkstyle");case "format":return u(e,"format")||g(i.join(e,"build.gradle")).includes("spotless")||g(i.join(e,"build.gradle.kts")).includes("spotless");default:return false}}function Ae(e,t){if(!Ee(e))return false;switch(t){case "init":case "dev":case "test":case "build":case "start":return true;case "lint":return u(e,"lint")||g(i.join(e,"Directory.Build.props")).includes("EnforceCodeStyleInBuild");case "format":return u(e,"format")||s(i.join(e,".editorconfig"));default:return false}}function Fe(e,t,r){return t==="init"?B(e):ie(e,t,{framework:r})!==null}function Le(e,t,r){switch(t){case "php":return r==="init"&&s(i.join(e,"composer.json"));case "ruby":return r==="init"&&s(i.join(e,"Gemfile"));case "rust":return s(i.join(e,"Cargo.toml"))?r==="init"||r==="test"||r==="build"||r==="start":false;case "elixir":return r==="init"&&s(i.join(e,"mix.exs"));case "deno":return s(i.join(e,"deno.json"))||s(i.join(e,"deno.jsonc"))?r==="init"||r==="dev"||r==="test"||r==="start":r==="init"&&s(i.join(e,"package.json"));case "bun":return s(i.join(e,"bunfig.toml"))||s(i.join(e,"bun.lock"))?r==="init"||r==="dev"||r==="test"||r==="build"||r==="start":r==="init"&&s(i.join(e,"package.json"));default:return false}}function De(e){try{let t=JSON.parse(g(i.join(e,"composer.json")));return new Set(Object.keys(t.scripts??{}))}catch{return new Set}}function Oe(e,t){if(!s(i.join(e,"composer.json")))return false;let r=De(e),n=s(i.join(e,"artisan"));switch(t){case "init":return true;case "dev":return n||r.has("dev");case "start":return n||r.has("start");case "test":return n||r.has("test");case "build":return r.has("build");case "lint":return r.has("lint")||r.has("analyse")||r.has("analyze");case "format":return r.has("format")||r.has("fmt")||s(i.join(e,"pint.json"))||s(i.join(e,"vendor","bin","pint"));default:return false}}function Te(e,t){return s(i.join(e,"Cargo.toml"))?t==="init"||t==="dev"||t==="start"||t==="build"||t==="test"||t==="lint"||t==="format":false}function _(e,t,r,n){if(E(t,r))return ce(e,r);if(!w(t))return Le(e,t,r);switch(t){case "node":return Fe(e,r,n);case "python":return ce(e,r);case "go":return Me(e,r);case "java":return _e(e,r);case "dotnet":return Ae(e,r);case "rust":return Te(e,r);case "php":return Oe(e,r);default:return false}}function Ie(e,t,r){return ["init","dev","start","build","test","lint","format"].filter(a=>_(e,t,a,r))}function me(e){let t=Z({runtime:e.runtime,moduleSupport:e.moduleSupport});if(!e.projectPath)return t;let r=Ie(e.projectPath,e.runtime,e.framework),n=new Set(["help"]);for(let c of r)t.lifecycleCommands.includes(c)&&n.add(c);e.runtime==="node"&&B(e.projectPath)&&n.add("init");let a=[...n].sort();return {lifecycleCommands:a,moduleCommands:t.moduleCommands,unsupportedLifecycleCommands:t.lifecycleCommands.filter(c=>!a.includes(c)).sort()}}var W=["version","commands","doctor","project","help"],A=["init","dev","start","build","test","lint","format"],$=["add","modules","upgrade","diff","merge","reconcile","rollback","uninstall","checkpoint","snapshot","optimize"],J=["create","list","info","frameworks","license"];W.filter(e=>e!=="help");function Be(e){let t$1=i.resolve(e);for(;;){if([...t(t$1,"project.json"),...t(t$1,"context.json")].some(a=>T.existsSync(a)))return t$1;let n=i.dirname(t$1);if(n===t$1)break;t$1=n;}return null}function v(e,t){return {command:e,...t}}var Ge=new Set(["dev","lint","format"]),Ue=new Set(I);function We(e,t){return t?Ue.has(e)?{executionScope:"fleet",fleetEligible:true}:Ge.has(e)?{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}}function $e(e,t){return E(t.runtime,e)?"core":"runtime"}function Je(e,t,r,n){return !e||!n.lifecycleCommands.includes(t)?false:_(e,r.runtime,t,r.key)}function qe(e,t){let r=!!e&&(t.runtime==="python"||w(t.runtime)&&_(e,t.runtime,"build",t.key));return v("docs",{owner:t.runtime==="python"?"core":"runtime",status:r?"supported":"unsupported",reason:r?t.runtime==="python"?"Documentation generation is delegated to Python Core for this project.":"Project documentation commands are available through the npm wrapper for this runtime.":"Documentation commands require a supported Python or npm-executor project manifest."})}function Ye(e){let t=i.resolve(e),r=Be(e);return r||(h$1(t).length>0?t:null)}function He(e=process.cwd()){let t=Ye(e),r=t?ne(t):null,n=r?.detection??j(e,r?.projectJson??null),a=r?.moduleSupport??false,c=r?.engine??"unknown",y=se(n.runtime),k=x(n.runtime),le=me({runtime:n.runtime,moduleSupport:a,projectPath:t??void 0,framework:n.key}),b={};for(let o of W)b[o]=v(o,{owner:o==="project"?"core":"npm",status:"supported",reason:o==="project"?"Project detection is a Core contract; workspace project lifecycle remains npm-owned.":o==="help"?"Help is available for every Workspai project through the npm CLI.":"Universal command available across Workspai project types."});for(let o of A){let S=Je(t,o,n,le),Y=$e(o,n),F=We(o,S);b[o]=v(o,{owner:Y,status:S?"supported":"unsupported",executionScope:F.executionScope,fleetEligible:F.fleetEligible,reason:S?Y==="core"?`Delegated to Python Core for ${n.displayName} projects.`:F.fleetEligible?`Handled by runtime adapter and eligible for workspace fleet stages (${o}).`:o==="dev"?"Local development command only; workspace fleet excludes dev by design.":n.runtime==="node"?`Handled by npm/pnpm/yarn via the resolved ${o} script in package.json.`:`Handled by the ${y?.displayName??n.displayName} runtime adapter for local project execution.`:t?n.runtime==="node"?`No ${o} script was found in package.json for this ${n.displayName} project.`:w(n.runtime)?`The ${n.displayName} runtime is tracked, but ${o} is not available from detected project manifests.`:`${n.displayName} is tracked as an observed runtime; ${o} requires project manifests or explicit scripts.`:"No Workspai project was detected."});}b.docs=qe(t,n);for(let o of $)b[o]=v(o,{owner:a?"core":"none",status:a?"supported":"unsupported",reason:a?"Core module/template command supported for this project.":`Core module/template commands are not available for ${n.displayName} projects.`});for(let o of J)b[o]=v(o,{owner:o==="create"?"npm":"core",status:"global",reason:o==="create"?"Create is orchestrated by npm for multi-language workspace support.":"Engine catalog command; not specific to the selected project runtime."});let N=Object.values(b),q=N.filter(o=>A.includes(o.command)).filter(o=>o.status==="supported"),de=I.filter(o=>q.some(S=>S.fleetEligible===true&&S.command===o)),ue=q.filter(o=>o.executionScope==="local-only").map(o=>o.command).sort();return {schemaVersion:1,scope:"project",projectRoot:t,engine:c,runtime:n.runtime,framework:n.key,frameworkDisplayName:n.displayName,frameworkConfidence:n.confidence,frameworkSupportTier:Q(n.key),runtimeSupportTier:k.tier,runtimeDoctorSupport:k.doctorSupport,moduleSupport:a,fleetStages:de,localOnlyCommands:ue,commandMap:b,supportedCommands:N.filter(o=>o.status==="supported").map(o=>o.command).sort(),unsupportedCommands:N.filter(o=>o.status==="unsupported").map(o=>o.command).sort(),globalCommands:N.filter(o=>o.status==="global").map(o=>o.command).sort()}}function cr(e,t=process.cwd()){let r=e[0];return r?He(t).commandMap[r]??null:null}function mr(e){if(e[0]==="project"&&e[1]==="commands")return true;if(e[0]==="commands"&&e.includes("--scope")){let t=e.indexOf("--scope");return e[t+1]==="project"}return e.some(t=>t==="--scope=project")&&e[0]==="commands"}function pr(e,t){return [`Workspai command not supported for this project: ${e.command}`,"",`Project: ${t.projectRoot??"not detected"}`,`Runtime: ${t.runtime}`,`Framework: ${t.frameworkDisplayName}`,`Reason: ${e.reason??"Unsupported for this project type."}`,"","Run `workspai project commands` to inspect supported commands for this project."].join(`
|
|
2
2
|
`)}export{R as a,ze as b,Ve as c,Xe as d,Qe as e,x as f,Q as g,w as h,re as i,pt as j,lt as k,dt as l,ut as m,ft as n,ht as o,ne as p,ve as q,Pt as r,Rt as s,ie as t,me as u,Be as v,He as w,cr as x,mr as y,pr as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b}from'./chunk-
|
|
1
|
+
import {b}from'./chunk-62K2H72S.js';var i=b.explain,g=["project","release-blocked","blocker","trace"];function s(t){let r=t.trim();if(!r)return null;if(r==="release-blocked")return {kind:"release-blocked"};if(r.startsWith("project:")){let e=r.slice(8).trim();return e?{kind:"project",project:e}:null}if(r.startsWith("blocker:")){let e=r.slice(8).trim();return e?{kind:"blocker",blockerId:e}:null}if(r.startsWith("trace:")){let e=r.slice(6).trim();return e?{kind:"trace",diffRef:e}:null}return {kind:"project",project:r}}function u(t){let r=t.trim();if(!r)return null;if(r.startsWith("trace:")){let n=s(r);return n?.kind==="trace"?n:null}let e=r.replace(/\\/g,"/").trim().toLowerCase();return e.endsWith(".json")||e.includes("workspace-model-diff")||e.startsWith(".rapidkit/")||e.includes("/.rapidkit/")?{kind:"trace",diffRef:r}:null}function A(t){if(!t||typeof t!="object"||Array.isArray(t))return false;let r=t;return r.schemaVersion===i&&typeof r.generatedAt=="string"&&typeof r.summary=="string"&&Array.isArray(r.sections)&&r.target!=null&&typeof r.target=="object"&&!Array.isArray(r.target)&&typeof r.target.kind=="string"}export{i as a,g as b,s as c,u as d,A as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b}from'./chunk-
|
|
1
|
+
import {b}from'./chunk-62K2H72S.js';var y=b.doctor,m="doctor-project-evidence-v1";function n(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function R(e,o){let r=n(e);if(!r)return false;let s=r.schemaVersion,i=r.evidenceType;return !(typeof s=="string"&&(s!==y&&s!==m||o==="workspace"&&s!==y||o==="project"&&s!==m)||typeof i=="string"&&(i!=="workspace"&&i!=="project"||o&&i!==o))}function c(e,o){let r=e[o];if(!Number.isInteger(r)||Number(r)<0)throw new Error(`Doctor evidence ${o} must be a non-negative integer.`);return Number(r)}function v(e){if(Array.isArray(e.projects))return e.projects.map(n).filter(r=>r!==null);let o=n(e.project);return o?[o]:[]}function S(e){let o=n(e);if(!o)throw new Error("Doctor evidence must be an object.");let r=n(o.healthScore);if(!r||typeof r.verdict!="string")return;let s=c(r,"total"),i=c(r,"passed"),f=c(r,"warnings"),u=c(r,"errors");if(s!==i+f+u)throw new Error("Doctor healthScore total must equal passed + warnings + errors.");let p=u>0?"blocked":f>0?"attention":"passed";if(r.verdict!==p)throw new Error(`Doctor healthScore verdict ${String(r.verdict)} contradicts score counts (${p}).`);let l=0,g=0;for(let t of v(o)){let w=Array.isArray(t.probes)?t.probes:[];l+=w.filter(d=>n(d)?.status==="fail").length,g+=Array.isArray(t.issues)?t.issues.length:0;let a=n(t.probeSummary);if(a){let d=c(a,"blockingFindings"),h=w.filter(k=>n(k)?.status==="fail").length+(Array.isArray(t.issues)?t.issues.length:0);if(d!==h)throw new Error("Doctor project probeSummary.blockingFindings contradicts failed probes and runtime issues.");let E=d>0?"blocked":c(a,"advisoryFindings")>0?"attention":"passed";if(a.verdict!==E||t.verdict!==E)throw new Error("Doctor project verdict contradicts its probe summary.")}}if(l+g>0&&u===0)throw new Error("Doctor evidence contains blocking findings but healthScore.errors is zero.")}export{y as a,m as b,R as c,S as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b as b$1,c as c$1}from'./chunk-QURMI7ID.js';import {a as a$2}from'./chunk-HPWLSLMC.js';import {q as q$1}from'./chunk-6AXRIAP2.js';import {a as a$3}from'./chunk-KHEJO3JU.js';import {g}from'./chunk-MZFSINY7.js';import {j,e as e$1}from'./chunk-ZVOEPWQM.js';import {l as l$1}from'./chunk-5XJRCP3D.js';import {c,d}from'./chunk-WJY7ZXVJ.js';import {a as a$1}from'./chunk-LPCL4U4L.js';import {f,g as g$1,h as h$3}from'./chunk-XHRHNVCZ.js';import {k,l,h as h$2,m as m$1,n,p as p$1,q}from'./chunk-PTTZPDLX.js';import {m,p,s}from'./chunk-FUPHQOJB.js';import {o,r as r$1,s as s$1}from'./chunk-B4CPDK6J.js';import {e}from'./chunk-MBRU3VWJ.js';import {b as b$2}from'./chunk-ULR66OJR.js';import {a,b,h as h$1,i,g as g$2,f as f$1}from'./chunk-62K2H72S.js';import {d as d$1}from'./chunk-VRW6KXNK.js';import oe from'path';import ce from'fs-extra';function r(t,s){if(!t)throw new Error(`Workspace Intelligence run semantic violation: ${s}`)}function ie(t,s){return t.length===s.length&&t.every((u,d)=>u===s[d])}function ne(t){b$2(a.intelligenceRun,t,"Workspace Intelligence run report"),r(t.chainSchemaVersion===a$1,`chainSchemaVersion must be ${a$1}`),r(t.artifactPath===a.intelligenceRun,`artifactPath must be ${a.intelligenceRun}`),r(t.preflight.length===g$2.length,`preflight must contain exactly ${g$2.length} entries`);for(let[o,i]of g$2.entries()){let a=t.preflight[o];r(a?.id===i,`preflight[${o}].id must be ${i}`),r(ie(a.artifacts,h$1[i]),`${i} preflight artifacts must match the runtime registry`),i==="sync"?r(a.status==="passed"&&a.result==="synchronized"||a.status==="failed"&&a.result==="failed","sync preflight status and result are incoherent"):r(a.status==="passed"&&(a.result==="created"||a.result==="reused")||a.status==="failed"&&a.result==="failed"||a.status==="skipped"&&a.result==="skipped","baseline preflight status and result are incoherent");}let s=t.preflight[1];r(t.baselineCreated===(s?.result==="created"),"baselineCreated must match the baseline preflight result"),r(t.stages.length===f$1.length,`stages must contain exactly ${f$1.length} canonical steps`);let u=t.preflight[0],d=u?.status==="failed";for(let[o,i$1]of f$1.entries()){let a=t.stages[o];r(a?.id===i$1,`stages[${o}].id must be ${i$1}`),r(ie(a.artifacts,i[i$1].produces),`${i$1} artifacts must match the runtime registry`),d&&r(a.status==="skipped",`${i$1} must be skipped after a hard failure`),a.status==="passed"?r(a.exitCode===0,`${i$1} passed stage must have exitCode 0`):a.status==="blocked"?r(a.exitCode!==0,`${i$1} blocked stage must have a non-zero exitCode`):a.status==="failed"?(r(a.exitCode===1,`${i$1} failed stage must have exitCode 1`),d=true):(r(a.exitCode===0,`${i$1} skipped stage must have exitCode 0`),r(a.durationMs===0,`${i$1} skipped stage must have durationMs 0`)),o===0&&((u?.status==="failed"||a.status==="failed")&&r(s?.status==="skipped","baseline must be skipped when sync or model fails"),s?.status==="skipped"&&r(u?.status==="failed"||a.status==="failed"||a.status==="skipped","baseline may be skipped only after an upstream failure"),s?.status!=="passed"&&(d=true));}let m=t.preflight.some(o=>o.status==="failed")||t.stages.some(o=>o.status==="failed"),y=t.stages.some(o=>o.status==="blocked"),n=m?"failed":y?"blocked":"passed",f=n==="failed"?1:n==="blocked"?2:0;r(t.status===n,`status must be ${n}`),r(t.exitCode===f,`exitCode must be ${f}`);}var me=a.intelligenceRun,fe=b.intelligenceRun,le=me;function h(t){d$1({action:"intelligence",status:t.status==="started"?"started":t.status==="passed"?"succeeded":t.status==="failed"?"failed":"warn",message:t.message,metadata:{phase:`workspace.intelligence.${t.kind}.${t.id}`,intelligenceMilestoneId:t.id,intelligenceMilestoneKind:t.kind,intelligenceMilestoneStatus:t.status}});}async function He(t){let s$2=oe.resolve(t.workspacePath),u=[],d$1=[],m$2=false,y=async(e,l)=>{let g=[...h$1[e]];if(m$2){h({id:e,kind:"preflight",status:"skipped",message:`${e} prerequisite skipped after an upstream failure`}),u.push({id:e,status:"skipped",result:"skipped",durationMs:0,artifacts:g,message:"skipped because a required upstream operation failed"});return}let I=Date.now();h({id:e,kind:"preflight",status:"started",message:`${e} prerequisite started`});try{let c=await l();h({id:e,kind:"preflight",status:"passed",message:c.message}),u.push({id:e,status:"passed",result:c.result,durationMs:Date.now()-I,artifacts:g,message:c.message});}catch(c){m$2=true;let k=c instanceof Error?c.message:String(c);h({id:e,kind:"preflight",status:"failed",message:k}),u.push({id:e,status:"failed",result:"failed",durationMs:Date.now()-I,artifacts:g,message:k});}},n$1=async(e,l)=>{let g=[...i[e].produces];if(m$2){h({id:e,kind:"stage",status:"skipped",message:`${e} skipped after an upstream failure`}),d$1.push({id:e,status:"skipped",durationMs:0,artifacts:g,exitCode:0,message:"skipped because a required upstream stage failed"});return}let I=Date.now();h({id:e,kind:"stage",status:"started",message:`${e} started`});try{let c=await l(),k=c.exitCode??0,x=c.blocked||k!==0?"blocked":"passed";h({id:e,kind:"stage",status:x,message:c.message}),d$1.push({id:e,status:x,durationMs:Date.now()-I,artifacts:g,exitCode:k,message:c.message});}catch(c){m$2=true;let k=c instanceof Error?c.message:String(c);h({id:e,kind:"stage",status:"failed",message:k}),d$1.push({id:e,status:"failed",durationMs:Date.now()-I,artifacts:g,exitCode:1,message:k});}};await y("sync",async()=>{let e=await g(s$2,true),l=await o({workspacePath:s$2});return {result:"synchronized",message:`registry ${e.added.length} added/${e.skipped} existing; contract ${l.contract.projects.length} projects`}});let f$1,o$1=()=>{if(!f$1)throw new Error("canonical workspace model is unavailable");return f$1};await n$1("model",async()=>(f$1={...await p({workspacePath:s$2,includeEvidence:true}),build:m({mode:"full",engineStatus:"disabled"})},await s(f$1,s$2),{message:`${f$1.summary.projectCount} projects modeled`}));let i$1=oe.join(s$2,a.snapshot),a$4=false;await y("baseline",async()=>{if(!await ce.pathExists(i$1)){let g=await k({workspacePath:s$2,model:o$1()});return await l(g,s$2),a$4=true,{result:"created",message:"initial structural baseline created"}}let e=await ce.readJson(i$1),l$1=h$2(e);return l$1?(await l(l$1,s$2),{result:"reused",message:"legacy structural baseline migrated and reused"}):{result:"reused",message:"existing structural baseline reused"}}),await n$1("diff",async()=>{let e=await m$1({workspacePath:s$2,fromPath:a.snapshot,model:o$1()});return await n(e,s$2),{message:e.summary.changed?"workspace changes detected":"no workspace changes"}}),await n$1("impact",async()=>{let e=await p$1({workspacePath:s$2,fromPath:a.diff});return await q(e,s$2),{message:`${e.summary.risk} risk; ${e.summary.affectedProjects} affected`}}),await n$1("doctor-evidence",async()=>{let e=await q$1({workspace:s$2,json:true,quiet:true});return {exitCode:e,blocked:e!==0,message:`doctor exit ${e}`}}),await n$1("contract-evidence",async()=>{let e=await r$1({workspacePath:s$2,strict:true});return await s$1({workspacePath:s$2,result:e}),{exitCode:e.status==="passed"?0:1,blocked:e.status!=="passed",message:`contract ${e.status}`}}),await n$1("analyze-evidence",async()=>{let e=await a$2({workspacePath:s$2,json:true,strict:false});return {blocked:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention",exitCode:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention"?1:0,message:`analyze ${e.summary.verdict} (${e.summary.score}/100)`}}),await n$1("readiness-evidence",async()=>{let e=await a$3({startPath:s$2,writeReport:true,skipVerify:true});return {blocked:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn",exitCode:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn"?1:0,message:`pre-verify readiness ${e.overallStatus}`}}),await n$1("verify",async()=>{let e=await f({workspacePath:s$2,fromImpactPath:a.impact});await g$1(e,s$2);let l=h$3(e,{strict:t.strict===true});return await j(s$2,e$1(e,l.passed)),{blocked:!l.passed,exitCode:l.exitCode,message:`${e.summary.verdict}; gate ${l.passed?"passed":"blocked"}`}}),await n$1("context",async()=>{let e=await c({workspacePath:s$2,model:o$1(),agent:t.agent??"generic",includeEvidence:true});return await d(e,s$2),{message:`context grounded for ${e.agent}`}}),await n$1("agent-sync",async()=>({message:`${(await l$1({workspacePath:s$2,agent:t.agent??"generic",write:true,refreshContext:false,strict:false,preset:"enterprise"})).writtenFiles.length} grounding files written`})),await n$1("explain",async()=>{let e=await b$1({workspacePath:s$2,target:{kind:"release-blocked"}});return await c$1(e,s$2),{message:e.summary}});let de=d$1.some(e=>e.status==="blocked"),P=m$2?"failed":de?"blocked":"passed",ue=m$2?1:P==="blocked"?2:0,R={schemaVersion:fe,chainSchemaVersion:a$1,generatedAt:new Date().toISOString(),workspacePath:s$2,baselineCreated:a$4,preflight:u,status:P,exitCode:ue,stages:d$1,artifactPath:le};return ne(R),await e(s$2,le,R),R}export{me as a,fe as b,He as c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {w}from'./chunk-6HJJHEL6.js';import {a as a$1}from'./chunk-GR6442P7.js';import {a as a$2,d,c,e as e$1}from'./chunk-MBRU3VWJ.js';import {b as b$1}from'./chunk-ULR66OJR.js';import {a,b}from'./chunk-62K2H72S.js';import {l}from'./chunk-OCGZNSOE.js';import {e}from'./chunk-RO73VVHW.js';import {s,t,p}from'./chunk-MOSXTVPU.js';import*as g from'path';import g__default from'path';import h from'fs-extra';var ge="unknown-run";function Z(e$1){let t=e();return !t||t===ge?e$1:{...e$1,runId:t}}async function Q(e,t){await h.ensureDir(g.dirname(e));let r=`${e}.${process.pid}.${Date.now()}.tmp`;try{await h.writeJSON(r,t,{spaces:2}),await h.move(r,e,{overwrite:true});}finally{await h.remove(r).catch(()=>{});}}function X(e){return p(e,"imported-projects.json")}async function I(e){let t=(await Promise.all(s(e,"imported-projects.json").map(async r=>await h.pathExists(r)?r:null))).find(r=>typeof r=="string");if(!t)return [];try{let r=await h.readJSON(t);if(!r||typeof r!="object"||r.version!==1||!Array.isArray(r.projects))throw new Error("expected a version 1 registry with a projects array");let o=r.projects,a=o.filter(c=>{if(!c||typeof c!="object")return false;let i=c;return typeof i.name=="string"&&typeof i.path=="string"&&typeof i.stack=="string"&&typeof i.confidence=="string"&&typeof i.importedAt=="string"});if(a.length!==o.length)throw new Error("one or more project entries are invalid");return a}catch(r){throw new Error(`Imported-project registry is invalid: ${t}`,{cause:r})}}async function Ne(e,t){if(t.length===0)return;let r=await I(e),o=new Map;for(let l of r)o.set(l.path,l);for(let l of t)o.set(l.path,l);let a=Array.from(o.values()).sort((l,u)=>l.name.localeCompare(u.name)).map(l=>({...l})),c={version:1,updatedAt:new Date().toISOString(),projects:a},i=X(e);await Q(i,c);}async function De(e,t){if(t.length===0)return;let r=await I(e),o=new Set(t.map(l=>g.resolve(l))),a=r.filter(l=>!o.has(g.resolve(l.path))),c={version:1,updatedAt:new Date().toISOString(),projects:a},i=X(e);await Q(i,c);}var $e="workspace-dependency-graph.v1",ee=["code-import","package-dep","event-pub-sub","service-dependsOn","shared-resource"],te=["inferred","contract","manual"];var E=".workspai/workspace.contract.json",fe=a.contractVerify,R=1,he=b.contractVerify,N=class extends Error{constructor(r){super(`Workspace contract verification failed: ${r.violations.join("; ")}`);this.verification=r;this.name="WorkspaceContractVerificationError";}verification};function se(e){return e.replace(/\\/g,"/")}function H(e){let t=se(e).trim();return !t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0")?false:!t.split("/").filter(Boolean).some(r=>r===".."||r===".")}function re(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,80)||t}function ke(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function we(e){let r=(Array.isArray(e.ports)?e.ports:[]).map(c=>{if(!c||typeof c!="object"||Array.isArray(c))return null;let i=c,l=Number(i.port);if(!Number.isInteger(l)||l<1||l>65535)return null;let u=i.protocol==="https"||i.protocol==="grpc"||i.protocol==="tcp"||i.protocol==="udp"?i.protocol:"http";return {name:typeof i.name=="string"&&i.name.trim()?i.name:"http",port:l,protocol:u}}).filter(c=>c!==null);if(r.length>0)return r;let o=e.frontend&&typeof e.frontend=="object"&&!Array.isArray(e.frontend)?e.frontend:void 0,a=Number(e.port??o?.default_port);return Number.isInteger(a)&&a>=1&&a<=65535?[{name:"http",port:a,protocol:"http"}]:[]}async function D(e){for(let t of e)if(await h.pathExists(t))return t;return null}async function Pe(e){for(let t of s(e,"workspace.json"))try{let r=await h.readJson(t);return {name:typeof r.workspace_name=="string"&&r.workspace_name.trim()||typeof r.name=="string"&&r.name.trim()||g__default.basename(e),profile:typeof r.profile=="string"?r.profile:void 0}}catch{}return {name:g__default.basename(e)}}async function ye(e){let t$1=[],r=[e],o=new Set,a=new Set([".git",".workspai",".rapidkit","node_modules",".venv","venv","dist","build","target",".next",".turbo",".cache"]);for(;r.length>0;){let c=r.shift();if(!c||o.has(c))continue;o.add(c);let i=await D(t(c,"project.json")),l=await D(t(c,"context.json"));if(i||l){t$1.push(i??l??"");continue}let u;try{u=await h.readdir(c,{withFileTypes:true});}catch{continue}for(let d of u)!d.isDirectory()||a.has(d.name)||a$1(d.name)||r.push(g__default.join(c,d.name));}return t$1.sort()}function Ce(e){let t=(e||"").toLowerCase();if(t.includes("fastapi"))return "fastapi";if(t.includes("nestjs"))return "nestjs";if(t.includes("springboot"))return "springboot";if(t.includes("gofiber"))return "fiber";if(t.includes("gogin"))return "gin"}function Ee(e,t){let r=(e||"").toLowerCase(),o=(t||"").toLowerCase();return r.includes("fastapi")?8e3:r.includes("nestjs")?3e3:r.includes("springboot")?8080:r.includes("gofiber")?3e3:r.includes("gogin")?8080:o==="node"?3e3:o==="python"?8e3:o==="java"||o==="go"?8080:null}function oe(e,t){let r=e;for(;t.has(r)&&r<65535;)r+=1;return r}function M(e,t,r){let o=e!==void 0&&e.source===void 0,a=Ee(t.kit,t.runtime),c=e?.ports||[],i=t.ports||[],u=(c.length>0?c:i.length>0?i:a?[{name:"http",port:oe(a,r),protocol:"http"}]:[]).map(p=>({...p,port:oe(p.port,r)}));for(let p of u)r.add(p.port);let d={...t,...e,slug:e?.slug||t.slug,relativePath:o&&e?.relativePath&&H(e.relativePath)?e.relativePath:t.relativePath,source:o&&e?.source||t.source,relationship:o&&e?.relationship||t.relationship,externalPath:o&&e?.externalPath||t.externalPath,runtime:e?.runtime||t.runtime,framework:e?.framework||t.framework,kit:e?.kit||t.kit,modules:e?.modules?.length?e.modules:t.modules,ports:u,contracts:{owns:e?.contracts?.owns||[],apis:e?.contracts?.apis||[],publishes:e?.contracts?.publishes||[],consumes:e?.contracts?.consumes||[],dependsOn:e?.contracts?.dependsOn||[],env:e?.contracts?.env||[]}},s=JSON.stringify(e||null)!==JSON.stringify(d);return {project:d,changed:s}}async function ce(e){let t$1=g__default.resolve(e.workspacePath),r=await Pe(t$1),o=await ye(t$1),a=await I(t$1),c=[];for(let d of a){let s=g__default.resolve(d.path),p=await D(t(s,"project.json"))??await D(t(s,"context.json"));!p||o.some(k=>g__default.resolve(k)===g__default.resolve(p))||c.push({projectJsonPath:p,registryEntry:d});}let i=[],l=[...o.map(d=>({projectJsonPath:d})),...c];for(let{projectJsonPath:d,registryEntry:s}of l){let p=g__default.dirname(g__default.dirname(d)),k=se(g__default.relative(t$1,p)),f=s!==void 0&&!H(k),P=re(s?.name||g__default.basename(p),g__default.basename(p)),y=f?`external/${P}`:k||P,w=await h.readJson(d),x=typeof w.kit_name=="string"&&w.kit_name||typeof w.kit=="string"&&w.kit||void 0,n=typeof w.framework=="string"&&w.framework||Ce(x);i.push({slug:s?.name||y||g__default.basename(p),relativePath:y,source:s?.source??"workspace",relationship:s?.relationship,externalPath:f?p:void 0,runtime:typeof w.runtime=="string"?w.runtime:void 0,framework:n,kit:x,modules:ke(w.modules),ports:we(w),contracts:{owns:[],apis:[],publishes:[],consumes:[],dependsOn:[],env:[]}});}let u=new Map;for(let d of i){let s=re(d.slug,d.relativePath),p=u.get(s);(!p||p.source!=="workspace"&&d.source==="workspace")&&u.set(s,d);}return {schemaVersion:R,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:r,projects:[...u.values()]}}async function et(e){let t=g__default.resolve(e.outputPath||a$2(e.workspacePath,E));if(await h.pathExists(t)&&e.force!==true)throw new Error(`Workspace contract already exists: ${t}. Use --force to overwrite.`);let r=await ce({workspacePath:e.workspacePath,now:e.now}),o=new Set,a={...r,projects:r.projects.map(i=>M(void 0,i,o).project)},c=await de({workspacePath:e.workspacePath,contractPath:t,contract:a});if(e.strict&&c.status==="failed")throw new N(c);return await ie({workspacePath:e.workspacePath,contractPath:t,contract:a,now:e.now}),{contractPath:t,contract:a}}async function tt(e){let t=g__default.resolve(e.workspacePath),r=a$2(t,E),o=await d(t,E)??r,a=await ce({workspacePath:t,now:e.now}),c=await h.pathExists(o)?await h.readJson(o):null,i=new Map((c?.projects||[]).map(f=>[f.slug,f])),l=new Set,u=[],d$1=[],s=[];for(let f of a.projects){let P=i.get(f.slug),y=M(P,f,l);P?y.changed&&d$1.push(f.slug):u.push(f.slug),s.push(y.project),i.delete(f.slug);}for(let f of i.values()){if(f.source)continue;let P=M(f,f,l);s.push(P.project);}let p={schemaVersion:R,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:{...c?.workspace||{},...a.workspace,name:a.workspace.name||c?.workspace?.name||g__default.basename(t)},projects:s.sort((f,P)=>f.slug.localeCompare(P.slug))},k=await de({workspacePath:t,contractPath:r,contract:p});if(e.strict&&k.status==="failed")throw new N(k);return await ie({workspacePath:t,contractPath:r,contract:p,now:e.now}),{contractPath:r,contract:p,addedProjects:u,updatedProjects:d$1,verification:k}}async function ne(e){return await h.pathExists(e)?{exists:true,contents:await h.readFile(e)}:{exists:false}}async function ae(e,t){if(!t.exists){await h.remove(e);return}await h.outputFile(e,t.contents);}async function ie(e){let{buildWorkspaceRegistrySummary:t,WORKSPACE_REGISTRY_SUMMARY_RELATIVE_PATH:r}=await import('./workspace-registry-summary-HOQ3OBNT.js'),o=await t(e.workspacePath,{now:e.now,contract:e.contract}),a=a$2(e.workspacePath,r),c$1=i=>{if(!i||typeof i!="object"||Array.isArray(i))return JSON.stringify(i);let{generatedAt:l,...u}=i;return JSON.stringify(u)};if(await h.pathExists(e.contractPath)&&await h.pathExists(a)){let[i,l]=await Promise.all([h.readJson(e.contractPath),h.readJson(a)]);if(c$1(i)===c$1(e.contract)&&c$1(l)===c$1(o))return}b$1(E,e.contract),b$1(r,o),await c(e.workspacePath,E,async()=>{let[i,l]=await Promise.all([ne(e.contractPath),ne(a)]);try{if(e.contractPath===a$2(e.workspacePath,E)?await e$1(e.workspacePath,E,e.contract):(await h.ensureDir(g__default.dirname(e.contractPath)),await h.writeJson(e.contractPath,e.contract,{spaces:2})),process.env.WORKSPAI_TEST_FAIL_WORKSPACE_REGISTRY_PUBLISH==="1")throw new Error("Injected workspace registry summary publication failure.");await e$1(e.workspacePath,r,o);}catch(u){let s=(await Promise.allSettled([ae(e.contractPath,i),ae(a,l)])).filter(p=>p.status==="rejected");throw s.length>0?new AggregateError([u,...s.map(p=>p.reason)],"Workspace contract publication failed and rollback was incomplete."):u}});}async function pe(e){let t=e.contractPath??(await d(e.workspacePath,E)||a$2(e.workspacePath,E)),r=await h.readJson(t);return {contractPath:t,contract:r}}var je={metadata:[".workspai/project.json",".workspai/context.json",".rapidkit/project.json",".rapidkit/context.json"],manifests:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","pyproject.toml","poetry.lock","requirements.txt","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","Gemfile","composer.json"],entrypoints:["src/main.ts","src/index.ts","src/app.ts","src/main.js","src/index.js","main.py","app/main.py","manage.py","main.go","cmd/main.go","Program.cs"],apiSpecifications:["openapi.yaml","openapi.yml","openapi.json","swagger.yaml","swagger.yml","swagger.json"],infrastructure:["Dockerfile","docker-compose.yml","docker-compose.yaml","compose.yml","compose.yaml","k8s","kubernetes","terraform"],documentation:["README.md","ARCHITECTURE.md","CONTRIBUTING.md","docs"]};function be(e,t){return t.externalPath?g__default.resolve(t.externalPath):g__default.resolve(e,t.relativePath)}async function ve(e){let t={metadata:[],manifests:[],entrypoints:[],apiSpecifications:[],infrastructure:[],documentation:[]};for(let[r,o]of Object.entries(je))for(let a of o)await h.pathExists(g__default.join(e,a))&&t[r].push(a);try{let r=await h.readdir(e,{withFileTypes:true});for(let o of r)o.isFile()&&(o.name.endsWith(".csproj")||o.name.endsWith(".sln"))&&t.manifests.push(o.name),o.isFile()&&o.name.endsWith(".tf")&&t.infrastructure.push(o.name);}catch{}for(let r of Object.values(t))r.sort((o,a)=>o.localeCompare(a));return t}function A(e){return !e||typeof e!="object"||Array.isArray(e)?[]:Object.keys(e).sort((t,r)=>t.localeCompare(r))}async function We(e){try{let t=await h.readJson(g__default.join(e,"package.json")),r={runtime:A(t.dependencies),development:A(t.devDependencies),peer:A(t.peerDependencies),optional:A(t.optionalDependencies)};return {...typeof t.name=="string"?{name:t.name}:{},...typeof t.version=="string"?{version:t.version}:{},...typeof t.private=="boolean"?{private:t.private}:{},scripts:A(t.scripts),dependencies:r,dependencyCount:new Set(Object.values(r).flat()).size}}catch{return}}async function Se(e){for(let t of [".env.example",".env.sample",".env.template"])try{return (await h.readFile(g__default.join(e,t),"utf8")).split(/\r?\n/).map(o=>o.trim()).filter(o=>o.length>0&&!o.startsWith("#")&&o.includes("=")).map(o=>o.slice(0,o.indexOf("=")).trim()).filter(o=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(o)).sort((o,a)=>o.localeCompare(a))}catch{}return []}function Ae(e,t){try{let r=w(e);if(r.engine!=="unknown")return r;let o=h.pathExistsSync(g__default.join(e,"package.json"))?"npm":h.pathExistsSync(g__default.join(e,"pyproject.toml"))?"python":h.pathExistsSync(g__default.join(e,"requirements.txt"))?"pip":"unknown";return {...r,engine:o,runtime:t.runtime??r.runtime,framework:t.framework??r.framework,frameworkDisplayName:t.framework??r.frameworkDisplayName}}catch{return {schemaVersion:1,scope:"project",projectRoot:null,engine:"unknown",runtime:"unknown",framework:"unknown",frameworkDisplayName:"Unknown",frameworkConfidence:"low",frameworkSupportTier:"observed",runtimeSupportTier:"observed",runtimeDoctorSupport:"observed",moduleSupport:false,fleetStages:[],localOnlyCommands:[],commandMap:{},supportedCommands:[],unsupportedCommands:[],globalCommands:[]}}}function Re(e,t,r){let o=e.projects.map(a=>({id:a.slug,path:a.relativePath,runtime:a.runtime,framework:a.framework}));return {schemaVersion:"workspace-dependency-graph.v1",generatedAt:t,nodes:o,edges:[],stats:{nodeCount:o.length,edgeCount:0,inferredEdges:0,contractEdges:0,manualEdges:0,authoritativeEdges:0,lowConfidenceEdges:0,orphanCount:o.length,connectedNodeCount:0,density:0,edgeCoverageRatio:o.length===0?1:0,evidenceCoverageRatio:1,hotspotCount:0,hasCycle:false},diagnostics:[{code:"graph.enrichment.failed",severity:"warning",message:r,recommendation:"Review project manifests and graph overrides, then rerun workspace contract graph."}]}}async function rt(e){let{contractPath:t,contract:r}=await pe(e),o=e.now??new Date,a$1=o.toISOString(),{buildWorkspaceModel:c,workspaceModelProjectTopology:i}=await import('./workspace-model-FJXX3NET.js'),{hashWorkspaceModel:l}=await import('./workspace-model-hash-ZXYPIGCW.js'),u=await c({workspacePath:e.workspacePath,includeEvidence:false,now:o}),d=i(u)??Re(r,a$1,"The canonical Workspace Model did not provide a project dependency topology."),s=new Map(d.nodes.map(n=>[n.id,n.operationalProfile])),{buildWorkspaceKnowledgeGraph:p}=await import('./workspace-knowledge-graph-LEM6X5CM.js'),k=await p({workspacePath:e.workspacePath,workspace:{name:u.workspace.name,...u.workspace.profile?{profile:u.workspace.profile}:{}},contract:r,projectTopology:d,now:o,projects:u.projects.map(n=>({id:n.name,path:n.path,...n.absolutePath?{absolutePath:n.absolutePath}:{},runtime:n.runtime,runtimeCandidates:n.runtimeCandidates,framework:n.framework,...n.kit?{kit:n.kit}:{}})),source:{kind:"workspace-model",artifact:a.model,hashAlgorithm:"sha256",hash:l(u)}}),f=await Promise.all(r.projects.map(async n=>{let m=be(e.workspacePath,n),[_,v,le]=await Promise.all([ve(m),We(m),Se(m)]),C=Ae(m,n);return {id:n.slug,label:n.slug,relativePath:n.relativePath,source:n.source,relationship:n.relationship,externalPath:n.externalPath,runtime:n.runtime??C.runtime,framework:n.framework??C.framework,kit:n.kit,modules:n.modules,ports:n.ports,apis:n.contracts.apis,owns:n.contracts.owns,env:[...new Set([...n.contracts.env,...le])].sort((ue,me)=>ue.localeCompare(me)),contracts:{owns:[...n.contracts.owns],apis:[...n.contracts.apis],publishes:[...n.contracts.publishes],consumes:[...n.contracts.consumes],dependsOn:[...n.contracts.dependsOn],env:[...n.contracts.env]},capabilities:{engine:C.engine,supportTier:C.frameworkSupportTier,runtimeSupportTier:C.runtimeSupportTier,doctorSupport:C.runtimeDoctorSupport,moduleSupport:C.moduleSupport,fleetStages:[...C.fleetStages],localOnlyCommands:[...C.localOnlyCommands],supportedCommands:[...C.supportedCommands]},files:_,...v?{package:v}:{},...s.get(n.slug)?{operationalProfile:s.get(n.slug)}:{}}})),P=new Set(f.map(n=>n.id)),y=new Map,w=[];for(let n of r.projects){for(let m of n.contracts.dependsOn||[])P.has(m)&&w.push({from:m,to:n.slug,type:"dependency",label:"dependsOn"});for(let m of n.contracts.publishes||[])y.has(m)||y.set(m,new Set),y.get(m)?.add(n.slug);}for(let n of r.projects)for(let m of n.contracts.consumes||[]){let _=y.get(m);if(_)for(let v of _)v!==n.slug&&w.push({from:v,to:n.slug,type:"event",label:m});}let x={schemaVersion:1,kind:"rapidkit.workspace.contract.graph",workspace:r.workspace,generatedAt:a$1,nodes:f.sort((n,m)=>n.id.localeCompare(m.id)),edges:w.sort((n,m)=>`${n.from}:${n.to}:${n.type}:${n.label}`.localeCompare(`${m.from}:${m.to}:${m.type}:${m.label}`)),dependencyGraph:d,knowledgeGraph:k,semantics:{legacyEdges:"producer-to-consumer",dependencyGraphEdges:"consumer-to-dependency"},summary:{projectCount:f.length,dependencyEdges:w.filter(n=>n.type==="dependency").length,eventEdges:w.filter(n=>n.type==="event").length,portCount:f.reduce((n,m)=>n+m.ports.length,0),apiCount:f.reduce((n,m)=>n+m.apis.length,0),relationshipEdges:d.stats.edgeCount,inferredEdges:d.stats.inferredEdges,authoritativeEdges:d.stats.authoritativeEdges,orphanProjects:d.stats.orphanCount,hotspotProjects:d.stats.hotspotCount,evidenceCoverageRatio:d.stats.evidenceCoverageRatio,edgeCoverageRatio:d.stats.edgeCoverageRatio,connectedProjects:d.stats.connectedNodeCount,lowConfidenceEdges:d.stats.lowConfidenceEdges,hasCycle:d.stats.hasCycle,manifestCount:f.reduce((n,m)=>n+m.files.manifests.length,0),entrypointCount:f.reduce((n,m)=>n+m.files.entrypoints.length,0),diagnostics:d.diagnostics?.length??0,relationshipKinds:Object.fromEntries(ee.map(n=>[n,d.edges.filter(m=>m.kind===n).length])),relationshipSources:Object.fromEntries(te.map(n=>[n,d.edges.filter(m=>m.source===n).length])),entityCount:k.quality.entityCount,knowledgeRelations:k.quality.relationCount,proofCount:k.quality.proofCount,providerCount:k.providers.length,knowledgeUnknowns:k.quality.unknownCount}};return {contractPath:t,graph:x}}async function de(e){let t=e.contract?{contractPath:e.contractPath??a$2(e.workspacePath,E),contract:e.contract}:await pe(e),{contractPath:r,contract:o}=t,a=[],c=[];o.kind!=="rapidkit.workspace.contract"&&a.push("Contract kind must be rapidkit.workspace.contract."),o.schemaVersion!==R&&a.push(`Contract schemaVersion must be ${R}.`),o.workspace?.name||a.push("Contract workspace.name is required."),Array.isArray(o.projects)||a.push("Contract projects must be an array.");let i=new Set,l$1=new Map;for(let s of o.projects||[]){if(!s.slug){a.push("Every project must declare slug.");continue}i.has(s.slug)&&a.push(`Duplicate project slug: ${s.slug}.`),i.add(s.slug),s.relativePath?H(s.relativePath)||a.push(`Project ${s.slug} declares unsafe relativePath: ${s.relativePath}.`):a.push(`Project ${s.slug} must declare relativePath.`),s.externalPath&&(s.relationship==="adopted"||s.source==="adopted-local"||s.source==="local-folder"||s.source==="git-url"||a.push(`Project ${s.slug} declares externalPath without imported/adopted provenance.`),g__default.isAbsolute(s.externalPath)||a.push(`Project ${s.slug} declares non-absolute externalPath.`));for(let p of s.ports||[]){(!Number.isInteger(p.port)||p.port<1||p.port>65535)&&a.push(`Project ${s.slug} declares invalid port: ${p.port}.`);let k=l$1.get(p.port);k&&a.push(`Port ${p.port} is claimed by both ${k} and ${s.slug}.`),l$1.set(p.port,s.slug);}for(let p of s.contracts?.apis||[])(!p.name?.trim()||!p.basePath?.startsWith("/"))&&a.push(`Project ${s.slug} declares invalid API contract.`);for(let p of [...s.contracts?.publishes||[],...s.contracts?.consumes||[]])p.trim()||a.push(`Project ${s.slug} declares an empty event contract.`);for(let p of s.contracts?.env||[])/^[A-Z_][A-Z0-9_]*$/.test(p)||a.push(`Project ${s.slug} declares invalid env contract: ${p}.`);for(let p of s.contracts?.dependsOn||[])i.has(p);}for(let s of o.projects||[])for(let p of s.contracts?.dependsOn||[])i.has(p)||a.push(`Project ${s.slug} depends on unknown project: ${p}.`);c.push({id:"schema",status:o.kind==="rapidkit.workspace.contract"&&o.schemaVersion===R?"passed":"failed",message:"Contract schema and kind are valid."}),c.push({id:"projects",status:Array.isArray(o.projects)?"passed":"failed",message:`Contract declares ${Array.isArray(o.projects)?o.projects.length:0} project(s).`}),c.push({id:"ports",status:a.some(s=>s.toLowerCase().includes("port"))?"failed":"passed",message:"Project port declarations are valid and collision-free."}),c.push({id:"dependencies",status:a.some(s=>s.includes("depends on unknown project"))?"failed":"passed",message:"Project dependencies point to known project slugs."}),c.push({id:"contracts",status:a.some(s=>s.includes("unsafe relativePath")||s.includes("invalid API contract")||s.includes("event contract")||s.includes("env contract"))?"failed":"passed",message:"Project path, API, event, and env contracts are valid."});let u=await l(e.workspacePath);if(u.moduleCount>0){for(let s of u.issues)a.push(`${g__default.basename(s.projectRoot)}: ${s.message} (slug=${s.slug})`);c.push({id:"module-paths",status:u.status,message:u.status==="passed"?`All ${u.moduleCount} registered module(s) resolve under canonical paths.`:`${u.issues.length} registered module(s) missing canonical install paths.`});}else e.strict&&c.push({id:"module-paths",status:"passed",message:"No registry-backed modules declared in workspace projects."});return {status:a.length>0?"failed":"passed",contractPath:r,projectCount:Array.isArray(o.projects)?o.projects.length:0,checks:c,violations:a}}async function ot(e){let t=g__default.resolve(e.workspacePath),r={schemaVersion:he,generatedAt:e.generatedAt??new Date().toISOString(),status:e.result.status,contractPath:e.result.contractPath,projectCount:e.result.projectCount,checks:e.result.checks,violations:e.result.violations};return e$1(t,fe,Z(r))}
|
|
2
|
+
export{I as a,Ne as b,De as c,Z as d,$e as e,ee as f,E as g,fe as h,R as i,he as j,N as k,ye as l,ce as m,et as n,tt as o,pe as p,rt as q,de as r,ot as s};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {c}from'./chunk-AL237TSJ.js';import {d as d$1,b,a as a$2}from'./chunk-3RBUSW7H.js';import {d}from'./chunk-EWZZUQBR.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {a}from'./chunk-AHLMIL2T.js';import {t,h,g}from'./chunk-MOSXTVPU.js';import z from'crypto';import I from'fs';import k from'fs/promises';import p from'path';import ne from'fs-extra';var oe="project-context-agent.v1",Ie=["managed","local","off"],X="<!-- WORKSPAI:PROJECT-GROUNDING:START -->",q="<!-- WORKSPAI:PROJECT-GROUNDING:END -->";function G(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}async function v(e){try{return JSON.parse(await k.readFile(e,"utf8"))}catch(t){return null}}function E(e){return e.replace(/\\/g,"/").replace(/^\.\/+/,"")}function W(e,t,r){let o=e.replace(/\\/g,"/"),s=/^[A-Za-z]:\//.test(o);if(!p.isAbsolute(e)&&!s)return E(o);if(s&&process.platform!=="win32")return null;let i=p.resolve(e),a=p.relative(r,i);if(a&&!a.startsWith("..")&&!p.isAbsolute(a))return E(a);let c=p.relative(t,i);return c&&!c.startsWith("..")&&!p.isAbsolute(c)?`workspace:${E(c)}`:null}function w(e,t,r){return [[r,"project:"],[r.replace(/\\/g,"/"),"project:"],[t,"workspace:"],[t.replace(/\\/g,"/"),"workspace:"]].reduce((s,[i,a])=>i.length>0?s.split(i).join(a):s,e)}function Z(e,t){return G(e?.adoption)?.mode==="linked"?"adopted":G(e?.import)?"imported":t}function se(e){if(!e.model)return null;let t=E(e.relativePath);return e.model.projects.find(r=>r.name===e.projectName||E(r.path)===t)??null}function B(e,t){e[t]=(e[t]??0)+1;}function ie(e,t){if(!e)return {entityCount:0,relationCount:0,proofCount:0,entitiesByKind:{},relationsByKind:{},relatedProjects:[],proofArtifacts:[],entities:[],relations:[],proofs:[],topology:{status:"unavailable",dependencies:[],dependents:[]},diagnostics:[]};let r=e.entities.find(n=>n.kind==="project"&&(n.id===t||n.label===t||n.projectId===t)),o=new Set(e.entities.filter(n=>n.projectId===t||n.id===r?.id||n.kind==="project"&&n.label===t).map(n=>n.id));r&&o.add(r.id);let s=e.relations.filter(n=>o.has(n.from)||o.has(n.to)),i=new Set(o);for(let n of s)i.add(n.from),i.add(n.to);let a=e.entities.filter(n=>i.has(n.id)),c=new Set,f={},y={};for(let n of a){B(f,n.kind);for(let d of n.proofIds)c.add(d);}for(let n of s){B(y,n.kind);for(let d of n.proofIds)c.add(d);}let m=e.proofs.filter(n=>c.has(n.id)),h=[...new Set(e.entities.filter(n=>i.has(n.id)&&n.projectId&&n.projectId!==t).map(n=>n.projectId))].sort(),j=e.diagnostics.filter(n=>n.entityIds?.some(d=>i.has(d))||n.relationIds?.some(d=>s.some(R=>R.id===d))).map(n=>({code:n.code,severity:n.severity,message:n.message,...n.recommendation?{recommendation:n.recommendation}:{}})),P=(n,d)=>({project:d,kind:n.kind,source:n.source,confidence:n.confidence,evidence:[...new Set(n.evidence.map(R=>R.file.replace(/\\/g,"/")))].sort()}),g=e.projectTopology.edges.filter(n=>n.from===t).map(n=>P(n,n.to)).sort((n,d)=>`${n.project}:${n.kind}`.localeCompare(`${d.project}:${d.kind}`)),u=e.projectTopology.edges.filter(n=>n.to===t).map(n=>P(n,n.from)).sort((n,d)=>`${n.project}:${n.kind}`.localeCompare(`${d.project}:${d.kind}`));return {entityCount:a.length,relationCount:s.length,proofCount:m.length,entitiesByKind:f,relationsByKind:y,relatedProjects:h,proofArtifacts:[...new Set(m.map(n=>n.artifact))].sort(),entities:[...a].sort((n,d)=>n.id.localeCompare(d.id)).slice(0,96),relations:[...s].sort((n,d)=>n.id.localeCompare(d.id)).slice(0,128),proofs:[...m].sort((n,d)=>n.id.localeCompare(d.id)).slice(0,128),topology:{status:g.length>0||u.length>0?"proven":e.projectTopology.nodes.some(n=>n.id===t)?"unproven":"unavailable",dependencies:g,dependents:u},diagnostics:j}}function Q(e,t,r){return Array.isArray(e)?e.map(o=>typeof o=="string"?w(o,t,r):o):typeof e=="string"?w(e,t,r):e}function ae(e,t,r){return {id:e.id,kind:e.kind,label:w(e.label,t,r),attributes:Object.fromEntries(Object.entries(e.attributes).map(([o,s])=>[o,Q(s,t,r)])),proofIds:[...e.proofIds].sort()}}function ce(e,t,r){let o=(...i)=>e.filter(a=>i.includes(a.kind)).map(a=>ae(a,t,r)).slice(0,32),s=[];for(let i of e){for(let[a,c]of Object.entries(i.attributes))if(/(?:^|[-_.])ports?(?:$|[-_.])/i.test(a)&&(s.push({entityId:i.id,label:w(i.label,t,r),attribute:a,value:Q(c,t,r)}),s.length>=32))break;if(s.length>=32)break}return {services:o("service"),apis:o("api"),endpoints:o("endpoint"),dataStores:o("database","queue"),deployments:o("container","deployment","environment"),pipelines:o("pipeline"),tests:o("test-suite"),owners:o("owner"),decisions:o("decision"),ports:s}}function le(e,t,r){let o=W(e.artifact,t,r);return o?{id:e.id,provider:e.provider,artifact:o,...e.pointer?{pointer:w(e.pointer,t,r)}:{},...e.line!==void 0?{line:e.line}:{},derivation:e.derivation,trust:e.trust,confidence:e.confidence,freshness:e.freshness}:null}async function pe(e,t,r){let o=[],s=await v(p.join(e,".workspai","reports","INDEX.json"));if(Array.isArray(s?.blockers))for(let a of s.blockers)typeof a=="string"&&(a.startsWith(`${r}:`)||a.includes(`project:${r}`)||a.includes(`project ${r}`))&&o.push({source:"workspace-report-index",severity:"error",message:w(a,e,t)});let i=await v(p.join(e,".workspai","reports","doctor-project-last-run.json"));if(i?.projectName===r){if(Array.isArray(i.project?.issues))for(let a of i.project.issues)typeof a=="string"&&o.push({source:"doctor-project",severity:"error",message:w(a,e,t)});if(Array.isArray(i.project?.probes))for(let a of i.project.probes){let c=G(a);if(!c||!["fail","warn"].includes(String(c.status)))continue;let f=typeof c.reason=="string"?c.reason:typeof c.label=="string"?c.label:"Project Doctor reported unresolved evidence.";o.push({source:"doctor-project",severity:c.status==="fail"?"error":"warning",message:w(f,e,t),...typeof c.id=="string"?{code:c.id}:{}});}}return [...new Map(o.map(a=>[`${a.source}:${a.code??""}:${a.message}`,a])).values()].slice(0,32)}function O(e,t=[]){return typeof e=="string"?/^[A-Za-z]:[\\/]/.test(e)||/(?:^|[\s("'`])[A-Za-z]:[\\/]/.test(e)||/(?:^|[\s("'`])\/(?:Users|home|private|var|opt|srv|mnt|Volumes|tmp)\//.test(e)||t.some(r=>r.length>0&&(e.includes(r)||e.includes(r.replace(/\\/g,"/")))):Array.isArray(e)?e.some(r=>O(r,t)):e&&typeof e=="object"?Object.values(e).some(r=>O(r,t)):false}function de(e){return z.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function ge(e){let t$1=p.resolve(e.workspacePath),r=p.resolve(e.projectPath),o=t(r,"project.json").find(l=>I.existsSync(l)),s=o?await v(o):null,i=await v(p.join(t$1,".workspai","workspace.contract.json")),a$2=p.resolve(r),c=i?.projects?.find(l=>l.externalPath?p.resolve(l.externalPath)===a$2:!l.relativePath||l.relativePath.startsWith("external/")?false:p.resolve(t$1,l.relativePath)===a$2)??i?.projects?.find(l=>l.slug===e.projectName||l.slug===p.basename(r)),f=e.projectName??(typeof s?.name=="string"?s.name:void 0)??c?.slug??p.basename(r),y=c?.relativePath??(()=>{let l=E(p.relative(t$1,r));return !l||l.startsWith("..")?`external/${f}`:l})(),m=await v(p.join(t$1,a.model)),h=await v(p.join(t$1,a.knowledgeGraph)),j=m?d(m):void 0,P=!!(j&&h?.source.hash===j),g=se({model:m,projectName:f,relativePath:y}),u=ie(P?h:null,f),n=await pe(t$1,r,f),d$1=u.proofs.map(l=>l.freshness),R=h?!P||d$1.includes("stale")?"stale":d$1.includes("unknown")?"unknown":"fresh":"missing",ee=m?m.factFreshness?.status??"unknown":"missing",te=[...m?[]:[{code:"project.context.model-missing",severity:"warning",message:"The canonical Workspace Model has not been generated yet. Refresh workspace intelligence before relying on project topology."}],...m&&!g?[{code:"project.context.project-not-materialized",severity:"warning",message:"The project is registered in the workspace contract but is not present in the current Workspace Model."}]:[],...h?[]:[{code:"project.context.graph-missing",severity:"warning",message:"The Workspace Knowledge Graph has not been generated yet. Run the workspace intelligence loop to build proof-backed relationships."}],...h&&!P?[{code:"project.context.graph-model-mismatch",severity:"warning",message:"The persisted Knowledge Graph does not match the current Workspace Model and was excluded from this project lens."}]:[]],re=Z(s,e.relationship??c?.relationship??"managed"),N={schemaVersion:oe,generatedAt:(e.now??new Date).toISOString(),workspace:{name:i?.workspace?.name??m?.workspace.name??p.basename(t$1),...i?.workspace?.profile||m?.workspace.profile?{profile:i?.workspace?.profile??m?.workspace.profile}:{},relationship:re,contract:".workspai/workspace.contract.json",model:a.model,knowledgeGraph:a.knowledgeGraph,access:{localBinding:".workspai/workspace-link.local.json",canonicalEvidenceAvailableAtGeneration:true}},project:{name:f,relativePath:y,...g?.kind?{kind:g.kind}:{},...g?.runtime||c?.runtime?{runtime:g?.runtime??c?.runtime}:{},...g?.framework||c?.framework?{framework:g?.framework??c?.framework}:{},...g?.kit||c?.kit?{kit:g?.kit??c?.kit}:{},...g?.supportTier?{supportTier:g.supportTier}:{},commands:{supported:[...g?.commands.supported??[]].sort(),unsupported:[...g?.commands.unsupported??[]].sort(),fleetStages:[...g?.commands.fleetStages??[]].sort()},importantFiles:[...new Set((g?.importantFiles??[]).map(l=>W(l,t$1,r)).filter(l=>l!==null))].sort()},intelligence:{...m?.generatedAt?{modelGeneratedAt:m.generatedAt}:{},...h?.generatedAt?{graphGeneratedAt:h.generatedAt}:{},...h?.source.hash?{graphModelHash:h.source.hash}:{},entityCount:u.entityCount,relationCount:u.relationCount,proofCount:u.proofCount,entitiesByKind:u.entitiesByKind,relationsByKind:u.relationsByKind,relatedProjects:u.relatedProjects,freshness:{model:ee,graph:R,graphMatchesModel:P},topology:{...u.topology,dependencies:u.topology.dependencies.map(l=>({...l,evidence:l.evidence.map(b=>W(b,t$1,r)).filter(b=>b!==null)})),dependents:u.topology.dependents.map(l=>({...l,evidence:l.evidence.map(b=>W(b,t$1,r)).filter(b=>b!==null)}))},surfaces:ce(u.entities,t$1,r),diagnostics:[...te,...u.diagnostics].map(l=>({...l,message:w(l.message,t$1,r),...l.recommendation?{recommendation:w(l.recommendation,t$1,r)}:{}}))},evidence:{readOrder:[".workspai/PROJECT-GROUNDING.md",".workspai/reports/project-context-agent.json","AGENTS.md","workspace:.workspai/reports/INDEX.json","workspace:.workspai/reports/workspace-context-agent.json",`workspace:${a.model}`,`workspace:${a.knowledgeGraph}`],projectProofArtifacts:[...new Set(u.proofArtifacts.map(l=>W(l,t$1,r)).filter(l=>l!==null))],relations:u.relations.map(l=>({id:l.id,from:l.from,to:l.to,kind:l.kind,derivation:l.derivation,trust:l.trust,confidence:l.confidence,proofIds:[...l.proofIds].sort()})),proofs:u.proofs.map(l=>le(l,t$1,r)).filter(l=>l!==null)},blockers:n,commands:{refresh:"npx workspai workspace intelligence run --for-agent generic --strict --json",verify:"npx workspai workspace verify --strict --json",graphSearch:`npx workspai workspace graph search ${JSON.stringify(f)} --limit 12 --json`,doctor:"npx workspai doctor project --json",workspaceStatus:"npx workspai project workspace status --json"}};if(O(N,[t$1,r]))throw new Error("Project context lens rejected a non-portable absolute path.");let L={...N,integrity:{algorithm:"sha256",...j?{modelHash:j}:{},payloadHash:de(N),portable:true,absolutePathsEmitted:false}};return a$1(L,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent"),L}function ue(e){let t=e.intelligence.relatedProjects.length>0?e.intelligence.relatedProjects.map(s=>`\`${s}\``).join(", "):"No proven cross-project relation is currently available.",r=e.intelligence.diagnostics.length>0?e.intelligence.diagnostics.slice(0,8).map(s=>`- **${s.severity} \xB7 ${s.code}:** ${s.message}`).join(`
|
|
1
|
+
import {c}from'./chunk-AL237TSJ.js';import {d as d$1,b,a as a$2}from'./chunk-3RBUSW7H.js';import {d}from'./chunk-EWZZUQBR.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {a}from'./chunk-62K2H72S.js';import {t,h,g}from'./chunk-MOSXTVPU.js';import z from'crypto';import I from'fs';import k from'fs/promises';import p from'path';import ne from'fs-extra';var oe="project-context-agent.v1",Ie=["managed","local","off"],X="<!-- WORKSPAI:PROJECT-GROUNDING:START -->",q="<!-- WORKSPAI:PROJECT-GROUNDING:END -->";function G(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}async function v(e){try{return JSON.parse(await k.readFile(e,"utf8"))}catch(t){return null}}function E(e){return e.replace(/\\/g,"/").replace(/^\.\/+/,"")}function W(e,t,r){let o=e.replace(/\\/g,"/"),s=/^[A-Za-z]:\//.test(o);if(!p.isAbsolute(e)&&!s)return E(o);if(s&&process.platform!=="win32")return null;let i=p.resolve(e),a=p.relative(r,i);if(a&&!a.startsWith("..")&&!p.isAbsolute(a))return E(a);let c=p.relative(t,i);return c&&!c.startsWith("..")&&!p.isAbsolute(c)?`workspace:${E(c)}`:null}function w(e,t,r){return [[r,"project:"],[r.replace(/\\/g,"/"),"project:"],[t,"workspace:"],[t.replace(/\\/g,"/"),"workspace:"]].reduce((s,[i,a])=>i.length>0?s.split(i).join(a):s,e)}function Z(e,t){return G(e?.adoption)?.mode==="linked"?"adopted":G(e?.import)?"imported":t}function se(e){if(!e.model)return null;let t=E(e.relativePath);return e.model.projects.find(r=>r.name===e.projectName||E(r.path)===t)??null}function B(e,t){e[t]=(e[t]??0)+1;}function ie(e,t){if(!e)return {entityCount:0,relationCount:0,proofCount:0,entitiesByKind:{},relationsByKind:{},relatedProjects:[],proofArtifacts:[],entities:[],relations:[],proofs:[],topology:{status:"unavailable",dependencies:[],dependents:[]},diagnostics:[]};let r=e.entities.find(n=>n.kind==="project"&&(n.id===t||n.label===t||n.projectId===t)),o=new Set(e.entities.filter(n=>n.projectId===t||n.id===r?.id||n.kind==="project"&&n.label===t).map(n=>n.id));r&&o.add(r.id);let s=e.relations.filter(n=>o.has(n.from)||o.has(n.to)),i=new Set(o);for(let n of s)i.add(n.from),i.add(n.to);let a=e.entities.filter(n=>i.has(n.id)),c=new Set,f={},y={};for(let n of a){B(f,n.kind);for(let d of n.proofIds)c.add(d);}for(let n of s){B(y,n.kind);for(let d of n.proofIds)c.add(d);}let m=e.proofs.filter(n=>c.has(n.id)),h=[...new Set(e.entities.filter(n=>i.has(n.id)&&n.projectId&&n.projectId!==t).map(n=>n.projectId))].sort(),j=e.diagnostics.filter(n=>n.entityIds?.some(d=>i.has(d))||n.relationIds?.some(d=>s.some(R=>R.id===d))).map(n=>({code:n.code,severity:n.severity,message:n.message,...n.recommendation?{recommendation:n.recommendation}:{}})),P=(n,d)=>({project:d,kind:n.kind,source:n.source,confidence:n.confidence,evidence:[...new Set(n.evidence.map(R=>R.file.replace(/\\/g,"/")))].sort()}),g=e.projectTopology.edges.filter(n=>n.from===t).map(n=>P(n,n.to)).sort((n,d)=>`${n.project}:${n.kind}`.localeCompare(`${d.project}:${d.kind}`)),u=e.projectTopology.edges.filter(n=>n.to===t).map(n=>P(n,n.from)).sort((n,d)=>`${n.project}:${n.kind}`.localeCompare(`${d.project}:${d.kind}`));return {entityCount:a.length,relationCount:s.length,proofCount:m.length,entitiesByKind:f,relationsByKind:y,relatedProjects:h,proofArtifacts:[...new Set(m.map(n=>n.artifact))].sort(),entities:[...a].sort((n,d)=>n.id.localeCompare(d.id)).slice(0,96),relations:[...s].sort((n,d)=>n.id.localeCompare(d.id)).slice(0,128),proofs:[...m].sort((n,d)=>n.id.localeCompare(d.id)).slice(0,128),topology:{status:g.length>0||u.length>0?"proven":e.projectTopology.nodes.some(n=>n.id===t)?"unproven":"unavailable",dependencies:g,dependents:u},diagnostics:j}}function Q(e,t,r){return Array.isArray(e)?e.map(o=>typeof o=="string"?w(o,t,r):o):typeof e=="string"?w(e,t,r):e}function ae(e,t,r){return {id:e.id,kind:e.kind,label:w(e.label,t,r),attributes:Object.fromEntries(Object.entries(e.attributes).map(([o,s])=>[o,Q(s,t,r)])),proofIds:[...e.proofIds].sort()}}function ce(e,t,r){let o=(...i)=>e.filter(a=>i.includes(a.kind)).map(a=>ae(a,t,r)).slice(0,32),s=[];for(let i of e){for(let[a,c]of Object.entries(i.attributes))if(/(?:^|[-_.])ports?(?:$|[-_.])/i.test(a)&&(s.push({entityId:i.id,label:w(i.label,t,r),attribute:a,value:Q(c,t,r)}),s.length>=32))break;if(s.length>=32)break}return {services:o("service"),apis:o("api"),endpoints:o("endpoint"),dataStores:o("database","queue"),deployments:o("container","deployment","environment"),pipelines:o("pipeline"),tests:o("test-suite"),owners:o("owner"),decisions:o("decision"),ports:s}}function le(e,t,r){let o=W(e.artifact,t,r);return o?{id:e.id,provider:e.provider,artifact:o,...e.pointer?{pointer:w(e.pointer,t,r)}:{},...e.line!==void 0?{line:e.line}:{},derivation:e.derivation,trust:e.trust,confidence:e.confidence,freshness:e.freshness}:null}async function pe(e,t,r){let o=[],s=await v(p.join(e,".workspai","reports","INDEX.json"));if(Array.isArray(s?.blockers))for(let a of s.blockers)typeof a=="string"&&(a.startsWith(`${r}:`)||a.includes(`project:${r}`)||a.includes(`project ${r}`))&&o.push({source:"workspace-report-index",severity:"error",message:w(a,e,t)});let i=await v(p.join(e,".workspai","reports","doctor-project-last-run.json"));if(i?.projectName===r){if(Array.isArray(i.project?.issues))for(let a of i.project.issues)typeof a=="string"&&o.push({source:"doctor-project",severity:"error",message:w(a,e,t)});if(Array.isArray(i.project?.probes))for(let a of i.project.probes){let c=G(a);if(!c||!["fail","warn"].includes(String(c.status)))continue;let f=typeof c.reason=="string"?c.reason:typeof c.label=="string"?c.label:"Project Doctor reported unresolved evidence.";o.push({source:"doctor-project",severity:c.status==="fail"?"error":"warning",message:w(f,e,t),...typeof c.id=="string"?{code:c.id}:{}});}}return [...new Map(o.map(a=>[`${a.source}:${a.code??""}:${a.message}`,a])).values()].slice(0,32)}function O(e,t=[]){return typeof e=="string"?/^[A-Za-z]:[\\/]/.test(e)||/(?:^|[\s("'`])[A-Za-z]:[\\/]/.test(e)||/(?:^|[\s("'`])\/(?:Users|home|private|var|opt|srv|mnt|Volumes|tmp)\//.test(e)||t.some(r=>r.length>0&&(e.includes(r)||e.includes(r.replace(/\\/g,"/")))):Array.isArray(e)?e.some(r=>O(r,t)):e&&typeof e=="object"?Object.values(e).some(r=>O(r,t)):false}function de(e){return z.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function ge(e){let t$1=p.resolve(e.workspacePath),r=p.resolve(e.projectPath),o=t(r,"project.json").find(l=>I.existsSync(l)),s=o?await v(o):null,i=await v(p.join(t$1,".workspai","workspace.contract.json")),a$2=p.resolve(r),c=i?.projects?.find(l=>l.externalPath?p.resolve(l.externalPath)===a$2:!l.relativePath||l.relativePath.startsWith("external/")?false:p.resolve(t$1,l.relativePath)===a$2)??i?.projects?.find(l=>l.slug===e.projectName||l.slug===p.basename(r)),f=e.projectName??(typeof s?.name=="string"?s.name:void 0)??c?.slug??p.basename(r),y=c?.relativePath??(()=>{let l=E(p.relative(t$1,r));return !l||l.startsWith("..")?`external/${f}`:l})(),m=await v(p.join(t$1,a.model)),h=await v(p.join(t$1,a.knowledgeGraph)),j=m?d(m):void 0,P=!!(j&&h?.source.hash===j),g=se({model:m,projectName:f,relativePath:y}),u=ie(P?h:null,f),n=await pe(t$1,r,f),d$1=u.proofs.map(l=>l.freshness),R=h?!P||d$1.includes("stale")?"stale":d$1.includes("unknown")?"unknown":"fresh":"missing",ee=m?m.factFreshness?.status??"unknown":"missing",te=[...m?[]:[{code:"project.context.model-missing",severity:"warning",message:"The canonical Workspace Model has not been generated yet. Refresh workspace intelligence before relying on project topology."}],...m&&!g?[{code:"project.context.project-not-materialized",severity:"warning",message:"The project is registered in the workspace contract but is not present in the current Workspace Model."}]:[],...h?[]:[{code:"project.context.graph-missing",severity:"warning",message:"The Workspace Knowledge Graph has not been generated yet. Run the workspace intelligence loop to build proof-backed relationships."}],...h&&!P?[{code:"project.context.graph-model-mismatch",severity:"warning",message:"The persisted Knowledge Graph does not match the current Workspace Model and was excluded from this project lens."}]:[]],re=Z(s,e.relationship??c?.relationship??"managed"),N={schemaVersion:oe,generatedAt:(e.now??new Date).toISOString(),workspace:{name:i?.workspace?.name??m?.workspace.name??p.basename(t$1),...i?.workspace?.profile||m?.workspace.profile?{profile:i?.workspace?.profile??m?.workspace.profile}:{},relationship:re,contract:".workspai/workspace.contract.json",model:a.model,knowledgeGraph:a.knowledgeGraph,access:{localBinding:".workspai/workspace-link.local.json",canonicalEvidenceAvailableAtGeneration:true}},project:{name:f,relativePath:y,...g?.kind?{kind:g.kind}:{},...g?.runtime||c?.runtime?{runtime:g?.runtime??c?.runtime}:{},...g?.framework||c?.framework?{framework:g?.framework??c?.framework}:{},...g?.kit||c?.kit?{kit:g?.kit??c?.kit}:{},...g?.supportTier?{supportTier:g.supportTier}:{},commands:{supported:[...g?.commands.supported??[]].sort(),unsupported:[...g?.commands.unsupported??[]].sort(),fleetStages:[...g?.commands.fleetStages??[]].sort()},importantFiles:[...new Set((g?.importantFiles??[]).map(l=>W(l,t$1,r)).filter(l=>l!==null))].sort()},intelligence:{...m?.generatedAt?{modelGeneratedAt:m.generatedAt}:{},...h?.generatedAt?{graphGeneratedAt:h.generatedAt}:{},...h?.source.hash?{graphModelHash:h.source.hash}:{},entityCount:u.entityCount,relationCount:u.relationCount,proofCount:u.proofCount,entitiesByKind:u.entitiesByKind,relationsByKind:u.relationsByKind,relatedProjects:u.relatedProjects,freshness:{model:ee,graph:R,graphMatchesModel:P},topology:{...u.topology,dependencies:u.topology.dependencies.map(l=>({...l,evidence:l.evidence.map(b=>W(b,t$1,r)).filter(b=>b!==null)})),dependents:u.topology.dependents.map(l=>({...l,evidence:l.evidence.map(b=>W(b,t$1,r)).filter(b=>b!==null)}))},surfaces:ce(u.entities,t$1,r),diagnostics:[...te,...u.diagnostics].map(l=>({...l,message:w(l.message,t$1,r),...l.recommendation?{recommendation:w(l.recommendation,t$1,r)}:{}}))},evidence:{readOrder:[".workspai/PROJECT-GROUNDING.md",".workspai/reports/project-context-agent.json","AGENTS.md","workspace:.workspai/reports/INDEX.json","workspace:.workspai/reports/workspace-context-agent.json",`workspace:${a.model}`,`workspace:${a.knowledgeGraph}`],projectProofArtifacts:[...new Set(u.proofArtifacts.map(l=>W(l,t$1,r)).filter(l=>l!==null))],relations:u.relations.map(l=>({id:l.id,from:l.from,to:l.to,kind:l.kind,derivation:l.derivation,trust:l.trust,confidence:l.confidence,proofIds:[...l.proofIds].sort()})),proofs:u.proofs.map(l=>le(l,t$1,r)).filter(l=>l!==null)},blockers:n,commands:{refresh:"npx workspai workspace intelligence run --for-agent generic --strict --json",verify:"npx workspai workspace verify --strict --json",graphSearch:`npx workspai workspace graph search ${JSON.stringify(f)} --limit 12 --json`,doctor:"npx workspai doctor project --json",workspaceStatus:"npx workspai project workspace status --json"}};if(O(N,[t$1,r]))throw new Error("Project context lens rejected a non-portable absolute path.");let L={...N,integrity:{algorithm:"sha256",...j?{modelHash:j}:{},payloadHash:de(N),portable:true,absolutePathsEmitted:false}};return a$1(L,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent"),L}function ue(e){let t=e.intelligence.relatedProjects.length>0?e.intelligence.relatedProjects.map(s=>`\`${s}\``).join(", "):"No proven cross-project relation is currently available.",r=e.intelligence.diagnostics.length>0?e.intelligence.diagnostics.slice(0,8).map(s=>`- **${s.severity} \xB7 ${s.code}:** ${s.message}`).join(`
|
|
2
2
|
`):"- No project-scoped graph diagnostic is currently recorded.",o=e.blockers.length>0?e.blockers.slice(0,12).map(s=>`- **${s.severity}${s.code?` \xB7 ${s.code}`:""}:** ${s.message}`).join(`
|
|
3
3
|
`):"- No current project-scoped blocker is recorded.";return `# Workspai project grounding
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {d,b as b$1,e}from'./chunk-BG4FWJJ3.js';import {d as d$2}from'./chunk-S5KTATOU.js';import {a}from'./chunk-2D4UOYOJ.js';import {p as p$1,w,t as t$1}from'./chunk-TROHVI2V.js';import {h,j,f,e as e$1}from'./chunk-L2E2Z4OE.js';import {d as d$1}from'./chunk-XBM2P45G.js';import {a as a$1}from'./chunk-TQEMLBAG.js';import {t,p,s}from'./chunk-MOSXTVPU.js';import {e as e$2,g}from'./chunk-RJIYCDVC.js';import _ from'fs';import b from'path';import E from'chalk';import {execa}from'execa';function Se(e){return _.existsSync(b.join(e,"bun.lock"))||_.existsSync(b.join(e,"bunfig.toml"))?"bun":_.existsSync(b.join(e,"pnpm-lock.yaml"))?"pnpm":_.existsSync(b.join(e,"yarn.lock"))?"yarn":(_.existsSync(b.join(e,"package-lock.json")),"npm")}function Ee(e,t,r=Se(e)){return r==="npm"?`npm run ${t}`:`${r} run ${t}`}function Ce(e,t=Se(e)){return `${t} install`}var Ge={"python-fastapi":{runtime:"python",framework:"FastAPI",markers:["pyproject.toml","fastapi"],commands:{init:"python -m pip install -e .",test:"pytest",build:"python -m build",start:"uvicorn main:app --reload"},errorPatterns:{setup:["ModuleNotFoundError","No module named","pip: command not found"],"test-failure":["FAILED","ERROR","test session started"],dependency:["ImportError","missing.*dependency"],runtime:["TypeError","AttributeError","ValueError"],timeout:["timeout","Timeout","timed out"],unknown:[]},healthCheck:{stage:"start",type:"http",value:"http://localhost:8000/docs"},validation:{command:"python -m pip list | grep fastapi",error:"FastAPI not installed"}},"python-django":{runtime:"python",framework:"Django",markers:["manage.py","django"],commands:{init:"python manage.py migrate",test:"python manage.py test",build:"python manage.py collectstatic --noinput",start:"python manage.py runserver 0.0.0.0:8000"},errorPatterns:{setup:["ModuleNotFoundError","ProgrammingError.*migrate"],"test-failure":["FAILED","ERROR","Ran.*test"],dependency:["ImportError","missing.*dependency"],runtime:["DatabaseError","ImproperlyConfigured"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"node-nestjs":{runtime:"node",framework:"NestJS",markers:["package.json","@nestjs/core"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm run start"},errorPatterns:{setup:["npm ERR!","ENOENT","not found"],"test-failure":["Tests.*failed","FAIL","fail.*test"],dependency:["Cannot find module","ERR_MODULE_NOT_FOUND"],runtime:["TypeError","Error: ","ReferenceError"],timeout:["timeout","TIMEOUT"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3}},"node-express":{runtime:"node",framework:"Express",markers:["package.json","express"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm start"},errorPatterns:{setup:["npm ERR!","ENOENT"],"test-failure":["failed","FAIL"],dependency:["Cannot find module"],runtime:["Error","TypeError"],timeout:["timeout"],unknown:[]}},"go-fiber":{runtime:"go",framework:"Fiber",markers:["go.mod","fiber"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found","cannot find","go mod tidy"],"test-failure":["FAIL","--- FAIL"],dependency:["missing.*module"],runtime:["panic","fatal","Error"],timeout:["timeout","context deadline"],unknown:[]},dependencies:["init"]},"go-gin":{runtime:"go",framework:"Gin",markers:["go.mod","gin-gonic"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found"],"test-failure":["FAIL"],dependency:["missing.*module"],runtime:["panic"],timeout:["timeout"],unknown:[]}},"java-springboot":{runtime:"java",framework:"Spring Boot",markers:["pom.xml","build.gradle","spring-boot"],commands:{init:"mvn dependency:go-offline",test:"mvn test",build:"mvn package -DskipTests",start:"mvn spring-boot:run"},errorPatterns:{setup:["\\[ERROR\\]","BUILD FAILURE","missing dependencies"],"test-failure":["\\[ERROR\\] Tests run:","BUILD FAILURE"],dependency:["missing.*dependency"],runtime:["Exception","Error","NullPointerException"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8080}},"php-laravel":{runtime:"php",framework:"Laravel",markers:["composer.json","artisan","app/Models"],commands:{init:"composer install && php artisan migrate:fresh --seed",test:"php artisan test",build:"php artisan config:cache && php artisan route:cache && php artisan view:cache",start:"php artisan serve --host=0.0.0.0 --port=8000"},errorPatterns:{setup:["Composer.*lock","Fatal error","Class.*not found"],"test-failure":["FAILED","Tests.*failed"],dependency:["Class.*not found","require.*failed"],runtime:["Fatal error","Exception","Error"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"php-symfony":{runtime:"php",framework:"Symfony",markers:["composer.json","symfony.lock","bin/console"],commands:{init:"composer install && php bin/console doctrine:database:create",test:"php bin/phpunit",build:"php bin/console cache:clear --env=prod",start:"symfony serve --no-tls"},errorPatterns:{setup:["Composer.*error","Fatal error"],"test-failure":["FAILED","failure"],dependency:["Class.*not found"],runtime:["Fatal error","Exception"],timeout:["timeout"],unknown:[]},dependencies:["init"]},"rust-actix":{runtime:"rust",framework:"Actix-web",markers:["Cargo.toml","actix"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find","failed.*download"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E","thread.*panicked"],timeout:["timeout"],unknown:[]},validation:{command:"cargo --version",error:"Rust/Cargo not installed"}},"rust-axum":{runtime:"rust",framework:"Axum",markers:["Cargo.toml","axum"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"rust-rocket":{runtime:"rust",framework:"Rocket",markers:["Cargo.toml","rocket"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["FAILED"],dependency:["can.t find"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"dotnet-aspnetcore":{runtime:"dotnet",framework:"ASP.NET Core",markers:[".csproj",".sln","Program.cs"],commands:{init:"dotnet restore",test:"dotnet test",build:"dotnet build -c Release",start:"dotnet run"},errorPatterns:{setup:["error CS","CSPROJ.*not found","NuGet.*restore"],"test-failure":["Failed:.*test","FAILED"],dependency:["error NU1101"],runtime:["error CS","Exception"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:5e3}},"elixir-phoenix":{runtime:"elixir",framework:"Phoenix",markers:["mix.exs","phoenix"],commands:{init:"mix setup",test:"mix test",build:"mix compile --all-warnings",start:"mix phx.server"},errorPatterns:{setup:["\\*\\* \\(.*Error\\)","Mix.InstallError"],"test-failure":["\\d+\\sfailed","FAILED"],dependency:["dependencies are not available"],runtime:["\\*\\* \\(","RuntimeError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:4e3},dependencies:["init"]},"ruby-rails":{runtime:"ruby",framework:"Rails",markers:["Gemfile","config/application.rb","bin/rails"],commands:{init:"bundle install && rails db:prepare",test:"rails test",build:"rails assets:precompile",start:"rails server --binding=0.0.0.0 --port=3000"},errorPatterns:{setup:["Bundler::.*Error","Gem::.*Error"],"test-failure":["failures,","error,","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","Exception","NoMethodError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3},dependencies:["init"]},"ruby-sinatra":{runtime:"ruby",framework:"Sinatra",markers:["Gemfile","app.rb","sinatra"],commands:{init:"bundle install",test:"rspec",build:`echo "Sinatra apps don't require build"`,start:"ruby app.rb"},errorPatterns:{setup:["Bundler.*Error","Gem.*Error"],"test-failure":["failure","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","NoMethodError"],timeout:["timeout"],unknown:[]}}},Be={init:{python:["pip install -e .","poetry install","pip install -r requirements.txt"],node:["npm install","pnpm install","yarn install"],go:["go mod download && go mod tidy","go get ./..."],java:["mvn dependency:go-offline","gradle dependencies"],php:["composer install"],rust:["cargo fetch"],dotnet:["dotnet restore"],elixir:["mix deps.get"],ruby:["bundle install"],"jvm-generic":["mvn dependency:go-offline","gradle dependencies"],unknown:[]},test:{python:["pytest","python -m unittest","python -m pytest"],node:["npm test","npm run test"],go:["go test ./...","make test"],java:["mvn test","gradle test"],php:["php artisan test","phpunit","pest"],rust:["cargo test"],dotnet:["dotnet test"],elixir:["mix test"],ruby:["rspec","ruby -m minitest"],"jvm-generic":["mvn test","gradle test"],unknown:[]},build:{python:["python -m build","python setup.py build"],node:["npm run build"],go:["go build -o app .","go build ./..."],java:["mvn package -DskipTests","gradle build -x test"],php:['echo "PHP build: typically no build step"'],rust:["cargo build --release"],dotnet:["dotnet build -c Release"],elixir:["mix compile"],ruby:["gem build *.gemspec"],"jvm-generic":["mvn package -DskipTests","gradle build"],unknown:[]},start:{python:["python app.py","python main.py","uvicorn main:app --reload"],node:["npm start","node index.js","node src/index.js"],go:["./app","go run main.go","go run ./..."],java:["mvn spring-boot:run","gradle bootRun","java -jar target/*.jar"],php:["php -S 0.0.0.0:8000","php artisan serve"],rust:["cargo run --release","./target/release/app"],dotnet:["dotnet run"],elixir:["mix phx.server","iex -S mix"],ruby:["rails server","ruby app.rb","bundle exec puma"],"jvm-generic":["java -jar *.jar","gradle run"],unknown:[]}};function se(e,t){if(t){let r=t.trim().toLowerCase().replace(/[_.\s]+/g,"-"),n=e$1(t),s=`${e}-${n==="gofiber"?"fiber":n==="gogin"?"gin":n==="dotnet"?"aspnetcore":n!=="unknown"?n:r==="fiber"?"fiber":r==="aspnetcore"||r==="asp-net-core"?"aspnetcore":r}`;return Ge[s]}}function Pe(e,t,r){if(t){let n=se(e,t);if(n&&n.commands[r])return n.commands[r]}if(["init","test","build","start"].includes(r)){let n=Be[r]?.[e]??[];return n.length>0?n[0]:void 0}}var ze={test:"test",build:"build",start:"start"};function ae(e){if(e.stage==="init")return e.runtime==="node"?Ce(e.projectPath):Pe(e.runtime,e.framework,e.stage);if(e.runtime==="node"){let t=ze[e.stage];if(t){let r=t$1(e.projectPath,t,{framework:e.framework});if(r)return Ee(e.projectPath,r.scriptName)}}return Pe(e.runtime,e.framework,e.stage)}function Ke(e){let t=h(e).map(r=>r==="python"?"python":r==="node"||r==="bun"?"node":r==="go"?"go":r==="java"?"java":r==="php"?"php":r==="rust"?"rust":r==="dotnet"?"dotnet":r==="elixir"?"elixir":r==="ruby"?"ruby":r==="clojure"||r==="scala"||r==="kotlin"?"jvm-generic":null).filter(r=>r!==null).filter((r,n,o)=>o.indexOf(r)===n);return {primary:t.length>0?t[0]:"unknown",secondary:t.slice(1)}}function Fe(e){return Ke(e).primary}function ie(e,t){if(!e)return "unknown";t||(t={setup:["ModuleNotFoundError","No module named","npm ERR!","error:","not found"],"test-failure":["FAILED","FAIL","failed"],dependency:["cannot find module","import.*error"],runtime:["Exception","Error:","panic","TypeError"],timeout:["timeout","Timeout","deadline exceeded"],unknown:[]});for(let[r,n]of Object.entries(t))for(let o of n)if(new RegExp(o,"i").test(e))return r;return "unknown"}async function q(e){let t=e.split(/[&|;]\s*/)[0].trim().split(/\s+/)[0];if(["echo","cd","pwd","test","true","false","exit"].includes(t))return {valid:true};try{let n=process.platform==="win32"?"where":"which";if((await execa(n,[t],{reject:false})).exitCode===0)return {valid:true}}catch{}return {valid:false,reason:`Command '${t}' not found or not executable`}}function Ae(e,t,r){if(!t)return e;let n=typeof t=="object"&&!Array.isArray(t)&&("dev"in t||"staging"in t||"prod"in t||"default"in t)&&!Object.keys(t).some(o=>["init","test","build","start"].includes(o))?t:{};return r&&typeof n[r]=="string"?n[r]:typeof n.default=="string"?n.default:e}var Ne={init:"init",test:"test",build:"build",start:"start"};function Ve(e){return e in Ne?Ne[e]:null}function He(e,t){let n=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$1,r)=>await qe([...t(t$1,"context.json"),...t(t$1,"project.json")])?true:b.resolve(t$1)===b.resolve(r)?false:h(t$1).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")??p(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")??p(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$1=Array.isArray(s.projects)?s.projects:[];for(let g of p$1){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"):[],$=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 $)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=s(e,"policies.yml").find(s=>_.existsSync(s))??p(e,"policies.yml");if(!await I(r))return true;let n="";try{n=await _.promises.readFile(r,"utf-8");}catch{return true}let o=n.match(/^[\t ]*rules\.enforce_workspace_run_gates:\s*(true|false)\s*(?:#.*)?$/m);return o?o[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"||e==="rust"||e==="php"}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??j(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-GHB6QMQH.js';import {d as d$2}from'./chunk-S5KTATOU.js';import {a}from'./chunk-27UR373Z.js';import {p as p$1,w,t as t$1}from'./chunk-6HJJHEL6.js';import {h,j,f,e as e$1}from'./chunk-2PY65U6X.js';import {d as d$1}from'./chunk-MBRU3VWJ.js';import {a as a$1}from'./chunk-TQEMLBAG.js';import {t,p,s}from'./chunk-MOSXTVPU.js';import {e as e$2,g}from'./chunk-RJIYCDVC.js';import _ from'fs';import b from'path';import E from'chalk';import {execa}from'execa';function Se(e){return _.existsSync(b.join(e,"bun.lock"))||_.existsSync(b.join(e,"bunfig.toml"))?"bun":_.existsSync(b.join(e,"pnpm-lock.yaml"))?"pnpm":_.existsSync(b.join(e,"yarn.lock"))?"yarn":(_.existsSync(b.join(e,"package-lock.json")),"npm")}function Ee(e,t,r=Se(e)){return r==="npm"?`npm run ${t}`:`${r} run ${t}`}function Ce(e,t=Se(e)){return `${t} install`}var Ge={"python-fastapi":{runtime:"python",framework:"FastAPI",markers:["pyproject.toml","fastapi"],commands:{init:"python -m pip install -e .",test:"pytest",build:"python -m build",start:"uvicorn main:app --reload"},errorPatterns:{setup:["ModuleNotFoundError","No module named","pip: command not found"],"test-failure":["FAILED","ERROR","test session started"],dependency:["ImportError","missing.*dependency"],runtime:["TypeError","AttributeError","ValueError"],timeout:["timeout","Timeout","timed out"],unknown:[]},healthCheck:{stage:"start",type:"http",value:"http://localhost:8000/docs"},validation:{command:"python -m pip list | grep fastapi",error:"FastAPI not installed"}},"python-django":{runtime:"python",framework:"Django",markers:["manage.py","django"],commands:{init:"python manage.py migrate",test:"python manage.py test",build:"python manage.py collectstatic --noinput",start:"python manage.py runserver 0.0.0.0:8000"},errorPatterns:{setup:["ModuleNotFoundError","ProgrammingError.*migrate"],"test-failure":["FAILED","ERROR","Ran.*test"],dependency:["ImportError","missing.*dependency"],runtime:["DatabaseError","ImproperlyConfigured"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"node-nestjs":{runtime:"node",framework:"NestJS",markers:["package.json","@nestjs/core"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm run start"},errorPatterns:{setup:["npm ERR!","ENOENT","not found"],"test-failure":["Tests.*failed","FAIL","fail.*test"],dependency:["Cannot find module","ERR_MODULE_NOT_FOUND"],runtime:["TypeError","Error: ","ReferenceError"],timeout:["timeout","TIMEOUT"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3}},"node-express":{runtime:"node",framework:"Express",markers:["package.json","express"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm start"},errorPatterns:{setup:["npm ERR!","ENOENT"],"test-failure":["failed","FAIL"],dependency:["Cannot find module"],runtime:["Error","TypeError"],timeout:["timeout"],unknown:[]}},"go-fiber":{runtime:"go",framework:"Fiber",markers:["go.mod","fiber"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found","cannot find","go mod tidy"],"test-failure":["FAIL","--- FAIL"],dependency:["missing.*module"],runtime:["panic","fatal","Error"],timeout:["timeout","context deadline"],unknown:[]},dependencies:["init"]},"go-gin":{runtime:"go",framework:"Gin",markers:["go.mod","gin-gonic"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found"],"test-failure":["FAIL"],dependency:["missing.*module"],runtime:["panic"],timeout:["timeout"],unknown:[]}},"java-springboot":{runtime:"java",framework:"Spring Boot",markers:["pom.xml","build.gradle","spring-boot"],commands:{init:"mvn dependency:go-offline",test:"mvn test",build:"mvn package -DskipTests",start:"mvn spring-boot:run"},errorPatterns:{setup:["\\[ERROR\\]","BUILD FAILURE","missing dependencies"],"test-failure":["\\[ERROR\\] Tests run:","BUILD FAILURE"],dependency:["missing.*dependency"],runtime:["Exception","Error","NullPointerException"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8080}},"php-laravel":{runtime:"php",framework:"Laravel",markers:["composer.json","artisan","app/Models"],commands:{init:"composer install && php artisan migrate:fresh --seed",test:"php artisan test",build:"php artisan config:cache && php artisan route:cache && php artisan view:cache",start:"php artisan serve --host=0.0.0.0 --port=8000"},errorPatterns:{setup:["Composer.*lock","Fatal error","Class.*not found"],"test-failure":["FAILED","Tests.*failed"],dependency:["Class.*not found","require.*failed"],runtime:["Fatal error","Exception","Error"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"php-symfony":{runtime:"php",framework:"Symfony",markers:["composer.json","symfony.lock","bin/console"],commands:{init:"composer install && php bin/console doctrine:database:create",test:"php bin/phpunit",build:"php bin/console cache:clear --env=prod",start:"symfony serve --no-tls"},errorPatterns:{setup:["Composer.*error","Fatal error"],"test-failure":["FAILED","failure"],dependency:["Class.*not found"],runtime:["Fatal error","Exception"],timeout:["timeout"],unknown:[]},dependencies:["init"]},"rust-actix":{runtime:"rust",framework:"Actix-web",markers:["Cargo.toml","actix"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find","failed.*download"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E","thread.*panicked"],timeout:["timeout"],unknown:[]},validation:{command:"cargo --version",error:"Rust/Cargo not installed"}},"rust-axum":{runtime:"rust",framework:"Axum",markers:["Cargo.toml","axum"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"rust-rocket":{runtime:"rust",framework:"Rocket",markers:["Cargo.toml","rocket"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["FAILED"],dependency:["can.t find"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"dotnet-aspnetcore":{runtime:"dotnet",framework:"ASP.NET Core",markers:[".csproj",".sln","Program.cs"],commands:{init:"dotnet restore",test:"dotnet test",build:"dotnet build -c Release",start:"dotnet run"},errorPatterns:{setup:["error CS","CSPROJ.*not found","NuGet.*restore"],"test-failure":["Failed:.*test","FAILED"],dependency:["error NU1101"],runtime:["error CS","Exception"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:5e3}},"elixir-phoenix":{runtime:"elixir",framework:"Phoenix",markers:["mix.exs","phoenix"],commands:{init:"mix setup",test:"mix test",build:"mix compile --all-warnings",start:"mix phx.server"},errorPatterns:{setup:["\\*\\* \\(.*Error\\)","Mix.InstallError"],"test-failure":["\\d+\\sfailed","FAILED"],dependency:["dependencies are not available"],runtime:["\\*\\* \\(","RuntimeError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:4e3},dependencies:["init"]},"ruby-rails":{runtime:"ruby",framework:"Rails",markers:["Gemfile","config/application.rb","bin/rails"],commands:{init:"bundle install && rails db:prepare",test:"rails test",build:"rails assets:precompile",start:"rails server --binding=0.0.0.0 --port=3000"},errorPatterns:{setup:["Bundler::.*Error","Gem::.*Error"],"test-failure":["failures,","error,","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","Exception","NoMethodError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3},dependencies:["init"]},"ruby-sinatra":{runtime:"ruby",framework:"Sinatra",markers:["Gemfile","app.rb","sinatra"],commands:{init:"bundle install",test:"rspec",build:`echo "Sinatra apps don't require build"`,start:"ruby app.rb"},errorPatterns:{setup:["Bundler.*Error","Gem.*Error"],"test-failure":["failure","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","NoMethodError"],timeout:["timeout"],unknown:[]}}},Be={init:{python:["pip install -e .","poetry install","pip install -r requirements.txt"],node:["npm install","pnpm install","yarn install"],go:["go mod download && go mod tidy","go get ./..."],java:["mvn dependency:go-offline","gradle dependencies"],php:["composer install"],rust:["cargo fetch"],dotnet:["dotnet restore"],elixir:["mix deps.get"],ruby:["bundle install"],"jvm-generic":["mvn dependency:go-offline","gradle dependencies"],unknown:[]},test:{python:["pytest","python -m unittest","python -m pytest"],node:["npm test","npm run test"],go:["go test ./...","make test"],java:["mvn test","gradle test"],php:["php artisan test","phpunit","pest"],rust:["cargo test"],dotnet:["dotnet test"],elixir:["mix test"],ruby:["rspec","ruby -m minitest"],"jvm-generic":["mvn test","gradle test"],unknown:[]},build:{python:["python -m build","python setup.py build"],node:["npm run build"],go:["go build -o app .","go build ./..."],java:["mvn package -DskipTests","gradle build -x test"],php:['echo "PHP build: typically no build step"'],rust:["cargo build --release"],dotnet:["dotnet build -c Release"],elixir:["mix compile"],ruby:["gem build *.gemspec"],"jvm-generic":["mvn package -DskipTests","gradle build"],unknown:[]},start:{python:["python app.py","python main.py","uvicorn main:app --reload"],node:["npm start","node index.js","node src/index.js"],go:["./app","go run main.go","go run ./..."],java:["mvn spring-boot:run","gradle bootRun","java -jar target/*.jar"],php:["php -S 0.0.0.0:8000","php artisan serve"],rust:["cargo run --release","./target/release/app"],dotnet:["dotnet run"],elixir:["mix phx.server","iex -S mix"],ruby:["rails server","ruby app.rb","bundle exec puma"],"jvm-generic":["java -jar *.jar","gradle run"],unknown:[]}};function se(e,t){if(t){let r=t.trim().toLowerCase().replace(/[_.\s]+/g,"-"),n=e$1(t),s=`${e}-${n==="gofiber"?"fiber":n==="gogin"?"gin":n==="dotnet"?"aspnetcore":n!=="unknown"?n:r==="fiber"?"fiber":r==="aspnetcore"||r==="asp-net-core"?"aspnetcore":r}`;return Ge[s]}}function Pe(e,t,r){if(t){let n=se(e,t);if(n&&n.commands[r])return n.commands[r]}if(["init","test","build","start"].includes(r)){let n=Be[r]?.[e]??[];return n.length>0?n[0]:void 0}}var ze={test:"test",build:"build",start:"start"};function ae(e){if(e.stage==="init")return e.runtime==="node"?Ce(e.projectPath):Pe(e.runtime,e.framework,e.stage);if(e.runtime==="node"){let t=ze[e.stage];if(t){let r=t$1(e.projectPath,t,{framework:e.framework});if(r)return Ee(e.projectPath,r.scriptName)}}return Pe(e.runtime,e.framework,e.stage)}function Ke(e){let t=h(e).map(r=>r==="python"?"python":r==="node"||r==="bun"?"node":r==="go"?"go":r==="java"?"java":r==="php"?"php":r==="rust"?"rust":r==="dotnet"?"dotnet":r==="elixir"?"elixir":r==="ruby"?"ruby":r==="clojure"||r==="scala"||r==="kotlin"?"jvm-generic":null).filter(r=>r!==null).filter((r,n,o)=>o.indexOf(r)===n);return {primary:t.length>0?t[0]:"unknown",secondary:t.slice(1)}}function Fe(e){return Ke(e).primary}function ie(e,t){if(!e)return "unknown";t||(t={setup:["ModuleNotFoundError","No module named","npm ERR!","error:","not found"],"test-failure":["FAILED","FAIL","failed"],dependency:["cannot find module","import.*error"],runtime:["Exception","Error:","panic","TypeError"],timeout:["timeout","Timeout","deadline exceeded"],unknown:[]});for(let[r,n]of Object.entries(t))for(let o of n)if(new RegExp(o,"i").test(e))return r;return "unknown"}async function q(e){let t=e.split(/[&|;]\s*/)[0].trim().split(/\s+/)[0];if(["echo","cd","pwd","test","true","false","exit"].includes(t))return {valid:true};try{let n=process.platform==="win32"?"where":"which";if((await execa(n,[t],{reject:false})).exitCode===0)return {valid:true}}catch{}return {valid:false,reason:`Command '${t}' not found or not executable`}}function Ae(e,t,r){if(!t)return e;let n=typeof t=="object"&&!Array.isArray(t)&&("dev"in t||"staging"in t||"prod"in t||"default"in t)&&!Object.keys(t).some(o=>["init","test","build","start"].includes(o))?t:{};return r&&typeof n[r]=="string"?n[r]:typeof n.default=="string"?n.default:e}var Ne={init:"init",test:"test",build:"build",start:"start"};function Ve(e){return e in Ne?Ne[e]:null}function He(e,t){let n=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$1,r)=>await qe([...t(t$1,"context.json"),...t(t$1,"project.json")])?true:b.resolve(t$1)===b.resolve(r)?false:h(t$1).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")??p(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")??p(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$1=Array.isArray(s.projects)?s.projects:[];for(let g of p$1){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"):[],$=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 $)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=s(e,"policies.yml").find(s=>_.existsSync(s))??p(e,"policies.yml");if(!await I(r))return true;let n="";try{n=await _.promises.readFile(r,"utf-8");}catch{return true}let o=n.match(/^[\t ]*rules\.enforce_workspace_run_gates:\s*(true|false)\s*(?:#.*)?$/m);return o?o[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"||e==="rust"||e==="php"}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??j(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
|
`),$=Date.now()-x,v=a===124||h==="timeout"||a===143&&$>=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",$=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), ${$?`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 M=n.stages[e$1.stage]??n.stages[e$1.stage];if(M&&Te(M,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).filter(M=>M!==e$1.stage);if(me.length>0&&n){let M=me.find(X=>{let L=n.stages[X];return !L||!Te(L,k,r)});if(M){i.status="skipped",i.reason=`dependency stage "${M}" not satisfied in workspace-run-last.json`,i.durationMs=Date.now()-A,i.exitCode=null,T+=1;return}}let W=await dt(k,e$1.stage,P,D,$e,Ie,Le);if(i.executionCommand=W.command,i.errorCategory=W.errorCategory,i.healthStatus=W.healthStatus,i.failureDiagnostic=W.failureDiagnostic,i.durationMs=Date.now()-A,i.exitCode=W.exitCode,W.exitCode===0?(i.status="passed",i.reason=void 0):(i.status="failed",i.reason=W.message||"stage command failed",i.errorMessage=W.message),T+=1,!e$1.json){let M=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}] (${M}%) ${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($&&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:$,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 {a as a$2}from'./chunk-
|
|
1
|
+
import {a as a$2}from'./chunk-F4KBYFZ5.js';import {a as a$5}from'./chunk-2OIBHUVH.js';import {a as a$3,e}from'./chunk-GHB6QMQH.js';import {d,a as a$1,e as e$1}from'./chunk-MBRU3VWJ.js';import {a}from'./chunk-62K2H72S.js';import a$4 from'chalk';import se from'fs';import b from'path';import {execa}from'execa';var G="autopilot-release-last-run.json",V="autopilot-release.json";function j(r){try{return JSON.parse(r)}catch{return null}}function Re(r){let e=b.resolve(r),n=a$5(e);if(!n)throw new Error("No Workspai workspace found in current directory or parents");return n}async function S(r,e){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[n,...r],{cwd:e,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function re(r){let e=r.toLowerCase();return e==="pass"?"pass":e==="warn"?"warn":e==="fail"?"fail":"warn"}function oe(r){return r.summary.failed>0||r.gates.results.some(e=>e.status==="fail")?"fail":r.gates.results.some(e=>e.status==="warn")?"warn":"pass"}function Se(r){let e=r.filter(o=>o.status!=="skipped");if(e.length===0)return 100;let n=e.reduce((o,t)=>t.status==="pass"?o+1:t.status==="warn"?o+.6:o,0);return Math.round(n/e.length*100)}function be(r){return r.executionError?["Re-run: npx workspai autopilot release --mode audit --json","Inspect .workspai/reports/autopilot-release-last-run.json for execution failure details"]:r.blockers.length>0?["Run: npx workspai doctor workspace --plan","Run: npx workspai readiness --json --strict","Run: npx workspai workspace run test --affected --strict"]:r.hasWarnings&&r.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx workspai autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function xe(r,e){await se.promises.mkdir(b.dirname(r),{recursive:true}),await se.promises.writeFile(r,`${JSON.stringify(e,null,2)}
|
|
2
2
|
`,"utf-8");}async function Me(r){let e$2=Re(r.workspacePath),n=r.mode,o=[],t=[],F,H,D,q,Q,X=0,f=false,T=0,L=0,N=-1,W=-1,c="skipped",d$1="skipped",ae=n==="enforce"?["doctor","workspace","--json","--strict"]:["doctor","workspace","--json","--ci"];if(r.skipPipelineStages)o.push({name:"doctor-workspace",status:"skipped",durationMs:0,summary:"doctor stage skipped (pipeline already executed)"},{name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped (pipeline already executed)"},{name:"readiness",status:"skipped",durationMs:0,summary:"readiness stage skipped (pipeline already executed)"});else {let s=Date.now(),l=await S([...ae],e$2),m=Date.now()-s;if(c="pass",l.crashed)c="fail",f=true,t.push(`doctor workspace execution error: ${l.stderr||"unknown error"}`);else if(l.exitCode===1)c="fail",t.push("doctor workspace command failed or reported errors");else if(l.exitCode===2)c="warn",t.push("doctor workspace reported warnings");else if(l.exitCode!==0)c="fail",t.push("doctor workspace command failed");else {let p=j(l.stdout),E=p&&p.healthScore&&typeof p.healthScore=="object"?p.healthScore:{},k=Number(E.errors??0),$=Number(E.warnings??0);Number.isFinite(k)&&k>0?(c="fail",t.push(`doctor workspace reports ${k} error(s)`)):Number.isFinite($)&&$>0&&(c="warn");}N=o.push({name:"doctor-workspace",status:c,durationMs:m,summary:c==="pass"?"doctor workspace passed":c==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors"})-1,n==="enforce"&&c==="warn"&&t.push("doctor workspace reported warnings under enforce mode");let g=Date.now(),w=await S(["analyze","--json"],e$2),v=Date.now()-g;H=await d(e$2,a.analyze)??a$1(e$2,a.analyze);let i="pass";if(w.crashed)i="fail",f=true,t.push(`analyze execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)i=w.exitCode===2?"warn":"fail",t.push(w.exitCode===2?"analyze reported needs-attention verdict":"analyze command failed or reported blocked verdict");else {let p=j(w.stdout),E=p&&p.summary&&typeof p.summary=="object"?p.summary:{},k=String(E.verdict??"ready");k==="blocked"?(i="fail",t.push("analyze reported blocked verdict")):k==="needs-attention"&&(i="warn");}o.push({name:"analyze",status:i,durationMs:v,summary:i==="pass"?"analyze passed":i==="warn"?"analyze reported needs-attention":"analyze reported blocked verdict"}),n==="enforce"&&i==="warn"&&t.push("analyze reported warnings under enforce mode");let P=Date.now(),h=await S(["readiness","--json"],e$2),y=Date.now()-P;if(d$1="fail",h.crashed)d$1="fail",f=true,t.push(`readiness execution error: ${h.stderr||"unknown error"}`);else if(h.exitCode!==0)d$1="fail",t.push("readiness command failed");else {let p=j(h.stdout),E=String(p?.overallStatus??"fail");if(d$1=re(E),typeof p?.evidencePath=="string"&&p.evidencePath.trim().length>0&&(F=p.evidencePath),d$1==="fail"){let k=Array.isArray(p?.blockingReasons)?p?.blockingReasons.filter($=>typeof $=="string"):[];k.length>0?t.push(...k.map($=>`readiness: ${$}`)):t.push("readiness overall status is fail");}}W=o.push({name:"readiness",status:d$1,durationMs:y,summary:`readiness overall status is ${d$1}`})-1,n==="enforce"&&d$1==="warn"&&t.push("readiness reported warnings under enforce mode");}let ne=Date.now(),z=await S(["doctor","workspace","--plan","--json"],e$2),ie=Date.now()-ne,R="warn";if(z.crashed)R="fail",f=true,t.push(`doctor remediation plan execution error: ${z.stderr||"unknown error"}`);else if(z.exitCode!==0)R="fail",t.push("doctor remediation plan command failed");else {let s=j(z.stdout),l=s&&s.remediationPlan&&typeof s.remediationPlan=="object"?s.remediationPlan:null,m=Number(l?.totalSteps??0),g=Number(l?.executableSteps??0);Number.isFinite(m)&&m>0&&(T=m),Number.isFinite(g)&&g>0&&(L=g),Number.isFinite(m)&&m===0?R="pass":R="warn";}if(o.push({name:"remediation-plan",status:R,durationMs:ie,summary:R==="pass"?"no remediation steps required":"remediation steps available"}),n==="enforce"&&R==="warn"&&t.push("remediation plan has pending steps under enforce mode"),n==="safe-fix"){let s=Date.now(),l=await S(["doctor","workspace","--apply"],e$2),m=Date.now()-s,g=l.crashed||l.exitCode!==0?"fail":"pass";if(l.crashed)f=true,t.push(`doctor remediation apply execution error: ${l.stderr||"unknown error"}`);else if(g==="fail")t.push("doctor remediation apply failed");else {X=L>0?L:T>0?T:1;let w=await S(["doctor","workspace","--json"],e$2);if(w.crashed)c="fail",f=true,t.push(`post-apply doctor execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)c="fail",t.push("post-apply doctor workspace command failed");else {let i=j(w.stdout),P=i&&i.healthScore&&typeof i.healthScore=="object"?i.healthScore:{},h=Number(P.errors??0),y=Number(P.warnings??0);Number.isFinite(h)&&h>0?(c="fail",t.push(`post-apply doctor reports ${h} error(s)`)):Number.isFinite(y)&&y>0?c="warn":c="pass";}N>=0&&(o[N].status=c,o[N].summary=`doctor workspace post-apply status is ${c}`);let v=await S(["readiness","--json"],e$2);if(v.crashed)d$1="fail",f=true,t.push(`post-apply readiness execution error: ${v.stderr||"unknown error"}`);else if(v.exitCode!==0)d$1="fail",t.push("post-apply readiness command failed");else {let i=j(v.stdout),P=String(i?.overallStatus??"fail");if(d$1=re(P),typeof i?.evidencePath=="string"&&i.evidencePath.trim().length>0&&(F=i.evidencePath),d$1==="fail"){let h=Array.isArray(i?.blockingReasons)?i?.blockingReasons.filter(y=>typeof y=="string"):[];h.length>0?t.push(...h.map(y=>`post-apply readiness: ${y}`)):t.push("post-apply readiness overall status is fail");}}W>=0&&(o[W].status=d$1,o[W].summary=`readiness post-apply overall status is ${d$1}`);}o.push({name:"remediation-apply",status:g,durationMs:m,summary:g==="pass"?"safe remediation apply completed":"safe remediation apply failed"});}else o.push({name:"remediation-apply",status:"skipped",durationMs:0,summary:"remediation apply is skipped for this mode"});let le=Date.now(),x="pass",A="workspace test/build completed for selected projects";try{let s=await a$2({workspacePath:e$2,stage:"test",affected:true,since:r.since,parallel:r.parallel,maxWorkers:r.maxWorkers,strict:true,json:true,enforceGates:false});D=a$1(e$2,b.join(".workspai","reports",a$3)),await e(e$2,s),q=D;let l=oe(s);if(l==="fail")x="fail",A="workspace test stage failed for selected projects",t.push("workspace run test failed for selected projects");else {l==="warn"&&(x="warn",A="workspace test stage completed with warnings",n==="enforce"&&t.push("workspace run test reported warnings under enforce mode"));let m=await a$2({workspacePath:e$2,stage:"build",affected:true,since:r.since,parallel:r.parallel,maxWorkers:r.maxWorkers,strict:true,json:true,enforceGates:false});await e(e$2,m),Q=D;let g=oe(m);g==="fail"?(x="fail",A="workspace build stage failed for selected projects",t.push("workspace run build failed for selected projects")):g==="warn"&&(x="warn",A="workspace test/build completed with warnings",n==="enforce"&&t.push("workspace run test/build reported warnings under enforce mode"));}}catch(s){x="fail",A="workspace test/build orchestration failed",f=true,t.push(`workspace run orchestration error: ${s instanceof Error?s.message:String(s)}`);}let ce=Date.now()-le;o.push({name:"workspace-run-test-build",status:x,durationMs:ce,summary:A});let M=o.filter(s=>s.status==="warn").length,pe=o.filter(s=>s.status==="fail").length,_=n==="enforce"?o.some(s=>s.status==="warn"||s.status==="fail"):pe>0,C=[...new Set(t)],O=f||_?Math.max(1,C.length):0,ue=O>0?C:[],de=O===0?C:[],fe=Se(o),me=f||_?"blocked":M>0?"partial":"approved",ge=f?3:_?1:M>0?2:0,we=be({mode:n,executionError:f,blockers:C,hasWarnings:M>0}),Y=a$1(e$2,".workspai/reports"),he=b.join(Y,G),ke=b.join(Y,V),u={schemaVersion:"autopilot-release-v1",generatedAt:new Date().toISOString(),workspacePath:e$2,mode:n,summary:{releaseScore:fe,verdict:me,blockers:O,warnings:M,safeFixesApplied:X,manualActions:C.length,exitCode:ge},stages:o,blockingReasons:ue,warningReasons:de,nextActions:we,artifacts:{reportPath:he,aliasEvidencePath:ke,analyzeEvidencePath:H,readinessEvidencePath:F,workspaceRunEvidencePath:D,workspaceRunTestPath:q,workspaceRunBuildPath:Q},enterpriseControls:{jsonReady:true,evidencePath:`.workspai/reports/${G}`,aliasEvidencePath:`.workspai/reports/${V}`}};if(await e$1(e$2,`.workspai/reports/${G}`,u),await e$1(e$2,`.workspai/reports/${V}`,u),r.output&&await xe(b.resolve(r.output),u),!r.json){console.log(a$4.bold.cyan(`
|
|
3
3
|
\u{1F680} Workspai Autopilot Release
|
|
4
4
|
`)),console.log(a$4.bold(`Workspace: ${a$4.cyan(b.basename(e$2))}`)),console.log(a$4.gray(`Path: ${e$2}`)),console.log(a$4.white(`Mode: ${n}`)),console.log(a$4.white(`Verdict: ${u.summary.verdict==="approved"?a$4.green("approved"):u.summary.verdict==="partial"?a$4.yellow("partial"):a$4.red("blocked")}`)),console.log(a$4.white(`Release score: ${u.summary.releaseScore}`));for(let s of u.stages){let l=s.status==="pass"?a$4.green("PASS"):s.status==="warn"?a$4.yellow("WARN"):s.status==="skipped"?a$4.gray("SKIP"):a$4.red("FAIL");console.log(` - ${s.name}: ${l} ${s.summary} (${s.durationMs}ms)`);}if(u.blockingReasons.length>0){console.log(a$4.bold.red(`
|