workspai 0.58.0 → 0.59.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -32
- package/contracts/agent-customization-pack.v1.json +52 -4
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +90 -0
- package/contracts/extension-cli-compatibility.v1.json +3 -1
- package/contracts/project-workspace-resolution.v1.json +15 -2
- package/contracts/published-contract-catalog.v1.json +10 -0
- package/contracts/runtime-command-surface.v1.json +54 -0
- package/contracts/workspace-intelligence/agent-bootstrap-receipt.v1.json +247 -0
- package/contracts/workspace-intelligence/agent-customization-pack-report.v1.json +16 -1
- package/contracts/workspace-intelligence/goal-index.v1.json +7 -1
- package/contracts/workspace-intelligence/goal-pack.v1.json +2 -1
- package/contracts/workspace-intelligence/project-agent-entry.v1.json +204 -0
- package/contracts/workspace-intelligence/project-context-agent.v1.json +43 -26
- package/contracts/workspace-intelligence/workspace-context.v1.json +14 -1
- package/contracts/workspace-intelligence/workspace-repair-transaction.v1.json +15 -2
- package/contracts/workspace-repair-capabilities.v1.json +5 -0
- package/dist/analyze-52TEGLDR.js +1 -0
- package/dist/{artifact-remediation-plan-JRX4XZ7C.js → artifact-remediation-plan-HPNQTNJ2.js} +1 -1
- package/dist/autopilot-release-NFLAKBA3.js +1 -0
- package/dist/capabilities-command-VBLZXP2T.js +1 -0
- package/dist/{chunk-TTLVG5AR.js → chunk-3CGR6435.js} +1 -1
- package/dist/chunk-4PUJVYRM.js +1 -0
- package/dist/{chunk-4NN5QWOB.js → chunk-5NIZNXRS.js} +1 -1
- package/dist/{chunk-HYY5PQCV.js → chunk-5PSKBJKJ.js} +1 -1
- package/dist/{chunk-AA4PNQKR.js → chunk-5SFCBZOH.js} +1 -1
- package/dist/{chunk-MFJ6ZP7S.js → chunk-6FBNSTUS.js} +1 -1
- package/dist/{chunk-FY6OHOXR.js → chunk-7DSYI7YN.js} +1 -1
- package/dist/chunk-7SFXADXO.js +2 -0
- package/dist/{chunk-GRGUPSNP.js → chunk-CCDGHPEJ.js} +1 -1
- package/dist/{chunk-T63WRURN.js → chunk-D65FCQIO.js} +1 -1
- package/dist/{chunk-YYCPRYP7.js → chunk-DGGTTRYE.js} +1 -1
- package/dist/chunk-DQ6VXTDE.js +1 -0
- package/dist/{chunk-SM55RK3C.js → chunk-ENKGGWRX.js} +1 -1
- package/dist/chunk-FLTIFYTJ.js +142 -0
- package/dist/{chunk-RMDVRNU7.js → chunk-GPOZILMY.js} +1 -1
- package/dist/{chunk-C4NYG57I.js → chunk-HCFWT42C.js} +1 -1
- package/dist/{chunk-RJDGC6AQ.js → chunk-HS3DJMU5.js} +1 -1
- package/dist/{chunk-HI7ONEFI.js → chunk-J3X56S7L.js} +1 -1
- package/dist/{chunk-N3DFX4BY.js → chunk-KBR4Y4RW.js} +1 -1
- package/dist/{chunk-H545P6LN.js → chunk-KTN2ARZJ.js} +1 -1
- package/dist/chunk-LPCWROQ3.js +1 -0
- package/dist/chunk-MZKKRAAJ.js +2 -0
- package/dist/{chunk-LGJAAPNR.js → chunk-N4QQADXX.js} +1 -1
- package/dist/{chunk-FXIE2WVG.js → chunk-NOZ4JCH7.js} +1 -1
- package/dist/chunk-NZ3WZYD5.js +1 -0
- package/dist/{chunk-VAWV3UKV.js → chunk-OFWSZYUX.js} +1 -1
- package/dist/{chunk-XC26FNRL.js → chunk-P2WH7W2H.js} +11 -11
- package/dist/chunk-PVXSIYLP.js +1 -0
- package/dist/{chunk-7KXRA5ST.js → chunk-PXWKMPPI.js} +1 -1
- package/dist/{chunk-II4ROT6X.js → chunk-QCKWQFCD.js} +1 -1
- package/dist/{chunk-4YICCES6.js → chunk-QFBVQUKV.js} +1 -1
- package/dist/{chunk-G4VMNWSU.js → chunk-QJCCZLOF.js} +1 -1
- package/dist/{chunk-A3JCETSF.js → chunk-QMPFNXI7.js} +1 -1
- package/dist/{chunk-CFBAGPB4.js → chunk-QPE6VCDW.js} +1 -1
- package/dist/chunk-RTDEFUTL.js +39 -0
- package/dist/{chunk-YMY6EFX4.js → chunk-RVKMGKYL.js} +1 -1
- package/dist/chunk-S4CWUZ4K.js +1 -0
- package/dist/{chunk-EEMRRCGR.js → chunk-SP5EHSWG.js} +1 -1
- package/dist/{chunk-CHMCKYJJ.js → chunk-U3MGJN7A.js} +1 -1
- package/dist/{chunk-WSDVFLHT.js → chunk-W6FHVXNL.js} +1 -1
- package/dist/{chunk-M2BK3XTP.js → chunk-WQX3JYEP.js} +1 -1
- package/dist/{chunk-AUCHMXUZ.js → chunk-WSRUPDZN.js} +1 -1
- package/dist/{chunk-6TNSCVR4.js → chunk-Y4B55J5S.js} +1 -1
- package/dist/{chunk-GVS5OFUB.js → chunk-YEEAWZWI.js} +1 -1
- package/dist/{chunk-I5PDN2P2.js → chunk-ZJCM37KX.js} +1 -1
- package/dist/{create-QIN56Y4M.js → create-HUEDWYDM.js} +1 -1
- package/dist/{doctor-RP4Q2CKJ.js → doctor-NAZEKMGU.js} +1 -1
- package/dist/goal-lifecycle-NUKWVUAL.js +1 -0
- package/dist/goal-pack-TWOXHXN6.js +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +134 -132
- package/dist/{pipeline-77NUVYQD.js → pipeline-62A2SDLC.js} +1 -1
- package/dist/project-agent-entry-7SYHRY7J.js +1 -0
- package/dist/{project-intelligence-lens-AM2B2PXU.js → project-intelligence-lens-BSG5LK6N.js} +1 -1
- package/dist/{project-test-coverage-MUSS7Z7V.js → project-test-coverage-HP37HUV2.js} +1 -1
- package/dist/{verified-goal-ZSIZYNVO.js → verified-goal-B6HQOZWA.js} +1 -1
- package/dist/{workspace-LFESVKE7.js → workspace-BNRSBWSL.js} +1 -1
- package/dist/{workspace-agent-sync-JMRX6J2Y.js → workspace-agent-sync-ANBHBZ2H.js} +1 -1
- package/dist/{workspace-archive-MFHCFCDO.js → workspace-archive-ZBCKJHXS.js} +1 -1
- package/dist/{workspace-context-TBKRMVMT.js → workspace-context-RAO62QVU.js} +1 -1
- package/dist/{workspace-contract-KKVC2DUQ.js → workspace-contract-ACSIHJIO.js} +1 -1
- package/dist/workspace-explain-RH27OQB4.js +1 -0
- package/dist/workspace-explain-contract-ZL4NMLZI.js +1 -0
- package/dist/{workspace-feedback-O6J3RQML.js → workspace-feedback-RQ4TGJW6.js} +1 -1
- package/dist/{workspace-foundation-JQWT7YGC.js → workspace-foundation-EWYJPPT6.js} +1 -1
- package/dist/{workspace-graph-stream-V5WOXP4B.js → workspace-graph-stream-ZZZEQQTE.js} +1 -1
- package/dist/workspace-graph-token-efficiency-D7CUT6NX.js +1 -0
- package/dist/{workspace-history-TOCRMJUJ.js → workspace-history-SYCDK7FO.js} +1 -1
- package/dist/{workspace-intelligence-SDBIRKMK.js → workspace-intelligence-3YERTBA3.js} +1 -1
- package/dist/{workspace-intelligence-evaluation-E4UMWDAZ.js → workspace-intelligence-evaluation-CQDKOYZZ.js} +1 -1
- package/dist/{workspace-intelligence-runner-DIMNL6CJ.js → workspace-intelligence-runner-QLLBUD6G.js} +1 -1
- package/dist/{workspace-intelligence-runtime-registry-YGWB2RRS.js → workspace-intelligence-runtime-registry-IW6J53LO.js} +1 -1
- package/dist/{workspace-knowledge-graph-MUW6UAGI.js → workspace-knowledge-graph-HZZP6ZRB.js} +1 -1
- package/dist/{workspace-knowledge-graph-query-6DAOXGGT.js → workspace-knowledge-graph-query-ON45H6Y7.js} +1 -1
- package/dist/workspace-knowledge-graph-snapshot-7DWHMEM2.js +1 -0
- package/dist/{workspace-mcp-serve-2SWLIH4I.js → workspace-mcp-serve-5TTAN243.js} +1 -1
- package/dist/{workspace-model-VPFCKTYQ.js → workspace-model-EIQSKDX7.js} +1 -1
- package/dist/{workspace-onboarding-GHI6UTQJ.js → workspace-onboarding-UW3CSURE.js} +1 -1
- package/dist/{workspace-readme-RASXBZRQ.js → workspace-readme-56YZ4EAZ.js} +1 -1
- package/dist/{workspace-registry-summary-7QT7YMIU.js → workspace-registry-summary-OV5KX3WC.js} +1 -1
- package/dist/workspace-repair-engine-DHH2UUJN.js +3 -0
- package/dist/workspace-run-BLHRXT2N.js +1 -0
- package/dist/{workspace-verify-RYCQZYYB.js → workspace-verify-W4P6LBIH.js} +1 -1
- package/dist/{workspace-watch-U3YGN3GG.js → workspace-watch-EZ4D4VCF.js} +1 -1
- package/docs/GLOSSARY.md +13 -10
- package/docs/README.md +24 -19
- package/docs/README_CONTENT_CONTRACT.md +12 -8
- package/docs/agent-entry.md +194 -0
- package/docs/ci-workflows.md +18 -1
- package/docs/commands-reference.md +26 -2
- package/docs/contracts/ARTIFACT_CATALOG.md +9 -3
- package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +3 -0
- package/docs/contracts/README.md +22 -2
- package/docs/goal-packs.md +70 -9
- package/docs/workspace-operations.md +16 -8
- package/docs/workspace-repair-engine.md +36 -5
- package/package.json +4 -2
- package/scripts/enterprise-package-smoke.mjs +4 -0
- package/dist/analyze-MAU36FTX.js +0 -1
- package/dist/autopilot-release-TA2L7SCB.js +0 -1
- package/dist/capabilities-command-HE2FICLG.js +0 -1
- package/dist/chunk-42Q5E2YV.js +0 -1
- package/dist/chunk-7IRGSM25.js +0 -1
- package/dist/chunk-CNWUIXF3.js +0 -1
- package/dist/chunk-FPJNWPKU.js +0 -1
- package/dist/chunk-HH54C3XJ.js +0 -1
- package/dist/chunk-NQ5H4R2I.js +0 -83
- package/dist/chunk-PCXBPQO6.js +0 -1
- package/dist/chunk-QXW3SLEX.js +0 -1
- package/dist/chunk-TMOKXYAQ.js +0 -2
- package/dist/chunk-VIFTO53Y.js +0 -1
- package/dist/chunk-ZDYGO3T7.js +0 -36
- package/dist/goal-lifecycle-YTBU3ICP.js +0 -1
- package/dist/goal-pack-MYYH7K43.js +0 -1
- package/dist/workspace-explain-RGGZL5IW.js +0 -1
- package/dist/workspace-explain-contract-4ZZ6CJ44.js +0 -1
- package/dist/workspace-graph-token-efficiency-TF23UYEF.js +0 -1
- package/dist/workspace-knowledge-graph-snapshot-7IU2QAXI.js +0 -1
- package/dist/workspace-repair-engine-AZTJIFCY.js +0 -3
- package/dist/workspace-run-VMZY6LIF.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a}from'./chunk-GR6442P7.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {i}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-GR6442P7.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {i}from'./chunk-NZ3WZYD5.js';import {j,s,p as p$1,v}from'./chunk-MOSXTVPU.js';import z from'crypto';import Y from'os';import l from'path';import {once}from'events';import {createWriteStream,createReadStream}from'fs';import*as Q from'readline';import {Transform,Readable}from'stream';import {pipeline}from'stream/promises';import {lookup}from'dns/promises';import T from'net';import p from'fs-extra';import*as ee from'yauzl';import*as te from'yazl';var qe="workspai-workspace-archive-capabilities-v1",q="workspai-workspace-archive-manifest-v1",k="workspai-workspace-archive-operation-result-v1";var K="contracts/workspace-archive-manifest.v1.json",Z="contracts/workspace-archive-operation-result.v1.json",Ke={archiveCompression:{signature:"--archive-compression <mode>",description:"Archive compression: store (default) or deflate",appliesTo:["export"]},maxDownloadSize:{signature:"--max-download-size <size>",description:"Maximum remote archive download size (secure default: 5gb)",appliesTo:["inspect","verify","doctor","hydrate","import"]},maxExpandedSize:{signature:"--max-expanded-size <size>",description:"Maximum expanded archive payload size (secure default: 20gb)",appliesTo:["inspect","verify","doctor","hydrate","import"]},downloadTimeoutMs:{signature:"--download-timeout-ms <ms>",description:"Remote archive download timeout in milliseconds; 0 disables it",appliesTo:["inspect","verify","doctor","hydrate","import"]},allowPrivateNetwork:{signature:"--allow-private-network",description:"Allow archive downloads from loopback/private networks (unsafe for untrusted input)",appliesTo:["inspect","verify","doctor","hydrate","import"]}};var A=".workspai/archive-manifest.json",R=".rapidkit/archive-manifest.json",de="workspai.workspace.archive",ye=300*1e3,ve=5*1024*1024*1024,we=20*1024*1024*1024,J=2e5,ge=5*1024*1024*1024,ke=1e3,M=5,Ee=64*1024*1024;function Ae(r){let t=r.toLowerCase().split("%")[0];if(T.isIPv4(t)){let e=t.split(".").map(Number);return e[0]===0||e[0]===10||e[0]===127||e[0]===169&&e[1]===254||e[0]===172&&e[1]>=16&&e[1]<=31||e[0]===192&&e[1]===168||e[0]===100&&e[1]>=64&&e[1]<=127||e[0]>=224}return T.isIPv6(t)?t==="::"||t==="::1"||t.startsWith("fc")||t.startsWith("fd")||/^fe[89ab]/.test(t)||t.startsWith("ff")||t.startsWith("::ffff:127.")||t.startsWith("::ffff:10.")||t.startsWith("::ffff:192.168."):true}async function X(r,t){let e=new URL(r);if(e.protocol!=="https:"&&e.protocol!=="http:")throw new Error(`Workspace archive URL protocol is not supported: ${e.protocol}`);if(e.protocol!=="https:"&&!t)throw new Error("Remote workspace archives require HTTPS unless private-network access is explicitly enabled.");if(e.username||e.password)throw new Error("Workspace archive URL must not contain embedded credentials.");if(t)return e;let i=e.hostname.replace(/^\[|\]$/g,"").toLowerCase();if(i==="localhost"||i.endsWith(".localhost"))throw new Error("Workspace archive URL resolves to a private or local network address.");let a=T.isIP(i)?[{address:i}]:await lookup(i,{all:true,verbatim:true});if(a.length===0||a.some(({address:s})=>Ae(s)))throw new Error("Workspace archive URL resolves to a private or local network address.");return e}async function Pe(r,t,e){let i=await X(r,e);for(let a=0;a<=M;a+=1){let s=await fetch(i,{signal:t,redirect:"manual",credentials:"omit"});if(![301,302,303,307,308].includes(s.status))return s;let n=s.headers.get("location");if(await s.body?.cancel(),!n)throw new Error("Workspace archive redirect is missing a Location header.");if(a===M)throw new Error(`Workspace archive download exceeded ${M} redirects.`);i=await X(new URL(n,i).href,e);}throw new Error("Workspace archive redirect policy failed.")}var We=new Set(["__pycache__",".venv","venv","node_modules",".git","dist","build","target",".pytest_cache",".mypy_cache",".ruff_cache","htmlcov",".next",".turbo",".cache"]),be=new Set([".DS_Store","Thumbs.db",".coverage","npm-debug.log","yarn-error.log","pnpm-debug.log","workspace-link.local.json","imported-projects.json","workspace-registry.v1.json"]),Se=[/^\.env$/i,/^\.env\.(?!example$|sample$|template$).+/i,/^.*\.pem$/i,/^.*\.key$/i,/^id_rsa$/i,/^id_ed25519$/i];function _(r){return r.replace(/\\/g,"/")}function re(r){return r.trim().replace(/\.workspai-archive\.zip$/i,"").replace(/\.rapidkit-archive\.zip$/i,"").replace(/\.zip$/i,"").trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,64)||"imported-workspace"}function ie(r){let t=_(r).trim();if(!t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0"))return false;let e=t.split("/").filter(Boolean);return e.length>0&&!e.some(i=>i===".."||i===".")}function ae(r){if(!ie(r))throw new Error(`Archive contains an unsafe path: ${r}`)}function Re(r,t){let e=l.relative(t,r);return e===""||!!e&&!e.startsWith("..")&&!l.isAbsolute(e)}function _e(r,t){let e=_(r),i$1=e.split("/").filter(Boolean);if(i$1.some((n,o)=>(n===".workspai"||n===".rapidkit")&&["cache","reports"].includes(i$1[o+1]||""))||i$1.some(n=>We.has(n)||a(n)))return true;let s=i$1[i$1.length-1]||"";return e===i.workspaceContract||e===".rapidkit/workspace.contract.json"||be.has(s)||/\.(?:workspai|rapidkit)-archive\.zip$/i.test(s)||!t?.includeEnv&&Se.some(n=>n.test(s))?true:s.endsWith(".pyc")||s.endsWith(".log")}async function Ce(r){for(let t of [l.join(r,".workspai","workspace.contract.json"),l.join(r,".rapidkit","workspace.contract.json")])if(await p.pathExists(t))try{return await p.readJson(t)}catch(e){throw new Error(`Workspace contract could not be inspected safely for archive portability: ${t}: ${e instanceof Error?e.message:String(e)}`)}return null}function xe(r){return (r?.projects??[]).filter(t=>typeof t.externalPath=="string"||typeof t.relativePath=="string"&&t.relativePath.startsWith("external/")).map(t=>({name:t.slug||t.relativePath||"external-project",relationship:["adopted","linked","imported","managed","restored"].includes(String(t.relationship))?t.relationship:"adopted",included:false,requiredAction:"relink"})).sort((t,e)=>t.name.localeCompare(e.name))}function Oe(r){if(r)return {...r,workspace:{...r.workspace},projects:r.projects.filter(t=>typeof t.externalPath!="string"&&!t.relativePath.startsWith("external/")).map(({externalPath:t,...e})=>({...e,modules:[...e.modules],ports:e.ports.map(i=>({...i})),contracts:{owns:[...e.contracts.owns],apis:e.contracts.apis.map(i=>({...i})),publishes:[...e.contracts.publishes],consumes:[...e.contracts.consumes],dependsOn:[...e.contracts.dependsOn],env:[...e.contracts.env]}}))}}async function*se(r,t,e){let i=(await p.readdir(t,{withFileTypes:true})).sort((a,s)=>a.name.localeCompare(s.name));for(let a of i){let s=l.join(t,a.name),n=_(l.relative(r,s));if(!(!n||_e(n,e))){if(a.isDirectory()){yield*se(r,s,e);continue}a.isFile()&&(yield {relativePath:n,fullPath:s});}}}async function ze(r){for(let t of s(r,"workspace.json"))try{let e=await p.readJson(t);if(typeof e.workspace_name=="string"&&e.workspace_name.trim())return e.workspace_name.trim();if(typeof e.name=="string"&&e.name.trim())return e.name.trim()}catch{}return l.basename(l.resolve(r))}async function Ne(r){let t=await p.stat(r.fullPath),e=z.createHash("sha256"),i=0;for await(let s of createReadStream(r.fullPath)){let n=Buffer.isBuffer(s)?s:Buffer.from(s);i+=n.length,e.update(n);}let a=await p.stat(r.fullPath);if(t.size!==a.size||t.mtimeMs!==a.mtimeMs||i!==a.size)throw new Error(`Workspace file changed while preparing archive: ${r.relativePath}`);return {...r,size:i,mtimeMs:a.mtimeMs,sha256:e.digest("hex")}}async function E(r,t){r.write(t)||await once(r,"drain");}async function ne(r){await new Promise((t,e)=>{r.once("error",e),r.end(t);});}async function*O(r){let t=Q.createInterface({input:createReadStream(r),crlfDelay:1/0});for await(let e of t){let i=e.trim();i&&(yield JSON.parse(i));}}async function Me(r){let t=createWriteStream(r.manifestPath,{flags:"wx"});try{await E(t,`{
|
|
2
2
|
`);for(let[i,a]of Object.entries(r.manifestBase))await E(t,` ${JSON.stringify(i)}: ${JSON.stringify(a,null,2)},
|
|
3
3
|
`);await E(t,` "files": [
|
|
4
4
|
`);let e=true;for await(let i of O(r.spoolPath)){let{mtimeMs:a,...s}=i;await E(t,`${e?"":`,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r="workspai-cli-operation-result-v1";function a(e,s,t,o=0){return {schemaVersion:r,operation:e,status:"success",exitCode:o,artifact:s,...t?{outputPath:t}:{}}}function c(e){return {schemaVersion:r,operation:e.operation,status:"error",exitCode:e.exitCode??1,error:{code:e.code,message:e.message},...e.context?{context:e.context}:{},...e.examples?{examples:e.examples}:{},...e.nextActions?{nextActions:e.nextActions}:{}}}export{r as a,a as b,c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {k}from'./chunk-DQ6VXTDE.js';import {b}from'./chunk-GPOZILMY.js';import {a as a$1}from'./chunk-5NIZNXRS.js';import {c}from'./chunk-EWZZUQBR.js';import {b as b$1}from'./chunk-D65FCQIO.js';import {a}from'./chunk-AFIFZTOY.js';import {h,i,e}from'./chunk-NZ3WZYD5.js';import he from'crypto';import G from'fs';import M from'fs/promises';import f from'path';var te=h.projectAgentEntry.schemaVersion,R=i.projectAgentEntry,fe="workspai.agent-bootstrap-receipt.v1",_e="<!-- WORKSPAI:AGENT-ENTRY:START -->",Ne="<!-- WORKSPAI:AGENT-ENTRY:END -->",O=["generic","codex","claude","gemini","qwen","kimi","grok","copilot","cursor","windsurf","amazon-q"],He=["CLAUDE.md","GEMINI.md","QWEN.md",".amazonq/rules/workspai-agent-entry.md"];function me(t){let s=t?.trim().toLowerCase()||"generic";if(s==="orca")return "grok";if(O.includes(s))return s;throw new Error(`Unsupported agent host "${s}". Expected one of: ${O.join(", ")}.`)}function oe(t){let s=t.map(i=>i.id).sort(),n=[...O].sort();if(s.length!==n.length||s.some((i,c)=>i!==n[c]))throw new Error("Project agent entry must define each supported host exactly once.")}function L(t){let{integrity:s,...n}=t;return n}function E(t){return c(t)}function Ge(t){oe(t.hosts);let s={schemaVersion:te,generatedAt:t.context.generatedAt,project:{name:t.context.project.name,relativePath:t.context.project.relativePath,...t.context.project.runtime?{runtime:t.context.project.runtime}:{},...t.context.project.framework?{framework:t.context.project.framework}:{}},workspace:{name:t.context.workspace.name,relationship:t.context.workspace.relationship,localBinding:i.projectWorkspaceLink,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"},canonical:{projectContext:i.projectContextAgent,projectGrounding:".workspai/PROJECT-GROUNDING.md",goalIndex:`workspace:${i.goalIndex}`,workspaceIndex:`workspace:${e.agentIndex}`,workspaceContext:`workspace:${e.agentContext}`,workspaceModel:`workspace:${e.model}`,knowledgeGraph:`workspace:${e.knowledgeGraph}`},protocol:{mode:"canonical-first",bootstrapCommand:"workspai agent bootstrap --for-agent generic --strict --json",verifyCommand:"workspai project agent-entry verify --for-agent all --strict --json",requiredReadOrder:[R,"command:workspai agent bootstrap --for-agent generic --strict --json","command:workspai project workspace status --json",i.projectContextAgent,`workspace:${i.goalIndex}`,`workspace:${e.agentIndex}`,`workspace:${e.agentContext}`,`workspace:${e.model}`,`workspace:${e.knowledgeGraph}`,"command:workspai workspace graph search <task-query> --scope project:<project> --limit 12 --json","source:targeted-live-files"],sourcePolicy:{liveSourceAuthority:"exact-implementation",workspaceEvidenceAuthority:"identity-topology-readiness-goals",broadScanBeforeBootstrap:false,sourceMutation:"governed-only",verificationClaims:"cli-evidence-only"},degradedMode:{discloseMissingEvidence:true,allowCompleteArchitectureClaims:false,allowReadOnlySourceInspection:true}},hosts:[...t.hosts].sort((i,c)=>i.id.localeCompare(c.id))},n={...s,integrity:{algorithm:"sha256",projectContextHash:t.context.integrity.payloadHash,payloadHash:E(s),portable:true,absolutePathsEmitted:false}};if(!y(n))throw new Error("Project agent entry rejected a non-portable local path.");return a(n,"contracts/workspace-intelligence/project-agent-entry.v1.json","Project agent entry"),n}function y(t){return typeof t=="string"?!(/^[A-Za-z]:[\\/]/.test(t)||/(?:^|[\s("'`])[A-Za-z]:[\\/]/.test(t)||/(?:^|[\s("'`])file:\/\//i.test(t)||/(?:^|[\s("'`])\\\\[^\\\s]+[\\]/.test(t)||/(?:^|[\s("'`])\/(?:Users|home|private|var|opt|srv|mnt|Volumes|tmp)\//.test(t)):Array.isArray(t)?t.every(y):t&&typeof t=="object"?Object.values(t).every(y):true}async function ue(t){let s=f.join(t,R),n=JSON.parse(await M.readFile(s,"utf8"));if(a(n,"contracts/workspace-intelligence/project-agent-entry.v1.json","Project agent entry"),n.integrity.payloadHash!==E(L(n)))throw new Error("Project agent entry integrity validation failed.");if(oe(n.hosts),!y(n)||n.integrity.absolutePathsEmitted)throw new Error("Project agent entry contains a non-portable local path.");return n}async function ye(t){let s=f.join(t,i.projectContextAgent),n=JSON.parse(await M.readFile(s,"utf8"));a(n,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent");let i$1=L(n),c=he.createHash("sha256").update(JSON.stringify(i$1)).digest("hex");if(n.integrity.payloadHash!==c)throw new Error("Project context agent integrity validation failed.");if(!y(n)||n.integrity.absolutePathsEmitted)throw new Error("Project context agent contains a non-portable local path.");return n}function we(t){return t.includes("blocked")?"blocked":t.includes("degraded")?"degraded":"ready"}async function Oe(t){let s=b({startPath:f.resolve(t.startPath??process.cwd()),strict:true,requireProjectMembership:true});if(!s?.projectPath)throw new Error("No canonically bound Workspai project was resolved.");let n=s.projectPath,i$1=s.workspacePath,c=await ue(n),o=await ye(n);if(c.integrity.projectContextHash!==o.integrity.payloadHash||c.project.name!==o.project.name||c.workspace.name!==o.workspace.name)throw new Error("Project agent entry is not bound to the current project context.");let $=t.forAgent?.trim().toLowerCase()||"generic",F=$==="all",g=F?"all":me($),W=g,h=F?c.hosts:c.hosts.filter(e=>e.id===g),K=c.hosts.find(e=>e.id==="generic");if(h.length===0&&K&&h.push(K),h.length===0)throw new Error("Project agent entry does not define generic host coverage.");let w=[],p=(e,r,S,u)=>w.push({id:e,status:r,message:S,...u?{artifact:u}:{}});p("workspace-binding","passed","Canonical workspace membership is resolved."),p("entry-integrity","passed","Project entry manifest integrity is valid.",R),p("project-context-integrity","passed","Project context integrity and manifest binding are valid.",i.projectContextAgent);let I=[...new Set(h.flatMap(e=>e.entryFiles))].sort(),ne=I.filter(e=>!G.existsSync(f.join(n,e))),m=h.some(e=>e.status==="blocked")||ne.length>0?"blocked":h.some(e=>e.status==="degraded")?"degraded":"ready";p("host-discovery",m==="ready"?"passed":m==="degraded"?"warning":"failed",m==="ready"?`${g} has discoverable Workspai entry coverage.`:m==="degraded"?h.find(e=>e.reason)?.reason??`${g} entry coverage is degraded.`:`${g} entry coverage is missing required files.`,I[0]);let V=[e.agentIndex,e.agentContext,e.model,e.knowledgeGraph],j=V.filter(e=>!G.existsSync(f.join(i$1,e)));p("canonical-evidence",j.length===0?"passed":"failed",j.length===0?"Required canonical workspace evidence is present.":`Required canonical evidence is missing: ${j.join(", ")}.`);let k$1=[],v=null,q=null;for(let e$1 of V)if(!j.includes(e$1))try{let r=JSON.parse(await M.readFile(f.join(i$1,e$1),"utf8"));b$1(e$1,r,e$1),e$1===e.model&&(v=r),e$1===e.knowledgeGraph&&(q=r);}catch{k$1.push(e$1);}p("canonical-contracts",k$1.length===0?"passed":"failed",k$1.length===0?"Canonical workspace evidence satisfies its published schemas.":`Canonical evidence failed contract validation: ${k$1.join(", ")}.`);let re=v?.workspace,se=q?.workspace,ae=Array.isArray(v?.projects)?v.projects:[],B=k$1.length===0&&re?.name===o.workspace.name&&se?.name===o.workspace.name&&ae.some(e=>e.name===o.project.name);p("canonical-project-membership",B?"passed":"failed",B?"The project and workspace identities agree across the entry, Model, and Graph.":"The project or workspace identity is missing or inconsistent in canonical evidence.");let J=!o.intelligence.freshness.graphMatchesModel||["missing","stale"].includes(o.intelligence.freshness.model)||["missing","stale"].includes(o.intelligence.freshness.graph)?"failed":o.intelligence.freshness.model==="unknown"||o.intelligence.freshness.graph==="unknown"?"warning":"passed",P=false,C;if(t.validateLiveInputs!==false)try{let e=await a$1(i$1);P=e.status==="hit";let r=e.status==="hit"?"Live project inputs match the persisted Model and Knowledge Graph snapshot.":`Live project inputs require an intelligence refresh (${e.reason}).`;C={id:"live-inputs",status:P?"passed":"failed",message:r};}catch{C={id:"live-inputs",status:"failed",message:"Live project inputs could not be validated against canonical graph evidence."};}else C={id:"live-inputs",status:"warning",message:"Live input validation was skipped; persisted compatibility was checked only."};let b$2=J==="warning"&&o.intelligence.freshness.model==="unknown"&&o.intelligence.freshness.graph==="fresh"&&o.intelligence.freshness.graphMatchesModel&&P?"passed":J;p("persisted-freshness",b$2,b$2==="passed"?o.intelligence.freshness.model==="unknown"?"Model and Graph bindings are current; live input validation closes structural freshness while verify-before-use facts remain individually governed.":"Persisted Model and Knowledge Graph bindings are current.":b$2==="warning"?"Persisted evidence is compatible, but at least one freshness state is unknown.":"Persisted Model or Knowledge Graph evidence is missing, stale, or mismatched."),w.push(C);let l={present:false,appliesToProject:false,status:"none"},T=[],ie=f.join(i$1,i.goalIndex);if(G.existsSync(ie)){let e=null;try{e=await k({workspacePath:i$1,validateBindings:false});}catch{T.push("workspai goal --list --json"),p("active-goal","failed","The Goal index is present but invalid.");}if(e?.active&&(l={present:true,appliesToProject:e.active.scope.projects.includes(o.project.name),status:"invalid",id:e.active.id,objective:e.active.objective,lifecycle:e.active.lifecycle,goalPack:`workspace:${e.active.goalPack}`,agentHandoff:`workspace:${e.active.agentHandoff}`}),e)try{let r=await k({workspacePath:i$1,validateBindings:true});r.active&&(l={present:true,appliesToProject:r.active.scope.projects.includes(o.project.name),status:"ready",id:r.active.id,objective:r.active.objective,lifecycle:r.active.lifecycle,goalPack:`workspace:${r.active.goalPack}`,agentHandoff:`workspace:${r.active.agentHandoff}`}),p("active-goal","passed",r.active?"The active Goal Pack and agent handoff have valid canonical bindings.":"No active Goal Pack is selected.");}catch(r){let S=r instanceof Error?r.message:String(r),u=l.present&&/\bstale\b|--refresh/i.test(S);if(l.present&&(l.status=u?"stale":"invalid"),u&&l.objective){let N=e.active,ge=N?.scope.kind==="project"&&N.scope.projects.length===1?`project:${N.scope.projects[0]}`:"workspace";T.push(`workspai goal ${JSON.stringify(l.objective)} --scope ${ge} --for-agent generic --refresh --json`);}else T.push("workspai goal --status --json");p("active-goal","failed",u?"The selected Goal Pack is present but stale; regenerate it against current canonical evidence before acting.":l.present?"The selected Goal Pack is present but its canonical binding or handoff is invalid.":"The Goal index could not be validated.");}}else p("active-goal","passed","No Goal index is present for this workspace.");let ce=w.some(e=>e.status==="failed")?"blocked":w.some(e=>e.status==="warning")?"degraded":"ready",x=we([m,ce]),le=`command:workspai agent bootstrap --for-agent ${g} --strict --json`,pe=c.protocol.requiredReadOrder.map(e=>e==="command:workspai agent bootstrap --for-agent generic --strict --json"?le:e),U={schemaVersion:fe,generatedAt:(t.now??new Date).toISOString(),status:x,requestedAgent:W,resolvedHost:g,project:{name:o.project.name,relativePath:o.project.relativePath,...o.project.runtime?{runtime:o.project.runtime}:{},...o.project.framework?{framework:o.project.framework}:{}},workspace:{name:o.workspace.name,relationship:o.workspace.relationship,resolved:true,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"},entry:{artifact:R,schemaVersion:te,hostStatus:m,entryFiles:I},canonicalEvidence:{projectContext:i.projectContextAgent,workspaceIndex:`workspace:${e.agentIndex}`,workspaceContext:`workspace:${e.agentContext}`,workspaceModel:`workspace:${e.model}`,knowledgeGraph:`workspace:${e.knowledgeGraph}`,modelFreshness:o.intelligence.freshness.model,graphFreshness:o.intelligence.freshness.graph,graphMatchesModel:o.intelligence.freshness.graphMatchesModel,liveInputsValidated:P,blockerCount:o.blockers.length},activeGoal:l,requiredReadOrder:pe,claims:{architecture:x==="ready"?"allowed-with-citations":"prohibited",sourceInspection:"bounded-and-targeted",sourceMutation:"governed-cli-transaction-only",verification:"cli-evidence-only"},checks:w,nextActions:x==="ready"?[...l.present&&l.appliesToProject&&l.agentHandoff?[`read:${l.agentHandoff}`]:[],`workspai workspace graph search <task-query> --scope project:${o.project.name} --limit 12 --json`,"inspect only the returned proof paths and target source files"]:[...T,"workspai workspace intelligence run --for-agent generic --strict --json",`workspai agent bootstrap --for-agent ${g} --strict --json`]},Y=E(L(c)),de=E({manifestHash:Y,projectContextHash:o.integrity.payloadHash,requestedAgent:W,status:x,generatedAt:U.generatedAt}),D={...U,receiptId:de},_={...D,integrity:{algorithm:"sha256",manifestHash:Y,projectContextHash:o.integrity.payloadHash,payloadHash:E(D),portable:true,absolutePathsEmitted:false}};if(!y(_))throw new Error("Agent bootstrap receipt rejected a non-portable local path.");return a(_,"contracts/workspace-intelligence/agent-bootstrap-receipt.v1.json","Agent bootstrap receipt"),_}
|
|
2
|
+
export{te as a,R as b,fe as c,_e as d,Ne as e,O as f,He as g,me as h,Ge as i,Oe as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {d as d$1,c,e as e$1}from'./chunk-
|
|
1
|
+
import {d as d$1,c,e as e$1}from'./chunk-CCDGHPEJ.js';import {f,e}from'./chunk-NZ3WZYD5.js';import k from'fs-extra';var y=f.history,a=e.history,d=50;function A(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return typeof e.generatedAt!="string"?null:e.kind==="agent-action"?typeof e.actionId!="string"||typeof e.summary!="string"||e.outcome!=="ok"&&e.outcome!=="failed"?null:{kind:"agent-action",generatedAt:e.generatedAt,actionId:e.actionId,scope:typeof e.scope=="string"?e.scope:"workspace",summary:e.summary,outcome:e.outcome,...typeof e.evidenceSha256=="string"?{evidenceSha256:e.evidenceSha256}:{}}:e.kind==="doctor-fix"?e.scope!=="workspace"&&e.scope!=="project"||typeof e.summary!="string"||e.outcome!=="ok"&&e.outcome!=="failed"?null:{kind:"doctor-fix",generatedAt:e.generatedAt,scope:e.scope,summary:e.summary,outcome:e.outcome,applied:typeof e.applied=="number"?e.applied:0,failed:typeof e.failed=="number"?e.failed:0,skipped:typeof e.skipped=="number"?e.skipped:0,remainingBlockers:typeof e.remainingBlockers=="number"?e.remainingBlockers:0}:typeof e.verdict!="string"||typeof e.risk!="string"||typeof e.gatePassed!="boolean"?null:{kind:"verify",generatedAt:e.generatedAt,verdict:e.verdict,risk:String(e.risk),affectedProjects:typeof e.affectedProjects=="number"?e.affectedProjects:0,freshness:e.freshness??"unknown",gatePassed:e.gatePassed,blockingReasons:typeof e.blockingReasons=="number"?e.blockingReasons:0,policyViolations:typeof e.policyViolations=="number"?e.policyViolations:0}}function S(t,e){return {kind:"verify",generatedAt:t.generatedAt,verdict:t.summary.verdict,risk:t.impact.risk,affectedProjects:t.impact.affectedProjects,freshness:t.freshness.verdict,gatePassed:e,blockingReasons:t.blockingReasons.length,policyViolations:t.policyViolations.length}}function F(t){return {kind:"agent-action",generatedAt:t.generatedAt,actionId:t.actionId,scope:t.scope,summary:t.summary,outcome:t.outcome,...t.evidenceSha256?{evidenceSha256:t.evidenceSha256}:{}}}function V(t,e){let o=t.appliedFixes.filter(i=>i.outcome==="applied").length,r=t.appliedFixes.filter(i=>i.outcome==="failed").length,n=t.appliedFixes.filter(i=>i.outcome==="skipped").length,s=t.appliedFixes.filter(i=>i.outcome==="guidance").length,c=t.remainingBlockers.length,g=r>0||c>0?"failed":"ok";return {kind:"doctor-fix",generatedAt:t.generatedAt,scope:e,summary:`${o} applied, ${r} failed, ${n} skipped, ${s} guidance, ${c} blocker(s) remaining`,outcome:g,applied:o,failed:r,skipped:n,remainingBlockers:c}}async function E(t){let e=await d$1(t,a);try{if(!e||!await k.pathExists(e))return null;let o=await k.readJson(e);return o?.schemaVersion!==y||!Array.isArray(o.entries)?null:{schemaVersion:y,retention:typeof o.retention=="number"?o.retention:d,entries:o.entries.map(r=>A(r)).filter(r=>r!=null)}}catch{return null}}function x(t,e,o=d){let r=Math.max(1,Math.floor(o)),n=[...t?.entries??[],e],s=n.slice(Math.max(0,n.length-r));return {schemaVersion:y,retention:r,entries:s}}async function v(t,e,o){return c(t,a,async()=>{let r=await d$1(t,a),n=await E(t);if(r&&!n)throw new Error(`Workspace history is unreadable or invalid; refusing to overwrite: ${r}`);let s=x(n,e,o?.retention??d);return await e$1(t,a,s),s})}export{y as a,a as b,d as c,A as d,S as e,F as f,V as g,E as h,x as i,v as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-A5FBGRJA.js';import {d as d$1,m}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-A5FBGRJA.js';import {d as d$1,m}from'./chunk-SP5EHSWG.js';import {d,e}from'./chunk-CCDGHPEJ.js';import {i,h}from'./chunk-NZ3WZYD5.js';import {s}from'./chunk-MOSXTVPU.js';import {s as s$1,q}from'./chunk-RJIYCDVC.js';import a from'path';import {existsSync}from'fs';import m$1 from'fs-extra';var f=i.workspaceRegistry,w=h.workspaceRegistry.schemaVersion;function E(r){return {slug:r.slug,relativePath:r.relativePath,framework:r.framework,kit:r.kit,source:r.source}}async function b(r){let e=s(r,"workspace.json").find(t=>existsSync(t));if(!e)return {exists:false,legacyProjectCount:0};try{let t=await m$1.readJson(e),c=Array.isArray(t.projects)?t.projects.length:0,o=typeof t.workspace_name=="string"&&t.workspace_name.trim()||typeof t.name=="string"&&t.name.trim()||a.basename(r);return {exists:true,manifestPath:e,workspaceName:o,profile:typeof t.profile=="string"?t.profile:void 0,legacyProjectCount:c}}catch{return {exists:true,manifestPath:e,legacyProjectCount:0,workspaceName:a.basename(r)}}}async function _(r){let e=a$1(r);for(let t of s$1())if(await m$1.pathExists(t))try{let o=((await m$1.readJson(t)).workspaces||[]).find(s=>a$1(s.path)===e);if(o)return {exists:true,projectCount:Array.isArray(o.projects)?o.projects.length:0,registryPath:t}}catch{continue}return {exists:false,projectCount:0,registryPath:a.join(q(),"workspaces.json")}}async function T(r,e){let t=a.resolve(r),c=await d(t,d$1),o=await b(t),s=await _(t),i=e?.contract!==void 0||!!c,n=[];if(e?.contract)n=e.contract.projects||[];else if(i)try{let{contract:A}=await m({workspacePath:t});n=A.projects||[];}catch{n=[];}let d$2={contract:{exists:i,projectCount:n.length,path:d$1},globalRegistry:{exists:s.exists,projectCount:s.projectCount,path:s.registryPath},legacyWorkspaceJson:{exists:o.exists,projectCount:o.legacyProjectCount,path:o.manifestPath?a.relative(t,o.manifestPath):void 0}},p="none",u=[],y=0;return i?(p="workspace.contract.json",u=n.map(E),y=u.length):s.projectCount>0?(p="global-registry",y=s.projectCount):o.legacyProjectCount>0&&(p="legacy-workspace.json",y=o.legacyProjectCount),{contractExists:i,summary:{schemaVersion:w,kind:"rapidkit.workspace.registry",workspacePath:t,workspaceName:o.workspaceName||a.basename(t),profile:o.profile,projectCount:y,authority:p,contractPath:d$1,projects:u,sources:d$2}}}async function U(r){let e=await d(r,f);if(!e)return null;try{let t=await m$1.readJson(e);return t?.schemaVersion!==w?null:t}catch{return null}}async function D(r,e$1){let t=await M(r,e$1);return await e(r,f,t),t}async function M(r,e){return {...(await T(r,{contract:e?.contract})).summary,generatedAt:(e?.now??new Date).toISOString(),registrySummaryPath:f}}function F(r,e=""){return r.projectCount>0?r.authority==="workspace.contract.json"?`${r.projectCount} project(s) registered in workspace contract${e}.`:r.authority==="global-registry"?`${r.projectCount} project(s) registered in global workspace registry${e}.`:`${r.projectCount} project(s) registered in legacy workspace manifest${e}.`:`Workspace state exists, but no projects are registered yet${e}.`}export{f as a,w as b,T as c,U as d,D as e,M as f,F as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r="workspai.doctor-capabilities.v1",k="universal-doctor-capabilities-v1",t="workspai.doctor-validation.v1",w="doctor-disease-corpus-v1";var o={model:".workspai/reports/workspace-model.json",knowledgeGraph:".workspai/reports/workspace-knowledge-graph.json",snapshot:".workspai/reports/workspace-model-snapshot.json",diff:".workspai/reports/workspace-model-diff-last-run.json",impact:".workspai/reports/workspace-impact-last-run.json",analyze:".workspai/reports/analyze-last-run.json",doctor:".workspai/reports/doctor-last-run.json",contractVerify:".workspai/reports/workspace-contract-verify-last-run.json",readiness:".workspai/reports/release-readiness-last-run.json",verify:".workspai/reports/workspace-verify-last-run.json",history:".workspai/reports/workspace-intelligence-history.json",agentContext:".workspai/reports/workspace-context-agent.json",agentIndex:".workspai/reports/INDEX.json",agentCustomizationPack:".workspai/reports/agent-customization-pack.json",skillsIndex:".workspai/reports/workspace-skills-index.json",agents:"AGENTS.md",explain:".workspai/reports/workspace-explain-last-run.json",intelligenceRun:".workspai/reports/workspace-intelligence-run-last-run.json",evaluationLive:".workspai/reports/workspace-intelligence-evaluation-live.json",evaluationLastRun:".workspai/reports/workspace-intelligence-evaluation-last-run.json",verifiedGoalStatus:".workspai/reports/verified-goal-last-run.json",repairTransaction:".workspai/reports/workspace-repair-last-run.json"},s={model:"workspace-model.v1",knowledgeGraph:"workspace-knowledge-graph.v1",snapshot:"workspace-model-snapshot.v1",diff:"workspace-model-diff.v1",impact:"workspace-impact.v1",analyze:"rapidkit-analyze-v1",doctor:"doctor-workspace-evidence-v1",contractVerify:"workspace-contract-verify.v1",readiness:"release-readiness-v1",verify:"workspace-verify.v1",history:"workspace-intelligence-history.v1",agentContext:"workspace-context.v1",agentIndex:"rapidkit-agent-reports-index.v1",agentCustomizationPack:"rapidkit-agent-customization-pack.v1",skillsIndex:"workspace-skills-index.v1",agents:null,explain:"workspace-explain.v1",intelligenceRun:"workspace-intelligence-run.v1",evaluationLive:"workspace-intelligence-evaluation.v1",evaluationLastRun:"workspace-intelligence-evaluation.v1",verifiedGoalStatus:"workspai.verified-goal-status.v1",repairTransaction:"workspai.workspace-repair-transaction.v1"},c={model:"contracts/workspace-intelligence/workspace-model.v1.json",knowledgeGraph:"contracts/workspace-intelligence/workspace-knowledge-graph.v1.json",snapshot:"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",diff:"contracts/workspace-intelligence/workspace-model-diff.v1.json",impact:"contracts/workspace-intelligence/workspace-impact.v1.json",analyze:"contracts/analyze-last-run.v1.json",doctor:"contracts/doctor-workspace-evidence.v1.json",contractVerify:"contracts/workspace-intelligence/workspace-contract-verify.v1.json",readiness:"contracts/release-readiness.v1.json",verify:"contracts/workspace-intelligence/workspace-verify.v1.json",history:"contracts/workspace-intelligence/workspace-intelligence-history.v1.json",agentContext:"contracts/workspace-intelligence/workspace-context.v1.json",agentIndex:"contracts/workspace-intelligence/agent-reports-index.v1.json",agentCustomizationPack:"contracts/workspace-intelligence/agent-customization-pack-report.v1.json",skillsIndex:"contracts/workspace-intelligence/workspace-skills-index.v1.json",agents:null,explain:"contracts/workspace-intelligence/workspace-explain.v1.json",intelligenceRun:"contracts/workspace-intelligence/workspace-intelligence-run.v1.json",evaluationLive:"contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",evaluationLastRun:"contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",verifiedGoalStatus:"contracts/workspace-intelligence/verified-goal-status.v1.json",repairTransaction:"contracts/workspace-intelligence/workspace-repair-transaction.v1.json"},l={goalIndex:{artifactPath:".workspai/goals/index.json",schemaVersion:"workspai.goal-index.v1",contractPath:"contracts/workspace-intelligence/goal-index.v1.json",producerCommands:[["goal"]]},projectWorkspaceLink:{artifactPath:".workspai/workspace-link.local.json",schemaVersion:"project-workspace-link.v1",contractPath:"contracts/project-workspace-link.v1.json",producerCommands:[["adopt"],["import"],["project","workspace","relink"],["workspace","sync"]]},projectContextAgent:{artifactPath:".workspai/reports/project-context-agent.json",schemaVersion:"project-context-agent.v1",contractPath:"contracts/workspace-intelligence/project-context-agent.v1.json",producerCommands:[["adopt"],["import"],["workspace","sync"],["workspace","agent-sync","--write"]]},projectAgentEntry:{artifactPath:".workspai/agent-entry.v1.json",schemaVersion:"workspai.agent-entry.v1",contractPath:"contracts/workspace-intelligence/project-agent-entry.v1.json",producerCommands:[["adopt"],["import"],["workspace","sync"],["workspace","agent-sync","--write"]]},workspaceContract:{artifactPath:".workspai/workspace.contract.json",schemaVersion:1,contractPath:"contracts/workspace-contract.v1.json",producerCommands:[["workspace","sync"],["workspace","contract","sync"]]},workspaceModelCache:{artifactPath:".workspai/cache/workspace-model.v1.json",schemaVersion:"workspace-model-cache.v1",contractPath:"contracts/workspace-model-cache.v1.json",producerCommands:[["workspace","model"]]},workspaceRegistry:{artifactPath:".workspai/workspace-registry.v1.json",schemaVersion:"workspace-registry.v1",contractPath:"contracts/workspace-registry.v1.json",producerCommands:[["workspace","sync"]]},compatibilityMatrix:{artifactPath:".workspai/compatibility-matrix.json",schemaVersion:"rapidkit.compatibility-matrix.v1",contractPath:"contracts/compatibility-matrix.v1.json",producerCommands:[["bootstrap"]]},doctorWorkspaceCache:{artifactPath:".workspai/reports/doctor-workspace-cache.json",schemaVersion:"doctor-workspace-cache-v2",contractPath:"contracts/doctor-workspace-cache.v2.json",producerCommands:[["doctor","workspace"]]},doctorCapabilities:{artifactPath:".workspai/reports/doctor-capabilities.json",schemaVersion:r,contractPath:"contracts/workspace-intelligence/doctor-capabilities.v1.json",producerCommands:[["doctor","capabilities","--write"]]},doctorValidation:{artifactPath:".workspai/reports/doctor-validation-last-run.json",schemaVersion:t,contractPath:"contracts/workspace-intelligence/doctor-validation.v1.json",producerCommands:[["doctor","capabilities","--validate","--write"]]},bootstrapCompliance:{artifactPath:".workspai/reports/bootstrap-compliance.latest.json",schemaVersion:"bootstrap-compliance.v1",contractPath:"contracts/bootstrap-compliance.v1.json",producerCommands:[["bootstrap"]]},mirrorOps:{artifactPath:".workspai/reports/mirror-ops.latest.json",schemaVersion:"mirror-ops.v1",contractPath:"contracts/mirror-ops.v1.json",producerCommands:[["mirror","status"]]},transparencyEvidence:{artifactPath:".workspai/reports/transparency-evidence.latest.json",schemaVersion:"transparency-evidence.v1",contractPath:"contracts/transparency-evidence.v1.json",producerCommands:[["mirror","sync"]]},workspaceShareBundle:{artifactPath:".workspai/reports/share-bundle.json",schemaVersion:"1.1",schemaVersionField:"schema_version",contractPath:"contracts/workspace-share-bundle.v1.json",producerCommands:[["workspace","share"]]},doctorProject:{artifactPath:".workspai/reports/doctor-project-last-run.json",schemaVersion:"doctor-project-evidence-v1",contractPath:"contracts/doctor-project-evidence.v1.json",producerCommands:[["doctor","project"]]},doctorReceipt:{artifactPath:".workspai/reports/doctor-receipt-last-run.json",schemaVersion:"workspai.doctor-receipt.v1",contractPath:"contracts/workspace-intelligence/doctor-receipt.v1.json",producerCommands:[["doctor","workspace"],["doctor","project"]]},projectTestCoverage:{artifactPath:".workspai/reports/project-test-coverage-last-run.json",schemaVersion:"workspai.project-test-coverage.v1",contractPath:"contracts/project-test-coverage.v1.json",producerCommands:[["project","coverage"]]},goalPackLastRun:{artifactPath:".workspai/reports/goal-pack-last-run.json",schemaVersion:"workspai.goal-pack.v1",contractPath:"contracts/workspace-intelligence/goal-pack.v1.json",producerCommands:[["goal"]]},doctorRemediationPlan:{artifactPath:".workspai/reports/doctor-remediation-plan-last-run.json",schemaVersion:"doctor-remediation-plan-v2",contractPath:"contracts/doctor-remediation-plan.v2.json",producerCommands:[["workspace","remediation-plan"]]},artifactRemediationPlan:{artifactPath:".workspai/reports/artifact-remediation-plan-last-run.json",schemaVersion:"artifact-remediation-plan-v1",contractPath:"contracts/artifact-remediation-plan.v1.json",producerCommands:[["workspace","remediation-plan"]]},doctorFixResult:{artifactPath:".workspai/reports/doctor-fix-result-last-run.json",schemaVersion:"rapidkit-doctor-fix-result-v1",contractPath:"contracts/workspace-intelligence/doctor-fix-result.v1.json",producerCommands:[["doctor","workspace"]]},pipelineLastRun:{artifactPath:".workspai/reports/pipeline-last-run.json",schemaVersion:"rapidkit-pipeline-v1",contractPath:"contracts/pipeline-last-run.v1.json",producerCommands:[["pipeline"]]},autopilotReleaseLastRun:{artifactPath:".workspai/reports/autopilot-release-last-run.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json",producerCommands:[["autopilot","release"]]},autopilotReleaseAlias:{artifactPath:".workspai/reports/autopilot-release.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json",producerCommands:[["autopilot","release"]]},workspaceRunLast:{artifactPath:".workspai/reports/workspace-run-last.json",schemaVersion:"workspace-run-v1",contractPath:"contracts/workspace-run-last.v1.json",producerCommands:[["workspace","run"]]},workspaiMcpDesign:{artifactPath:".workspai/reports/workspai-mcp-design.json",schemaVersion:"workspai-mcp-design.v1",contractPath:"contracts/workspace-intelligence/mcp-design.v1.json",producerCommands:[["workspace","agent-sync","--write"]]},legacyMcpDesign:{artifactPath:".workspai/reports/rapidkit-mcp-design.json",schemaVersion:"workspai-mcp-design.v1",contractPath:"contracts/workspace-intelligence/mcp-design.v1.json",producerCommands:[["workspace","agent-sync","--write"]]},workspaceWhy:{artifactPath:".workspai/reports/workspace-why-last-run.json",schemaVersion:s.explain,contractPath:c.explain,producerCommands:[["workspace","why"]]},workspaceTrace:{artifactPath:".workspai/reports/workspace-trace-last-run.json",schemaVersion:s.explain,contractPath:c.explain,producerCommands:[["workspace","trace"]]},agentHooks:{artifactPath:".vscode/workspai-agent-hooks.json",schemaVersion:"workspai-agent-hooks.v1",contractPath:"contracts/workspace-intelligence/agent-hooks.v1.json",producerCommands:[["workspace","agent-sync"]]},infraPlan:{artifactPath:".workspai/reports/infra-plan.json",schemaVersion:"rapidkit.infra-plan.v1",contractPath:"contracts/infra-plan.v1.json",producerCommands:[["infra","plan"]]}},u=Object.freeze(Object.fromEntries(Object.entries(l).map(([a,n])=>[a,n.artifactPath]))),h={[o.intelligenceRun]:[["workspace","intelligence","run"]],[o.snapshot]:[["workspace","snapshot"]],[o.history]:[["workspace","feedback","record","--json"]],[o.evaluationLive]:[["workspace","eval","init"],["workspace","eval","record","--json"]],[o.evaluationLastRun]:[["workspace","eval","report","--json"]],[o.verifiedGoalStatus]:[["workspace","goal","plan"],["workspace","goal","verify"]],[o.repairTransaction]:[["workspace","repair","plan"],["workspace","repair","propose"],["workspace","repair","approve"],["workspace","repair","decide"],["workspace","repair","execute"],["workspace","repair","resume"],["workspace","repair","rollback"],["workspace","repair","cancel"]]},j={analyze:"analyze",workspace:"workspace <action> [subaction] [key] [value]",doctor:"doctor [scope]",readiness:"readiness"},f=["analyze","readiness","doctor","workspace"],C=["model","diff","impact","doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence","verify","context","agent-sync","explain"],P=["sync","baseline"],y={sync:[".workspai/workspace.contract.json",".workspai/workspace-registry.v1.json"],baseline:[o.snapshot]},e=o,d={model:{command:["workspace","model","--json","--write"],produces:[e.model,e.knowledgeGraph]},diff:{command:["workspace","diff","--from",e.snapshot,"--json"],produces:[e.diff]},impact:{command:["workspace","impact","--from",e.diff,"--json"],produces:[e.impact]},"doctor-evidence":{command:["doctor","workspace","--json"],produces:[e.doctor]},"contract-evidence":{command:["workspace","contract","verify","--strict","--json"],produces:[e.contractVerify]},"analyze-evidence":{command:["analyze","--json"],produces:[e.analyze]},"readiness-evidence":{command:["readiness","--json","--skip-verify"],produces:[e.readiness]},verify:{command:["workspace","verify","--from-impact",e.impact,"--json"],produces:[e.verify,e.history]},context:{command:["workspace","context","--for-agent","--json","--write","--no-agent-sync"],produces:[e.agentContext]},"agent-sync":{command:["workspace","agent-sync","--write","--json","--preset","enterprise"],produces:[e.agentIndex,e.agentCustomizationPack,e.skillsIndex,e.agents]},explain:{command:["workspace","explain","release-blocked","--json","--write"],produces:[e.explain]}};function I(a){return d[a]}export{r as a,k as b,t as c,w as d,o as e,s as f,c as g,l as h,u as i,h as j,j as k,f as l,C as m,P as n,y as o,d as p,I as q};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {p,k,l,j}from'./chunk-
|
|
1
|
+
import {p,k,l,j}from'./chunk-WSRUPDZN.js';import {a as a$1}from'./chunk-HTYMXMQM.js';import {c}from'./chunk-S5KTATOU.js';import {e as e$1,d,b}from'./chunk-EWZZUQBR.js';import {a}from'./chunk-SP5EHSWG.js';import {e as e$2}from'./chunk-CCDGHPEJ.js';import {a as a$2}from'./chunk-AFIFZTOY.js';import {f,e}from'./chunk-NZ3WZYD5.js';import k$1 from'path';import V from'fs-extra';import {spawnSync}from'child_process';function ue(){let e={...process.env};return delete e.GIT_DIR,delete e.GIT_WORK_TREE,delete e.GIT_INDEX_FILE,delete e.GIT_PREFIX,e}function F(e,t,a){let r=spawnSync("git",t,{cwd:e,env:ue(),encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(r.status!==0)return {ok:false,stdout:""};let c=r.stdout??"";return {ok:true,stdout:a?.preserveWhitespace?c:c.trim()}}function ge(e){let t=e.replace(/\\/g,"/").replace(/^\.\//,"");return t===".workspai/AGENT-GROUNDING.md"?true:[".workspai/reports/",".workspai/cache/",".rapidkit/reports/",".rapidkit/cache/"].some(a=>t.startsWith(a))}function ke(e){let t=[],a=[],r=[];for(let c of e.split(`
|
|
2
2
|
`)){if(!c.trim())continue;let n=c.slice(0,2),i=c.slice(3).trim();if(i&&!ge(i)){if(n==="??"){a.push(i);continue}n.includes("D")&&r.push(i),t.push(i);}}return {changedFiles:[...new Set(t)].sort(),untrackedFiles:[...new Set(a)].sort(),deletedFiles:[...new Set(r)].sort()}}function Q(e,t){let a={available:false,dirty:false,changedFiles:[],untrackedFiles:[],deletedFiles:[]},r=F(e,["rev-parse","--is-inside-work-tree"]);if(!r.ok||r.stdout!=="true")return a;let c=F(e,["rev-parse","--abbrev-ref","HEAD"]),n=F(e,["rev-parse","HEAD"]),i=F(e,["status","--porcelain=v1","--untracked-files=all"],{preserveWhitespace:true}),p=ke(i.stdout),m=p.changedFiles.length>0||p.untrackedFiles.length>0||p.deletedFiles.length>0;return {available:true,branch:c.ok?c.stdout:void 0,commit:n.ok?n.stdout:void 0,ref:t?.ref,dirty:m,changedFiles:p.changedFiles,untrackedFiles:p.untrackedFiles,deletedFiles:p.deletedFiles}}var oe=f.snapshot,L=f.diff,_=e.snapshot,ae=e.diff,he=f.impact,we=e.impact;function ye(e){if(e.model.projectTopology||!e.model.graph||e.modelHash!==e$1(e.model))return null;let t={...e.model,projectTopology:e.model.graph,graph:e.model.graph};return {...e,modelHash:d(t),model:t}}function ne(e){let t=e.trim().toLowerCase();return t==="git"||t.startsWith("git:")}function We(e){let t=e.trim();return t.toLowerCase()==="git"?"HEAD":t.toLowerCase().startsWith("git:")&&t.slice(4).trim()||"HEAD"}function se(e,t){return k$1.isAbsolute(t)?t:k$1.join(e,t)}async function be(e){let t=await V.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace model input is not a JSON object: ${e}`);let a=t;if(a.schemaVersion===oe){a$2(t,"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",`Workspace model snapshot ${e}`);let r=a;if(!r.model||r.model.schemaVersion!==j)throw new Error(`Invalid workspace model snapshot: ${e}`);let c=d(r.model);if(r.modelHash!==c){let n=ye(r);if(!n)throw new Error(`Workspace model snapshot hash mismatch: ${e}`);return {model:n.model,hash:n.modelHash}}return {model:r.model,hash:r.modelHash}}if(a.schemaVersion===j){a$2(t,"contracts/workspace-intelligence/workspace-model.v1.json",`Workspace model ${e}`);let r=a;return {model:r,hash:d(r)}}throw a.schemaVersion===L?new Error(`workspace diff --from received a diff report (${k$1.basename(e)}). Use a workspace model snapshot or model report as baseline, e.g. ${_}. To analyze an existing diff report, run: npx workspai workspace impact --from ${k$1.basename(e)} --json`):new Error(`Unsupported workspace model input schema: ${String(a.schemaVersion)}`)}async function ve(e){let t=await V.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace diff input is not a JSON object: ${e}`);let a=t;if(a.schemaVersion!==L)return null;a$2(t,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Workspace model diff ${e}`);let r=a;if(!r.currentModel||r.currentModel.schemaVersion!==j||!r.summary||!Array.isArray(r.changes))throw new Error(`Invalid workspace model diff report: ${e}`);if(r.toHash!==d(r.currentModel))throw new Error(`Workspace model diff current-model hash mismatch: ${e}`);return r}async function Ye(e){let t=e.model??await p({workspacePath:e.workspacePath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {schemaVersion:oe,generatedAt:(e.now??new Date).toISOString(),modelHash:d(t),modelRef:k,model:t}}async function Qe(e,t){return e$2(t,_,a(e))}function x(e){return {name:e.name,path:e.path,kind:e.kind,category:e.category,runtime:e.runtime,framework:e.framework,generator:e.generator,supportTier:e.supportTier,commands:e.commands,importantFiles:e.importantFiles}}function w(e,t){e.push(t);}function Me(e,t){let a=[],r=["name","profile","type"],c=["workspaceType","surfaces","runtimeFamilies","businessCapabilities"];for(let n of r){let i=e.workspace[n],p=t.workspace[n];b(i)!==b(p)&&w(a,{type:"workspace.changed",severity:"info",target:`workspace.${n}`,message:`Workspace metadata field changed: ${String(n)}`,before:i,after:p});}for(let n of c){let i=e.identity[n],p=t.identity[n];b(i)!==b(p)&&w(a,{type:"workspace.changed",severity:"info",target:`identity.${n}`,message:`Workspace identity field changed: ${String(n)}`,before:i,after:p});}return b(e.policies)!==b(t.policies)&&w(a,{type:"workspace.changed",severity:"warning",target:"policies",message:"Workspace policy summary changed.",before:e.policies,after:t.policies}),b(e.discovery)!==b(t.discovery)&&w(a,{type:"workspace.changed",severity:"info",target:"discovery",message:"Workspace discovery settings changed.",before:e.discovery,after:t.discovery}),e.contracts.exists!==t.contracts.exists&&w(a,{type:"workspace.changed",severity:t.contracts.exists?"info":"warning",target:t.contracts.workspaceContractPath,message:"Workspace contract presence changed.",before:e.contracts.exists,after:t.contracts.exists}),a}function je(e,t){let a=e.validation??null,r=t.validation??null;return b(a)===b(r)?[]:[{type:"validation.changed",severity:r?.status==="failed"?"critical":"warning",target:"validation",message:"Workspace model validation changed.",before:a,after:r}]}function Ie(e,t){let a=[],r=new Map(e.projects.map(n=>[n.path,n])),c=new Map(t.projects.map(n=>[n.path,n]));for(let[n,i]of c.entries()){let p=r.get(n);if(!p){w(a,{type:"project.added",severity:"info",target:n,message:`Project added: ${i.name}`,after:x(i)});continue}let m=x(p),l=x(i);if(b(m)!==b(l)){let u=p.runtime!==i.runtime||p.framework!==i.framework;w(a,{type:"project.changed",severity:u?"warning":"info",target:n,message:`Project changed: ${i.name}`,before:m,after:l});}}for(let[n,i]of r.entries())c.has(n)||w(a,{type:"project.removed",severity:"warning",target:n,message:`Project removed: ${i.name}`,before:x(i)});return a.sort((n,i)=>`${n.type}:${n.target}`.localeCompare(`${i.type}:${i.target}`))}async function Pe(e){let t=k$1.resolve(e.workspacePath),a=ne(e.fromPath),r=a?We(e.fromPath):void 0,c=e.fromPath;if(a){let f=k$1.join(t,_);if(!await V.pathExists(f))throw new Error("Git-aware workspace diff requires an existing snapshot at .workspai/reports/workspace-model-snapshot.json. Run: npx workspai workspace snapshot --json");c=_;}let n=se(t,c),i=await be(n),p$1=e.model??await p({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),m=d(p$1),l=[...Me(i.model,p$1),...Ie(i.model,p$1),...je(i.model,p$1)],u;e.includeGitObservation!==false&&(u=e.gitObservation??Q(t,{ref:r}),u.available&&Ee(l,u,p$1));let v=l.filter(f=>f.type.startsWith("git.")).length,R=i.hash!==m,y=a?`git:${r??"HEAD"}`:k$1.relative(t,n).split(k$1.sep).join("/");return {schemaVersion:L,generatedAt:(e.now??new Date).toISOString(),fromRef:y,toRef:k,fromHash:i.hash,toHash:m,summary:{changed:R||v>0,addedProjects:l.filter(f=>f.type==="project.added").length,removedProjects:l.filter(f=>f.type==="project.removed").length,changedProjects:l.filter(f=>f.type==="project.changed").length,workspaceChanges:l.filter(f=>f.type==="workspace.changed").length,validationChanges:l.filter(f=>f.type==="validation.changed").length,gitChangedFiles:v},git:u?.available?Oe(u,r):{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:l,currentModel:p$1}}async function Ze(e,t){return e$2(t,ae,a(e))}function I(e){return {none:0,low:1,medium:2,high:3,critical:4}[e]}function Z(e){return e.reduce((t,a)=>I(a)>I(t)?a:t,"none")}var N=["none","low","medium","high","critical"];function Re(e){let t=Math.max(1,I(e)-1);return N[t]}function Ce(e){let t=Math.min(N.length-1,I(e)+1);return N[t]}function ee(e){return e.join(" ")}function h(e,t,a,r){return {id:e,label:t,scope:r.scope,project:r.project,display:ee(["npx","workspai",...a]),execute:ee(["npx","--yes","--package","workspai","workspai",...a]),required:r.required!==false}}function te(e){let t=`project:${e.name}`,a=e.commands.fleetStages;return [h(`project.${e.name}.init`,`Run init for ${e.name}`,["workspace","run","init","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("init")}),h(`project.${e.name}.test`,`Run tests for ${e.name}`,["workspace","run","test","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("test")}),h(`project.${e.name}.build`,`Run build for ${e.name}`,["workspace","run","build","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("build")}),h(`project.${e.name}.start`,`Run start for ${e.name}`,["workspace","run","start","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("start")})]}function T(){return [h("workspace.doctor","Run workspace doctor",["doctor","workspace","--json"],{scope:"workspace"}),h("workspace.contract.verify","Verify workspace contract",["workspace","contract","verify","--json"],{scope:"workspace"}),h("workspace.readiness","Run release readiness",["readiness","--json"],{scope:"workspace"}),h("workspace.analyze","Run workspace analyze",["analyze","--json"],{scope:"workspace",required:false}),h("workspace.pipeline","Run governance pipeline",["pipeline","--json"],{scope:"workspace",required:false}),h("workspace.doctor-fix","Verify doctor fix result",["doctor","workspace","--fix","--json"],{scope:"workspace",required:false})]}function Se(e,t){let a=t.split(k$1.sep).join("/");return e.projects.filter(c=>{let n=c.path.split(k$1.sep).join("/");return a===n||a.startsWith(`${n}/`)}).sort((c,n)=>n.path.length-c.path.length)[0]}function Ee(e,t,a){let r=new Set(e.map(n=>n.target)),c=(n,i)=>{let p=i.split(k$1.sep).join("/"),m=`git:${p}`;if(r.has(m))return;let l=Se(a,p),u=l?`${l.name} (${l.path})`:"workspace";w(e,{type:n,severity:n==="git.deleted"?"warning":"info",target:m,message:`Git ${n==="git.untracked"?"untracked":n==="git.deleted"?"deleted":"changed"} file affects ${u}: ${p}`,after:{path:p,project:l?.name,projectPath:l?.path}}),r.add(m);};for(let n of t.changedFiles)c("git.file.changed",n);for(let n of t.untrackedFiles)c("git.untracked",n);for(let n of t.deletedFiles)c("git.deleted",n);}function Oe(e,t){return {available:true,ref:t??e.ref,branch:e.branch,commit:e.commit,dirty:e.dirty,changedFiles:e.changedFiles.length,untrackedFiles:e.untrackedFiles.length,deletedFiles:e.deletedFiles.length}}function Ae(e){let t=new Set,a=[];for(let r of e){let c=`${r.scope}:${r.project??""}:${r.display}`;t.has(c)||(t.add(c),a.push(r));}return a}function De(e){return e.type==="project.removed"?"high":e.severity==="critical"?"critical":e.severity==="warning"?"high":("medium")}function $e(e,t){return e.severity==="critical"?"critical":e.target==="policies"||e.target.includes("contract")?"high":e.type==="validation.changed"?(t?.projectCount??0)===0?"low":"high":e.target==="evidence"?"low":e.severity==="warning"?"medium":"low"}function Fe(e){return e.affectedProjects>0||e.projectCount>0||!e.changes.every(a=>a.severity==="critical"?false:a.type.startsWith("git.")||a.type==="validation.changed")?e.risk:I(e.risk)>=I("high")||e.risk==="medium"?"low":e.risk}function re(e,t){if(!e||e==="workspace")return true;let a=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return [t.name,t.path,k$1.basename(t.path),t.absolutePath].filter(r=>typeof r=="string"&&r.trim().length>0).map(r=>r.trim().toLowerCase()).includes(a)}function xe(e){if(!e.changed)return {headline:"No workspace model impact detected.",bullets:["The current workspace model matches the provided snapshot/report."],unsafeAssumptions:["Do not claim runtime verification passed unless a report exists."]};let t=e.affectedProjects.map(a=>a.project?.name??a.target);return {headline:`Workspace impact risk: ${e.risk}.`,bullets:[`Affected projects: ${t.length?t.join(", "):"none"}.`,`Workspace-level items: ${e.workspaceImpact.length}.`,"Use the verification plan before recommending apply, rollback, or release actions."],unsafeAssumptions:["Do not infer test/build success from impact alone.","Do not apply fixes without project scope and verification evidence.","Use display commands for users and execute commands for automation."]}}async function et(e){let t=k$1.resolve(e.workspacePath),a=ne(e.fromPath),r=e.diff;if(!r&&!a){let o=se(t,e.fromPath);r=await ve(o)??void 0;}r||(r=await Pe({workspacePath:t,fromPath:e.fromPath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,includeGitObservation:e.includeGitObservation,gitObservation:e.gitObservation,now:e.now,model:e.model}));let c$1=new Map(r.currentModel.projects.map(o=>[o.path,o])),n=new Map(r.currentModel.projects.map(o=>[o.name,o])),i=r.changes.filter(o=>o.type.startsWith("project.")),p=new Map;for(let o of i){let d=(c$1.get(o.target)??(typeof o.before?.name=="string"?n.get(o.before.name):void 0))?.path??o.target,W=p.get(d)??[];W.push(o),p.set(d,W);}let m=[];for(let[o,s]of p.entries()){let d=c$1.get(o);if(d&&!re(e.scope,d))continue;let W=Z(s.map(De)),C=d?.name??(typeof s[0]?.before?.name=="string"?String(s[0].before.name):o);m.push({id:`project:${C}`,scope:"project",target:o,title:`Project impact: ${C}`,summary:s.map(M=>M.message).join(" "),risk:W,reasons:s.map(M=>`${M.type}: ${M.message}`),project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?te(d):T()});}let l$1=l(r.currentModel),u=l$1?a$1(l$1):void 0,v=new Set(m.map(o=>o.project?.name).filter(o=>typeof o=="string")),R=new Map;for(let o of m)if(o.project?.name){let s=u?.byId.get(o.project.name);s&&(o.centrality={fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness,isHotspot:s.isHotspot},s.isHotspot&&(o.risk=Ce(o.risk),o.reasons=[...o.reasons,`graph.hotspot: critical-path project with ${s.reach} transitive dependent(s); risk escalated.`])),o.origin="direct",o.distance=0,R.set(o.project.name,o.risk);}let y=[],f=0;if(l$1&&v.size>0){let o=c(l$1,v);for(let s of o.values()){if(s.distance===0||v.has(s.id))continue;let d=n.get(s.id);if(d&&!re(e.scope,d))continue;let W=s.path[0],C=s.path[s.path.length-2]??W,M=R.get(W)??"medium",de=Re(M),j=u?.byId.get(s.id);f=Math.max(f,s.distance),y.push({id:`transitive:${s.id}`,scope:"project",target:d?.path??s.id,title:`Transitive impact: ${s.id}`,summary:`Depends on changed project ${W}${s.via?` via ${s.via}`:""} (distance ${s.distance}).`,risk:de,reasons:[`graph.dependent: depends on ${C}${s.via?` via ${s.via}`:""} (path ${s.path.join(" -> ")})`],project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?te(d):T(),origin:"transitive",distance:s.distance,path:s.path,via:s.via,...j?{centrality:{fanIn:j.fanIn,fanOut:j.fanOut,reach:j.reach,betweenness:j.betweenness,isHotspot:j.isHotspot}}:{}});}}y.sort((o,s)=>o.target.localeCompare(s.target));let ie=u?u.hotspots.flatMap(o=>{let s=u.byId.get(o);return s?[{project:o,fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness}]:[]}):[],ce=r.changes.filter(o=>!o.type.startsWith("project.")),K=r.currentModel.summary?.projectCount??r.currentModel.projects.length,P=ce.map(o=>({id:`workspace:${o.target}`,scope:"workspace",target:o.target,title:`Workspace impact: ${o.target}`,summary:o.message,risk:$e(o,{projectCount:K}),reasons:[`${o.type}: ${o.message}`],verification:T()})),B=Ae([...m.flatMap(o=>o.verification),...y.flatMap(o=>o.verification),...P.flatMap(o=>o.verification),...r.summary.changed?T():[]]).filter(o=>o.required),pe=Z([...m.map(o=>o.risk),...y.map(o=>o.risk),...P.map(o=>o.risk)]),q=Fe({risk:pe,affectedProjects:m.length,projectCount:K,changes:r.changes}),z={changed:r.summary.changed,risk:q,affectedProjects:m.length,workspaceItems:P.length,recommendedCommands:B.length,blastRadius:{directlyAffected:m.length,transitivelyAffected:y.length,maxDistance:f,graphEdges:l$1?.edges.length??0}};return {schemaVersion:he,generatedAt:(e.now??new Date).toISOString(),fromRef:r.fromRef,diffRef:ae,workspace:{name:r.currentModel.workspace.name,profile:r.currentModel.workspace.profile,type:r.currentModel.workspace.type},summary:z,affectedProjects:m.sort((o,s)=>o.target.localeCompare(s.target)),transitiveImpact:y,criticalPathHotspots:ie,workspaceImpact:P.sort((o,s)=>o.target.localeCompare(s.target)),verificationPlan:B,agentBrief:xe({changed:z.changed,risk:q,affectedProjects:m,workspaceImpact:P}),diff:r}}async function tt(e,t){return e$2(t,we,a(e))}export{Q as a,oe as b,L as c,_ as d,ae as e,he as f,we as g,ye as h,ne as i,We as j,Ye as k,Qe as l,Pe as m,Ze as n,T as o,et as p,tt as q};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {c as c$1}from'./chunk-
|
|
2
|
-
`);}async function re(e,r){let t=p.dirname(e);await promises.mkdir(t,{recursive:true});let o=`${e}.${process.pid}.${randomUUID()}.tmp`;try{await promises.writeFile(o,r);let a=await promises.open(o,"r");try{await te(a);}finally{await a.close();}try{await promises.rename(o,e);}catch(s){let i=s.code;if(i!=="EEXIST"&&i!=="EPERM")throw s;await ne.move(o,e,{overwrite:true});}}finally{await promises.rm(o,{force:true}).catch(()=>{});}}async function
|
|
3
|
-
`),await te(s);}catch(i){if(i.code!=="EEXIST")throw i;let n=await promises.stat(t).catch(()=>null);if(n&&Date.now()-n.mtimeMs>
|
|
1
|
+
import {c as c$1}from'./chunk-HCFWT42C.js';import {a}from'./chunk-A5FBGRJA.js';import {a as a$2}from'./chunk-27UR373Z.js';import {b as b$1}from'./chunk-D65FCQIO.js';import {i as i$1,h}from'./chunk-NZ3WZYD5.js';import {i}from'./chunk-VRW6KXNK.js';import {a as a$1}from'./chunk-TQEMLBAG.js';import {t,s}from'./chunk-MOSXTVPU.js';import {q as q$1,r,s as s$1}from'./chunk-RJIYCDVC.js';import {promises}from'fs';import {randomUUID}from'crypto';import p from'path';import c from'chalk';import ne from'fs-extra';import P from'ora';import {execa}from'execa';var ce=3e4,pe=45e3;async function le(e){try{let r=await execa("git",["rev-parse","--show-toplevel"],{cwd:e,env:a$1()});return r.stdout.trim()?p.resolve(e,r.stdout.trim()):null}catch{return null}}async function Z(e,r,t){if(await le(e)){r.warn("Git initialization skipped because target is already inside a git worktree");return}r.start("Initializing git repository...");try{await execa("git",["init"],{cwd:e,env:a$1()}),await execa("git",["add","."],{cwd:e,env:a$1()}),await execa("git",["-c","user.name=Workspai","-c","user.email=workspai@localhost","commit","-m",t],{cwd:e,env:a$1()}),r.succeed("Git repository initialized");}catch{r.warn("Could not initialize git repository");}}function B(e){let r=a(e.path),t=Array.isArray(e.projects)?e.projects:[],o=[],a$1=new Set;for(let s of t){if(!s||typeof s.name!="string"||typeof s.path!="string")continue;let i=a(s.path);a$1.has(i)||(a$1.add(i),o.push({name:s.name,path:i}));}return {name:e.name,path:r,mode:e.mode,projects:o}}function b(e){let r=[],t=new Set;for(let o of e.workspaces||[]){if(!o||typeof o.name!="string"||typeof o.path!="string")continue;let a=B(o);t.has(a.path)||(t.add(a.path),r.push(a));}return {workspaces:r}}async function de(e){let r;try{r=await promises.readFile(e,"utf8");}catch(t){if(t.code==="ENOENT")return {workspaces:[]};throw t}try{let t=JSON.parse(r);if(!t||!Array.isArray(t.workspaces))throw new Error("missing workspaces array");return b(t)}catch(t){throw new Error(`Workspace registry is invalid: ${e}`,{cause:t})}}async function me(e){let r;try{r=await promises.readFile(e,"utf8");}catch(o){if(o.code==="ENOENT")return {workspaces:[]};throw o}let t;try{t=JSON.parse(r);}catch(o){throw new Error(`Workspace registry is invalid: ${e}`,{cause:o})}if(!t||typeof t!="object"||!Array.isArray(t.workspaces))throw new Error(`Workspace registry is invalid: ${e}`);for(let o of t.workspaces)if(!o||typeof o.name!="string"||typeof o.path!="string"||o.mode!==void 0&&typeof o.mode!="string"||o.projects!==void 0&&!Array.isArray(o.projects)||Array.isArray(o.projects)&&o.projects.some(a=>!a||typeof a.name!="string"||typeof a.path!="string"))throw new Error(`Workspace registry contains an invalid entry: ${e}`);return b(t)}async function F(){let e={workspaces:[]},r=new Set;for(let t of s$1()){let o=await de(t);for(let a of o.workspaces)r.has(a.path)||(r.add(a.path),e.workspaces.push(a));}return e}async function ee(e=s$1()){let r={workspaces:[]},t=new Set;for(let o of e){let a=await me(o);for(let s of a.workspaces)t.has(s.path)||(t.add(s.path),r.workspaces.push(s));}return r}function ge(e){let r=e?.code;return process.platform==="win32"&&(r==="EPERM"||r==="EINVAL"||r==="ENOSYS")}async function te(e){try{await e.sync();}catch(r){if(!ge(r))throw r}}async function K(e,r){let t=p.dirname(e);await promises.mkdir(t,{recursive:true});let o=`${p.basename(e)}.`,a=Date.now();for(let i of await promises.readdir(t)){if(!i.startsWith(o)||!i.endsWith(".tmp"))continue;let n=p.join(t,i),d=await promises.stat(n).catch(()=>null);d&&a-d.mtimeMs>3e4&&await promises.rm(n,{force:true}).catch(()=>{});}let s=await promises.readFile(e,"utf8").catch(()=>null);if(s!==null){let i=false;try{let n=JSON.parse(s);i=Array.isArray(n.workspaces);}catch{i=false;}if(!i){let n=`${e}.corrupt-${Date.now()}`;await promises.copyFile(e,n);}}await re(e,`${JSON.stringify(b(r),null,2)}
|
|
2
|
+
`);}async function re(e,r){let t=p.dirname(e);await promises.mkdir(t,{recursive:true});let o=`${e}.${process.pid}.${randomUUID()}.tmp`;try{await promises.writeFile(o,r);let a=await promises.open(o,"r");try{await te(a);}finally{await a.close();}try{await promises.rename(o,e);}catch(s){let i=s.code;if(i!=="EEXIST"&&i!=="EPERM")throw s;await ne.move(o,e,{overwrite:true});}}finally{await promises.rm(o,{force:true}).catch(()=>{});}}async function q(e){try{return {exists:true,content:await promises.readFile(e)}}catch(r){if(r.code==="ENOENT")return {exists:false};throw r}}async function Q(e,r){if(!r.exists){await promises.rm(e,{force:true});return}await re(e,r.content);}async function ue(e,r){let t=p.join(e,"workspaces.json.lock"),o=randomUUID();await promises.mkdir(e,{recursive:true});let a=Date.now(),s;for(;!s;)try{s=await promises.open(t,"wx"),await s.writeFile(`${JSON.stringify({pid:process.pid,lockId:o,createdAt:new Date().toISOString()})}
|
|
3
|
+
`),await te(s);}catch(i){if(i.code!=="EEXIST")throw i;let n=await promises.stat(t).catch(()=>null);if(n&&Date.now()-n.mtimeMs>ce){let d=await promises.readFile(t,"utf8").then(m=>JSON.parse(m)).catch(()=>null),u=Number(d?.pid),w=false;if(Number.isInteger(u)&&u>0)try{process.kill(u,0),w=true;}catch(m){w=m.code==="EPERM";}if(!w){await promises.rm(t,{force:true}).catch(()=>{});continue}}if(Date.now()-a>pe)throw new Error(`Timed out waiting for workspace registry lock: ${t}`);await new Promise(d=>setTimeout(d,25));}try{return await r()}finally{await s.close().catch(()=>{}),await promises.readFile(t,"utf8").then(n=>JSON.parse(n).lockId===o).catch(()=>false)&&await promises.rm(t,{force:true}).catch(()=>{});}}async function _(e){let r$1=q$1(),t=p.join(r$1,"workspaces.json"),o=p.join(r(),"workspaces.json"),a=[...new Set(s$1())];return ue(r$1,async()=>{let[s,i]=await Promise.all([q(t),q(o)]),n=await ee(a);await e(n);let d=b(n);try{await K(t,d),await K(o,d);}catch(u){let m=(await Promise.allSettled([Q(t,s),Q(o,i)])).filter(g=>g.status==="rejected").map(g=>g.reason);throw m.length>0?new AggregateError([u,...m],"Workspace registry transaction failed and could not be fully restored"):u}return d})}async function oe(e,r){let t=a(e);await _(o=>{let a=o.workspaces.find(s=>s.path===t);if(a){a.name=r,a.mode=a.mode||"full",a.projects=Array.isArray(a.projects)?a.projects:[];return}o.workspaces.push({name:r,path:t,mode:"full",projects:[]});});}async function ze(e){let r=a(e),o=(await ee()).workspaces.find(a=>a.path===r);return o?{...o,projects:o.projects.map(a=>({...a}))}:null}async function Ge(e,r){let t=a(e);await _(o=>{let a=o.workspaces.findIndex(i=>i.path===t);if(!r){a>=0&&o.workspaces.splice(a,1);return}let s=B(r);a>=0?o.workspaces[a]=s:o.workspaces.push(s);});}async function Me(e){let r=a(e);await _(t=>{t.workspaces=t.workspaces.filter(o=>o.path!==r);});}async function ke(e,r){try{await oe(e,r);}catch{console.warn(c.gray("Note: Could not register workspace in shared registry"));}}async function Ve(e,r=false){let t$1=a(e),o={workspacePath:t$1,workspaceFound:false,added:[],skipped:0};try{let a$1=await F(),s=a$1.workspaces.find(g=>g.path===t$1);if(!s){if(await ke(t$1,p.basename(p.resolve(e))),a$1=await F(),s=a$1.workspaces.find(g=>g.path===t$1),!s)return r||console.log("\u26A0\uFE0F Workspace could not be registered in registry"),o;r||console.log("\u2714 Registered workspace in shared registry");}Array.isArray(s.projects)||(s.projects=[]);let i=0,n=0,d=[],u=[],w=[e],m=new Set;for(;w.length>0;){let g=w.shift();if(!g||m.has(g))continue;m.add(g);let y=await promises.readdir(g,{withFileTypes:true});for(let h of y){if(!h.isDirectory()||h.name.startsWith(".")||["node_modules","dist","build","target","coverage","htmlcov"].includes(h.name))continue;let j=p.join(g,h.name),f=a(j);try{let k=false;for(let $ of [...t(f,"context.json"),...t(f,"project.json")])try{await promises.access($),k=true;break}catch{}if(k){let $=p.basename(f),R=s.projects.some(C=>C.path===f);u.push({name:$,path:f}),R?n++:(s.projects.push({name:$,path:f}),i++,d.push(f),r||console.log(`\u2714 Added: ${p.relative(e,f)}`));continue}}catch{}w.push(j);}}return await _(g=>{let y=g.workspaces.find(f=>f.path===t$1);if(!y)return;let h=`${t$1}${p.sep}`,j=(y.projects||[]).filter(f=>f.path!==t$1&&!f.path.startsWith(h));y.projects=B({...y,projects:[...j,...u]}).projects;}),i>0?r||console.log(`
|
|
4
4
|
\u2705 Synced ${i} project(s) to registry`):r||console.log(`
|
|
5
|
-
\u2705 All projects already registered (${n} found)`),{workspacePath:t$1,workspaceFound:true,added:d,skipped:n}}catch(a){return r||console.error("\u274C Failed to sync projects:",a.message),o}}async function
|
|
5
|
+
\u2705 All projects already registered (${n} found)`),{workspacePath:t$1,workspaceFound:true,added:d,skipped:n}}catch(a){return r||console.error("\u274C Failed to sync projects:",a.message),o}}async function we(e,r,t){let o=a(e),a$1=a(t);await _(s=>{let i=s.workspaces.find(u=>u.path===o);if(!i)throw new Error(`Workspace is not registered: ${o}`);i.projects=Array.isArray(i.projects)?i.projects:[];let n=i.projects.findIndex(u=>u.path===a$1||u.name===r),d={name:r,path:a$1};n>=0?i.projects[n]=d:i.projects.push(d);});}async function Ye(e,r,t){try{await we(e,r,t);}catch{}}async function He(e,r){let t=P("Creating Workspai workspace...").start();try{await promises.mkdir(e,{recursive:true}),await promises.mkdir(p.join(e,".workspai"),{recursive:true});let o={workspace_name:r.name,author:r.author,rapidkit_version:i(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(p.join(e,".workspai","config.json"),JSON.stringify(o,null,2));let{syncWorkspaceFoundationFiles:a}=await import('./create-HUEDWYDM.js');await a(e,{workspaceName:r.name,installMethod:"venv",writeMarker:true,writeGitignore:false,onlyIfMissing:true});let s=fe();await promises.writeFile(p.join(e,"rapidkit"),s),await promises.chmod(p.join(e,"rapidkit"),493);let i$1=he();await promises.writeFile(p.join(e,"rapidkit.cmd"),i$1);let n=ye(r.name);await promises.writeFile(p.join(e,"README.md"),n),await promises.writeFile(p.join(e,".gitignore"),`# Workspai workspace
|
|
6
6
|
.env
|
|
7
7
|
.env.*
|
|
8
8
|
!.env.example
|
|
@@ -17,7 +17,7 @@ Thumbs.db
|
|
|
17
17
|
|
|
18
18
|
# Logs
|
|
19
19
|
*.log
|
|
20
|
-
`),await
|
|
20
|
+
`),await $e(e),t.succeed("Workspace created!"),r.skipGit||await Z(e,P(),"Initial commit: Workspai workspace"),await oe(e,r.name);let{publishWorkspaceRegistrySummary:u}=await import('./workspace-registry-summary-OV5KX3WC.js');await u(e),console.log(`
|
|
21
21
|
${c.green("\u2728 Workspai workspace created successfully!")}
|
|
22
22
|
|
|
23
23
|
${c.bold("\u{1F4C2} Workspace structure:")}
|
|
@@ -54,7 +54,7 @@ ${c.bold("\u{1F4DA} Commands:")}
|
|
|
54
54
|
|
|
55
55
|
${c.gray("Alternative: npx workspai dev, make dev")}
|
|
56
56
|
${c.gray("\u{1F4A1} Tip: Install globally (npm i -g workspai) to use without npx")}
|
|
57
|
-
`);}catch(o){throw t.fail("Failed to create workspace"),o}}function
|
|
57
|
+
`);}catch(o){throw t.fail("Failed to create workspace"),o}}function fe(){return `#!/usr/bin/env bash
|
|
58
58
|
#
|
|
59
59
|
# Workspai CLI - local workspace commands
|
|
60
60
|
# This script provides legacy ./rapidkit commands within the workspace
|
|
@@ -440,7 +440,7 @@ main() {
|
|
|
440
440
|
}
|
|
441
441
|
|
|
442
442
|
main "$@"
|
|
443
|
-
`}function
|
|
443
|
+
`}function he(){return `@echo off
|
|
444
444
|
setlocal enabledelayedexpansion
|
|
445
445
|
|
|
446
446
|
set "SCRIPT_DIR=%~dp0"
|
|
@@ -460,7 +460,7 @@ if %ERRORLEVEL%==0 (
|
|
|
460
460
|
echo [Workspai] No sh/bash found. Falling back to npx workspai.
|
|
461
461
|
npx workspai %*
|
|
462
462
|
exit /b %ERRORLEVEL%
|
|
463
|
-
`}function
|
|
463
|
+
`}function ye(e){return `# ${e}
|
|
464
464
|
|
|
465
465
|
Workspai workspace for building API projects.
|
|
466
466
|
|
|
@@ -517,7 +517,7 @@ instructions start at \`AGENTS.md\`.
|
|
|
517
517
|
|
|
518
518
|
- [Workspai Documentation](https://workspai.dev)
|
|
519
519
|
- [GitHub Repository](https://github.com/chistiq/workspai)
|
|
520
|
-
`}async function
|
|
520
|
+
`}async function $e(e){let{fileURLToPath:r}=await import('url'),t=r(import.meta.url),o=p.dirname(t),a=p.resolve(o,".."),s=p.join(a,"templates","kits"),i=p.join(e,".workspai","templates"),{default:n}=await import('fs-extra');await n.copy(s,i);let d=p.join(a,"templates","generator.js"),u=p.join(e,".workspai","generator.js");await n.copy(d,u);}async function Ke(e,r){let t=r.template==="fastapi",o=t?"FastAPI":"NestJS",a=P(`Creating ${o} project...`).start();try{let{fileURLToPath:s}=await import('url'),i$1=s(import.meta.url),n=p.dirname(i$1),d=p.resolve(n,".."),u=t?"fastapi-standard":"nestjs-standard",w=p.join(d,"templates","kits",u);await promises.mkdir(e,{recursive:true});let m={project_name:t?r.name.replace(/-/g,"_").toLowerCase():r.name.replace(/_/g,"-").toLowerCase(),author:r.author,description:r.description||`${o} application generated with Workspai`,app_version:"0.1.0",license:"MIT",package_manager:r.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:i()};await ae(w,e,m);let g=t?`# Python
|
|
521
521
|
__pycache__/
|
|
522
522
|
*.py[cod]
|
|
523
523
|
*$py.class
|
|
@@ -651,7 +651,7 @@ ${c.bold("\u{1F310} API endpoints:")}
|
|
|
651
651
|
http://localhost:8000/examples/notes # Example API
|
|
652
652
|
|
|
653
653
|
${c.gray("\u{1F4A1} Tip: Install globally (npm i -g workspai) to use without npx")}
|
|
654
|
-
`);}catch(s){throw a.fail(`Failed to create ${o} project`),s}}async function ae(e,r,t){let o=await promises.readdir(e,{withFileTypes:true});for(let a of o){let s=p.join(e,a.name),i=a.name.replace(/\.j2$/,""),n=p.join(r,i);if(a.isDirectory())await promises.mkdir(n,{recursive:true}),await ae(s,n,t);else {let d=await promises.readFile(s,"utf-8");a.name.endsWith(".j2")&&(d=
|
|
654
|
+
`);}catch(s){throw a.fail(`Failed to create ${o} project`),s}}async function ae(e,r,t){let o=await promises.readdir(e,{withFileTypes:true});for(let a of o){let s=p.join(e,a.name),i=a.name.replace(/\.j2$/,""),n=p.join(r,i);if(a.isDirectory())await promises.mkdir(n,{recursive:true}),await ae(s,n,t);else {let d=await promises.readFile(s,"utf-8");a.name.endsWith(".j2")&&(d=je(d,t)),await promises.writeFile(n,d),(i==="rapidkit"||i==="activate"||i.endsWith(".py")&&(n.includes(".workspai")||n.includes(".rapidkit")))&&await promises.chmod(n,493);}}}function je(e,r){let t=e;for(let[o,a]of Object.entries(r)){let s=new RegExp(`\\{\\{\\s*${o}\\s*\\}\\}`,"g");t=t.replace(s,String(a));let i=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");t=t.replace(i,(u,w,m)=>String(a).replace(new RegExp(w,"g"),m));let n=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*lower\\s*\\}\\}`,"g");t=t.replace(n,String(a).toLowerCase());let d=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");t=t.replace(d,(u,w,m)=>String(a).replace(new RegExp(w,"g"),m).toLowerCase());}return t}async function qe(e={}){let r=q$1(),t=p.join(r,"workspaces.json"),o=await F();if(o.workspaces.length===0){if(e.json){console.log(JSON.stringify({schemaVersion:"rapidkit-workspace-list-v1",registryPath:t,workspaces:[],summary:{total:0,missing:0,registryExists:false}},null,2));return}console.log(c.yellow(`
|
|
655
655
|
\u26A0\uFE0F No workspaces registered yet.
|
|
656
656
|
`)),console.log(c.gray(`Create a workspace with: npx workspai <workspace-name>
|
|
657
657
|
`));return}try{let a=o;if(!a||typeof a!="object"||!Array.isArray(a.workspaces)){if(e.json){console.log(JSON.stringify({schemaVersion:"rapidkit-workspace-list-v1",registryPath:t,workspaces:[],summary:{total:0,missing:0,registryExists:true,registryValid:false},error:{code:"workspace.registry.invalid",message:"Workspace registry is invalid."}},null,2));return}console.log(c.yellow(`
|
|
@@ -663,4 +663,4 @@ ${c.gray("\u{1F4A1} Tip: Install globally (npm i -g workspai) to use without npx
|
|
|
663
663
|
\u{1F4E6} Registered Workspai Workspaces:
|
|
664
664
|
`));for(let m of d.workspaces)console.log(c.cyan(` ${m.name}`)),console.log(c.gray(` Path: ${m.path}`)),console.log(c.gray(` Projects: ${m.projects?.length||0}`)),console.log();n>0&&console.log(c.gray(`Cleaned ${n} stale workspace entr${n===1?"y":"ies"}.`)),console.log(c.gray(`Total: ${d.workspaces.length} workspace(s)
|
|
665
665
|
`));}catch(a){if(e.json){console.log(JSON.stringify({schemaVersion:"rapidkit-workspace-list-v1",registryPath:t,workspaces:[],summary:{total:0,missing:0,registryExists:true,registryValid:false},error:{code:"workspace.registry.read_failed",message:a.message}},null,2));return}console.error(c.red(`
|
|
666
|
-
\u274C Failed to read workspace registry`)),console.error(c.gray(String(a)));}}async function
|
|
666
|
+
\u274C Failed to read workspace registry`)),console.error(c.gray(String(a)));}}async function ve(e){try{let r=await promises.readFile(e,"utf8");return JSON.parse(r)}catch{return null}}async function D(e){for(let r of e){let t=await ve(r);if(t!==null)return t}return null}function _e(e){return c$1(e)}async function Ee(e){return a$2(e,{skipDirs:new Set(["node_modules","dist","build","target","coverage","htmlcov"]),includeHiddenDirs:false,descendIntoMatchedProjects:true})}async function O(e){try{return (await promises.readdir(e,{withFileTypes:true})).filter(t=>t.isFile()&&t.name.toLowerCase().endsWith(".json")).map(t=>t.name).sort((t,o)=>t.localeCompare(o))}catch{return []}}async function Qe(e,r){let t$1=r?.includePaths===true,o=r?.includeDoctorEvidence!==false,a=r?.includeBlueprint!==false,s$1=p.resolve(e),i=await D(s(s$1,"workspace.json")),n=typeof i?.workspace_name=="string"&&i.workspace_name.trim()||p.basename(s$1),d=typeof i?.profile=="string"?i.profile:void 0,u=typeof i?.rapidkit_version=="string"?i.rapidkit_version:void 0,w=await Ee(s$1),m=[];for(let k of w){let $=await D(t(k,"project.json")),R=p.relative(s$1,k)||".",C=p.dirname(t(k,p.join("reports","placeholder"))[0]),J=p.dirname(t(k,p.join("reports","placeholder"))[1]),N={name:p.basename(k),relative_path:R,runtime:typeof $?.runtime=="string"?$.runtime:void 0,kit_name:typeof $?.kit_name=="string"?$.kit_name:void 0,modules:Array.isArray($?.modules)?$.modules.filter(E=>typeof E=="string"):void 0};if(t$1&&(N.absolute_path=k),o){let E=await D([p.join(C,"doctor-last-run.json"),p.join(J,"doctor-last-run.json")]);_e(E)&&(N.doctor_report=E);}let U=[...await O(C),...await O(J)].filter((E,se,ie)=>ie.indexOf(E)===se);U.length>0&&(N.reports=U),m.push(N);}let g=s(s$1,"reports"),y=[...await O(g[0]),...await O(g[1])].filter((k,$,R)=>R.indexOf(k)===$),h$1=await D(s(s$1,"workspace.contract.json")),j={schema_version:h.workspaceShareBundle.schemaVersion,generated_at:new Date().toISOString(),generated_by:"workspai",workspace:{name:n,relative_root:".",profile:d,rapidkit_version:u,...t$1?{absolute_root:s$1}:{}},summary:{project_count:m.length,doctor_evidence_included:o,contract_included:!!h$1},reports:{workspace:y},projects:m,...h$1?{contract:h$1}:{}};a&&(j.blueprint={schema_version:"rapidkit.workspace-blueprint.v1",purpose:"portable-reproducibility",workspace:{name:n,profile:d},projects:m.map(k=>({name:k.name,relative_path:k.relative_path,runtime:k.runtime,kit_name:k.kit_name,modules:k.modules??[],recreate_commands:[...k.kit_name?[`npx workspai create project ${k.kit_name} ${k.name} --yes --skip-install`]:[],`cd ${k.relative_path}`,"npx workspai init","npx workspai test"]})),recommended_commands:["npx workspai workspace contract verify --strict","npx workspai doctor workspace","npx workspai workspace run init --json","npx workspai workspace run test --strict --json","npx workspai readiness --strict --json"]});let f=r?.outputPath?p.resolve(r.outputPath):p.join(g[0],"share-bundle.json");return r?.outputPath||b$1(i$1.workspaceShareBundle,j),await promises.mkdir(p.dirname(f),{recursive:true}),await promises.writeFile(f,JSON.stringify(j,null,2),"utf8"),f}export{B as a,oe as b,ze as c,Ge as d,Me as e,ke as f,Ve as g,we as h,Ye as i,He as j,Ke as k,qe as l,Qe as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {h}from'./chunk-NZ3WZYD5.js';var _=h.artifactRemediationPlan.schemaVersion;export{_ as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {f}from'./chunk-
|
|
1
|
+
import {f}from'./chunk-NZ3WZYD5.js';var i=f.explain,u=["project","release-blocked","blocker","trace"];function s(t){let e=t.trim();if(!e)return null;if(e==="release-blocked")return {kind:"release-blocked"};if(e.startsWith("project:")){let r=e.slice(8).trim();return r?{kind:"project",project:r}:null}if(e.startsWith("blocker:")){let r=e.slice(8).trim();return r?{kind:"blocker",blockerId:r}:null}if(e.startsWith("trace:")){let r=e.slice(6).trim();return r?{kind:"trace",diffRef:r}:null}return {kind:"project",project:e}}function E(t){let e=t.trim();if(!e)return null;if(e.startsWith("trace:")){let n=s(e);return n?.kind==="trace"?n:null}let r=e.replace(/\\/g,"/").trim().toLowerCase();return r.endsWith(".json")||r.includes("workspace-model-diff")||r.startsWith(".rapidkit/")||r.includes("/.rapidkit/")?{kind:"trace",diffRef:e}:null}function A(t){if(!t||typeof t!="object"||Array.isArray(t))return false;let e=t;return e.schemaVersion===i&&typeof e.generatedAt=="string"&&typeof e.summary=="string"&&Array.isArray(e.sections)&&e.target!=null&&typeof e.target=="object"&&!Array.isArray(e.target)&&typeof e.target.kind=="string"}export{i as a,u as b,s as c,E as d,A as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {f}from'./chunk-
|
|
1
|
+
import {f}from'./chunk-NZ3WZYD5.js';var o="model-usage-event.v1",s=f.evaluationLive,a="workspace-intelligence-evaluation-comparison.v1",i=["provider-reported","tokenizer-counted","estimated","unavailable"];export{o as a,s as b,a as c,i as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-2647BYBC.js';import {l}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-2647BYBC.js';import {l}from'./chunk-WSRUPDZN.js';import {d,c}from'./chunk-EWZZUQBR.js';import {a}from'./chunk-GR6442P7.js';import {f,e,i}from'./chunk-NZ3WZYD5.js';import p from'path';import {createHash}from'crypto';import {createReadStream}from'fs';import {execFile}from'child_process';import {promisify}from'util';import S from'fs-extra';import {parseAllDocuments}from'yaml';var pe=f.knowledgeGraph;var Yt=e.knowledgeGraph;function Xt(e$1,t){if(e$1.source.kind!=="workspace-model")throw new Error(`Workspace knowledge graph is not bound to the canonical workspace model (source: ${e$1.source.kind}).`);if(e$1.source.artifact!==e.model)throw new Error(`Workspace knowledge graph source artifact is ${e$1.source.artifact}; expected ${e.model}.`);if(e$1.source.hashAlgorithm!=="sha256")throw new Error(`Workspace knowledge graph source hash algorithm is ${e$1.source.hashAlgorithm}; expected sha256.`);let o=d(t);if(e$1.source.hash!==o)throw new Error("Workspace knowledge graph is stale: its source hash does not match the canonical workspace model.");if(e$1.workspace.name!==t.workspace.name||(e$1.workspace.profile??void 0)!==(t.workspace.profile??void 0))throw new Error("Workspace knowledge graph identity does not match the canonical workspace model.");let i=l(t);if(!i)throw new Error("Canonical workspace model has no project topology for the workspace knowledge graph.");let r=c=>({...c,generatedAt:"<ignored>"});if(c(r(e$1.projectTopology))!==c(r(i)))throw new Error("Workspace knowledge graph project topology does not match the canonical workspace model.")}var De=new Set([".git",".hg",".svn",".workspai",".rapidkit",".venv","venv","vendor","node_modules","dist","build","target","coverage",".next",".turbo",".cache",".vscode-test","graphify-out",".pytest_cache",".mypy_cache",".ruff_cache",".tox",".gradle","fixture","fixtures","__fixtures__","testdata"]),Me=new Set(["test","tests","spec","specs","e2e","integration","integration-tests","integration_tests","__tests__","fixture","fixtures","__fixtures__","testdata"]),ze=new Set(["examples","samples","worked"]);function se(e,t){let o=p.relative(e,t).split(p.sep).map(r=>r.toLowerCase()),i=p.basename(t).toLowerCase();return o.some(r=>Me.has(r))||/(?:\.test|\.spec|_test)\.[a-z0-9]+$/i.test(i)||/^test_.+\.[a-z0-9]+$/i.test(i)||/(?:tests?|specs?)\.(?:cs|fs|vb|java|kt|kts)$/i.test(i)}function ie(e,t){return p.relative(e,t).split(p.sep).map(o=>o.toLowerCase()).some(o=>ze.has(o))}function M(e,t){return se(e,t)||ie(e,t)}function oe(e,t){return p.relative(e,t).split(p.sep).some(o=>o.toLowerCase()==="generated")}var fe=new Set(["package.json","pyproject.toml","requirements.txt","Pipfile","go.mod","Cargo.toml","pom.xml","build.gradle","build.gradle.kts","composer.json","Gemfile","mix.exs","pubspec.yaml","Package.swift","CMakeLists.txt","deno.json","deno.jsonc","project.clj","deps.edn","build.sbt","BUILD","BUILD.bazel","WORKSPACE.bazel"]),Be=new Set(["get","put","post","delete","options","head","patch","trace"]),T=new Set([".c",".cc",".cpp",".cs",".dart",".ex",".exs",".go",".h",".hpp",".java",".js",".jsx",".kt",".kts",".mjs",".php",".py",".r",".rb",".rs",".scala",".svelte",".swift",".ts",".tsx",".vue",".clj",".cljs",".fs",".fsx",".lua",".vb"]);function F(e,t){let o=p.extname(e).toLowerCase();return o===".h"&&t==="cpp"?"cpp":{".c":"c",".cc":"cpp",".cpp":"cpp",".cs":"csharp",".dart":"dart",".ex":"elixir",".exs":"elixir",".go":"go",".h":"c",".hpp":"cpp",".java":"java",".js":"javascript",".jsx":"javascript",".kt":"kotlin",".kts":"kotlin",".mjs":"javascript",".php":"php",".py":"python",".r":"r",".rb":"ruby",".rs":"rust",".scala":"scala",".svelte":"svelte",".swift":"swift",".ts":"typescript",".tsx":"typescript",".vue":"vue",".clj":"clojure",".cljs":"clojure",".fs":"fsharp",".fsx":"fsharp",".lua":"lua",".vb":"visual-basic"}[o]??o.slice(1)}function Ge(e,t){if(e.length<=t)return [...e];let o=new Map;for(let c of e){let s=F(c),a=o.get(s)??[];a.push(c),o.set(s,a);}let i=new Set,r=Math.max(1,Math.min(25,Math.floor(t/Math.max(o.size,1))));for(let c of [...o.values()])for(let s of c.slice(0,r))i.add(s);for(let c of e){if(i.size>=t)break;i.add(c);}return [...i].sort((c,s)=>c.localeCompare(s))}function Q(e,t,o){let i=[],r=e.split(/\r?\n/);for(let c=0;c<r.length&&i.length<o;c+=1)for(let s of t){let n=r[c].match(s.pattern)?.[1]?.trim();if(n){i.push({name:n,line:c+1,detail:s.detail});break}}return i}var xe=[{pattern:/^\s*(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/,detail:"function"},{pattern:/^\s*(?:export\s+)?(?:abstract\s+)?(?:class|interface|enum|type)\s+([A-Za-z_$][\w$]*)/,detail:"type"},{pattern:/^\s*(?:export\s+)?(?:declare\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)/,detail:"value"},{pattern:/^\s*(?:async\s+)?def\s+([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*class\s+([A-Za-z_]\w*)/,detail:"type"},{pattern:/^\s*func\s+(?:\([^)]*\)\s*)?([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*type\s+([A-Za-z_]\w*)\s+/,detail:"type"},{pattern:/^\s*(?:public\s+|private\s+|protected\s+|internal\s+|abstract\s+|final\s+)*(?:class|interface|record|enum)\s+([A-Za-z_]\w*)/,detail:"type"},{pattern:/^\s*(?:public|protected|internal)\s+(?:(?:static|virtual|override|abstract|async|sealed|final|synchronized|native|unsafe|partial|extern|new)\s+)*(?:<[^>]+>\s*)?[A-Za-z_$][\w$<>,.?\[\]: ]*\s+([A-Za-z_$][\w$]*)\s*\(/,detail:"method"},{pattern:/^\s*(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*(?:pub(?:\([^)]*\))?\s+)?(?:struct|trait|enum|type)\s+([A-Za-z_]\w*)/,detail:"type"},{pattern:/^\s*(?:public\s+|private\s+|protected\s+)?function\s+([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*(?:class|module|struct|protocol|mixin)\s+([A-Za-z_]\w*)/,detail:"type"}],qe=[{pattern:/^\s*import(?:.+?from\s*)?["']([^"']+)["']/,detail:"import"},{pattern:/require\(["']([^"']+)["']\)/,detail:"require"},{pattern:/^\s*from\s+([A-Za-z0-9_.]+)\s+import\s+/,detail:"import"},{pattern:/^\s*import\s+([A-Za-z0-9_.]+)(?:\s|$)/,detail:"import"},{pattern:/^\s*(?:import|using|use)\s+([A-Za-z0-9_:.*\\/.-]+)/,detail:"import"},{pattern:/^\s*require(?:_relative)?\s+["']([^"']+)["']/,detail:"require"}];function Ze(e,t,o,i){let r=p.extname(e).toLowerCase()===".py",c;if(r){let d=t.match(/^\.+/)?.[0].length??0,l=d>0?p.dirname(e):p.resolve(i??"");for(let u=1;u<d;u+=1)l=p.dirname(l);let m=t.slice(d).replace(/\./g,p.sep);c=m?p.join(l,m):l;}else {if(!t.startsWith("."))return null;c=p.resolve(p.dirname(e),t);}let s=p.extname(c).toLowerCase(),a=T.has(s),n=new Set([c]);if(r&&(n.add(`${c}.py`),n.add(p.join(c,"__init__.py"))),a){let d=c.slice(0,-s.length);if([".js",".jsx",".mjs"].includes(s))for(let l of [".ts",".tsx",".js",".jsx",".mjs"])n.add(`${d}${l}`);}else for(let d of T)n.add(`${c}${d}`),n.add(p.join(c,`index${d}`));return [...n].find(d=>o.has(p.resolve(d)))??null}function He(e,t){let o=t.trimStart(),i=p.extname(e).toLowerCase();return [".py",".rb",".sh",".bash",".zsh"].includes(i)?o.startsWith("#"):[".sql",".lua",".hs"].includes(i)?o.startsWith("--"):o.startsWith("//")||o.startsWith("/*")||o.startsWith("*")}function Ve(e,t){if(p.extname(e).toLowerCase()!==".py")return t;let o=null;return t.split(/\r?\n/).map(i=>{let r=0,c="";for(;r<i.length;){if(o){let l=i.indexOf(o,r);if(l<0)return c;r=l+3,o=null;continue}let s=i.indexOf("'''",r),a=i.indexOf('"""',r),n=i.indexOf("#",r),d=s<0?a:a<0?s:Math.min(s,a);if(n>=0&&(d<0||n<d)){c+=i.slice(r,n);break}if(d<0){c+=i.slice(r);break}c+=i.slice(r,d),o=i.startsWith("'''",d)?"'''":'"""',r=d+3;}return c}).join(`
|
|
2
2
|
`)}function Je(e,t){if(![".js",".jsx",".mjs",".ts",".tsx"].includes(p.extname(e).toLowerCase()))return t;let o=false,i=false;return t.split(/\r?\n/).map(r=>{let c="",s=null,a=false;for(let n=0;n<r.length;n+=1){let d=r[n],l=r[n+1];if(o){c+=" ",d==="*"&&l==="/"&&(c+=" ",n+=1,o=false);continue}if(i){c+=" ",d==="`"&&!a&&(i=false),a=d==="\\"&&!a,d!=="\\"&&(a=false);continue}if(s){c+=d,d===s&&!a&&(s=null),a=d==="\\"&&!a,d!=="\\"&&(a=false);continue}if(d==="/"&&l==="/")return c.padEnd(r.length," ");if(d==="/"&&l==="*"){c+=" ",n+=1,o=true;continue}if(d==="`"){c+=" ",i=true,a=false;continue}(d==="'"||d==='"')&&(s=d),c+=d;}return c}).join(`
|
|
3
3
|
`)}function Ue(e,t){return Je(e,Ve(e,t))}var Ye=[{pattern:/@(?:Get|Post|Put|Delete|Patch|Options|Head)\s*\(\s*["']([^"']*)["']/i,detail:"decorated route"},{pattern:/\b(?:app|router|server|api|route|fastify|fiber)\.(?:get|post|put|delete|patch|options|head)\s*\(\s*["']([^"']+)["']/i,detail:"router route"},{pattern:/@(?:GetMapping|PostMapping|PutMapping|DeleteMapping|PatchMapping|RequestMapping)\s*\([^"']*["']([^"']*)["']/,detail:"mapped route"},{pattern:/\[Http(?:Get|Post|Put|Delete|Patch)\s*\(\s*["']([^"']*)["']/i,detail:"HTTP route"},{pattern:/^\s*(?:get|post|put|delete|patch)\s+["']([^"']+)["']/i,detail:"HTTP route"}];function V(e){return createHash("sha256").update(e).digest("hex")}function E(e,t){return `wkg:${e}:${V(`${e}\0${t}`).slice(0,20)}`}function O(e){return e.replace(/\\/g,"/")}function x(e){let t=O(e).replace(/^\.\//,"");return !t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")?"unknown":t}function j(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function b(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function K(e){if(Array.isArray(e))return e.filter(o=>typeof o=="string").map(o=>o.trim()).filter(Boolean).sort();let t=j(e);return t?Object.keys(t).map(o=>o.trim()).filter(Boolean).sort():[]}function Xe(e){if(Array.isArray(e))return e.map(o=>typeof o=="string"?o.split("=",1)[0]?.trim():"").filter(o=>!!o).sort();let t=j(e);return t?Object.keys(t).sort():[]}function Qe(e){return Object.fromEntries(Object.entries(e).filter(t=>t[1]!==void 0).sort(([t],[o])=>t.localeCompare(o)))}async function q(e,t){let o=[],i=[e],r=0;for(;r<i.length&&o.length<t;){let c=i[r++],s;try{s=await S.readdir(c,{withFileTypes:true});}catch{continue}s.sort((a,n)=>a.name.localeCompare(n.name));for(let a$1 of s){if(o.length>=t)break;if(a$1.isSymbolicLink())continue;let n=p.join(c,a$1.name);a$1.isDirectory()?!De.has(a$1.name)&&!a(a$1.name)&&i.push(n):a$1.isFile()&&o.push(n);}}return o.sort((c,s)=>c.localeCompare(s))}async function Se(e){return new Promise(t=>{let o=createHash("sha256"),i=createReadStream(e);i.on("data",r=>o.update(r)),i.on("error",r=>{t(`unreadable:${r.code??"unknown"}`);}),i.on("end",()=>t(o.digest("hex")));})}var et=promisify(execFile);async function D(e,t){let o=await et("git",t,{cwd:e,encoding:"buffer",maxBuffer:268435456,windowsHide:true});return Buffer.isBuffer(o.stdout)?o.stdout:Buffer.from(o.stdout)}async function tt(e){try{let t=(await D(e.root,["rev-parse","--show-prefix"])).toString("utf8").trim().replace(/\\/gu,"/"),o=t?`${t.replace(/^\/+|\/+$/gu,"")}/`:"";if(p.posix.isAbsolute(o)||o==="../"||o.startsWith("../")||o.includes("/../"))return null;let i=o.replace(/\/$/u,""),r=i?`HEAD:${i}`:"HEAD^{tree}",[c,s,a,n,d,l]=await Promise.all([D(e.root,["rev-parse",r]),D(e.root,["diff","--no-ext-diff","--no-textconv","--binary","HEAD","--","."]),D(e.root,["ls-files","--full-name","--others","--exclude-standard","-z","--","."]),D(e.root,["ls-files","--full-name","--others","--ignored","--exclude-standard","-z","--","."]),D(e.root,["ls-files","-v","--","."]),D(e.root,["ls-files","--full-name","-s","--","."])]);if(d.toString("utf8").split(/\r?\n/u).some(f=>/^[a-z] /u.test(f)))return null;let m=e.files.map(f=>{let y=O(p.relative(e.root,f));return `${o}${y}`});if(l.toString("utf8").split(/\r?\n/u).filter(f=>f.startsWith("160000 ")).map(f=>f.split(" ",2)[1]).filter(f=>!!f).map(f=>f.replace(/\\/gu,"/").replace(/\/$/u,"")).some(f=>m.some(y=>y.startsWith(`${f}/`))))return null;let v=new Set(m),g=Buffer.concat([a,n]).toString("utf8").split("\0").filter(Boolean).map(f=>f.replace(/\\/gu,"/")).filter(f=>v.has(f)),w=await Ae([...new Set(g)].sort((f,y)=>f.localeCompare(y)),16,async f=>{let y=o?f.slice(o.length):f;return {path:y,hash:await Se(p.resolve(e.root,...y.split("/").filter(Boolean)))}}),P=createHash("sha256");P.update(`git-worktree-v2\0${e.kind}\0${e.id}\0${e.fileLimit}\0`),P.update(c),P.update(createHash("sha256").update(s).digest());for(let f of w)P.update(`${f.path}\0${f.hash}\0`);return {kind:e.kind,id:e.id,strategy:"git-worktree-v2",hash:P.digest("hex"),fileCount:e.files.length,fileLimit:e.fileLimit,truncated:e.files.length>=e.fileLimit}}catch{return null}}async function Ae(e,t,o){let i=new Array(e.length),r=0,c=Array.from({length:Math.min(t,Math.max(e.length,1))},async()=>{for(;r<e.length;){let s=r++;i[s]=await o(e[s]);}});return await Promise.all(c),i}async function ue(e){let t=await tt(e);if(t)return t;let o=await Ae(e.files,16,async r=>({path:O(p.relative(e.root,r)),hash:await Se(r)}));o.sort((r,c)=>r.path.localeCompare(c.path));let i=createHash("sha256");i.update(`content-merkle-v1\0${e.kind}\0${e.id}\0${e.fileLimit}\0`);for(let r of o)i.update(`${r.path}\0${r.hash}\0`);return {kind:e.kind,id:e.id,strategy:"content-merkle-v1",hash:i.digest("hex"),fileCount:o.length,fileLimit:e.fileLimit,truncated:o.length>=e.fileLimit}}async function ot(e){let t=p.resolve(e.workspacePath),o=[...e.projects].sort((s,a)=>s.id.localeCompare(a.id)),i=e.inventories?.workspaceFiles??await q(t,e.workspaceFileLimit),r=await Promise.all([ue({kind:"workspace",id:"workspace",root:t,files:i,fileLimit:e.workspaceFileLimit}),...o.map(async s=>{let a=s.absolutePath?p.resolve(s.absolutePath):p.resolve(t,s.path),n=e.inventories?.projectFiles?.get(s.id)??await q(a,e.projectFileLimit);return ue({kind:"project",id:s.id,root:a,files:n,fileLimit:e.projectFileLimit})})]);r.sort((s,a)=>s.kind.localeCompare(a.kind)||s.id.localeCompare(a.id));let c=createHash("sha256");c.update("workspace-knowledge-graph-inputs.v1\0hybrid-git-content-v2\0");for(let s of r)c.update(`${s.kind}\0${s.id}\0${s.hash}\0${s.fileCount}\0${s.fileLimit}\0${s.truncated}\0`);return {schemaVersion:"workspace-knowledge-graph-inputs.v1",strategy:"hybrid-git-content-v2",hashAlgorithm:"sha256",hash:c.digest("hex"),scopes:r}}async function B(e){let t=await S.readFile(e,"utf8");if(e.toLowerCase().endsWith(".json")){let o=JSON.parse(t),i=j(o);return i?[i]:[]}return parseAllDocuments(t,{logLevel:"silent"}).map(o=>j(o.toJSON())).filter(o=>o!==null)}function J(e){return [...new Set([...e.workspaceFiles,...e.projects.flatMap(t=>e.filesByProject.get(t.id)??[])])].sort((t,o)=>t.localeCompare(o))}function me(e){return /^(?:openapi|swagger)(?:\.[^.]+)?\.(?:json|ya?ml)$/i.test(p.basename(e))}function ge(e){let t=p.basename(e).toLowerCase();return /\.(?:graphql|gql|proto)$/.test(t)||/^asyncapi(?:\.[^.]+)?\.(?:json|ya?ml)$/.test(t)}function he(e){let t=p.basename(e);return /^Dockerfile(?:\..+)?$/i.test(t)||/\.tf$/i.test(t)||t==="Chart.yaml"}function ye(e){return /(?:^|[\\/])(?:README|ARCHITECTURE|CONTRIBUTING|SECURITY)\.md$/i.test(e)}function rt(e,t){let o=O(p.relative(e,t));return /^\.github\/workflows\/.+\.ya?ml$/i.test(o)||/^(?:\.gitlab-ci\.ya?ml|azure-pipelines\.ya?ml|Jenkinsfile|bitbucket-pipelines\.ya?ml|\.woodpecker\.ya?ml)$/i.test(o)||/^\.circleci\/config\.ya?ml$/i.test(o)}function ve(e,t){let o=O(p.relative(e,t));return /(?:^|\/)(?:adr|adrs|decisions)(?:\/).+\.md$/i.test(o)||/(?:^|\/)ADR[-_0-9].+\.md$/i.test(o)}async function ke(e){let t=new Set;for(let o of [e.workspacePath,...e.projects.map(i=>i.root)])for(let i of ["compose.yml","compose.yaml","docker-compose.yml","docker-compose.yaml"]){let r=p.join(o,i);await S.pathExists(r)&&t.add(r);}return [...t].sort((o,i)=>o.localeCompare(i))}async function be(e){let o=[e.workspacePath,...e.projects.map(r=>r.root)].flatMap(r=>[p.join(r,"CODEOWNERS"),p.join(r,".github","CODEOWNERS"),p.join(r,"docs","CODEOWNERS")]),i=await Promise.all(o.map(async r=>await S.pathExists(r)?r:null));return [...new Set(i.filter(r=>!!r))].sort((r,c)=>r.localeCompare(c))}function we(e){let t=[{root:e.workspacePath,files:e.workspaceFiles},...e.projects.map(o=>({root:o.root,files:e.filesByProject.get(o.id)??[]}))];return [...new Set(t.flatMap(o=>o.files.filter(i=>rt(o.root,i))))].sort((o,i)=>o.localeCompare(i))}async function Pe(e){let t=[];for(let o of J(e))if(/\.ya?ml$/i.test(o))try{(await B(o)).some(r=>{let c=j(r.metadata);return !!(b(r.apiVersion)&&b(r.kind)&&b(c?.name))})&&t.push(o);}catch{}return t.sort((o,i)=>o.localeCompare(i))}function N(e,t){let o=p.resolve(t);return e.filter(i=>o===i.root||o.startsWith(`${i.root}${p.sep}`)).sort((i,r)=>r.root.length-i.root.length)[0]??null}var re=class{constructor(t,o,i){this.workspacePath=t;this.now=o;this.workspaceName=i;}workspacePath;now;workspaceName;entities=new Map;relations=new Map;proofs=new Map;providers=[];diagnostics=[];contentHashes=new Map;attributeConflicts=new Set;emptyLabelDiagnostics=new Set;artifactPath(t,o){if(o){let i=O(p.relative(o.root,t));return x(p.posix.join(o.artifactPrefix,i))}return x(p.relative(this.workspacePath,t))}async addProof(t){let o;if(t.absolutePath){if(!this.contentHashes.has(t.absolutePath))try{this.contentHashes.set(t.absolutePath,V(await S.readFile(t.absolutePath)));}catch{this.contentHashes.set(t.absolutePath,null);}o=this.contentHashes.get(t.absolutePath)??void 0;}let i=x(t.artifact),r=E("proof",[t.provider,i,t.pointer??"",t.line??"",t.detail??""].join("\0"));return this.proofs.has(r)||this.proofs.set(r,{id:r,provider:t.provider,artifact:i,...t.pointer?{pointer:t.pointer}:{},...t.line?{line:t.line}:{},...t.column?{column:t.column}:{},...o?{contentHash:o}:{},observedAt:this.now.toISOString(),derivation:t.derivation??"extracted",trust:t.trust??"observed",confidence:t.confidence??"high",freshness:"fresh",...t.detail?{detail:t.detail}:{}}),r}addEntity(t){let o=E(t.kind,t.key),i=Qe(t.attributes??{}),r=this.entities.get(o),c=t.label.trim(),s=c||r?.label||t.key.trim()||t.kind;!c&&!this.emptyLabelDiagnostics.has(o)&&(this.emptyLabelDiagnostics.add(o),this.diagnostics.push({code:"graph.knowledge.empty_label_normalized",severity:"warning",message:`An empty ${t.kind} label was normalized to ${s}.`,entityIds:[o],recommendation:"Inspect the provider proof and preserve a non-empty source identifier before publishing the entity."}));let a={...r?.attributes??{}};for(let[l,m]of Object.entries(i)){if(l in a&&JSON.stringify(a[l])!==JSON.stringify(m)){let u=`${o}\0${l}`;this.attributeConflicts.has(u)||(this.attributeConflicts.add(u),this.diagnostics.push({code:"graph.knowledge.attribute_conflict",severity:"warning",message:`Conflicting ${l} values were observed for ${t.kind} ${s}.`,entityIds:[o],recommendation:"Inspect the entity proof paths and make the authoritative source explicit."}));continue}a[l]=m;}let n=[...new Set([...r?.identity.aliases??[],...t.aliases??[]].map(l=>l.trim()).filter(Boolean))].sort(),d=[...new Set([...r?.proofIds??[],...t.proofIds??[]])].sort();return this.entities.set(o,{id:o,kind:t.kind,label:s,...t.projectId?{projectId:t.projectId}:{},identity:{key:t.key,scope:t.projectId?"project":"workspace",aliases:n,fingerprint:V(JSON.stringify({kind:t.kind,key:t.key,attributes:a}))},attributes:a,proofIds:d}),o}addRelation(t){let o=E("relation",`${t.from}\0${t.kind}\0${t.to}`),i=this.relations.get(o),r=[...new Set([...i?.proofIds??[],...t.proofIds])].sort(),c=new Set(r.map(n=>this.proofs.get(n)?.provider).filter(Boolean)).size,s=t.trust??i?.trust??"observed",a=c>=2&&s!=="ambiguous"?"corroborated":s;return this.relations.set(o,{id:o,from:t.from,to:t.to,kind:t.kind,derivation:t.derivation??i?.derivation??"extracted",trust:a,confidence:a==="corroborated"?"high":t.confidence??i?.confidence??"high",proofIds:r}),o}};function ee(e){let t=[],o=null;for(let i of e.split(/\r?\n/)){let r=i.match(/^\s*\[\[([^\]]+)\]\]\s*(?:#.*)?$/)?.[1]?.trim()??i.match(/^\s*\[([^\]]+)\]\s*(?:#.*)?$/)?.[1]?.trim();if(r){o&&t.push({name:o.name,body:o.lines.join(`
|
|
4
4
|
`)}),o={name:r,lines:[]};continue}o?.lines.push(i);}return o&&t.push({name:o.name,body:o.lines.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b}from'./chunk-
|
|
1
|
+
import {b}from'./chunk-GPOZILMY.js';import {c,d,a,b as b$1}from'./chunk-MOSXTVPU.js';import n from'fs';import o from'path';function _(t){return b({startPath:t})?.workspacePath??null}function k(t){let s=o.resolve(t),p=n.existsSync(o.join(s,c))||n.existsSync(o.join(s,d))||n.existsSync(o.join(s,a,"workspace.json"))||n.existsSync(o.join(s,b$1,"workspace.json")),A=n.existsSync(o.join(s,a,"project.json"))||n.existsSync(o.join(s,a,"context.json"))||n.existsSync(o.join(s,b$1,"project.json"))||n.existsSync(o.join(s,b$1,"context.json"));return p&&!A}export{_ as a,k as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {f,l}from'./chunk-
|
|
1
|
+
import {f,l}from'./chunk-WSRUPDZN.js';import {a,b}from'./chunk-S5KTATOU.js';function u(r){let s=new Map;for(let n of r.projects)s.has(n.name)||s.set(n.name,f(n));return s}function w(r){let s=u(r),n=l(r)??{nodes:r.projects.map(t=>({id:t.name,path:t.path})),edges:[]},a$1=a(n),o=new Map;for(let t of n.nodes){let e=s.get(t.id)??f({missing:t.id}),l=[...b(a$1,[t.id],{direction:"dependencies"}).keys()].filter(c=>c!==t.id).sort((c,f)=>c.localeCompare(f)).map(c=>({id:c,hash:s.get(c)??"<unknown>"}));o.set(t.id,{id:t.id,ownHash:e,transitiveInputsHash:f({own:e,dependencies:l})});}return o}function y(r,s){if(!s||Object.keys(s).length===0)return {verdict:"unknown",baseline:"none",changed:[],added:[],removed:[]};let n=[],a=[];for(let[e,i]of r.entries())e in s?s[e]!==i.transitiveInputsHash&&n.push(e):a.push(e);let o=[];for(let e of Object.keys(s))r.has(e)||o.push(e);return n.sort((e,i)=>e.localeCompare(i)),a.sort((e,i)=>e.localeCompare(i)),o.sort((e,i)=>e.localeCompare(i)),{verdict:n.length>0||a.length>0||o.length>0?"stale":"fresh",baseline:"recorded",changed:n,added:a,removed:o}}function M(r){let s={};for(let[n,a]of [...r.entries()].sort((o,t)=>o[0].localeCompare(t[0])))s[n]=a.transitiveInputsHash;return s}export{u as a,w as b,y as c,M as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {f,e as e$1,g as g$1}from'./chunk-7WUT5ZSO.js';import {b as b$
|
|
1
|
+
import {f,e as e$1,g as g$1}from'./chunk-7WUT5ZSO.js';import {b as b$3}from'./chunk-Y4B55J5S.js';import {b as b$6,a as a$3}from'./chunk-THIOE2PB.js';import {b as b$2}from'./chunk-KVSYBHUR.js';import {a as a$2}from'./chunk-NOZ4JCH7.js';import {e,g,f as f$2,b as b$5,c as c$2,d as d$2}from'./chunk-WJVB6SSD.js';import {d,b as b$1}from'./chunk-Y5YAP4F3.js';import {d as d$3}from'./chunk-SP5EHSWG.js';import {i,f as f$1,c as c$1,e as e$2}from'./chunk-VRW6KXNK.js';import {a as a$1}from'./chunk-TQEMLBAG.js';import {b,a,c,d as d$1}from'./chunk-MOSXTVPU.js';import {b as b$4,k,j,m,i as i$1,t,s,q as q$1}from'./chunk-RJIYCDVC.js';import {promises}from'fs';import*as P from'fs-extra';import p from'path';import r from'chalk';import {execa}from'execa';function st(e){let n=e.projectCount??0,t=n===1?"project":"projects",a=e.pythonEngine==="installed"?`Python ${e.pythonVersion||"3.10+"} \xB7 ${e.installMethod||"local environment"}`:e.pythonEngine==="skipped"?"Python engine not installed":"Runtime-neutral foundation";return ["","\u2713 Workspace ready",`${e.workspaceName} \xB7 ${e.profile} \xB7 ${n} registered ${t}`,`Location ${e.workspacePath}`,`Runtime ${a}`,...e.note?[`Note ${e.note}`]:[],"","Workspace Intelligence"," \u2713 Contract and project registry"," \u2713 Canonical model and proof-backed graph"," \u2713 Agent context, grounding, and evidence index","","Next",` ${g$1(e.workspacePath)}`," npx workspai create"," npx workspai workspace intelligence run --for-agent generic --strict --json","","Evidence .workspai/reports/INDEX.json","Guide README.md",""]}function q(e){let n=st(e);for(let t of n)t==="\u2713 Workspace ready"?console.log(r.green.bold(t)):t==="Workspace Intelligence"||t==="Next"?console.log(r.cyan.bold(t)):t.startsWith(" \u2713")?console.log(r.green(t)):t.startsWith("Location")||t.startsWith("Runtime")?console.log(r.gray(t)):console.log(t);}function M(){return i$1()}var lt="transactions";function ct(){return p.join(q$1(),lt)}async function Ve(){let e=ct();return await b$6(e),a$3({journalDirectory:e})}async function Ge(e){for(let n of s())await e.captureFile(n);}async function ae(e){let n=await Ve();try{return await Ge(n),await n.captureOwnedTree(e),n}catch(t){return K(n,t)}}async function pt(e){let n=await Ve();try{await Ge(n),await n.captureOwnedTree(p.join(e,a)),await n.captureOwnedTree(p.join(e,".venv"));let t=[c,".gitignore",p.join(a,"workspace.json"),p.join(a,"toolchain.lock"),p.join(a,"policies.yml"),p.join(a,"cache-config.yml"),d$3,a$2,"pyproject.toml","poetry.toml","poetry.lock","rapidkit","rapidkit.cmd","README.md",".rapidkit-global"];for(let a of t)await n.captureFile(p.join(e,a));return n}catch(t){return K(n,t)}}async function z(e){await e.commit(),e.journalPath&&await promises.rm(p.dirname(e.journalPath),{recursive:true,force:true}).catch(n=>f$1.debug(`Could not remove committed lifecycle journal: ${n}`));}async function K(e,n){try{await e.rollback();}catch(t){throw new AggregateError([n,t],"Workspace lifecycle failed and rollback was incomplete.")}throw n}async function B(e,n,t,a,s){let l=d(n,i(),t,s?.pythonEngine?{coreStatus:s.pythonEngine,...s.pythonEngineReason?{coreReason:s.pythonEngineReason}:{},...a?{pythonVersion:a}:{}}:void 0);a&&!s?.pythonEngine&&(l.metadata||(l.metadata={}),l.metadata.python={pythonVersion:a}),await b$1(e,l);}async function G(e){await P.outputFile(p.join(e,".gitignore"),`.venv/
|
|
2
2
|
__pycache__/
|
|
3
3
|
*.pyc
|
|
4
4
|
.env
|