workspai 0.75.1 → 0.76.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/contracts/agent-framework-capabilities.v1.json +2 -2
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +12 -0
- package/contracts/create-planner-capabilities.v1.json +24 -0
- package/contracts/extension-cli-compatibility.v1.json +4 -2
- package/contracts/published-contract-catalog.v1.json +10 -0
- package/contracts/runtime-command-surface.v1.json +3 -1
- package/contracts/workspace-intelligence/agent-framework-admission-candidate.v2.json +217 -0
- package/contracts/workspace-intelligence/agent-framework-conformance-report.v2.json +274 -0
- package/contracts/workspace-intelligence-architecture.v1.json +5 -3
- package/dist/analyze-QVRVJB7I.js +1 -0
- package/dist/{artifact-remediation-plan-HD5K52UJ.js → artifact-remediation-plan-SRH2Q6N2.js} +1 -1
- package/dist/autopilot-release-DOGIETAT.js +1 -0
- package/dist/capabilities-command-FYBUVHZ7.js +1 -0
- package/dist/{chunk-SCKEFXF5.js → chunk-23CNBYIW.js} +1 -1
- package/dist/chunk-2DZLCINC.js +1 -0
- package/dist/{chunk-2GWQ6NZV.js → chunk-2I2A55RE.js} +1 -1
- package/dist/{chunk-W7I65IXY.js → chunk-3HXEPDFF.js} +2 -2
- package/dist/{chunk-2OCJKLTW.js → chunk-4BBFEHPL.js} +1 -1
- package/dist/{chunk-VHMDWRDG.js → chunk-4BPZJR4Z.js} +4 -4
- package/dist/{chunk-UE7ART6X.js → chunk-4MXKXHLW.js} +1 -1
- package/dist/{chunk-JKAAKE4Z.js → chunk-4R44E7HN.js} +1 -1
- package/dist/chunk-5HNQIMGW.js +1 -0
- package/dist/chunk-5S6IZ6PY.js +2 -0
- package/dist/chunk-6BO4QHKA.js +1 -0
- package/dist/{chunk-25V5XMWB.js → chunk-AGI46TSQ.js} +1 -1
- package/dist/{chunk-2CT5SN2L.js → chunk-BZLDCASY.js} +1 -1
- package/dist/{chunk-OA2YJN22.js → chunk-DWDYLKVW.js} +1 -1
- package/dist/{chunk-6B7L4NZE.js → chunk-EFHSRPW7.js} +6 -6
- package/dist/{chunk-RTD5D35M.js → chunk-FBF767WP.js} +1 -1
- package/dist/{chunk-NGZF4YJS.js → chunk-FD2ZGGCQ.js} +1 -1
- package/dist/chunk-H4YHIOCT.js +7 -0
- package/dist/{chunk-ZI54C2AO.js → chunk-HRGIHWYH.js} +1 -1
- package/dist/{chunk-HDISUL3F.js → chunk-IKNWNGLY.js} +1 -1
- package/dist/{chunk-NRIMJMTF.js → chunk-KO4DM2AV.js} +8 -8
- package/dist/{chunk-6KMR5PKQ.js → chunk-KW35SWG6.js} +5 -5
- package/dist/{chunk-NI5QWBZK.js → chunk-L6VNI4DN.js} +1 -1
- package/dist/chunk-NSC4VWV2.js +1 -0
- package/dist/chunk-P5LI5DL3.js +1 -0
- package/dist/chunk-PSQPKK6H.js +97 -0
- package/dist/chunk-PUH3TSPC.js +1 -0
- package/dist/chunk-QFDTKOYS.js +2649 -0
- package/dist/chunk-QIPW3G2H.js +1 -0
- package/dist/chunk-QVFIR64T.js +10 -0
- package/dist/{chunk-AICCXYY5.js → chunk-R3Z4LY3O.js} +1 -1
- package/dist/chunk-RKFTUIZ4.js +4 -0
- package/dist/chunk-ROOPODG6.js +2 -0
- package/dist/{chunk-COOVCORC.js → chunk-SVO2GGTV.js} +1 -1
- package/dist/chunk-TFFNHWXY.js +4 -0
- package/dist/chunk-TJ3MDZMC.js +6 -0
- package/dist/{chunk-DJH2CH42.js → chunk-UHIN3RS6.js} +1 -1
- package/dist/chunk-UOTOJJI4.js +681 -0
- package/dist/chunk-VODNLROY.js +1 -0
- package/dist/{chunk-3WQ5TYCO.js → chunk-X7MDTBX5.js} +1 -1
- package/dist/{chunk-RPM67N7A.js → chunk-XHUM372O.js} +1 -1
- package/dist/chunk-YLLCZMKP.js +2 -0
- package/dist/{chunk-4VSQNSGH.js → chunk-Z2M2XCIB.js} +1 -1
- package/dist/chunk-ZXQC36NJ.js +1 -0
- package/dist/{create-P4XJVZCL.js → create-ZRUQ3KNZ.js} +1 -1
- package/dist/{demo-kit-ALW6OSQV.js → demo-kit-QNGY4KQ5.js} +1 -1
- package/dist/{doctor-PFN6KB6P.js → doctor-7V7LJLHX.js} +1 -1
- package/dist/{dotnet-webapi-clean-6Z4EXEJY.js → dotnet-webapi-clean-GXTNZMKO.js} +1 -1
- package/dist/{goal-lifecycle-BDWTWS55.js → goal-lifecycle-EM4DUJCR.js} +1 -1
- package/dist/{goal-pack-5JDNZFKV.js → goal-pack-YMWZHAH6.js} +1 -1
- package/dist/{gofiber-standard-TDJQIVQZ.js → gofiber-standard-PFBIAMGR.js} +1 -1
- package/dist/{gogin-standard-UEF3IHSJ.js → gogin-standard-DW5GL7YG.js} +1 -1
- package/dist/index.d.ts +12 -6
- package/dist/index.js +255 -253
- package/dist/{pipeline-OUYS4ZYV.js → pipeline-6MBH3MU2.js} +1 -1
- package/dist/platform-capabilities-RWOWND5Q.js +1 -0
- package/dist/{project-agent-entry-75WO3QWP.js → project-agent-entry-ZXAE2MAJ.js} +1 -1
- package/dist/{project-intelligence-lens-JCHFOIA7.js → project-intelligence-lens-NBTPOK2R.js} +1 -1
- package/dist/{project-test-coverage-3P5FH6E5.js → project-test-coverage-HOZC72EK.js} +1 -1
- package/dist/proof-carrying-change-WJFAKK3C.js +1 -0
- package/dist/{pythonRapidkitExec-UMFLDIYR.js → pythonRapidkitExec-S35OEIEF.js} +1 -1
- package/dist/{rust-axum-4TRVPFMB.js → rust-axum-L7UAYARA.js} +1 -1
- package/dist/{springboot-standard-COWL75GT.js → springboot-standard-CZH24KWD.js} +1 -1
- package/dist/verified-goal-B7EX2PBE.js +1 -0
- package/dist/{workspace-CBQDOUSH.js → workspace-EBPYCSEM.js} +1 -1
- package/dist/{workspace-agent-sync-RTOTO3DY.js → workspace-agent-sync-Y4F6FBBC.js} +1 -1
- package/dist/{workspace-context-STRZO2N3.js → workspace-context-Y7F7GJCQ.js} +1 -1
- package/dist/{workspace-contract-PMHUUKFM.js → workspace-contract-XJMWMVQE.js} +1 -1
- package/dist/{workspace-explain-CATMJUMN.js → workspace-explain-T2J5ZLY7.js} +1 -1
- package/dist/{workspace-foundation-OULCDCXG.js → workspace-foundation-2UP6IMTH.js} +1 -1
- package/dist/{workspace-graph-stream-Q55CI4K4.js → workspace-graph-stream-MZVL3OCX.js} +1 -1
- package/dist/workspace-graph-token-efficiency-WF6TGSK7.js +1 -0
- package/dist/{workspace-intelligence-3RPZRWSF.js → workspace-intelligence-FZRQIFFM.js} +1 -1
- package/dist/{workspace-intelligence-benchmark-R5MEGJQS.js → workspace-intelligence-benchmark-V6AEVDMB.js} +1 -1
- package/dist/{workspace-intelligence-runner-BNZUYUUN.js → workspace-intelligence-runner-IXT62JG7.js} +1 -1
- package/dist/{workspace-knowledge-graph-VJLD35ES.js → workspace-knowledge-graph-EFC4TUDZ.js} +1 -1
- package/dist/workspace-knowledge-graph-query-BROIV27M.js +1 -0
- package/dist/workspace-knowledge-graph-snapshot-QIMF7TCF.js +1 -0
- package/dist/{workspace-mcp-serve-67NTYD67.js → workspace-mcp-serve-C42UUU7W.js} +1 -1
- package/dist/{workspace-model-6TKZMNEF.js → workspace-model-72SJ6WXT.js} +1 -1
- package/dist/{workspace-onboarding-7V7EH3RH.js → workspace-onboarding-TFDAIHTS.js} +1 -1
- package/dist/{workspace-registry-summary-ILVO7DEU.js → workspace-registry-summary-ZNTXSUI4.js} +1 -1
- package/dist/{workspace-repair-engine-2VGFB3DJ.js → workspace-repair-engine-542TAL3Z.js} +1 -1
- package/dist/workspace-run-NAPJYNSZ.js +1 -0
- package/dist/{workspace-verify-VQWYDAF2.js → workspace-verify-UXKENOQU.js} +1 -1
- package/dist/{workspace-watch-2Z636HWS.js → workspace-watch-DV5AHLOK.js} +1 -1
- package/docs/README.md +2 -2
- package/docs/agent-framework-adapters.md +190 -46
- package/docs/ci-workflows.md +37 -14
- package/docs/commands-reference.md +30 -14
- package/docs/creating-workspaces-and-projects.md +30 -10
- package/docs/doctor-command.md +6 -0
- package/docs/native-kit-baselines.md +4 -0
- package/docs/workspace-run.md +10 -0
- package/package.json +7 -4
- package/scripts/enterprise-package-smoke.mjs +98 -5
- package/dist/analyze-Z3EZNJRI.js +0 -1
- package/dist/autopilot-release-T6XFRWZT.js +0 -1
- package/dist/capabilities-command-VK3LQLP2.js +0 -1
- package/dist/chunk-566NQQTJ.js +0 -97
- package/dist/chunk-5EEXLM45.js +0 -1
- package/dist/chunk-65AE7EC5.js +0 -2
- package/dist/chunk-6NSJBKKK.js +0 -4
- package/dist/chunk-7NKM6EHE.js +0 -7
- package/dist/chunk-ABUSBLBH.js +0 -1
- package/dist/chunk-BR6QIYQS.js +0 -1
- package/dist/chunk-CMLLERGG.js +0 -418
- package/dist/chunk-DFREJHG7.js +0 -1
- package/dist/chunk-FU6SQ2ND.js +0 -1
- package/dist/chunk-M6DVNC6X.js +0 -2
- package/dist/chunk-O5XQP5E7.js +0 -1
- package/dist/chunk-OH6LV5JP.js +0 -6
- package/dist/chunk-PTI743SC.js +0 -7
- package/dist/chunk-QBKOPXKC.js +0 -1
- package/dist/chunk-RGNCL5OB.js +0 -1
- package/dist/chunk-VJQPIH2S.js +0 -681
- package/dist/chunk-WPPRUFJW.js +0 -4
- package/dist/chunk-ZKYH44ER.js +0 -1
- package/dist/platform-capabilities-DB4BZPTD.js +0 -1
- package/dist/proof-carrying-change-LAYV4LTI.js +0 -1
- package/dist/verified-goal-75KGBWTE.js +0 -1
- package/dist/workspace-graph-token-efficiency-YHXFGH3Z.js +0 -1
- package/dist/workspace-knowledge-graph-query-TT2KK3SF.js +0 -1
- package/dist/workspace-knowledge-graph-snapshot-TQAKDDUA.js +0 -1
- package/dist/workspace-run-X7KV6MIT.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {H,k,q as q$1,P as P$1}from'./chunk-QFDTKOYS.js';import {b as b$2,c as c$2,a as a$3}from'./chunk-NSC4VWV2.js';import {a as a$2}from'./chunk-NMXGSVMD.js';import {a as a$6}from'./chunk-HTYMXMQM.js';import {d as d$1,a as a$1,p as p$1,g as g$2,f as f$1,e}from'./chunk-YLLCZMKP.js';import {c,b as b$1,j as j$2,q as q$3,D,f}from'./chunk-TJ3MDZMC.js';import {d,b as b$3}from'./chunk-ROOPODG6.js';import {j as j$3,m,l}from'./chunk-H4YHIOCT.js';import {a as a$5}from'./chunk-GR6442P7.js';import {j as j$1,g as g$1,a as a$4,h}from'./chunk-BLEIUQL6.js';import {a}from'./chunk-252EKOR6.js';import {d as d$2,c as c$1}from'./chunk-EWZZUQBR.js';import {t}from'./chunk-VQZ5PI5J.js';import {q as q$2,p,t as t$1,s}from'./chunk-ODK4LCEL.js';import g from'path';import C from'fs-extra';import Nt from'crypto';import {execFile}from'child_process';import {promisify}from'util';import {createRequire}from'module';var Gt=new Set([...c().map(e=>e.id),...H().map(e=>e.id)]),_t=[...k().map(e=>({id:e.kitId,aliases:[...e.aliases],ecosystem:e.framework,plannerFramework:e.id,runtime:"node",runtimeCandidates:["node"],workspacePythonEngine:"none",status:"available",canExecuteCreate:true,versionPolicy:e.versionPolicy,officialCommands:[e.commandDisplay("<name>",{skipGit:false,skipInstall:false})],adoptAfterCreate:true,...e.minNodeVersion?{runtimeRequirements:{node:`>=${e.minNodeVersion}`}}:e.minNodeMajor?{runtimeRequirements:{node:`>=${e.minNodeMajor}`}}:{}})),...q$1().map(e=>({id:e.kitId,aliases:[...e.aliases],ecosystem:e.framework,plannerFramework:e.framework,runtime:e.runtime,runtimeCandidates:[...e.runtimeCandidates],workspacePythonEngine:"none",status:"available",canExecuteCreate:true,versionPolicy:e.versionPolicy,officialCommands:[e.commandDisplay("<name>",{skipGit:false,skipInstall:false})],adoptAfterCreate:true,...e.nodeSupport?{runtimeRequirements:{node:e.nodeSupport.requirement}}:{}})),{id:"wordpress-site",aliases:["wordpress","wordpress-site","wp","wp-site"],ecosystem:"wordpress",plannerFramework:"wordpress",runtime:"php",runtimeCandidates:["php"],workspacePythonEngine:"none",status:"planned",canExecuteCreate:false,versionPolicy:"planned",officialCommands:["wp core download","wp config create","wp db create","wp core install"],adoptAfterCreate:true},{id:"wordpress-block",aliases:["wordpress-block","wp-block","gutenberg-block"],ecosystem:"wordpress",plannerFramework:"wordpress",runtime:"node",runtimeCandidates:["node","php"],workspacePythonEngine:"none",status:"planned",canExecuteCreate:false,versionPolicy:"planned",officialCommands:["npx @wordpress/create-block@latest <slug>"],adoptAfterCreate:true},{id:"symfony",aliases:["symfony","php-symfony"],ecosystem:"php",plannerFramework:"symfony",runtime:"php",runtimeCandidates:["php"],workspacePythonEngine:"none",status:"planned",canExecuteCreate:false,versionPolicy:"planned",officialCommands:["composer create-project symfony/skeleton <name>"],adoptAfterCreate:true},{id:"rails",aliases:["rails","ruby-on-rails","ruby-rails"],ecosystem:"ruby",plannerFramework:"rails",runtime:"ruby",runtimeCandidates:["ruby"],workspacePythonEngine:"none",status:"planned",canExecuteCreate:false,versionPolicy:"planned",officialCommands:["rails new <name>"],adoptAfterCreate:true}],L=new Map;for(let e of _t){L.set(e.id,e);for(let t of e.aliases)L.set(t,e);}var Tt=new Set(["php","ruby","rust","elixir","clojure","scala","kotlin","unknown"]);function V(e){return e?.trim().toLowerCase()||void 0}function it(e){let t=V(e.kitId)??V(e.framework)??V(e.runtime)??"unknown";if(e.projectExists)return {lane:"existing",status:"available",canExecuteCreate:false,requested:t,reason:"Existing projects enter Workspace Intelligence through adopt/import."};let r=e.kitId?b$1(e.kitId):void 0;if(r&&Gt.has(r))return {lane:"native",status:"available",canExecuteCreate:true,requested:t,resolved:r,reason:"Workspai owns the create contract, project marker, registry, doctor, and workspace model path."};let o=L.get(t)??L.get(V(e.framework)??"")??L.get(V(e.runtime)??"");if(o)return {lane:"official",status:o.status,canExecuteCreate:o.canExecuteCreate,requested:t,resolved:o.id,officialCommands:o.officialCommands,fallbackLane:o.canExecuteCreate?void 0:"existing",reason:o.status==="available"?"Workspai runs the official ecosystem generator, then registers the project in Workspace Intelligence.":"Official generator support is planned but not enabled; use adopt/import until Workspai owns the post-create contract."};let s=V(e.runtime);return s&&Tt.has(s)?{lane:"existing",status:"available",canExecuteCreate:false,requested:t,resolved:s,reason:"Runtime can be governed through Workspace Intelligence, but native create is not supported."}:{lane:"existing",status:"available",canExecuteCreate:false,requested:t,reason:"No native create contract is available; use adopt/import to enter Workspace Intelligence."}}function Xr(e){return !e.canExecuteCreate&&(e.lane==="official"||e.lane==="existing"&&e.resolved!==void 0)}var en="rapidkit-freshness-metadata-v1";function he(e){if(Array.isArray(e))return e.map(t=>he(t));if(e&&typeof e=="object"){let t={};for(let r of Object.keys(e).sort())t[r]=he(e[r]);return t}return e}function Kt(e){return JSON.stringify(he(e))}function _(e){return Nt.createHash("sha256").update(Kt(e)).digest("hex")}var ct=".workspai/workspace-graph.overrides.json",$t=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs"]),Vt=new Set([".git",".hg",".svn",".workspai",".rapidkit",".venv","node_modules","dist","build","out","target","coverage","htmlcov",".next",".turbo",".cache"]),lt=600,pt=5,Ht=256*1024,dt={inferred:1,contract:2,manual:3};function Bt(e){return e.split(g.sep).join("/")}function ee(e,t){return Bt(g.relative(e,t)||".")}function ut(e){let t=new Map;for(let r of e.projects)t.has(r.name)||t.set(r.name,{id:r.name,path:r.path,...r.runtime?{runtime:r.runtime}:{},...r.framework?{framework:r.framework}:{},...r.kind?{kind:r.kind}:{}});return [...t.values()].sort((r,o)=>r.id.localeCompare(o.id))}function ft(e,t){let r=new Map,o=new Map;for(let n of t.projects){if(r.has(n.name))continue;let i=d(e,n.path,{...n.absolutePath?{absolutePath:n.absolutePath}:{}});r.set(n.name,i),o.has(i)||o.set(i,n.name);}let s=[...o.entries()].map(([n,i])=>({dir:n,id:i})).sort((n,i)=>i.dir.length-n.dir.length||n.dir.localeCompare(i.dir));return {idToDir:r,dirToId:o,sortedDirs:s}}function te(e,t){let r=g.resolve(t);for(let{dir:o,id:s}of e.sortedDirs)if(r===o||r.startsWith(`${o}${g.sep}`))return s;return null}function we(e,t){let r=g.relative(e,t);return r.length>0&&!r.startsWith("..")&&!g.isAbsolute(r)}function Pe(e,t,r){let o=e.idToDir.get(t),s=e.idToDir.get(r);return !o||!s?false:we(o,s)||we(s,o)}async function ve(e){try{if(!await C.pathExists(e))return null;let t=await C.readJSON(e);return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}async function je(e){try{return await C.pathExists(e)?await C.readFile(e,"utf8"):null}catch{return null}}async function mt(e,t){let r=[],o=new Map;for(let[s,n]of t.idToDir.entries()){let i=await ve(g.join(n,"package.json")),a=typeof i?.name=="string"?i.name.trim():"";a&&!o.has(a)&&o.set(a,s);}for(let[s,n]of t.idToDir.entries()){let i=await ve(g.join(n,"package.json"));if(i){let a=["dependencies","devDependencies","peerDependencies","optionalDependencies"],c=new Set;for(let l of a){let u=i[l];if(!(!u||typeof u!="object"||Array.isArray(u)))for(let p of Object.keys(u)){let d=o.get(p);!d||d===s||c.has(d)||(c.add(d),r.push({from:s,to:d,kind:"package-dep",source:"inferred",confidence:"high",evidence:[{file:ee(e,g.join(n,"package.json")),detail:`declares dependency ${p}`}]}));}}}r.push(...await Lt(e,t,s,n)),r.push(...await Ut(e,t,s,n));}return r}async function Lt(e,t,r,o){let s=await je(g.join(o,"pyproject.toml"));if(!s)return [];let n=[],i=new Set,a=/path\s*=\s*["']([^"']+)["']/g,c;for(;(c=a.exec(s))!==null;){let l=te(t,g.resolve(o,c[1]));!l||l===r||Pe(t,r,l)||i.has(l)||(i.add(l),n.push({from:r,to:l,kind:"package-dep",source:"inferred",confidence:"high",evidence:[{file:ee(e,g.join(o,"pyproject.toml")),detail:`path dependency ${c[1]}`}]}));}return n}async function Ut(e,t,r,o){let s=await je(g.join(o,"go.mod"));if(!s)return [];let n=[],i=new Set,a=/replace\s+\S+\s+=>\s+(\.[^\s]+)/g,c;for(;(c=a.exec(s))!==null;){let l=te(t,g.resolve(o,c[1]));!l||l===r||Pe(t,r,l)||i.has(l)||(i.add(l),n.push({from:r,to:l,kind:"package-dep",source:"inferred",confidence:"high",evidence:[{file:ee(e,g.join(o,"go.mod")),detail:`go.mod replace ${c[1]}`}]}));}return n}async function zt(e,t,r=new Set){let o=[],s=[e];for(;s.length>0&&o.length<t;){let n=s.shift();if(!n)continue;let i=[];try{i=await C.readdir(n,{withFileTypes:true});}catch{continue}let a=[],c=[];for(let l of i)if(l.isDirectory()){let u=g.resolve(n,l.name);if(r.has(u)||Vt.has(l.name)||a$5(l.name)||l.name.startsWith("."))continue;a.push(g.join(n,l.name));}else l.isFile()&&$t.has(g.extname(l.name))&&c.push(g.join(n,l.name));c.sort((l,u)=>l.localeCompare(u)),a.sort((l,u)=>l.localeCompare(u));for(let l of c){if(o.length>=t)break;o.push(l);}s.push(...a);}return o}var qt=[/\bfrom\s+["']([^"']+)["']/g,/\bimport\s+["']([^"']+)["']/g,/\bimport\s*\(\s*["']([^"']+)["']\s*\)/g,/\brequire\s*\(\s*["']([^"']+)["']\s*\)/g];function Jt(e){let t=new Set;for(let r of qt){r.lastIndex=0;let o;for(;(o=r.exec(e))!==null;){let s=o[1];s.startsWith(".")&&t.add(s);}}return [...t]}async function be(e,t,r,o){let s=new Map;for(let[n,i]of t.idToDir.entries()){if(o&&!o.has(n))continue;let a=new Set([...t.idToDir.entries()].filter(([l,u])=>l!==n&&we(i,u)).map(([,l])=>g.resolve(l))),c=await zt(i,r,a);for(let l of c){let u=await C.stat(l).catch(()=>null);if(!u||u.size>Ht)continue;let p=await je(l);if(p)for(let d of Jt(p)){let f=g.resolve(g.dirname(l),d),h=te(t,f);if(!h||h===n||Pe(t,n,h))continue;let m=`${n}\0${h}`,v=s.get(m);v||(v={from:n,to:h,evidence:[]},s.set(m,v)),v.evidence.length<pt&&v.evidence.push({file:ee(e,l),detail:`imports ${d}`});}}}return [...s.values()].map(n=>({from:n.from,to:n.to,kind:"code-import",source:"inferred",confidence:"medium",evidence:n.evidence}))}function Xt(e,t,r){let o=new Map;for(let s of r.projects){let n=Yt(e,t,s);n&&o.set(s.slug,n);}return o}function Yt(e,t,r){let o=[r.relativePath,r.externalPath].filter(s=>typeof s=="string"&&s.length>0);for(let s of o){let n=g.resolve(e,s),i=t.dirToId.get(n)??te(t,n);if(i)return i}return t.idToDir.has(r.slug)?r.slug:null}function gt(e,t,r){let o=[],s=Xt(e,t,r),n=g$2,i=new Map,a=new Map;for(let c of r.projects){let l=s.get(c.slug);if(!l)continue;let u=c.contracts??{publishes:[],consumes:[],dependsOn:[]};for(let p of u.dependsOn??[]){let d=s.get(p);!d||d===l||o.push({from:l,to:d,kind:"service-dependsOn",source:"contract",confidence:"high",evidence:[{file:n,detail:`dependsOn ${p}`}]});}for(let p of u.publishes??[])i.has(p)||i.set(p,new Set),i.get(p)?.add(l);for(let p of u.consumes??[])a.has(p)||a.set(p,new Set),a.get(p)?.add(l);}for(let[c,l]of i.entries()){let u=a.get(c);if(u)for(let p of u)for(let d of l)p!==d&&o.push({from:p,to:d,kind:"event-pub-sub",source:"contract",confidence:"high",evidence:[{file:n,detail:`consumes event ${c}`}]});}return o.push(...Qt(r,s)),o}function ke(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function Qt(e,t){let r=[],o=e.projects.map(s=>({project:s,id:t.get(s.slug)})).filter(s=>!!s.id).filter(s=>ke(s.project.slug).length>=3);for(let s of e.projects){let n=t.get(s.slug);if(!n)continue;let i=s.contracts?.env??[];if(i.length===0)continue;let a=new Set;for(let c of i){let l=ke(c);for(let u of o)u.id===n||a.has(u.id)||!(l.includes(ke(u.project.slug))&&(u.project.ports?.length??0)>0)||(a.add(u.id),r.push({from:n,to:u.id,kind:"shared-resource",source:"inferred",confidence:"low",evidence:[{file:g$2,detail:`env ${c} references ${u.project.slug}`}]}));}}return r}async function ht(e,t){let r=await ve(g.join(e,ct)),o=Array.isArray(r?.edges)?r?.edges:[],s=[],n=new Set(f$1);for(let i of o){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i,c=typeof a.from=="string"?a.from:"",l=typeof a.to=="string"?a.to:"",u=typeof a.kind=="string"?a.kind:"";if(!t.has(c)||!t.has(l)||c===l||!n.has(u))continue;let p=Array.isArray(a.evidence)?a.evidence.map(d=>d&&typeof d=="object"&&typeof d.file=="string"?{file:d.file,...typeof d.detail=="string"?{detail:d.detail}:{}}:null).filter(d=>!!d):[];s.push({from:c,to:l,kind:u,source:"manual",confidence:"high",evidence:p.length>0?p:[{file:ct,detail:"manual edge"}]});}return s}function Zt(e){return `${e.from}\0${e.to}\0${e.kind}`}function er(e){let t=new Set,r=[];for(let o of e){let s=`${o.file}\0${o.detail??""}`;t.has(s)||(t.add(s),r.push(o));}return r.sort((o,s)=>o.file.localeCompare(s.file)||(o.detail??"").localeCompare(s.detail??"")).slice(0,pt)}function tr(e){let t=new Map;for(let r of e){let o=Zt(r),s=t.get(o);if(!s){t.set(o,{...r,evidence:[...r.evidence]});continue}let n=dt[s.source],i=dt[r.source];i>n?t.set(o,{...r,evidence:[...r.evidence,...s.evidence]}):i===n&&s.evidence.push(...r.evidence);}return [...t.values()].map(r=>({from:r.from,to:r.to,kind:r.kind,source:r.source,confidence:r.confidence,evidence:er(r.evidence)})).sort((r,o)=>r.from.localeCompare(o.from)||r.to.localeCompare(o.to)||r.kind.localeCompare(o.kind)||r.source.localeCompare(o.source))}function ye(e){return Math.round(e*1e3)/1e3}function rr(e){return Math.max(0,Math.min(100,Math.round(e)))}function nr(e){return e>=75?"critical":e>=50?"high":e>=20?"medium":"low"}function or(e){return e==="critical"||e==="high"?"strict":e==="medium"?"elevated":"normal"}function sr(e,t){let r=a$6({nodes:e,edges:t}),o=new Map;for(let s of e){let n=r.byId.get(s.id)??{fanIn:0,fanOut:0,reach:0,betweenness:0,isHotspot:false},i=t.filter(f=>f.from===s.id||f.to===s.id),a=i.filter(f=>f.source==="contract"||f.source==="manual").length,c=i.filter(f=>f.confidence==="low").length,l=[],u=n.reach*20+n.fanIn*14+n.fanOut*8+Math.min(20,n.betweenness*4)+a*8;n.isHotspot&&(u+=24,l.push("Critical-path hotspot in dependency graph")),n.reach>0&&l.push(`Change reaches ${n.reach} dependent project(s)`),n.fanIn>0&&l.push(`${n.fanIn} direct dependent project(s)`),n.fanOut>0&&l.push(`${n.fanOut} direct dependency project(s)`),a>0&&l.push(`${a} contract/manual edge(s)`),c>0&&l.push(`${c} low-confidence inferred edge(s) need review`),i.length===0&&l.push(e.length===1?"Single-project workspace; inter-project dependency edges are not applicable":"No dependency evidence connected to this project yet");let p=rr(u),d=nr(p);o.set(s.id,{weight:d,score:p,verificationPriority:or(d),reasons:l.slice(0,5),centrality:{fanIn:n.fanIn,fanOut:n.fanOut,reach:n.reach,betweenness:n.betweenness,isHotspot:n.isHotspot}});}return o}function ar(e,t){let r=sr(e,t);return e.map(o=>({...o,operationalProfile:r.get(o.id)}))}function ir(e,t){let r=new Set;for(let c of t)r.add(c.from),r.add(c.to);let o=e.length,s=t.length,n=e.filter(c=>r.has(c.id)).length,i=Math.max(0,o-n),a=a$6({nodes:e,edges:t});return {nodeCount:o,edgeCount:s,inferredEdges:t.filter(c=>c.source==="inferred").length,contractEdges:t.filter(c=>c.source==="contract").length,manualEdges:t.filter(c=>c.source==="manual").length,authoritativeEdges:t.filter(c=>c.source==="contract"||c.source==="manual").length,lowConfidenceEdges:t.filter(c=>c.confidence==="low").length,orphanCount:i,connectedNodeCount:n,density:ye(o>1?s/(o*(o-1)):0),edgeCoverageRatio:ye(o>0?n/o:1),evidenceCoverageRatio:ye(s>0?t.filter(c=>c.evidence.length>0).length/s:1),hotspotCount:a.hotspots.length,hasCycle:dr(e,t)}}function cr(e,t,r){let o=[],s=e.filter(n=>!t.some(i=>i.from===n.id||i.to===n.id)).map(n=>n.id).sort((n,i)=>n.localeCompare(i));return r.nodeCount===0&&o.push({code:"graph.empty",severity:"info",message:"Workspace model has no projects, so dependency reasoning is unavailable.",recommendation:"Import, scaffold, or register projects before relying on graph-aware impact."}),r.nodeCount>1&&r.edgeCount===0?o.push({code:"graph.edges.missing",severity:"warning",message:"Projects were detected, but no inter-project dependency edges were found.",recommendation:"Run graph explain, add workspace contract relationships, or define manual graph overrides for operational dependencies that code imports cannot reveal.",nodeIds:s}):r.nodeCount>1&&r.orphanCount>0&&o.push({code:"graph.orphans.detected",severity:"warning",message:`${r.orphanCount} project(s) have no dependency evidence connected to the graph.`,recommendation:"Review isolated projects and add package, contract, or manual edges when they participate in release-critical flows.",nodeIds:s.slice(0,12)}),r.lowConfidenceEdges>0&&o.push({code:"graph.low_confidence_edges",severity:"info",message:`${r.lowConfidenceEdges} inferred edge(s) are low confidence.`,recommendation:"Promote important low-confidence relationships to workspace contract or manual overrides."}),r.edgeCount>0&&r.evidenceCoverageRatio<1&&o.push({code:"graph.evidence.partial",severity:"warning",message:"Some dependency edges do not include file-level evidence.",recommendation:"Attach evidence to manual overrides so agents can audit why a relationship exists."}),r.hasCycle&&o.push({code:"graph.cycle.detected",severity:"error",message:"The dependency graph contains at least one directed cycle.",recommendation:"Break the cycle or document the relationship explicitly before using graph-aware release gates."}),o.sort((n,i)=>{let a={error:0,warning:1,info:2};return a[n.severity]-a[i.severity]||n.code.localeCompare(i.code)})}function dr(e,t){let r=new Map;for(let c of e)r.set(c.id,[]);for(let c of t)r.has(c.from)||r.set(c.from,[]),r.get(c.from)?.push(c.to);let o=0,s=1,n=2,i=new Map;for(let c of r.keys())i.set(c,o);let a=c=>{let l=[{id:c,index:0}];for(i.set(c,s);l.length>0;){let u=l[l.length-1],p=r.get(u.id)??[];if(u.index>=p.length){i.set(u.id,n),l.pop();continue}let d=p[u.index];u.index+=1;let f=i.get(d)??o;if(f===s)return true;f===o&&(i.set(d,s),l.push({id:d,index:0}));}return false};for(let c of [...r.keys()].sort())if(i.get(c)===o&&a(c))return true;return false}function kt(e$1,t,r,o){let s=tr(r.filter(c=>t.has(c.from)&&t.has(c.to))),n=ar(e$1,s),i=ir(e$1,s),a=cr(e$1,s,i);return {schemaVersion:e,generatedAt:(o??new Date).toISOString(),nodes:n,edges:s,stats:i,...a.length>0?{diagnostics:a}:{}}}async function yt(e){let t=g.resolve(e.workspacePath),r=e.maxImportFilesPerProject??lt,o=ut(e.model),s=new Set(o.map(a=>a.id)),n=ft(t,e.model),i=[];return i.push(...await mt(t,n)),i.push(...await be(t,n,r)),e.contract&&i.push(...gt(t,n,e.contract)),i.push(...await ht(t,s)),kt(o,s,i,e.now)}async function wt(e){let t=g.resolve(e.workspacePath),r=e.maxImportFilesPerProject??lt,o=ut(e.model),s=new Set(o.map(a=>a.id)),n=ft(t,e.model),i=[];if(i.push(...await mt(t,n)),e.structuralChange)i.push(...await be(t,n,r));else {i.push(...await be(t,n,r,e.changedProjectIds));for(let a of e.previousGraph.edges)a.kind==="code-import"&&a.source==="inferred"&&!e.changedProjectIds.has(a.from)&&s.has(a.from)&&s.has(a.to)&&i.push({from:a.from,to:a.to,kind:"code-import",source:"inferred",confidence:a.confidence,evidence:a.evidence});}return e.contract&&i.push(...gt(t,n,e.contract)),i.push(...await ht(t,s)),kt(o,s,i,e.now)}var re="workspace-model-producer.v3";var Se=s.workspaceModelCache.schemaVersion,Ce=t$1.workspaceModelCache,mr=["package.json","pyproject.toml","setup.py","requirements.txt","requirements.in","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","composer.json","Gemfile","Gemfile.lock","mix.exs","mix.lock","deno.json","deno.jsonc","deno.lock","bun.lock","bun.lockb","bunfig.toml",".bunfig.toml","deps.edn","project.clj","build.sbt","CMakeLists.txt","meson.build","workspai.project.json",".workspai/project.json",".workspai/context.json","rapidkit.project.json",".rapidkit/project.json",".rapidkit/context.json"],gr=[".csproj",".fsproj",".vbproj",".sln",".slnx",".gemspec"],vt=[t$1.workspaceContract,".workspai/workspace.json","workspai.workspace.json",".workspai/policies.yml",".workspai/policies.yaml",".rapidkit/workspace.contract.json",".rapidkit/workspace.json","rapidkit.workspace.json",".rapidkit/policies.yml",".rapidkit/policies.yaml"],bt=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".vue",".svelte",".rb",".go",".py",".java",".kt",".kts",".rs",".cs",".php",".ex",".exs",".clj",".cljs",".scala",".c",".cc",".cpp",".cxx",".h",".hh",".hpp",".hxx",".proto",".graphql",".gql",".sql",".sh"]),hr=new Set([".git",".workspai",".rapidkit","node_modules","dist","build","out","target","coverage",".next",".turbo",".cache",".venv"]),kr=1500,ne=promisify(execFile);function yr(e){return bt.has(g.extname(e).toLowerCase())}async function wr(e){try{let{stdout:t}=await ne("git",["-C",e,"rev-parse","--show-toplevel"],{encoding:"utf8",timeout:1e4,maxBuffer:1048576}),r=t.trim();if(!r)return null;let o=g.relative(r,e).split(g.sep).join("/");if(o===".."||o.startsWith("../"))return null;let s=o||".",n=o?`HEAD:${o}`:"HEAD^{tree}",{stdout:i}=await ne("git",["-C",r,"rev-parse",n],{encoding:"utf8",timeout:1e4,maxBuffer:1024*1024}),[a,c]=await Promise.all([ne("git",["-C",r,"diff","--name-only","-z","HEAD","--",s],{encoding:"buffer",timeout:2e4,maxBuffer:64*1024*1024}),ne("git",["-C",r,"ls-files","--others","--exclude-standard","-z","--",s],{encoding:"buffer",timeout:2e4,maxBuffer:64*1024*1024})]),l=new Set([a.stdout,c.stdout].flatMap(p=>p.toString("utf8").split("\0")).filter(Boolean)),u=[`git-tree:${i.trim()}`];for(let p of [...l].sort((d,f)=>d.localeCompare(f))){let d=g.resolve(r,p),f=g.relative(e,d).split(g.sep).join("/");f===".."||f.startsWith("../")||!yr(f)||u.push(`${f}:${await z(d)??"<deleted>"}`);}return u}catch{return null}}var U=null;function Ee(){if(U)return U;try{U=createRequire(import.meta.url)("../package.json")?.version??"0.0.0";}catch{U="0.0.0";}return U}async function z(e){try{let t=await C.readFile(e);return Nt.createHash("sha256").update(t).digest("hex")}catch{return null}}async function Pt(e){let t={};for(let o of mr){let s=await z(g.join(e,o));s&&(t[o]=s);}let r=await C.readdir(e).catch(()=>[]);for(let o of r.sort((s,n)=>s.localeCompare(n))){if(!gr.some(n=>o.toLowerCase().endsWith(n)))continue;let s=await z(g.join(e,o));s&&(t[o]=s);}return t}async function vr(e){let t=await Pt(e),r=await wr(e),o=r??[];if(r)return _({manifests:t,source:o});let s=[e];for(;s.length>0&&o.length<kr;){let n=s.shift();if(!n)continue;let i=[];try{i=await C.readdir(n,{withFileTypes:true});}catch{continue}let a=[];for(let c of i)if(c.isDirectory()){if(hr.has(c.name)||a$5(c.name)||c.name.startsWith("."))continue;a.push(g.join(n,c.name));}else if(c.isFile()&&bt.has(g.extname(c.name))){let l=g.join(n,c.name),u=await C.stat(l).catch(()=>null);if(u){let p=g.relative(e,l).split(g.sep).join("/");o.push(`${p}:${u.size}:${Math.round(u.mtimeMs)}`);}}a.sort((c,l)=>c.localeCompare(l)),s.push(...a);}return o.sort((n,i)=>n.localeCompare(i)),_({manifests:t,source:o})}async function oe(e,t){let r=g.resolve(e),o={},s=[...new Set(t.map(n=>g.relative(r,g.resolve(n)).split(g.sep).join("/")))].sort((n,i)=>n.localeCompare(i));for(let n of s)o[n]=await vr(g.join(r,n));return o}async function se(e){let t=g.resolve(e),r={};for(let o of vt){let s=await z(g.join(t,o));s&&(r[o]=s);}return r}async function ae(e){let t=g.resolve(e.workspacePath),r=[...new Set(e.projectPaths.map(n=>g.relative(t,g.resolve(n)).split(g.sep).join("/")))].sort((n,i)=>n.localeCompare(i)),o=[];for(let n of r){let i=await Pt(g.join(t,n));o.push({project:n,manifests:i});}let s={};for(let n of vt){let i=await z(g.join(t,n));i&&(s[n]=i);}return _({cacheSchema:Se,cliVersion:e.cliVersion,flags:e.flags,workspaceJson:e.workspaceJson??null,marker:e.marker??null,projects:o,workspaceFiles:s})}async function We(e){let t=await g$1(e,Ce)??a$4(e,Ce);try{if(!await C.pathExists(t))return null;let r=await C.readJson(t);return !r||r.schemaVersion!==Se||r.producerRevision!==re||typeof r.inputsHash!="string"||typeof r.cliVersion!="string"||!r.model?null:r}catch{return null}}async function ie(e,t){let r={schemaVersion:Se,producerRevision:re,...t};return h(e,Ce,r)}var jt="rapidkit-fact-freshness-v1",q={durable:720*60*60,derived:10080*60,evidenceBacked:1440*60,live:300,verifyBeforeUse:1440*60};function br(e){switch(e){case "durable":return q.durable;case "derived":return q.derived;case "evidence-backed":return q.evidenceBacked;case "live":return q.live;case "verify-before-use":return q.verifyBeforeUse}}function Pr(e){if(e.status)return e.status;if(e.ttlSeconds===null)return "unknown";let t=Date.parse(e.generatedAt);if(!Number.isFinite(t))return "unknown";let r=t+e.ttlSeconds*1e3;return e.now.getTime()>r?"stale":"fresh"}function jr(e){let t=e.now??new Date,r=e.generatedAt??t.toISOString(),o=Date.parse(r),s=Number.isFinite(o),n=s?r:t.toISOString(),i=e.ttlSeconds===void 0?br(e.kind):e.ttlSeconds,a=Pr({generatedAt:n,ttlSeconds:i,status:e.status??(s?void 0:"unknown"),now:t}),c=Date.parse(n),l=i===null||!Number.isFinite(c)?void 0:new Date(c+i*1e3),u=e.verifyBeforeUse??(e.kind==="live"||e.kind==="verify-before-use"||e.category!=="structure"||a!=="fresh");return {schemaVersion:jt,kind:e.kind,category:e.category,generatedAt:n,ttlSeconds:i,...l?{expiresAt:l.toISOString()}:{},status:a,verifyBeforeUse:u,...e.sourceArtifact?{sourceArtifact:e.sourceArtifact}:{},...e.sourcePath?{sourcePath:e.sourcePath}:{},inputsHash:e.inputsHash??_(e.value??null),reason:e.reason}}function b(e){return {id:e.id,label:e.label,scope:e.scope,value:e.value,...e.project?{project:e.project}:{},freshness:jr({...e.freshness,value:e.value})}}function Ct(e){let t=e.generatedAt??(e.now??new Date).toISOString(),r={durable:0,derived:0,"evidence-backed":0,live:0,"verify-before-use":0},o={structure:0,verification:0,state:0},s=0,n=0,i=0,a=0;for(let c of e.facts)r[c.freshness.kind]+=1,o[c.freshness.category]+=1,c.freshness.status==="stale"&&(s+=1),c.freshness.status==="unknown"&&(n+=1),c.freshness.kind==="live"&&(i+=1),c.freshness.verifyBeforeUse&&(a+=1);return {schemaVersion:jt,generatedAt:t,status:s>0?"stale":n>0?"unknown":"fresh",totalFacts:e.facts.length,staleFacts:s,unknownFacts:n,liveFacts:i,verifyBeforeUseFacts:a,byKind:r,byCategory:o}}function J(e,t){let r=[...new Set(e)],o=r.filter(s=>t.has(s)).length;return {eligibleCount:r.length,boundCount:o,unknownCount:r.length-o,coverageRatio:r.length===0?null:o/r.length}}function St(e,t){let r=e.filter(d=>d.kind==="project").map(d=>d.id),o=e.filter(d=>d.kind==="endpoint").map(d=>d.id),s=new Set(o),n=e.filter(d=>d.kind==="api"&&!!d.projectId&&d.attributes.runtimeRegistrationRequired===true).map(d=>d.id),i=new Set(n),a=new Map(e.map(d=>[d.id,d.kind])),c=new Set(t.filter(d=>d.kind==="implements"||d.kind==="defines"&&a.get(d.from)==="file"&&a.get(d.to)==="endpoint").flatMap(d=>s.has(d.from)?[d.from]:s.has(d.to)?[d.to]:[])),l=new Set(t.filter(d=>d.kind==="implements"&&(a.get(d.from)==="runtime-unit"||a.get(d.to)==="runtime-unit")).flatMap(d=>i.has(d.from)?[d.from]:i.has(d.to)?[d.to]:[])),u=new Set(r),p=d=>new Set(t.filter(f=>f.kind===d).flatMap(f=>[f.from,f.to]).filter(f=>u.has(f)));return {apiImplementation:J(o,c),apiRuntimeRegistration:J(n,l),projectTests:J(r,p("tests")),projectDeployment:J(r,p("deploys")),projectOwnership:J(r,p("owns"))}}function Et(e,t){return e.filter(o=>o.code.includes("unknown")||o.code.includes("unresolved")||o.code.includes("limit_reached")||o.code.endsWith(".empty_result")).reduce((o,s)=>o+Math.max(s.entityIds?.length??0,s.relationIds?.length??0,1),0)+Object.values(t).reduce((o,s)=>o+s.unknownCount,0)}function Re(e,t){return t===0?1:e/t}function Cr(e,t,r,o){return e.entityIds?.some(s=>t.has(s))||e.relationIds?.some(s=>r.has(s))?true:e.entityIds?.length||e.relationIds?.length?false:!/\bproject\b/i.test(e.message)||e.message.includes(o)}function Sr(e,t,r,o,s){let n=new Set(s.filter(a=>a.provider===e.id).map(a=>a.id)),i=e.inputCoverage?.filter(a=>a.scope==="workspace"||a.scope==="project"&&a.scopeId===t);return {...e,discoveredEntities:r.filter(a=>a.proofIds.some(c=>n.has(c))).length,discoveredRelations:o.filter(a=>a.proofIds.some(c=>n.has(c))).length,proofCount:n.size,...i?{inputCoverage:i}:{}}}function Er(e,t){let r=new Set(e.entities.filter(m=>m.projectId===t).map(m=>m.id)),o=e.relations.filter(m=>r.has(m.from)||r.has(m.to)),s=new Set(r);for(let m of o)s.add(m.from),s.add(m.to);let n=e.entities.filter(m=>s.has(m.id)),i=new Set([...n,...o].flatMap(m=>m.proofIds)),a=e.proofs.filter(m=>i.has(m.id)),c=new Set(o.map(m=>m.id)),l=e.diagnostics.filter(m=>Cr(m,s,c,t)),u=e.providers.map(m=>Sr(m,t,n,o,a)),p=e.source.inputs?.scopes.filter(m=>m.kind==="workspace"||m.kind==="project"&&m.id===t)??[],d=p.filter(m=>!m.truncated).length,f=u.reduce((m,v)=>(v.status==="failed"?m.failed+=1:v.status==="skipped"||v.inputCoverage?.every(W=>W.status==="not-applicable")?m.notApplicable+=1:v.status==="partial"||v.inputCoverage?.some(W=>W.status==="bounded")?m.bounded+=1:m.complete+=1,m),{complete:0,bounded:0,notApplicable:0,failed:0}),h=St(n,o);return {...e,entities:n,relations:o,proofs:a,providers:u,quality:{entityCount:n.length,relationCount:o.length,proofCount:a.length,entityProofCoverageRatio:Re(n.filter(m=>m.proofIds.length>0).length,n.length),relationProofCoverageRatio:Re(o.filter(m=>m.proofIds.length>0).length,o.length),providerSuccessRatio:Re(u.filter(m=>m.status!=="failed").length,u.length),conflictCount:l.filter(m=>m.code.includes("conflict")).length,unknownCount:Et(l,h),bindingCoverage:h,...e.quality.completeness?{completeness:{status:p.some(m=>m.truncated)||f.bounded>0||f.failed>0?"bounded":"complete",inventory:{scopeCount:p.length,completeScopes:d,boundedScopes:p.length-d,eligibleFiles:p.reduce((m,v)=>m+(v.eligibleFileCount??v.fileCount),0),indexedFiles:p.reduce((m,v)=>m+v.fileCount,0),eligibleFileCountExact:p.every(m=>m.eligibleFileCountExact!==false)},providers:f}}:{},portable:true,secretValuesEmitted:false},diagnostics:l}}var Wr=s.projectKnowledgeGraphReference.schemaVersion;function Wt(e,t){let r=Er(e,t),o={schemaVersion:Wr,generatedAt:e.generatedAt,project:{name:t},canonical:{graph:"workspace:.workspai/reports/workspace-knowledge-graph.json",boundedQuery:`workspai workspace graph search <task-query> --scope project:${t} --limit 12 --json`,sourceHash:e.source.hash,projectionHash:c$1(r)},summary:{entityCount:r.entities.length,relationCount:r.relations.length,proofCount:r.proofs.length}};return {...o,integrity:{algorithm:"sha256",payloadHash:c$1(o),portable:true,absolutePathsEmitted:false}}}function Rt(e,t){return d(e,t.path,{...t.absolutePath?{absolutePath:t.absolutePath}:{}})}var Rr=q$2.model,de=p.model;function xe(e){return e.projectTopology??e.graph}function At(e){return !!(e.projectTopology&&e.graph&&c$1(e.projectTopology)===c$1(e.graph))}function mo(e){let t=e.engineStatus==="hit"||e.engineStatus==="unchanged"?"reused":e.engineStatus==="incremental"?"partially-reused":"rebuilt";return {schemaVersion:"workspace-model-build.v1",mode:e.mode,outcome:t,engineStatus:e.engineStatus}}var xr=["package.json","pyproject.toml","requirements.txt","go.mod","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","composer.json","Gemfile","mix.exs","deno.json","deno.jsonc","bun.lock","bun.lockb","bunfig.toml",".bunfig.toml","deps.edn","project.clj","build.sbt","docker-compose.yml","docker-compose.yaml","compose.yml","compose.yaml","terraform.tf"],Ar=new Set([".git",".hg",".svn",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next",".turbo"]);function Mr(e,t){return (g.relative(e,t)||".").split(g.sep).join("/")}function ce(e,t){return Mr(e,d(e,t.path,{...t.absolutePath?{absolutePath:t.absolutePath}:{}}))}async function Mt(e){try{if(!await C.pathExists(e))return null;let t=await C.readJSON(e);return t&&typeof t=="object"?t:null}catch{return null}}async function Ir(e,t){for(let r of t)if(await C.pathExists(g.join(e,r)))return true;return false}function Ae(e){let t=Number.parseInt(process.env.RAPIDKIT_WORKSPACE_MODEL_SCAN_DEPTH??"",10),r=typeof e=="number"&&Number.isFinite(e)?e:Number.isFinite(t)?t:4;return Math.min(12,Math.max(1,Math.trunc(r)))}async function Fr(e,t){let r=g.resolve(e),o=[{dirPath:r,depth:0}],s=new Set,n=new Set;for(;o.length>0;){let i=o.shift();if(!i)continue;let a=g.resolve(i.dirPath);if(n.has(a))continue;if(n.add(a),a!==r&&await Ir(a,xr)){s.add(a);continue}if(i.depth>=t)continue;let c=[];try{c=await C.readdir(a,{withFileTypes:true});}catch{continue}for(let l of c)!l.isDirectory()||Ar.has(l.name)||a$5(l.name)||l.name.startsWith(".")&&l.name!==".config"||o.push({dirPath:g.join(a,l.name),depth:i.depth+1});}return Array.from(s).sort((i,a)=>i.localeCompare(a))}function Dr(e){let t=new Set,r=[];for(let o of e){let s=g.resolve(o);t.has(s)||(t.add(s),r.push(s));}return r.sort((o,s)=>o.localeCompare(s))}function xt(e,t){let r=e?.[t];return typeof r=="string"&&r.trim()?r.trim():void 0}function Or(e,t){return e?.[t]===true}function Gr(e,t,r){let o=e?.frontend&&typeof e.frontend=="object"&&!Array.isArray(e.frontend)?e.frontend:void 0,s=xt(o,"generator"),n=xt(o,"command_display"),i=typeof t=="string"&&t.startsWith("frontend.");if(!(!s&&!i))return {...s?{id:s}:{},...t?{kit:t}:{},displayName:r,source:Or(o,"official_generator")?"official-generator":"metadata",...n?{commandDisplay:n}:{}}}async function _r(e){let t=[".workspai/project.json",".workspai/context.json",".rapidkit/project.json",".rapidkit/context.json","package.json","product.json","tsconfig.json","pnpm-workspace.yaml","bunfig.toml",".bunfig.toml","nx.json","turbo.json","pyproject.toml","requirements.txt","go.mod","go.work","go.work.sum","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","rust-toolchain.toml","rust-toolchain","CMakeLists.txt","meson.build","Makefile","WORKSPACE","WORKSPACE.bazel","MODULE.bazel","BUILD","BUILD.bazel",".bazelrc","composer.json","Gemfile","mix.exs","deno.json","setup.py","setup.cfg","Dockerfile","docker-compose.yml","docker-compose.yaml","compose.yml","compose.yaml","README.md"],r=[];for(let s of t)await C.pathExists(g.join(e,s))&&r.push(s);let o=new Set(["package.json","pyproject.toml","go.mod","go.work","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","CMakeLists.txt","meson.build","composer.json","Gemfile","mix.exs","deno.json"]);if(!r.some(s=>o.has(s))){let s=[],n=new Set([".git",".workspai",".rapidkit",".venv","build","dist","node_modules","target","third_party","vendor"]),i=(p,d)=>{let f=p.toLowerCase();return ["package.json","pyproject.toml","go.mod","pom.xml","build.gradle","build.gradle.kts","cargo.toml","cmakelists.txt","meson.build","composer.json","gemfile","mix.exs","deno.json"].includes(f)||f.endsWith(".gemspec")||f==="description"&&d.toLowerCase()==="r"},a=async(p,d)=>{if(d>3||s.length>=512)return;let f=await C.readdir(p,{withFileTypes:true}).catch(()=>[]);for(let h of f.sort((m,v)=>m.name.localeCompare(v.name))){if(s.length>=512)return;h.isFile()&&i(h.name,g.basename(p))?s.push(g.relative(e,g.join(p,h.name)).split(g.sep).join("/")):h.isDirectory()&&!n.has(h.name)&&await a(g.join(p,h.name),d+1);}};await a(e,0);let c=new Map;for(let p of s){let d=p.split("/")[0],f=c.get(d)??[];f.push(p),c.set(d,f);}for(let p of c.values())p.sort((d,f)=>d.split("/").length-f.split("/").length||d.localeCompare(f));let l=[],u=[...c.keys()].sort();for(let p=0;l.length<16&&u.some(d=>p<(c.get(d)?.length??0));p+=1)for(let d of u){let f=c.get(d)?.[p];f&&l.length<16&&l.push(f);}r.push(...l.filter(p=>!r.includes(p)));}return r}async function A(e,t,r,o=t){let s=await g$1(e,t),n=s!==null,i={path:o.split(g.sep).join("/"),exists:n};if(s&&r){let a=await Mt(s);typeof a?.generatedAt=="string"&&(i.generatedAt=a.generatedAt);let c=a?.status??a?.result??a?.verdict;typeof c=="string"&&(i.status=c);}return i}async function Tr(e,t,r,o){let s=".workspai/reports",n=c=>A(t,`${s}/${c}`,r,`${o}/${s}/${c}`),i=await n("doctor-project-last-run.json");return {doctor:i?.exists===true?i:await n("doctor-last-run.json"),remediationPlan:await n("doctor-remediation-plan-last-run.json"),fixResult:await n("doctor-fix-result-last-run.json"),analyze:await n("analyze-last-run.json"),readiness:await n("release-readiness-last-run.json")}}async function Nr(e,t,r){let o=j$2(t,{searchParents:false}),s=q$3(t),n=s&&!j$3(o)?s.detection:m(t,o),i=D(t),a=f(n.runtime),c=await b$2(t,o,{runtime:n.runtime,framework:n.key}),l$1=r.contractProject?.slug?r.contractProject.slug:typeof o?.name=="string"&&o.name.trim()?o.name.trim():g.basename(t),u=j$3(o)?`adopted.${n.key}`:typeof o?.kit_name=="string"?o.kit_name:typeof o?.kit=="string"?o.kit:r.contractProject?.kit,p=typeof o?.engine=="string"?o.engine:i.engine!=="unknown"?i.engine:void 0,d=Gr(o,u,n.displayName),f$1=it({kitId:u,framework:n.key,runtime:n.runtime}),h=l(t),m$1=[n.runtime,...h.filter(T=>T!==n.runtime)],v=await c$2({projectPath:t,declaration:r.contractProject?.governance}),W=b$3({workspacePath:e,projectPath:t,projectName:l$1,declaredRelativePath:r.contractProject?.relativePath});return {name:l$1,path:W,...r.includeAbsolutePaths?{absolutePath:t}:{},kind:c,category:a$3(c),runtime:n.runtime,runtimeCandidates:m$1,framework:n.key,frameworkDisplayName:n.displayName,confidence:n.confidence,detectionSource:n.source,supportTier:n.supportTier,runtimeSupportTier:a.tier,runtimeDoctorSupport:a.doctorSupport,moduleSupport:i.moduleSupport,...u?{kit:u}:{},...p?{engine:p}:{},...d?{generator:d}:{},createCapability:f$1,commands:{supported:i.supportedCommands,unsupported:i.unsupportedCommands,global:i.globalCommands,fleetStages:i.fleetStages,localOnly:i.localOnlyCommands,map:i.commandMap},importantFiles:await _r(t),governance:v,evidence:await Tr(e,t,r.includeEvidence,W),provenance:{path:r.contractProject?"workspace contract declaration reconciled with filesystem discovery":"filesystem discovery",runtime:n.source,framework:n.source,commands:"project command capability matrix",createCapability:"create planner capability contract",governance:r.contractProject?.governance!==void 0?"workspace contract declaration reconciled with repository evidence":"repository and documented external governance discovery",evidence:"project .workspai/reports"}}}async function Kr(e){for(let t$1 of t(e,"workspace.json")){let r=await Mt(t$1);if(r)return r}return null}function $r(e){if(e.length===0)return "empty-workspace";let t=new Set(e.map(r=>r.category));return t.size>1?"polyglot-product-workspace":t.has("frontend")&&e.length>1?"full-stack-workspace":t.has("frontend")?"frontend-workspace":t.has("desktop")?"desktop-application-workspace":t.has("extension")?"extension-workspace":t.has("agent")?e.length>1?"agent-platform-workspace":"agent-workspace":t.has("platform")?"platform-workspace":t.has("library")?"library-workspace":e.length>1?"backend-platform":"backend-workspace"}function Vr(e){let t=new Set;for(let r of e){let o=`${r.name} ${r.path}`.toLowerCase();for(let s of ["auth","billing","payment","notification","order","admin","report","search","analytics"])o.includes(s)&&t.add(s);}return Array.from(t).sort()}function j(e,t,r,o){return {severity:e,code:t,message:r,target:o}}function It(e){let t=[];if(e.workspace.name.trim()||t.push(j("error","workspace.name.missing","Workspace name could not be resolved.","workspace")),e.workspace.type==="observed-workspace"&&t.push(j("warning","workspace.marker.missing","Workspace marker is missing; model is based on filesystem observation.","workspace.marker")),e.summary.projectCount===0&&t.push(j("warning","workspace.projects.empty","No project roots were detected in this workspace.","projects")),e.workspace.profile){let n=P$1({profile:e.workspace.profile,runtimes:e.summary.runtimes});n.ok||t.push(j("warning","workspace.profile.mismatch",[n.message,n.recommendedCommand?`Keep the current profile and run ${n.recommendedCommand} when you want the recommended profile.`:void 0].filter(Boolean).join(" "),"workspace.profile"));}e.contracts.exists||t.push(j("warning","workspace.contract.missing","Workspace contract is missing; dependency and API edges may be incomplete.",e.contracts.workspaceContractPath));let r=new Map;for(let n of e.projects){let i=n.name.toLowerCase(),a=r.get(i)??[];a.push(n),r.set(i,a),n.importantFiles.length||t.push(j("warning","project.markers.missing",`Project ${n.name} has no important manifest files recorded.`,n.path));let c=d(e.workspace.root,n.path,{...n.absolutePath?{absolutePath:n.absolutePath}:{}});C.existsSync(c)||t.push(j("warning","project.path.missing",`Registered project ${n.name} is not available at its declared path.`,n.path)),n.runtime==="unknown"&&t.push(j("warning","project.runtime.unknown",`Project ${n.name} runtime could not be confidently detected.`,n.path));let l=["test","build"];for(let d of l)n.commands.supported.includes(d)&&n.commands.unsupported.includes(d)&&t.push(j("error","project.commands.conflict",`Project ${n.name} marks ${d} as both supported and unsupported.`,n.path));let u=new Set(n.commands.fleetStages),p=new Set(n.commands.localOnly);for(let d of n.commands.fleetStages){p.has(d)&&t.push(j("error","project.commands.scope-conflict",`Project ${n.name} marks ${d} as both fleet and local-only.`,n.path));let f=n.commands.map[d];(!f||f.fleetEligible!==true||f.executionScope!=="fleet")&&t.push(j("error","project.commands.fleet-stage-invalid",`Project ${n.name} advertises ${d} as a fleet stage without a supported fleet capability.`,n.path));}for(let d of n.commands.localOnly){let f=n.commands.map[d];(!f||f.status!=="supported"||f.executionScope!=="local-only"||f.fleetEligible===true)&&t.push(j("error","project.commands.local-only-invalid",`Project ${n.name} advertises ${d} as local-only without a matching local-only capability.`,n.path));}for(let d of Object.values(n.commands.map))d.status==="supported"&&(d.fleetEligible===true&&!u.has(d.command)&&t.push(j("error","project.commands.fleet-stage-missing",`Project ${n.name} capability ${d.command} is fleet-eligible but missing from fleetStages.`,n.path)),d.executionScope==="local-only"&&d.fleetEligible!==true&&!p.has(d.command)&&t.push(j("error","project.commands.local-only-missing",`Project ${n.name} capability ${d.command} is local-only but missing from localOnly commands.`,n.path)));}for(let[n,i]of r.entries())i.length>1&&t.push(j("error","project.name.duplicate",`Project name "${n}" is ambiguous across ${i.length} project roots.`,i.map(a=>a.path).join(", ")));e.projectTopology&&e.graph&&c$1({...e.projectTopology,generatedAt:"<ignored>"})!==c$1({...e.graph,generatedAt:"<ignored>"})&&t.push(j("error","workspace.project-topology.alias-mismatch","Deprecated model.graph must remain structurally identical to canonical model.projectTopology during the v1 migration window.","projectTopology"));let o=t.filter(n=>n.severity==="error").length,s=t.filter(n=>n.severity==="warning").length;return {status:o>0?"failed":s>0?"warning":"passed",errors:o,warnings:s,issues:t}}function go(e){return It(e)}function P(e){return e.join(".")}function Hr(e,t){let r=de,o=e.generatedAt,s=[b({id:"workspace.name",label:"Workspace name",scope:"workspace",value:e.workspace.name,freshness:{kind:"durable",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:P(["workspace","name"]),reason:"Workspace identity is structural metadata and changes through workspace setup."}}),b({id:"workspace.type",label:"Workspace type",scope:"workspace",value:e.identity.workspaceType,freshness:{kind:"derived",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:P(["identity","workspaceType"]),reason:"Workspace type is derived from the current project inventory."}}),b({id:"workspace.projectCount",label:"Project count",scope:"workspace",value:e.summary.projectCount,freshness:{kind:"derived",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:P(["summary","projectCount"]),reason:"Project count is derived from workspace discovery and should be refreshed after structural changes."}}),b({id:"workspace.runtimeFamilies",label:"Runtime families",scope:"workspace",value:e.identity.runtimeFamilies,freshness:{kind:"derived",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:P(["identity","runtimeFamilies"]),reason:"Runtime coverage is inferred from project surfaces."}}),b({id:"workspace.policyMode",label:"Workspace policy mode",scope:"policy",value:e.policies.mode,freshness:{kind:"durable",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:P(["policies","mode"]),reason:"Policy mode is configuration, not runtime state."}}),b({id:"workspace.contract.exists",label:"Workspace contract presence",scope:"contract",value:e.contracts.exists,freshness:{kind:"derived",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:P(["contracts","exists"]),reason:"Contract presence is derived from workspace files and should be refreshed before release gating."}})],n=xe(e);n&&s.push(b({id:"graph.edgeCount",label:"Dependency graph edge count",scope:"graph",value:n.stats.edgeCount,freshness:{kind:"derived",category:"structure",generatedAt:n.generatedAt??o,now:t,sourceArtifact:r,sourcePath:P(["projectTopology","stats","edgeCount"]),reason:"Graph topology is derived from manifests, imports, and workspace contracts."}}),b({id:"graph.evidenceCoverageRatio",label:"Dependency graph evidence coverage",scope:"graph",value:n.stats.evidenceCoverageRatio,freshness:{kind:"derived",category:"structure",generatedAt:n.generatedAt??o,now:t,sourceArtifact:r,sourcePath:P(["projectTopology","stats","evidenceCoverageRatio"]),reason:"Graph evidence coverage changes when dependency evidence or contract edges change."}}));for(let[i,a]of e.projects.entries()){let c=`projects[${i}]`,l={kind:"derived",category:"structure",generatedAt:o,now:t,sourceArtifact:r,reason:"Project facts are derived from workspace discovery, project metadata, and framework probes."};s.push(b({id:`project.${a.name}.kind`,label:`${a.name} kind`,scope:"project",project:a.name,value:a.kind,freshness:{...l,sourcePath:P([c,"kind"])}}),b({id:`project.${a.name}.category`,label:`${a.name} category`,scope:"project",project:a.name,value:a.category,freshness:{...l,sourcePath:P([c,"category"])}}),b({id:`project.${a.name}.runtime`,label:`${a.name} runtime`,scope:"project",project:a.name,value:a.runtime,freshness:{...l,sourcePath:P([c,"runtime"])}}),b({id:`project.${a.name}.framework`,label:`${a.name} framework`,scope:"project",project:a.name,value:a.frameworkDisplayName,freshness:{...l,sourcePath:P([c,"frameworkDisplayName"])}}),b({id:`project.${a.name}.supportTier`,label:`${a.name} support tier`,scope:"project",project:a.name,value:a.supportTier,freshness:{...l,sourcePath:P([c,"supportTier"])}}),b({id:`project.${a.name}.safeFleetStages`,label:`${a.name} safe fleet stages`,scope:"command",project:a.name,value:a.commands.fleetStages,freshness:{...l,sourcePath:P([c,"commands","fleetStages"]),reason:"Safe command availability is derived from package and project command surfaces."}}),...["ci","release","ownership"].map(u=>b({id:`project.${a.name}.governance.${u}`,label:`${a.name} ${u} governance`,scope:"policy",project:a.name,value:a.governance?.[u]??{status:"unknown",provider:null,evidence:[],reference:null},freshness:{...l,sourcePath:P([c,"governance",u]),reason:"Governance truth is reconciled from repository surfaces and explicit workspace contract declarations."}})));for(let[u,p]of Object.entries(a.evidence))s.push(b({id:`project.${a.name}.evidence.${u}`,label:`${a.name} ${u} evidence`,scope:"evidence",project:a.name,value:p?{path:p.path,exists:p.exists,status:p.status??null}:{exists:false},freshness:{kind:p?.exists?"evidence-backed":"verify-before-use",category:"verification",generatedAt:p?.generatedAt??o,now:t,status:p?.exists?void 0:"unknown",sourceArtifact:p?.path??r,sourcePath:P([c,"evidence",u]),verifyBeforeUse:true,reason:p?.exists?"Evidence reports can expire or become stale after source changes.":"Missing evidence must be generated before this fact is used for verification."}}));}for(let[i,a]of Object.entries(e.evidence))s.push(b({id:`workspace.evidence.${i}`,label:`Workspace ${i} evidence`,scope:"evidence",value:a?{path:a.path,exists:a.exists,status:a.status??null}:null,freshness:{kind:a?.exists?"evidence-backed":"verify-before-use",category:"verification",generatedAt:a?.generatedAt??o,now:t,status:a?.exists?void 0:"unknown",sourceArtifact:a?.path??r,sourcePath:P(["evidence",i]),verifyBeforeUse:true,reason:a?.exists?"Workspace evidence can expire or become stale after project, dependency, or policy changes.":"Missing workspace evidence must be generated before release or repair decisions."}}));return s}async function Me(e,t){let[r,o,s,n,i,a$3]=await Promise.all([a(e),Kr(e),Ie(e),a$1(e),a$2(e,{descendIntoMatchedProjects:false}),Fr(e,t)]),c=new Map;for(let u of s?.projects??[]){let p=d(e,u.relativePath,u.externalPath?{absolutePath:u.externalPath}:{});c.set(p,u);}let l=Dr([...i,...a$3.filter(u=>!i.some(p=>{let d=g.relative(p,u);return d!==""&&d!==".."&&!d.startsWith(`..${g.sep}`)&&!g.isAbsolute(d)})),...c.keys(),...n.map(u=>d(e,u.relativePath||u.name,u.path?{absolutePath:u.path}:{}))]);return {marker:r,workspaceJson:o,workspaceContract:s,contractProjectPaths:c,projectPaths:l}}async function le(e){let t$2=g.resolve(e.workspacePath),r=e.includeAbsolutePaths===true,o=e.includeEvidence===true,s=Ae(e.observableScanDepth),n=e.now??new Date,{marker:i,workspaceJson:a,workspaceContract:c,contractProjectPaths:l,projectPaths:u}=await Me(t$2,s),p$1=e.reuseProjectModels,d=await Promise.all(u.map(w=>{if(p$1){let Ot=g.relative(t$2,g.resolve(w)).split(g.sep).join("/"),Fe=p$1.get(Ot);if(Fe)return Promise.resolve(Fe)}return Nr(t$2,w,{includeAbsolutePaths:r,includeEvidence:o,contractProject:l.get(g.resolve(w))})})),f=typeof a?.workspace_name=="string"?a.workspace_name:typeof a?.name=="string"?a.name:i?.name||c?.workspace.name||g.basename(t$2),h=typeof a?.profile=="string"?a.profile:typeof a?.mode=="string"?a.mode:c?.workspace.profile,m=Array.from(new Set(d.map(w=>w.kind))).sort(),v=Array.from(new Set(d.map(w=>w.category))).sort(),W=Array.from(new Set(d.flatMap(w=>w.runtimeCandidates.length>0?w.runtimeCandidates:[w.runtime]))).sort(),T=Array.from(new Set(d.map(w=>w.framework))).sort(),N=[".workspai/policies.yml",".workspai/policies.yaml",".rapidkit/policies.yml",".rapidkit/policies.yaml"].find(w=>C.existsSync(g.join(t$2,w))),X=t(t$2,"workspace.contract.json").map(w=>g.relative(t$2,w).split(g.sep).join("/")).find(w=>C.existsSync(g.join(t$2,w)))??t$1.workspaceContract,O=await C.pathExists(g.join(t$2,X)),Y={schemaVersion:Rr,generatedAt:n.toISOString(),workspace:{name:f,root:t$2,...h?{profile:h}:{},type:i?"rapidkit-workspace":"observed-workspace",...i?{marker:{createdBy:i.createdBy,version:i.version,createdAt:i.createdAt}}:{}},identity:{workspaceType:$r(d),surfaces:m,categories:v,runtimeFamilies:W,businessCapabilities:Vr(d)},discovery:{observableScanDepth:s},projects:d,policies:{mode:typeof a?.policy_mode=="string"?a.policy_mode:typeof a?.policyMode=="string"?a.policyMode:"warn",source:N??null,exists:!!N},contracts:{workspaceContractPath:X,exists:O,status:O?"known":"missing"},evidence:{doctor:await A(t$2,p.doctor,o),projectDoctor:await A(t$2,t$1.doctorProject,o),doctorRemediationPlan:await A(t$2,t$1.doctorRemediationPlan,o),artifactRemediationPlan:await A(t$2,t$1.artifactRemediationPlan,o),doctorFixResult:await A(t$2,t$1.doctorFixResult,o),analyze:await A(t$2,p.analyze,o),readiness:await A(t$2,p.readiness,o),pipeline:await A(t$2,t$1.pipelineLastRun,o)},summary:{projectCount:d.length,runtimes:W,frameworks:T,firstClassProjects:d.filter(w=>w.supportTier==="first-class").length,extendedProjects:d.filter(w=>w.supportTier==="extended").length,observedProjects:d.filter(w=>w.supportTier==="observed").length}},S=await Ft(t$2,Y,{contractExists:O,now:n,incrementalGraph:e.incrementalGraph}),E={...Y,projectTopology:S,graph:S},G=It(E),K=Hr({...E},n),Dt=Ct({facts:K,generatedAt:n.toISOString(),now:n});return {...E,facts:K,factFreshness:Dt,validation:G}}async function ho(e){if(e.cache!==true)return {model:await le(e),cache:"disabled"};let t=g.resolve(e.workspacePath),r=Ae(e.observableScanDepth),o=Ee(),{marker:s,workspaceJson:n,projectPaths:i}=await Me(t,r),a=await ae({workspacePath:t,cliVersion:o,flags:{includeAbsolutePaths:e.includeAbsolutePaths===true,includeEvidence:e.includeEvidence===true,observableScanDepth:r},projectPaths:i,workspaceJson:n,marker:s}),c=await We(t);if(c&&c.cliVersion===o&&c.inputsHash===a&&At(c.model))return {model:c.model,cache:"hit"};let l=await le({...e}),[u,p]=await Promise.all([oe(t,i),se(t)]);return await ie(t,{cliVersion:o,inputsHash:a,generatedAt:(e.now??new Date).toISOString(),model:l,projectSignatures:u,workspaceFileSignatures:p}),{model:l,cache:"miss"}}function Br(e,t){let r=new Set,o=new Set,s=new Set;for(let[n,i]of Object.entries(t))n in e?e[n]!==i&&r.add(n):o.add(n);for(let n of Object.keys(e))n in t||s.add(n);return {changed:r,added:o,removed:s}}function Lr(e={},t={}){let r=new Set([...Object.keys(e),...Object.keys(t)]);for(let o of r)if(e[o]!==t[o])return false;return true}async function ko(e){let t=g.resolve(e.workspacePath),r=Ae(e.observableScanDepth),o=Ee(),s=e.now??new Date,{marker:n,workspaceJson:i,projectPaths:a}=await Me(t,r),c=await We(t),l=async()=>{let S=await le({...e}),E=await ae({workspacePath:t,cliVersion:o,flags:{includeAbsolutePaths:e.includeAbsolutePaths===true,includeEvidence:e.includeEvidence===true,observableScanDepth:r},projectPaths:a,workspaceJson:i,marker:n}),[G,K]=await Promise.all([oe(t,a),se(t)]);return await ie(t,{cliVersion:o,inputsHash:E,generatedAt:s.toISOString(),model:S,projectSignatures:G,workspaceFileSignatures:K}),{model:S,mode:"full"}},u=c?xe(c.model):void 0;if(!c||c.cliVersion!==o||!c.projectSignatures||!u||!At(c.model))return l();let p=await se(t);if(!Lr(c.workspaceFileSignatures,p))return l();let d=await oe(t,a),{changed:f,added:h,removed:m}=Br(c.projectSignatures,d);if(f.size===0&&h.size===0&&m.size===0)return {model:c.model,mode:"unchanged"};let v=new Set([...f,...h]),W=new Map;for(let S of c.model.projects){let E=ce(t,S);!v.has(E)&&!m.has(E)&&W.set(E,S);}let T=new Set,N=false;for(let S of c.model.projects){let E=ce(t,S);f.has(E)&&T.add(S.name);}let X=h.size>0||m.size>0,O=await le({...e,reuseProjectModels:W,incrementalGraph:{previousGraph:u,changedProjectIds:T,structuralChange:X||N}});for(let S of c.model.projects){let E=ce(t,S);if(!f.has(E))continue;let G=O.projects.find(K=>ce(t,K)===E);if(G&&G.name!==S.name){N=true;break}}if(N)return l();let Y=await ae({workspacePath:t,cliVersion:o,flags:{includeAbsolutePaths:e.includeAbsolutePaths===true,includeEvidence:e.includeEvidence===true,observableScanDepth:r},projectPaths:a,workspaceJson:i,marker:n});return await ie(t,{cliVersion:o,inputsHash:Y,generatedAt:s.toISOString(),model:O,projectSignatures:d,workspaceFileSignatures:p}),{model:O,mode:"incremental"}}async function Ie(e){try{let{contract:t}=await p$1({workspacePath:e});return t&&typeof t=="object"?t:null}catch{return null}}async function Ft(e,t,r){let o=r.contractExists?await Ie(e):null;try{return r.incrementalGraph?await wt({workspacePath:e,model:t,contract:o,now:r.now,previousGraph:r.incrementalGraph.previousGraph,changedProjectIds:r.incrementalGraph.changedProjectIds,structuralChange:r.incrementalGraph.structuralChange}):await yt({workspacePath:e,model:t,contract:o,now:r.now})}catch{let s=t.projects.map(n=>({id:n.name,path:n.path}));return {schemaVersion:"workspace-dependency-graph.v1",generatedAt:r.now.toISOString(),nodes:s,edges:[],stats:{nodeCount:s.length,edgeCount:0,inferredEdges:0,contractEdges:0,manualEdges:0,authoritativeEdges:0,lowConfidenceEdges:0,orphanCount:s.length,connectedNodeCount:0,density:0,edgeCoverageRatio:s.length>0?0:1,evidenceCoverageRatio:1,hotspotCount:0,hasCycle:false},diagnostics:s.length>1?[{code:"graph.inference.failed",severity:"warning",message:"Dependency graph inference failed; model contains projects but no dependency edges.",recommendation:"Run workspace model again after fixing graph inputs, or add workspace contract/manual graph overrides.",nodeIds:s.map(n=>n.id).sort((n,i)=>n.localeCompare(i))}]:void 0}}}async function yo(e,t,r={}){let o=e.contracts.exists?await Ie(t):null,{buildWorkspaceKnowledgeGraph:s}=await import('./workspace-knowledge-graph-EFC4TUDZ.js'),n=d$1(e),i=r.refreshKnowledgeGraph?null:await C.readJson(g.join(t,p.knowledgeGraph)).then(p=>p).catch(()=>null),a=await s({workspacePath:t,workspace:{name:e.workspace.name,...e.workspace.profile?{profile:e.workspace.profile}:{}},projects:e.projects.map(p=>({id:p.name,path:p.path,...p.absolutePath?{absolutePath:p.absolutePath}:{},runtime:p.runtime,runtimeCandidates:p.runtimeCandidates,framework:p.framework,kind:p.kind,category:p.category,...p.governance?{governance:p.governance}:{},...p.kit?{kit:p.kit}:{}})),projectTopology:xe(e)??await Ft(t,e,{contractExists:e.contracts.exists,now:new Date(e.generatedAt)}),contract:o,now:new Date(e.generatedAt),source:{kind:"workspace-model",artifact:de,hashAlgorithm:"sha256",hash:d$2(n)},previousGraph:i}),c=[],l=new Map;for(let p of e.projects){let d=Rt(t,p);if(!(await C.stat(d).catch(()=>null))?.isDirectory())continue;let h=await C.realpath(d),m=l.get(h);if(m)throw new Error(`Projects ${m} and ${p.name} resolve to the same graph artifact root: ${d}`);l.set(h,p.name),c.push({rootPath:d,relativePath:t$1.projectKnowledgeGraphReference,payload:Wt(a,p.name)});}let u=await j$1(t,de,[{rootPath:t,relativePath:p.knowledgeGraph,payload:a},{rootPath:t,relativePath:de,payload:n},...c]);for(let p$1 of c){let d=g.join(p$1.rootPath,p.knowledgeGraph);(await C.readJson(d).catch(()=>null))?.schemaVersion===q$2.knowledgeGraph&&await C.remove(d).catch(()=>{});}return u[1]}export{it as a,Xr as b,en as c,_ as d,jt as e,b as f,Ct as g,St as h,Et as i,Er as j,Rt as k,Rr as l,de as m,xe as n,mo as o,go as p,Hr as q,le as r,ho as s,ko as t,yo as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {g,b,i,d as d$1,e,f}from'./chunk-SCKEFXF5.js';import {c as c$1}from'./chunk-X7FYEKLI.js';import {d as d$2,b as b$1,a as a$1}from'./chunk-3RBUSW7H.js';import {c}from'./chunk-OA2YJN22.js';import {a}from'./chunk-AFIFZTOY.js';import {d}from'./chunk-EWZZUQBR.js';import {u,h,g as g$1}from'./chunk-VQZ5PI5J.js';import {s,p,t}from'./chunk-ODK4LCEL.js';import Ee from'crypto';import se from'fs';import y from'fs/promises';import l from'path';import {execa}from'execa';import Q from'fs-extra';async function Z(e,t){let[n,r]=await Promise.all([Q.realpath(e).catch(()=>null),Q.realpath(t).catch(()=>null)]);if(!n||!r)return null;let s=l.relative(n,r);return !s||l.isAbsolute(s)||s===".."||s.startsWith(`..${l.sep}`)?null:(await Q.stat(r).catch(()=>null))?.isFile()?r:null}var Ge=s.projectContextAgent.schemaVersion,yt=["managed","local","off"],ae="<!-- WORKSPAI:PROJECT-GROUNDING:START -->",Ce="<!-- WORKSPAI:PROJECT-GROUNDING:END -->",te="<!-- WORKSPAI:GENERATED-PROJECT-SKILL -->",B=".agents/skills/workspai-grounding/SKILL.md";function ke(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}async function A(e){try{return JSON.parse(await y.readFile(e,"utf8"))}catch(t){return null}}function $(e){return e.replace(/\\/g,"/").replace(/^\.\/+/,"")}function _(e,t,n){let r=e.replace(/\\/g,"/"),s=/^[A-Za-z]:\//.test(r);if(!l.isAbsolute(e)&&!s)return $(r);if(s&&process.platform!=="win32")return null;let a=l.resolve(e),i=l.relative(n,a);if(i&&!i.startsWith("..")&&!l.isAbsolute(i))return $(i);let c=l.relative(t,a);return c&&!c.startsWith("..")&&!l.isAbsolute(c)?`workspace:${$(c)}`:null}function I(e,t,n){return [[n,"project:"],[n.replace(/\\/g,"/"),"project:"],[t,"workspace:"],[t.replace(/\\/g,"/"),"workspace:"]].reduce((s,[a,i])=>a.length>0?s.split(a).join(i):s,e)}function Re(e,t){return ke(e?.adoption)?.mode==="linked"?"adopted":ke(e?.import)?"imported":t}function We(e){if(!e.model)return null;let t=$(e.relativePath);return e.model.projects.find(n=>n.name===e.projectName||$(n.path)===t)??null}function U(e,t){e[t]=(e[t]??0)+1;}var we=["project","language","service","api","endpoint","schema","protocol","runtime-unit","lifecycle-stage","database","queue","container","deployment","pipeline","environment","test-suite","owner","decision","document","package","file","module","symbol"],oe=48,ye=16,re=12*1024;function Oe(e,t=oe,n=re){let r={language:12,api:8,service:8,endpoint:8,schema:8,protocol:8,"runtime-unit":12,"lifecycle-stage":12,file:4,module:4,symbol:4},s=new Map,a={};for(let u of e)U(a,u.kind);for(let u of we)s.set(u,e.filter(w=>w.kind===u).sort((w,f)=>w.label.localeCompare(f.label)||w.id.localeCompare(f.id)).slice(0,r[u]??6));let i=[],c={},h=0,g=0,d=true;for(;i.length<t&&d;){d=false;for(let u of we){let w=s.get(u)?.[g];if(!w)continue;let f=Buffer.byteLength(JSON.stringify(w));if(!(h+f>n)&&(i.push(w),h+=f,U(c,u),d=true,i.length>=t))break}g+=1;}let m=Object.fromEntries(Object.entries(a).map(([u,w])=>[u,w-(c[u]??0)]).filter(([,u])=>u>0).sort(([u],[w])=>u.localeCompare(w)));return {entities:i,selectedBytes:h,selectedByKind:c,omittedByKind:m}}function Ke(e,t){if(!e)return {entityCount:0,relationCount:0,proofCount:0,entitiesByKind:{},relationsByKind:{},languages:{},semantic:{protocolConceptCount:0,protocolImplementationBindings:0,equivalenceBindings:0,generationBindings:0,runtimeUnitCount:0,lifecycleStageCount:0,runtimeCoverage:[]},projection:{mode:"stratified-byte-bounded",maxEntities:oe,byteBudget:re,selectedBytes:0,eligibleCount:0,selectedCount:0,omittedCount:0,selectedByKind:{},omittedByKind:{}},relatedProjects:[],proofArtifacts:[],entities:[],relations:[],proofs:[],topology:{status:"unavailable",dependencies:[],dependents:[]},diagnostics:[]};let n=e.entities.find(o=>o.kind==="project"&&(o.id===t||o.label===t||o.projectId===t)),r=new Set(e.entities.filter(o=>o.projectId===t||o.id===n?.id||o.kind==="project"&&o.label===t).map(o=>o.id));n&&r.add(n.id);let s=e.relations.filter(o=>r.has(o.from)||r.has(o.to)),a=new Set(r);for(let o of s)a.add(o.from),a.add(o.to);let i=e.entities.filter(o=>a.has(o.id)),c=new Set,h={},g={},d={},m=new Set(i.filter(o=>o.kind==="language").map(o=>o.attributes.language).filter(o=>typeof o=="string"));for(let o of i){U(h,o.kind);let k=typeof o.attributes.language=="string"?o.attributes.language:void 0;if(k&&o.kind==="language")d[k]={fileCount:typeof o.attributes.fileCount=="number"?o.attributes.fileCount:0,symbolCount:d[k]?.symbolCount??0,generatedFileCount:typeof o.attributes.generatedFileCount=="number"?o.attributes.generatedFileCount:0};else if(k&&(o.kind==="file"||o.kind==="symbol")){let p=d[k]??{fileCount:0,symbolCount:0,generatedFileCount:0};o.kind==="file"&&!m.has(k)?(p.fileCount+=1,o.attributes.generated===true&&(p.generatedFileCount+=1)):o.kind==="symbol"&&(p.symbolCount+=1),d[k]=p;}for(let p of o.proofIds)c.add(p);}for(let o of s){U(g,o.kind);for(let k of o.proofIds)c.add(k);}let u=e.proofs.filter(o=>c.has(o.id)),w=[...new Set(e.entities.filter(o=>a.has(o.id)&&o.projectId&&o.projectId!==t).map(o=>o.projectId))].sort(),f=e.diagnostics.filter(o=>(!o.entityIds||o.entityIds.length===0)&&(!o.relationIds||o.relationIds.length===0)||o.entityIds?.some(k=>a.has(k))||o.relationIds?.some(k=>s.some(p=>p.id===k))).map(o=>({code:o.code,severity:o.severity,message:o.message,...o.recommendation?{recommendation:o.recommendation}:{}})),j=(o,k)=>({project:k,kind:o.kind,source:o.source,confidence:o.confidence,evidence:[...new Set(o.evidence.map(p=>p.file.replace(/\\/g,"/")))].sort()}),P=e.projectTopology.edges.filter(o=>o.from===t).map(o=>j(o,o.to)).sort((o,k)=>`${o.project}:${o.kind}`.localeCompare(`${k.project}:${k.kind}`)),S=e.projectTopology.edges.filter(o=>o.to===t).map(o=>j(o,o.from)).sort((o,k)=>`${o.project}:${o.kind}`.localeCompare(`${k.project}:${k.kind}`)),N=Oe(i),T=N.entities,G=i.filter(o=>o.kind==="runtime-unit"),b=new Set(T.map(o=>o.id)),W=[...s].sort((o,k)=>{let p=Number(b.has(o.from)||b.has(o.to));return Number(b.has(k.from)||b.has(k.to))-p||o.id.localeCompare(k.id)}).slice(0,16),H=new Set([...T.flatMap(o=>o.proofIds),...W.flatMap(o=>o.proofIds)]),D=u.filter(o=>H.has(o.id)).sort((o,k)=>o.id.localeCompare(k.id)).slice(0,16);return {entityCount:i.length,relationCount:s.length,proofCount:u.length,entitiesByKind:h,relationsByKind:g,languages:Object.fromEntries(Object.entries(d).sort(([o],[k])=>o.localeCompare(k))),semantic:{protocolConceptCount:h.protocol??0,protocolImplementationBindings:g["implements-protocol"]??0,equivalenceBindings:g["equivalent-to"]??0,generationBindings:(g["generated-from"]??0)+(g["generated-by"]??0),runtimeUnitCount:G.length,lifecycleStageCount:h["lifecycle-stage"]??0,runtimeCoverage:[...new Set(G.map(o=>o.attributes.runtime).filter(o=>typeof o=="string"))].sort()},projection:{mode:"stratified-byte-bounded",maxEntities:oe,byteBudget:re,selectedBytes:N.selectedBytes,eligibleCount:i.length,selectedCount:T.length,omittedCount:Math.max(0,i.length-T.length),selectedByKind:Object.fromEntries(Object.entries(N.selectedByKind).sort(([o],[k])=>o.localeCompare(k))),omittedByKind:N.omittedByKind},relatedProjects:w,proofArtifacts:[...new Set(D.map(o=>o.artifact))].sort().slice(0,24),entities:T,relations:W,proofs:D,topology:{status:P.length>0||S.length>0?"proven":e.projectTopology.nodes.some(o=>o.id===t)?"unproven":"unavailable",dependencies:P,dependents:S},diagnostics:f}}function Se(e,t,n){return Array.isArray(e)?e.map(r=>typeof r=="string"?I(r,t,n):r):typeof e=="string"?I(e,t,n):e}function _e(e,t,n){return {id:e.id,kind:e.kind,label:I(e.label,t,n),attributes:Object.fromEntries(Object.entries(e.attributes).map(([r,s])=>[r,Se(s,t,n)])),proofIds:[...e.proofIds].sort()}}function Fe(e,t,n){let r=(...a)=>e.filter(i=>a.includes(i.kind)).map(i=>_e(i,t,n)).slice(0,4),s=[];for(let a of e){for(let[i,c]of Object.entries(a.attributes))if(/(?:^|[-_.])ports?(?:$|[-_.])/i.test(i)&&(s.push({entityId:a.id,label:I(a.label,t,n),attribute:i,value:Se(c,t,n)}),s.length>=8))break;if(s.length>=8)break}return {services:r("service"),packages:r("package"),protocols:r("protocol"),runtimeUnits:r("runtime-unit"),lifecycleStages:r("lifecycle-stage"),apis:r("api"),endpoints:r("endpoint"),dataStores:r("database","queue"),deployments:r("container","deployment","environment"),pipelines:r("pipeline"),tests:r("test-suite"),owners:r("owner"),decisions:r("decision"),ports:s}}function Be(e,t,n){let r=_(e.artifact,t,n);return r?{id:e.id,provider:e.provider,artifact:r,...e.pointer?{pointer:I(e.pointer,t,n)}:{},...e.line!==void 0?{line:e.line}:{},derivation:e.derivation,trust:e.trust,confidence:e.confidence,freshness:e.freshness}:null}async function Me(e,t,n){let r=[],s=await A(l.join(e,".workspai","reports","INDEX.json"));if(Array.isArray(s?.blockers))for(let d of s.blockers)typeof d=="string"&&(d.startsWith(`${n}:`)||d.includes(`project:${n}`)||d.includes(`project ${n}`))&&r.push({source:"workspace-report-index",severity:"error",message:I(d,e,t)});let a=await A(l.join(e,".workspai","reports","doctor-project-last-run.json")),i=await A(l.join(e,".workspai","reports","doctor-last-run.json")),c=i?.projects?.find(d=>d.name===n),g=[...a?.project&&(a.projectName===n||a.project.name===n)?[{generatedAt:a.generatedAt,project:a.project}]:[],...c?[{generatedAt:i?.generatedAt,project:c}]:[]].sort((d,m)=>{let u=typeof d.generatedAt=="string"&&Date.parse(d.generatedAt)||0;return (typeof m.generatedAt=="string"&&Date.parse(m.generatedAt)||0)-u})[0];if(g)for(let d of c$1({project:g.project}))r.push({source:"doctor-project",severity:d.status==="blocking"?"error":"warning",message:I(d.message,e,t),...d.id?{code:d.id}:{}});return [...new Map(r.map(d=>[`${d.source}:${d.code??""}:${d.message}`,d])).values()].slice(0,32)}function ne(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(n=>n.length>0&&(e.includes(n)||e.includes(n.replace(/\\/g,"/")))):Array.isArray(e)?e.some(n=>ne(n,t)):e&&typeof e=="object"?Object.values(e).some(n=>ne(n,t)):false}function De(e){return Ee.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function Je(e){let t$1=l.resolve(e.workspacePath),n=l.resolve(e.projectPath),r=u(n,"project.json").find(p=>se.existsSync(p)),s=r?await A(r):null,a$1=await A(l.join(t$1,".workspai","workspace.contract.json")),i=l.resolve(n),c=a$1?.projects?.find(p=>p.externalPath?l.resolve(p.externalPath)===i:!p.relativePath||p.relativePath.startsWith("external/")?false:l.resolve(t$1,p.relativePath)===i)??a$1?.projects?.find(p=>p.slug===e.projectName||p.slug===l.basename(n)),h=e.projectName??(typeof s?.name=="string"?s.name:void 0)??c?.slug??l.basename(n),g=c?.relativePath??(()=>{let p=$(l.relative(t$1,n));return !p||p.startsWith("..")?`external/${h}`:p})(),d$1=await A(l.join(t$1,p.model)),m=await A(l.join(t$1,p.knowledgeGraph)),u$1=d$1?d(d$1):void 0,w=!!(u$1&&m?.source.hash===u$1),f=We({model:d$1,projectName:h,relativePath:g}),j=Ke(w?m:null,h),P=await Me(t$1,n,h),S=j.proofs.map(p=>p.freshness),N=m?!w||S.includes("stale")?"stale":S.includes("unknown")?"unknown":"fresh":"missing",T=d$1?d$1.factFreshness?.status??"unknown":"missing",b$1=[...[...d$1?[]:[{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."}],...d$1&&!f?[{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."}]:[],...m?[]:[{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."}],...m&&!w?[{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."}]:[]],...j.diagnostics].filter((p,E,Ne)=>Ne.findIndex(ie=>ie.code===p.code&&ie.message===p.message)===E),W=Math.max(0,b$1.length-ye+1),H=W>0?[...b$1.slice(0,ye-1),{code:"project.context.diagnostics-truncated",severity:"info",message:`${W} additional diagnostic(s) remain available in the canonical Workspace Knowledge Graph.`,recommendation:"Inspect workspace:.workspai/reports/workspace-knowledge-graph.json for the complete diagnostic set."}]:b$1,D=Re(s,e.relationship??c?.relationship??"managed"),o={schemaVersion:Ge,generatedAt:(e.now??new Date).toISOString(),workspace:{name:a$1?.workspace?.name??d$1?.workspace.name??l.basename(t$1),...a$1?.workspace?.profile||d$1?.workspace.profile?{profile:a$1?.workspace?.profile??d$1?.workspace.profile}:{},relationship:D,contract:`workspace:${t.workspaceContract}`,projectKnowledgeGraph:t.projectKnowledgeGraphReference,model:`workspace:${p.model}`,knowledgeGraph:`workspace:${p.knowledgeGraph}`,index:`workspace:${p.agentIndex}`,context:`workspace:${p.agentContext}`,skillsIndex:`workspace:${p.skillsIndex}`,boundedGraphSearch:`workspai workspace graph search <task-query> --scope project:${h} --limit 12 --json`,access:{localBinding:t.projectWorkspaceLink,canonicalEvidenceAvailableAtGeneration:true,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"}},project:{name:h,relativePath:g,...f?.kind?{kind:f.kind}:{},...f?.runtime||c?.runtime?{runtime:f?.runtime??c?.runtime}:{},...f?.runtimeCandidates?.length?{runtimeCandidates:[...f.runtimeCandidates].sort()}:{},...f?.framework||c?.framework?{framework:f?.framework??c?.framework}:{},...f?.kit||c?.kit?{kit:f?.kit??c?.kit}:{},...f?.supportTier?{supportTier:f.supportTier}:{},...f?.governance?{governance:f.governance}:{},commands:{supported:[...f?.commands.supported??[]].sort(),unsupported:[...f?.commands.unsupported??[]].sort(),fleetStages:[...f?.commands.fleetStages??[]].sort()},importantFiles:[...new Set((f?.importantFiles??[]).map(p=>_(p,t$1,n)).filter(p=>p!==null))].sort()},intelligence:{...d$1?.generatedAt?{modelGeneratedAt:d$1.generatedAt}:{},...m?.generatedAt?{graphGeneratedAt:m.generatedAt}:{},...m?.source.hash?{graphModelHash:m.source.hash}:{},entityCount:j.entityCount,relationCount:j.relationCount,proofCount:j.proofCount,entitiesByKind:j.entitiesByKind,relationsByKind:j.relationsByKind,languages:j.languages,semantic:j.semantic,projection:{...j.projection,continuationCommand:`workspai workspace graph search <task-query> --scope project:${h} --limit 12 --json`},relatedProjects:j.relatedProjects,freshness:{model:T,graph:N,graphMatchesModel:w},topology:{...j.topology,dependencies:j.topology.dependencies.map(p=>({...p,evidence:p.evidence.map(E=>_(E,t$1,n)).filter(E=>E!==null)})),dependents:j.topology.dependents.map(p=>({...p,evidence:p.evidence.map(E=>_(E,t$1,n)).filter(E=>E!==null)}))},surfaces:Fe(j.entities,t$1,n),diagnostics:H.map(p=>({...p,message:I(p.message,t$1,n),...p.recommendation?{recommendation:I(p.recommendation,t$1,n)}:{}}))},evidence:{readOrder:[b,".workspai/PROJECT-GROUNDING.md",t.projectContextAgent,"AGENTS.md","workspace:.workspai/goals/index.json",`workspace:${t.goalPackLastRun}`,"workspace:.workspai/reports/workspace-skills-index.json",`command:workspai workspace graph search <task-query> --scope project:${h} --limit 12 --json`],projectProofArtifacts:[...new Set(j.proofArtifacts.map(p=>_(p,t$1,n)).filter(p=>p!==null))],relations:j.relations.map(p=>({id:p.id,from:p.from,to:p.to,kind:p.kind,derivation:p.derivation,trust:p.trust,confidence:p.confidence,proofIds:[...p.proofIds].sort()})),proofs:j.proofs.map(p=>Be(p,t$1,n)).filter(p=>p!==null)},blockers:P,agentRouting:{enforcement:"required",mandatoryPreflight:{command:"workspai agent bootstrap --for-agent generic --strict --json",successCondition:"ready"},workspaceLocator:{command:"workspai project workspace status --json",successCondition:"resolved",outputClassification:"machine-local",persistence:"forbidden",disclosure:"forbidden",portableUriScheme:"workspace:"},workspaceEvidenceRequiredFor:["repository-analysis","architecture-analysis","change-impact","cross-project-change","contract-change","infrastructure-change","release-readiness"],requiredReadOrder:[b,"command:workspai agent bootstrap --for-agent generic --strict --json","command:workspai project workspace status --json",t.projectContextAgent,"workspace:.workspai/reports/workspace-skills-index.json",`command:workspai workspace graph search ${JSON.stringify(h)} --scope ${JSON.stringify(`project:${h}`)} --limit 12 --json`],degradedMode:{allowCompleteArchitectureClaims:false,requireDisclosure:true}},commands:{refresh:"workspai workspace intelligence run --for-agent generic --strict --json",verify:"workspai workspace verify --strict --json",graphSearch:`workspai workspace graph search ${JSON.stringify(h)} --scope ${JSON.stringify(`project:${h}`)} --limit 12 --json`,doctor:"workspai doctor project --json",workspaceStatus:"workspai project workspace status --json"}};if(ne(o,[t$1,n]))throw new Error("Project context lens rejected a non-portable absolute path.");let k={...o,integrity:{algorithm:"sha256",...u$1?{modelHash:u$1}:{},payloadHash:De(o),portable:true,absolutePathsEmitted:false}};return a(k,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent"),k}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.",n=e.intelligence.diagnostics.length>0?e.intelligence.diagnostics.slice(0,8).map(s=>`- **${s.severity} \xB7 ${s.code}:** ${s.message}`).join(`
|
|
1
|
+
import {g,b,i,d as d$1,e,f}from'./chunk-23CNBYIW.js';import {c as c$1}from'./chunk-X7FYEKLI.js';import {d as d$2,b as b$1,a as a$1}from'./chunk-3RBUSW7H.js';import {c}from'./chunk-DWDYLKVW.js';import {a}from'./chunk-AFIFZTOY.js';import {d}from'./chunk-EWZZUQBR.js';import {u,h,g as g$1}from'./chunk-VQZ5PI5J.js';import {s,p,t}from'./chunk-ODK4LCEL.js';import Ee from'crypto';import se from'fs';import y from'fs/promises';import l from'path';import {execa}from'execa';import Q from'fs-extra';async function Z(e,t){let[n,r]=await Promise.all([Q.realpath(e).catch(()=>null),Q.realpath(t).catch(()=>null)]);if(!n||!r)return null;let s=l.relative(n,r);return !s||l.isAbsolute(s)||s===".."||s.startsWith(`..${l.sep}`)?null:(await Q.stat(r).catch(()=>null))?.isFile()?r:null}var Ge=s.projectContextAgent.schemaVersion,yt=["managed","local","off"],ae="<!-- WORKSPAI:PROJECT-GROUNDING:START -->",Ce="<!-- WORKSPAI:PROJECT-GROUNDING:END -->",te="<!-- WORKSPAI:GENERATED-PROJECT-SKILL -->",B=".agents/skills/workspai-grounding/SKILL.md";function ke(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}async function A(e){try{return JSON.parse(await y.readFile(e,"utf8"))}catch(t){return null}}function $(e){return e.replace(/\\/g,"/").replace(/^\.\/+/,"")}function _(e,t,n){let r=e.replace(/\\/g,"/"),s=/^[A-Za-z]:\//.test(r);if(!l.isAbsolute(e)&&!s)return $(r);if(s&&process.platform!=="win32")return null;let a=l.resolve(e),i=l.relative(n,a);if(i&&!i.startsWith("..")&&!l.isAbsolute(i))return $(i);let c=l.relative(t,a);return c&&!c.startsWith("..")&&!l.isAbsolute(c)?`workspace:${$(c)}`:null}function I(e,t,n){return [[n,"project:"],[n.replace(/\\/g,"/"),"project:"],[t,"workspace:"],[t.replace(/\\/g,"/"),"workspace:"]].reduce((s,[a,i])=>a.length>0?s.split(a).join(i):s,e)}function Re(e,t){return ke(e?.adoption)?.mode==="linked"?"adopted":ke(e?.import)?"imported":t}function We(e){if(!e.model)return null;let t=$(e.relativePath);return e.model.projects.find(n=>n.name===e.projectName||$(n.path)===t)??null}function U(e,t){e[t]=(e[t]??0)+1;}var we=["project","language","service","api","endpoint","schema","protocol","runtime-unit","lifecycle-stage","database","queue","container","deployment","pipeline","environment","test-suite","owner","decision","document","package","file","module","symbol"],oe=48,ye=16,re=12*1024;function Oe(e,t=oe,n=re){let r={language:12,api:8,service:8,endpoint:8,schema:8,protocol:8,"runtime-unit":12,"lifecycle-stage":12,file:4,module:4,symbol:4},s=new Map,a={};for(let u of e)U(a,u.kind);for(let u of we)s.set(u,e.filter(w=>w.kind===u).sort((w,f)=>w.label.localeCompare(f.label)||w.id.localeCompare(f.id)).slice(0,r[u]??6));let i=[],c={},h=0,g=0,d=true;for(;i.length<t&&d;){d=false;for(let u of we){let w=s.get(u)?.[g];if(!w)continue;let f=Buffer.byteLength(JSON.stringify(w));if(!(h+f>n)&&(i.push(w),h+=f,U(c,u),d=true,i.length>=t))break}g+=1;}let m=Object.fromEntries(Object.entries(a).map(([u,w])=>[u,w-(c[u]??0)]).filter(([,u])=>u>0).sort(([u],[w])=>u.localeCompare(w)));return {entities:i,selectedBytes:h,selectedByKind:c,omittedByKind:m}}function Ke(e,t){if(!e)return {entityCount:0,relationCount:0,proofCount:0,entitiesByKind:{},relationsByKind:{},languages:{},semantic:{protocolConceptCount:0,protocolImplementationBindings:0,equivalenceBindings:0,generationBindings:0,runtimeUnitCount:0,lifecycleStageCount:0,runtimeCoverage:[]},projection:{mode:"stratified-byte-bounded",maxEntities:oe,byteBudget:re,selectedBytes:0,eligibleCount:0,selectedCount:0,omittedCount:0,selectedByKind:{},omittedByKind:{}},relatedProjects:[],proofArtifacts:[],entities:[],relations:[],proofs:[],topology:{status:"unavailable",dependencies:[],dependents:[]},diagnostics:[]};let n=e.entities.find(o=>o.kind==="project"&&(o.id===t||o.label===t||o.projectId===t)),r=new Set(e.entities.filter(o=>o.projectId===t||o.id===n?.id||o.kind==="project"&&o.label===t).map(o=>o.id));n&&r.add(n.id);let s=e.relations.filter(o=>r.has(o.from)||r.has(o.to)),a=new Set(r);for(let o of s)a.add(o.from),a.add(o.to);let i=e.entities.filter(o=>a.has(o.id)),c=new Set,h={},g={},d={},m=new Set(i.filter(o=>o.kind==="language").map(o=>o.attributes.language).filter(o=>typeof o=="string"));for(let o of i){U(h,o.kind);let k=typeof o.attributes.language=="string"?o.attributes.language:void 0;if(k&&o.kind==="language")d[k]={fileCount:typeof o.attributes.fileCount=="number"?o.attributes.fileCount:0,symbolCount:d[k]?.symbolCount??0,generatedFileCount:typeof o.attributes.generatedFileCount=="number"?o.attributes.generatedFileCount:0};else if(k&&(o.kind==="file"||o.kind==="symbol")){let p=d[k]??{fileCount:0,symbolCount:0,generatedFileCount:0};o.kind==="file"&&!m.has(k)?(p.fileCount+=1,o.attributes.generated===true&&(p.generatedFileCount+=1)):o.kind==="symbol"&&(p.symbolCount+=1),d[k]=p;}for(let p of o.proofIds)c.add(p);}for(let o of s){U(g,o.kind);for(let k of o.proofIds)c.add(k);}let u=e.proofs.filter(o=>c.has(o.id)),w=[...new Set(e.entities.filter(o=>a.has(o.id)&&o.projectId&&o.projectId!==t).map(o=>o.projectId))].sort(),f=e.diagnostics.filter(o=>(!o.entityIds||o.entityIds.length===0)&&(!o.relationIds||o.relationIds.length===0)||o.entityIds?.some(k=>a.has(k))||o.relationIds?.some(k=>s.some(p=>p.id===k))).map(o=>({code:o.code,severity:o.severity,message:o.message,...o.recommendation?{recommendation:o.recommendation}:{}})),j=(o,k)=>({project:k,kind:o.kind,source:o.source,confidence:o.confidence,evidence:[...new Set(o.evidence.map(p=>p.file.replace(/\\/g,"/")))].sort()}),P=e.projectTopology.edges.filter(o=>o.from===t).map(o=>j(o,o.to)).sort((o,k)=>`${o.project}:${o.kind}`.localeCompare(`${k.project}:${k.kind}`)),S=e.projectTopology.edges.filter(o=>o.to===t).map(o=>j(o,o.from)).sort((o,k)=>`${o.project}:${o.kind}`.localeCompare(`${k.project}:${k.kind}`)),N=Oe(i),T=N.entities,G=i.filter(o=>o.kind==="runtime-unit"),b=new Set(T.map(o=>o.id)),W=[...s].sort((o,k)=>{let p=Number(b.has(o.from)||b.has(o.to));return Number(b.has(k.from)||b.has(k.to))-p||o.id.localeCompare(k.id)}).slice(0,16),H=new Set([...T.flatMap(o=>o.proofIds),...W.flatMap(o=>o.proofIds)]),D=u.filter(o=>H.has(o.id)).sort((o,k)=>o.id.localeCompare(k.id)).slice(0,16);return {entityCount:i.length,relationCount:s.length,proofCount:u.length,entitiesByKind:h,relationsByKind:g,languages:Object.fromEntries(Object.entries(d).sort(([o],[k])=>o.localeCompare(k))),semantic:{protocolConceptCount:h.protocol??0,protocolImplementationBindings:g["implements-protocol"]??0,equivalenceBindings:g["equivalent-to"]??0,generationBindings:(g["generated-from"]??0)+(g["generated-by"]??0),runtimeUnitCount:G.length,lifecycleStageCount:h["lifecycle-stage"]??0,runtimeCoverage:[...new Set(G.map(o=>o.attributes.runtime).filter(o=>typeof o=="string"))].sort()},projection:{mode:"stratified-byte-bounded",maxEntities:oe,byteBudget:re,selectedBytes:N.selectedBytes,eligibleCount:i.length,selectedCount:T.length,omittedCount:Math.max(0,i.length-T.length),selectedByKind:Object.fromEntries(Object.entries(N.selectedByKind).sort(([o],[k])=>o.localeCompare(k))),omittedByKind:N.omittedByKind},relatedProjects:w,proofArtifacts:[...new Set(D.map(o=>o.artifact))].sort().slice(0,24),entities:T,relations:W,proofs:D,topology:{status:P.length>0||S.length>0?"proven":e.projectTopology.nodes.some(o=>o.id===t)?"unproven":"unavailable",dependencies:P,dependents:S},diagnostics:f}}function Se(e,t,n){return Array.isArray(e)?e.map(r=>typeof r=="string"?I(r,t,n):r):typeof e=="string"?I(e,t,n):e}function _e(e,t,n){return {id:e.id,kind:e.kind,label:I(e.label,t,n),attributes:Object.fromEntries(Object.entries(e.attributes).map(([r,s])=>[r,Se(s,t,n)])),proofIds:[...e.proofIds].sort()}}function Fe(e,t,n){let r=(...a)=>e.filter(i=>a.includes(i.kind)).map(i=>_e(i,t,n)).slice(0,4),s=[];for(let a of e){for(let[i,c]of Object.entries(a.attributes))if(/(?:^|[-_.])ports?(?:$|[-_.])/i.test(i)&&(s.push({entityId:a.id,label:I(a.label,t,n),attribute:i,value:Se(c,t,n)}),s.length>=8))break;if(s.length>=8)break}return {services:r("service"),packages:r("package"),protocols:r("protocol"),runtimeUnits:r("runtime-unit"),lifecycleStages:r("lifecycle-stage"),apis:r("api"),endpoints:r("endpoint"),dataStores:r("database","queue"),deployments:r("container","deployment","environment"),pipelines:r("pipeline"),tests:r("test-suite"),owners:r("owner"),decisions:r("decision"),ports:s}}function Be(e,t,n){let r=_(e.artifact,t,n);return r?{id:e.id,provider:e.provider,artifact:r,...e.pointer?{pointer:I(e.pointer,t,n)}:{},...e.line!==void 0?{line:e.line}:{},derivation:e.derivation,trust:e.trust,confidence:e.confidence,freshness:e.freshness}:null}async function Me(e,t,n){let r=[],s=await A(l.join(e,".workspai","reports","INDEX.json"));if(Array.isArray(s?.blockers))for(let d of s.blockers)typeof d=="string"&&(d.startsWith(`${n}:`)||d.includes(`project:${n}`)||d.includes(`project ${n}`))&&r.push({source:"workspace-report-index",severity:"error",message:I(d,e,t)});let a=await A(l.join(e,".workspai","reports","doctor-project-last-run.json")),i=await A(l.join(e,".workspai","reports","doctor-last-run.json")),c=i?.projects?.find(d=>d.name===n),g=[...a?.project&&(a.projectName===n||a.project.name===n)?[{generatedAt:a.generatedAt,project:a.project}]:[],...c?[{generatedAt:i?.generatedAt,project:c}]:[]].sort((d,m)=>{let u=typeof d.generatedAt=="string"&&Date.parse(d.generatedAt)||0;return (typeof m.generatedAt=="string"&&Date.parse(m.generatedAt)||0)-u})[0];if(g)for(let d of c$1({project:g.project}))r.push({source:"doctor-project",severity:d.status==="blocking"?"error":"warning",message:I(d.message,e,t),...d.id?{code:d.id}:{}});return [...new Map(r.map(d=>[`${d.source}:${d.code??""}:${d.message}`,d])).values()].slice(0,32)}function ne(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(n=>n.length>0&&(e.includes(n)||e.includes(n.replace(/\\/g,"/")))):Array.isArray(e)?e.some(n=>ne(n,t)):e&&typeof e=="object"?Object.values(e).some(n=>ne(n,t)):false}function De(e){return Ee.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function Je(e){let t$1=l.resolve(e.workspacePath),n=l.resolve(e.projectPath),r=u(n,"project.json").find(p=>se.existsSync(p)),s=r?await A(r):null,a$1=await A(l.join(t$1,".workspai","workspace.contract.json")),i=l.resolve(n),c=a$1?.projects?.find(p=>p.externalPath?l.resolve(p.externalPath)===i:!p.relativePath||p.relativePath.startsWith("external/")?false:l.resolve(t$1,p.relativePath)===i)??a$1?.projects?.find(p=>p.slug===e.projectName||p.slug===l.basename(n)),h=e.projectName??(typeof s?.name=="string"?s.name:void 0)??c?.slug??l.basename(n),g=c?.relativePath??(()=>{let p=$(l.relative(t$1,n));return !p||p.startsWith("..")?`external/${h}`:p})(),d$1=await A(l.join(t$1,p.model)),m=await A(l.join(t$1,p.knowledgeGraph)),u$1=d$1?d(d$1):void 0,w=!!(u$1&&m?.source.hash===u$1),f=We({model:d$1,projectName:h,relativePath:g}),j=Ke(w?m:null,h),P=await Me(t$1,n,h),S=j.proofs.map(p=>p.freshness),N=m?!w||S.includes("stale")?"stale":S.includes("unknown")?"unknown":"fresh":"missing",T=d$1?d$1.factFreshness?.status??"unknown":"missing",b$1=[...[...d$1?[]:[{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."}],...d$1&&!f?[{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."}]:[],...m?[]:[{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."}],...m&&!w?[{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."}]:[]],...j.diagnostics].filter((p,E,Ne)=>Ne.findIndex(ie=>ie.code===p.code&&ie.message===p.message)===E),W=Math.max(0,b$1.length-ye+1),H=W>0?[...b$1.slice(0,ye-1),{code:"project.context.diagnostics-truncated",severity:"info",message:`${W} additional diagnostic(s) remain available in the canonical Workspace Knowledge Graph.`,recommendation:"Inspect workspace:.workspai/reports/workspace-knowledge-graph.json for the complete diagnostic set."}]:b$1,D=Re(s,e.relationship??c?.relationship??"managed"),o={schemaVersion:Ge,generatedAt:(e.now??new Date).toISOString(),workspace:{name:a$1?.workspace?.name??d$1?.workspace.name??l.basename(t$1),...a$1?.workspace?.profile||d$1?.workspace.profile?{profile:a$1?.workspace?.profile??d$1?.workspace.profile}:{},relationship:D,contract:`workspace:${t.workspaceContract}`,projectKnowledgeGraph:t.projectKnowledgeGraphReference,model:`workspace:${p.model}`,knowledgeGraph:`workspace:${p.knowledgeGraph}`,index:`workspace:${p.agentIndex}`,context:`workspace:${p.agentContext}`,skillsIndex:`workspace:${p.skillsIndex}`,boundedGraphSearch:`workspai workspace graph search <task-query> --scope project:${h} --limit 12 --json`,access:{localBinding:t.projectWorkspaceLink,canonicalEvidenceAvailableAtGeneration:true,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"}},project:{name:h,relativePath:g,...f?.kind?{kind:f.kind}:{},...f?.runtime||c?.runtime?{runtime:f?.runtime??c?.runtime}:{},...f?.runtimeCandidates?.length?{runtimeCandidates:[...f.runtimeCandidates].sort()}:{},...f?.framework||c?.framework?{framework:f?.framework??c?.framework}:{},...f?.kit||c?.kit?{kit:f?.kit??c?.kit}:{},...f?.supportTier?{supportTier:f.supportTier}:{},...f?.governance?{governance:f.governance}:{},commands:{supported:[...f?.commands.supported??[]].sort(),unsupported:[...f?.commands.unsupported??[]].sort(),fleetStages:[...f?.commands.fleetStages??[]].sort()},importantFiles:[...new Set((f?.importantFiles??[]).map(p=>_(p,t$1,n)).filter(p=>p!==null))].sort()},intelligence:{...d$1?.generatedAt?{modelGeneratedAt:d$1.generatedAt}:{},...m?.generatedAt?{graphGeneratedAt:m.generatedAt}:{},...m?.source.hash?{graphModelHash:m.source.hash}:{},entityCount:j.entityCount,relationCount:j.relationCount,proofCount:j.proofCount,entitiesByKind:j.entitiesByKind,relationsByKind:j.relationsByKind,languages:j.languages,semantic:j.semantic,projection:{...j.projection,continuationCommand:`workspai workspace graph search <task-query> --scope project:${h} --limit 12 --json`},relatedProjects:j.relatedProjects,freshness:{model:T,graph:N,graphMatchesModel:w},topology:{...j.topology,dependencies:j.topology.dependencies.map(p=>({...p,evidence:p.evidence.map(E=>_(E,t$1,n)).filter(E=>E!==null)})),dependents:j.topology.dependents.map(p=>({...p,evidence:p.evidence.map(E=>_(E,t$1,n)).filter(E=>E!==null)}))},surfaces:Fe(j.entities,t$1,n),diagnostics:H.map(p=>({...p,message:I(p.message,t$1,n),...p.recommendation?{recommendation:I(p.recommendation,t$1,n)}:{}}))},evidence:{readOrder:[b,".workspai/PROJECT-GROUNDING.md",t.projectContextAgent,"AGENTS.md","workspace:.workspai/goals/index.json",`workspace:${t.goalPackLastRun}`,"workspace:.workspai/reports/workspace-skills-index.json",`command:workspai workspace graph search <task-query> --scope project:${h} --limit 12 --json`],projectProofArtifacts:[...new Set(j.proofArtifacts.map(p=>_(p,t$1,n)).filter(p=>p!==null))],relations:j.relations.map(p=>({id:p.id,from:p.from,to:p.to,kind:p.kind,derivation:p.derivation,trust:p.trust,confidence:p.confidence,proofIds:[...p.proofIds].sort()})),proofs:j.proofs.map(p=>Be(p,t$1,n)).filter(p=>p!==null)},blockers:P,agentRouting:{enforcement:"required",mandatoryPreflight:{command:"workspai agent bootstrap --for-agent generic --strict --json",successCondition:"ready"},workspaceLocator:{command:"workspai project workspace status --json",successCondition:"resolved",outputClassification:"machine-local",persistence:"forbidden",disclosure:"forbidden",portableUriScheme:"workspace:"},workspaceEvidenceRequiredFor:["repository-analysis","architecture-analysis","change-impact","cross-project-change","contract-change","infrastructure-change","release-readiness"],requiredReadOrder:[b,"command:workspai agent bootstrap --for-agent generic --strict --json","command:workspai project workspace status --json",t.projectContextAgent,"workspace:.workspai/reports/workspace-skills-index.json",`command:workspai workspace graph search ${JSON.stringify(h)} --scope ${JSON.stringify(`project:${h}`)} --limit 12 --json`],degradedMode:{allowCompleteArchitectureClaims:false,requireDisclosure:true}},commands:{refresh:"workspai workspace intelligence run --for-agent generic --strict --json",verify:"workspai workspace verify --strict --json",graphSearch:`workspai workspace graph search ${JSON.stringify(h)} --scope ${JSON.stringify(`project:${h}`)} --limit 12 --json`,doctor:"workspai doctor project --json",workspaceStatus:"workspai project workspace status --json"}};if(ne(o,[t$1,n]))throw new Error("Project context lens rejected a non-portable absolute path.");let k={...o,integrity:{algorithm:"sha256",...u$1?{modelHash:u$1}:{},payloadHash:De(o),portable:true,absolutePathsEmitted:false}};return a(k,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent"),k}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.",n=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.",r=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 +1 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {g}from'./chunk-5HNQIMGW.js';import a from'path';import d from'fs-extra';var b=4,C="workspace-graph-token-efficiency.v1";function k(e){return Math.ceil(e/b)}function y(e,o){let n=a.resolve(e,o),t=a.relative(e,n);return !t||t.startsWith("..")||a.isAbsolute(t)?null:n}async function P(e){let o=new Map,n=[a.join(e,".workspai","workspace.contract.json"),a.join(e,".rapidkit","workspace.contract.json")];for(let t of n)if(await d.pathExists(t))try{let s=await d.readJson(t);for(let r of s.projects??[])typeof r.relativePath=="string"&&typeof r.externalPath=="string"&&a.isAbsolute(r.externalPath)&&o.set(r.relativePath.replace(/\\/g,"/").replace(/\/$/,""),r.externalPath);break}catch{}return o}function A(e,o,n){if(!o||a.isAbsolute(o))return null;let t=a.resolve(e),s=o.replace(/\\/g,"/");for(let[r,c]of [...n.entries()].sort(([u],[l])=>l.length-u.length))if(s.startsWith(`${r}/`))return y(c,s.slice(r.length+1));return y(t,s)}async function S(e){let o=a.resolve(e.workspacePath),n=g(e.graph,{query:e.query,...e.kind?{kind:e.kind}:{},...e.projectId?{projectId:e.projectId}:{},limit:e.limit,projection:"agent"}),t=e.corpus;if(!t){let l=[...new Set(e.graph.proofs.map(i=>i.artifact))].sort(),p=[],v=await P(o),h=0,g=0;for(let i of l){let f=A(o,i,v);if(!f){p.push(i);continue}try{let w=await d.readFile(f,"utf8");h+=w.length,g+=1;}catch{p.push(i);}}t={artifactCount:g,characterCount:h,estimatedTokens:k(h),unreadableArtifacts:p};}let s=JSON.stringify(n).length,r=t.estimatedTokens,c=k(s),u=Math.max(0,r-c);return {schemaVersion:C,generatedAt:(e.now??new Date).toISOString(),workspacePath:o,query:e.query,graph:{schemaVersion:e.graph.schemaVersion,sourceArtifact:e.graph.source.artifact,sourceHash:e.graph.source.hash,entityCount:e.graph.entities.length,relationCount:e.graph.relations.length,proofCount:e.graph.proofs.length},methodology:{id:"indexed-corpus-vs-bounded-retrieval.v1",estimated:true,charsPerToken:b,claimBoundary:"Measures retrieval payload reduction against readable proof-source text; it does not claim equivalent answer quality or model-specific billing savings."},corpus:t,retrieval:{matchCount:n.entities.length,characterCount:s,estimatedTokens:c,truncated:n.truncated,payload:n},savings:{estimatedTokensAvoided:u,reductionRatio:c===0?0:Number((r/c).toFixed(2)),reductionPercent:r===0?0:Number((u/r*100).toFixed(2))}}}export{C as a,S as b};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a as a$2,D as D$1}from'./chunk-TJ3MDZMC.js';import {d}from'./chunk-ROOPODG6.js';import {j,m,i}from'./chunk-H4YHIOCT.js';import {a as a$1}from'./chunk-GR6442P7.js';import {a as a$3,g,f as f$1,h}from'./chunk-BLEIUQL6.js';import {b}from'./chunk-VN2MKTQO.js';import {a}from'./chunk-XWKGZRHN.js';import {a as a$4}from'./chunk-252EKOR6.js';import {l}from'./chunk-OCGZNSOE.js';import {c}from'./chunk-64XWHDZ3.js';import {t as t$1,u,q as q$1}from'./chunk-VQZ5PI5J.js';import {t,p,s,q}from'./chunk-ODK4LCEL.js';import*as f from'path';import f__default from'path';import k from'fs-extra';import Re from'crypto';var Ae="unknown-run";function de(e){let t=c();return !t||t===Ae?e:{...e,runId:t}}async function ue(e,t){await k.ensureDir(f.dirname(e));let r=`${e}.${process.pid}.${Date.now()}.${Re.randomUUID()}.tmp`;try{await k.writeJSON(r,t,{spaces:2}),await k.move(r,e,{overwrite:true});}finally{await k.remove(r).catch(()=>{});}}function le(e){return q$1(e,"imported-projects.json")}async function I(e){let t=(await Promise.all(t$1(e,"imported-projects.json").map(async r=>await k.pathExists(r)?r:null))).find(r=>typeof r=="string");if(!t)return [];try{let r=await k.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,n=o.filter(i=>{if(!i||typeof i!="object")return false;let c=i;return typeof c.name=="string"&&typeof c.path=="string"&&typeof c.stack=="string"&&typeof c.confidence=="string"&&typeof c.importedAt=="string"});if(n.length!==o.length)throw new Error("one or more project entries are invalid");return n}catch(r){throw new Error(`Imported-project registry is invalid: ${t}`,{cause:r})}}async function Xe(e,t){if(t.length===0)return;let r=le(e);await a(`${r}.lock`,async()=>{let o=await I(e),n=new Map;for(let c of o)n.set(c.path,c);for(let c of t)n.set(c.path,c);let i=Array.from(n.values()).sort((c,l)=>c.name.localeCompare(l.name)).map(c=>({...c}));await ue(r,{version:1,updatedAt:new Date().toISOString(),projects:i});},{timeoutMs:3e4,staleMs:6e4,purpose:"imported-projects-registry-upsert"});}async function et(e,t){if(t.length===0)return;let r=le(e);await a(`${r}.lock`,async()=>{let o=await I(e),n=new Set(t.map(c=>f.resolve(c))),i=o.filter(c=>!n.has(f.resolve(c.path)));await ue(r,{version:1,updatedAt:new Date().toISOString(),projects:i});},{timeoutMs:3e4,staleMs:6e4,purpose:"imported-projects-registry-remove"});}var ot="workspace-dependency-graph.v1",me=["code-import","package-dep","event-pub-sub","service-dependsOn","shared-resource"],ge=["inferred","contract","manual"];var v=t.workspaceContract,xe=p.contractVerify,G=s.workspaceContract.schemaVersion,_e=q.contractVerify,D=class extends Error{constructor(r){super(`Workspace contract verification failed: ${r.violations.join("; ")}`);this.verification=r;this.name="WorkspaceContractVerificationError";}verification};function Pe(e){return e.replace(/\\/g,"/")}function z(e){let t=Pe(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 fe(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,80)||t}function ye(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function Ge(e){return [...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}function Oe(e){let t=e.contracts;return !t||typeof t!="object"||Array.isArray(t)?[]:ye(t.env)}function Ce(e){let t=(e||"").toLowerCase();return t.includes("vscode-extension")||t.includes("desktop.electron")||t.startsWith("extension.")||t.startsWith("desktop.")&&!t.includes("tauri")||t.includes("agent.microsoft")||t.includes("agent.openai")}function he(e){let r=(Array.isArray(e.ports)?e.ports:[]).map(i=>{if(!i||typeof i!="object"||Array.isArray(i))return null;let c=i,l=Number(c.port);if(!Number.isInteger(l)||l<1||l>65535)return null;let m=c.protocol==="https"||c.protocol==="grpc"||c.protocol==="tcp"||c.protocol==="udp"?c.protocol:"http";return {name:typeof c.name=="string"&&c.name.trim()?c.name:"http",port:l,protocol:m}}).filter(i=>i!==null);if(r.length>0)return r;let o=e.frontend&&typeof e.frontend=="object"&&!Array.isArray(e.frontend)?e.frontend:void 0,n=Number(e.port??o?.default_port);return Number.isInteger(n)&&n>=1&&n<=65535?[{name:"http",port:n,protocol:"http"}]:[]}async function Ne(e){let t=f__default.join(e,"Dockerfile");if(!await k.pathExists(t))return [];try{let r=await k.readFile(t,"utf8"),o=new Map;for(let n of r.matchAll(/^\s*EXPOSE\s+(.+)$/gim))for(let i of n[1].split(/\s+/)){let c=i.match(/^(\d{1,5})(?:\/(tcp|udp))?$/i),l=Number(c?.[1]);if(!c||!Number.isInteger(l)||l<1||l>65535)continue;let m=c[2]?.toLowerCase();o.set(l,{name:"http",port:l,protocol:m==="udp"?"udp":"http"});}return [...o.values()].sort((n,i)=>n.port-i.port)}catch{return []}}async function T(e){for(let t of e)if(await k.pathExists(t))return t;return null}async function Ie(e){for(let r of t$1(e,"workspace.json"))try{let o=await k.readJson(r);return {name:typeof o.workspace_name=="string"&&o.workspace_name.trim()||typeof o.name=="string"&&o.name.trim()||f__default.basename(e),profile:typeof o.profile=="string"?o.profile:void 0}}catch{}let t=await a$4(e);return t?.name?.trim()?{name:t.name.trim()}:{name:f__default.basename(e)}}async function De(e){let t=[],r=[e],o=new Set,n=new Set([".git",".workspai",".rapidkit","node_modules",".venv","venv","dist","build","target",".next",".turbo",".cache"]);for(;r.length>0;){let i=r.shift();if(!i||o.has(i))continue;o.add(i);let c=await T(u(i,"project.json")),l=await T(u(i,"context.json"));if(c||l){t.push(c??l??"");continue}let m;try{m=await k.readdir(i,{withFileTypes:true});}catch{continue}for(let d of m)!d.isDirectory()||n.has(d.name)||a$1(d.name)||r.push(f__default.join(i,d.name));}return t.sort()}function Te(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 $e(e,t){let r=(e||"").toLowerCase(),o=(t||"").toLowerCase();return Ce(e)?null:r.includes("fastapi")?8e3:r.includes("nestjs")?3e3:r.includes("springboot")?8080:r.includes("gofiber")?3e3:r.includes("gogin")?8080:r.startsWith("adopted.")?null:o==="node"?3e3:o==="python"?8e3:o==="java"||o==="go"?8080:null}function B(e,t){let r=e;for(;t.has(r)&&r<65535;)r+=1;return r}function U(e,t,r){let o=e!==void 0&&e.source===void 0,n=$e(t.kit,t.runtime),i=e?.ports||[],c=t.ports||[],l=Ce(t.kit),m=t.source==="adopted-local"&&e?.source!==void 0,d=t.source!==void 0&&e?.source!==void 0,p=(l&&c.length===0?[]:m?c.length>0?c:n?[{name:"http",port:B(n,r),protocol:"http"}]:[]:i.length>0?i:c.length>0?c:n?[{name:"http",port:B(n,r),protocol:"http"}]:[]).map(P=>({...P,port:B(P.port,r)}));for(let P of p)r.add(P.port);let g={...t,...e,slug:e?.slug||t.slug,relativePath:o&&e?.relativePath&&z(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:d?t.runtime:e?.runtime||t.runtime,framework:d?t.framework:e?.framework||t.framework,kit:d?t.kit:e?.kit||t.kit,modules:e?.modules?.length?e.modules:t.modules,ports:p,contracts:{owns:e?.contracts?.owns||[],apis:e?.contracts?.apis||[],publishes:e?.contracts?.publishes||[],consumes:e?.contracts?.consumes||[],dependsOn:e?.contracts?.dependsOn||[],env:Ge([...e?.contracts?.env??[],...t.contracts.env??[]])}},h=JSON.stringify(e||null)!==JSON.stringify(g);return {project:g,changed:h}}async function Ee(e){let t=f__default.resolve(e.workspacePath),r=await Ie(t),o=await De(t),n=await I(t),i$1=new Map(n.map(s=>[f__default.resolve(s.path),s])),c=[];for(let s of n){let p=f__default.resolve(s.path),g=await T(u(p,"project.json"))??await T(u(p,"context.json"));!g||o.some(h=>f__default.resolve(h)===f__default.resolve(g))||c.push({projectJsonPath:g,registryEntry:s});}let l=[],m$1=[...o.map(s=>({projectJsonPath:s,registryEntry:i$1.get(f__default.resolve(f__default.dirname(f__default.dirname(s))))})),...c];for(let{projectJsonPath:s,registryEntry:p}of m$1){let g=f__default.dirname(f__default.dirname(s)),h=Pe(f__default.relative(t,g)),P=p!==void 0&&!z(h),C=fe(p?.name||f__default.basename(g),f__default.basename(g)),b=P?`external/${C}`:h||C,w=await k.readJson(s),a=typeof w.kit_name=="string"&&w.kit_name||typeof w.kit=="string"&&w.kit||void 0,E=j(w)?m(g,w):void 0,j$1=E!==void 0&&E.key!=="unknown",S=i({runtime:typeof w.runtime=="string"?w.runtime:void 0,framework:typeof w.framework=="string"?w.framework:void 0,kitName:a}),y=a$2(a),$=j$1?E.runtime:S.runtime!=="unknown"?S.runtime:y?.runtime,K=j$1?E.key:typeof w.framework=="string"&&w.framework||(S.key!=="unknown"?S.key:void 0)||y?.framework||Te(a),We=p?.relationship==="adopted"?"adopted":"imported",Se=j$1?`${We}.${E.key}`:a;l.push({slug:p?.name||b||f__default.basename(g),relativePath:b,source:p?.source??"workspace",relationship:p?.relationship,externalPath:P?g:void 0,runtime:$,framework:K,kit:Se,modules:ye(w.modules),ports:he(w).length>0?he(w):await Ne(g),contracts:{owns:[],apis:[],publishes:[],consumes:[],dependsOn:[],env:Oe(w)}});}let d=new Map;for(let s of l){let p=fe(s.slug,s.relativePath),g=d.get(p);(!g||g.source!=="workspace"&&s.source==="workspace")&&d.set(p,s);}return {schemaVersion:G,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:r,projects:[...d.values()]}}async function Et(e){let t=f__default.resolve(e.outputPath||a$3(e.workspacePath,v));if(await k.pathExists(t)&&e.force!==true)throw new Error(`Workspace contract already exists: ${t}. Use --force to overwrite.`);let r=await Ee({workspacePath:e.workspacePath,now:e.now}),o=new Set,n={...r,projects:r.projects.map(c=>U(void 0,c,o).project)},i=await be({workspacePath:e.workspacePath,contractPath:t,contract:n});if(e.strict&&i.status==="failed")throw new D(i);return await ve({workspacePath:e.workspacePath,contractPath:t,contract:n,now:e.now}),{contractPath:t,contract:n}}async function vt(e){let t=f__default.resolve(e.workspacePath),r=a$3(t,v),o=await g(t,v)??r,n=await Ee({workspacePath:t,now:e.now}),i=await k.pathExists(o)?await k.readJson(o):null,c=new Map((i?.projects||[]).map(h=>[h.slug,h])),l=new Set,m=[],d=[],s=[];for(let h of n.projects){let P=c.get(h.slug),C=U(P,h,l);P?C.changed&&d.push(h.slug):m.push(h.slug),s.push(C.project),c.delete(h.slug);}for(let h of c.values()){if(h.source)continue;let P=U(h,h,l);s.push(P.project);}let p={schemaVersion:G,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:{...i?.workspace||{},...n.workspace,name:n.workspace.name||i?.workspace?.name||f__default.basename(t)},projects:s.sort((h,P)=>h.slug.localeCompare(P.slug))},g$1=await be({workspacePath:t,contractPath:r,contract:p});if(e.strict&&g$1.status==="failed")throw new D(g$1);return await ve({workspacePath:t,contractPath:r,contract:p,now:e.now}),{contractPath:r,contract:p,addedProjects:m,updatedProjects:d,verification:g$1}}async function ke(e){return await k.pathExists(e)?{exists:true,contents:await k.readFile(e)}:{exists:false}}async function we(e,t){if(!t.exists){await k.remove(e);return}await k.outputFile(e,t.contents);}async function ve(e){let{buildWorkspaceRegistrySummary:t,WORKSPACE_REGISTRY_SUMMARY_RELATIVE_PATH:r}=await import('./workspace-registry-summary-ZNTXSUI4.js'),o=await t(e.workspacePath,{now:e.now,contract:e.contract}),n=a$3(e.workspacePath,r),i=c=>{if(!c||typeof c!="object"||Array.isArray(c))return JSON.stringify(c);let{generatedAt:l,...m}=c;return JSON.stringify(m)};if(await k.pathExists(e.contractPath)&&await k.pathExists(n)){let[c,l]=await Promise.all([k.readJson(e.contractPath),k.readJson(n)]);if(i(c)===i(e.contract)&&i(l)===i(o))return}b(v,e.contract),b(r,o),await f$1(e.workspacePath,v,async()=>{let[c,l]=await Promise.all([ke(e.contractPath),ke(n)]);try{if(e.contractPath===a$3(e.workspacePath,v)?await h(e.workspacePath,v,e.contract):(await k.ensureDir(f__default.dirname(e.contractPath)),await k.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 h(e.workspacePath,r,o);}catch(m){let s=(await Promise.allSettled([we(e.contractPath,c),we(n,l)])).filter(p=>p.status==="rejected");throw s.length>0?new AggregateError([m,...s.map(p=>p.reason)],"Workspace contract publication failed and rollback was incomplete."):m}});}async function je(e){let t=e.contractPath??(await g(e.workspacePath,v)||a$3(e.workspacePath,v)),r=await k.readJson(t);return {contractPath:t,contract:r}}var Ke={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 Ve(e,t){return d(e,t.relativePath,{...t.externalPath?{absolutePath:t.externalPath}:{}})}async function Me(e){let t={metadata:[],manifests:[],entrypoints:[],apiSpecifications:[],infrastructure:[],documentation:[]};for(let[r,o]of Object.entries(Ke))for(let n of o)await k.pathExists(f__default.join(e,n))&&t[r].push(n);try{let r=await k.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,n)=>o.localeCompare(n));return t}function _(e){return !e||typeof e!="object"||Array.isArray(e)?[]:Object.keys(e).sort((t,r)=>t.localeCompare(r))}async function Fe(e){try{let t=await k.readJson(f__default.join(e,"package.json")),r={runtime:_(t.dependencies),development:_(t.devDependencies),peer:_(t.peerDependencies),optional:_(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:_(t.scripts),dependencies:r,dependencyCount:new Set(Object.values(r).flat()).size}}catch{return}}async function Le(e){for(let t of [".env.example",".env.sample",".env.template"])try{return (await k.readFile(f__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,n)=>o.localeCompare(n))}catch{}return []}function He(e,t){try{let r=D$1(e);if(r.engine!=="unknown")return r;let o=k.pathExistsSync(f__default.join(e,"package.json"))?"npm":k.pathExistsSync(f__default.join(e,"pyproject.toml"))?"python":k.pathExistsSync(f__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",runtimeCandidates:["unknown"],compositeRuntime:false,lifecycleCoverage:"complete",framework:"unknown",frameworkDisplayName:"Unknown",frameworkConfidence:"low",frameworkSupportTier:"observed",runtimeSupportTier:"observed",runtimeDoctorSupport:"observed",moduleSupport:false,fleetStages:[],localOnlyCommands:[],commandMap:{},supportedCommands:[],unsupportedCommands:[],globalCommands:[]}}}function Je(e,t,r){let o=e.projects.map(n=>({id:n.slug,path:n.relativePath,runtime:n.runtime,framework:n.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 jt(e){let{contractPath:t,contract:r}=await je(e),o=e.now??new Date,n=o.toISOString(),{buildWorkspaceModel:i,workspaceModelProjectTopology:c}=await import('./workspace-model-72SJ6WXT.js'),{hashWorkspaceModel:l}=await import('./workspace-model-hash-ZXYPIGCW.js'),m=await i({workspacePath:e.workspacePath,includeEvidence:false,now:o}),d=c(m)??Je(r,n,"The canonical Workspace Model did not provide a project dependency topology."),s=new Map(d.nodes.map(a=>[a.id,a.operationalProfile])),{buildWorkspaceKnowledgeGraph:p$1}=await import('./workspace-knowledge-graph-EFC4TUDZ.js'),g=await p$1({workspacePath:e.workspacePath,workspace:{name:m.workspace.name,...m.workspace.profile?{profile:m.workspace.profile}:{}},contract:r,projectTopology:d,now:o,projects:m.projects.map(a=>({id:a.name,path:a.path,...a.absolutePath?{absolutePath:a.absolutePath}:{},runtime:a.runtime,runtimeCandidates:a.runtimeCandidates,framework:a.framework,...a.kit?{kit:a.kit}:{}})),source:{kind:"workspace-model",artifact:p.model,hashAlgorithm:"sha256",hash:l(m)}}),h=await Promise.all(r.projects.map(async a=>{let u=Ve(e.workspacePath,a),[E,j,S]=await Promise.all([Me(u),Fe(u),Le(u)]),y=He(u,a);return {id:a.slug,label:a.slug,relativePath:a.relativePath,source:a.source,relationship:a.relationship,externalPath:a.externalPath,runtime:a.runtime??y.runtime,framework:a.framework??y.framework,kit:a.kit,modules:a.modules,ports:a.ports,apis:a.contracts.apis,owns:a.contracts.owns,env:[...new Set([...a.contracts.env,...S])].sort(($,K)=>$.localeCompare(K)),contracts:{owns:[...a.contracts.owns],apis:[...a.contracts.apis],publishes:[...a.contracts.publishes],consumes:[...a.contracts.consumes],dependsOn:[...a.contracts.dependsOn],env:[...a.contracts.env]},capabilities:{engine:y.engine,supportTier:y.frameworkSupportTier,runtimeSupportTier:y.runtimeSupportTier,doctorSupport:y.runtimeDoctorSupport,moduleSupport:y.moduleSupport,fleetStages:[...y.fleetStages],localOnlyCommands:[...y.localOnlyCommands],supportedCommands:[...y.supportedCommands]},files:E,...j?{package:j}:{},...s.get(a.slug)?{operationalProfile:s.get(a.slug)}:{}}})),P=new Set(h.map(a=>a.id)),C=new Map,b=[];for(let a of r.projects){for(let u of a.contracts.dependsOn||[])P.has(u)&&b.push({from:u,to:a.slug,type:"dependency",label:"dependsOn"});for(let u of a.contracts.publishes||[])C.has(u)||C.set(u,new Set),C.get(u)?.add(a.slug);}for(let a of r.projects)for(let u of a.contracts.consumes||[]){let E=C.get(u);if(E)for(let j of E)j!==a.slug&&b.push({from:j,to:a.slug,type:"event",label:u});}let w={schemaVersion:1,kind:"rapidkit.workspace.contract.graph",workspace:r.workspace,generatedAt:n,nodes:h.sort((a,u)=>a.id.localeCompare(u.id)),edges:b.sort((a,u)=>`${a.from}:${a.to}:${a.type}:${a.label}`.localeCompare(`${u.from}:${u.to}:${u.type}:${u.label}`)),dependencyGraph:d,knowledgeGraph:g,semantics:{legacyEdges:"producer-to-consumer",dependencyGraphEdges:"consumer-to-dependency"},summary:{projectCount:h.length,dependencyEdges:b.filter(a=>a.type==="dependency").length,eventEdges:b.filter(a=>a.type==="event").length,portCount:h.reduce((a,u)=>a+u.ports.length,0),apiCount:h.reduce((a,u)=>a+u.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:h.reduce((a,u)=>a+u.files.manifests.length,0),entrypointCount:h.reduce((a,u)=>a+u.files.entrypoints.length,0),diagnostics:d.diagnostics?.length??0,relationshipKinds:Object.fromEntries(me.map(a=>[a,d.edges.filter(u=>u.kind===a).length])),relationshipSources:Object.fromEntries(ge.map(a=>[a,d.edges.filter(u=>u.source===a).length])),entityCount:g.quality.entityCount,knowledgeRelations:g.quality.relationCount,proofCount:g.quality.proofCount,providerCount:g.providers.length,knowledgeUnknowns:g.quality.unknownCount}};return {contractPath:t,graph:w}}async function be(e){let t=e.contract?{contractPath:e.contractPath??a$3(e.workspacePath,v),contract:e.contract}:await je(e),{contractPath:r,contract:o}=t,n=[],i=[];o.kind!=="rapidkit.workspace.contract"&&n.push("Contract kind must be rapidkit.workspace.contract."),o.schemaVersion!==G&&n.push(`Contract schemaVersion must be ${G}.`),o.workspace?.name||n.push("Contract workspace.name is required."),Array.isArray(o.projects)||n.push("Contract projects must be an array.");let c=new Set,l$1=new Map;for(let s of o.projects||[]){if(!s.slug){n.push("Every project must declare slug.");continue}c.has(s.slug)&&n.push(`Duplicate project slug: ${s.slug}.`),c.add(s.slug),s.relativePath?z(s.relativePath)||n.push(`Project ${s.slug} declares unsafe relativePath: ${s.relativePath}.`):n.push(`Project ${s.slug} must declare relativePath.`),s.externalPath&&(s.relationship==="adopted"||s.source==="adopted-local"||s.source==="local-folder"||s.source==="git-url"||n.push(`Project ${s.slug} declares externalPath without imported/adopted provenance.`),f__default.isAbsolute(s.externalPath)||n.push(`Project ${s.slug} declares non-absolute externalPath.`));for(let p of s.ports||[]){(!Number.isInteger(p.port)||p.port<1||p.port>65535)&&n.push(`Project ${s.slug} declares invalid port: ${p.port}.`);let g=l$1.get(p.port);g&&n.push(`Port ${p.port} is claimed by both ${g} and ${s.slug}.`),l$1.set(p.port,s.slug);}for(let p of s.contracts?.apis||[])(!p.name?.trim()||!p.basePath?.startsWith("/"))&&n.push(`Project ${s.slug} declares invalid API contract.`);for(let p of [...s.contracts?.publishes||[],...s.contracts?.consumes||[]])p.trim()||n.push(`Project ${s.slug} declares an empty event contract.`);for(let p of s.contracts?.env||[])/^[A-Z_][A-Z0-9_]*$/.test(p)||n.push(`Project ${s.slug} declares invalid env contract: ${p}.`);for(let p of s.contracts?.dependsOn||[])c.has(p);}for(let s of o.projects||[])for(let p of s.contracts?.dependsOn||[])c.has(p)||n.push(`Project ${s.slug} depends on unknown project: ${p}.`);i.push({id:"schema",status:o.kind==="rapidkit.workspace.contract"&&o.schemaVersion===G?"passed":"failed",message:"Contract schema and kind are valid."}),i.push({id:"projects",status:Array.isArray(o.projects)?"passed":"failed",message:`Contract declares ${Array.isArray(o.projects)?o.projects.length:0} project(s).`}),i.push({id:"ports",status:n.some(s=>s.toLowerCase().includes("port"))?"failed":"passed",message:"Project port declarations are valid and collision-free."}),i.push({id:"dependencies",status:n.some(s=>s.includes("depends on unknown project"))?"failed":"passed",message:"Project dependencies point to known project slugs."}),i.push({id:"contracts",status:n.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 m=await l(e.workspacePath);if(m.moduleCount>0){for(let s of m.issues)n.push(`${f__default.basename(s.projectRoot)}: ${s.message} (slug=${s.slug})`);i.push({id:"module-paths",status:m.status,message:m.status==="passed"?`All ${m.moduleCount} registered module(s) resolve under canonical paths.`:`${m.issues.length} registered module(s) missing canonical install paths.`});}else e.strict&&i.push({id:"module-paths",status:"passed",message:"No registry-backed modules declared in workspace projects."});return {status:n.length>0?"failed":"passed",contractPath:r,projectCount:Array.isArray(o.projects)?o.projects.length:0,checks:i,violations:n}}async function bt(e){let t=f__default.resolve(e.workspacePath),r={schemaVersion:_e,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 h(t,xe,de(r))}
|
|
2
|
+
export{I as a,Xe as b,et as c,de as d,ot as e,me as f,v as g,xe as h,G as i,_e as j,D as k,De as l,Ee as m,Et as n,vt as o,je as p,jt as q,be as r,bt as s};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {f,e,h as h$1,g}from'./chunk-XF65LQ6M.js';import {a,b}from'./chunk-
|
|
1
|
+
import {f,e,h as h$1,g}from'./chunk-XF65LQ6M.js';import {a,b}from'./chunk-SVO2GGTV.js';import {b as b$1,c as c$1}from'./chunk-NSC4VWV2.js';import {a as a$1}from'./chunk-NMXGSVMD.js';import {p,a as a$2}from'./chunk-YLLCZMKP.js';import {k as k$2,m,l}from'./chunk-H4YHIOCT.js';import {h}from'./chunk-BLEIUQL6.js';import {k,t,u}from'./chunk-VQZ5PI5J.js';import {p as p$1,q}from'./chunk-ODK4LCEL.js';import k$1 from'fs';import c from'path';import s from'chalk';var ee=new Set([".git",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function E(e){try{return await k$1.promises.access(e,k$1.constants.F_OK),true}catch{return false}}async function F(e){try{let n=JSON.parse(await k$1.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function C(e){try{return await k$1.promises.readFile(e,"utf-8")}catch{return ""}}function re(e){return a(e)}async function oe(e,n){return await ne([...u(e,"project.json"),...u(e,"context.json")])?true:b(e)?false:c.resolve(e)===c.resolve(n)?k$2(e).length>0:k$2(e).length>0}async function ie(e){let n=await a$1(e,{skipDirs:ee,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:oe}),o=(await a$2(e)).filter(i=>i.relationship==="adopted"||i.source==="adopted-local").map(i=>c.resolve(i.path)).filter(i=>k$1.existsSync(i)),r=[...new Set([...n.map(i=>c.resolve(i)),...o])];return r.length>0?r:b(e)?[]:k$2(e).length>0?[e]:[]}function ae(e,n){return c.relative(e,n).replace(/\\/g,"/")||"."}async function T(e,n){for(let t of n)if(await E(c.join(e,t)))return true;return false}async function se(e,n,t=4){let o=async(r,i)=>{if(i>t)return false;let l;try{l=await k$1.promises.readdir(r,{withFileTypes:true});}catch{return false}for(let a of l)if(a.isFile()&&n.has(a.name.toLowerCase())||a.isDirectory()&&!a.isSymbolicLink()&&!ee.has(a.name)&&await o(c.join(r,a.name),i+1))return true;return false};return o(e,0)}async function ne(e){for(let n of e)if(await E(n))return true;return false}async function te(e){for(let n of e){let t=await F(n);if(t)return t}return null}async function ce(e,n){if(await T(e,[".env",".env.local"]))return true;let t=n?.contracts&&typeof n.contracts=="object"?n.contracts:null;if(Array.isArray(t?.env)&&t.env.length>0)return true;let o=await F(c.join(e,"package.json")),r={...o?.dependencies??{},...o?.devDependencies??{}};if(Object.keys(r).some(a=>/^(?:dotenv|dotenv-flow|env-cmd)$/iu.test(a)))return true;let i=await C(c.join(e,"pyproject.toml"));if(/\b(?:python-dotenv|pydantic-settings)\b/iu.test(i))return true;let l=[await C(c.join(e,"compose.yaml")),await C(c.join(e,"compose.yml")),await C(c.join(e,"docker-compose.yml")),await C(c.join(e,"docker-compose.yaml"))].join(`
|
|
2
2
|
`);return /^\s*(?:env_file|environment)\s*:/imu.test(l)}async function de(e){return (await g(e)).detected}async function le(e){let n=await F(c.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function w(e,n,t,o,r,i,l){return {id:e,severity:n,target:t,title:o,detail:r,remediation:i,...l&&l.length>0?{files:[...l]}:{}}}function pe(e){let n=e.reduce((t,o)=>o.severity==="fail"?t+28:o.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function ue(e,n,t){let o=await te(u(n,"project.json")),r=m(n,o),i=l(n),l$1=r.runtime==="unknown"?i[0]||"unknown":r.runtime,a=[l$1,...i.filter(G=>G!==l$1)],u$1=r.key==="unknown"&&new Set(a.filter(G=>G!=="unknown")).size>1,b=await b$1(n,o,{runtime:l$1,framework:r.key}),m$1=["backend","service","worker","agent"].includes(b),h=["backend","service","worker"].includes(b),v=m$1&&/^(?:fastapi|django|flask|nestjs|express|fastify|springboot|gofiber|gogin|dotnet-webapi|laravel|rails|phoenix|axum|actix|rocket)$/u.test(r.key),j=ae(e,n),f=j,$=await le(n),P=await ne([...u(n,"project.json"),...u(n,"context.json")]),x=await de(n),R=await T(n,["Dockerfile","dockerfile"]),g=await T(n,[".env.example","env.example","config/env.example"])||await se(n,new Set([".env.example","env.example"])),p=await ce(n,o),d=await c$1({projectPath:n,declaration:t?.governance}),z=d.ci.status==="repository",D=await h$1(n),y=[];return r.key==="unknown"&&y.push(w(u$1?"project.stack.aggregate":"project.stack.unknown",u$1?"info":"fail",f,u$1?"Multi-runtime aggregate boundary detected":"Project stack is unknown",u$1?`Workspai detected multiple runtimes (${a.join(", ")}) and intentionally did not promote one nested framework as the aggregate project identity.`:"Workspai cannot confidently classify this backend project.",u$1?"Adopt independently operated nested projects when they need separate lifecycle, ownership, or release evidence.":"Add .workspai/project.json metadata or import the project with `workspai import`.")),P||y.push(w("project.marker.missing","warn",f,"Workspai marker is missing","The project can be detected by files, but it is not registered with Workspai metadata.","Run `workspai import <path>` from a workspace or create the project through Workspai.")),x||y.push(w("project.tests.missing","warn",f,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `workspai workspace run test --affected` can gate changes.")),m$1&&p&&!g&&y.push(w("project.env.example.missing","info",f,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.",[".env.example"])),d.ci.status==="unknown"?y.push(w("project.ci.missing","warn",f,"CI governance is not proven","No repository CI surface or canonical external CI declaration was found for this project.","Add repository CI configuration or declare the external CI authority in the workspace contract.",[".github/workflows/ci.yml"])):d.ci.status==="external-observed"&&y.push(w("project.ci.external-observed","info",f,"Continuous integration appears externally managed",`Repository documentation references an external CI control plane (${d.ci.evidence.join(", ")}).`,"Declare the external CI provider in the canonical workspace contract when authoritative release gating depends on it.")),v&&!D&&y.push(w("project.health.missing","info",f,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),h&&!R&&y.push(w("project.container.missing","info",f,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.",["Dockerfile"])),{name:typeof o?.name=="string"&&o.name.trim()?o.name.trim():c.basename(n),path:n,relativePath:j,runtime:l$1,runtimeCandidates:a,framework:r.key,confidence:r.confidence,supportTier:r.supportTier,hasRapidKitMarker:P,hasTests:x,hasDockerfile:R,hasEnvExample:g,hasCiConfig:z,governance:d,hasHealthEndpoint:D,scripts:$,findings:y,score:pe(y)}}function me(e){return e.name.toLowerCase()}async function fe(e){let n=new Map(e.map(r=>[me(r),r])),t=[];for(let r of e){let i=await F(c.join(r.path,"package.json")),l={...i?.dependencies??{},...i?.devDependencies??{},...i?.peerDependencies??{}};for(let u of Object.keys(l)){let b=u.replace(/^@[^/]+\//,"").toLowerCase(),m=n.get(b);m&&m.relativePath!==r.relativePath&&t.push({from:r.relativePath,to:m.relativePath,kind:"package"});}let a=await C(c.join(r.path,"pyproject.toml"));for(let u of e)u.relativePath!==r.relativePath&&a.includes(u.name)&&t.push({from:r.relativePath,to:u.relativePath,kind:"workspace-reference"});}let o=new Set;return t.filter(r=>{let i=`${r.from}\0${r.to}\0${r.kind}`;return o.has(i)?false:(o.add(i),true)})}function ge(e,n){let t=new Map;for(let o of e)t.set(o.relativePath,{project:o.relativePath,directDependents:0,directDependencies:0});for(let o of n){let r=t.get(o.from),i=t.get(o.to);r&&(r.directDependencies+=1),i&&(i.directDependents+=1);}return Array.from(t.values()).sort((o,r)=>r.directDependents-o.directDependents||r.directDependencies-o.directDependencies)}async function ye(e){let n=await te(t(e,"workspace.json"));return typeof n?.profile=="string"?n.profile:null}function we(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function ke(e){if(e.projectCount===0)return e.workspaceDetected?["Add your first project: npx workspai create project <name> --kit <kit>","Import an existing service: npx workspai import <path>"]:["Create a Workspai workspace: npx workspai create workspace my-workspace --profile polyglot","Import an existing service: npx workspai import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `workspai bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `workspai import <path>` or recreate them via `workspai create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `workspai workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasCanonicalGraph||n.push("Generate canonical topology with `workspai workspace model --write --include-evidence`."),n.push("Run `workspai autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function Te(e$1={}){let n=c.resolve(e$1.workspacePath||process.cwd());if(!await E(n))throw new Error(`Workspace path does not exist: ${n}`);let t=re(n)??n,o=k(t),r=await ye(t),i=await ie(t),l;try{l=(await p({workspacePath:t})).contract;}catch{}let a=await Promise.all(i.map(p=>{let d=l?.projects.find(z=>{let D=z.externalPath??z.relativePath;return c.resolve(t,D)===c.resolve(p)});return ue(t,p,d)})),u=await fe(a),b=ge(a,u),m=[];o||m.push(w("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered Workspai workspace.","Run `workspai create workspace` or `workspai bootstrap --profile polyglot` in a workspace root.")),a.length===0&&m.push(w("workspace.projects.missing","warn",".","No backend projects detected","Workspai did not find runtime markers or project metadata under this root.","Create a project with `workspai create project` or import one with `workspai import <path>`."));let h$1=[...m,...a.flatMap(p=>p.findings)],v=we(h$1),j={};for(let p of a)for(let d of p.runtimeCandidates)j[d]=(j[d]||0)+1;let f$1=a.length>0?Math.round(a.reduce((p,d)=>p+d.score,0)/a.length):0,$=m.reduce((p,d)=>p+(d.severity==="fail"?20:d.severity==="warn"?8:2),0),P=Math.max(0,f$1-$),x=a.length===0&&v.fail===0&&h$1.length>0&&h$1.every(p=>p.id==="workspace.projects.missing"&&p.severity==="warn"),R=v.fail>0||e$1.strict&&v.warn>0&&!x?"blocked":v.warn>0?"needs-attention":"ready",g={schemaVersion:q.analyze,generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:o,profile:r,summary:{statusScope:"source-structure",releaseReadiness:"not-evaluated",score:P,verdict:R,projectCount:a.length,runtimeCount:Object.keys(j).length,findings:v},runtimes:j,projects:a,dependencyGraph:{status:u.length>0?"generated":"empty",edges:u,topImpactedProjects:b.slice(0,5)},findings:h$1,nextActions:ke({findings:h$1,projectCount:a.length,hasCanonicalGraph:await E(c.join(t,p$1.knowledgeGraph)),workspaceDetected:o}),enterpriseControls:{jsonReady:true,ciGateCommand:"workspai analyze --json --strict",releaseGateCommand:"workspai autopilot release --mode enforce --json",evidencePath:p$1.analyze}};if(e$1.output&&(await k$1.promises.mkdir(c.dirname(c.resolve(e$1.output)),{recursive:true}),await k$1.promises.writeFile(c.resolve(e$1.output),`${JSON.stringify(g,null,2)}
|
|
3
3
|
`)),!e$1.output&&o){let p=f(g,{commandId:"workspaceAnalyze",exitCode:g.summary.verdict==="blocked"?2:g.summary.verdict==="needs-attention"?1:0,generatedAt:g.generatedAt,blockers:g.findings.filter(d=>d.severity==="fail").map(d=>d.title).slice(0,12),runId:e()});await h(t,p$1.analyze,p);}return g}function Ne(e){let n=e.summary.verdict==="ready"?s.green:e.summary.verdict==="needs-attention"?s.yellow:s.red;if(console.log(s.bold(`
|
|
4
4
|
Workspai Workspace Analysis
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {c}from'./chunk-4MXKXHLW.js';import {j,i,d as d$1,f as f$1,c as c$2,e,h}from'./chunk-QIPW3G2H.js';import {g}from'./chunk-5HNQIMGW.js';import {a as a$1}from'./chunk-AGI46TSQ.js';import {c as c$3}from'./chunk-HRGIHWYH.js';import {b}from'./chunk-DWDYLKVW.js';import {b as b$1}from'./chunk-KO4DM2AV.js';import {d as d$2}from'./chunk-ROOPODG6.js';import {f,i as i$1}from'./chunk-BLEIUQL6.js';import {a}from'./chunk-AFIFZTOY.js';import {d,c as c$1}from'./chunk-EWZZUQBR.js';import {q,p}from'./chunk-ODK4LCEL.js';import R from'path';import _ from'fs-extra';var we=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/,ke=/(?:^|\s)(?:\/(?:home|Users|private|var|tmp|mnt|opt|srv|root|workspace|workspaces|data|Volumes|etc|usr|run|dev|proc|sys)\/[^\s]+|[A-Za-z]:[\\/][^\s]+|\\\\[^\\\s]+\\[^\s]+)/,ve=/(?:-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\b(?:github_pat_|gh[pousr]_|glpat-|npm_|xox[baprs]-|sk-(?:proj-)?)[A-Za-z0-9_-]{12,}|\b(?:AKIA|ASIA)[A-Z0-9]{16}\b|\bAIza[A-Za-z0-9_-]{20,}|\bBearer\s+[A-Za-z0-9._~+/-]{16,}|[a-z][a-z0-9+.-]*:\/\/[^\s:/]+:[^\s@/]+@|\b(?:password|passwd|secret|token|api[_-]?key)\s*[:=]\s*[^\s]{6,})/i,ye=[{category:"test-coverage",patterns:[/\b(?:test\s+)?coverage\b/i,/\bcoverage\s+(?:to|above|at least)\b/i]},{category:"dependency-security",patterns:[/\b(?:dependency|dependencies|package|packages)\b.*\b(?:security|vulnerab|audit)\b/i,/\b(?:security|vulnerab|audit)\b.*\b(?:dependency|dependencies|package|packages)\b/i]},{category:"release-readiness",patterns:[/\brelease[ -]readiness\b/i,/\bready (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare\b[^\n]{0,80}\bfor release\b/i]},{category:"defect-repair",patterns:[/\b(?:fix|repair|resolve|debug)\b.*\b(?:bug|error|failure|issue|regression)\b/i]},{category:"performance",patterns:[/\b(?:performance|latency|throughput|cpu|optimi[sz]e|faster|slower)\b/i,/\b(?:memory\s+(?:allocation|consumption|footprint|leak|pressure|usage)|out[ -]of[ -]memory|heap|ram)\b/i]},{category:"refactor",patterns:[/\b(?:refactor|restructure|decouple|extract|simplify|cleanup|clean up)\b/i]},{category:"documentation",patterns:[/\b(?:document|documentation|readme|guide|tutorial|docs)\b/i]},{category:"feature-change",patterns:[/\b(?:add|build|create|enforce|enhance|harden|implement|improve|introduce|support)\b/i]},{category:"system-understanding",patterns:[/\b(?:understand|explain|map|find|where|how|architecture|analy[sz]e|search)\b/i]}];function Pe(e){if(typeof e!="string")throw new Error("Goal intent must be text.");let t=e.trim().replace(/\s+/g," ");if(!t)throw new Error("Goal intent cannot be empty.");if(t.length>2e3)throw new Error("Goal intent exceeds the 2000 character safety limit.");if(we.test(t))throw new Error("Goal intent contains unsupported control characters.");if(ke.test(t))throw new Error("Goal intent contains a machine-local absolute path. Use a workspace-relative path or project scope.");if(ve.test(t))throw new Error("Goal intent appears to contain secret material and was not persisted.");return t}function je(e){let t=e.match(/\b(?:coverage\D{0,24})?((?:100(?:\.0+)?|\d{1,2}(?:\.\d+)?))\s*(?:%|percent(?:age)?(?:\s+points?)?)/i);if(!t||!/coverage/i.test(e))return null;let r=Number(t[1]);return Number.isFinite(r)&&r>=0&&r<=100?r:null}var oe=[{runtime:"cpp",patterns:[/\bc\+\+/i,/\bcpp\b/i]},{runtime:"dotnet",patterns:[/\.net\b/i,/\bdotnet\b/i,/\bc#/i,/\bcsharp\b/i]},{runtime:"node",patterns:[/\bnode(?:\.js)?\b/i,/\btypescript\b/i,/\bjavascript\b/i,/\b(?:js|ts)\b/i]},{runtime:"python",patterns:[/\bpython\b/i,/\bpytest\b/i]},{runtime:"go",patterns:[/\bgolang\b/i,/\bgo(?:\s+(?:test|coverage|tests))\b/i]},{runtime:"java",patterns:[/\bjava\b/i,/\bjunit\b/i,/\bjacoco\b/i]},{runtime:"rust",patterns:[/\brust\b/i,/\bcargo\b/i]},{runtime:"php",patterns:[/\bphp\b/i,/\bphpunit\b/i]},{runtime:"ruby",patterns:[/\bruby\b/i,/\brspec\b/i]},{runtime:"kotlin",patterns:[/\bkotlin\b/i]},{runtime:"scala",patterns:[/\bscala\b/i]},{runtime:"clojure",patterns:[/\bclojure\b/i]},{runtime:"elixir",patterns:[/\belixir\b/i]},{runtime:"deno",patterns:[/\bdeno\b/i]},{runtime:"bun",patterns:[/\bbun\b/i]},{runtime:"c",patterns:[/\bc(?:\s+(?:test|coverage|tests|code))\b/i]}];function Ge(e){return oe.filter(t=>t.patterns.some(r=>r.test(e))).map(t=>t.runtime)}function K(e,t={}){let r=Pe(e),n=ye.filter(u=>u.patterns.some(j=>j.test(r))).map(u=>u.category),a=n.some(u=>u!=="feature-change")?n.filter(u=>u!=="feature-change"):n,s=a[0]??"feature-change",l=je(r),d=Ge(r),p=d.length===0&&t.selectedCoverageRuntime?[t.selectedCoverageRuntime]:d,m=[...new Set((t.availableCoverageRuntimes??[]).filter(u=>oe.some(j=>j.runtime===u)))].sort(),b=[];return a.length>1&&a[0]!=="test-coverage"&&b.push(`The intent also contains signals for: ${a.slice(1).join(", ")}.`),s==="test-coverage"&&l===null&&b.push("A numeric test coverage target is required for machine verification."),s==="test-coverage"&&p.length>1&&b.push(`The Goal names multiple coverage runtimes: ${p.join(", ")}. Select one runtime per Goal.`),s==="test-coverage"&&p.length===0&&m.length>1&&b.push(`Coverage scope is ambiguous across detected runtimes: ${m.join(", ")}. Name one runtime or language in the Goal.`),s==="test-coverage"&&p.length===1&&m.length>0&&!m.includes(p[0])&&b.push(`The requested ${p[0]} coverage runtime is not present in the selected scope. Detected runtimes: ${m.join(", ")}.`),{original:r,normalized:r.toLocaleLowerCase("en-US"),statement:r.replace(/[.!?]+$/,""),category:s,confidence:a.length===1?"high":a.length>1?"medium":"low",ambiguities:b,...l===null?{}:{requestedTarget:{metric:"test-coverage-percent",operator:"at-least",value:l,...p.length===1?{runtime:p[0]}:{}}}}}function ae(e){let t={"test-coverage":["test suite coverage configuration instrumentation","CI tests LCOV Cobertura JaCoCo LLVM coverage"],"dependency-security":["dependency manifest lockfile security audit vulnerability"],"release-readiness":["release pipeline readiness gates build test deploy"],"defect-repair":["failure error test implementation call path"],"feature-change":["API implementation module dependency tests"],refactor:["module dependency ownership implementation tests"],performance:["performance benchmark latency throughput runtime"],documentation:["documentation README guide architecture decision"],"system-understanding":["architecture service API dependency ownership"]};return [...new Set([e.statement,...t[e.category]])].slice(0,3)}var se="contracts/workspace-intelligence/goal-pack.v1.json",ie="contracts/workspace-intelligence/goal-agent-handoff.v1.json",Ce="contracts/workspace-intelligence/goal-plan-result.v1.json",ue="contracts/workspace-intelligence/goal-index.v1.json",de=new Set(["node","bun","deno","python","go","java","dotnet","rust","php","ruby","elixir","clojure","scala","kotlin","c","cpp"]);function Ae(e,t){let r=e.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)??[],n=new Set(t.map(m=>m.toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"")).filter(Boolean)),a=[];for(let m=0;m<r.length;){let b=0;for(let u=Math.min(4,r.length-m);u>=1;u-=1){let j=r.slice(m,m+u).join("").toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"");if(n.has(j)){b=u;break}}if(b>0){m+=b;continue}a.push(r[m]),m+=1;}let s=a.findIndex((m,b)=>{let u=m.toLocaleLowerCase("en-US"),j=a[b+1]?.toLocaleLowerCase("en-US");return u==="without"&&["breaking","changing","modifying","removing"].includes(j??"")||u==="while"&&["keeping","maintaining","preserving"].includes(j??"")}),l=s>=2?a.slice(0,s):a,d=l.length>=2?l.join(" "):e;if(s<2)return [d];let p=a.slice(s).filter(m=>!["without","while","breaking","changing","modifying","removing","keeping","maintaining","preserving"].includes(m.toLocaleLowerCase("en-US")));return p.length>0?[d,p.join(" ")]:[d]}function ce(e){return e.split(R.sep).join("/")}function V(e,t){return d$2(e,t.path,{...t.absolutePath?{absolutePath:t.absolutePath}:{}})}function le(e){let t=e.requested.trim().replace(/^project:/,"");if(!t)throw new Error("Project goal scope must name a project.");let r=R.isAbsolute(t)?R.resolve(t):null,n=e.model.projects.filter(a=>a.name===t||ce(a.path)===ce(t)||r!==null&&V(e.workspacePath,a)===r);if(n.length!==1)throw new Error(n.length===0?`Project goal scope was not found in the canonical model: ${t}`:`Project goal scope is ambiguous in the canonical model: ${t}`);return n[0]}async function Re(e){let t=await a$1(e);if(t.status==="miss")throw new Error(`Canonical model and live graph evidence are required (${t.reason}). Run \`workspai workspace intelligence run --for-agent generic --strict --json\` or retry with --refresh.`);let{model:r,graph:n}=t;return a(r,"contracts/workspace-intelligence/workspace-model.v1.json","Goal source model"),a(n,"contracts/workspace-intelligence/workspace-knowledge-graph.v1.json","Goal source graph"),b$1(n,r),{model:r,graph:n}}function pe(e){let t=e.scope.trim();if(t==="workspace")return {kind:"workspace",projects:e.model.projects.map(n=>n.name).sort(),selectionSource:e.selectionSource,resolution:"selected"};let r=t.startsWith("projects:")?"projects:":t.startsWith("project:")&&t.slice(8).includes(",")?"project:":null;if(r){let n=t.slice(r.length).split(",").map(l=>l.trim()).filter(Boolean);if(n.length<2)throw new Error("A project-set Goal scope must name at least two projects.");let a=n.map(l=>le({workspacePath:e.workspacePath,model:e.model,requested:l})),s=[...new Set(a.map(l=>l.name))].sort();if(s.length!==n.length)throw new Error("A project-set Goal scope must not contain duplicate projects.");return {kind:"project-set",projects:s,selectionSource:e.selectionSource,resolution:"selected"}}if(t)return {kind:"project",projects:[le({workspacePath:e.workspacePath,model:e.model,requested:t}).name],selectionSource:e.selectionSource,resolution:"selected"};throw new Error("Goal scope cannot be empty.")}async function Se(e){if(e.explicitScope?.trim())return {scope:pe({workspacePath:e.workspacePath,model:e.model,scope:e.explicitScope,selectionSource:"explicit"}),selectionRequired:false};if(e.invocationProjectPath){let t=R.resolve(e.invocationProjectPath),r=e.model.projects.filter(n=>V(e.workspacePath,n)===t);if(r.length!==1)throw new Error("The invocation project is not represented uniquely in the canonical workspace model. Refresh intelligence or pass --scope explicitly.");return {scope:{kind:"project",projects:[r[0].name],selectionSource:"invocation-project",resolution:"selected"},selectionRequired:false}}if(e.model.projects.length===1)return {scope:{kind:"project",projects:[e.model.projects[0].name],selectionSource:"single-project-workspace",resolution:"selected"},selectionRequired:false};if(e.selectScope){let t=await e.selectScope({workspaceName:e.model.workspace.name,projects:e.model.projects.map(n=>({name:n.name,runtime:n.runtime,runtimeCandidates:[...n.runtimeCandidates].sort(),framework:n.framework})).sort((n,a)=>n.name.localeCompare(a.name))}),r=t.kind==="workspace"?"workspace":t.projects.length===1?`project:${t.projects[0]}`:`projects:${t.projects.join(",")}`;return {scope:pe({workspacePath:e.workspacePath,model:e.model,scope:r,selectionSource:"interactive"}),selectionRequired:false}}return {scope:{kind:"workspace",projects:e.model.projects.map(t=>t.name).sort(),selectionSource:"workspace",resolution:"selection-required"},selectionRequired:true}}function Ee(e,t){if(t.kind==="workspace")return {entities:e.quality.entityCount,relationships:e.quality.relationCount,proofs:e.quality.proofCount,unresolved:e.quality.unknownCount,proofCoveragePercent:Number((e.quality.relationProofCoverageRatio*100).toFixed(2))};let r=new Set(t.projects),n=e.entities.filter(p=>p.projectId!==void 0&&r.has(p.projectId)),a=new Set(n.map(p=>p.id)),s=e.relations.filter(p=>a.has(p.from)||a.has(p.to)),l=new Set([...n.flatMap(p=>p.proofIds),...s.flatMap(p=>p.proofIds)]),d=s.filter(p=>p.proofIds.length>0).length;return {entities:n.length,relationships:s.length,proofs:l.size,unresolved:s.length-d,proofCoveragePercent:s.length===0?100:Number((d/s.length*100).toFixed(2))}}function Ie(e){let t=new Map;for(let n of e){let a=t.get(n.kind)??[];a.push(n),t.set(n.kind,a);}let r=[];for(let n=0;[...t.values()].some(a=>n<a.length);n+=1)for(let a of t.values()){let s=a[n];s&&r.push(s);}return r}async function Te(e){let t=R.join(e.workspacePath,p.intelligenceRun),r=await _.readJson(t).catch(()=>null),a=(Array.isArray(r?.stages)?r.stages:[]).filter(o=>o.status==="blocked"||o.status==="failed").map(o=>String(o.id??"unknown")).sort(),s=r?.status,l={status:s==="passed"?"passed":s==="blocked"||s==="failed"?"blocked":"unknown",artifact:p.intelligenceRun,blockedStages:a},d={status:"not-applicable",runtime:null,runtimeChoices:[],runner:null,existingEvidence:[],prerequisites:[]};if(e.intent.category==="test-coverage"){let o=e.intent.requestedTarget?.runtime;if(e.intent.ambiguities.some(P=>P.startsWith("Coverage scope is ambiguous")||P.startsWith("The Goal names multiple coverage runtimes")||P.startsWith("The selected projects do not share a common canonical coverage runtime")||P.startsWith("The requested ")))d={status:"requires-setup",runtime:o??null,runtimeChoices:e.coverageRuntimeChoices,runner:null,existingEvidence:[],prerequisites:["Select exactly one detected runtime or language for this coverage Goal."]};else {let P=o?e.projects.filter(c=>c.runtimeCandidates.includes(o)):e.projects,i=await Promise.all(P.map(async c=>({project:c,capability:await c$3(V(e.workspacePath,c),o??(de.has(c.runtime)?c.runtime:"unknown"))}))),h=i.map(c=>c.capability.status);d={status:h.includes("unsupported")?"unsupported":h.includes("requires-setup")?"requires-setup":"available",runtime:i.length===1?i[0].capability.runtime:[...new Set(i.map(c=>c.capability.runtime))].join(","),runtimeChoices:e.coverageRuntimeChoices,runner:i.length===1?i[0].capability.runner:[...new Set(i.flatMap(c=>c.capability.runner?[c.capability.runner]:[]))].join(",")||null,existingEvidence:i.flatMap(c=>c.capability.existingEvidence.map(C=>({project:c.project.name,...C}))).filter((c,C,w)=>w.findIndex(k=>k.project===c.project&&k.path===c.path&&k.sha256===c.sha256)===C).sort((c,C)=>c.project.localeCompare(C.project)||c.path.localeCompare(C.path)),prerequisites:[...new Set(i.flatMap(c=>c.capability.prerequisites))].sort()};}}let p$1=ae(e.intent),m=[...Ae(p$1[0],e.projects.map(o=>o.name)),...p$1.slice(1)].filter((o,y,P)=>P.indexOf(o)===y).slice(0,3),b=m.map((o,y)=>{let P=o.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)?.length??0,i=y===0&&P>=4?2:1,h=e.projects.map(w=>{let k=G=>g(e.graph,{query:o,projectId:w.name,...G?{kind:G}:{},limit:60,relationsPerEntity:0,minimumTermMatches:i}).entities,S=k(),me=[...new Set(e.graph.entities.filter(G=>G.projectId===w.name||G.projectId===void 0&&G.identity.scope==="workspace").map(G=>G.kind))].flatMap(G=>k(G).slice(0,8)),F=[...S,...me];return F.filter((G,ge)=>F.findIndex(he=>he.id===G.id)===ge)}),c=[],C=new Set;for(let w=0;h.some(k=>w<k.length);w+=1)for(let k of h){let S=k[w];!S||C.has(S.id)||(C.add(S.id),c.push(S));}return Ie(c)}),u={"test-coverage":["test-suite"],"dependency-security":["package","module"],"release-readiness":["pipeline","deployment","lifecycle-stage"],"defect-repair":["test-suite","lifecycle-stage"],"feature-change":["project","runtime-unit","api","package","module","test-suite"],refactor:["package","module","api","test-suite"],performance:["lifecycle-stage","test-suite","pipeline"],documentation:["document","decision"],"system-understanding":["project","service","api","package","protocol"]},j=new Set(e.projects.map(o=>o.name)),v=e.graph.entities.filter(o=>o.proofIds.length>0&&(!o.projectId||j.has(o.projectId))&&u[e.intent.category].includes(o.kind)).sort((o,y)=>u[e.intent.category].indexOf(o.kind)-u[e.intent.category].indexOf(y.kind)||o.label.localeCompare(y.label)),f=[],M=new Set,E=o=>{!o||f.length>=20||M.has(o.id)||(M.add(o.id),f.push(o));},I=(e.intent.statement.match(/[A-Za-z][A-Za-z0-9+#.-]{1,}/g)??[]).length>=2,g$1=I?b[0]??[]:[];for(let o of g$1.slice(0,12))E(o);if(!I)for(let o of v)E(o);for(let o=0;f.length<20&&b.slice(1).some(y=>o<y.length);o+=1)for(let y of b.slice(1))E(y[o]);if(I)for(let o of v)E(o);for(let o of g$1.slice(12))E(o);let T=f.map(o=>({entityId:o.id,kind:o.kind,label:o.label,proofIds:o.proofIds.slice(0,12)})),L=b[0]?.length??0;return {workspaceIntelligence:l,measurement:d,retrieval:{status:I&&L>=3?"grounded":T.length>0?"partial":"empty",strategy:"deterministic-category-v1",queries:m,anchors:T}}}async function xe(e$1){let t=R.join(e$1,f$1);if(!await _.pathExists(t))return {schemaVersion:e,generatedAt:new Date(0).toISOString(),activeGoalId:null,goals:[]};let r=await _.readJson(t);a(r,ue,"Goal index");try{i(r);}catch(n){let a=h(r);if(!(a!==null&&n instanceof Error&&n.message==="Goal index is inconsistent: activeGoalId must identify the only selected actionable lifecycle entry.")||!a)throw n;return a}return r}function _e(e$1,t,r){let n=e$1.goals.find(l=>l.id===t.id),a=t.state==="ready-to-plan",s={id:t.id,fingerprint:t.fingerprint,objective:t.intent.statement,category:t.intent.category,state:t.state,lifecycle:n?.lifecycle==="cancelled"?"cancelled":a?"active":"planned",scope:t.scope,createdAt:n?.createdAt??t.generatedAt,updatedAt:r,goalPack:t.artifacts.goalPack,agentHandoff:t.artifacts.agentHandoff,...n?.verifiedGoalId?{verifiedGoalId:n.verifiedGoalId}:{},...n?.repairTransactionId?{repairTransactionId:n.repairTransactionId}:{},...n?.repairTransactionIds?{repairTransactionIds:n.repairTransactionIds}:{},...n?.changeTransactionId?{changeTransactionId:n.changeTransactionId}:{},...n?.changeTransactionIds?{changeTransactionIds:n.changeTransactionIds}:{},...n?.verificationReceipt?{verificationReceipt:n.verificationReceipt}:{}};return {schemaVersion:e,generatedAt:r,activeGoalId:s.lifecycle==="active"?t.id:e$1.activeGoalId===t.id?null:e$1.activeGoalId,goals:[...e$1.goals.filter(l=>l.id!==t.id).map(l=>s.lifecycle==="active"&&l.lifecycle==="active"?{...l,lifecycle:"planned",updatedAt:r}:l),s].sort((l,d)=>l.id.localeCompare(d.id))}}async function nt(e){let t=b({startPath:R.resolve(e.startPath),explicitWorkspacePath:e.workspacePath,strict:true,requireProjectMembership:!e.scope?.trim()});if(!t)throw new Error("No canonical Workspai workspace could be resolved.");let r=R.resolve(t.workspacePath);e.refresh&&await c({workspacePath:r,strict:false,agent:"generic"});let{model:n,graph:a$1}=await Re(r),s=await Se({workspacePath:r,invocationProjectPath:t.projectPath,model:n,explicitScope:e.scope,selectScope:e.selectScope}),l=s.scope,d$2=n.projects.filter(i=>l.projects.includes(i.name));if(d$2.length===0)throw new Error("A Goal Pack requires at least one registered project in its selected scope.");let p$1=e.maxAttempts??5;if(!Number.isInteger(p$1)||p$1<1||p$1>25)throw new Error("--max-attempts must be an integer from 1 to 25.");let m=new Date().toISOString(),b$1=d(n),u=d$2.map(i=>({name:i.name,runtimes:[...new Set(i.runtimeCandidates.filter(h=>de.has(h)))].sort()})),j$1=[...new Set(u.flatMap(i=>i.runtimes))].sort(),v=u.length<=1?j$1:u[0].runtimes.filter(i=>u.every(h=>h.runtimes.includes(i))),f$2=K(e.intent,{availableCoverageRuntimes:v,...e.runtime?{selectedCoverageRuntime:e.runtime}:v.length===1?{selectedCoverageRuntime:v[0]}:{}});if(e.runtime&&!v.includes(e.runtime)){let i=e.runtime,h=u.filter(c=>!c.runtimes.includes(i)).map(c=>c.name);throw new Error(d$2.length>1&&h.length>0?`--runtime ${e.runtime} is not canonical for every project in the selected Goal scope. Missing from: ${h.join(", ")}. Split the projects into runtime-compatible Goal scopes.`:`--runtime ${e.runtime} is not present in the canonical Workspace Model for the selected Goal scope. Available runtimes: ${v.join(", ")||"none"}.`)}if(e.runtime&&f$2.category!=="test-coverage")throw new Error("--runtime is valid only for a test-coverage Goal.");if(e.runtime&&f$2.requestedTarget?.runtime&&f$2.requestedTarget.runtime!==e.runtime)throw new Error(`--runtime ${e.runtime} conflicts with the ${f$2.requestedTarget.runtime} runtime named in the Goal intent.`);if(!s.selectionRequired&&f$2.category==="test-coverage"&&f$2.requestedTarget&&!f$2.requestedTarget.runtime&&v.length>1&&!e.runtime&&e.selectCoverageRuntime){let i=await e.selectCoverageRuntime({workspaceName:n.workspace.name,scope:l,projects:d$2.map(h=>({name:h.name,runtime:h.runtime,runtimeCandidates:[...h.runtimeCandidates].sort()})),runtimes:v});if(!v.includes(i))throw new Error("The selected coverage runtime is outside the canonical Goal scope.");f$2=K(e.intent,{availableCoverageRuntimes:v,selectedCoverageRuntime:i});}!s.selectionRequired&&f$2.category==="test-coverage"&&d$2.length>1&&v.length===0&&(f$2={...f$2,ambiguities:[`The selected projects do not share a common canonical coverage runtime: ${u.map(i=>`${i.name} (${i.runtimes.join(", ")||"none"})`).join("; ")}. Split them into runtime-compatible Goal scopes so every selected project is verified.`,...f$2.ambiguities]}),s.selectionRequired&&(f$2={...f$2,ambiguities:[`Goal scope is unresolved across ${l.projects.length} registered projects: ${l.projects.join(", ")}. Select one project, multiple projects, or the entire workspace.`,...f$2.ambiguities]});let M=await Te({workspacePath:r,projects:d$2,graph:a$1,intent:f$2,coverageRuntimeChoices:v}),E={generatedAt:m,intent:f$2,workspaceName:n.workspace.name,scope:l,sourceBinding:{model:{artifact:p.model,schemaVersion:q.model,hashAlgorithm:"sha256",hashSemantics:"workspace-model-structural-v1",hash:b$1,generatedAt:n.generatedAt},graph:{artifact:p.knowledgeGraph,schemaVersion:q.knowledgeGraph,hashAlgorithm:"sha256",hashSemantics:"canonical-json-v1",hash:c$1(a$1),generatedAt:a$1.generatedAt,modelHash:a$1.source.hash,...a$1.source.inputs?.hash?{inputHash:a$1.source.inputs.hash}:{}}},preflight:M,baseline:{projectCount:d$2.length,runtimes:[...new Set(d$2.flatMap(i=>i.runtimeCandidates))].sort(),frameworks:[...new Set(d$2.map(i=>i.framework))].sort(),graph:Ee(a$1,l)},maxAttempts:p$1,consumer:e.consumer??"generic"},I={digestCanonical:c$1},{goalPack:g,handoff:T}=j(E,I);a(g,se,"Goal Pack"),a(T,ie,"Goal agent handoff");let L=false,o=async()=>{let i=R.join(r,g.artifacts.goalPack),h=R.join(r,g.artifacts.agentHandoff),[c,C]=await Promise.all([_.pathExists(i),_.pathExists(h)]);if(c!==C)throw new Error(`Goal Pack instance is incomplete and cannot be resumed: ${g.id}`);if(!c)return;let[w,k]=await Promise.all([_.readJson(i),_.readJson(h)]);a(w,se,"Persisted Goal Pack"),a(k,ie,"Persisted goal agent handoff");let S=j({...E,generatedAt:w.generatedAt,sourceBinding:w.sourceBinding},I);if(w.id!==g.id||k.goalId!==g.id||c$1(w)!==c$1(S.goalPack)||c$1(k)!==c$1(S.handoff))throw new Error(`Goal Pack instance failed immutable integrity validation: ${g.id}`);g=w,T=k,L=true;};if(e.dryRun)await o();else {let i$2=`.workspai/goals/${g.id}/publication`;await f(r,i$2,async()=>{await o();let h=_e(await xe(r),g,new Date().toISOString());a(h,ue,"Goal index"),i(h),await i$1(r,d$1,L?[{relativePath:d$1,payload:g},{relativePath:f$1,payload:h}]:[{relativePath:g.artifacts.goalPack,payload:g},{relativePath:g.artifacts.agentHandoff,payload:T},{relativePath:d$1,payload:g},{relativePath:f$1,payload:h}]);});}let y=[g.artifacts.goalPack,g.artifacts.agentHandoff,d$1,f$1],P={schemaVersion:c$2,result:g.state==="needs-confirmation"?"needs-confirmation":g.state==="blocked"?"blocked":g.state==="needs-evidence"?"needs-evidence":"planned",resolution:{source:t.source,invocationScope:t.projectPath?"project":"workspace"},goalPack:g,agentHandoff:T,writtenArtifacts:e.dryRun?[]:L?[d$1,f$1]:y,dryRun:e.dryRun===true,resumed:L};return a(P,Ce,"Goal plan result"),P}export{nt as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{b as buildWorkspaceManifest,f as createProject,a as initializeStandaloneGitRepository,g as registerWorkspaceAtPath,d as resolvePythonFreeFallbackProfile,c as syncWorkspaceFoundationFiles,e as writeWorkspaceLauncher}from'./chunk-
|
|
1
|
+
export{b as buildWorkspaceManifest,f as createProject,a as initializeStandaloneGitRepository,g as registerWorkspaceAtPath,d as resolvePythonFreeFallbackProfile,c as syncWorkspaceFoundationFiles,e as writeWorkspaceLauncher}from'./chunk-UOTOJJI4.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {h as h$1}from'./chunk-
|
|
1
|
+
import {h as h$1}from'./chunk-EFHSRPW7.js';import {b,a as a$1}from'./chunk-TQEMLBAG.js';import {promises}from'fs';import a from'path';import T from'nunjucks';import e from'chalk';import h from'ora';import {fileURLToPath}from'url';import {execa}from'execa';import G from'crypto';var J=fileURLToPath(import.meta.url),M=a.dirname(J);function O(t=32){let i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",x=G.randomBytes(t),o="";for(let p=0;p<t;p++)o+=i[x[p]%i.length];return o}async function te(t,i){let o=(i.template||"fastapi")==="fastapi",p=o?"FastAPI":"NestJS",d=i.kit_name||(o?"fastapi.standard":"nestjs.standard"),D=d.replace(".","/"),$=h(`Generating ${p} project...`).start();try{let w=a.resolve(M,".."),m;d==="fastapi.ddd"?m="fastapi-ddd":d.startsWith("fastapi")?m="fastapi-standard":m="nestjs-standard";let f=a.join(w,"templates","kits",m),S=T.configure(f,{autoescape:false,trimBlocks:true,lstripBlocks:true});S.addFilter("generate_secret",function(n,r=32){return O(r)});let F={project_name:i.project_name,author:i.author||"Workspai User",description:i.description||(o?"FastAPI service generated with Workspai":"NestJS application generated with Workspai"),app_version:i.app_version||"0.1.0",license:i.license||"MIT",package_manager:i.package_manager||"npm",node_version:i.node_version||"20.0.0",database_type:i.database_type||"postgresql",include_caching:i.include_caching||false,created_at:new Date().toISOString(),workspai_version:h$1(),rapidkit_version:h$1()},y;o?y=["src/main.py.j2","src/__init__.py.j2","src/cli.py.j2","src/routing/__init__.py.j2","src/routing/health.py.j2","src/routing/examples.py.j2","src/modules/__init__.py.j2","tests/__init__.py.j2","tests/test_health.py.j2","tests/test_examples.py.j2","README.md.j2","pyproject.toml.j2","Makefile.j2","env.example.j2","rapidkit.j2","rapidkit.cmd.j2"]:y=["src/main.ts.j2","src/app.module.ts.j2","src/app.controller.ts.j2","src/app.service.ts.j2","src/config/configuration.ts.j2","src/config/validation.ts.j2","src/config/index.ts.j2","src/modules/index.ts.j2","src/examples/examples.module.ts.j2","src/examples/examples.controller.ts.j2","src/examples/examples.service.ts.j2","src/examples/dto/create-note.dto.ts.j2","test/app.controller.spec.ts.j2","test/examples.controller.spec.ts.j2","test/app.e2e-spec.ts.j2","test/jest-e2e.json.j2","package.json.j2","tsconfig.json.j2","tsconfig.build.json.j2","nest-cli.json.j2","jest.config.ts.j2","eslint.config.cjs.j2","env.example.j2","docker-compose.yml.j2","Dockerfile.j2","README.md.j2","rapidkit.j2","rapidkit.cmd.j2"];for(let n of y){let r=a.join(f,n);try{await promises.access(r);}catch{continue}let _=await promises.readFile(r,"utf-8"),g;try{g=S.renderString(_,F);}catch(W){throw console.error(`Failed to render template: ${n}`),W}let c=n==="env.example.j2"?".env.example":n.replace(/\.j2$/,""),v=a.join(t,c);await promises.mkdir(a.dirname(v),{recursive:true}),await promises.writeFile(v,g),(c.endsWith(".workspai/rapidkit")||c.endsWith(".workspai/cli.py")||c.endsWith(".workspai/activate")||c.endsWith(".rapidkit/rapidkit")||c.endsWith(".rapidkit/cli.py")||c.endsWith(".rapidkit/activate")||c==="rapidkit")&&await promises.chmod(v,493);}if(o){let n=a.join(f,".rapidkit","context.json"),r=a.join(t,".workspai","context.json");try{await promises.mkdir(a.join(t,".workspai"),{recursive:true}),await promises.copyFile(n,r);}catch{await promises.mkdir(a.join(t,".workspai"),{recursive:true});let g=i.engine||"pip";await promises.writeFile(r,JSON.stringify({engine:g,created_by:"workspai-cli-fallback",legacyCreatedBy:"rapidkit-npm-fallback"},null,2));}}let I=a.join(t,".workspai");await promises.mkdir(I,{recursive:true});let R=a.join(I,"project.json"),C={kit_name:d,profile:D,created_at:new Date().toISOString(),created_by:"workspai-cli-fallback",workspai_version:h$1(),rapidkit_version:h$1(),runtime:o?"python":"node"},P=JSON.stringify(C,null,2);await promises.writeFile(R,P,"utf-8");let j=a.join(t,"rapidkit");await promises.access(j).then(()=>true).catch(()=>false)||(await promises.writeFile(j,`#!/usr/bin/env bash
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
SCRIPT_DIR="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
|
|
4
4
|
cd "$SCRIPT_DIR"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{d as DOCTOR_WORKSPACE_REPORT_PATH,r as applyEnvKeyAddFix,n as applyFileAppendFix,o as applyFileCopyFix,m as applyFileCreateFix,q as applyJsonEditFix,s as applyMakefileTargetFix,l as applyPackageScriptFix,j as assertOperationPathInsideProject,k as assertOperationPathInsideProjectResolved,i as buildRepairOperationIdentity,u as computeDoctorFixAwareExitCode,t as computeDoctorGateExitCode,p as decodeJsonPointerSegment,h as parseInternalRepairCommand,g as parsePackageScriptFix,f as pythonPackageListProvesDependencies,e as resolveDoctorPolicyProfile,v as runDoctor}from'./chunk-
|
|
1
|
+
export{d as DOCTOR_WORKSPACE_REPORT_PATH,r as applyEnvKeyAddFix,n as applyFileAppendFix,o as applyFileCopyFix,m as applyFileCreateFix,q as applyJsonEditFix,s as applyMakefileTargetFix,l as applyPackageScriptFix,j as assertOperationPathInsideProject,k as assertOperationPathInsideProjectResolved,i as buildRepairOperationIdentity,u as computeDoctorFixAwareExitCode,t as computeDoctorGateExitCode,p as decodeJsonPointerSegment,h as parseInternalRepairCommand,g as parsePackageScriptFix,f as pythonPackageListProvesDependencies,e as resolveDoctorPolicyProfile,v as runDoctor}from'./chunk-PSQPKK6H.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a,d,e,b}from'./chunk-HV6EQMUJ.js';import {h as h$1}from'./chunk-
|
|
1
|
+
import {a,d,e,b}from'./chunk-HV6EQMUJ.js';import {h as h$1}from'./chunk-EFHSRPW7.js';import {b as b$1,a as a$1}from'./chunk-TQEMLBAG.js';import {promises}from'fs';import n from'path';import s from'chalk';import y from'ora';import {execa}from'execa';var l=a.dotnet.targetFramework,_="8080";function $(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(/-{2,}/g,"-")}function E(e,r){return e.trim().replace(/[^A-Za-z0-9_.]+/g,".").replace(/^\.+|\.+$/g,"").replace(/\.{2,}/g,".").split(".").map(c=>c.replace(/^[^A-Za-z_]+/,"").replace(/[^A-Za-z0-9_]/g,"")).filter(Boolean).join(".")||r}function D(e,r){return e.replace(/[\r\n\t]+/g," ").trim()||r}function I(e){return e.trim()===l}function P(){return JSON.stringify({engine:"npm",runtime:"dotnet"},null,2)}function k(e,r){return JSON.stringify({kit_name:"dotnet.webapi.clean",runtime:"dotnet",framework:"dotnet",module_support:false,project_name:e.project_name,root_namespace:e.root_namespace,target_framework:e.target_framework,app_version:e.app_version,created_by:"workspai",workspai_version:r,rapidkit_version:r,created_at:new Date().toISOString()},null,2)}function T(e){return `<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
2
2
|
<PropertyGroup>
|
|
3
3
|
<TargetFramework>${e.target_framework}</TargetFramework>
|
|
4
4
|
<Nullable>enable</Nullable>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,k as buildGoalLifecycleResult,l as inspectGoalLifecycle,q as linkGoalChangeTransaction,p as linkGoalRepairTransaction,n as prepareGoalVerification,m as transitionGoalLifecycle,o as verifyGoalLifecycle}from'./chunk-
|
|
1
|
+
export{f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,k as buildGoalLifecycleResult,l as inspectGoalLifecycle,q as linkGoalChangeTransaction,p as linkGoalRepairTransaction,n as prepareGoalVerification,m as transitionGoalLifecycle,o as verifyGoalLifecycle}from'./chunk-QIPW3G2H.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as planGoalPack}from'./chunk-
|
|
1
|
+
export{a as planGoalPack}from'./chunk-ZXQC36NJ.js';export{b as GOAL_AGENT_HANDOFF_SCHEMA_VERSION,f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,g as GOAL_LIFECYCLE_RESULT_SCHEMA_VERSION,d as GOAL_PACK_LAST_RUN_PATH,a as GOAL_PACK_SCHEMA_VERSION,c as GOAL_PLAN_RESULT_SCHEMA_VERSION}from'./chunk-QIPW3G2H.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {c,b,e,d,f,g,h as h$1,a as a$1}from'./chunk-HV6EQMUJ.js';import {h}from'./chunk-
|
|
1
|
+
import {c,b,e,d,f,g,h as h$1,a as a$1}from'./chunk-HV6EQMUJ.js';import {h}from'./chunk-EFHSRPW7.js';import {b as b$1,a}from'./chunk-TQEMLBAG.js';import {promises}from'fs';import u from'path';import o from'chalk';import O from'ora';import {execa}from'execa';function y(e){return `package main
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"fmt"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {c,b as b$1,e,d,f,g,h as h$1,a as a$1}from'./chunk-HV6EQMUJ.js';import {h}from'./chunk-
|
|
1
|
+
import {c,b as b$1,e,d,f,g,h as h$1,a as a$1}from'./chunk-HV6EQMUJ.js';import {h}from'./chunk-EFHSRPW7.js';import {b as b$2,a}from'./chunk-TQEMLBAG.js';import {promises}from'fs';import u from'path';import o from'chalk';import b from'ora';import {execa}from'execa';function G(e){return `package main
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"context"
|
package/dist/index.d.ts
CHANGED
|
@@ -137,10 +137,12 @@ declare function getPublishedContractVersions(): {
|
|
|
137
137
|
agentCustomizationPackCapabilities: "workspai-agent-customization-pack-capabilities.v1";
|
|
138
138
|
agentFrameworkCapabilities: "workspai.agent-framework-capabilities.v1";
|
|
139
139
|
agentFrameworkAdapterManifest: "workspai.agent-framework-adapter-manifest.v1";
|
|
140
|
-
agentFrameworkConformanceReport: "workspai.agent-framework-conformance-report.
|
|
140
|
+
agentFrameworkConformanceReport: "workspai.agent-framework-conformance-report.v2";
|
|
141
|
+
agentFrameworkConformanceReportLegacy: string;
|
|
141
142
|
agentFrameworkChangePlan: "workspai.agent-framework-change-plan.v1";
|
|
142
143
|
agentFrameworkOwnershipReceipt: "workspai.agent-framework-ownership-receipt.v1";
|
|
143
|
-
agentFrameworkAdmissionCandidate: "workspai.agent-framework-admission-candidate.
|
|
144
|
+
agentFrameworkAdmissionCandidate: "workspai.agent-framework-admission-candidate.v2";
|
|
145
|
+
agentFrameworkAdmissionCandidateLegacy: string;
|
|
144
146
|
agentCustomizationPackReport: "rapidkit-agent-customization-pack.v1";
|
|
145
147
|
agentReportsIndex: "rapidkit-agent-reports-index.v1";
|
|
146
148
|
workspaceOperationalSkill: "workspace-operational-skill.v1";
|
|
@@ -367,10 +369,12 @@ declare function getVersionContract(): {
|
|
|
367
369
|
agentCustomizationPackCapabilities: "workspai-agent-customization-pack-capabilities.v1";
|
|
368
370
|
agentFrameworkCapabilities: "workspai.agent-framework-capabilities.v1";
|
|
369
371
|
agentFrameworkAdapterManifest: "workspai.agent-framework-adapter-manifest.v1";
|
|
370
|
-
agentFrameworkConformanceReport: "workspai.agent-framework-conformance-report.
|
|
372
|
+
agentFrameworkConformanceReport: "workspai.agent-framework-conformance-report.v2";
|
|
373
|
+
agentFrameworkConformanceReportLegacy: string;
|
|
371
374
|
agentFrameworkChangePlan: "workspai.agent-framework-change-plan.v1";
|
|
372
375
|
agentFrameworkOwnershipReceipt: "workspai.agent-framework-ownership-receipt.v1";
|
|
373
|
-
agentFrameworkAdmissionCandidate: "workspai.agent-framework-admission-candidate.
|
|
376
|
+
agentFrameworkAdmissionCandidate: "workspai.agent-framework-admission-candidate.v2";
|
|
377
|
+
agentFrameworkAdmissionCandidateLegacy: string;
|
|
374
378
|
agentCustomizationPackReport: "rapidkit-agent-customization-pack.v1";
|
|
375
379
|
agentReportsIndex: "rapidkit-agent-reports-index.v1";
|
|
376
380
|
workspaceOperationalSkill: "workspace-operational-skill.v1";
|
|
@@ -590,10 +594,12 @@ declare function getGlobalCommandCapabilities(): {
|
|
|
590
594
|
agentCustomizationPackCapabilities: "workspai-agent-customization-pack-capabilities.v1";
|
|
591
595
|
agentFrameworkCapabilities: "workspai.agent-framework-capabilities.v1";
|
|
592
596
|
agentFrameworkAdapterManifest: "workspai.agent-framework-adapter-manifest.v1";
|
|
593
|
-
agentFrameworkConformanceReport: "workspai.agent-framework-conformance-report.
|
|
597
|
+
agentFrameworkConformanceReport: "workspai.agent-framework-conformance-report.v2";
|
|
598
|
+
agentFrameworkConformanceReportLegacy: string;
|
|
594
599
|
agentFrameworkChangePlan: "workspai.agent-framework-change-plan.v1";
|
|
595
600
|
agentFrameworkOwnershipReceipt: "workspai.agent-framework-ownership-receipt.v1";
|
|
596
|
-
agentFrameworkAdmissionCandidate: "workspai.agent-framework-admission-candidate.
|
|
601
|
+
agentFrameworkAdmissionCandidate: "workspai.agent-framework-admission-candidate.v2";
|
|
602
|
+
agentFrameworkAdmissionCandidateLegacy: string;
|
|
597
603
|
agentCustomizationPackReport: "rapidkit-agent-customization-pack.v1";
|
|
598
604
|
agentReportsIndex: "rapidkit-agent-reports-index.v1";
|
|
599
605
|
workspaceOperationalSkill: "workspace-operational-skill.v1";
|