@kitelev/exocortex-cli 16.184.6 → 16.184.7

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.
Files changed (2) hide show
  1. package/dist/index.js +3 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // @kitelev/exocortex-cli v16.184.6
2
+ // @kitelev/exocortex-cli v16.184.7
3
3
  // CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
4
4
  // License: MIT
5
5
 
@@ -306,7 +306,7 @@ To resolve:
306
306
  path = ${e}
307
307
  url = ${t}
308
308
  `;return{content:n+i+s,added:!0}}a(lY,"appendGitmodulesEntry");function uY(n,e){let t=n.split(/\r?\n/),r=[],i=!1,s=new RegExp(`^\\[submodule\\s+"${ET(e)}"\\]\\s*$`);for(let l of t){if(i){if(/^\[.+\]\s*$/.test(l)){i=!1,r.push(l);continue}continue}if(s.test(l)){i=!0;continue}r.push(l)}let o=[],c=!1;for(let l of r){let u=l.trim().length===0;u&&c||(o.push(l),c=u)}return o.join(`
309
- `)}a(uY,"stripGitmodulesEntry")});var hu=T(TT=>{"use strict";Object.defineProperty(TT,"__esModule",{value:!0});TT.gitBlobSha=fY;async function fY(n,e){let t=new TextEncoder,r=typeof n=="string"?t.encode(n):n,i=t.encode(`blob ${r.byteLength}\0`),s=new Uint8Array(i.byteLength+r.byteLength);return s.set(i,0),s.set(r,i.byteLength),e(s)}a(fY,"gitBlobSha")});var md=T(Oy=>{"use strict";Object.defineProperty(Oy,"__esModule",{value:!0});Oy.extractAssetUid=gD;Oy.detectChanges=hY;var dY=hu();function gD(n){let e=/^---\r?\n([\s\S]*?)\r?\n---(?=\r?\n|$)/.exec(n);if(!e)return;let t=/^exo__Asset_uid:[ \t]*["']?([^\s"']+)["']?[ \t]*$/m.exec(e[1]);return t?t[1]:void 0}a(gD,"extractAssetUid");async function hY(n){let{localFiles:e,cachedEntries:t,watermark:r,actualBaseTreeSha:i,sha1:s}=n;if(r===null)return{kind:"full-conflict",reason:"first-sync"};if(i===null)return{kind:"full-conflict",reason:"base-mismatch",detail:`watermark commit ${r.lastSyncedSha} not resolvable on remote`};if(i!==r.rootTreeSha)return{kind:"full-conflict",reason:"base-mismatch",detail:`stored root tree ${r.rootTreeSha} != actual ${i} at ${r.lastSyncedSha}`};let o=[],c=new Map;for(let[I,C]of e){let D=await(0,dY.gitBlobSha)(C,s);c.set(I,D),o.push({path:I,blobSha:D,uid:typeof C=="string"?gD(C):void 0})}if(t!==void 0)for(let[I,C]of t)c.set(I,C.blobSha),o.push({path:I,blobSha:C.blobSha,uid:C.uid});let l=[],u=[],f=[],d=[],h=new Map;for(let I of o){if(I.uid===void 0)continue;let C=h.get(I.uid)??[];C.push(I.path),h.set(I.uid,C)}let p=new Map;for(let I of r.files){if(I.uid===void 0)continue;let C=p.get(I.uid)??[];C.push(I.path),p.set(I.uid,C)}let y=new Set;for(let[I,C]of h)C.length>1&&y.add(I);for(let[I,C]of p)C.length>1&&y.add(I);for(let I of[...y].sort()){let C=h.get(I)??[],D=C.length>1?`on disk (${C.join(", ")})`:`in the sync base (${(p.get(I)??[]).join(", ")})`;d.push(`duplicate uid ${I} ${D} \u2014 uid identity suppressed for the group; every path matched by path identity (#3477)`)}let _=new Map,w=[];for(let I of r.files)I.uid!==void 0&&!y.has(I.uid)?_.set(I.uid,I):w.push(I);let S=[],v=new Set;for(let I of o){let C=I.uid!==void 0&&!y.has(I.uid)?_.get(I.uid):void 0;I.uid!==void 0&&C!==void 0?(v.add(I.uid),(C.blobSha!==I.blobSha||C.path!==I.path)&&u.push({path:I.path,uid:I.uid,blobSha:I.blobSha,...C.path!==I.path?{basePath:C.path}:{}})):S.push(I)}let x=new Map;for(let I of w)x.set(I.path,I);for(let[I,C]of _)v.has(I)||x.set(C.path,C);for(let I of S){let C=x.get(I.path);C!==void 0?(x.delete(I.path),C.blobSha!==I.blobSha&&u.push({path:I.path,uid:I.uid,blobSha:I.blobSha})):l.push({path:I.path,uid:I.uid,blobSha:I.blobSha})}for(let I of x.values())f.push({path:I.path,uid:I.uid,blobSha:I.blobSha});return{kind:"changes",added:l,modified:u,deleted:f,warnings:d,diskBlobShas:c,duplicateUids:y}}a(hY,"detectChanges")});var bD=T(gd=>{"use strict";Object.defineProperty(gd,"__esModule",{value:!0});gd.rewriteAssetUid=yD;gd.findDuplicateUidGroups=_D;gd.planDuplicateUidFix=mY;var pY=md();function yD(n,e){let t=/^(---\r?\n)([\s\S]*?)(\r?\n---(?=\r?\n|$))/.exec(n);if(t===null)return n;let r=t[2].replace(/^(exo__Asset_uid:[ \t]*["']?)[^\s"']+(["']?[ \t]*)$/m,`$1${e}$2`);return r===t[2]?n:n.slice(0,t.index)+t[1]+r+t[3]+n.slice(t.index+t[0].length)}a(yD,"rewriteAssetUid");function _D(n){let e=new Map;for(let t of n){let r=(0,pY.extractAssetUid)(t.content);if(r===void 0)continue;let i=e.get(r)??[];i.push(t.path),e.set(r,i)}return[...e.entries()].filter(([,t])=>t.length>1).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>({uid:t,paths:r}))}a(_D,"findDuplicateUidGroups");function mY(n,e){let t=new Map(n.map(i=>[i.path,i.content])),r=[];for(let i of _D(n)){let s=[...i.paths].sort((o,c)=>o.localeCompare(c));for(let o of s.slice(1)){let c=t.get(o);if(c===void 0)continue;let l=e(),u=yD(c,l);u!==c&&r.push({path:o,fromUid:i.uid,toUid:l,content:u})}}return r}a(mY,"planDuplicateUidFix")});var _d=T(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});Oc.getHeadSha=yY;Oc.getCommitInfo=_Y;Oc.getTree=bY;Oc.getBlobText=SY;Oc.getBlobBytes=wY;var SD=ul(),gY="https://api.github.com";function yd(n){return(n??gY).replace(/\/$/,"")}a(yd,"api");function Rc(n){return n!==null&&typeof n=="object"?n:void 0}a(Rc,"asRecord");function Ns(n,e){let r=Rc(n)?.[e];return typeof r=="string"?r:void 0}a(Ns,"readString");async function yY(n,e,t,r,i){let s=await n({method:"GET",url:`${yd(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/refs/heads/${encodeURIComponent(r)}`}),o=Ns(Rc(s?.json)?.object,"sha");if(typeof o!="string"||o.length===0)throw new Error(`ExoSync: missing object.sha for ref heads/${r}`);return o}a(yY,"getHeadSha");async function _Y(n,e,t,r,i){let s=await n({method:"GET",url:`${yd(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/commits/${encodeURIComponent(r)}`}),o=Rc(s?.json),c=Ns(o,"sha"),l=Ns(o?.tree,"sha");if(!c||!l)throw new Error(`ExoSync: malformed commit response for ${r}`);let u=o?.parents,f=Array.isArray(u)?u.map(d=>Ns(d,"sha")).filter(d=>typeof d=="string"):[];return{sha:c,treeSha:l,parents:f}}a(_Y,"getCommitInfo");async function bY(n,e,t,r,i){let s=await n({method:"GET",url:`${yd(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/trees/${encodeURIComponent(r)}?recursive=1`}),o=Rc(s?.json);if(o?.truncated===!0)throw new Error(`ExoSync: tree ${r} is truncated by GitHub (repo too large for recursive listing) \u2014 refusing to diff`);let c=o?.tree;if(!Array.isArray(c))throw new Error(`ExoSync: malformed tree response for ${r}`);let l=[];for(let u of c){let f=Rc(u);if(f?.type!=="blob")continue;let d=Ns(f,"path"),h=Ns(f,"sha"),p=typeof f.size=="number"?f.size:void 0;d&&h&&l.push({path:d,blobSha:h,...p!==void 0?{size:p}:{}})}return l}a(bY,"getTree");async function SY(n,e,t,r,i){let s=await n({method:"GET",url:`${yd(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(r)}`}),o=Rc(s?.json),c=Ns(o,"content");if(typeof c!="string")throw new Error(`ExoSync: malformed blob response for ${r}`);return Ns(o,"encoding")==="utf-8"?c:(0,SD.base64ToUtf8)(c)}a(SY,"getBlobText");async function wY(n,e,t,r,i){let s=await n({method:"GET",url:`${yd(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(r)}`}),o=Rc(s?.json),c=Ns(o,"content");if(typeof c!="string")throw new Error(`ExoSync: malformed blob response for ${r}`);return Ns(o,"encoding")==="utf-8"?new TextEncoder().encode(c):(0,SD.base64ToBytes)(c)}a(wY,"getBlobBytes")});var RT=T(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});er.SyncPhaseTimer=er.SYNC_PHASES=void 0;er.classifyRestPhase=vY;er.emptyTimings=vD;er.totalMs=Cy;er.addTimings=ED;er.aggregateTimings=EY;er.dominantPhase=TY;er.fmtMs=bd;er.formatTimingsLine=AY;er.formatRepoTimings=IY;er.SYNC_PHASES=["localList","localRead","localWrite","hash","restHead","restCommit","restTree","restBlob","restPush"];function IT(){let n={};for(let e of er.SYNC_PHASES)n[e]=0;return n}a(IT,"zeroDurations");function wD(){return{filesRead:0,filesHashed:0,filesWritten:0,restCalls:0}}a(wD,"zeroCounts");function vY(n){if(n.method!=="GET")return"restPush";let e=n.url;return e.includes("/git/blobs/")?"restBlob":e.includes("/git/trees/")?"restTree":e.includes("/git/commits/")?"restCommit":e.includes("/git/refs/")?"restHead":"restCommit"}a(vY,"classifyRestPhase");var AT=class{static{a(this,"SyncPhaseTimer")}constructor(e){this.now=e,this.durations=IT(),this.counts=wD()}async time(e,t){let r=this.now();try{return await t()}finally{this.durations[e]+=this.now()-r}}bumpRead(){this.counts.filesRead++}bumpHashed(){this.counts.filesHashed++}bumpWritten(){this.counts.filesWritten++}bumpRest(){this.counts.restCalls++}snapshot(){return{durations:{...this.durations},counts:{...this.counts}}}};er.SyncPhaseTimer=AT;function vD(){return{durations:IT(),counts:wD()}}a(vD,"emptyTimings");function Cy(n){let e=0;for(let t of er.SYNC_PHASES)e+=n.durations[t];return e}a(Cy,"totalMs");function ED(n,e){let t=IT();for(let r of er.SYNC_PHASES)t[r]=n.durations[r]+e.durations[r];return{durations:t,counts:{filesRead:n.counts.filesRead+e.counts.filesRead,filesHashed:n.counts.filesHashed+e.counts.filesHashed,filesWritten:n.counts.filesWritten+e.counts.filesWritten,restCalls:n.counts.restCalls+e.counts.restCalls}}}a(ED,"addTimings");function EY(n){let e=vD();for(let t of n)t.timings!==void 0&&(e=ED(e,t.timings));return e}a(EY,"aggregateTimings");function TY(n){let e=Cy(n);if(e<=0)return null;let t=er.SYNC_PHASES[0],r=-1;for(let i of er.SYNC_PHASES)n.durations[i]>r&&(r=n.durations[i],t=i);return{phase:t,ms:r,pct:r/e*100}}a(TY,"dominantPhase");function bd(n){return n>=1e3?`${(n/1e3).toFixed(1)}s`:`${Math.round(n)}ms`}a(bd,"fmtMs");function AY(n){let e=Cy(n);if(e<=0)return"";let t=er.SYNC_PHASES.filter(r=>n.durations[r]>0).sort((r,i)=>n.durations[i]-n.durations[r]).map(r=>`${r} ${bd(n.durations[r])} ${Math.round(n.durations[r]/e*100)}%`);return`\u23F1 ExoSync ${bd(e)} \u2014 ${t.join(" \xB7 ")} (${n.counts.filesHashed} hashed, ${n.counts.filesRead} read, ${n.counts.restCalls} REST)`}a(AY,"formatTimingsLine");function IY(n,e){let t=er.SYNC_PHASES.map(r=>`${r}=${bd(e.durations[r])}`);return`[ExoSync timings] ${n}: total ${bd(Cy(e))} \u2014 ${t.join(" ")} | hashed ${e.counts.filesHashed} read ${e.counts.filesRead} written ${e.counts.filesWritten} REST ${e.counts.restCalls}`}a(IY,"formatRepoTimings")});var xy=T(Sa=>{"use strict";Object.defineProperty(Sa,"__esModule",{value:!0});Sa.LocalOutboxStore=Sa.OUTBOX_REMOTE_ABSENT=Sa.OUTBOX_STORE_FILENAME=void 0;Sa.OUTBOX_STORE_FILENAME="exosync-outbox.local.json";Sa.OUTBOX_REMOTE_ABSENT=" absent";function OT(n,e){return`${n}\0${e}`}a(OT,"outboxKey");function TD(n){if(n===null||typeof n!="object")return!1;let e=n;return typeof e.repoKey=="string"&&typeof e.path=="string"&&typeof e.chosenContent=="string"&&typeof e.baseRemoteSha=="string"}a(TD,"isEntry");var CT=class{static{a(this,"LocalOutboxStore")}constructor(e){this.writeChain=Promise.resolve(),this.io=e.io,this.now=e.now??(()=>new Date().toISOString())}async enqueue(e){await this.mutate(t=>{t.entries[OT(e.repoKey,e.path)]={version:1,...e,resolvedAt:e.resolvedAt.length>0?e.resolvedAt:this.now()}})}async remove(e,t){await this.mutate(r=>{delete r.entries[OT(e,t)]})}async list(){let e=await this.read();return Object.values(e.entries).filter(TD)}async listForRepo(e){return(await this.list()).filter(t=>t.repoKey===e)}async has(e,t){let i=(await this.read()).entries[OT(e,t)];return i!==void 0&&TD(i)}async mutate(e){let t=this.writeChain.then(async()=>{let r=await this.read();e(r),await this.io.writeAtomic(JSON.stringify(r,null,2))});return this.writeChain=t.catch(()=>{}),t}async read(){try{let e=await this.io.read();if(e===null)return{version:1,entries:{}};let t=JSON.parse(e);if(t===null||typeof t!="object")return{version:1,entries:{}};let r=t.entries;return r===null||typeof r!="object"?{version:1,entries:{}}:{version:1,entries:{...r}}}catch{return{version:1,entries:{}}}}};Sa.LocalOutboxStore=CT});var Py=T(xT=>{"use strict";Object.defineProperty(xT,"__esModule",{value:!0});xT.isAuthError=RY;function RY(n){let e=n instanceof Error?n.message:String(n);return/HTTP 401/.test(e)?!0:/HTTP 403/.test(e)&&!/rate limit/i.test(e)&&!/abuse detection/i.test(e)}a(RY,"isAuthError")});var PT=T(Dy=>{"use strict";Object.defineProperty(Dy,"__esModule",{value:!0});Dy.scanForSecrets=OY;Dy.redactSecrets=CY;var AD=[{kind:"github-token",re:/gh[pousr]_[A-Za-z0-9_]{36,}/},{kind:"github-fine-grained-token",re:/github_pat_[A-Za-z0-9_]{22,}_[A-Za-z0-9_]{59,}/},{kind:"private-key",re:/-----BEGIN [A-Z ]*PRIVATE KEY-----/}];function OY(n){let e=[];for(let[t,r]of n)for(let{kind:i,re:s}of AD)s.test(r)&&e.push({path:t,kind:i});return e}a(OY,"scanForSecrets");function CY(n){let e=n;for(let{kind:t,re:r}of AD)e=e.replace(new RegExp(r.source,"g"),`[REDACTED:${t}]`);return e}a(CY,"redactSecrets")});var Ly=T(Fy=>{"use strict";Object.defineProperty(Fy,"__esModule",{value:!0});Fy.isRateLimitError=ID;Fy.withRateLimitBackoff=PY;function ID(n){let e=n instanceof Error?n.message:String(n);return/HTTP 429/.test(e)?!0:/HTTP 403/.test(e)&&(/rate limit/i.test(e)||/abuse detection/i.test(e))}a(ID,"isRateLimitError");var xY=a(n=>new Promise(e=>setTimeout(e,n)),"defaultSleep");function PY(n,e={}){let t=e.maxRetries??3,r=e.baseDelayMs??1e3,i=e.sleep??xY,s=e.random??Math.random;return async o=>{let c=0;for(;;)try{return await n(o)}catch(l){if(!ID(l)||c>=t)throw l;let u=r*2**c*(1+s());c++,await i(u)}}}a(PY,"withRateLimitBackoff")});var Ny=T(No=>{"use strict";Object.defineProperty(No,"__esModule",{value:!0});No.DEFAULT_MAX_FILE_BYTES=No.InMemoryQuarantineStore=void 0;No.contentEquals=DY;No.isSyncablePath=FY;No.isFileSpaceSyncablePath=LY;function DY(n,e){if(n===void 0||e===void 0||typeof n=="string"&&typeof e=="string")return n===e;if(typeof n=="string"||typeof e=="string"||n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.byteLength;t++)if(n[t]!==e[t])return!1;return!0}a(DY,"contentEquals");var DT=class{static{a(this,"InMemoryQuarantineStore")}constructor(){this.entries=[]}async quarantine(e){this.entries.push(e)}};No.InMemoryQuarantineStore=DT;function FY(n){return n.endsWith(".md")&&!n.includes(".local.")&&!n.includes(".conflict.")}a(FY,"isSyncablePath");function LY(n){return!n.includes(".local.")&&!n.includes(".conflict.")}a(LY,"isFileSpaceSyncablePath");No.DEFAULT_MAX_FILE_BYTES=30*1024*1024});var LD=T(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.SyncEngine=qn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=qn.DEFAULT_MAX_PUSH_RETRIES=void 0;qn.syncProgressPhaseText=$Y;qn.isNonFastForwardError=FD;qn.orderChildrenFirst=HY;var RD=Iy(),OD=RT(),mt=_d(),ko=md(),NY=ul(),Cc=hu(),FT=xy(),kY=Py(),MY=PT(),jY=Ly(),ks=Ny();qn.DEFAULT_MAX_PUSH_RETRIES=3;qn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=720*60*1e3;function $Y(n){switch(n.phase){case"reading-local":return n.detail!==void 0?`reading local files ${n.detail.done}\u2026`:"reading local files\u2026";case"detecting":return"detecting changes\u2026";case"pulling-remote":return"pulling remote tree\u2026";case"fetching-blobs":return n.detail!==void 0?`fetching remote files ${n.detail.done}/${n.detail.total}\u2026`:"fetching remote files\u2026";case"writing-files":return n.detail!==void 0?`writing files ${n.detail.done}\u2026`:"writing files\u2026";case"merging":return"merge layer firing\u2026";default:return n.phase}}a($Y,"syncProgressPhaseText");var CD=25,UY=10,BY=500,VY=25;function qY(n){try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{return null}}a(qY,"decodeUtf8Strict");function GY(n){return typeof n=="string"?n:{base64:(0,NY.bytesToBase64)(n)}}a(GY,"toCommitContent");async function xD(n,e){if(n.readBinary===void 0)throw new Error("LocalFilesPort.readBinary is required for file-mode sync (Phase C)");return n.readBinary(e)}a(xD,"readBinaryStrict");async function WY(n,e,t){if(n.writeBinary===void 0)throw new Error("LocalFilesPort.writeBinary is required for file-mode sync (Phase C)");return n.writeBinary(e,t)}a(WY,"writeBinaryStrict");function PD(n){return n.length===0||n.startsWith("/")||n.includes("\\")?!1:n.split("/").every(e=>e.length>0&&e!=="."&&e!=="..")}a(PD,"isSafeRepoRelativePath");function FD(n){let e=n instanceof Error?n.message:String(n);return/HTTP 422/.test(e)&&/git\/refs/.test(e)||/ref update mismatch/.test(e)||/HTTP 422/.test(e)&&/git\/trees/.test(e)&&/BadObjectState/.test(e)}a(FD,"isNonFastForwardError");function HY(n){let e=a(t=>t.split("/").filter(r=>r.length>0).length,"depth");return[...n].sort((t,r)=>e(r.localPath)-e(t.localPath))}a(HY,"orderChildrenFirst");function DD(n,e){let t=new Map(n.map(o=>[o.path,o])),r=new Set,i=[];for(let o of e){r.add(o.path);let c=t.get(o.path);(c===void 0||c.blobSha!==o.blobSha)&&i.push(o)}let s=n.filter(o=>!r.has(o.path));return{changed:i,deleted:s}}a(DD,"diffTrees");function wa(n){return n instanceof Error?n.message:String(n)}a(wa,"errMsg");function zY(n,e,t){if(t.size===0)return n;let r=new Map(e.files.map(o=>[o.path,o])),i=new Set(n.map(o=>o.path)),s=[];for(let o of n){if(!t.has(o.path)){s.push(o);continue}let c=r.get(o.path);c!==void 0&&s.push(c)}for(let o of t){if(i.has(o))continue;let c=r.get(o);c!==void 0&&s.push(c)}return s}a(zY,"applyWatermarkPins");var LT={mergedFiles:new Map,mergedWrites:[],quarantineEntries:[],resolvedQuarantineEntries:[],mergedCount:0,mergedPaths:[],warnings:[]};function NT(n){return new Map(n.map(e=>[e.path,e.blobSha]))}a(NT,"treeByPath");function ky(n){return[...n.quarantineEntries.map(e=>e.path),...n.resolvedQuarantineEntries.map(e=>e.path)]}a(ky,"quarantinedPathsOf");var kT=class{static{a(this,"SyncEngine")}constructor(e){this.activeTimer=null,this.activeLocalIoProgress=null,this.opInProgress=!1,this.deps=e,this.now=e.now??(()=>Date.now()),this.transport=this.instrumentTransport((0,jY.withRateLimitBackoff)(e.transport,e.backoff)),this.sha1=this.instrumentSha1(e.sha1)}instrumentTransport(e){return async t=>{let r=this.activeTimer;return r===null?e(t):(r.bumpRest(),r.time((0,OD.classifyRestPhase)(t),()=>e(t)))}}instrumentSha1(e){return t=>{let r=this.activeTimer;return r===null?e(t):(r.bumpHashed(),r.time("hash",()=>e(t)))}}instrumentLocalFiles(e){let t=a((c,l)=>{let u=this.activeTimer;return u===null?l():u.time(c,l)},"timed"),r={list:a(()=>t("localList",()=>e.list()),"list"),read:a(c=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>e.read(c))),"read"),write:a((c,l)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),e.write(c,l))),"write"),delete:a(c=>e.delete(c),"delete")},i=e.readBinary?.bind(e);i!==void 0&&(r.readBinary=c=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>i(c))));let s=e.writeBinary?.bind(e);s!==void 0&&(r.writeBinary=(c,l)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),s(c,l))));let o=e.stat?.bind(e);return o!==void 0&&(r.stat=c=>t("localList",()=>o(c))),r}busyResult(e){return{repoKey:e.repoKey,status:"busy",pulledCount:0,pushedCount:0,mergedCount:0,quarantinedCount:0,warnings:[],deferredDeletes:[],detail:"another sync operation is in progress (D11 guard) \u2014 retry after it finishes"}}modeOps(e){let t=e.spaceKind==="file",r=t?ks.isFileSpaceSyncablePath:ks.isSyncablePath,i=this.deps.maxFileBytes??ks.DEFAULT_MAX_FILE_BYTES;return{fileMode:t,syncable:r,treeFilter:a(s=>r(s.path)&&(!t||s.size===void 0||s.size<=i),"treeFilter")}}async buildFileModeFirstSyncBase(e,t,r,i){let s=await(0,mt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),c=(await(0,mt.getTree)(this.transport,e.owner,e.repo,o.treeSha,this.deps.baseURL)).filter(r.treeFilter),l=[];for(let u of c){let f=t.get(u.path);f!==void 0&&await(0,Cc.gitBlobSha)(f,this.sha1)===u.blobSha&&l.push({path:u.path,blobSha:u.blobSha})}return i.push(`first-sync (file mode): synthetic base from ${l.length} already-identical file(s) at head ${s} \u2014 divergence resolves through the remote-wins layer (D22)`),{lastSyncedSha:s,rootTreeSha:o.treeSha,files:l,spaceKind:"file"}}async syncAll(e,t="sync",r){if(this.opInProgress)return e.map(i=>this.busyResult(i));this.opInProgress=!0;try{let i=[];for(let s of e)i.push(await this.syncLocked(s,t,r));return i}finally{this.opInProgress=!1}}async sync(e,t="sync",r){if(this.opInProgress)return this.busyResult(e);this.opInProgress=!0;try{return await this.syncLocked(e,t,r)}finally{this.opInProgress=!1}}emitProgress(e,t,r,i){if(e!==void 0)try{e(i===void 0?{repoKey:t,phase:r}:{repoKey:t,phase:r,detail:i})}catch{}}bumpReadProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.reads+=1,e.reads%BY===0&&this.emitProgress(e.emit,e.repoKey,"reading-local",{done:e.reads}))}bumpWriteProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.writes+=1,e.writes%VY===0&&this.emitProgress(e.emit,e.repoKey,"writing-files",{done:e.writes}))}async syncLocked(e,t="sync",r){let i=new OD.SyncPhaseTimer(this.now),s=this.activeTimer;this.activeTimer=i;let o=this.activeLocalIoProgress;this.activeLocalIoProgress=r!==void 0?{emit:r,repoKey:e.repoKey,reads:0,writes:0}:null;let c=[],l=[],u=0,f=0,d=[],h=a((p,y={})=>({repoKey:e.repoKey,status:p,pulledCount:0,pushedCount:0,mergedCount:0,quarantinedCount:0,warnings:c,deferredDeletes:l,...u>0?{outboxPushedCount:u}:{},...f>0?{outboxReconflictedCount:f}:{},timings:i.snapshot(),...y}),"result");try{let p=await this.deps.materializationCheck.check(e);if(!p.fullyMaterialized)return c.push(`skipped: repo not fully materialized${p.reason?` (${p.reason})`:""} \u2014 deletes NOT inferred (D19)`),h("skipped-not-materialized");let y=this.modeOps(e),_=this.instrumentLocalFiles(this.deps.localFilesFor(e));if(y.fileMode&&(_.readBinary===void 0||_.writeBinary===void 0))return h("error",{detail:"file-mode repo requires a LocalFilesPort with readBinary/writeBinary \u2014 refusing to sync through the text-only port (binary would corrupt)"});if(y.fileMode&&this.deps.quarantine===void 0)return h("error",{detail:"file-mode repo requires a quarantine sink (D18 remote-wins preserves losing local bytes there) \u2014 configure the quarantine repo before syncing FileSpaces"});let w=this.deps.maxFileBytes??ks.DEFAULT_MAX_FILE_BYTES;if(t!=="pull"&&this.deps.outbox!==void 0){let ee=await this.flushOutbox(e,c);u=ee.pushed,f=ee.reconflicted}let S=await this.deps.watermarkStore.get(e.repoKey);if(S?.spaceKind==="file"&&!y.fileMode)return h("error",{detail:"watermark was written by a FILE-mode sync but the spec now resolves to asset mode \u2014 refusing (fix the conflicting Space declarations, or clear the watermark to restart)"});S!==null&&y.fileMode&&S.spaceKind!=="file"&&(c.push("watermark was written by an ASSET-mode sync \u2014 rebuilding the base through the file-mode first-sync layer (kind flip)"),S=null);let v=this.deps.localManifestStore!==void 0?_.stat?.bind(_):void 0,x=v!==void 0&&S!==null&&!y.fileMode,I=x&&this.deps.localManifestStore!==void 0?await this.deps.localManifestStore.get(e.repoKey):null,C=this.deps.localManifestFullRehashMs??qn.DEFAULT_LOCAL_MANIFEST_REHASH_MS,D=x&&(I===null||this.now()-I.lastFullRehashMs>=C),K=new Map,U=new Set,k=new Map,z=new Map,N=new Map,ae=!1,_e=new Map;if(x&&S!==null)for(let ee of S.files)_e.set(ee.path,ee.blobSha);for(let ee of(await _.list()).filter(y.syncable)){if(y.fileMode){let Re=await xD(_,ee);if(Re.byteLength>w){U.add(ee),c.push(`skipped oversized file ${ee} (${Re.byteLength} bytes > ${w} cap) \u2014 excluded from sync symmetrically (Phase C size cap)`);continue}K.set(ee,Re);continue}if(!x||v===void 0){K.set(ee,await _.read(ee));continue}let de=await v(ee),we=!D&&de!==null?I?.files[ee]:void 0;if(de!==null&&we!==void 0&&we.mtimeMs===de.mtimeMs&&we.size===de.size&&we.blobSha===_e.get(ee)){k.set(ee,{blobSha:we.blobSha,...we.uid!==void 0?{uid:we.uid}:{}}),z.set(ee,we.blobSha),N.set(ee,de);continue}ae=!0,K.set(ee,await _.read(ee)),de!==null&&N.set(ee,de)}let J=!1;if(S===null)if(y.fileMode)J=!0,S=await this.buildFileModeFirstSyncBase(e,K,y,c);else{let ee=await this.bootstrapWatermark(e,K,c,h);if(ee.kind==="settled")return ee.outcome;J=!0,S=ee.base}let he=S;y.fileMode&&U.size>0&&(S={...S,files:S.files.filter(ee=>!U.has(ee.path))});let Q,ve;x&&!D?(Q=await(0,mt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),ve=Q===S.lastSyncedSha?S.rootTreeSha:await this.resolveBaseTreeSha(e,S)):ve=await this.resolveBaseTreeSha(e,S),this.emitProgress(r,e.repoKey,"detecting");let ie=await(0,ko.detectChanges)({localFiles:K,...x?{cachedEntries:k}:{},watermark:S,actualBaseTreeSha:ve,sha1:this.sha1});if(ie.kind==="full-conflict")return h("full-conflict",{detail:`${ie.reason}${ie.detail?`: ${ie.detail}`:""} \u2014 divergence must go through merge/quarantine (A2/A3), not overwrite`});if(c.push(...ie.warnings),x&&this.deps.localManifestStore!==void 0){let ee={};for(let[de,we]of K){let Re=N.get(de),Me=ie.diskBlobShas.get(de);if(Re===void 0||Me===void 0)continue;let Ne=typeof we=="string"?(0,ko.extractAssetUid)(we):void 0;ee[de]={mtimeMs:Re.mtimeMs,size:Re.size,blobSha:Me,...Ne!==void 0?{uid:Ne}:{}}}for(let[de,we]of k){let Re=N.get(de);Re!==void 0&&(ee[de]={mtimeMs:Re.mtimeMs,size:Re.size,blobSha:we.blobSha,...we.uid!==void 0?{uid:we.uid}:{}})}if(I!==null&&Object.keys(I.files).some(de=>!(de in ee))&&(ae=!0),ae||D||I===null){let de={version:1,files:ee,lastFullRehashMs:D||I===null?this.now():I.lastFullRehashMs};await this.deps.localManifestStore.set(e.repoKey,de)}}let te=this.pinLocalChanges(ie,K,c,l,t);d=[...te.pushDeletionsAll.keys()];let me=await this.runPushLoop(e,S,te,K,c,y,J,U,t,r,Q);if(d=[],me.kind!=="done"&&te.pushDeletionsAll.size>0&&l.push(...te.pushDeletionsAll.keys()),me.kind==="conflict")return h("conflict",{detail:me.detail});if(me.kind==="secret-detected")return h("error",{detail:me.detail});if(me.kind==="retry-exhausted"){c.push(...me.merge.warnings);let ee=await this.buildTerminalQuarantineEntries(e,S,me.pushFiles,me.merge.quarantineEntries,K),de=[...me.merge.quarantineEntries,...me.merge.resolvedQuarantineEntries,...ee];return await this.flushQuarantine(de,c),h("retry-exhausted",{detail:me.detail,quarantinedCount:de.length,...de.length>0?{quarantinedPaths:de.map(we=>we.path)}:{}})}let{examinedHead:Ee,pushedSha:re,applyWrites:ye,applyDeletes:Fe,pushFiles:se}=me,ge=me.merge;c.push(...ge.warnings),c.push(...me.deferredWarnings),l.push(...me.withheldDeletions);let Le=me.deferredPaths.size>0?{deferredPaths:[...me.deferredPaths]}:{},Y=me.pushedDeletions.length>0?{pushedDeletes:me.pushedDeletions}:{},ce=await this.flushQuarantine([...ge.quarantineEntries,...ge.resolvedQuarantineEntries],c),be=new Set;if(!ce&&ge.resolvedQuarantineEntries.length>0){for(let ee of ge.resolvedQuarantineEntries)be.add(ee.path);c.push(`quarantine flush failed \u2014 remote-wins apply withheld for ${be.size} path(s); local files untouched, conflict re-derives next sync (D18 durability gate)`)}if(re===void 0&&Ee===S.lastSyncedSha&&ye.length===0&&Fe.length===0&&ge.mergedWrites.length===0&&ge.quarantineEntries.length===0&&ge.resolvedQuarantineEntries.length===0&&(S.pinnedPaths?.length??0)===0&&me.alreadyInHead.length===0&&me.deferredPaths.size===0&&!J)return h("synced");let Ie=re??Ee,Ce=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,Ie,this.deps.baseURL);if(re!==void 0&&Ce.parents[0]!==Ee)return await this.checkRaceWindow(e,S,Ee,Ce.parents[0],se,new Set(me.pushedDeletions),c,y),c.push(`race-window: watermark NOT advanced (pushed commit's parent ${Ce.parents[0]} != examined head ${Ee}) \u2014 next sync reconciles the concurrent change`),h("synced",{pushedSha:re,pushedCount:se.size,mergedCount:ge.mergedCount,quarantinedCount:ge.quarantineEntries.length+ge.resolvedQuarantineEntries.length,...ge.mergedPaths.length>0?{mergedPaths:ge.mergedPaths}:{},...ky(ge).length>0?{quarantinedPaths:ky(ge)}:{},...Le,...Y});let{pulledCount:De,pinnedPaths:Pe,pulledPaths:Te}=await this.applyRemoteChanges(_,K,[...ye,...ge.mergedWrites].filter(ee=>!be.has(ee.path)),Fe.filter(ee=>!be.has(ee.path)),c,z);for(let ee of ge.quarantineEntries)Pe.add(ee.path);for(let ee of me.deferredPaths)Pe.add(ee);for(let ee of be)Pe.add(ee);if(y.fileMode){for(let ee of U)Pe.add(ee);for(let ee of me.remoteOversized)Pe.add(ee)}return await this.advanceWatermark(e,Ie,Ce.treeSha,K,[...ye,...ge.mergedWrites,...me.deferredRemoteChanges],he,Pe,ie.diskBlobShas,y,U),await this.resolveClearedPins(e,he,Pe,c,new Set(ge.resolvedQuarantineEntries.map(ee=>ee.path))),h("synced",{pushedSha:re,pulledCount:De,pushedCount:se.size,mergedCount:ge.mergedCount,quarantinedCount:ge.quarantineEntries.length+ge.resolvedQuarantineEntries.length,...ge.mergedPaths.length>0?{mergedPaths:ge.mergedPaths}:{},...Te.length>0?{pulledPaths:Te}:{},...ky(ge).length>0?{quarantinedPaths:ky(ge)}:{},...Le,...Y})}catch(p){let y=this.deps.redact??(_=>_);return d.length>0&&l.push(...d),(0,kY.isAuthError)(p)?h("auth-required",{detail:y(`authentication failed: ${wa(p)} \u2014 the PAT is expired, revoked or under-scoped; update it in the per-device secure storage (R8). Never treated as success.`)}):(c.push(`sync failed: ${y(wa(p))}`),h("error",{detail:y(wa(p))}))}finally{this.activeTimer=s,this.activeLocalIoProgress=o}}async flushQuarantine(e,t){if(e.length===0)return!0;let r=this.deps.redact??(s=>s);for(let s of e)t.push(r(`quarantined ${s.path}: ${s.reason}`));let i=this.deps.quarantine;if(i===void 0)return!1;try{if(i.quarantineAll!==void 0)await i.quarantineAll(e);else for(let s of e)await i.quarantine(s);return!0}catch(s){let o=this.deps.redact??(c=>c);return t.push(`quarantine sink failed: ${o(wa(s))} \u2014 files untouched on disk; the conflict re-derives next sync (D17 degradation)`),!1}}async flushOutbox(e,t){let r=this.deps.outbox;if(r===void 0)return{pushed:0,reconflicted:0};let i=await r.listForRepo(e.repoKey);if(i.length===0)return{pushed:0,reconflicted:0};let s=this.deps.redact??(y=>y),o,c;try{({head:o,shaByPath:c}=await this.outboxHeadTreeShas(e))}catch(y){return t.push(`outbox flush deferred (${i.length} resolution(s) awaiting push): ${s(wa(y))}`),{pushed:0,reconflicted:0}}let l=0,u=[];for(let y of i){let _=c.get(y.path)??FT.OUTBOX_REMOTE_ABSENT,w=_===FT.OUTBOX_REMOTE_ABSENT&&y.baseRemoteSha!==FT.OUTBOX_REMOTE_ABSENT?[...c].filter(([S,v])=>S!==y.path&&v===y.baseRemoteSha).map(([S])=>S):[];if(_!==y.baseRemoteSha&&w.length===0){await r.remove(y.repoKey,y.path),l++,t.push(s(`outbox: remote moved for ${y.path} since you resolved it \u2014 NOT pushed; resolve again (your choice is preserved on disk)`));continue}u.push({entry:y,stalePaths:w})}if(u.length===0)return{pushed:0,reconflicted:l};let f=new Map;for(let{entry:y}of u)f.set(y.path,y.chosenContent);let d=new Set;for(let{stalePaths:y}of u)for(let _ of y)f.has(_)||d.add(_);let h=[...d];try{await(0,RD.restCreateCommit)(this.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:f,...h.length>0?{deletions:h}:{},message:h.length>0?`chore(exosync): resolve ${u.length} keep-local conflict(s) (consolidate ${h.length} stale remote path(s))`:`chore(exosync): push ${u.length} resolved conflict(s)`,expectedHeadSha:o,...this.deps.baseURL!==void 0?{baseURL:this.deps.baseURL}:{},...this.deps.redact!==void 0?{redact:this.deps.redact}:{}})}catch(y){return t.push(`outbox: batch push deferred for ${u.length} resolution(s), will retry next sync: ${s(wa(y))}`),{pushed:0,reconflicted:l}}let p=0;for(let{entry:y,stalePaths:_}of u){let w=_.filter(S=>!f.has(S));await this.snapOutboxWatermark(e,y.path,y.chosenContent,w),await this.deps.quarantine?.markResolved?.(y.repoKey,y.path);for(let S of w)await this.deps.quarantine?.markResolved?.(y.repoKey,S);await r.remove(y.repoKey,y.path),p++,w.length>0&&t.push(`consolidated cross-path conflict for ${y.path} \u2014 removed ${w.length} stale remote copy/copies (recoverable in git history)`)}return p>0&&t.push(`pushed ${p} resolved conflict(s)`),{pushed:p,reconflicted:l}}async outboxHeadTreeShas(e){let t=await(0,mt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),r=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,mt.getTree)(this.transport,e.owner,e.repo,r.treeSha,this.deps.baseURL),s=new Map;for(let o of i)s.set(o.path,o.blobSha);return{head:t,shaByPath:s}}async snapOutboxWatermark(e,t,r,i=[]){let s=await this.deps.watermarkStore.get(e.repoKey);if(s===null)return;let o=new Set([t,...i]),c=(s.pinnedPaths??[]).filter(_=>!o.has(_)),l=await(0,Cc.gitBlobSha)(r,this.sha1),u=(0,ko.extractAssetUid)(r),f={path:t,blobSha:l,...u!==void 0?{uid:u}:{}},d=new Set(i),h=s.files.filter(_=>!d.has(_.path)),p=h.findIndex(_=>_.path===t),y=p>=0?h.map((_,w)=>w===p?f:_):[...h,f];await this.deps.watermarkStore.set(e.repoKey,{...s,files:y,...c.length>0?{pinnedPaths:c}:{pinnedPaths:void 0}})}async buildTerminalQuarantineEntries(e,t,r,i,s){let o=new Set(i.map(u=>u.path)),c=new Map;try{let u=await(0,mt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),f=(await(0,mt.getTree)(this.transport,e.owner,e.repo,(await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,u,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(d=>r.has(d.path));for(let d of f)c.set(d.path,await(0,mt.getBlobText)(this.transport,e.owner,e.repo,d.blobSha,this.deps.baseURL))}catch{}let l=[];for(let[u,f]of r){if(o.has(u))continue;let d=s.get(u),h=d??f,p=d!==void 0&&!(0,ks.contentEquals)(d,f),y=typeof h=="string"?(0,ko.extractAssetUid)(h):void 0,_=c.get(u);l.push({repoKey:e.repoKey,path:u,...y!==void 0?{uid:y}:{},reason:`non-fast-forward push failed after ${this.deps.maxPushRetries??qn.DEFAULT_MAX_PUSH_RETRIES} retries (D16) \u2014 a concurrent writer keeps moving ${e.branch}; base recoverable from git history at ${t.lastSyncedSha}${p?"; the contended push payload was a merged proposal (never applied to disk) \u2014 the merge re-derives next sync":""}`,...typeof h=="string"?{localContent:h}:{localContentBytes:h},..._!==void 0?{remoteContent:_}:{}})}return l}async resolveClearedPins(e,t,r,i,s=new Set){let o=this.deps.quarantine;if(o===void 0||o.markResolved===void 0)return;let c=(t.pinnedPaths??[]).filter(l=>!r.has(l)&&!s.has(l));for(let l of c)try{await o.markResolved?.(e.repoKey,l)}catch(u){let f=this.deps.redact??(d=>d);i.push(`quarantine markResolved failed for ${l}: ${f(wa(u))} \u2014 unresolved-count may overcount until the resolver UI reconciles (CQ4)`)}}async resolveBaseTreeSha(e,t){try{return(await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,t.lastSyncedSha,this.deps.baseURL)).treeSha}catch{return null}}pinLocalChanges(e,t,r,i,s){let o=e.modified.filter(h=>h.basePath!==void 0),c=[...e.added,...e.modified.filter(h=>h.basePath===void 0)],l=new Map;if(s==="pull"){for(let h of o)h.basePath!==void 0&&i.push(h.basePath),r.push(`pull-only: rename (uid ${h.uid??"?"}) ${h.basePath} \u2192 ${h.path} not pushed \u2014 propagates on the next push/Sync (#3473)`);for(let h of e.deleted)i.push(h.path),r.push(`pull-only: delete of ${h.path} not pushed \u2014 propagates on the next push/Sync (#3473)`)}else{for(let h of o)h.basePath!==void 0&&l.set(h.basePath,h.path);for(let h of e.deleted)l.set(h.path,h.path)}let u=[...c,...o,...e.deleted.map(h=>({...h}))],f=new Set(e.deleted.map(h=>h.path)),d=new Map;for(let h of[...c,...s==="pull"?[]:o]){let p=t.get(h.path);p!==void 0&&d.set(h.path,p)}return{localChanges:u,localDeletedPaths:f,pushFilesAll:d,pushDeletionsAll:l,dupUids:e.duplicateUids}}async runPushLoop(e,t,r,i,s,o,c=!1,l=new Set,u="sync",f,d){let{localChanges:h,localDeletedPaths:p,pushFilesAll:y,pushDeletionsAll:_,dupUids:w}=r,S=this.deps.maxPushRetries??qn.DEFAULT_MAX_PUSH_RETRIES,v=0,x="",I,C=[],D=[],K=new Map,U=new Set,k=[],z=LT,N=[],ae=new Set,_e=[],J=[],he=new Set;for(;;){x=v===0&&d!==void 0&&y.size===0&&_.size===0?d:await(0,mt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),C=[],D=[],z=LT,N=[],ae=new Set,_e=[],J=[];let Q,ve=new Set,ie=(t.pinnedPaths?.length??0)>0;if(x!==t.lastSyncedSha||ie||c){this.emitProgress(f,e.repoKey,"pulling-remote");let Ee=await this.collectRemoteChanges(e,t,x,o,l,s,he,f);Q=Ee.headTreeByPath;let re=this.matchLocalVsRemote(h,p,i,Ee.changes,ve,w,Ee.headTreeByPath);if(re.conflicts.length>0){if(u==="sync"&&this.emitProgress(f,e.repoKey,"merging"),u!=="sync"){for(let ye of re.conflicts){ae.add(ye.local.path),ye.local.basePath!==void 0&&ae.add(ye.local.basePath);for(let Fe of ye.remotes)ae.add(Fe.path),Fe.kind==="change"&&_e.push(Fe)}J.push(`${u}-only: ${re.conflicts.length} conflict(s) deferred to a full Sync (${re.conflicts.map(ye=>ye.desc).join("; ")}) \u2014 paths pinned, nothing merged`)}else if(o.fileMode)z=this.resolveFileModeConflicts(e,re.conflicts,i,re.applyWrites,re.applyDeletes);else{if(this.deps.mergeLayer===void 0)return{kind:"conflict",detail:`overlapping change on ${re.conflicts[0].desc} \u2014 merge layer (A2/A3) required; nothing pushed, nothing written`};z=await this.resolveMergeConflicts(e,t,re.conflicts,i)}if(u==="sync")for(let ye of re.conflicts)for(let Fe of ye.remotes)Fe.path!==ye.local.path&&(ae.add(Fe.path),Fe.kind==="change"&&_e.push(Fe),J.push(`conflict group ${ye.desc}: remote change at ${Fe.path} NOT applied \u2014 pinned to re-derive on the next sync (#3477)`))}if(C=re.applyWrites,D=re.applyDeletes,u==="push"&&(C.length>0||D.length>0)){for(let ye of C)ae.add(ye.path),_e.push(ye);for(let ye of D)ae.add(ye.path);J.push(`push-only: ${C.length+D.length} remote change(s) NOT applied \u2014 pinned to re-derive on the next pull/Sync`),C=[],D=[]}}K=u==="pull"?new Map:new Map([...[...y].filter(([Ee])=>!ve.has(Ee)),...z.mergedFiles]),U=new Set,k=[];for(let[Ee,re]of _){if(ve.has(re)){k.push(Ee);continue}K.has(Ee)||U.add(Ee)}if((K.size>0||U.size>0)&&Q===void 0&&(Q=NT(await(0,mt.getTree)(this.transport,e.owner,e.repo,t.rootTreeSha,this.deps.baseURL))),K.size>0&&Q!==void 0){for(let[Ee,re]of K){let ye=Q.get(Ee);ye!==void 0&&ye===await(0,Cc.gitBlobSha)(re,this.sha1)&&(K.delete(Ee),N.push(Ee))}N.length>0&&s.push(`phantom push skipped: ${N.length} file(s) already identical in remote HEAD (${N.join(", ")}) \u2014 excluded from the commit (#3475)`)}if(U.size>0&&Q!==void 0){for(let Ee of[...U])Q.has(Ee)||U.delete(Ee);K.size===0&&U.size>=Q.size&&(k.push(...U),J.push(`deletion of ALL ${U.size} remaining file(s) deferred \u2014 GitHub cannot create an empty tree; the deletes re-derive and propagate once the repo has at least one surviving file`),U.clear())}if(K.size===0&&U.size===0)break;let te=new Map;for(let[Ee,re]of K)if(typeof re=="string")te.set(Ee,re);else{let ye=qY(re);ye!==null&&te.set(Ee,ye)}let me=(0,MY.scanForSecrets)(te);if(me.length>0)return{kind:"secret-detected",detail:`secret-scan: refusing to push \u2014 ${me.map(Ee=>`${Ee.path} (${Ee.kind})`).join(", ")} (R5); remove the secret and re-sync`};try{I=await(0,RD.restCreateCommit)(this.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([...K].map(([Ee,re])=>[Ee,GY(re)])),deletions:[...U],message:this.deps.commitMessage?.(e,K.size,U.size)??`chore(exosync): sync ${K.size} file(s)${U.size>0?`, ${U.size} deletion(s)`:""}`,baseURL:this.deps.baseURL,redact:this.deps.redact});break}catch(Ee){if(!FD(Ee))throw Ee;if(v++,v>S)return{kind:"retry-exhausted",detail:`non-fast-forward push failed after ${S} retries (D16 cap) \u2014 contended files routed to quarantine (D17)`,pushFiles:K,merge:z};s.push(`non-fast-forward push (attempt ${v}/${S}) \u2014 re-pulling and retrying (D16)`)}}return{kind:"done",examinedHead:x,pushedSha:I,applyWrites:C,applyDeletes:D,pushFiles:K,pushedDeletions:I!==void 0?[...U]:[],withheldDeletions:k,merge:z,remoteOversized:he,alreadyInHead:N,deferredPaths:ae,deferredRemoteChanges:_e,deferredWarnings:J}}async resolveMergeConflicts(e,t,r,i){let s=this.deps.mergeLayer;if(s===void 0)return LT;let o=new Map(t.files.map(_=>[_.path,_])),c=new Map,l=[],u=[],f=[],d=[],h=0,p=a(_=>typeof _=="string"?_:void 0,"asText"),y=a((_,w,S)=>{let v=p(i.get(_.local.path)),x=p(_.remotes[0]?.content);return{repoKey:e.repoKey,path:_.local.path,..._.local.uid!==void 0?{uid:_.local.uid}:{},reason:w,...S!==void 0?{baseContent:S}:{},...v!==void 0?{localContent:v}:{},...x!==void 0?{remoteContent:x}:{}}},"entry");for(let _ of r){let w=o.get(_.local.basePath??_.local.path)??o.get(_.remotes[0]?.path??""),S;if(w!==void 0&&(S=await(0,mt.getBlobText)(this.transport,e.owner,e.repo,w.blobSha,this.deps.baseURL)),_.remotes.length>1){u.push(y(_,`ambiguous conflict: local change overlaps ${_.remotes.length} remote changes (${_.remotes.map(D=>D.path).join(", ")})`,S));continue}let v=_.remotes[0],x=p(i.get(_.local.path)),I=await s.resolve({path:_.local.path,..._.local.uid!==void 0?{uid:_.local.uid}:{},...S!==void 0?{base:S}:{},...x!==void 0?{local:x}:{},...v.kind==="change"&&typeof v.content=="string"?{remote:v.content}:{}});if(I.action==="quarantine"){u.push(y(_,I.reason,S));continue}h++,d.push(_.local.path);for(let D of I.warnings??[])f.push(`merge(${_.local.path}): ${D}`);let C=v.kind==="change"?v.content:void 0;if(I.content!==C&&c.set(_.local.path,I.content),I.content!==i.get(_.local.path)){let D=(0,ko.extractAssetUid)(I.content)??_.local.uid;l.push({path:_.local.path,kind:"change",content:I.content,blobSha:await(0,Cc.gitBlobSha)(I.content,this.sha1),...D!==void 0?{uid:D}:{}})}}return{mergedFiles:c,mergedWrites:l,quarantineEntries:u,resolvedQuarantineEntries:[],mergedCount:h,mergedPaths:d,warnings:f}}resolveFileModeConflicts(e,t,r,i,s){let o=[],c=[];for(let l of t){l.remotes.length>1&&c.push(`file-mode conflict on ${l.local.path} unexpectedly overlaps ${l.remotes.length} remote changes \u2014 resolving against the first`);let u=l.remotes[0],f=r.get(l.local.path);u.kind==="change"?i.push(u):s.push(u),!(l.localIsDelete||f===void 0)&&o.push({repoKey:e.repoKey,path:l.local.path,reason:`file-mode remote-wins (D18): remote ${u.kind==="change"?`version ${u.blobSha}`:"delete"} wins; this is the losing LOCAL version, preserved byte-exact`,...typeof f=="string"?{localContent:f}:{localContentBytes:f}})}return{mergedFiles:new Map,mergedWrites:[],quarantineEntries:[],resolvedQuarantineEntries:o,mergedCount:0,mergedPaths:[],warnings:c}}async applyRemoteChanges(e,t,r,i,s,o=new Map){let c=0,l=new Set,u=[],f=a(async(p,y)=>{try{return y?await xD(e,p):await e.read(p)}catch{return}},"tryRead"),d=a(async(p,y)=>{typeof y=="string"?await e.write(p,y):await WY(e,p,y)},"writeContent"),h=a(async p=>{let y=await f(p,!1);return y===void 0?!0:await(0,Cc.gitBlobSha)(y,this.sha1)===o.get(p)},"cacheHitUnchanged");for(let p of r){if(p.content===void 0)continue;if(!PD(p.path)){s.push(`unsafe remote path skipped on pull-apply: ${p.path}`),l.add(p.path);continue}let y=t.get(p.path);if(y===void 0&&o.has(p.path)){if(!await h(p.path)){s.push(`pull-apply skipped: ${p.path} changed on disk mid-sync (TOCTOU) \u2014 remote change re-derives next sync`),l.add(p.path);continue}await d(p.path,p.content),c++,u.push(p.path);continue}let _=await f(p.path,typeof(y??p.content)!="string");if(!(0,ks.contentEquals)(_,y)){s.push(`pull-apply skipped: ${p.path} changed on disk mid-sync (TOCTOU) \u2014 remote change re-derives next sync`),l.add(p.path);continue}await d(p.path,p.content),c++,u.push(p.path)}for(let p of i){if(!PD(p.path)){s.push(`unsafe remote path skipped on pull-delete: ${p.path}`),l.add(p.path);continue}let y=t.get(p.path);if(y===void 0&&o.has(p.path)){if(!await h(p.path)){s.push(`pull-delete skipped: ${p.path} changed on disk mid-sync (TOCTOU) \u2014 delete-vs-modify re-derives next sync`),l.add(p.path);continue}await e.delete(p.path),c++,u.push(p.path);continue}if(y!==void 0){let _=await f(p.path,typeof y!="string");if(_!==void 0&&!(0,ks.contentEquals)(_,y)){s.push(`pull-delete skipped: ${p.path} changed on disk mid-sync (TOCTOU) \u2014 delete-vs-modify re-derives next sync`),l.add(p.path);continue}await e.delete(p.path),c++,u.push(p.path)}}return{pulledCount:c,pinnedPaths:l,pulledPaths:u}}async advanceWatermark(e,t,r,i,s,o,c,l,u,f=new Set){let d=(await(0,mt.getTree)(this.transport,e.owner,e.repo,r,this.deps.baseURL)).filter(p=>u.treeFilter(p)&&!f.has(p.path)),h=zY(await this.buildWatermarkFiles(e,d,i,s,o,l,u),o,c);await this.deps.watermarkStore.set(e.repoKey,{lastSyncedSha:t,rootTreeSha:r,files:h,...c.size>0?{pinnedPaths:[...c]}:{},...u.fileMode?{spaceKind:"file"}:{}})}async tryMountBaseBootstrap(e,t,r,i,s){let o=this.deps.mountBaseStore,c=null;if(o!==void 0)try{c=await o.get(e.repoKey)}catch{return null}let l=!1;if(c===null&&this.deps.localBaseShaProvider!==void 0)try{let w=await this.deps.localBaseShaProvider(e);typeof w=="string"&&w.length>0&&(c=w,l=!0)}catch{}if(c===null||t.startsWith(c))return null;let u=300,f=null;try{let w=t;for(let S=0;S<u;S++){let v=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,w,this.deps.baseURL);if(v.sha===c||v.sha.startsWith(c)){f=v;break}if(v.parents.length===0)break;w=v.parents[0]}}catch{return null}if(f===null)return null;let d;try{d=(await(0,mt.getTree)(this.transport,e.owner,e.repo,f.treeSha,this.deps.baseURL)).filter(w=>(0,ks.isSyncablePath)(w.path))}catch{return null}let h;try{let w=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL);h=NT((await(0,mt.getTree)(this.transport,e.owner,e.repo,w.treeSha,this.deps.baseURL)).filter(S=>(0,ks.isSyncablePath)(S.path)))}catch{return null}let p=d.filter(w=>!r.has(w.path)&&h.get(w.path)===w.blobSha);if(p.length>0){let w=p.slice(0,3).map(S=>S.path).join(", ")+(p.length>3?", \u2026":"");return i.push(`first-sync (asset mode): base-tree\u2286working-tree sanity guard fired \u2014 ${p.length} base file(s) absent from the working tree but UNCHANGED on remote head (${w}); the verified-ancestor base may not match the working tree's derivation commit (out-of-band submodule manipulation) \u2192 routing to merge/quarantine instead of inferring a silent deletion (#3610)`),{kind:"settled",outcome:s("full-conflict",{detail:`first-sync: base-tree\u2286working-tree sanity guard \u2014 ${p.length} base file(s) absent from the working tree are unchanged on remote head (${w}); refusing to infer a silent deletion from a base that may not match the derivation commit \u2014 divergence must go through merge/quarantine (A2/A3), never a silent delete (#3610)`})}}let y=d.map(w=>({path:w.path,blobSha:w.blobSha})),_={lastSyncedSha:f.sha,rootTreeSha:f.treeSha,files:y};if(l&&o!==void 0)try{await o.set(e.repoKey,f.sha)}catch{}return i.push(l?`first-sync (asset mode): BACKFILLED the 3-way base from the locally checked-out commit ${f.sha} (no recorded mount base) \u2014 remote head ${t} advanced since; local edits 3-way merge against it instead of false-conflicting (#3590)`:`first-sync (asset mode): reconciling against the recorded mount base ${f.sha} \u2014 remote head ${t} advanced since mount; local edits 3-way merge against it instead of false-conflicting (#3590)`),{kind:"additive-base",base:_}}async bootstrapWatermark(e,t,r,i){let s=await(0,mt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await this.tryMountBaseBootstrap(e,s,t,r,i);if(o!==null)return o;let c=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),l=(await(0,mt.getTree)(this.transport,e.owner,e.repo,c.treeSha,this.deps.baseURL)).filter(h=>(0,ks.isSyncablePath)(h.path)),u=[],f;for(let h of l){let p=t.get(h.path);if(p===void 0||await(0,Cc.gitBlobSha)(p,this.sha1)!==h.blobSha){f===void 0&&(f=h.path);continue}let y=typeof p=="string"?(0,ko.extractAssetUid)(p):void 0;u.push({path:h.path,blobSha:h.blobSha,...y?{uid:y}:{}})}let d={lastSyncedSha:s,rootTreeSha:c.treeSha,files:u};return f!==void 0?this.deps.mergeLayer===void 0?{kind:"settled",outcome:i("full-conflict",{detail:`first-sync: no watermark and local content diverges from remote head at ${f} \u2014 A2/A3 scope`})}:(r.push(`first-sync (asset mode): no 3-way merge base and local diverges from remote head (first at ${f}) \u2014 reconciling ZERO-LOSS against ${u.length} byte-identical file(s) as a synthetic base: remote-only files pull, local-only files push, overlapping divergences route to the merge/quarantine layer (both versions preserved), never a silent overwrite or delete`),{kind:"additive-base",base:d}):t.size===l.length?(await this.deps.watermarkStore.set(e.repoKey,d),r.push(`watermark bootstrapped from head ${s} (local tree identical to remote)`),{kind:"settled",outcome:i("synced")}):(r.push(`first-sync (asset mode): local tree (${t.size} files) is a pure superset of remote head ${s} (${l.length} files) \u2014 ${t.size-l.length} local-only addition(s) derive as pushable adds (#3565)`),{kind:"additive-base",base:d})}async collectRemoteChanges(e,t,r,i,s=new Set,o=[],c=new Set,l){let u=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,r,this.deps.baseURL),f=await(0,mt.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL);if(i.fileMode)for(let v of f)i.syncable(v.path)&&!i.treeFilter(v)&&!c.has(v.path)&&(c.add(v.path),o.push(`skipped oversized REMOTE file ${v.path} (${v.size??"?"} bytes over cap) \u2014 excluded from sync symmetrically (Phase C size cap)`));let d=f.filter(v=>i.treeFilter(v)&&!s.has(v.path)),h=t.files.filter(v=>!c.has(v.path)&&!s.has(v.path)),{changed:p,deleted:y}=DD(h,d),_=p.length;_>=CD&&this.emitProgress(l,e.repoKey,"fetching-blobs",{done:0,total:_});let w=0,S=[];for(let v of p){if(i.fileMode){let x=await(0,mt.getBlobBytes)(this.transport,e.owner,e.repo,v.blobSha,this.deps.baseURL);S.push({path:v.path,kind:"change",blobSha:v.blobSha,content:x})}else{let x=await(0,mt.getBlobText)(this.transport,e.owner,e.repo,v.blobSha,this.deps.baseURL);S.push({path:v.path,kind:"change",blobSha:v.blobSha,content:x,uid:(0,ko.extractAssetUid)(x)})}w+=1,_>=CD&&w%UY===0&&w<_&&this.emitProgress(l,e.repoKey,"fetching-blobs",{done:w,total:_})}for(let v of y)S.push({path:v.path,kind:"delete",uid:v.uid});return{changes:S,headTreeByPath:NT(f)}}matchLocalVsRemote(e,t,r,i,s,o=new Set,c){let l=new Set,u=[],f=new Map;for(let _ of i)_.kind==="change"&&_.uid!==void 0&&f.set(_.uid,(f.get(_.uid)??0)+1);let d=new Set(o);for(let[_,w]of f)w>1&&d.add(_);let h=new Map,p=new Map;for(let _ of i){if(_.uid!==void 0&&!d.has(_.uid)){let w=h.get(_.uid)??[];w.push(_),h.set(_.uid,w)}p.set(_.path,_)}for(let _ of e){let w=new Set;if(_.uid!==void 0&&!d.has(_.uid))for(let I of h.get(_.uid)??[])I.kind==="change"&&I.path!==_.path&&(c?.has(_.path)===!0||_.basePath!==void 0&&c?.has(_.basePath)===!0)||w.add(I);let S=p.get(_.path);if(S!==void 0&&w.add(S),_.basePath!==void 0){let I=p.get(_.basePath);I!==void 0&&w.add(I)}let v=[],x=!1;for(let I of w){if(x=t.has(_.path)&&!r.has(_.path),x&&I.kind==="delete"){l.add(I);continue}if(!x&&I.kind==="change"&&I.path===_.path&&I.blobSha===_.blobSha){l.add(I),s.add(_.path);continue}if(I.kind==="delete"&&_.basePath!==void 0&&I.path===_.basePath){let C=p.get(_.path);if(C!==void 0&&C.kind==="change"&&C.blobSha===_.blobSha){l.add(I);continue}}if(I.kind==="delete"&&I.path!==_.path&&I.path!==_.basePath&&!r.has(I.path)&&c?.has(I.path)!==!0){l.add(I);continue}v.push(I),l.add(I)}v.length>0&&(u.push({local:_,localIsDelete:x,remotes:v,desc:`${_.uid!==void 0&&!d.has(_.uid)?_.uid:_.path} (local ${x?"delete":"change"} vs remote ${v[0].kind} at ${v[0].path})`}),s.add(_.path))}let y=i.filter(_=>!l.has(_));return{conflicts:u,applyWrites:y.filter(_=>_.kind==="change"),applyDeletes:y.filter(_=>_.kind==="delete")}}async checkRaceWindow(e,t,r,i,s,o,c,l){try{let u=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,i,this.deps.baseURL),f=(await(0,mt.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL)).filter(l.treeFilter),d=r===t.lastSyncedSha?t.files:(await(0,mt.getTree)(this.transport,e.owner,e.repo,(await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,r,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(l.treeFilter),{changed:h,deleted:p}=DD(d,f);for(let y of h)s.has(y.path)&&c.push(`race-window: concurrent commit ${i} changed ${y.path} between conflict check (head ${r}) and push \u2014 local version won; previous version recoverable from git history`),o.has(y.path)&&c.push(`race-window: concurrent commit ${i} changed ${y.path} which this push DELETED \u2014 the delete won; the concurrent version is recoverable from git history`);for(let y of p)s.has(y.path)&&c.push(`race-window: concurrent commit ${i} deleted ${y.path}; push re-created it`)}catch(u){let f=this.deps.redact??(d=>d);c.push(`race-window check failed: ${f(wa(u))}`)}}async buildWatermarkFiles(e,t,r,i,s,o,c){if(c.fileMode)return t.map(f=>({path:f.path,blobSha:f.blobSha}));let l=new Map;for(let f of i)f.kind==="change"&&f.blobSha!==void 0&&l.set(f.blobSha,f.uid);for(let[f,d]of r){let h=o?.get(f)??await(0,Cc.gitBlobSha)(d,this.sha1);l.set(h,typeof d=="string"?(0,ko.extractAssetUid)(d):void 0)}for(let f of s.files)l.has(f.blobSha)||l.set(f.blobSha,f.uid);let u=[];for(let f of t){let d;if(l.has(f.blobSha))d=l.get(f.blobSha);else{let h=await(0,mt.getBlobText)(this.transport,e.owner,e.repo,f.blobSha,this.deps.baseURL);d=(0,ko.extractAssetUid)(h)}u.push({path:f.path,blobSha:f.blobSha,...d?{uid:d}:{}})}return u}};qn.SyncEngine=kT});var kD=T(vd=>{"use strict";Object.defineProperty(vd,"__esModule",{value:!0});vd.QuarantineResolver=void 0;vd.backupPathFor=ND;var KY=Iy(),My=_d(),Sd=hu(),wd=md(),YY=xy(),Ms="\0absent",MT=class{static{a(this,"QuarantineResolver")}constructor(e){this.deps=e}async listOpenConflicts(e){let t=[];for(let r of e)t.push(...await this.listRepoConflicts(r));return t}async listRepoConflicts(e){if(e.spaceKind==="file")return[];let t=await this.deps.watermarkStore.get(e.repoKey),r=t?.pinnedPaths??[];if(r.length===0)return[];if(this.deps.outbox!==void 0){let p=await this.deps.outbox.listForRepo(e.repoKey);if(p.length>0){let y=new Set(p.map(_=>_.path));if(r=r.filter(_=>!y.has(_)),r.length===0)return[]}}let i=new Map;for(let p of t?.files??[])i.set(p.path,p.blobSha);let s=this.deps.conflictCache!==void 0,o=await this.cachedRecordsFor(e,r),c=r.some(p=>!o.has(p)),l=new Map,u=!0;if(c)if(s)try{l=await this.remoteTreeShas(e)}catch{u=!1}else l=await this.remoteTreeShas(e);let f=this.deps.localFilesFor(e),d=new Set(await f.list()),h=[];for(let p of r){let y=o.get(p),_,w;if(y!==void 0)w=y.remoteContent!==void 0?await(0,Sd.gitBlobSha)(y.remoteContent,this.deps.sha1):Ms,_=y.baseContent!==void 0?await(0,Sd.gitBlobSha)(y.baseContent,this.deps.sha1):i.get(p)??Ms;else{if(!u)continue;w=l.get(p)??Ms,_=i.get(p)??Ms}let S=Ms,v;if(d.has(p)&&(v=await f.read(p),S=await(0,Sd.gitBlobSha)(v,this.deps.sha1)),!(S!==w&&S!==_&&w!==_))continue;let I=(v!==void 0?(0,wd.extractAssetUid)(v):void 0)??y?.uid;h.push({repoKey:e.repoKey,path:p,...I!==void 0?{uid:I}:{},hasLocal:S!==Ms,hasRemote:w!==Ms})}return h}async cachedRecordsFor(e,t){let r=new Map,i=this.deps.conflictCache;if(i===void 0)return r;for(let s of t){let o=await i.get(e.repoKey,s);o!==null&&r.set(s,o)}return r}async detectDuplicateUids(e){let t=new Map;for(let i of e){let s=this.deps.localFilesFor(i);for(let o of await s.list()){if(!o.endsWith(".md"))continue;let c;try{c=await s.read(o)}catch{continue}let l=(0,wd.extractAssetUid)(c);l!==void 0&&t.set(l,(t.get(l)??0)+1)}}let r=0;for(let i of t.values())i>1&&r++;return r}async loadConflict(e,t){let r=this.deps.localFilesFor(e),s=new Set(await r.list()).has(t)?await r.read(t):void 0,o=await this.deps.conflictCache?.get(e.repoKey,t)??null,c,l;if(o!==null)c=o.remoteContent,l=o.baseContent;else{let d=(await this.remoteTreeShas(e)).get(t);c=d!==void 0?await this.blobText(e,d):void 0;let p=((await this.deps.watermarkStore.get(e.repoKey))?.files??[]).find(y=>y.path===t)?.blobSha;if(p!==void 0)try{l=await this.blobText(e,p)}catch{l=void 0}}let u=(s!==void 0?(0,wd.extractAssetUid)(s):void 0)??(c!==void 0?(0,wd.extractAssetUid)(c):void 0)??o?.uid;return{repoKey:e.repoKey,path:t,...u!==void 0?{uid:u}:{},hasLocal:s!==void 0,hasRemote:c!==void 0,...l!==void 0?{base:l}:{},...s!==void 0?{local:s}:{},...c!==void 0?{remote:c}:{}}}async resolve(e,t,r){let i=this.deps.localFilesFor(e),o=new Set(await i.list()).has(t)?await i.read(t):void 0,c=this.deps.outbox!==void 0,{remote:l,remoteSha:u}=c?await this.remoteForResolve(e,t):await this.liveRemoteForResolve(e,t),f=this.chosenContent(r,o,l),d;r.take!=="local"&&o!==void 0&&o!==f&&(d=ND(t),await i.write(d,o)),f===void 0?await i.delete(t):await i.write(t,f);let p=f===void 0&&l===void 0||f===l;if(c&&this.deps.outbox!==void 0&&!p&&f!==void 0)return await this.deps.outbox.enqueue({repoKey:e.repoKey,path:t,chosenContent:f,resolvedTo:r.take==="merged"?"merged":"local",baseRemoteSha:u===Ms?YY.OUTBOX_REMOTE_ABSENT:u,resolvedAt:""}),{repoKey:e.repoKey,path:t,resolvedTo:r.take,awaitingPush:!0,...d!==void 0?{discardedLocalBackupPath:d}:{}};let y;return p||(y=await this.commitChoice(e,t,f)),await this.snapWatermark(e,t,f),this.deps.quarantine?.markResolved!==void 0&&await this.deps.quarantine.markResolved(e.repoKey,t),{repoKey:e.repoKey,path:t,resolvedTo:r.take,...y!==void 0?{pushedSha:y}:{},...d!==void 0?{discardedLocalBackupPath:d}:{}}}async remoteForResolve(e,t){let r=await this.deps.conflictCache?.get(e.repoKey,t)??null;if(r!==null){let i=r.remoteContent,s=i!==void 0?await(0,Sd.gitBlobSha)(i,this.deps.sha1):Ms;return{remote:i,remoteSha:s}}return this.liveRemoteForResolve(e,t)}async liveRemoteForResolve(e,t){let i=(await this.remoteTreeShas(e)).get(t);return{remote:i!==void 0?await this.blobText(e,i):void 0,remoteSha:i??Ms}}chosenContent(e,t,r){switch(e.take){case"local":if(t===void 0)throw new Error("resolve: cannot keep local \u2014 no local version exists on disk");return t;case"remote":return r;case"merged":return e.content}}async commitChoice(e,t,r){let i=this.deps.commitMessage?.(e,t)??`chore(exosync): resolve conflict for ${t}`;if(r===void 0)throw new Error(`resolve: cannot push an empty resolution for ${t}`);return(0,KY.restCreateCommit)(this.deps.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([[t,r]]),message:i,...this.deps.baseURL!==void 0?{baseURL:this.deps.baseURL}:{},...this.deps.redact!==void 0?{redact:this.deps.redact}:{}})}async snapWatermark(e,t,r){let i=await this.deps.watermarkStore.get(e.repoKey);if(i===null)return;let s=(i.pinnedPaths??[]).filter(c=>c!==t),o=i.files;if(r===void 0)o=o.filter(c=>c.path!==t);else{let c=await(0,Sd.gitBlobSha)(r,this.deps.sha1),l=(0,wd.extractAssetUid)(r),u={path:t,blobSha:c,...l!==void 0?{uid:l}:{}},f=o.findIndex(d=>d.path===t);o=f>=0?o.map((d,h)=>h===f?u:d):[...o,u]}await this.deps.watermarkStore.set(e.repoKey,{...i,files:o,...s.length>0?{pinnedPaths:s}:{pinnedPaths:void 0}})}async remoteTreeShas(e){let t=await(0,My.getHeadSha)(this.deps.transport,e.owner,e.repo,e.branch,this.deps.baseURL),r=await(0,My.getCommitInfo)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,My.getTree)(this.deps.transport,e.owner,e.repo,r.treeSha,this.deps.baseURL),s=new Map;for(let o of i)s.set(o.path,o.blobSha);return s}async blobText(e,t){return(0,My.getBlobText)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL)}};vd.QuarantineResolver=MT;function ND(n){return`${n}.conflict.local.txt`}a(ND,"backupPathFor")});var MD=T(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});pu.FileLocalManifestStore=pu.LOCAL_MANIFEST_STORE_FILENAME=void 0;pu.LOCAL_MANIFEST_STORE_FILENAME="exosync-localmanifest.local.json";function QY(n){if(n===null||typeof n!="object")return!1;let e=n;return e.version===1&&typeof e.lastFullRehashMs=="number"&&e.files!==null&&typeof e.files=="object"}a(QY,"isLocalManifestRecord");var jT=class{static{a(this,"FileLocalManifestStore")}constructor(e){this.io=e,this.writeChain=Promise.resolve()}async get(e){let r=(await this.readRepos())[e];return QY(r)?r:null}async set(e,t){let r=this.writeChain.then(async()=>{let i=await this.readRepos();i[e]=t;let s={version:1,repos:i};await this.io.writeAtomic(JSON.stringify(s))});return this.writeChain=r.catch(()=>{}),r}async readRepos(){try{let e=await this.io.read();if(e===null)return{};let t=JSON.parse(e);if(t===null||typeof t!="object")return{};let r=t.repos;return r===null||typeof r!="object"?{}:{...r}}catch{return{}}}};pu.FileLocalManifestStore=jT});var BT=T(UT=>{"use strict";Object.defineProperty(UT,"__esModule",{value:!0});UT.diff3=XY;function jD(n,e){let t=n.length,r=e.length,i=Array.from({length:t+1},()=>new Int32Array(r+1));for(let l=t-1;l>=0;l--)for(let u=r-1;u>=0;u--)i[l][u]=n[l]===e[u]?i[l+1][u+1]+1:Math.max(i[l+1][u],i[l][u+1]);let s=new Map,o=0,c=0;for(;o<t&&c<r;)n[o]===e[c]?(s.set(o,c),o++,c++):i[o+1][c]>=i[o][c+1]?o++:c++;return s}a(jD,"lcsMatch");function $T(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}a($T,"sliceEq");function XY(n,e,t){let r=jD(n,e),i=jD(n,t),s=[],o=0,c=0,l=0;for(;;){let u=o;for(;u<n.length&&!(r.has(u)&&i.has(u));)u++;let f=u<n.length?r.get(u):e.length,d=u<n.length?i.get(u):t.length,h=n.slice(o,u),p=e.slice(c,f),y=t.slice(l,d),_=!$T(p,h),w=!$T(y,h);if(!_&&!w)s.push(...h);else if(!_)s.push(...y);else if(!w)s.push(...p);else if($T(p,y))s.push(...p);else return{ok:!1,conflict:{base:h,local:p,remote:y}};if(u>=n.length)break;s.push(n[u]),o=u+1,c=f+1,l=d+1}return{ok:!0,merged:s}}a(XY,"diff3")});var UD=T(Ad=>{"use strict";Object.defineProperty(Ad,"__esModule",{value:!0});Ad.StructuredMerger=void 0;Ad.splitSections=jy;var $D=BT(),JY=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,Ed="exo__Instance_class";function Td(n){if(n===null||typeof n!="object")return!0;if(Array.isArray(n))return n.every(Td);let e=Object.getPrototypeOf(n);return e!==Object.prototype&&e!==null?!1:Object.values(n).every(Td)}a(Td,"isPlainValue");function va(n,e){if(n===e)return!0;if(n===null||e===null||n===void 0||e===void 0||typeof n!="object"||typeof e!="object"||Array.isArray(n)!==Array.isArray(e))return!1;if(Array.isArray(n)&&Array.isArray(e))return n.length!==e.length?!1:n.every((s,o)=>va(s,e[o]));let t=n,r=e,i=Object.keys(t);return i.length!==Object.keys(r).length?!1:i.every(s=>va(t[s],r[s]))}a(va,"deepEqual");function xc(n){return typeof n=="string"?`s:${n}`:`j:${JSON.stringify(n)}`}a(xc,"setKey");function hi(n){return n==null?[]:Array.isArray(n)?n:[n]}a(hi,"toElements");function ZY(n,e,t){let r=new Set(hi(n).map(xc)),i=hi(e),s=hi(t),o=new Set(i.map(xc)),c=new Set(s.map(xc)),l=a(d=>o.has(d)&&c.has(d)||o.has(d)&&!r.has(d)||c.has(d)&&!r.has(d),"keep"),u=[],f=new Set;for(let d of[...i,...s]){let h=xc(d);f.has(h)||!l(h)||(f.add(h),u.push(d))}return u}a(ZY,"mergeSet");function eQ(n,e,t){let r=[],i=[],s=new Set;for(let c of[...Object.keys(n),...Object.keys(e),...Object.keys(t)])s.has(c)||(s.add(c),i.push(c));let o={};for(let c of i){let l=n[c],u=e[c],f=t[c];if(!Td(l)||!Td(u)||!Td(f))return{ok:!1,reason:`frontmatter key "${c}" contains a non-plain value (Date?) \u2014 the codec must round-trip scalars as strings (CORE_SCHEMA contract)`};if(Array.isArray(l)||Array.isArray(u)||Array.isArray(f)){if(!(c in e)&&!(c in t))continue;let d=ZY(l,u,f),h=new Set(hi(l).map(xc)),p=hi(u).some(_=>!h.has(xc(_))),y=hi(f).some(_=>!h.has(xc(_)));p&&y&&!va(hi(u),hi(f))&&r.push(`both sides added values to multi-valued key "${c}" \u2014 union kept (D20)`),d.length>0&&(o[c]=d);continue}if(va(u,f)){u!==void 0&&(o[c]=u);continue}if(va(u,l)){f!==void 0&&(o[c]=f);continue}if(va(f,l)){u!==void 0&&(o[c]=u);continue}return{ok:!1,reason:`frontmatter key "${c}" changed differently on both sides`}}return{ok:!0,value:o,warnings:r}}a(eQ,"mergeFrontmatter");var tQ=/^(```|~~~)/,rQ=/^#{1,6}\s/;function jy(n){let e=n.split(`
309
+ `)}a(uY,"stripGitmodulesEntry")});var hu=T(TT=>{"use strict";Object.defineProperty(TT,"__esModule",{value:!0});TT.gitBlobSha=fY;async function fY(n,e){let t=new TextEncoder,r=typeof n=="string"?t.encode(n):n,i=t.encode(`blob ${r.byteLength}\0`),s=new Uint8Array(i.byteLength+r.byteLength);return s.set(i,0),s.set(r,i.byteLength),e(s)}a(fY,"gitBlobSha")});var md=T(Oy=>{"use strict";Object.defineProperty(Oy,"__esModule",{value:!0});Oy.extractAssetUid=gD;Oy.detectChanges=hY;var dY=hu();function gD(n){let e=/^---\r?\n([\s\S]*?)\r?\n---(?=\r?\n|$)/.exec(n);if(!e)return;let t=/^exo__Asset_uid:[ \t]*["']?([^\s"']+)["']?[ \t]*$/m.exec(e[1]);return t?t[1]:void 0}a(gD,"extractAssetUid");async function hY(n){let{localFiles:e,cachedEntries:t,watermark:r,actualBaseTreeSha:i,sha1:s}=n;if(r===null)return{kind:"full-conflict",reason:"first-sync"};if(i===null)return{kind:"full-conflict",reason:"base-mismatch",detail:`watermark commit ${r.lastSyncedSha} not resolvable on remote`};if(i!==r.rootTreeSha)return{kind:"full-conflict",reason:"base-mismatch",detail:`stored root tree ${r.rootTreeSha} != actual ${i} at ${r.lastSyncedSha}`};let o=[],c=new Map;for(let[I,C]of e){let D=await(0,dY.gitBlobSha)(C,s);c.set(I,D),o.push({path:I,blobSha:D,uid:typeof C=="string"?gD(C):void 0})}if(t!==void 0)for(let[I,C]of t)c.set(I,C.blobSha),o.push({path:I,blobSha:C.blobSha,uid:C.uid});let l=[],u=[],f=[],d=[],h=new Map;for(let I of o){if(I.uid===void 0)continue;let C=h.get(I.uid)??[];C.push(I.path),h.set(I.uid,C)}let p=new Map;for(let I of r.files){if(I.uid===void 0)continue;let C=p.get(I.uid)??[];C.push(I.path),p.set(I.uid,C)}let y=new Set;for(let[I,C]of h)C.length>1&&y.add(I);for(let[I,C]of p)C.length>1&&y.add(I);for(let I of[...y].sort()){let C=h.get(I)??[],D=C.length>1?`on disk (${C.join(", ")})`:`in the sync base (${(p.get(I)??[]).join(", ")})`;d.push(`duplicate uid ${I} ${D} \u2014 uid identity suppressed for the group; every path matched by path identity (#3477)`)}let _=new Map,w=[];for(let I of r.files)I.uid!==void 0&&!y.has(I.uid)?_.set(I.uid,I):w.push(I);let S=[],v=new Set;for(let I of o){let C=I.uid!==void 0&&!y.has(I.uid)?_.get(I.uid):void 0;I.uid!==void 0&&C!==void 0?(v.add(I.uid),(C.blobSha!==I.blobSha||C.path!==I.path)&&u.push({path:I.path,uid:I.uid,blobSha:I.blobSha,...C.path!==I.path?{basePath:C.path}:{}})):S.push(I)}let x=new Map;for(let I of w)x.set(I.path,I);for(let[I,C]of _)v.has(I)||x.set(C.path,C);for(let I of S){let C=x.get(I.path);C!==void 0?(x.delete(I.path),C.blobSha!==I.blobSha&&u.push({path:I.path,uid:I.uid,blobSha:I.blobSha})):l.push({path:I.path,uid:I.uid,blobSha:I.blobSha})}for(let I of x.values())f.push({path:I.path,uid:I.uid,blobSha:I.blobSha});return{kind:"changes",added:l,modified:u,deleted:f,warnings:d,diskBlobShas:c,duplicateUids:y}}a(hY,"detectChanges")});var bD=T(gd=>{"use strict";Object.defineProperty(gd,"__esModule",{value:!0});gd.rewriteAssetUid=yD;gd.findDuplicateUidGroups=_D;gd.planDuplicateUidFix=mY;var pY=md();function yD(n,e){let t=/^(---\r?\n)([\s\S]*?)(\r?\n---(?=\r?\n|$))/.exec(n);if(t===null)return n;let r=t[2].replace(/^(exo__Asset_uid:[ \t]*["']?)[^\s"']+(["']?[ \t]*)$/m,`$1${e}$2`);return r===t[2]?n:n.slice(0,t.index)+t[1]+r+t[3]+n.slice(t.index+t[0].length)}a(yD,"rewriteAssetUid");function _D(n){let e=new Map;for(let t of n){let r=(0,pY.extractAssetUid)(t.content);if(r===void 0)continue;let i=e.get(r)??[];i.push(t.path),e.set(r,i)}return[...e.entries()].filter(([,t])=>t.length>1).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>({uid:t,paths:r}))}a(_D,"findDuplicateUidGroups");function mY(n,e){let t=new Map(n.map(i=>[i.path,i.content])),r=[];for(let i of _D(n)){let s=[...i.paths].sort((o,c)=>o.localeCompare(c));for(let o of s.slice(1)){let c=t.get(o);if(c===void 0)continue;let l=e(),u=yD(c,l);u!==c&&r.push({path:o,fromUid:i.uid,toUid:l,content:u})}}return r}a(mY,"planDuplicateUidFix")});var _d=T(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});Oc.getHeadSha=yY;Oc.getCommitInfo=_Y;Oc.getTree=bY;Oc.getBlobText=SY;Oc.getBlobBytes=wY;var SD=ul(),gY="https://api.github.com";function yd(n){return(n??gY).replace(/\/$/,"")}a(yd,"api");function Rc(n){return n!==null&&typeof n=="object"?n:void 0}a(Rc,"asRecord");function Ns(n,e){let r=Rc(n)?.[e];return typeof r=="string"?r:void 0}a(Ns,"readString");async function yY(n,e,t,r,i){let s=await n({method:"GET",url:`${yd(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/refs/heads/${encodeURIComponent(r)}`}),o=Ns(Rc(s?.json)?.object,"sha");if(typeof o!="string"||o.length===0)throw new Error(`ExoSync: missing object.sha for ref heads/${r}`);return o}a(yY,"getHeadSha");async function _Y(n,e,t,r,i){let s=await n({method:"GET",url:`${yd(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/commits/${encodeURIComponent(r)}`}),o=Rc(s?.json),c=Ns(o,"sha"),l=Ns(o?.tree,"sha");if(!c||!l)throw new Error(`ExoSync: malformed commit response for ${r}`);let u=o?.parents,f=Array.isArray(u)?u.map(d=>Ns(d,"sha")).filter(d=>typeof d=="string"):[];return{sha:c,treeSha:l,parents:f}}a(_Y,"getCommitInfo");async function bY(n,e,t,r,i){let s=await n({method:"GET",url:`${yd(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/trees/${encodeURIComponent(r)}?recursive=1`}),o=Rc(s?.json);if(o?.truncated===!0)throw new Error(`ExoSync: tree ${r} is truncated by GitHub (repo too large for recursive listing) \u2014 refusing to diff`);let c=o?.tree;if(!Array.isArray(c))throw new Error(`ExoSync: malformed tree response for ${r}`);let l=[];for(let u of c){let f=Rc(u);if(f?.type!=="blob")continue;let d=Ns(f,"path"),h=Ns(f,"sha"),p=typeof f.size=="number"?f.size:void 0;d&&h&&l.push({path:d,blobSha:h,...p!==void 0?{size:p}:{}})}return l}a(bY,"getTree");async function SY(n,e,t,r,i){let s=await n({method:"GET",url:`${yd(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(r)}`}),o=Rc(s?.json),c=Ns(o,"content");if(typeof c!="string")throw new Error(`ExoSync: malformed blob response for ${r}`);return Ns(o,"encoding")==="utf-8"?c:(0,SD.base64ToUtf8)(c)}a(SY,"getBlobText");async function wY(n,e,t,r,i){let s=await n({method:"GET",url:`${yd(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(r)}`}),o=Rc(s?.json),c=Ns(o,"content");if(typeof c!="string")throw new Error(`ExoSync: malformed blob response for ${r}`);return Ns(o,"encoding")==="utf-8"?new TextEncoder().encode(c):(0,SD.base64ToBytes)(c)}a(wY,"getBlobBytes")});var RT=T(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});er.SyncPhaseTimer=er.SYNC_PHASES=void 0;er.classifyRestPhase=vY;er.emptyTimings=vD;er.totalMs=Cy;er.addTimings=ED;er.aggregateTimings=EY;er.dominantPhase=TY;er.fmtMs=bd;er.formatTimingsLine=AY;er.formatRepoTimings=IY;er.SYNC_PHASES=["localList","localRead","localWrite","hash","restHead","restCommit","restTree","restBlob","restPush"];function IT(){let n={};for(let e of er.SYNC_PHASES)n[e]=0;return n}a(IT,"zeroDurations");function wD(){return{filesRead:0,filesHashed:0,filesWritten:0,restCalls:0}}a(wD,"zeroCounts");function vY(n){if(n.method!=="GET")return"restPush";let e=n.url;return e.includes("/git/blobs/")?"restBlob":e.includes("/git/trees/")?"restTree":e.includes("/git/commits/")?"restCommit":e.includes("/git/refs/")?"restHead":"restCommit"}a(vY,"classifyRestPhase");var AT=class{static{a(this,"SyncPhaseTimer")}constructor(e){this.now=e,this.durations=IT(),this.counts=wD()}async time(e,t){let r=this.now();try{return await t()}finally{this.durations[e]+=this.now()-r}}bumpRead(){this.counts.filesRead++}bumpHashed(){this.counts.filesHashed++}bumpWritten(){this.counts.filesWritten++}bumpRest(){this.counts.restCalls++}snapshot(){return{durations:{...this.durations},counts:{...this.counts}}}};er.SyncPhaseTimer=AT;function vD(){return{durations:IT(),counts:wD()}}a(vD,"emptyTimings");function Cy(n){let e=0;for(let t of er.SYNC_PHASES)e+=n.durations[t];return e}a(Cy,"totalMs");function ED(n,e){let t=IT();for(let r of er.SYNC_PHASES)t[r]=n.durations[r]+e.durations[r];return{durations:t,counts:{filesRead:n.counts.filesRead+e.counts.filesRead,filesHashed:n.counts.filesHashed+e.counts.filesHashed,filesWritten:n.counts.filesWritten+e.counts.filesWritten,restCalls:n.counts.restCalls+e.counts.restCalls}}}a(ED,"addTimings");function EY(n){let e=vD();for(let t of n)t.timings!==void 0&&(e=ED(e,t.timings));return e}a(EY,"aggregateTimings");function TY(n){let e=Cy(n);if(e<=0)return null;let t=er.SYNC_PHASES[0],r=-1;for(let i of er.SYNC_PHASES)n.durations[i]>r&&(r=n.durations[i],t=i);return{phase:t,ms:r,pct:r/e*100}}a(TY,"dominantPhase");function bd(n){return n>=1e3?`${(n/1e3).toFixed(1)}s`:`${Math.round(n)}ms`}a(bd,"fmtMs");function AY(n){let e=Cy(n);if(e<=0)return"";let t=er.SYNC_PHASES.filter(r=>n.durations[r]>0).sort((r,i)=>n.durations[i]-n.durations[r]).map(r=>`${r} ${bd(n.durations[r])} ${Math.round(n.durations[r]/e*100)}%`);return`\u23F1 ExoSync ${bd(e)} \u2014 ${t.join(" \xB7 ")} (${n.counts.filesHashed} hashed, ${n.counts.filesRead} read, ${n.counts.restCalls} REST)`}a(AY,"formatTimingsLine");function IY(n,e){let t=er.SYNC_PHASES.map(r=>`${r}=${bd(e.durations[r])}`);return`[ExoSync timings] ${n}: total ${bd(Cy(e))} \u2014 ${t.join(" ")} | hashed ${e.counts.filesHashed} read ${e.counts.filesRead} written ${e.counts.filesWritten} REST ${e.counts.restCalls}`}a(IY,"formatRepoTimings")});var xy=T(Sa=>{"use strict";Object.defineProperty(Sa,"__esModule",{value:!0});Sa.LocalOutboxStore=Sa.OUTBOX_REMOTE_ABSENT=Sa.OUTBOX_STORE_FILENAME=void 0;Sa.OUTBOX_STORE_FILENAME="exosync-outbox.local.json";Sa.OUTBOX_REMOTE_ABSENT=" absent";function OT(n,e){return`${n}\0${e}`}a(OT,"outboxKey");function TD(n){if(n===null||typeof n!="object")return!1;let e=n;return typeof e.repoKey=="string"&&typeof e.path=="string"&&typeof e.chosenContent=="string"&&typeof e.baseRemoteSha=="string"}a(TD,"isEntry");var CT=class{static{a(this,"LocalOutboxStore")}constructor(e){this.writeChain=Promise.resolve(),this.io=e.io,this.now=e.now??(()=>new Date().toISOString())}async enqueue(e){await this.mutate(t=>{t.entries[OT(e.repoKey,e.path)]={version:1,...e,resolvedAt:e.resolvedAt.length>0?e.resolvedAt:this.now()}})}async remove(e,t){await this.mutate(r=>{delete r.entries[OT(e,t)]})}async list(){let e=await this.read();return Object.values(e.entries).filter(TD)}async listForRepo(e){return(await this.list()).filter(t=>t.repoKey===e)}async has(e,t){let i=(await this.read()).entries[OT(e,t)];return i!==void 0&&TD(i)}async mutate(e){let t=this.writeChain.then(async()=>{let r=await this.read();e(r),await this.io.writeAtomic(JSON.stringify(r,null,2))});return this.writeChain=t.catch(()=>{}),t}async read(){try{let e=await this.io.read();if(e===null)return{version:1,entries:{}};let t=JSON.parse(e);if(t===null||typeof t!="object")return{version:1,entries:{}};let r=t.entries;return r===null||typeof r!="object"?{version:1,entries:{}}:{version:1,entries:{...r}}}catch{return{version:1,entries:{}}}}};Sa.LocalOutboxStore=CT});var Py=T(xT=>{"use strict";Object.defineProperty(xT,"__esModule",{value:!0});xT.isAuthError=RY;function RY(n){let e=n instanceof Error?n.message:String(n);return/HTTP 401/.test(e)?!0:/HTTP 403/.test(e)&&!/rate limit/i.test(e)&&!/abuse detection/i.test(e)}a(RY,"isAuthError")});var PT=T(Dy=>{"use strict";Object.defineProperty(Dy,"__esModule",{value:!0});Dy.scanForSecrets=OY;Dy.redactSecrets=CY;var AD=[{kind:"github-token",re:/gh[pousr]_[A-Za-z0-9_]{36,}/},{kind:"github-fine-grained-token",re:/github_pat_[A-Za-z0-9_]{22,}_[A-Za-z0-9_]{59,}/},{kind:"private-key",re:/-----BEGIN [A-Z ]*PRIVATE KEY-----/}];function OY(n){let e=[];for(let[t,r]of n)for(let{kind:i,re:s}of AD)s.test(r)&&e.push({path:t,kind:i});return e}a(OY,"scanForSecrets");function CY(n){let e=n;for(let{kind:t,re:r}of AD)e=e.replace(new RegExp(r.source,"g"),`[REDACTED:${t}]`);return e}a(CY,"redactSecrets")});var Ly=T(Fy=>{"use strict";Object.defineProperty(Fy,"__esModule",{value:!0});Fy.isRateLimitError=ID;Fy.withRateLimitBackoff=PY;function ID(n){let e=n instanceof Error?n.message:String(n);return/HTTP 429/.test(e)?!0:/HTTP 403/.test(e)&&(/rate limit/i.test(e)||/abuse detection/i.test(e))}a(ID,"isRateLimitError");var xY=a(n=>new Promise(e=>setTimeout(e,n)),"defaultSleep");function PY(n,e={}){let t=e.maxRetries??3,r=e.baseDelayMs??1e3,i=e.sleep??xY,s=e.random??Math.random;return async o=>{let c=0;for(;;)try{return await n(o)}catch(l){if(!ID(l)||c>=t)throw l;let u=r*2**c*(1+s());c++,await i(u)}}}a(PY,"withRateLimitBackoff")});var Ny=T(No=>{"use strict";Object.defineProperty(No,"__esModule",{value:!0});No.DEFAULT_MAX_FILE_BYTES=No.InMemoryQuarantineStore=void 0;No.contentEquals=DY;No.isSyncablePath=FY;No.isFileSpaceSyncablePath=LY;function DY(n,e){if(n===void 0||e===void 0||typeof n=="string"&&typeof e=="string")return n===e;if(typeof n=="string"||typeof e=="string"||n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.byteLength;t++)if(n[t]!==e[t])return!1;return!0}a(DY,"contentEquals");var DT=class{static{a(this,"InMemoryQuarantineStore")}constructor(){this.entries=[]}async quarantine(e){this.entries.push(e)}};No.InMemoryQuarantineStore=DT;function FY(n){return n.endsWith(".md")&&!n.includes(".local.")&&!n.includes(".conflict.")}a(FY,"isSyncablePath");function LY(n){return!n.includes(".local.")&&!n.includes(".conflict.")}a(LY,"isFileSpaceSyncablePath");No.DEFAULT_MAX_FILE_BYTES=30*1024*1024});var LD=T(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.SyncEngine=qn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=qn.DEFAULT_MAX_PUSH_RETRIES=void 0;qn.syncProgressPhaseText=$Y;qn.isNonFastForwardError=FD;qn.orderChildrenFirst=HY;var RD=Iy(),OD=RT(),mt=_d(),ko=md(),NY=ul(),Cc=hu(),FT=xy(),kY=Py(),MY=PT(),jY=Ly(),ks=Ny();qn.DEFAULT_MAX_PUSH_RETRIES=3;qn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=720*60*1e3;function $Y(n){switch(n.phase){case"reading-local":return n.detail!==void 0?`reading local files ${n.detail.done}\u2026`:"reading local files\u2026";case"detecting":return"detecting changes\u2026";case"pulling-remote":return"pulling remote tree\u2026";case"fetching-blobs":return n.detail!==void 0?`fetching remote files ${n.detail.done}/${n.detail.total}\u2026`:"fetching remote files\u2026";case"writing-files":return n.detail!==void 0?`writing files ${n.detail.done}\u2026`:"writing files\u2026";case"merging":return"merge layer firing\u2026";default:return n.phase}}a($Y,"syncProgressPhaseText");var CD=25,UY=10,BY=500,VY=25;function qY(n){try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{return null}}a(qY,"decodeUtf8Strict");function GY(n){return typeof n=="string"?n:{base64:(0,NY.bytesToBase64)(n)}}a(GY,"toCommitContent");async function xD(n,e){if(n.readBinary===void 0)throw new Error("LocalFilesPort.readBinary is required for file-mode sync (Phase C)");return n.readBinary(e)}a(xD,"readBinaryStrict");async function WY(n,e,t){if(n.writeBinary===void 0)throw new Error("LocalFilesPort.writeBinary is required for file-mode sync (Phase C)");return n.writeBinary(e,t)}a(WY,"writeBinaryStrict");function PD(n){return n.length===0||n.startsWith("/")||n.includes("\\")?!1:n.split("/").every(e=>e.length>0&&e!=="."&&e!=="..")}a(PD,"isSafeRepoRelativePath");function FD(n){let e=n instanceof Error?n.message:String(n);return/HTTP 422/.test(e)&&/git\/refs/.test(e)||/ref update mismatch/.test(e)||/HTTP 422/.test(e)&&/git\/trees/.test(e)&&/BadObjectState/.test(e)}a(FD,"isNonFastForwardError");function HY(n){let e=a(t=>t.split("/").filter(r=>r.length>0).length,"depth");return[...n].sort((t,r)=>e(r.localPath)-e(t.localPath))}a(HY,"orderChildrenFirst");function DD(n,e){let t=new Map(n.map(o=>[o.path,o])),r=new Set,i=[];for(let o of e){r.add(o.path);let c=t.get(o.path);(c===void 0||c.blobSha!==o.blobSha)&&i.push(o)}let s=n.filter(o=>!r.has(o.path));return{changed:i,deleted:s}}a(DD,"diffTrees");function wa(n){return n instanceof Error?n.message:String(n)}a(wa,"errMsg");function zY(n,e,t){if(t.size===0)return n;let r=new Map(e.files.map(o=>[o.path,o])),i=new Set(n.map(o=>o.path)),s=[];for(let o of n){if(!t.has(o.path)){s.push(o);continue}let c=r.get(o.path);c!==void 0&&s.push(c)}for(let o of t){if(i.has(o))continue;let c=r.get(o);c!==void 0&&s.push(c)}return s}a(zY,"applyWatermarkPins");var LT={mergedFiles:new Map,mergedWrites:[],quarantineEntries:[],resolvedQuarantineEntries:[],mergedCount:0,mergedPaths:[],warnings:[]};function NT(n){return new Map(n.map(e=>[e.path,e.blobSha]))}a(NT,"treeByPath");function ky(n){return[...n.quarantineEntries.map(e=>e.path),...n.resolvedQuarantineEntries.map(e=>e.path)]}a(ky,"quarantinedPathsOf");var kT=class{static{a(this,"SyncEngine")}constructor(e){this.activeTimer=null,this.activeLocalIoProgress=null,this.opInProgress=!1,this.deps=e,this.now=e.now??(()=>Date.now()),this.transport=this.instrumentTransport((0,jY.withRateLimitBackoff)(e.transport,e.backoff)),this.sha1=this.instrumentSha1(e.sha1)}instrumentTransport(e){return async t=>{let r=this.activeTimer;return r===null?e(t):(r.bumpRest(),r.time((0,OD.classifyRestPhase)(t),()=>e(t)))}}instrumentSha1(e){return t=>{let r=this.activeTimer;return r===null?e(t):(r.bumpHashed(),r.time("hash",()=>e(t)))}}instrumentLocalFiles(e){let t=a((c,l)=>{let u=this.activeTimer;return u===null?l():u.time(c,l)},"timed"),r={list:a(()=>t("localList",()=>e.list()),"list"),read:a(c=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>e.read(c))),"read"),write:a((c,l)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),e.write(c,l))),"write"),delete:a(c=>e.delete(c),"delete")},i=e.readBinary?.bind(e);i!==void 0&&(r.readBinary=c=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>i(c))));let s=e.writeBinary?.bind(e);s!==void 0&&(r.writeBinary=(c,l)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),s(c,l))));let o=e.stat?.bind(e);return o!==void 0&&(r.stat=c=>t("localList",()=>o(c))),r}busyResult(e){return{repoKey:e.repoKey,status:"busy",pulledCount:0,pushedCount:0,mergedCount:0,quarantinedCount:0,warnings:[],deferredDeletes:[],detail:"another sync operation is in progress (D11 guard) \u2014 retry after it finishes"}}modeOps(e){let t=e.spaceKind==="file",r=t?ks.isFileSpaceSyncablePath:ks.isSyncablePath,i=this.deps.maxFileBytes??ks.DEFAULT_MAX_FILE_BYTES;return{fileMode:t,syncable:r,treeFilter:a(s=>r(s.path)&&(!t||s.size===void 0||s.size<=i),"treeFilter")}}async buildFileModeFirstSyncBase(e,t,r,i){let s=await(0,mt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),c=(await(0,mt.getTree)(this.transport,e.owner,e.repo,o.treeSha,this.deps.baseURL)).filter(r.treeFilter),l=[];for(let u of c){let f=t.get(u.path);f!==void 0&&await(0,Cc.gitBlobSha)(f,this.sha1)===u.blobSha&&l.push({path:u.path,blobSha:u.blobSha})}return i.push(`first-sync (file mode): synthetic base from ${l.length} already-identical file(s) at head ${s} \u2014 divergence resolves through the remote-wins layer (D22)`),{lastSyncedSha:s,rootTreeSha:o.treeSha,files:l,spaceKind:"file"}}async syncAll(e,t="sync",r){if(this.opInProgress)return e.map(i=>this.busyResult(i));this.opInProgress=!0;try{let i=[];for(let s of e)i.push(await this.syncLocked(s,t,r));return i}finally{this.opInProgress=!1}}async sync(e,t="sync",r){if(this.opInProgress)return this.busyResult(e);this.opInProgress=!0;try{return await this.syncLocked(e,t,r)}finally{this.opInProgress=!1}}emitProgress(e,t,r,i){if(e!==void 0)try{e(i===void 0?{repoKey:t,phase:r}:{repoKey:t,phase:r,detail:i})}catch{}}bumpReadProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.reads+=1,e.reads%BY===0&&this.emitProgress(e.emit,e.repoKey,"reading-local",{done:e.reads}))}bumpWriteProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.writes+=1,e.writes%VY===0&&this.emitProgress(e.emit,e.repoKey,"writing-files",{done:e.writes}))}async syncLocked(e,t="sync",r){let i=new OD.SyncPhaseTimer(this.now),s=this.activeTimer;this.activeTimer=i;let o=this.activeLocalIoProgress;this.activeLocalIoProgress=r!==void 0?{emit:r,repoKey:e.repoKey,reads:0,writes:0}:null;let c=[],l=[],u=0,f=0,d=[],h=a((p,y={})=>({repoKey:e.repoKey,status:p,pulledCount:0,pushedCount:0,mergedCount:0,quarantinedCount:0,warnings:c,deferredDeletes:l,...u>0?{outboxPushedCount:u}:{},...f>0?{outboxReconflictedCount:f}:{},timings:i.snapshot(),...y}),"result");try{let p=await this.deps.materializationCheck.check(e);if(!p.fullyMaterialized)return c.push(`skipped: repo not fully materialized${p.reason?` (${p.reason})`:""} \u2014 deletes NOT inferred (D19)`),h("skipped-not-materialized");let y=this.modeOps(e),_=this.instrumentLocalFiles(this.deps.localFilesFor(e));if(y.fileMode&&(_.readBinary===void 0||_.writeBinary===void 0))return h("error",{detail:"file-mode repo requires a LocalFilesPort with readBinary/writeBinary \u2014 refusing to sync through the text-only port (binary would corrupt)"});if(y.fileMode&&this.deps.quarantine===void 0)return h("error",{detail:"file-mode repo requires a quarantine sink (D18 remote-wins preserves losing local bytes there) \u2014 configure the quarantine repo before syncing FileSpaces"});let w=this.deps.maxFileBytes??ks.DEFAULT_MAX_FILE_BYTES;if(t!=="pull"&&this.deps.outbox!==void 0){let ee=await this.flushOutbox(e,c);u=ee.pushed,f=ee.reconflicted}let S=await this.deps.watermarkStore.get(e.repoKey);if(S?.spaceKind==="file"&&!y.fileMode)return h("error",{detail:"watermark was written by a FILE-mode sync but the spec now resolves to asset mode \u2014 refusing (fix the conflicting Space declarations, or clear the watermark to restart)"});S!==null&&y.fileMode&&S.spaceKind!=="file"&&(c.push("watermark was written by an ASSET-mode sync \u2014 rebuilding the base through the file-mode first-sync layer (kind flip)"),S=null);let v=this.deps.localManifestStore!==void 0?_.stat?.bind(_):void 0,x=v!==void 0&&S!==null&&!y.fileMode,I=x&&this.deps.localManifestStore!==void 0?await this.deps.localManifestStore.get(e.repoKey):null,C=this.deps.localManifestFullRehashMs??qn.DEFAULT_LOCAL_MANIFEST_REHASH_MS,D=x&&(I===null||this.now()-I.lastFullRehashMs>=C),K=new Map,U=new Set,k=new Map,z=new Map,N=new Map,ae=!1,_e=new Map;if(x&&S!==null)for(let ee of S.files)_e.set(ee.path,ee.blobSha);for(let ee of(await _.list()).filter(y.syncable)){if(y.fileMode){let Re=await xD(_,ee);if(Re.byteLength>w){U.add(ee),c.push(`skipped oversized file ${ee} (${Re.byteLength} bytes > ${w} cap) \u2014 excluded from sync symmetrically (Phase C size cap)`);continue}K.set(ee,Re);continue}if(!x||v===void 0){K.set(ee,await _.read(ee));continue}let de=await v(ee),we=!D&&de!==null?I?.files[ee]:void 0;if(de!==null&&we!==void 0&&we.mtimeMs===de.mtimeMs&&we.size===de.size&&we.blobSha===_e.get(ee)){k.set(ee,{blobSha:we.blobSha,...we.uid!==void 0?{uid:we.uid}:{}}),z.set(ee,we.blobSha),N.set(ee,de);continue}ae=!0,K.set(ee,await _.read(ee)),de!==null&&N.set(ee,de)}let J=!1;if(S===null)if(y.fileMode)J=!0,S=await this.buildFileModeFirstSyncBase(e,K,y,c);else{let ee=await this.bootstrapWatermark(e,K,c,h);if(ee.kind==="settled")return ee.outcome;J=!0,S=ee.base}let he=S;y.fileMode&&U.size>0&&(S={...S,files:S.files.filter(ee=>!U.has(ee.path))});let Q,ve;x&&!D?(Q=await(0,mt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),ve=Q===S.lastSyncedSha?S.rootTreeSha:await this.resolveBaseTreeSha(e,S)):ve=await this.resolveBaseTreeSha(e,S),this.emitProgress(r,e.repoKey,"detecting");let ie=await(0,ko.detectChanges)({localFiles:K,...x?{cachedEntries:k}:{},watermark:S,actualBaseTreeSha:ve,sha1:this.sha1});if(ie.kind==="full-conflict")return h("full-conflict",{detail:`${ie.reason}${ie.detail?`: ${ie.detail}`:""} \u2014 divergence must go through merge/quarantine (A2/A3), not overwrite`});if(c.push(...ie.warnings),x&&this.deps.localManifestStore!==void 0){let ee={};for(let[de,we]of K){let Re=N.get(de),Me=ie.diskBlobShas.get(de);if(Re===void 0||Me===void 0)continue;let Ne=typeof we=="string"?(0,ko.extractAssetUid)(we):void 0;ee[de]={mtimeMs:Re.mtimeMs,size:Re.size,blobSha:Me,...Ne!==void 0?{uid:Ne}:{}}}for(let[de,we]of k){let Re=N.get(de);Re!==void 0&&(ee[de]={mtimeMs:Re.mtimeMs,size:Re.size,blobSha:we.blobSha,...we.uid!==void 0?{uid:we.uid}:{}})}if(I!==null&&Object.keys(I.files).some(de=>!(de in ee))&&(ae=!0),ae||D||I===null){let de={version:1,files:ee,lastFullRehashMs:D||I===null?this.now():I.lastFullRehashMs};await this.deps.localManifestStore.set(e.repoKey,de)}}let te=this.pinLocalChanges(ie,K,c,l,t);d=[...te.pushDeletionsAll.keys()];let me=await this.runPushLoop(e,S,te,K,c,y,J,U,t,r,Q);if(d=[],me.kind!=="done"&&te.pushDeletionsAll.size>0&&l.push(...te.pushDeletionsAll.keys()),me.kind==="conflict")return h("conflict",{detail:me.detail});if(me.kind==="secret-detected")return h("error",{detail:me.detail});if(me.kind==="retry-exhausted"){c.push(...me.merge.warnings);let ee=await this.buildTerminalQuarantineEntries(e,S,me.pushFiles,me.merge.quarantineEntries,K),de=[...me.merge.quarantineEntries,...me.merge.resolvedQuarantineEntries,...ee];return await this.flushQuarantine(de,c),h("retry-exhausted",{detail:me.detail,quarantinedCount:de.length,...de.length>0?{quarantinedPaths:de.map(we=>we.path)}:{}})}let{examinedHead:Ee,pushedSha:re,applyWrites:ye,applyDeletes:Fe,pushFiles:se}=me,ge=me.merge;c.push(...ge.warnings),c.push(...me.deferredWarnings),l.push(...me.withheldDeletions);let Le=me.deferredPaths.size>0?{deferredPaths:[...me.deferredPaths]}:{},Y=me.pushedDeletions.length>0?{pushedDeletes:me.pushedDeletions}:{},ce=await this.flushQuarantine([...ge.quarantineEntries,...ge.resolvedQuarantineEntries],c),be=new Set;if(!ce&&ge.resolvedQuarantineEntries.length>0){for(let ee of ge.resolvedQuarantineEntries)be.add(ee.path);c.push(`quarantine flush failed \u2014 remote-wins apply withheld for ${be.size} path(s); local files untouched, conflict re-derives next sync (D18 durability gate)`)}if(re===void 0&&Ee===S.lastSyncedSha&&ye.length===0&&Fe.length===0&&ge.mergedWrites.length===0&&ge.quarantineEntries.length===0&&ge.resolvedQuarantineEntries.length===0&&(S.pinnedPaths?.length??0)===0&&me.alreadyInHead.length===0&&me.deferredPaths.size===0&&!J)return h("synced");let Ie=re??Ee,Ce=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,Ie,this.deps.baseURL);if(re!==void 0&&Ce.parents[0]!==Ee)return await this.checkRaceWindow(e,S,Ee,Ce.parents[0],se,new Set(me.pushedDeletions),c,y),c.push(`race-window: watermark NOT advanced (pushed commit's parent ${Ce.parents[0]} != examined head ${Ee}) \u2014 next sync reconciles the concurrent change`),h("synced",{pushedSha:re,pushedCount:se.size,mergedCount:ge.mergedCount,quarantinedCount:ge.quarantineEntries.length+ge.resolvedQuarantineEntries.length,...ge.mergedPaths.length>0?{mergedPaths:ge.mergedPaths}:{},...ky(ge).length>0?{quarantinedPaths:ky(ge)}:{},...Le,...Y});let{pulledCount:De,pinnedPaths:Pe,pulledPaths:Te}=await this.applyRemoteChanges(_,K,[...ye,...ge.mergedWrites].filter(ee=>!be.has(ee.path)),Fe.filter(ee=>!be.has(ee.path)),c,z);for(let ee of ge.quarantineEntries)Pe.add(ee.path);for(let ee of me.deferredPaths)Pe.add(ee);for(let ee of be)Pe.add(ee);if(y.fileMode){for(let ee of U)Pe.add(ee);for(let ee of me.remoteOversized)Pe.add(ee)}return await this.advanceWatermark(e,Ie,Ce.treeSha,K,[...ye,...ge.mergedWrites,...me.deferredRemoteChanges],he,Pe,ie.diskBlobShas,y,U),await this.resolveClearedPins(e,he,Pe,c,new Set(ge.resolvedQuarantineEntries.map(ee=>ee.path))),h("synced",{pushedSha:re,pulledCount:De,pushedCount:se.size,mergedCount:ge.mergedCount,quarantinedCount:ge.quarantineEntries.length+ge.resolvedQuarantineEntries.length,...ge.mergedPaths.length>0?{mergedPaths:ge.mergedPaths}:{},...Te.length>0?{pulledPaths:Te}:{},...ky(ge).length>0?{quarantinedPaths:ky(ge)}:{},...Le,...Y})}catch(p){let y=this.deps.redact??(_=>_);return d.length>0&&l.push(...d),(0,kY.isAuthError)(p)?h("auth-required",{detail:y(`authentication failed: ${wa(p)} \u2014 the PAT is expired, revoked or under-scoped; update it in the per-device secure storage (R8). Never treated as success.`)}):(c.push(`sync failed: ${y(wa(p))}`),h("error",{detail:y(wa(p))}))}finally{this.activeTimer=s,this.activeLocalIoProgress=o}}async flushQuarantine(e,t){if(e.length===0)return!0;let r=this.deps.redact??(s=>s);for(let s of e)t.push(r(`quarantined ${s.path}: ${s.reason}`));let i=this.deps.quarantine;if(i===void 0)return!1;try{if(i.quarantineAll!==void 0)await i.quarantineAll(e);else for(let s of e)await i.quarantine(s);return!0}catch(s){let o=this.deps.redact??(c=>c);return t.push(`quarantine sink failed: ${o(wa(s))} \u2014 files untouched on disk; the conflict re-derives next sync (D17 degradation)`),!1}}async flushOutbox(e,t){let r=this.deps.outbox;if(r===void 0)return{pushed:0,reconflicted:0};let i=await r.listForRepo(e.repoKey);if(i.length===0)return{pushed:0,reconflicted:0};let s=this.deps.redact??(y=>y),o,c;try{({head:o,shaByPath:c}=await this.outboxHeadTreeShas(e))}catch(y){return t.push(`outbox flush deferred (${i.length} resolution(s) awaiting push): ${s(wa(y))}`),{pushed:0,reconflicted:0}}let l=0,u=[];for(let y of i){let _=c.get(y.path)??FT.OUTBOX_REMOTE_ABSENT,w=_===FT.OUTBOX_REMOTE_ABSENT&&y.baseRemoteSha!==FT.OUTBOX_REMOTE_ABSENT?[...c].filter(([S,v])=>S!==y.path&&v===y.baseRemoteSha).map(([S])=>S):[];if(_!==y.baseRemoteSha&&w.length===0){await r.remove(y.repoKey,y.path),l++,t.push(s(`outbox: remote moved for ${y.path} since you resolved it \u2014 NOT pushed; resolve again (your choice is preserved on disk)`));continue}u.push({entry:y,stalePaths:w})}if(u.length===0)return{pushed:0,reconflicted:l};let f=new Map;for(let{entry:y}of u)f.set(y.path,y.chosenContent);let d=new Set;for(let{stalePaths:y}of u)for(let _ of y)f.has(_)||d.add(_);let h=[...d];try{await(0,RD.restCreateCommit)(this.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:f,...h.length>0?{deletions:h}:{},message:h.length>0?`chore(exosync): resolve ${u.length} keep-local conflict(s) (consolidate ${h.length} stale remote path(s))`:`chore(exosync): push ${u.length} resolved conflict(s)`,expectedHeadSha:o,...this.deps.baseURL!==void 0?{baseURL:this.deps.baseURL}:{},...this.deps.redact!==void 0?{redact:this.deps.redact}:{}})}catch(y){return t.push(`outbox: batch push deferred for ${u.length} resolution(s), will retry next sync: ${s(wa(y))}`),{pushed:0,reconflicted:l}}let p=0;for(let{entry:y,stalePaths:_}of u){let w=_.filter(S=>!f.has(S));await this.snapOutboxWatermark(e,y.path,y.chosenContent,w),await this.deps.quarantine?.markResolved?.(y.repoKey,y.path);for(let S of w)await this.deps.quarantine?.markResolved?.(y.repoKey,S);await r.remove(y.repoKey,y.path),p++,w.length>0&&t.push(`consolidated cross-path conflict for ${y.path} \u2014 removed ${w.length} stale remote copy/copies (recoverable in git history)`)}return p>0&&t.push(`pushed ${p} resolved conflict(s)`),{pushed:p,reconflicted:l}}async outboxHeadTreeShas(e){let t=await(0,mt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),r=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,mt.getTree)(this.transport,e.owner,e.repo,r.treeSha,this.deps.baseURL),s=new Map;for(let o of i)s.set(o.path,o.blobSha);return{head:t,shaByPath:s}}async snapOutboxWatermark(e,t,r,i=[]){let s=await this.deps.watermarkStore.get(e.repoKey);if(s===null)return;let o=new Set([t,...i]),c=(s.pinnedPaths??[]).filter(_=>!o.has(_)),l=await(0,Cc.gitBlobSha)(r,this.sha1),u=(0,ko.extractAssetUid)(r),f={path:t,blobSha:l,...u!==void 0?{uid:u}:{}},d=new Set(i),h=s.files.filter(_=>!d.has(_.path)),p=h.findIndex(_=>_.path===t),y=p>=0?h.map((_,w)=>w===p?f:_):[...h,f];await this.deps.watermarkStore.set(e.repoKey,{...s,files:y,...c.length>0?{pinnedPaths:c}:{pinnedPaths:void 0}})}async buildTerminalQuarantineEntries(e,t,r,i,s){let o=new Set(i.map(u=>u.path)),c=new Map;try{let u=await(0,mt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),f=(await(0,mt.getTree)(this.transport,e.owner,e.repo,(await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,u,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(d=>r.has(d.path));for(let d of f)c.set(d.path,await(0,mt.getBlobText)(this.transport,e.owner,e.repo,d.blobSha,this.deps.baseURL))}catch{}let l=[];for(let[u,f]of r){if(o.has(u))continue;let d=s.get(u),h=d??f,p=d!==void 0&&!(0,ks.contentEquals)(d,f),y=typeof h=="string"?(0,ko.extractAssetUid)(h):void 0,_=c.get(u);l.push({repoKey:e.repoKey,path:u,...y!==void 0?{uid:y}:{},reason:`non-fast-forward push failed after ${this.deps.maxPushRetries??qn.DEFAULT_MAX_PUSH_RETRIES} retries (D16) \u2014 a concurrent writer keeps moving ${e.branch}; base recoverable from git history at ${t.lastSyncedSha}${p?"; the contended push payload was a merged proposal (never applied to disk) \u2014 the merge re-derives next sync":""}`,...typeof h=="string"?{localContent:h}:{localContentBytes:h},..._!==void 0?{remoteContent:_}:{}})}return l}async resolveClearedPins(e,t,r,i,s=new Set){let o=this.deps.quarantine;if(o===void 0||o.markResolved===void 0)return;let c=(t.pinnedPaths??[]).filter(l=>!r.has(l)&&!s.has(l));for(let l of c)try{await o.markResolved?.(e.repoKey,l)}catch(u){let f=this.deps.redact??(d=>d);i.push(`quarantine markResolved failed for ${l}: ${f(wa(u))} \u2014 unresolved-count may overcount until the resolver UI reconciles (CQ4)`)}}async resolveBaseTreeSha(e,t){try{return(await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,t.lastSyncedSha,this.deps.baseURL)).treeSha}catch{return null}}pinLocalChanges(e,t,r,i,s){let o=e.modified.filter(h=>h.basePath!==void 0),c=[...e.added,...e.modified.filter(h=>h.basePath===void 0)],l=new Map;if(s==="pull"){for(let h of o)h.basePath!==void 0&&i.push(h.basePath),r.push(`pull-only: rename (uid ${h.uid??"?"}) ${h.basePath} \u2192 ${h.path} not pushed \u2014 propagates on the next push/Sync (#3473)`);for(let h of e.deleted)i.push(h.path),r.push(`pull-only: delete of ${h.path} not pushed \u2014 propagates on the next push/Sync (#3473)`)}else{for(let h of o)h.basePath!==void 0&&l.set(h.basePath,h.path);for(let h of e.deleted)l.set(h.path,h.path)}let u=[...c,...o,...e.deleted.map(h=>({...h}))],f=new Set(e.deleted.map(h=>h.path)),d=new Map;for(let h of[...c,...s==="pull"?[]:o]){let p=t.get(h.path);p!==void 0&&d.set(h.path,p)}return{localChanges:u,localDeletedPaths:f,pushFilesAll:d,pushDeletionsAll:l,dupUids:e.duplicateUids}}async runPushLoop(e,t,r,i,s,o,c=!1,l=new Set,u="sync",f,d){let{localChanges:h,localDeletedPaths:p,pushFilesAll:y,pushDeletionsAll:_,dupUids:w}=r,S=this.deps.maxPushRetries??qn.DEFAULT_MAX_PUSH_RETRIES,v=0,x="",I,C=[],D=[],K=new Map,U=new Set,k=[],z=LT,N=[],ae=new Set,_e=[],J=[],he=new Set;for(;;){x=v===0&&d!==void 0&&y.size===0&&_.size===0?d:await(0,mt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),C=[],D=[],z=LT,N=[],ae=new Set,_e=[],J=[];let Q,ve=new Set,ie=(t.pinnedPaths?.length??0)>0;if(x!==t.lastSyncedSha||ie||c){this.emitProgress(f,e.repoKey,"pulling-remote");let Ee=await this.collectRemoteChanges(e,t,x,o,l,s,he,f);Q=Ee.headTreeByPath;let re=this.matchLocalVsRemote(h,p,i,Ee.changes,ve,w,Ee.headTreeByPath);if(re.conflicts.length>0){if(u==="sync"&&this.emitProgress(f,e.repoKey,"merging"),u!=="sync"){for(let ye of re.conflicts){ae.add(ye.local.path),ye.local.basePath!==void 0&&ae.add(ye.local.basePath);for(let Fe of ye.remotes)ae.add(Fe.path),Fe.kind==="change"&&_e.push(Fe)}J.push(`${u}-only: ${re.conflicts.length} conflict(s) deferred to a full Sync (${re.conflicts.map(ye=>ye.desc).join("; ")}) \u2014 paths pinned, nothing merged`)}else if(o.fileMode)z=this.resolveFileModeConflicts(e,re.conflicts,i,re.applyWrites,re.applyDeletes);else{if(this.deps.mergeLayer===void 0)return{kind:"conflict",detail:`overlapping change on ${re.conflicts[0].desc} \u2014 merge layer (A2/A3) required; nothing pushed, nothing written`};z=await this.resolveMergeConflicts(e,t,re.conflicts,i)}if(u==="sync")for(let ye of re.conflicts)for(let Fe of ye.remotes)Fe.path!==ye.local.path&&(ae.add(Fe.path),Fe.kind==="change"&&_e.push(Fe),J.push(`conflict group ${ye.desc}: remote change at ${Fe.path} NOT applied \u2014 pinned to re-derive on the next sync (#3477)`))}if(C=re.applyWrites,D=re.applyDeletes,u==="push"&&(C.length>0||D.length>0)){for(let ye of C)ae.add(ye.path),_e.push(ye);for(let ye of D)ae.add(ye.path);J.push(`push-only: ${C.length+D.length} remote change(s) NOT applied \u2014 pinned to re-derive on the next pull/Sync`),C=[],D=[]}}K=u==="pull"?new Map:new Map([...[...y].filter(([Ee])=>!ve.has(Ee)),...z.mergedFiles]),U=new Set,k=[];for(let[Ee,re]of _){if(ve.has(re)){k.push(Ee);continue}K.has(Ee)||U.add(Ee)}if((K.size>0||U.size>0)&&Q===void 0&&(Q=NT(await(0,mt.getTree)(this.transport,e.owner,e.repo,t.rootTreeSha,this.deps.baseURL))),K.size>0&&Q!==void 0){for(let[Ee,re]of K){let ye=Q.get(Ee);ye!==void 0&&ye===await(0,Cc.gitBlobSha)(re,this.sha1)&&(K.delete(Ee),N.push(Ee))}N.length>0&&s.push(`phantom push skipped: ${N.length} file(s) already identical in remote HEAD (${N.join(", ")}) \u2014 excluded from the commit (#3475)`)}if(U.size>0&&Q!==void 0){for(let Ee of[...U])Q.has(Ee)||U.delete(Ee);K.size===0&&U.size>=Q.size&&(k.push(...U),J.push(`deletion of ALL ${U.size} remaining file(s) deferred \u2014 GitHub cannot create an empty tree; the deletes re-derive and propagate once the repo has at least one surviving file`),U.clear())}if(K.size===0&&U.size===0)break;let te=new Map;for(let[Ee,re]of K)if(typeof re=="string")te.set(Ee,re);else{let ye=qY(re);ye!==null&&te.set(Ee,ye)}let me=(0,MY.scanForSecrets)(te);if(me.length>0)return{kind:"secret-detected",detail:`secret-scan: refusing to push \u2014 ${me.map(Ee=>`${Ee.path} (${Ee.kind})`).join(", ")} (R5); remove the secret and re-sync`};try{I=await(0,RD.restCreateCommit)(this.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([...K].map(([Ee,re])=>[Ee,GY(re)])),deletions:[...U],message:this.deps.commitMessage?.(e,K.size,U.size)??`chore(exosync): sync ${K.size} file(s)${U.size>0?`, ${U.size} deletion(s)`:""}`,baseURL:this.deps.baseURL,redact:this.deps.redact});break}catch(Ee){if(!FD(Ee))throw Ee;if(v++,v>S)return{kind:"retry-exhausted",detail:`non-fast-forward push failed after ${S} retries (D16 cap) \u2014 contended files routed to quarantine (D17)`,pushFiles:K,merge:z};s.push(`non-fast-forward push (attempt ${v}/${S}) \u2014 re-pulling and retrying (D16)`)}}return{kind:"done",examinedHead:x,pushedSha:I,applyWrites:C,applyDeletes:D,pushFiles:K,pushedDeletions:I!==void 0?[...U]:[],withheldDeletions:k,merge:z,remoteOversized:he,alreadyInHead:N,deferredPaths:ae,deferredRemoteChanges:_e,deferredWarnings:J}}async resolveMergeConflicts(e,t,r,i){let s=this.deps.mergeLayer;if(s===void 0)return LT;let o=new Map(t.files.map(_=>[_.path,_])),c=new Map,l=[],u=[],f=[],d=[],h=0,p=a(_=>typeof _=="string"?_:void 0,"asText"),y=a((_,w,S)=>{let v=p(i.get(_.local.path)),x=p(_.remotes[0]?.content);return{repoKey:e.repoKey,path:_.local.path,..._.local.uid!==void 0?{uid:_.local.uid}:{},reason:w,...S!==void 0?{baseContent:S}:{},...v!==void 0?{localContent:v}:{},...x!==void 0?{remoteContent:x}:{}}},"entry");for(let _ of r){let w=o.get(_.local.basePath??_.local.path)??o.get(_.remotes[0]?.path??""),S;if(w!==void 0&&(S=await(0,mt.getBlobText)(this.transport,e.owner,e.repo,w.blobSha,this.deps.baseURL)),_.remotes.length>1){u.push(y(_,`ambiguous conflict: local change overlaps ${_.remotes.length} remote changes (${_.remotes.map(D=>D.path).join(", ")})`,S));continue}let v=_.remotes[0],x=p(i.get(_.local.path)),I=await s.resolve({path:_.local.path,..._.local.uid!==void 0?{uid:_.local.uid}:{},...S!==void 0?{base:S}:{},...x!==void 0?{local:x}:{},...v.kind==="change"&&typeof v.content=="string"?{remote:v.content}:{}});if(I.action==="quarantine"){u.push(y(_,I.reason,S));continue}h++,d.push(_.local.path);for(let D of I.warnings??[])f.push(`merge(${_.local.path}): ${D}`);let C=v.kind==="change"?v.content:void 0;if(I.content!==C&&c.set(_.local.path,I.content),I.content!==i.get(_.local.path)){let D=(0,ko.extractAssetUid)(I.content)??_.local.uid;l.push({path:_.local.path,kind:"change",content:I.content,blobSha:await(0,Cc.gitBlobSha)(I.content,this.sha1),...D!==void 0?{uid:D}:{}})}}return{mergedFiles:c,mergedWrites:l,quarantineEntries:u,resolvedQuarantineEntries:[],mergedCount:h,mergedPaths:d,warnings:f}}resolveFileModeConflicts(e,t,r,i,s){let o=[],c=[];for(let l of t){l.remotes.length>1&&c.push(`file-mode conflict on ${l.local.path} unexpectedly overlaps ${l.remotes.length} remote changes \u2014 resolving against the first`);let u=l.remotes[0],f=r.get(l.local.path);u.kind==="change"?i.push(u):s.push(u),!(l.localIsDelete||f===void 0)&&o.push({repoKey:e.repoKey,path:l.local.path,reason:`file-mode remote-wins (D18): remote ${u.kind==="change"?`version ${u.blobSha}`:"delete"} wins; this is the losing LOCAL version, preserved byte-exact`,...typeof f=="string"?{localContent:f}:{localContentBytes:f}})}return{mergedFiles:new Map,mergedWrites:[],quarantineEntries:[],resolvedQuarantineEntries:o,mergedCount:0,mergedPaths:[],warnings:c}}async applyRemoteChanges(e,t,r,i,s,o=new Map){let c=0,l=new Set,u=[],f=a(async(p,y)=>{try{return y?await xD(e,p):await e.read(p)}catch{return}},"tryRead"),d=a(async(p,y)=>{typeof y=="string"?await e.write(p,y):await WY(e,p,y)},"writeContent"),h=a(async p=>{let y=await f(p,!1);return y===void 0?!0:await(0,Cc.gitBlobSha)(y,this.sha1)===o.get(p)},"cacheHitUnchanged");for(let p of r){if(p.content===void 0)continue;if(!PD(p.path)){s.push(`unsafe remote path skipped on pull-apply: ${p.path}`),l.add(p.path);continue}let y=t.get(p.path);if(y===void 0&&o.has(p.path)){if(!await h(p.path)){s.push(`pull-apply skipped: ${p.path} changed on disk mid-sync (TOCTOU) \u2014 remote change re-derives next sync`),l.add(p.path);continue}await d(p.path,p.content),c++,u.push(p.path);continue}let _=await f(p.path,typeof(y??p.content)!="string");if(!(0,ks.contentEquals)(_,y)){s.push(`pull-apply skipped: ${p.path} changed on disk mid-sync (TOCTOU) \u2014 remote change re-derives next sync`),l.add(p.path);continue}await d(p.path,p.content),c++,u.push(p.path)}for(let p of i){if(!PD(p.path)){s.push(`unsafe remote path skipped on pull-delete: ${p.path}`),l.add(p.path);continue}let y=t.get(p.path);if(y===void 0&&o.has(p.path)){if(!await h(p.path)){s.push(`pull-delete skipped: ${p.path} changed on disk mid-sync (TOCTOU) \u2014 delete-vs-modify re-derives next sync`),l.add(p.path);continue}await e.delete(p.path),c++,u.push(p.path);continue}if(y!==void 0){let _=await f(p.path,typeof y!="string");if(_!==void 0&&!(0,ks.contentEquals)(_,y)){s.push(`pull-delete skipped: ${p.path} changed on disk mid-sync (TOCTOU) \u2014 delete-vs-modify re-derives next sync`),l.add(p.path);continue}await e.delete(p.path),c++,u.push(p.path)}}return{pulledCount:c,pinnedPaths:l,pulledPaths:u}}async advanceWatermark(e,t,r,i,s,o,c,l,u,f=new Set){let d=(await(0,mt.getTree)(this.transport,e.owner,e.repo,r,this.deps.baseURL)).filter(p=>u.treeFilter(p)&&!f.has(p.path)),h=zY(await this.buildWatermarkFiles(e,d,i,s,o,l,u),o,c);await this.deps.watermarkStore.set(e.repoKey,{lastSyncedSha:t,rootTreeSha:r,files:h,...c.size>0?{pinnedPaths:[...c]}:{},...u.fileMode?{spaceKind:"file"}:{}})}async tryMountBaseBootstrap(e,t,r,i,s){let o=this.deps.mountBaseStore,c=null;if(o!==void 0)try{c=await o.get(e.repoKey)}catch{return null}let l=!1;if(c===null&&this.deps.localBaseShaProvider!==void 0)try{let w=await this.deps.localBaseShaProvider(e);typeof w=="string"&&w.length>0&&(c=w,l=!0)}catch{}if(c===null||t.startsWith(c))return null;let u=300,f=null;try{let w=t;for(let S=0;S<u;S++){let v=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,w,this.deps.baseURL);if(v.sha===c||v.sha.startsWith(c)){f=v;break}if(v.parents.length===0)break;w=v.parents[0]}}catch{return null}if(f===null)return null;let d;try{d=(await(0,mt.getTree)(this.transport,e.owner,e.repo,f.treeSha,this.deps.baseURL)).filter(w=>(0,ks.isSyncablePath)(w.path))}catch{return null}let h;try{let w=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL);h=NT((await(0,mt.getTree)(this.transport,e.owner,e.repo,w.treeSha,this.deps.baseURL)).filter(S=>(0,ks.isSyncablePath)(S.path)))}catch{return null}let p=d.filter(w=>!r.has(w.path)&&h.get(w.path)===w.blobSha);if(p.length>0){let w=p.slice(0,3).map(S=>S.path).join(", ")+(p.length>3?", \u2026":"");return i.push(`first-sync (asset mode): base-tree\u2286working-tree sanity guard fired \u2014 ${p.length} base file(s) absent from the working tree but UNCHANGED on remote head (${w}); the verified-ancestor base may not match the working tree's derivation commit (out-of-band submodule manipulation) \u2192 routing to merge/quarantine instead of inferring a silent deletion (#3610)`),{kind:"settled",outcome:s("full-conflict",{detail:`first-sync: base-tree\u2286working-tree sanity guard \u2014 ${p.length} base file(s) absent from the working tree are unchanged on remote head (${w}); refusing to infer a silent deletion from a base that may not match the derivation commit \u2014 divergence must go through merge/quarantine (A2/A3), never a silent delete (#3610)`})}}let y=d.map(w=>({path:w.path,blobSha:w.blobSha})),_={lastSyncedSha:f.sha,rootTreeSha:f.treeSha,files:y};if(l&&o!==void 0)try{await o.set(e.repoKey,f.sha)}catch{}return i.push(l?`first-sync (asset mode): BACKFILLED the 3-way base from the locally checked-out commit ${f.sha} (no recorded mount base) \u2014 remote head ${t} advanced since; local edits 3-way merge against it instead of false-conflicting (#3590)`:`first-sync (asset mode): reconciling against the recorded mount base ${f.sha} \u2014 remote head ${t} advanced since mount; local edits 3-way merge against it instead of false-conflicting (#3590)`),{kind:"additive-base",base:_}}async bootstrapWatermark(e,t,r,i){let s=await(0,mt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await this.tryMountBaseBootstrap(e,s,t,r,i);if(o!==null)return o;let c=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),l=(await(0,mt.getTree)(this.transport,e.owner,e.repo,c.treeSha,this.deps.baseURL)).filter(h=>(0,ks.isSyncablePath)(h.path)),u=[],f;for(let h of l){let p=t.get(h.path);if(p===void 0||await(0,Cc.gitBlobSha)(p,this.sha1)!==h.blobSha){f===void 0&&(f=h.path);continue}let y=typeof p=="string"?(0,ko.extractAssetUid)(p):void 0;u.push({path:h.path,blobSha:h.blobSha,...y?{uid:y}:{}})}let d={lastSyncedSha:s,rootTreeSha:c.treeSha,files:u};return f!==void 0?this.deps.mergeLayer===void 0?{kind:"settled",outcome:i("full-conflict",{detail:`first-sync: no watermark and local content diverges from remote head at ${f} \u2014 A2/A3 scope`})}:(r.push(`first-sync (asset mode): no 3-way merge base and local diverges from remote head (first at ${f}) \u2014 reconciling ZERO-LOSS against ${u.length} byte-identical file(s) as a synthetic base: remote-only files pull, local-only files push, overlapping divergences route to the merge/quarantine layer (both versions preserved), never a silent overwrite or delete`),{kind:"additive-base",base:d}):t.size===l.length?(await this.deps.watermarkStore.set(e.repoKey,d),r.push(`watermark bootstrapped from head ${s} (local tree identical to remote)`),{kind:"settled",outcome:i("synced")}):(r.push(`first-sync (asset mode): local tree (${t.size} files) is a pure superset of remote head ${s} (${l.length} files) \u2014 ${t.size-l.length} local-only addition(s) derive as pushable adds (#3565)`),{kind:"additive-base",base:d})}async collectRemoteChanges(e,t,r,i,s=new Set,o=[],c=new Set,l){let u=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,r,this.deps.baseURL),f=await(0,mt.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL);if(i.fileMode)for(let v of f)i.syncable(v.path)&&!i.treeFilter(v)&&!c.has(v.path)&&(c.add(v.path),o.push(`skipped oversized REMOTE file ${v.path} (${v.size??"?"} bytes over cap) \u2014 excluded from sync symmetrically (Phase C size cap)`));let d=f.filter(v=>i.treeFilter(v)&&!s.has(v.path)),h=t.files.filter(v=>!c.has(v.path)&&!s.has(v.path)),{changed:p,deleted:y}=DD(h,d),_=p.length;_>=CD&&this.emitProgress(l,e.repoKey,"fetching-blobs",{done:0,total:_});let w=0,S=[];for(let v of p){if(i.fileMode){let x=await(0,mt.getBlobBytes)(this.transport,e.owner,e.repo,v.blobSha,this.deps.baseURL);S.push({path:v.path,kind:"change",blobSha:v.blobSha,content:x})}else{let x=await(0,mt.getBlobText)(this.transport,e.owner,e.repo,v.blobSha,this.deps.baseURL);S.push({path:v.path,kind:"change",blobSha:v.blobSha,content:x,uid:(0,ko.extractAssetUid)(x)})}w+=1,_>=CD&&w%UY===0&&w<_&&this.emitProgress(l,e.repoKey,"fetching-blobs",{done:w,total:_})}for(let v of y)S.push({path:v.path,kind:"delete",uid:v.uid});return{changes:S,headTreeByPath:NT(f)}}matchLocalVsRemote(e,t,r,i,s,o=new Set,c){let l=new Set,u=[],f=new Map;for(let _ of i)_.kind==="change"&&_.uid!==void 0&&f.set(_.uid,(f.get(_.uid)??0)+1);let d=new Set(o);for(let[_,w]of f)w>1&&d.add(_);let h=new Map,p=new Map;for(let _ of i){if(_.uid!==void 0&&!d.has(_.uid)){let w=h.get(_.uid)??[];w.push(_),h.set(_.uid,w)}p.set(_.path,_)}for(let _ of e){let w=new Set;if(_.uid!==void 0&&!d.has(_.uid))for(let I of h.get(_.uid)??[])I.kind==="change"&&I.path!==_.path&&(c?.has(_.path)===!0||_.basePath!==void 0&&c?.has(_.basePath)===!0)||w.add(I);let S=p.get(_.path);if(S!==void 0&&w.add(S),_.basePath!==void 0){let I=p.get(_.basePath);I!==void 0&&w.add(I)}let v=[],x=!1;for(let I of w){if(x=t.has(_.path)&&!r.has(_.path),x&&I.kind==="delete"){l.add(I);continue}if(!x&&I.kind==="change"&&I.path===_.path&&I.blobSha===_.blobSha){l.add(I),s.add(_.path);continue}if(I.kind==="delete"&&_.basePath!==void 0&&I.path===_.basePath){let C=p.get(_.path);if(C!==void 0&&C.kind==="change"&&(C.blobSha===_.blobSha||C.uid!==void 0&&C.uid===_.uid)){l.add(I);continue}}if(I.kind==="delete"&&I.path!==_.path&&I.path!==_.basePath&&!r.has(I.path)&&c?.has(I.path)!==!0){l.add(I);continue}v.push(I),l.add(I)}v.length>0&&(u.push({local:_,localIsDelete:x,remotes:v,desc:`${_.uid!==void 0&&!d.has(_.uid)?_.uid:_.path} (local ${x?"delete":"change"} vs remote ${v[0].kind} at ${v[0].path})`}),s.add(_.path))}let y=i.filter(_=>!l.has(_));return{conflicts:u,applyWrites:y.filter(_=>_.kind==="change"),applyDeletes:y.filter(_=>_.kind==="delete")}}async checkRaceWindow(e,t,r,i,s,o,c,l){try{let u=await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,i,this.deps.baseURL),f=(await(0,mt.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL)).filter(l.treeFilter),d=r===t.lastSyncedSha?t.files:(await(0,mt.getTree)(this.transport,e.owner,e.repo,(await(0,mt.getCommitInfo)(this.transport,e.owner,e.repo,r,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(l.treeFilter),{changed:h,deleted:p}=DD(d,f);for(let y of h)s.has(y.path)&&c.push(`race-window: concurrent commit ${i} changed ${y.path} between conflict check (head ${r}) and push \u2014 local version won; previous version recoverable from git history`),o.has(y.path)&&c.push(`race-window: concurrent commit ${i} changed ${y.path} which this push DELETED \u2014 the delete won; the concurrent version is recoverable from git history`);for(let y of p)s.has(y.path)&&c.push(`race-window: concurrent commit ${i} deleted ${y.path}; push re-created it`)}catch(u){let f=this.deps.redact??(d=>d);c.push(`race-window check failed: ${f(wa(u))}`)}}async buildWatermarkFiles(e,t,r,i,s,o,c){if(c.fileMode)return t.map(f=>({path:f.path,blobSha:f.blobSha}));let l=new Map;for(let f of i)f.kind==="change"&&f.blobSha!==void 0&&l.set(f.blobSha,f.uid);for(let[f,d]of r){let h=o?.get(f)??await(0,Cc.gitBlobSha)(d,this.sha1);l.set(h,typeof d=="string"?(0,ko.extractAssetUid)(d):void 0)}for(let f of s.files)l.has(f.blobSha)||l.set(f.blobSha,f.uid);let u=[];for(let f of t){let d;if(l.has(f.blobSha))d=l.get(f.blobSha);else{let h=await(0,mt.getBlobText)(this.transport,e.owner,e.repo,f.blobSha,this.deps.baseURL);d=(0,ko.extractAssetUid)(h)}u.push({path:f.path,blobSha:f.blobSha,...d?{uid:d}:{}})}return u}};qn.SyncEngine=kT});var kD=T(vd=>{"use strict";Object.defineProperty(vd,"__esModule",{value:!0});vd.QuarantineResolver=void 0;vd.backupPathFor=ND;var KY=Iy(),My=_d(),Sd=hu(),wd=md(),YY=xy(),Ms="\0absent",MT=class{static{a(this,"QuarantineResolver")}constructor(e){this.deps=e}async listOpenConflicts(e){let t=[];for(let r of e)t.push(...await this.listRepoConflicts(r));return t}async listRepoConflicts(e){if(e.spaceKind==="file")return[];let t=await this.deps.watermarkStore.get(e.repoKey),r=t?.pinnedPaths??[];if(r.length===0)return[];if(this.deps.outbox!==void 0){let p=await this.deps.outbox.listForRepo(e.repoKey);if(p.length>0){let y=new Set(p.map(_=>_.path));if(r=r.filter(_=>!y.has(_)),r.length===0)return[]}}let i=new Map;for(let p of t?.files??[])i.set(p.path,p.blobSha);let s=this.deps.conflictCache!==void 0,o=await this.cachedRecordsFor(e,r),c=r.some(p=>!o.has(p)),l=new Map,u=!0;if(c)if(s)try{l=await this.remoteTreeShas(e)}catch{u=!1}else l=await this.remoteTreeShas(e);let f=this.deps.localFilesFor(e),d=new Set(await f.list()),h=[];for(let p of r){let y=o.get(p),_,w;if(y!==void 0)w=y.remoteContent!==void 0?await(0,Sd.gitBlobSha)(y.remoteContent,this.deps.sha1):Ms,_=y.baseContent!==void 0?await(0,Sd.gitBlobSha)(y.baseContent,this.deps.sha1):i.get(p)??Ms;else{if(!u)continue;w=l.get(p)??Ms,_=i.get(p)??Ms}let S=Ms,v;if(d.has(p)&&(v=await f.read(p),S=await(0,Sd.gitBlobSha)(v,this.deps.sha1)),!(S!==w&&S!==_&&w!==_))continue;let I=(v!==void 0?(0,wd.extractAssetUid)(v):void 0)??y?.uid;h.push({repoKey:e.repoKey,path:p,...I!==void 0?{uid:I}:{},hasLocal:S!==Ms,hasRemote:w!==Ms})}return h}async cachedRecordsFor(e,t){let r=new Map,i=this.deps.conflictCache;if(i===void 0)return r;for(let s of t){let o=await i.get(e.repoKey,s);o!==null&&r.set(s,o)}return r}async detectDuplicateUids(e){let t=new Map;for(let i of e){let s=this.deps.localFilesFor(i);for(let o of await s.list()){if(!o.endsWith(".md"))continue;let c;try{c=await s.read(o)}catch{continue}let l=(0,wd.extractAssetUid)(c);l!==void 0&&t.set(l,(t.get(l)??0)+1)}}let r=0;for(let i of t.values())i>1&&r++;return r}async loadConflict(e,t){let r=this.deps.localFilesFor(e),s=new Set(await r.list()).has(t)?await r.read(t):void 0,o=await this.deps.conflictCache?.get(e.repoKey,t)??null,c,l;if(o!==null)c=o.remoteContent,l=o.baseContent;else{let d=(await this.remoteTreeShas(e)).get(t);c=d!==void 0?await this.blobText(e,d):void 0;let p=((await this.deps.watermarkStore.get(e.repoKey))?.files??[]).find(y=>y.path===t)?.blobSha;if(p!==void 0)try{l=await this.blobText(e,p)}catch{l=void 0}}let u=(s!==void 0?(0,wd.extractAssetUid)(s):void 0)??(c!==void 0?(0,wd.extractAssetUid)(c):void 0)??o?.uid;return{repoKey:e.repoKey,path:t,...u!==void 0?{uid:u}:{},hasLocal:s!==void 0,hasRemote:c!==void 0,...l!==void 0?{base:l}:{},...s!==void 0?{local:s}:{},...c!==void 0?{remote:c}:{}}}async resolve(e,t,r){let i=this.deps.localFilesFor(e),o=new Set(await i.list()).has(t)?await i.read(t):void 0,c=this.deps.outbox!==void 0,{remote:l,remoteSha:u}=c?await this.remoteForResolve(e,t):await this.liveRemoteForResolve(e,t),f=this.chosenContent(r,o,l),d;r.take!=="local"&&o!==void 0&&o!==f&&(d=ND(t),await i.write(d,o)),f===void 0?await i.delete(t):await i.write(t,f);let p=f===void 0&&l===void 0||f===l;if(c&&this.deps.outbox!==void 0&&!p&&f!==void 0)return await this.deps.outbox.enqueue({repoKey:e.repoKey,path:t,chosenContent:f,resolvedTo:r.take==="merged"?"merged":"local",baseRemoteSha:u===Ms?YY.OUTBOX_REMOTE_ABSENT:u,resolvedAt:""}),{repoKey:e.repoKey,path:t,resolvedTo:r.take,awaitingPush:!0,...d!==void 0?{discardedLocalBackupPath:d}:{}};let y;return p||(y=await this.commitChoice(e,t,f)),await this.snapWatermark(e,t,f),this.deps.quarantine?.markResolved!==void 0&&await this.deps.quarantine.markResolved(e.repoKey,t),{repoKey:e.repoKey,path:t,resolvedTo:r.take,...y!==void 0?{pushedSha:y}:{},...d!==void 0?{discardedLocalBackupPath:d}:{}}}async remoteForResolve(e,t){let r=await this.deps.conflictCache?.get(e.repoKey,t)??null;if(r!==null){let i=r.remoteContent,s=i!==void 0?await(0,Sd.gitBlobSha)(i,this.deps.sha1):Ms;return{remote:i,remoteSha:s}}return this.liveRemoteForResolve(e,t)}async liveRemoteForResolve(e,t){let i=(await this.remoteTreeShas(e)).get(t);return{remote:i!==void 0?await this.blobText(e,i):void 0,remoteSha:i??Ms}}chosenContent(e,t,r){switch(e.take){case"local":if(t===void 0)throw new Error("resolve: cannot keep local \u2014 no local version exists on disk");return t;case"remote":return r;case"merged":return e.content}}async commitChoice(e,t,r){let i=this.deps.commitMessage?.(e,t)??`chore(exosync): resolve conflict for ${t}`;if(r===void 0)throw new Error(`resolve: cannot push an empty resolution for ${t}`);return(0,KY.restCreateCommit)(this.deps.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([[t,r]]),message:i,...this.deps.baseURL!==void 0?{baseURL:this.deps.baseURL}:{},...this.deps.redact!==void 0?{redact:this.deps.redact}:{}})}async snapWatermark(e,t,r){let i=await this.deps.watermarkStore.get(e.repoKey);if(i===null)return;let s=(i.pinnedPaths??[]).filter(c=>c!==t),o=i.files;if(r===void 0)o=o.filter(c=>c.path!==t);else{let c=await(0,Sd.gitBlobSha)(r,this.deps.sha1),l=(0,wd.extractAssetUid)(r),u={path:t,blobSha:c,...l!==void 0?{uid:l}:{}},f=o.findIndex(d=>d.path===t);o=f>=0?o.map((d,h)=>h===f?u:d):[...o,u]}await this.deps.watermarkStore.set(e.repoKey,{...i,files:o,...s.length>0?{pinnedPaths:s}:{pinnedPaths:void 0}})}async remoteTreeShas(e){let t=await(0,My.getHeadSha)(this.deps.transport,e.owner,e.repo,e.branch,this.deps.baseURL),r=await(0,My.getCommitInfo)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,My.getTree)(this.deps.transport,e.owner,e.repo,r.treeSha,this.deps.baseURL),s=new Map;for(let o of i)s.set(o.path,o.blobSha);return s}async blobText(e,t){return(0,My.getBlobText)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL)}};vd.QuarantineResolver=MT;function ND(n){return`${n}.conflict.local.txt`}a(ND,"backupPathFor")});var MD=T(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});pu.FileLocalManifestStore=pu.LOCAL_MANIFEST_STORE_FILENAME=void 0;pu.LOCAL_MANIFEST_STORE_FILENAME="exosync-localmanifest.local.json";function QY(n){if(n===null||typeof n!="object")return!1;let e=n;return e.version===1&&typeof e.lastFullRehashMs=="number"&&e.files!==null&&typeof e.files=="object"}a(QY,"isLocalManifestRecord");var jT=class{static{a(this,"FileLocalManifestStore")}constructor(e){this.io=e,this.writeChain=Promise.resolve()}async get(e){let r=(await this.readRepos())[e];return QY(r)?r:null}async set(e,t){let r=this.writeChain.then(async()=>{let i=await this.readRepos();i[e]=t;let s={version:1,repos:i};await this.io.writeAtomic(JSON.stringify(s))});return this.writeChain=r.catch(()=>{}),r}async readRepos(){try{let e=await this.io.read();if(e===null)return{};let t=JSON.parse(e);if(t===null||typeof t!="object")return{};let r=t.repos;return r===null||typeof r!="object"?{}:{...r}}catch{return{}}}};pu.FileLocalManifestStore=jT});var BT=T(UT=>{"use strict";Object.defineProperty(UT,"__esModule",{value:!0});UT.diff3=XY;function jD(n,e){let t=n.length,r=e.length,i=Array.from({length:t+1},()=>new Int32Array(r+1));for(let l=t-1;l>=0;l--)for(let u=r-1;u>=0;u--)i[l][u]=n[l]===e[u]?i[l+1][u+1]+1:Math.max(i[l+1][u],i[l][u+1]);let s=new Map,o=0,c=0;for(;o<t&&c<r;)n[o]===e[c]?(s.set(o,c),o++,c++):i[o+1][c]>=i[o][c+1]?o++:c++;return s}a(jD,"lcsMatch");function $T(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}a($T,"sliceEq");function XY(n,e,t){let r=jD(n,e),i=jD(n,t),s=[],o=0,c=0,l=0;for(;;){let u=o;for(;u<n.length&&!(r.has(u)&&i.has(u));)u++;let f=u<n.length?r.get(u):e.length,d=u<n.length?i.get(u):t.length,h=n.slice(o,u),p=e.slice(c,f),y=t.slice(l,d),_=!$T(p,h),w=!$T(y,h);if(!_&&!w)s.push(...h);else if(!_)s.push(...y);else if(!w)s.push(...p);else if($T(p,y))s.push(...p);else return{ok:!1,conflict:{base:h,local:p,remote:y}};if(u>=n.length)break;s.push(n[u]),o=u+1,c=f+1,l=d+1}return{ok:!0,merged:s}}a(XY,"diff3")});var UD=T(Ad=>{"use strict";Object.defineProperty(Ad,"__esModule",{value:!0});Ad.StructuredMerger=void 0;Ad.splitSections=jy;var $D=BT(),JY=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,Ed="exo__Instance_class";function Td(n){if(n===null||typeof n!="object")return!0;if(Array.isArray(n))return n.every(Td);let e=Object.getPrototypeOf(n);return e!==Object.prototype&&e!==null?!1:Object.values(n).every(Td)}a(Td,"isPlainValue");function va(n,e){if(n===e)return!0;if(n===null||e===null||n===void 0||e===void 0||typeof n!="object"||typeof e!="object"||Array.isArray(n)!==Array.isArray(e))return!1;if(Array.isArray(n)&&Array.isArray(e))return n.length!==e.length?!1:n.every((s,o)=>va(s,e[o]));let t=n,r=e,i=Object.keys(t);return i.length!==Object.keys(r).length?!1:i.every(s=>va(t[s],r[s]))}a(va,"deepEqual");function xc(n){return typeof n=="string"?`s:${n}`:`j:${JSON.stringify(n)}`}a(xc,"setKey");function hi(n){return n==null?[]:Array.isArray(n)?n:[n]}a(hi,"toElements");function ZY(n,e,t){let r=new Set(hi(n).map(xc)),i=hi(e),s=hi(t),o=new Set(i.map(xc)),c=new Set(s.map(xc)),l=a(d=>o.has(d)&&c.has(d)||o.has(d)&&!r.has(d)||c.has(d)&&!r.has(d),"keep"),u=[],f=new Set;for(let d of[...i,...s]){let h=xc(d);f.has(h)||!l(h)||(f.add(h),u.push(d))}return u}a(ZY,"mergeSet");function eQ(n,e,t){let r=[],i=[],s=new Set;for(let c of[...Object.keys(n),...Object.keys(e),...Object.keys(t)])s.has(c)||(s.add(c),i.push(c));let o={};for(let c of i){let l=n[c],u=e[c],f=t[c];if(!Td(l)||!Td(u)||!Td(f))return{ok:!1,reason:`frontmatter key "${c}" contains a non-plain value (Date?) \u2014 the codec must round-trip scalars as strings (CORE_SCHEMA contract)`};if(Array.isArray(l)||Array.isArray(u)||Array.isArray(f)){if(!(c in e)&&!(c in t))continue;let d=ZY(l,u,f),h=new Set(hi(l).map(xc)),p=hi(u).some(_=>!h.has(xc(_))),y=hi(f).some(_=>!h.has(xc(_)));p&&y&&!va(hi(u),hi(f))&&r.push(`both sides added values to multi-valued key "${c}" \u2014 union kept (D20)`),d.length>0&&(o[c]=d);continue}if(va(u,f)){u!==void 0&&(o[c]=u);continue}if(va(u,l)){f!==void 0&&(o[c]=f);continue}if(va(f,l)){u!==void 0&&(o[c]=u);continue}return{ok:!1,reason:`frontmatter key "${c}" changed differently on both sides`}}return{ok:!0,value:o,warnings:r}}a(eQ,"mergeFrontmatter");var tQ=/^(```|~~~)/,rQ=/^#{1,6}\s/;function jy(n){let e=n.split(`
310
310
  `),t=[],r=null,i="",s=!1,o=a(()=>{r!==null&&t.push({heading:i,text:r.join(`
311
311
  `)})},"flush");for(let c of e){if(tQ.test(c.trimStart())&&(s=!s),!s&&rQ.test(c)){o(),r=[c],i=c.trim();continue}r===null&&(r=[],i=""),r.push(c)}return o(),t}a(jy,"splitSections");function VT(n){return n.split(/\n{2,}/)}a(VT,"splitParagraphs");function nQ(n){return n.join(`
312
312
 
@@ -602,7 +602,7 @@ Duplicate bindings (${n.duplicates.length}) \u2014 uid claimed by >1 test (warni
602
602
  Skipped floor check for ${n.unknownPriority} requirement(s) with unparseable priority (fail-open).`),n.clean?e==="hard"&&!n.rampReady?console.error(`
603
603
  FAIL (hard gate): ramp not ready \u2014 ${n.p0Orphans} P0 requirement(s) unbound`+(n.p0Total===0?" (no P0 requirements found)":"")+"."):console.log(`
604
604
  OK: no hard findings (dangling tags + binding-class floor are clean).`):console.error(`
605
- FAIL: ${n.dangling.length} dangling + ${n.floorViolations.length} floor violation(s) + ${n.activeViolations.length} active-requirement invariant violation(s) + ${n.danglingEvidence.length} dangling evidence link(s).`)}a(Woe,"renderText");function Hoe(n,e,t){return!n.clean||t&&n.orphans.length>0||e==="hard"&&!n.rampReady}a(Hoe,"isHardFail");function k9(){return new $e("audit").description("Audit requirement\u2194test traceability: orphans, dangling @req tags, duplicate bindings, binding-class floor, coverage, P0 ramp-readiness").requiredOption("--reqs <path>","Directory tree containing req__Requirement assets (a vault or a reqs assetspace clone)").option("--tests <path>","Test-corpus root scanned for @req:<uid> tags",".").option("--output <type>","Response format: text|json","text").option("--strict","Also exit 1 on orphan requirements",!1).option("--gate <mode>","Gate mode: soft (warn only on hard findings) | hard (also block when the P0 checklist is not ramp-ready)","soft").action(async n=>{let e=n.output??"text";Ae.setFormat(e);let t=n.gate==="hard"?"hard":"soft";try{let r=(0,Ua.resolve)(n.reqs);if(!(0,Ba.existsSync)(r)||!(0,Ba.statSync)(r).isDirectory())throw new tt(r);let i=(0,Ua.resolve)(n.tests??".");if(!(0,Ba.existsSync)(i)||!(0,Ba.statSync)(i).isDirectory())throw new tt(i);let[s,o]=await Promise.all([Uoe(r),Voe(i)]),c=qoe(s,o);e==="json"?console.log(JSON.stringify({...c,gate:t},null,2)):Woe(c,t),Hoe(c,t,n.strict===!0)&&(process.exitCode=1)}catch(r){Ae.handle(r)}})}a(k9,"requirementsAuditCommand");function M9(){let n=new $e("requirements").description("Requirements-management tooling (RFC 0003): traceability checker");return n.addCommand(k9()),n}a(M9,"requirementsCommand");function F_(n){let e=new $e;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(n??"16.184.6"),e.addCommand(xj()),e.addCommand($j()),e.addCommand(I4()),e.addCommand(x4()),e.addCommand(Y4()),e.addCommand(P4()),e.addCommand(M4()),e.addCommand(rj()),e.addCommand(aj()),e.addCommand(yj()),e.addCommand(Rj()),e.addCommand(n9()),e.addCommand(o9()),e.addCommand(v9()),e.addCommand(T9()),e.addCommand(R9()),e.addCommand(O9()),e.addCommand(D9()),e.addCommand(h9()),e.addCommand(b9()),e.addCommand(M9()),e}a(F_,"createProgram");F_().parse();0&&(module.exports={createProgram});
605
+ FAIL: ${n.dangling.length} dangling + ${n.floorViolations.length} floor violation(s) + ${n.activeViolations.length} active-requirement invariant violation(s) + ${n.danglingEvidence.length} dangling evidence link(s).`)}a(Woe,"renderText");function Hoe(n,e,t){return!n.clean||t&&n.orphans.length>0||e==="hard"&&!n.rampReady}a(Hoe,"isHardFail");function k9(){return new $e("audit").description("Audit requirement\u2194test traceability: orphans, dangling @req tags, duplicate bindings, binding-class floor, coverage, P0 ramp-readiness").requiredOption("--reqs <path>","Directory tree containing req__Requirement assets (a vault or a reqs assetspace clone)").option("--tests <path>","Test-corpus root scanned for @req:<uid> tags",".").option("--output <type>","Response format: text|json","text").option("--strict","Also exit 1 on orphan requirements",!1).option("--gate <mode>","Gate mode: soft (warn only on hard findings) | hard (also block when the P0 checklist is not ramp-ready)","soft").action(async n=>{let e=n.output??"text";Ae.setFormat(e);let t=n.gate==="hard"?"hard":"soft";try{let r=(0,Ua.resolve)(n.reqs);if(!(0,Ba.existsSync)(r)||!(0,Ba.statSync)(r).isDirectory())throw new tt(r);let i=(0,Ua.resolve)(n.tests??".");if(!(0,Ba.existsSync)(i)||!(0,Ba.statSync)(i).isDirectory())throw new tt(i);let[s,o]=await Promise.all([Uoe(r),Voe(i)]),c=qoe(s,o);e==="json"?console.log(JSON.stringify({...c,gate:t},null,2)):Woe(c,t),Hoe(c,t,n.strict===!0)&&(process.exitCode=1)}catch(r){Ae.handle(r)}})}a(k9,"requirementsAuditCommand");function M9(){let n=new $e("requirements").description("Requirements-management tooling (RFC 0003): traceability checker");return n.addCommand(k9()),n}a(M9,"requirementsCommand");function F_(n){let e=new $e;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(n??"16.184.7"),e.addCommand(xj()),e.addCommand($j()),e.addCommand(I4()),e.addCommand(x4()),e.addCommand(Y4()),e.addCommand(P4()),e.addCommand(M4()),e.addCommand(rj()),e.addCommand(aj()),e.addCommand(yj()),e.addCommand(Rj()),e.addCommand(n9()),e.addCommand(o9()),e.addCommand(v9()),e.addCommand(T9()),e.addCommand(R9()),e.addCommand(O9()),e.addCommand(D9()),e.addCommand(h9()),e.addCommand(b9()),e.addCommand(M9()),e}a(F_,"createProgram");F_().parse();0&&(module.exports={createProgram});
606
606
  /*! Bundled license information:
607
607
 
608
608
  reflect-metadata/Reflect.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitelev/exocortex-cli",
3
- "version": "16.184.6",
3
+ "version": "16.184.7",
4
4
  "description": "CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more",
5
5
  "main": "dist/index.js",
6
6
  "bin": {