workspai 0.68.0 → 0.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -18
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +459 -0
- package/contracts/extension-cli-compatibility.v1.json +11 -0
- package/contracts/published-contract-catalog.v1.json +55 -0
- package/contracts/runtime-command-surface.v1.json +282 -0
- package/contracts/workspace-intelligence/architecture-change-lease.v1.json +50 -0
- package/contracts/workspace-intelligence/architecture-surprise-report.v1.json +46 -0
- package/contracts/workspace-intelligence/change-operation-result.v1.json +43 -0
- package/contracts/workspace-intelligence/decision-checkpoint.v1.json +18 -0
- package/contracts/workspace-intelligence/decision-event.v1.json +154 -0
- package/contracts/workspace-intelligence/decision-transaction.v1.json +29 -0
- package/contracts/workspace-intelligence/goal-index.v1.json +13 -0
- package/contracts/workspace-intelligence/goal-pack.v1.json +2 -1
- package/contracts/workspace-intelligence/predicted-architecture-change.v1.json +34 -0
- package/contracts/workspace-intelligence/proof-carrying-change-capsule-export.v1.json +14 -0
- package/contracts/workspace-intelligence/proof-carrying-change-capsule-validation.v1.json +16 -0
- package/contracts/workspace-intelligence/proof-carrying-change-capsule.v1.json +63 -0
- package/contracts/workspace-intelligence/proof-carrying-change-list.v1.json +80 -0
- package/contracts/workspace-intelligence/workspace-knowledge-graph-change-overlay.v1.json +9 -1
- package/dist/analyze-OGWDSPXQ.js +1 -0
- package/dist/{artifact-remediation-plan-I7IKC5MR.js → artifact-remediation-plan-URQL5MBN.js} +1 -1
- package/dist/autopilot-release-QQDFEPT7.js +1 -0
- package/dist/capabilities-command-NFGX42CH.js +1 -0
- package/dist/chunk-37SWTS2B.js +1 -0
- package/dist/{chunk-KDY4X7SQ.js → chunk-3S2U7WRM.js} +1 -1
- package/dist/{chunk-BHM6RHTA.js → chunk-3WHE7V4M.js} +1 -1
- package/dist/{chunk-2C5XJBYI.js → chunk-4R7STECB.js} +64 -64
- package/dist/chunk-AGZWDYMF.js +12 -0
- package/dist/chunk-COICGD62.js +1 -0
- package/dist/chunk-DNZHKBQ3.js +49 -0
- package/dist/{chunk-4WVOAX2V.js → chunk-DWL3PPLA.js} +1 -1
- package/dist/chunk-EBQS5T7Q.js +7 -0
- package/dist/chunk-EP6Q2QBU.js +1 -0
- package/dist/chunk-EZPLMAW2.js +1 -0
- package/dist/chunk-FE5R6EUV.js +2 -0
- package/dist/chunk-FIK343LI.js +1 -0
- package/dist/chunk-GED7JURY.js +157 -0
- package/dist/{chunk-3Z4SVBMR.js → chunk-GL3KLNIG.js} +1 -1
- package/dist/{chunk-TMRCPT7S.js → chunk-GYN6RPNU.js} +1 -1
- package/dist/{chunk-6E2Y3XGT.js → chunk-HCFOVANQ.js} +1 -1
- package/dist/{chunk-7DDEMDG2.js → chunk-IET57ZKN.js} +2 -2
- package/dist/{chunk-5OV2WXAR.js → chunk-IFHM2SI6.js} +1 -1
- package/dist/{chunk-3BMYMZQB.js → chunk-IGJA6GBQ.js} +1 -1
- package/dist/chunk-IHKG5C6G.js +1 -0
- package/dist/chunk-IRLKWRLP.js +3 -0
- package/dist/{chunk-FX5J6JCK.js → chunk-IVYPC36J.js} +1 -1
- package/dist/{chunk-DFVG4DDZ.js → chunk-JK6XEF7K.js} +3 -3
- package/dist/chunk-K33JJVQZ.js +2 -0
- package/dist/{chunk-3XF7O66C.js → chunk-LE2I2E6R.js} +5 -5
- package/dist/chunk-LU6CYDLN.js +1 -0
- package/dist/{chunk-QMQBX3RV.js → chunk-MGL6DBOR.js} +1 -1
- package/dist/chunk-N4B2M44I.js +1 -0
- package/dist/chunk-N6FJZ62B.js +2 -0
- package/dist/chunk-NSH7TTSV.js +1 -0
- package/dist/chunk-O5XQP5E7.js +1 -0
- package/dist/chunk-ODK4LCEL.js +1 -0
- package/dist/chunk-PTSEDZIV.js +2 -0
- package/dist/chunk-QNHKUSBH.js +1 -0
- package/dist/{chunk-SLFOUSRW.js → chunk-QYEQVNBF.js} +1 -1
- package/dist/chunk-QZODGRAI.js +2 -0
- package/dist/chunk-S2TOSHQW.js +4 -0
- package/dist/chunk-S42KDOGG.js +1 -0
- package/dist/chunk-TEMFNVO2.js +2 -0
- package/dist/chunk-TKXRP2B4.js +1 -0
- package/dist/{chunk-IXXQMD34.js → chunk-TLMP2MGH.js} +1 -1
- package/dist/chunk-UNXG3ZFV.js +1 -0
- package/dist/chunk-UT57IFS4.js +8 -0
- package/dist/{chunk-2MTJWPQ4.js → chunk-V52R2W2Q.js} +1 -1
- package/dist/chunk-WUXJCSYO.js +9 -0
- package/dist/chunk-XSSNM4F5.js +5 -0
- package/dist/chunk-XVTN5DDV.js +1 -0
- package/dist/{chunk-OFYY4725.js → chunk-Z7JIUA6I.js} +1 -1
- package/dist/chunk-ZLCLGIM6.js +1 -0
- package/dist/chunk-ZPOZ6MDX.js +4 -0
- package/dist/{create-U5PQHOZ4.js → create-BBALBC3U.js} +1 -1
- package/dist/doctor-WWVY7NB6.js +1 -0
- package/dist/goal-lifecycle-CEUTKUNV.js +1 -0
- package/dist/goal-pack-JQL3YOKT.js +1 -0
- package/dist/index.d.ts +35 -2
- package/dist/index.js +239 -239
- package/dist/pipeline-V46WWMP4.js +5 -0
- package/dist/{project-agent-entry-MH7364BE.js → project-agent-entry-MRAYG7QD.js} +1 -1
- package/dist/{project-intelligence-lens-ZCCHUKVI.js → project-intelligence-lens-4BKPN4PE.js} +1 -1
- package/dist/{project-test-coverage-JPWTBSSJ.js → project-test-coverage-4RRCHY5W.js} +1 -1
- package/dist/proof-carrying-change-B7ONTBYO.js +1 -0
- package/dist/verified-goal-YNSBL7L3.js +1 -0
- package/dist/{workspace-B33BFZZ3.js → workspace-FJ6JRYWA.js} +1 -1
- package/dist/{workspace-agent-sync-T3MJO2MX.js → workspace-agent-sync-V33UGII3.js} +1 -1
- package/dist/{workspace-archive-NOSGRKRZ.js → workspace-archive-OSMU3CK6.js} +1 -1
- package/dist/{workspace-context-KOCEP4MJ.js → workspace-context-O6UBCBEA.js} +1 -1
- package/dist/{workspace-contract-MQ3QE52V.js → workspace-contract-S2JYDA4K.js} +1 -1
- package/dist/workspace-explain-RP6VJ6QM.js +1 -0
- package/dist/workspace-explain-contract-KV7RTEJU.js +1 -0
- package/dist/{workspace-feedback-3YLIUFQ7.js → workspace-feedback-D6HJLKBQ.js} +1 -1
- package/dist/{workspace-foundation-O7O3QIS4.js → workspace-foundation-7QXEJJKZ.js} +1 -1
- package/dist/{workspace-graph-stream-XTGGBD7D.js → workspace-graph-stream-YY65R5EC.js} +1 -1
- package/dist/workspace-graph-token-efficiency-WNAFAN2F.js +1 -0
- package/dist/{workspace-history-7HDZZ4G5.js → workspace-history-WWPS4U7H.js} +1 -1
- package/dist/{workspace-intelligence-TFEQBPUP.js → workspace-intelligence-LMR42ICR.js} +1 -1
- package/dist/{workspace-intelligence-benchmark-PLVUBGWO.js → workspace-intelligence-benchmark-S5OXVNLC.js} +1 -1
- package/dist/{workspace-intelligence-evaluation-OJIQS5SN.js → workspace-intelligence-evaluation-QDSOOUHH.js} +1 -1
- package/dist/{workspace-intelligence-runner-6ZAV6RO4.js → workspace-intelligence-runner-FXFSTCHC.js} +1 -1
- package/dist/workspace-intelligence-runtime-registry-ZLPF7BAY.js +1 -0
- package/dist/{workspace-knowledge-graph-AUXYL3L6.js → workspace-knowledge-graph-3564KQXT.js} +1 -1
- package/dist/workspace-knowledge-graph-change-overlay-FIIAFLO6.js +1 -0
- package/dist/{workspace-knowledge-graph-contract-X52KXBXJ.js → workspace-knowledge-graph-contract-FVX5T7SU.js} +1 -1
- package/dist/{workspace-knowledge-graph-query-A7TKONWY.js → workspace-knowledge-graph-query-WHCGPBGS.js} +1 -1
- package/dist/workspace-knowledge-graph-snapshot-P27RPMV5.js +1 -0
- package/dist/workspace-mcp-serve-ZK46EZUD.js +3 -0
- package/dist/{workspace-model-GVXNLSQM.js → workspace-model-6UMQAGUK.js} +1 -1
- package/dist/{workspace-onboarding-ECZ2KJ2A.js → workspace-onboarding-C57OQ7XZ.js} +1 -1
- package/dist/{workspace-readme-6N5Y2ZSJ.js → workspace-readme-HA6XLDME.js} +2 -2
- package/dist/{workspace-registry-summary-5SFBTRGQ.js → workspace-registry-summary-GLQO4ZUF.js} +1 -1
- package/dist/workspace-repair-engine-5ZSSF3T5.js +3 -0
- package/dist/workspace-run-UGWGT3K2.js +1 -0
- package/dist/{workspace-verify-D3QTMAUI.js → workspace-verify-LQHXBH2D.js} +1 -1
- package/dist/{workspace-watch-XYJEW2Z2.js → workspace-watch-Z32443UP.js} +1 -1
- package/docs/README.md +35 -31
- package/docs/ci-workflows.md +1 -1
- package/docs/commands-reference.md +26 -0
- package/docs/contracts/ARTIFACT_CATALOG.md +37 -18
- package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +17 -0
- package/docs/contracts/PROOF_CARRYING_CHANGE_CONTRACT_PLAN.md +68 -0
- package/docs/proof-carrying-change.implementation.v1.json +119 -0
- package/docs/proof-carrying-change.md +236 -0
- package/docs/real-world-qualification.md +8 -3
- package/package.json +1 -1
- package/dist/analyze-JDEWUBC6.js +0 -1
- package/dist/autopilot-release-OELUFNLL.js +0 -1
- package/dist/capabilities-command-RAAYENQ6.js +0 -1
- package/dist/chunk-2KX6KHEC.js +0 -1
- package/dist/chunk-3KU3YUWD.js +0 -2
- package/dist/chunk-3NF3M3RE.js +0 -1
- package/dist/chunk-3OGPTLI2.js +0 -1
- package/dist/chunk-5ME4W4LN.js +0 -1
- package/dist/chunk-5XUAAQSV.js +0 -5
- package/dist/chunk-5YZ2W57R.js +0 -8
- package/dist/chunk-7DZNZ3GM.js +0 -3
- package/dist/chunk-BG6IX6HA.js +0 -1
- package/dist/chunk-BMAFHX6A.js +0 -1
- package/dist/chunk-BUYLM6QV.js +0 -1
- package/dist/chunk-C2VTO5WT.js +0 -2
- package/dist/chunk-CPR2CMOY.js +0 -1
- package/dist/chunk-CSZPE637.js +0 -2
- package/dist/chunk-EHLGPLIU.js +0 -1
- package/dist/chunk-FPDH3N3A.js +0 -7
- package/dist/chunk-GVQKAINC.js +0 -49
- package/dist/chunk-IKUFNK46.js +0 -2
- package/dist/chunk-JYMO7QXQ.js +0 -1
- package/dist/chunk-KY2GOSO5.js +0 -1
- package/dist/chunk-LEOFD3W5.js +0 -12
- package/dist/chunk-LPCZHKD5.js +0 -1
- package/dist/chunk-N5HPMATQ.js +0 -1
- package/dist/chunk-P3622IM5.js +0 -4
- package/dist/chunk-Q7UGDNSM.js +0 -1
- package/dist/chunk-RVAOJOXA.js +0 -2
- package/dist/chunk-TCLKGPXF.js +0 -2
- package/dist/chunk-VIN7NJW3.js +0 -9
- package/dist/chunk-W5VKBDSD.js +0 -157
- package/dist/chunk-WRZSQDZV.js +0 -1
- package/dist/chunk-Y4Z6CEII.js +0 -1
- package/dist/chunk-ZEEV5J4I.js +0 -1
- package/dist/chunk-ZGHJIQXL.js +0 -1
- package/dist/doctor-D7YI7LSA.js +0 -1
- package/dist/goal-lifecycle-BMS6GSIU.js +0 -1
- package/dist/goal-pack-RBSVQMMX.js +0 -1
- package/dist/pipeline-QOMXH2EK.js +0 -5
- package/dist/verified-goal-XUXU2X5H.js +0 -1
- package/dist/workspace-explain-DTFCKYXK.js +0 -1
- package/dist/workspace-explain-contract-WMREJWHF.js +0 -1
- package/dist/workspace-graph-token-efficiency-5LJKQU2J.js +0 -1
- package/dist/workspace-intelligence-runtime-registry-UKFB3BI7.js +0 -1
- package/dist/workspace-knowledge-graph-change-overlay-XG6FC4IX.js +0 -1
- package/dist/workspace-knowledge-graph-snapshot-GPBDAKAU.js +0 -1
- package/dist/workspace-mcp-serve-TDUXJUAA.js +0 -3
- package/dist/workspace-repair-engine-CKJCTWKX.js +0 -3
- package/dist/workspace-run-ZZ5WHL7W.js +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {m,a as a$1,l as l$1}from'./chunk-GED7JURY.js';import {b as b$5,g as g$2}from'./chunk-QZODGRAI.js';import {b as b$4,a}from'./chunk-D5LLTUTY.js';import {b as b$2,f as f$2,s as s$1,t as t$1,u,P as P$1,v,q as q$2,r,R,n,o,p as p$2,h as h$2,i,m as m$1,j,k,l,O,w,x,y,z as z$1,A,B as B$1,C,E,G,I,D as D$1,F,H,J as J$1,K,L,M,N,S,T,U,V,Y as Y$1,X as X$1,W,a as a$3,Q}from'./chunk-QYEQVNBF.js';import {b as b$1,c,d}from'./chunk-N6FJZ62B.js';import {b as b$3}from'./chunk-COICGD62.js';import {d as d$2}from'./chunk-S42KDOGG.js';import {b as b$7}from'./chunk-AGZWDYMF.js';import {q as q$1,l as l$2,d as d$1}from'./chunk-IHKG5C6G.js';import {p as p$1}from'./chunk-PTSEDZIV.js';import {g}from'./chunk-FE5R6EUV.js';import {a as a$2,b as b$6}from'./chunk-K33JJVQZ.js';import {q,p,t,s as s$2}from'./chunk-ODK4LCEL.js';import {f as f$1,g as g$1,h}from'./chunk-VQZ5PI5J.js';import s from'path';import h$1 from'fs-extra';var pe=["Scope","Evidence","Diagnosis","Fix Plan","Run","Verify","Assumptions"];var Jt="workspace-operational-skill.v1";function Yt(e){if(typeof e!="string")return null;let t=e.trim();return !t||t.includes("/")||t.includes("..")?null:t}function Ot(e){let t=Yt(e.skillId);if(!t)throw new Error(`Invalid skill id: ${e.skillId}`);return {schemaVersion:Jt,skillId:t,canonicalPath:W(t),title:e.title,triggers:[...e.triggers].sort((r,n)=>r.localeCompare(n)),requiredReports:[...e.requiredReports].sort((r,n)=>r.localeCompare(n)),scopedProjects:[...e.scopedProjects??[]].sort((r,n)=>r.localeCompare(n)),verificationCommands:[...e.verificationCommands],answerContractSections:[...pe],...e.promptStem?{promptStem:e.promptStem}:{},markdown:e.markdown}}var Xt=q.skillsIndex;function Tt(e){let t=[...e.skills].sort((i,c)=>i.skillId.localeCompare(c.skillId)),r=e.inputsHash??d$1({skillIds:t.map(i=>i.skillId),paths:t.map(i=>i.canonicalPath),decisions:e.decisions??[]}),n=e.decisions?[...e.decisions].sort((i,c)=>i.skillId.localeCompare(c.skillId)):void 0;return {schemaVersion:Xt,generatedAt:e.generatedAt,inputsHash:r,skills:t.map(i=>({skillId:i.skillId,path:i.canonicalPath,schemaVersion:i.schemaVersion,title:i.title})),...n?{selection:{generatedCount:n.filter(i=>i.status==="generated").length,suppressedCount:n.filter(i=>i.status==="suppressed").length,decisions:n}}:{}}}var _t=[p.agentIndex,b$1,d$2],B="<!-- WORKSPAI:GENERATED-OPERATIONAL-SKILL -->",Qt=[{skillId:"workspai-diagnose-api-failure",title:"Diagnose API failure",triggers:["api failure","500 error","integration test failed","service unreachable"],objective:"Investigate a failing API or service using Workspai evidence before editing application code.",steps:[`Read \`${p.agentIndex}\` and identify fail/warn reports for the scoped project.`,`Read \`${p.doctor}\`, \`doctor-project-last-run.json\`, and project-scoped run evidence if present.`,"If a fix was requested, read `artifact-remediation-plan-last-run.json` for cross-artifact next steps, then `doctor-remediation-plan-last-run.json` for Doctor-specific file edits.","Map the failure to workspace vs project scope; cite exit codes and blocker messages.","Propose the smallest safe fix (config, env, dependency) with explicit verification commands."],applicability:"api"},{skillId:"workspai-release-readiness",title:"Release readiness",triggers:["release","ship","production","readiness gate"],objective:"Assess whether this workspace is release-ready using governed Workspai gates.",steps:[`Read \`${p.readiness}\` and \`pipeline-last-run.json\`.`,`Read \`${p.verify}\` for verdict and blocking reasons.`,`Read \`${t.artifactRemediationPlan}\` when a Studio or agent repair path is needed.`,"List blocking gates first; never claim ready without cited report fields.","Provide one safe next command and a verification checklist."],applicability:"workspace"},{skillId:"workspai-safe-schema-migration",title:"Safe schema migration",triggers:["migration","schema change","database migration","db migrate"],objective:"Plan and verify a schema migration with blast-radius awareness.",steps:["Identify affected projects from workspace model and dependency graph.","Run or review impact/verify evidence for transitive dependents.","Run a registered project-scoped test/build command when available; otherwise resolve the repository-authored validation command from cited manifests before promoting the migration.","Document rollback and verification signals."],applicability:"schema"},{skillId:"workspai-dependency-upgrade",title:"Dependency upgrade",triggers:["upgrade dependency","bump package","security advisory","outdated deps"],objective:"Upgrade dependencies with graph-aware verification.",steps:["Scope the upgrade to the owning project from workspace model.","Check transitive dependents via workspace graph / impact reports.","Use registered test/build commands for affected projects; when none are registered, resolve repository-authored commands from cited manifests instead of inventing one.","Re-run `workspace verify` after evidence refresh."],applicability:"dependency"},{skillId:"workspai-rename-contract",title:"Rename contract safely",triggers:["rename contract","rename event","breaking api","contract change"],objective:"Rename or change a shared contract with consumer awareness.",steps:[`Read \`${t.workspaceContract}\` for publishes/consumes/owns edges.`,"List all consumer projects before proposing renames.","Update contract file and regenerate workspace model.","Verify contract gate and integration tests for consumers."],applicability:"contract"}];function z(e){return `npx workspai ${e}`.trim()}function Zt(e){let t=["---",`name: ${e.template.skillId}`,`description: ${e.template.objective}`,"---","",B,"",`# ${e.template.title}`,"",`> Workspace: **${e.workspaceName}** \xB7 Skill: \`${e.template.skillId}\``,"","## Objective","",e.template.objective,"","## Triggers","",...e.template.triggers.map(r=>`- ${r}`),"","## Required evidence (read first)","",..._t.map(r=>`- \`${r}\``),"","## Why this skill exists here","",`Applicability: **${e.decision.confidence} confidence**.`,"",...e.decision.reasons.map(r=>`- ${r}`),...e.decision.signals.length>0?["","Evidence signals:","",...e.decision.signals.map(r=>`- \`${r}\``)]:[],"","## Project-aware execution boundary","",...e.projectEvidence,"",...e.retrievalCommands.length>0?["## Scoped retrieval commands","",...e.retrievalCommands.map(r=>`- \`${r}\``),""]:[],"## Procedure","",...e.template.steps.map((r,n)=>`${n+1}. ${r}`),""];if(e.scopedProjects.length>0&&t.push("## Scoped projects","",...e.scopedProjects.map(r=>`- ${r}`),""),e.contractSummary&&t.push("## Contract context","",e.contractSummary,""),e.verificationCommands.length>0){t.push("## Verification commands (this workspace)","");for(let r of e.verificationCommands)t.push(`- \`${r}\``);t.push("");}return t.push("## Answer contract","","Return: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh stale evidence","","```bash",z("workspace agent-sync --write --refresh-context"),"```",""),t.join(`
|
|
2
|
+
`)}function er(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function tr(e){let t=new Map;for(let c of e.projects){let m=new Set([c.runtime,...c.runtimeCandidates??[]].map(er).filter(a=>a&&a!=="unknown"));for(let a of m){let k=t.get(a)??[];k.includes(c.name)||k.push(c.name),t.set(a,k);}}let r=[];for(let[c,m]of [...t.entries()].sort(([a],[k])=>a.localeCompare(k)))r.push({skillId:`workspai-${c}-runtime-validation`,title:`${c.toUpperCase()} runtime validation`,triggers:[`${c} build`,`${c} test`,`${c} runtime failure`],objective:`Validate ${c} changes against the detected runtime boundary, registered project commands, and canonical Workspai evidence.`,steps:["Read the scoped project lens and current fail/warn evidence before changing source.",`Use a registered ${c} command only when the project model identifies ${c} as the primary runtime; for a composite secondary boundary, inspect its manifest and Graph proofs instead of assuming the primary adapter covers it.`,"Run only the affected project validation first, then verify the workspace when the change crosses a contract boundary."],scopedProjects:[...m].sort(),applicability:"derived"});t.size>1&&r.push({skillId:"workspai-polyglot-change-validation",title:"Polyglot change validation",triggers:["cross-language change","polyglot change","binding change","multi-runtime validation"],objective:"Plan and verify a cross-runtime change without assuming that one runtime command proves the whole system.",steps:["Use the project topology and bounded Graph query to identify runtime and contract boundaries.","Validate each affected runtime with its registered project command.","Run workspace impact and canonical verification before declaring the change complete."],scopedProjects:Wt([...t.values()].flat()),applicability:"derived"});let n=e.projects.filter(c=>c.commands.supported.includes("test")).map(c=>c.name).sort();n.length>0&&r.push({skillId:"workspai-test-evidence-recovery",title:"Test evidence recovery",triggers:["test failure","coverage","regression","test evidence"],objective:"Repair a test or coverage blocker by proving changed behavior, not merely improving a metric.",steps:["Read the exact Analyze, Doctor, or Goal evidence that owns the test finding.","Inspect the behavior and relevant test boundary before proposing a source change.","Run the scoped test command, then the exact producer and canonical verification."],scopedProjects:n,applicability:"derived"});let i=e.projects.filter(c=>c.importantFiles.some(m=>/(?:^|\/)(?:Dockerfile|docker-compose|compose\.|Chart\.yaml|\.github\/workflows)/i.test(m))).map(c=>c.name).sort();return i.length>0&&r.push({skillId:"workspai-delivery-evidence",title:"Delivery evidence and CI recovery",triggers:["ci failure","workflow failure","container build","deployment evidence"],objective:"Diagnose delivery evidence with the owning project and CI/container artifacts before changing application source.",steps:["Identify whether the failing evidence is project-owned or workspace-owned.","Inspect the referenced workflow or delivery artifact and its bounded proof paths.","Validate the affected project first, then refresh the exact evidence producer and verify the workspace."],scopedProjects:i,applicability:"derived"}),r}function rr(e,t){if(!e?.safeCommands?.length)return [z("workspace verify --json"),z("doctor workspace --json")];let r=new Set(t);return e.safeCommands.filter(n=>n.scope==="workspace"||n.project&&r.has(n.project)).slice(0,8).map(n=>n.display)}function nr(e,t){if(!e?.projects?.length)return;let r=new Set(t),n=e.projects.filter(i=>r.has(i.slug)).filter(i=>(i.contracts?.owns?.length??0)>0||(i.contracts?.publishes?.length??0)>0||(i.contracts?.consumes?.length??0)>0||(i.contracts?.apis?.length??0)>0).slice(0,12).map(i=>{let c=i.contracts?.owns?.join(", ")||"none",m=i.contracts?.publishes?.join(", ")||"none",a=i.contracts?.consumes?.join(", ")||"none";return `- **${i.slug}**: owns \`${c}\`; publishes \`${m}\`; consumes \`${a}\``});return n.length>0?n.join(`
|
|
3
|
+
`):void 0}var ar=/(?:^|\/)(?:package(?:-lock)?\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb?|pyproject\.toml|poetry\.lock|requirements[^/]*\.txt|Pipfile(?:\.lock)?|uv\.lock|Cargo\.toml|Cargo\.lock|go\.mod|go\.sum|pom\.xml|build\.gradle(?:\.kts)?|settings\.gradle(?:\.kts)?|Gemfile(?:\.lock)?|composer\.(?:json|lock)|mix\.exs|deps\.edn|project\.clj|[^/]+\.(?:csproj|fsproj|vbproj)|Directory\.Packages\.props)$/i,or=/(?:^|\/)(?:openapi|swagger|asyncapi)\.(?:json|ya?ml)$|(?:^|\/)(?:routes?|controllers?|endpoints?|proto)(?:\/|\.)/i,ir=/(?:^|\/)(?:migrations?|database|db|prisma)(?:\/|\.)|(?:^|\/)schema\.(?:sql|prisma)$/i;function sr(e){let t=e.attributes.artifact;return typeof t=="string"&&t.trim()?t.trim():null}function cr(e){let t=e.attributes.ports;return Array.isArray(t)&&t.length>0}function lr(e,t){return e?.entities.filter(r=>r.projectId===t)??[]}function ue(e,t=12){return [...new Set([...e].map(r=>r.trim()).filter(Boolean))].sort((r,n)=>r.localeCompare(n)).slice(0,t)}function Wt(e){return [...new Set([...e].map(t=>t.trim()).filter(Boolean))].sort((t,r)=>t.localeCompare(r))}function dr(e){if(e.template.scopedProjects)return {projects:[...e.template.scopedProjects].sort(),reasons:["The canonical workspace model directly derived this capability."],signals:ue(e.template.scopedProjects.map(i=>`model:project:${i}:${e.template.skillId}`)),confidence:"high",applicable:true};if(e.template.applicability==="workspace")return {projects:e.model.projects.map(i=>i.name).sort(),reasons:["Workspace-level release and verification gates are always available."],signals:["model:workspace",`model:project-count:${e.model.projects.length}`],confidence:"high",applicable:true};let t=[],r=[],n=new Set;for(let i of e.model.projects){let c=lr(e.graph,i.name),m=Wt([...i.importantFiles,...c.map(sr).filter(l=>!!l)]),a=e.contract?.projects.find(l=>l.slug===i.name),k=false;switch(e.template.applicability){case "dependency":{let l=m.filter(d=>ar.test(d)),p=c.filter(d=>d.kind==="package");k=l.length>0||p.length>0,r.push(...l.map(d=>`artifact:${d}`),...p.slice(0,4).map(d=>`graph:package:${d.label}`)),k&&n.add("Dependency manifests or package entities were observed.");break}case "api":{let l=c.filter(w=>w.kind==="api"||w.kind==="endpoint"||w.kind==="service"&&cr(w)),p=m.filter(w=>or.test(w)),d=a?.contracts?.apis??[],R=(a?.ports??[]).filter(w=>["http","https","grpc"].includes(w.protocol));k=l.length>0||p.length>0||d.length>0||R.length>0,r.push(...l.slice(0,4).map(w=>`graph:${w.kind}:${w.label}`),...p.map(w=>`artifact:${w}`),...d.map(w=>`contract:api:${w.name}:${w.basePath}`),...R.map(w=>`contract:port:${w.name}:${w.protocol}:${w.port}`)),k&&n.add("An API, endpoint, routed artifact, or network contract was observed.");break}case "schema":{let l=c.filter(d=>{if(d.kind==="database")return true;if(d.kind!=="schema")return false;let R=`${d.label} ${JSON.stringify(d.attributes)}`;return /database|migration|sql|prisma|orm/i.test(R)}),p=m.filter(d=>ir.test(d));k=l.length>0||p.length>0,r.push(...l.slice(0,4).map(d=>`graph:${d.kind}:${d.label}`),...p.map(d=>`artifact:${d}`)),k&&n.add("A database, schema, or migration artifact was observed.");break}case "contract":{let l=a?[...a.contracts?.owns??[],...a.contracts?.publishes??[],...a.contracts?.consumes??[],...(a.contracts?.apis??[]).map(d=>d.name)]:[],p=c.filter(d=>["api","protocol"].includes(d.kind));k=l.length>0||p.length>0,r.push(...l.map(d=>`contract:${i.name}:${d}`),...p.slice(0,6).map(d=>`graph:${d.kind}:${d.label}`)),k&&n.add("A shared API, protocol, schema, or authored contract edge was observed.");break}case "derived":k=true;break}k&&t.push(i.name);}return {projects:ue(t,e.model.projects.length),reasons:[...n],signals:ue(r),confidence:e.graph||e.contract?"high":"medium",applicable:t.length>0}}function pr(e,t,r){let n=[];for(let i of t){let c=e.projects.find(l=>l.name===i);if(!c)continue;let m=c.commands.supported.filter(l=>["build","test","lint","format"].includes(l)),a=c.commands.supported.filter(l=>["docs","doctor"].includes(l)),k=r.filter(l=>l.startsWith("artifact:")).map(l=>l.slice(9)).filter(l=>c.importantFiles.includes(l)||l.includes(c.name));n.push(`- **${c.name}** \u2014 runtime \`${c.runtime}\`, framework \`${c.framework}\`, confidence \`${c.confidence}\`.`),n.push(m.length>0?` Registered lifecycle commands: ${m.map(l=>`\`${l}\``).join(", ")}.`:" No project-native build/test command is registered; inspect repository-authored manifests and Graph proofs before running a command."),a.length>0&&n.push(` Registered evidence commands: ${a.map(l=>`\`${l}\``).join(", ")}.`),k.length>0&&n.push(` Relevant artifacts: ${ue(k,6).map(l=>`\`${l}\``).join(", ")}.`);}return n.length>0?n:["- No project boundary was proven; do not infer repository-specific commands or files."]}function ur(e,t){let r=e.applicability==="api"?"api endpoint route service failure":e.applicability==="schema"?"database schema migration persistence":e.applicability==="dependency"?"package dependency manifest lockfile":e.applicability==="contract"?"api protocol published consumed contract":e.applicability==="workspace"?"release pipeline deployment verification":`${e.title.toLowerCase()} manifest command test`;return t.slice(0,8).map(n=>z(`workspace graph search "${r}" --scope project:${n} --limit 12 --json`))}function jt(e){let t=e.model.workspace.name,r=[],n=[];for(let i of [...Qt,...tr(e.model)]){let c=dr({template:i,model:e.model,contract:e.contract??null,graph:e.graph??null}),m={skillId:i.skillId,title:i.title,status:c.applicable?"generated":"suppressed",confidence:c.confidence,reasons:c.reasons.length>0?c.reasons:["No authoritative workspace signal proves this capability is present."],signals:c.signals,scopedProjects:c.projects};if(n.push(m),m.status==="suppressed")continue;let a=m.scopedProjects,k=rr(e.context??null,a),l=nr(e.contract??null,a),p=Zt({template:i,workspaceName:t,scopedProjects:a,verificationCommands:k,contractSummary:l,decision:m,projectEvidence:pr(e.model,a,m.signals),retrievalCommands:ur(i,a)});r.push(Ot({skillId:i.skillId,title:i.title,triggers:i.triggers,requiredReports:[..._t],scopedProjects:a,verificationCommands:k,...X$1(i.skillId)?{promptStem:Y$1[i.skillId]}:{},markdown:p}));}return {skills:r,decisions:n}}async function Nt(e){let t=s.resolve(e.workspacePath),r=[],n=d$1({skills:e.skills.map(a=>({id:a.skillId,path:a.canonicalPath,hash:d$1({markdown:a.markdown})})),decisions:e.decisions??[]}),i=Tt({generatedAt:e.generatedAt,skills:e.skills,inputsHash:n,decisions:e.decisions}),c=new Set(e.skills.map(a=>a.skillId)),m=[];if(e.write){let a=s.join(t,".workspai","skills");if(await h$1.pathExists(a))for(let l of await h$1.readdir(a,{withFileTypes:true})){if(!l.isFile()||!l.name.endsWith(".md"))continue;let p=l.name.slice(0,-3);if(c.has(p))continue;let d=s.join(a,l.name);(await h$1.readFile(d,"utf8")).includes(B)&&(await h$1.remove(d),m.push(p));}for(let l of e.skills){let p=s.join(t,l.canonicalPath);await h$1.ensureDir(s.dirname(p)),await h$1.writeFile(p,l.markdown,"utf8"),r.push(l.canonicalPath);}let k=s.join(t,b$2);await h$1.ensureDir(s.dirname(k)),await h$1.writeJson(k,i,{spaces:2}),r.push(b$2);}return {skills:e.skills,index:i,writtenPaths:r,removedSkillIds:m.sort()}}function Lt(e){return ["## Operational skills (canonical)","","Read workspace-native playbooks from `.workspai/skills/` before generic repo scans. Legacy `.rapidkit/skills/` playbooks are read only when already present from older workspaces:","",...e.skills.map(r=>`- \`${r.path}\` \u2014 ${r.title} (\`${r.skillId}\`)`),"","Regenerate:","","```bash",z("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
4
|
+
`)}var gr={"workspai-diagnose-api-failure":A,"workspai-release-readiness":E},Je="## Workspace verification (hydrated)";function mr(e){let t=[Je,"","Verification commands for this workspace:","",...e.verificationCommands.length?e.verificationCommands.map(r=>`- \`${r}\``):["- `npx workspai workspace verify --json`"]];return e.scopedProjects.length>0&&t.push("","Scoped projects:","",...e.scopedProjects.map(r=>`- ${r}`)),t.push(""),t.join(`
|
|
5
|
+
`)}async function Gt(e){let t=s.resolve(e.workspacePath),r=[];for(let n of e.skills){let i=gr[n.skillId];if(!i)continue;let c=s.join(t,i);if(!await h$1.pathExists(c))continue;let m=await h$1.readFile(c,"utf8"),a=mr(n),k=m.includes(Je)?m.replace(new RegExp(`${Je}[\\s\\S]*$`),a.trimEnd()):`${m.trimEnd()}
|
|
6
|
+
|
|
7
|
+
${a}`;e.write&&await h$1.writeFile(c,`${k.trimEnd()}
|
|
8
|
+
`,"utf8"),r.push(i);}return r}var fr="workspai-agent-customization-pack-capabilities.v1";function $t(){return {schemaVersion:fr,presets:{minimal:{meaning:"Generate the portable grounding index, AGENTS.md, and provider-specific lightweight instructions.",requiredOutputs:[p.agentIndex,p.agentCustomizationPack,p.agents]},enterprise:{meaning:"Generate the full VS Code-native pack: instructions, prompts, skills, custom agents, and validation metadata.",requiredOutputs:[p.agentIndex,p.agentCustomizationPack,p.agents,w,A,M,".github/agents/workspai-advisor.agent.md",S,b$2]}},targets:{all:{meaning:"Generate every supported customization surface.",outputFamilies:["portable","vscode","copilot","cursor","claude","gemini","qwen","kimi","grok","windsurf","amazon-q"]},vscode:{meaning:"Generate VS Code-native customizations for Copilot Chat and agent workflows.",outputFamilies:["instructions","prompts","skills","agents","hooks"]},agents:{meaning:"Generate portable AGENTS.md grounding and .agents/skills projections.",outputFamilies:["portable","skills"]},copilot:{meaning:"Generate GitHub Copilot instructions, prompts, and skills.",outputFamilies:["instructions","prompts","skills"]},cursor:{meaning:"Generate Cursor rules.",outputFamilies:["rules"]},claude:{meaning:"Generate Claude Code grounding files.",outputFamilies:["rules","portable"]},codex:{meaning:"Use AGENTS.md and the report index as the Codex grounding layer.",outputFamilies:["portable"]},gemini:{meaning:"Generate Gemini CLI grounding through GEMINI.md and canonical AGENTS.md.",outputFamilies:["adapter","portable"]},qwen:{meaning:"Generate Qwen Code grounding through QWEN.md and canonical AGENTS.md.",outputFamilies:["adapter","portable"]},kimi:{meaning:"Use AGENTS.md and the report index as the Kimi Code grounding layer.",outputFamilies:["portable"]},grok:{meaning:"Use AGENTS.md and the report index as the xAI Grok grounding layer.",outputFamilies:["portable"]},windsurf:{meaning:"Use AGENTS.md and the report index as the Windsurf grounding layer.",outputFamilies:["portable"]},"amazon-q":{meaning:"Generate an Amazon Q project rule that routes agents to canonical evidence.",outputFamilies:["rules","portable"]},orca:{meaning:"Legacy compatibility alias for AGENTS.md consumers; prefer the grok target.",outputFamilies:["portable"]}},standardAnswerContract:[...pe],requiredReports:J.map(e=>({path:e.relativePath,label:e.label,required:e.required})),strictRules:["Required reports must exist.","Generated report paths must stay inside the workspace root.","Generated customization text must be English-only.","Agent answers must not claim pass, ready, or healthy without cited evidence.","Commands must distinguish display guidance from execution requests.","Agent hook files must be advisory and disabled by default unless the user explicitly enables them.","MCP design artifacts must stay read-mostly until write tools have explicit approval boundaries."],outputKinds:["report","grounding","instruction","prompt","skill","skill-resource","operational-skill","skills-index","explain-report","agent","rule","hook","mcp-design"],pathLayers:{l1CanonicalRoots:[".workspai/reports/",`${a$3}/`],l2PrefixedMirrorRoots:[".agents/",".github/",".cursor/",".claude/",".amazonq/"],l3SharedIndustryFiles:["AGENTS.md",".github/copilot-instructions.md","CLAUDE.md","GEMINI.md","QWEN.md"]}}}var kr=q.agentIndex,hr=q.agentCustomizationPack,X=p.agentIndex,Y=p.agentCustomizationPack;var J=[{relativePath:t.goalIndex,label:"Active Goal Pack index",required:false},{relativePath:t.goalPackLastRun,label:"Latest governed Goal Pack",required:false},{relativePath:b$1,label:"Agent context pack",required:true},{relativePath:b$2,label:"Operational skills index",required:true},{relativePath:p.model,label:"Workspace model",required:false},{relativePath:p.knowledgeGraph,label:"Workspace knowledge graph",required:false},{relativePath:p.evaluationLastRun,label:"Workspace Intelligence evaluation",required:false},{relativePath:p.doctor,label:"Workspace doctor",required:false},{relativePath:t.doctorProject,label:"Project doctor",required:false},{relativePath:t.doctorRemediationPlan,label:"Doctor remediation plan",required:false},{relativePath:t.artifactRemediationPlan,label:"Artifact remediation plan",required:false},{relativePath:t.doctorFixResult,label:"Doctor fix result",required:false},{relativePath:p.analyze,label:"Workspace analyze",required:false},{relativePath:t.pipelineLastRun,label:"Governance pipeline",required:false},{relativePath:p.readiness,label:"Release readiness",required:false},{relativePath:p.impact,label:"Workspace impact",required:false},{relativePath:p.verify,label:"Workspace verify",required:false},{relativePath:p.snapshot,label:"Workspace model snapshot",required:false},{relativePath:p.diff,label:"Workspace model diff",required:false},{relativePath:p.explain,label:"Workspace explain",required:false},{relativePath:p.contractVerify,label:"Workspace contract verify",required:false},{relativePath:p.history,label:"Workspace intelligence history",required:false}];function wr(){let e=J.map(r=>r.relativePath),t=b$3().consumers.agents.canonicalReadOrder;return [...new Set(t.filter(r=>r!==X&&e.includes(r)))]}async function Ar(e){try{let{contract:t}=await p$1({workspacePath:e});if(t?.workspace?.name)return `workspace:${t.workspace.name}`}catch{}for(let t of [".workspai/workspace.json",".rapidkit/workspace.json"])try{let r=await h$1.readJson(s.join(e,t)),n=typeof r.workspace_name=="string"?r.workspace_name:typeof r.name=="string"?r.name:null;if(n?.trim())return `workspace:${n.trim()}`}catch{}return `workspace:${s.basename(s.resolve(e))}`}function P(e){return `npx workspai ${e}`.trim()}function rt(e){return e&&typeof e=="object"?e:null}function Ye(e,t=12){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0).slice(0,t):[]}function yr(e){let t=Ye(e.blockers,12);if(t.length>0)return t;let r=Ye(e.blockingReasons,12);if(r.length>0)return r;let n=rt(e.summary);return n&&Array.isArray(n.blockingReasons)?Ye(n.blockingReasons,12):[]}function Rr(e){let t=[...new Set(e.map(r=>r.trim()).filter(Boolean))];return t.filter(r=>{let n=r.toLowerCase();return !t.some(i=>{if(i===r||!i.includes(":"))return false;let c=i.toLowerCase();return c.length>n.length&&c.endsWith(n)})})}function br(e){for(let t of ["generatedAt","updatedAt","timestamp"]){let r=e[t];if(typeof r=="string"&&r.trim())return r.trim()}if(Array.isArray(e.entries)){let t=e.entries.map(r=>rt(r)?.generatedAt).filter(r=>typeof r=="string"&&r.trim().length>0).map(r=>r.trim()).filter(r=>Number.isFinite(Date.parse(r)));if(t.length>0)return t.reduce((r,n)=>Date.parse(n)>Date.parse(r)?n:r)}}function Pr(e,t,r){if(!e)return true;let n=Date.parse(e);return Number.isFinite(n)?r.getTime()-n>t*60*60*1e3:true}function vr(e,t,r){return e.path===p.snapshot?false:Pr(e.generatedAt,t,r)}function Sr(e){let t=e&&e.length>0?e:["all"];return t.includes("all")?new Set(["all","vscode","agents","copilot","cursor","claude","codex","gemini","qwen","kimi","grok","windsurf","amazon-q","orca"]):new Set(t)}function b(e,t){return e.has("all")||e.has(t)}function Ft(e){return b(e,"copilot")||b(e,"vscode")}function Xe(e){return b(e,"agents")||b(e,"codex")||b(e,"kimi")||b(e,"grok")||b(e,"orca")}function Er(e,t){return t==="generic"?b(e,"agents"):t==="copilot"?Ft(e):t==="grok"?b(e,"grok")||b(e,"orca"):b(e,t)}function Ir(e){return e??"enterprise"}function Cr(e){return e===b$2?"skills-index":e.includes("workspace-explain-last-run.json")?"explain-report":(e.startsWith(`${a$3}/`)||e.startsWith(".rapidkit/skills/"))&&e.endsWith(".md")?"operational-skill":e.includes("hooks")||e===U||e===V?"hook":e.includes("mcp")||e===S||e===T?"mcp-design":e.endsWith(".json")?"report":e.includes("/instructions/")||e.endsWith("copilot-instructions.md")?"instruction":e.includes("/prompts/")?"prompt":e.includes("/skills/")&&e.endsWith("/SKILL.md")?"skill":e.includes("/skills/")?"skill-resource":e.includes("/agents/")?"agent":e.includes("/rules/")||e.endsWith(".mdc")?"rule":"grounding"}function xr(e){return e.startsWith(".github/")?["vscode","copilot"]:e.startsWith(".cursor/")?["cursor"]:e.startsWith(".claude/")||e==="CLAUDE.md"?["claude"]:e==="GEMINI.md"?["gemini"]:e==="QWEN.md"?["qwen"]:e.startsWith(".amazonq/")?["amazon-q"]:e===".windsurfrules"||e.startsWith(".windsurf/")?["windsurf"]:e.startsWith(".grok/")?["grok"]:e.startsWith(".agents/")?["agents","codex","kimi","grok","orca"]:e==="AGENTS.md"||e.startsWith(".rapidkit/")?["agents","codex","kimi","grok","copilot","cursor","claude","gemini","qwen","amazon-q","windsurf","orca","vscode"]:e.startsWith(".vscode/")?["vscode"]:["agents"]}function Dt(e){return [{target:"agents",path:`.agents/skills/${e}/SKILL.md`},{target:"copilot",path:`.github/skills/${e}/SKILL.md`},{target:"claude",path:`.claude/skills/${e}/SKILL.md`},{target:"cursor",path:`.cursor/skills/${e}/SKILL.md`},{target:"grok",path:`.grok/skills/${e}/SKILL.md`}]}async function Or(e,t){let r=s.join(e,t);!await h$1.pathExists(r)||!(await h$1.readFile(r,"utf8")).includes(B)||await h$1.remove(r);}function Tr(e,t){return $t().presets[t].requiredOutputs.includes(e)}async function _r(e,t){if(t)return t;let r=await g(e,l$2)??s.join(e,l$2);if(await h$1.pathExists(r))try{let n=await h$1.readJson(r);return b$6(l$2,n,r),n}catch{}return q$1({workspacePath:e,includeEvidence:true})}async function Wr(e,t){let r=await g(e,p.knowledgeGraph);if(!r)return null;try{let n=await h$1.readJson(r);b$6(p.knowledgeGraph,n,r);let i=n;return i.proofs.some(c=>c.freshness==="stale")?null:(b$7(i,t),i)}catch{return null}}function jr(e){return e.length>0&&!s.isAbsolute(e)&&!e.split(/[\\/]+/).includes("..")}function Nr(e){return Object.fromEntries(["all","vscode","agents","copilot","cursor","claude","codex","gemini","qwen","kimi","grok","windsurf","amazon-q","orca"].map(r=>[r,{enabled:e.targets.includes("all")||e.targets.includes(r),outputs:e.outputs.filter(n=>n.targets.includes(r)).map(n=>n.path).sort()}]))}async function Lr(e,t){try{if(!await h$1.pathExists(e))return {payload:null,exists:false,validity:"missing"};let r=await h$1.readJson(e),n=rt(r);return n?a$2(t)?(b$6(t,n,e),{payload:n,exists:true,validity:"valid"}):{payload:n,exists:true,validity:"uncontracted"}:{payload:null,exists:true,validity:"invalid",validationError:"Artifact root must be a JSON object"}}catch(r){return {payload:null,exists:true,validity:"invalid",validationError:r instanceof Error?r.message:String(r)}}}async function Kt(e){let t=e.now??new Date,r=e.staleAfterHours??24,n=[],i=[];for(let a of J){let k=await g(e.workspacePath,a.relativePath)??s.join(e.workspacePath,a.relativePath),l=await Lr(k,a.relativePath),p=l.payload;l.validity==="invalid"?i.push(`Invalid evidence contract: ${a.relativePath}`):p&&i.push(...yr(p)),n.push({path:a.relativePath,label:a.label,required:a.required,exists:l.exists,validity:l.validity,validationError:l.validationError,generatedAt:p?br(p):void 0,commandId:typeof p?.commandId=="string"?p.commandId:void 0,exitCode:typeof p?.exitCode=="number"?p.exitCode:void 0});}let c=Rr(i).slice(0,16),m=b$3();return {schemaVersion:kr,generatedAt:t.toISOString(),workspaceRoot:await Ar(e.workspacePath),intelligenceChain:{schemaVersion:m.schemaVersion,contractPath:m.contractPath,currentStep:"agent-sync"},readOrder:wr(),blockers:c,staleAfterHours:r,reports:n,refreshCommand:P("workspace agent-sync --write --refresh-context")}}function Gr(e){let t$1=["# Workspai agent grounding","","Cross-tool instructions for Copilot, Cursor, Claude Code, Codex, Grok, and other agents.","","## Read order (mandatory before workspace diagnosis)","",`1. \`${p.agentIndex}\` \u2014 latest blockers, timestamps, and report paths`,`2. \`${t.goalIndex}\` \u2014 when present, read the active Goal Pack and its handoff before choosing work.`,`3. \`${p.agentContext}\` \u2014 read only task-relevant context`,`4. \`${p.skillsIndex}\` \u2014 select only the Skill that matches the task.`,"5. Read only the task-relevant evidence artifacts listed in the index.","6. Use the Goal Pack retrieval queries, `workspace graph search <query> --limit 12 --json`, or MCP `searchWorkspaceGraph` before loading the full graph.","","Do **not** full-repo scan or inject the complete graph when a bounded query can answer the task.","","## Proof-carrying mutations","","For source-changing work, use the active Goal Pack command `beginChange` before the first mutation.","Prediction is planning input, never proof. Execute only explicitly authorized effect classes, record typed effect receipts, then run `workspai change verify --change <id> --json`.","A task is not complete until its capsule is sealed or its remaining uncertainty is reported.","","## Regenerate intelligence","","```bash",P("workspace agent-sync --write --refresh-context"),P("workspace context --for-agent --json --write"),P("pipeline --json --write"),"```",""];if(e.index.blockers.length>0){t$1.push("## Current blockers","");for(let r of e.index.blockers.slice(0,12))t$1.push(`- ${r}`);t$1.push("");}if(e.context?.safeCommands?.length){t$1.push("## Safe commands (prefer these)","");for(let r of e.context.safeCommands.slice(0,10))t$1.push(`- \`${r.display}\` \u2014 ${r.description}`);t$1.push("");}return t$1.push("## Rules","","- Treat `.workspai/reports/*` as the source of truth for health, gates, and release posture.","- Prefer deterministic Workspai CLI commands over heuristic framework guesses.","- If evidence is missing or stale, run the refresh commands above before proposing fixes.","- Keep project-scoped advice aligned with the active project named in the context pack.","- Never claim that an active goal is satisfied until its CLI-owned verification lifecycle is `verified`.",""),t$1.join(`
|
|
9
|
+
`)}function $r(e){return ["# Workspai agent grounding","",`Generated: ${e.generatedAt}`,"",`This file is tool-agnostic. Synced agents should read it together with \`${p.agentIndex}\`.`,"","## Mandatory read order","",...e.readOrder.map((t,r)=>`${r+1}. \`${t}\``),"",e.blockers.length>0?"## Blockers":"",...e.blockers.length>0?e.blockers.map(t=>`- ${t}`):[],"","## Refresh","","```bash",e.refreshCommand,"```",""].filter(t=>t!=="").join(`
|
|
10
|
+
`)}function Dr(){return ["# Workspai workspace grounding","","Before answering workspace, release, or architecture questions:","","1. Read `AGENTS.md` (managed Workspai section).",`2. Read \`${p.agentIndex}\` and only task-relevant context from \`${p.agentContext}\`.`,"3. Use bounded `workspace graph search` or MCP `searchWorkspaceGraph` before scanning the full repository.","","Regenerate stale intelligence:","","```bash",P("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
11
|
+
`)}function Kr(){return ["## Claude Code","",`- Load \`${p.agentIndex}\` before diagnosing blockers.`,"- Use `.claude/rules/workspai-evidence.md` for scoped Workspai evidence rules.","- Treat `.claude/rules/rapidkit-evidence.md` as a legacy compatibility mirror.","- Refresh grounding with `npx workspai workspace agent-sync --write`.",""].join(`
|
|
12
|
+
`)}function Qe(e){return [`## ${e}`,"","- Treat `AGENTS.md` as the portable workspace instruction authority.",`- Load \`${p.agentIndex}\` before diagnosing blockers or architecture.`,`- Read only task-relevant context from \`${p.agentContext}\`.`,"- Use bounded Workspace Knowledge Graph search before broad source discovery.","- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","- Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","- Refresh grounding with `workspai workspace agent-sync --write --refresh-context`.",""].join(`
|
|
13
|
+
`)}function qr(){return ["---","description: Workspai workspace evidence and intelligence grounding","globs: []","alwaysApply: true","---","","# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Read order","",`1. Read \`${p.agents}\` and \`${p.agentIndex}\`.`,`2. Read only task-relevant context from \`${p.agentContext}\`.`,"3. Prefer bounded graph search and evidence reports over full-repo exploration.","","## Scope rules","",`- Start from \`${p.agentIndex}\`; read only task-relevant context and evidence.`,"- Distinguish workspace-level blockers from project-level blockers.","- When a project is active, cite its name, path, framework, and evidence source.","- Do not translate unsupported stack requests into unrelated native kits.","","## Intelligent loop","","When applying changes, follow the full repair loop:","","1. Discover \u2014 read bounded workspace context, select a matching Skill, and query the graph for the task.","2. Inspect \u2014 read relevant evidence and source files.","3. Patch \u2014 apply changes through the CLI-owned repair transaction.","4. Verify \u2014 run verification to confirm workspace health.","5. Complete \u2014 only after verified evidence confirms success.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh when stale","","```bash",P("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
14
|
+
`)}function Mr(){return ["---","description: Workspai evidence artifact discipline",'globs: [".workspai/**", "**/.workspai/**", ".rapidkit/**", "**/.rapidkit/**"]',"alwaysApply: false","---","","When reading or editing `.workspai/` or legacy `.rapidkit/` artifacts:","",`- Start from \`${p.agentIndex}\` for read order and active blockers.`,"- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","- JSON files (.json) require strictly valid JSON. Never include comments, trailing commas, or non-standard syntax.","","Regenerate evidence:","","```bash",P("workspace intelligence run"),"```",""].join(`
|
|
15
|
+
`)}function nt(e){return ["---",`description: ${e.description}`,`globs: ${e.globs}`,"alwaysApply: false","---","",e.objective,"","Read first:","",`- \`${p.agentIndex}\``,`- \`${p.agentContext}\``,"- Any report referenced by the current blocker or task","","Steps:","",...e.steps.map((t,r)=>`${r+1}. ${t}`),"","Use the standard Workspai answer contract: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.",""].join(`
|
|
16
|
+
`)}function Hr(){return nt({description:"Diagnose Workspai workspace blockers from evidence reports",globs:"[]",objective:"Diagnose this workspace using Workspai evidence only.",steps:["Root cause grounded in report blockers","Smallest safe fix path (commands + file edits)","One verification command to prove recovery"]})}function Ur(){return nt({description:"Repair Workspai blockers with evidence and verification",globs:"[]",objective:"Plan the smallest safe repair for the current Workspai blocker.",steps:["Blocker and affected workspace/project scope","Evidence paths and exact failing signals","Minimal fix plan","Human-run commands","Verification command and expected success signal"]})}function Fr(){return nt({description:"Assess Workspai release readiness from evidence",globs:"[]",objective:"Assess whether this workspace is release-ready using Workspai gates.",steps:["Readiness verdict with cited reports","Blocking gates","Safe next command","Verification checklist"]})}function Vr(){return ["---","trigger: always_on","description: Workspai workspace evidence and intelligence grounding","---","","# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Read order","",`1. \`${p.agents}\` and \`${p.agentIndex}\`.`,`2. Only task-relevant context from \`${p.agentContext}\`.`,"3. Prefer bounded graph search and evidence reports over full-repo exploration.","","## Scope rules","",`- Start from \`${p.agentIndex}\`; read only task-relevant context.`,"- Distinguish workspace-level blockers from project-level blockers.","- When a project is active, cite its name, path, framework, and evidence source.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh when stale","","```bash",P("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
17
|
+
`)}function zr(){return ["---","trigger: glob","description: Workspai evidence artifact discipline",'globs: [".workspai/**", ".rapidkit/**"]',"---","","When reading or editing `.workspai/` or legacy `.rapidkit/` artifacts:","",`- Start from \`${p.agentIndex}\` for read order and active blockers.`,"- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","- JSON files (.json) require strictly valid JSON. No comments, no trailing commas.",""].join(`
|
|
18
|
+
`)}function Br(){return ["# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Read order","",`1. \`${p.agents}\` and \`${p.agentIndex}\`.`,`2. Only task-relevant context from \`${p.agentContext}\`.`,"3. Prefer bounded graph search and evidence reports over full-repo exploration.","","## Scope rules","",`- Start from \`${p.agentIndex}\`; read only task-relevant context.`,"- Distinguish workspace-level blockers from project-level blockers.","- When a project is active, cite its name, path, framework, and evidence source.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh when stale","","```bash",P("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
19
|
+
`)}function Jr(){return ["# Workspai evidence artifact discipline","","Applies when reading or editing `.workspai/` or legacy `.rapidkit/` artifacts.","",`- Start from \`${p.agentIndex}\` for read order and active blockers.`,"- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","- JSON files (.json) require strictly valid JSON. No comments, no trailing commas.","","Regenerate evidence:","","```bash",P("workspace intelligence run"),"```",""].join(`
|
|
20
|
+
`)}function Yr(){return ["# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Read order","",`1. \`${p.agents}\` and \`${p.agentIndex}\`.`,`2. Only task-relevant context from \`${p.agentContext}\`.`,"3. Prefer bounded graph search and evidence reports over full-repo exploration.","","## Scope rules","",`- Start from \`${p.agentIndex}\`; read only task-relevant context.`,"- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.",""].join(`
|
|
21
|
+
`)}function Xr(){return ["# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Read order","",`1. \`${p.agents}\` and \`${p.agentIndex}\`.`,`2. Only task-relevant context from \`${p.agentContext}\`.`,"3. Prefer bounded graph search and evidence reports over full-repo exploration.","","## Scope rules","",`- Start from \`${p.agentIndex}\`; read only task-relevant context.`,"- Distinguish workspace-level blockers from project-level blockers.","- When a project is active, cite its name, path, framework, and evidence source.","- Do not translate unsupported stack requests into unrelated native kits.","","## Evidence discipline","","- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","- JSON files (.json) require strictly valid JSON. No comments, no trailing commas.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh when stale","","```bash",P("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
22
|
+
`)}function Qr(){return ["# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Read order","",`1. \`${p.agents}\` and \`${p.agentIndex}\`.`,`2. Only task-relevant context from \`${p.agentContext}\`.`,"3. Prefer bounded graph search and evidence reports over full-repo exploration.","","## Scope rules","",`- Start from \`${p.agentIndex}\`; read only task-relevant context and evidence.`,"- Distinguish workspace-level blockers from project-level blockers.","- When a project is active, cite its name, path, framework, and evidence source.","","## Intelligent loop","","When applying changes, follow the full repair loop:","","1. Discover \u2014 read bounded workspace context, select a matching Skill, and query the graph for the task.","2. Inspect \u2014 read relevant evidence and source files.","3. Patch \u2014 apply changes through the CLI-owned repair transaction.","4. Verify \u2014 run verification to confirm workspace health.","5. Complete \u2014 only after verified evidence confirms success.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh when stale","","```bash",P("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
23
|
+
`)}function Zr(){return ["---",'applyTo: ".workspai/**,**/.workspai/**,.rapidkit/**,**/.rapidkit/**"',"description: Workspai evidence and intelligence artifacts","---","","When working under `.workspai/` or legacy `.rapidkit/`:","","- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.",`- Start from \`${p.agentIndex}\` for read order and blockers.`,"- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.",""].join(`
|
|
24
|
+
`)}function en(){return ["---",'applyTo: "**"',"description: Workspai workspace scope, evidence, and command discipline","---","","# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Scope rules","",`- Start from \`${p.agentIndex}\`; read only task-relevant context and evidence.`,"- Prefer bounded `workspace graph search` or MCP `searchWorkspaceGraph` over loading the complete graph.","- Distinguish workspace-level blockers from project-level blockers.","- When a project is active, cite its name, path, framework, and evidence source.","- Do not translate unsupported stack requests into unrelated native kits.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.",""].join(`
|
|
25
|
+
`)}function tn(){return ["---","paths:",' - ".workspai/**"',' - ".rapidkit/**"',"---","","# Workspai evidence","","When reading or editing `.workspai/` or legacy `.rapidkit/` artifacts:","",`- Start from \`${p.agentIndex}\` for read order and active blockers.`,"- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","- JSON files (.json) require strictly valid JSON. No comments, no trailing commas.","","Regenerate evidence:","","```bash",P("workspace intelligence run"),"```",""].join(`
|
|
26
|
+
`)}function rn(){return ["# Legacy RapidKit evidence alias","","Compatibility path only. Use `.claude/rules/workspai-evidence.md` as the canonical rule.",""].join(`
|
|
27
|
+
`)}function nn(){return ["---","description: Legacy RapidKit metadata compatibility alias",'globs: [".rapidkit/**", "**/.rapidkit/**"]',"alwaysApply: false","---","","Use `.cursor/rules/workspai-grounding.mdc` for canonical Workspai grounding.",""].join(`
|
|
28
|
+
`)}function qt(e){return ["---",'applyTo: ".rapidkit/**,**/.rapidkit/**"',"description: Legacy RapidKit metadata compatibility alias","---","",`Use \`.github/instructions/workspai-${e}.instructions.md\` as the canonical Workspai instruction.`,""].join(`
|
|
29
|
+
`)}function Mt(){return ["---","description: Diagnose Workspai workspace blockers from evidence reports","---","","Diagnose this workspace using Workspai evidence only.","","Read:","",`- \`${p.agentIndex}\``,`- \`${p.agentContext}\``,"- Any fail/warn reports referenced in the index","","Return:","","1. Root cause grounded in report blockers","2. Smallest safe fix path (commands + file edits)","3. One verification command to prove recovery",""].join(`
|
|
30
|
+
`)}function ge(e){return ["---",`description: ${e.description}`,"---","",e.objective,"","Read first:","",`- \`${p.agentIndex}\``,`- \`${p.agentContext}\``,"- Any report referenced by the current blocker or task","","Return:","",...e.expectedOutput.map((t,r)=>`${r+1}. ${t}`),"","Use the standard Workspai answer contract: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.",""].join(`
|
|
31
|
+
`)}function D(e){return ["# "+e.title,"",...e.lines,""].join(`
|
|
32
|
+
`)}function an(){return D({title:"MCP Tool Design",lines:["Workspai MCP is a read-mostly bridge over contract-validated workspace artifacts.","","Served read tools:",`- \`getWorkspaceModel\` \u2014 read \`${p.model}\`.`,`- \`getWorkspaceKnowledgeGraph\` \u2014 read \`${p.knowledgeGraph}\`.`,`- \`getWorkspaceEvaluation\` \u2014 read \`${p.evaluationLastRun}\` (or the live evaluation when requested).`,"- `queryWorkspaceEntities` \u2014 filter proof-backed graph entities by kind.","- `searchWorkspaceGraph` \u2014 retrieve bounded proof-backed context by text query.","- `getWorkspaceGraphEvidence` \u2014 resolve evidence for an entity or relation.","- `findWorkspaceGraphPath` \u2014 find a shortest proof-carrying relationship path.",`- \`getEvidenceIndex\` \u2014 read \`${p.agentIndex}\`.`,"- `getBlockers` \u2014 derive current blockers from INDEX and gate reports.","- `getSafeCommands` \u2014 read safe commands from `workspace-context-agent.json`.","- `getProjectContext` \u2014 return one project-scoped slice of the workspace model.","- `getArtifact` \u2014 read one explicit artifact path inside the workspace root.",`- \`listOperationalSkills\` \u2014 read \`${p.skillsIndex}\`.`,"- `getWorkspaceExplain` \u2014 read/build workspace explain for release-blocked or project scope.","- `listProofCarryingChanges` \u2014 list change lifecycle, assurance, blockers, and integrity.","- `getProofCarryingChange` \u2014 inspect one ledger-derived change capsule.","- `validateProofCarryingChange` \u2014 replay and validate one capsule and its evidence bindings.","","Planned, not served:","- `refreshWorkspaceIntelligence` \u2014 requires an explicit approval boundary before it can become an MCP write tool.","","The server supports legacy initialize-era clients and the 2026-07-28 stateless discovery era. Tool results include text plus structured content; actionable execution failures are returned as tool errors."]})}function on(e){return `${JSON.stringify({schemaVersion:s$2.workspaiMcpDesign.schemaVersion,generatedAt:e.generatedAt,workspaceRoot:e.workspaceRef,status:"implemented",mode:"read-mostly",runtime:{command:P("workspace mcp serve"),transport:"stdio-jsonrpc",lifecycle:"dual-era",supportedProtocolVersions:["2024-11-05","2025-03-26","2025-06-18","2025-11-25","2026-07-28"],structuredContent:true,toolExecutionErrors:true},safety:{writeToolsEnabled:false,approvalRequiredForRefresh:true,artifactReadsMustStayInsideWorkspace:true},candidateTools:[{name:"getWorkspaceModel",reads:[p.model],mutates:false},{name:"getWorkspaceKnowledgeGraph",reads:[p.knowledgeGraph],mutates:false},{name:"getWorkspaceEvaluation",reads:[p.evaluationLive,p.evaluationLastRun],mutates:false},{name:"queryWorkspaceEntities",reads:[p.knowledgeGraph],mutates:false},{name:"searchWorkspaceGraph",reads:[p.knowledgeGraph],mutates:false},{name:"getWorkspaceGraphEvidence",reads:[p.knowledgeGraph],mutates:false},{name:"findWorkspaceGraphPath",reads:[p.knowledgeGraph],mutates:false},{name:"getEvidenceIndex",reads:[p.agentIndex],mutates:false},{name:"getBlockers",reads:[p.agentIndex,p.verify,t.pipelineLastRun],mutates:false},{name:"getSafeCommands",reads:[p.agentContext],mutates:false},{name:"getProjectContext",reads:[p.model,p.agentContext],mutates:false},{name:"getArtifact",reads:["requested workspace-relative artifact path"],mutates:false},{name:"listOperationalSkills",reads:[p.skillsIndex],mutates:false},{name:"getWorkspaceExplain",reads:[p.explain,p.verify,p.impact],mutates:false},{name:"listProofCarryingChanges",reads:[".workspai/changes/*",".workspai/decisions/*"],mutates:false},{name:"getProofCarryingChange",reads:[".workspai/changes/<change-id>/*",".workspai/decisions/<change-id>/*"],mutates:false},{name:"validateProofCarryingChange",reads:[".workspai/changes/<change-id>/*",".workspai/decisions/<change-id>/*","capsule-referenced evidence artifacts"],mutates:false}],plannedTools:[{name:"refreshWorkspaceIntelligence",command:P("workspace agent-sync --write --refresh-context"),mutates:true,approvalRequired:true,availability:"not-served"}]},null,2)}
|
|
33
|
+
`}function sn(e){return `${JSON.stringify({schemaVersion:s$2.agentHooks.schemaVersion,generatedAt:e.generatedAt,workspaceRoot:e.workspaceRef,enabledByDefault:false,mode:"advisory",hooks:[{name:"workspai-pre-tool-use-workspace-boundary",event:"PreToolUse",purpose:"Block or warn on state-changing commands outside the active workspace root.",defaultAction:"warn",rules:["Allow read-only commands.","Warn before write/delete commands outside workspaceRoot.","Never run destructive commands without explicit user approval."]},{name:"workspai-post-tool-use-verify-suggestion",event:"PostToolUse",purpose:"Suggest non-destructive verification commands after edits.",defaultAction:"suggest",commands:[P("doctor workspace"),P("workspace verify --strict --json")]},{name:"workspai-user-prompt-submit-scope-hint",event:"UserPromptSubmit",purpose:"Inject lightweight workspace scope and evidence index hints.",defaultAction:"inject-context-hint",reads:[p.agentIndex,p.agentContext]}]},null,2)}
|
|
34
|
+
`}function Ht(e){let t=["---","name: workspai-workspace-intelligence","description: Use Workspai workspace intelligence reports to answer, repair, verify, and release with evidence","---","","# Workspai Workspace Intelligence","","Use this skill for workspace architecture, project lifecycle, blocker repair, release readiness, agent grounding, and CI evidence questions.","","## Decision flow","","1. Load `resources/scope-model.md`.",`2. Load \`${p.agentIndex}\`.`,`3. Load \`${p.agentContext}\`.`,`4. Load \`${p.skillsIndex}\` when operational playbooks are needed.`,"5. Load the smallest evidence report required for the task.","6. Answer with Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Rules","","- Prefer Workspai reports over full-repo scans.","- Never claim a gate passed without a cited report.","- Separate display commands from execution requests.","- Keep project-scoped fixes inside the active project unless workspace evidence says otherwise.",""];return e?.trim()&&t.push(e.trim(),""),t.join(`
|
|
35
|
+
`)}function me(e){return ["---",`name: ${e.name}`,`description: ${e.description}`,`tools: [${e.tools.map(t=>`'${t}'`).join(", ")}]`,"---","",`You are the ${e.name} agent for Workspai Workspace Intelligence.`,"",`Mode: ${e.mode}.`,"",`Start every task by reading \`${p.agentIndex}\` and \`${p.agentContext}\`.`,"","Use this answer contract:","","- Scope","- Evidence","- Diagnosis","- Fix Plan","- Run","- Verify","- Assumptions","","Do not invent health, readiness, or policy status. Cite report paths and command outputs.",""].join(`
|
|
36
|
+
`)}function $(e){let t=["---","name: workspai-grounding","description: Load Workspai workspace intelligence reports before diagnosing or changing code","---","","<!-- WORKSPAI:GENERATED-PORTABLE-SKILL -->","","# Workspai grounding","","Use when the user asks about workspace health, release gates, doctor/pipeline failures, or project structure.","","## Workflow","",`1. Read \`${p.agentIndex}\``,`2. Read \`${p.agentContext}\``,"3. Read fail/warn evidence artifacts listed in the index","4. Propose the smallest safe fix with explicit verification commands",""],r=e.model?.projects?.map(n=>n.name||n.slug).filter(Boolean).slice(0,10);if(r&&r.length>0){t.push("## Projects in this workspace","");for(let n of r)t.push(`- ${n}`);t.push("");}if(e.index.blockers.length>0){t.push("## Current blockers","");for(let n of e.index.blockers.slice(0,8))t.push(`- ${n}`);t.push("");}if(e.context?.safeCommands?.length){t.push("## Safe commands (prefer these)","");for(let n of e.context.safeCommands.slice(0,6))t.push(`- \`${n.display}\` \u2014 ${n.description}`);t.push("");}return t.push("## Rules","","- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","- Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh stale evidence","","```bash",P("workspace agent-sync --write --refresh-context"),"```",""),t.join(`
|
|
37
|
+
`)}async function f(e,t,r){return r?(await h$1.ensureDir(s.dirname(e)),await h$1.writeFile(e,t,"utf8"),"written"):"skipped"}async function Ut(e){if(!e.write)return "skipped";let t=s.join(e.workspacePath,e.relativePath),r=await fe(e.workspacePath,t);if(await h$1.pathExists(r)){let n=await h$1.readFile(r,"utf8");if(!(n.includes(B)||n.includes("<!-- WORKSPAI:GENERATED-PORTABLE-SKILL -->")||n.includes("name: workspai-grounding")&&n.includes("# Workspai grounding")&&n.includes("workspace agent-sync --write --refresh-context")))return "skipped"}return await h$1.ensureDir(s.dirname(r)),await h$1.writeFile(r,e.content,"utf8"),"written"}async function Ze(e){if(!e.write)return "skipped";await fe(e.workspacePath,e.absolutePath);let t=await h$1.pathExists(e.absolutePath)?await h$1.readFile(e.absolutePath,"utf8"):null,{upsertManagedAgentSection:r}=await import('./managed-agent-markers-COE5DJ3W.js'),n=r(t,e.generatedBody),i=e.preamble?`${e.preamble.trimEnd()}
|
|
38
|
+
|
|
39
|
+
${n}`:n;return await h$1.ensureDir(s.dirname(e.absolutePath)),await h$1.writeFile(e.absolutePath,i,"utf8"),"written"}async function et(e){if(!e.write)return "skipped";await fe(e.workspacePath,e.absolutePath);let t=await h$1.pathExists(e.absolutePath)?await h$1.readFile(e.absolutePath,"utf8"):"",{upsertManagedAgentSection:r}=await import('./managed-agent-markers-COE5DJ3W.js'),n=r(t,e.generatedBody),i=n.includes(e.importLine)?n:`${e.importLine}
|
|
40
|
+
|
|
41
|
+
${n}`;return await h$1.ensureDir(s.dirname(e.absolutePath)),await h$1.writeFile(e.absolutePath,i,"utf8"),"written"}async function fe(e,t){let r=s.resolve(e),n=await h$1.realpath(r).catch(()=>r),i=s.resolve(t),c=s.relative(r,i);if(!c||c===".."||c.startsWith(`..${s.sep}`)||s.isAbsolute(c))throw new Error("Agent output path must remain inside the canonical workspace.");let m=c.split(s.sep),a=r;for(let[k,l]of m.entries()){a=s.join(a,l);let p=await h$1.lstat(a).catch(R=>{if(R.code==="ENOENT")return null;throw R});if(!p)return s.join(a,...m.slice(k+1));let d=k===m.length-1;if(p.isSymbolicLink()){if(d)throw new Error(`Agent output path is blocked by authored repository state: ${c}`);let R=await h$1.realpath(a),w=s.relative(n,R),I=w!==".."&&!w.startsWith(`..${s.sep}`)&&!s.isAbsolute(w),K=await h$1.stat(R);if(!I||!K.isDirectory())throw new Error(`Agent output path is blocked by authored repository state: ${c}`);a=R;continue}if(d?!p.isFile():!p.isDirectory())throw new Error(`Agent output path is blocked by authored repository state: ${c}`)}return a}function aa(e){if(!e?.trim())return;let t=new Set(["all","vscode","agents","copilot","cursor","claude","codex","gemini","qwen","kimi","grok","windsurf","amazon-q","orca"]),r=e.split(",").map(n=>n.trim().toLowerCase()).filter(n=>t.has(n));return r.length>0?r:void 0}function cn(e){let t=[...e.outputs].sort((n,i)=>n.path.localeCompare(i.path)),r=b$3();return {schemaVersion:hr,generatedAt:e.generatedAt,workspaceRoot:e.workspaceRef,preset:e.preset,targets:[...e.targets].sort(),sourceReports:e.index.reports.filter(n=>n.exists).map(n=>n.path).sort(),intelligenceChain:{schemaVersion:r.schemaVersion,contractPath:r.contractPath,currentStep:"agent-sync"},outputInventory:t,capabilityMatrix:Nr({targets:e.targets,outputs:t}),drift:{missingRequired:e.missingRequired,staleReports:e.staleReports,strictViolations:e.strictViolations},answerContract:["Scope","Evidence","Diagnosis","Fix Plan","Run","Verify","Assumptions"],refreshCommand:P(`workspace agent-sync --write --refresh-context --preset ${e.preset}`),experimental:{hooksEnabled:e.experimentalHooks,mcpReady:t.some(n=>n.kind==="mcp-design")}}}async function tt(e){let t=s.resolve(e.workspacePath),r$1=e.now??new Date,n$1=e.staleAfterHours??24,i$1=Sr(e.targets),c$1=[...i$1].sort(),m=Ir(e.preset),a=e.write===true,k$1=e.strict===true,l$2,p=null,d$1=e.model;e.refreshContext&&(d$1??=await q$1({workspacePath:t,includeEvidence:true}),p=await c({workspacePath:t,model:d$1,agent:e.agent??"generic",scope:e.scope,includeEvidence:true}),a&&(l$2=await d(p,t)));let R$1=[],w$1=[],I$1=[],K$1=[],g=(u,A)=>{u==="written"?w$1.push(A):I$1.push(A),K$1.push({path:A,kind:Cr(A),targets:xr(A),required:Tr(A,m),status:u==="written"?"written":e.dryRun?"planned":"skipped"});},ke="",T$1=await _r(t,d$1),he=null;try{he=(await p$1({workspacePath:t})).contract;}catch{he=null;}let Vt=await Wr(t,T$1),at=jt({model:T$1,context:p,contract:he,graph:Vt}),zt=at.skills,Q$1=await Nt({workspacePath:t,skills:zt,generatedAt:r$1.toISOString(),write:a,decisions:at.decisions});for(let u of Q$1.skills){g(a?"written":"skipped",u.canonicalPath);for(let A of Dt(u.skillId))(A.target==="agents"?!Xe(i$1):!b(i$1,A.target))||g(await Ut({workspacePath:t,relativePath:A.path,content:u.markdown,write:a}),A.path);}for(let u of Q$1.removedSkillIds)for(let A of Dt(u))!(A.target==="agents"?Xe(i$1):b(i$1,A.target))||!a||await Or(t,A.path);g(a?"written":"skipped",b$2),ke=Lt(Q$1.index);let v$1=await Kt({workspacePath:t,staleAfterHours:n$1,now:r$1});if(g(await f(s.join(t,X),`${JSON.stringify(v$1,null,2)}
|
|
42
|
+
`,a),X),g(await f(s.join(t,f$2),`${$r(v$1)}
|
|
43
|
+
`,a),f$2),["agents","vscode","copilot","cursor","claude","codex","gemini","qwen","kimi","grok","windsurf","amazon-q","orca"].some(u=>b(i$1,u))&&g(await Ze({workspacePath:t,absolutePath:s.join(t,"AGENTS.md"),generatedBody:Gr({index:v$1,context:p}),write:a}),"AGENTS.md"),b(i$1,"claude")){let u$1=s.join(t,"CLAUDE.md");if(a){await fe(t,u$1);let{upsertManagedAgentSection:A}=await import('./managed-agent-markers-COE5DJ3W.js'),y=await h$1.pathExists(u$1)?await h$1.readFile(u$1,"utf8"):"",E=A(y,Kr()),_=E.includes("@AGENTS.md")?E:`@AGENTS.md
|
|
44
|
+
|
|
45
|
+
${E}`;await h$1.ensureDir(s.dirname(u$1)),await h$1.writeFile(u$1,_,"utf8"),w$1.push("CLAUDE.md");}else I$1.push("CLAUDE.md");g(await f(s.join(t,s$1),`${tn()}
|
|
46
|
+
`,a),s$1),g(await f(s.join(t,t$1),`${Qr()}
|
|
47
|
+
`,a),t$1),g(await f(s.join(t,u),`${rn()}
|
|
48
|
+
`,a),u),g(await f(s.join(t,P$1),$({index:v$1,context:p,model:T$1}),a),P$1);}if(b(i$1,"gemini")&&g(await et({workspacePath:t,absolutePath:s.join(t,"GEMINI.md"),importLine:"@./AGENTS.md",generatedBody:Qe("Gemini CLI"),write:a}),"GEMINI.md"),b(i$1,"qwen")&&g(await et({workspacePath:t,absolutePath:s.join(t,"QWEN.md"),importLine:"@AGENTS.md",generatedBody:Qe("Qwen Code"),write:a}),"QWEN.md"),b(i$1,"amazon-q")&&(g(await et({workspacePath:t,absolutePath:s.join(t,".amazonq/rules/workspai-agent-entry.md"),importLine:"@../../AGENTS.md",generatedBody:Qe("Amazon Q Developer"),write:a}),".amazonq/rules/workspai-agent-entry.md"),g(await f(s.join(t,v),Yr(),a),v)),b(i$1,"grok")&&(g(await f(s.join(t,q$2),Br(),a),q$2),g(await f(s.join(t,r),Jr(),a),r),g(await f(s.join(t,R),$({index:v$1,context:p,model:T$1}),a),R)),Xe(i$1)&&g(await Ut({workspacePath:t,relativePath:Q,content:$({index:v$1,context:p,model:T$1}),write:a}),Q),b(i$1,"windsurf")&&(g(await Ze({workspacePath:t,absolutePath:s.join(t,n),generatedBody:Xr(),write:a}),n),g(await f(s.join(t,o),Vr(),a),o),g(await f(s.join(t,p$2),zr(),a),p$2)),b(i$1,"cursor")&&(g(await f(s.join(t,h$2),qr(),a),h$2),g(await f(s.join(t,i),Mr(),a),i),g(await f(s.join(t,m$1),nn(),a),m$1),m==="enterprise"&&(g(await f(s.join(t,j),Hr(),a),j),g(await f(s.join(t,k),Ur(),a),k),g(await f(s.join(t,l),Fr(),a),l)),g(await f(s.join(t,O),$({index:v$1,context:p,model:T$1}),a),O)),Ft(i$1)){if(g(await Ze({workspacePath:t,absolutePath:s.join(t,".github/copilot-instructions.md"),generatedBody:Dr(),write:a}),".github/copilot-instructions.md"),g(await f(s.join(t,w),en(),a),w),g(await f(s.join(t,x),qt("workspace"),a),x),g(await f(s.join(t,y),Zr(),a),y),g(await f(s.join(t,z$1),qt("evidence"),a),z$1),g(await f(s.join(t,A),Mt(),a),A),g(await f(s.join(t,B$1),Mt(),a),B$1),m==="enterprise"){let u=[[C,ge({description:"Repair Workspai blockers with evidence and verification",objective:"Plan the smallest safe repair for the current Workspai blocker.",expectedOutput:["Blocker and affected workspace/project scope","Evidence paths and exact failing signals","Minimal fix plan","Human-run commands","Verification command and expected success signal"]})],[E,ge({description:"Assess Workspai release readiness from evidence",objective:"Assess whether this workspace is release-ready using Workspai gates.",expectedOutput:["Readiness verdict with cited reports","Blocking gates","Safe next command","Verification checklist"]})],[G,ge({description:"Onboard a project into Workspai Workspace Intelligence",objective:"Guide project onboarding using workspace model and create planner capabilities.",expectedOutput:["Target project scope","Native create, official generator, or existing lane","Safe commands","Post-onboarding verification"]})],[I,ge({description:"Adopt an existing project into Workspai governance",objective:"Adopt an existing project without changing its runtime behavior.",expectedOutput:["Detected stack and confidence","Adoption plan","Generated metadata expectations","Doctor and workspace model verification"]})]];for(let[y,E]of u)g(await f(s.join(t,y),E,a),y);let A=[[D$1,u[0][1]],[F,u[1][1]],[H,u[2][1]],[J$1,u[3][1]]];for(let[y,E]of A)g(await f(s.join(t,y),E,a),y);if(e.hydratePrompts===true)for(let y of await Gt({workspacePath:t,skills:Q$1.skills,write:a}))g(a?"written":"skipped",y);}if(g(await f(s.join(t,K),$({index:v$1,context:p,model:T$1}),a),K),g(await f(s.join(t,L),$({index:v$1,context:p,model:T$1}),a),L),m==="enterprise"){g(await f(s.join(t,M),Ht(ke),a),M),g(await f(s.join(t,N),Ht(ke),a),N);let u=[["artifact-map.md",D({title:"Artifact Map",lines:J.map(y=>`- \`${y.relativePath}\` \u2014 ${y.label}`)})],["command-map.md",D({title:"Command Map",lines:["- `npx workspai workspace agent-sync --write --refresh-context` \u2014 refresh agent grounding.","- `npx workspai workspace model --json --write` \u2014 refresh workspace model.","- `npx workspai doctor workspace` \u2014 refresh health evidence.","- `npx workspai workspace verify --strict --json` \u2014 verify release gates."]})],["scope-model.md",D({title:"Scope Model",lines:["- Workspace scope is the default source of truth.","- Project scope is selected only when the active task targets a specific project.","- Always name the workspace and project when giving repair or lifecycle advice."]})],["runtime-support.md",D({title:"Runtime Support",lines:["- Native create is available only for Workspai-owned scaffold contracts.","- Unsupported stacks should use the official lane when a stable ecosystem generator exists.","- Existing projects should use the existing lane when native create is unavailable."]})],["create-planner-capabilities.md",D({title:"Create Planner Capabilities",lines:["- Use `contracts/create-planner-capabilities.v1.json` to decide native, official, or existing.","- Do not map PHP, WordPress, Laravel, Rails, or Symfony requests to unrelated native kits.","- Explain unsupported native create requests and guide users to adopt/import."]})],["mcp-tools.md",an()]];for(let[y,E]of u){let _=`${s.dirname(M)}/resources/${y}`;g(await f(s.join(t,_),E,a),_);let it=`${s.dirname(N)}/resources/${y}`;g(await f(s.join(t,it),E,a),it);}let A=[["workspai-advisor.agent.md",me({name:"Workspai Advisor",description:"Read-only workspace and project guidance using Workspai evidence",mode:"read-only",tools:["search","read"]})],["workspai-repair.agent.md",me({name:"Workspai Repair",description:"Turn Workspai blockers into minimal fixes and verification steps",mode:"repair",tools:["search","read","edit"]})],["workspai-release.agent.md",me({name:"Workspai Release",description:"Assess readiness, governance gates, and release safety from evidence",mode:"release",tools:["search","read"]})],["workspai-project-onboarder.agent.md",me({name:"Workspai Project Onboarder",description:"Guide create, import, and adopt flows with Workspai contracts",mode:"onboard",tools:["search","read","edit"]})]];for(let[y,E]of A){let _=`.github/agents/${y}`;g(await f(s.join(t,_),E,a),_);}}}if(m==="enterprise"){let u=on({workspaceRef:v$1.workspaceRoot,generatedAt:v$1.generatedAt});b$6(S,JSON.parse(u)),g(await f(s.join(t,S),u,a),S),g(await f(s.join(t,T),u,a),T);}if(m==="enterprise"&&e.experimentalHooks===true){let u=sn({workspaceRef:v$1.workspaceRoot,generatedAt:v$1.generatedAt});b$6(U,JSON.parse(u)),g(await f(s.join(t,U),u,a),U),g(await f(s.join(t,V),u,a),V);}let Z=a?await Kt({workspacePath:t,staleAfterHours:n$1,now:r$1}):v$1,ee=Z.reports.filter(u=>u.required&&!u.exists).map(u=>u.path),te=Z.reports.filter(u=>u.exists&&vr(u,n$1,r$1)).map(u=>u.path);if(k$1){ee.length>0&&R$1.push(`Missing required reports: ${ee.join(", ")}`),te.length>0&&R$1.push(`Stale reports (>${n$1}h): ${te.join(", ")}`);let u=K$1.map(A=>A.path).filter(A=>!jr(A));u.length>0&&R$1.push(`Unsafe generated output paths: ${u.join(", ")}`);}let N$1=a?await l$1({workspacePath:t,mode:e.projectGrounding??"managed",now:r$1}):void 0;if(k$1&&N$1&&N$1.skipped.length>0&&R$1.push(`Project grounding incomplete: ${N$1.skipped.map(u=>`${u.name} (${u.reason})`).join(", ")}`),k$1&&N$1){let u=N$1.projects.flatMap(A=>(A.hostCoverage??[]).filter(y=>y.status==="blocked"&&Er(i$1,y.id)).map(y=>`${s.basename(A.projectPath)}:${y.id}`));u.length>0&&R$1.push(`Project agent entry coverage blocked: ${u.join(", ")}`);}let ot=cn({workspaceRef:Z.workspaceRoot,generatedAt:r$1.toISOString(),preset:m,targets:c$1,index:Z,outputs:[...K$1,{path:Y,kind:"report",targets:["agents","vscode","copilot","cursor","claude","codex","gemini","qwen","kimi","grok","windsurf","amazon-q","orca"],required:true,status:a?"written":e.dryRun?"planned":"skipped"}],missingRequired:ee,staleReports:te,strictViolations:R$1,experimentalHooks:e.experimentalHooks===true});if(a&&process.env.WORKSPAI_TEST_FAIL_AGENT_SYNC_BEFORE_PACK==="1")throw new Error("Injected agent-sync failure before generation commit.");return g(await f(s.join(t,Y),`${JSON.stringify(ot,null,2)}
|
|
49
|
+
`,a),Y),{workspacePath:t,indexPath:s.join(t,X),packPath:s.join(t,Y),pack:ot,contextPath:l$2,writtenFiles:w$1,skippedFiles:I$1,blockers:v$1.blockers,missingRequired:ee,staleReports:te,strictViolations:R$1,projectLenses:N$1}}async function oa(e){if(e.write!==true)return tt(e);let t=s.resolve(e.workspacePath),r=s.join(t,".workspai","transactions","agent-sync");await b$4(r);let n=await tt({...e,write:false,dryRun:true});if(!n.pack)throw new Error("Agent-sync dry run did not produce an output inventory.");let i=[...n.pack.outputInventory.map(m=>m.path),X,Y],c=await a({journalDirectory:r});try{for(let l of [...new Set(i)].sort()){let p=s.resolve(t,l),d=s.relative(t,p);if(d===".."||d.startsWith(`..${s.sep}`)||s.isAbsolute(d))throw new Error(`Agent-sync output escapes workspace root: ${l}`);await c.captureFile(p);}let m$1=await m(t),a=new Set;for(let l of m$1.resolved)for(let p of [f$1,g$1,h,b$5,...g$2,"AGENTS.md",".gitignore"]){let d=s.join(l.projectPath,p);if((p==="AGENTS.md"||g$2.some(w=>w===p))&&(await h$1.lstat(d).catch(I=>{if(I.code==="ENOENT")return null;throw I}))?.isSymbolicLink()){let I=await a$1(l.projectPath,d);if(!I)continue;d=I;}a.has(d)||(await c.captureFile(d),a.add(d));}let k=await tt(e);return await c.commit(),k}catch(m){try{await c.rollback();}catch(a){throw new AggregateError([m,a],"Agent-sync generation failed and rollback was incomplete.")}throw m}}export{Jt as a,Xt as b,fr as c,kr as d,hr as e,X as f,Y as g,J as h,wr as i,Kt as j,aa as k,oa as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-LPCWROQ3.js';import {f,e as e$1,g,i}from'./chunk-ZGHJIQXL.js';var R=f.repairTransaction,C=e$1.repairTransaction,E=g.repairTransaction;var y="workspai.workspace-repair-proposal.v1",j="contracts/workspace-intelligence/workspace-repair-proposal.v1.json";var A="workspai.workspace-repair-capabilities.v1",b="workspai.workspace-repair-consumer-protocol.v1",v=["project","workspace","linked-project","polyglot-project"],d=["missing-tool","stale-evidence","missing-artifact","no-op-proposal","source-drift","validation-failure","producer-failure","provider-outage","interrupted-rollback","unsupported-runtime"],u=["automatic-refresh","bounded-replan","decision-required","checkpoint-rollback","durable-resume","manual-repair"],w={"missing-tool":"decision-required","stale-evidence":"automatic-refresh","missing-artifact":"automatic-refresh","no-op-proposal":"bounded-replan","source-drift":"bounded-replan","validation-failure":"checkpoint-rollback","producer-failure":"bounded-replan","provider-outage":"durable-resume","interrupted-rollback":"durable-resume","unsupported-runtime":"manual-repair"};function P(){let i=[],s=c.map(o=>o.id);new Set(s).size!==s.length&&i.push("adapter ids are not unique"),v.length<4&&i.push("scope matrix is incomplete"),d.length<10&&i.push("failure-family matrix is incomplete"),u.length<6&&i.push("recovery-path matrix is incomplete");for(let o of d){let t=w[o];u.includes(t)||i.push(`${o} has no bounded recovery policy`);}for(let o of c)for(let t of ["reconcile","audit","test","build"])o.stages[t]||i.push(`${o.id}.${t} is undeclared`);return i}var c=[{id:"node",ecosystem:"JavaScript / TypeScript",manifests:["package.json"],lockfiles:["package-lock.json","npm-shrinkwrap.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb"],packageManagers:["npm","pnpm","yarn","bun"],support:"full",stages:{reconcile:"native",audit:"native",test:"declared",build:"declared"},requiredToolFamilies:["selected package manager"]},{id:"python",ecosystem:"Python",manifests:["pyproject.toml","requirements.txt"],lockfiles:["uv.lock","poetry.lock","requirements.txt"],packageManagers:["uv","poetry","pip"],support:"conditional",stages:{reconcile:"conditional",audit:"conditional",test:"conditional",build:"declared"},requiredToolFamilies:["isolated Python","selected environment manager","pip-audit or governed Doctor audit"],limitation:"A bounded isolated environment and an installed audit surface are required."},{id:"go",ecosystem:"Go",manifests:["go.mod"],lockfiles:["go.sum"],packageManagers:["go modules"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["go","govulncheck"],limitation:"govulncheck must be installed; the engine never fetches an unreviewed tool."},{id:"rust",ecosystem:"Rust",manifests:["Cargo.toml"],lockfiles:["Cargo.lock"],packageManagers:["cargo"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["cargo","cargo-audit"],limitation:"The cargo-audit subcommand must already be installed."},{id:"php-composer",ecosystem:"PHP",manifests:["composer.json"],lockfiles:["composer.lock"],packageManagers:["composer"],support:"full",stages:{reconcile:"native",audit:"native",test:"declared",build:"declared"},requiredToolFamilies:["composer"]},{id:"ruby-bundler",ecosystem:"Ruby",manifests:["Gemfile"],lockfiles:["Gemfile.lock"],packageManagers:["bundler"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"declared",build:"declared"},requiredToolFamilies:["bundle","bundle-audit"],limitation:"bundle-audit and the declared Rake tasks must already exist."},{id:"elixir-mix",ecosystem:"Elixir",manifests:["mix.exs"],lockfiles:["mix.lock"],packageManagers:["mix"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["mix","Hex audit task"],limitation:"The project must expose the Hex audit task used by its dependency policy."},{id:"deno",ecosystem:"Deno",manifests:["deno.json","deno.jsonc"],lockfiles:["deno.lock"],packageManagers:["deno"],support:"full",stages:{reconcile:"native",audit:"native",test:"declared",build:"declared"},requiredToolFamilies:["deno"]},{id:"dotnet",ecosystem:".NET",manifests:["*.sln","*.csproj","*.fsproj","*.vbproj"],lockfiles:["Directory.Packages.props","packages.lock.json"],packageManagers:["NuGet / dotnet"],support:"full",stages:{reconcile:"native",audit:"native",test:"native",build:"native"},requiredToolFamilies:["dotnet"]},{id:"jvm-maven",ecosystem:"JVM / Maven",manifests:["pom.xml"],lockfiles:[],packageManagers:["Maven Wrapper","Maven"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["mvnw or mvn","governed Doctor audit"],limitation:"A project-specific dependency audit command must be declared by Doctor evidence."},{id:"jvm-gradle",ecosystem:"JVM / Gradle",manifests:["build.gradle.kts","build.gradle"],lockfiles:["gradle.lockfile","gradle/libs.versions.toml"],packageManagers:["Gradle Wrapper","Gradle"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["gradlew or gradle","governed Doctor audit"],limitation:"A project-specific dependency audit command must be declared by Doctor evidence."},{id:"clojure",ecosystem:"Clojure",manifests:["deps.edn","project.clj"],lockfiles:[],packageManagers:["Clojure CLI","Leiningen"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"conditional",build:"conditional"},requiredToolFamilies:["clojure or lein","governed project audit"],limitation:"Tests and builds run only when the selected Clojure project surface declares a deterministic entrypoint."},{id:"scala-sbt",ecosystem:"Scala / sbt",manifests:["build.sbt"],lockfiles:[],packageManagers:["sbt"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["sbt","governed project audit"],limitation:"A project-specific dependency audit command must be declared by Doctor evidence."}];function M(){let i=P();if(i.length>0)throw new Error(`Workspace Repair qualification matrix is incomplete: ${i.join("; ")}`);return {schemaVersion:A,owner:"Workspai CLI",workflow:["plan","preconditions","approval","target-precondition","checkpoint","execute","reconcile","audit","test","build","target-producer-verify","canonical-verify","close-or-rollback-or-decision"],invariants:{multiAdapterProjects:true,missingTools:"decision-required",unsupportedEcosystems:"decision-required",silentFallbackToModelExecution:false,mutationAuthority:"cli-only",targetClosure:"selected-causal-action-set",changeReceipt:"checkpoint-hash-delta",consumerTimeline:"durable-transaction-events",typedDecisionCauses:true,registeredLinkedProjectMutationBoundary:true,sourceProposalIntegrity:"project-bound-hash-pinned",completionAuthority:"cli-verification-receipt",goalSourceTransition:"closed-integrity-bound-v1",goalAttemptBudget:"durable-serialized-v1",consumerHandshakeRequired:true,ephemeralProposalsAreEvidence:false,approvalBoundToPlanHash:true,canonicalVerificationRequired:true,rollbackConflictDetection:true},consumerProtocol:{protocolVersion:b,versionProbe:{args:["--version","--json"],schemaVersion:"rapidkit-version-v1"},capabilityProbe:{args:["workspace","repair","capabilities","--json"],schemaVersion:A},invocation:{command:"workspace repair",workspaceResolution:["process-cwd","--workspace"],actions:["capabilities","plan","propose","approve","decide","execute","resume","status","list","rollback","cancel"]},contracts:{operationResult:a$1,proposal:y,transaction:R},transientPaths:[".workspai/repair/inbox/*.json",".workspai/repair/engine.lock"]},qualificationMatrix:{schemaVersion:"workspai.workspace-repair-qualification-matrix.v1",status:"contract-enforced",dimensions:{adapters:c.map(s=>s.id),scopes:v,failureFamilies:d,recoveryPaths:u,failureRecoveryPolicy:w},invariants:{everyAdapterDeclaresClosureStages:true,everyFailureTerminates:true,everyMutationIsCheckpointed:true,workspaceAndProjectScopesUseTheSameEngine:true,linkedProjectsRemainBoundaryChecked:true}},adapters:c}}var V="workspai.studio-card-repair-capabilities.v1",h="npx workspai workspace verify --json",r=e$1,a=i;function e(i,s,o,t={}){return {cardId:i,scope:t.scope??"workspace",producerCommand:s,producerArtifact:o,verifyCommand:s,verifyArtifact:o,aggregateVerifyCommand:h,targetClosure:"exact-producer-and-causal-action-set",aggregateRepair:"sequential-causal-queue",transactionScope:"one-causal-finding-family",workspacePosture:"reported-separately",repairPolicy:t.repairPolicy??"refresh-producer",remediationArtifacts:t.remediationArtifacts??[]}}var H=[e("doctor","npx workspai doctor workspace --json",r.doctor,{repairPolicy:"diagnose-and-repair",remediationArtifacts:[a.doctorRemediationPlan,a.artifactRemediationPlan]}),e("projectDoctor","npx workspai doctor project --json",a.doctorProject,{scope:"project",repairPolicy:"diagnose-and-repair",remediationArtifacts:[a.doctorRemediationPlan,a.artifactRemediationPlan]}),e("pipeline","npx workspai pipeline --json --strict",a.pipelineLastRun,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("analyze","npx workspai analyze --json",r.analyze,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("readiness","npx workspai readiness --json",r.readiness,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("bootstrap","npx workspai bootstrap --ci --json",a.bootstrapCompliance,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("workspaceSync","npx workspai workspace sync --json",a.workspaceRegistry),e("foundation","npx workspai workspace foundation ensure --json",".workspai/workspace.json"),e("contract","npx workspai workspace contract verify --strict --json",r.contractVerify,{repairPolicy:"source-repair-then-produce"}),e("autopilot","npx workspai autopilot release --json",a.autopilotReleaseLastRun,{repairPolicy:"source-repair-then-produce"}),e("workspaceRun","npx workspai workspace run test --json",a.workspaceRunLast,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("setup","npx workspai setup --json",".workspai/toolchain.lock",{repairPolicy:"source-repair-then-produce"}),e("importReadiness","npx workspai doctor project --json",a.doctorProject,{scope:"project",repairPolicy:"diagnose-and-repair",remediationArtifacts:[a.artifactRemediationPlan]}),e("snapshot","npx workspai snapshot create --json",".workspai/reports/snapshot-last-run.json"),e("workspaceModel","npx workspai workspace model --json --write",r.model),e("intelligenceSnapshot","npx workspai workspace snapshot --json",r.snapshot),e("workspaceDiff",`npx workspai workspace diff --from ${r.snapshot} --json`,r.diff),e("workspaceImpact",`npx workspai workspace impact --from ${r.diff} --json`,r.impact),e("workspaceIntelligenceRun","npx workspai workspace intelligence run --for-agent generic --strict --json",r.intelligenceRun,{repairPolicy:"source-repair-then-produce"}),e("workspaceVerify",h,r.verify,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("workspaceExplain","npx workspai workspace explain release-blocked --json --write",r.explain),e("workspaceWhy","npx workspai workspace why release-blocked --json --write",a.workspaceWhy),e("workspaceTrace",`npx workspai workspace trace --from ${r.diff} --json --write`,a.workspaceTrace),e("workspaceWatch","npx workspai workspace watch --once --json",r.model),e("workspaceContextAgent","npx workspai workspace context --for-agent --json --write",r.agentContext),e("agentGrounding","npx workspai workspace agent-sync --write --refresh-context --json --preset enterprise --target vscode",r.agentCustomizationPack),e("share",`npx workspai workspace share --output ${a.workspaceShareBundle} --json`,a.workspaceShareBundle),e("archive","npx workspai workspace export --output team-workspace.workspai-archive.zip --json",".workspai/archive-manifest.json"),e("mirror","npx workspai mirror status --json",a.mirrorOps),e("cache","npx workspai cache status --json",".workspai/cache-config.yml"),e("policy","npx workspai workspace policy show --json",".workspai/policies.yml",{repairPolicy:"source-repair-then-produce"}),e("infra","npx workspai infra plan --json",a.infraPlan,{repairPolicy:"source-repair-then-produce"})];export{R as a,C as b,E as c,y as d,j as e,A as f,c as g,M as h,V as i,H as j};
|
|
1
|
+
import {a as a$1}from'./chunk-LPCWROQ3.js';import {q,p,r as r$1,t}from'./chunk-ODK4LCEL.js';var R=q.repairTransaction,C=p.repairTransaction,E=r$1.repairTransaction;var y="workspai.workspace-repair-proposal.v1",j="contracts/workspace-intelligence/workspace-repair-proposal.v1.json";var A="workspai.workspace-repair-capabilities.v1",b="workspai.workspace-repair-consumer-protocol.v1",v=["project","workspace","linked-project","polyglot-project"],d=["missing-tool","stale-evidence","missing-artifact","no-op-proposal","source-drift","validation-failure","producer-failure","provider-outage","interrupted-rollback","unsupported-runtime"],u=["automatic-refresh","bounded-replan","decision-required","checkpoint-rollback","durable-resume","manual-repair"],w={"missing-tool":"decision-required","stale-evidence":"automatic-refresh","missing-artifact":"automatic-refresh","no-op-proposal":"bounded-replan","source-drift":"bounded-replan","validation-failure":"checkpoint-rollback","producer-failure":"bounded-replan","provider-outage":"durable-resume","interrupted-rollback":"durable-resume","unsupported-runtime":"manual-repair"};function P(){let i=[],s=c.map(o=>o.id);new Set(s).size!==s.length&&i.push("adapter ids are not unique"),v.length<4&&i.push("scope matrix is incomplete"),d.length<10&&i.push("failure-family matrix is incomplete"),u.length<6&&i.push("recovery-path matrix is incomplete");for(let o of d){let t=w[o];u.includes(t)||i.push(`${o} has no bounded recovery policy`);}for(let o of c)for(let t of ["reconcile","audit","test","build"])o.stages[t]||i.push(`${o.id}.${t} is undeclared`);return i}var c=[{id:"node",ecosystem:"JavaScript / TypeScript",manifests:["package.json"],lockfiles:["package-lock.json","npm-shrinkwrap.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb"],packageManagers:["npm","pnpm","yarn","bun"],support:"full",stages:{reconcile:"native",audit:"native",test:"declared",build:"declared"},requiredToolFamilies:["selected package manager"]},{id:"python",ecosystem:"Python",manifests:["pyproject.toml","requirements.txt"],lockfiles:["uv.lock","poetry.lock","requirements.txt"],packageManagers:["uv","poetry","pip"],support:"conditional",stages:{reconcile:"conditional",audit:"conditional",test:"conditional",build:"declared"},requiredToolFamilies:["isolated Python","selected environment manager","pip-audit or governed Doctor audit"],limitation:"A bounded isolated environment and an installed audit surface are required."},{id:"go",ecosystem:"Go",manifests:["go.mod"],lockfiles:["go.sum"],packageManagers:["go modules"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["go","govulncheck"],limitation:"govulncheck must be installed; the engine never fetches an unreviewed tool."},{id:"rust",ecosystem:"Rust",manifests:["Cargo.toml"],lockfiles:["Cargo.lock"],packageManagers:["cargo"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["cargo","cargo-audit"],limitation:"The cargo-audit subcommand must already be installed."},{id:"php-composer",ecosystem:"PHP",manifests:["composer.json"],lockfiles:["composer.lock"],packageManagers:["composer"],support:"full",stages:{reconcile:"native",audit:"native",test:"declared",build:"declared"},requiredToolFamilies:["composer"]},{id:"ruby-bundler",ecosystem:"Ruby",manifests:["Gemfile"],lockfiles:["Gemfile.lock"],packageManagers:["bundler"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"declared",build:"declared"},requiredToolFamilies:["bundle","bundle-audit"],limitation:"bundle-audit and the declared Rake tasks must already exist."},{id:"elixir-mix",ecosystem:"Elixir",manifests:["mix.exs"],lockfiles:["mix.lock"],packageManagers:["mix"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["mix","Hex audit task"],limitation:"The project must expose the Hex audit task used by its dependency policy."},{id:"deno",ecosystem:"Deno",manifests:["deno.json","deno.jsonc"],lockfiles:["deno.lock"],packageManagers:["deno"],support:"full",stages:{reconcile:"native",audit:"native",test:"declared",build:"declared"},requiredToolFamilies:["deno"]},{id:"dotnet",ecosystem:".NET",manifests:["*.sln","*.csproj","*.fsproj","*.vbproj"],lockfiles:["Directory.Packages.props","packages.lock.json"],packageManagers:["NuGet / dotnet"],support:"full",stages:{reconcile:"native",audit:"native",test:"native",build:"native"},requiredToolFamilies:["dotnet"]},{id:"jvm-maven",ecosystem:"JVM / Maven",manifests:["pom.xml"],lockfiles:[],packageManagers:["Maven Wrapper","Maven"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["mvnw or mvn","governed Doctor audit"],limitation:"A project-specific dependency audit command must be declared by Doctor evidence."},{id:"jvm-gradle",ecosystem:"JVM / Gradle",manifests:["build.gradle.kts","build.gradle"],lockfiles:["gradle.lockfile","gradle/libs.versions.toml"],packageManagers:["Gradle Wrapper","Gradle"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["gradlew or gradle","governed Doctor audit"],limitation:"A project-specific dependency audit command must be declared by Doctor evidence."},{id:"clojure",ecosystem:"Clojure",manifests:["deps.edn","project.clj"],lockfiles:[],packageManagers:["Clojure CLI","Leiningen"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"conditional",build:"conditional"},requiredToolFamilies:["clojure or lein","governed project audit"],limitation:"Tests and builds run only when the selected Clojure project surface declares a deterministic entrypoint."},{id:"scala-sbt",ecosystem:"Scala / sbt",manifests:["build.sbt"],lockfiles:[],packageManagers:["sbt"],support:"conditional",stages:{reconcile:"native",audit:"conditional",test:"native",build:"native"},requiredToolFamilies:["sbt","governed project audit"],limitation:"A project-specific dependency audit command must be declared by Doctor evidence."}];function M(){let i=P();if(i.length>0)throw new Error(`Workspace Repair qualification matrix is incomplete: ${i.join("; ")}`);return {schemaVersion:A,owner:"Workspai CLI",workflow:["plan","preconditions","approval","target-precondition","checkpoint","execute","reconcile","audit","test","build","target-producer-verify","canonical-verify","close-or-rollback-or-decision"],invariants:{multiAdapterProjects:true,missingTools:"decision-required",unsupportedEcosystems:"decision-required",silentFallbackToModelExecution:false,mutationAuthority:"cli-only",targetClosure:"selected-causal-action-set",changeReceipt:"checkpoint-hash-delta",consumerTimeline:"durable-transaction-events",typedDecisionCauses:true,registeredLinkedProjectMutationBoundary:true,sourceProposalIntegrity:"project-bound-hash-pinned",completionAuthority:"cli-verification-receipt",goalSourceTransition:"closed-integrity-bound-v1",goalAttemptBudget:"durable-serialized-v1",consumerHandshakeRequired:true,ephemeralProposalsAreEvidence:false,approvalBoundToPlanHash:true,canonicalVerificationRequired:true,rollbackConflictDetection:true},consumerProtocol:{protocolVersion:b,versionProbe:{args:["--version","--json"],schemaVersion:"rapidkit-version-v1"},capabilityProbe:{args:["workspace","repair","capabilities","--json"],schemaVersion:A},invocation:{command:"workspace repair",workspaceResolution:["process-cwd","--workspace"],actions:["capabilities","plan","propose","approve","decide","execute","resume","status","list","rollback","cancel"]},contracts:{operationResult:a$1,proposal:y,transaction:R},transientPaths:[".workspai/repair/inbox/*.json",".workspai/repair/engine.lock"]},qualificationMatrix:{schemaVersion:"workspai.workspace-repair-qualification-matrix.v1",status:"contract-enforced",dimensions:{adapters:c.map(s=>s.id),scopes:v,failureFamilies:d,recoveryPaths:u,failureRecoveryPolicy:w},invariants:{everyAdapterDeclaresClosureStages:true,everyFailureTerminates:true,everyMutationIsCheckpointed:true,workspaceAndProjectScopesUseTheSameEngine:true,linkedProjectsRemainBoundaryChecked:true}},adapters:c}}var V="workspai.studio-card-repair-capabilities.v1",h="npx workspai workspace verify --json",r=p,a=t;function e(i,s,o,t={}){return {cardId:i,scope:t.scope??"workspace",producerCommand:s,producerArtifact:o,verifyCommand:s,verifyArtifact:o,aggregateVerifyCommand:h,targetClosure:"exact-producer-and-causal-action-set",aggregateRepair:"sequential-causal-queue",transactionScope:"one-causal-finding-family",workspacePosture:"reported-separately",repairPolicy:t.repairPolicy??"refresh-producer",remediationArtifacts:t.remediationArtifacts??[]}}var H=[e("doctor","npx workspai doctor workspace --json",r.doctor,{repairPolicy:"diagnose-and-repair",remediationArtifacts:[a.doctorRemediationPlan,a.artifactRemediationPlan]}),e("projectDoctor","npx workspai doctor project --json",a.doctorProject,{scope:"project",repairPolicy:"diagnose-and-repair",remediationArtifacts:[a.doctorRemediationPlan,a.artifactRemediationPlan]}),e("pipeline","npx workspai pipeline --json --strict",a.pipelineLastRun,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("analyze","npx workspai analyze --json",r.analyze,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("readiness","npx workspai readiness --json",r.readiness,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("bootstrap","npx workspai bootstrap --ci --json",a.bootstrapCompliance,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("workspaceSync","npx workspai workspace sync --json",a.workspaceRegistry),e("foundation","npx workspai workspace foundation ensure --json",".workspai/workspace.json"),e("contract","npx workspai workspace contract verify --strict --json",r.contractVerify,{repairPolicy:"source-repair-then-produce"}),e("autopilot","npx workspai autopilot release --json",a.autopilotReleaseLastRun,{repairPolicy:"source-repair-then-produce"}),e("workspaceRun","npx workspai workspace run test --json",a.workspaceRunLast,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("setup","npx workspai setup --json",".workspai/toolchain.lock",{repairPolicy:"source-repair-then-produce"}),e("importReadiness","npx workspai doctor project --json",a.doctorProject,{scope:"project",repairPolicy:"diagnose-and-repair",remediationArtifacts:[a.artifactRemediationPlan]}),e("snapshot","npx workspai snapshot create --json",".workspai/reports/snapshot-last-run.json"),e("workspaceModel","npx workspai workspace model --json --write",r.model),e("intelligenceSnapshot","npx workspai workspace snapshot --json",r.snapshot),e("workspaceDiff",`npx workspai workspace diff --from ${r.snapshot} --json`,r.diff),e("workspaceImpact",`npx workspai workspace impact --from ${r.diff} --json`,r.impact),e("workspaceIntelligenceRun","npx workspai workspace intelligence run --for-agent generic --strict --json",r.intelligenceRun,{repairPolicy:"source-repair-then-produce"}),e("workspaceVerify",h,r.verify,{repairPolicy:"source-repair-then-produce",remediationArtifacts:[a.artifactRemediationPlan]}),e("workspaceExplain","npx workspai workspace explain release-blocked --json --write",r.explain),e("workspaceWhy","npx workspai workspace why release-blocked --json --write",a.workspaceWhy),e("workspaceTrace",`npx workspai workspace trace --from ${r.diff} --json --write`,a.workspaceTrace),e("workspaceWatch","npx workspai workspace watch --once --json",r.model),e("workspaceContextAgent","npx workspai workspace context --for-agent --json --write",r.agentContext),e("agentGrounding","npx workspai workspace agent-sync --write --refresh-context --json --preset enterprise --target vscode",r.agentCustomizationPack),e("share",`npx workspai workspace share --output ${a.workspaceShareBundle} --json`,a.workspaceShareBundle),e("archive","npx workspai workspace export --output team-workspace.workspai-archive.zip --json",".workspai/archive-manifest.json"),e("mirror","npx workspai mirror status --json",a.mirrorOps),e("cache","npx workspai cache status --json",".workspai/cache-config.yml"),e("policy","npx workspai workspace policy show --json",".workspai/policies.yml",{repairPolicy:"source-repair-then-produce"}),e("infra","npx workspai infra plan --json",a.infraPlan,{repairPolicy:"source-repair-then-produce"})];export{R as a,C as b,E as c,y as d,j as e,A as f,c as g,M as h,V as i,H as j};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import {a}from'./chunk-A5FBGRJA.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {t,s}from'./chunk-ODK4LCEL.js';import {s as s$1}from'./chunk-RGNCL5OB.js';import {k,v,e,a as a$2,u,f as f$1}from'./chunk-VQZ5PI5J.js';import b from'crypto';import P from'fs';import d from'fs/promises';import i from'path';import T from'fs-extra';var x=s.projectWorkspaceLink.schemaVersion,L="workspai.project-workspace-link",l=class extends Error{constructor(r,a,o={}){super(a);this.code=r;this.context=o;this.name="ProjectWorkspaceResolutionError";}code;context};function $(e){return P.existsSync(i.join(e,".workspai-workspace"))?".workspai-workspace":".workspai/workspace.json"}function _(e){return b.createHash("sha256").update([e.workspaceName,a(e.workspacePath),e.projectName,a(e.projectPath),e.relativePath.replace(/\\/g,"/"),e.relationship].join("\0")).digest("hex")}function I(e){let t=i.resolve(e);for(;;){if(k(t))return t;let r=i.dirname(t);if(r===t)return null;t=r;}}function J(e){let t=i.resolve(e);for(;;){if([...u(t,"project.json"),...u(t,"context.json")].some(a=>P.existsSync(a)))return t;let r=i.dirname(t);if(r===t)return null;t=r;}}function y(e){return JSON.parse(P.readFileSync(e,"utf8"))}function K(e){let t$1=y(e);if(!t$1||typeof t$1!="object"||Array.isArray(t$1))throw new l("project.workspace.link-invalid",`Project workspace link is not a JSON object: ${e}`,{linkPath:e});let r=t$1;if(r.schemaVersion!==x||r.kind!==L||r.state!=="active"||!r.workspace||typeof r.workspace.name!="string"||r.workspace.name.trim().length===0||typeof r.workspace.root!="string"||!i.isAbsolute(r.workspace.root)||![".workspai-workspace",".workspai/workspace.json"].includes(r.workspace.marker??"")||r.workspace.contract!==t.workspaceContract||!r.project||typeof r.project.name!="string"||r.project.name.trim().length===0||typeof r.project.relativePath!="string"||i.isAbsolute(r.project.relativePath)||r.project.relativePath.split(/[\\/]/).includes("..")||!["managed","adopted","imported","linked","restored"].includes(r.project.relationship??"")||!r.integrity||r.integrity.algorithm!=="sha256"||typeof r.integrity.binding!="string"||!/^[a-f0-9]{64}$/.test(r.integrity.binding))throw new l("project.workspace.link-invalid",`Project workspace link does not satisfy ${x}: ${e}`,{linkPath:e});try{a$1(t$1,"contracts/project-workspace-link.v1.json","Project workspace link");}catch(a){throw new l("project.workspace.link-invalid",`Project workspace link does not satisfy ${x}: ${e}`,{linkPath:e,validationError:a instanceof Error?a.message:String(a)})}return r}function f(e,t){let r=i.join(e,".workspai","workspace.contract.json");if(!P.existsSync(r))return null;try{let a$1=y(r);if(!Array.isArray(a$1.projects))return false;let o=a(t);return a$1.projects.some(n=>typeof n.externalPath=="string"?a(n.externalPath)===o:typeof n.relativePath!="string"||n.relativePath.startsWith("external/")?false:a(i.resolve(e,n.relativePath))===o)}catch{return false}}function M(e,t,r){let a$1=a(e),o=new Map;for(let n of s$1(t,r)){if(!P.existsSync(n))continue;let c;try{c=y(n);}catch{continue}if(Array.isArray(c.workspaces))for(let p of c.workspaces){if(!p||typeof p.name!="string"||typeof p.path!="string"||!Array.isArray(p.projects)||!p.projects.some(w=>w&&typeof w.path=="string"&&a(w.path)===a$1))continue;let s=a(p.path);!k(s)||f(s,e)!==true||o.set(s,{name:p.name,path:s});}}return [...o.values()].sort((n,c)=>n.path.localeCompare(c.path))}function m(e,t){if(e)throw t;return null}function te(e$1){let t=e$1.strict===true,r=i.resolve(e$1.startPath),a=e$1.explicitWorkspacePath?i.resolve(e$1.explicitWorkspacePath):null,o=J(r);if(a)return k(a)?e$1.requireProjectMembership===true&&o&&f(a,o)!==true?m(t,new l("project.workspace.membership-missing",`Project is not registered in the explicit workspace contract: ${a}`,{workspacePath:a,projectPath:o})):{workspacePath:a,projectPath:o,source:"explicit",linkPath:o?v(o,e):null,recovered:false}:m(t,new l("project.workspace.explicit-invalid",`Explicit workspace path is not a Workspai workspace: ${a}`,{workspacePath:a,projectPath:o}));let n=I(r);if(n)return e$1.requireProjectMembership===true&&o&&f(n,o)!==true?m(t,new l("project.workspace.membership-missing",`Project is not registered in its parent workspace contract: ${n}`,{workspacePath:n,projectPath:o})):{workspacePath:n,projectPath:o,source:"parent",linkPath:o?v(o,e):null,recovered:false};if(!o)return m(t,new l("project.workspace.unlinked","No Workspai project or workspace could be resolved from the current directory.",{startPath:r}));let c=v(o,e),p=null;if(P.existsSync(c)){let s;try{s=K(c);}catch(O){if(t)throw O;return null}let u=_({workspaceName:s.workspace.name,workspacePath:s.workspace.root,projectName:s.project.name,projectPath:o,relativePath:s.project.relativePath,relationship:s.project.relationship}),w=f(s.workspace.root,o);if(s.integrity.binding===u&&k(s.workspace.root)&&P.existsSync(i.join(s.workspace.root,s.workspace.marker))&&w===true)return {workspacePath:i.resolve(s.workspace.root),projectPath:o,source:"local-link",linkPath:c,recovered:false};p=s;}let h=M(o,e$1.env??process.env,e$1.platform??process.platform);return h.length>1?m(t,new l("project.workspace.ambiguous",`Project is registered in more than one valid workspace: ${h.map(s=>s.name).join(", ")}. Pass --workspace <path> or run project workspace relink.`,{projectPath:o,candidates:h})):h.length===1?{workspacePath:h[0].path,projectPath:o,source:"registry",linkPath:c,recovered:p!==null}:p?m(t,new l("project.workspace.link-stale",`Project workspace link is stale and no valid registry relocation was found: ${p.workspace.root}`,{projectPath:o,linkPath:c,linkedWorkspacePath:p.workspace.root})):m(t,new l("project.workspace.unlinked","This Workspai project is not linked to a valid workspace. Run `npx workspai adopt .` or `npx workspai project workspace relink --workspace <path>`.",{projectPath:o,linkPath:c}))}async function F(e,t){await d.mkdir(i.dirname(e),{recursive:true});let r=`${e}.${process.pid}.${b.randomUUID()}.tmp`;try{await d.writeFile(r,`${JSON.stringify(t,null,2)}
|
|
2
|
+
`,{encoding:"utf8",mode:384});try{await d.rename(r,e);}catch(a){let o=a.code;if(o!=="EEXIST"&&o!=="EPERM")throw a;await T.move(r,e,{overwrite:true});}}finally{await d.rm(r,{force:true}).catch(()=>{});}}async function D(e){let t=i.join(e,".gitignore"),r=await d.readFile(t,"utf8").catch(c=>{if(c.code==="ENOENT")return "";throw c});if(r.split(/\r?\n/).map(c=>c.trim()).includes(f$1))return;let n=`${r.length>0&&!r.endsWith(`
|
|
3
|
+
`)?`
|
|
4
|
+
`:""}
|
|
5
|
+
# Workspai machine-local workspace binding
|
|
6
|
+
${f$1}
|
|
7
|
+
`;await d.writeFile(t,`${r}${n}`,"utf8");}async function V(e$1){let t$1=i.resolve(e$1.workspacePath),r=i.resolve(e$1.projectPath);if(!k(t$1))throw new l("project.workspace.explicit-invalid",`Cannot link project to an invalid Workspai workspace: ${t$1}`,{workspacePath:t$1,projectPath:r});let a$3=i.join(t$1,".workspai","workspace.contract.json"),o=e$1.workspaceName??i.basename(t$1),n=e$1.relativePath;if(P.existsSync(a$3)){let h=y(a$3);typeof h.workspace?.name=="string"&&(o=h.workspace.name);let s=a(r),u=h.projects?.find(w=>typeof w.externalPath=="string"?a(w.externalPath)===s:typeof w.relativePath=="string"&&!w.relativePath.startsWith("external/")&&a(i.resolve(t$1,w.relativePath))===s);u&&typeof u.relativePath=="string"&&(n=u.relativePath);}if(n??=i.relative(t$1,r).replace(/\\/g,"/"),(!n||n.startsWith(".."))&&(n=`external/${e$1.projectName}`),f(t$1,r)!==true)throw new l("project.workspace.membership-missing",`Project is not registered in the canonical workspace contract: ${e$1.projectName}`,{workspacePath:t$1,projectPath:r,projectName:e$1.projectName});let c={schemaVersion:x,kind:L,generatedAt:(e$1.now??new Date).toISOString(),state:"active",workspace:{name:o,root:t$1,marker:$(t$1),contract:t.workspaceContract},project:{name:e$1.projectName,relativePath:n,relationship:e$1.relationship},integrity:{algorithm:"sha256",binding:_({workspaceName:o,workspacePath:t$1,projectName:e$1.projectName,projectPath:r,relativePath:n,relationship:e$1.relationship})}};a$1(c,"contracts/project-workspace-link.v1.json","Project workspace link");let p=i.join(r,a$2,e);return await D(r),await F(p,c),{linkPath:p,link:c}}async function oe(e,t="linked"){if(!e.projectPath)return null;let r=u(e.projectPath,"project.json").find(o=>P.existsSync(o)),a=i.basename(e.projectPath);if(r)try{let o=y(r);typeof o.name=="string"?a=o.name:typeof o.slug=="string"&&(a=o.slug);}catch{}return V({workspacePath:e.workspacePath,projectPath:e.projectPath,projectName:a,relationship:t})}export{l as a,te as b,V as c,oe as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-A5FBGRJA.js';import {g as g$1,p}from'./chunk-PTSEDZIV.js';import {g,h}from'./chunk-FE5R6EUV.js';import {t,s}from'./chunk-ODK4LCEL.js';import {s as s$1,q}from'./chunk-RGNCL5OB.js';import {t as t$1}from'./chunk-VQZ5PI5J.js';import a from'path';import {existsSync}from'fs';import m from'fs-extra';var f=t.workspaceRegistry,w=s.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=t$1(r,"workspace.json").find(t=>existsSync(t));if(!e)return {exists:false,legacyProjectCount:0};try{let t=await m.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.pathExists(t))try{let o=((await m.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 g(t,g$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 p({workspacePath:t});n=A.projects||[];}catch{n=[];}let d={contract:{exists:i,projectCount:n.length,path:g$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$1="none",u=[],y=0;return i?(p$1="workspace.contract.json",u=n.map(E),y=u.length):s.projectCount>0?(p$1="global-registry",y=s.projectCount):o.legacyProjectCount>0&&(p$1="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$1,contractPath:g$1,projects:u,sources:d}}}async function U(r){let e=await g(r,f);if(!e)return null;try{let t=await m.readJson(e);return t?.schemaVersion!==w?null:t}catch{return null}}async function D(r,e){let t=await M(r,e);return await h(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 ne="workspace-knowledge-search.v1";function b(e){return e.trim().toLowerCase()}var V=new WeakMap;function B(e){let t=V.get(e);if(t)return t;let s=new Map(e.relations.map(a=>[a.id,a])),o=new Map(e.entities.map(a=>[a.id,a])),i=new Map(e.proofs.map(a=>[a.id,a])),r=new Map,d=new Map,h=(a,g)=>{let p=d.get(a)??[];p.push(g),d.set(a,p);};for(let a of e.entities){let g=[a.id,a.label,a.identity.key,...a.kind==="project"&&a.projectId?[a.projectId]:[],...a.identity.aliases];for(let p of new Set(g.map(b))){let k=r.get(p)??[];k.push(a),r.set(p,k);}}for(let a of e.relations)h(a.from,{from:a.from,to:a.to,relationId:a.id,kind:a.kind,direction:"forward",proofIds:a.proofIds}),h(a.to,{from:a.to,to:a.from,relationId:a.id,kind:a.kind,direction:"reverse",proofIds:a.proofIds});for(let a of r.values())a.sort((g,p)=>g.id.localeCompare(p.id));for(let a of d.values())a.sort((g,p)=>g.to.localeCompare(p.to)||g.relationId.localeCompare(p.relationId));let l={entitiesById:o,relationsById:s,entitiesByAlias:r,proofsById:i,adjacency:d};return V.set(e,l),l}function D(e,t){let s=B(e),o=s.relationsById.get(t);if(o)return {found:true,targetType:"relation",relation:o};let i=b(t),r=s.entitiesByAlias.get(i)??[];return r.length===1?{found:true,targetType:"entity",entity:r[0]}:{found:false,query:t,candidates:r.map(d=>d.id).sort()}}function Ke(e,t){let s=D(e,t);if(!s.found)return {query:t,found:false,target:null,proofs:[],candidates:s.candidates};let o=s.targetType==="entity"?s.entity:s.relation,i=new Set(o.proofIds);return {query:t,found:true,target:o,candidates:[],proofs:[...i].map(r=>B(e).proofsById.get(r)).filter(r=>!!r).sort((r,d)=>r.id.localeCompare(d.id))}}function Se(e,t,s){let o=D(e,t),i=D(e,s);if(!o.found||o.targetType!=="entity"||!i.found||i.targetType!=="entity")return {from:t,to:s,found:false,resolvedFrom:o.found&&o.targetType==="entity"?o.entity.id:null,resolvedTo:i.found&&i.targetType==="entity"?i.entity.id:null,entityPath:[],hops:[],proofs:[]};let r=B(e),d=[o.entity.id],h=new Map,l=new Set(d),a=0;for(;a<d.length&&!l.has(i.entity.id);){let u=d[a++];for(let w of r.adjacency.get(u)??[])l.has(w.to)||(l.add(w.to),h.set(w.to,w),d.push(w.to));}if(!l.has(i.entity.id))return {from:t,to:s,found:false,resolvedFrom:o.entity.id,resolvedTo:i.entity.id,entityPath:[],hops:[],proofs:[]};let g=[],p=i.entity.id;for(;p!==o.entity.id;){let u=h.get(p);if(!u)break;g.push(u),p=u.from;}g.reverse();let k=new Set(g.flatMap(u=>u.proofIds));return {from:t,to:s,found:true,resolvedFrom:o.entity.id,resolvedTo:i.entity.id,entityPath:[o.entity.id,...g.map(u=>u.to)],hops:g,proofs:[...k].map(u=>r.proofsById.get(u)).filter(u=>!!u).sort((u,w)=>u.id.localeCompare(w.id))}}function Ee(e,t,s){return e.entities.filter(o=>(!t||o.kind===t)&&(!s||o.projectId===s)).sort((o,i)=>o.kind.localeCompare(i.kind)||o.label.localeCompare(i.label))}var m={relations:12,relatedEntities:12,proofs:8,proofIdsPerItem:4,aliasesPerEntity:8,attributeArrayItems:8,attributeStringCharacters:256};function oe(e){let t=[],s=new Set;for(let o=0;o<m.proofIdsPerItem&&t.length<m.proofs;o+=1)for(let i of e){let r=i.proofIds[o];if(!(!r||s.has(r))&&(s.add(r),t.push(r),t.length>=m.proofs))break}return t}function se(e,t,s){let o=e.identity.aliases.slice(0,m.aliasesPerEntity);s.aliases+=e.identity.aliases.length-o.length;let i=Object.fromEntries(Object.entries(e.attributes).map(([d,h])=>{if(Array.isArray(h)){let l=h.slice(0,m.attributeArrayItems);return s.attributeValues+=h.length-l.length,[d,l]}return typeof h=="string"&&h.length>m.attributeStringCharacters?(s.attributeValues+=1,[d,h.slice(0,m.attributeStringCharacters)]):[d,h]})),r=e.proofIds.filter(d=>t.has(d)).slice(0,m.proofIdsPerItem);return s.proofReferences+=e.proofIds.length-r.length,{...e,identity:{...e.identity,aliases:o},attributes:i,proofIds:r}}function ae(e){let t=Object.values(e.attributes).flatMap(s=>Array.isArray(s)?s:[s]);return [e.id,e.kind,e.label,e.projectId??"",e.identity.key,...e.identity.aliases,...t.map(s=>String(s??""))].join(" ").toLowerCase()}var ie=new Set(["a","an","and","are","as","at","be","been","being","by","can","check","could","did","do","does","find","for","from","give","had","has","have","how","i","in","into","is","it","its","may","might","of","on","or","our","show","should","that","the","their","them","then","there","these","they","this","those","tell","to","was","we","were","what","when","where","which","who","why","will","with","would","you","your"]),re=new Map([["authenticate","auth"],["authenticated","auth"],["authentication","auth"],["authorization","auth"],["authorizing","auth"],["config","configuration"],["configs","configuration"],["dependencies","dependency"],["connected","connect"],["connecting","connect"],["connection","connect"],["connections","connect"],["diagnostics","diagnostic"],["reliable","reliability"],["tested","test"],["testing","test"],["tests","test"],["verification","verify"],["verified","verify"],["verifies","verify"],["verifying","verify"]]);function M(e){let t=s=>b(s).replace(/\bc\+\+/gu," cplusplus ").replace(/\bc#/gu," csharp ").split(/[^a-z0-9]+/u).filter(o=>o.length>1||o==="c"||o==="r").map(o=>re.get(o)??o);return [...new Set([...t(e),...t(e.replace(/([a-z0-9])([A-Z])/g,"$1 $2"))])]}function ce(e){let t=b(e.label),s=b(e.identity.key),o=e.identity.aliases.map(b),i=ae(e);return {entity:e,label:t,identity:s,aliases:o,haystack:i,labelTokens:new Set(M(e.label)),identityTokens:new Set(M(e.identity.key)),aliasTokens:new Set(e.identity.aliases.flatMap(M)),allTokens:new Set(M(i))}}function E(e,t){return e.has(t)||t.length>=3&&[...e].some(s=>s.startsWith(t))}function _(e,t){return E(e.labelTokens,t)||E(e.identityTokens,t)||E(e.aliasTokens,t)||E(e.allTokens,t)}function le(e,t,s,o){let{label:i,identity:r,aliases:d,haystack:h}=e,l=0;(i===t||r===t||d.includes(t))&&(l+=1e4),(i.startsWith(t)||r.startsWith(t))&&(l+=250),h.includes(t)&&(l+=100);let a=0;for(let g of s){let p=o.get(g)??1,k=E(e.labelTokens,g),u=E(e.identityTokens,g),w=E(e.aliasTokens,g),f=_(e,g);f&&(a+=1),i===g?l+=80*p:k&&(l+=36*p),u&&(l+=24*p),w&&(l+=20*p),f&&(l+=10*p);}return s.length>0&&(l+=a/s.length*120),l}function F(e,t){let s=new Set;for(let o of t){let i=e.allTokens.has(o)?o:void 0,r=i===void 0&&o.length>=3?[...e.allTokens].find(h=>h.startsWith(o)&&!s.has(h)):void 0,d=i??r;d&&!s.has(d)&&s.add(d);}return s.size}var de=new Map([["c","c"],["clojure","clojure"],["cplusplus","cpp"],["cpp","cpp"],["typescript","typescript"],["ts","typescript"],["javascript","javascript"],["js","javascript"],["nodejs","javascript"],["python","python"],["py","python"],["go","go"],["golang","go"],["csharp","csharp"],["ada","ada"],["assembly","assembly"],["asm","assembly"],["cuda","cuda"],["dotnet","csharp"],["dart","dart"],["elixir","elixir"],["fsharp","fsharp"],["fortran","fortran"],["java","java"],["kotlin","kotlin"],["hlsl","hlsl"],["llvmir","llvm-ir"],["mlir","mlir"],["lua","lua"],["php","php"],["r","r"],["ruby","ruby"],["rust","rust"],["tablegen","tablegen"],["scala","scala"],["svelte","svelte"],["swift","swift"],["vue","vue"]]);function pe(e){return new Set(e.map(t=>de.get(t)).filter(t=>!!t))}function Y(e){let t=e.attributes.language;return typeof t=="string"?b(t):null}function ge(e){return {project:1e3,service:900,api:900,package:850,endpoint:800,container:700,deployment:700,environment:650,pipeline:600,"test-suite":550,owner:500,decision:450,document:400}[e.kind]??0}var he=new Set(["language","languages","binding","bindings","bridge","bridges","dependency","dependencies","depends","core","runtime","owner","owners","ownership","maintainer","ci","pipeline","pipelines","workflow","deploy","deployment","infrastructure","container","doc","docs","document","documentation","service","services","api","rpc","schema","schemas","message","protobuf","proto","contract"]),ue=new Set(["app","application","applications","call","calls","code","communicate","communication","connect","define","defined","expose","exposed","handle","handled","implement","implementation","integrate","integration","interact","interaction","project","provide","provided","system","use","used","uses","using"]);function fe(e){return he.has(e)||ue.has(e)}function ye(e,t){let s=t.has("language")||t.has("languages"),o=t.has("binding")||t.has("bindings")||t.has("bridge")||t.has("bridges"),i=t.has("dependency")||t.has("dependencies")||t.has("depends"),r=t.has("core")||t.has("runtime"),d=t.has("owner")||t.has("owners")||t.has("ownership")||t.has("maintainer"),h=t.has("ci")||t.has("pipeline")||t.has("pipelines")||t.has("workflow"),l=t.has("deploy")||t.has("deployment")||t.has("infrastructure")||t.has("container"),a=t.has("doc")||t.has("docs")||t.has("document")||t.has("documentation"),g=t.has("service")||t.has("services")||t.has("api")||t.has("rpc"),p=t.has("schema")||t.has("schemas")||t.has("message")||t.has("protobuf")||t.has("proto")||t.has("contract"),k=typeof e.attributes.mechanism=="string"?b(e.attributes.mechanism):"",u=typeof e.attributes.specification=="string"?b(e.attributes.specification):"",w=b(e.label),f=0;if(s&&e.kind==="language"){let O=typeof e.attributes.fileCount=="number"?e.attributes.fileCount:0;f+=900+Math.min(O,1e4)/10;}return o&&e.kind==="protocol"&&(f+=800),i&&e.kind==="package"&&(f+=650),r&&e.kind==="package"&&/(?:^|[_-])core(?:$|[_-])/u.test(w)&&(f+=700),r&&e.kind==="protocol"&&k.includes("core")&&(f+=300),d&&e.kind==="owner"&&(f+=850),h&&e.kind==="pipeline"&&(f+=800),l&&["deployment","container","environment"].includes(e.kind)&&(f+=775),a&&["document","decision"].includes(e.kind)&&(f+=725),g&&["api","endpoint","service"].includes(e.kind)&&(f+=700),p&&(e.kind==="schema"||(e.kind==="api"||e.kind==="protocol")&&(u.includes("protobuf")||k.includes("protobuf")))&&(f+=750),f}function we(e){return [e.has("language")||e.has("languages"),e.has("binding")||e.has("bindings")||e.has("bridge")||e.has("bridges"),e.has("dependency")||e.has("dependencies")||e.has("depends"),e.has("core")||e.has("runtime"),e.has("owner")||e.has("ownership")||e.has("maintainer"),e.has("ci")||e.has("pipeline")||e.has("workflow"),e.has("deploy")||e.has("deployment")||e.has("infrastructure"),e.has("doc")||e.has("docs")||e.has("documentation"),e.has("service")||e.has("api")||e.has("rpc"),e.has("schema")||e.has("protobuf")||e.has("proto")||e.has("contract")].filter(Boolean).length>=3}function We(e,t){let s=b(t.query),o=[...new Set(M(t.query))],i=new Set(M(t.projectId??"")),r=t.projectId?o.filter(n=>!i.has(n)):o,d=!!(t.projectId&&o.length>0&&r.length===0),h=r.filter(n=>!ie.has(n)),l=h.length>0?h:r,a=pe(l),g=new Set(l),p=l.filter(n=>!fe(n)),k=we(g),u=l.length<=1?l.length:Math.min(2,Math.ceil(l.length/3)),w=t.minimumTermMatches===void 0?u:Math.min(u,Math.max(1,Math.trunc(t.minimumTermMatches))),f=Math.max(1,Math.min(Math.trunc(t.limit??12),100)),O=Math.max(0,Math.min(Math.trunc(t.relationsPerEntity??4),20)),G=new Set;if(t.projectId){let n=new Set(e.entities.filter(c=>c.kind==="project"&&(c.projectId===t.projectId||c.label===t.projectId)).map(c=>c.id));for(let c of e.relations)n.has(c.from)&&G.add(c.to),n.has(c.to)&&G.add(c.from);}let P=e.entities.filter(n=>(!t.kind||n.kind===t.kind)&&(!t.projectId||n.projectId===t.projectId||n.projectId===void 0&&G.has(n.id))).map(ce),$=new Map(l.map(n=>{let c=P.filter(y=>_(y,n)).length;return [n,Math.log((P.length+1)/(c+1))+1]})),X=p.some(n=>P.some(c=>_(c,n))),v=P.map(n=>{let c=F(n,l),y=F(n,p),I=Y(n.entity),S=I&&a.has(I)?400:0,x=ye(n.entity,g),j=p.length===0||p.some(te=>_(n,te))?x:0;return {entity:n.entity,matchedTerms:c,matchedQualifiers:y,intentScore:j,score:d?ge(n.entity):le(n,s,l,$)+y*300+S+j}}).filter(n=>{let c=Y(n.entity);return (a.size===0||c===null||a.has(c))&&(s.length===0||n.score>0&&(!X||p.length===0||n.matchedQualifiers>0)&&(d||n.matchedTerms>=w||n.intentScore>0&&(k||l.length<=2)))}).sort((n,c)=>c.score-n.score||n.entity.kind.localeCompare(c.entity.kind)||n.entity.label.localeCompare(c.entity.label)),W=(k?(()=>{let n=[],c=[],y=new Map,I=new Set;for(let S of v){let x=y.get(S.entity.kind)??0,j=b(S.entity.label);x<2&&!I.has(j)?(n.push(S),y.set(S.entity.kind,x+1),I.add(j)):c.push(S);}return [...n,...c]})():v).slice(0,f).map(n=>n.entity),R=new Set(W.map(n=>n.id)),L=new Map,H=e.relations.filter(n=>{if(!(R.has(n.from)||R.has(n.to)))return false;let y=R.has(n.from)?n.from:n.to,I=L.get(y)??0;return I>=O?false:(L.set(y,I+1),true)}),K=t.projection==="agent",T=K?H.slice(0,m.relations):H,z=B(e),N=[...new Set(T.flatMap(n=>[n.from,n.to]).filter(n=>!R.has(n)))].map(n=>z.entitiesById.get(n)).filter(n=>!!n).map(({id:n,kind:c,label:y,projectId:I})=>({id:n,kind:c,label:y,...I?{projectId:I}:{}})).sort((n,c)=>n.kind.localeCompare(c.kind)||n.label.localeCompare(c.label)),Q=K?N.slice(0,m.relatedEntities):N,q=new Set([...W.flatMap(n=>n.proofIds),...T.flatMap(n=>n.proofIds)]),Z=K?oe([...W,...T]):[...q],C=new Set(Z),A={entities:v.length-W.length,relations:H.length-T.length,relatedEntities:N.length-Q.length,proofs:q.size-C.size,proofReferences:0,aliases:0,attributeValues:0},U=K?W.map(n=>se(n,C,A)):W,J=K?T.map(n=>{let c=n.proofIds.filter(y=>C.has(y)).slice(0,m.proofIdsPerItem);return A.proofReferences+=n.proofIds.length-c.length,{...n,proofIds:c}}):T,ee=[...C].map(n=>z.proofsById.get(n)).filter(n=>!!n).sort((n,c)=>n.id.localeCompare(c.id));return {schemaVersion:ne,graphSourceHash:e.source.hash,query:t.query,kind:t.kind??null,...t.projectId?{projectId:t.projectId}:{},limit:f,totalMatches:v.length,truncated:v.length>U.length||K&&Object.values(A).some(n=>n>0),entities:U,relatedEntities:Q,relations:J,proofs:ee,...K?{budget:{mode:"agent",limits:{...m},omitted:A}}:{}}}export{ne as a,D as b,Ke as c,Se as d,Ee as e,We as f};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b}from'./chunk-K33JJVQZ.js';import {t}from'./chunk-ODK4LCEL.js';import {d}from'./chunk-25AWHAB5.js';import {w,x as x$1}from'./chunk-VQZ5PI5J.js';import s from'path';import {randomUUID}from'crypto';import {open,link,copyFile}from'fs/promises';import f from'fs-extra';function N(e,t){let n=s.resolve(e),r=t.trim();if(!r||s.isAbsolute(r))throw new Error(`Workspace artifact path must be non-empty and relative: ${t}`);let l=s.resolve(n,r),o=s.relative(n,l);if(o===".."||o.startsWith(`..${s.sep}`)||s.isAbsolute(o))throw new Error(`Workspace artifact path escapes workspace root: ${t}`);return l}function m(e,t){return N(e,w(t))}async function T(e,t,n="file"){let r=s.resolve(e),l=m(r,t);if(!await f.pathExists(r)||!await f.pathExists(l))return null;let[o,p,a]=await Promise.all([f.realpath(r),f.realpath(l),f.stat(l)]),c=s.relative(o,p);if(c===".."||c.startsWith(`..${s.sep}`)||s.isAbsolute(c))throw new Error(`Workspace artifact resolves outside workspace root: ${t}`);if(!(n==="file"?a.isFile():a.isDirectory()))throw new Error(`Workspace artifact is not a regular ${n}: ${t}`);return p}async function rt(e,t$1){let n=t$1.trim().replace(/\\/g,"/").replace(/^\.\//,"");if(!n||s.isAbsolute(n))return null;let r=await T(e,n);if(r)return r;let l=t.workspaceContract;for(let o of [l,x$1(l)]){let p=await T(e,o);if(!p)continue;let a=[];try{a=(await f.readJson(p)).projects??[];}catch{return null}let c=a.filter(i=>typeof i.relativePath=="string"&&typeof i.externalPath=="string"&&s.isAbsolute(i.externalPath)).map(i=>({prefix:i.relativePath.replace(/\\/g,"/").replace(/\/$/,""),root:s.resolve(i.externalPath)})).filter(({prefix:i})=>n.startsWith(`${i}/`)).sort((i,u)=>u.prefix.length-i.prefix.length);for(let i of c){let u=n.slice(i.prefix.length+1),d=s.resolve(i.root,u),w=s.relative(i.root,d);if(!w||w===".."||w.startsWith(`..${s.sep}`)||s.isAbsolute(w)||!await f.pathExists(i.root)||!await f.pathExists(d))continue;let[g,h,P]=await Promise.all([f.realpath(i.root),f.realpath(d),f.stat(d)]),v=s.relative(g,h);if(v===".."||v.startsWith(`..${s.sep}`)||s.isAbsolute(v))throw new Error(`External evidence resolves outside its contracted root: ${t$1}`);if(!P.isFile())throw new Error(`External evidence is not a regular file: ${t$1}`);return h}return null}return null}async function C(e,t,n){let r=s.resolve(e),l=s.resolve(r,t),o=s.relative(r,l);if(!o||o===".."||o.startsWith(`..${s.sep}`)||s.isAbsolute(o)||!await f.pathExists(r))return null;let p=await f.realpath(r),a=l;for(;!await f.pathExists(a);){let u=s.dirname(a);if(u===a)return null;a=u;}let c=await f.realpath(a),i=s.relative(p,c);if(i===".."||i.startsWith(`..${s.sep}`)||s.isAbsolute(i))throw new Error(n);return l}async function at(e,t$1){let n=t$1.trim().replace(/\\/g,"/").replace(/^\.\//,"");if(!n||s.isAbsolute(n))return null;let r=t.workspaceContract;for(let l of [r,x$1(r)]){let o=await T(e,l);if(!o)continue;let p=[];try{p=(await f.readJson(o)).projects??[];}catch{return null}let a=p.filter(c=>typeof c.relativePath=="string"&&typeof c.externalPath=="string"&&s.isAbsolute(c.externalPath)).map(c=>({prefix:c.relativePath.replace(/\\/g,"/").replace(/\/$/,""),root:s.resolve(c.externalPath)})).filter(({prefix:c})=>n.startsWith(`${c}/`)).sort((c,i)=>i.prefix.length-c.prefix.length);if(a.length>0){for(let c of a){let i=n.slice(c.prefix.length+1),u=await C(c.root,i,`External evidence candidate resolves outside its contracted root: ${t$1}`);if(u)return u}return null}break}return C(e,n,`Workspace evidence candidate resolves outside workspace root: ${t$1}`)}function O(e,t){return N(e,x$1(t))}async function _(e,t){let n=s.resolve(e);await f.ensureDir(n);let r=s.dirname(t);await f.ensureDir(r);let[l,o]=await Promise.all([f.realpath(n),f.realpath(r)]),p=s.relative(l,o);if(p===".."||p.startsWith(`..${s.sep}`)||s.isAbsolute(p))throw new Error(`Workspace artifact parent resolves outside workspace root: ${r}`)}async function J(e,t){let n=s.resolve(e),[r,l]=await Promise.all([f.realpath(n),f.realpath(t)]),o=s.relative(r,l);if(o===".."||o.startsWith(`..${s.sep}`)||s.isAbsolute(o))throw new Error(`Workspace artifact resolves outside workspace root: ${t}`)}function j(e){let t=e?.code;return process.platform==="win32"&&(t==="EPERM"||t==="EINVAL"||t==="ENOSYS")}function F(e,t=process.platform){if(t!=="win32")return false;let n=e?.code;return n==="EPERM"||n==="EACCES"||n==="EBUSY"}async function E(e){let t=process.platform==="win32"?6:1,n;for(let r=0;r<t;r+=1)try{await f.remove(e);return}catch(l){if(n=l,!F(l)||r===t-1)throw l;await new Promise(o=>setTimeout(o,10*2**r));}throw n}var x=new Map;async function K(e,t){let n=x.get(e)??Promise.resolve(),r,l=new Promise(p=>{r=p;}),o=n.catch(()=>{}).then(()=>l);x.set(e,o),await n.catch(()=>{});try{return await t()}finally{r(),x.get(e)===o&&x.delete(e);}}async function L(e){try{await e.sync();}catch(t){if(!j(t))throw t}}async function k(e,t,n){await _(e,t);let r=s.dirname(t),l=`${s.basename(t)}.`,o=Date.now();for(let a of await f.readdir(r)){if(!a.startsWith(l)||!a.endsWith(".tmp"))continue;let c=s.join(r,a),i=await f.stat(c).catch(()=>null);i&&o-i.mtimeMs>3e4&&await f.remove(c).catch(()=>{});}let p=`${t}.${process.pid}.${randomUUID()}.tmp`;try{await n(p);let a=await open(p,"r");try{await L(a);}finally{await a.close();}let c=Number(process.env.WORKSPAI_TEST_ATOMIC_WRITE_DELAY_MS??0);Number.isFinite(c)&&c>0&&await new Promise(i=>setTimeout(i,Math.min(c,3e4)));try{await f.rename(p,t);}catch(i){let u=i.code;if(u!=="EEXIST"&&u!=="EPERM")throw i;await f.move(p,t,{overwrite:true});}}finally{await f.remove(p).catch(()=>{});}}async function U(e,t,n,r={}){let l=m(e,t);await _(e,l);let o=`${l}.lock`;return K(o,()=>z(o,t,n,r))}async function z(e,t,n,r){let l=r.timeoutMs??1e4,o=r.staleAfterMs??3e4,p=Date.now(),a;for(;!a;)try{a=await open(e,"wx"),await a.writeFile(`${JSON.stringify({pid:process.pid,createdAt:new Date().toISOString()})}
|
|
2
|
+
`),await L(a);}catch(c){if(!(c.code==="EEXIST"||F(c)))throw a&&(await a.close().catch(()=>{}),a=void 0,await E(e).catch(()=>{})),c;a&&(await a.close().catch(()=>{}),a=void 0,await E(e).catch(()=>{}));let[d,w]=await Promise.all([f.stat(e).catch(()=>null),f.readJson(e).catch(()=>null)]),g=Number(w?.pid),h=Number.isInteger(g)&&g>0,P=false;if(h)try{process.kill(g,0),P=true;}catch(b){P=b.code==="EPERM";}let v=!h&&!!(d&&Date.now()-d.mtimeMs>o);if(h&&!P||v){await E(e).catch(()=>{});continue}if(Date.now()-p>=l)throw new Error(`Timed out waiting for workspace artifact lock: ${t}`);await new Promise(b=>setTimeout(b,20));}try{return await n()}finally{await a.close().catch(()=>{}),await E(e);}}async function nt(e,t){let n=[m(e,t),O(e,t)];for(let r of n)if(await f.pathExists(r))return await J(e,r),r;return null}async function ot(e,t,n){b(t,n);let r=m(e,t);return await k(e,r,l=>f.writeJson(l,n,{spaces:2})),d({workspacePath:e,relativePath:t}),r}async function it(e,t,n){return Y(e,t,n.map(r=>({rootPath:e,...r})))}async function Y(e,t,n){if(n.length===0)return [];let r=n.map(o=>({...o,rootPath:s.resolve(o.rootPath),path:m(o.rootPath,o.relativePath)})),l=r.find((o,p)=>r.findIndex(a=>a.path===o.path)!==p);if(l)throw new Error(`Duplicate workspace artifact transaction target: ${l.relativePath}`);for(let o of r)b(o.relativePath,o.payload);return U(e,t,async()=>{let o=randomUUID(),p=[];try{for(let a of r){let c=await f.pathExists(a.path),i={path:a.path,rootPath:a.rootPath,exists:c,backupPath:null};if(p.push(i),c){let u=`${a.path}.${process.pid}.${o}.rollback`;await J(a.rootPath,a.path);try{try{await link(a.path,u);}catch{await copyFile(a.path,u);}i.backupPath=u;}catch(d){throw await f.remove(u).catch(()=>{}),d}}}for(let a=0;a<r.length;a+=1){let c=r[a];await k(c.rootPath,c.path,u=>f.writeJson(u,c.payload,{spaces:2}));let i=Number(process.env.WORKSPAI_TEST_FAIL_ARTIFACT_SET_AFTER??0);if(Number.isInteger(i)&&i===a+1)throw new Error(`Injected artifact-set failure after ${i} write(s).`)}for(let a of r)d({workspacePath:a.rootPath,relativePath:a.relativePath});return r.map(a=>a.path)}catch(a){let i=(await Promise.allSettled(p.map(async u=>{if(!u.exists){await f.remove(u.path);return}u.backupPath&&await k(u.rootPath,u.path,d=>copyFile(u.backupPath,d));}))).filter(u=>u.status==="rejected");throw i.length>0?new AggregateError([a,...i.map(u=>u.reason)],"Workspace artifact transaction failed and rollback was incomplete."):a}finally{await Promise.all(p.map(a=>a.backupPath?f.remove(a.backupPath).catch(()=>{}):Promise.resolve()));}})}async function st(e,t,n){let r=m(e,t);return await k(e,r,l=>f.writeFile(l,n,"utf-8")),d({workspacePath:e,relativePath:t}),r}export{m as a,T as b,rt as c,at as d,O as e,U as f,nt as g,ot as h,it as i,Y as j,st as k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a}from'./chunk-FB7SCXAZ.js';import {createHash}from'crypto';function p(o){return Array.isArray(o)?`[${o.map(p).join(",")}]`:o&&typeof o=="object"?`{${Object.entries(o).sort(([t],[d])=>t.localeCompare(d)).map(([t,d])=>`${JSON.stringify(t)}:${p(d)}`).join(",")}}`:JSON.stringify(o)}function k(o){return createHash("sha256").update(p({entities:o.entities,relations:o.relations,proofs:o.proofs.map(({observedAt:t,freshness:d,...r})=>r)})).digest("hex")}function v(o,t){return [...new Set([...Object.keys(o),...Object.keys(t)])].filter(d=>p(o[d])!==p(t[d])).sort()}function f(o,t){let d=new Map(o.map(a=>[a.id,a])),r=new Map(t.map(a=>[a.id,a])),s=t.filter(a=>!d.has(a.id)),e=o.filter(a=>!r.has(a.id)),c=[];for(let[a,i]of d){let g=r.get(a);if(!g)continue;let l=v(i,g);l.length>0&&c.push({id:a,before:i,after:g,changedFields:l});}return {added:[...s].sort((a,i)=>a.id.localeCompare(i.id)),removed:[...e].sort((a,i)=>a.id.localeCompare(i.id)),changed:c.sort((a,i)=>a.id.localeCompare(i.id))}}function y(o){return {...o,observedAt:"1970-01-01T00:00:00.000Z",freshness:"fresh"}}function A(o,t){let d=f(o.map(y),t.map(y)),r=new Map(o.map(e=>[e.id,e])),s=new Map(t.map(e=>[e.id,e]));return {added:d.added.map(e=>s.get(e.id)??e),removed:d.removed.map(e=>r.get(e.id)??e),changed:d.changed.map(e=>({id:e.id,before:r.get(e.id),after:s.get(e.id),changedFields:e.changedFields}))}}function K(o,t){let d=new Set(t);return o.proofs.filter(r=>d.has(r.id)).map(r=>r.artifact)}function P(o,t,d=new Date){let r=f(o.entities,t.entities),s=f(o.relations,t.relations),e=A(o.proofs,t.proofs),c=new Set([...r.added.map(n=>n.id),...r.removed.map(n=>n.id),...r.changed.map(n=>n.id)]),a$1=[...s.added,...s.removed,...s.changed.flatMap(n=>[n.before,n.after].filter(Boolean))];for(let n of a$1)c.add(n.from),c.add(n.to);let i=new Set(c);for(let n of [...o.relations,...t.relations])(c.has(n.from)||c.has(n.to))&&(i.add(n.from),i.add(n.to));let g=new Set([...e.added.map(n=>n.id),...e.removed.map(n=>n.id),...e.changed.map(n=>n.id)]),l=[...new Set([...K(o,g),...K(t,g),...e.added.map(n=>n.artifact),...e.removed.map(n=>n.artifact),...e.changed.flatMap(n=>[n.before?.artifact,n.after?.artifact])])].filter(n=>!!n).sort(),h=r.removed.length+s.removed.length+e.removed.length,m=h+r.added.length+r.changed.length+s.added.length+s.changed.length+e.added.length+e.removed.length+e.changed.length,W=m===0?"none":h>0||i.size>=10?"high":i.size>=5||m>=5?"medium":"low";return {schemaVersion:a,generatedAt:d.toISOString(),workspace:t.workspace,base:{schemaVersion:o.schemaVersion,generatedAt:o.generatedAt,fingerprint:k(o)},head:{schemaVersion:t.schemaVersion,generatedAt:t.generatedAt,fingerprint:k(t)},entities:r,relations:s,proofs:e,impactedEntityIds:[...i].sort(),changedArtifacts:l,summary:{entityAdds:r.added.length,entityRemovals:r.removed.length,entityChanges:r.changed.length,relationAdds:s.added.length,relationRemovals:s.removed.length,relationChanges:s.changed.length,proofAdds:e.added.length,proofRemovals:e.removed.length,proofChanges:e.changed.length,impactedEntities:i.size,changedArtifacts:l.length,risk:W}}}export{P as a};
|