workspai 0.58.0 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -32
- package/contracts/agent-customization-pack.v1.json +52 -4
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +90 -0
- package/contracts/extension-cli-compatibility.v1.json +3 -1
- package/contracts/project-workspace-resolution.v1.json +15 -2
- package/contracts/published-contract-catalog.v1.json +10 -0
- package/contracts/runtime-command-surface.v1.json +54 -0
- package/contracts/workspace-intelligence/agent-bootstrap-receipt.v1.json +247 -0
- package/contracts/workspace-intelligence/agent-customization-pack-report.v1.json +16 -1
- package/contracts/workspace-intelligence/goal-index.v1.json +7 -1
- package/contracts/workspace-intelligence/goal-pack.v1.json +2 -1
- package/contracts/workspace-intelligence/project-agent-entry.v1.json +204 -0
- package/contracts/workspace-intelligence/project-context-agent.v1.json +43 -26
- package/contracts/workspace-intelligence/workspace-context.v1.json +14 -1
- package/contracts/workspace-intelligence/workspace-repair-transaction.v1.json +15 -2
- package/contracts/workspace-repair-capabilities.v1.json +5 -0
- package/dist/analyze-52TEGLDR.js +1 -0
- package/dist/{artifact-remediation-plan-JRX4XZ7C.js → artifact-remediation-plan-HPNQTNJ2.js} +1 -1
- package/dist/autopilot-release-KQGDM2AA.js +1 -0
- package/dist/capabilities-command-VBLZXP2T.js +1 -0
- package/dist/chunk-4PUJVYRM.js +1 -0
- package/dist/{chunk-4NN5QWOB.js → chunk-5NIZNXRS.js} +1 -1
- package/dist/{chunk-HYY5PQCV.js → chunk-5PSKBJKJ.js} +1 -1
- package/dist/{chunk-AA4PNQKR.js → chunk-5SFCBZOH.js} +1 -1
- package/dist/{chunk-MFJ6ZP7S.js → chunk-6FBNSTUS.js} +1 -1
- package/dist/{chunk-FY6OHOXR.js → chunk-7DSYI7YN.js} +1 -1
- package/dist/chunk-7SFXADXO.js +2 -0
- package/dist/{chunk-GRGUPSNP.js → chunk-CCDGHPEJ.js} +1 -1
- package/dist/{chunk-T63WRURN.js → chunk-D65FCQIO.js} +1 -1
- package/dist/{chunk-YYCPRYP7.js → chunk-DGGTTRYE.js} +1 -1
- package/dist/{chunk-SM55RK3C.js → chunk-ENKGGWRX.js} +1 -1
- package/dist/{chunk-RMDVRNU7.js → chunk-GPOZILMY.js} +1 -1
- package/dist/{chunk-C4NYG57I.js → chunk-HCFWT42C.js} +1 -1
- package/dist/chunk-HOUQIT7U.js +1 -0
- package/dist/{chunk-RJDGC6AQ.js → chunk-HS3DJMU5.js} +1 -1
- package/dist/{chunk-HI7ONEFI.js → chunk-J3X56S7L.js} +1 -1
- package/dist/{chunk-N3DFX4BY.js → chunk-KBR4Y4RW.js} +1 -1
- package/dist/{chunk-H545P6LN.js → chunk-KTN2ARZJ.js} +1 -1
- package/dist/chunk-LPCWROQ3.js +1 -0
- package/dist/{chunk-6TNSCVR4.js → chunk-M3IKRWXA.js} +1 -1
- package/dist/{chunk-CFBAGPB4.js → chunk-M4UOXP5T.js} +1 -1
- package/dist/{chunk-LGJAAPNR.js → chunk-N4QQADXX.js} +1 -1
- package/dist/{chunk-FXIE2WVG.js → chunk-NOZ4JCH7.js} +1 -1
- package/dist/chunk-NZ3WZYD5.js +1 -0
- package/dist/{chunk-VAWV3UKV.js → chunk-OFWSZYUX.js} +1 -1
- package/dist/{chunk-XC26FNRL.js → chunk-OLC7EYUA.js} +3 -3
- package/dist/chunk-PVXSIYLP.js +1 -0
- package/dist/{chunk-7KXRA5ST.js → chunk-PXWKMPPI.js} +1 -1
- package/dist/{chunk-II4ROT6X.js → chunk-QCKWQFCD.js} +1 -1
- package/dist/{chunk-4YICCES6.js → chunk-QFBVQUKV.js} +1 -1
- package/dist/{chunk-G4VMNWSU.js → chunk-QJCCZLOF.js} +1 -1
- package/dist/{chunk-A3JCETSF.js → chunk-QMPFNXI7.js} +1 -1
- package/dist/{chunk-YMY6EFX4.js → chunk-RBBBXFEU.js} +1 -1
- package/dist/{chunk-TTLVG5AR.js → chunk-RHK53ZK7.js} +1 -1
- package/dist/chunk-S45YGN2I.js +142 -0
- package/dist/chunk-S4CWUZ4K.js +1 -0
- package/dist/{chunk-EEMRRCGR.js → chunk-SP5EHSWG.js} +1 -1
- package/dist/chunk-TCURN5VD.js +2 -0
- package/dist/{chunk-CHMCKYJJ.js → chunk-UVBPEX3E.js} +1 -1
- package/dist/chunk-V3ABABV5.js +39 -0
- package/dist/{chunk-WSDVFLHT.js → chunk-W6FHVXNL.js} +1 -1
- package/dist/{chunk-M2BK3XTP.js → chunk-WQX3JYEP.js} +1 -1
- package/dist/{chunk-AUCHMXUZ.js → chunk-WSRUPDZN.js} +1 -1
- package/dist/{chunk-GVS5OFUB.js → chunk-YEEAWZWI.js} +1 -1
- package/dist/{chunk-I5PDN2P2.js → chunk-ZJCM37KX.js} +1 -1
- package/dist/{create-QIN56Y4M.js → create-6QWIJTGU.js} +1 -1
- package/dist/{doctor-RP4Q2CKJ.js → doctor-NAZEKMGU.js} +1 -1
- package/dist/goal-lifecycle-ECIRCHN5.js +1 -0
- package/dist/goal-pack-HBOPVZFO.js +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +134 -132
- package/dist/{pipeline-77NUVYQD.js → pipeline-5LLFP5ZH.js} +1 -1
- package/dist/project-agent-entry-AFKDDRDL.js +1 -0
- package/dist/{project-intelligence-lens-AM2B2PXU.js → project-intelligence-lens-U2V3VNZG.js} +1 -1
- package/dist/{project-test-coverage-MUSS7Z7V.js → project-test-coverage-HP37HUV2.js} +1 -1
- package/dist/{verified-goal-ZSIZYNVO.js → verified-goal-HUYJ6LBI.js} +1 -1
- package/dist/{workspace-LFESVKE7.js → workspace-CQ43AWUF.js} +1 -1
- package/dist/{workspace-agent-sync-JMRX6J2Y.js → workspace-agent-sync-YMXYUGYY.js} +1 -1
- package/dist/{workspace-archive-MFHCFCDO.js → workspace-archive-ZBCKJHXS.js} +1 -1
- package/dist/{workspace-context-TBKRMVMT.js → workspace-context-RAO62QVU.js} +1 -1
- package/dist/{workspace-contract-KKVC2DUQ.js → workspace-contract-ACSIHJIO.js} +1 -1
- package/dist/workspace-explain-RH27OQB4.js +1 -0
- package/dist/workspace-explain-contract-ZL4NMLZI.js +1 -0
- package/dist/{workspace-feedback-O6J3RQML.js → workspace-feedback-RQ4TGJW6.js} +1 -1
- package/dist/{workspace-foundation-JQWT7YGC.js → workspace-foundation-JH2GFSAZ.js} +1 -1
- package/dist/{workspace-graph-stream-V5WOXP4B.js → workspace-graph-stream-ZZZEQQTE.js} +1 -1
- package/dist/workspace-graph-token-efficiency-D7CUT6NX.js +1 -0
- package/dist/{workspace-history-TOCRMJUJ.js → workspace-history-SYCDK7FO.js} +1 -1
- package/dist/{workspace-intelligence-SDBIRKMK.js → workspace-intelligence-3YERTBA3.js} +1 -1
- package/dist/{workspace-intelligence-evaluation-E4UMWDAZ.js → workspace-intelligence-evaluation-CQDKOYZZ.js} +1 -1
- package/dist/{workspace-intelligence-runner-DIMNL6CJ.js → workspace-intelligence-runner-YXMOT6GK.js} +1 -1
- package/dist/{workspace-intelligence-runtime-registry-YGWB2RRS.js → workspace-intelligence-runtime-registry-IW6J53LO.js} +1 -1
- package/dist/{workspace-knowledge-graph-MUW6UAGI.js → workspace-knowledge-graph-HZZP6ZRB.js} +1 -1
- package/dist/{workspace-knowledge-graph-query-6DAOXGGT.js → workspace-knowledge-graph-query-ON45H6Y7.js} +1 -1
- package/dist/workspace-knowledge-graph-snapshot-7DWHMEM2.js +1 -0
- package/dist/{workspace-mcp-serve-2SWLIH4I.js → workspace-mcp-serve-5TTAN243.js} +1 -1
- package/dist/{workspace-model-VPFCKTYQ.js → workspace-model-EIQSKDX7.js} +1 -1
- package/dist/{workspace-onboarding-GHI6UTQJ.js → workspace-onboarding-SHHW4R4G.js} +1 -1
- package/dist/{workspace-readme-RASXBZRQ.js → workspace-readme-56YZ4EAZ.js} +1 -1
- package/dist/{workspace-registry-summary-7QT7YMIU.js → workspace-registry-summary-OV5KX3WC.js} +1 -1
- package/dist/workspace-repair-engine-BNXZHW35.js +3 -0
- package/dist/workspace-run-7EJEBHAH.js +1 -0
- package/dist/{workspace-verify-RYCQZYYB.js → workspace-verify-W4P6LBIH.js} +1 -1
- package/dist/{workspace-watch-U3YGN3GG.js → workspace-watch-EZ4D4VCF.js} +1 -1
- package/docs/GLOSSARY.md +13 -10
- package/docs/README.md +24 -19
- package/docs/README_CONTENT_CONTRACT.md +12 -8
- package/docs/agent-entry.md +194 -0
- package/docs/ci-workflows.md +1 -1
- package/docs/commands-reference.md +26 -2
- package/docs/contracts/ARTIFACT_CATALOG.md +9 -3
- package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +3 -0
- package/docs/contracts/README.md +7 -0
- package/docs/goal-packs.md +70 -9
- package/docs/workspace-operations.md +16 -8
- package/docs/workspace-repair-engine.md +36 -5
- package/package.json +3 -2
- package/scripts/enterprise-package-smoke.mjs +4 -0
- package/dist/analyze-MAU36FTX.js +0 -1
- package/dist/autopilot-release-TA2L7SCB.js +0 -1
- package/dist/capabilities-command-HE2FICLG.js +0 -1
- package/dist/chunk-42Q5E2YV.js +0 -1
- package/dist/chunk-7IRGSM25.js +0 -1
- package/dist/chunk-CNWUIXF3.js +0 -1
- package/dist/chunk-FPJNWPKU.js +0 -1
- package/dist/chunk-HH54C3XJ.js +0 -1
- package/dist/chunk-NQ5H4R2I.js +0 -83
- package/dist/chunk-PCXBPQO6.js +0 -1
- package/dist/chunk-QXW3SLEX.js +0 -1
- package/dist/chunk-TMOKXYAQ.js +0 -2
- package/dist/chunk-VIFTO53Y.js +0 -1
- package/dist/chunk-ZDYGO3T7.js +0 -36
- package/dist/goal-lifecycle-YTBU3ICP.js +0 -1
- package/dist/goal-pack-MYYH7K43.js +0 -1
- package/dist/workspace-explain-RGGZL5IW.js +0 -1
- package/dist/workspace-explain-contract-4ZZ6CJ44.js +0 -1
- package/dist/workspace-graph-token-efficiency-TF23UYEF.js +0 -1
- package/dist/workspace-knowledge-graph-snapshot-7IU2QAXI.js +0 -1
- package/dist/workspace-repair-engine-AZTJIFCY.js +0 -3
- package/dist/workspace-run-VMZY6LIF.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {c as c$1}from'./chunk-
|
|
1
|
+
import {c as c$1}from'./chunk-HCFWT42C.js';import {a}from'./chunk-A5FBGRJA.js';import {a as a$2}from'./chunk-27UR373Z.js';import {b as b$1}from'./chunk-D65FCQIO.js';import {i as i$1,h}from'./chunk-NZ3WZYD5.js';import {i}from'./chunk-VRW6KXNK.js';import {a as a$1}from'./chunk-TQEMLBAG.js';import {t,s}from'./chunk-MOSXTVPU.js';import {q as q$1,r,s as s$1}from'./chunk-RJIYCDVC.js';import {promises}from'fs';import {randomUUID}from'crypto';import p from'path';import c from'chalk';import ne from'fs-extra';import P from'ora';import {execa}from'execa';async function ce(e){try{let r=await execa("git",["rev-parse","--show-toplevel"],{cwd:e,env:a$1()});return r.stdout.trim()?p.resolve(e,r.stdout.trim()):null}catch{return null}}async function Z(e,r,t){if(await ce(e)){r.warn("Git initialization skipped because target is already inside a git worktree");return}r.start("Initializing git repository...");try{await execa("git",["init"],{cwd:e,env:a$1()}),await execa("git",["add","."],{cwd:e,env:a$1()}),await execa("git",["-c","user.name=Workspai","-c","user.email=workspai@localhost","commit","-m",t],{cwd:e,env:a$1()}),r.succeed("Git repository initialized");}catch{r.warn("Could not initialize git repository");}}function B(e){let r=a(e.path),t=Array.isArray(e.projects)?e.projects:[],o=[],a$1=new Set;for(let s of t){if(!s||typeof s.name!="string"||typeof s.path!="string")continue;let i=a(s.path);a$1.has(i)||(a$1.add(i),o.push({name:s.name,path:i}));}return {name:e.name,path:r,mode:e.mode,projects:o}}function b(e){let r=[],t=new Set;for(let o of e.workspaces||[]){if(!o||typeof o.name!="string"||typeof o.path!="string")continue;let a=B(o);t.has(a.path)||(t.add(a.path),r.push(a));}return {workspaces:r}}async function pe(e){let r;try{r=await promises.readFile(e,"utf8");}catch(t){if(t.code==="ENOENT")return {workspaces:[]};throw t}try{let t=JSON.parse(r);if(!t||!Array.isArray(t.workspaces))throw new Error("missing workspaces array");return b(t)}catch(t){throw new Error(`Workspace registry is invalid: ${e}`,{cause:t})}}async function le(e){let r;try{r=await promises.readFile(e,"utf8");}catch(o){if(o.code==="ENOENT")return {workspaces:[]};throw o}let t;try{t=JSON.parse(r);}catch(o){throw new Error(`Workspace registry is invalid: ${e}`,{cause:o})}if(!t||typeof t!="object"||!Array.isArray(t.workspaces))throw new Error(`Workspace registry is invalid: ${e}`);for(let o of t.workspaces)if(!o||typeof o.name!="string"||typeof o.path!="string"||o.mode!==void 0&&typeof o.mode!="string"||o.projects!==void 0&&!Array.isArray(o.projects)||Array.isArray(o.projects)&&o.projects.some(a=>!a||typeof a.name!="string"||typeof a.path!="string"))throw new Error(`Workspace registry contains an invalid entry: ${e}`);return b(t)}async function F(){let e={workspaces:[]},r=new Set;for(let t of s$1()){let o=await pe(t);for(let a of o.workspaces)r.has(a.path)||(r.add(a.path),e.workspaces.push(a));}return e}async function ee(e=s$1()){let r={workspaces:[]},t=new Set;for(let o of e){let a=await le(o);for(let s of a.workspaces)t.has(s.path)||(t.add(s.path),r.workspaces.push(s));}return r}function de(e){let r=e?.code;return process.platform==="win32"&&(r==="EPERM"||r==="EINVAL"||r==="ENOSYS")}async function te(e){try{await e.sync();}catch(r){if(!de(r))throw r}}async function q(e,r){let t=p.dirname(e);await promises.mkdir(t,{recursive:true});let o=`${p.basename(e)}.`,a=Date.now();for(let i of await promises.readdir(t)){if(!i.startsWith(o)||!i.endsWith(".tmp"))continue;let n=p.join(t,i),d=await promises.stat(n).catch(()=>null);d&&a-d.mtimeMs>3e4&&await promises.rm(n,{force:true}).catch(()=>{});}let s=await promises.readFile(e,"utf8").catch(()=>null);if(s!==null){let i=false;try{let n=JSON.parse(s);i=Array.isArray(n.workspaces);}catch{i=false;}if(!i){let n=`${e}.corrupt-${Date.now()}`;await promises.copyFile(e,n);}}await re(e,`${JSON.stringify(b(r),null,2)}
|
|
2
2
|
`);}async function re(e,r){let t=p.dirname(e);await promises.mkdir(t,{recursive:true});let o=`${e}.${process.pid}.${randomUUID()}.tmp`;try{await promises.writeFile(o,r);let a=await promises.open(o,"r");try{await te(a);}finally{await a.close();}try{await promises.rename(o,e);}catch(s){let i=s.code;if(i!=="EEXIST"&&i!=="EPERM")throw s;await ne.move(o,e,{overwrite:true});}}finally{await promises.rm(o,{force:true}).catch(()=>{});}}async function K(e){try{return {exists:true,content:await promises.readFile(e)}}catch(r){if(r.code==="ENOENT")return {exists:false};throw r}}async function X(e,r){if(!r.exists){await promises.rm(e,{force:true});return}await re(e,r.content);}async function me(e,r){let t=p.join(e,"workspaces.json.lock"),o=randomUUID();await promises.mkdir(e,{recursive:true});let a=Date.now(),s;for(;!s;)try{s=await promises.open(t,"wx"),await s.writeFile(`${JSON.stringify({pid:process.pid,lockId:o,createdAt:new Date().toISOString()})}
|
|
3
3
|
`),await te(s);}catch(i){if(i.code!=="EEXIST")throw i;let n=await promises.stat(t).catch(()=>null);if(n&&Date.now()-n.mtimeMs>3e4){let d=await promises.readFile(t,"utf8").then(m=>JSON.parse(m)).catch(()=>null),u=Number(d?.pid),w=false;if(Number.isInteger(u)&&u>0)try{process.kill(u,0),w=true;}catch(m){w=m.code==="EPERM";}if(!w){await promises.rm(t,{force:true}).catch(()=>{});continue}}if(Date.now()-a>1e4)throw new Error(`Timed out waiting for workspace registry lock: ${t}`);await new Promise(d=>setTimeout(d,25));}try{return await r()}finally{await s.close().catch(()=>{}),await promises.readFile(t,"utf8").then(n=>JSON.parse(n).lockId===o).catch(()=>false)&&await promises.rm(t,{force:true}).catch(()=>{});}}async function _(e){let r$1=q$1(),t=p.join(r$1,"workspaces.json"),o=p.join(r(),"workspaces.json"),a=[...new Set(s$1())];return me(r$1,async()=>{let[s,i]=await Promise.all([K(t),K(o)]),n=await ee(a);await e(n);let d=b(n);try{await q(t,d),await q(o,d);}catch(u){let m=(await Promise.allSettled([X(t,s),X(o,i)])).filter(g=>g.status==="rejected").map(g=>g.reason);throw m.length>0?new AggregateError([u,...m],"Workspace registry transaction failed and could not be fully restored"):u}return d})}async function oe(e,r){let t=a(e);await _(o=>{let a=o.workspaces.find(s=>s.path===t);if(a){a.name=r,a.mode=a.mode||"full",a.projects=Array.isArray(a.projects)?a.projects:[];return}o.workspaces.push({name:r,path:t,mode:"full",projects:[]});});}async function Je(e){let r=a(e),o=(await ee()).workspaces.find(a=>a.path===r);return o?{...o,projects:o.projects.map(a=>({...a}))}:null}async function ze(e,r){let t=a(e);await _(o=>{let a=o.workspaces.findIndex(i=>i.path===t);if(!r){a>=0&&o.workspaces.splice(a,1);return}let s=B(r);a>=0?o.workspaces[a]=s:o.workspaces.push(s);});}async function Ue(e){let r=a(e);await _(t=>{t.workspaces=t.workspaces.filter(o=>o.path!==r);});}async function ge(e,r){try{await oe(e,r);}catch{console.warn(c.gray("Note: Could not register workspace in shared registry"));}}async function Ge(e,r=false){let t$1=a(e),o={workspacePath:t$1,workspaceFound:false,added:[],skipped:0};try{let a$1=await F(),s=a$1.workspaces.find(g=>g.path===t$1);if(!s){if(await ge(t$1,p.basename(p.resolve(e))),a$1=await F(),s=a$1.workspaces.find(g=>g.path===t$1),!s)return r||console.log("\u26A0\uFE0F Workspace could not be registered in registry"),o;r||console.log("\u2714 Registered workspace in shared registry");}Array.isArray(s.projects)||(s.projects=[]);let i=0,n=0,d=[],u=[],w=[e],m=new Set;for(;w.length>0;){let g=w.shift();if(!g||m.has(g))continue;m.add(g);let y=await promises.readdir(g,{withFileTypes:true});for(let h of y){if(!h.isDirectory()||h.name.startsWith(".")||["node_modules","dist","build","target","coverage","htmlcov"].includes(h.name))continue;let j=p.join(g,h.name),f=a(j);try{let k=false;for(let $ of [...t(f,"context.json"),...t(f,"project.json")])try{await promises.access($),k=true;break}catch{}if(k){let $=p.basename(f),S=s.projects.some(C=>C.path===f);u.push({name:$,path:f}),S?n++:(s.projects.push({name:$,path:f}),i++,d.push(f),r||console.log(`\u2714 Added: ${p.relative(e,f)}`));continue}}catch{}w.push(j);}}return await _(g=>{let y=g.workspaces.find(f=>f.path===t$1);if(!y)return;let h=`${t$1}${p.sep}`,j=(y.projects||[]).filter(f=>f.path!==t$1&&!f.path.startsWith(h));y.projects=B({...y,projects:[...j,...u]}).projects;}),i>0?r||console.log(`
|
|
4
4
|
\u2705 Synced ${i} project(s) to registry`):r||console.log(`
|
|
5
|
-
\u2705 All projects already registered (${n} found)`),{workspacePath:t$1,workspaceFound:true,added:d,skipped:n}}catch(a){return r||console.error("\u274C Failed to sync projects:",a.message),o}}async function ue(e,r,t){let o=a(e),a$1=a(t);await _(s=>{let i=s.workspaces.find(u=>u.path===o);if(!i)throw new Error(`Workspace is not registered: ${o}`);i.projects=Array.isArray(i.projects)?i.projects:[];let n=i.projects.findIndex(u=>u.path===a$1||u.name===r),d={name:r,path:a$1};n>=0?i.projects[n]=d:i.projects.push(d);});}async function Me(e,r,t){try{await ue(e,r,t);}catch{}}async function Ve(e,r){let t=P("Creating Workspai workspace...").start();try{await promises.mkdir(e,{recursive:true}),await promises.mkdir(p.join(e,".workspai"),{recursive:true});let o={workspace_name:r.name,author:r.author,rapidkit_version:i(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(p.join(e,".workspai","config.json"),JSON.stringify(o,null,2));let{syncWorkspaceFoundationFiles:a}=await import('./create-
|
|
5
|
+
\u2705 All projects already registered (${n} found)`),{workspacePath:t$1,workspaceFound:true,added:d,skipped:n}}catch(a){return r||console.error("\u274C Failed to sync projects:",a.message),o}}async function ue(e,r,t){let o=a(e),a$1=a(t);await _(s=>{let i=s.workspaces.find(u=>u.path===o);if(!i)throw new Error(`Workspace is not registered: ${o}`);i.projects=Array.isArray(i.projects)?i.projects:[];let n=i.projects.findIndex(u=>u.path===a$1||u.name===r),d={name:r,path:a$1};n>=0?i.projects[n]=d:i.projects.push(d);});}async function Me(e,r,t){try{await ue(e,r,t);}catch{}}async function Ve(e,r){let t=P("Creating Workspai workspace...").start();try{await promises.mkdir(e,{recursive:true}),await promises.mkdir(p.join(e,".workspai"),{recursive:true});let o={workspace_name:r.name,author:r.author,rapidkit_version:i(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(p.join(e,".workspai","config.json"),JSON.stringify(o,null,2));let{syncWorkspaceFoundationFiles:a}=await import('./create-6QWIJTGU.js');await a(e,{workspaceName:r.name,installMethod:"venv",writeMarker:true,writeGitignore:false,onlyIfMissing:true});let s=ke();await promises.writeFile(p.join(e,"rapidkit"),s),await promises.chmod(p.join(e,"rapidkit"),493);let i$1=we();await promises.writeFile(p.join(e,"rapidkit.cmd"),i$1);let n=fe(r.name);await promises.writeFile(p.join(e,"README.md"),n),await promises.writeFile(p.join(e,".gitignore"),`# Workspai workspace
|
|
6
6
|
.env
|
|
7
7
|
.env.*
|
|
8
8
|
!.env.example
|
|
@@ -17,7 +17,7 @@ Thumbs.db
|
|
|
17
17
|
|
|
18
18
|
# Logs
|
|
19
19
|
*.log
|
|
20
|
-
`),await he(e),t.succeed("Workspace created!"),r.skipGit||await Z(e,P(),"Initial commit: Workspai workspace"),await oe(e,r.name);let{publishWorkspaceRegistrySummary:u}=await import('./workspace-registry-summary-
|
|
20
|
+
`),await he(e),t.succeed("Workspace created!"),r.skipGit||await Z(e,P(),"Initial commit: Workspai workspace"),await oe(e,r.name);let{publishWorkspaceRegistrySummary:u}=await import('./workspace-registry-summary-OV5KX3WC.js');await u(e),console.log(`
|
|
21
21
|
${c.green("\u2728 Workspai workspace created successfully!")}
|
|
22
22
|
|
|
23
23
|
${c.bold("\u{1F4C2} Workspace structure:")}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {h}from'./chunk-NZ3WZYD5.js';var _=h.artifactRemediationPlan.schemaVersion;export{_ as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {f}from'./chunk-
|
|
1
|
+
import {f}from'./chunk-NZ3WZYD5.js';var i=f.explain,u=["project","release-blocked","blocker","trace"];function s(t){let e=t.trim();if(!e)return null;if(e==="release-blocked")return {kind:"release-blocked"};if(e.startsWith("project:")){let r=e.slice(8).trim();return r?{kind:"project",project:r}:null}if(e.startsWith("blocker:")){let r=e.slice(8).trim();return r?{kind:"blocker",blockerId:r}:null}if(e.startsWith("trace:")){let r=e.slice(6).trim();return r?{kind:"trace",diffRef:r}:null}return {kind:"project",project:e}}function E(t){let e=t.trim();if(!e)return null;if(e.startsWith("trace:")){let n=s(e);return n?.kind==="trace"?n:null}let r=e.replace(/\\/g,"/").trim().toLowerCase();return r.endsWith(".json")||r.includes("workspace-model-diff")||r.startsWith(".rapidkit/")||r.includes("/.rapidkit/")?{kind:"trace",diffRef:e}:null}function A(t){if(!t||typeof t!="object"||Array.isArray(t))return false;let e=t;return e.schemaVersion===i&&typeof e.generatedAt=="string"&&typeof e.summary=="string"&&Array.isArray(e.sections)&&e.target!=null&&typeof e.target=="object"&&!Array.isArray(e.target)&&typeof e.target.kind=="string"}export{i as a,u as b,s as c,E as d,A as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {f}from'./chunk-
|
|
1
|
+
import {f}from'./chunk-NZ3WZYD5.js';var o="model-usage-event.v1",s=f.evaluationLive,a="workspace-intelligence-evaluation-comparison.v1",i=["provider-reported","tokenizer-counted","estimated","unavailable"];export{o as a,s as b,a as c,i as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-2647BYBC.js';import {l}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-2647BYBC.js';import {l}from'./chunk-WSRUPDZN.js';import {d,c}from'./chunk-EWZZUQBR.js';import {a}from'./chunk-GR6442P7.js';import {f,e,i}from'./chunk-NZ3WZYD5.js';import p from'path';import {createHash}from'crypto';import {createReadStream}from'fs';import {execFile}from'child_process';import {promisify}from'util';import S from'fs-extra';import {parseAllDocuments}from'yaml';var pe=f.knowledgeGraph;var Yt=e.knowledgeGraph;function Xt(e$1,t){if(e$1.source.kind!=="workspace-model")throw new Error(`Workspace knowledge graph is not bound to the canonical workspace model (source: ${e$1.source.kind}).`);if(e$1.source.artifact!==e.model)throw new Error(`Workspace knowledge graph source artifact is ${e$1.source.artifact}; expected ${e.model}.`);if(e$1.source.hashAlgorithm!=="sha256")throw new Error(`Workspace knowledge graph source hash algorithm is ${e$1.source.hashAlgorithm}; expected sha256.`);let o=d(t);if(e$1.source.hash!==o)throw new Error("Workspace knowledge graph is stale: its source hash does not match the canonical workspace model.");if(e$1.workspace.name!==t.workspace.name||(e$1.workspace.profile??void 0)!==(t.workspace.profile??void 0))throw new Error("Workspace knowledge graph identity does not match the canonical workspace model.");let i=l(t);if(!i)throw new Error("Canonical workspace model has no project topology for the workspace knowledge graph.");let r=c=>({...c,generatedAt:"<ignored>"});if(c(r(e$1.projectTopology))!==c(r(i)))throw new Error("Workspace knowledge graph project topology does not match the canonical workspace model.")}var De=new Set([".git",".hg",".svn",".workspai",".rapidkit",".venv","venv","vendor","node_modules","dist","build","target","coverage",".next",".turbo",".cache",".vscode-test","graphify-out",".pytest_cache",".mypy_cache",".ruff_cache",".tox",".gradle","fixture","fixtures","__fixtures__","testdata"]),Me=new Set(["test","tests","spec","specs","e2e","integration","integration-tests","integration_tests","__tests__","fixture","fixtures","__fixtures__","testdata"]),ze=new Set(["examples","samples","worked"]);function se(e,t){let o=p.relative(e,t).split(p.sep).map(r=>r.toLowerCase()),i=p.basename(t).toLowerCase();return o.some(r=>Me.has(r))||/(?:\.test|\.spec|_test)\.[a-z0-9]+$/i.test(i)||/^test_.+\.[a-z0-9]+$/i.test(i)||/(?:tests?|specs?)\.(?:cs|fs|vb|java|kt|kts)$/i.test(i)}function ie(e,t){return p.relative(e,t).split(p.sep).map(o=>o.toLowerCase()).some(o=>ze.has(o))}function M(e,t){return se(e,t)||ie(e,t)}function oe(e,t){return p.relative(e,t).split(p.sep).some(o=>o.toLowerCase()==="generated")}var fe=new Set(["package.json","pyproject.toml","requirements.txt","Pipfile","go.mod","Cargo.toml","pom.xml","build.gradle","build.gradle.kts","composer.json","Gemfile","mix.exs","pubspec.yaml","Package.swift","CMakeLists.txt","deno.json","deno.jsonc","project.clj","deps.edn","build.sbt","BUILD","BUILD.bazel","WORKSPACE.bazel"]),Be=new Set(["get","put","post","delete","options","head","patch","trace"]),T=new Set([".c",".cc",".cpp",".cs",".dart",".ex",".exs",".go",".h",".hpp",".java",".js",".jsx",".kt",".kts",".mjs",".php",".py",".r",".rb",".rs",".scala",".svelte",".swift",".ts",".tsx",".vue",".clj",".cljs",".fs",".fsx",".lua",".vb"]);function F(e,t){let o=p.extname(e).toLowerCase();return o===".h"&&t==="cpp"?"cpp":{".c":"c",".cc":"cpp",".cpp":"cpp",".cs":"csharp",".dart":"dart",".ex":"elixir",".exs":"elixir",".go":"go",".h":"c",".hpp":"cpp",".java":"java",".js":"javascript",".jsx":"javascript",".kt":"kotlin",".kts":"kotlin",".mjs":"javascript",".php":"php",".py":"python",".r":"r",".rb":"ruby",".rs":"rust",".scala":"scala",".svelte":"svelte",".swift":"swift",".ts":"typescript",".tsx":"typescript",".vue":"vue",".clj":"clojure",".cljs":"clojure",".fs":"fsharp",".fsx":"fsharp",".lua":"lua",".vb":"visual-basic"}[o]??o.slice(1)}function Ge(e,t){if(e.length<=t)return [...e];let o=new Map;for(let c of e){let s=F(c),a=o.get(s)??[];a.push(c),o.set(s,a);}let i=new Set,r=Math.max(1,Math.min(25,Math.floor(t/Math.max(o.size,1))));for(let c of [...o.values()])for(let s of c.slice(0,r))i.add(s);for(let c of e){if(i.size>=t)break;i.add(c);}return [...i].sort((c,s)=>c.localeCompare(s))}function Q(e,t,o){let i=[],r=e.split(/\r?\n/);for(let c=0;c<r.length&&i.length<o;c+=1)for(let s of t){let n=r[c].match(s.pattern)?.[1]?.trim();if(n){i.push({name:n,line:c+1,detail:s.detail});break}}return i}var xe=[{pattern:/^\s*(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/,detail:"function"},{pattern:/^\s*(?:export\s+)?(?:abstract\s+)?(?:class|interface|enum|type)\s+([A-Za-z_$][\w$]*)/,detail:"type"},{pattern:/^\s*(?:export\s+)?(?:declare\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)/,detail:"value"},{pattern:/^\s*(?:async\s+)?def\s+([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*class\s+([A-Za-z_]\w*)/,detail:"type"},{pattern:/^\s*func\s+(?:\([^)]*\)\s*)?([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*type\s+([A-Za-z_]\w*)\s+/,detail:"type"},{pattern:/^\s*(?:public\s+|private\s+|protected\s+|internal\s+|abstract\s+|final\s+)*(?:class|interface|record|enum)\s+([A-Za-z_]\w*)/,detail:"type"},{pattern:/^\s*(?:public|protected|internal)\s+(?:(?:static|virtual|override|abstract|async|sealed|final|synchronized|native|unsafe|partial|extern|new)\s+)*(?:<[^>]+>\s*)?[A-Za-z_$][\w$<>,.?\[\]: ]*\s+([A-Za-z_$][\w$]*)\s*\(/,detail:"method"},{pattern:/^\s*(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*(?:pub(?:\([^)]*\))?\s+)?(?:struct|trait|enum|type)\s+([A-Za-z_]\w*)/,detail:"type"},{pattern:/^\s*(?:public\s+|private\s+|protected\s+)?function\s+([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*(?:class|module|struct|protocol|mixin)\s+([A-Za-z_]\w*)/,detail:"type"}],qe=[{pattern:/^\s*import(?:.+?from\s*)?["']([^"']+)["']/,detail:"import"},{pattern:/require\(["']([^"']+)["']\)/,detail:"require"},{pattern:/^\s*from\s+([A-Za-z0-9_.]+)\s+import\s+/,detail:"import"},{pattern:/^\s*import\s+([A-Za-z0-9_.]+)(?:\s|$)/,detail:"import"},{pattern:/^\s*(?:import|using|use)\s+([A-Za-z0-9_:.*\\/.-]+)/,detail:"import"},{pattern:/^\s*require(?:_relative)?\s+["']([^"']+)["']/,detail:"require"}];function Ze(e,t,o,i){let r=p.extname(e).toLowerCase()===".py",c;if(r){let d=t.match(/^\.+/)?.[0].length??0,l=d>0?p.dirname(e):p.resolve(i??"");for(let u=1;u<d;u+=1)l=p.dirname(l);let m=t.slice(d).replace(/\./g,p.sep);c=m?p.join(l,m):l;}else {if(!t.startsWith("."))return null;c=p.resolve(p.dirname(e),t);}let s=p.extname(c).toLowerCase(),a=T.has(s),n=new Set([c]);if(r&&(n.add(`${c}.py`),n.add(p.join(c,"__init__.py"))),a){let d=c.slice(0,-s.length);if([".js",".jsx",".mjs"].includes(s))for(let l of [".ts",".tsx",".js",".jsx",".mjs"])n.add(`${d}${l}`);}else for(let d of T)n.add(`${c}${d}`),n.add(p.join(c,`index${d}`));return [...n].find(d=>o.has(p.resolve(d)))??null}function He(e,t){let o=t.trimStart(),i=p.extname(e).toLowerCase();return [".py",".rb",".sh",".bash",".zsh"].includes(i)?o.startsWith("#"):[".sql",".lua",".hs"].includes(i)?o.startsWith("--"):o.startsWith("//")||o.startsWith("/*")||o.startsWith("*")}function Ve(e,t){if(p.extname(e).toLowerCase()!==".py")return t;let o=null;return t.split(/\r?\n/).map(i=>{let r=0,c="";for(;r<i.length;){if(o){let l=i.indexOf(o,r);if(l<0)return c;r=l+3,o=null;continue}let s=i.indexOf("'''",r),a=i.indexOf('"""',r),n=i.indexOf("#",r),d=s<0?a:a<0?s:Math.min(s,a);if(n>=0&&(d<0||n<d)){c+=i.slice(r,n);break}if(d<0){c+=i.slice(r);break}c+=i.slice(r,d),o=i.startsWith("'''",d)?"'''":'"""',r=d+3;}return c}).join(`
|
|
2
2
|
`)}function Je(e,t){if(![".js",".jsx",".mjs",".ts",".tsx"].includes(p.extname(e).toLowerCase()))return t;let o=false,i=false;return t.split(/\r?\n/).map(r=>{let c="",s=null,a=false;for(let n=0;n<r.length;n+=1){let d=r[n],l=r[n+1];if(o){c+=" ",d==="*"&&l==="/"&&(c+=" ",n+=1,o=false);continue}if(i){c+=" ",d==="`"&&!a&&(i=false),a=d==="\\"&&!a,d!=="\\"&&(a=false);continue}if(s){c+=d,d===s&&!a&&(s=null),a=d==="\\"&&!a,d!=="\\"&&(a=false);continue}if(d==="/"&&l==="/")return c.padEnd(r.length," ");if(d==="/"&&l==="*"){c+=" ",n+=1,o=true;continue}if(d==="`"){c+=" ",i=true,a=false;continue}(d==="'"||d==='"')&&(s=d),c+=d;}return c}).join(`
|
|
3
3
|
`)}function Ue(e,t){return Je(e,Ve(e,t))}var Ye=[{pattern:/@(?:Get|Post|Put|Delete|Patch|Options|Head)\s*\(\s*["']([^"']*)["']/i,detail:"decorated route"},{pattern:/\b(?:app|router|server|api|route|fastify|fiber)\.(?:get|post|put|delete|patch|options|head)\s*\(\s*["']([^"']+)["']/i,detail:"router route"},{pattern:/@(?:GetMapping|PostMapping|PutMapping|DeleteMapping|PatchMapping|RequestMapping)\s*\([^"']*["']([^"']*)["']/,detail:"mapped route"},{pattern:/\[Http(?:Get|Post|Put|Delete|Patch)\s*\(\s*["']([^"']*)["']/i,detail:"HTTP route"},{pattern:/^\s*(?:get|post|put|delete|patch)\s+["']([^"']+)["']/i,detail:"HTTP route"}];function V(e){return createHash("sha256").update(e).digest("hex")}function E(e,t){return `wkg:${e}:${V(`${e}\0${t}`).slice(0,20)}`}function O(e){return e.replace(/\\/g,"/")}function x(e){let t=O(e).replace(/^\.\//,"");return !t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")?"unknown":t}function j(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function b(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function K(e){if(Array.isArray(e))return e.filter(o=>typeof o=="string").map(o=>o.trim()).filter(Boolean).sort();let t=j(e);return t?Object.keys(t).map(o=>o.trim()).filter(Boolean).sort():[]}function Xe(e){if(Array.isArray(e))return e.map(o=>typeof o=="string"?o.split("=",1)[0]?.trim():"").filter(o=>!!o).sort();let t=j(e);return t?Object.keys(t).sort():[]}function Qe(e){return Object.fromEntries(Object.entries(e).filter(t=>t[1]!==void 0).sort(([t],[o])=>t.localeCompare(o)))}async function q(e,t){let o=[],i=[e],r=0;for(;r<i.length&&o.length<t;){let c=i[r++],s;try{s=await S.readdir(c,{withFileTypes:true});}catch{continue}s.sort((a,n)=>a.name.localeCompare(n.name));for(let a$1 of s){if(o.length>=t)break;if(a$1.isSymbolicLink())continue;let n=p.join(c,a$1.name);a$1.isDirectory()?!De.has(a$1.name)&&!a(a$1.name)&&i.push(n):a$1.isFile()&&o.push(n);}}return o.sort((c,s)=>c.localeCompare(s))}async function Se(e){return new Promise(t=>{let o=createHash("sha256"),i=createReadStream(e);i.on("data",r=>o.update(r)),i.on("error",r=>{t(`unreadable:${r.code??"unknown"}`);}),i.on("end",()=>t(o.digest("hex")));})}var et=promisify(execFile);async function D(e,t){let o=await et("git",t,{cwd:e,encoding:"buffer",maxBuffer:268435456,windowsHide:true});return Buffer.isBuffer(o.stdout)?o.stdout:Buffer.from(o.stdout)}async function tt(e){try{let t=(await D(e.root,["rev-parse","--show-prefix"])).toString("utf8").trim().replace(/\\/gu,"/"),o=t?`${t.replace(/^\/+|\/+$/gu,"")}/`:"";if(p.posix.isAbsolute(o)||o==="../"||o.startsWith("../")||o.includes("/../"))return null;let i=o.replace(/\/$/u,""),r=i?`HEAD:${i}`:"HEAD^{tree}",[c,s,a,n,d,l]=await Promise.all([D(e.root,["rev-parse",r]),D(e.root,["diff","--no-ext-diff","--no-textconv","--binary","HEAD","--","."]),D(e.root,["ls-files","--full-name","--others","--exclude-standard","-z","--","."]),D(e.root,["ls-files","--full-name","--others","--ignored","--exclude-standard","-z","--","."]),D(e.root,["ls-files","-v","--","."]),D(e.root,["ls-files","--full-name","-s","--","."])]);if(d.toString("utf8").split(/\r?\n/u).some(f=>/^[a-z] /u.test(f)))return null;let m=e.files.map(f=>{let y=O(p.relative(e.root,f));return `${o}${y}`});if(l.toString("utf8").split(/\r?\n/u).filter(f=>f.startsWith("160000 ")).map(f=>f.split(" ",2)[1]).filter(f=>!!f).map(f=>f.replace(/\\/gu,"/").replace(/\/$/u,"")).some(f=>m.some(y=>y.startsWith(`${f}/`))))return null;let v=new Set(m),g=Buffer.concat([a,n]).toString("utf8").split("\0").filter(Boolean).map(f=>f.replace(/\\/gu,"/")).filter(f=>v.has(f)),w=await Ae([...new Set(g)].sort((f,y)=>f.localeCompare(y)),16,async f=>{let y=o?f.slice(o.length):f;return {path:y,hash:await Se(p.resolve(e.root,...y.split("/").filter(Boolean)))}}),P=createHash("sha256");P.update(`git-worktree-v2\0${e.kind}\0${e.id}\0${e.fileLimit}\0`),P.update(c),P.update(createHash("sha256").update(s).digest());for(let f of w)P.update(`${f.path}\0${f.hash}\0`);return {kind:e.kind,id:e.id,strategy:"git-worktree-v2",hash:P.digest("hex"),fileCount:e.files.length,fileLimit:e.fileLimit,truncated:e.files.length>=e.fileLimit}}catch{return null}}async function Ae(e,t,o){let i=new Array(e.length),r=0,c=Array.from({length:Math.min(t,Math.max(e.length,1))},async()=>{for(;r<e.length;){let s=r++;i[s]=await o(e[s]);}});return await Promise.all(c),i}async function ue(e){let t=await tt(e);if(t)return t;let o=await Ae(e.files,16,async r=>({path:O(p.relative(e.root,r)),hash:await Se(r)}));o.sort((r,c)=>r.path.localeCompare(c.path));let i=createHash("sha256");i.update(`content-merkle-v1\0${e.kind}\0${e.id}\0${e.fileLimit}\0`);for(let r of o)i.update(`${r.path}\0${r.hash}\0`);return {kind:e.kind,id:e.id,strategy:"content-merkle-v1",hash:i.digest("hex"),fileCount:o.length,fileLimit:e.fileLimit,truncated:o.length>=e.fileLimit}}async function ot(e){let t=p.resolve(e.workspacePath),o=[...e.projects].sort((s,a)=>s.id.localeCompare(a.id)),i=e.inventories?.workspaceFiles??await q(t,e.workspaceFileLimit),r=await Promise.all([ue({kind:"workspace",id:"workspace",root:t,files:i,fileLimit:e.workspaceFileLimit}),...o.map(async s=>{let a=s.absolutePath?p.resolve(s.absolutePath):p.resolve(t,s.path),n=e.inventories?.projectFiles?.get(s.id)??await q(a,e.projectFileLimit);return ue({kind:"project",id:s.id,root:a,files:n,fileLimit:e.projectFileLimit})})]);r.sort((s,a)=>s.kind.localeCompare(a.kind)||s.id.localeCompare(a.id));let c=createHash("sha256");c.update("workspace-knowledge-graph-inputs.v1\0hybrid-git-content-v2\0");for(let s of r)c.update(`${s.kind}\0${s.id}\0${s.hash}\0${s.fileCount}\0${s.fileLimit}\0${s.truncated}\0`);return {schemaVersion:"workspace-knowledge-graph-inputs.v1",strategy:"hybrid-git-content-v2",hashAlgorithm:"sha256",hash:c.digest("hex"),scopes:r}}async function B(e){let t=await S.readFile(e,"utf8");if(e.toLowerCase().endsWith(".json")){let o=JSON.parse(t),i=j(o);return i?[i]:[]}return parseAllDocuments(t,{logLevel:"silent"}).map(o=>j(o.toJSON())).filter(o=>o!==null)}function J(e){return [...new Set([...e.workspaceFiles,...e.projects.flatMap(t=>e.filesByProject.get(t.id)??[])])].sort((t,o)=>t.localeCompare(o))}function me(e){return /^(?:openapi|swagger)(?:\.[^.]+)?\.(?:json|ya?ml)$/i.test(p.basename(e))}function ge(e){let t=p.basename(e).toLowerCase();return /\.(?:graphql|gql|proto)$/.test(t)||/^asyncapi(?:\.[^.]+)?\.(?:json|ya?ml)$/.test(t)}function he(e){let t=p.basename(e);return /^Dockerfile(?:\..+)?$/i.test(t)||/\.tf$/i.test(t)||t==="Chart.yaml"}function ye(e){return /(?:^|[\\/])(?:README|ARCHITECTURE|CONTRIBUTING|SECURITY)\.md$/i.test(e)}function rt(e,t){let o=O(p.relative(e,t));return /^\.github\/workflows\/.+\.ya?ml$/i.test(o)||/^(?:\.gitlab-ci\.ya?ml|azure-pipelines\.ya?ml|Jenkinsfile|bitbucket-pipelines\.ya?ml|\.woodpecker\.ya?ml)$/i.test(o)||/^\.circleci\/config\.ya?ml$/i.test(o)}function ve(e,t){let o=O(p.relative(e,t));return /(?:^|\/)(?:adr|adrs|decisions)(?:\/).+\.md$/i.test(o)||/(?:^|\/)ADR[-_0-9].+\.md$/i.test(o)}async function ke(e){let t=new Set;for(let o of [e.workspacePath,...e.projects.map(i=>i.root)])for(let i of ["compose.yml","compose.yaml","docker-compose.yml","docker-compose.yaml"]){let r=p.join(o,i);await S.pathExists(r)&&t.add(r);}return [...t].sort((o,i)=>o.localeCompare(i))}async function be(e){let o=[e.workspacePath,...e.projects.map(r=>r.root)].flatMap(r=>[p.join(r,"CODEOWNERS"),p.join(r,".github","CODEOWNERS"),p.join(r,"docs","CODEOWNERS")]),i=await Promise.all(o.map(async r=>await S.pathExists(r)?r:null));return [...new Set(i.filter(r=>!!r))].sort((r,c)=>r.localeCompare(c))}function we(e){let t=[{root:e.workspacePath,files:e.workspaceFiles},...e.projects.map(o=>({root:o.root,files:e.filesByProject.get(o.id)??[]}))];return [...new Set(t.flatMap(o=>o.files.filter(i=>rt(o.root,i))))].sort((o,i)=>o.localeCompare(i))}async function Pe(e){let t=[];for(let o of J(e))if(/\.ya?ml$/i.test(o))try{(await B(o)).some(r=>{let c=j(r.metadata);return !!(b(r.apiVersion)&&b(r.kind)&&b(c?.name))})&&t.push(o);}catch{}return t.sort((o,i)=>o.localeCompare(i))}function N(e,t){let o=p.resolve(t);return e.filter(i=>o===i.root||o.startsWith(`${i.root}${p.sep}`)).sort((i,r)=>r.root.length-i.root.length)[0]??null}var re=class{constructor(t,o,i){this.workspacePath=t;this.now=o;this.workspaceName=i;}workspacePath;now;workspaceName;entities=new Map;relations=new Map;proofs=new Map;providers=[];diagnostics=[];contentHashes=new Map;attributeConflicts=new Set;emptyLabelDiagnostics=new Set;artifactPath(t,o){if(o){let i=O(p.relative(o.root,t));return x(p.posix.join(o.artifactPrefix,i))}return x(p.relative(this.workspacePath,t))}async addProof(t){let o;if(t.absolutePath){if(!this.contentHashes.has(t.absolutePath))try{this.contentHashes.set(t.absolutePath,V(await S.readFile(t.absolutePath)));}catch{this.contentHashes.set(t.absolutePath,null);}o=this.contentHashes.get(t.absolutePath)??void 0;}let i=x(t.artifact),r=E("proof",[t.provider,i,t.pointer??"",t.line??"",t.detail??""].join("\0"));return this.proofs.has(r)||this.proofs.set(r,{id:r,provider:t.provider,artifact:i,...t.pointer?{pointer:t.pointer}:{},...t.line?{line:t.line}:{},...t.column?{column:t.column}:{},...o?{contentHash:o}:{},observedAt:this.now.toISOString(),derivation:t.derivation??"extracted",trust:t.trust??"observed",confidence:t.confidence??"high",freshness:"fresh",...t.detail?{detail:t.detail}:{}}),r}addEntity(t){let o=E(t.kind,t.key),i=Qe(t.attributes??{}),r=this.entities.get(o),c=t.label.trim(),s=c||r?.label||t.key.trim()||t.kind;!c&&!this.emptyLabelDiagnostics.has(o)&&(this.emptyLabelDiagnostics.add(o),this.diagnostics.push({code:"graph.knowledge.empty_label_normalized",severity:"warning",message:`An empty ${t.kind} label was normalized to ${s}.`,entityIds:[o],recommendation:"Inspect the provider proof and preserve a non-empty source identifier before publishing the entity."}));let a={...r?.attributes??{}};for(let[l,m]of Object.entries(i)){if(l in a&&JSON.stringify(a[l])!==JSON.stringify(m)){let u=`${o}\0${l}`;this.attributeConflicts.has(u)||(this.attributeConflicts.add(u),this.diagnostics.push({code:"graph.knowledge.attribute_conflict",severity:"warning",message:`Conflicting ${l} values were observed for ${t.kind} ${s}.`,entityIds:[o],recommendation:"Inspect the entity proof paths and make the authoritative source explicit."}));continue}a[l]=m;}let n=[...new Set([...r?.identity.aliases??[],...t.aliases??[]].map(l=>l.trim()).filter(Boolean))].sort(),d=[...new Set([...r?.proofIds??[],...t.proofIds??[]])].sort();return this.entities.set(o,{id:o,kind:t.kind,label:s,...t.projectId?{projectId:t.projectId}:{},identity:{key:t.key,scope:t.projectId?"project":"workspace",aliases:n,fingerprint:V(JSON.stringify({kind:t.kind,key:t.key,attributes:a}))},attributes:a,proofIds:d}),o}addRelation(t){let o=E("relation",`${t.from}\0${t.kind}\0${t.to}`),i=this.relations.get(o),r=[...new Set([...i?.proofIds??[],...t.proofIds])].sort(),c=new Set(r.map(n=>this.proofs.get(n)?.provider).filter(Boolean)).size,s=t.trust??i?.trust??"observed",a=c>=2&&s!=="ambiguous"?"corroborated":s;return this.relations.set(o,{id:o,from:t.from,to:t.to,kind:t.kind,derivation:t.derivation??i?.derivation??"extracted",trust:a,confidence:a==="corroborated"?"high":t.confidence??i?.confidence??"high",proofIds:r}),o}};function ee(e){let t=[],o=null;for(let i of e.split(/\r?\n/)){let r=i.match(/^\s*\[\[([^\]]+)\]\]\s*(?:#.*)?$/)?.[1]?.trim()??i.match(/^\s*\[([^\]]+)\]\s*(?:#.*)?$/)?.[1]?.trim();if(r){o&&t.push({name:o.name,body:o.lines.join(`
|
|
4
4
|
`)}),o={name:r,lines:[]};continue}o?.lines.push(i);}return o&&t.push({name:o.name,body:o.lines.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b}from'./chunk-
|
|
1
|
+
import {b}from'./chunk-GPOZILMY.js';import {c,d,a,b as b$1}from'./chunk-MOSXTVPU.js';import n from'fs';import o from'path';function _(t){return b({startPath:t})?.workspacePath??null}function k(t){let s=o.resolve(t),p=n.existsSync(o.join(s,c))||n.existsSync(o.join(s,d))||n.existsSync(o.join(s,a,"workspace.json"))||n.existsSync(o.join(s,b$1,"workspace.json")),A=n.existsSync(o.join(s,a,"project.json"))||n.existsSync(o.join(s,a,"context.json"))||n.existsSync(o.join(s,b$1,"project.json"))||n.existsSync(o.join(s,b$1,"context.json"));return p&&!A}export{_ as a,k as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {f,l}from'./chunk-
|
|
1
|
+
import {f,l}from'./chunk-WSRUPDZN.js';import {a,b}from'./chunk-S5KTATOU.js';function u(r){let s=new Map;for(let n of r.projects)s.has(n.name)||s.set(n.name,f(n));return s}function w(r){let s=u(r),n=l(r)??{nodes:r.projects.map(t=>({id:t.name,path:t.path})),edges:[]},a$1=a(n),o=new Map;for(let t of n.nodes){let e=s.get(t.id)??f({missing:t.id}),l=[...b(a$1,[t.id],{direction:"dependencies"}).keys()].filter(c=>c!==t.id).sort((c,f)=>c.localeCompare(f)).map(c=>({id:c,hash:s.get(c)??"<unknown>"}));o.set(t.id,{id:t.id,ownHash:e,transitiveInputsHash:f({own:e,dependencies:l})});}return o}function y(r,s){if(!s||Object.keys(s).length===0)return {verdict:"unknown",baseline:"none",changed:[],added:[],removed:[]};let n=[],a=[];for(let[e,i]of r.entries())e in s?s[e]!==i.transitiveInputsHash&&n.push(e):a.push(e);let o=[];for(let e of Object.keys(s))r.has(e)||o.push(e);return n.sort((e,i)=>e.localeCompare(i)),a.sort((e,i)=>e.localeCompare(i)),o.sort((e,i)=>e.localeCompare(i)),{verdict:n.length>0||a.length>0||o.length>0?"stale":"fresh",baseline:"recorded",changed:n,added:a,removed:o}}function M(r){let s={};for(let[n,a]of [...r.entries()].sort((o,t)=>o[0].localeCompare(t[0])))s[n]=a.transitiveInputsHash;return s}export{u as a,w as b,y as c,M as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b,c as c$2}from'./chunk-I5PDN2P2.js';import {a as a$3}from'./chunk-4NN5QWOB.js';import {a as a$1}from'./chunk-YYCPRYP7.js';import {r as r$1}from'./chunk-SM55RK3C.js';import {a as a$2}from'./chunk-MFJ6ZP7S.js';import {g}from'./chunk-XC26FNRL.js';import {j as j$1,e as e$2}from'./chunk-LGJAAPNR.js';import {j,l as l$2}from'./chunk-ZDYGO3T7.js';import {c as c$1,d}from'./chunk-TMOKXYAQ.js';import {a}from'./chunk-M2BK3XTP.js';import {f as f$1,g as g$1,h as h$1}from'./chunk-GVS5OFUB.js';import {k,l as l$1,h,m as m$1,n,p as p$2,q}from'./chunk-VAWV3UKV.js';import {m,p as p$1,s}from'./chunk-AUCHMXUZ.js';import {l,o as o$1,p as p$3}from'./chunk-EEMRRCGR.js';import {c,e as e$1}from'./chunk-GRGUPSNP.js';import {b as b$1}from'./chunk-T63WRURN.js';import {e,f,o,p,n as n$1,m as m$2}from'./chunk-HH54C3XJ.js';import {d as d$1}from'./chunk-VRW6KXNK.js';import ge from'path';import pe from'fs-extra';function r(t,s){if(!t)throw new Error(`Workspace Intelligence run semantic violation: ${s}`)}function de(t,s){return t.length===s.length&&t.every((m,u)=>m===s[u])}function ue(t){b$1(e.intelligenceRun,t,"Workspace Intelligence run report"),r(t.chainSchemaVersion===a,`chainSchemaVersion must be ${a}`),r(t.artifactPath===e.intelligenceRun,`artifactPath must be ${e.intelligenceRun}`),r(t.preflight.length===n$1.length,`preflight must contain exactly ${n$1.length} entries`);for(let[d,n]of n$1.entries()){let a=t.preflight[d];r(a?.id===n,`preflight[${d}].id must be ${n}`),r(de(a.artifacts,o[n]),`${n} preflight artifacts must match the runtime registry`),n==="sync"?r(a.status==="passed"&&a.result==="synchronized"||a.status==="failed"&&a.result==="failed","sync preflight status and result are incoherent"):r(a.status==="passed"&&(a.result==="created"||a.result==="reused")||a.status==="failed"&&a.result==="failed"||a.status==="skipped"&&a.result==="skipped","baseline preflight status and result are incoherent");}let s=t.preflight[1];r(t.baselineCreated===(s?.result==="created"),"baselineCreated must match the baseline preflight result"),r(t.stages.length===m$2.length,`stages must contain exactly ${m$2.length} canonical steps`);let m=t.preflight[0],u=m?.status==="failed";for(let[d,n]of m$2.entries()){let a=t.stages[d];r(a?.id===n,`stages[${d}].id must be ${n}`),r(de(a.artifacts,p[n].produces),`${n} artifacts must match the runtime registry`),u&&r(a.status==="skipped",`${n} must be skipped after a hard failure`),a.status==="passed"?r(a.exitCode===0,`${n} passed stage must have exitCode 0`):a.status==="blocked"?r(a.exitCode!==0,`${n} blocked stage must have a non-zero exitCode`):a.status==="failed"?(r(a.exitCode===1,`${n} failed stage must have exitCode 1`),u=true):(r(a.exitCode===0,`${n} skipped stage must have exitCode 0`),r(a.durationMs===0,`${n} skipped stage must have durationMs 0`)),d===0&&((m?.status==="failed"||a.status==="failed")&&r(s?.status==="skipped","baseline must be skipped when sync or model fails"),s?.status==="skipped"&&r(m?.status==="failed"||a.status==="failed"||a.status==="skipped","baseline may be skipped only after an upstream failure"),s?.status!=="passed"&&(u=true));}let h=t.preflight.some(d=>d.status==="failed")||t.stages.some(d=>d.status==="failed"),y=t.stages.some(d=>d.status==="blocked"),l=h?"failed":y?"blocked":"passed",p$1=l==="failed"?1:l==="blocked"?2:0;r(t.status===l,`status must be ${l}`),r(t.exitCode===p$1,`exitCode must be ${p$1}`);}var we=e.intelligenceRun,Ee=f.intelligenceRun,L=we;function I(t){d$1({action:"intelligence",status:t.status==="started"?"started":t.status==="passed"?"succeeded":t.status==="failed"?"failed":"warn",message:t.message,metadata:{phase:`workspace.intelligence.${t.kind}.${t.id}`,intelligenceMilestoneId:t.id,intelligenceMilestoneKind:t.kind,intelligenceMilestoneStatus:t.status}});}async function Ue(t){let s=ge.resolve(t.workspacePath);return c(s,L,()=>ye({...t,workspacePath:s}),{timeoutMs:15*6e4,staleAfterMs:3e4})}async function ye(t){let s$1=t.workspacePath,m$2=[],u=[],h$2=false,y=async(e,o$1)=>{let c=[...o[e]];if(h$2){I({id:e,kind:"preflight",status:"skipped",message:`${e} prerequisite skipped after an upstream failure`}),m$2.push({id:e,status:"skipped",result:"skipped",durationMs:0,artifacts:c,message:"skipped because a required upstream operation failed"});return}let k=Date.now();I({id:e,kind:"preflight",status:"started",message:`${e} prerequisite started`});try{let i=await o$1();I({id:e,kind:"preflight",status:"passed",message:i.message}),m$2.push({id:e,status:"passed",result:i.result,durationMs:Date.now()-k,artifacts:c,message:i.message});}catch(i){h$2=true;let f=i instanceof Error?i.message:String(i);I({id:e,kind:"preflight",status:"failed",message:f}),m$2.push({id:e,status:"failed",result:"failed",durationMs:Date.now()-k,artifacts:c,message:f});}},l$3=async(e,o)=>{let c=[...p[e].produces];if(h$2){I({id:e,kind:"stage",status:"skipped",message:`${e} skipped after an upstream failure`}),u.push({id:e,status:"skipped",durationMs:0,artifacts:c,exitCode:0,message:"skipped because a required upstream stage failed"});return}let k=Date.now();I({id:e,kind:"stage",status:"started",message:`${e} started`});try{let i=await o(),f=i.exitCode??0,w=i.blocked||f!==0?"blocked":"passed";I({id:e,kind:"stage",status:w,message:i.message}),u.push({id:e,status:w,durationMs:Date.now()-k,artifacts:c,exitCode:f,message:i.message});}catch(i){h$2=true;let f=i instanceof Error?i.message:String(i);I({id:e,kind:"stage",status:"failed",message:f}),u.push({id:e,status:"failed",durationMs:Date.now()-k,artifacts:c,exitCode:1,message:f});}};await y("sync",async()=>{let e=await g(s$1,true),o=await l({workspacePath:s$1});return {result:"synchronized",message:`registry ${e.added.length} added/${e.skipped} existing; contract ${o.contract.projects.length} projects`}});let p$4,d$1=()=>{if(!p$4)throw new Error("canonical workspace model is unavailable");return p$4};await l$3("model",async()=>(p$4={...await p$1({workspacePath:s$1,includeEvidence:true}),build:m({mode:"full",engineStatus:"disabled"})},await s(p$4,s$1),{message:`${p$4.summary.projectCount} projects modeled`}));let n$1=ge.join(s$1,e.snapshot),a$4=false;await y("baseline",async()=>{if(!await pe.pathExists(n$1)){let c=await k({workspacePath:s$1,model:d$1()});return await l$1(c,s$1),a$4=true,{result:"created",message:"initial structural baseline created"}}let e=await pe.readJson(n$1),o=h(e);return o?(await l$1(o,s$1),{result:"reused",message:"legacy structural baseline migrated and reused"}):{result:"reused",message:"existing structural baseline reused"}}),await l$3("diff",async()=>{let e$1=await m$1({workspacePath:s$1,fromPath:e.snapshot,model:d$1()});return await n(e$1,s$1),{message:e$1.summary.changed?"workspace changes detected":"no workspace changes"}}),await l$3("impact",async()=>{let e$1=await p$2({workspacePath:s$1,fromPath:e.diff});return await q(e$1,s$1),{message:`${e$1.summary.risk} risk; ${e$1.summary.affectedProjects} affected`}}),await l$3("doctor-evidence",async()=>{let e=await r$1({workspace:s$1,json:true,quiet:true,profile:t.strict===true?"enterprise-strict":"local"});return {exitCode:e,blocked:e!==0,message:`doctor exit ${e}`}}),await l$3("contract-evidence",async()=>{let e=await o$1({workspacePath:s$1,strict:true});return await p$3({workspacePath:s$1,result:e}),{exitCode:e.status==="passed"?0:1,blocked:e.status!=="passed",message:`contract ${e.status}`}}),await l$3("analyze-evidence",async()=>{let e=await a$1({workspacePath:s$1,json:true,strict:t.strict===true});return {blocked:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention",exitCode:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention"?1:0,message:`analyze ${e.summary.verdict} (${e.summary.score}/100)`}}),await l$3("readiness-evidence",async()=>{let e=await a$2({startPath:s$1,writeReport:true,skipVerify:true});return {blocked:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn",exitCode:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn"?1:0,message:`pre-verify readiness ${e.overallStatus}`}}),await l$3("verify",async()=>{let e$1=await f$1({workspacePath:s$1,fromImpactPath:e.impact});await g$1(e$1,s$1);let o=h$1(e$1,{strict:t.strict===true});return await j$1(s$1,e$2(e$1,o.passed)),{blocked:!o.passed,exitCode:o.exitCode,message:`${e$1.summary.verdict}; gate ${o.passed?"passed":"blocked"}`}}),await l$3("context",async()=>{let e=await c$1({workspacePath:s$1,model:d$1(),agent:t.agent??"generic",includeEvidence:true});return await d(e,s$1),{message:`context grounded for ${e.agent}`}}),await l$3("agent-sync",async()=>{let e=await l$2({workspacePath:s$1,agent:t.agent??"generic",write:true,refreshContext:false,strict:t.strict===true,preset:"enterprise"}),o=false,c=await a$3(s$1);if(c.status==="miss"){if(c.reason!=="live-input-mismatch")throw new Error(`Agent grounding left canonical evidence invalid (${c.reason}).`);p$4={...await p$1({workspacePath:s$1,includeEvidence:true}),build:m({mode:"full",engineStatus:"disabled"})},await s(p$4,s$1);let f=await c$1({workspacePath:s$1,model:p$4,agent:t.agent??"generic",includeEvidence:true});await d(f,s$1);let w=await l$2({workspacePath:s$1,agent:t.agent??"generic",write:true,refreshContext:false,strict:t.strict===true,preset:"enterprise"});e={...w,writtenFiles:[...new Set([...e.writtenFiles,...w.writtenFiles])].sort(),strictViolations:[...new Set([...e.strictViolations??[],...w.strictViolations??[]])].sort()};let O=await a$3(s$1);if(O.status==="miss")throw new Error(`Agent grounding reconciliation did not produce fresh canonical evidence (${O.reason}).`);o=true;}let k=e.strictViolations??[],i=t.strict===true&&k.length>0;return {blocked:i,exitCode:i?2:0,message:i?`${e.writtenFiles.length} grounding files written; ${k.length} strict grounding violation(s): ${k.join("; ")}`:`${e.writtenFiles.length} grounding files written${o?"; canonical Model/Graph freshness sealed":""}`}}),await l$3("explain",async()=>{let e=await b({workspacePath:s$1,target:{kind:"release-blocked"}});await c$2(e,s$1);let o=t.strict===true?u.filter(c=>c.status==="blocked").map(c=>c.id):[];return {message:o.length>0&&e.blocking!==true?`Strict policy blocked advisory or incomplete evidence in ${o.join(", ")}. ${e.summary}`:e.summary}});let me=u.some(e=>e.status==="blocked"),G=h$2?"failed":me?"blocked":"passed",fe=h$2?1:G==="blocked"?2:0,b$1={schemaVersion:Ee,chainSchemaVersion:a,generatedAt:new Date().toISOString(),workspacePath:s$1,baselineCreated:a$4,preflight:m$2,status:G,exitCode:fe,stages:u,artifactPath:L};ue(b$1),await e$1(s$1,L,b$1);let ke=await j({workspacePath:s$1});return await e$1(s$1,e.agentIndex,ke),b$1}export{we as a,Ee as b,Ue as c};
|
|
1
|
+
import {r as r$1}from'./chunk-ENKGGWRX.js';import {a as a$1}from'./chunk-DGGTTRYE.js';import {b,c as c$2}from'./chunk-ZJCM37KX.js';import {a as a$2}from'./chunk-6FBNSTUS.js';import {g}from'./chunk-OLC7EYUA.js';import {j,l as l$2}from'./chunk-V3ABABV5.js';import {c as c$1,d}from'./chunk-7SFXADXO.js';import {a}from'./chunk-WQX3JYEP.js';import {f as f$1,g as g$1,h as h$1}from'./chunk-YEEAWZWI.js';import {k,l as l$1,h,m as m$1,n,p as p$2,q}from'./chunk-OFWSZYUX.js';import {a as a$3}from'./chunk-5NIZNXRS.js';import {j as j$1,e as e$2}from'./chunk-N4QQADXX.js';import {m,p as p$1,s}from'./chunk-WSRUPDZN.js';import {l,o as o$1,p as p$3}from'./chunk-SP5EHSWG.js';import {c,e as e$1}from'./chunk-CCDGHPEJ.js';import {b as b$1}from'./chunk-D65FCQIO.js';import {e,f,o,p,n as n$1,m as m$2}from'./chunk-NZ3WZYD5.js';import {d as d$1}from'./chunk-VRW6KXNK.js';import ge from'path';import pe from'fs-extra';function r(t,s){if(!t)throw new Error(`Workspace Intelligence run semantic violation: ${s}`)}function de(t,s){return t.length===s.length&&t.every((m,u)=>m===s[u])}function ue(t){b$1(e.intelligenceRun,t,"Workspace Intelligence run report"),r(t.chainSchemaVersion===a,`chainSchemaVersion must be ${a}`),r(t.artifactPath===e.intelligenceRun,`artifactPath must be ${e.intelligenceRun}`),r(t.preflight.length===n$1.length,`preflight must contain exactly ${n$1.length} entries`);for(let[d,n]of n$1.entries()){let a=t.preflight[d];r(a?.id===n,`preflight[${d}].id must be ${n}`),r(de(a.artifacts,o[n]),`${n} preflight artifacts must match the runtime registry`),n==="sync"?r(a.status==="passed"&&a.result==="synchronized"||a.status==="failed"&&a.result==="failed","sync preflight status and result are incoherent"):r(a.status==="passed"&&(a.result==="created"||a.result==="reused")||a.status==="failed"&&a.result==="failed"||a.status==="skipped"&&a.result==="skipped","baseline preflight status and result are incoherent");}let s=t.preflight[1];r(t.baselineCreated===(s?.result==="created"),"baselineCreated must match the baseline preflight result"),r(t.stages.length===m$2.length,`stages must contain exactly ${m$2.length} canonical steps`);let m=t.preflight[0],u=m?.status==="failed";for(let[d,n]of m$2.entries()){let a=t.stages[d];r(a?.id===n,`stages[${d}].id must be ${n}`),r(de(a.artifacts,p[n].produces),`${n} artifacts must match the runtime registry`),u&&r(a.status==="skipped",`${n} must be skipped after a hard failure`),a.status==="passed"?r(a.exitCode===0,`${n} passed stage must have exitCode 0`):a.status==="blocked"?r(a.exitCode!==0,`${n} blocked stage must have a non-zero exitCode`):a.status==="failed"?(r(a.exitCode===1,`${n} failed stage must have exitCode 1`),u=true):(r(a.exitCode===0,`${n} skipped stage must have exitCode 0`),r(a.durationMs===0,`${n} skipped stage must have durationMs 0`)),d===0&&((m?.status==="failed"||a.status==="failed")&&r(s?.status==="skipped","baseline must be skipped when sync or model fails"),s?.status==="skipped"&&r(m?.status==="failed"||a.status==="failed"||a.status==="skipped","baseline may be skipped only after an upstream failure"),s?.status!=="passed"&&(u=true));}let h=t.preflight.some(d=>d.status==="failed")||t.stages.some(d=>d.status==="failed"),y=t.stages.some(d=>d.status==="blocked"),l=h?"failed":y?"blocked":"passed",p$1=l==="failed"?1:l==="blocked"?2:0;r(t.status===l,`status must be ${l}`),r(t.exitCode===p$1,`exitCode must be ${p$1}`);}var we=e.intelligenceRun,Ee=f.intelligenceRun,L=we;function I(t){d$1({action:"intelligence",status:t.status==="started"?"started":t.status==="passed"?"succeeded":t.status==="failed"?"failed":"warn",message:t.message,metadata:{phase:`workspace.intelligence.${t.kind}.${t.id}`,intelligenceMilestoneId:t.id,intelligenceMilestoneKind:t.kind,intelligenceMilestoneStatus:t.status}});}async function Ue(t){let s=ge.resolve(t.workspacePath);return c(s,L,()=>ye({...t,workspacePath:s}),{timeoutMs:15*6e4,staleAfterMs:3e4})}async function ye(t){let s$1=t.workspacePath,m$2=[],u=[],h$2=false,y=async(e,o$1)=>{let c=[...o[e]];if(h$2){I({id:e,kind:"preflight",status:"skipped",message:`${e} prerequisite skipped after an upstream failure`}),m$2.push({id:e,status:"skipped",result:"skipped",durationMs:0,artifacts:c,message:"skipped because a required upstream operation failed"});return}let k=Date.now();I({id:e,kind:"preflight",status:"started",message:`${e} prerequisite started`});try{let i=await o$1();I({id:e,kind:"preflight",status:"passed",message:i.message}),m$2.push({id:e,status:"passed",result:i.result,durationMs:Date.now()-k,artifacts:c,message:i.message});}catch(i){h$2=true;let f=i instanceof Error?i.message:String(i);I({id:e,kind:"preflight",status:"failed",message:f}),m$2.push({id:e,status:"failed",result:"failed",durationMs:Date.now()-k,artifacts:c,message:f});}},l$3=async(e,o)=>{let c=[...p[e].produces];if(h$2){I({id:e,kind:"stage",status:"skipped",message:`${e} skipped after an upstream failure`}),u.push({id:e,status:"skipped",durationMs:0,artifacts:c,exitCode:0,message:"skipped because a required upstream stage failed"});return}let k=Date.now();I({id:e,kind:"stage",status:"started",message:`${e} started`});try{let i=await o(),f=i.exitCode??0,w=i.blocked||f!==0?"blocked":"passed";I({id:e,kind:"stage",status:w,message:i.message}),u.push({id:e,status:w,durationMs:Date.now()-k,artifacts:c,exitCode:f,message:i.message});}catch(i){h$2=true;let f=i instanceof Error?i.message:String(i);I({id:e,kind:"stage",status:"failed",message:f}),u.push({id:e,status:"failed",durationMs:Date.now()-k,artifacts:c,exitCode:1,message:f});}};await y("sync",async()=>{let e=await g(s$1,true),o=await l({workspacePath:s$1});return {result:"synchronized",message:`registry ${e.added.length} added/${e.skipped} existing; contract ${o.contract.projects.length} projects`}});let p$4,d$1=()=>{if(!p$4)throw new Error("canonical workspace model is unavailable");return p$4};await l$3("model",async()=>(p$4={...await p$1({workspacePath:s$1,includeEvidence:true}),build:m({mode:"full",engineStatus:"disabled"})},await s(p$4,s$1),{message:`${p$4.summary.projectCount} projects modeled`}));let n$1=ge.join(s$1,e.snapshot),a$4=false;await y("baseline",async()=>{if(!await pe.pathExists(n$1)){let c=await k({workspacePath:s$1,model:d$1()});return await l$1(c,s$1),a$4=true,{result:"created",message:"initial structural baseline created"}}let e=await pe.readJson(n$1),o=h(e);return o?(await l$1(o,s$1),{result:"reused",message:"legacy structural baseline migrated and reused"}):{result:"reused",message:"existing structural baseline reused"}}),await l$3("diff",async()=>{let e$1=await m$1({workspacePath:s$1,fromPath:e.snapshot,model:d$1()});return await n(e$1,s$1),{message:e$1.summary.changed?"workspace changes detected":"no workspace changes"}}),await l$3("impact",async()=>{let e$1=await p$2({workspacePath:s$1,fromPath:e.diff});return await q(e$1,s$1),{message:`${e$1.summary.risk} risk; ${e$1.summary.affectedProjects} affected`}}),await l$3("doctor-evidence",async()=>{let e=await r$1({workspace:s$1,json:true,quiet:true,profile:t.strict===true?"enterprise-strict":"local"});return {exitCode:e,blocked:e!==0,message:`doctor exit ${e}`}}),await l$3("contract-evidence",async()=>{let e=await o$1({workspacePath:s$1,strict:true});return await p$3({workspacePath:s$1,result:e}),{exitCode:e.status==="passed"?0:1,blocked:e.status!=="passed",message:`contract ${e.status}`}}),await l$3("analyze-evidence",async()=>{let e=await a$1({workspacePath:s$1,json:true,strict:t.strict===true});return {blocked:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention",exitCode:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention"?1:0,message:`analyze ${e.summary.verdict} (${e.summary.score}/100)`}}),await l$3("readiness-evidence",async()=>{let e=await a$2({startPath:s$1,writeReport:true,skipVerify:true});return {blocked:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn",exitCode:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn"?1:0,message:`pre-verify readiness ${e.overallStatus}`}}),await l$3("verify",async()=>{let e$1=await f$1({workspacePath:s$1,fromImpactPath:e.impact});await g$1(e$1,s$1);let o=h$1(e$1,{strict:t.strict===true});return await j$1(s$1,e$2(e$1,o.passed)),{blocked:!o.passed,exitCode:o.exitCode,message:`${e$1.summary.verdict}; gate ${o.passed?"passed":"blocked"}`}}),await l$3("context",async()=>{let e=await c$1({workspacePath:s$1,model:d$1(),agent:t.agent??"generic",includeEvidence:true});return await d(e,s$1),{message:`context grounded for ${e.agent}`}}),await l$3("agent-sync",async()=>{let e=await l$2({workspacePath:s$1,agent:t.agent??"generic",targets:["all"],write:true,refreshContext:false,strict:t.strict===true,preset:"enterprise"}),o=false,c=await a$3(s$1);if(c.status==="miss"){if(c.reason!=="live-input-mismatch")throw new Error(`Agent grounding left canonical evidence invalid (${c.reason}).`);p$4={...await p$1({workspacePath:s$1,includeEvidence:true}),build:m({mode:"full",engineStatus:"disabled"})},await s(p$4,s$1);let f=await c$1({workspacePath:s$1,model:p$4,agent:t.agent??"generic",includeEvidence:true});await d(f,s$1);let w=await l$2({workspacePath:s$1,agent:t.agent??"generic",targets:["all"],write:true,refreshContext:false,strict:t.strict===true,preset:"enterprise"});e={...w,writtenFiles:[...new Set([...e.writtenFiles,...w.writtenFiles])].sort(),strictViolations:[...new Set([...e.strictViolations??[],...w.strictViolations??[]])].sort()};let O=await a$3(s$1);if(O.status==="miss")throw new Error(`Agent grounding reconciliation did not produce fresh canonical evidence (${O.reason}).`);o=true;}let k=e.strictViolations??[],i=t.strict===true&&k.length>0;return {blocked:i,exitCode:i?2:0,message:i?`${e.writtenFiles.length} grounding files written; ${k.length} strict grounding violation(s): ${k.join("; ")}`:`${e.writtenFiles.length} grounding files written; portable entry surfaces prepared for all supported hosts${o?"; canonical Model/Graph freshness sealed":""}`}}),await l$3("explain",async()=>{let e=await b({workspacePath:s$1,target:{kind:"release-blocked"}});await c$2(e,s$1);let o=t.strict===true?u.filter(c=>c.status==="blocked").map(c=>c.id):[];return {message:o.length>0&&e.blocking!==true?`Strict policy blocked advisory or incomplete evidence in ${o.join(", ")}. ${e.summary}`:e.summary}});let me=u.some(e=>e.status==="blocked"),G=h$2?"failed":me?"blocked":"passed",fe=h$2?1:G==="blocked"?2:0,b$1={schemaVersion:Ee,chainSchemaVersion:a,generatedAt:new Date().toISOString(),workspacePath:s$1,baselineCreated:a$4,preflight:m$2,status:G,exitCode:fe,stages:u,artifactPath:L};ue(b$1),await e$1(s$1,L,b$1);let ke=await j({workspacePath:s$1});return await e$1(s$1,e.agentIndex,ke),b$1}export{we as a,Ee as b,Ue as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-UVBPEX3E.js';import {a as a$4}from'./chunk-QJCCZLOF.js';import {a as a$2,e as e$1}from'./chunk-W6FHVXNL.js';import {d,a,e as e$2}from'./chunk-CCDGHPEJ.js';import {e,h}from'./chunk-NZ3WZYD5.js';import a$3 from'chalk';import re from'fs';import b from'path';import {execa}from'execa';var V="autopilot-release-last-run.json",G="autopilot-release.json";function $(r){try{return JSON.parse(r)}catch{return null}}function Se(r){let e=b.resolve(r),n=a$4(e);if(!n)throw new Error("No Workspai workspace found in current directory or parents");return n}async function S(r,e){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[n,...r],{cwd:e,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function oe(r){let e=r.toLowerCase();return e==="pass"?"pass":e==="warn"?"warn":e==="fail"?"fail":"warn"}function ae(r){return r.summary.failed>0||r.gates.results.some(e=>e.status==="fail")?"fail":r.gates.results.some(e=>e.status==="warn")?"warn":"pass"}function be(r){let e=r.filter(o=>o.status!=="skipped");if(e.length===0)return 100;let n=e.reduce((o,t)=>t.status==="pass"?o+1:t.status==="warn"?o+.6:o,0);return Math.round(n/e.length*100)}function Ae(r){return r.executionError?["Re-run: npx workspai autopilot release --mode audit --json","Inspect .workspai/reports/autopilot-release-last-run.json for execution failure details"]:r.blockers.length>0?["Run: npx workspai doctor workspace --plan","Run: npx workspai readiness --json --strict","Run: npx workspai workspace run test --affected --strict"]:r.hasWarnings&&r.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx workspai autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function xe(r,e){await re.promises.mkdir(b.dirname(r),{recursive:true}),await re.promises.writeFile(r,`${JSON.stringify(e,null,2)}
|
|
2
2
|
`,"utf-8");}async function ze(r){let e$3=Se(r.workspacePath),n=r.mode,o=[],t=[],L,H,N,q,Q,X=0,f=false,I=0,_=0,W=-1,T=-1,c="skipped",d$1="skipped",ne=n==="enforce"?["doctor","workspace","--json","--strict"]:["doctor","workspace","--json","--ci"];if(r.skipPipelineStages)o.push({name:"doctor-workspace",status:"skipped",durationMs:0,summary:"doctor stage skipped (pipeline already executed)"},{name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped (pipeline already executed)"},{name:"readiness",status:"skipped",durationMs:0,summary:"readiness stage skipped (pipeline already executed)"});else {let s=Date.now(),l=await S([...ne],e$3),m=Date.now()-s;if(c="pass",l.crashed)c="fail",f=true,t.push(`doctor workspace execution error: ${l.stderr||"unknown error"}`);else if(l.exitCode===1)c="fail",t.push("doctor workspace command failed or reported errors");else if(l.exitCode===2)c="warn",t.push("doctor workspace reported warnings");else if(l.exitCode!==0)c="fail",t.push("doctor workspace command failed");else {let p=$(l.stdout),E=p&&p.healthScore&&typeof p.healthScore=="object"?p.healthScore:{},k=Number(E.errors??0),C=Number(E.warnings??0);Number.isFinite(k)&&k>0?(c="fail",t.push(`doctor workspace reports ${k} error(s)`)):Number.isFinite(C)&&C>0&&(c="warn");}W=o.push({name:"doctor-workspace",status:c,durationMs:m,summary:c==="pass"?"doctor workspace passed":c==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors"})-1,n==="enforce"&&c==="warn"&&t.push("doctor workspace reported warnings under enforce mode");let g=Date.now(),w=await S(["analyze","--json"],e$3),P=Date.now()-g;H=await d(e$3,e.analyze)??a(e$3,e.analyze);let i="pass";if(w.crashed)i="fail",f=true,t.push(`analyze execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)i=w.exitCode===2?"warn":"fail",t.push(w.exitCode===2?"analyze reported needs-attention verdict":"analyze command failed or reported blocked verdict");else {let p=$(w.stdout),E=p&&p.summary&&typeof p.summary=="object"?p.summary:{},k=String(E.verdict??"ready");k==="blocked"?(i="fail",t.push("analyze reported blocked verdict")):k==="needs-attention"&&(i="warn");}o.push({name:"analyze",status:i,durationMs:P,summary:i==="pass"?"analyze passed":i==="warn"?"analyze reported needs-attention":"analyze reported blocked verdict"}),n==="enforce"&&i==="warn"&&t.push("analyze reported warnings under enforce mode");let v=Date.now(),h=await S(["readiness","--json"],e$3),y=Date.now()-v;if(d$1="fail",h.crashed)d$1="fail",f=true,t.push(`readiness execution error: ${h.stderr||"unknown error"}`);else if(h.exitCode!==0)d$1="fail",t.push("readiness command failed");else {let p=$(h.stdout),E=String(p?.overallStatus??"fail");if(d$1=oe(E),typeof p?.evidencePath=="string"&&p.evidencePath.trim().length>0&&(L=p.evidencePath),d$1==="fail"){let k=Array.isArray(p?.blockingReasons)?p?.blockingReasons.filter(C=>typeof C=="string"):[];k.length>0?t.push(...k.map(C=>`readiness: ${C}`)):t.push("readiness overall status is fail");}}T=o.push({name:"readiness",status:d$1,durationMs:y,summary:`readiness overall status is ${d$1}`})-1,n==="enforce"&&d$1==="warn"&&t.push("readiness reported warnings under enforce mode");}let ie=Date.now(),D=await S(["doctor","workspace","--plan","--json"],e$3),le=Date.now()-ie,R="warn";if(D.crashed)R="fail",f=true,t.push(`doctor remediation plan execution error: ${D.stderr||"unknown error"}`);else if(D.exitCode!==0)R="fail",t.push("doctor remediation plan command failed");else {let s=$(D.stdout),l=s&&s.remediationPlan&&typeof s.remediationPlan=="object"?s.remediationPlan:null,m=Number(l?.totalSteps??0),g=Number(l?.executableSteps??0);Number.isFinite(m)&&m>0&&(I=m),Number.isFinite(g)&&g>0&&(_=g),Number.isFinite(m)&&m===0?R="pass":R="warn";}if(o.push({name:"remediation-plan",status:R,durationMs:le,summary:R==="pass"?"no remediation steps required":"remediation steps available"}),n==="enforce"&&R==="warn"&&t.push("remediation plan has pending steps under enforce mode"),n==="safe-fix"){let s=Date.now(),l=await S(["doctor","workspace","--apply"],e$3),m=Date.now()-s,g=l.crashed||l.exitCode!==0?"fail":"pass";if(l.crashed)f=true,t.push(`doctor remediation apply execution error: ${l.stderr||"unknown error"}`);else if(g==="fail")t.push("doctor remediation apply failed");else {X=_>0?_:I>0?I:1;let w=await S(["doctor","workspace","--json"],e$3);if(w.crashed)c="fail",f=true,t.push(`post-apply doctor execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)c="fail",t.push("post-apply doctor workspace command failed");else {let i=$(w.stdout),v=i&&i.healthScore&&typeof i.healthScore=="object"?i.healthScore:{},h=Number(v.errors??0),y=Number(v.warnings??0);Number.isFinite(h)&&h>0?(c="fail",t.push(`post-apply doctor reports ${h} error(s)`)):Number.isFinite(y)&&y>0?c="warn":c="pass";}W>=0&&(o[W].status=c,o[W].summary=`doctor workspace post-apply status is ${c}`);let P=await S(["readiness","--json"],e$3);if(P.crashed)d$1="fail",f=true,t.push(`post-apply readiness execution error: ${P.stderr||"unknown error"}`);else if(P.exitCode!==0)d$1="fail",t.push("post-apply readiness command failed");else {let i=$(P.stdout),v=String(i?.overallStatus??"fail");if(d$1=oe(v),typeof i?.evidencePath=="string"&&i.evidencePath.trim().length>0&&(L=i.evidencePath),d$1==="fail"){let h=Array.isArray(i?.blockingReasons)?i?.blockingReasons.filter(y=>typeof y=="string"):[];h.length>0?t.push(...h.map(y=>`post-apply readiness: ${y}`)):t.push("post-apply readiness overall status is fail");}}T>=0&&(o[T].status=d$1,o[T].summary=`readiness post-apply overall status is ${d$1}`);}o.push({name:"remediation-apply",status:g,durationMs:m,summary:g==="pass"?"safe remediation apply completed":"safe remediation apply failed"});}else o.push({name:"remediation-apply",status:"skipped",durationMs:0,summary:"remediation apply is skipped for this mode"});let ce=Date.now(),A="pass",x="workspace test/build completed for selected projects";try{let s=await a$1({workspacePath:e$3,stage:"test",affected:true,since:r.since,parallel:r.parallel,maxWorkers:r.maxWorkers,strict:true,json:true,enforceGates:false});N=a(e$3,b.join(".workspai","reports",a$2)),await e$1(e$3,s),q=N;let l=ae(s);if(l==="fail")A="fail",x="workspace test stage failed for selected projects",t.push("workspace run test failed for selected projects");else {l==="warn"&&(A="warn",x="workspace test stage completed with warnings",n==="enforce"&&t.push("workspace run test reported warnings under enforce mode"));let m=await a$1({workspacePath:e$3,stage:"build",affected:true,since:r.since,parallel:r.parallel,maxWorkers:r.maxWorkers,strict:true,json:true,enforceGates:false});await e$1(e$3,m),Q=N;let g=ae(m);g==="fail"?(A="fail",x="workspace build stage failed for selected projects",t.push("workspace run build failed for selected projects")):g==="warn"&&(A="warn",x="workspace test/build completed with warnings",n==="enforce"&&t.push("workspace run test/build reported warnings under enforce mode"));}}catch(s){A="fail",x="workspace test/build orchestration failed",f=true,t.push(`workspace run orchestration error: ${s instanceof Error?s.message:String(s)}`);}let pe=Date.now()-ce;o.push({name:"workspace-run-test-build",status:A,durationMs:pe,summary:x});let M=o.filter(s=>s.status==="warn").length,ue=o.filter(s=>s.status==="fail").length,F=n==="enforce"?o.some(s=>s.status==="warn"||s.status==="fail"):ue>0,j=[...new Set(t)],O=f||F?Math.max(1,j.length):0,de=O>0?j:[],fe=O===0?j:[],me=be(o),ge=f||F?"blocked":M>0?"partial":"approved",we=f?3:F?1:M>0?2:0,he=Ae({mode:n,executionError:f,blockers:j,hasWarnings:M>0}),Y=a(e$3,".workspai/reports"),ke=b.join(Y,V),ye=b.join(Y,G),u={schemaVersion:h.autopilotReleaseLastRun.schemaVersion,generatedAt:new Date().toISOString(),workspacePath:e$3,mode:n,summary:{releaseScore:me,verdict:ge,blockers:O,warnings:M,safeFixesApplied:X,manualActions:j.length,exitCode:we},stages:o,blockingReasons:de,warningReasons:fe,nextActions:he,artifacts:{reportPath:ke,aliasEvidencePath:ye,analyzeEvidencePath:H,readinessEvidencePath:L,workspaceRunEvidencePath:N,workspaceRunTestPath:q,workspaceRunBuildPath:Q},enterpriseControls:{jsonReady:true,evidencePath:`.workspai/reports/${V}`,aliasEvidencePath:`.workspai/reports/${G}`}};if(await e$2(e$3,`.workspai/reports/${V}`,u),await e$2(e$3,`.workspai/reports/${G}`,u),r.output&&await xe(b.resolve(r.output),u),!r.json){console.log(a$3.bold.cyan(`
|
|
3
3
|
\u{1F680} Workspai Autopilot Release
|
|
4
4
|
`)),console.log(a$3.bold(`Workspace: ${a$3.cyan(b.basename(e$3))}`)),console.log(a$3.gray(`Path: ${e$3}`)),console.log(a$3.white(`Mode: ${n}`)),console.log(a$3.white(`Verdict: ${u.summary.verdict==="approved"?a$3.green("approved"):u.summary.verdict==="partial"?a$3.yellow("partial"):a$3.red("blocked")}`)),console.log(a$3.white(`Release score: ${u.summary.releaseScore}`));for(let s of u.stages){let l=s.status==="pass"?a$3.green("PASS"):s.status==="warn"?a$3.yellow("WARN"):s.status==="skipped"?a$3.gray("SKIP"):a$3.red("FAIL");console.log(` - ${s.name}: ${l} ${s.summary} (${s.durationMs}ms)`);}if(u.blockingReasons.length>0){console.log(a$3.bold.red(`
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {g,b,i as i$1,d as d$2,e as e$1,f}from'./chunk-TCURN5VD.js';import {c}from'./chunk-GPOZILMY.js';import {c as c$1}from'./chunk-X7FYEKLI.js';import {d as d$3,b as b$1,a as a$1}from'./chunk-3RBUSW7H.js';import {d as d$1}from'./chunk-EWZZUQBR.js';import {a}from'./chunk-AFIFZTOY.js';import {h,e,i}from'./chunk-NZ3WZYD5.js';import {t,h as h$1,g as g$1}from'./chunk-MOSXTVPU.js';import le from'crypto';import H from'fs';import k from'fs/promises';import d from'path';import {execa}from'execa';import he from'fs-extra';var ke=h.projectContextAgent.schemaVersion,Ze=["managed","local","off"],de="<!-- WORKSPAI:PROJECT-GROUNDING:START -->",pe="<!-- WORKSPAI:PROJECT-GROUNDING:END -->";function oe(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}async function E(e){try{return JSON.parse(await k.readFile(e,"utf8"))}catch(t){return null}}function G(e){return e.replace(/\\/g,"/").replace(/^\.\/+/,"")}function x(e,t,n){let o=e.replace(/\\/g,"/"),i=/^[A-Za-z]:\//.test(o);if(!d.isAbsolute(e)&&!i)return G(o);if(i&&process.platform!=="win32")return null;let c=d.resolve(e),s=d.relative(n,c);if(s&&!s.startsWith("..")&&!d.isAbsolute(s))return G(s);let l=d.relative(t,c);return l&&!l.startsWith("..")&&!d.isAbsolute(l)?`workspace:${G(l)}`:null}function P(e,t,n){return [[n,"project:"],[n.replace(/\\/g,"/"),"project:"],[t,"workspace:"],[t.replace(/\\/g,"/"),"workspace:"]].reduce((i,[c,s])=>c.length>0?i.split(c).join(s):i,e)}function ge(e,t){return oe(e?.adoption)?.mode==="linked"?"adopted":oe(e?.import)?"imported":t}function we(e){if(!e.model)return null;let t=G(e.relativePath);return e.model.projects.find(n=>n.name===e.projectName||G(n.path)===t)??null}function ne(e,t){e[t]=(e[t]??0)+1;}var ye=["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"];function je(e,t=160){let n={language:32,api:32,service:32,endpoint:32,schema:32,protocol:32,"runtime-unit":32,"lifecycle-stage":32,file:8,module:8,symbol:8},o=[];for(let i of ye){let c=e.filter(s=>s.kind===i).sort((s,l)=>s.label.localeCompare(l.label)||s.id.localeCompare(l.id)).slice(0,n[i]??32);for(let s of c){if(o.length>=t)return o;o.push(s);}}return o}function Pe(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:[]},relatedProjects:[],proofArtifacts:[],entities:[],relations:[],proofs:[],topology:{status:"unavailable",dependencies:[],dependents:[]},diagnostics:[]};let n=e.entities.find(r=>r.kind==="project"&&(r.id===t||r.label===t||r.projectId===t)),o=new Set(e.entities.filter(r=>r.projectId===t||r.id===n?.id||r.kind==="project"&&r.label===t).map(r=>r.id));n&&o.add(n.id);let i=e.relations.filter(r=>o.has(r.from)||o.has(r.to)),c=new Set(o);for(let r of i)c.add(r.from),c.add(r.to);let s=e.entities.filter(r=>c.has(r.id)),l=new Set,g={},u={},f={},w=new Set(s.filter(r=>r.kind==="language").map(r=>r.attributes.language).filter(r=>typeof r=="string"));for(let r of s){ne(g,r.kind);let a=typeof r.attributes.language=="string"?r.attributes.language:void 0;if(a&&r.kind==="language")f[a]={fileCount:typeof r.attributes.fileCount=="number"?r.attributes.fileCount:0,symbolCount:f[a]?.symbolCount??0,generatedFileCount:typeof r.attributes.generatedFileCount=="number"?r.attributes.generatedFileCount:0};else if(a&&(r.kind==="file"||r.kind==="symbol")){let h=f[a]??{fileCount:0,symbolCount:0,generatedFileCount:0};r.kind==="file"&&!w.has(a)?(h.fileCount+=1,r.attributes.generated===true&&(h.generatedFileCount+=1)):r.kind==="symbol"&&(h.symbolCount+=1),f[a]=h;}for(let h of r.proofIds)l.add(h);}for(let r of i){ne(u,r.kind);for(let a of r.proofIds)l.add(a);}let y=e.proofs.filter(r=>l.has(r.id)),b=[...new Set(e.entities.filter(r=>c.has(r.id)&&r.projectId&&r.projectId!==t).map(r=>r.projectId))].sort(),m=e.diagnostics.filter(r=>r.entityIds?.some(a=>c.has(a))||r.relationIds?.some(a=>i.some(h=>h.id===a))).map(r=>({code:r.code,severity:r.severity,message:r.message,...r.recommendation?{recommendation:r.recommendation}:{}})),p=(r,a)=>({project:a,kind:r.kind,source:r.source,confidence:r.confidence,evidence:[...new Set(r.evidence.map(h=>h.file.replace(/\\/g,"/")))].sort()}),v=e.projectTopology.edges.filter(r=>r.from===t).map(r=>p(r,r.to)).sort((r,a)=>`${r.project}:${r.kind}`.localeCompare(`${a.project}:${a.kind}`)),C=e.projectTopology.edges.filter(r=>r.to===t).map(r=>p(r,r.from)).sort((r,a)=>`${r.project}:${r.kind}`.localeCompare(`${a.project}:${a.kind}`)),R=je(s),N=s.filter(r=>r.kind==="runtime-unit"),j=new Set(R.map(r=>r.id)),_=[...i].sort((r,a)=>{let h=Number(j.has(r.from)||j.has(r.to));return Number(j.has(a.from)||j.has(a.to))-h||r.id.localeCompare(a.id)}).slice(0,128),$=new Set([...R.flatMap(r=>r.proofIds),..._.flatMap(r=>r.proofIds)]);return {entityCount:s.length,relationCount:i.length,proofCount:y.length,entitiesByKind:g,relationsByKind:u,languages:Object.fromEntries(Object.entries(f).sort(([r],[a])=>r.localeCompare(a))),semantic:{protocolConceptCount:g.protocol??0,protocolImplementationBindings:u["implements-protocol"]??0,equivalenceBindings:u["equivalent-to"]??0,generationBindings:(u["generated-from"]??0)+(u["generated-by"]??0),runtimeUnitCount:N.length,lifecycleStageCount:g["lifecycle-stage"]??0,runtimeCoverage:[...new Set(N.map(r=>r.attributes.runtime).filter(r=>typeof r=="string"))].sort()},relatedProjects:b,proofArtifacts:[...new Set(y.map(r=>r.artifact))].sort(),entities:R,relations:_,proofs:y.filter(r=>$.has(r.id)).sort((r,a)=>r.id.localeCompare(a.id)).slice(0,128),topology:{status:v.length>0||C.length>0?"proven":e.projectTopology.nodes.some(r=>r.id===t)?"unproven":"unavailable",dependencies:v,dependents:C},diagnostics:m}}function ue(e,t,n){return Array.isArray(e)?e.map(o=>typeof o=="string"?P(o,t,n):o):typeof e=="string"?P(e,t,n):e}function be(e,t,n){return {id:e.id,kind:e.kind,label:P(e.label,t,n),attributes:Object.fromEntries(Object.entries(e.attributes).map(([o,i])=>[o,ue(i,t,n)])),proofIds:[...e.proofIds].sort()}}function ve(e,t,n){let o=(...c)=>e.filter(s=>c.includes(s.kind)).map(s=>be(s,t,n)).slice(0,32),i=[];for(let c of e){for(let[s,l]of Object.entries(c.attributes))if(/(?:^|[-_.])ports?(?:$|[-_.])/i.test(s)&&(i.push({entityId:c.id,label:P(c.label,t,n),attribute:s,value:ue(l,t,n)}),i.length>=32))break;if(i.length>=32)break}return {services:o("service"),packages:o("package"),protocols:o("protocol"),runtimeUnits:o("runtime-unit"),lifecycleStages:o("lifecycle-stage"),apis:o("api"),endpoints:o("endpoint"),dataStores:o("database","queue"),deployments:o("container","deployment","environment"),pipelines:o("pipeline"),tests:o("test-suite"),owners:o("owner"),decisions:o("decision"),ports:i}}function Ae(e,t,n){let o=x(e.artifact,t,n);return o?{id:e.id,provider:e.provider,artifact:o,...e.pointer?{pointer:P(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 Ee(e,t,n){let o=[],i=await E(d.join(e,".workspai","reports","INDEX.json"));if(Array.isArray(i?.blockers))for(let s of i.blockers)typeof s=="string"&&(s.startsWith(`${n}:`)||s.includes(`project:${n}`)||s.includes(`project ${n}`))&&o.push({source:"workspace-report-index",severity:"error",message:P(s,e,t)});let c=await E(d.join(e,".workspai","reports","doctor-project-last-run.json"));if(c?.projectName===n)for(let s of c$1({project:c.project}))o.push({source:"doctor-project",severity:s.status==="blocking"?"error":"warning",message:P(s.message,e,t),...s.id?{code:s.id}:{}});return [...new Map(o.map(s=>[`${s.source}:${s.code??""}:${s.message}`,s])).values()].slice(0,32)}function U(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=>U(n,t)):e&&typeof e=="object"?Object.values(e).some(n=>U(n,t)):false}function Ce(e){return le.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function Re(e$1){let t$1=d.resolve(e$1.workspacePath),n=d.resolve(e$1.projectPath),o=t(n,"project.json").find(a=>H.existsSync(a)),i$1=o?await E(o):null,c=await E(d.join(t$1,".workspai","workspace.contract.json")),s=d.resolve(n),l=c?.projects?.find(a=>a.externalPath?d.resolve(a.externalPath)===s:!a.relativePath||a.relativePath.startsWith("external/")?false:d.resolve(t$1,a.relativePath)===s)??c?.projects?.find(a=>a.slug===e$1.projectName||a.slug===d.basename(n)),g=e$1.projectName??(typeof i$1?.name=="string"?i$1.name:void 0)??l?.slug??d.basename(n),u=l?.relativePath??(()=>{let a=G(d.relative(t$1,n));return !a||a.startsWith("..")?`external/${g}`:a})(),f=await E(d.join(t$1,e.model)),w=await E(d.join(t$1,e.knowledgeGraph)),y=f?d$1(f):void 0,b$1=!!(y&&w?.source.hash===y),m=we({model:f,projectName:g,relativePath:u}),p=Pe(b$1?w:null,g),v=await Ee(t$1,n,g),C=p.proofs.map(a=>a.freshness),R=w?!b$1||C.includes("stale")?"stale":C.includes("unknown")?"unknown":"fresh":"missing",N=f?f.factFreshness?.status??"unknown":"missing",j=[...f?[]:[{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."}],...f&&!m?[{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."}]:[],...w?[]:[{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."}],...w&&!b$1?[{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."}]:[]],_=ge(i$1,e$1.relationship??l?.relationship??"managed"),$={schemaVersion:ke,generatedAt:(e$1.now??new Date).toISOString(),workspace:{name:c?.workspace?.name??f?.workspace.name??d.basename(t$1),...c?.workspace?.profile||f?.workspace.profile?{profile:c?.workspace?.profile??f?.workspace.profile}:{},relationship:_,contract:`workspace:${i.workspaceContract}`,model:`workspace:${e.model}`,knowledgeGraph:`workspace:${e.knowledgeGraph}`,access:{localBinding:i.projectWorkspaceLink,canonicalEvidenceAvailableAtGeneration:true,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"}},project:{name:g,relativePath:u,...m?.kind?{kind:m.kind}:{},...m?.runtime||l?.runtime?{runtime:m?.runtime??l?.runtime}:{},...m?.runtimeCandidates?.length?{runtimeCandidates:[...m.runtimeCandidates].sort()}:{},...m?.framework||l?.framework?{framework:m?.framework??l?.framework}:{},...m?.kit||l?.kit?{kit:m?.kit??l?.kit}:{},...m?.supportTier?{supportTier:m.supportTier}:{},commands:{supported:[...m?.commands.supported??[]].sort(),unsupported:[...m?.commands.unsupported??[]].sort(),fleetStages:[...m?.commands.fleetStages??[]].sort()},importantFiles:[...new Set((m?.importantFiles??[]).map(a=>x(a,t$1,n)).filter(a=>a!==null))].sort()},intelligence:{...f?.generatedAt?{modelGeneratedAt:f.generatedAt}:{},...w?.generatedAt?{graphGeneratedAt:w.generatedAt}:{},...w?.source.hash?{graphModelHash:w.source.hash}:{},entityCount:p.entityCount,relationCount:p.relationCount,proofCount:p.proofCount,entitiesByKind:p.entitiesByKind,relationsByKind:p.relationsByKind,languages:p.languages,semantic:p.semantic,relatedProjects:p.relatedProjects,freshness:{model:N,graph:R,graphMatchesModel:b$1},topology:{...p.topology,dependencies:p.topology.dependencies.map(a=>({...a,evidence:a.evidence.map(h=>x(h,t$1,n)).filter(h=>h!==null)})),dependents:p.topology.dependents.map(a=>({...a,evidence:a.evidence.map(h=>x(h,t$1,n)).filter(h=>h!==null)}))},surfaces:ve(p.entities,t$1,n),diagnostics:[...j,...p.diagnostics].map(a=>({...a,message:P(a.message,t$1,n),...a.recommendation?{recommendation:P(a.recommendation,t$1,n)}:{}}))},evidence:{readOrder:[b,".workspai/PROJECT-GROUNDING.md",i.projectContextAgent,"AGENTS.md","workspace:.workspai/goals/index.json",`workspace:${i.goalPackLastRun}`,"workspace:.workspai/reports/INDEX.json","workspace:.workspai/reports/workspace-context-agent.json",`workspace:${e.model}`,`workspace:${e.knowledgeGraph}`],projectProofArtifacts:[...new Set(p.proofArtifacts.map(a=>x(a,t$1,n)).filter(a=>a!==null))],relations:p.relations.map(a=>({id:a.id,from:a.from,to:a.to,kind:a.kind,derivation:a.derivation,trust:a.trust,confidence:a.confidence,proofIds:[...a.proofIds].sort()})),proofs:p.proofs.map(a=>Ae(a,t$1,n)).filter(a=>a!==null)},blockers:v,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",i.projectContextAgent,"workspace:.workspai/reports/INDEX.json","workspace:.workspai/reports/workspace-context-agent.json",`command:npx workspai workspace graph search ${JSON.stringify(g)} --scope ${JSON.stringify(`project:${g}`)} --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(g)} --scope ${JSON.stringify(`project:${g}`)} --limit 12 --json`,doctor:"workspai doctor project --json",workspaceStatus:"workspai project workspace status --json"}};if(U($,[t$1,n]))throw new Error("Project context lens rejected a non-portable absolute path.");let r={...$,integrity:{algorithm:"sha256",...y?{modelHash:y}:{},payloadHash:Ce($),portable:true,absolutePathsEmitted:false}};return a(r,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent"),r}function Te(e){let t=e.intelligence.relatedProjects.length>0?e.intelligence.relatedProjects.map(i=>`\`${i}\``).join(", "):"No proven cross-project relation is currently available.",n=e.intelligence.diagnostics.length>0?e.intelligence.diagnostics.slice(0,8).map(i=>`- **${i.severity} \xB7 ${i.code}:** ${i.message}`).join(`
|
|
2
|
+
`):"- No project-scoped graph diagnostic is currently recorded.",o=e.blockers.length>0?e.blockers.slice(0,12).map(i=>`- **${i.severity}${i.code?` \xB7 ${i.code}`:""}:** ${i.message}`).join(`
|
|
3
|
+
`):"- No current project-scoped blocker is recorded.";return `# Workspai project grounding
|
|
4
|
+
|
|
5
|
+
This project is adopted into the **${e.workspace.name}** Workspai workspace.
|
|
6
|
+
That value is the canonical workspace identity, not its filesystem path. Workspai
|
|
7
|
+
commands launched here resolve the machine-local workspace automatically.
|
|
8
|
+
|
|
9
|
+
## Mandatory first contact
|
|
10
|
+
|
|
11
|
+
Do not begin broad repository discovery, architecture claims, planning, or mutation
|
|
12
|
+
until this sequence is complete:
|
|
13
|
+
|
|
14
|
+
1. Read \`.workspai/agent-entry.v1.json\` to discover the portable protocol.
|
|
15
|
+
2. Run \`workspai agent bootstrap --for-agent generic --strict --json\`.
|
|
16
|
+
3. Follow the receipt's \`requiredReadOrder\` exactly.
|
|
17
|
+
4. Read \`.workspai/reports/project-context-agent.json\`.
|
|
18
|
+
5. If the receipt reports an active Goal, read its immutable Goal Pack and agent
|
|
19
|
+
handoff before choosing or expanding work.
|
|
20
|
+
6. Query the bounded Workspace Graph with the user's actual task before opening broad
|
|
21
|
+
source, then inspect only returned proof paths and targeted live files.
|
|
22
|
+
|
|
23
|
+
Receipt policy:
|
|
24
|
+
|
|
25
|
+
- \`ready\`: continue with bounded evidence and targeted source inspection.
|
|
26
|
+
- \`degraded\`: disclose the limitation and do not claim complete architecture or verification.
|
|
27
|
+
- \`blocked\`: stop governed claims, execute \`nextActions\`, and rerun bootstrap.
|
|
28
|
+
|
|
29
|
+
## Workspace location and portable paths
|
|
30
|
+
|
|
31
|
+
- \`${e.workspace.name}\` is an identity, not a directory name to guess.
|
|
32
|
+
- Project-local paths begin with \`.workspai/\`.
|
|
33
|
+
- Canonical workspace paths begin with \`workspace:\`.
|
|
34
|
+
- Resolve the exact local workspace root only when direct file access is necessary by
|
|
35
|
+
running \`workspai project workspace status --json\` from this project.
|
|
36
|
+
- The resolver's absolute paths are machine-local runtime data. Never persist or copy
|
|
37
|
+
them into answers, shared logs, commits, prompts, telemetry, or portable artifacts.
|
|
38
|
+
|
|
39
|
+
## Authority boundary
|
|
40
|
+
|
|
41
|
+
The Workspace Model owns canonical project identity and its compact \`projectTopology\`.
|
|
42
|
+
The Workspace Knowledge Graph is a separate, proof-backed enrichment containing
|
|
43
|
+
files, symbols, APIs, infrastructure, tests, owners, and decisions. Do not treat
|
|
44
|
+
an unproven topology edge as proof that two projects are independent. Live source owns
|
|
45
|
+
exact implementation. CLI evidence owns Goal, readiness, repair, and verification claims.
|
|
46
|
+
Repository-authored instructions remain authoritative for source changes after this
|
|
47
|
+
entry gate; Workspai preserves rather than replaces them.
|
|
48
|
+
|
|
49
|
+
## Project
|
|
50
|
+
|
|
51
|
+
- Name: \`${e.project.name}\`
|
|
52
|
+
- Workspace-relative identity: \`${e.project.relativePath}\`
|
|
53
|
+
- Runtime: \`${e.project.runtime??"unknown"}\`
|
|
54
|
+
- Framework: \`${e.project.framework??"unknown"}\`
|
|
55
|
+
- Relationship: \`${e.workspace.relationship}\`
|
|
56
|
+
- Related projects: ${t}
|
|
57
|
+
- Topology status: \`${e.intelligence.topology.status}\`
|
|
58
|
+
- Model freshness: \`${e.intelligence.freshness.model}\`
|
|
59
|
+
- Knowledge Graph freshness: \`${e.intelligence.freshness.graph}\`
|
|
60
|
+
|
|
61
|
+
## Current evidence coverage
|
|
62
|
+
|
|
63
|
+
- Project-scoped entities: ${e.intelligence.entityCount}
|
|
64
|
+
- Project-scoped relations: ${e.intelligence.relationCount}
|
|
65
|
+
- Portable proofs: ${e.intelligence.proofCount}
|
|
66
|
+
|
|
67
|
+
${n}
|
|
68
|
+
|
|
69
|
+
## Current project blockers
|
|
70
|
+
|
|
71
|
+
${o}
|
|
72
|
+
|
|
73
|
+
## Safe commands from this project
|
|
74
|
+
|
|
75
|
+
\`\`\`bash
|
|
76
|
+
${e.commands.workspaceStatus}
|
|
77
|
+
${e.commands.doctor}
|
|
78
|
+
${e.commands.graphSearch}
|
|
79
|
+
${e.commands.verify}
|
|
80
|
+
\`\`\`
|
|
81
|
+
|
|
82
|
+
The machine-local workspace binding lives only in
|
|
83
|
+
\`.workspai/workspace-link.local.json\`, which is gitignored. Portable grounding files
|
|
84
|
+
never publish its value.
|
|
85
|
+
`}function Se(e){return `# Workspai agent entry gate (mandatory)
|
|
86
|
+
|
|
87
|
+
- Project: \`${e.project.name}\`
|
|
88
|
+
- Workspace identity: \`${e.workspace.name}\` (logical name, not a filesystem path)
|
|
89
|
+
- Entry contract: \`.workspai/agent-entry.v1.json\`
|
|
90
|
+
|
|
91
|
+
Before broad repository discovery, architecture claims, planning, or mutation:
|
|
92
|
+
|
|
93
|
+
1. Read \`.workspai/agent-entry.v1.json\`.
|
|
94
|
+
2. Run \`workspai agent bootstrap --for-agent generic --strict --json\`.
|
|
95
|
+
3. Follow the receipt's \`requiredReadOrder\` exactly.
|
|
96
|
+
4. If a Goal is active, read its immutable Goal Pack and handoff before acting.
|
|
97
|
+
5. Query the bounded Workspace Graph with the user's task, then inspect only returned proofs and targeted live source.
|
|
98
|
+
|
|
99
|
+
Receipt policy: \`ready\` may proceed; \`degraded\` must disclose limitations and may not claim complete architecture or verification; \`blocked\` must stop governed claims, execute \`nextActions\`, and rerun bootstrap.
|
|
100
|
+
|
|
101
|
+
\`workspace:\` paths belong to the canonical workspace, not this project's \`.workspai\` directory. Resolve their machine-local root at runtime with \`workspai project workspace status --json\`. That output is machine-local: never copy it into answers, shared logs, commits, or portable artifacts.
|
|
102
|
+
|
|
103
|
+
Authority: Workspai evidence owns identity, topology, goals, readiness, and verification. Live source and repository-authored rules own exact implementation and source conventions.`}function se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function q(e,t){return new RegExp(`${se(e)}[\\s\\S]*?${se(t)}`,"m")}function me(e){let t=e.replace(q(de,pe),"");return d$3(t)?.includes("# Workspai project boundary")&&(t=t.replace(q(a$1,b$1),"")),t.replace(/\n{3,}/g,`
|
|
104
|
+
|
|
105
|
+
`).trim()}function Ne(e,t){let n=me(e),o=`${de}
|
|
106
|
+
${t.trim()}
|
|
107
|
+
${pe}`;return n?`${o}
|
|
108
|
+
|
|
109
|
+
${n}
|
|
110
|
+
`:`${o}
|
|
111
|
+
`}async function W(e,t){await k.mkdir(d.dirname(e),{recursive:true});let n=`${e}.${process.pid}.${le.randomUUID()}.tmp`;try{await k.writeFile(n,t,"utf8");try{await k.rename(n,e);}catch(o){let i=o.code;if(i!=="EEXIST"&&i!=="EPERM")throw o;await he.move(n,e,{overwrite:true});}}finally{await k.rm(n,{force:true}).catch(()=>{});}}async function fe(e,t){let n;try{n=await execa("git",["rev-parse","--show-toplevel"],{cwd:e,reject:false});}catch{return false}if(n?.exitCode!==0)return false;let o=n.stdout.trim();if(!o)return false;let i,c;try{[i,c]=await Promise.all([k.realpath(d.resolve(o)),k.realpath(e)]);}catch{return false}let s=d.resolve(c,t),l=d.relative(i,s).replace(/\\/g,"/");if(!l||d.isAbsolute(l)||l===".."||l.startsWith("../"))return false;let g;try{g=await execa("git",["cat-file","-e",`HEAD:${l}`],{cwd:i,reject:false});}catch{return false}if(g?.exitCode!==0)return false;let u;try{u=await execa("git",["ls-files","--deleted","--error-unmatch","--",`:(top)${l}`],{cwd:i,reject:false});}catch{return false}return u?.exitCode===0}async function ae(e,t){let n=d.join(e,".gitignore"),o=await k.readFile(n,"utf8").catch(l=>{if(l.code==="ENOENT")return "";throw l}),i=[g$1,h$1,b],c=o.split(/\r?\n/).filter(l=>l.trim()!=="# Workspai local project grounding"&&!i.includes(l.trim()));for(;c.length>0&&c[c.length-1]==="";)c.pop();t==="local"&&(c.length>0&&c.push(""),c.push("# Workspai local project grounding",...i));let s=c.length>0?`${c.join(`
|
|
112
|
+
`)}
|
|
113
|
+
`:"";s!==o&&await W(n,s);}var L=[{host:"claude",relativePath:"CLAUDE.md",importFromAgents:"@AGENTS.md",importFromGrounding:"@.workspai/PROJECT-GROUNDING.md"},{host:"gemini",relativePath:"GEMINI.md",importFromAgents:"@./AGENTS.md",importFromGrounding:"@./.workspai/PROJECT-GROUNDING.md"},{host:"qwen",relativePath:"QWEN.md",importFromAgents:"@AGENTS.md",importFromGrounding:"@.workspai/PROJECT-GROUNDING.md"},{host:"amazon-q",relativePath:".amazonq/rules/workspai-agent-entry.md",importFromAgents:"",importFromGrounding:""}];if(L.length!==g.length||L.some((e,t)=>e.relativePath!==g[t]))throw new Error("Project agent adapter paths must match the portable entry contract.");async function Ie(e,t){let n=t.split("/").slice(0,-1),o=e;for(let i of n){o=d.join(o,i);let c=await k.lstat(o).catch(s=>{if(s.code==="ENOENT")return null;throw s});if(!c)return null;if(c.isSymbolicLink()||!c.isDirectory())return d.relative(e,o).split(d.sep).join("/")}return null}function Ge(e){let t=e.agentsAvailable?e.adapter.importFromAgents:e.adapter.importFromGrounding;return t?`${t}
|
|
114
|
+
|
|
115
|
+
# Workspai host binding \xB7 ${e.adapter.host}
|
|
116
|
+
|
|
117
|
+
The imported Workspai entry gate is mandatory. Validate this host with
|
|
118
|
+
\`workspai agent bootstrap --for-agent ${e.adapter.host} --strict --json\`, then follow
|
|
119
|
+
the receipt's \`requiredReadOrder\`, Goal handoff, bounded Graph queries, proof paths,
|
|
120
|
+
status policy, workspace locator privacy policy, and authority boundary. Do not repeat
|
|
121
|
+
the imported instructions or replace repository-authored source rules.`:`# Workspai entry for ${e.adapter.host}
|
|
122
|
+
|
|
123
|
+
Before broad repository discovery, architecture claims, planning, or mutation:
|
|
124
|
+
|
|
125
|
+
1. Read \`.workspai/agent-entry.v1.json\`.
|
|
126
|
+
2. Run \`workspai agent bootstrap --for-agent ${e.adapter.host} --strict --json\`.
|
|
127
|
+
3. Follow \`requiredReadOrder\`, any active Goal handoff, bounded Graph queries, and returned proof paths.
|
|
128
|
+
|
|
129
|
+
Receipt policy: \`ready\` may proceed; \`degraded\` must disclose limitations; \`blocked\` must execute \`nextActions\` and rerun bootstrap before governed claims.
|
|
130
|
+
|
|
131
|
+
The workspace name is a logical identity, not a path. Resolve \`workspace:\` URIs at runtime with \`workspai project workspace status --json\`; its absolute paths are machine-local and must never be copied into shared output or portable artifacts. Live source owns exact implementation; Workspai evidence owns identity, topology, goals, readiness, and verification. Repository-authored rules remain authoritative for source changes after this entry gate.`}async function ie(e){let t=await Ie(e.projectPath,e.adapter.relativePath);if(t)return {reason:`${e.adapter.relativePath} has an unsafe repository-authored parent at ${t}.`};let n=d.join(e.projectPath,e.adapter.relativePath),o=await k.lstat(n).catch(u=>{if(u.code==="ENOENT")return null;throw u});if(o?.isSymbolicLink())return {reason:`${e.adapter.relativePath} is a repository-authored symbolic link.`};let i=o?.isFile()===true,c=await k.readFile(n,"utf8").catch(u=>{if(u.code==="ENOENT")return "";throw u});if(e.mode==="managed"&&!i&&await fe(e.projectPath,e.adapter.relativePath))return {reason:`${e.adapter.relativePath} has an authored tracked deletion.`};let s=c.replace(q(d$2,e$1),"").replace(/\n{3,}/g,`
|
|
132
|
+
|
|
133
|
+
`).trim(),l=e.mode==="managed"?[s,`${d$2}
|
|
134
|
+
${Ge(e).trim()}
|
|
135
|
+
${e$1}`].filter(Boolean).join(`
|
|
136
|
+
|
|
137
|
+
`):s;if(!l)return i&&await k.rm(n,{force:true}),{};let g=`${l.trimEnd()}
|
|
138
|
+
`;return g!==c&&await W(n,g),e.mode==="managed"?{path:e.adapter.relativePath}:{}}function We(e){let t={id:"generic",discovery:"portable-fallback",entryFiles:[g$1],status:"ready",managed:e.mode==="managed"},o=["codex","kimi","grok","copilot","cursor","windsurf"].map(s=>({id:s,discovery:"native",entryFiles:["AGENTS.md"],status:e.agentsAvailable?"ready":"blocked",managed:e.mode==="managed"&&e.agentsAvailable,...e.agentsAvailable?{}:{reason:"AGENTS.md could not be managed without overriding authored repository state."}})),i=L.map(s=>{let l=e.adapters.get(s.host);return {id:s.host,discovery:"adapter",entryFiles:[s.relativePath],status:l?.path?"ready":e.mode==="managed"?"blocked":"degraded",managed:!!l?.path,...l?.path?{}:{reason:l?.reason??"Provider adapter generation is disabled by the project grounding policy."}}}),c=[t,...o,...i];return f.map(s=>c.find(l=>l.id===s))}async function ce(e,t,n){let o=d.join(e,"AGENTS.md"),i=await k.lstat(o).catch(u=>{if(u.code==="ENOENT")return null;throw u});if(i?.isSymbolicLink())return;let c=i?.isFile()===true,s=await k.readFile(o,"utf8").catch(u=>{if(u.code==="ENOENT")return "";throw u});if(t==="managed"&&!n)throw new Error("Managed project grounding requires a project context.");if(t==="managed"&&!c&&await fe(e,"AGENTS.md"))return;let l=t==="managed"&&n?Ne(s,Se(n)):me(s);if(!l){c&&await k.rm(o,{force:true});return}let g=`${l.trimEnd()}
|
|
139
|
+
`;return g!==s&&await W(o,g),t==="managed"?o:void 0}async function $e(e){let t$1=e.mode??"managed",n=d.resolve(e.workspacePath),o=d.resolve(e.projectPath);if(t$1==="off"){let p=t(o,"project.json").find(j=>H.existsSync(j)),v=p?await E(p):null,C=e.projectName??(typeof v?.name=="string"?v.name:void 0)??d.basename(o),R=ge(v,e.relationship??"managed"),N=await c({workspacePath:n,projectPath:o,projectName:C,relationship:R,now:e.now});return await ae(o,t$1),await ce(o,t$1),await Promise.all(L.map(j=>ie({projectPath:o,adapter:j,mode:t$1,agentsAvailable:false}))),await Promise.all([k.rm(d.join(o,h$1),{force:true}),k.rm(d.join(o,g$1),{force:true}),k.rm(d.join(o,b),{force:true})]),{mode:t$1,projectPath:o,linkPath:N.linkPath,writtenFiles:[i.projectWorkspaceLink]}}let i$2=await Re(e),c$1=i$2.workspace.relationship,s=await c({workspacePath:n,projectPath:o,projectName:i$2.project.name,relationship:c$1,workspaceName:i$2.workspace.name,relativePath:i$2.project.relativePath,now:e.now});await ae(o,t$1);let l=await ce(o,t$1,i$2),g=new Map;for(let p of L)g.set(p.host,await ie({projectPath:o,adapter:p,mode:t$1,agentsAvailable:!!l}));let u=We({mode:t$1,agentsAvailable:!!l,adapters:g}),f=d.join(o,h$1),w=d.join(o,g$1),y=d.join(o,b),b$1=i$1({context:i$2,hosts:u});await W(f,`${JSON.stringify(i$2,null,2)}
|
|
140
|
+
`),await W(w,`${Te(i$2).trimEnd()}
|
|
141
|
+
`),await W(y,`${JSON.stringify(b$1,null,2)}
|
|
142
|
+
`);let m=[i.projectWorkspaceLink,h$1,g$1,b];l&&m.push("AGENTS.md");for(let p of g.values())p.path&&m.push(p.path);return {mode:t$1,projectPath:o,linkPath:s.linkPath,groundingPath:w,contextPath:f,agentEntryPath:y,agentsPath:l,hostCoverage:u,writtenFiles:m}}async function et(e){let t=d.resolve(e.workspacePath),n=e.mode??"managed",o=await Oe(t),i=[],c=[];for(let s of o.resolved)try{i.push(await $e({workspacePath:t,projectPath:s.projectPath,projectName:s.name,relationship:s.relationship,mode:n,now:e.now}));}catch(l){c.push({name:s.name,reason:l instanceof Error?l.message:String(l)});}return {workspacePath:t,mode:n,projects:i,skipped:[...o.skipped,...c]}}async function Oe(e){let t=d.resolve(e),n=await E(d.join(t,".workspai","workspace.contract.json")),o=[],i=[];for(let c of n?.projects??[]){let s=c.slug??c.relativePath??"unknown-project",l=typeof c.externalPath=="string"?d.resolve(c.externalPath):typeof c.relativePath=="string"&&!c.relativePath.startsWith("external/")?d.resolve(t,c.relativePath):null;if(!l||!H.existsSync(l)){i.push({name:s,reason:"project path is unavailable on this machine"});continue}o.push({name:s,projectPath:l,relationship:c.relationship??"managed"});}return {resolved:o,skipped:i}}export{ke as a,Ze as b,de as c,pe as d,Re as e,$e as f,et as g,Oe as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-LPCWROQ3.js';import {f,e as e$1,g as g$1,i}from'./chunk-NZ3WZYD5.js';var g=f.repairTransaction,v=e$1.repairTransaction,b=g$1.repairTransaction;var k="workspai.workspace-repair-proposal.v1",x="contracts/workspace-intelligence/workspace-repair-proposal.v1.json";var m="workspai.workspace-repair-capabilities.v1",y="workspai.workspace-repair-consumer-protocol.v1",w=[{id:"node",ecosystem:"JavaScript / TypeScript",manifests:["package.json"],lockfiles:["package-lock.json","npm-shrinkwrap.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb"],packageManagers:["npm","pnpm","yarn","bun"],support:"full",stages:{reconcile:"native",audit:"native",test:"declared",build:"declared"},requiredToolFamilies:["selected package manager"]},{id:"python",ecosystem:"Python",manifests:["pyproject.toml","requirements.txt"],lockfiles:["uv.lock","poetry.lock","requirements.txt"],packageManagers:["uv","poetry","pip"],support:"conditional",stages:{reconcile:"conditional",audit:"conditional",test:"conditional",build:"declared"},requiredToolFamilies:["isolated Python","selected environment manager","pip-audit or governed Doctor audit"],limitation:"A bounded isolated environment and an installed audit surface are required."},{id:"go",ecosystem:"Go",manifests:["go.mod"],lockfiles:["go.sum"],packageManagers:["go modules"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["go","govulncheck"],limitation:"govulncheck must be installed; the engine never fetches an unreviewed tool."},{id:"rust",ecosystem:"Rust",manifests:["Cargo.toml"],lockfiles:["Cargo.lock"],packageManagers:["cargo"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["cargo","cargo-audit"],limitation:"The cargo-audit subcommand must already be installed."},{id:"php-composer",ecosystem:"PHP",manifests:["composer.json"],lockfiles:["composer.lock"],packageManagers:["composer"],support:"full",stages:{reconcile:"native",audit:"native",test:"declared",build:"declared"},requiredToolFamilies:["composer"]},{id:"ruby-bundler",ecosystem:"Ruby",manifests:["Gemfile"],lockfiles:["Gemfile.lock"],packageManagers:["bundler"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"declared",build:"declared"},requiredToolFamilies:["bundle","bundle-audit"],limitation:"bundle-audit and the declared Rake tasks must already exist."},{id:"elixir-mix",ecosystem:"Elixir",manifests:["mix.exs"],lockfiles:["mix.lock"],packageManagers:["mix"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["mix","Hex audit task"],limitation:"The project must expose the Hex audit task used by its dependency policy."},{id:"deno",ecosystem:"Deno",manifests:["deno.json","deno.jsonc"],lockfiles:["deno.lock"],packageManagers:["deno"],support:"full",stages:{reconcile:"native",audit:"native",test:"declared",build:"declared"},requiredToolFamilies:["deno"]},{id:"dotnet",ecosystem:".NET",manifests:["*.sln","*.csproj","*.fsproj","*.vbproj"],lockfiles:["Directory.Packages.props","packages.lock.json"],packageManagers:["NuGet / dotnet"],support:"full",stages:{reconcile:"native",audit:"native",test:"native",build:"native"},requiredToolFamilies:["dotnet"]},{id:"jvm-maven",ecosystem:"JVM / Maven",manifests:["pom.xml"],lockfiles:[],packageManagers:["Maven Wrapper","Maven"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["mvnw or mvn","governed Doctor audit"],limitation:"A project-specific dependency audit command must be declared by Doctor evidence."},{id:"jvm-gradle",ecosystem:"JVM / Gradle",manifests:["build.gradle.kts","build.gradle"],lockfiles:["gradle.lockfile","gradle/libs.versions.toml"],packageManagers:["Gradle Wrapper","Gradle"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["gradlew or gradle","governed Doctor audit"],limitation:"A project-specific dependency audit command must be declared by Doctor evidence."},{id:"clojure",ecosystem:"Clojure",manifests:["deps.edn","project.clj"],lockfiles:[],packageManagers:["Clojure CLI","Leiningen"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"conditional",build:"conditional"},requiredToolFamilies:["clojure or lein","governed project audit"],limitation:"Tests and builds run only when the selected Clojure project surface declares a deterministic entrypoint."},{id:"scala-sbt",ecosystem:"Scala / sbt",manifests:["build.sbt"],lockfiles:[],packageManagers:["sbt"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["sbt","governed project audit"],limitation:"A project-specific dependency audit command must be declared by Doctor evidence."}];function T(){return {schemaVersion:m,owner:"Workspai CLI",workflow:["plan","preconditions","approval","target-precondition","checkpoint","execute","reconcile","audit","test","build","target-producer-verify","canonical-verify","close-or-rollback-or-decision"],invariants:{multiAdapterProjects:true,missingTools:"decision-required",unsupportedEcosystems:"decision-required",silentFallbackToModelExecution:false,mutationAuthority:"cli-only",targetClosure:"selected-causal-action-set",changeReceipt:"checkpoint-hash-delta",consumerTimeline:"durable-transaction-events",typedDecisionCauses:true,registeredLinkedProjectMutationBoundary:true,sourceProposalIntegrity:"project-bound-hash-pinned",completionAuthority:"cli-verification-receipt",goalSourceTransition:"closed-integrity-bound-v1",goalAttemptBudget:"durable-serialized-v1",consumerHandshakeRequired:true,ephemeralProposalsAreEvidence:false,approvalBoundToPlanHash:true,canonicalVerificationRequired:true,rollbackConflictDetection:true},consumerProtocol:{protocolVersion:y,versionProbe:{args:["--version","--json"],schemaVersion:"rapidkit-version-v1"},capabilityProbe:{args:["workspace","repair","capabilities","--json"],schemaVersion:m},invocation:{command:"workspace repair",workspaceResolution:["process-cwd","--workspace"],actions:["capabilities","plan","propose","approve","decide","execute","resume","status","list","rollback","cancel"]},contracts:{operationResult:a$1,proposal:k,transaction:g},transientPaths:[".workspai/repair/inbox/*.json",".workspai/repair/engine.lock"]},adapters:w}}var N="workspai.studio-card-repair-capabilities.v1",R="npx workspai workspace verify --json",r=e$1,a=i;function e(f,n,c,o={}){return {cardId:f,scope:o.scope??"workspace",producerCommand:n,producerArtifact:c,verifyCommand:n,verifyArtifact:c,aggregateVerifyCommand:R,targetClosure:"exact-producer-and-causal-action-set",workspacePosture:"reported-separately",repairPolicy:o.repairPolicy??"refresh-producer",remediationArtifacts:o.remediationArtifacts??[]}}var M=[e("doctor","npx workspai doctor workspace --json",r.doctor,{repairPolicy:"diagnose-and-repair",remediationArtifacts:[a.doctorRemediationPlan,a.artifactRemediationPlan]}),e("projectDoctor","npx workspai doctor project --json",a.doctorProject,{scope:"project",repairPolicy:"diagnose-and-repair",remediationArtifacts:[a.doctorRemediationPlan,a.artifactRemediationPlan]}),e("pipeline","npx workspai pipeline --json --strict",a.pipelineLastRun,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("analyze","npx workspai analyze --json",r.analyze,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("readiness","npx workspai readiness --json",r.readiness,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("bootstrap","npx workspai bootstrap --ci --json",a.bootstrapCompliance,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("workspaceSync","npx workspai workspace sync --json",a.workspaceRegistry),e("foundation","npx workspai workspace foundation ensure --json",".workspai/workspace.json"),e("contract","npx workspai workspace contract verify --strict --json",r.contractVerify,{repairPolicy:"source-repair-then-produce"}),e("autopilot","npx workspai autopilot release --json",a.autopilotReleaseLastRun,{repairPolicy:"source-repair-then-produce"}),e("workspaceRun","npx workspai workspace run test --json",a.workspaceRunLast,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("setup","npx workspai setup --json",".workspai/toolchain.lock",{repairPolicy:"source-repair-then-produce"}),e("importReadiness","npx workspai doctor project --json",a.doctorProject,{scope:"project",repairPolicy:"diagnose-and-repair",remediationArtifacts:[a.artifactRemediationPlan]}),e("snapshot","npx workspai snapshot create --json",".workspai/reports/snapshot-last-run.json"),e("workspaceModel","npx workspai workspace model --json --write",r.model),e("intelligenceSnapshot","npx workspai workspace snapshot --json",r.snapshot),e("workspaceDiff",`npx workspai workspace diff --from ${r.snapshot} --json`,r.diff),e("workspaceImpact",`npx workspai workspace impact --from ${r.diff} --json`,r.impact),e("workspaceIntelligenceRun","npx workspai workspace intelligence run --for-agent generic --strict --json",r.intelligenceRun,{repairPolicy:"source-repair-then-produce"}),e("workspaceVerify",R,r.verify,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("workspaceExplain","npx workspai workspace explain release-blocked --json --write",r.explain),e("workspaceWhy","npx workspai workspace why release-blocked --json --write",a.workspaceWhy),e("workspaceTrace",`npx workspai workspace trace --from ${r.diff} --json --write`,a.workspaceTrace),e("workspaceWatch","npx workspai workspace watch --once --json",r.model),e("workspaceContextAgent","npx workspai workspace context --for-agent --json --write",r.agentContext),e("agentGrounding","npx workspai workspace agent-sync --write --refresh-context --json --preset enterprise --target vscode",r.agentCustomizationPack),e("share",`npx workspai workspace share --output ${a.workspaceShareBundle} --json`,a.workspaceShareBundle),e("archive","npx workspai workspace export --output team-workspace.workspai-archive.zip --json",".workspai/archive-manifest.json"),e("mirror","npx workspai mirror status --json",a.mirrorOps),e("cache","npx workspai cache status --json",".workspai/cache-config.yml"),e("policy","npx workspai workspace policy show --json",".workspai/policies.yml",{repairPolicy:"source-repair-then-produce"}),e("infra","npx workspai infra plan --json",a.infraPlan,{repairPolicy:"source-repair-then-produce"})];export{g as a,v as b,b as c,k as d,x as e,m as f,w as g,T as h,N as i,M as j};
|