workspai 0.75.2 → 0.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contracts/agent-framework-capabilities.v1.json +2 -2
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +12 -0
- package/contracts/create-planner-capabilities.v1.json +24 -0
- package/contracts/extension-cli-compatibility.v1.json +4 -2
- package/contracts/published-contract-catalog.v1.json +10 -0
- package/contracts/runtime-command-surface.v1.json +3 -1
- package/contracts/workspace-intelligence/agent-framework-admission-candidate.v2.json +217 -0
- package/contracts/workspace-intelligence/agent-framework-conformance-report.v2.json +274 -0
- package/contracts/workspace-intelligence-architecture.v1.json +5 -3
- package/dist/analyze-QVRVJB7I.js +1 -0
- package/dist/autopilot-release-DOGIETAT.js +1 -0
- package/dist/capabilities-command-FYBUVHZ7.js +1 -0
- package/dist/{chunk-ADHX7D3F.js → chunk-23CNBYIW.js} +1 -1
- package/dist/{chunk-IKBE3HOH.js → chunk-2I2A55RE.js} +1 -1
- package/dist/{chunk-4JXJRIJM.js → chunk-4BBFEHPL.js} +1 -1
- package/dist/{chunk-VHMDWRDG.js → chunk-4BPZJR4Z.js} +4 -4
- package/dist/{chunk-KDVNRNDU.js → chunk-4MXKXHLW.js} +1 -1
- package/dist/{chunk-JKAAKE4Z.js → chunk-4R44E7HN.js} +1 -1
- package/dist/chunk-5S6IZ6PY.js +2 -0
- package/dist/chunk-6BO4QHKA.js +1 -0
- package/dist/{chunk-VWBWDDU2.js → chunk-AGI46TSQ.js} +1 -1
- package/dist/{chunk-GDOO2YZW.js → chunk-BZLDCASY.js} +1 -1
- package/dist/{chunk-OA2YJN22.js → chunk-DWDYLKVW.js} +1 -1
- package/dist/{chunk-P36TACKN.js → chunk-FBF767WP.js} +1 -1
- package/dist/{chunk-PFAGXI3G.js → chunk-FD2ZGGCQ.js} +1 -1
- package/dist/chunk-H4YHIOCT.js +7 -0
- package/dist/{chunk-ZI54C2AO.js → chunk-HRGIHWYH.js} +1 -1
- package/dist/{chunk-LFY7KTPD.js → chunk-IKNWNGLY.js} +1 -1
- package/dist/{chunk-ZGVODK5C.js → chunk-KO4DM2AV.js} +1 -1
- package/dist/{chunk-FNVWDXK2.js → chunk-KW35SWG6.js} +5 -5
- package/dist/{chunk-EP7SUMAX.js → chunk-L6VNI4DN.js} +1 -1
- package/dist/chunk-NSC4VWV2.js +1 -0
- package/dist/chunk-P5LI5DL3.js +1 -0
- package/dist/chunk-PSQPKK6H.js +97 -0
- package/dist/chunk-PUH3TSPC.js +1 -0
- package/dist/chunk-QFDTKOYS.js +2649 -0
- package/dist/chunk-QIPW3G2H.js +1 -0
- package/dist/chunk-QVFIR64T.js +10 -0
- package/dist/{chunk-FZWLWFR4.js → chunk-R3Z4LY3O.js} +1 -1
- package/dist/chunk-RKFTUIZ4.js +4 -0
- package/dist/{chunk-COOVCORC.js → chunk-SVO2GGTV.js} +1 -1
- package/dist/{chunk-5K4O3TAW.js → chunk-TFFNHWXY.js} +1 -1
- package/dist/chunk-TJ3MDZMC.js +6 -0
- package/dist/{chunk-WXUCAVFT.js → chunk-UOTOJJI4.js} +8 -8
- package/dist/chunk-VODNLROY.js +1 -0
- package/dist/{chunk-WHBKKJ7L.js → chunk-X7MDTBX5.js} +1 -1
- package/dist/chunk-YLLCZMKP.js +2 -0
- package/dist/{chunk-K52IQX3J.js → chunk-Z2M2XCIB.js} +1 -1
- package/dist/{chunk-DTNOF3MP.js → chunk-ZXQC36NJ.js} +1 -1
- package/dist/{create-ZFSFWAW3.js → create-ZRUQ3KNZ.js} +1 -1
- package/dist/{doctor-4KL4XUCS.js → doctor-7V7LJLHX.js} +1 -1
- package/dist/{goal-lifecycle-EXQZD7IA.js → goal-lifecycle-EM4DUJCR.js} +1 -1
- package/dist/{goal-pack-DKJU2DEP.js → goal-pack-YMWZHAH6.js} +1 -1
- package/dist/index.d.ts +12 -6
- package/dist/index.js +251 -250
- package/dist/{pipeline-4GVAOCEN.js → pipeline-6MBH3MU2.js} +1 -1
- package/dist/platform-capabilities-RWOWND5Q.js +1 -0
- package/dist/{project-agent-entry-7QKNEEXP.js → project-agent-entry-ZXAE2MAJ.js} +1 -1
- package/dist/{project-intelligence-lens-IHRYCLNU.js → project-intelligence-lens-NBTPOK2R.js} +1 -1
- package/dist/{project-test-coverage-3P5FH6E5.js → project-test-coverage-HOZC72EK.js} +1 -1
- package/dist/proof-carrying-change-WJFAKK3C.js +1 -0
- package/dist/{pythonRapidkitExec-UMFLDIYR.js → pythonRapidkitExec-S35OEIEF.js} +1 -1
- package/dist/{verified-goal-XI4RQESU.js → verified-goal-B7EX2PBE.js} +1 -1
- package/dist/{workspace-EYXAKMVI.js → workspace-EBPYCSEM.js} +1 -1
- package/dist/{workspace-agent-sync-SN55KT6N.js → workspace-agent-sync-Y4F6FBBC.js} +1 -1
- package/dist/{workspace-context-PW6ESEHH.js → workspace-context-Y7F7GJCQ.js} +1 -1
- package/dist/{workspace-contract-FPLFL4G3.js → workspace-contract-XJMWMVQE.js} +1 -1
- package/dist/{workspace-explain-TVQ5IF5D.js → workspace-explain-T2J5ZLY7.js} +1 -1
- package/dist/{workspace-foundation-DWIJPZRH.js → workspace-foundation-2UP6IMTH.js} +1 -1
- package/dist/{workspace-graph-stream-RUTNWLQB.js → workspace-graph-stream-MZVL3OCX.js} +1 -1
- package/dist/{workspace-intelligence-4CA2CSPZ.js → workspace-intelligence-FZRQIFFM.js} +1 -1
- package/dist/{workspace-intelligence-runner-VM5SXXAT.js → workspace-intelligence-runner-IXT62JG7.js} +1 -1
- package/dist/{workspace-knowledge-graph-JXN2ZOAF.js → workspace-knowledge-graph-EFC4TUDZ.js} +1 -1
- package/dist/workspace-knowledge-graph-snapshot-QIMF7TCF.js +1 -0
- package/dist/{workspace-mcp-serve-4WN4CSD7.js → workspace-mcp-serve-C42UUU7W.js} +1 -1
- package/dist/{workspace-model-D4IECQML.js → workspace-model-72SJ6WXT.js} +1 -1
- package/dist/{workspace-onboarding-6XWDKLM5.js → workspace-onboarding-TFDAIHTS.js} +1 -1
- package/dist/{workspace-registry-summary-Y3ET36NH.js → workspace-registry-summary-ZNTXSUI4.js} +1 -1
- package/dist/{workspace-repair-engine-HBUXRHDY.js → workspace-repair-engine-542TAL3Z.js} +1 -1
- package/dist/workspace-run-NAPJYNSZ.js +1 -0
- package/dist/{workspace-verify-OOAZ3NMZ.js → workspace-verify-UXKENOQU.js} +1 -1
- package/dist/{workspace-watch-BNM5B6HU.js → workspace-watch-DV5AHLOK.js} +1 -1
- package/docs/README.md +2 -2
- package/docs/agent-framework-adapters.md +164 -39
- package/docs/ci-workflows.md +29 -22
- package/docs/commands-reference.md +17 -8
- package/docs/creating-workspaces-and-projects.md +4 -2
- package/docs/doctor-command.md +6 -4
- package/docs/native-kit-baselines.md +2 -1
- package/docs/workspace-run.md +3 -1
- package/package.json +3 -1
- package/scripts/enterprise-package-smoke.mjs +98 -5
- package/dist/analyze-6UEBC5OJ.js +0 -1
- package/dist/autopilot-release-H5TO6NYY.js +0 -1
- package/dist/capabilities-command-VK3LQLP2.js +0 -1
- package/dist/chunk-3N27P3KO.js +0 -7
- package/dist/chunk-3RNWBFRP.js +0 -4
- package/dist/chunk-66O62XNJ.js +0 -97
- package/dist/chunk-7NKM6EHE.js +0 -7
- package/dist/chunk-BR6QIYQS.js +0 -1
- package/dist/chunk-DFREJHG7.js +0 -1
- package/dist/chunk-E42IFQFR.js +0 -6
- package/dist/chunk-EWD6QTAM.js +0 -2
- package/dist/chunk-G5UCEXP6.js +0 -1
- package/dist/chunk-LARREYZN.js +0 -1
- package/dist/chunk-RGNCL5OB.js +0 -1
- package/dist/chunk-SZHRPELL.js +0 -1
- package/dist/chunk-VXFIMEC6.js +0 -2
- package/dist/chunk-X7OI24LO.js +0 -418
- package/dist/platform-capabilities-DB4BZPTD.js +0 -1
- package/dist/proof-carrying-change-O37XUPIZ.js +0 -1
- package/dist/workspace-knowledge-graph-snapshot-KBNUXA64.js +0 -1
- package/dist/workspace-run-VN7KV4BU.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a as a$2,D as D$1}from'./chunk-TJ3MDZMC.js';import {d}from'./chunk-ROOPODG6.js';import {j,m,i}from'./chunk-H4YHIOCT.js';import {a as a$1}from'./chunk-GR6442P7.js';import {a as a$3,g,f as f$1,h}from'./chunk-BLEIUQL6.js';import {b}from'./chunk-VN2MKTQO.js';import {a}from'./chunk-XWKGZRHN.js';import {a as a$4}from'./chunk-252EKOR6.js';import {l}from'./chunk-OCGZNSOE.js';import {c}from'./chunk-64XWHDZ3.js';import {t as t$1,u,q as q$1}from'./chunk-VQZ5PI5J.js';import {t,p,s,q}from'./chunk-ODK4LCEL.js';import*as f from'path';import f__default from'path';import k from'fs-extra';import Re from'crypto';var Ae="unknown-run";function de(e){let t=c();return !t||t===Ae?e:{...e,runId:t}}async function ue(e,t){await k.ensureDir(f.dirname(e));let r=`${e}.${process.pid}.${Date.now()}.${Re.randomUUID()}.tmp`;try{await k.writeJSON(r,t,{spaces:2}),await k.move(r,e,{overwrite:true});}finally{await k.remove(r).catch(()=>{});}}function le(e){return q$1(e,"imported-projects.json")}async function I(e){let t=(await Promise.all(t$1(e,"imported-projects.json").map(async r=>await k.pathExists(r)?r:null))).find(r=>typeof r=="string");if(!t)return [];try{let r=await k.readJSON(t);if(!r||typeof r!="object"||r.version!==1||!Array.isArray(r.projects))throw new Error("expected a version 1 registry with a projects array");let o=r.projects,n=o.filter(i=>{if(!i||typeof i!="object")return false;let c=i;return typeof c.name=="string"&&typeof c.path=="string"&&typeof c.stack=="string"&&typeof c.confidence=="string"&&typeof c.importedAt=="string"});if(n.length!==o.length)throw new Error("one or more project entries are invalid");return n}catch(r){throw new Error(`Imported-project registry is invalid: ${t}`,{cause:r})}}async function Xe(e,t){if(t.length===0)return;let r=le(e);await a(`${r}.lock`,async()=>{let o=await I(e),n=new Map;for(let c of o)n.set(c.path,c);for(let c of t)n.set(c.path,c);let i=Array.from(n.values()).sort((c,l)=>c.name.localeCompare(l.name)).map(c=>({...c}));await ue(r,{version:1,updatedAt:new Date().toISOString(),projects:i});},{timeoutMs:3e4,staleMs:6e4,purpose:"imported-projects-registry-upsert"});}async function et(e,t){if(t.length===0)return;let r=le(e);await a(`${r}.lock`,async()=>{let o=await I(e),n=new Set(t.map(c=>f.resolve(c))),i=o.filter(c=>!n.has(f.resolve(c.path)));await ue(r,{version:1,updatedAt:new Date().toISOString(),projects:i});},{timeoutMs:3e4,staleMs:6e4,purpose:"imported-projects-registry-remove"});}var ot="workspace-dependency-graph.v1",me=["code-import","package-dep","event-pub-sub","service-dependsOn","shared-resource"],ge=["inferred","contract","manual"];var v=t.workspaceContract,xe=p.contractVerify,G=s.workspaceContract.schemaVersion,_e=q.contractVerify,D=class extends Error{constructor(r){super(`Workspace contract verification failed: ${r.violations.join("; ")}`);this.verification=r;this.name="WorkspaceContractVerificationError";}verification};function Pe(e){return e.replace(/\\/g,"/")}function z(e){let t=Pe(e).trim();return !t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0")?false:!t.split("/").filter(Boolean).some(r=>r===".."||r===".")}function fe(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,80)||t}function ye(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function Ge(e){return [...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}function Oe(e){let t=e.contracts;return !t||typeof t!="object"||Array.isArray(t)?[]:ye(t.env)}function Ce(e){let t=(e||"").toLowerCase();return t.includes("vscode-extension")||t.includes("desktop.electron")||t.startsWith("extension.")||t.startsWith("desktop.")&&!t.includes("tauri")||t.includes("agent.microsoft")||t.includes("agent.openai")}function he(e){let r=(Array.isArray(e.ports)?e.ports:[]).map(i=>{if(!i||typeof i!="object"||Array.isArray(i))return null;let c=i,l=Number(c.port);if(!Number.isInteger(l)||l<1||l>65535)return null;let m=c.protocol==="https"||c.protocol==="grpc"||c.protocol==="tcp"||c.protocol==="udp"?c.protocol:"http";return {name:typeof c.name=="string"&&c.name.trim()?c.name:"http",port:l,protocol:m}}).filter(i=>i!==null);if(r.length>0)return r;let o=e.frontend&&typeof e.frontend=="object"&&!Array.isArray(e.frontend)?e.frontend:void 0,n=Number(e.port??o?.default_port);return Number.isInteger(n)&&n>=1&&n<=65535?[{name:"http",port:n,protocol:"http"}]:[]}async function Ne(e){let t=f__default.join(e,"Dockerfile");if(!await k.pathExists(t))return [];try{let r=await k.readFile(t,"utf8"),o=new Map;for(let n of r.matchAll(/^\s*EXPOSE\s+(.+)$/gim))for(let i of n[1].split(/\s+/)){let c=i.match(/^(\d{1,5})(?:\/(tcp|udp))?$/i),l=Number(c?.[1]);if(!c||!Number.isInteger(l)||l<1||l>65535)continue;let m=c[2]?.toLowerCase();o.set(l,{name:"http",port:l,protocol:m==="udp"?"udp":"http"});}return [...o.values()].sort((n,i)=>n.port-i.port)}catch{return []}}async function T(e){for(let t of e)if(await k.pathExists(t))return t;return null}async function Ie(e){for(let r of t$1(e,"workspace.json"))try{let o=await k.readJson(r);return {name:typeof o.workspace_name=="string"&&o.workspace_name.trim()||typeof o.name=="string"&&o.name.trim()||f__default.basename(e),profile:typeof o.profile=="string"?o.profile:void 0}}catch{}let t=await a$4(e);return t?.name?.trim()?{name:t.name.trim()}:{name:f__default.basename(e)}}async function De(e){let t=[],r=[e],o=new Set,n=new Set([".git",".workspai",".rapidkit","node_modules",".venv","venv","dist","build","target",".next",".turbo",".cache"]);for(;r.length>0;){let i=r.shift();if(!i||o.has(i))continue;o.add(i);let c=await T(u(i,"project.json")),l=await T(u(i,"context.json"));if(c||l){t.push(c??l??"");continue}let m;try{m=await k.readdir(i,{withFileTypes:true});}catch{continue}for(let d of m)!d.isDirectory()||n.has(d.name)||a$1(d.name)||r.push(f__default.join(i,d.name));}return t.sort()}function Te(e){let t=(e||"").toLowerCase();if(t.includes("fastapi"))return "fastapi";if(t.includes("nestjs"))return "nestjs";if(t.includes("springboot"))return "springboot";if(t.includes("gofiber"))return "fiber";if(t.includes("gogin"))return "gin"}function $e(e,t){let r=(e||"").toLowerCase(),o=(t||"").toLowerCase();return Ce(e)?null:r.includes("fastapi")?8e3:r.includes("nestjs")?3e3:r.includes("springboot")?8080:r.includes("gofiber")?3e3:r.includes("gogin")?8080:r.startsWith("adopted.")?null:o==="node"?3e3:o==="python"?8e3:o==="java"||o==="go"?8080:null}function B(e,t){let r=e;for(;t.has(r)&&r<65535;)r+=1;return r}function U(e,t,r){let o=e!==void 0&&e.source===void 0,n=$e(t.kit,t.runtime),i=e?.ports||[],c=t.ports||[],l=Ce(t.kit),m=t.source==="adopted-local"&&e?.source!==void 0,d=t.source!==void 0&&e?.source!==void 0,p=(l&&c.length===0?[]:m?c.length>0?c:n?[{name:"http",port:B(n,r),protocol:"http"}]:[]:i.length>0?i:c.length>0?c:n?[{name:"http",port:B(n,r),protocol:"http"}]:[]).map(P=>({...P,port:B(P.port,r)}));for(let P of p)r.add(P.port);let g={...t,...e,slug:e?.slug||t.slug,relativePath:o&&e?.relativePath&&z(e.relativePath)?e.relativePath:t.relativePath,source:o&&e?.source||t.source,relationship:o&&e?.relationship||t.relationship,externalPath:o&&e?.externalPath||t.externalPath,runtime:d?t.runtime:e?.runtime||t.runtime,framework:d?t.framework:e?.framework||t.framework,kit:d?t.kit:e?.kit||t.kit,modules:e?.modules?.length?e.modules:t.modules,ports:p,contracts:{owns:e?.contracts?.owns||[],apis:e?.contracts?.apis||[],publishes:e?.contracts?.publishes||[],consumes:e?.contracts?.consumes||[],dependsOn:e?.contracts?.dependsOn||[],env:Ge([...e?.contracts?.env??[],...t.contracts.env??[]])}},h=JSON.stringify(e||null)!==JSON.stringify(g);return {project:g,changed:h}}async function Ee(e){let t=f__default.resolve(e.workspacePath),r=await Ie(t),o=await De(t),n=await I(t),i$1=new Map(n.map(s=>[f__default.resolve(s.path),s])),c=[];for(let s of n){let p=f__default.resolve(s.path),g=await T(u(p,"project.json"))??await T(u(p,"context.json"));!g||o.some(h=>f__default.resolve(h)===f__default.resolve(g))||c.push({projectJsonPath:g,registryEntry:s});}let l=[],m$1=[...o.map(s=>({projectJsonPath:s,registryEntry:i$1.get(f__default.resolve(f__default.dirname(f__default.dirname(s))))})),...c];for(let{projectJsonPath:s,registryEntry:p}of m$1){let g=f__default.dirname(f__default.dirname(s)),h=Pe(f__default.relative(t,g)),P=p!==void 0&&!z(h),C=fe(p?.name||f__default.basename(g),f__default.basename(g)),b=P?`external/${C}`:h||C,w=await k.readJson(s),a=typeof w.kit_name=="string"&&w.kit_name||typeof w.kit=="string"&&w.kit||void 0,E=j(w)?m(g,w):void 0,j$1=E!==void 0&&E.key!=="unknown",S=i({runtime:typeof w.runtime=="string"?w.runtime:void 0,framework:typeof w.framework=="string"?w.framework:void 0,kitName:a}),y=a$2(a),$=j$1?E.runtime:S.runtime!=="unknown"?S.runtime:y?.runtime,K=j$1?E.key:typeof w.framework=="string"&&w.framework||(S.key!=="unknown"?S.key:void 0)||y?.framework||Te(a),We=p?.relationship==="adopted"?"adopted":"imported",Se=j$1?`${We}.${E.key}`:a;l.push({slug:p?.name||b||f__default.basename(g),relativePath:b,source:p?.source??"workspace",relationship:p?.relationship,externalPath:P?g:void 0,runtime:$,framework:K,kit:Se,modules:ye(w.modules),ports:he(w).length>0?he(w):await Ne(g),contracts:{owns:[],apis:[],publishes:[],consumes:[],dependsOn:[],env:Oe(w)}});}let d=new Map;for(let s of l){let p=fe(s.slug,s.relativePath),g=d.get(p);(!g||g.source!=="workspace"&&s.source==="workspace")&&d.set(p,s);}return {schemaVersion:G,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:r,projects:[...d.values()]}}async function Et(e){let t=f__default.resolve(e.outputPath||a$3(e.workspacePath,v));if(await k.pathExists(t)&&e.force!==true)throw new Error(`Workspace contract already exists: ${t}. Use --force to overwrite.`);let r=await Ee({workspacePath:e.workspacePath,now:e.now}),o=new Set,n={...r,projects:r.projects.map(c=>U(void 0,c,o).project)},i=await be({workspacePath:e.workspacePath,contractPath:t,contract:n});if(e.strict&&i.status==="failed")throw new D(i);return await ve({workspacePath:e.workspacePath,contractPath:t,contract:n,now:e.now}),{contractPath:t,contract:n}}async function vt(e){let t=f__default.resolve(e.workspacePath),r=a$3(t,v),o=await g(t,v)??r,n=await Ee({workspacePath:t,now:e.now}),i=await k.pathExists(o)?await k.readJson(o):null,c=new Map((i?.projects||[]).map(h=>[h.slug,h])),l=new Set,m=[],d=[],s=[];for(let h of n.projects){let P=c.get(h.slug),C=U(P,h,l);P?C.changed&&d.push(h.slug):m.push(h.slug),s.push(C.project),c.delete(h.slug);}for(let h of c.values()){if(h.source)continue;let P=U(h,h,l);s.push(P.project);}let p={schemaVersion:G,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:{...i?.workspace||{},...n.workspace,name:n.workspace.name||i?.workspace?.name||f__default.basename(t)},projects:s.sort((h,P)=>h.slug.localeCompare(P.slug))},g$1=await be({workspacePath:t,contractPath:r,contract:p});if(e.strict&&g$1.status==="failed")throw new D(g$1);return await ve({workspacePath:t,contractPath:r,contract:p,now:e.now}),{contractPath:r,contract:p,addedProjects:m,updatedProjects:d,verification:g$1}}async function ke(e){return await k.pathExists(e)?{exists:true,contents:await k.readFile(e)}:{exists:false}}async function we(e,t){if(!t.exists){await k.remove(e);return}await k.outputFile(e,t.contents);}async function ve(e){let{buildWorkspaceRegistrySummary:t,WORKSPACE_REGISTRY_SUMMARY_RELATIVE_PATH:r}=await import('./workspace-registry-summary-ZNTXSUI4.js'),o=await t(e.workspacePath,{now:e.now,contract:e.contract}),n=a$3(e.workspacePath,r),i=c=>{if(!c||typeof c!="object"||Array.isArray(c))return JSON.stringify(c);let{generatedAt:l,...m}=c;return JSON.stringify(m)};if(await k.pathExists(e.contractPath)&&await k.pathExists(n)){let[c,l]=await Promise.all([k.readJson(e.contractPath),k.readJson(n)]);if(i(c)===i(e.contract)&&i(l)===i(o))return}b(v,e.contract),b(r,o),await f$1(e.workspacePath,v,async()=>{let[c,l]=await Promise.all([ke(e.contractPath),ke(n)]);try{if(e.contractPath===a$3(e.workspacePath,v)?await h(e.workspacePath,v,e.contract):(await k.ensureDir(f__default.dirname(e.contractPath)),await k.writeJson(e.contractPath,e.contract,{spaces:2})),process.env.WORKSPAI_TEST_FAIL_WORKSPACE_REGISTRY_PUBLISH==="1")throw new Error("Injected workspace registry summary publication failure.");await h(e.workspacePath,r,o);}catch(m){let s=(await Promise.allSettled([we(e.contractPath,c),we(n,l)])).filter(p=>p.status==="rejected");throw s.length>0?new AggregateError([m,...s.map(p=>p.reason)],"Workspace contract publication failed and rollback was incomplete."):m}});}async function je(e){let t=e.contractPath??(await g(e.workspacePath,v)||a$3(e.workspacePath,v)),r=await k.readJson(t);return {contractPath:t,contract:r}}var Ke={metadata:[".workspai/project.json",".workspai/context.json",".rapidkit/project.json",".rapidkit/context.json"],manifests:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","pyproject.toml","poetry.lock","requirements.txt","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","Gemfile","composer.json"],entrypoints:["src/main.ts","src/index.ts","src/app.ts","src/main.js","src/index.js","main.py","app/main.py","manage.py","main.go","cmd/main.go","Program.cs"],apiSpecifications:["openapi.yaml","openapi.yml","openapi.json","swagger.yaml","swagger.yml","swagger.json"],infrastructure:["Dockerfile","docker-compose.yml","docker-compose.yaml","compose.yml","compose.yaml","k8s","kubernetes","terraform"],documentation:["README.md","ARCHITECTURE.md","CONTRIBUTING.md","docs"]};function Ve(e,t){return d(e,t.relativePath,{...t.externalPath?{absolutePath:t.externalPath}:{}})}async function Me(e){let t={metadata:[],manifests:[],entrypoints:[],apiSpecifications:[],infrastructure:[],documentation:[]};for(let[r,o]of Object.entries(Ke))for(let n of o)await k.pathExists(f__default.join(e,n))&&t[r].push(n);try{let r=await k.readdir(e,{withFileTypes:true});for(let o of r)o.isFile()&&(o.name.endsWith(".csproj")||o.name.endsWith(".sln"))&&t.manifests.push(o.name),o.isFile()&&o.name.endsWith(".tf")&&t.infrastructure.push(o.name);}catch{}for(let r of Object.values(t))r.sort((o,n)=>o.localeCompare(n));return t}function _(e){return !e||typeof e!="object"||Array.isArray(e)?[]:Object.keys(e).sort((t,r)=>t.localeCompare(r))}async function Fe(e){try{let t=await k.readJson(f__default.join(e,"package.json")),r={runtime:_(t.dependencies),development:_(t.devDependencies),peer:_(t.peerDependencies),optional:_(t.optionalDependencies)};return {...typeof t.name=="string"?{name:t.name}:{},...typeof t.version=="string"?{version:t.version}:{},...typeof t.private=="boolean"?{private:t.private}:{},scripts:_(t.scripts),dependencies:r,dependencyCount:new Set(Object.values(r).flat()).size}}catch{return}}async function Le(e){for(let t of [".env.example",".env.sample",".env.template"])try{return (await k.readFile(f__default.join(e,t),"utf8")).split(/\r?\n/).map(o=>o.trim()).filter(o=>o.length>0&&!o.startsWith("#")&&o.includes("=")).map(o=>o.slice(0,o.indexOf("=")).trim()).filter(o=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(o)).sort((o,n)=>o.localeCompare(n))}catch{}return []}function He(e,t){try{let r=D$1(e);if(r.engine!=="unknown")return r;let o=k.pathExistsSync(f__default.join(e,"package.json"))?"npm":k.pathExistsSync(f__default.join(e,"pyproject.toml"))?"python":k.pathExistsSync(f__default.join(e,"requirements.txt"))?"pip":"unknown";return {...r,engine:o,runtime:t.runtime??r.runtime,framework:t.framework??r.framework,frameworkDisplayName:t.framework??r.frameworkDisplayName}}catch{return {schemaVersion:1,scope:"project",projectRoot:null,engine:"unknown",runtime:"unknown",runtimeCandidates:["unknown"],compositeRuntime:false,lifecycleCoverage:"complete",framework:"unknown",frameworkDisplayName:"Unknown",frameworkConfidence:"low",frameworkSupportTier:"observed",runtimeSupportTier:"observed",runtimeDoctorSupport:"observed",moduleSupport:false,fleetStages:[],localOnlyCommands:[],commandMap:{},supportedCommands:[],unsupportedCommands:[],globalCommands:[]}}}function Je(e,t,r){let o=e.projects.map(n=>({id:n.slug,path:n.relativePath,runtime:n.runtime,framework:n.framework}));return {schemaVersion:"workspace-dependency-graph.v1",generatedAt:t,nodes:o,edges:[],stats:{nodeCount:o.length,edgeCount:0,inferredEdges:0,contractEdges:0,manualEdges:0,authoritativeEdges:0,lowConfidenceEdges:0,orphanCount:o.length,connectedNodeCount:0,density:0,edgeCoverageRatio:o.length===0?1:0,evidenceCoverageRatio:1,hotspotCount:0,hasCycle:false},diagnostics:[{code:"graph.enrichment.failed",severity:"warning",message:r,recommendation:"Review project manifests and graph overrides, then rerun workspace contract graph."}]}}async function jt(e){let{contractPath:t,contract:r}=await je(e),o=e.now??new Date,n=o.toISOString(),{buildWorkspaceModel:i,workspaceModelProjectTopology:c}=await import('./workspace-model-72SJ6WXT.js'),{hashWorkspaceModel:l}=await import('./workspace-model-hash-ZXYPIGCW.js'),m=await i({workspacePath:e.workspacePath,includeEvidence:false,now:o}),d=c(m)??Je(r,n,"The canonical Workspace Model did not provide a project dependency topology."),s=new Map(d.nodes.map(a=>[a.id,a.operationalProfile])),{buildWorkspaceKnowledgeGraph:p$1}=await import('./workspace-knowledge-graph-EFC4TUDZ.js'),g=await p$1({workspacePath:e.workspacePath,workspace:{name:m.workspace.name,...m.workspace.profile?{profile:m.workspace.profile}:{}},contract:r,projectTopology:d,now:o,projects:m.projects.map(a=>({id:a.name,path:a.path,...a.absolutePath?{absolutePath:a.absolutePath}:{},runtime:a.runtime,runtimeCandidates:a.runtimeCandidates,framework:a.framework,...a.kit?{kit:a.kit}:{}})),source:{kind:"workspace-model",artifact:p.model,hashAlgorithm:"sha256",hash:l(m)}}),h=await Promise.all(r.projects.map(async a=>{let u=Ve(e.workspacePath,a),[E,j,S]=await Promise.all([Me(u),Fe(u),Le(u)]),y=He(u,a);return {id:a.slug,label:a.slug,relativePath:a.relativePath,source:a.source,relationship:a.relationship,externalPath:a.externalPath,runtime:a.runtime??y.runtime,framework:a.framework??y.framework,kit:a.kit,modules:a.modules,ports:a.ports,apis:a.contracts.apis,owns:a.contracts.owns,env:[...new Set([...a.contracts.env,...S])].sort(($,K)=>$.localeCompare(K)),contracts:{owns:[...a.contracts.owns],apis:[...a.contracts.apis],publishes:[...a.contracts.publishes],consumes:[...a.contracts.consumes],dependsOn:[...a.contracts.dependsOn],env:[...a.contracts.env]},capabilities:{engine:y.engine,supportTier:y.frameworkSupportTier,runtimeSupportTier:y.runtimeSupportTier,doctorSupport:y.runtimeDoctorSupport,moduleSupport:y.moduleSupport,fleetStages:[...y.fleetStages],localOnlyCommands:[...y.localOnlyCommands],supportedCommands:[...y.supportedCommands]},files:E,...j?{package:j}:{},...s.get(a.slug)?{operationalProfile:s.get(a.slug)}:{}}})),P=new Set(h.map(a=>a.id)),C=new Map,b=[];for(let a of r.projects){for(let u of a.contracts.dependsOn||[])P.has(u)&&b.push({from:u,to:a.slug,type:"dependency",label:"dependsOn"});for(let u of a.contracts.publishes||[])C.has(u)||C.set(u,new Set),C.get(u)?.add(a.slug);}for(let a of r.projects)for(let u of a.contracts.consumes||[]){let E=C.get(u);if(E)for(let j of E)j!==a.slug&&b.push({from:j,to:a.slug,type:"event",label:u});}let w={schemaVersion:1,kind:"rapidkit.workspace.contract.graph",workspace:r.workspace,generatedAt:n,nodes:h.sort((a,u)=>a.id.localeCompare(u.id)),edges:b.sort((a,u)=>`${a.from}:${a.to}:${a.type}:${a.label}`.localeCompare(`${u.from}:${u.to}:${u.type}:${u.label}`)),dependencyGraph:d,knowledgeGraph:g,semantics:{legacyEdges:"producer-to-consumer",dependencyGraphEdges:"consumer-to-dependency"},summary:{projectCount:h.length,dependencyEdges:b.filter(a=>a.type==="dependency").length,eventEdges:b.filter(a=>a.type==="event").length,portCount:h.reduce((a,u)=>a+u.ports.length,0),apiCount:h.reduce((a,u)=>a+u.apis.length,0),relationshipEdges:d.stats.edgeCount,inferredEdges:d.stats.inferredEdges,authoritativeEdges:d.stats.authoritativeEdges,orphanProjects:d.stats.orphanCount,hotspotProjects:d.stats.hotspotCount,evidenceCoverageRatio:d.stats.evidenceCoverageRatio,edgeCoverageRatio:d.stats.edgeCoverageRatio,connectedProjects:d.stats.connectedNodeCount,lowConfidenceEdges:d.stats.lowConfidenceEdges,hasCycle:d.stats.hasCycle,manifestCount:h.reduce((a,u)=>a+u.files.manifests.length,0),entrypointCount:h.reduce((a,u)=>a+u.files.entrypoints.length,0),diagnostics:d.diagnostics?.length??0,relationshipKinds:Object.fromEntries(me.map(a=>[a,d.edges.filter(u=>u.kind===a).length])),relationshipSources:Object.fromEntries(ge.map(a=>[a,d.edges.filter(u=>u.source===a).length])),entityCount:g.quality.entityCount,knowledgeRelations:g.quality.relationCount,proofCount:g.quality.proofCount,providerCount:g.providers.length,knowledgeUnknowns:g.quality.unknownCount}};return {contractPath:t,graph:w}}async function be(e){let t=e.contract?{contractPath:e.contractPath??a$3(e.workspacePath,v),contract:e.contract}:await je(e),{contractPath:r,contract:o}=t,n=[],i=[];o.kind!=="rapidkit.workspace.contract"&&n.push("Contract kind must be rapidkit.workspace.contract."),o.schemaVersion!==G&&n.push(`Contract schemaVersion must be ${G}.`),o.workspace?.name||n.push("Contract workspace.name is required."),Array.isArray(o.projects)||n.push("Contract projects must be an array.");let c=new Set,l$1=new Map;for(let s of o.projects||[]){if(!s.slug){n.push("Every project must declare slug.");continue}c.has(s.slug)&&n.push(`Duplicate project slug: ${s.slug}.`),c.add(s.slug),s.relativePath?z(s.relativePath)||n.push(`Project ${s.slug} declares unsafe relativePath: ${s.relativePath}.`):n.push(`Project ${s.slug} must declare relativePath.`),s.externalPath&&(s.relationship==="adopted"||s.source==="adopted-local"||s.source==="local-folder"||s.source==="git-url"||n.push(`Project ${s.slug} declares externalPath without imported/adopted provenance.`),f__default.isAbsolute(s.externalPath)||n.push(`Project ${s.slug} declares non-absolute externalPath.`));for(let p of s.ports||[]){(!Number.isInteger(p.port)||p.port<1||p.port>65535)&&n.push(`Project ${s.slug} declares invalid port: ${p.port}.`);let g=l$1.get(p.port);g&&n.push(`Port ${p.port} is claimed by both ${g} and ${s.slug}.`),l$1.set(p.port,s.slug);}for(let p of s.contracts?.apis||[])(!p.name?.trim()||!p.basePath?.startsWith("/"))&&n.push(`Project ${s.slug} declares invalid API contract.`);for(let p of [...s.contracts?.publishes||[],...s.contracts?.consumes||[]])p.trim()||n.push(`Project ${s.slug} declares an empty event contract.`);for(let p of s.contracts?.env||[])/^[A-Z_][A-Z0-9_]*$/.test(p)||n.push(`Project ${s.slug} declares invalid env contract: ${p}.`);for(let p of s.contracts?.dependsOn||[])c.has(p);}for(let s of o.projects||[])for(let p of s.contracts?.dependsOn||[])c.has(p)||n.push(`Project ${s.slug} depends on unknown project: ${p}.`);i.push({id:"schema",status:o.kind==="rapidkit.workspace.contract"&&o.schemaVersion===G?"passed":"failed",message:"Contract schema and kind are valid."}),i.push({id:"projects",status:Array.isArray(o.projects)?"passed":"failed",message:`Contract declares ${Array.isArray(o.projects)?o.projects.length:0} project(s).`}),i.push({id:"ports",status:n.some(s=>s.toLowerCase().includes("port"))?"failed":"passed",message:"Project port declarations are valid and collision-free."}),i.push({id:"dependencies",status:n.some(s=>s.includes("depends on unknown project"))?"failed":"passed",message:"Project dependencies point to known project slugs."}),i.push({id:"contracts",status:n.some(s=>s.includes("unsafe relativePath")||s.includes("invalid API contract")||s.includes("event contract")||s.includes("env contract"))?"failed":"passed",message:"Project path, API, event, and env contracts are valid."});let m=await l(e.workspacePath);if(m.moduleCount>0){for(let s of m.issues)n.push(`${f__default.basename(s.projectRoot)}: ${s.message} (slug=${s.slug})`);i.push({id:"module-paths",status:m.status,message:m.status==="passed"?`All ${m.moduleCount} registered module(s) resolve under canonical paths.`:`${m.issues.length} registered module(s) missing canonical install paths.`});}else e.strict&&i.push({id:"module-paths",status:"passed",message:"No registry-backed modules declared in workspace projects."});return {status:n.length>0?"failed":"passed",contractPath:r,projectCount:Array.isArray(o.projects)?o.projects.length:0,checks:i,violations:n}}async function bt(e){let t=f__default.resolve(e.workspacePath),r={schemaVersion:_e,generatedAt:e.generatedAt??new Date().toISOString(),status:e.result.status,contractPath:e.result.contractPath,projectCount:e.result.projectCount,checks:e.result.checks,violations:e.result.violations};return h(t,xe,de(r))}
|
|
2
|
+
export{I as a,Xe as b,et as c,de as d,ot as e,me as f,v as g,xe as h,G as i,_e as j,D as k,De as l,Ee as m,Et as n,vt as o,je as p,jt as q,be as r,bt as s};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {f,e,h as h$1,g}from'./chunk-XF65LQ6M.js';import {a,b}from'./chunk-
|
|
1
|
+
import {f,e,h as h$1,g}from'./chunk-XF65LQ6M.js';import {a,b}from'./chunk-SVO2GGTV.js';import {b as b$1,c as c$1}from'./chunk-NSC4VWV2.js';import {a as a$1}from'./chunk-NMXGSVMD.js';import {p,a as a$2}from'./chunk-YLLCZMKP.js';import {k as k$2,m,l}from'./chunk-H4YHIOCT.js';import {h}from'./chunk-BLEIUQL6.js';import {k,t,u}from'./chunk-VQZ5PI5J.js';import {p as p$1,q}from'./chunk-ODK4LCEL.js';import k$1 from'fs';import c from'path';import s from'chalk';var ee=new Set([".git",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function E(e){try{return await k$1.promises.access(e,k$1.constants.F_OK),true}catch{return false}}async function F(e){try{let n=JSON.parse(await k$1.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function C(e){try{return await k$1.promises.readFile(e,"utf-8")}catch{return ""}}function re(e){return a(e)}async function oe(e,n){return await ne([...u(e,"project.json"),...u(e,"context.json")])?true:b(e)?false:c.resolve(e)===c.resolve(n)?k$2(e).length>0:k$2(e).length>0}async function ie(e){let n=await a$1(e,{skipDirs:ee,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:oe}),o=(await a$2(e)).filter(i=>i.relationship==="adopted"||i.source==="adopted-local").map(i=>c.resolve(i.path)).filter(i=>k$1.existsSync(i)),r=[...new Set([...n.map(i=>c.resolve(i)),...o])];return r.length>0?r:b(e)?[]:k$2(e).length>0?[e]:[]}function ae(e,n){return c.relative(e,n).replace(/\\/g,"/")||"."}async function T(e,n){for(let t of n)if(await E(c.join(e,t)))return true;return false}async function se(e,n,t=4){let o=async(r,i)=>{if(i>t)return false;let l;try{l=await k$1.promises.readdir(r,{withFileTypes:true});}catch{return false}for(let a of l)if(a.isFile()&&n.has(a.name.toLowerCase())||a.isDirectory()&&!a.isSymbolicLink()&&!ee.has(a.name)&&await o(c.join(r,a.name),i+1))return true;return false};return o(e,0)}async function ne(e){for(let n of e)if(await E(n))return true;return false}async function te(e){for(let n of e){let t=await F(n);if(t)return t}return null}async function ce(e,n){if(await T(e,[".env",".env.local"]))return true;let t=n?.contracts&&typeof n.contracts=="object"?n.contracts:null;if(Array.isArray(t?.env)&&t.env.length>0)return true;let o=await F(c.join(e,"package.json")),r={...o?.dependencies??{},...o?.devDependencies??{}};if(Object.keys(r).some(a=>/^(?:dotenv|dotenv-flow|env-cmd)$/iu.test(a)))return true;let i=await C(c.join(e,"pyproject.toml"));if(/\b(?:python-dotenv|pydantic-settings)\b/iu.test(i))return true;let l=[await C(c.join(e,"compose.yaml")),await C(c.join(e,"compose.yml")),await C(c.join(e,"docker-compose.yml")),await C(c.join(e,"docker-compose.yaml"))].join(`
|
|
2
2
|
`);return /^\s*(?:env_file|environment)\s*:/imu.test(l)}async function de(e){return (await g(e)).detected}async function le(e){let n=await F(c.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function w(e,n,t,o,r,i,l){return {id:e,severity:n,target:t,title:o,detail:r,remediation:i,...l&&l.length>0?{files:[...l]}:{}}}function pe(e){let n=e.reduce((t,o)=>o.severity==="fail"?t+28:o.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function ue(e,n,t){let o=await te(u(n,"project.json")),r=m(n,o),i=l(n),l$1=r.runtime==="unknown"?i[0]||"unknown":r.runtime,a=[l$1,...i.filter(G=>G!==l$1)],u$1=r.key==="unknown"&&new Set(a.filter(G=>G!=="unknown")).size>1,b=await b$1(n,o,{runtime:l$1,framework:r.key}),m$1=["backend","service","worker","agent"].includes(b),h=["backend","service","worker"].includes(b),v=m$1&&/^(?:fastapi|django|flask|nestjs|express|fastify|springboot|gofiber|gogin|dotnet-webapi|laravel|rails|phoenix|axum|actix|rocket)$/u.test(r.key),j=ae(e,n),f=j,$=await le(n),P=await ne([...u(n,"project.json"),...u(n,"context.json")]),x=await de(n),R=await T(n,["Dockerfile","dockerfile"]),g=await T(n,[".env.example","env.example","config/env.example"])||await se(n,new Set([".env.example","env.example"])),p=await ce(n,o),d=await c$1({projectPath:n,declaration:t?.governance}),z=d.ci.status==="repository",D=await h$1(n),y=[];return r.key==="unknown"&&y.push(w(u$1?"project.stack.aggregate":"project.stack.unknown",u$1?"info":"fail",f,u$1?"Multi-runtime aggregate boundary detected":"Project stack is unknown",u$1?`Workspai detected multiple runtimes (${a.join(", ")}) and intentionally did not promote one nested framework as the aggregate project identity.`:"Workspai cannot confidently classify this backend project.",u$1?"Adopt independently operated nested projects when they need separate lifecycle, ownership, or release evidence.":"Add .workspai/project.json metadata or import the project with `workspai import`.")),P||y.push(w("project.marker.missing","warn",f,"Workspai marker is missing","The project can be detected by files, but it is not registered with Workspai metadata.","Run `workspai import <path>` from a workspace or create the project through Workspai.")),x||y.push(w("project.tests.missing","warn",f,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `workspai workspace run test --affected` can gate changes.")),m$1&&p&&!g&&y.push(w("project.env.example.missing","info",f,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.",[".env.example"])),d.ci.status==="unknown"?y.push(w("project.ci.missing","warn",f,"CI governance is not proven","No repository CI surface or canonical external CI declaration was found for this project.","Add repository CI configuration or declare the external CI authority in the workspace contract.",[".github/workflows/ci.yml"])):d.ci.status==="external-observed"&&y.push(w("project.ci.external-observed","info",f,"Continuous integration appears externally managed",`Repository documentation references an external CI control plane (${d.ci.evidence.join(", ")}).`,"Declare the external CI provider in the canonical workspace contract when authoritative release gating depends on it.")),v&&!D&&y.push(w("project.health.missing","info",f,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),h&&!R&&y.push(w("project.container.missing","info",f,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.",["Dockerfile"])),{name:typeof o?.name=="string"&&o.name.trim()?o.name.trim():c.basename(n),path:n,relativePath:j,runtime:l$1,runtimeCandidates:a,framework:r.key,confidence:r.confidence,supportTier:r.supportTier,hasRapidKitMarker:P,hasTests:x,hasDockerfile:R,hasEnvExample:g,hasCiConfig:z,governance:d,hasHealthEndpoint:D,scripts:$,findings:y,score:pe(y)}}function me(e){return e.name.toLowerCase()}async function fe(e){let n=new Map(e.map(r=>[me(r),r])),t=[];for(let r of e){let i=await F(c.join(r.path,"package.json")),l={...i?.dependencies??{},...i?.devDependencies??{},...i?.peerDependencies??{}};for(let u of Object.keys(l)){let b=u.replace(/^@[^/]+\//,"").toLowerCase(),m=n.get(b);m&&m.relativePath!==r.relativePath&&t.push({from:r.relativePath,to:m.relativePath,kind:"package"});}let a=await C(c.join(r.path,"pyproject.toml"));for(let u of e)u.relativePath!==r.relativePath&&a.includes(u.name)&&t.push({from:r.relativePath,to:u.relativePath,kind:"workspace-reference"});}let o=new Set;return t.filter(r=>{let i=`${r.from}\0${r.to}\0${r.kind}`;return o.has(i)?false:(o.add(i),true)})}function ge(e,n){let t=new Map;for(let o of e)t.set(o.relativePath,{project:o.relativePath,directDependents:0,directDependencies:0});for(let o of n){let r=t.get(o.from),i=t.get(o.to);r&&(r.directDependencies+=1),i&&(i.directDependents+=1);}return Array.from(t.values()).sort((o,r)=>r.directDependents-o.directDependents||r.directDependencies-o.directDependencies)}async function ye(e){let n=await te(t(e,"workspace.json"));return typeof n?.profile=="string"?n.profile:null}function we(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function ke(e){if(e.projectCount===0)return e.workspaceDetected?["Add your first project: npx workspai create project <name> --kit <kit>","Import an existing service: npx workspai import <path>"]:["Create a Workspai workspace: npx workspai create workspace my-workspace --profile polyglot","Import an existing service: npx workspai import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `workspai bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `workspai import <path>` or recreate them via `workspai create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `workspai workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasCanonicalGraph||n.push("Generate canonical topology with `workspai workspace model --write --include-evidence`."),n.push("Run `workspai autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function Te(e$1={}){let n=c.resolve(e$1.workspacePath||process.cwd());if(!await E(n))throw new Error(`Workspace path does not exist: ${n}`);let t=re(n)??n,o=k(t),r=await ye(t),i=await ie(t),l;try{l=(await p({workspacePath:t})).contract;}catch{}let a=await Promise.all(i.map(p=>{let d=l?.projects.find(z=>{let D=z.externalPath??z.relativePath;return c.resolve(t,D)===c.resolve(p)});return ue(t,p,d)})),u=await fe(a),b=ge(a,u),m=[];o||m.push(w("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered Workspai workspace.","Run `workspai create workspace` or `workspai bootstrap --profile polyglot` in a workspace root.")),a.length===0&&m.push(w("workspace.projects.missing","warn",".","No backend projects detected","Workspai did not find runtime markers or project metadata under this root.","Create a project with `workspai create project` or import one with `workspai import <path>`."));let h$1=[...m,...a.flatMap(p=>p.findings)],v=we(h$1),j={};for(let p of a)for(let d of p.runtimeCandidates)j[d]=(j[d]||0)+1;let f$1=a.length>0?Math.round(a.reduce((p,d)=>p+d.score,0)/a.length):0,$=m.reduce((p,d)=>p+(d.severity==="fail"?20:d.severity==="warn"?8:2),0),P=Math.max(0,f$1-$),x=a.length===0&&v.fail===0&&h$1.length>0&&h$1.every(p=>p.id==="workspace.projects.missing"&&p.severity==="warn"),R=v.fail>0||e$1.strict&&v.warn>0&&!x?"blocked":v.warn>0?"needs-attention":"ready",g={schemaVersion:q.analyze,generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:o,profile:r,summary:{statusScope:"source-structure",releaseReadiness:"not-evaluated",score:P,verdict:R,projectCount:a.length,runtimeCount:Object.keys(j).length,findings:v},runtimes:j,projects:a,dependencyGraph:{status:u.length>0?"generated":"empty",edges:u,topImpactedProjects:b.slice(0,5)},findings:h$1,nextActions:ke({findings:h$1,projectCount:a.length,hasCanonicalGraph:await E(c.join(t,p$1.knowledgeGraph)),workspaceDetected:o}),enterpriseControls:{jsonReady:true,ciGateCommand:"workspai analyze --json --strict",releaseGateCommand:"workspai autopilot release --mode enforce --json",evidencePath:p$1.analyze}};if(e$1.output&&(await k$1.promises.mkdir(c.dirname(c.resolve(e$1.output)),{recursive:true}),await k$1.promises.writeFile(c.resolve(e$1.output),`${JSON.stringify(g,null,2)}
|
|
3
3
|
`)),!e$1.output&&o){let p=f(g,{commandId:"workspaceAnalyze",exitCode:g.summary.verdict==="blocked"?2:g.summary.verdict==="needs-attention"?1:0,generatedAt:g.generatedAt,blockers:g.findings.filter(d=>d.severity==="fail").map(d=>d.title).slice(0,12),runId:e()});await h(t,p$1.analyze,p);}return g}function Ne(e){let n=e.summary.verdict==="ready"?s.green:e.summary.verdict==="needs-attention"?s.yellow:s.red;if(console.log(s.bold(`
|
|
4
4
|
Workspai Workspace Analysis
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {c}from'./chunk-KDVNRNDU.js';import {j,i,d as d$1,f as f$1,c as c$2,e,h}from'./chunk-G5UCEXP6.js';import {g}from'./chunk-5HNQIMGW.js';import {a as a$1}from'./chunk-VWBWDDU2.js';import {c as c$3}from'./chunk-ZI54C2AO.js';import {b}from'./chunk-OA2YJN22.js';import {b as b$1}from'./chunk-ZGVODK5C.js';import {d as d$2}from'./chunk-ROOPODG6.js';import {f,i as i$1}from'./chunk-BLEIUQL6.js';import {a}from'./chunk-AFIFZTOY.js';import {d,c as c$1}from'./chunk-EWZZUQBR.js';import {q,p}from'./chunk-ODK4LCEL.js';import R from'path';import _ from'fs-extra';var we=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/,ke=/(?:^|\s)(?:\/(?:home|Users|private|var|tmp|mnt|opt|srv|root|workspace|workspaces|data|Volumes|etc|usr|run|dev|proc|sys)\/[^\s]+|[A-Za-z]:[\\/][^\s]+|\\\\[^\\\s]+\\[^\s]+)/,ve=/(?:-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\b(?:github_pat_|gh[pousr]_|glpat-|npm_|xox[baprs]-|sk-(?:proj-)?)[A-Za-z0-9_-]{12,}|\b(?:AKIA|ASIA)[A-Z0-9]{16}\b|\bAIza[A-Za-z0-9_-]{20,}|\bBearer\s+[A-Za-z0-9._~+/-]{16,}|[a-z][a-z0-9+.-]*:\/\/[^\s:/]+:[^\s@/]+@|\b(?:password|passwd|secret|token|api[_-]?key)\s*[:=]\s*[^\s]{6,})/i,ye=[{category:"test-coverage",patterns:[/\b(?:test\s+)?coverage\b/i,/\bcoverage\s+(?:to|above|at least)\b/i]},{category:"dependency-security",patterns:[/\b(?:dependency|dependencies|package|packages)\b.*\b(?:security|vulnerab|audit)\b/i,/\b(?:security|vulnerab|audit)\b.*\b(?:dependency|dependencies|package|packages)\b/i]},{category:"release-readiness",patterns:[/\brelease[ -]readiness\b/i,/\bready (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare\b[^\n]{0,80}\bfor release\b/i]},{category:"defect-repair",patterns:[/\b(?:fix|repair|resolve|debug)\b.*\b(?:bug|error|failure|issue|regression)\b/i]},{category:"performance",patterns:[/\b(?:performance|latency|throughput|cpu|optimi[sz]e|faster|slower)\b/i,/\b(?:memory\s+(?:allocation|consumption|footprint|leak|pressure|usage)|out[ -]of[ -]memory|heap|ram)\b/i]},{category:"refactor",patterns:[/\b(?:refactor|restructure|decouple|extract|simplify|cleanup|clean up)\b/i]},{category:"documentation",patterns:[/\b(?:document|documentation|readme|guide|tutorial|docs)\b/i]},{category:"feature-change",patterns:[/\b(?:add|build|create|enforce|enhance|harden|implement|improve|introduce|support)\b/i]},{category:"system-understanding",patterns:[/\b(?:understand|explain|map|find|where|how|architecture|analy[sz]e|search)\b/i]}];function Pe(e){if(typeof e!="string")throw new Error("Goal intent must be text.");let t=e.trim().replace(/\s+/g," ");if(!t)throw new Error("Goal intent cannot be empty.");if(t.length>2e3)throw new Error("Goal intent exceeds the 2000 character safety limit.");if(we.test(t))throw new Error("Goal intent contains unsupported control characters.");if(ke.test(t))throw new Error("Goal intent contains a machine-local absolute path. Use a workspace-relative path or project scope.");if(ve.test(t))throw new Error("Goal intent appears to contain secret material and was not persisted.");return t}function je(e){let t=e.match(/\b(?:coverage\D{0,24})?((?:100(?:\.0+)?|\d{1,2}(?:\.\d+)?))\s*(?:%|percent(?:age)?(?:\s+points?)?)/i);if(!t||!/coverage/i.test(e))return null;let r=Number(t[1]);return Number.isFinite(r)&&r>=0&&r<=100?r:null}var oe=[{runtime:"cpp",patterns:[/\bc\+\+/i,/\bcpp\b/i]},{runtime:"dotnet",patterns:[/\.net\b/i,/\bdotnet\b/i,/\bc#/i,/\bcsharp\b/i]},{runtime:"node",patterns:[/\bnode(?:\.js)?\b/i,/\btypescript\b/i,/\bjavascript\b/i,/\b(?:js|ts)\b/i]},{runtime:"python",patterns:[/\bpython\b/i,/\bpytest\b/i]},{runtime:"go",patterns:[/\bgolang\b/i,/\bgo(?:\s+(?:test|coverage|tests))\b/i]},{runtime:"java",patterns:[/\bjava\b/i,/\bjunit\b/i,/\bjacoco\b/i]},{runtime:"rust",patterns:[/\brust\b/i,/\bcargo\b/i]},{runtime:"php",patterns:[/\bphp\b/i,/\bphpunit\b/i]},{runtime:"ruby",patterns:[/\bruby\b/i,/\brspec\b/i]},{runtime:"kotlin",patterns:[/\bkotlin\b/i]},{runtime:"scala",patterns:[/\bscala\b/i]},{runtime:"clojure",patterns:[/\bclojure\b/i]},{runtime:"elixir",patterns:[/\belixir\b/i]},{runtime:"deno",patterns:[/\bdeno\b/i]},{runtime:"bun",patterns:[/\bbun\b/i]},{runtime:"c",patterns:[/\bc(?:\s+(?:test|coverage|tests|code))\b/i]}];function Ge(e){return oe.filter(t=>t.patterns.some(r=>r.test(e))).map(t=>t.runtime)}function K(e,t={}){let r=Pe(e),n=ye.filter(u=>u.patterns.some(j=>j.test(r))).map(u=>u.category),a=n.some(u=>u!=="feature-change")?n.filter(u=>u!=="feature-change"):n,s=a[0]??"feature-change",l=je(r),d=Ge(r),p=d.length===0&&t.selectedCoverageRuntime?[t.selectedCoverageRuntime]:d,m=[...new Set((t.availableCoverageRuntimes??[]).filter(u=>oe.some(j=>j.runtime===u)))].sort(),b=[];return a.length>1&&a[0]!=="test-coverage"&&b.push(`The intent also contains signals for: ${a.slice(1).join(", ")}.`),s==="test-coverage"&&l===null&&b.push("A numeric test coverage target is required for machine verification."),s==="test-coverage"&&p.length>1&&b.push(`The Goal names multiple coverage runtimes: ${p.join(", ")}. Select one runtime per Goal.`),s==="test-coverage"&&p.length===0&&m.length>1&&b.push(`Coverage scope is ambiguous across detected runtimes: ${m.join(", ")}. Name one runtime or language in the Goal.`),s==="test-coverage"&&p.length===1&&m.length>0&&!m.includes(p[0])&&b.push(`The requested ${p[0]} coverage runtime is not present in the selected scope. Detected runtimes: ${m.join(", ")}.`),{original:r,normalized:r.toLocaleLowerCase("en-US"),statement:r.replace(/[.!?]+$/,""),category:s,confidence:a.length===1?"high":a.length>1?"medium":"low",ambiguities:b,...l===null?{}:{requestedTarget:{metric:"test-coverage-percent",operator:"at-least",value:l,...p.length===1?{runtime:p[0]}:{}}}}}function ae(e){let t={"test-coverage":["test suite coverage configuration instrumentation","CI tests LCOV Cobertura JaCoCo LLVM coverage"],"dependency-security":["dependency manifest lockfile security audit vulnerability"],"release-readiness":["release pipeline readiness gates build test deploy"],"defect-repair":["failure error test implementation call path"],"feature-change":["API implementation module dependency tests"],refactor:["module dependency ownership implementation tests"],performance:["performance benchmark latency throughput runtime"],documentation:["documentation README guide architecture decision"],"system-understanding":["architecture service API dependency ownership"]};return [...new Set([e.statement,...t[e.category]])].slice(0,3)}var se="contracts/workspace-intelligence/goal-pack.v1.json",ie="contracts/workspace-intelligence/goal-agent-handoff.v1.json",Ce="contracts/workspace-intelligence/goal-plan-result.v1.json",ue="contracts/workspace-intelligence/goal-index.v1.json",de=new Set(["node","bun","deno","python","go","java","dotnet","rust","php","ruby","elixir","clojure","scala","kotlin","c","cpp"]);function Ae(e,t){let r=e.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)??[],n=new Set(t.map(m=>m.toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"")).filter(Boolean)),a=[];for(let m=0;m<r.length;){let b=0;for(let u=Math.min(4,r.length-m);u>=1;u-=1){let j=r.slice(m,m+u).join("").toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"");if(n.has(j)){b=u;break}}if(b>0){m+=b;continue}a.push(r[m]),m+=1;}let s=a.findIndex((m,b)=>{let u=m.toLocaleLowerCase("en-US"),j=a[b+1]?.toLocaleLowerCase("en-US");return u==="without"&&["breaking","changing","modifying","removing"].includes(j??"")||u==="while"&&["keeping","maintaining","preserving"].includes(j??"")}),l=s>=2?a.slice(0,s):a,d=l.length>=2?l.join(" "):e;if(s<2)return [d];let p=a.slice(s).filter(m=>!["without","while","breaking","changing","modifying","removing","keeping","maintaining","preserving"].includes(m.toLocaleLowerCase("en-US")));return p.length>0?[d,p.join(" ")]:[d]}function ce(e){return e.split(R.sep).join("/")}function V(e,t){return d$2(e,t.path,{...t.absolutePath?{absolutePath:t.absolutePath}:{}})}function le(e){let t=e.requested.trim().replace(/^project:/,"");if(!t)throw new Error("Project goal scope must name a project.");let r=R.isAbsolute(t)?R.resolve(t):null,n=e.model.projects.filter(a=>a.name===t||ce(a.path)===ce(t)||r!==null&&V(e.workspacePath,a)===r);if(n.length!==1)throw new Error(n.length===0?`Project goal scope was not found in the canonical model: ${t}`:`Project goal scope is ambiguous in the canonical model: ${t}`);return n[0]}async function Re(e){let t=await a$1(e);if(t.status==="miss")throw new Error(`Canonical model and live graph evidence are required (${t.reason}). Run \`workspai workspace intelligence run --for-agent generic --strict --json\` or retry with --refresh.`);let{model:r,graph:n}=t;return a(r,"contracts/workspace-intelligence/workspace-model.v1.json","Goal source model"),a(n,"contracts/workspace-intelligence/workspace-knowledge-graph.v1.json","Goal source graph"),b$1(n,r),{model:r,graph:n}}function pe(e){let t=e.scope.trim();if(t==="workspace")return {kind:"workspace",projects:e.model.projects.map(n=>n.name).sort(),selectionSource:e.selectionSource,resolution:"selected"};let r=t.startsWith("projects:")?"projects:":t.startsWith("project:")&&t.slice(8).includes(",")?"project:":null;if(r){let n=t.slice(r.length).split(",").map(l=>l.trim()).filter(Boolean);if(n.length<2)throw new Error("A project-set Goal scope must name at least two projects.");let a=n.map(l=>le({workspacePath:e.workspacePath,model:e.model,requested:l})),s=[...new Set(a.map(l=>l.name))].sort();if(s.length!==n.length)throw new Error("A project-set Goal scope must not contain duplicate projects.");return {kind:"project-set",projects:s,selectionSource:e.selectionSource,resolution:"selected"}}if(t)return {kind:"project",projects:[le({workspacePath:e.workspacePath,model:e.model,requested:t}).name],selectionSource:e.selectionSource,resolution:"selected"};throw new Error("Goal scope cannot be empty.")}async function Se(e){if(e.explicitScope?.trim())return {scope:pe({workspacePath:e.workspacePath,model:e.model,scope:e.explicitScope,selectionSource:"explicit"}),selectionRequired:false};if(e.invocationProjectPath){let t=R.resolve(e.invocationProjectPath),r=e.model.projects.filter(n=>V(e.workspacePath,n)===t);if(r.length!==1)throw new Error("The invocation project is not represented uniquely in the canonical workspace model. Refresh intelligence or pass --scope explicitly.");return {scope:{kind:"project",projects:[r[0].name],selectionSource:"invocation-project",resolution:"selected"},selectionRequired:false}}if(e.model.projects.length===1)return {scope:{kind:"project",projects:[e.model.projects[0].name],selectionSource:"single-project-workspace",resolution:"selected"},selectionRequired:false};if(e.selectScope){let t=await e.selectScope({workspaceName:e.model.workspace.name,projects:e.model.projects.map(n=>({name:n.name,runtime:n.runtime,runtimeCandidates:[...n.runtimeCandidates].sort(),framework:n.framework})).sort((n,a)=>n.name.localeCompare(a.name))}),r=t.kind==="workspace"?"workspace":t.projects.length===1?`project:${t.projects[0]}`:`projects:${t.projects.join(",")}`;return {scope:pe({workspacePath:e.workspacePath,model:e.model,scope:r,selectionSource:"interactive"}),selectionRequired:false}}return {scope:{kind:"workspace",projects:e.model.projects.map(t=>t.name).sort(),selectionSource:"workspace",resolution:"selection-required"},selectionRequired:true}}function Ee(e,t){if(t.kind==="workspace")return {entities:e.quality.entityCount,relationships:e.quality.relationCount,proofs:e.quality.proofCount,unresolved:e.quality.unknownCount,proofCoveragePercent:Number((e.quality.relationProofCoverageRatio*100).toFixed(2))};let r=new Set(t.projects),n=e.entities.filter(p=>p.projectId!==void 0&&r.has(p.projectId)),a=new Set(n.map(p=>p.id)),s=e.relations.filter(p=>a.has(p.from)||a.has(p.to)),l=new Set([...n.flatMap(p=>p.proofIds),...s.flatMap(p=>p.proofIds)]),d=s.filter(p=>p.proofIds.length>0).length;return {entities:n.length,relationships:s.length,proofs:l.size,unresolved:s.length-d,proofCoveragePercent:s.length===0?100:Number((d/s.length*100).toFixed(2))}}function Ie(e){let t=new Map;for(let n of e){let a=t.get(n.kind)??[];a.push(n),t.set(n.kind,a);}let r=[];for(let n=0;[...t.values()].some(a=>n<a.length);n+=1)for(let a of t.values()){let s=a[n];s&&r.push(s);}return r}async function Te(e){let t=R.join(e.workspacePath,p.intelligenceRun),r=await _.readJson(t).catch(()=>null),a=(Array.isArray(r?.stages)?r.stages:[]).filter(o=>o.status==="blocked"||o.status==="failed").map(o=>String(o.id??"unknown")).sort(),s=r?.status,l={status:s==="passed"?"passed":s==="blocked"||s==="failed"?"blocked":"unknown",artifact:p.intelligenceRun,blockedStages:a},d={status:"not-applicable",runtime:null,runtimeChoices:[],runner:null,existingEvidence:[],prerequisites:[]};if(e.intent.category==="test-coverage"){let o=e.intent.requestedTarget?.runtime;if(e.intent.ambiguities.some(P=>P.startsWith("Coverage scope is ambiguous")||P.startsWith("The Goal names multiple coverage runtimes")||P.startsWith("The selected projects do not share a common canonical coverage runtime")||P.startsWith("The requested ")))d={status:"requires-setup",runtime:o??null,runtimeChoices:e.coverageRuntimeChoices,runner:null,existingEvidence:[],prerequisites:["Select exactly one detected runtime or language for this coverage Goal."]};else {let P=o?e.projects.filter(c=>c.runtimeCandidates.includes(o)):e.projects,i=await Promise.all(P.map(async c=>({project:c,capability:await c$3(V(e.workspacePath,c),o??(de.has(c.runtime)?c.runtime:"unknown"))}))),h=i.map(c=>c.capability.status);d={status:h.includes("unsupported")?"unsupported":h.includes("requires-setup")?"requires-setup":"available",runtime:i.length===1?i[0].capability.runtime:[...new Set(i.map(c=>c.capability.runtime))].join(","),runtimeChoices:e.coverageRuntimeChoices,runner:i.length===1?i[0].capability.runner:[...new Set(i.flatMap(c=>c.capability.runner?[c.capability.runner]:[]))].join(",")||null,existingEvidence:i.flatMap(c=>c.capability.existingEvidence.map(C=>({project:c.project.name,...C}))).filter((c,C,w)=>w.findIndex(k=>k.project===c.project&&k.path===c.path&&k.sha256===c.sha256)===C).sort((c,C)=>c.project.localeCompare(C.project)||c.path.localeCompare(C.path)),prerequisites:[...new Set(i.flatMap(c=>c.capability.prerequisites))].sort()};}}let p$1=ae(e.intent),m=[...Ae(p$1[0],e.projects.map(o=>o.name)),...p$1.slice(1)].filter((o,y,P)=>P.indexOf(o)===y).slice(0,3),b=m.map((o,y)=>{let P=o.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)?.length??0,i=y===0&&P>=4?2:1,h=e.projects.map(w=>{let k=G=>g(e.graph,{query:o,projectId:w.name,...G?{kind:G}:{},limit:60,relationsPerEntity:0,minimumTermMatches:i}).entities,S=k(),me=[...new Set(e.graph.entities.filter(G=>G.projectId===w.name||G.projectId===void 0&&G.identity.scope==="workspace").map(G=>G.kind))].flatMap(G=>k(G).slice(0,8)),F=[...S,...me];return F.filter((G,ge)=>F.findIndex(he=>he.id===G.id)===ge)}),c=[],C=new Set;for(let w=0;h.some(k=>w<k.length);w+=1)for(let k of h){let S=k[w];!S||C.has(S.id)||(C.add(S.id),c.push(S));}return Ie(c)}),u={"test-coverage":["test-suite"],"dependency-security":["package","module"],"release-readiness":["pipeline","deployment","lifecycle-stage"],"defect-repair":["test-suite","lifecycle-stage"],"feature-change":["project","runtime-unit","api","package","module","test-suite"],refactor:["package","module","api","test-suite"],performance:["lifecycle-stage","test-suite","pipeline"],documentation:["document","decision"],"system-understanding":["project","service","api","package","protocol"]},j=new Set(e.projects.map(o=>o.name)),v=e.graph.entities.filter(o=>o.proofIds.length>0&&(!o.projectId||j.has(o.projectId))&&u[e.intent.category].includes(o.kind)).sort((o,y)=>u[e.intent.category].indexOf(o.kind)-u[e.intent.category].indexOf(y.kind)||o.label.localeCompare(y.label)),f=[],M=new Set,E=o=>{!o||f.length>=20||M.has(o.id)||(M.add(o.id),f.push(o));},I=(e.intent.statement.match(/[A-Za-z][A-Za-z0-9+#.-]{1,}/g)??[]).length>=2,g$1=I?b[0]??[]:[];for(let o of g$1.slice(0,12))E(o);if(!I)for(let o of v)E(o);for(let o=0;f.length<20&&b.slice(1).some(y=>o<y.length);o+=1)for(let y of b.slice(1))E(y[o]);if(I)for(let o of v)E(o);for(let o of g$1.slice(12))E(o);let T=f.map(o=>({entityId:o.id,kind:o.kind,label:o.label,proofIds:o.proofIds.slice(0,12)})),L=b[0]?.length??0;return {workspaceIntelligence:l,measurement:d,retrieval:{status:I&&L>=3?"grounded":T.length>0?"partial":"empty",strategy:"deterministic-category-v1",queries:m,anchors:T}}}async function xe(e$1){let t=R.join(e$1,f$1);if(!await _.pathExists(t))return {schemaVersion:e,generatedAt:new Date(0).toISOString(),activeGoalId:null,goals:[]};let r=await _.readJson(t);a(r,ue,"Goal index");try{i(r);}catch(n){let a=h(r);if(!(a!==null&&n instanceof Error&&n.message==="Goal index is inconsistent: activeGoalId must identify the only selected actionable lifecycle entry.")||!a)throw n;return a}return r}function _e(e$1,t,r){let n=e$1.goals.find(l=>l.id===t.id),a=t.state==="ready-to-plan",s={id:t.id,fingerprint:t.fingerprint,objective:t.intent.statement,category:t.intent.category,state:t.state,lifecycle:n?.lifecycle==="cancelled"?"cancelled":a?"active":"planned",scope:t.scope,createdAt:n?.createdAt??t.generatedAt,updatedAt:r,goalPack:t.artifacts.goalPack,agentHandoff:t.artifacts.agentHandoff,...n?.verifiedGoalId?{verifiedGoalId:n.verifiedGoalId}:{},...n?.repairTransactionId?{repairTransactionId:n.repairTransactionId}:{},...n?.repairTransactionIds?{repairTransactionIds:n.repairTransactionIds}:{},...n?.changeTransactionId?{changeTransactionId:n.changeTransactionId}:{},...n?.changeTransactionIds?{changeTransactionIds:n.changeTransactionIds}:{},...n?.verificationReceipt?{verificationReceipt:n.verificationReceipt}:{}};return {schemaVersion:e,generatedAt:r,activeGoalId:s.lifecycle==="active"?t.id:e$1.activeGoalId===t.id?null:e$1.activeGoalId,goals:[...e$1.goals.filter(l=>l.id!==t.id).map(l=>s.lifecycle==="active"&&l.lifecycle==="active"?{...l,lifecycle:"planned",updatedAt:r}:l),s].sort((l,d)=>l.id.localeCompare(d.id))}}async function nt(e){let t=b({startPath:R.resolve(e.startPath),explicitWorkspacePath:e.workspacePath,strict:true,requireProjectMembership:!e.scope?.trim()});if(!t)throw new Error("No canonical Workspai workspace could be resolved.");let r=R.resolve(t.workspacePath);e.refresh&&await c({workspacePath:r,strict:false,agent:"generic"});let{model:n,graph:a$1}=await Re(r),s=await Se({workspacePath:r,invocationProjectPath:t.projectPath,model:n,explicitScope:e.scope,selectScope:e.selectScope}),l=s.scope,d$2=n.projects.filter(i=>l.projects.includes(i.name));if(d$2.length===0)throw new Error("A Goal Pack requires at least one registered project in its selected scope.");let p$1=e.maxAttempts??5;if(!Number.isInteger(p$1)||p$1<1||p$1>25)throw new Error("--max-attempts must be an integer from 1 to 25.");let m=new Date().toISOString(),b$1=d(n),u=d$2.map(i=>({name:i.name,runtimes:[...new Set(i.runtimeCandidates.filter(h=>de.has(h)))].sort()})),j$1=[...new Set(u.flatMap(i=>i.runtimes))].sort(),v=u.length<=1?j$1:u[0].runtimes.filter(i=>u.every(h=>h.runtimes.includes(i))),f$2=K(e.intent,{availableCoverageRuntimes:v,...e.runtime?{selectedCoverageRuntime:e.runtime}:v.length===1?{selectedCoverageRuntime:v[0]}:{}});if(e.runtime&&!v.includes(e.runtime)){let i=e.runtime,h=u.filter(c=>!c.runtimes.includes(i)).map(c=>c.name);throw new Error(d$2.length>1&&h.length>0?`--runtime ${e.runtime} is not canonical for every project in the selected Goal scope. Missing from: ${h.join(", ")}. Split the projects into runtime-compatible Goal scopes.`:`--runtime ${e.runtime} is not present in the canonical Workspace Model for the selected Goal scope. Available runtimes: ${v.join(", ")||"none"}.`)}if(e.runtime&&f$2.category!=="test-coverage")throw new Error("--runtime is valid only for a test-coverage Goal.");if(e.runtime&&f$2.requestedTarget?.runtime&&f$2.requestedTarget.runtime!==e.runtime)throw new Error(`--runtime ${e.runtime} conflicts with the ${f$2.requestedTarget.runtime} runtime named in the Goal intent.`);if(!s.selectionRequired&&f$2.category==="test-coverage"&&f$2.requestedTarget&&!f$2.requestedTarget.runtime&&v.length>1&&!e.runtime&&e.selectCoverageRuntime){let i=await e.selectCoverageRuntime({workspaceName:n.workspace.name,scope:l,projects:d$2.map(h=>({name:h.name,runtime:h.runtime,runtimeCandidates:[...h.runtimeCandidates].sort()})),runtimes:v});if(!v.includes(i))throw new Error("The selected coverage runtime is outside the canonical Goal scope.");f$2=K(e.intent,{availableCoverageRuntimes:v,selectedCoverageRuntime:i});}!s.selectionRequired&&f$2.category==="test-coverage"&&d$2.length>1&&v.length===0&&(f$2={...f$2,ambiguities:[`The selected projects do not share a common canonical coverage runtime: ${u.map(i=>`${i.name} (${i.runtimes.join(", ")||"none"})`).join("; ")}. Split them into runtime-compatible Goal scopes so every selected project is verified.`,...f$2.ambiguities]}),s.selectionRequired&&(f$2={...f$2,ambiguities:[`Goal scope is unresolved across ${l.projects.length} registered projects: ${l.projects.join(", ")}. Select one project, multiple projects, or the entire workspace.`,...f$2.ambiguities]});let M=await Te({workspacePath:r,projects:d$2,graph:a$1,intent:f$2,coverageRuntimeChoices:v}),E={generatedAt:m,intent:f$2,workspaceName:n.workspace.name,scope:l,sourceBinding:{model:{artifact:p.model,schemaVersion:q.model,hashAlgorithm:"sha256",hashSemantics:"workspace-model-structural-v1",hash:b$1,generatedAt:n.generatedAt},graph:{artifact:p.knowledgeGraph,schemaVersion:q.knowledgeGraph,hashAlgorithm:"sha256",hashSemantics:"canonical-json-v1",hash:c$1(a$1),generatedAt:a$1.generatedAt,modelHash:a$1.source.hash,...a$1.source.inputs?.hash?{inputHash:a$1.source.inputs.hash}:{}}},preflight:M,baseline:{projectCount:d$2.length,runtimes:[...new Set(d$2.flatMap(i=>i.runtimeCandidates))].sort(),frameworks:[...new Set(d$2.map(i=>i.framework))].sort(),graph:Ee(a$1,l)},maxAttempts:p$1,consumer:e.consumer??"generic"},I={digestCanonical:c$1},{goalPack:g,handoff:T}=j(E,I);a(g,se,"Goal Pack"),a(T,ie,"Goal agent handoff");let L=false,o=async()=>{let i=R.join(r,g.artifacts.goalPack),h=R.join(r,g.artifacts.agentHandoff),[c,C]=await Promise.all([_.pathExists(i),_.pathExists(h)]);if(c!==C)throw new Error(`Goal Pack instance is incomplete and cannot be resumed: ${g.id}`);if(!c)return;let[w,k]=await Promise.all([_.readJson(i),_.readJson(h)]);a(w,se,"Persisted Goal Pack"),a(k,ie,"Persisted goal agent handoff");let S=j({...E,generatedAt:w.generatedAt,sourceBinding:w.sourceBinding},I);if(w.id!==g.id||k.goalId!==g.id||c$1(w)!==c$1(S.goalPack)||c$1(k)!==c$1(S.handoff))throw new Error(`Goal Pack instance failed immutable integrity validation: ${g.id}`);g=w,T=k,L=true;};if(e.dryRun)await o();else {let i$2=`.workspai/goals/${g.id}/publication`;await f(r,i$2,async()=>{await o();let h=_e(await xe(r),g,new Date().toISOString());a(h,ue,"Goal index"),i(h),await i$1(r,d$1,L?[{relativePath:d$1,payload:g},{relativePath:f$1,payload:h}]:[{relativePath:g.artifacts.goalPack,payload:g},{relativePath:g.artifacts.agentHandoff,payload:T},{relativePath:d$1,payload:g},{relativePath:f$1,payload:h}]);});}let y=[g.artifacts.goalPack,g.artifacts.agentHandoff,d$1,f$1],P={schemaVersion:c$2,result:g.state==="needs-confirmation"?"needs-confirmation":g.state==="blocked"?"blocked":g.state==="needs-evidence"?"needs-evidence":"planned",resolution:{source:t.source,invocationScope:t.projectPath?"project":"workspace"},goalPack:g,agentHandoff:T,writtenArtifacts:e.dryRun?[]:L?[d$1,f$1]:y,dryRun:e.dryRun===true,resumed:L};return a(P,Ce,"Goal plan result"),P}export{nt as a};
|
|
1
|
+
import {c}from'./chunk-4MXKXHLW.js';import {j,i,d as d$1,f as f$1,c as c$2,e,h}from'./chunk-QIPW3G2H.js';import {g}from'./chunk-5HNQIMGW.js';import {a as a$1}from'./chunk-AGI46TSQ.js';import {c as c$3}from'./chunk-HRGIHWYH.js';import {b}from'./chunk-DWDYLKVW.js';import {b as b$1}from'./chunk-KO4DM2AV.js';import {d as d$2}from'./chunk-ROOPODG6.js';import {f,i as i$1}from'./chunk-BLEIUQL6.js';import {a}from'./chunk-AFIFZTOY.js';import {d,c as c$1}from'./chunk-EWZZUQBR.js';import {q,p}from'./chunk-ODK4LCEL.js';import R from'path';import _ from'fs-extra';var we=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/,ke=/(?:^|\s)(?:\/(?:home|Users|private|var|tmp|mnt|opt|srv|root|workspace|workspaces|data|Volumes|etc|usr|run|dev|proc|sys)\/[^\s]+|[A-Za-z]:[\\/][^\s]+|\\\\[^\\\s]+\\[^\s]+)/,ve=/(?:-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\b(?:github_pat_|gh[pousr]_|glpat-|npm_|xox[baprs]-|sk-(?:proj-)?)[A-Za-z0-9_-]{12,}|\b(?:AKIA|ASIA)[A-Z0-9]{16}\b|\bAIza[A-Za-z0-9_-]{20,}|\bBearer\s+[A-Za-z0-9._~+/-]{16,}|[a-z][a-z0-9+.-]*:\/\/[^\s:/]+:[^\s@/]+@|\b(?:password|passwd|secret|token|api[_-]?key)\s*[:=]\s*[^\s]{6,})/i,ye=[{category:"test-coverage",patterns:[/\b(?:test\s+)?coverage\b/i,/\bcoverage\s+(?:to|above|at least)\b/i]},{category:"dependency-security",patterns:[/\b(?:dependency|dependencies|package|packages)\b.*\b(?:security|vulnerab|audit)\b/i,/\b(?:security|vulnerab|audit)\b.*\b(?:dependency|dependencies|package|packages)\b/i]},{category:"release-readiness",patterns:[/\brelease[ -]readiness\b/i,/\bready (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare\b[^\n]{0,80}\bfor release\b/i]},{category:"defect-repair",patterns:[/\b(?:fix|repair|resolve|debug)\b.*\b(?:bug|error|failure|issue|regression)\b/i]},{category:"performance",patterns:[/\b(?:performance|latency|throughput|cpu|optimi[sz]e|faster|slower)\b/i,/\b(?:memory\s+(?:allocation|consumption|footprint|leak|pressure|usage)|out[ -]of[ -]memory|heap|ram)\b/i]},{category:"refactor",patterns:[/\b(?:refactor|restructure|decouple|extract|simplify|cleanup|clean up)\b/i]},{category:"documentation",patterns:[/\b(?:document|documentation|readme|guide|tutorial|docs)\b/i]},{category:"feature-change",patterns:[/\b(?:add|build|create|enforce|enhance|harden|implement|improve|introduce|support)\b/i]},{category:"system-understanding",patterns:[/\b(?:understand|explain|map|find|where|how|architecture|analy[sz]e|search)\b/i]}];function Pe(e){if(typeof e!="string")throw new Error("Goal intent must be text.");let t=e.trim().replace(/\s+/g," ");if(!t)throw new Error("Goal intent cannot be empty.");if(t.length>2e3)throw new Error("Goal intent exceeds the 2000 character safety limit.");if(we.test(t))throw new Error("Goal intent contains unsupported control characters.");if(ke.test(t))throw new Error("Goal intent contains a machine-local absolute path. Use a workspace-relative path or project scope.");if(ve.test(t))throw new Error("Goal intent appears to contain secret material and was not persisted.");return t}function je(e){let t=e.match(/\b(?:coverage\D{0,24})?((?:100(?:\.0+)?|\d{1,2}(?:\.\d+)?))\s*(?:%|percent(?:age)?(?:\s+points?)?)/i);if(!t||!/coverage/i.test(e))return null;let r=Number(t[1]);return Number.isFinite(r)&&r>=0&&r<=100?r:null}var oe=[{runtime:"cpp",patterns:[/\bc\+\+/i,/\bcpp\b/i]},{runtime:"dotnet",patterns:[/\.net\b/i,/\bdotnet\b/i,/\bc#/i,/\bcsharp\b/i]},{runtime:"node",patterns:[/\bnode(?:\.js)?\b/i,/\btypescript\b/i,/\bjavascript\b/i,/\b(?:js|ts)\b/i]},{runtime:"python",patterns:[/\bpython\b/i,/\bpytest\b/i]},{runtime:"go",patterns:[/\bgolang\b/i,/\bgo(?:\s+(?:test|coverage|tests))\b/i]},{runtime:"java",patterns:[/\bjava\b/i,/\bjunit\b/i,/\bjacoco\b/i]},{runtime:"rust",patterns:[/\brust\b/i,/\bcargo\b/i]},{runtime:"php",patterns:[/\bphp\b/i,/\bphpunit\b/i]},{runtime:"ruby",patterns:[/\bruby\b/i,/\brspec\b/i]},{runtime:"kotlin",patterns:[/\bkotlin\b/i]},{runtime:"scala",patterns:[/\bscala\b/i]},{runtime:"clojure",patterns:[/\bclojure\b/i]},{runtime:"elixir",patterns:[/\belixir\b/i]},{runtime:"deno",patterns:[/\bdeno\b/i]},{runtime:"bun",patterns:[/\bbun\b/i]},{runtime:"c",patterns:[/\bc(?:\s+(?:test|coverage|tests|code))\b/i]}];function Ge(e){return oe.filter(t=>t.patterns.some(r=>r.test(e))).map(t=>t.runtime)}function K(e,t={}){let r=Pe(e),n=ye.filter(u=>u.patterns.some(j=>j.test(r))).map(u=>u.category),a=n.some(u=>u!=="feature-change")?n.filter(u=>u!=="feature-change"):n,s=a[0]??"feature-change",l=je(r),d=Ge(r),p=d.length===0&&t.selectedCoverageRuntime?[t.selectedCoverageRuntime]:d,m=[...new Set((t.availableCoverageRuntimes??[]).filter(u=>oe.some(j=>j.runtime===u)))].sort(),b=[];return a.length>1&&a[0]!=="test-coverage"&&b.push(`The intent also contains signals for: ${a.slice(1).join(", ")}.`),s==="test-coverage"&&l===null&&b.push("A numeric test coverage target is required for machine verification."),s==="test-coverage"&&p.length>1&&b.push(`The Goal names multiple coverage runtimes: ${p.join(", ")}. Select one runtime per Goal.`),s==="test-coverage"&&p.length===0&&m.length>1&&b.push(`Coverage scope is ambiguous across detected runtimes: ${m.join(", ")}. Name one runtime or language in the Goal.`),s==="test-coverage"&&p.length===1&&m.length>0&&!m.includes(p[0])&&b.push(`The requested ${p[0]} coverage runtime is not present in the selected scope. Detected runtimes: ${m.join(", ")}.`),{original:r,normalized:r.toLocaleLowerCase("en-US"),statement:r.replace(/[.!?]+$/,""),category:s,confidence:a.length===1?"high":a.length>1?"medium":"low",ambiguities:b,...l===null?{}:{requestedTarget:{metric:"test-coverage-percent",operator:"at-least",value:l,...p.length===1?{runtime:p[0]}:{}}}}}function ae(e){let t={"test-coverage":["test suite coverage configuration instrumentation","CI tests LCOV Cobertura JaCoCo LLVM coverage"],"dependency-security":["dependency manifest lockfile security audit vulnerability"],"release-readiness":["release pipeline readiness gates build test deploy"],"defect-repair":["failure error test implementation call path"],"feature-change":["API implementation module dependency tests"],refactor:["module dependency ownership implementation tests"],performance:["performance benchmark latency throughput runtime"],documentation:["documentation README guide architecture decision"],"system-understanding":["architecture service API dependency ownership"]};return [...new Set([e.statement,...t[e.category]])].slice(0,3)}var se="contracts/workspace-intelligence/goal-pack.v1.json",ie="contracts/workspace-intelligence/goal-agent-handoff.v1.json",Ce="contracts/workspace-intelligence/goal-plan-result.v1.json",ue="contracts/workspace-intelligence/goal-index.v1.json",de=new Set(["node","bun","deno","python","go","java","dotnet","rust","php","ruby","elixir","clojure","scala","kotlin","c","cpp"]);function Ae(e,t){let r=e.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)??[],n=new Set(t.map(m=>m.toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"")).filter(Boolean)),a=[];for(let m=0;m<r.length;){let b=0;for(let u=Math.min(4,r.length-m);u>=1;u-=1){let j=r.slice(m,m+u).join("").toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"");if(n.has(j)){b=u;break}}if(b>0){m+=b;continue}a.push(r[m]),m+=1;}let s=a.findIndex((m,b)=>{let u=m.toLocaleLowerCase("en-US"),j=a[b+1]?.toLocaleLowerCase("en-US");return u==="without"&&["breaking","changing","modifying","removing"].includes(j??"")||u==="while"&&["keeping","maintaining","preserving"].includes(j??"")}),l=s>=2?a.slice(0,s):a,d=l.length>=2?l.join(" "):e;if(s<2)return [d];let p=a.slice(s).filter(m=>!["without","while","breaking","changing","modifying","removing","keeping","maintaining","preserving"].includes(m.toLocaleLowerCase("en-US")));return p.length>0?[d,p.join(" ")]:[d]}function ce(e){return e.split(R.sep).join("/")}function V(e,t){return d$2(e,t.path,{...t.absolutePath?{absolutePath:t.absolutePath}:{}})}function le(e){let t=e.requested.trim().replace(/^project:/,"");if(!t)throw new Error("Project goal scope must name a project.");let r=R.isAbsolute(t)?R.resolve(t):null,n=e.model.projects.filter(a=>a.name===t||ce(a.path)===ce(t)||r!==null&&V(e.workspacePath,a)===r);if(n.length!==1)throw new Error(n.length===0?`Project goal scope was not found in the canonical model: ${t}`:`Project goal scope is ambiguous in the canonical model: ${t}`);return n[0]}async function Re(e){let t=await a$1(e);if(t.status==="miss")throw new Error(`Canonical model and live graph evidence are required (${t.reason}). Run \`workspai workspace intelligence run --for-agent generic --strict --json\` or retry with --refresh.`);let{model:r,graph:n}=t;return a(r,"contracts/workspace-intelligence/workspace-model.v1.json","Goal source model"),a(n,"contracts/workspace-intelligence/workspace-knowledge-graph.v1.json","Goal source graph"),b$1(n,r),{model:r,graph:n}}function pe(e){let t=e.scope.trim();if(t==="workspace")return {kind:"workspace",projects:e.model.projects.map(n=>n.name).sort(),selectionSource:e.selectionSource,resolution:"selected"};let r=t.startsWith("projects:")?"projects:":t.startsWith("project:")&&t.slice(8).includes(",")?"project:":null;if(r){let n=t.slice(r.length).split(",").map(l=>l.trim()).filter(Boolean);if(n.length<2)throw new Error("A project-set Goal scope must name at least two projects.");let a=n.map(l=>le({workspacePath:e.workspacePath,model:e.model,requested:l})),s=[...new Set(a.map(l=>l.name))].sort();if(s.length!==n.length)throw new Error("A project-set Goal scope must not contain duplicate projects.");return {kind:"project-set",projects:s,selectionSource:e.selectionSource,resolution:"selected"}}if(t)return {kind:"project",projects:[le({workspacePath:e.workspacePath,model:e.model,requested:t}).name],selectionSource:e.selectionSource,resolution:"selected"};throw new Error("Goal scope cannot be empty.")}async function Se(e){if(e.explicitScope?.trim())return {scope:pe({workspacePath:e.workspacePath,model:e.model,scope:e.explicitScope,selectionSource:"explicit"}),selectionRequired:false};if(e.invocationProjectPath){let t=R.resolve(e.invocationProjectPath),r=e.model.projects.filter(n=>V(e.workspacePath,n)===t);if(r.length!==1)throw new Error("The invocation project is not represented uniquely in the canonical workspace model. Refresh intelligence or pass --scope explicitly.");return {scope:{kind:"project",projects:[r[0].name],selectionSource:"invocation-project",resolution:"selected"},selectionRequired:false}}if(e.model.projects.length===1)return {scope:{kind:"project",projects:[e.model.projects[0].name],selectionSource:"single-project-workspace",resolution:"selected"},selectionRequired:false};if(e.selectScope){let t=await e.selectScope({workspaceName:e.model.workspace.name,projects:e.model.projects.map(n=>({name:n.name,runtime:n.runtime,runtimeCandidates:[...n.runtimeCandidates].sort(),framework:n.framework})).sort((n,a)=>n.name.localeCompare(a.name))}),r=t.kind==="workspace"?"workspace":t.projects.length===1?`project:${t.projects[0]}`:`projects:${t.projects.join(",")}`;return {scope:pe({workspacePath:e.workspacePath,model:e.model,scope:r,selectionSource:"interactive"}),selectionRequired:false}}return {scope:{kind:"workspace",projects:e.model.projects.map(t=>t.name).sort(),selectionSource:"workspace",resolution:"selection-required"},selectionRequired:true}}function Ee(e,t){if(t.kind==="workspace")return {entities:e.quality.entityCount,relationships:e.quality.relationCount,proofs:e.quality.proofCount,unresolved:e.quality.unknownCount,proofCoveragePercent:Number((e.quality.relationProofCoverageRatio*100).toFixed(2))};let r=new Set(t.projects),n=e.entities.filter(p=>p.projectId!==void 0&&r.has(p.projectId)),a=new Set(n.map(p=>p.id)),s=e.relations.filter(p=>a.has(p.from)||a.has(p.to)),l=new Set([...n.flatMap(p=>p.proofIds),...s.flatMap(p=>p.proofIds)]),d=s.filter(p=>p.proofIds.length>0).length;return {entities:n.length,relationships:s.length,proofs:l.size,unresolved:s.length-d,proofCoveragePercent:s.length===0?100:Number((d/s.length*100).toFixed(2))}}function Ie(e){let t=new Map;for(let n of e){let a=t.get(n.kind)??[];a.push(n),t.set(n.kind,a);}let r=[];for(let n=0;[...t.values()].some(a=>n<a.length);n+=1)for(let a of t.values()){let s=a[n];s&&r.push(s);}return r}async function Te(e){let t=R.join(e.workspacePath,p.intelligenceRun),r=await _.readJson(t).catch(()=>null),a=(Array.isArray(r?.stages)?r.stages:[]).filter(o=>o.status==="blocked"||o.status==="failed").map(o=>String(o.id??"unknown")).sort(),s=r?.status,l={status:s==="passed"?"passed":s==="blocked"||s==="failed"?"blocked":"unknown",artifact:p.intelligenceRun,blockedStages:a},d={status:"not-applicable",runtime:null,runtimeChoices:[],runner:null,existingEvidence:[],prerequisites:[]};if(e.intent.category==="test-coverage"){let o=e.intent.requestedTarget?.runtime;if(e.intent.ambiguities.some(P=>P.startsWith("Coverage scope is ambiguous")||P.startsWith("The Goal names multiple coverage runtimes")||P.startsWith("The selected projects do not share a common canonical coverage runtime")||P.startsWith("The requested ")))d={status:"requires-setup",runtime:o??null,runtimeChoices:e.coverageRuntimeChoices,runner:null,existingEvidence:[],prerequisites:["Select exactly one detected runtime or language for this coverage Goal."]};else {let P=o?e.projects.filter(c=>c.runtimeCandidates.includes(o)):e.projects,i=await Promise.all(P.map(async c=>({project:c,capability:await c$3(V(e.workspacePath,c),o??(de.has(c.runtime)?c.runtime:"unknown"))}))),h=i.map(c=>c.capability.status);d={status:h.includes("unsupported")?"unsupported":h.includes("requires-setup")?"requires-setup":"available",runtime:i.length===1?i[0].capability.runtime:[...new Set(i.map(c=>c.capability.runtime))].join(","),runtimeChoices:e.coverageRuntimeChoices,runner:i.length===1?i[0].capability.runner:[...new Set(i.flatMap(c=>c.capability.runner?[c.capability.runner]:[]))].join(",")||null,existingEvidence:i.flatMap(c=>c.capability.existingEvidence.map(C=>({project:c.project.name,...C}))).filter((c,C,w)=>w.findIndex(k=>k.project===c.project&&k.path===c.path&&k.sha256===c.sha256)===C).sort((c,C)=>c.project.localeCompare(C.project)||c.path.localeCompare(C.path)),prerequisites:[...new Set(i.flatMap(c=>c.capability.prerequisites))].sort()};}}let p$1=ae(e.intent),m=[...Ae(p$1[0],e.projects.map(o=>o.name)),...p$1.slice(1)].filter((o,y,P)=>P.indexOf(o)===y).slice(0,3),b=m.map((o,y)=>{let P=o.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)?.length??0,i=y===0&&P>=4?2:1,h=e.projects.map(w=>{let k=G=>g(e.graph,{query:o,projectId:w.name,...G?{kind:G}:{},limit:60,relationsPerEntity:0,minimumTermMatches:i}).entities,S=k(),me=[...new Set(e.graph.entities.filter(G=>G.projectId===w.name||G.projectId===void 0&&G.identity.scope==="workspace").map(G=>G.kind))].flatMap(G=>k(G).slice(0,8)),F=[...S,...me];return F.filter((G,ge)=>F.findIndex(he=>he.id===G.id)===ge)}),c=[],C=new Set;for(let w=0;h.some(k=>w<k.length);w+=1)for(let k of h){let S=k[w];!S||C.has(S.id)||(C.add(S.id),c.push(S));}return Ie(c)}),u={"test-coverage":["test-suite"],"dependency-security":["package","module"],"release-readiness":["pipeline","deployment","lifecycle-stage"],"defect-repair":["test-suite","lifecycle-stage"],"feature-change":["project","runtime-unit","api","package","module","test-suite"],refactor:["package","module","api","test-suite"],performance:["lifecycle-stage","test-suite","pipeline"],documentation:["document","decision"],"system-understanding":["project","service","api","package","protocol"]},j=new Set(e.projects.map(o=>o.name)),v=e.graph.entities.filter(o=>o.proofIds.length>0&&(!o.projectId||j.has(o.projectId))&&u[e.intent.category].includes(o.kind)).sort((o,y)=>u[e.intent.category].indexOf(o.kind)-u[e.intent.category].indexOf(y.kind)||o.label.localeCompare(y.label)),f=[],M=new Set,E=o=>{!o||f.length>=20||M.has(o.id)||(M.add(o.id),f.push(o));},I=(e.intent.statement.match(/[A-Za-z][A-Za-z0-9+#.-]{1,}/g)??[]).length>=2,g$1=I?b[0]??[]:[];for(let o of g$1.slice(0,12))E(o);if(!I)for(let o of v)E(o);for(let o=0;f.length<20&&b.slice(1).some(y=>o<y.length);o+=1)for(let y of b.slice(1))E(y[o]);if(I)for(let o of v)E(o);for(let o of g$1.slice(12))E(o);let T=f.map(o=>({entityId:o.id,kind:o.kind,label:o.label,proofIds:o.proofIds.slice(0,12)})),L=b[0]?.length??0;return {workspaceIntelligence:l,measurement:d,retrieval:{status:I&&L>=3?"grounded":T.length>0?"partial":"empty",strategy:"deterministic-category-v1",queries:m,anchors:T}}}async function xe(e$1){let t=R.join(e$1,f$1);if(!await _.pathExists(t))return {schemaVersion:e,generatedAt:new Date(0).toISOString(),activeGoalId:null,goals:[]};let r=await _.readJson(t);a(r,ue,"Goal index");try{i(r);}catch(n){let a=h(r);if(!(a!==null&&n instanceof Error&&n.message==="Goal index is inconsistent: activeGoalId must identify the only selected actionable lifecycle entry.")||!a)throw n;return a}return r}function _e(e$1,t,r){let n=e$1.goals.find(l=>l.id===t.id),a=t.state==="ready-to-plan",s={id:t.id,fingerprint:t.fingerprint,objective:t.intent.statement,category:t.intent.category,state:t.state,lifecycle:n?.lifecycle==="cancelled"?"cancelled":a?"active":"planned",scope:t.scope,createdAt:n?.createdAt??t.generatedAt,updatedAt:r,goalPack:t.artifacts.goalPack,agentHandoff:t.artifacts.agentHandoff,...n?.verifiedGoalId?{verifiedGoalId:n.verifiedGoalId}:{},...n?.repairTransactionId?{repairTransactionId:n.repairTransactionId}:{},...n?.repairTransactionIds?{repairTransactionIds:n.repairTransactionIds}:{},...n?.changeTransactionId?{changeTransactionId:n.changeTransactionId}:{},...n?.changeTransactionIds?{changeTransactionIds:n.changeTransactionIds}:{},...n?.verificationReceipt?{verificationReceipt:n.verificationReceipt}:{}};return {schemaVersion:e,generatedAt:r,activeGoalId:s.lifecycle==="active"?t.id:e$1.activeGoalId===t.id?null:e$1.activeGoalId,goals:[...e$1.goals.filter(l=>l.id!==t.id).map(l=>s.lifecycle==="active"&&l.lifecycle==="active"?{...l,lifecycle:"planned",updatedAt:r}:l),s].sort((l,d)=>l.id.localeCompare(d.id))}}async function nt(e){let t=b({startPath:R.resolve(e.startPath),explicitWorkspacePath:e.workspacePath,strict:true,requireProjectMembership:!e.scope?.trim()});if(!t)throw new Error("No canonical Workspai workspace could be resolved.");let r=R.resolve(t.workspacePath);e.refresh&&await c({workspacePath:r,strict:false,agent:"generic"});let{model:n,graph:a$1}=await Re(r),s=await Se({workspacePath:r,invocationProjectPath:t.projectPath,model:n,explicitScope:e.scope,selectScope:e.selectScope}),l=s.scope,d$2=n.projects.filter(i=>l.projects.includes(i.name));if(d$2.length===0)throw new Error("A Goal Pack requires at least one registered project in its selected scope.");let p$1=e.maxAttempts??5;if(!Number.isInteger(p$1)||p$1<1||p$1>25)throw new Error("--max-attempts must be an integer from 1 to 25.");let m=new Date().toISOString(),b$1=d(n),u=d$2.map(i=>({name:i.name,runtimes:[...new Set(i.runtimeCandidates.filter(h=>de.has(h)))].sort()})),j$1=[...new Set(u.flatMap(i=>i.runtimes))].sort(),v=u.length<=1?j$1:u[0].runtimes.filter(i=>u.every(h=>h.runtimes.includes(i))),f$2=K(e.intent,{availableCoverageRuntimes:v,...e.runtime?{selectedCoverageRuntime:e.runtime}:v.length===1?{selectedCoverageRuntime:v[0]}:{}});if(e.runtime&&!v.includes(e.runtime)){let i=e.runtime,h=u.filter(c=>!c.runtimes.includes(i)).map(c=>c.name);throw new Error(d$2.length>1&&h.length>0?`--runtime ${e.runtime} is not canonical for every project in the selected Goal scope. Missing from: ${h.join(", ")}. Split the projects into runtime-compatible Goal scopes.`:`--runtime ${e.runtime} is not present in the canonical Workspace Model for the selected Goal scope. Available runtimes: ${v.join(", ")||"none"}.`)}if(e.runtime&&f$2.category!=="test-coverage")throw new Error("--runtime is valid only for a test-coverage Goal.");if(e.runtime&&f$2.requestedTarget?.runtime&&f$2.requestedTarget.runtime!==e.runtime)throw new Error(`--runtime ${e.runtime} conflicts with the ${f$2.requestedTarget.runtime} runtime named in the Goal intent.`);if(!s.selectionRequired&&f$2.category==="test-coverage"&&f$2.requestedTarget&&!f$2.requestedTarget.runtime&&v.length>1&&!e.runtime&&e.selectCoverageRuntime){let i=await e.selectCoverageRuntime({workspaceName:n.workspace.name,scope:l,projects:d$2.map(h=>({name:h.name,runtime:h.runtime,runtimeCandidates:[...h.runtimeCandidates].sort()})),runtimes:v});if(!v.includes(i))throw new Error("The selected coverage runtime is outside the canonical Goal scope.");f$2=K(e.intent,{availableCoverageRuntimes:v,selectedCoverageRuntime:i});}!s.selectionRequired&&f$2.category==="test-coverage"&&d$2.length>1&&v.length===0&&(f$2={...f$2,ambiguities:[`The selected projects do not share a common canonical coverage runtime: ${u.map(i=>`${i.name} (${i.runtimes.join(", ")||"none"})`).join("; ")}. Split them into runtime-compatible Goal scopes so every selected project is verified.`,...f$2.ambiguities]}),s.selectionRequired&&(f$2={...f$2,ambiguities:[`Goal scope is unresolved across ${l.projects.length} registered projects: ${l.projects.join(", ")}. Select one project, multiple projects, or the entire workspace.`,...f$2.ambiguities]});let M=await Te({workspacePath:r,projects:d$2,graph:a$1,intent:f$2,coverageRuntimeChoices:v}),E={generatedAt:m,intent:f$2,workspaceName:n.workspace.name,scope:l,sourceBinding:{model:{artifact:p.model,schemaVersion:q.model,hashAlgorithm:"sha256",hashSemantics:"workspace-model-structural-v1",hash:b$1,generatedAt:n.generatedAt},graph:{artifact:p.knowledgeGraph,schemaVersion:q.knowledgeGraph,hashAlgorithm:"sha256",hashSemantics:"canonical-json-v1",hash:c$1(a$1),generatedAt:a$1.generatedAt,modelHash:a$1.source.hash,...a$1.source.inputs?.hash?{inputHash:a$1.source.inputs.hash}:{}}},preflight:M,baseline:{projectCount:d$2.length,runtimes:[...new Set(d$2.flatMap(i=>i.runtimeCandidates))].sort(),frameworks:[...new Set(d$2.map(i=>i.framework))].sort(),graph:Ee(a$1,l)},maxAttempts:p$1,consumer:e.consumer??"generic"},I={digestCanonical:c$1},{goalPack:g,handoff:T}=j(E,I);a(g,se,"Goal Pack"),a(T,ie,"Goal agent handoff");let L=false,o=async()=>{let i=R.join(r,g.artifacts.goalPack),h=R.join(r,g.artifacts.agentHandoff),[c,C]=await Promise.all([_.pathExists(i),_.pathExists(h)]);if(c!==C)throw new Error(`Goal Pack instance is incomplete and cannot be resumed: ${g.id}`);if(!c)return;let[w,k]=await Promise.all([_.readJson(i),_.readJson(h)]);a(w,se,"Persisted Goal Pack"),a(k,ie,"Persisted goal agent handoff");let S=j({...E,generatedAt:w.generatedAt,sourceBinding:w.sourceBinding},I);if(w.id!==g.id||k.goalId!==g.id||c$1(w)!==c$1(S.goalPack)||c$1(k)!==c$1(S.handoff))throw new Error(`Goal Pack instance failed immutable integrity validation: ${g.id}`);g=w,T=k,L=true;};if(e.dryRun)await o();else {let i$2=`.workspai/goals/${g.id}/publication`;await f(r,i$2,async()=>{await o();let h=_e(await xe(r),g,new Date().toISOString());a(h,ue,"Goal index"),i(h),await i$1(r,d$1,L?[{relativePath:d$1,payload:g},{relativePath:f$1,payload:h}]:[{relativePath:g.artifacts.goalPack,payload:g},{relativePath:g.artifacts.agentHandoff,payload:T},{relativePath:d$1,payload:g},{relativePath:f$1,payload:h}]);});}let y=[g.artifacts.goalPack,g.artifacts.agentHandoff,d$1,f$1],P={schemaVersion:c$2,result:g.state==="needs-confirmation"?"needs-confirmation":g.state==="blocked"?"blocked":g.state==="needs-evidence"?"needs-evidence":"planned",resolution:{source:t.source,invocationScope:t.projectPath?"project":"workspace"},goalPack:g,agentHandoff:T,writtenArtifacts:e.dryRun?[]:L?[d$1,f$1]:y,dryRun:e.dryRun===true,resumed:L};return a(P,Ce,"Goal plan result"),P}export{nt as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{b as buildWorkspaceManifest,f as createProject,a as initializeStandaloneGitRepository,g as registerWorkspaceAtPath,d as resolvePythonFreeFallbackProfile,c as syncWorkspaceFoundationFiles,e as writeWorkspaceLauncher}from'./chunk-
|
|
1
|
+
export{b as buildWorkspaceManifest,f as createProject,a as initializeStandaloneGitRepository,g as registerWorkspaceAtPath,d as resolvePythonFreeFallbackProfile,c as syncWorkspaceFoundationFiles,e as writeWorkspaceLauncher}from'./chunk-UOTOJJI4.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{d as DOCTOR_WORKSPACE_REPORT_PATH,r as applyEnvKeyAddFix,n as applyFileAppendFix,o as applyFileCopyFix,m as applyFileCreateFix,q as applyJsonEditFix,s as applyMakefileTargetFix,l as applyPackageScriptFix,j as assertOperationPathInsideProject,k as assertOperationPathInsideProjectResolved,i as buildRepairOperationIdentity,u as computeDoctorFixAwareExitCode,t as computeDoctorGateExitCode,p as decodeJsonPointerSegment,h as parseInternalRepairCommand,g as parsePackageScriptFix,f as pythonPackageListProvesDependencies,e as resolveDoctorPolicyProfile,v as runDoctor}from'./chunk-
|
|
1
|
+
export{d as DOCTOR_WORKSPACE_REPORT_PATH,r as applyEnvKeyAddFix,n as applyFileAppendFix,o as applyFileCopyFix,m as applyFileCreateFix,q as applyJsonEditFix,s as applyMakefileTargetFix,l as applyPackageScriptFix,j as assertOperationPathInsideProject,k as assertOperationPathInsideProjectResolved,i as buildRepairOperationIdentity,u as computeDoctorFixAwareExitCode,t as computeDoctorGateExitCode,p as decodeJsonPointerSegment,h as parseInternalRepairCommand,g as parsePackageScriptFix,f as pythonPackageListProvesDependencies,e as resolveDoctorPolicyProfile,v as runDoctor}from'./chunk-PSQPKK6H.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,k as buildGoalLifecycleResult,l as inspectGoalLifecycle,q as linkGoalChangeTransaction,p as linkGoalRepairTransaction,n as prepareGoalVerification,m as transitionGoalLifecycle,o as verifyGoalLifecycle}from'./chunk-
|
|
1
|
+
export{f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,k as buildGoalLifecycleResult,l as inspectGoalLifecycle,q as linkGoalChangeTransaction,p as linkGoalRepairTransaction,n as prepareGoalVerification,m as transitionGoalLifecycle,o as verifyGoalLifecycle}from'./chunk-QIPW3G2H.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as planGoalPack}from'./chunk-
|
|
1
|
+
export{a as planGoalPack}from'./chunk-ZXQC36NJ.js';export{b as GOAL_AGENT_HANDOFF_SCHEMA_VERSION,f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,g as GOAL_LIFECYCLE_RESULT_SCHEMA_VERSION,d as GOAL_PACK_LAST_RUN_PATH,a as GOAL_PACK_SCHEMA_VERSION,c as GOAL_PLAN_RESULT_SCHEMA_VERSION}from'./chunk-QIPW3G2H.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -137,10 +137,12 @@ declare function getPublishedContractVersions(): {
|
|
|
137
137
|
agentCustomizationPackCapabilities: "workspai-agent-customization-pack-capabilities.v1";
|
|
138
138
|
agentFrameworkCapabilities: "workspai.agent-framework-capabilities.v1";
|
|
139
139
|
agentFrameworkAdapterManifest: "workspai.agent-framework-adapter-manifest.v1";
|
|
140
|
-
agentFrameworkConformanceReport: "workspai.agent-framework-conformance-report.
|
|
140
|
+
agentFrameworkConformanceReport: "workspai.agent-framework-conformance-report.v2";
|
|
141
|
+
agentFrameworkConformanceReportLegacy: string;
|
|
141
142
|
agentFrameworkChangePlan: "workspai.agent-framework-change-plan.v1";
|
|
142
143
|
agentFrameworkOwnershipReceipt: "workspai.agent-framework-ownership-receipt.v1";
|
|
143
|
-
agentFrameworkAdmissionCandidate: "workspai.agent-framework-admission-candidate.
|
|
144
|
+
agentFrameworkAdmissionCandidate: "workspai.agent-framework-admission-candidate.v2";
|
|
145
|
+
agentFrameworkAdmissionCandidateLegacy: string;
|
|
144
146
|
agentCustomizationPackReport: "rapidkit-agent-customization-pack.v1";
|
|
145
147
|
agentReportsIndex: "rapidkit-agent-reports-index.v1";
|
|
146
148
|
workspaceOperationalSkill: "workspace-operational-skill.v1";
|
|
@@ -367,10 +369,12 @@ declare function getVersionContract(): {
|
|
|
367
369
|
agentCustomizationPackCapabilities: "workspai-agent-customization-pack-capabilities.v1";
|
|
368
370
|
agentFrameworkCapabilities: "workspai.agent-framework-capabilities.v1";
|
|
369
371
|
agentFrameworkAdapterManifest: "workspai.agent-framework-adapter-manifest.v1";
|
|
370
|
-
agentFrameworkConformanceReport: "workspai.agent-framework-conformance-report.
|
|
372
|
+
agentFrameworkConformanceReport: "workspai.agent-framework-conformance-report.v2";
|
|
373
|
+
agentFrameworkConformanceReportLegacy: string;
|
|
371
374
|
agentFrameworkChangePlan: "workspai.agent-framework-change-plan.v1";
|
|
372
375
|
agentFrameworkOwnershipReceipt: "workspai.agent-framework-ownership-receipt.v1";
|
|
373
|
-
agentFrameworkAdmissionCandidate: "workspai.agent-framework-admission-candidate.
|
|
376
|
+
agentFrameworkAdmissionCandidate: "workspai.agent-framework-admission-candidate.v2";
|
|
377
|
+
agentFrameworkAdmissionCandidateLegacy: string;
|
|
374
378
|
agentCustomizationPackReport: "rapidkit-agent-customization-pack.v1";
|
|
375
379
|
agentReportsIndex: "rapidkit-agent-reports-index.v1";
|
|
376
380
|
workspaceOperationalSkill: "workspace-operational-skill.v1";
|
|
@@ -590,10 +594,12 @@ declare function getGlobalCommandCapabilities(): {
|
|
|
590
594
|
agentCustomizationPackCapabilities: "workspai-agent-customization-pack-capabilities.v1";
|
|
591
595
|
agentFrameworkCapabilities: "workspai.agent-framework-capabilities.v1";
|
|
592
596
|
agentFrameworkAdapterManifest: "workspai.agent-framework-adapter-manifest.v1";
|
|
593
|
-
agentFrameworkConformanceReport: "workspai.agent-framework-conformance-report.
|
|
597
|
+
agentFrameworkConformanceReport: "workspai.agent-framework-conformance-report.v2";
|
|
598
|
+
agentFrameworkConformanceReportLegacy: string;
|
|
594
599
|
agentFrameworkChangePlan: "workspai.agent-framework-change-plan.v1";
|
|
595
600
|
agentFrameworkOwnershipReceipt: "workspai.agent-framework-ownership-receipt.v1";
|
|
596
|
-
agentFrameworkAdmissionCandidate: "workspai.agent-framework-admission-candidate.
|
|
601
|
+
agentFrameworkAdmissionCandidate: "workspai.agent-framework-admission-candidate.v2";
|
|
602
|
+
agentFrameworkAdmissionCandidateLegacy: string;
|
|
597
603
|
agentCustomizationPackReport: "rapidkit-agent-customization-pack.v1";
|
|
598
604
|
agentReportsIndex: "rapidkit-agent-reports-index.v1";
|
|
599
605
|
workspaceOperationalSkill: "workspace-operational-skill.v1";
|