workspai 0.66.0 → 0.68.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 +24 -22
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +4 -0
- package/contracts/extension-cli-compatibility.v1.json +4 -0
- package/contracts/published-contract-catalog.v1.json +20 -0
- package/contracts/runtime-command-surface.v1.json +55 -2
- package/contracts/workspace-activity-board.v1.json +120 -0
- package/contracts/workspace-activity-event.v1.json +31 -1
- package/contracts/workspace-activity-monitor-fleet.v1.json +18 -0
- package/contracts/workspace-activity-monitor-snapshot.v1.json +194 -0
- package/contracts/workspace-intelligence/workspace-intelligence-benchmark.v1.json +196 -0
- package/contracts/workspace-intelligence/workspace-knowledge-search.v1.json +1 -0
- package/contracts/workspace-intelligence-architecture.v1.json +17 -0
- package/contracts/workspace-intelligence-chain.v1.json +17 -0
- package/dist/analyze-JDEWUBC6.js +1 -0
- package/dist/{artifact-remediation-plan-M2XBS2IU.js → artifact-remediation-plan-I7IKC5MR.js} +1 -1
- package/dist/autopilot-release-OELUFNLL.js +1 -0
- package/dist/capabilities-command-RAAYENQ6.js +1 -0
- package/dist/chunk-25AWHAB5.js +2 -0
- package/dist/{chunk-QGAPGZPL.js → chunk-2C5XJBYI.js} +1 -1
- package/dist/{chunk-PJPS7CNH.js → chunk-2KX6KHEC.js} +1 -1
- package/dist/{chunk-JZJBA2V2.js → chunk-2MTJWPQ4.js} +1 -1
- package/dist/chunk-3BMYMZQB.js +1 -0
- package/dist/{chunk-VA5VSOBL.js → chunk-3KU3YUWD.js} +1 -1
- package/dist/{chunk-UPIPSSXY.js → chunk-3NF3M3RE.js} +1 -1
- package/dist/chunk-3OGPTLI2.js +1 -0
- package/dist/{chunk-EHH4SKVH.js → chunk-3XF7O66C.js} +3 -3
- package/dist/{chunk-WTWRSEOW.js → chunk-3Z4SVBMR.js} +1 -1
- package/dist/{chunk-NVND4727.js → chunk-46QH3ZVI.js} +1 -1
- package/dist/{chunk-XQFWUM2P.js → chunk-4WVOAX2V.js} +1 -1
- package/dist/{chunk-727IQFGN.js → chunk-5ME4W4LN.js} +1 -1
- package/dist/{chunk-IVF6NEHS.js → chunk-5OV2WXAR.js} +1 -1
- package/dist/{chunk-R2M5OJOK.js → chunk-5XUAAQSV.js} +2 -2
- package/dist/{chunk-IIFFEEMX.js → chunk-5YZ2W57R.js} +1 -1
- package/dist/{chunk-B4IVVTMQ.js → chunk-64XWHDZ3.js} +1 -1
- package/dist/{chunk-AP4PV6WJ.js → chunk-6E2Y3XGT.js} +1 -1
- package/dist/{chunk-4XEH3WNV.js → chunk-7DDEMDG2.js} +1 -1
- package/dist/{chunk-YX5VWPR5.js → chunk-7DZNZ3GM.js} +1 -1
- package/dist/{chunk-OI2VOU6S.js → chunk-BG6IX6HA.js} +1 -1
- package/dist/{chunk-6JX56VAL.js → chunk-BHM6RHTA.js} +1 -1
- package/dist/chunk-BMAFHX6A.js +1 -0
- package/dist/{chunk-3NM3JAZW.js → chunk-BUYLM6QV.js} +1 -1
- package/dist/{chunk-GAYK3WGV.js → chunk-C2VTO5WT.js} +1 -1
- package/dist/chunk-CPR2CMOY.js +1 -0
- package/dist/{chunk-PD7Y6HIM.js → chunk-CSZPE637.js} +1 -1
- package/dist/{chunk-5OA33JH2.js → chunk-D5LLTUTY.js} +1 -1
- package/dist/{chunk-3H5ACWWZ.js → chunk-DFVG4DDZ.js} +1 -1
- package/dist/{chunk-5XGR3LRI.js → chunk-EHLGPLIU.js} +1 -1
- package/dist/{chunk-334J2KIP.js → chunk-FPDH3N3A.js} +1 -1
- package/dist/{chunk-D4UHRJAP.js → chunk-FX5J6JCK.js} +1 -1
- package/dist/{chunk-DUBOKZMA.js → chunk-GVQKAINC.js} +12 -12
- package/dist/{chunk-XESFJN52.js → chunk-IKUFNK46.js} +1 -1
- package/dist/{chunk-AXUA7PFV.js → chunk-IXXQMD34.js} +1 -1
- package/dist/{chunk-HJLGXFMK.js → chunk-JYMO7QXQ.js} +1 -1
- package/dist/{chunk-JRP6WP5C.js → chunk-KDY4X7SQ.js} +1 -1
- package/dist/{chunk-L5Q2S5GY.js → chunk-KFTJVVJR.js} +1 -1
- package/dist/{chunk-SX6A656X.js → chunk-KY2GOSO5.js} +1 -1
- package/dist/chunk-LDBULT2T.js +4 -0
- package/dist/{chunk-VQOWB26M.js → chunk-LEOFD3W5.js} +1 -1
- package/dist/{chunk-L5CCIIF2.js → chunk-N5HPMATQ.js} +1 -1
- package/dist/{chunk-2PACEMNE.js → chunk-OFYY4725.js} +1 -1
- package/dist/{chunk-O37UBRMX.js → chunk-P3622IM5.js} +1 -1
- package/dist/{chunk-TABXSDTR.js → chunk-PKKSRXUS.js} +1 -1
- package/dist/{chunk-ZQH2I5RQ.js → chunk-Q7UGDNSM.js} +1 -1
- package/dist/{chunk-HLWDIIWL.js → chunk-QMQBX3RV.js} +1 -1
- package/dist/{chunk-TTHO4MFC.js → chunk-RVAOJOXA.js} +1 -1
- package/dist/{chunk-H5RJCS5E.js → chunk-SLFOUSRW.js} +1 -1
- package/dist/{chunk-7FF5EOIO.js → chunk-TCLKGPXF.js} +1 -1
- package/dist/chunk-TMRCPT7S.js +1 -0
- package/dist/{chunk-EP4CUWOO.js → chunk-VIN7NJW3.js} +1 -1
- package/dist/chunk-W37NOQVG.js +1 -0
- package/dist/chunk-W5VKBDSD.js +157 -0
- package/dist/{chunk-UOCERSAN.js → chunk-WRZSQDZV.js} +1 -1
- package/dist/{chunk-ECLMYTWT.js → chunk-Y4Z6CEII.js} +1 -1
- package/dist/{chunk-6UNATTB7.js → chunk-ZGHJIQXL.js} +1 -1
- package/dist/{create-SOLLXXAB.js → create-U5PQHOZ4.js} +1 -1
- package/dist/{demo-kit-5UQH2OXC.js → demo-kit-RKTHTXHJ.js} +1 -1
- package/dist/{doctor-NQ5PUCUP.js → doctor-D7YI7LSA.js} +1 -1
- package/dist/{dotnet-webapi-clean-YEHYIGOT.js → dotnet-webapi-clean-XL4IBUQV.js} +1 -1
- package/dist/{goal-lifecycle-IPNY7KNR.js → goal-lifecycle-BMS6GSIU.js} +1 -1
- package/dist/{goal-pack-2WV3EA4Y.js → goal-pack-RBSVQMMX.js} +1 -1
- package/dist/{gofiber-standard-C44IIQYH.js → gofiber-standard-OHHMCNMJ.js} +1 -1
- package/dist/{gogin-standard-X7VKACVR.js → gogin-standard-BAZXPOKL.js} +1 -1
- package/dist/index.d.ts +14 -2
- package/dist/index.js +129 -129
- package/dist/live-command-GNAASZ7U.js +15 -0
- package/dist/{pipeline-MIMENSI7.js → pipeline-QOMXH2EK.js} +1 -1
- package/dist/{project-agent-entry-OWLJ3IHQ.js → project-agent-entry-MH7364BE.js} +1 -1
- package/dist/{project-intelligence-lens-I67EO6AE.js → project-intelligence-lens-ZCCHUKVI.js} +1 -1
- package/dist/{project-test-coverage-OPDVSFPH.js → project-test-coverage-JPWTBSSJ.js} +1 -1
- package/dist/{rust-axum-JKZTZDRZ.js → rust-axum-CCJ6UCBW.js} +1 -1
- package/dist/{springboot-standard-PI4FLTAN.js → springboot-standard-M5JQEJML.js} +1 -1
- package/dist/{verified-goal-46JWNCDY.js → verified-goal-XUXU2X5H.js} +1 -1
- package/dist/{workspace-KO37XHF6.js → workspace-B33BFZZ3.js} +1 -1
- package/dist/{workspace-agent-sync-32FIJQBH.js → workspace-agent-sync-T3MJO2MX.js} +1 -1
- package/dist/{workspace-archive-6R5DRNZW.js → workspace-archive-NOSGRKRZ.js} +1 -1
- package/dist/{workspace-context-JKRPX775.js → workspace-context-KOCEP4MJ.js} +1 -1
- package/dist/{workspace-contract-4T3NYNK5.js → workspace-contract-MQ3QE52V.js} +1 -1
- package/dist/workspace-explain-DTFCKYXK.js +1 -0
- package/dist/workspace-explain-contract-WMREJWHF.js +1 -0
- package/dist/{workspace-feedback-6VQ7T4CR.js → workspace-feedback-3YLIUFQ7.js} +1 -1
- package/dist/{workspace-foundation-GHWO3BZU.js → workspace-foundation-O7O3QIS4.js} +1 -1
- package/dist/{workspace-graph-stream-PTVS47NJ.js → workspace-graph-stream-XTGGBD7D.js} +1 -1
- package/dist/workspace-graph-token-efficiency-5LJKQU2J.js +1 -0
- package/dist/{workspace-history-M2K4M2JY.js → workspace-history-7HDZZ4G5.js} +1 -1
- package/dist/{workspace-intelligence-PJIPTXL3.js → workspace-intelligence-TFEQBPUP.js} +1 -1
- package/dist/workspace-intelligence-benchmark-PLVUBGWO.js +1 -0
- package/dist/workspace-intelligence-evaluation-OJIQS5SN.js +1 -0
- package/dist/{workspace-intelligence-runner-M47QR3JM.js → workspace-intelligence-runner-6ZAV6RO4.js} +1 -1
- package/dist/{workspace-intelligence-runtime-registry-FFGQF4A7.js → workspace-intelligence-runtime-registry-UKFB3BI7.js} +1 -1
- package/dist/{workspace-knowledge-graph-V2EAYDCL.js → workspace-knowledge-graph-AUXYL3L6.js} +1 -1
- package/dist/{workspace-knowledge-graph-contract-VANN7RCA.js → workspace-knowledge-graph-contract-X52KXBXJ.js} +1 -1
- package/dist/{workspace-knowledge-graph-query-RASPF7FS.js → workspace-knowledge-graph-query-A7TKONWY.js} +1 -1
- package/dist/workspace-knowledge-graph-snapshot-GPBDAKAU.js +1 -0
- package/dist/{workspace-mcp-serve-YRORNE4P.js → workspace-mcp-serve-TDUXJUAA.js} +1 -1
- package/dist/{workspace-model-VSVKLX7M.js → workspace-model-GVXNLSQM.js} +1 -1
- package/dist/{workspace-onboarding-2VMJZVLZ.js → workspace-onboarding-ECZ2KJ2A.js} +1 -1
- package/dist/{workspace-readme-6X3GLTBM.js → workspace-readme-6N5Y2ZSJ.js} +1 -1
- package/dist/{workspace-registry-summary-QVSJKKTX.js → workspace-registry-summary-5SFBTRGQ.js} +1 -1
- package/dist/{workspace-repair-engine-WSKV3Q4V.js → workspace-repair-engine-CKJCTWKX.js} +1 -1
- package/dist/workspace-run-ZZ5WHL7W.js +1 -0
- package/dist/{workspace-verify-EJCSOBIK.js → workspace-verify-D3QTMAUI.js} +1 -1
- package/dist/{workspace-watch-JTIFBF4Z.js → workspace-watch-XYJEW2Z2.js} +1 -1
- package/docs/DEVELOPMENT.md +19 -0
- package/docs/README.md +19 -16
- package/docs/ci-workflows.md +1 -1
- package/docs/commands-reference.md +20 -2
- package/docs/contracts/ARTIFACT_CATALOG.md +1 -0
- package/docs/contracts/README.md +3 -0
- package/docs/workspace-intelligence-benchmark.md +82 -0
- package/docs/workspace-knowledge-graph.md +1 -0
- package/docs/workspace-live-activity.md +29 -5
- package/package.json +4 -2
- package/dist/analyze-UJQWGNM2.js +0 -1
- package/dist/autopilot-release-U6F4M2BQ.js +0 -1
- package/dist/capabilities-command-XUKPO25Z.js +0 -1
- package/dist/chunk-5TY74LLW.js +0 -2
- package/dist/chunk-5U4L6VF2.js +0 -1
- package/dist/chunk-C4S22E6S.js +0 -1
- package/dist/chunk-H7MRINGP.js +0 -1
- package/dist/chunk-JC4XSU7G.js +0 -1
- package/dist/chunk-MZ7U4BIQ.js +0 -157
- package/dist/chunk-UTV4DTNM.js +0 -1
- package/dist/live-command-Q6E45N7S.js +0 -18
- package/dist/workspace-explain-MOGL4GEA.js +0 -1
- package/dist/workspace-explain-contract-W2E6LF4Q.js +0 -1
- package/dist/workspace-graph-token-efficiency-Z5JD5NHI.js +0 -1
- package/dist/workspace-intelligence-evaluation-GONCRE6O.js +0 -1
- package/dist/workspace-knowledge-graph-snapshot-5YIG6EMG.js +0 -1
- package/dist/workspace-run-3BXKTLVL.js +0 -1
package/dist/chunk-MZ7U4BIQ.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import {g,b,i as i$1,d as d$2,e as e$1,f}from'./chunk-TTHO4MFC.js';import {c}from'./chunk-334J2KIP.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 {a}from'./chunk-AFIFZTOY.js';import {d as d$1}from'./chunk-EWZZUQBR.js';import {h,e,i}from'./chunk-6UNATTB7.js';import {u,h as h$1,g as g$1}from'./chunk-VQZ5PI5J.js';import be from'crypto';import ne from'fs';import y from'fs/promises';import d from'path';import {execa}from'execa';import X from'fs-extra';async function Q(e,t){let[n,r]=await Promise.all([X.realpath(e).catch(()=>null),X.realpath(t).catch(()=>null)]);if(!n||!r)return null;let s=d.relative(n,r);return !s||d.isAbsolute(s)||s===".."||s.startsWith(`..${d.sep}`)?null:(await X.stat(r).catch(()=>null))?.isFile()?r:null}var Ne=h.projectContextAgent.schemaVersion,ft=["managed","local","off"],se="<!-- WORKSPAI:PROJECT-GROUNDING:START -->",ve="<!-- WORKSPAI:PROJECT-GROUNDING:END -->",ee="<!-- WORKSPAI:GENERATED-PROJECT-SKILL -->",B=".agents/skills/workspai-grounding/SKILL.md";function he(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}async function E(e){try{return JSON.parse(await y.readFile(e,"utf8"))}catch(t){return null}}function W(e){return e.replace(/\\/g,"/").replace(/^\.\/+/,"")}function _(e,t,n){let r=e.replace(/\\/g,"/"),s=/^[A-Za-z]:\//.test(r);if(!d.isAbsolute(e)&&!s)return W(r);if(s&&process.platform!=="win32")return null;let a=d.resolve(e),i=d.relative(n,a);if(i&&!i.startsWith("..")&&!d.isAbsolute(i))return W(i);let c=d.relative(t,a);return c&&!c.startsWith("..")&&!d.isAbsolute(c)?`workspace:${W(c)}`:null}function I(e,t,n){return [[n,"project:"],[n.replace(/\\/g,"/"),"project:"],[t,"workspace:"],[t.replace(/\\/g,"/"),"workspace:"]].reduce((s,[a,i])=>a.length>0?s.split(a).join(i):s,e)}function Ee(e,t){return he(e?.adoption)?.mode==="linked"?"adopted":he(e?.import)?"imported":t}function xe(e){if(!e.model)return null;let t=W(e.relativePath);return e.model.projects.find(n=>n.name===e.projectName||W(n.path)===t)??null}function U(e,t){e[t]=(e[t]??0)+1;}var fe=["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"],te=48,oe=12*1024;function Le(e,t=te,n=oe){let r={language:12,api:8,service:8,endpoint:8,schema:8,protocol:8,"runtime-unit":12,"lifecycle-stage":12,file:4,module:4,symbol:4},s=new Map,a={};for(let u of e)U(a,u.kind);for(let u of fe)s.set(u,e.filter(h=>h.kind===u).sort((h,f)=>h.label.localeCompare(f.label)||h.id.localeCompare(f.id)).slice(0,r[u]??6));let i=[],c={},m=0,p=0,l=true;for(;i.length<t&&l;){l=false;for(let u of fe){let h=s.get(u)?.[p];if(!h)continue;let f=Buffer.byteLength(JSON.stringify(h));if(!(m+f>n)&&(i.push(h),m+=f,U(c,u),l=true,i.length>=t))break}p+=1;}let k=Object.fromEntries(Object.entries(a).map(([u,h])=>[u,h-(c[u]??0)]).filter(([,u])=>u>0).sort(([u],[h])=>u.localeCompare(h)));return {entities:i,selectedBytes:m,selectedByKind:c,omittedByKind:k}}function $e(e,t){if(!e)return {entityCount:0,relationCount:0,proofCount:0,entitiesByKind:{},relationsByKind:{},languages:{},semantic:{protocolConceptCount:0,protocolImplementationBindings:0,equivalenceBindings:0,generationBindings:0,runtimeUnitCount:0,lifecycleStageCount:0,runtimeCoverage:[]},projection:{mode:"stratified-byte-bounded",maxEntities:te,byteBudget:oe,selectedBytes:0,eligibleCount:0,selectedCount:0,omittedCount:0,selectedByKind:{},omittedByKind:{}},relatedProjects:[],proofArtifacts:[],entities:[],relations:[],proofs:[],topology:{status:"unavailable",dependencies:[],dependents:[]},diagnostics:[]};let n=e.entities.find(o=>o.kind==="project"&&(o.id===t||o.label===t||o.projectId===t)),r=new Set(e.entities.filter(o=>o.projectId===t||o.id===n?.id||o.kind==="project"&&o.label===t).map(o=>o.id));n&&r.add(n.id);let s=e.relations.filter(o=>r.has(o.from)||r.has(o.to)),a=new Set(r);for(let o of s)a.add(o.from),a.add(o.to);let i=e.entities.filter(o=>a.has(o.id)),c=new Set,m={},p={},l={},k=new Set(i.filter(o=>o.kind==="language").map(o=>o.attributes.language).filter(o=>typeof o=="string"));for(let o of i){U(m,o.kind);let w=typeof o.attributes.language=="string"?o.attributes.language:void 0;if(w&&o.kind==="language")l[w]={fileCount:typeof o.attributes.fileCount=="number"?o.attributes.fileCount:0,symbolCount:l[w]?.symbolCount??0,generatedFileCount:typeof o.attributes.generatedFileCount=="number"?o.attributes.generatedFileCount:0};else if(w&&(o.kind==="file"||o.kind==="symbol")){let b=l[w]??{fileCount:0,symbolCount:0,generatedFileCount:0};o.kind==="file"&&!k.has(w)?(b.fileCount+=1,o.attributes.generated===true&&(b.generatedFileCount+=1)):o.kind==="symbol"&&(b.symbolCount+=1),l[w]=b;}for(let b of o.proofIds)c.add(b);}for(let o of s){U(p,o.kind);for(let w of o.proofIds)c.add(w);}let u=e.proofs.filter(o=>c.has(o.id)),h=[...new Set(e.entities.filter(o=>a.has(o.id)&&o.projectId&&o.projectId!==t).map(o=>o.projectId))].sort(),f=e.diagnostics.filter(o=>(!o.entityIds||o.entityIds.length===0)&&(!o.relationIds||o.relationIds.length===0)||o.entityIds?.some(w=>a.has(w))||o.relationIds?.some(w=>s.some(b=>b.id===w))).map(o=>({code:o.code,severity:o.severity,message:o.message,...o.recommendation?{recommendation:o.recommendation}:{}})),j=(o,w)=>({project:w,kind:o.kind,source:o.source,confidence:o.confidence,evidence:[...new Set(o.evidence.map(b=>b.file.replace(/\\/g,"/")))].sort()}),P=e.projectTopology.edges.filter(o=>o.from===t).map(o=>j(o,o.to)).sort((o,w)=>`${o.project}:${o.kind}`.localeCompare(`${w.project}:${w.kind}`)),S=e.projectTopology.edges.filter(o=>o.to===t).map(o=>j(o,o.from)).sort((o,w)=>`${o.project}:${o.kind}`.localeCompare(`${w.project}:${w.kind}`)),N=Le(i),T=N.entities,L=i.filter(o=>o.kind==="runtime-unit"),A=new Set(T.map(o=>o.id)),$=[...s].sort((o,w)=>{let b=Number(A.has(o.from)||A.has(o.to));return Number(A.has(w.from)||A.has(w.to))-b||o.id.localeCompare(w.id)}).slice(0,16),D=new Set([...T.flatMap(o=>o.proofIds),...$.flatMap(o=>o.proofIds)]),g=u.filter(o=>D.has(o.id)).sort((o,w)=>o.id.localeCompare(w.id)).slice(0,16);return {entityCount:i.length,relationCount:s.length,proofCount:u.length,entitiesByKind:m,relationsByKind:p,languages:Object.fromEntries(Object.entries(l).sort(([o],[w])=>o.localeCompare(w))),semantic:{protocolConceptCount:m.protocol??0,protocolImplementationBindings:p["implements-protocol"]??0,equivalenceBindings:p["equivalent-to"]??0,generationBindings:(p["generated-from"]??0)+(p["generated-by"]??0),runtimeUnitCount:L.length,lifecycleStageCount:m["lifecycle-stage"]??0,runtimeCoverage:[...new Set(L.map(o=>o.attributes.runtime).filter(o=>typeof o=="string"))].sort()},projection:{mode:"stratified-byte-bounded",maxEntities:te,byteBudget:oe,selectedBytes:N.selectedBytes,eligibleCount:i.length,selectedCount:T.length,omittedCount:Math.max(0,i.length-T.length),selectedByKind:Object.fromEntries(Object.entries(N.selectedByKind).sort(([o],[w])=>o.localeCompare(w))),omittedByKind:N.omittedByKind},relatedProjects:h,proofArtifacts:[...new Set(g.map(o=>o.artifact))].sort().slice(0,24),entities:T,relations:$,proofs:g,topology:{status:P.length>0||S.length>0?"proven":e.projectTopology.nodes.some(o=>o.id===t)?"unproven":"unavailable",dependencies:P,dependents:S},diagnostics:f}}function Ae(e,t,n){return Array.isArray(e)?e.map(r=>typeof r=="string"?I(r,t,n):r):typeof e=="string"?I(e,t,n):e}function Ge(e,t,n){return {id:e.id,kind:e.kind,label:I(e.label,t,n),attributes:Object.fromEntries(Object.entries(e.attributes).map(([r,s])=>[r,Ae(s,t,n)])),proofIds:[...e.proofIds].sort()}}function We(e,t,n){let r=(...a)=>e.filter(i=>a.includes(i.kind)).map(i=>Ge(i,t,n)).slice(0,4),s=[];for(let a of e){for(let[i,c]of Object.entries(a.attributes))if(/(?:^|[-_.])ports?(?:$|[-_.])/i.test(i)&&(s.push({entityId:a.id,label:I(a.label,t,n),attribute:i,value:Ae(c,t,n)}),s.length>=8))break;if(s.length>=8)break}return {services:r("service"),packages:r("package"),protocols:r("protocol"),runtimeUnits:r("runtime-unit"),lifecycleStages:r("lifecycle-stage"),apis:r("api"),endpoints:r("endpoint"),dataStores:r("database","queue"),deployments:r("container","deployment","environment"),pipelines:r("pipeline"),tests:r("test-suite"),owners:r("owner"),decisions:r("decision"),ports:s}}function Oe(e,t,n){let r=_(e.artifact,t,n);return r?{id:e.id,provider:e.provider,artifact:r,...e.pointer?{pointer:I(e.pointer,t,n)}:{},...e.line!==void 0?{line:e.line}:{},derivation:e.derivation,trust:e.trust,confidence:e.confidence,freshness:e.freshness}:null}async function Ke(e,t,n){let r=[],s=await E(d.join(e,".workspai","reports","INDEX.json"));if(Array.isArray(s?.blockers))for(let l of s.blockers)typeof l=="string"&&(l.startsWith(`${n}:`)||l.includes(`project:${n}`)||l.includes(`project ${n}`))&&r.push({source:"workspace-report-index",severity:"error",message:I(l,e,t)});let a=await E(d.join(e,".workspai","reports","doctor-project-last-run.json")),i=await E(d.join(e,".workspai","reports","doctor-last-run.json")),c=i?.projects?.find(l=>l.name===n),p=[...a?.project&&(a.projectName===n||a.project.name===n)?[{generatedAt:a.generatedAt,project:a.project}]:[],...c?[{generatedAt:i?.generatedAt,project:c}]:[]].sort((l,k)=>{let u=typeof l.generatedAt=="string"&&Date.parse(l.generatedAt)||0;return (typeof k.generatedAt=="string"&&Date.parse(k.generatedAt)||0)-u})[0];if(p)for(let l of c$1({project:p.project}))r.push({source:"doctor-project",severity:l.status==="blocking"?"error":"warning",message:I(l.message,e,t),...l.id?{code:l.id}:{}});return [...new Map(r.map(l=>[`${l.source}:${l.code??""}:${l.message}`,l])).values()].slice(0,32)}function re(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=>re(n,t)):e&&typeof e=="object"?Object.values(e).some(n=>re(n,t)):false}function _e(e){return be.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function Fe(e$1){let t=d.resolve(e$1.workspacePath),n=d.resolve(e$1.projectPath),r=u(n,"project.json").find(g=>ne.existsSync(g)),s=r?await E(r):null,a$1=await E(d.join(t,".workspai","workspace.contract.json")),i$1=d.resolve(n),c=a$1?.projects?.find(g=>g.externalPath?d.resolve(g.externalPath)===i$1:!g.relativePath||g.relativePath.startsWith("external/")?false:d.resolve(t,g.relativePath)===i$1)??a$1?.projects?.find(g=>g.slug===e$1.projectName||g.slug===d.basename(n)),m=e$1.projectName??(typeof s?.name=="string"?s.name:void 0)??c?.slug??d.basename(n),p=c?.relativePath??(()=>{let g=W(d.relative(t,n));return !g||g.startsWith("..")?`external/${m}`:g})(),l=await E(d.join(t,e.model)),k=await E(d.join(t,e.knowledgeGraph)),u$1=l?d$1(l):void 0,h=!!(u$1&&k?.source.hash===u$1),f=xe({model:l,projectName:m,relativePath:p}),j=$e(h?k:null,m),P=await Ke(t,n,m),S=j.proofs.map(g=>g.freshness),N=k?!h||S.includes("stale")?"stale":S.includes("unknown")?"unknown":"fresh":"missing",T=l?l.factFreshness?.status??"unknown":"missing",L=[...l?[]:[{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."}],...l&&!f?[{code:"project.context.project-not-materialized",severity:"warning",message:"The project is registered in the workspace contract but is not present in the current Workspace Model."}]:[],...k?[]:[{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."}],...k&&!h?[{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."}]:[]],A=Ee(s,e$1.relationship??c?.relationship??"managed"),$={schemaVersion:Ne,generatedAt:(e$1.now??new Date).toISOString(),workspace:{name:a$1?.workspace?.name??l?.workspace.name??d.basename(t),...a$1?.workspace?.profile||l?.workspace.profile?{profile:a$1?.workspace?.profile??l?.workspace.profile}:{},relationship:A,contract:`workspace:${i.workspaceContract}`,projectKnowledgeGraph:i.projectKnowledgeGraphReference,model:`workspace:${e.model}`,knowledgeGraph:`workspace:${e.knowledgeGraph}`,index:`workspace:${e.agentIndex}`,context:`workspace:${e.agentContext}`,skillsIndex:`workspace:${e.skillsIndex}`,boundedGraphSearch:`workspai workspace graph search <task-query> --scope project:${m} --limit 12 --json`,access:{localBinding:i.projectWorkspaceLink,canonicalEvidenceAvailableAtGeneration:true,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"}},project:{name:m,relativePath:p,...f?.kind?{kind:f.kind}:{},...f?.runtime||c?.runtime?{runtime:f?.runtime??c?.runtime}:{},...f?.runtimeCandidates?.length?{runtimeCandidates:[...f.runtimeCandidates].sort()}:{},...f?.framework||c?.framework?{framework:f?.framework??c?.framework}:{},...f?.kit||c?.kit?{kit:f?.kit??c?.kit}:{},...f?.supportTier?{supportTier:f.supportTier}:{},...f?.governance?{governance:f.governance}:{},commands:{supported:[...f?.commands.supported??[]].sort(),unsupported:[...f?.commands.unsupported??[]].sort(),fleetStages:[...f?.commands.fleetStages??[]].sort()},importantFiles:[...new Set((f?.importantFiles??[]).map(g=>_(g,t,n)).filter(g=>g!==null))].sort()},intelligence:{...l?.generatedAt?{modelGeneratedAt:l.generatedAt}:{},...k?.generatedAt?{graphGeneratedAt:k.generatedAt}:{},...k?.source.hash?{graphModelHash:k.source.hash}:{},entityCount:j.entityCount,relationCount:j.relationCount,proofCount:j.proofCount,entitiesByKind:j.entitiesByKind,relationsByKind:j.relationsByKind,languages:j.languages,semantic:j.semantic,projection:{...j.projection,continuationCommand:`workspai workspace graph search <task-query> --scope project:${m} --limit 12 --json`},relatedProjects:j.relatedProjects,freshness:{model:T,graph:N,graphMatchesModel:h},topology:{...j.topology,dependencies:j.topology.dependencies.map(g=>({...g,evidence:g.evidence.map(o=>_(o,t,n)).filter(o=>o!==null)})),dependents:j.topology.dependents.map(g=>({...g,evidence:g.evidence.map(o=>_(o,t,n)).filter(o=>o!==null)}))},surfaces:We(j.entities,t,n),diagnostics:[...L,...j.diagnostics].map(g=>({...g,message:I(g.message,t,n),...g.recommendation?{recommendation:I(g.recommendation,t,n)}:{}}))},evidence:{readOrder:[b,".workspai/PROJECT-GROUNDING.md",i.projectContextAgent,"AGENTS.md","workspace:.workspai/goals/index.json",`workspace:${i.goalPackLastRun}`,"workspace:.workspai/reports/workspace-skills-index.json",`command:workspai workspace graph search <task-query> --scope project:${m} --limit 12 --json`],projectProofArtifacts:[...new Set(j.proofArtifacts.map(g=>_(g,t,n)).filter(g=>g!==null))],relations:j.relations.map(g=>({id:g.id,from:g.from,to:g.to,kind:g.kind,derivation:g.derivation,trust:g.trust,confidence:g.confidence,proofIds:[...g.proofIds].sort()})),proofs:j.proofs.map(g=>Oe(g,t,n)).filter(g=>g!==null)},blockers:P,agentRouting:{enforcement:"required",mandatoryPreflight:{command:"workspai agent bootstrap --for-agent generic --strict --json",successCondition:"ready"},workspaceLocator:{command:"workspai project workspace status --json",successCondition:"resolved",outputClassification:"machine-local",persistence:"forbidden",disclosure:"forbidden",portableUriScheme:"workspace:"},workspaceEvidenceRequiredFor:["repository-analysis","architecture-analysis","change-impact","cross-project-change","contract-change","infrastructure-change","release-readiness"],requiredReadOrder:[b,"command:workspai agent bootstrap --for-agent generic --strict --json","command:workspai project workspace status --json",i.projectContextAgent,"workspace:.workspai/reports/workspace-skills-index.json",`command:workspai workspace graph search ${JSON.stringify(m)} --scope ${JSON.stringify(`project:${m}`)} --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(m)} --scope ${JSON.stringify(`project:${m}`)} --limit 12 --json`,doctor:"workspai doctor project --json",workspaceStatus:"workspai project workspace status --json"}};if(re($,[t,n]))throw new Error("Project context lens rejected a non-portable absolute path.");let D={...$,integrity:{algorithm:"sha256",...u$1?{modelHash:u$1}:{},payloadHash:_e($),portable:true,absolutePathsEmitted:false}};return a(D,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent"),D}function Be(e){let t=e.intelligence.relatedProjects.length>0?e.intelligence.relatedProjects.map(s=>`\`${s}\``).join(", "):"No proven cross-project relation is currently available.",n=e.intelligence.diagnostics.length>0?e.intelligence.diagnostics.slice(0,8).map(s=>`- **${s.severity} \xB7 ${s.code}:** ${s.message}`).join(`
|
|
2
|
-
`):"- No project-scoped graph diagnostic is currently recorded.",r=e.blockers.length>0?e.blockers.slice(0,12).map(s=>`- **${s.severity}${s.code?` \xB7 ${s.code}`:""}:** ${s.message}`).join(`
|
|
3
|
-
`):"- 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 \`${b}\` 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. Read the compact workspace Skills index and load only a matching playbook.
|
|
21
|
-
7. Query the bounded Workspace Graph with the user's actual task before opening broad
|
|
22
|
-
source, then inspect only returned proof paths and targeted live files.
|
|
23
|
-
|
|
24
|
-
Receipt policy:
|
|
25
|
-
|
|
26
|
-
- \`ready\`: continue with bounded evidence and targeted source inspection.
|
|
27
|
-
- \`degraded\`: disclose the limitation and do not claim complete architecture or verification.
|
|
28
|
-
- \`blocked\`: stop governed claims, execute \`nextActions\`, and rerun bootstrap.
|
|
29
|
-
|
|
30
|
-
## Workspace location and portable paths
|
|
31
|
-
|
|
32
|
-
- \`${e.workspace.name}\` is an identity, not a directory name to guess.
|
|
33
|
-
- Project-local paths begin with \`.workspai/\`.
|
|
34
|
-
- Canonical workspace paths begin with \`workspace:\`.
|
|
35
|
-
- Resolve the exact local workspace root only when direct file access is necessary by
|
|
36
|
-
running \`workspai project workspace status --json\` from this project.
|
|
37
|
-
- The resolver's absolute paths are machine-local runtime data. Never persist or copy
|
|
38
|
-
them into answers, shared logs, commits, prompts, telemetry, or portable artifacts.
|
|
39
|
-
|
|
40
|
-
## Authority boundary
|
|
41
|
-
|
|
42
|
-
The Workspace Model owns canonical project identity and its compact \`projectTopology\`.
|
|
43
|
-
The Workspace Knowledge Graph is a separate, proof-backed enrichment containing
|
|
44
|
-
files, symbols, APIs, infrastructure, tests, owners, and decisions. Do not treat
|
|
45
|
-
an unproven topology edge as proof that two projects are independent. Live source owns
|
|
46
|
-
exact implementation. CLI evidence owns Goal, readiness, repair, and verification claims.
|
|
47
|
-
Repository-authored instructions remain authoritative for source changes after this
|
|
48
|
-
entry gate; Workspai preserves rather than replaces them.
|
|
49
|
-
|
|
50
|
-
## Knowledge Graph routing
|
|
51
|
-
|
|
52
|
-
- Project graph reference: \`${e.workspace.projectKnowledgeGraph}\`. It integrity-binds
|
|
53
|
-
this project to its exact canonical projection without duplicating the full graph.
|
|
54
|
-
- Workspace aggregate: \`${e.workspace.knowledgeGraph}\`. Resolve it through the
|
|
55
|
-
workspace binding only for cross-project or workspace-wide consumption.
|
|
56
|
-
- Default agent path: use the bounded graph-search command below; resolve the canonical
|
|
57
|
-
graph only when the task explicitly requires full graph interchange.
|
|
58
|
-
|
|
59
|
-
## Project
|
|
60
|
-
|
|
61
|
-
- Name: \`${e.project.name}\`
|
|
62
|
-
- Workspace-relative identity: \`${e.project.relativePath}\`
|
|
63
|
-
- Runtime: \`${e.project.runtime??"unknown"}\`
|
|
64
|
-
- Framework: \`${e.project.framework??"unknown"}\`
|
|
65
|
-
- Relationship: \`${e.workspace.relationship}\`
|
|
66
|
-
- Related projects: ${t}
|
|
67
|
-
- Topology status: \`${e.intelligence.topology.status}\`
|
|
68
|
-
- Model freshness: \`${e.intelligence.freshness.model}\`
|
|
69
|
-
- Knowledge Graph freshness: \`${e.intelligence.freshness.graph}\`
|
|
70
|
-
|
|
71
|
-
## Current evidence coverage
|
|
72
|
-
|
|
73
|
-
- Project-scoped entities: ${e.intelligence.entityCount}
|
|
74
|
-
- Project-scoped relations: ${e.intelligence.relationCount}
|
|
75
|
-
- Portable proofs: ${e.intelligence.proofCount}
|
|
76
|
-
|
|
77
|
-
${n}
|
|
78
|
-
|
|
79
|
-
## Current project blockers
|
|
80
|
-
|
|
81
|
-
${r}
|
|
82
|
-
|
|
83
|
-
## Safe commands from this project
|
|
84
|
-
|
|
85
|
-
\`\`\`bash
|
|
86
|
-
${e.commands.workspaceStatus}
|
|
87
|
-
${e.commands.doctor}
|
|
88
|
-
${e.commands.graphSearch}
|
|
89
|
-
${e.commands.verify}
|
|
90
|
-
\`\`\`
|
|
91
|
-
|
|
92
|
-
The machine-local workspace binding lives only in
|
|
93
|
-
\`.workspai/workspace-link.local.json\`, which is gitignored. Portable grounding files
|
|
94
|
-
never publish its value.
|
|
95
|
-
`}function Me(e){return `# Workspai agent entry gate (mandatory)
|
|
96
|
-
|
|
97
|
-
- Project: \`${e.project.name}\`
|
|
98
|
-
- Workspace identity: \`${e.workspace.name}\` (logical name, not a filesystem path)
|
|
99
|
-
- Entry contract: \`${b}\`
|
|
100
|
-
|
|
101
|
-
Before broad repository discovery, architecture claims, planning, or mutation:
|
|
102
|
-
|
|
103
|
-
1. Read \`${b}\`.
|
|
104
|
-
2. Run \`workspai agent bootstrap --for-agent generic --strict --json\`.
|
|
105
|
-
3. Follow the receipt's \`requiredReadOrder\` exactly.
|
|
106
|
-
4. If a Goal is active, read its immutable Goal Pack and handoff before acting.
|
|
107
|
-
5. Read the compact workspace Skills index and load only a matching playbook.
|
|
108
|
-
6. Query the bounded Workspace Graph with the user's task, then inspect only returned proofs and targeted live source.
|
|
109
|
-
|
|
110
|
-
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.
|
|
111
|
-
|
|
112
|
-
\`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.
|
|
113
|
-
|
|
114
|
-
Authority: Workspai evidence owns identity, topology, goals, readiness, and verification. Live source and repository-authored rules own exact implementation and source conventions.`}function ke(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function q(e,t){return new RegExp(`${ke(e)}[\\s\\S]*?${ke(t)}`,"m")}function Ce(e){let t=e.replace(q(se,ve),"");return d$3(t)?.includes("# Workspai project boundary")&&(t=t.replace(q(a$1,b$1),"")),t.replace(/\n{3,}/g,`
|
|
115
|
-
|
|
116
|
-
`).trim()}function De(e,t){let n=Ce(e),r=`${se}
|
|
117
|
-
${t.trim()}
|
|
118
|
-
${ve}`;return n?`${r}
|
|
119
|
-
|
|
120
|
-
${n}
|
|
121
|
-
`:`${r}
|
|
122
|
-
`}async function x(e,t){await y.mkdir(d.dirname(e),{recursive:true});let n=`${e}.${process.pid}.${be.randomUUID()}.tmp`;try{await y.writeFile(n,t,"utf8");try{await y.rename(n,e);}catch(r){let s=r.code;if(s!=="EEXIST"&&s!=="EPERM")throw r;await X.move(n,e,{overwrite:true});}}finally{await y.rm(n,{force:true}).catch(()=>{});}}async function F(e,t){let n=d.resolve(e),r=await y.realpath(n).catch(()=>n),s=d.resolve(t),a=d.relative(n,s);if(!a||a===".."||a.startsWith(`..${d.sep}`)||d.isAbsolute(a))throw new Error("Project agent output path must remain inside the project.");let i=a.split(d.sep),c=n;for(let[m,p]of i.entries()){c=d.join(c,p);let l=await y.lstat(c).catch(u=>{if(u.code==="ENOENT")return null;throw u});if(!l)return d.join(c,...i.slice(m+1));let k=m===i.length-1;if(l.isSymbolicLink()){if(k)throw new Error(`Project agent output is blocked by authored state: ${a}`);let u=await y.realpath(c),h=d.relative(r,u),f=await y.stat(u);if(h===".."||h.startsWith(`..${d.sep}`)||d.isAbsolute(h)||!f.isDirectory())throw new Error(`Project agent output is blocked by authored state: ${a}`);c=u;continue}if(k?!l.isFile():!l.isDirectory())throw new Error(`Project agent output is blocked by authored state: ${a}`)}return c}async function kt(e$1){let t=d.join(e$1.projectPath,".agents","skills");try{await F(e$1.projectPath,d.join(t,"workspai-grounding","SKILL.md"));}catch{return []}let n=await E(d.join(e$1.workspacePath,e.skillsIndex)),r=new Set([B,...(n?.skills??[]).map(i=>`.agents/skills/${i.skillId}/SKILL.md`)]),s=await y.readdir(t,{withFileTypes:true}).catch(i=>{if(i.code==="ENOENT")return [];throw i});for(let i of s)i.isDirectory()&&i.name.startsWith("workspai-")&&r.add(`.agents/skills/${i.name}/SKILL.md`);let a=[];for(let i of r){let c=d.join(e$1.projectPath,i);a.push(await F(e$1.projectPath,c));}return a}function Je(e,t){let n=t?.skillId??"workspai-grounding",r=t?.title??"Workspai project grounding",s=t?`workspace:${t.path}`:null;return ["---",`name: ${n}`,`description: ${JSON.stringify(`${r} through the Workspai project intelligence contract`)}`,"---","",ee,"",`# ${r}`,"",`This is a portable project entry for \`${e.project.name}\`. It contains no machine-local workspace path.`,"","## Workflow","",`1. Read \`${b}\`.`,"2. Run `workspai agent bootstrap --for-agent generic --strict --json`.","3. Continue only when the receipt permits it and follow its bounded `requiredReadOrder`.",...s?[`4. Resolve and follow the canonical Skill \`${s}\` listed in \`workspace:.workspai/reports/workspace-skills-index.json\`.`,`5. Query the graph with \`workspai workspace graph search <task-query> --scope project:${e.project.name} --limit 12 --json\` before broad source inspection.`]:["4. Load only the matching canonical Skill from `workspace:.workspai/reports/workspace-skills-index.json`.",`5. Query the graph with \`workspai workspace graph search <task-query> --scope project:${e.project.name} --limit 12 --json\` before broad source inspection.`],"","Repository-authored instructions and live source remain authoritative for exact implementation.",""].join(`
|
|
123
|
-
`)}async function we(e$1){let t=d.join(e$1.projectPath,".agents","skills"),n=await E(d.join(e$1.workspacePath,e.skillsIndex)),r=e$1.context?[{relativePath:B,skill:void 0},...(n?.skills??[]).map(p=>({relativePath:`.agents/skills/${p.skillId}/SKILL.md`,skill:p}))]:[],s=new Set(r.map(p=>p.relativePath)),a=[],i=[],c=[];try{await F(e$1.projectPath,d.join(t,"workspai-grounding","SKILL.md"));}catch(p){return {availableFiles:a,writtenFiles:i,authoredCollisions:c,reason:String(p)}}if(e$1.mode==="managed"&&e$1.context)for(let p of r){let l=d.join(e$1.projectPath,p.relativePath),k=await F(e$1.projectPath,l),u=await y.readFile(k,"utf8").catch(f=>{if(f.code==="ENOENT")return "";throw f});if(u&&!u.includes(ee)){a.push(p.relativePath),c.push(p.relativePath);continue}let h=Je(e$1.context,p.skill);h!==u&&await x(k,h),a.push(p.relativePath),i.push(p.relativePath);}let m=await y.readdir(t,{withFileTypes:true}).catch(p=>{if(p.code==="ENOENT")return [];throw p});for(let p of m){if(!p.isDirectory()||!p.name.startsWith("workspai-"))continue;let l=`.agents/skills/${p.name}/SKILL.md`;if(e$1.mode==="managed"&&s.has(l))continue;let k=d.join(e$1.projectPath,l),u=await F(e$1.projectPath,k);(await y.readFile(u,"utf8").catch(()=>"")).includes(ee)&&await y.rm(d.dirname(u),{recursive:true,force:true});}return {availableFiles:a,writtenFiles:i,authoredCollisions:c}}async function Re(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 r=n.stdout.trim();if(!r)return false;let s,a;try{[s,a]=await Promise.all([y.realpath(d.resolve(r)),y.realpath(e)]);}catch{return false}let i=d.resolve(a,t),c=d.relative(s,i).replace(/\\/g,"/");if(!c||d.isAbsolute(c)||c===".."||c.startsWith("../"))return false;let m;try{m=await execa("git",["cat-file","-e",`HEAD:${c}`],{cwd:s,reject:false});}catch{return false}if(m?.exitCode!==0)return false;let p;try{p=await execa("git",["ls-files","--deleted","--error-unmatch","--",`:(top)${c}`],{cwd:s,reject:false});}catch{return false}return p?.exitCode===0}async function ye(e,t){let n=d.join(e,".gitignore"),r=await y.readFile(n,"utf8").catch(c=>{if(c.code==="ENOENT")return "";throw c}),s=[g$1,h$1,b],a=r.split(/\r?\n/).filter(c=>c.trim()!=="# Workspai local project grounding"&&!s.includes(c.trim()));for(;a.length>0&&a[a.length-1]==="";)a.pop();t==="local"&&(a.length>0&&a.push(""),a.push("# Workspai local project grounding",...s));let i=a.length>0?`${a.join(`
|
|
124
|
-
`)}
|
|
125
|
-
`:"";i!==r&&await x(n,i);}var M=[{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(M.length!==g.length||M.some((e,t)=>e.relativePath!==g[t]))throw new Error("Project agent adapter paths must match the portable entry contract.");async function Ue(e,t){let n=t.split("/").slice(0,-1),r=e;for(let s of n){r=d.join(r,s);let a=await y.lstat(r).catch(i=>{if(i.code==="ENOENT")return null;throw i});if(!a)return null;if(a.isSymbolicLink()||!a.isDirectory())return d.relative(e,r).split(d.sep).join("/")}return null}function qe(e){let t=e.agentsAvailable?e.adapter.importFromAgents:e.adapter.importFromGrounding;return t?`${t}
|
|
126
|
-
|
|
127
|
-
# Workspai host binding \xB7 ${e.adapter.host}
|
|
128
|
-
|
|
129
|
-
The imported Workspai entry gate is mandatory. Validate this host with
|
|
130
|
-
\`workspai agent bootstrap --for-agent ${e.adapter.host} --strict --json\`, then follow
|
|
131
|
-
the receipt's \`requiredReadOrder\`, Goal handoff, bounded Graph queries, proof paths,
|
|
132
|
-
status policy, workspace locator privacy policy, and authority boundary. Do not repeat
|
|
133
|
-
the imported instructions or replace repository-authored source rules.`:`# Workspai entry for ${e.adapter.host}
|
|
134
|
-
|
|
135
|
-
Before broad repository discovery, architecture claims, planning, or mutation:
|
|
136
|
-
|
|
137
|
-
1. Read \`${b}\`.
|
|
138
|
-
2. Run \`workspai agent bootstrap --for-agent ${e.adapter.host} --strict --json\`.
|
|
139
|
-
3. Follow \`requiredReadOrder\`, any active Goal handoff, bounded Graph queries, and returned proof paths.
|
|
140
|
-
|
|
141
|
-
Receipt policy: \`ready\` may proceed; \`degraded\` must disclose limitations; \`blocked\` must execute \`nextActions\` and rerun bootstrap before governed claims.
|
|
142
|
-
|
|
143
|
-
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 je(e){let t=await Ue(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),r=n,s=await y.lstat(n).catch(l=>{if(l.code==="ENOENT")return null;throw l});if(s?.isSymbolicLink()){let l=await Q(e.projectPath,n);if(!l)return {reason:`${e.adapter.relativePath} is a symbolic link without a safe repository-local file target.`};let k=await y.readFile(l,"utf8");if(e.agentsAvailable&&k.includes(se)){let h=`${k.replace(q(d$2,e$1),"").replace(/\n{3,}/g,`
|
|
144
|
-
|
|
145
|
-
`).trimEnd()}
|
|
146
|
-
`;return h!==k&&await x(l,h),{path:e.adapter.relativePath}}if(k.includes(d$2))return {path:e.adapter.relativePath};r=l;}let a=s?.isFile()===true,i=await y.readFile(r,"utf8").catch(l=>{if(l.code==="ENOENT")return "";throw l});if(e.mode==="managed"&&!a&&await Re(e.projectPath,e.adapter.relativePath))return {reason:`${e.adapter.relativePath} has an authored tracked deletion.`};let c=i.replace(q(d$2,e$1),"").replace(/\n{3,}/g,`
|
|
147
|
-
|
|
148
|
-
`).trim(),m=e.mode==="managed"?[c,`${d$2}
|
|
149
|
-
${qe(e).trim()}
|
|
150
|
-
${e$1}`].filter(Boolean).join(`
|
|
151
|
-
|
|
152
|
-
`):c;if(!m)return a&&!s?.isSymbolicLink()&&await y.rm(r,{force:true}),{};let p=`${m.trimEnd()}
|
|
153
|
-
`;return p!==i&&await x(r,p),e.mode==="managed"?{path:e.adapter.relativePath}:{}}function He(e){let t={id:"generic",discovery:"portable-fallback",entryFiles:[g$1],status:"ready",managed:e.mode==="managed"},r=["codex","kimi","grok","copilot","cursor","windsurf"].map(i=>({id:i,discovery:"native",entryFiles:["AGENTS.md",...["codex","kimi","grok"].includes(i)&&e.portableSkillsAvailable?[B]:[]],status:e.agentsAvailable?["codex","kimi","grok"].includes(i)&&!e.portableSkillsAvailable?"blocked":["codex","kimi","grok"].includes(i)&&e.portableGroundingAuthoredCollision?"degraded":"ready":"blocked",managed:e.mode==="managed"&&e.agentsAvailable&&(!["codex","kimi","grok"].includes(i)||e.portableSkillsAvailable&&!e.portableGroundingAuthoredCollision),...e.agentsAvailable?["codex","kimi","grok"].includes(i)&&!e.portableSkillsAvailable?{reason:e.portableSkillsReason??"The provider-neutral project Skill projection could not be generated safely."}:["codex","kimi","grok"].includes(i)&&e.portableGroundingAuthoredCollision?{reason:"An authored Skill occupies the Workspai grounding path; it was preserved and AGENTS.md remains the fallback entry."}:{}:{reason:"AGENTS.md could not be managed without overriding authored repository state."}})),s=M.map(i=>{let c=e.adapters.get(i.host);return {id:i.host,discovery:"adapter",entryFiles:[i.relativePath],status:c?.path?"ready":e.mode==="managed"?"blocked":"degraded",managed:!!c?.path,...c?.path?{}:{reason:c?.reason??"Provider adapter generation is disabled by the project grounding policy."}}}),a=[t,...r,...s];return f.map(i=>a.find(c=>c.id===i))}async function Pe(e,t,n){let r=d.join(e,"AGENTS.md"),s=await y.lstat(r).catch(l=>{if(l.code==="ENOENT")return null;throw l}),a=s?.isSymbolicLink()?await Q(e,r):r;if(!a)return;let i=s?.isFile()===true||s?.isSymbolicLink()===true,c=await y.readFile(a,"utf8").catch(l=>{if(l.code==="ENOENT")return "";throw l});if(t==="managed"&&!n)throw new Error("Managed project grounding requires a project context.");if(t==="managed"&&!i&&await Re(e,"AGENTS.md"))return;let m=t==="managed"&&n?De(c,Me(n)):Ce(c);if(!m){i&&!s?.isSymbolicLink()&&await y.rm(a,{force:true});return}let p=`${m.trimEnd()}
|
|
154
|
-
`;return p!==c&&await x(a,p),t==="managed"?r:void 0}async function ze(e){let t=e.mode??"managed",n=d.resolve(e.workspacePath),r=d.resolve(e.projectPath);if(t==="off"){let P=u(r,"project.json").find(A=>ne.existsSync(A)),S=P?await E(P):null,N=e.projectName??(typeof S?.name=="string"?S.name:void 0)??d.basename(r),T=Ee(S,e.relationship??"managed"),L=await c({workspacePath:n,projectPath:r,projectName:N,relationship:T,now:e.now});return await ye(r,t),await Pe(r,t),await we({workspacePath:n,projectPath:r,mode:t}),await Promise.all(M.map(A=>je({projectPath:r,adapter:A,mode:t,agentsAvailable:false}))),await Promise.all([y.rm(d.join(r,h$1),{force:true}),y.rm(d.join(r,g$1),{force:true}),y.rm(d.join(r,b),{force:true}),y.rm(d.join(r,i.projectKnowledgeGraphReference),{force:true})]),{mode:t,projectPath:r,linkPath:L.linkPath,writtenFiles:[i.projectWorkspaceLink]}}let s=await Fe(e),a=s.workspace.relationship,i$2=await c({workspacePath:n,projectPath:r,projectName:s.project.name,relationship:a,workspaceName:s.workspace.name,relativePath:s.project.relativePath,now:e.now});await ye(r,t);let c$1=await Pe(r,t,s),m=new Map;for(let P of M)m.set(P.host,await je({projectPath:r,adapter:P,mode:t,agentsAvailable:!!c$1}));let p=await we({workspacePath:n,projectPath:r,mode:t,context:s}),l=He({mode:t,agentsAvailable:!!c$1,portableSkillsAvailable:p.availableFiles.includes(B),portableGroundingAuthoredCollision:p.authoredCollisions.includes(B),...p.reason?{portableSkillsReason:p.reason}:{},adapters:m}),k=d.join(r,h$1),u$1=d.join(r,g$1),h=d.join(r,b),f=i$1({context:s,hosts:l});await x(k,`${JSON.stringify(s,null,2)}
|
|
155
|
-
`),await x(u$1,`${Be(s).trimEnd()}
|
|
156
|
-
`),await x(h,`${JSON.stringify(f,null,2)}
|
|
157
|
-
`);let j=[i.projectWorkspaceLink,h$1,g$1,b];c$1&&j.push("AGENTS.md");for(let P of m.values())P.path&&j.push(P.path);return j.push(...p.writtenFiles),{mode:t,projectPath:r,linkPath:i$2.linkPath,groundingPath:u$1,contextPath:k,agentEntryPath:h,agentsPath:c$1,hostCoverage:l,writtenFiles:j}}async function wt(e){let t=d.resolve(e.workspacePath),n=e.mode??"managed",r=await Ve(t),s=[],a=[];for(let i of r.resolved)try{s.push(await ze({workspacePath:t,projectPath:i.projectPath,projectName:i.name,relationship:i.relationship,mode:n,now:e.now}));}catch(c){a.push({name:i.name,reason:c instanceof Error?c.message:String(c)});}return {workspacePath:t,mode:n,projects:s,skipped:[...r.skipped,...a]}}async function Ve(e){let t=d.resolve(e),n=await E(d.join(t,".workspai","workspace.contract.json")),r=[],s=[];for(let a of n?.projects??[]){let i=a.slug??a.relativePath??"unknown-project",c=typeof a.externalPath=="string"?d.resolve(a.externalPath):typeof a.relativePath=="string"&&!a.relativePath.startsWith("external/")?d.resolve(t,a.relativePath):null;if(!c||!ne.existsSync(c)){s.push({name:i,reason:"project path is unavailable on this machine"});continue}r.push({name:i,projectPath:c,relationship:a.relationship??"managed"});}return {resolved:r,skipped:s}}export{Q as a,Ne as b,ft as c,se as d,ve as e,ee as f,B as g,Le as h,Fe as i,kt as j,ze as k,wt as l,Ve as m};
|
package/dist/chunk-UTV4DTNM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {u,e,k}from'./chunk-VQZ5PI5J.js';import T from'crypto';import p from'fs';import m from'os';import r from'path';var K="workspace-activity-event.v1",N=["run.started","run.completed","run.failed","run.cancelled","block.planned","block.started","block.progress","block.completed","block.failed","block.blocked","block.skipped","edge.declared","operation.started","operation.completed","operation.failed","touch.planned","touch.observed","artifact.published","artifact.rejected","warning.detected"],V=["planned","running","succeeded","warned","blocked","failed","cancelled","skipped","rolled-back"];var _=["package.json","pyproject.toml","go.mod","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","*.sln"];function l(t){try{return p.existsSync(t)}catch{return false}}function x(t,n){return n.some(e=>{if(e==="*.sln")try{return p.readdirSync(t).some(o=>o.toLowerCase().endsWith(".sln"))}catch{return false}return l(r.join(t,e))})}function I(t,n,e){let o=r.resolve(t),s=e?r.resolve(e):null;for(;;){if(n(o))return o;if(s&&o===s)return null;let a=r.dirname(o);if(a===o)return null;o=a;}}function j(t){for(let n of u(t,e))if(l(n))try{let e=JSON.parse(p.readFileSync(n,"utf8")),o=typeof e.workspace?.root=="string"?e.workspace.root:null;if(o&&k(r.resolve(o)))return r.resolve(o)}catch{}return null}function w(t=process.env){return t.WORKSPAI_ACTIVITY_STATE_DIR?r.resolve(t.WORKSPAI_ACTIVITY_STATE_DIR):process.platform==="win32"?r.join(t.LOCALAPPDATA||m.homedir(),"Workspai","activity"):process.platform==="darwin"?r.join(m.homedir(),"Library","Application Support","Workspai","activity"):r.join(t.XDG_STATE_HOME||r.join(m.homedir(),".local","state"),"workspai","activity")}function W(t,n){let e=r.resolve(n);try{e=p.realpathSync.native(e);}catch{}return process.platform==="win32"&&(e=e.toLowerCase()),`${t}-${T.createHash("sha256").update(e).digest("hex").slice(0,24)}`}function E(t){let n=r.resolve(t);try{n=p.realpathSync.native(n);}catch{}return process.platform==="win32"&&(n=n.toLowerCase()),`local-${T.createHash("sha256").update(n).digest("hex").slice(0,24)}`}function J(t=process.cwd(),n={}){let e=r.resolve(t),o=I(e,k),s=I(e,f=>l(r.join(f,".git"))||x(f,_),o??void 0),a=s?j(s):null,i=o??a??s??e,c=s??o??e,y=o||a?"workspace":s&&u(s,"project.json").some(l)?"project":"ephemeral-project",R=W(y,i),v=w(n.env),k$1=r.join(v,E(c)),A=r.join(v,E(i));return {rootPath:i,observationRootPath:c,statePath:k$1,mirrorStatePaths:A===k$1?[]:[A],scope:{kind:y,id:R,label:r.basename(i)||"project",portable:false}}}function U(t){let n=r.resolve(t.rootPath),e=r.resolve(t.observationRootPath);return {id:W("project",e),kind:e===n?"workspace-root":"project",label:r.basename(e)||t.scope.label}}function q(t,n){let e=r.resolve(n),o=r.relative(r.resolve(t),e);return o===""?".":!o.startsWith("..")&&!r.isAbsolute(o)?o.replaceAll("\\","/"):`<external>/${r.basename(e)}`}var P=200,O=14;function Q(t,n={}){let e=Math.max(10,n.maxRuns??P),o=Date.now()-Math.max(1,n.maxAgeDays??O)*24*60*60*1e3,s=[];try{s=p.readdirSync(t,{withFileTypes:true}).filter(i=>i.isFile()&&i.name.endsWith(".ndjson")).map(i=>{let c=r.join(t,i.name);return {path:c,mtimeMs:p.statSync(c).mtimeMs}}).sort((i,c)=>c.mtimeMs-i.mtimeMs);}catch{return 0}let a=0;for(let[i,c]of s.entries())if(!(i<e&&c.mtimeMs>=o))try{p.unlinkSync(c.path),a+=1;}catch{}return a}export{K as a,N as b,V as c,w as d,J as e,U as f,q as g,P as h,Q as i};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {e,i,d,a,b,c}from'./chunk-UTV4DTNM.js';import _ from'path';import B from'fs';var kt=64*1024,Et=1024*1024;function Jt(t){if(!t||typeof t!="object")return false;let e=t;return e.schemaVersion===a&&typeof e.eventId=="string"&&typeof e.runId=="string"&&Number.isInteger(e.sequence)&&Number(e.sequence)>0&&typeof e.timestamp=="string"&&!!e.scope&&typeof e.scope?.id=="string"&&typeof e.scope?.label=="string"&&["ephemeral-project","project","workspace"].includes(String(e.scope?.kind))&&typeof e.scope?.portable=="boolean"&&b.includes(e.kind)&&c.includes(e.status)&&(e.attempt===void 0||Number.isInteger(e.attempt)&&e.attempt>0)&&(e.origin===void 0||typeof e.origin.id=="string"&&typeof e.origin.label=="string"&&["project","workspace-root"].includes(e.origin.kind))&&typeof e.message=="string"}function Ct(t,e){try{let r=B.statSync(t).size,o;if(r<=kt+Et)o=B.readFileSync(t,"utf8");else {let n=B.openSync(t,"r");try{let s=Buffer.allocUnsafe(kt),a=Buffer.allocUnsafe(Et),i=B.readSync(n,s,0,s.length,0),c=Math.max(0,r-a.length),d=B.readSync(n,a,0,a.length,c),u=s.subarray(0,i).toString("utf8"),l=a.subarray(0,d).toString("utf8"),p=l.indexOf(`
|
|
2
|
-
`),f=p>=0?l.slice(p+1):"";o=`${u.endsWith(`
|
|
3
|
-
`)?u:`${u}
|
|
4
|
-
`}${f}`,e.push(`Bounded replay window applied to ${_.basename(t)}.`);}finally{B.closeSync(n);}}return o.split(/\r?\n/).filter(Boolean).flatMap(n=>{try{let s=JSON.parse(n);return Jt(s)?[s]:[]}catch{return e.push(`Ignored an incomplete activity record in ${_.basename(t)}.`),[]}})}catch(r){return e.push(`Unable to read ${_.basename(t)}: ${r instanceof Error?r.message:String(r)}`),[]}}function Kt(t,e,r){let o=e.get(t.fromBlockId),n=e.get(t.toBlockId);return !o||!n?"planned":n.status!=="planned"?n.status:r!=="running"&&r!=="planned"?"skipped":o.status==="succeeded"||o.status==="warned"?"running":o.status==="failed"?"failed":o.status==="blocked"?"blocked":o.status==="cancelled"?"cancelled":"planned"}function gt(t){let e$1=e(t.targetPath??process.cwd(),{env:t.env}),r=[],o=_.join(e$1.statePath,"runs"),n=[];try{n=B.readdirSync(o,{withFileTypes:true}).filter(i=>i.isFile()&&i.name.endsWith(".ndjson")).map(i=>{let c=_.join(o,i.name);return {name:i.name,mtimeMs:B.statSync(c).mtimeMs}}).sort((i,c)=>c.mtimeMs-i.mtimeMs);}catch(i){i.code!=="ENOENT"&&r.push(i instanceof Error?i.message:String(i));}t.runId&&(n=n.filter(i=>i.name===`${t.runId}.ndjson`)),n=n.slice(0,Math.max(1,t.maxRuns??25));let s=n.flatMap(i=>Ct(_.join(o,i.name),r)).sort((i,c)=>i.timestamp.localeCompare(c.timestamp)||i.sequence-c.sequence),a=Math.max(100,t.maxEvents??2e4);return {resolvedScope:e$1,events:s.slice(-a),diagnostics:r}}function yt(t){let e=new Map,r=new Map,o=new Map;for(let n of t.events){let s=e.get(n.runId);if(!s){let a=Array.isArray(n.attributes?.command)?n.attributes.command.filter(i=>typeof i=="string"):[];s={runId:n.runId,...n.parentRunId?{parentRunId:n.parentRunId}:{},...Number.isInteger(Number(n.attributes?.pid))&&Number(n.attributes?.pid)>0?{pid:Number(n.attributes?.pid)}:{},...n.origin?{origin:n.origin}:{},command:a,status:n.status,startedAt:n.timestamp,updatedAt:n.timestamp,blocks:[],edges:[],touches:[],artifacts:[],warnings:[]},e.set(n.runId,s),r.set(n.runId,new Map),o.set(n.runId,new Map);}if(s.updatedAt=n.timestamp,n.kind.startsWith("run.")){if(s.status=n.status,n.kind==="run.started"&&Array.isArray(n.attributes?.command)){let i=n.attributes?.command;s.command=i.filter(c=>typeof c=="string");}let a=Number(n.attributes?.pid);n.kind==="run.started"&&Number.isInteger(a)&&a>0&&(s.pid=a),n.origin&&(s.origin=n.origin),n.durationMs!==void 0&&(s.durationMs=n.durationMs);}if(n.blockId&&n.kind.startsWith("block.")){let a=r.get(n.runId),i=a.get(n.blockId),c=Number(n.attributes?.order),d=i?.attempt??0,u=n.kind==="block.planned"||n.kind==="block.skipped"&&d===0?void 0:n.kind==="block.started"&&i?.status!=="running"?d+1:Math.max(1,d),l=n.attempt??u,p=[...i?.attempts??[]];if(l!==void 0){let f=p.findIndex(h=>h.attempt===l),m=f>=0?p[f]:void 0,v={attempt:l,status:n.status,startedAt:m?.startedAt??n.timestamp,updatedAt:n.timestamp,...n.progress?{progress:n.progress}:m?.progress?{progress:m.progress}:{},...n.durationMs!==void 0?{durationMs:n.durationMs}:m?.durationMs!==void 0?{durationMs:m.durationMs}:{}};f>=0?p[f]=v:p.push(v);}a.set(n.blockId,{id:n.blockId,label:n.kind==="block.planned"||!i?n.message||n.blockId:i.label,status:n.status,order:Number.isFinite(c)?c:i?.order??a.size+1,...n.parentSpanId?{parentId:n.parentSpanId}:i?.parentId?{parentId:i.parentId}:{},...n.progress?{progress:n.progress}:i?.progress?{progress:i.progress}:{},...n.durationMs!==void 0?{durationMs:n.durationMs}:i?.durationMs!==void 0?{durationMs:i.durationMs}:{},...typeof n.attributes?.layoutHint=="string"?{layoutHint:n.attributes.layoutHint}:i?.layoutHint?{layoutHint:i.layoutHint}:{},...typeof n.attributes?.group=="string"?{group:n.attributes.group}:i?.group?{group:i.group}:{},updatedAt:n.timestamp,...l!==void 0?{attempt:l}:i?.attempt?{attempt:i.attempt}:{},attempts:p});}if(n.kind==="edge.declared"&&n.edge){let a=o.get(n.runId),i=Number(n.attributes?.order);a.set(n.edge.id,{id:n.edge.id,fromBlockId:n.edge.fromBlockId,toBlockId:n.edge.toBlockId,kind:n.edge.kind,status:"planned",order:Number.isFinite(i)?i:a.size+1,updatedAt:n.timestamp});}(n.kind==="touch.observed"||n.kind==="touch.planned")&&(s.touches.push({locator:n.target?.locator??n.message,...n.target?.operation?{operation:n.target.operation}:{},at:n.timestamp}),s.touches=s.touches.slice(-20)),n.kind==="artifact.published"&&(s.artifacts.push({locator:n.target?.locator??n.message,at:n.timestamp}),s.artifacts=s.artifacts.slice(-20)),n.kind==="warning.detected"&&(s.warnings.push(n.message),s.warnings=s.warnings.slice(-20));}for(let[n,s]of e){s.blocks=[...r.get(n)?.values()??[]].sort((i,c)=>i.order-c.order||i.id.localeCompare(c.id));let a=r.get(n)??new Map;s.edges=[...o.get(n)?.values()??[]].map(i=>({...i,status:Kt(i,a,s.status),updatedAt:a.get(i.toBlockId)?.updatedAt??a.get(i.fromBlockId)?.updatedAt??i.updatedAt})).sort((i,c)=>i.order-c.order||i.id.localeCompare(c.id));}return {schemaVersion:"workspace-activity-monitor-snapshot.v1",generatedAt:new Date().toISOString(),scope:t.resolvedScope.scope,runs:[...e.values()].sort((n,s)=>s.updatedAt.localeCompare(n.updatedAt)),diagnostics:[...t.diagnostics??[]]}}function Tt(t){let e=Math.max(0,Math.min(t.events.length,Math.floor(t.eventCount)));return yt({resolvedScope:t.resolvedScope,events:t.events.slice(0,e),diagnostics:t.diagnostics})}function Xt(t){try{return process.kill(t,0),true}catch(e){return e.code==="EPERM"}}function Bt(t,e=Xt){return {...t,runs:t.runs.map(r=>{if(r.status!=="running"||!r.pid||e(r.pid))return r;let o=Date.parse(r.updatedAt),n=Date.parse(r.startedAt);return {...r,status:"cancelled",orphaned:true,durationMs:Number.isFinite(o)&&Number.isFinite(n)?Math.max(0,o-n):r.durationMs,blocks:r.blocks.map(s=>({...s,status:s.status==="running"?"cancelled":s.status==="planned"?"skipped":s.status,attempts:s.attempts.map((a,i,c)=>i===c.length-1&&a.status==="running"?{...a,status:"cancelled"}:a)})),edges:r.edges.map(s=>({...s,status:s.status==="running"?"cancelled":s.status==="planned"?"skipped":s.status}))}})}}function Qt(t){let e=[];try{e=B.readdirSync(t.stateHome,{withFileTypes:true}).filter(i=>i.isDirectory()).flatMap(i=>{let c=_.join(t.stateHome,i.name,"runs");try{return [{path:c,mtimeMs:B.statSync(c).mtimeMs}]}catch{return []}}).sort((i,c)=>c.mtimeMs-i.mtimeMs).slice(0,Math.min(200,Math.max(16,t.maxScopes*4)));}catch(i){i.code!=="ENOENT"&&t.diagnostics.push(i instanceof Error?i.message:String(i));}let r=e.flatMap(i=>{try{return B.readdirSync(i.path,{withFileTypes:true}).filter(c=>c.isFile()&&c.name.endsWith(".ndjson")&&(!t.runId||c.name===`${t.runId}.ndjson`)).map(c=>{let d=_.join(i.path,c.name);return {filePath:d,mtimeMs:B.statSync(d).mtimeMs}})}catch{return []}}).sort((i,c)=>c.mtimeMs-i.mtimeMs).slice(0,Math.max(t.maxRuns*4,t.maxScopes*2)),o=new Map;for(let i of r)for(let c of Ct(i.filePath,t.diagnostics))o.has(c.eventId)||o.set(c.eventId,c);let n=[...o.values()].sort((i,c)=>i.timestamp.localeCompare(c.timestamp)||i.sequence-c.sequence),s=[...new Set([...n].reverse().map(i=>i.runId))].slice(0,t.maxRuns),a=new Set(s);return n.filter(i=>a.has(i.runId))}function Lt(t={}){let e=[],r=Math.max(1,Math.min(100,t.maxRuns??12)),o=Math.max(1,Math.min(50,t.maxScopes??12)),n=Qt({stateHome:d(t.env),runId:t.runId,maxRuns:r,maxScopes:o,diagnostics:e}),s=Math.max(100,Math.min(5e5,t.maxEvents??5e4));n=n.slice(-s);let a=new Map;for(let c of n){let d=a.get(c.scope.id)??{scope:c.scope,events:[]};d.events.push(c),a.set(c.scope.id,d);}let i=[...a.values()].map(c=>Bt(yt({resolvedScope:{scope:c.scope},events:c.events}))).sort((c,d)=>(d.runs[0]?.updatedAt??"").localeCompare(c.runs[0]?.updatedAt??"")||c.scope.label.localeCompare(d.scope.label)).slice(0,o);return {schemaVersion:"workspace-activity-monitor-fleet.v1",generatedAt:new Date().toISOString(),scopes:i,diagnostics:e}}function Pt(t={}){let e=gt(t);return Bt(yt({resolvedScope:e.resolvedScope,events:e.events,diagnostics:e.diagnostics}))}function Ot(t={}){let e$1=e(t.targetPath??process.cwd(),{env:t.env}),r=_.join(e$1.statePath,"runs");return i(r,{maxRuns:t.maxRuns,maxAgeDays:t.maxAgeDays})}var Zt=new Set(["planned","running"]);function te(t){return Zt.has(t)}function ee(t){return t.command.length>0?`workspai ${t.command.join(" ")}`:`run ${t.runId.slice(0,8)}`}function ne(t){return t.slice(1).map((e,r)=>{let o=t[r];return {id:`inferred:${o.id}->${e.id}`,fromBlockId:o.id,toBlockId:e.id,kind:e.layoutHint==="gate"?"gate":e.layoutHint==="sink"?"handoff":"sequence",status:re(o.status,e.status),order:r+1,updatedAt:e.updatedAt,inferred:true}})}function re(t,e){return e!=="planned"?e:t==="succeeded"||t==="warned"?"running":t==="failed"||t==="blocked"||t==="cancelled"?t:"planned"}function ie(t,e,r){let o=[...t.blocks].sort((i,c)=>i.order-c.order||i.id.localeCompare(c.id)),n=o.some(i=>i.parentId),s=o.filter(i=>!n||!!i.parentId).map(i=>({...i,root:!i.parentId})),a=t.edges.length>0?t.edges.map(i=>({...i,inferred:false})):ne(s);return {run:t,commandLabel:ee(t),active:t.status==="running",nodes:s,edges:a,activeBlockCount:s.filter(i=>i.status==="running").length,warningCount:t.warnings.length+s.filter(i=>i.status==="warned").length,scope:e,locationLabel:t.origin&&(t.origin.label!==e.label||r.originLabel!==t.origin.label)?`${r.scopeLabel}/${r.originLabel}`:r.scopeLabel}}function D(t,e={}){let r=Math.max(1,e.maxRuns??6),o=t.schemaVersion==="workspace-activity-monitor-fleet.v1",n=o?t.scopes:[t],s=new Map,a=new Map;for(let u of n){let l=s.get(u.scope.label)??new Set;l.add(u.scope.id),s.set(u.scope.label,l);for(let p of u.runs){if(!p.origin)continue;let f=`${u.scope.id}\0${p.origin.label}`,m=a.get(f)??new Set;m.add(p.origin.id),a.set(f,m);}}let i=n.flatMap(u=>u.runs.map(l=>{let p=(s.get(u.scope.label)?.size??0)>1?`${u.scope.label}#${u.scope.id.slice(-4)}`:u.scope.label,f=l.origin?`${u.scope.id}\0${l.origin.label}`:void 0,m=l.origin?(a.get(f??"")?.size??0)>1?`${l.origin.label}#${l.origin.id.slice(-4)}`:l.origin.label:void 0;return ie(l,u.scope,{scopeLabel:p,originLabel:m})})).sort((u,l)=>u.active!==l.active?u.active?-1:1:l.run.updatedAt.localeCompare(u.run.updatedAt)),c=(e.activeOnly?i.filter(u=>u.active):i).slice(0,r),d=c.find(u=>u.run.runId===e.selectedRunId)?.run.runId??c.find(u=>u.active)?.run.runId??c[0]?.run.runId;return {scopeLabel:o?"Global activity":n[0]?.scope.label??"activity",generatedAt:t.generatedAt,activeRunCount:i.filter(u=>u.active).length,healthyRunCount:i.filter(u=>u.run.status==="succeeded").length,warningRunCount:i.filter(u=>u.run.status==="warned"||u.warningCount>0).length,failedRunCount:i.filter(u=>u.run.status==="failed").length,...d?{selectedRunId:d}:{},runs:c,diagnostics:o?[...t.diagnostics,...n.flatMap(u=>u.diagnostics)]:t.diagnostics,global:o,scopeCount:n.length}}function F(t,e,r){return t.edges.find(o=>o.fromBlockId===e&&o.toBlockId===r)}function Nt(t){return t.runs.map(e=>e.run.runId)}function Wt(t){return t.runs.some(e=>e.active||e.nodes.some(r=>te(r.status))||e.edges.some(r=>r.status==="running"))}var P={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",cyan:"\x1B[36m",brightCyan:"\x1B[96m",green:"\x1B[32m",yellow:"\x1B[33m",red:"\x1B[31m",magenta:"\x1B[35m"},oe={planned:"\u25CB",running:"\u25C9",succeeded:"\u2713",warned:"!",blocked:"\u2298",failed:"\xD7",cancelled:"\xD7",skipped:"\u2013","rolled-back":"\u21B6"},se={planned:"o",running:"*",succeeded:"+",warned:"!",blocked:"#",failed:"x",cancelled:"x",skipped:"-","rolled-back":"~"};function ht(t){return t.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g,"")}function L(t){return ht(t).replace(/[\u0000-\u001f\u007f-\u009f]/g," ")}function N(t){return [...ht(t)].length}function W(t,e){let r=L(t),o=[...r];return o.length<=e?r:e<=0?"":e===1?"\u2026":`${o.slice(0,e-1).join("")}\u2026`}function x(t,e){return N(t)<=e?t:W(ht(t),e)}function ae(t,e){return t==="running"?e%2===0?P.brightCyan:P.cyan:t==="succeeded"?P.green:t==="warned"||t==="blocked"?P.yellow:t==="failed"||t==="cancelled"?P.red:t==="rolled-back"?P.magenta:P.dim}function O(t,e,r,o){return r?`${ae(e,o)}${t}${P.reset}`:t}function X(t,e){return e?`${P.bold}${P.brightCyan}${t}${P.reset}`:t}function U(t,e){return (e?se:oe)[t]}function ot(t,e){let r=t.durationMs??Math.max(0,e-Date.parse(t.startedAt));if(r<1e3)return `${r}ms`;let o=Math.floor(r/1e3);if(o<60)return `${o}s`;let n=Math.floor(o/60);return n<60?`${n}m ${o%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function H(t){let e=t.progress;return e?e.percent!==void 0?`${Math.round(e.percent)}%`:e.completed!==void 0&&e.total!==void 0?`${e.completed}/${e.total}`:e.iteration!==void 0&&e.iterations!==void 0?`${e.iteration}/${e.iterations}`:"":""}function Q(t,e){return t.attempt&&t.attempt>1?`${e?"R":"\u21BB"}${t.attempt}`:""}function jt(t,e,r){let o=N(t),n=N(e);return o+n+1>r?x(`${t} ${e}`,r):`${t}${" ".repeat(r-o-n)}${e}`}var st={planned:"QUEUE",running:"RUN",succeeded:"DONE",warned:"WARN",blocked:"BLOCK",failed:"FAIL",cancelled:"STOP",skipped:"SKIP","rolled-back":"ROLL"};function it(t,e,r,o){return o?"+":r?{left:"\u252B",right:"\u2523",top:"\u253B",bottom:"\u2533"}[t]:e==="planned"||e==="skipped"?{left:"\u2524",right:"\u251C",top:"\u2534",bottom:"\u252C"}[t]:{left:"\u2525",right:"\u251D",top:"\u2537",bottom:"\u252F"}[t]}function ce(t,e,r){let o=W(e,Math.max(3,Math.floor(r*.6))),n=Math.max(0,r-N(o)-(o?1:0)),s=W(t,n);return `${s}${" ".repeat(Math.max(0,r-N(s)-N(o)))}${o}`}function Vt(t,e,r,o,n){let s=Array.from({length:Math.max(0,o-2)},()=>r);return n&&s.length>0&&(s[Math.floor(s.length/2)]=n),`${t}${s.join("")}${e}`}function de(t,e,r,o){let n=t.status==="running",s=r.ascii?{topLeft:"+",topRight:"+",bottomLeft:"+",bottomRight:"+",horizontal:"-",vertical:"|"}:n?{topLeft:"\u250F",topRight:"\u2513",bottomLeft:"\u2517",bottomRight:"\u251B",horizontal:"\u2501",vertical:"\u2503"}:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502"},a=H(t),i=Q(t,r.ascii),c=[st[t.status],i,a].filter(Boolean).join(" "),d=Vt(s.topLeft,s.topRight,s.horizontal,e,o.top?it("top",o.top,n,r.ascii):void 0),u=`${o.left?it("left",o.left,n,r.ascii):s.vertical}${ce(L(t.label),c,e-2)}${o.right?it("right",o.right,n,r.ascii):s.vertical}`,l=Vt(s.bottomLeft,s.bottomRight,s.horizontal,e,o.bottom?it("bottom",o.bottom,n,r.ascii):void 0);return [d,u,l].map(p=>O(p,t.status,r.color,r.frame))}function ue(t,e,r,o,n,s){let a=Math.max(2,s),i=n?"-":"\u2501",c=n?".":"\u2504";if(t==="running"&&o){let d=n?"=":"\u254D",u=Array.from({length:a},()=>i),l=r%a;return u[e==="right"?l:a-l-1]=d,u.join("")}return t==="planned"||t==="skipped"?c.repeat(a):t==="blocked"||t==="warned"?(n?"~":"\u2505").repeat(a):t==="failed"||t==="cancelled"?(n?"=":"\u254D").repeat(a):i.repeat(a)}function _t(t,e,r,o=7){return t?O(ue(t.status,e,r.frame,r.motion,r.ascii,o),t.status,r.color,r.frame):" ".repeat(o)}function le(t,e,r,o){let n=t?.status??"planned",s=n==="running"&&o.motion,a=n==="planned"||n==="skipped"?o.ascii?":":"\u250A":n==="blocked"||n==="warned"?o.ascii?"~":"\u250B":o.ascii?"|":"\u2503",i=o.ascii?":":"\u254F";return [s&&o.frame%2===0?i:a,s&&o.frame%2===1?i:a].map(d=>O(`${" ".repeat(Math.max(0,e))}${d}`.padEnd(r),n,o.color,o.frame))}function pe(t,e,r){let o=e>=132?9:7,n=t.nodes.length<=2?Math.min(32,e):e>=132?19:e>=100?17:15,s=Math.max(1,Math.floor((e+o)/(n+o))),a=[];for(let c=0;c<t.nodes.length;c+=s)a.push(t.nodes.slice(c,c+s));let i=[];return a.forEach((c,d)=>{let u=d%2===0?"right":"left",l=u==="right"?c:[...c].reverse(),p=a[d+1],f=a[d-1],m=f?F(t,f.at(-1)?.id??"",c[0]?.id??""):void 0,v=p?F(t,c.at(-1)?.id??"",p[0]?.id??""):void 0,h=(y,S)=>u==="right"?F(t,y.id,S.id):F(t,S.id,y.id),E=l.map((y,S)=>{let b=S>0?h(l[S-1],y):void 0,M=S<l.length-1?h(y,l[S+1]):void 0;return de(y,n,r,{...b?{left:b.status}:{},...M?{right:M.status}:{},...m&&y.id===c[0]?.id?{top:m.status}:{},...v&&y.id===c.at(-1)?.id?{bottom:v.status}:{}})});for(let y=0;y<3;y+=1){let S="";l.forEach((b,M)=>{if(S+=E[M][y],M>=l.length-1)return;if(y!==1){S+=" ".repeat(o);return}let k=l[M+1],$=u==="right"?F(t,b.id,k.id):F(t,k.id,b.id);S+=_t($,u,r,o);}),i.push(x(S,e));}if(!p)return;let I=v,w=l.length*n+(l.length-1)*o,T=u==="right"?Math.max(0,w-Math.ceil(n/2)):Math.floor(n/2);i.push(...le(I,T,e,r));}),i}function me(t,e){let r=H(t),o=Q(t,e.ascii),n=`${U(t.status,e.ascii)} ${L(t.label)}${o?` ${o}`:""}${r?` ${r}`:""}`;return O(`[${n}]`,t.status,e.color,e.frame)}function fe(t,e,r,o){if(t.nodes.length===0)return [];let n=[],s="",a=0;for(let[i,c]of t.nodes.entries()){let d=me(c,o),u=t.nodes[i-1],l=u?F(t,u.id,c.id):void 0,p=u?_t(l,"right",o,7):"",f=`${s?p:""}${d}`;if(s&&N(s)+N(f)>e){if(n.push(x(s,e)),n.length>=r)break;s=`${o.ascii?"> ":"\u21B3 "}${d}`;}else s+=f;a=i+1;}if(n.length<r&&s&&n.push(x(s,e)),a<t.nodes.length&&n.length>0){let i=` \u2026 +${t.nodes.length-a}`;n[n.length-1]=x(`${n.at(-1)}${i}`,e);}return n.slice(0,r)}function ge(t,e,r,o){if(t.length===0)return;let n=e>=130?3:e>=92?2:1,s=t.slice(0,n),a="ALSO ACTIVE ",i=s.map(d=>{let u=W(d.commandLabel.replace(/^workspai\s+/,""),24),l=o?`${W(d.locationLabel,20)} \xB7 `:"";return O(`[${U("running",r.ascii)} ${l}${u} \xB7 ${d.run.runId.slice(0,8)}]`,"running",r.color,r.frame)}),c=t.length-s.length;return x(`${a}${i.join(" ")}${c>0?` +${c}`:""}`,e)}function ye(t){let e=t.map(r=>r.status);for(let r of ["failed","cancelled","blocked","warned","running"])if(e.includes(r))return r;return e.length>0&&e.every(r=>r==="succeeded")?"succeeded":e.some(r=>r==="succeeded")?"running":e[0]??"planned"}function he(t,e,r){let o=[...new Set(t.nodes.map(a=>a.group).filter(Boolean))];if(o.length<2)return;let n=r.ascii?" > ":" \u2501 ",s=o.map((a,i)=>{let c=ye(t.nodes.filter(d=>d.group===a));return O(`${String(i+1).padStart(2,"0")} ${W(a,14)}`,c,r.color,r.frame)});return x(`PHASES ${s.join(n)}`,e)}function Dt(t){return [...t.nodes].reverse().find(e=>e.status==="running")??[...t.nodes].reverse().find(e=>["failed","blocked","warned","cancelled"].includes(e.status))??[...t.nodes].sort((e,r)=>r.updatedAt.localeCompare(e.updatedAt))[0]}function ve(t){if(t<1e3)return `${t}ms`;let e=Math.floor(t/1e3);if(e<60)return `${e}s`;let r=Math.floor(e/60);return r<60?`${r}m ${e%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function be(t,e,r,o){let n=Dt(t);if(!n||e<24)return [];let s=o.ascii?"-":"\u2500",a=o.ascii?"|":"\u2502",i=e-2,c=n.attempt??0,d=n.attempts.at(-1)?.startedAt??n.updatedAt,u=n.durationMs??(n.status==="running"?Math.max(0,r-Date.parse(d)):void 0),l=[X("INSPECT",o.color),L(n.label),"",`STATE ${st[n.status]}`,`PHASE ${n.group??"GENERAL"}`,`ATTEMPT ${c>0?`${c}/${Math.max(c,n.attempts.length)}`:"\u2014"}`,`PROGRESS ${H(n)||"\u2014"}`,`ELAPSED ${u===void 0?"\u2014":ve(u)}`,"",`TOUCHES ${t.run.touches.length}`,`ARTIFACTS ${t.run.artifacts.length}`,`WARNINGS ${t.warningCount}`],p=o.ascii?{tl:"+",tr:"+",bl:"+",br:"+"}:{tl:"\u250C",tr:"\u2510",bl:"\u2514",br:"\u2518"};return [`${p.tl}${s.repeat(i)}${p.tr}`,...l.map(f=>{let m=x(f,i);return `${a}${m}${" ".repeat(Math.max(0,i-N(m)))}${a}`}),`${p.bl}${s.repeat(i)}${p.br}`]}function Ae(t,e,r,o=3){return Array.from({length:Math.max(t.length,e.length)},(n,s)=>{let a=x(t[s]??"",r);return `${a}${" ".repeat(Math.max(0,r-N(a))+o)}${e[s]??""}`})}function $e(t,e,r,o,n){let s=[...t.runs.filter(p=>p.active),...t.runs.filter(p=>!p.active&&p.run.runId===e)].filter((p,f,m)=>m.findIndex(v=>v.run.runId===p.run.runId)===f);if(s.length===0)return [];let a=s.slice(0,r>=110?4:2),i=Math.max(12,Math.min(28,Math.floor(r*.24))),c=Math.max(14,Math.min(30,Math.floor(r*.27))),d=Math.max(10,Math.min(20,Math.floor(r*.18))),u=`FLEET ${"LOCATION".padEnd(i)} ${"COMMAND".padEnd(c)} ${"ACTIVE BLOCK".padEnd(d)} STATE`,l=[X(x(u,r),n.color)];for(let p of a){let f=Dt(p),m=p.run.runId===e?n.ascii?">":"\u25C6":" ",v=p.commandLabel.replace(/^workspai\s+/,""),h=`${m} ${W(p.locationLabel,i).padEnd(i)} ${W(v,c).padEnd(c)} ${W(f?.label??"\u2014",d).padEnd(d)} ${st[p.run.status]} \xB7 ${ot(p.run,o)}`;l.push(O(x(h,r),p.run.status,n.color,n.frame));}return s.length>a.length&&l.push(x(` +${s.length-a.length} more runs`,r)),l}function xe(t,e,r,o,n,s){let a=n.ascii?">":"\u25C6",i=s?`${W(t.locationLabel,28)} `:"",c=`RUN ${t.run.runId.slice(0,8).toUpperCase()} ${i}${L(t.commandLabel)}`,d=t.warningCount>0?` \xB7 !${t.warningCount}`:"",u=`${st[t.run.status]} \xB7 ${ot(t.run,o)}${d}`,l=O(jt(c,u,Math.max(0,r-2)),t.run.status,n.color,n.frame);return `${X(a,n.color)} ${l}`}function Se(t,e,r){let o=[x(`Workspai Live | ${L(t.scopeLabel)} | ${t.activeRunCount} active | ${t.failedRunCount} failed`,e)];t.runs.length===0&&o.push("WAITING");for(let n of t.runs){o.push(x(`RUN ${n.run.status.toUpperCase()} | ${L(n.commandLabel)} | ${n.run.runId.slice(0,8)} | ${ot(n.run,r)}`,e));for(let s of n.nodes)o.push(x(` BLOCK ${s.status.toUpperCase()} | ${L(s.label)}${Q(s,true)?` | ATTEMPT ${s.attempt}`:""}${H(s)?` | ${H(s)}`:""}`,e));}return o.join(`
|
|
5
|
-
`)}function Y(t,e={}){if(e.classic)return Me(t,e);let r=Math.max(20,e.width??process.stdout.columns??100),o=Math.max(1,e.height??process.stdout.rows??28),n=e.now??Date.now(),s=e.frame??0,a=e.ascii??(process.env.WORKSPAI_LIVE_ASCII==="1"||process.env.TERM==="dumb"),i=e.color??(process.stdout.isTTY&&process.env.NO_COLOR===void 0&&process.env.TERM!=="dumb"),c=e.motion??(process.env.WORKSPAI_LIVE_REDUCED_MOTION!=="1"&&process.env.CI!=="true"),d=D(t,{selectedRunId:e.selectedRunId,activeOnly:e.activeOnly,maxRuns:e.maxRuns});if(e.accessible)return Se(d,r,n);let u={ascii:a,color:i,frame:s,motion:c},l=X("WORKSPAI LIVE",i),p=x(L(d.scopeLabel),Math.max(8,Math.floor(r/3))),m=`${d.global?`${d.scopeCount} SCOPES `:""}${U("running",a)} ${d.activeRunCount} ACTIVE ${U("succeeded",a)} ${d.healthyRunCount} ${U("warned",a)} ${d.warningRunCount} ${U("failed",a)} ${d.failedRunCount}`,v=a?"-".repeat(r):"\u2501".repeat(r),h=[jt(`${l} ${p}`,m,r),O(v,"planned",i,s)],E=x(e.replay?`${e.replay.paused?"PAUSED":"PLAY"} ${e.replay.index}/${e.replay.total} \xB7 ${e.replay.speed}x SPACE PLAY/PAUSE ${a?"<>":"\u2190\u2192"} STEP Q CLOSE`:`${a?"^v":"\u2191\u2193"} SELECT ENTER FOCUS I INSPECT F ACTIVE Q CLOSE`,r),I=e.interactive?o>=8?[O(v,"planned",i,s),E]:o>=3?[E]:[]:[];if(d.runs.length===0)h.push("",X(`${a?"*":"\u25C7"} WAITING FOR WORKSPAI ACTIVITY`,i));else {let w=d.runs.find(J=>J.run.runId===d.selectedRunId)??d.runs[0],T=e.focused?[]:d.runs.filter(J=>J.run.runId!==w.run.runId&&J.active);d.global&&!e.focused&&h.push(...$e(d,w.run.runId,r,n,u)),h.push(xe(w,true,r,n,u,d.global));let y=e.inspector!==false&&r>=132,S=y?Math.min(34,Math.floor(r*.25)):0,b=y?r-S-3:r,M=he(w,b,u),k=[...M?[M]:[],...pe(w,b,u)],$=y?be(w,S,n,u):[],tt=y?Ae(k,$,b):k,G=ge(T,r,u,d.global),et=G&&!d.global?1:0,q=Math.max(0,o-I.length-h.length-et),j=r>=72&&o>=14&&tt.length<=q;G&&!d.global&&h.length+I.length<o&&h.push(G),h.push(...j?tt:q>0?fe(w,r,Math.min(3,q),u):[]);}return d.diagnostics.length>0&&h.length+I.length<o&&h.push(O(`! ${d.diagnostics.length} DIAGNOSTIC`,"warned",i,s)),h.push(...I),h.slice(0,o).map(w=>x(w,r)).join(`
|
|
6
|
-
`)}function Me(t,e={}){let r=Math.max(20,e.width??process.stdout.columns??100),o=e.now??Date.now(),n=e.ascii??false,s=D(t,{maxRuns:e.maxRuns}),a=s.runs.map(d=>d.run),i=s.activeRunCount,c=[x(`Workspai Live \xB7 ${L(s.scopeLabel)} \xB7 ${i} active run${i===1?"":"s"}`,r),(n?"-":"\u2500").repeat(Math.min(r,100))];a.length===0&&c.push("Waiting for Workspai commands in this project or workspace\u2026");for(let[d,u]of a.entries()){d>0&&c.push("");let l=L(u.command.length>0?`workspai ${u.command.join(" ")}`:u.runId);c.push(x(`${U(u.status,n)} ${l} \xB7 ${u.runId.slice(0,8)} \xB7 ${ot(u,o)}`,r));for(let p of u.blocks.slice(0,18))c.push(x(` ${U(p.status,n)} ${L(p.label)}${Q(p,n)?` ${Q(p,n)}`:""}${H(p)?` ${H(p)}`:""}`,r));}return c.join(`
|
|
7
|
-
`)}var Ut={github:{width:1280,height:720},linkedin:{width:1200,height:627},x:{width:1600,height:900},square:{width:1080,height:1080},wide:{width:1600,height:900}},we={obsidian:{background:"#070b12",surface:"#0d1420",surfaceRaised:"#121c2b",grid:"#1d2a3b",text:"#edf6ff",muted:"#8090a5",cyan:"#20d9ff",green:"#27e0a3",yellow:"#f4d35e",red:"#ff667d",violet:"#b89cff"},light:{background:"#f4f7fb",surface:"#ffffff",surfaceRaised:"#eef3f9",grid:"#d9e2ee",text:"#102033",muted:"#617187",cyan:"#007fa3",green:"#087f5b",yellow:"#a16a00",red:"#c92a42",violet:"#6741d9"},mono:{background:"#080808",surface:"#111111",surfaceRaised:"#181818",grid:"#303030",text:"#f4f4f4",muted:"#9a9a9a",cyan:"#f4f4f4",green:"#d8d8d8",yellow:"#bdbdbd",red:"#ffffff",violet:"#c9c9c9"}};function V(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g," ")}function ct(t,e){let r=[...t];return r.length<=e?t:`${r.slice(0,e-1).join("")}\u2026`}function Z(t,e){return t==="running"?e.cyan:t==="succeeded"?e.green:t==="warned"||t==="blocked"?e.yellow:t==="failed"||t==="cancelled"?e.red:t==="rolled-back"?e.violet:e.muted}function bt(t){return {planned:"QUEUE",running:"RUNNING",succeeded:"COMPLETE",warned:"WARNING",blocked:"BLOCKED",failed:"FAILED",cancelled:"CANCELLED",skipped:"SKIPPED","rolled-back":"ROLLED BACK"}[t]}function Re(t){if(t<1e3)return `${t}ms`;let e=Math.floor(t/1e3);if(e<60)return `${e}s`;let r=Math.floor(e/60);return r<60?`${r}m ${e%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function Ft(t){return t.progress?.percent!==void 0?`${Math.round(t.progress.percent)}%`:t.progress?.completed!==void 0&&t.progress.total!==void 0?`${t.progress.completed}/${t.progress.total}`:""}function Ie(t){return [...t].reverse().find(e=>e.status==="running")??[...t].reverse().find(e=>["failed","blocked","warned"].includes(e.status))??[...t].sort((e,r)=>r.updatedAt.localeCompare(e.updatedAt))[0]}function ke(t,e){if(!e)return `workspai ${t.join(" ")}`.trim();let r=t[0]?.match(/^[a-z][a-z0-9-]*$/i)?.[0]??"command",n=new Set(["workspace","doctor","goal","graph","model","context"]).has(r)?t[1]?.match(/^[a-z][a-z0-9-]*$/i)?.[0]:void 0;return `workspai ${[r,n].filter(Boolean).join(" ")}`}function Ee(t,e={}){let r=e.preset??"github",o=e.theme??"obsidian",{width:n,height:s}=Ut[r],a=we[o],i=D(t,{selectedRunId:e.runId,maxRuns:50}),c=i.runs.find(g=>g.run.runId===i.selectedRunId)??i.runs[0],d=e.now??Date.parse(t.generatedAt),u=Math.round(n*.045),l=28,p=Math.max(250,Math.round(n*.24)),f=n-u*2-p-l,m=u,v=m+f+l,h=184,E=s-54,I=30,w=34,T=Math.max(2,Math.min(5,Math.floor((f+I)/180))),y=Math.floor((f-I*(T-1))/T),S=Math.max(1,Math.ceil((c?.nodes.length??0)/T)),b=Math.max(48,Math.min(64,Math.floor((E-h-w*(S-1))/S))),M=[...new Set(c?.nodes.map(g=>g.group).filter(Boolean)??[])],k=new Map;c?.nodes.forEach((g,A)=>{let R=Math.floor(A/T),C=A%T,z=R%2===0?C:T-C-1;k.set(g.id,{x:m+z*(y+I),y:h+R*(b+w)});});let $=c?Ie(c.nodes):void 0,tt=e.redact?"workspace / project":i.scopeLabel,G=e.redact?"workspace / project":c?.locationLabel,et=c?ke(c.run.command,e.redact===true):"Waiting for activity",q=c?c.run.durationMs??Math.max(0,d-Date.parse(c.run.startedAt)):0,j=[`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${s}" viewBox="0 0 ${n} ${s}" role="img" aria-labelledby="title description">`,'<title id="title">Workspai Live execution board</title>',`<desc id="description">${V(et)} execution graph with ${c?.nodes.length??0} blocks.</desc>`,"<defs>",`<pattern id="grid" width="28" height="28" patternUnits="userSpaceOnUse"><path d="M 28 0 L 0 0 0 28" fill="none" stroke="${a.grid}" stroke-width="1" opacity="0.28"/></pattern>`,...["planned","running","succeeded","warned","blocked","failed","cancelled","skipped","rolled-back"].map(g=>`<marker id="arrow-${g}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M 0 0 L 10 5 L 0 10 z" fill="${Z(g,a)}"/></marker>`),'<filter id="glow"><feGaussianBlur stdDeviation="3" result="blur"/><feMerge><feMergeNode in="blur"/><feMergeNode in="SourceGraphic"/></feMerge></filter>',"</defs>",`<rect width="${n}" height="${s}" fill="${a.background}"/>`,`<rect width="${n}" height="${s}" fill="url(#grid)"/>`,`<text x="${u}" y="58" fill="${a.cyan}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="17" font-weight="700" letter-spacing="2">WORKSPAI LIVE</text>`,`<text x="${u}" y="91" fill="${a.text}" font-family="Inter,ui-sans-serif,system-ui,sans-serif" font-size="27" font-weight="650">${V(ct(et,62))}</text>`,`<text x="${u}" y="118" fill="${a.muted}" font-family="Inter,ui-sans-serif,system-ui,sans-serif" font-size="14">${V(ct(G??tt,72))}</text>`,`<text x="${n-u}" y="61" text-anchor="end" fill="${c?Z(c.run.status,a):a.muted}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="14" font-weight="700">${c?bt(c.run.status):"STANDBY"} \xB7 ${Re(q)}</text>`,`<line x1="${u}" y1="143" x2="${n-u}" y2="143" stroke="${a.grid}" stroke-width="2"/>`];if(M.length>1){let g=Math.min(132,Math.floor((f-12*(M.length-1))/M.length));M.forEach((A,R)=>{let C=m+R*(g+12);j.push(`<rect x="${C}" y="156" width="${g}" height="20" rx="10" fill="${a.surfaceRaised}" stroke="${a.grid}"/>`,`<text x="${C+g/2}" y="170" text-anchor="middle" fill="${a.muted}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="10" font-weight="700" letter-spacing="1">${V(A)}</text>`);});}for(let g of c?.edges??[]){let A=k.get(g.fromBlockId),R=k.get(g.toBlockId);if(!A||!R)continue;let C=A.x+y/2,z=A.y+b/2,dt=R.x+y/2,$t=R.y+b/2,K=Math.abs($t-z)<2,ut=K?dt>C?A.x+y:A.x:C,lt=K?z:A.y+b,pt=K?dt>C?R.x:R.x+y:dt,mt=K?$t:R.y,xt=(lt+mt)/2,Gt=K?`M ${ut} ${lt} L ${pt} ${mt}`:`M ${ut} ${lt} L ${ut} ${xt} L ${pt} ${xt} L ${pt} ${mt}`,qt=Z(g.status,a);j.push(`<path d="${Gt}" fill="none" stroke="${qt}" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" ${g.status==="planned"?'stroke-dasharray="5 7"':""} marker-end="url(#arrow-${g.status})" opacity="${g.status==="planned"?"0.55":"0.9"}"/>`);}for(let g of c?.nodes??[]){let A=k.get(g.id);if(!A)continue;let R=Z(g.status,a),C=g.attempt&&g.attempt>1?` \xB7 R${g.attempt}`:"",z=Ft(g);j.push(`<g${g.status==="running"?' filter="url(#glow)"':""}>`,`<rect x="${A.x}" y="${A.y}" width="${y}" height="${b}" rx="8" fill="${a.surface}" stroke="${R}" stroke-width="${g.status==="running"?3:1.5}"/>`,`<rect x="${A.x}" y="${A.y}" width="4" height="${b}" rx="2" fill="${R}"/>`,`<text x="${A.x+15}" y="${A.y+25}" fill="${a.text}" font-family="Inter,ui-sans-serif,system-ui,sans-serif" font-size="13" font-weight="650">${V(ct(g.label,Math.max(10,Math.floor(y/8))))}</text>`,`<text x="${A.x+15}" y="${A.y+45}" fill="${R}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="10" font-weight="700">${bt(g.status)}${V(C)}${z?` \xB7 ${V(z)}`:""}</text>`,"</g>");}return j.push(`<rect x="${v}" y="156" width="${p}" height="${Math.max(250,s-210)}" rx="12" fill="${a.surface}" stroke="${a.grid}" stroke-width="1.5"/>`,`<text x="${v+24}" y="191" fill="${a.cyan}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="12" font-weight="700" letter-spacing="1.5">INSPECT</text>`,`<text x="${v+24}" y="224" fill="${a.text}" font-family="Inter,ui-sans-serif,system-ui,sans-serif" font-size="19" font-weight="650">${V(ct($?.label??"No active block",24))}</text>`),[["STATE",$?bt($.status):"STANDBY"],["PHASE",$?.group??"GENERAL"],["ATTEMPT",$?.attempt?String($.attempt):"\u2014"],["PROGRESS",$&&Ft($)||"\u2014"],["TOUCHES",String(c?.run.touches.length??0)],["ARTIFACTS",String(c?.run.artifacts.length??0)],["WARNINGS",String(c?.warningCount??0)]].forEach(([g,A],R)=>{let C=273+R*45;j.push(`<text x="${v+24}" y="${C}" fill="${a.muted}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="10" font-weight="700" letter-spacing="1">${g}</text>`,`<text x="${v+p-24}" y="${C}" text-anchor="end" fill="${g==="STATE"&&$?Z($.status,a):a.text}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="12" font-weight="700">${V(A)}</text>`);}),j.push(`<text x="${u}" y="${s-24}" fill="${a.muted}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="10" letter-spacing="1">EVENT-DRIVEN \xB7 DETERMINISTIC \xB7 LOCAL-FIRST</text>`,`<text x="${n-u}" y="${s-24}" text-anchor="end" fill="${a.muted}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="10">${e.redact?"PRODUCT-SAFE CAPTURE":V(c?.run.runId.slice(0,8).toUpperCase()??"NO RUN")}</text>`,"</svg>"),`${j.join(`
|
|
8
|
-
`)}
|
|
9
|
-
`}function zt(t,e){let r=e.preset??"github",o=_.resolve(e.outputPath);if(_.extname(o).toLowerCase()!==".svg")throw new Error("Activity capture output must use the .svg extension.");B.mkdirSync(_.dirname(o),{recursive:true,mode:448});let n=Ee(t,e),s=`${o}.${process.pid}.tmp`;try{B.writeFileSync(s,n,{encoding:"utf8",mode:384}),B.renameSync(s,o);}finally{try{B.unlinkSync(s);}catch(a){if(a.code!=="ENOENT")throw a}}return {outputPath:o,...Ut[r],bytes:Buffer.byteLength(n)}}function Te(t){return JSON.stringify(t.schemaVersion==="workspace-activity-monitor-fleet.v1"?{...t,generatedAt:"",scopes:t.scopes.map(e=>({...e,generatedAt:""}))}:{...t,generatedAt:""})}function Yt(t,e,r={}){let o=Math.max(1,r.height??process.stdout.rows??28),n=e.split(`
|
|
10
|
-
`).slice(0,o),s=Math.min(o,Math.max(t.length,n.length)),a=r.force?"\x1B[2J":"",i=r.force===true;for(let c=0;c<s;c+=1){let d=n[c]??"";!r.force&&t[c]===d||(i=true,a+=`\x1B[${c+1};1H\x1B[2K${d}`);}return i&&(a+=`\x1B[${Math.min(o,n.length+1)};1H`),{output:a,lines:n}}function Be(t,e,r){return Nt(D(t,{selectedRunId:e.selectedRunId,activeOnly:e.activeOnly,maxRuns:r}))}function At(t,e,r){let o=D(t,{selectedRunId:e.selectionPinned?e.selectedRunId:void 0,activeOnly:e.activeOnly,maxRuns:r});e.selectedRunId=o.selectedRunId;}function Ht(t,e,r,o){let n=Be(e,r,o);if(n.length===0)return;let s=Math.max(0,n.indexOf(r.selectedRunId??""));r.selectedRunId=n[(s+t+n.length)%n.length],r.selectionPinned=true,r.dirty=true;}function Le(t){let e=process.stdin;if(!e.isTTY||typeof e.setRawMode!="function")return null;let r=e.isRaw,o=e.isPaused(),n=s=>{let a=s.toString();if(a===""||a.toLowerCase()==="q"){t.stop();return}if(a==="\x1B[A"||a==="\x1B[D"||a.toLowerCase()==="k"){Ht(-1,t.snapshot(),t.state,t.maxRuns);return}if(a==="\x1B[B"||a==="\x1B[C"||a.toLowerCase()==="j"){Ht(1,t.snapshot(),t.state,t.maxRuns);return}if(a==="\r"||a===`
|
|
11
|
-
`){t.state.focused=!t.state.focused,t.state.focused&&(t.state.selectionPinned=true),t.state.dirty=true;return}if(a.toLowerCase()==="f"){t.state.activeOnly=!t.state.activeOnly,At(t.snapshot(),t.state,t.maxRuns),t.state.dirty=true;return}(a===" "||a.toLowerCase()==="i")&&(t.state.inspector=!t.state.inspector,t.state.dirty=true);};return e.setRawMode(true),e.resume(),e.on("data",n),()=>{e.removeListener("data",n),e.setRawMode(r===true),o&&e.pause();}}async function Pe(t){let e=gt({targetPath:t.targetPath,runId:t.runId,maxRuns:t.maxRuns});if(e.events.length===0)throw new Error(`No activity journal found for run ${t.runId}.`);let r=f=>Tt({resolvedScope:e.resolvedScope,events:e.events,eventCount:f+1,diagnostics:e.diagnostics}),o=r(e.events.length-1);if(t.options.once||t.options.json||t.options.accessible||t.options.classic||!process.stdout.isTTY||!process.stdin.isTTY)return process.stdout.write(t.options.json?`${JSON.stringify(o,null,2)}
|
|
12
|
-
`:`${Y(o,{width:process.stdout.columns,height:process.stdout.rows,maxRuns:t.maxRuns,selectedRunId:t.runId,color:t.options.color,motion:false,ascii:t.options.ascii,accessible:t.options.accessible,classic:t.options.classic})}
|
|
13
|
-
`),o;let n=0,s=false,a=false,i=true,c=[],d=process.stdin,u=d.isRaw,l=d.isPaused(),p=f=>{let m=f.toString();m===""||m.toLowerCase()==="q"?a=true:m===" "?s=!s:m==="\x1B[C"||m==="."?(n=Math.min(e.events.length-1,n+1),s=true):(m==="\x1B[D"||m===",")&&(n=Math.max(0,n-1),s=true),i=true;};d.setRawMode(true),d.resume(),d.on("data",p),process.stdout.write("\x1B[?1049h\x1B[?25l");try{for(;!a;){n>=e.events.length-1&&!s&&(s=true,i=true);let f=r(n);if(i){let E=Y(f,{width:process.stdout.columns,height:process.stdout.rows,maxRuns:t.maxRuns,selectedRunId:t.runId,focused:true,frame:n,color:t.options.color,motion:t.options.motion,ascii:t.options.ascii,accessible:t.options.accessible,classic:t.options.classic,inspector:true,interactive:true,replay:{index:n+1,total:e.events.length,paused:s,speed:t.speed}}),I=Yt(c,E,{force:c.length===0,height:process.stdout.rows});I.output&&process.stdout.write(I.output),c=I.lines,i=false;}if(s||n>=e.events.length-1){s=n>=e.events.length-1?true:s,await new Promise(E=>setTimeout(E,50));continue}let m=Date.parse(e.events[n]?.timestamp??""),v=Date.parse(e.events[n+1]?.timestamp??""),h=Math.max(30,Math.min(1e3,(v-m)/t.speed||30));await new Promise(E=>setTimeout(E,h)),n+=1,i=true;}}finally{d.removeListener("data",p),d.setRawMode(u===true),l&&d.pause(),process.stdout.write("\x1B[0m\x1B[?25h\x1B[?1049l");}return r(n)}async function rn(t){let e=_.resolve(t.targetPath??process.cwd()),r=Math.max(1,Math.min(50,t.maxRuns??6)),o=Math.max(1,Math.min(50,t.maxScopes??12)),n=Math.max(100,Math.min(5e3,t.refreshMs??250)),s=Math.max(.25,Math.min(64,t.replaySpeed??4));if(t.replayRunId){if(t.global)throw new Error("--replay cannot be combined with --global.");return Pe({targetPath:e,runId:t.replayRunId,speed:s,maxRuns:r,options:t})}t.global||Ot({targetPath:e});let a=()=>t.global?Lt({runId:t.runId,maxRuns:r,maxScopes:o}):Pt({targetPath:e,runId:t.runId,maxRuns:r}),i=a(),c=!!(process.stdout.isTTY&&process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&!t.json&&!t.accessible),d={selectedRunId:t.runId,selectionPinned:!!t.runId,focused:!!t.runId,activeOnly:false,inspector:true,dirty:true},u=0,l=()=>({width:process.stdout.columns,height:process.stdout.rows,maxRuns:r,selectedRunId:d.selectedRunId,focused:d.focused,activeOnly:d.activeOnly,frame:u,color:t.color,motion:t.motion,ascii:t.ascii,accessible:t.accessible,classic:t.classic,interactive:c,inspector:d.inspector});if(At(i,d,r),t.capturePath){let b=zt(i,{outputPath:t.capturePath,runId:d.selectedRunId,preset:t.capturePreset,theme:t.captureTheme,redact:t.captureRedact});return process.stdout.write(`${JSON.stringify({kind:"workspai.live.capture",...b},null,t.json?2:0)}
|
|
14
|
-
`),i}if(t.once)return t.json?process.stdout.write(`${JSON.stringify(i,null,2)}
|
|
15
|
-
`):process.stdout.write(`${Y(i,l())}
|
|
16
|
-
`),i;let p=false,f,m=()=>{p=true,f?.();},v=b=>new Promise(M=>{let k=setTimeout(()=>{f=void 0,M();},b);f=()=>{clearTimeout(k),f=void 0,M();};});process.once("SIGINT",m),process.once("SIGTERM",m);let h=true,E=()=>{h=true,d.dirty=true;};process.stdout.on("resize",E);let I=c?Le({snapshot:()=>i,state:d,maxRuns:r,stop:m}):null;c&&process.stdout.write("\x1B[?1049h\x1B[?25l");let w="",T=[],y=0,S=c&&t.motion!==false&&process.env.WORKSPAI_LIVE_REDUCED_MOTION!=="1"&&process.env.CI!=="true";try{for(;!p;){let b=Date.now();if((y===0||b-y>=n)&&(i=a(),At(i,d,r),y=b,d.dirty=true),c){let k=Y(i,l()),$=Yt(T,k,{force:h,height:process.stdout.rows});$.output&&process.stdout.write($.output),T=$.lines,h=false,d.dirty=false,u+=1;}else {let k=JSON.stringify(i),$=Te(i);$!==w&&(process.stdout.write(t.json?`${k}
|
|
17
|
-
`:`${Y(i,l())}
|
|
18
|
-
`),w=$);}let M=S&&Wt(D(i,{selectedRunId:d.selectedRunId,activeOnly:d.activeOnly,maxRuns:r}));p||await v(M?Math.min(n,125):n);}}finally{I?.(),process.removeListener("SIGINT",m),process.removeListener("SIGTERM",m),process.stdout.removeListener("resize",E),c&&process.stdout.write("\x1B[0m\x1B[?25h\x1B[?1049l");}return i}export{Te as activitySnapshotComparisonKey,Yt as renderActivityScreenDiff,rn as runLiveCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{b as buildWorkspaceExplain,a as resolveWorkspaceExplainArtifactPath,c as writeWorkspaceExplainReport}from'./chunk-4XEH3WNV.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-H5RJCS5E.js';export{e as WORKSPACE_MODEL_DIFF_REPORT_PATH}from'./chunk-VA5VSOBL.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as WORKSPACE_EXPLAIN_SCHEMA_VERSION,b as WORKSPACE_EXPLAIN_TARGETS,e as isWorkspaceExplainReport,c as parseWorkspaceExplainTarget,d as resolveWorkspaceTraceTarget}from'./chunk-D4UHRJAP.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-H5RJCS5E.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as WORKSPACE_GRAPH_TOKEN_EFFICIENCY_SCHEMA_VERSION,b as buildWorkspaceGraphTokenEfficiencyReport}from'./chunk-H7MRINGP.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a as a$1,b as b$1,c,d as d$1}from'./chunk-5U4L6VF2.js';import {a}from'./chunk-AFIFZTOY.js';import {e}from'./chunk-6UNATTB7.js';import d from'crypto';import s from'path';import {open,unlink,stat}from'fs/promises';import u from'fs-extra';var k=e.evaluationLive,O=e.evaluationLastRun,W="contracts/workspace-intelligence/model-usage-event.v1.json",E="contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",P="contracts/workspace-intelligence/workspace-intelligence-evaluation-comparison.v1.json",_=3e4,N=100,b=25;function C(){return {modelCalls:0,toolCalls:0,tokenSources:{providerReported:0,tokenizerCounted:0,estimated:0,unavailable:0},tokens:{input:0,output:0,cachedInput:0,reasoning:0,observedTotal:0},latencyMs:0,costs:[],outcome:{status:"unknown",verified:false,blockersResolved:0},efficiency:{tokensPerVerifiedOutcome:null,noProgressDecisions:0,repeatedArtifactReads:0}}}function m(t){return t??0}function S(t){let e=C(),a=new Map,n=new Map;for(let o of t){if(o.kind==="model-call"){e.modelCalls+=1;let r={"provider-reported":"providerReported","tokenizer-counted":"tokenizerCounted",estimated:"estimated",unavailable:"unavailable"}[o.modelCall.source];if(e.tokenSources[r]+=1,e.tokens.input+=m(o.modelCall.inputTokens),e.tokens.output+=m(o.modelCall.outputTokens),e.tokens.cachedInput+=m(o.modelCall.cachedInputTokens),e.tokens.reasoning+=m(o.modelCall.reasoningTokens),e.latencyMs+=o.modelCall.latencyMs??0,o.modelCall.cost){let i=o.modelCall.cost.currency.toUpperCase(),l=n.get(i)??{currency:i,amount:0,providerReported:0,estimated:0};l.amount+=o.modelCall.cost.amount,o.modelCall.cost.source==="provider-reported"?l.providerReported+=o.modelCall.cost.amount:l.estimated+=o.modelCall.cost.amount,n.set(i,l);}continue}if(o.kind==="tool-call"){e.toolCalls+=1,e.latencyMs+=o.toolCall.durationMs??0,!o.toolCall.changedSource&&o.toolCall.result==="passed"&&(e.efficiency.noProgressDecisions+=1),o.toolCall.artifact&&a.set(o.toolCall.artifact,(a.get(o.toolCall.artifact)??0)+1);continue}o.kind==="outcome"&&(e.outcome={status:o.outcome.status,verified:o.outcome.verified,blockersResolved:o.outcome.blockersResolved});}return e.tokens.observedTotal=e.tokens.input+e.tokens.output,e.costs=[...n.values()].map(o=>({...o,amount:Number(o.amount.toFixed(8)),providerReported:Number(o.providerReported.toFixed(8)),estimated:Number(o.estimated.toFixed(8))})).sort((o,r)=>o.currency.localeCompare(r.currency)),e.efficiency.repeatedArtifactReads=[...a.values()].reduce((o,r)=>o+Math.max(0,r-1),0),e.efficiency.tokensPerVerifiedOutcome=e.outcome.verified&&e.outcome.status==="passed"?e.tokens.observedTotal:null,e}function x(t,e=new Date){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Evaluation event must be a JSON object.");let a$2=t,n={...a$2,schemaVersion:a$1,eventId:typeof a$2.eventId=="string"&&a$2.eventId.trim()?a$2.eventId.trim():d.randomUUID(),recordedAt:typeof a$2.recordedAt=="string"&&a$2.recordedAt.trim()?a$2.recordedAt:e.toISOString()};a(n,W,"workspace evaluation event");let o={"model-call":"modelCall","tool-call":"toolCall",outcome:"outcome",milestone:"milestone"}[n.kind],r=["modelCall","toolCall","outcome","milestone"].filter(i=>a$2[i]!==void 0);if(r.length!==1||r[0]!==o)throw new Error(`Evaluation event kind ${n.kind} requires only ${o}.`);if(n.kind==="model-call"&&n.modelCall.source!=="unavailable"&&n.modelCall.inputTokens===null&&n.modelCall.outputTokens===null)throw new Error("Measured model calls require at least one input or output token count.");return n}function J(t){let e=t.now??new Date,a$1=s.resolve(t.workspacePath),n={schemaVersion:b$1,runId:t.runId??d.randomUUID(),sessionId:t.sessionId??d.randomUUID(),status:"live",startedAt:e.toISOString(),updatedAt:e.toISOString(),workspace:{name:t.workspaceName?.trim()||s.basename(a$1),path:a$1},configuration:{taskId:t.taskId.trim(),strategy:t.strategy??"workspace-intelligence",...t.provider?{provider:t.provider}:{},...t.model?{model:t.model}:{},...t.temperature!==void 0?{temperature:t.temperature}:{},...t.baselineRunId?{baselineRunId:t.baselineRunId}:{}},methodology:{id:"provider-usage-and-verified-outcome.v1",claimBoundary:"Provider-reported and tokenizer-counted values are measured; estimated values remain explicitly labelled. Verified task success is required before reporting tokens per successful outcome."},events:[],summary:C()};return a(n,E,"workspace evaluation"),n}async function L(t,e){await u.ensureDir(s.dirname(t));let a=`${t}.${process.pid}.${d.randomUUID()}.tmp`;try{await u.writeJson(a,e,{spaces:2}),await u.rename(a,t);}finally{await u.remove(a).catch(()=>{});}}async function A(t,e){let a=s.join(s.resolve(t),`${k}.lock`);await u.ensureDir(s.dirname(a));for(let n=0;n<N;n+=1)try{let o=await open(a,"wx");try{return await o.writeFile(JSON.stringify({pid:process.pid,acquiredAt:new Date().toISOString()})),await e()}finally{await o.close(),await unlink(a).catch(()=>{});}}catch(o){if(o.code!=="EEXIST")throw o;let i=await stat(a).catch(()=>null);if(i&&Date.now()-i.mtimeMs>_){await unlink(a).catch(()=>{});continue}await new Promise(l=>setTimeout(l,b));}throw new Error("Timed out waiting for the workspace evaluation writer lock.")}async function v(t,e,a$1=k){let n=s.join(s.resolve(t),a$1);return a(e,E,a$1),await L(n,e),n}async function T(t,e=k){let a$1=s.isAbsolute(e)?e:s.join(s.resolve(t),e),n=await u.readJson(a$1);return a(n,E,a$1),n}async function G(t){return A(t.workspacePath,async()=>{let e=await T(t.workspacePath);if(e.status!=="live")throw new Error(`Evaluation ${e.runId} is ${e.status}; initialize a new run.`);let a=x(t.payload,t.now);if(e.events.some(o=>o.eventId===a.eventId))return e;let n={...e,updatedAt:(t.now??new Date).toISOString(),events:[...e.events,a],summary:S([...e.events,a])};return await v(t.workspacePath,n),n})}async function H(t){return A(t.workspacePath,async()=>{let e=await T(t.workspacePath),a=(t.now??new Date).toISOString(),n={...e,status:t.status??"completed",updatedAt:a,completedAt:a,summary:S(e.events)},o=await v(t.workspacePath,n,O);return await v(t.workspacePath,n),{report:n,outputPath:o}})}function q(t,e){let a$1=t.summary.tokens.observedTotal,n=e.summary.tokens.observedTotal,o=a$1-n,r={schemaVersion:c,generatedAt:new Date().toISOString(),taskAligned:t.configuration.taskId===e.configuration.taskId,current:{runId:t.runId,strategy:t.configuration.strategy,tokens:a$1,verified:t.summary.outcome.verified,status:t.summary.outcome.status},baseline:{runId:e.runId,strategy:e.configuration.strategy,tokens:n,verified:e.summary.outcome.verified,status:e.summary.outcome.status},delta:{tokens:o,reductionPercent:n===0?null:Number((-o/n*100).toFixed(2)),modelCalls:t.summary.modelCalls-e.summary.modelCalls,toolCalls:t.summary.toolCalls-e.summary.toolCalls,latencyMs:Number((t.summary.latencyMs-e.summary.latencyMs).toFixed(2))},comparableOutcome:t.summary.outcome.verified&&e.summary.outcome.verified&&t.summary.outcome.status===e.summary.outcome.status};return a(r,P,"workspace evaluation comparison"),r}function B(){if(d$1.length!==4)throw new Error("Model usage source taxonomy is incomplete.")}export{O as WORKSPACE_EVALUATION_LAST_RUN_PATH,k as WORKSPACE_EVALUATION_LIVE_PATH,G as appendWorkspaceEvaluationEvent,B as assertWorkspaceEvaluationSourceTaxonomy,q as compareWorkspaceEvaluations,J as createWorkspaceEvaluation,H as finalizeWorkspaceEvaluation,x as normalizeWorkspaceEvaluationEvent,T as readWorkspaceEvaluation,S as summarizeWorkspaceEvaluation,v as writeWorkspaceEvaluation};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as readWorkspaceKnowledgeGraphSnapshot}from'./chunk-UPIPSSXY.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as runWorkspaceStage}from'./chunk-R2M5OJOK.js';export{a as WORKSPACE_RUN_LAST_REPORT_FILENAME}from'./chunk-5XGR3LRI.js';
|