@legit-sdk/core 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Nils Jacobsen, Jannes Blobel, Martin Lysk
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/dist/index.js CHANGED
@@ -84,7 +84,7 @@ gpgsig`+av(o)+`
84
84
  `,author:h,committer:c,signingKey:d})}i(nQ,"_addNote");async function TB({fs:e,onSign:t,dir:r,gitdir:n=Re(r,".git"),ref:a="refs/notes/commits",oid:s,note:o,force:f,author:h,committer:c,signingKey:d,cache:p={}}){try{ae("fs",e),ae("gitdir",n),ae("oid",s),ae("note",o),d&&ae("onSign",t);let m=new Le(e),g=await Co({fs:m,gitdir:n,author:h});if(!g)throw new ur("author");let b=await bl({fs:m,gitdir:n,author:g,committer:c});if(!b)throw new ur("committer");return await nQ({fs:new Le(m),cache:p,onSign:t,gitdir:n,ref:a,oid:s,note:o,force:f,author:g,committer:b,signingKey:d})}catch(m){throw m.caller="git.addNote",m}}i(TB,"addNote");var iQ=/(^|[/.])([/.]|$)|^@$|@{|[\x00-\x20\x7f~^:?*[\\]|\.lock(\/|$)/;function Iu(e,t){if(typeof e!="string")throw new TypeError("Reference name must be a string");return!iQ.test(e)&&(!!t||e.includes("/"))}i(Iu,"isValidRef");async function FB({fs:e,gitdir:t,remote:r,url:n,force:a}){if(!Iu(r,!0))throw new Tn(r,hu.clean(r));let s=await xt.get({fs:e,gitdir:t});if(!a&&(await s.getSubsections("remote")).includes(r)&&n!==await s.get(`remote.${r}.url`))throw new Rn("remote",r);await s.set(`remote.${r}.url`,n),await s.set(`remote.${r}.fetch`,`+refs/heads/*:refs/remotes/${r}/*`),await xt.save({fs:e,gitdir:t,config:s})}i(FB,"_addRemote");async function xB({fs:e,dir:t,gitdir:r=Re(t,".git"),remote:n,url:a,force:s=!1}){try{return ae("fs",e),ae("gitdir",r),ae("remote",n),ae("url",a),await FB({fs:new Le(e),gitdir:r,remote:n,url:a,force:s})}catch(o){throw o.caller="git.addRemote",o}}i(xB,"addRemote");async function oQ({fs:e,cache:t,onSign:r,gitdir:n,ref:a,tagger:s,message:o=a,gpgsig:f,object:h,signingKey:c,force:d=!1}){if(a=a.startsWith("refs/tags/")?a:`refs/tags/${a}`,!d&&await Pe.exists({fs:e,gitdir:n,ref:a}))throw new Rn("tag",a);let p=await Pe.resolve({fs:e,gitdir:n,ref:h||"HEAD"}),{type:m}=await dt({fs:e,cache:t,gitdir:n,oid:p}),g=zr.from({object:p,type:m,tag:a.replace("refs/tags/",""),tagger:s,message:o,gpgsig:f});c&&(g=await zr.sign(g,r,c));let b=await Br({fs:e,gitdir:n,type:"tag",object:g.toObject()});await Pe.writeRef({fs:e,gitdir:n,ref:a,value:b})}i(oQ,"_annotatedTag");async function OB({fs:e,onSign:t,dir:r,gitdir:n=Re(r,".git"),ref:a,tagger:s,message:o=a,gpgsig:f,object:h,signingKey:c,force:d=!1,cache:p={}}){try{ae("fs",e),ae("gitdir",n),ae("ref",a),c&&ae("onSign",t);let m=new Le(e),g=await Co({fs:m,gitdir:n,author:s});if(!g)throw new ur("tagger");return await oQ({fs:m,cache:p,onSign:t,gitdir:n,ref:a,tagger:g,message:o,gpgsig:f,object:h,signingKey:c,force:d})}catch(m){throw m.caller="git.annotatedTag",m}}i(OB,"annotatedTag");async function aQ({fs:e,gitdir:t,ref:r,object:n,checkout:a=!1,force:s=!1}){if(!Iu(r,!0))throw new Tn(r,hu.clean(r));let o=`refs/heads/${r}`;if(!s&&await Pe.exists({fs:e,gitdir:t,ref:o}))throw new Rn("branch",r,!1);let f;try{f=await Pe.resolve({fs:e,gitdir:t,ref:n||"HEAD"})}catch{}f&&await Pe.writeRef({fs:e,gitdir:t,ref:o,value:f}),a&&await Pe.writeSymbolicRef({fs:e,gitdir:t,ref:"HEAD",value:o})}i(aQ,"_branch");async function IB({fs:e,dir:t,gitdir:r=Re(t,".git"),ref:n,object:a,checkout:s=!1,force:o=!1}){try{return ae("fs",e),ae("gitdir",r),ae("ref",n),await aQ({fs:new Le(e),gitdir:r,ref:n,object:a,checkout:s,force:o})}catch(f){throw f.caller="git.branch",f}}i(IB,"branch");var PB=i((e,t)=>e==="."||t==null||t.length===0||t==="."?!0:t.length>=e.length?t.startsWith(e):e.startsWith(t),"worthWalking");async function Fv({fs:e,cache:t,onProgress:r,onPostCheckout:n,dir:a,gitdir:s,remote:o,ref:f,filepaths:h,noCheckout:c,noUpdateHead:d,dryRun:p,force:m,track:g=!0,nonBlocking:b=!1,batchSize:v=100}){let _;if(n)try{_=await Pe.resolve({fs:e,gitdir:s,ref:"HEAD"})}catch{_="0000000000000000000000000000000000000000"}let E;try{E=await Pe.resolve({fs:e,gitdir:s,ref:f})}catch(R){if(f==="HEAD")throw R;let T=`${o}/${f}`;if(E=await Pe.resolve({fs:e,gitdir:s,ref:T}),g){let F=await xt.get({fs:e,gitdir:s});await F.set(`branch.${f}.remote`,o),await F.set(`branch.${f}.merge`,`refs/heads/${f}`),await xt.save({fs:e,gitdir:s,config:F})}await Pe.writeRef({fs:e,gitdir:s,ref:`refs/heads/${f}`,value:E})}if(!c){let R;try{R=await sQ({fs:e,cache:t,onProgress:r,dir:a,gitdir:s,ref:f,force:m,filepaths:h})}catch(I){throw I instanceof st&&I.data.what===E?new wu(f,E):I}let T=R.filter(([I])=>I==="conflict").map(([I,D])=>D);if(T.length>0)throw new gu(T);let F=R.filter(([I])=>I==="error").map(([I,D])=>D);if(F.length>0)throw new Ue(F.join(", "));if(p){n&&await n({previousHead:_,newHead:E,type:h!=null&&h.length>0?"file":"branch"});return}let S=0,k=R.length;if(await It.acquire({fs:e,gitdir:s,cache:t},async function(I){await Promise.all(R.filter(([D])=>D==="delete"||D==="delete-index").map(async function([D,L]){let C=`${a}/${L}`;D==="delete"&&await e.rm(C),I.delete({filepath:L}),r&&await r({phase:"Updating workdir",loaded:++S,total:k})}))}),await It.acquire({fs:e,gitdir:s,cache:t},async function(I){for(let[D,L]of R)if(D==="rmdir"||D==="rmdir-index"){let C=`${a}/${L}`;try{D==="rmdir"&&await e.rmdir(C),I.delete({filepath:L}),r&&await r({phase:"Updating workdir",loaded:++S,total:k})}catch(j){if(j.code==="ENOTEMPTY")console.log(`Did not delete ${L} because directory is not empty`);else throw j}}}),await Promise.all(R.filter(([I])=>I==="mkdir"||I==="mkdir-index").map(async function([I,D]){let L=`${a}/${D}`;await e.mkdir(L),r&&await r({phase:"Updating workdir",loaded:++S,total:k})})),b){let I=R.filter(([L])=>L==="create"||L==="create-index"||L==="update"||L==="mkdir-index"),D=await Zk("Update Working Dir",I.map(([L,C,j,q,J])=>()=>fQ({fs:e,cache:t,gitdir:s,dir:a},[L,C,j,q,J])),r,v);await It.acquire({fs:e,gitdir:s,cache:t,allowUnmerged:!0},async function(L){await Zk("Update Index",D.map(([C,j,q])=>()=>lQ({index:L,fullpath:C,oid:j,stats:q})),r,v)})}else await It.acquire({fs:e,gitdir:s,cache:t,allowUnmerged:!0},async function(I){await Promise.all(R.filter(([D])=>D==="create"||D==="create-index"||D==="update"||D==="mkdir-index").map(async function([D,L,C,j,q]){let J=`${a}/${L}`;try{if(D!=="create-index"&&D!=="mkdir-index"){let{object:se}=await dt({fs:e,cache:t,gitdir:s,oid:C});if(q&&await e.rm(J),j===33188)await e.write(J,se);else if(j===33261)await e.write(J,se,{mode:511});else if(j===40960)await e.writelink(J,se);else throw new Ue(`Invalid mode 0o${j.toString(8)} detected in blob ${C}`)}let K=await e.lstat(J);j===33261&&(K.mode=493),D==="mkdir-index"&&(K.mode=57344),I.insert({filepath:L,stats:K,oid:C}),r&&await r({phase:"Updating workdir",loaded:++S,total:k})}catch(K){console.log(K)}}))});n&&await n({previousHead:_,newHead:E,type:h!=null&&h.length>0?"file":"branch"})}if(!d){let R=await Pe.expand({fs:e,gitdir:s,ref:f});R.startsWith("refs/heads")?await Pe.writeSymbolicRef({fs:e,gitdir:s,ref:"HEAD",value:R}):await Pe.writeRef({fs:e,gitdir:s,ref:"HEAD",value:E})}}i(Fv,"_checkout");async function sQ({fs:e,cache:t,onProgress:r,dir:n,gitdir:a,ref:s,force:o,filepaths:f}){let h=0;return ko({fs:e,cache:t,dir:n,gitdir:a,trees:[qr({ref:s}),Al(),Ba()],map:i(async function(c,[d,p,m]){if(c===".")return;if(f&&!f.some(b=>PB(c,b)))return null;switch(r&&await r({phase:"Analyzing workdir",loaded:++h}),[!!m,!!d,!!p].map(Number).join("")){case"000":return;case"001":return o&&f&&f.includes(c)?["delete",c]:void 0;case"010":switch(await d.type()){case"tree":return["mkdir",c];case"blob":return["create",c,await d.oid(),await d.mode()];case"commit":return["mkdir-index",c,await d.oid(),await d.mode()];default:return["error",`new entry Unhandled type ${await d.type()}`]}case"011":switch(`${await d.type()}-${await p.type()}`){case"tree-tree":return;case"tree-blob":case"blob-tree":return["conflict",c];case"blob-blob":return await d.oid()!==await p.oid()?o?["update",c,await d.oid(),await d.mode(),await d.mode()!==await p.mode()]:["conflict",c]:await d.mode()!==await p.mode()?o?["update",c,await d.oid(),await d.mode(),!0]:["conflict",c]:["create-index",c,await d.oid(),await d.mode()];case"commit-tree":return;case"commit-blob":return["conflict",c];default:return["error",`new entry Unhandled type ${d.type}`]}case"100":return["delete-index",c];case"101":switch(await m.type()){case"tree":return["rmdir-index",c];case"blob":return await m.oid()!==await p.oid()?o?["delete",c]:["conflict",c]:["delete",c];case"commit":return["rmdir-index",c];default:return["error",`delete entry Unhandled type ${await m.type()}`]}case"110":case"111":switch(`${await m.type()}-${await d.type()}`){case"tree-tree":return;case"blob-blob":{if(await m.oid()===await d.oid()&&await m.mode()===await d.mode()&&!o)return;if(p){if(await p.oid()!==await m.oid()&&await p.oid()!==await d.oid())return o?["update",c,await d.oid(),await d.mode(),await d.mode()!==await p.mode()]:["conflict",c]}else if(o)return["update",c,await d.oid(),await d.mode(),await d.mode()!==await m.mode()];return await d.mode()!==await m.mode()?["update",c,await d.oid(),await d.mode(),!0]:await d.oid()!==await m.oid()?["update",c,await d.oid(),await d.mode(),!1]:void 0}case"tree-blob":return["update-dir-to-blob",c,await d.oid()];case"blob-tree":return["update-blob-to-tree",c];case"commit-commit":return["mkdir-index",c,await d.oid(),await d.mode()];default:return["error",`update entry Unhandled type ${await m.type()}-${await d.type()}`]}}},"map"),reduce:i(async function(c,d){return d=gB(d),c?c&&c[0]==="rmdir"?(d.push(c),d):(d.unshift(c),d):d},"reduce")})}i(sQ,"analyze");async function lQ({index:e,fullpath:t,stats:r,oid:n}){try{e.insert({filepath:t,stats:r,oid:n})}catch(a){console.warn(`Error inserting ${t} into index:`,a)}}i(lQ,"updateIndex");async function fQ({fs:e,cache:t,gitdir:r,dir:n},[a,s,o,f,h]){let c=`${n}/${s}`;if(a!=="create-index"&&a!=="mkdir-index"){let{object:p}=await dt({fs:e,cache:t,gitdir:r,oid:o});if(h&&await e.rm(c),f===33188)await e.write(c,p);else if(f===33261)await e.write(c,p,{mode:511});else if(f===40960)await e.writelink(c,p);else throw new Ue(`Invalid mode 0o${f.toString(8)} detected in blob ${o}`)}let d=await e.lstat(c);return f===33261&&(d.mode=493),a==="mkdir-index"&&(d.mode=57344),[s,o,d]}i(fQ,"updateWorkingDir");async function Zk(e,t,r,n){let a=[];try{for(let s=0;s<t.length;s+=n){let o=t.slice(s,s+n).map(h=>h());(await Promise.allSettled(o)).forEach(h=>{h.status==="fulfilled"&&a.push(h.value)}),r&&await r({phase:"Updating workdir",loaded:s+o.length,total:t.length})}return a}catch(s){console.error(`Error during ${e}: ${s}`)}return a}i(Zk,"batchAllSettled");async function xv({fs:e,onProgress:t,onPostCheckout:r,dir:n,gitdir:a=Re(n,".git"),remote:s="origin",ref:o,filepaths:f,noCheckout:h=!1,noUpdateHead:c=o===void 0,dryRun:d=!1,force:p=!1,track:m=!0,cache:g={},nonBlocking:b=!1,batchSize:v=100}){try{ae("fs",e),ae("dir",n),ae("gitdir",a);let _=o||"HEAD";return await Fv({fs:new Le(e),cache:g,onProgress:t,onPostCheckout:r,dir:n,gitdir:a,remote:s,ref:_,filepaths:f,noCheckout:h,noUpdateHead:c,dryRun:d,force:p,track:m,nonBlocking:b,batchSize:v})}catch(_){throw _.caller="git.checkout",_}}i(xv,"checkout");var uQ=/^refs\/(heads\/|tags\/|remotes\/)?(.*)/;function Oa(e){let t=uQ.exec(e);return t?t[1]==="remotes/"&&e.endsWith("/HEAD")?t[2].slice(0,-5):t[2]:e}i(Oa,"abbreviateRef");async function Do({fs:e,gitdir:t,fullname:r=!1,test:n=!1}){let a=await Pe.resolve({fs:e,gitdir:t,ref:"HEAD",depth:2});if(n)try{await Pe.resolve({fs:e,gitdir:t,ref:a})}catch{return}if(a.startsWith("refs/"))return r?a:Oa(a)}i(Do,"_currentBranch");function cQ(e){return e=e.replace(/^git@([^:]+):/,"https://$1/"),e=e.replace(/^ssh:\/\//,"https://"),e}i(cQ,"translateSSHtoHTTP");function kB({username:e="",password:t=""}){return`Basic ${Buffer.from(`${e}:${t}`).toString("base64")}`}i(kB,"calculateBasicAuthHeader");async function Bu(e,t){let r=pB(e);for(;;){let{value:n,done:a}=await r.next();if(n&&await t(n),a)break}r.return&&r.return()}i(Bu,"forAwait");async function kd(e){let t=0,r=[];await Bu(e,s=>{r.push(s),t+=s.byteLength});let n=new Uint8Array(t),a=0;for(let s of r)n.set(s,a),a+=s.byteLength;return n}i(kd,"collect");function Qk(e){let t=e.match(/^https?:\/\/([^/]+)@/);if(t==null)return{url:e,auth:{}};t=t[1];let[r,n]=t.split(":");return e=e.replace(`${t}@`,""),{url:e,auth:{username:r,password:n}}}i(Qk,"extractAuthFromUrl");function Av(e,t){let r=t.toString(16);return"0".repeat(e-r.length)+r}i(Av,"padHex");var Hv=class Hv{static flush(){return Buffer.from("0000","utf8")}static delim(){return Buffer.from("0001","utf8")}static encode(t){typeof t=="string"&&(t=Buffer.from(t));let r=t.length+4,n=Av(4,r);return Buffer.concat([Buffer.from(n,"utf8"),t])}static streamReader(t){let r=new Od(t);return i(async function(){try{let a=await r.read(4);if(a==null)return!0;if(a=parseInt(a.toString("utf8"),16),a===0||a===1)return null;let s=await r.read(a-4);return s??!0}catch(a){return t.error=a,!0}},"read")}};i(Hv,"GitPktLine");var bt=Hv;async function eB(e){let t={},r;for(;r=await e(),r!==!0;){if(r===null)continue;r=r.toString("utf8").replace(/\n$/,"");let n=r.indexOf("=");if(n>-1){let a=r.slice(0,n),s=r.slice(n+1);t[a]=s}else t[r]=!0}return{protocolVersion:2,capabilities2:t}}i(eB,"parseCapabilitiesV2");async function tB(e,{service:t}){let r=new Set,n=new Map,a=new Map,s=bt.streamReader(e),o=await s();for(;o===null;)o=await s();if(o===!0)throw new bu;if(o.includes("version 2"))return eB(s);if(o.toString("utf8").replace(/\n$/,"")!==`# service=${t}`)throw new Ia(`# service=${t}\\n`,o.toString("utf8"));let f=await s();for(;f===null;)f=await s();if(f===!0)return{capabilities:r,refs:n,symrefs:a};if(f=f.toString("utf8"),f.includes("version 2"))return eB(s);let[h,c]=lv(f,"\0","\\x00");if(c.split(" ").map(d=>r.add(d)),h!=="0000000000000000000000000000000000000000 capabilities^{}"){let[d,p]=lv(h," "," ");for(n.set(p,d);;){let m=await s();if(m===!0)break;if(m!==null){let[g,b]=lv(m.toString("utf8")," "," ");n.set(b,g)}}}for(let d of r)if(d.startsWith("symref=")){let p=d.match(/symref=([^:]+):(.*)/);p.length===3&&a.set(p[1],p[2])}return{protocolVersion:1,capabilities:r,refs:n,symrefs:a}}i(tB,"parseRefsAdResponse");function lv(e,t,r){let n=e.trim().split(t);if(n.length!==2)throw new Ia(`Two strings separated by '${r}'`,e.toString("utf8"));return n}i(lv,"splitAndAssert");var rB=i((e,t)=>e.endsWith("?")?`${e}${t}`:`${e}/${t.replace(/^https?:\/\//,"")}`,"corsProxify"),nB=i((e,t)=>{(t.username||t.password)&&(e.Authorization=kB(t)),t.headers&&Object.assign(e,t.headers)},"updateHeaders"),fv=i(async e=>{try{let t=Buffer.from(await kd(e.body)),r=t.toString("utf8");return{preview:r.length<256?r:r.slice(0,256)+"...",response:r,data:t}}catch{return{}}},"stringifyBody"),qv=class qv{static async capabilities(){return["discover","connect"]}static async discover({http:t,onProgress:r,onAuth:n,onAuthSuccess:a,onAuthFailure:s,corsProxy:o,service:f,url:h,headers:c,protocolVersion:d}){let{url:p,auth:m}=Qk(h),g=o?rB(o,p):p;(m.username||m.password)&&(c.Authorization=kB(m)),d===2&&(c["Git-Protocol"]="version=2");let b,v,_=!1;do if(b=await t.request({onProgress:r,method:"GET",url:`${g}/info/refs?service=${f}`,headers:c}),v=!1,b.statusCode===401||b.statusCode===203){let E=_?s:n;if(E){if(m=await E(p,{...m,headers:{...c}}),m&&m.cancel)throw new gl;m&&(nB(c,m),_=!0,v=!0)}}else b.statusCode===200&&_&&a&&await a(p,m);while(v);if(b.statusCode!==200){let{response:E}=await fv(b);throw new dl(b.statusCode,b.statusMessage,E)}if(b.headers["content-type"]===`application/x-${f}-advertisement`){let E=await tB(b.body,{service:f});return E.auth=m,E}else{let{preview:E,response:R,data:T}=await fv(b);try{let F=await tB([T],{service:f});return F.auth=m,F}catch{throw new Au(E,R)}}}static async connect({http:t,onProgress:r,corsProxy:n,service:a,url:s,auth:o,body:f,headers:h}){let c=Qk(s);c&&(s=c.url),n&&(s=rB(n,s)),h["content-type"]=`application/x-${a}-request`,h.accept=`application/x-${a}-result`,nB(h,o);let d=await t.request({onProgress:r,method:"POST",url:`${s}/${a}`,body:f,headers:h});if(d.statusCode!==200){let{response:p}=fv(d);throw new dl(d.statusCode,d.statusMessage,p)}return d}};i(qv,"GitRemoteHTTP");var _l=qv,zv=class zv{static getRemoteHelperFor({url:t}){let r=new Map;r.set("http",_l),r.set("https",_l);let n=hQ({url:t});if(!n)throw new Tu(t);if(r.has(n.transport))return r.get(n.transport);throw new Ru(t,n.transport,n.transport==="ssh"?cQ(t):void 0)}};i(zv,"GitRemoteManager");var El=zv;function hQ({url:e}){if(e.startsWith("git@"))return{transport:"ssh",address:e};let t=e.match(/(\w+)(:\/\/|::)(.*)/);if(t!==null){if(t[2]==="://")return{transport:t[1],address:t[0]};if(t[2]==="::")return{transport:t[1],address:t[3]}}}i(hQ,"parseRemoteUrl");var xa=null,Vv=class Vv{static async read({fs:t,gitdir:r}){xa===null&&(xa=new cu);let n=Re(r,"shallow"),a=new Set;return await xa.acquire(n,async function(){let s=await t.read(n,{encoding:"utf8"});if(s===null||s.trim()==="")return a;s.trim().split(`
85
85
  `).map(o=>a.add(o))}),a}static async write({fs:t,gitdir:r,oids:n}){xa===null&&(xa=new cu);let a=Re(r,"shallow");if(n.size>0){let s=[...n].join(`
86
86
  `)+`
87
- `;await xa.acquire(a,async function(){await t.write(a,s,{encoding:"utf8"})})}else await xa.acquire(a,async function(){await t.rm(a)})}};i(Vv,"GitShallowManager");var Pa=Vv;async function dQ({fs:e,gitdir:t,oid:r}){let n=`objects/${r.slice(0,2)}/${r.slice(2)}`;return e.exists(`${t}/${n}`)}i(dQ,"hasObjectLoose");async function pQ({fs:e,cache:t,gitdir:r,oid:n,getExternalRefDelta:a}){let s=await e.readdir(Re(r,"objects/pack"));s=s.filter(o=>o.endsWith(".idx"));for(let o of s){let f=`${r}/objects/pack/${o}`,h=await Tv({fs:e,cache:t,filename:f,getExternalRefDelta:a});if(h.error)throw new Ue(h.error);if(h.offsets.has(n))return!0}return!1}i(pQ,"hasObjectPacked");async function iB({fs:e,cache:t,gitdir:r,oid:n,format:a="content"}){let s=i(f=>dt({fs:e,cache:t,gitdir:r,oid:f}),"getExternalRefDelta"),o=await dQ({fs:e,gitdir:r,oid:n});return o||(o=await pQ({fs:e,cache:t,gitdir:r,oid:n,getExternalRefDelta:s})),o}i(iB,"hasObject");function yQ(e){let a="5041434b"+"00000002"+"00000000";return e.slice(0,12).toString("hex")===a}i(yQ,"emptyPackfile");function BB(e,t){let r=e.map(n=>n.split("=",1)[0]);return t.filter(n=>{let a=n.split("=",1)[0];return r.includes(a)})}i(BB,"filterCapabilities");var Sp={name:"isomorphic-git",version:"1.34.1",agent:"git/isomorphic-git@1.34.1"},Gv=class Gv{constructor(){this._queue=[]}write(t){if(this._ended)throw Error("You cannot write to a FIFO that has already been ended!");if(this._waiting){let r=this._waiting;this._waiting=null,r({value:t})}else this._queue.push(t)}end(){if(this._ended=!0,this._waiting){let t=this._waiting;this._waiting=null,t({done:!0})}}destroy(t){this.error=t,this.end()}async next(){if(this._queue.length>0)return{value:this._queue.shift()};if(this._ended)return{done:!0};if(this._waiting)throw Error("You cannot call read until the previous call to read has returned!");return new Promise(t=>{this._waiting=t})}};i(Gv,"FIFO");var fl=Gv;function mQ(e){let t=e.indexOf("\r"),r=e.indexOf(`
87
+ `;await xa.acquire(a,async function(){await t.write(a,s,{encoding:"utf8"})})}else await xa.acquire(a,async function(){await t.rm(a)})}};i(Vv,"GitShallowManager");var Pa=Vv;async function dQ({fs:e,gitdir:t,oid:r}){let n=`objects/${r.slice(0,2)}/${r.slice(2)}`;return e.exists(`${t}/${n}`)}i(dQ,"hasObjectLoose");async function pQ({fs:e,cache:t,gitdir:r,oid:n,getExternalRefDelta:a}){let s=await e.readdir(Re(r,"objects/pack"));s=s.filter(o=>o.endsWith(".idx"));for(let o of s){let f=`${r}/objects/pack/${o}`,h=await Tv({fs:e,cache:t,filename:f,getExternalRefDelta:a});if(h.error)throw new Ue(h.error);if(h.offsets.has(n))return!0}return!1}i(pQ,"hasObjectPacked");async function iB({fs:e,cache:t,gitdir:r,oid:n,format:a="content"}){let s=i(f=>dt({fs:e,cache:t,gitdir:r,oid:f}),"getExternalRefDelta"),o=await dQ({fs:e,gitdir:r,oid:n});return o||(o=await pQ({fs:e,cache:t,gitdir:r,oid:n,getExternalRefDelta:s})),o}i(iB,"hasObject");function yQ(e){let a="5041434b"+"00000002"+"00000000";return e.slice(0,12).toString("hex")===a}i(yQ,"emptyPackfile");function BB(e,t){let r=e.map(n=>n.split("=",1)[0]);return t.filter(n=>{let a=n.split("=",1)[0];return r.includes(a)})}i(BB,"filterCapabilities");var Sp={name:"isomorphic-git",version:"0.0.0-development",agent:"git/isomorphic-git@0.0.0-development"},Gv=class Gv{constructor(){this._queue=[]}write(t){if(this._ended)throw Error("You cannot write to a FIFO that has already been ended!");if(this._waiting){let r=this._waiting;this._waiting=null,r({value:t})}else this._queue.push(t)}end(){if(this._ended=!0,this._waiting){let t=this._waiting;this._waiting=null,t({done:!0})}}destroy(t){this.error=t,this.end()}async next(){if(this._queue.length>0)return{value:this._queue.shift()};if(this._ended)return{done:!0};if(this._waiting)throw Error("You cannot call read until the previous call to read has returned!");return new Promise(t=>{this._waiting=t})}};i(Gv,"FIFO");var fl=Gv;function mQ(e){let t=e.indexOf("\r"),r=e.indexOf(`
88
88
  `);return t===-1&&r===-1?-1:t===-1?r+1:r===-1?t+1:r===t+1?r+1:Math.min(t,r)+1}i(mQ,"findSplit");function CB(e){let t=new fl,r="";return(async()=>(await Bu(e,n=>{for(n=n.toString("utf8"),r+=n;;){let a=mQ(r);if(a===-1)break;t.write(r.slice(0,a)),r=r.slice(a)}}),r.length>0&&t.write(r),t.end()))(),t}i(CB,"splitLines");var Yv=class Yv{static demux(t){let r=bt.streamReader(t),n=new fl,a=new fl,s=new fl,o=i(async function(){let f=await r();if(f===null)return o();if(f===!0){n.end(),s.end(),t.error?a.destroy(t.error):a.end();return}switch(f[0]){case 1:{a.write(f.slice(1));break}case 2:{s.write(f.slice(1));break}case 3:{let h=f.slice(1);s.write(h),n.end(),s.end(),a.destroy(new Error(h.toString("utf8")));return}default:n.write(f)}o()},"nextBit");return o(),{packetlines:n,packfile:a,progress:s}}};i(Yv,"GitSideBand");var Bd=Yv;async function gQ(e){let{packetlines:t,packfile:r,progress:n}=Bd.demux(e),a=[],s=[],o=[],f=!1,h=!1;return new Promise((c,d)=>{Bu(t,p=>{let m=p.toString("utf8").trim();if(m.startsWith("shallow")){let g=m.slice(-41).trim();g.length!==40&&d(new Oo(g)),a.push(g)}else if(m.startsWith("unshallow")){let g=m.slice(-41).trim();g.length!==40&&d(new Oo(g)),s.push(g)}else if(m.startsWith("ACK")){let[,g,b]=m.split(" ");o.push({oid:g,status:b}),b||(h=!0)}else m.startsWith("NAK")?(f=!0,h=!0):(h=!0,f=!0);h&&(e.error?d(e.error):c({shallows:a,unshallows:s,acks:o,nak:f,packfile:r,progress:n}))}).finally(()=>{h||(e.error?d(e.error):c({shallows:a,unshallows:s,acks:o,nak:f,packfile:r,progress:n}))})})}i(gQ,"parseUploadPackResponse");function wQ({capabilities:e=[],wants:t=[],haves:r=[],shallows:n=[],depth:a=null,since:s=null,exclude:o=[]}){let f=[];t=[...new Set(t)];let h=` ${e.join(" ")}`;for(let c of t)f.push(bt.encode(`want ${c}${h}
89
89
  `)),h="";for(let c of n)f.push(bt.encode(`shallow ${c}
90
90
  `));a!==null&&f.push(bt.encode(`deepen ${a}
package/dist/server.js CHANGED
@@ -64,7 +64,7 @@ gpgsig`+dc(s)+`
64
64
  `,author:u,committer:c,signingKey:f})}o(Ek,"_addNote");async function Yw({fs:e,onSign:t,dir:r,gitdir:i=D(r,".git"),ref:n="refs/notes/commits",oid:a,note:s,force:l,author:u,committer:c,signingKey:f,cache:d={}}){try{E("fs",e),E("gitdir",i),E("oid",a),E("note",s),f&&E("onSign",t);let h=new N(e),p=await rr({fs:h,gitdir:i,author:u});if(!p)throw new Ee("author");let m=await vi({fs:h,gitdir:i,author:p,committer:c});if(!m)throw new Ee("committer");return await Ek({fs:new N(h),cache:d,onSign:t,gitdir:i,ref:n,oid:a,note:s,force:l,author:p,committer:m,signingKey:f})}catch(h){throw h.caller="git.addNote",h}}o(Yw,"addNote");var kk=/(^|[/.])([/.]|$)|^@$|@{|[\x00-\x20\x7f~^:?*[\\]|\.lock(\/|$)/;function Ln(e,t){if(typeof e!="string")throw new TypeError("Reference name must be a string");return!kk.test(e)&&(!!t||e.includes("/"))}o(Ln,"isValidRef");async function Xw({fs:e,gitdir:t,remote:r,url:i,force:n}){if(!Ln(r,!0))throw new lt(r,_n.clean(r));let a=await se.get({fs:e,gitdir:t});if(!n&&(await a.getSubsections("remote")).includes(r)&&i!==await a.get(`remote.${r}.url`))throw new st("remote",r);await a.set(`remote.${r}.url`,i),await a.set(`remote.${r}.fetch`,`+refs/heads/*:refs/remotes/${r}/*`),await se.save({fs:e,gitdir:t,config:a})}o(Xw,"_addRemote");async function Jw({fs:e,dir:t,gitdir:r=D(t,".git"),remote:i,url:n,force:a=!1}){try{return E("fs",e),E("gitdir",r),E("remote",i),E("url",n),await Xw({fs:new N(e),gitdir:r,remote:i,url:n,force:a})}catch(s){throw s.caller="git.addRemote",s}}o(Jw,"addRemote");async function xk({fs:e,cache:t,onSign:r,gitdir:i,ref:n,tagger:a,message:s=n,gpgsig:l,object:u,signingKey:c,force:f=!1}){if(n=n.startsWith("refs/tags/")?n:`refs/tags/${n}`,!f&&await C.exists({fs:e,gitdir:i,ref:n}))throw new st("tag",n);let d=await C.resolve({fs:e,gitdir:i,ref:u||"HEAD"}),{type:h}=await Q({fs:e,cache:t,gitdir:i,oid:d}),p=Ve.from({object:d,type:h,tag:n.replace("refs/tags/",""),tagger:a,message:s,gpgsig:l});c&&(p=await Ve.sign(p,r,c));let m=await He({fs:e,gitdir:i,type:"tag",object:p.toObject()});await C.writeRef({fs:e,gitdir:i,ref:n,value:m})}o(xk,"_annotatedTag");async function Qw({fs:e,onSign:t,dir:r,gitdir:i=D(r,".git"),ref:n,tagger:a,message:s=n,gpgsig:l,object:u,signingKey:c,force:f=!1,cache:d={}}){try{E("fs",e),E("gitdir",i),E("ref",n),c&&E("onSign",t);let h=new N(e),p=await rr({fs:h,gitdir:i,author:a});if(!p)throw new Ee("tagger");return await xk({fs:h,cache:d,onSign:t,gitdir:i,ref:n,tagger:p,message:s,gpgsig:l,object:u,signingKey:c,force:f})}catch(h){throw h.caller="git.annotatedTag",h}}o(Qw,"annotatedTag");async function Pk({fs:e,gitdir:t,ref:r,object:i,checkout:n=!1,force:a=!1}){if(!Ln(r,!0))throw new lt(r,_n.clean(r));let s=`refs/heads/${r}`;if(!a&&await C.exists({fs:e,gitdir:t,ref:s}))throw new st("branch",r,!1);let l;try{l=await C.resolve({fs:e,gitdir:t,ref:i||"HEAD"})}catch{}l&&await C.writeRef({fs:e,gitdir:t,ref:s,value:l}),n&&await C.writeSymbolicRef({fs:e,gitdir:t,ref:"HEAD",value:s})}o(Pk,"_branch");async function eg({fs:e,dir:t,gitdir:r=D(t,".git"),ref:i,object:n,checkout:a=!1,force:s=!1}){try{return E("fs",e),E("gitdir",r),E("ref",i),await Pk({fs:new N(e),gitdir:r,ref:i,object:n,checkout:a,force:s})}catch(l){throw l.caller="git.branch",l}}o(eg,"branch");var tg=o((e,t)=>e==="."||t==null||t.length===0||t==="."?!0:t.length>=e.length?t.startsWith(e):e.startsWith(t),"worthWalking");async function Cc({fs:e,cache:t,onProgress:r,onPostCheckout:i,dir:n,gitdir:a,remote:s,ref:l,filepaths:u,noCheckout:c,noUpdateHead:f,dryRun:d,force:h,track:p=!0,nonBlocking:m=!1,batchSize:w=100}){let y;if(i)try{y=await C.resolve({fs:e,gitdir:a,ref:"HEAD"})}catch{y="0000000000000000000000000000000000000000"}let g;try{g=await C.resolve({fs:e,gitdir:a,ref:l})}catch(_){if(l==="HEAD")throw _;let k=`${s}/${l}`;if(g=await C.resolve({fs:e,gitdir:a,ref:k}),p){let F=await se.get({fs:e,gitdir:a});await F.set(`branch.${l}.remote`,s),await F.set(`branch.${l}.merge`,`refs/heads/${l}`),await se.save({fs:e,gitdir:a,config:F})}await C.writeRef({fs:e,gitdir:a,ref:`refs/heads/${l}`,value:g})}if(!c){let _;try{_=await Tk({fs:e,cache:t,onProgress:r,dir:n,gitdir:a,ref:l,force:h,filepaths:u})}catch(b){throw b instanceof J&&b.data.what===g?new xn(l,g):b}let k=_.filter(([b])=>b==="conflict").map(([b,x])=>x);if(k.length>0)throw new kn(k);let F=_.filter(([b])=>b==="error").map(([b,x])=>x);if(F.length>0)throw new L(F.join(", "));if(d){i&&await i({previousHead:y,newHead:g,type:u!=null&&u.length>0?"file":"branch"});return}let S=0,P=_.length;if(await fe.acquire({fs:e,gitdir:a,cache:t},async function(b){await Promise.all(_.filter(([x])=>x==="delete"||x==="delete-index").map(async function([x,v]){let A=`${n}/${v}`;x==="delete"&&await e.rm(A),b.delete({filepath:v}),r&&await r({phase:"Updating workdir",loaded:++S,total:P})}))}),await fe.acquire({fs:e,gitdir:a,cache:t},async function(b){for(let[x,v]of _)if(x==="rmdir"||x==="rmdir-index"){let A=`${n}/${v}`;try{x==="rmdir"&&await e.rmdir(A),b.delete({filepath:v}),r&&await r({phase:"Updating workdir",loaded:++S,total:P})}catch(T){if(T.code==="ENOTEMPTY")console.log(`Did not delete ${v} because directory is not empty`);else throw T}}}),await Promise.all(_.filter(([b])=>b==="mkdir"||b==="mkdir-index").map(async function([b,x]){let v=`${n}/${x}`;await e.mkdir(v),r&&await r({phase:"Updating workdir",loaded:++S,total:P})})),m){let b=_.filter(([v])=>v==="create"||v==="create-index"||v==="update"||v==="mkdir-index"),x=await Fw("Update Working Dir",b.map(([v,A,T,R,B])=>()=>Ok({fs:e,cache:t,gitdir:a,dir:n},[v,A,T,R,B])),r,w);await fe.acquire({fs:e,gitdir:a,cache:t,allowUnmerged:!0},async function(v){await Fw("Update Index",x.map(([A,T,R])=>()=>Ak({index:v,fullpath:A,oid:T,stats:R})),r,w)})}else await fe.acquire({fs:e,gitdir:a,cache:t,allowUnmerged:!0},async function(b){await Promise.all(_.filter(([x])=>x==="create"||x==="create-index"||x==="update"||x==="mkdir-index").map(async function([x,v,A,T,R]){let B=`${n}/${v}`;try{if(x!=="create-index"&&x!=="mkdir-index"){let{object:de}=await Q({fs:e,cache:t,gitdir:a,oid:A});if(R&&await e.rm(B),T===33188)await e.write(B,de);else if(T===33261)await e.write(B,de,{mode:511});else if(T===40960)await e.writelink(B,de);else throw new L(`Invalid mode 0o${T.toString(8)} detected in blob ${A}`)}let M=await e.lstat(B);T===33261&&(M.mode=493),x==="mkdir-index"&&(M.mode=57344),b.insert({filepath:v,stats:M,oid:A}),r&&await r({phase:"Updating workdir",loaded:++S,total:P})}catch(M){console.log(M)}}))});i&&await i({previousHead:y,newHead:g,type:u!=null&&u.length>0?"file":"branch"})}if(!f){let _=await C.expand({fs:e,gitdir:a,ref:l});_.startsWith("refs/heads")?await C.writeSymbolicRef({fs:e,gitdir:a,ref:"HEAD",value:_}):await C.writeRef({fs:e,gitdir:a,ref:"HEAD",value:g})}}o(Cc,"_checkout");async function Tk({fs:e,cache:t,onProgress:r,dir:i,gitdir:n,ref:a,force:s,filepaths:l}){let u=0;return er({fs:e,cache:t,dir:i,gitdir:n,trees:[We({ref:a}),xi(),Tr()],map:o(async function(c,[f,d,h]){if(c===".")return;if(l&&!l.some(m=>tg(c,m)))return null;switch(r&&await r({phase:"Analyzing workdir",loaded:++u}),[!!h,!!f,!!d].map(Number).join("")){case"000":return;case"001":return s&&l&&l.includes(c)?["delete",c]:void 0;case"010":switch(await f.type()){case"tree":return["mkdir",c];case"blob":return["create",c,await f.oid(),await f.mode()];case"commit":return["mkdir-index",c,await f.oid(),await f.mode()];default:return["error",`new entry Unhandled type ${await f.type()}`]}case"011":switch(`${await f.type()}-${await d.type()}`){case"tree-tree":return;case"tree-blob":case"blob-tree":return["conflict",c];case"blob-blob":return await f.oid()!==await d.oid()?s?["update",c,await f.oid(),await f.mode(),await f.mode()!==await d.mode()]:["conflict",c]:await f.mode()!==await d.mode()?s?["update",c,await f.oid(),await f.mode(),!0]:["conflict",c]:["create-index",c,await f.oid(),await f.mode()];case"commit-tree":return;case"commit-blob":return["conflict",c];default:return["error",`new entry Unhandled type ${f.type}`]}case"100":return["delete-index",c];case"101":switch(await h.type()){case"tree":return["rmdir-index",c];case"blob":return await h.oid()!==await d.oid()?s?["delete",c]:["conflict",c]:["delete",c];case"commit":return["rmdir-index",c];default:return["error",`delete entry Unhandled type ${await h.type()}`]}case"110":case"111":switch(`${await h.type()}-${await f.type()}`){case"tree-tree":return;case"blob-blob":{if(await h.oid()===await f.oid()&&await h.mode()===await f.mode()&&!s)return;if(d){if(await d.oid()!==await h.oid()&&await d.oid()!==await f.oid())return s?["update",c,await f.oid(),await f.mode(),await f.mode()!==await d.mode()]:["conflict",c]}else if(s)return["update",c,await f.oid(),await f.mode(),await f.mode()!==await h.mode()];return await f.mode()!==await h.mode()?["update",c,await f.oid(),await f.mode(),!0]:await f.oid()!==await h.oid()?["update",c,await f.oid(),await f.mode(),!1]:void 0}case"tree-blob":return["update-dir-to-blob",c,await f.oid()];case"blob-tree":return["update-blob-to-tree",c];case"commit-commit":return["mkdir-index",c,await f.oid(),await f.mode()];default:return["error",`update entry Unhandled type ${await h.type()}-${await f.type()}`]}}},"map"),reduce:o(async function(c,f){return f=Hw(f),c?c&&c[0]==="rmdir"?(f.push(c),f):(f.unshift(c),f):f},"reduce")})}o(Tk,"analyze");async function Ak({index:e,fullpath:t,stats:r,oid:i}){try{e.insert({filepath:t,stats:r,oid:i})}catch(n){console.warn(`Error inserting ${t} into index:`,n)}}o(Ak,"updateIndex");async function Ok({fs:e,cache:t,gitdir:r,dir:i},[n,a,s,l,u]){let c=`${i}/${a}`;if(n!=="create-index"&&n!=="mkdir-index"){let{object:d}=await Q({fs:e,cache:t,gitdir:r,oid:s});if(u&&await e.rm(c),l===33188)await e.write(c,d);else if(l===33261)await e.write(c,d,{mode:511});else if(l===40960)await e.writelink(c,d);else throw new L(`Invalid mode 0o${l.toString(8)} detected in blob ${s}`)}let f=await e.lstat(c);return l===33261&&(f.mode=493),n==="mkdir-index"&&(f.mode=57344),[a,s,f]}o(Ok,"updateWorkingDir");async function Fw(e,t,r,i){let n=[];try{for(let a=0;a<t.length;a+=i){let s=t.slice(a,a+i).map(u=>u());(await Promise.allSettled(s)).forEach(u=>{u.status==="fulfilled"&&n.push(u.value)}),r&&await r({phase:"Updating workdir",loaded:a+s.length,total:t.length})}return n}catch(a){console.error(`Error during ${e}: ${a}`)}return n}o(Fw,"batchAllSettled");async function Ic({fs:e,onProgress:t,onPostCheckout:r,dir:i,gitdir:n=D(i,".git"),remote:a="origin",ref:s,filepaths:l,noCheckout:u=!1,noUpdateHead:c=s===void 0,dryRun:f=!1,force:d=!1,track:h=!0,cache:p={},nonBlocking:m=!1,batchSize:w=100}){try{E("fs",e),E("dir",i),E("gitdir",n);let y=s||"HEAD";return await Cc({fs:new N(e),cache:p,onProgress:t,onPostCheckout:r,dir:i,gitdir:n,remote:a,ref:y,filepaths:l,noCheckout:u,noUpdateHead:c,dryRun:f,force:d,track:h,nonBlocking:m,batchSize:w})}catch(y){throw y.caller="git.checkout",y}}o(Ic,"checkout");var Dk=/^refs\/(heads\/|tags\/|remotes\/)?(.*)/;function Er(e){let t=Dk.exec(e);return t?t[1]==="remotes/"&&e.endsWith("/HEAD")?t[2].slice(0,-5):t[2]:e}o(Er,"abbreviateRef");async function nr({fs:e,gitdir:t,fullname:r=!1,test:i=!1}){let n=await C.resolve({fs:e,gitdir:t,ref:"HEAD",depth:2});if(i)try{await C.resolve({fs:e,gitdir:t,ref:n})}catch{return}if(n.startsWith("refs/"))return r?n:Er(n)}o(nr,"_currentBranch");function Rk(e){return e=e.replace(/^git@([^:]+):/,"https://$1/"),e=e.replace(/^ssh:\/\//,"https://"),e}o(Rk,"translateSSHtoHTTP");function rg({username:e="",password:t=""}){return`Basic ${Buffer.from(`${e}:${t}`).toString("base64")}`}o(rg,"calculateBasicAuthHeader");async function Hn(e,t){let r=Lw(e);for(;;){let{value:i,done:n}=await r.next();if(i&&await t(i),n)break}r.return&&r.return()}o(Hn,"forAwait");async function ro(e){let t=0,r=[];await Hn(e,a=>{r.push(a),t+=a.byteLength});let i=new Uint8Array(t),n=0;for(let a of r)i.set(a,n),n+=a.byteLength;return i}o(ro,"collect");function Sw(e){let t=e.match(/^https?:\/\/([^/]+)@/);if(t==null)return{url:e,auth:{}};t=t[1];let[r,i]=t.split(":");return e=e.replace(`${t}@`,""),{url:e,auth:{username:r,password:i}}}o(Sw,"extractAuthFromUrl");function Oc(e,t){let r=t.toString(16);return"0".repeat(e-r.length)+r}o(Oc,"padHex");var Kc=class Kc{static flush(){return Buffer.from("0000","utf8")}static delim(){return Buffer.from("0001","utf8")}static encode(t){typeof t=="string"&&(t=Buffer.from(t));let r=t.length+4,i=Oc(4,r);return Buffer.concat([Buffer.from(i,"utf8"),t])}static streamReader(t){let r=new Qa(t);return o(async function(){try{let n=await r.read(4);if(n==null)return!0;if(n=parseInt(n.toString("utf8"),16),n===0||n===1)return null;let a=await r.read(n-4);return a??!0}catch(n){return t.error=n,!0}},"read")}};o(Kc,"GitPktLine");var ae=Kc;async function Ew(e){let t={},r;for(;r=await e(),r!==!0;){if(r===null)continue;r=r.toString("utf8").replace(/\n$/,"");let i=r.indexOf("=");if(i>-1){let n=r.slice(0,i),a=r.slice(i+1);t[n]=a}else t[r]=!0}return{protocolVersion:2,capabilities2:t}}o(Ew,"parseCapabilitiesV2");async function kw(e,{service:t}){let r=new Set,i=new Map,n=new Map,a=ae.streamReader(e),s=await a();for(;s===null;)s=await a();if(s===!0)throw new Pn;if(s.includes("version 2"))return Ew(a);if(s.toString("utf8").replace(/\n$/,"")!==`# service=${t}`)throw new kr(`# service=${t}\\n`,s.toString("utf8"));let l=await a();for(;l===null;)l=await a();if(l===!0)return{capabilities:r,refs:i,symrefs:n};if(l=l.toString("utf8"),l.includes("version 2"))return Ew(a);let[u,c]=pc(l,"\0","\\x00");if(c.split(" ").map(f=>r.add(f)),u!=="0000000000000000000000000000000000000000 capabilities^{}"){let[f,d]=pc(u," "," ");for(i.set(d,f);;){let h=await a();if(h===!0)break;if(h!==null){let[p,m]=pc(h.toString("utf8")," "," ");i.set(m,p)}}}for(let f of r)if(f.startsWith("symref=")){let d=f.match(/symref=([^:]+):(.*)/);d.length===3&&n.set(d[1],d[2])}return{protocolVersion:1,capabilities:r,refs:i,symrefs:n}}o(kw,"parseRefsAdResponse");function pc(e,t,r){let i=e.trim().split(t);if(i.length!==2)throw new kr(`Two strings separated by '${r}'`,e.toString("utf8"));return i}o(pc,"splitAndAssert");var xw=o((e,t)=>e.endsWith("?")?`${e}${t}`:`${e}/${t.replace(/^https?:\/\//,"")}`,"corsProxify"),Pw=o((e,t)=>{(t.username||t.password)&&(e.Authorization=rg(t)),t.headers&&Object.assign(e,t.headers)},"updateHeaders"),mc=o(async e=>{try{let t=Buffer.from(await ro(e.body)),r=t.toString("utf8");return{preview:r.length<256?r:r.slice(0,256)+"...",response:r,data:t}}catch{return{}}},"stringifyBody"),Yc=class Yc{static async capabilities(){return["discover","connect"]}static async discover({http:t,onProgress:r,onAuth:i,onAuthSuccess:n,onAuthFailure:a,corsProxy:s,service:l,url:u,headers:c,protocolVersion:f}){let{url:d,auth:h}=Sw(u),p=s?xw(s,d):d;(h.username||h.password)&&(c.Authorization=rg(h)),f===2&&(c["Git-Protocol"]="version=2");let m,w,y=!1;do if(m=await t.request({onProgress:r,method:"GET",url:`${p}/info/refs?service=${l}`,headers:c}),w=!1,m.statusCode===401||m.statusCode===203){let g=y?a:i;if(g){if(h=await g(d,{...h,headers:{...c}}),h&&h.cancel)throw new bi;h&&(Pw(c,h),y=!0,w=!0)}}else m.statusCode===200&&y&&n&&await n(d,h);while(w);if(m.statusCode!==200){let{response:g}=await mc(m);throw new mi(m.statusCode,m.statusMessage,g)}if(m.headers["content-type"]===`application/x-${l}-advertisement`){let g=await kw(m.body,{service:l});return g.auth=h,g}else{let{preview:g,response:_,data:k}=await mc(m);try{let F=await kw([k],{service:l});return F.auth=h,F}catch{throw new Rn(g,_)}}}static async connect({http:t,onProgress:r,corsProxy:i,service:n,url:a,auth:s,body:l,headers:u}){let c=Sw(a);c&&(a=c.url),i&&(a=xw(i,a)),u["content-type"]=`application/x-${n}-request`,u.accept=`application/x-${n}-result`,Pw(u,s);let f=await t.request({onProgress:r,method:"POST",url:`${a}/${n}`,body:l,headers:u});if(f.statusCode!==200){let{response:d}=mc(f);throw new mi(f.statusCode,f.statusMessage,d)}return f}};o(Yc,"GitRemoteHTTP");var Si=Yc,Xc=class Xc{static getRemoteHelperFor({url:t}){let r=new Map;r.set("http",Si),r.set("https",Si);let i=Ck({url:t});if(!i)throw new In(t);if(r.has(i.transport))return r.get(i.transport);throw new Cn(t,i.transport,i.transport==="ssh"?Rk(t):void 0)}};o(Xc,"GitRemoteManager");var Ei=Xc;function Ck({url:e}){if(e.startsWith("git@"))return{transport:"ssh",address:e};let t=e.match(/(\w+)(:\/\/|::)(.*)/);if(t!==null){if(t[2]==="://")return{transport:t[1],address:t[0]};if(t[2]==="::")return{transport:t[1],address:t[3]}}}o(Ck,"parseRemoteUrl");var Sr=null,Jc=class Jc{static async read({fs:t,gitdir:r}){Sr===null&&(Sr=new bn);let i=D(r,"shallow"),n=new Set;return await Sr.acquire(i,async function(){let a=await t.read(i,{encoding:"utf8"});if(a===null||a.trim()==="")return n;a.trim().split(`
65
65
  `).map(s=>n.add(s))}),n}static async write({fs:t,gitdir:r,oids:i}){Sr===null&&(Sr=new bn);let n=D(r,"shallow");if(i.size>0){let a=[...i].join(`
66
66
  `)+`
67
- `;await Sr.acquire(n,async function(){await t.write(n,a,{encoding:"utf8"})})}else await Sr.acquire(n,async function(){await t.rm(n)})}};o(Jc,"GitShallowManager");var xr=Jc;async function Ik({fs:e,gitdir:t,oid:r}){let i=`objects/${r.slice(0,2)}/${r.slice(2)}`;return e.exists(`${t}/${i}`)}o(Ik,"hasObjectLoose");async function Bk({fs:e,cache:t,gitdir:r,oid:i,getExternalRefDelta:n}){let a=await e.readdir(D(r,"objects/pack"));a=a.filter(s=>s.endsWith(".idx"));for(let s of a){let l=`${r}/objects/pack/${s}`,u=await Rc({fs:e,cache:t,filename:l,getExternalRefDelta:n});if(u.error)throw new L(u.error);if(u.offsets.has(i))return!0}return!1}o(Bk,"hasObjectPacked");async function Tw({fs:e,cache:t,gitdir:r,oid:i,format:n="content"}){let a=o(l=>Q({fs:e,cache:t,gitdir:r,oid:l}),"getExternalRefDelta"),s=await Ik({fs:e,gitdir:r,oid:i});return s||(s=await Bk({fs:e,cache:t,gitdir:r,oid:i,getExternalRefDelta:a})),s}o(Tw,"hasObject");function Nk(e){let n="5041434b"+"00000002"+"00000000";return e.slice(0,12).toString("hex")===n}o(Nk,"emptyPackfile");function ig(e,t){let r=e.map(i=>i.split("=",1)[0]);return t.filter(i=>{let n=i.split("=",1)[0];return r.includes(n)})}o(ig,"filterCapabilities");var Zo={name:"isomorphic-git",version:"1.34.1",agent:"git/isomorphic-git@1.34.1"},Qc=class Qc{constructor(){this._queue=[]}write(t){if(this._ended)throw Error("You cannot write to a FIFO that has already been ended!");if(this._waiting){let r=this._waiting;this._waiting=null,r({value:t})}else this._queue.push(t)}end(){if(this._ended=!0,this._waiting){let t=this._waiting;this._waiting=null,t({done:!0})}}destroy(t){this.error=t,this.end()}async next(){if(this._queue.length>0)return{value:this._queue.shift()};if(this._ended)return{done:!0};if(this._waiting)throw Error("You cannot call read until the previous call to read has returned!");return new Promise(t=>{this._waiting=t})}};o(Qc,"FIFO");var ui=Qc;function $k(e){let t=e.indexOf("\r"),r=e.indexOf(`
67
+ `;await Sr.acquire(n,async function(){await t.write(n,a,{encoding:"utf8"})})}else await Sr.acquire(n,async function(){await t.rm(n)})}};o(Jc,"GitShallowManager");var xr=Jc;async function Ik({fs:e,gitdir:t,oid:r}){let i=`objects/${r.slice(0,2)}/${r.slice(2)}`;return e.exists(`${t}/${i}`)}o(Ik,"hasObjectLoose");async function Bk({fs:e,cache:t,gitdir:r,oid:i,getExternalRefDelta:n}){let a=await e.readdir(D(r,"objects/pack"));a=a.filter(s=>s.endsWith(".idx"));for(let s of a){let l=`${r}/objects/pack/${s}`,u=await Rc({fs:e,cache:t,filename:l,getExternalRefDelta:n});if(u.error)throw new L(u.error);if(u.offsets.has(i))return!0}return!1}o(Bk,"hasObjectPacked");async function Tw({fs:e,cache:t,gitdir:r,oid:i,format:n="content"}){let a=o(l=>Q({fs:e,cache:t,gitdir:r,oid:l}),"getExternalRefDelta"),s=await Ik({fs:e,gitdir:r,oid:i});return s||(s=await Bk({fs:e,cache:t,gitdir:r,oid:i,getExternalRefDelta:a})),s}o(Tw,"hasObject");function Nk(e){let n="5041434b"+"00000002"+"00000000";return e.slice(0,12).toString("hex")===n}o(Nk,"emptyPackfile");function ig(e,t){let r=e.map(i=>i.split("=",1)[0]);return t.filter(i=>{let n=i.split("=",1)[0];return r.includes(n)})}o(ig,"filterCapabilities");var Zo={name:"isomorphic-git",version:"0.0.0-development",agent:"git/isomorphic-git@0.0.0-development"},Qc=class Qc{constructor(){this._queue=[]}write(t){if(this._ended)throw Error("You cannot write to a FIFO that has already been ended!");if(this._waiting){let r=this._waiting;this._waiting=null,r({value:t})}else this._queue.push(t)}end(){if(this._ended=!0,this._waiting){let t=this._waiting;this._waiting=null,t({done:!0})}}destroy(t){this.error=t,this.end()}async next(){if(this._queue.length>0)return{value:this._queue.shift()};if(this._ended)return{done:!0};if(this._waiting)throw Error("You cannot call read until the previous call to read has returned!");return new Promise(t=>{this._waiting=t})}};o(Qc,"FIFO");var ui=Qc;function $k(e){let t=e.indexOf("\r"),r=e.indexOf(`
68
68
  `);return t===-1&&r===-1?-1:t===-1?r+1:r===-1?t+1:r===t+1?r+1:Math.min(t,r)+1}o($k,"findSplit");function ng(e){let t=new ui,r="";return(async()=>(await Hn(e,i=>{for(i=i.toString("utf8"),r+=i;;){let n=$k(r);if(n===-1)break;t.write(r.slice(0,n)),r=r.slice(n)}}),r.length>0&&t.write(r),t.end()))(),t}o(ng,"splitLines");var ef=class ef{static demux(t){let r=ae.streamReader(t),i=new ui,n=new ui,a=new ui,s=o(async function(){let l=await r();if(l===null)return s();if(l===!0){i.end(),a.end(),t.error?n.destroy(t.error):n.end();return}switch(l[0]){case 1:{n.write(l.slice(1));break}case 2:{a.write(l.slice(1));break}case 3:{let u=l.slice(1);a.write(u),i.end(),a.end(),n.destroy(new Error(u.toString("utf8")));return}default:i.write(l)}s()},"nextBit");return s(),{packetlines:i,packfile:n,progress:a}}};o(ef,"GitSideBand");var io=ef;async function Lk(e){let{packetlines:t,packfile:r,progress:i}=io.demux(e),n=[],a=[],s=[],l=!1,u=!1;return new Promise((c,f)=>{Hn(t,d=>{let h=d.toString("utf8").trim();if(h.startsWith("shallow")){let p=h.slice(-41).trim();p.length!==40&&f(new Xt(p)),n.push(p)}else if(h.startsWith("unshallow")){let p=h.slice(-41).trim();p.length!==40&&f(new Xt(p)),a.push(p)}else if(h.startsWith("ACK")){let[,p,m]=h.split(" ");s.push({oid:p,status:m}),m||(u=!0)}else h.startsWith("NAK")?(l=!0,u=!0):(u=!0,l=!0);u&&(e.error?f(e.error):c({shallows:n,unshallows:a,acks:s,nak:l,packfile:r,progress:i}))}).finally(()=>{u||(e.error?f(e.error):c({shallows:n,unshallows:a,acks:s,nak:l,packfile:r,progress:i}))})})}o(Lk,"parseUploadPackResponse");function Mk({capabilities:e=[],wants:t=[],haves:r=[],shallows:i=[],depth:n=null,since:a=null,exclude:s=[]}){let l=[];t=[...new Set(t)];let u=` ${e.join(" ")}`;for(let c of t)l.push(ae.encode(`want ${c}${u}
69
69
  `)),u="";for(let c of i)l.push(ae.encode(`shallow ${c}
70
70
  `));n!==null&&l.push(ae.encode(`deepen ${n}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legit-sdk/core",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Legit SDK - Infrastructure for write-enabled AI",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -18,18 +18,9 @@
18
18
  "require": "./dist/server.js"
19
19
  }
20
20
  },
21
- "scripts": {
22
- "test": "vitest",
23
- "dev": "node --loader ts-node/esm --inspect ./node_modules/vite-node/dist/cli.mjs --watch src/vite.ts",
24
- "build": "tsc && node esbuild.config.js && rollup -c rollup.dts.config.js",
25
- "build:dev": "tsc --build",
26
- "build:watch": "tsc --noEmitOnError false --watch",
27
- "test:watch": "vitest --watch"
28
- },
29
21
  "keywords": [],
30
22
  "author": "",
31
- "license": "PolyForm Noncommercial License 1.0.0",
32
- "packageManager": "pnpm@10.4.1",
23
+ "license": "Apache-2.0",
33
24
  "publishConfig": {
34
25
  "access": "public"
35
26
  },
@@ -62,9 +53,17 @@
62
53
  "vitest": "^3.1.1"
63
54
  },
64
55
  "dependencies": {
65
- "@legit-sdk/isomorphic-git": "workspace:*",
66
56
  "ignore": "^7.0.4",
67
57
  "memfs": "^4.14.0",
68
- "typescript": "^5.8.3"
58
+ "typescript": "^5.8.3",
59
+ "@legit-sdk/isomorphic-git": "1.34.2"
60
+ },
61
+ "scripts": {
62
+ "test": "vitest",
63
+ "dev": "node --loader ts-node/esm --inspect ./node_modules/vite-node/dist/cli.mjs --watch src/vite.ts",
64
+ "build": "tsc && node esbuild.config.js && rollup -c rollup.dts.config.js",
65
+ "build:dev": "tsc --build",
66
+ "build:watch": "tsc --noEmitOnError false --watch",
67
+ "test:watch": "vitest --watch"
69
68
  }
70
- }
69
+ }