workspai 0.58.0 → 0.59.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -32
- package/contracts/agent-customization-pack.v1.json +52 -4
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +90 -0
- package/contracts/extension-cli-compatibility.v1.json +3 -1
- package/contracts/project-workspace-resolution.v1.json +15 -2
- package/contracts/published-contract-catalog.v1.json +10 -0
- package/contracts/runtime-command-surface.v1.json +54 -0
- package/contracts/workspace-intelligence/agent-bootstrap-receipt.v1.json +247 -0
- package/contracts/workspace-intelligence/agent-customization-pack-report.v1.json +16 -1
- package/contracts/workspace-intelligence/goal-index.v1.json +7 -1
- package/contracts/workspace-intelligence/goal-pack.v1.json +2 -1
- package/contracts/workspace-intelligence/project-agent-entry.v1.json +204 -0
- package/contracts/workspace-intelligence/project-context-agent.v1.json +43 -26
- package/contracts/workspace-intelligence/workspace-context.v1.json +14 -1
- package/contracts/workspace-intelligence/workspace-repair-transaction.v1.json +15 -2
- package/contracts/workspace-repair-capabilities.v1.json +5 -0
- package/dist/analyze-52TEGLDR.js +1 -0
- package/dist/{artifact-remediation-plan-JRX4XZ7C.js → artifact-remediation-plan-HPNQTNJ2.js} +1 -1
- package/dist/autopilot-release-NFLAKBA3.js +1 -0
- package/dist/capabilities-command-VBLZXP2T.js +1 -0
- package/dist/{chunk-TTLVG5AR.js → chunk-3CGR6435.js} +1 -1
- package/dist/chunk-4PUJVYRM.js +1 -0
- package/dist/{chunk-4NN5QWOB.js → chunk-5NIZNXRS.js} +1 -1
- package/dist/{chunk-HYY5PQCV.js → chunk-5PSKBJKJ.js} +1 -1
- package/dist/{chunk-AA4PNQKR.js → chunk-5SFCBZOH.js} +1 -1
- package/dist/{chunk-MFJ6ZP7S.js → chunk-6FBNSTUS.js} +1 -1
- package/dist/{chunk-FY6OHOXR.js → chunk-7DSYI7YN.js} +1 -1
- package/dist/chunk-7SFXADXO.js +2 -0
- package/dist/{chunk-GRGUPSNP.js → chunk-CCDGHPEJ.js} +1 -1
- package/dist/{chunk-T63WRURN.js → chunk-D65FCQIO.js} +1 -1
- package/dist/{chunk-YYCPRYP7.js → chunk-DGGTTRYE.js} +1 -1
- package/dist/chunk-DQ6VXTDE.js +1 -0
- package/dist/{chunk-SM55RK3C.js → chunk-ENKGGWRX.js} +1 -1
- package/dist/chunk-FLTIFYTJ.js +142 -0
- package/dist/{chunk-RMDVRNU7.js → chunk-GPOZILMY.js} +1 -1
- package/dist/{chunk-C4NYG57I.js → chunk-HCFWT42C.js} +1 -1
- package/dist/{chunk-RJDGC6AQ.js → chunk-HS3DJMU5.js} +1 -1
- package/dist/{chunk-HI7ONEFI.js → chunk-J3X56S7L.js} +1 -1
- package/dist/{chunk-N3DFX4BY.js → chunk-KBR4Y4RW.js} +1 -1
- package/dist/{chunk-H545P6LN.js → chunk-KTN2ARZJ.js} +1 -1
- package/dist/chunk-LPCWROQ3.js +1 -0
- package/dist/chunk-MZKKRAAJ.js +2 -0
- package/dist/{chunk-LGJAAPNR.js → chunk-N4QQADXX.js} +1 -1
- package/dist/{chunk-FXIE2WVG.js → chunk-NOZ4JCH7.js} +1 -1
- package/dist/chunk-NZ3WZYD5.js +1 -0
- package/dist/{chunk-VAWV3UKV.js → chunk-OFWSZYUX.js} +1 -1
- package/dist/{chunk-XC26FNRL.js → chunk-P2WH7W2H.js} +11 -11
- package/dist/chunk-PVXSIYLP.js +1 -0
- package/dist/{chunk-7KXRA5ST.js → chunk-PXWKMPPI.js} +1 -1
- package/dist/{chunk-II4ROT6X.js → chunk-QCKWQFCD.js} +1 -1
- package/dist/{chunk-4YICCES6.js → chunk-QFBVQUKV.js} +1 -1
- package/dist/{chunk-G4VMNWSU.js → chunk-QJCCZLOF.js} +1 -1
- package/dist/{chunk-A3JCETSF.js → chunk-QMPFNXI7.js} +1 -1
- package/dist/{chunk-CFBAGPB4.js → chunk-QPE6VCDW.js} +1 -1
- package/dist/chunk-RTDEFUTL.js +39 -0
- package/dist/{chunk-YMY6EFX4.js → chunk-RVKMGKYL.js} +1 -1
- package/dist/chunk-S4CWUZ4K.js +1 -0
- package/dist/{chunk-EEMRRCGR.js → chunk-SP5EHSWG.js} +1 -1
- package/dist/{chunk-CHMCKYJJ.js → chunk-U3MGJN7A.js} +1 -1
- package/dist/{chunk-WSDVFLHT.js → chunk-W6FHVXNL.js} +1 -1
- package/dist/{chunk-M2BK3XTP.js → chunk-WQX3JYEP.js} +1 -1
- package/dist/{chunk-AUCHMXUZ.js → chunk-WSRUPDZN.js} +1 -1
- package/dist/{chunk-6TNSCVR4.js → chunk-Y4B55J5S.js} +1 -1
- package/dist/{chunk-GVS5OFUB.js → chunk-YEEAWZWI.js} +1 -1
- package/dist/{chunk-I5PDN2P2.js → chunk-ZJCM37KX.js} +1 -1
- package/dist/{create-QIN56Y4M.js → create-HUEDWYDM.js} +1 -1
- package/dist/{doctor-RP4Q2CKJ.js → doctor-NAZEKMGU.js} +1 -1
- package/dist/goal-lifecycle-NUKWVUAL.js +1 -0
- package/dist/goal-pack-TWOXHXN6.js +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +134 -132
- package/dist/{pipeline-77NUVYQD.js → pipeline-62A2SDLC.js} +1 -1
- package/dist/project-agent-entry-7SYHRY7J.js +1 -0
- package/dist/{project-intelligence-lens-AM2B2PXU.js → project-intelligence-lens-BSG5LK6N.js} +1 -1
- package/dist/{project-test-coverage-MUSS7Z7V.js → project-test-coverage-HP37HUV2.js} +1 -1
- package/dist/{verified-goal-ZSIZYNVO.js → verified-goal-B6HQOZWA.js} +1 -1
- package/dist/{workspace-LFESVKE7.js → workspace-BNRSBWSL.js} +1 -1
- package/dist/{workspace-agent-sync-JMRX6J2Y.js → workspace-agent-sync-ANBHBZ2H.js} +1 -1
- package/dist/{workspace-archive-MFHCFCDO.js → workspace-archive-ZBCKJHXS.js} +1 -1
- package/dist/{workspace-context-TBKRMVMT.js → workspace-context-RAO62QVU.js} +1 -1
- package/dist/{workspace-contract-KKVC2DUQ.js → workspace-contract-ACSIHJIO.js} +1 -1
- package/dist/workspace-explain-RH27OQB4.js +1 -0
- package/dist/workspace-explain-contract-ZL4NMLZI.js +1 -0
- package/dist/{workspace-feedback-O6J3RQML.js → workspace-feedback-RQ4TGJW6.js} +1 -1
- package/dist/{workspace-foundation-JQWT7YGC.js → workspace-foundation-EWYJPPT6.js} +1 -1
- package/dist/{workspace-graph-stream-V5WOXP4B.js → workspace-graph-stream-ZZZEQQTE.js} +1 -1
- package/dist/workspace-graph-token-efficiency-D7CUT6NX.js +1 -0
- package/dist/{workspace-history-TOCRMJUJ.js → workspace-history-SYCDK7FO.js} +1 -1
- package/dist/{workspace-intelligence-SDBIRKMK.js → workspace-intelligence-3YERTBA3.js} +1 -1
- package/dist/{workspace-intelligence-evaluation-E4UMWDAZ.js → workspace-intelligence-evaluation-CQDKOYZZ.js} +1 -1
- package/dist/{workspace-intelligence-runner-DIMNL6CJ.js → workspace-intelligence-runner-QLLBUD6G.js} +1 -1
- package/dist/{workspace-intelligence-runtime-registry-YGWB2RRS.js → workspace-intelligence-runtime-registry-IW6J53LO.js} +1 -1
- package/dist/{workspace-knowledge-graph-MUW6UAGI.js → workspace-knowledge-graph-HZZP6ZRB.js} +1 -1
- package/dist/{workspace-knowledge-graph-query-6DAOXGGT.js → workspace-knowledge-graph-query-ON45H6Y7.js} +1 -1
- package/dist/workspace-knowledge-graph-snapshot-7DWHMEM2.js +1 -0
- package/dist/{workspace-mcp-serve-2SWLIH4I.js → workspace-mcp-serve-5TTAN243.js} +1 -1
- package/dist/{workspace-model-VPFCKTYQ.js → workspace-model-EIQSKDX7.js} +1 -1
- package/dist/{workspace-onboarding-GHI6UTQJ.js → workspace-onboarding-UW3CSURE.js} +1 -1
- package/dist/{workspace-readme-RASXBZRQ.js → workspace-readme-56YZ4EAZ.js} +1 -1
- package/dist/{workspace-registry-summary-7QT7YMIU.js → workspace-registry-summary-OV5KX3WC.js} +1 -1
- package/dist/workspace-repair-engine-DHH2UUJN.js +3 -0
- package/dist/workspace-run-BLHRXT2N.js +1 -0
- package/dist/{workspace-verify-RYCQZYYB.js → workspace-verify-W4P6LBIH.js} +1 -1
- package/dist/{workspace-watch-U3YGN3GG.js → workspace-watch-EZ4D4VCF.js} +1 -1
- package/docs/GLOSSARY.md +13 -10
- package/docs/README.md +24 -19
- package/docs/README_CONTENT_CONTRACT.md +12 -8
- package/docs/agent-entry.md +194 -0
- package/docs/ci-workflows.md +18 -1
- package/docs/commands-reference.md +26 -2
- package/docs/contracts/ARTIFACT_CATALOG.md +9 -3
- package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +3 -0
- package/docs/contracts/README.md +22 -2
- package/docs/goal-packs.md +70 -9
- package/docs/workspace-operations.md +16 -8
- package/docs/workspace-repair-engine.md +36 -5
- package/package.json +4 -2
- package/scripts/enterprise-package-smoke.mjs +4 -0
- package/dist/analyze-MAU36FTX.js +0 -1
- package/dist/autopilot-release-TA2L7SCB.js +0 -1
- package/dist/capabilities-command-HE2FICLG.js +0 -1
- package/dist/chunk-42Q5E2YV.js +0 -1
- package/dist/chunk-7IRGSM25.js +0 -1
- package/dist/chunk-CNWUIXF3.js +0 -1
- package/dist/chunk-FPJNWPKU.js +0 -1
- package/dist/chunk-HH54C3XJ.js +0 -1
- package/dist/chunk-NQ5H4R2I.js +0 -83
- package/dist/chunk-PCXBPQO6.js +0 -1
- package/dist/chunk-QXW3SLEX.js +0 -1
- package/dist/chunk-TMOKXYAQ.js +0 -2
- package/dist/chunk-VIFTO53Y.js +0 -1
- package/dist/chunk-ZDYGO3T7.js +0 -36
- package/dist/goal-lifecycle-YTBU3ICP.js +0 -1
- package/dist/goal-pack-MYYH7K43.js +0 -1
- package/dist/workspace-explain-RGGZL5IW.js +0 -1
- package/dist/workspace-explain-contract-4ZZ6CJ44.js +0 -1
- package/dist/workspace-graph-token-efficiency-TF23UYEF.js +0 -1
- package/dist/workspace-knowledge-graph-snapshot-7IU2QAXI.js +0 -1
- package/dist/workspace-repair-engine-AZTJIFCY.js +0 -3
- package/dist/workspace-run-VMZY6LIF.js +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {c as c$3}from'./chunk-RVKMGKYL.js';import {d as d$2,i,j as j$1,k as k$2,h as h$2,m as m$1,n,o as o$1}from'./chunk-ENKGGWRX.js';import {a as a$2}from'./chunk-7DSYI7YN.js';import {a,c,h,b,e,j,g,d as d$1}from'./chunk-S4CWUZ4K.js';import {h as h$1}from'./chunk-FLTIFYTJ.js';import {k as k$1,o}from'./chunk-DQ6VXTDE.js';import {a as a$3}from'./chunk-5NIZNXRS.js';import {a as a$4}from'./chunk-AO2ZI42U.js';import {c as c$4,d}from'./chunk-EWZZUQBR.js';import {m}from'./chunk-SP5EHSWG.js';import {c as c$2}from'./chunk-CCDGHPEJ.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {e as e$1}from'./chunk-NZ3WZYD5.js';import {randomUUID,createHash}from'crypto';import {hostname}from'os';import c$1 from'path';import {execa}from'execa';import k from'fs-extra';var Ce=".workspai/repair",ja="transaction.json",Ia="source-plan.json",oa="checkpoint",Ea="engine.lock",ua=5*1024*1024,Aa=25*1024*1024,$a=25*1024*1024,ha=4*1024*1024,Sa=900*1e3,Wa=new Set(["package.json","pyproject.toml","requirements.txt","go.mod","Cargo.toml","composer.json","Gemfile","mix.exs","deno.json","deno.jsonc","pom.xml","build.gradle","build.gradle.kts","deps.edn","project.clj","build.sbt"]),Ca=new Set(["package.json","package-lock.json","npm-shrinkwrap.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb","pyproject.toml","requirements.txt","requirements-dev.txt","uv.lock","poetry.lock","go.mod","go.sum","Cargo.toml","Cargo.lock","composer.json","composer.lock","Gemfile","Gemfile.lock","mix.exs","mix.lock","deno.json","deno.jsonc","deno.lock","Directory.Packages.props","packages.lock.json","pom.xml","build.gradle","build.gradle.kts","gradle.lockfile","deps.edn","project.clj","build.sbt"]),H={safe:0,guarded:1,invasive:2},Ta=new Set(["node","npm","npx","pnpm","yarn","bun","deno","python","python3","py","pip","pip3","poetry","uv","pytest","pip-audit","govulncheck","go","cargo","composer","bundle","bundle-audit","dotnet","mvn","mvnw","gradle","gradlew","mix","clojure","lein","sbt","make"]);function Na(e){return [e.kind,e.id,e.projectPath??"",e.adapterId??"",e.executable??""].join("\0")}function D(e,a,r={kind:"failed-precondition"}){return {reason:e,options:a,causes:[{...r,id:r.id??`runtime:${$(e).slice(0,16)}`,message:r.message??e}]}}function ga(e){let a=new Map,r=t=>a.set(Na(t),t);for(let t of e.adapters){(t.support==="unsupported"||t.status==="unsupported")&&r({kind:"unsupported-adapter",id:`adapter:${t.projectPath}:${t.adapterId}`,message:t.message,projectPath:t.projectPath,adapterId:t.adapterId});for(let o of t.missingExecutables)r({kind:"missing-executable",id:`tool:${t.projectPath}:${t.adapterId}:${o}`,message:`Required repair executable is unavailable: ${o} (${t.projectPath}).`,projectPath:t.projectPath,adapterId:t.adapterId,executable:o});}for(let t of e.actions??[]){let o=Re(t);(t.status==="blocked"||t.status==="guidance-only"||!o&&!t.invocation)&&r({kind:"source-repair-required",id:`action:${t.id}`,message:t.blocker||`${t.id} requires a bounded source repair proposal.`,...t.projectPath?{projectPath:t.projectPath}:{}}),H[t.risk]>H[e.maxRisk]&&r({kind:"risk-approval",id:`risk:${t.id}`,message:`${t.id} exceeds the approved ${e.maxRisk} risk ceiling.`,...t.projectPath?{projectPath:t.projectPath}:{}});}for(let t of e.preconditions.filter(o=>o.status==="failed")){if(t.id==="structured-execution"){r({kind:"source-repair-required",id:`precondition:${t.id}`,message:t.message});continue}if(t.id.startsWith("tool:")){let o=e.stages.find(s=>s.invocation&&`tool:${s.invocation.cwd}:${s.invocation.executable}`===t.id);if(o?.invocation){r({kind:"missing-executable",id:t.id,message:t.message,projectPath:o.invocation.cwd,executable:o.invocation.executable});continue}}r({kind:"failed-precondition",id:`precondition:${t.id}`,message:t.message});}if(e.decisionOptions.has("allow-force")&&r({kind:"policy-exception",id:"policy:allow-force",message:"The proposed repair requires an explicit force-install policy exception."}),e.decisionOptions.has("allow-breaking")&&r({kind:"policy-exception",id:"policy:allow-breaking",message:"The proposed repair requires an explicit breaking-change policy exception."}),a.size===0){let t=e.fallbackReasons.find(o=>o.trim().length>0);t&&r({kind:"failed-precondition",id:`decision:${$(t).slice(0,16)}`,message:t});}return [...a.values()]}function F(e){return (e?.()??new Date).toISOString()}function $(e){return createHash("sha256").update(e).digest("hex")}function K(e){return Array.isArray(e)?`[${e.map(K).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).filter(([,a])=>a!==void 0).sort(([a],[r])=>a.localeCompare(r)).map(([a,r])=>`${JSON.stringify(a)}:${K(r)}`).join(",")}}`:e===void 0?"null":JSON.stringify(e)}var Se="causal-action-integrity:";function fa(e){return $(K([...e].sort((a,r)=>a.id.localeCompare(r.id)).map(a=>({id:a.id,artifactKind:a.artifactKind,cardId:a.cardId,title:a.title,phase:a.phase,scope:a.scope,projectName:a.projectName,projectPath:a.projectPath,sourceStepId:a.sourceStepId,findingId:a.findingId,findingStatus:a.findingStatus,causalKey:a.causalKey,dependsOn:a.dependsOn,strategy:a.strategy,transaction:a.transaction,status:a.status,mode:a.mode,risk:a.risk,requiresApproval:a.requiresApproval,blocker:a.blocker,summary:a.summary,command:a.command,invocation:a.invocation,verifyCommand:a.verifyCommand,cwd:a.cwd,files:a.files,operation:a.operation,rollback:a.rollback,notes:a.notes}))))}function ka(e){if(e.length===0)return;let a=fa(e);return {id:`${Se}${a}`,status:"passed",message:`${e.length} causal action(s) are semantically pinned to this approval (${a.slice(0,12)}).`}}function E(e,a){let r=c$1.relative(c$1.resolve(e),c$1.resolve(a));return r===""||!r.startsWith("..")&&!c$1.isAbsolute(r)}async function _(e,a){let r=await k.realpath(e).catch(()=>c$1.resolve(e)),t=c$1.resolve(a);for(;!await k.pathExists(t);){let s=c$1.dirname(t);if(s===t)return false;t=s;}let o=await k.realpath(t).catch(()=>c$1.resolve(t));return E(r,o)}function O(e,a,r){let t=c$1.isAbsolute(a)?c$1.resolve(a):c$1.resolve(e,a);if(!E(e,t)&&!(r&&E(c$1.resolve(r),t)))throw new Error(`Repair path escapes workspace boundary: ${a}`);return c$1.relative(e,t).split(c$1.sep).join("/")||"."}function sa(e,a,r){return O(e,a,r)}async function qa(e){if(!e.proposal.projectName&&!e.proposal.projectPath)return;let a=e.proposal.projectPath?c$1.resolve(e.workspacePath,e.proposal.projectPath):void 0;if(a&&E(e.workspacePath,a))return a;let{contract:r}=await m({workspacePath:e.workspacePath}),t=r.projects.find(o=>{let s=o.externalPath?c$1.resolve(o.externalPath):c$1.resolve(e.workspacePath,o.relativePath);return (!e.proposal.projectName||o.slug===e.proposal.projectName)&&(!a||s===a)});if(!t)throw new Error("Repair proposal project must match one canonical registered project.");return t.externalPath?c$1.resolve(t.externalPath):c$1.resolve(e.workspacePath,t.relativePath)}function oe(e,a){if(!/^[A-Za-z0-9_-]{12,128}$/.test(a))throw new Error("Invalid repair transaction id.");return c$1.join(e,Ce,"transactions",a)}function be(e,a){return a.target.projectPath?c$1.resolve(e,a.target.projectPath):void 0}function ye(e,a){return c$1.join(oe(e,a),ja)}function Te(e,a){return c$1.join(oe(e,a),Ia)}async function Z(e,a){await k.ensureDir(c$1.dirname(e));let r=`${e}.${process.pid}.${randomUUID()}.tmp`;await k.writeJson(r,a,{spaces:2}),await k.move(r,e,{overwrite:true});}function I(e,a,r,t={}){e.events.push({sequence:e.events.length+1,at:F(t.now),type:a,...t.stageId?{stageId:t.stageId}:{},...t.status?{status:t.status}:{},message:r});}async function P(e,a,r){a.revision+=1,a.updatedAt=F(r),a$1(a,c,"Workspace repair transaction"),await Z(ye(e,a.transactionId),a),await Z(c$1.join(e,b),a);}async function se(e){let a$2=await k.readJson(ye(e.workspacePath,e.transactionId));if(a$2.schemaVersion!==a)throw new Error(`Unsupported repair transaction schema: ${a$2.schemaVersion}`);return a$1(a$2,c,"Workspace repair transaction"),a$2}async function Pe(e,a){return await k.readJson(Te(e,a))}function re(e){return e.schemaVersion===d$1}function fe(e,a,r){let t=a.scope==="project"&&a.projectPath?a.projectPath:".",o=c$1.isAbsolute(t)?c$1.resolve(t):c$1.resolve(e,t);if(!E(e,o)&&!(r&&c$1.resolve(r)===o))throw new Error(`Repair project scope escapes workspace: ${t}`);return o}function v(e){return {cwd:O(e.workspacePath,e.projectPath,e.projectPath),executable:e.executable,args:[...e.args],purpose:e.purpose,timeoutMs:e.timeoutMs??6e5}}async function $e(e){return k.readFile(e,"utf8").catch(()=>"")}async function Da(e){return k.readJson(e).catch(()=>({}))}function ia(e){let a=e.manager==="yarn"?[e.script]:["run",e.script];return v({...e,executable:e.manager,args:a,purpose:e.purpose})}function Fa(e){let a=process.platform==="win32"?(process.env.PATHEXT??".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean).map(t=>t.toLowerCase()):[""],r=c$1.extname(e).length>0;return (process.env.PATH??"").split(c$1.delimiter).filter(Boolean).flatMap(t=>r?[c$1.join(t,e)]:a.map(o=>c$1.join(t,`${e}${o}`)))}function na(e){return e?.isFile()?process.platform==="win32"||(e.mode&73)!==0:false}async function ma(e){let a=c$1.resolve(e.workspacePath,e.invocation.cwd);if(e.toolAvailable)return e.toolAvailable(e.invocation.executable,a);let r=e.invocation.executable;if(c$1.isAbsolute(r)||/^\.{1,2}[\\/]/.test(r)){let t=c$1.isAbsolute(r)?r:c$1.resolve(a,r),o=await k.stat(t).catch(()=>{});return na(o)}for(let t of Fa(r)){let o=await k.stat(t).catch(()=>{});if(na(o))return true}return false}async function Ne(e){let a=new Set;for(let s of e.stages){if(s.kind!=="repair"||!s.invocation)continue;let d=xe(s.invocation.executable);!["python","python3","py"].includes(d)||!s.invocation.args.includes("venv")||!s.invocation.args.includes(".venv")||a.add(c$1.normalize(c$1.join(c$1.resolve(e.workspacePath,s.invocation.cwd),".venv",process.platform==="win32"?"Scripts/python.exe":"bin/python")));}let r=e.stages.filter(s=>s.required&&s.status!=="skipped"&&s.invocation).map(s=>s.invocation),t=new Map;for(let s of r)t.set(`${s.cwd}\0${s.executable}`,s);let o=[];for(let s of t.values()){let d=c$1.isAbsolute(s.executable)?c$1.normalize(s.executable):c$1.normalize(c$1.resolve(e.workspacePath,s.cwd,s.executable));if(a.has(d)){o.push({id:`tool:${s.cwd}:${s.executable}`,status:"passed",message:`Repair stage will create the isolated executable before use: ${s.executable} (${s.cwd}).`});continue}let i=await ma({workspacePath:e.workspacePath,invocation:s,toolAvailable:e.toolAvailable});o.push({id:`tool:${s.cwd}:${s.executable}`,status:i?"passed":"failed",message:i?`Required repair executable is available: ${s.executable} (${s.cwd}).`:`Required repair executable is unavailable: ${s.executable} (${s.cwd}). Install or configure it, then create a fresh plan.`});}return o}function X(e,a,r){return {id:e,kind:a,status:"skipped",required:false,risk:"safe",summary:r}}function y(e){return {id:e.id,kind:e.kind,status:e.invocation?"pending":e.required===false?"skipped":"blocked",required:e.required??true,risk:e.risk??"safe",summary:e.summary,...e.invocation?{invocation:e.invocation}:{}}}function Ha(e,a,r){let t=r.strategy?.find(o=>o.kind==="verify"&&o.invocation)?.invocation;if(t)return v({workspacePath:e,projectPath:a,executable:t.executable,args:t.args,purpose:"audit"})}async function Oa(e){let a=fe(e.workspacePath,e.action,e.authorizedProjectRoot),r=O(e.workspacePath,a,a),t=async p=>k.pathExists(c$1.join(a,p)),o=new Set,s=[],d=[],i=p=>`${r}:${e.adapterId}:${p}`,g$1=p=>p.forEach(u=>o.add(O(e.workspacePath,c$1.join(a,u),a))),n=p=>{s.push(p),p.required&&p.status==="blocked"&&d.push(p.summary);},f=Ha(e.workspacePath,a,e.action),m=()=>{let p=g.find(u=>u.id===e.adapterId);if(!p)throw new Error(`Unknown workspace repair adapter: ${e.adapterId}`);return {stages:s,checkpointFiles:[...o],blockers:d,adapters:[{adapterId:p.id,ecosystem:p.ecosystem,projectPath:r,manifests:p.manifests,support:p.support,status:d.length>0?"partial":"ready",requiredExecutables:[...new Set(s.filter(u=>u.required&&u.invocation).map(u=>u.invocation.executable))],missingExecutables:[],message:d.length>0?[...new Set(d)].join(" "):`${p.ecosystem} repair stages are deterministically planned.`}]}};if(e.adapterId==="node"&&await t("package.json")){let p=await Da(c$1.join(a,"package.json")),u=p.scripts&&typeof p.scripts=="object"&&!Array.isArray(p.scripts)?p.scripts:{},w=await t("bun.lock")||await t("bun.lockb")?"bun":await t("pnpm-lock.yaml")?"pnpm":await t("yarn.lock")?"yarn":"npm",T=w==="bun"?await t("bun.lock")?"bun.lock":"bun.lockb":w==="pnpm"?"pnpm-lock.yaml":w==="yarn"?"yarn.lock":await t("npm-shrinkwrap.json")?"npm-shrinkwrap.json":"package-lock.json";g$1(["package.json",T]),n(y({id:i("reconcile"),kind:"reconcile",risk:"guarded",summary:`Reconcile ${w} manifest, lockfile, and installed tree.`,invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:w,args:["install"],purpose:"reconcile"})}));let L=v(w==="npm"?{workspacePath:e.workspacePath,projectPath:a,executable:"npm",args:["audit","--audit-level=moderate","--json"],purpose:"audit"}:w==="pnpm"?{workspacePath:e.workspacePath,projectPath:a,executable:"pnpm",args:["audit","--audit-level=moderate","--json"],purpose:"audit"}:w==="yarn"?{workspacePath:e.workspacePath,projectPath:a,executable:"yarn",args:["npm","audit","--json","--severity","moderate"],purpose:"audit"}:{workspacePath:e.workspacePath,projectPath:a,executable:"bun",args:["audit","--json"],purpose:"audit"});return n(y({id:i("audit"),kind:"audit",summary:"Prove the dependency advisory graph is clean.",invocation:f??L})),n(typeof u.test=="string"&&u.test.trim()?y({id:i("test"),kind:"test",summary:"Run the declared project test contract.",invocation:ia({workspacePath:e.workspacePath,projectPath:a,manager:w,script:"test",purpose:"test"})}):X(i("test"),"test","No test script is declared.")),n(typeof u.build=="string"&&u.build.trim()?y({id:i("build"),kind:"build",summary:"Run the declared project build contract.",invocation:ia({workspacePath:e.workspacePath,projectPath:a,manager:w,script:"build",purpose:"build"})}):X(i("build"),"build","No build script is declared.")),m()}if(e.adapterId==="python"&&(await t("pyproject.toml")||await t("requirements.txt"))){g$1(["pyproject.toml","requirements.txt","uv.lock","poetry.lock"]);let p=e.action.transaction?.ecosystem.toLowerCase(),u=c$1.basename(e.action.invocation?.executable??"").toLowerCase().replace(/\.(?:cmd|bat|exe)$/i,""),w=u==="uv"||p==="uv"||await t("uv.lock"),T=!w&&(u==="poetry"||p==="poetry"||await t("poetry.lock")),L=!w&&!T&&["python","python3","py"].includes(u)&&(e.action.invocation?.args??[]).some(ae=>ae==="venv")&&(e.action.invocation?.args??[]).some(ae=>ae===".venv"),j=process.platform==="win32"?"python":"python3",W=c$1.join(a,".venv",process.platform==="win32"?"Scripts/python.exe":"bin/python");(await k.pathExists(W)||L)&&(j=W);let Q=w?v({workspacePath:e.workspacePath,projectPath:a,executable:"uv",args:["sync"],purpose:"reconcile"}):T?v({workspacePath:e.workspacePath,projectPath:a,executable:"poetry",args:["install","--no-interaction"],purpose:"reconcile"}):await t("requirements.txt")&&E(e.workspacePath,j)?v({workspacePath:e.workspacePath,projectPath:a,executable:j,args:["-m","pip","install","-r","requirements.txt"],purpose:"reconcile"}):await t("pyproject.toml")&&E(e.workspacePath,j)?v({workspacePath:e.workspacePath,projectPath:a,executable:j,args:["-m","pip","install","-e","."],purpose:"reconcile"}):void 0;n(y({id:i("reconcile"),kind:"reconcile",risk:"guarded",summary:"Reconcile the isolated Python dependency environment.",invocation:Q})),n(y({id:i("audit"),kind:"audit",summary:"Prove the Python advisory graph is clean.",invocation:f}));let M=await $e(c$1.join(a,"pyproject.toml")),G=await t("tests")||/\[tool\.pytest/i.test(M),ee=v(T?{workspacePath:e.workspacePath,projectPath:a,executable:"poetry",args:["run","python","-m","pytest"],purpose:"test"}:w?{workspacePath:e.workspacePath,projectPath:a,executable:"uv",args:["run","python","-m","pytest"],purpose:"test"}:{workspacePath:e.workspacePath,projectPath:a,executable:j,args:["-m","pytest"],purpose:"test"}),B=v(T?{workspacePath:e.workspacePath,projectPath:a,executable:"poetry",args:["build"],purpose:"build"}:w?{workspacePath:e.workspacePath,projectPath:a,executable:"uv",args:["build"],purpose:"build"}:{workspacePath:e.workspacePath,projectPath:a,executable:j,args:["-m","build"],purpose:"build"});return n(G?y({id:i("test"),kind:"test",summary:"Run the Python test contract.",invocation:ee}):X(i("test"),"test","No Python test surface is declared.")),n(/\[build-system\]/i.test(M)?y({id:i("build"),kind:"build",summary:"Build the declared Python package.",invocation:B}):X(i("build"),"build","No Python build contract is declared.")),m()}let b=[{adapterId:"go",manifest:"go.mod",files:["go.mod","go.sum"],reconcile:["go",["mod","tidy"]],audit:["govulncheck",["-json","./..."]],test:["go",["test","./..."]],build:["go",["build","./..."]]},{adapterId:"rust",manifest:"Cargo.toml",files:["Cargo.toml","Cargo.lock"],reconcile:["cargo",["check"]],audit:["cargo",["audit","--json"]],test:["cargo",["test"]],build:["cargo",["build"]]},{adapterId:"php-composer",manifest:"composer.json",files:["composer.json","composer.lock"],reconcile:["composer",["install","--no-interaction"]],audit:["composer",["audit","--format=json"]],test:["composer",["run-script","test"]],build:["composer",["run-script","build"]]},{adapterId:"ruby-bundler",manifest:"Gemfile",files:["Gemfile","Gemfile.lock"],reconcile:["bundle",["install"]],audit:["bundle-audit",["check","--format","json"]],test:["bundle",["exec","rake","test"]],build:["bundle",["exec","rake","build"]]},{adapterId:"elixir-mix",manifest:"mix.exs",files:["mix.exs","mix.lock"],reconcile:["mix",["deps.get"]],audit:["mix",["hex.audit"]],test:["mix",["test"]],build:["mix",["compile","--warnings-as-errors"]]},{adapterId:"deno",manifest:"deno.json",alternateManifest:"deno.jsonc",files:["deno.json","deno.lock"],reconcile:["deno",["install"]],audit:["deno",["audit"]],test:["deno",["task","test"]],build:["deno",["task","build"]]}];for(let p of b){if(p.adapterId!==e.adapterId)continue;let u=await t(p.manifest)?p.manifest:p.alternateManifest&&await t(p.alternateManifest)?p.alternateManifest:void 0;if(!u)continue;g$1(p.files),n(y({id:i("reconcile"),kind:"reconcile",risk:"guarded",summary:`Reconcile ${u} and its lock/baseline.`,invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:p.reconcile[0],args:p.reconcile[1],purpose:"reconcile"})})),n(y({id:i("audit"),kind:"audit",summary:"Run the runtime-native dependency audit.",invocation:f??(p.audit?v({workspacePath:e.workspacePath,projectPath:a,executable:p.audit[0],args:p.audit[1],purpose:"audit"}):void 0)}));let w=await $e(c$1.join(a,u)),T=p.manifest==="composer.json"||p.adapterId==="deno"?/["']test["']\s*:/.test(w):p.manifest==="Gemfile"?await t("Rakefile"):true,L=p.manifest==="composer.json"||p.manifest==="deno.json"?/["']build["']\s*:/.test(w):p.manifest==="Gemfile"?(await k.readdir(a)).some(j=>j.endsWith(".gemspec")):true;return n(T?y({id:i("test"),kind:"test",summary:"Run the runtime-native test contract.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:p.test[0],args:p.test[1],purpose:"test"})}):X(i("test"),"test","No test contract is declared.")),n(L?y({id:i("build"),kind:"build",summary:"Run the runtime-native build contract.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:p.build[0],args:p.build[1],purpose:"build"})}):X(i("build"),"build","No build contract is declared.")),m()}let R=await k.readdir(a).catch(()=>[]);if(e.adapterId==="dotnet"&&R.some(p=>/\.(?:cs|fs|vb)proj$|\.sln$/i.test(p)))return g$1(["Directory.Packages.props","packages.lock.json",...R.filter(p=>/\.(?:cs|fs|vb)proj$|\.sln$/i.test(p))]),n(y({id:i("reconcile"),kind:"reconcile",risk:"guarded",summary:"Restore the NuGet dependency graph.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:"dotnet",args:["restore"],purpose:"reconcile"})})),n(y({id:i("audit"),kind:"audit",summary:"Prove the NuGet advisory graph is clean.",invocation:f??v({workspacePath:e.workspacePath,projectPath:a,executable:"dotnet",args:["package","list","--vulnerable","--include-transitive","--format","json"],purpose:"audit"})})),n(y({id:i("test"),kind:"test",summary:"Run .NET tests.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:"dotnet",args:["test","--no-restore"],purpose:"test"})})),n(y({id:i("build"),kind:"build",summary:"Build the .NET project.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:"dotnet",args:["build","--no-restore"],purpose:"build"})})),m();let x=await t("mvnw")?"./mvnw":await t("mvnw.cmd")?".\\mvnw.cmd":"mvn";if(e.adapterId==="jvm-maven"&&await t("pom.xml"))return g$1(["pom.xml"]),n(y({id:i("reconcile"),kind:"reconcile",risk:"guarded",summary:"Resolve the Maven dependency graph.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:x,args:["dependency:resolve"],purpose:"reconcile"})})),n(y({id:i("audit"),kind:"audit",summary:"Run the declared JVM dependency audit.",invocation:f})),n(y({id:i("test"),kind:"test",summary:"Run Maven tests.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:x,args:["test"],purpose:"test"})})),n(y({id:i("build"),kind:"build",summary:"Build the Maven artifact.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:x,args:["package","-DskipTests"],purpose:"build"})})),m();let A=await t("build.gradle.kts")?"build.gradle.kts":await t("build.gradle")?"build.gradle":void 0;if(e.adapterId==="jvm-gradle"&&A){let p=await t("gradlew")?"./gradlew":await t("gradlew.bat")?".\\gradlew.bat":"gradle";return g$1([A,"gradle.lockfile","gradle/libs.versions.toml"]),n(y({id:i("reconcile"),kind:"reconcile",risk:"guarded",summary:"Resolve the Gradle dependency graph.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:p,args:["dependencies"],purpose:"reconcile"})})),n(y({id:i("audit"),kind:"audit",summary:"Run the declared JVM dependency audit.",invocation:f})),n(y({id:i("test"),kind:"test",summary:"Run Gradle tests.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:p,args:["test"],purpose:"test"})})),n(y({id:i("build"),kind:"build",summary:"Build the Gradle project.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:p,args:["build","-x","test"],purpose:"build"})})),m()}let q=await t("deps.edn")?"deps.edn":await t("project.clj")?"project.clj":void 0;if(e.adapterId==="clojure"&&q){let p=q==="deps.edn",u=await $e(c$1.join(a,q)),w=p?"clojure":"lein";g$1([q]),n(y({id:i("reconcile"),kind:"reconcile",risk:"guarded",summary:`Resolve the ${q} dependency graph.`,invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:w,args:p?["-P"]:["deps"],purpose:"reconcile"})})),n(y({id:i("audit"),kind:"audit",summary:"Run the declared Clojure dependency audit.",invocation:f}));let T=!p||/:test\b/.test(u);return n(T?y({id:i("test"),kind:"test",summary:"Run the declared Clojure test contract.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:w,args:p?["-M:test"]:["test"],purpose:"test"})}):X(i("test"),"test","No Clojure :test alias is declared.")),n(p?X(i("build"),"build","No portable Clojure CLI build entrypoint is declared."):y({id:i("build"),kind:"build",summary:"Build the Leiningen project artifact.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:"lein",args:["uberjar"],purpose:"build"})})),m()}return e.adapterId==="scala-sbt"&&await t("build.sbt")?(g$1(["build.sbt"]),n(y({id:i("reconcile"),kind:"reconcile",risk:"guarded",summary:"Resolve and compile the sbt dependency graph.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:"sbt",args:["compile"],purpose:"reconcile"})})),n(y({id:i("audit"),kind:"audit",summary:"Run the declared Scala dependency audit.",invocation:f})),n(y({id:i("test"),kind:"test",summary:"Run sbt tests.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:"sbt",args:["test"],purpose:"test"})})),n(y({id:i("build"),kind:"build",summary:"Build the sbt project artifact.",invocation:v({workspacePath:e.workspacePath,projectPath:a,executable:"sbt",args:["package"],purpose:"build"})})),m()):(d.push(`The ${e.adapterId} repair adapter no longer matches the source at ${r}; refresh evidence and create a fresh plan.`),n(y({id:i("reconcile"),kind:"reconcile",required:true,summary:d[0]})),m())}async function wa(e){let a=s=>k.pathExists(c$1.join(e,s)),r=await k.readdir(e).catch(()=>[]),t=[];await a("package.json")&&t.push("node"),(await a("pyproject.toml")||await a("requirements.txt"))&&t.push("python"),await a("go.mod")&&t.push("go"),await a("Cargo.toml")&&t.push("rust"),await a("composer.json")&&t.push("php-composer"),await a("Gemfile")&&t.push("ruby-bundler"),await a("mix.exs")&&t.push("elixir-mix"),(await a("deno.json")||await a("deno.jsonc"))&&t.push("deno"),r.some(s=>/\.(?:cs|fs|vb)proj$|\.sln$/i.test(s))&&t.push("dotnet"),await a("pom.xml")&&t.push("jvm-maven"),(await a("build.gradle.kts")||await a("build.gradle"))&&t.push("jvm-gradle"),(await a("deps.edn")||await a("project.clj"))&&t.push("clojure"),await a("build.sbt")&&t.push("scala-sbt");let o=new Map(g.map((s,d)=>[s.id,d]));return [...new Set(t)].sort((s,d)=>(o.get(s)??999)-(o.get(d)??999))}function Ma(e){let a=e?.trim().toLowerCase();if(a){if(["npm","pnpm","yarn","bun","node","javascript","typescript"].includes(a))return "node";if(["python","pip","poetry","uv"].includes(a))return "python";if(["go","gomod","go-modules"].includes(a))return "go";if(["rust","cargo"].includes(a))return "rust";if(["php","composer"].includes(a))return "php-composer";if(["ruby","bundler","bundle"].includes(a))return "ruby-bundler";if(["elixir","mix"].includes(a))return "elixir-mix";if(a==="deno")return "deno";if(["dotnet",".net","nuget"].includes(a))return "dotnet";if(["maven","jvm-maven"].includes(a))return "jvm-maven";if(["gradle","jvm-gradle"].includes(a))return "jvm-gradle";if(["clojure","lein","leiningen"].includes(a))return "clojure";if(["scala","sbt","scala-sbt"].includes(a))return "scala-sbt"}}async function ba(e,a={}){let r=fe(e.workspacePath,e.action,e.authorizedProjectRoot),t=O(e.workspacePath,r,r),o=await wa(r),s=Ma(e.action.transaction?.ecosystem),d=s?[s]:o;if(s&&!o.includes(s)){let n=`Doctor declared the ${s} repair adapter for ${t}, but its canonical manifest is not present. Refresh Doctor evidence before repair.`;return {stages:[y({id:`${t}:${s}:reconcile`,kind:"reconcile",required:true,summary:n})],checkpointFiles:[],blockers:[n],adapters:[{adapterId:s,ecosystem:g.find(f=>f.id===s)?.ecosystem??s,projectPath:t,manifests:[],support:"conditional",status:"partial",requiredExecutables:[],missingExecutables:[],message:n}]}}if(d.length===0){let n=`No deterministic dependency transaction adapter exists for ${t}.`;return {stages:[y({id:`${t}:unsupported:reconcile`,kind:"reconcile",required:true,summary:n})],checkpointFiles:[],blockers:[n],adapters:[{adapterId:"unsupported",ecosystem:"Unknown",projectPath:t,manifests:[],support:"unsupported",status:"unsupported",requiredExecutables:[],missingExecutables:[],message:n}]}}let i={stages:[],checkpointFiles:[],blockers:[],adapters:[]};for(let n of d){let f=await Oa({...e,adapterId:n});i.stages.push(...f.stages),i.checkpointFiles.push(...f.checkpointFiles),i.blockers.push(...f.blockers),i.adapters.push(...f.adapters);}i.stages=[...new Map(i.stages.map(n=>[n.id,n])).values()],i.checkpointFiles=[...new Set(i.checkpointFiles)].sort(),i.blockers=[...new Set(i.blockers)];let g$1=new Set;if(e.action.transaction?.kind==="dependency-materialization"){let n=new Set(e.action.transaction.requiredStages),f=xe(e.action.invocation?.executable??""),m=e.action.invocation?.args??[],b=e.action.transaction.ecosystem==="python"&&["python","python3","py"].includes(f)&&m.includes("venv")&&m.includes(".venv");b&&g$1.add(c$1.normalize(c$1.join(r,".venv",process.platform==="win32"?"Scripts/python.exe":"bin/python"))),i.stages=i.stages.filter(R=>R.kind==="reconcile"?b&&n.has("reconcile"):n.has(R.kind)),i.blockers=i.stages.filter(R=>R.required&&R.status==="blocked").map(R=>R.summary);}for(let n of i.adapters){let f=i.stages.filter(b=>b.id.startsWith(`${n.projectPath}:${n.adapterId}:`)),m=[];n.requiredExecutables=[...new Set(f.filter(b=>b.required&&b.invocation).map(b=>b.invocation.executable))];for(let b of f){if(!b.required||!b.invocation)continue;let R=c$1.isAbsolute(b.invocation.executable)?c$1.normalize(b.invocation.executable):c$1.normalize(c$1.resolve(e.workspacePath,b.invocation.cwd,b.invocation.executable));g$1.has(R)||await ma({workspacePath:e.workspacePath,invocation:b.invocation,toolAvailable:a.toolAvailable})||m.push(b.invocation.executable);}n.missingExecutables=[...new Set(m)],n.missingExecutables.length>0&&(n.status="partial",n.message=`Required executable(s) unavailable: ${n.missingExecutables.join(", ")}.`);}if(d.length===1){let n=`:${d[0]}:`;for(let f of i.stages)f.id=f.id.replace(n,":");}return i}async function $t(e={}){let a=h();if(!e.workspacePath&&!e.projectPath&&!e.project)return a;let r=c$1.resolve(e.workspacePath??process.cwd()),t,o;if(e.project?.trim()){let s=e.project.trim(),d=await h$1(r),i=s.replace(/\\/g,"/").replace(/^\.\//,""),g=c$1.resolve(r,s),n=d.resolved.filter(f=>{let m=E(r,f.projectPath)?O(r,f.projectPath):void 0;return f.name===s||m===i||c$1.resolve(f.projectPath)===g});if(n.length===0){let f=d.skipped.find(m=>m.name===s);throw f?new Error(`Registered project is unavailable for repair capability inspection: ${s} (${f.reason}).`):new Error(`Registered project not found for repair capability inspection: ${s}.`)}if(n.length>1)throw new Error(`Project reference is ambiguous for repair capability inspection: ${s}.`);t=c$1.resolve(n[0].projectPath),o=n[0].name;}else {if(t=c$1.resolve(r,e.projectPath??"."),!E(r,t))throw new Error("Repair capability inspection project path escapes the workspace.");o=O(r,t);}return {...a,inspection:{projectPath:o,detectedAdapters:await wa(t)}}}function Re(e){if(e.command){let a=d$2(e.command);if(a)return a}return a$4(e.operation)??void 0}async function Ba(e){let a=new Set(e.dependencyFiles);for(let r of e.actions){let t=fe(e.workspacePath,r);if(!await _(e.workspacePath,t))throw new Error(`Repair project scope escapes workspace through a symbolic link: ${t}`);for(let d of r.files){let i=c$1.isAbsolute(d)?c$1.resolve(d):c$1.resolve(e.workspacePath,d);if(!await _(e.workspacePath,i))throw new Error(`Repair checkpoint path escapes workspace through a symbolic link: ${d}`);a.add(O(e.workspacePath,d));}let o=Re(r);if(!o)continue;let s="path"in o?o.path:void 0;if(s){let d=c$1.resolve(t,s);if(!await _(e.workspacePath,d))throw new Error(`Repair operation target escapes workspace through a symbolic link: ${s}`);a.add(O(e.workspacePath,d));}}return [...a].filter(r=>r!==".").sort()}function _a(e,a){if(!a.invocation)return;let r=fe(e,a);return v({workspacePath:e,projectPath:r,executable:a.invocation.executable,args:a.invocation.args,purpose:"repair"})}function qe(e){return $(K({sourceEvidenceHash:e.sourceEvidenceHash,target:e.target,policy:e.policy,preconditions:e.preconditions,adapterEvaluations:e.adapterEvaluations??[],stages:e.stages.map(a=>({id:a.id,kind:a.kind,required:a.required,risk:a.risk,...a.invocation?{invocation:a.invocation}:{}})),checkpointFiles:e.checkpointFiles.map(a=>({path:a.path,existed:a.existed,beforeHash:a.beforeHash,...a.mode!==void 0?{mode:a.mode}:{}}))}))}function De(e){return qe({sourceEvidenceHash:e.integrity.sourceEvidenceHash,target:e.target,policy:e.policy,preconditions:e.preconditions,adapterEvaluations:e.adapterEvaluations,stages:e.stages.filter(a=>a.kind!=="rollback"),checkpointFiles:e.checkpoint.files})}function va(e){return $(K({transactionId:e.transactionId,state:e.state,planHash:e.integrity.planHash,sourceEvidenceHash:e.integrity.sourceEvidenceHash,approvedPlanHash:e.approval.approvedPlanHash,checkpoint:{status:e.checkpoint.status,files:e.checkpoint.files.map(a=>({path:a.path,existed:a.existed,beforeHash:a.beforeHash,afterHash:a.afterHash??null,...a.mode!==void 0?{mode:a.mode}:{}}))},verification:e.verification}))}async function St(e){let a=c$1.resolve(e.workspacePath),r=await se({workspacePath:a,transactionId:e.transactionId}),t=await Pe(a,e.transactionId);if(r.state!=="closed"||r.approval.status!=="approved"||r.approval.approvedPlanHash!==r.integrity.planHash||De(r)!==r.integrity.planHash||!r.integrity.closureHash||va(r)!==r.integrity.closureHash||$(K(t))!==r.integrity.sourceEvidenceHash||!re(t)||t.goalId!==e.goalId||r.verification?.status!=="passed"||r.verification.targetStatus!=="passed"||!r.verification.sourceBinding||r.checkpoint.status!=="captured")throw new Error(`Goal repair transaction is not a current, closed, integrity-bound source transition: ${e.transactionId}`);let o=be(a,r);for(let s of r.checkpoint.files){let d=c$1.resolve(a,s.path);if(!E(a,d)&&!(o&&E(o,d)))throw new Error(`Goal repair checkpoint escaped its canonical source boundary: ${s.path}`);let i=await k.lstat(d).catch(()=>{});if(!i){if(s.afterHash!==null)throw new Error(`Goal repair output is no longer current: ${s.path}`);continue}if(!i.isFile()||i.isSymbolicLink())throw new Error(`Goal repair output is no longer a regular source file: ${s.path}`);let g=await k.readFile(d);if(s.afterHash!==$(g))throw new Error(`Goal repair output changed after transaction closure: ${s.path}`);if(s.mode!==void 0&&i.mode!==s.mode)throw new Error(`Goal repair output mode changed after transaction closure: ${s.path}`)}return r.verification.sourceBinding}async function ve(e,a,r){let t=[],o=[],s=0;for(let d of a){let i=c$1.resolve(e,d),g=r&&E(c$1.resolve(r),i)?c$1.resolve(r):e;if(!E(g,i)){o.push(`Checkpoint path escapes authorized workspace/project boundaries: ${d}`);continue}if(!await _(g,i)){o.push(`Checkpoint path resolves through a link outside its authorized boundary: ${d}`);continue}let n=await k.lstat(i).catch(()=>{});if(n?.isSymbolicLink()){o.push(`Checkpoint refuses symbolic link mutation: ${d}`);continue}if(n&&!n.isFile()){o.push(`Checkpoint target is not a regular file: ${d}`);continue}if(n&&n.size>ua){o.push(`Checkpoint file exceeds 5 MiB: ${d}`);continue}if(s+=n?.size??0,s>Aa){o.push("Checkpoint exceeds the 25 MiB transaction limit.");break}let f=n?await k.readFile(i):void 0;t.push({path:d,existed:!!n,beforeHash:f?$(f):null,...n?{mode:n.mode}:{}});}return {entries:t,errors:o}}function ya(e){let a=e.replaceAll("\\","/"),r=a.split("/"),t=r.at(-1)??a;if(a===".workspai-workspace"||a.startsWith(".workspai/"))return "Canonical workspace state and evidence cannot be edited through a model proposal.";if(a===".git"||a.startsWith(".git/"))return "Git internals cannot be edited through a model proposal.";if(r.includes("node_modules"))return "Installed dependency trees cannot be edited through a model proposal.";if(/^\.env(?:\.|$)/i.test(t)&&!/^\.env\.(?:example|sample|template)$/i.test(t))return "Secret-bearing environment files cannot be edited through a model proposal.";if(/\.(?:pem|key|p12|pfx|jks|keystore)$/i.test(t))return "Private key and credential containers cannot be edited through a model proposal."}async function La(e){let a=await k.readJson(c$1.join(e,".workspai-workspace")).catch(()=>{});return typeof a?.name=="string"&&a.name.trim()?a.name.trim():c$1.basename(e)}function Ga(e){return Wa.has(e)||/\.(?:cs|fs|vb)proj$|\.sln$/i.test(e)}async function Va(e,a){let r=c$1.resolve(e,a),t=c$1.dirname(r);for(;E(e,t);){if((await k.readdir(t).catch(()=>[])).some(Ga))return t;if(c$1.resolve(t)===c$1.resolve(e))break;t=c$1.dirname(t);}return e}function Ka(e,a,r){return r.some(t=>{let o=c$1.resolve(e,t.path);if(!E(a,o))return false;let s=c$1.basename(o);return Ca.has(s)||/\.(?:cs|fs|vb)proj$|\.sln$/i.test(s)})}function za(e){let a=O(e.workspacePath,e.projectPath,e.projectPath);return {id:`proposal:${e.proposal.cardId}:${a}`,artifactKind:"workspace-repair-proposal",cardId:e.proposal.cardId,findingId:e.proposal.targetActionIds?.[0]??e.proposal.blockerSignature??"proposal",findingStatus:"blocking",causalKey:[e.proposal.cardId,e.proposal.projectName??a,e.proposal.targetActionIds?.[0]??e.proposal.blockerSignature??"proposal"].map(r=>r.trim().toLowerCase()).join(":"),title:"Validate model-proposed repair",order:1,phase:"source-repair",scope:a==="."?"workspace":"project",...e.proposal.projectName?{projectName:e.proposal.projectName}:{},...a!=="."?{projectPath:a}:{},status:"ready",mode:"edit-file",risk:"guarded",requiresApproval:true,blocker:"",summary:e.proposal.rationale,verifyCommand:"workspai workspace intelligence run --for-agent generic --strict --json",cwd:a==="."?"workspace":"project",files:e.proposal.changes.map(r=>r.path),rollback:{available:true,strategy:"idempotent"},notes:["Source changes are applied only by the CLI Repair Engine after hash-bound approval."]}}function Ja(e,a){let r=xe(a.executable),[t="",o=""]=a.args;if(a.args.some(i=>/^(?:-e|--eval|-c|--command|-command)$/i.test(i)))throw new Error(`Validation ${e.id} cannot execute inline program text.`);let s=["npm","pnpm","yarn","bun"].includes(r);if(!(s&&e.kind==="audit"&&a.args.some(i=>/audit/i.test(i))||s&&["test","build"].includes(e.kind)&&(t==="run"||t===e.kind||o===e.kind)||["pytest","pip-audit","govulncheck","bundle-audit"].includes(r)||["python","python3","py"].includes(r)&&t==="-m"&&["pytest","unittest","build","pip_audit"].includes(o.replaceAll("-","_"))||r==="poetry"&&["run","check"].includes(t)||r==="uv"&&t==="run"||r==="go"&&["test","build","vet"].includes(t)||r==="cargo"&&["test","build","check","audit"].includes(t)||r==="composer"&&["audit","run-script","validate"].includes(t)||r==="bundle"&&t==="exec"&&o==="rake"||r==="dotnet"&&["test","build"].includes(t)||["mvn","mvnw","gradle","gradlew"].includes(r)&&a.args.some(i=>/^(?:test|build|check|verify|package)$/i.test(i))||r==="mix"&&(t==="test"||t==="compile"||t==="hex.audit"&&e.kind==="audit")||r==="clojure"&&t==="-M:test"&&e.kind==="test"||r==="lein"&&(t==="test"&&e.kind==="test"||t==="uberjar"&&e.kind==="build")||r==="sbt"&&(t==="test"&&e.kind==="test"||t==="package"&&e.kind==="build")||r==="deno"&&(t==="test"||t==="task"&&["test","build"].includes(o))))throw new Error(`Validation ${e.id} must use a runtime-native audit, test, or build command; arbitrary executables are not accepted from a model.`)}async function Ua(e){let a=[],r=new Set,t=[],o=[],s=new Set,d=e.proposal.projectPath?c$1.resolve(e.workspacePath,e.proposal.projectPath):void 0;for(let i of e.proposal.validation??[]){let g=c$1.resolve(e.workspacePath,i.cwd),n=O(e.workspacePath,g,d),f=await k.lstat(g).catch(()=>{});if(!f?.isDirectory()||f.isSymbolicLink()||!await _(d??e.workspacePath,g)){t.push(`Validation ${i.id} requires a real directory inside the workspace.`);continue}if(d&&!E(d,g)){t.push(`Validation ${i.id} escapes the declared project scope.`);continue}if(H[i.risk]>H[e.maxRisk]){t.push(`Validation ${i.id} exceeds the approved ${e.maxRisk} risk ceiling.`);continue}let m=v({workspacePath:e.workspacePath,projectPath:g,executable:i.executable,args:i.args,purpose:i.kind,timeoutMs:i.timeoutMs});try{Fe(e.workspacePath,m,e.policy,e.projectRoots),Ja(i,m);}catch(b){t.push(b instanceof Error?b.message:String(b));continue}a.push(y({id:`validation:${i.id}`,kind:i.kind,risk:i.risk,required:i.required,summary:i.summary,invocation:m})),s.add(`${n}:${i.kind}`);}for(let i of e.projectRoots){let g=za({workspacePath:e.workspacePath,projectPath:i,proposal:e.proposal}),n=await ba({workspacePath:e.workspacePath,action:g,authorizedProjectRoot:i},e.dependencies);o.push(...n.adapters);let f=Ka(e.workspacePath,i,e.proposal.changes);if(f){for(let b of n.checkpointFiles)r.add(b);t.push(...n.blockers);}let m=O(e.workspacePath,i,i);for(let b of n.stages)!f&&!["test","build"].includes(b.kind)||s.has(`${m}:${b.kind}`)||a.push(b);}return {stages:[...new Map(a.map(i=>[i.id,i])).values()],checkpointFiles:[...r],blockers:[...new Set(t)],adapters:[...new Map(o.map(i=>[`${i.projectPath}:${i.adapterId}`,i])).values()]}}async function Ya(e,a$3={}){let r=c$1.resolve(e.workspacePath),t=await a$2({workspacePath:r,includeAbsolutePaths:false,ciMode:true}),o=t.actions.filter(h=>h.cardId===e.cardId).filter(h=>!e.projectName||h.projectName===e.projectName).sort((h,C)=>h.order-C.order||h.id.localeCompare(C.id)),s=e.actionId?o.filter(h=>h.id===e.actionId):o,d=t.actions.filter(h=>!e.projectName||!h.projectName||h.projectName===e.projectName).sort((h,C)=>h.order-C.order||h.id.localeCompare(C.id)),i=new Map(d.map(h=>[h.id,h])),g=h=>{let C=new Set(h.map(ce=>ce.id)),N=[...h];for(;N.length>0;){let ce=N.pop();for(let V of ce?.dependsOn??[]){let Y=i.get(V);!Y||C.has(Y.id)||(C.add(Y.id),N.push(Y));}}return d.filter(ce=>C.has(ce.id))},n=s.filter(h=>h.findingStatus==="blocking"||h.notes.includes("Doctor finding status: blocking")),f=n.length>0?n:s.filter(h=>h.findingStatus!=="advisory"&&h.findingStatus!=="informational"),m=e.actionId?s.filter(h=>h.id===e.actionId):[],b$1=f[0],R=b$1?f.filter(h=>h.cardId===b$1.cardId&&h.findingId===b$1.findingId):[],x=g(e.actionId?m:R),A=e.maxRisk??"guarded",q={maxRisk:A,allowForce:e.allowForce===true,allowBreaking:e.allowBreaking===true,autoRollback:e.autoRollback!==false,strictVerify:true},p=[{id:"workspace-root",status:await k.pathExists(c$1.join(r,".workspai-workspace"))||await k.pathExists(c$1.join(r,".workspai"))?"passed":"failed",message:"Workspace root markers must exist."},{id:"actions-selected",status:x.length>0?"passed":"failed",message:x.length>0?`${x.length} governed action(s) selected.`:"No governed remediation action matches this target."}],u=ka(x);u&&p.push(u);let w=[],T=[],L=[],j=[],W=new Set(["manual-repair","cancel"]);for(let h of x){let C=Re(h),N=_a(r,h);if(H[h.risk]<=H[A]||(j.push(`${h.id} exceeds the approved ${A} risk ceiling.`),W.add(h.risk==="invasive"?"approve-invasive":"approve-guarded")),(h.status==="blocked"||h.status==="guidance-only")&&j.push(`${h.id} is ${h.status}: ${h.blocker}`),!C&&!N&&j.push(`${h.id} has no typed operation or structured invocation.`),N)try{Fe(r,N,q);}catch(V){let Y=V instanceof Error?V.message:String(V);j.push(Y),/Force-based/.test(Y)&&W.add("allow-force"),/Breaking dependency/.test(Y)&&W.add("allow-breaking");}if(w.push({id:`action:${h.id}`,kind:"repair",status:C||N?"pending":"blocked",required:true,risk:h.risk,summary:h.summary,...N?{invocation:N}:{}}),h.transaction){let V=await ba({workspacePath:r,action:h},a$3);w.push(...V.stages),T.push(...V.checkpointFiles),j.push(...V.blockers),L.push(...V.adapters);}}let Q=[...new Map(w.map(h=>[h.id,h])).values()];w.splice(0,w.length,...Q),w.unshift({id:"target-precondition",kind:"verify",status:"pending",required:true,risk:"safe",summary:"Refresh the exact producer and prove the approved causal target is still current before mutation."}),w.push({id:"target-producer-verify",kind:"verify",status:"pending",required:true,risk:"safe",summary:"Refresh the exact producer that owns the selected repair card."}),w.push({id:"canonical-verify",kind:"verify",status:"pending",required:true,risk:"safe",summary:"Run the complete canonical Workspace Intelligence loop in strict mode."}),p.push(...await Ne({workspacePath:r,stages:w,toolAvailable:a$3.toolAvailable}));let M=await Ba({workspacePath:r,actions:x,dependencyFiles:T}),G=await ve(r,M);p.push({id:"rollback-coverage",status:x.some(h=>h.mode==="edit-file"||h.mode==="run-command")&&M.length===0?"failed":"passed",message:M.length>0?`${M.length} bounded rollback candidate(s) identified.`:"No source file mutation is declared."}),p.push({id:"structured-execution",status:w.some(h=>h.required&&h.status==="blocked")?"failed":"passed",message:"Every executable stage must use a typed operation or structured invocation."}),p.push({id:"checkpoint-boundary",status:G.errors.length===0?"passed":"failed",message:G.errors.length===0?"Every mutable path is bounded, regular, size-limited, and hash-pinned.":G.errors.join(" ")});let ee=$(K(t)),B=[...new Set(x.map(h=>h.projectPath).filter(Boolean))],ae={cardId:e.cardId,scope:e.projectName||B.length===1?"project":"workspace",...e.projectName?{projectName:e.projectName}:{},...B.length===1?{projectPath:B[0]}:{},actionIds:x.map(h=>h.id)},ie=F(a$3.now),te=`repair_${randomUUID().replaceAll("-","")}`,ne=p.some(h=>h.status==="failed")||j.length>0,J=[...j,...p.filter(h=>h.status==="failed").map(h=>h.message)],le=[...new Map(L.map(h=>[`${h.projectPath}:${h.adapterId}`,h])).values()],l=ga({actions:x,adapters:le,preconditions:p,stages:w,decisionOptions:W,maxRisk:A,fallbackReasons:J}),S={schemaVersion:a,transactionId:te,revision:1,createdAt:ie,updatedAt:ie,workspace:{name:t.workspace.name,rootRef:"."},target:ae,state:ne?"decision-required":"awaiting-approval",policy:q,approval:{required:true,status:"pending"},preconditions:p,adapterEvaluations:le,checkpoint:{status:M.length>0?"pending":"unavailable",files:G.entries},stages:w,...ne?{decision:{reason:[...new Set(J)].join(" "),options:[...W],causes:l}}:{},events:[],integrity:{sourceEvidenceHash:ee,planHash:qe({sourceEvidenceHash:ee,target:ae,policy:q,preconditions:p,adapterEvaluations:le,stages:w,checkpointFiles:G.entries})}};I(S,"planned",ne?"Repair plan requires an engineering decision.":"Repair plan is ready for explicit approval.",{now:a$3.now}),a$1(S,c,"Workspace repair transaction");let U=oe(r,te);return await k.ensureDir(U),await Z(Te(r,te),t),await Z(ye(r,te),S),await Z(c$1.join(r,b),S),S}async function Xa(e,a={}){let r=e.proposal.goalId;if(!r)return ca(e,a);let t=c$1.resolve(e.workspacePath);return c$2(t,`.workspai/goals/${r}/repair-proposal`,()=>ca({...e,workspacePath:t},a))}async function ca(e$1,a$3={}){a$1(e$1.proposal,e,"Workspace repair proposal");let r=c$1.resolve(e$1.workspacePath),t=JSON.parse(JSON.stringify(e$1.proposal));if(t.goalId){let l=await k$1({workspacePath:r,goalId:t.goalId});if(!l.active||l.index.activeGoalId!==t.goalId)throw new Error(`Repair proposal Goal Pack is not active: ${t.goalId}`);if(l.goalPack?.state!=="ready-to-plan")throw new Error(`Repair proposal Goal Pack is not ready for proposal execution: ${l.goalPack?.state??"missing"}`);if((l.active.repairTransactionIds??(l.active.repairTransactionId?[l.active.repairTransactionId]:[])).length>=l.goalPack.policy.maxAttempts)throw new Error(`Goal ${t.goalId} exhausted its repair proposal budget (${l.goalPack.policy.maxAttempts}). Review the latest evidence before creating another Goal Pack.`);if(l.goalPack.scope.kind==="project"){let U=l.goalPack.scope.projects[0];if(!t.projectName||t.projectName!==U)throw new Error(`Goal-bound repair must declare the exact permitted projectName (${U}).`)}}let o$1=e$1.maxRisk??"guarded",s={maxRisk:o$1,allowForce:e$1.allowForce===true,allowBreaking:e$1.allowBreaking===true,autoRollback:e$1.autoRollback!==false,strictVerify:true},d=[],i=[],g=new Set(["manual-repair","cancel"]),n=await k.pathExists(c$1.join(r,".workspai-workspace"))||await k.pathExists(c$1.join(r,".workspai"));d.push({id:"workspace-root",status:n?"passed":"failed",message:n?"Canonical workspace root markers exist.":"Workspace root markers must exist."});let f;try{f=await qa({workspacePath:r,proposal:t});}catch(l){i.push(l instanceof Error?l.message:String(l));}if(f&&(t.projectName||t.projectPath)&&(t.projectPath=c$1.relative(r,f).split(c$1.sep).join("/")),t.projectPath){let l=f??c$1.resolve(r,t.projectPath),S=await k.lstat(l).catch(()=>{});(!S?.isDirectory()||S.isSymbolicLink())&&i.push("The declared project path must be a real canonical registered project directory.");}t.validation=t.validation?.map(l=>({...l,cwd:sa(r,l.cwd,f)}));let m=new Set,b$1=new Set,R=0;for(let l of t.changes){l.path=sa(r,l.path,f),l.path==="."&&i.push(`${l.id} cannot replace the workspace root.`),m.has(l.id)&&i.push(`Duplicate proposal change id: ${l.id}.`),b$1.has(l.path)&&i.push(`Multiple proposal changes target ${l.path}.`),m.add(l.id),b$1.add(l.path),R+=Buffer.byteLength(l.content??"","utf8"),R>$a&&i.push("The model proposal exceeds the 25 MiB source-change limit.");let S=ya(l.path);if(S&&i.push(`${l.path}: ${S}`),H[l.risk]>H[o$1]&&(i.push(`${l.id} exceeds the approved ${o$1} risk ceiling.`),g.add(l.risk==="invasive"?"approve-invasive":"approve-guarded")),t.projectPath){let U=c$1.resolve(r,t.projectPath),h=c$1.resolve(r,l.path);E(U,h)||i.push(`${l.path} escapes the declared project scope.`);}}let x=[...b$1].sort(),A=await ve(r,x,f);i.push(...A.errors);let q=new Map(A.entries.map(l=>[l.path,l]));for(let l of t.changes){let S=q.get(l.path);if(!S||S.beforeHash!==l.expectedBeforeHash){i.push(`${l.path} no longer matches the model's expected source hash; refresh context and re-propose.`);continue}l.operation==="delete"&&!S.existed&&i.push(`${l.path} cannot be deleted because it does not exist.`),l.operation==="write"&&S.beforeHash!==null&&$(l.content??"")===S.beforeHash&&i.push(`${l.path} is a no-op and cannot prove source progress.`);}d.push({id:"proposal-boundary",status:i.length===0?"passed":"failed",message:i.length===0?`${t.changes.length} unique, bounded, hash-pinned source change(s) validated.`:[...new Set(i)].join(" ")});let p=new Set;if(t.projectPath)p.add(f??c$1.resolve(r,t.projectPath));else for(let l of t.changes)p.add(await Va(r,l.path));let u=await Ua({workspacePath:r,proposal:t,projectRoots:[...p].sort(),maxRisk:o$1,policy:s,dependencies:a$3});i.push(...u.blockers);let w=u.stages,T=w.some(l=>l.status!=="skipped"&&["audit","test","build"].includes(l.kind));d.push({id:"validation-coverage",status:T?"passed":"unknown",message:T?"Runtime-native validation is included before canonical verification.":"No runtime-native test, build, or audit command was discovered; strict canonical verification remains mandatory."});let L=[...new Set([...x,...u.checkpointFiles])].sort(),j=await ve(r,L,f);i.push(...j.errors),d.push({id:"checkpoint-boundary",status:j.errors.length===0?"passed":"failed",message:j.errors.length===0?`${j.entries.length} mutable path(s) are bounded and hash-pinned for rollback.`:j.errors.join(" ")});let W=[{id:"target-precondition",kind:"verify",status:"pending",required:true,risk:"safe",summary:"Refresh the exact producer and prove the approved causal target is still current before mutation."},...t.changes.map(l=>({id:`proposal:${l.id}`,kind:"repair",status:H[l.risk]<=H[o$1]?"pending":"blocked",required:true,risk:l.risk,summary:l.summary,changedPaths:[l.path]})),...w,{id:"target-producer-verify",kind:"verify",status:"pending",required:true,risk:"safe",summary:"Refresh the exact producer that owns the selected repair card."},{id:"canonical-verify",kind:"verify",status:"pending",required:true,risk:"safe",summary:"Run the complete canonical Workspace Intelligence loop in strict mode."}];d.push(...await Ne({workspacePath:r,stages:W,toolAvailable:a$3.toolAvailable}));let Q=new Set(W.map(l=>l.id));Q.size!==W.length&&i.push("Repair proposal stage ids must be unique."),d.push({id:"stage-identity",status:Q.size===W.length?"passed":"failed",message:Q.size===W.length?"Every repair and validation stage has a stable unique identity.":"Repair proposal stage ids collide."});try{let l=await a$2({workspacePath:r,includeAbsolutePaths:false,ciMode:true});if(!t.targetActionIds?.length){let C=l.actions.filter(N=>N.cardId===t.cardId&&(!t.projectName||N.projectName===t.projectName)&&(!t.projectPath||N.projectPath===t.projectPath)).map(N=>N.id).sort();C.length>0&&(t.targetActionIds=C);}let S=new Set(t.targetActionIds??[]),U=l.actions.filter(C=>S.has(C.id)),h=ka(U);h&&d.push(h);}catch{}let M=$(K(t)),G={cardId:t.cardId,scope:t.projectPath||t.projectName?"project":"workspace",...t.projectName?{projectName:t.projectName}:{},...t.projectPath?{projectPath:t.projectPath}:{},...t.blockerSignature?{blockerSignature:t.blockerSignature}:{},actionIds:t.targetActionIds&&t.targetActionIds.length>0?[...new Set(t.targetActionIds)].sort():t.changes.map(l=>`proposal:${l.id}`)},ee=F(a$3.now),B=`repair_${randomUUID().replaceAll("-","")}`,ie=d.some(l=>l.status==="failed")||i.length>0,te=[...i,...d.filter(l=>l.status==="failed"&&l.id!=="proposal-boundary").map(l=>l.message)],ne=ga({adapters:u.adapters,preconditions:d,stages:W,decisionOptions:g,maxRisk:o$1,fallbackReasons:te});for(let l of t.changes)H[l.risk]<=H[o$1]||ne.push({kind:"risk-approval",id:`risk:${l.id}`,message:`${l.id} exceeds the approved ${o$1} risk ceiling.`,...t.projectPath?{projectPath:t.projectPath}:{}});let J={schemaVersion:a,transactionId:B,revision:1,createdAt:ee,updatedAt:ee,workspace:{name:await La(r),rootRef:"."},target:G,state:ie?"decision-required":"awaiting-approval",policy:s,approval:{required:true,status:"pending"},preconditions:d,adapterEvaluations:u.adapters,checkpoint:{status:"pending",files:j.entries},stages:W,...ie?{decision:{reason:[...new Set(te)].join(" "),options:[...g],causes:ne}}:{},events:[],integrity:{sourceEvidenceHash:M,planHash:qe({sourceEvidenceHash:M,target:G,policy:s,preconditions:d,adapterEvaluations:u.adapters,stages:W,checkpointFiles:j.entries})}};I(J,"planned",ie?"Model-proposed repair requires an engineering decision.":"Model-proposed source repair is bounded and ready for explicit approval.",{now:a$3.now}),a$1(J,c,"Workspace repair transaction");let le=oe(r,B);return await k.ensureDir(le),await Z(Te(r,B),t),await Z(ye(r,B),J),await Z(c$1.join(r,b),J),t.goalId&&await o({workspacePath:r,goalId:t.goalId,transactionId:B}),J}async function Wt(e,a={}){let r=await se(e);if(r.state!=="awaiting-approval")throw new Error(`Repair transaction is not awaiting approval: ${r.state}`);if(De(r)!==r.integrity.planHash)return r.approval.status="expired",r.state="decision-required",r.decision=D("The compiled repair plan changed after planning.",["cancel"]),await P(e.workspacePath,r,a.now),r;let t=await Pe(e.workspacePath,e.transactionId);return $(K(t))!==r.integrity.sourceEvidenceHash?(r.approval.status="expired",r.state="decision-required",r.decision=D("The persisted source plan changed after planning.",["cancel"]),await P(e.workspacePath,r,a.now),r):(r.approval={required:true,status:"approved",approvedAt:F(a.now),approvedBy:e.approvedBy?.trim()||"local-user",approvedPlanHash:r.integrity.planHash},r.state="approved",I(r,"approval","The immutable repair plan was explicitly approved.",{status:"approved",now:a.now}),await P(e.workspacePath,r,a.now),r)}async function Pa(e,a){let r=c$1.join(e,Ce,Ea);await k.ensureDir(c$1.dirname(r));try{let t=await k.stat(r),o=await k.readJson(r).catch(()=>({})),s=typeof o.host=="string"?o.host:void 0,d=typeof o.pid=="number"&&Number.isSafeInteger(o.pid)&&o.pid>0?o.pid:void 0,i=false;if((!s||s===hostname())&&d)try{process.kill(d,0),i=true;}catch(n){i=n!==null&&typeof n=="object"&&"code"in n&&n.code==="EPERM";}let g=!!(s&&s!==hostname());!i&&!g&&Date.now()-t.mtimeMs>Sa&&await k.remove(r);}catch{}try{await k.outputFile(r,`${JSON.stringify({transactionId:a,pid:process.pid,host:hostname(),acquiredAt:new Date().toISOString()})}
|
|
2
|
+
`,{flag:"wx"});}catch{throw new Error("Another workspace repair transaction currently owns the engine lock.")}return async()=>{(await k.readJson(r).catch(async()=>{let o=await k.readFile(r,"utf8").catch(()=>"");try{return JSON.parse(o)}catch{return {}}})).transactionId===a&&await k.remove(r);}}async function Ra(e){let a=e.transaction.target.projectPath?c$1.resolve(e.workspacePath,e.transaction.target.projectPath):void 0,r=await ve(e.workspacePath,e.transaction.checkpoint.files.map(o=>o.path),a);if(r.errors.length>0)throw new Error(r.errors.join(" "));let t=new Map(r.entries.map(o=>[o.path,o]));for(let o of e.transaction.checkpoint.files){let s=t.get(o.path);if(!s||o.existed!==s.existed||o.beforeHash!==s.beforeHash||o.mode!==s.mode)throw new Error(`Checkpoint precondition changed after planning: ${o.path}. Create and approve a fresh plan.`)}}async function Za(e){if(e.transaction.checkpoint.status==="captured")return;await Ra(e);let a=c$1.join(oe(e.workspacePath,e.transaction.transactionId),oa);await k.ensureDir(a);for(let r=0;r<e.transaction.checkpoint.files.length;r+=1){let t=e.transaction.checkpoint.files[r],o=c$1.resolve(e.workspacePath,t.path),s=t.existed?await k.readFile(o):void 0;if(s&&$(s)!==t.beforeHash)throw new Error(`Checkpoint source changed while it was being captured: ${t.path}. Create and approve a fresh plan.`);let d=`${oa}/${String(r).padStart(4,"0")}.bin`;if(s){let i=c$1.join(oe(e.workspacePath,e.transaction.transactionId),d),g=`${i}.${process.pid}.${randomUUID()}.tmp`;await k.writeFile(g,s,{flag:"wx"});let n=await k.readFile(g);if($(n)!==t.beforeHash)throw await k.remove(g),new Error(`Checkpoint backup verification failed for ${t.path}.`);await k.move(g,i,{overwrite:true}),t.backupRef=d;}}e.transaction.checkpoint.status="captured",e.transaction.checkpoint.capturedAt=F(e.now),e.transaction.state="checkpointed",I(e.transaction,"checkpoint",`Captured ${e.transaction.checkpoint.files.length} bounded file checkpoint(s).`,{status:"captured",now:e.now});}async function da(e,a){for(let r of a.checkpoint.files){let t=c$1.resolve(e,r.path),o=await k.readFile(t).catch(()=>{});r.afterHash=o?$(o):null;}}function xe(e){return c$1.posix.basename(e.replaceAll("\\","/")).toLowerCase().replace(/\.(?:bat|cmd|exe)$/i,"")}function Fe(e,a,r,t=[]){let o=c$1.resolve(e,a.cwd);if(!(E(e,o)||t.some(n=>E(n,o))))throw new Error(`Invocation cwd escapes authorized repair boundaries: ${a.cwd}`);if(a.args.length>100||a.args.some(n=>!n||/[\0\r\n]/.test(n)))throw new Error("Invocation contains invalid arguments.");let d=xe(a.executable),i=c$1.isAbsolute(a.executable),g=/^\.{1,2}[\\/]/.test(a.executable);if(i&&!E(e,a.executable)&&!t.some(n=>E(n,a.executable)))throw new Error(`Invocation executable escapes authorized repair boundaries: ${a.executable}`);if(!i&&!g&&!Ta.has(d))throw new Error(`Invocation executable is not governed: ${a.executable}`);if(!r.allowForce&&a.args.some(n=>/^(?:--force|-f)$/i.test(n)))throw new Error("Force-based repair requires explicit allowForce policy approval.");if(!r.allowBreaking&&a.args.some(n=>/(?:breaking|legacy-peer-deps)/i.test(n)))throw new Error("Breaking dependency repair requires explicit allowBreaking policy approval.");if(["npx","pnpx","bunx"].includes(d)&&!a.args.includes("--no-install")&&!a.args.includes("--no"))throw new Error(`${d} cannot fetch an unreviewed package during autonomous repair.`);return {cwd:o,executable:a.executable}}async function We(e){let a=e.projectBoundary?[c$1.resolve(e.projectBoundary)]:[],r=Fe(e.workspacePath,e.invocation,e.policy,a),t=await k.lstat(r.cwd).catch(()=>{});if(!t?.isDirectory()||t.isSymbolicLink()||!await _(e.projectBoundary??e.workspacePath,r.cwd))throw new Error(`Invocation cwd is not a real workspace directory: ${e.invocation.cwd}`);if(c$1.isAbsolute(r.executable)||/^\.{1,2}[\\/]/.test(r.executable)){let d=c$1.isAbsolute(r.executable)?r.executable:c$1.resolve(r.cwd,r.executable);if(!await _(e.projectBoundary??e.workspacePath,d))throw new Error(`Invocation executable resolves outside the workspace: ${e.invocation.executable}`)}let o=Object.fromEntries(Object.entries(process.env).filter(([d])=>!/(?:TOKEN|SECRET|PASSWORD|PASSWD|API_KEY|PRIVATE_KEY|CREDENTIAL|COOKIE|AUTH)/i.test(d))),s=await execa(r.executable,e.invocation.args,{cwd:r.cwd,shell:false,reject:false,timeout:e.invocation.timeoutMs,maxBuffer:ha,stdin:"ignore",extendEnv:false,env:{...o,NO_COLOR:"1",CI:process.env.CI??"1"}});return {exitCode:s.exitCode??null,stdout:s.stdout??"",stderr:s.stderr??""}}function Qa(e){let a=j.find(t=>t.cardId===e);if(!a)throw new Error(`No canonical producer is registered for repair card ${e}.`);let r=a.verifyCommand.trim().split(/\s+/);if(r[0]!=="npx"||r[1]!=="workspai"||r.length<3)throw new Error(`Repair card ${e} publishes an invalid canonical producer command.`);return r.slice(2)}async function et(e){let a=j.find(d=>d.cardId===e.transaction.target.cardId);if(!a)throw new Error(`No canonical producer is registered for repair card ${e.transaction.target.cardId}.`);let r=process.argv[1]?.trim();if(!r||!await k.pathExists(r))throw new Error("The running Workspai CLI entrypoint is unavailable for target verification.");let t=a.scope==="project"&&e.transaction.target.projectPath?c$1.resolve(e.workspacePath,e.transaction.target.projectPath):c$1.resolve(e.workspacePath);if(a.scope==="project"&&!e.transaction.target.projectPath)throw new Error(`Repair card ${a.cardId} requires an explicit project path for exact producer verification.`);if(!await _(e.workspacePath,t))throw new Error("The target producer working directory escapes the workspace boundary.");let o=Object.fromEntries(Object.entries(process.env).filter(([d])=>!/(?:TOKEN|SECRET|PASSWORD|PASSWD|API_KEY|PRIVATE_KEY|CREDENTIAL|COOKIE|AUTH)/i.test(d))),s=await execa(process.execPath,[r,...Qa(a.cardId)],{cwd:t,shell:false,reject:false,timeout:15*6e4,maxBuffer:ha,stdin:"ignore",extendEnv:false,env:{...o,NO_COLOR:"1",CI:process.env.CI??"1"}});return {exitCode:s.exitCode??null,stdout:s.stdout??"",stderr:s.stderr??""}}async function at(e){if(e.dependencies.targetVerify)return e.dependencies.targetVerify({workspacePath:e.workspacePath,transaction:e.transaction});if(e.dependencies.verify)return {status:e.workspaceStatus==="passed"?"passed":"failed",remainingActionIds:e.workspaceStatus==="passed"?[]:[...e.transaction.target.actionIds]};if(e.workspaceStatus==="failed")return {status:"unknown",remainingActionIds:[...e.transaction.target.actionIds]};try{let a=await a$2({workspacePath:e.workspacePath,includeAbsolutePaths:false,ciMode:true}),r=new Set(e.transaction.target.actionIds),t=re(e.sourcePlan)&&Array.isArray(e.sourcePlan.targetActionIds)&&e.sourcePlan.targetActionIds.length>0,o=re(e.sourcePlan)?a.actions.filter(s=>t?r.has(s.id):s.cardId===e.transaction.target.cardId&&(!e.transaction.target.projectName||s.projectName===e.transaction.target.projectName)&&(!e.transaction.target.projectPath||s.projectPath===e.transaction.target.projectPath)):a.actions.filter(s=>r.has(s.id));return {status:o.length===0?"passed":"failed",remainingActionIds:o.map(s=>s.id).sort()}}catch{return {status:"unknown",remainingActionIds:[...e.transaction.target.actionIds]}}}async function tt(e){if(e.dependencies.verify||e.dependencies.targetVerify)return {current:true,missingActionIds:[],semanticDrift:false};let a=e.transaction.target.actionIds.filter(g=>!g.startsWith("proposal:"));if(a.length===0)return {current:true,missingActionIds:[],semanticDrift:false};let r=await a$2({workspacePath:e.workspacePath,includeAbsolutePaths:false,ciMode:true}),t=new Set(r.actions.map(g=>g.id)),o=a.filter(g=>!t.has(g)),s=e.transaction.preconditions.map(g=>g.id).find(g=>g.startsWith(Se))?.slice(Se.length),d=r.actions.filter(g=>t.has(g.id)&&a.includes(g.id)),i=o.length===0&&!!s&&fa(d)!==s;return {current:o.length===0&&!i,missingActionIds:o,semanticDrift:i}}function z(e,a=8e3){return e.length<=a?e:`\u2026[truncated]\u2026
|
|
3
|
+
${e.slice(-a)}`}async function rt(e,a){if(a.type==="file-create")return i({projectPath:e,operation:a});if(a.type==="file-append")return j$1({projectPath:e,operation:a});if(a.type==="file-copy")return k$2({projectPath:e,operation:a});if(a.type==="package-json-script")return h$2({projectPath:e,packageJsonPath:a.path,scriptName:a.scriptName,scriptValue:a.scriptValue});if(a.type==="json-edit")return m$1({projectPath:e,operation:a});if(a.type==="env-key-add")return n({projectPath:e,operation:a});if(a.type==="makefile-target")return o$1({projectPath:e,operation:a})}async function ot(e){let a=c$1.resolve(e.workspacePath,e.change.path),r=e.transaction.target.projectPath?c$1.resolve(e.workspacePath,e.transaction.target.projectPath):e.workspacePath;if(!E(r,a)||!await _(r,a))throw new Error(`Proposal target escaped the canonical repair boundary: ${e.change.path}`);let t=ya(e.change.path);if(t)throw new Error(`${e.change.path}: ${t}`);let o=e.transaction.checkpoint.files.find(m=>m.path===e.change.path);if(!o)throw new Error(`Proposal target is missing from the checkpoint: ${e.change.path}`);let s=await k.readFile(a).catch(()=>{}),d=s?$(s):null;if(d!==o.beforeHash||d!==e.change.expectedBeforeHash)throw new Error(`Proposal target changed before execution: ${e.change.path}`);let i=await k.lstat(a).catch(()=>{});if(i?.isSymbolicLink()||i&&!i.isFile())throw new Error(`Proposal target must be a regular file: ${e.change.path}`);if(e.change.operation==="delete"){if(!i)throw new Error(`Proposal delete target does not exist: ${e.change.path}`);await k.remove(a);return}let g=e.change.content??"";if(Buffer.byteLength(g,"utf8")>ua)throw new Error(`Proposal write exceeds the 5 MiB file limit: ${e.change.path}`);await k.ensureDir(c$1.dirname(a));let n=c$1.join(c$1.dirname(a),`.${c$1.basename(a)}.${process.pid}.${randomUUID()}.repair-tmp`);await k.writeFile(n,g,{encoding:"utf8",flag:"wx"}),await k.move(n,a,{overwrite:true});let f=await k.readFile(a);if($(f)!==$(g))throw new Error(`Proposal write could not be verified: ${e.change.path}`)}async function pa(e){if(e.stage.status==="passed"||e.stage.status==="skipped")return true;if(e.stage.status==="blocked")return false;e.stage.status="running",e.stage.startedAt=F(e.dependencies.now),I(e.transaction,"stage",e.stage.summary,{stageId:e.stage.id,status:"running",now:e.dependencies.now}),await P(e.workspacePath,e.transaction,e.dependencies.now);try{if(e.stage.id==="target-precondition"||e.stage.id==="target-producer-verify"){let a=!!(e.dependencies.verify||e.dependencies.targetVerify||e.dependencies.runInvocation||e.dependencies.toolAvailable||e.dependencies.now),r=await(e.dependencies.runTargetProducer??(a?async()=>({exitCode:0,stdout:"",stderr:""}):et))({workspacePath:e.workspacePath,transaction:e.transaction});if(e.stage.exitCode=r.exitCode,e.stage.stdoutTail=z(r.stdout),e.stage.stderrTail=z(r.stderr),r.exitCode!==0&&r.exitCode!==2)throw new Error(r.stderr||r.stdout||`Exact card producer exited with ${String(r.exitCode)}.`);if(e.stage.id==="target-precondition"){let t=await tt({workspacePath:e.workspacePath,transaction:e.transaction,dependencies:e.dependencies});if(!t.current){let o=t.semanticDrift?"The selected action semantics changed after approval.":`Missing action(s): ${t.missingActionIds.join(", ")}.`;throw new Error(`The approved causal repair target changed before mutation. ${o} Create and approve a fresh plan.`)}}}else if(e.stage.kind==="repair"){let a=e.actions.get(e.stage.id);if(!a)throw new Error(`Persisted repair action is missing: ${e.stage.id}`);if(a.kind==="proposal")await ot({workspacePath:e.workspacePath,transaction:e.transaction,change:a.change});else {let r=Re(a.action);if(r){let t=fe(e.workspacePath,a.action);if(!await _(e.workspacePath,t))throw new Error(`Repair project scope escapes workspace through a symbolic link: ${t}`);await rt(t,r);}else if(e.stage.invocation){let t=await(e.dependencies.runInvocation??We)({workspacePath:e.workspacePath,invocation:e.stage.invocation,policy:e.transaction.policy,projectBoundary:be(e.workspacePath,e.transaction)});if(e.stage.exitCode=t.exitCode,e.stage.stdoutTail=z(t.stdout),e.stage.stderrTail=z(t.stderr),t.exitCode!==0)throw new Error(t.stderr||t.stdout||`Repair command exited with ${t.exitCode}.`)}else throw new Error("Repair stage has no typed operation or structured invocation.")}}else if(e.stage.invocation){let a=await(e.dependencies.runInvocation??We)({workspacePath:e.workspacePath,invocation:e.stage.invocation,policy:e.transaction.policy,projectBoundary:be(e.workspacePath,e.transaction)});if(e.stage.exitCode=a.exitCode,e.stage.stdoutTail=z(a.stdout),e.stage.stderrTail=z(a.stderr),a.exitCode!==0)throw new Error(a.stderr||a.stdout||`${e.stage.kind} exited with ${a.exitCode}.`)}return e.stage.status="passed",e.stage.completedAt=F(e.dependencies.now),e.stage.summary=e.stage.id==="target-precondition"?`Exact ${e.transaction.target.cardId} target revalidated before mutation.`:e.stage.id==="target-producer-verify"?`Exact ${e.transaction.target.cardId} producer refreshed after mutation.`:`${e.stage.kind} completed.`,await da(e.workspacePath,e.transaction),I(e.transaction,"stage",e.stage.summary,{stageId:e.stage.id,status:"passed",now:e.dependencies.now}),await P(e.workspacePath,e.transaction,e.dependencies.now),true}catch(a){return e.stage.status="failed",e.stage.completedAt=F(e.dependencies.now),e.stage.summary=a instanceof Error?a.message:String(a),await da(e.workspacePath,e.transaction),I(e.transaction,"stage",e.stage.summary,{stageId:e.stage.id,status:"failed",now:e.dependencies.now}),await P(e.workspacePath,e.transaction,e.dependencies.now),false}}async function ge(e){let a=e.transaction.state==="rolling-back"||e.transaction.checkpoint.status==="restored";e.transaction.state="rolling-back",I(e.transaction,"rollback","Rollback started from the bounded transaction checkpoint.",{status:"running",now:e.dependencies.now}),await P(e.workspacePath,e.transaction,e.dependencies.now);let r=async s=>(e.transaction.checkpoint.status="conflicted",e.transaction.state="decision-required",e.transaction.decision=D(s,["manual-repair","cancel"]),I(e.transaction,"decision",s,{status:"conflicted",now:e.dependencies.now}),await P(e.workspacePath,e.transaction,e.dependencies.now),false),t=[];for(let s of e.transaction.checkpoint.files){let d=c$1.resolve(e.workspacePath,s.path),i=e.transaction.target.projectPath?c$1.resolve(e.workspacePath,e.transaction.target.projectPath):e.workspacePath;if(!E(i,d)||!await _(i,d))return r(`Rollback refused because ${s.path} escaped the canonical repair boundary.`);let g=await k.lstat(d).catch(()=>{});if(g?.isSymbolicLink()||g&&!g.isFile())return r(`Rollback refused because ${s.path} is no longer a regular file.`);let n=g?await k.readFile(d):void 0,f=n?$(n):null,m=s.afterHash!==void 0&&f===s.afterHash,b=a&&f===s.beforeHash;if(!m&&!b)return r(`Rollback refused because ${s.path} changed outside this transaction.`);if(!s.existed){t.push({entry:s,absolute:d});continue}if(!s.backupRef)return r(`Rollback refused because the checkpoint backup is missing for ${s.path}.`);let R=c$1.join(oe(e.workspacePath,e.transaction.transactionId),s.backupRef),x=await k.lstat(R).catch(()=>{});if(!x?.isFile()||x.isSymbolicLink())return r(`Rollback refused because the checkpoint backup is invalid for ${s.path}.`);let A=await k.readFile(R);if($(A)!==s.beforeHash)return r(`Rollback refused because the checkpoint backup hash is invalid for ${s.path}.`);t.push({entry:s,absolute:d,backup:A});}for(let s of t){if(!s.entry.existed){await k.remove(s.absolute);continue}let d=s.backup;if(d===void 0)throw new Error(`Validated checkpoint backup disappeared for ${s.entry.path}.`);let i=c$1.join(c$1.dirname(s.absolute),`.${c$1.basename(s.absolute)}.${process.pid}.${randomUUID()}.rollback-tmp`);await k.ensureDir(c$1.dirname(s.absolute)),await k.writeFile(i,d,{flag:"wx"}),s.entry.mode!==void 0&&await k.chmod(i,s.entry.mode),await k.move(i,s.absolute,{overwrite:true});}e.transaction.checkpoint.status="restored",e.transaction.checkpoint.restoredAt=F(e.dependencies.now);let o=e.transaction.stages.filter(s=>s.kind==="reconcile"&&s.invocation);for(let s of o){let d=s.invocation;if(!d)continue;let i=`rollback:${s.id}`,g=e.transaction.stages.find(m=>m.id===i&&m.kind==="rollback"),n=g??{id:i,kind:"rollback",status:"pending",required:true,risk:s.risk,summary:"Reconcile the installed dependency tree with the restored manifest and lockfile.",invocation:d};g||e.transaction.stages.push(n),n.status="running",n.startedAt=F(e.dependencies.now),delete n.completedAt,delete n.exitCode,delete n.stdoutTail,delete n.stderrTail,I(e.transaction,"rollback",n.summary,{stageId:n.id,status:"running",now:e.dependencies.now}),await P(e.workspacePath,e.transaction,e.dependencies.now);let f;try{f=await(e.dependencies.runInvocation??We)({workspacePath:e.workspacePath,invocation:d,policy:e.transaction.policy,projectBoundary:be(e.workspacePath,e.transaction)});}catch(m){f={exitCode:null,stdout:"",stderr:m instanceof Error?m.message:String(m)};}if(n.exitCode=f.exitCode,n.stdoutTail=z(f.stdout),n.stderrTail=z(f.stderr),n.completedAt=F(e.dependencies.now),f.exitCode!==0)return n.status="failed",n.summary=f.stderr||f.stdout||`Rollback reconciliation exited with ${f.exitCode}.`,e.transaction.state="decision-required",e.transaction.decision=D(`Source files were restored, but the installed dependency tree could not be reconciled: ${n.summary}`,["manual-repair","cancel"]),I(e.transaction,"decision",e.transaction.decision.reason,{stageId:n.id,status:"rollback-reconcile-failed",now:e.dependencies.now}),await P(e.workspacePath,e.transaction,e.dependencies.now),false;n.status="passed",n.summary="Installed dependency tree reconciled with the restored source state.",I(e.transaction,"rollback",n.summary,{stageId:n.id,status:"passed",now:e.dependencies.now});}return e.transaction.state="rolled-back",delete e.transaction.decision,I(e.transaction,"rollback","Rollback restored every bounded checkpoint file and reconciled dependency state.",{status:"passed",now:e.dependencies.now}),await P(e.workspacePath,e.transaction,e.dependencies.now),true}async function Ct(e,a={}){let r=c$1.resolve(e.workspacePath),t=await Pa(r,e.transactionId);try{let o=await se({workspacePath:r,transactionId:e.transactionId});if(!["approved","checkpointed","executing","verifying","rollback-required","rolling-back"].includes(o.state))throw new Error(`Repair transaction cannot execute from state ${o.state}.`);if(o.approval.status!=="approved"||o.approval.approvedPlanHash!==o.integrity.planHash)throw new Error("Repair approval is missing, expired, or bound to another plan revision.");if(De(o)!==o.integrity.planHash)return o.approval.status="expired",o.state="decision-required",o.decision=D("The compiled repair plan changed after approval. Create and approve a fresh transaction.",["cancel"]),I(o,"decision",o.decision.reason,{status:"integrity-failed",now:a.now}),await P(r,o,a.now),o;let s=await Pe(r,e.transactionId);if($(K(s))!==o.integrity.sourceEvidenceHash)return o.approval.status="expired",o.state="decision-required",o.decision=D("Persisted remediation evidence changed after approval. Create and approve a fresh transaction.",["cancel"]),I(o,"decision",o.decision.reason,{status:"integrity-failed",now:a.now}),await P(r,o,a.now),o;if(o.state==="approved"&&re(s)&&s.goalId){let u=await k$1({workspacePath:r,goalId:s.goalId}),w=u.active?.repairTransactionIds??(u.active?.repairTransactionId?[u.active.repairTransactionId]:[]);if(u.index.activeGoalId!==s.goalId||!w.includes(o.transactionId))throw new Error(`Goal-bound repair transaction is not linked to the active Goal Pack: ${o.transactionId}`)}let i=(await Ne({workspacePath:r,stages:o.stages,toolAvailable:a.toolAvailable})).find(u=>u.status==="failed");if(i){let u=o.stages.find(w=>w.invocation&&`tool:${w.invocation.cwd}:${w.invocation.executable}`===i.id)?.invocation?.executable;return o.approval.status="expired",o.state="decision-required",o.decision=D(`${i.message} The approved plan cannot execute against a changed toolchain.`,["manual-repair","cancel"],{kind:"missing-executable",id:i.id,message:i.message,...u?{executable:u}:{}}),I(o,"decision",o.decision.reason,{status:"tool-precondition-failed",now:a.now}),await P(r,o,a.now),o}if(o.state==="rollback-required"||o.state==="rolling-back"){if(!["captured","restored"].includes(o.checkpoint.status))throw new Error("A captured checkpoint is required to resume rollback.");return await ge({workspacePath:r,transaction:o,dependencies:a}),o}let g=new Map(re(s)?s.changes.map(u=>[`proposal:${u.id}`,{kind:"proposal",change:u}]):s.actions.map(u=>[`action:${u.id}`,{kind:"canonical",action:u}]));try{await Ra({workspacePath:r,transaction:o});}catch(u){return o.approval.status="expired",o.state="decision-required",o.decision=D(u instanceof Error?u.message:String(u),["cancel"]),I(o,"decision",o.decision.reason,{status:"source-precondition-failed",now:a.now}),await P(r,o,a.now),o}let n=o.stages.find(u=>u.id==="target-precondition");if(!n)return o.approval.status="expired",o.state="decision-required",o.decision=D("The approved plan has no exact target precondition. Create and approve a fresh transaction.",["cancel"]),await P(r,o,a.now),o;if(!await pa({workspacePath:r,transaction:o,stage:n,actions:g,dependencies:a}))return o.approval.status="expired",o.state="decision-required",o.decision=D(`Target precondition failed before checkpoint: ${n.summary}`,["cancel"]),I(o,"decision",o.decision.reason,{status:"target-precondition-failed",now:a.now}),await P(r,o,a.now),o;try{await Za({workspacePath:r,transaction:o,now:a.now});}catch(u){return o.approval.status="expired",o.state="decision-required",o.decision=D(u instanceof Error?u.message:String(u),["cancel"]),I(o,"decision",o.decision.reason,{status:"precondition-failed",now:a.now}),await P(r,o,a.now),o}o.state="executing",await P(r,o,a.now);for(let u of o.stages.filter(w=>w.id!=="target-precondition"&&w.id!=="canonical-verify"&&w.kind!=="rollback"))if(!await pa({workspacePath:r,transaction:o,stage:u,actions:g,dependencies:a})&&u.required)return o.state=o.policy.autoRollback?"rollback-required":"decision-required",o.decision=D(`Required stage ${u.id} failed: ${u.summary}`,o.policy.autoRollback?["rollback","manual-repair","cancel"]:["manual-repair","rollback","cancel"]),await P(r,o,a.now),o.policy.autoRollback&&await ge({workspacePath:r,transaction:o,dependencies:a}),o;o.state="verifying";let m=o.stages.find(u=>u.id==="canonical-verify");if(!m)return o.state=o.policy.autoRollback?"rollback-required":"decision-required",o.decision=D("The approved plan has no canonical verification stage.",o.policy.autoRollback?["rollback","manual-repair","cancel"]:["manual-repair","rollback","cancel"]),await P(r,o,a.now),o.policy.autoRollback&&await ge({workspacePath:r,transaction:o,dependencies:a}),o;m.status="running",m.startedAt=F(a.now),I(o,"verification","Canonical Workspace Intelligence verification started.",{stageId:m.id,status:"running",now:a.now}),await P(r,o,a.now);let b;try{b=a.verify?await a.verify(r):await c$3({workspacePath:r,strict:true,agent:"generic"});}catch(u){b={status:"failed",exitCode:1,artifactPath:e$1.intelligenceRun},m.stderrTail=z(u instanceof Error?u.message:String(u));}let R=b.status==="passed"&&b.exitCode===0?"passed":b.status==="failed"||b.exitCode===1?"failed":"blocked",x=await at({workspacePath:r,transaction:o,sourcePlan:s,dependencies:a,workspaceStatus:R}),A=x.status==="passed"&&R!=="failed",q,p;if(A&&re(s)&&s.goalId){let u=await a$3(r);if(u.status==="miss")A=false,p=`Goal-bound repair could not seal its post-repair Model/Graph source state (${u.reason}).`;else {let w=u.graph.source.inputs?.hash;w?q={modelHash:d(u.model),modelHashSemantics:"workspace-model-structural-v1",graphHash:c$4(u.graph),graphHashSemantics:"canonical-json-v1",graphInputHash:w}:(A=false,p="Goal-bound repair could not seal its post-repair Graph input fingerprint.");}}return m.status=A?"passed":"failed",m.completedAt=F(a.now),m.exitCode=b.exitCode,m.summary=A&&R==="passed"?"Selected repair target and canonical workspace verification passed.":A?"Selected repair target passed; canonical workspace verification remains blocked by other governed findings.":p||(x.status==="unknown"?"Canonical verification could not establish the selected repair target outcome.":`Selected repair target remains unresolved; canonical workspace verification is ${R}.`),o.verification={status:A?"passed":"failed",targetStatus:x.status,workspaceStatus:R,remainingActionIds:x.remainingActionIds,artifact:e$1.intelligenceRun,exitCode:b.exitCode,summary:m.summary,...q?{sourceBinding:q}:{}},I(o,"verification",m.summary,{stageId:m.id,status:m.status,now:a.now}),A?(o.state="closed",delete o.decision,I(o,"closed",m.summary,{status:"passed",now:a.now}),o.integrity.closureHash=va(o),await P(r,o,a.now),o):(o.state=o.policy.autoRollback?"rollback-required":"decision-required",o.decision=D(m.summary,o.policy.autoRollback?["rollback","manual-repair","cancel"]:["manual-repair","rollback","cancel"]),await P(r,o,a.now),o.policy.autoRollback&&await ge({workspacePath:r,transaction:o,dependencies:a}),o)}finally{await t();}}async function st(e,a={}){let r=c$1.resolve(e.workspacePath),t=await Pa(r,e.transactionId);try{let o=await se({workspacePath:r,transactionId:e.transactionId});if(!["checkpointed","executing","verifying","rollback-required","rolling-back","decision-required","failed"].includes(o.state))throw new Error(`Repair transaction cannot roll back from state ${o.state}.`);if(!["captured","restored"].includes(o.checkpoint.status))throw new Error("A captured checkpoint is required for rollback.");return await ge({workspacePath:r,transaction:o,dependencies:a}),o}finally{await t();}}async function Tt(e,a={}){let r=await se(e);if(["closed","rolled-back","cancelled"].includes(r.state))return r;if(r.checkpoint.status==="captured")throw new Error("Rollback a mutated transaction before cancelling it.");return r.state="cancelled",r.approval.status=r.approval.status==="approved"?"expired":r.approval.status,I(r,"cancelled","Repair transaction cancelled before mutation.",{status:"cancelled",now:a.now}),await P(e.workspacePath,r,a.now),r}async function Nt(e,a={}){let r=c$1.resolve(e.workspacePath),t=await se({workspacePath:r,transactionId:e.transactionId});if(t.state!=="decision-required"||!t.decision)throw new Error(`Repair transaction is not awaiting a decision: ${t.state}`);if(!t.decision.options.includes(e.decision))throw new Error(`Decision ${e.decision} is not available. Allowed: ${t.decision.options.join(", ")}.`);if(e.decision==="rollback")return st({workspacePath:r,transactionId:e.transactionId},a);if(e.decision==="cancel"||e.decision==="manual-repair"){if(t.checkpoint.status==="captured")throw new Error("A mutated transaction must be rolled back before control is released.");return t.state="cancelled",t.approval.status=t.approval.status==="approved"?"expired":t.approval.status,I(t,"decision",e.decision==="manual-repair"?"The user chose manual repair; this transaction released source ownership without mutation.":"The user cancelled the decision-required transaction.",{status:e.decision,now:a.now}),await P(r,t,a.now),t}if(t.checkpoint.status==="captured")throw new Error("Repair policy cannot change after a checkpoint has been captured. Roll back first.");let o=await Pe(r,e.transactionId);t.state="cancelled",t.approval.status=t.approval.status==="approved"?"expired":t.approval.status,I(t,"decision",`The user selected ${e.decision}; a fresh immutable plan and approval are required.`,{status:"superseded",now:a.now}),await P(r,t,a.now);let s={maxRisk:e.decision==="approve-invasive"?"invasive":e.decision==="approve-guarded"&&t.policy.maxRisk==="safe"?"guarded":t.policy.maxRisk,allowForce:t.policy.allowForce||e.decision==="allow-force",allowBreaking:t.policy.allowBreaking||e.decision==="allow-breaking",autoRollback:t.policy.autoRollback};if(re(o))return Xa({workspacePath:r,proposal:o,...s},a);let d=t.target.actionIds.map(i=>i.startsWith("action:")?i.slice(7):i);return Ya({workspacePath:r,cardId:t.target.cardId,...d.length===1?{actionId:d[0]}:{},projectName:t.target.projectName,...s},a)}async function qt(e){let a=c$1.join(e,Ce,"transactions"),r=await k.readdir(a).catch(()=>[]);return (await Promise.all(r.map(o=>se({workspacePath:e,transactionId:o}).catch(()=>{})))).filter(o=>!!o).sort((o,s)=>s.updatedAt.localeCompare(o.updatedAt))}export{Wt as approveWorkspaceRepair,St as assertClosedGoalRepairTransactionCurrent,Tt as cancelWorkspaceRepair,Nt as decideWorkspaceRepair,Qa as exactCardProducerArgs,Ct as executeWorkspaceRepair,$t as inspectWorkspaceRepairCapabilities,qt as listWorkspaceRepairTransactions,Ya as planWorkspaceRepair,Xa as planWorkspaceRepairProposal,se as readWorkspaceRepairTransaction,st as rollbackWorkspaceRepair};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as runWorkspaceStage}from'./chunk-U3MGJN7A.js';export{a as WORKSPACE_RUN_LAST_REPORT_FILENAME}from'./chunk-W6FHVXNL.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{d as WORKSPACE_VERIFY_REPORT_PATH,c as WORKSPACE_VERIFY_SCHEMA_VERSION,f as buildWorkspaceVerify,e as computeAffectedSubgraphGate,h as evaluateWorkspaceVerifyGate,i as workspaceVerifyExitCode,g as writeWorkspaceVerify}from'./chunk-
|
|
1
|
+
export{d as WORKSPACE_VERIFY_REPORT_PATH,c as WORKSPACE_VERIFY_SCHEMA_VERSION,f as buildWorkspaceVerify,e as computeAffectedSubgraphGate,h as evaluateWorkspaceVerifyGate,i as workspaceVerifyExitCode,g as writeWorkspaceVerify}from'./chunk-YEEAWZWI.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-QMPFNXI7.js';import {f as f$1,r,l}from'./chunk-WSRUPDZN.js';import {a as a$1}from'./chunk-GR6442P7.js';import {a as a$2}from'./chunk-AFIFZTOY.js';import y from'fs';var b="workspace-watch-event.v1";function R(e){return a$2(e,"contracts/workspace-watch-event.v1.json","Workspace watch event"),e}function g(e){return `${e.from}\0${e.to}\0${e.kind}`}function f(e){return (l(e)?.edges??[]).map(o=>({from:o.from,to:o.to,kind:o.kind}))}function m(e){let r=[...a(e).entries()].sort((a,n)=>a[0].localeCompare(n[0])).map(([a,n])=>({id:a,hash:n})),c=f(e).map(g).sort((a,n)=>a.localeCompare(n));return f$1({projects:r,edges:c})}function C(e,o){let r=a(o),c=e?a(e):new Map,a$1=[],n=[];for(let[t,s]of r.entries())c.has(t)?c.get(t)!==s&&a$1.push(t):n.push(t);let d=[];for(let t of c.keys())r.has(t)||d.push(t);let i=new Map(e?f(e).map(t=>[g(t),t]):[]),l=new Map(f(o).map(t=>[g(t),t])),p=[];for(let[t,s]of l.entries())i.has(t)||p.push(s);let h=[];for(let[t,s]of i.entries())l.has(t)||h.push(s);let u=(t,s)=>g(t).localeCompare(g(s));return a$1.sort((t,s)=>t.localeCompare(s)),n.sort((t,s)=>t.localeCompare(s)),d.sort((t,s)=>t.localeCompare(s)),p.sort(u),h.sort(u),{changedProjects:a$1,addedProjects:n,removedProjects:d,edgesAdded:p,edgesRemoved:h}}var k=class{model=null;sequence=0;rebuild;now;constructor(o,r$1){this.rebuild=r$1?.rebuild??(()=>r({...o})),this.now=r$1?.now??(()=>new Date);}get currentModel(){return this.model}async start(){let o=Date.now(),{model:r}=await this.rebuild();return this.model=r,this.buildEvent("ready","initial",null,r,Date.now()-o)}async pulse(){let o=Date.now(),r=this.model,{model:c,mode:a}=await this.rebuild(),n=this.buildEvent(this.hasStructuralChange(r,c)?"changed":"unchanged",a,r,c,Date.now()-o);return this.model=c,n}hasStructuralChange(o,r){return o?m(o)!==m(r):true}buildEvent(o,r,c,a,n){let d=C(c,a),i=m(a),l=c?m(c)!==i:true;return R({schemaVersion:b,kind:o,sequence:this.sequence++,timestamp:this.now().toISOString(),mode:r,modelHash:i,modelHashChanged:l,changedProjects:d.changedProjects,addedProjects:d.addedProjects,removedProjects:d.removedProjects,graph:{nodeCount:a.graph?.nodes.length??0,edgeCount:a.graph?.edges.length??0,edgesAdded:d.edgesAdded,edgesRemoved:d.edgesRemoved},durationMs:n})}},S=new Set([".git",".hg",".svn","node_modules",".venv","venv","dist","build","out","target","coverage","htmlcov",".next",".turbo",".cache"]),j=new Set(["reports","cache","tmp",".cache"]);function O(e){if(!e)return false;let o=e.split(/[\\/]/).filter(Boolean);if(o.some(r=>S.has(r)||a$1(r)))return false;for(let r=0;r<o.length-1;r+=1)if((o[r]===".workspai"||o[r]===".rapidkit")&&j.has(o[r+1]))return false;return true}async function N(e){let o=new k(e.buildOptions,e.engineOptions),r=await o.start();if(e.emit(r),o.currentModel&&await e.onModel?.(o.currentModel,r),e.once)return;let c=e.debounceMs??250,a=e.selfWriteSuppressionMs??Math.max(400,c+150),n=null,d=false,i=false,l=0,p=async()=>{if(d){i=true;return}d=true;try{let t=await o.pulse();e.emit(t),o.currentModel&&await e.onModel?.(o.currentModel,t);}catch(t){e.emit(R({schemaVersion:b,kind:"error",sequence:-1,timestamp:new Date().toISOString(),mode:"full",modelHash:o.currentModel?m(o.currentModel):"",modelHashChanged:false,changedProjects:[],addedProjects:[],removedProjects:[],graph:{nodeCount:0,edgeCount:0,edgesAdded:[],edgesRemoved:[]},durationMs:0,error:t instanceof Error?t.message:String(t)}));}finally{d=false,l=Date.now()+a,i&&(i=false,p());}},h=t=>{O(t)&&(d||Date.now()<l||(n&&clearTimeout(n),n=setTimeout(()=>{n=null,p();},c)));};e.onProgress?.(`Watching ${e.workspacePath} for changes (Ctrl+C to stop).`);let u=y.watch(e.workspacePath,{recursive:true},(t,s)=>{typeof s=="string"?h(s):s&&h(Buffer.from(s).toString("utf8"));});await new Promise(t=>{let s=()=>{n&&clearTimeout(n),u.close(),t();};if(e.signal){if(e.signal.aborted){s();return}e.signal.addEventListener("abort",s,{once:true});}u.on("error",()=>s());});}export{b as WORKSPACE_WATCH_EVENT_SCHEMA_VERSION,k as WorkspaceWatchEngine,m as computeWatchModelHash,C as diffWatchModels,O as isWatchRelevantPath,N as runWorkspaceWatch};
|
package/docs/GLOSSARY.md
CHANGED
|
@@ -46,20 +46,23 @@ CI workflows, and AI consumers.
|
|
|
46
46
|
|
|
47
47
|
## AI and integration
|
|
48
48
|
|
|
49
|
-
| Term
|
|
50
|
-
|
|
|
51
|
-
| Agent grounding
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
49
|
+
| Term | Plain-language meaning |
|
|
50
|
+
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
51
|
+
| Agent grounding | Instructions and evidence references that keep an AI agent inside the correct workspace, contracts, and command loop. |
|
|
52
|
+
| Canonical-first entry | A host-discovered project protocol that validates Workspai identity, evidence, freshness, and Goal bindings before broad source discovery. |
|
|
53
|
+
| Agent bootstrap receipt | A portable per-session result proving which entry and evidence checks passed, degraded, or blocked; it does not prove model compliance. |
|
|
54
|
+
| Bounded retrieval | Returning only the most relevant entities and proof paths for a question instead of injecting the complete graph or model. |
|
|
55
|
+
| Retrieval benchmark | A deterministic comparison of readable proof-source corpus size with one bounded graph response; it is not billing evidence. |
|
|
56
|
+
| Token provenance | Whether a token value was provider-reported, counted by a named tokenizer, estimated, or unavailable. |
|
|
57
|
+
| MCP | Model Context Protocol; Workspai exposes read-oriented workspace tools through `workspace mcp serve`. |
|
|
58
|
+
| Module recommender | The optional embedding-based FastAPI/NestJS recommendation feature. It is separate from deterministic Workspace Intelligence. |
|
|
59
|
+
| Canonical path | The current `.workspai` path that new writers and consumers should prefer. |
|
|
60
|
+
| Legacy path | A `.rapidkit` compatibility path read for older workspaces; it is not the target for new integrations. |
|
|
59
61
|
|
|
60
62
|
## Where to continue
|
|
61
63
|
|
|
62
64
|
- Run the full loop: [Unified Workspace Intelligence Runner](./workspace-intelligence-runner.md)
|
|
63
65
|
- Query evidence: [Workspace Knowledge Graph](./workspace-knowledge-graph.md)
|
|
66
|
+
- Ground an agent: [Canonical-first agent entry](./agent-entry.md)
|
|
64
67
|
- Find an output: [Artifact Catalog](./contracts/ARTIFACT_CATALOG.md)
|
|
65
68
|
- Look up syntax: [Command Reference](./commands-reference.md)
|
package/docs/README.md
CHANGED
|
@@ -24,15 +24,17 @@ workspace. Continue from the same project terminal:
|
|
|
24
24
|
```bash
|
|
25
25
|
npx workspai project workspace status --json
|
|
26
26
|
npx workspai workspace intelligence run --for-agent generic --strict --json
|
|
27
|
+
npx workspai agent bootstrap --for-agent generic --json
|
|
27
28
|
```
|
|
28
29
|
|
|
29
30
|
The first command proves which canonical workspace owns the project. Workspai
|
|
30
31
|
uses a gitignored machine-local binding and portable project grounding, so
|
|
31
32
|
workspace commands and compatible agents do not need a manual `cd`.
|
|
32
33
|
|
|
33
|
-
Use `generic` for a vendor-neutral context pack, or select
|
|
34
|
-
`
|
|
35
|
-
|
|
34
|
+
Use `generic` for a vendor-neutral context pack, or select a published host
|
|
35
|
+
target such as `codex`, `claude`, `gemini`, `qwen`, `kimi`, `grok`, `copilot`,
|
|
36
|
+
`cursor`, `windsurf`, or `amazon-q`. Agent Sync publishes shared files and thin
|
|
37
|
+
host adapters that route every consumer to the same evidence.
|
|
36
38
|
|
|
37
39
|
Use the release pipeline when you need the broader release workflow:
|
|
38
40
|
|
|
@@ -72,21 +74,22 @@ or use `import` to copy or clone one into the workspace.
|
|
|
72
74
|
|
|
73
75
|
## Choose a guide by goal
|
|
74
76
|
|
|
75
|
-
| I want to… | Start here
|
|
76
|
-
| ------------------------------------------------- |
|
|
77
|
-
| Create a workspace or project | [Creating workspaces and projects](./creating-workspaces-and-projects.md)
|
|
78
|
-
| Bring an existing repository under governance | [Workspace operations](./workspace-operations.md#import-and-adoption)
|
|
79
|
-
| Run the complete intelligence loop | [Unified runner](./workspace-intelligence-runner.md)
|
|
80
|
-
| Turn plain language into governed work
|
|
81
|
-
|
|
|
82
|
-
|
|
|
83
|
-
|
|
|
84
|
-
|
|
|
85
|
-
|
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
77
|
+
| I want to… | Start here | Expected outcome |
|
|
78
|
+
| ------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
79
|
+
| Create a workspace or project | [Creating workspaces and projects](./creating-workspaces-and-projects.md) | A registered project with canonical `.workspai` metadata |
|
|
80
|
+
| Bring an existing repository under governance | [Workspace operations](./workspace-operations.md#import-and-adoption) | Source stays in place with `adopt`, or is copied/cloned with `import` |
|
|
81
|
+
| Run the complete intelligence loop | [Unified runner](./workspace-intelligence-runner.md) | One ordered run report with durable stage evidence |
|
|
82
|
+
| Turn plain language into governed work | [Goal Packs](./goal-packs.md) | A scope-bound, evidence-pinned plan and portable agent handoff |
|
|
83
|
+
| Ground an agent before broad source discovery | [Canonical-first agent entry](./agent-entry.md) | A portable receipt for host discovery, evidence integrity, and freshness |
|
|
84
|
+
| Repair a blocker through an approved transaction | [Workspace Repair Engine](./workspace-repair-engine.md) | Checkpointed execution, validation, canonical verify, and safe rollback |
|
|
85
|
+
| Set a release, security, or coverage outcome | [Verified engineering goals](./workspace-intelligence-runner.md#verified-engineering-goals) | A durable success contract with a current evidence-backed verdict |
|
|
86
|
+
| Ask an architecture or dependency question | [Workspace Knowledge Graph](./workspace-knowledge-graph.md) | A bounded answer with proof references rather than the whole graph |
|
|
87
|
+
| Measure agent token, cost, and outcome efficiency | [Workspace Intelligence Evaluation](./workspace-intelligence-evaluation.md) | A live, provenance-aware report suitable for CLI, IDE, and CI |
|
|
88
|
+
| Integrate CI or release gates | [CI workflows](./ci-workflows.md) | Machine-readable exit codes and uploadable evidence |
|
|
89
|
+
| Find the writer, schema, or path for an output | [Artifact Catalog](./contracts/ARTIFACT_CATALOG.md) | One canonical source instead of path guessing |
|
|
90
|
+
| Understand Workspai terminology | [Glossary](./GLOSSARY.md) | Shared meanings for model, graph, evidence, gate, and artifacts |
|
|
91
|
+
| Review or change the main product README | [README content contract](./README_CONTENT_CONTRACT.md) | Stable narrative, claim boundaries, and machine-enforced drift rules |
|
|
92
|
+
| Contribute to the CLI | [Development](./DEVELOPMENT.md) | Local build, test, contract, and documentation gates |
|
|
90
93
|
|
|
91
94
|
There are two different AI-facing features. Workspace Intelligence is
|
|
92
95
|
deterministic, proof-backed, and does not require an AI API key. The optional
|
|
@@ -103,7 +106,8 @@ with [AI Quickstart](./AI_QUICKSTART.md) only when that is your goal.
|
|
|
103
106
|
| [workspace-run.md](./workspace-run.md) | Polyglot fleet orchestration (`workspace run`) |
|
|
104
107
|
| [workspace-intelligence-runner.md](./workspace-intelligence-runner.md) | Canonical unified runner, execution envelope, report schema, exit codes, failure propagation, and CI consumption |
|
|
105
108
|
| [workspace-repair-engine.md](./workspace-repair-engine.md) | CLI-owned plan, approval, checkpoint, execution, verification, decision, and rollback state machine |
|
|
106
|
-
| [goal-packs.md](./goal-packs.md) | Plain-language intent compilation, scope/evidence binding, agent handoff, and mutation boundary
|
|
109
|
+
| [goal-packs.md](./goal-packs.md) | Plain-language intent compilation, scope/evidence binding, agent handoff, and mutation boundary |
|
|
110
|
+
| [agent-entry.md](./agent-entry.md) | Host-native discovery, canonical evidence preflight, receipt status, privacy, and consumer integration |
|
|
107
111
|
| [workspace-knowledge-graph.md](./workspace-knowledge-graph.md) | Two-minute graph quickstart, proof model, AI/MCP consumption, performance, and honest token-efficiency measurement |
|
|
108
112
|
| [graph-benchmark-methodology.md](./graph-benchmark-methodology.md) | Reproducible payload-reduction benchmark, formulas, claim boundaries, and publication rules |
|
|
109
113
|
| [workspace-intelligence-evaluation.md](./workspace-intelligence-evaluation.md) | Provider usage, cost provenance, verified outcomes, comparison, and extension consumption |
|
|
@@ -124,6 +128,7 @@ with [AI Quickstart](./AI_QUICKSTART.md) only when that is your goal.
|
|
|
124
128
|
- Adopt an existing repo: [workspace-operations.md#import-and-adoption](./workspace-operations.md#import-and-adoption)
|
|
125
129
|
- Scaffold a frontend app: [commands-reference.md](./commands-reference.md) (`create project nextjs <name>`)
|
|
126
130
|
- Canonical intelligence gate: `workspace intelligence run --for-agent generic --strict --json`
|
|
131
|
+
- Agent entry preflight: `agent bootstrap --for-agent <host> --json`
|
|
127
132
|
- Broader CI release gate: [commands-reference.md](./commands-reference.md) (`pipeline`, `readiness`)
|
|
128
133
|
- Targeted model/context inspection — schemas in [contracts/workspace-intelligence/](../contracts/workspace-intelligence/)
|
|
129
134
|
|
|
@@ -21,20 +21,22 @@ The root README keeps this order:
|
|
|
21
21
|
1. a problem-first product promise, slogan, and copyable first run;
|
|
22
22
|
2. product category and three durable outcomes;
|
|
23
23
|
3. one copyable path for existing software and one guided path for new software;
|
|
24
|
-
4.
|
|
25
|
-
5.
|
|
26
|
-
6.
|
|
27
|
-
7.
|
|
24
|
+
4. one plain-language Goal path with explicit scope and verification ownership;
|
|
25
|
+
5. a short outcome-oriented view of what Workspai provides;
|
|
26
|
+
6. the canonical Model → derived Graph boundary and intelligence chain;
|
|
27
|
+
7. consumer surfaces and goal-based documentation links;
|
|
28
|
+
8. package, contributor, community, and license routes.
|
|
28
29
|
|
|
29
30
|
The CLI README keeps this order:
|
|
30
31
|
|
|
31
32
|
1. a problem-first product promise, slogan, and copyable first run;
|
|
32
33
|
2. product category and durable value;
|
|
33
34
|
3. a two-minute existing-project path and the guided create path;
|
|
34
|
-
4.
|
|
35
|
-
5. the
|
|
36
|
-
6.
|
|
37
|
-
7.
|
|
35
|
+
4. one plain-language Goal path with explicit scope and verification ownership;
|
|
36
|
+
5. the small set of durable outputs a user should recognize;
|
|
37
|
+
6. the canonical Model → derived Graph boundary and intelligence chain;
|
|
38
|
+
7. everyday workflows grouped by goal;
|
|
39
|
+
8. outputs, requirements, documentation, troubleshooting, and contribution.
|
|
38
40
|
|
|
39
41
|
## What does not belong in a main README
|
|
40
42
|
|
|
@@ -100,6 +102,8 @@ task-success claim.
|
|
|
100
102
|
- Quickstarts must be copyable and use the canonical `workspai` package.
|
|
101
103
|
- `wspai` is only an optional short alias.
|
|
102
104
|
- The main path uses the complete contract-backed intelligence runner.
|
|
105
|
+
- The Goal path states that it prepares bounded work and does not itself edit
|
|
106
|
+
source or claim completion.
|
|
103
107
|
- A partial command sequence must not be presented as a replacement loop.
|
|
104
108
|
- Exhaustive syntax belongs in `docs/commands-reference.md`.
|
|
105
109
|
|