pad.fyi 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -2
- package/SKILL.md +42 -0
- package/dist/pad.mjs +13 -0
- package/package.json +34 -5
package/README.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pad.fyi CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Short links for files, for developers and agents.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx pad.fyi upload report.html
|
|
7
|
+
npx pad.fyi upload ./site --ttl 1d
|
|
8
|
+
npx pad.fyi delete report.html
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Uploading a folder makes a multi-file pad served from its `index.html`. Uploading the same path again adds a version at the same URL, and `--new` makes a new pad instead. A `--password` is sent in the `Pad-Password` header as UTF-8 bytes, so readers enter the same password in their browser or `curl -u`. `npx pad.fyi --help` lists the options.
|
|
12
|
+
|
|
13
|
+
The CLI keeps each pad's edit token in `~/.pad`, readable only by you. Set `PAD_STORE` to use another file, and `PAD_API` to talk to another server.
|
|
14
|
+
|
|
15
|
+
`SKILL.md` teaches an agent to use the CLI.
|
|
16
|
+
|
|
17
|
+
## Develop
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bun run --cwd packages/cli build
|
|
21
|
+
node packages/cli/dist/pad.mjs --help
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Tests run from the repository root with `bun run test -- --run packages/cli`.
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pad-fyi
|
|
3
|
+
description: Share a file or folder as a short, expiring link with pad.fyi. Use when a task needs a link anyone can open, such as a rendered HTML page, a report, notes, code, or a small static site to preview or hand off.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# pad.fyi
|
|
7
|
+
|
|
8
|
+
pad.fyi turns a file or a folder into a link like `https://abc123defg.pad.fyi/`. Every pad expires, and anyone with the link can open it.
|
|
9
|
+
|
|
10
|
+
## Upload
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npx pad.fyi upload <file or folder> --json
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The JSON has `url`, the link to share, `versionUrl`, a link to this exact version, and `expiresAt`. Give the user `url` and the expiry.
|
|
17
|
+
|
|
18
|
+
| Option | Effect |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| `--ttl 1h\|1d\|7d\|30d` | How long the pad lasts; 7 days by default |
|
|
21
|
+
| `--burn` | Delete the pad once it has been read; single files only |
|
|
22
|
+
| `--views N` | Delete it after N reads; single files only |
|
|
23
|
+
| `--password P` | Readers need the password, through HTTP Basic auth. The CLI sends it as UTF-8 bytes, which matches what browsers and curl send for Basic auth. |
|
|
24
|
+
| `--new` | Make a new pad instead of updating this path's pad |
|
|
25
|
+
|
|
26
|
+
A folder becomes a multi-file pad: it needs an `index.html` at its top, and links between its files work as on a website. Uploading the same path again adds a version at the same `url`, which keeps the pad's expiry, view limit and password; `--ttl`, `--burn`, `--views` and `--password` then need `--new`. The edit tokens that allow updates and deletes live in `~/.pad`.
|
|
27
|
+
|
|
28
|
+
## Limits
|
|
29
|
+
|
|
30
|
+
- Text files only, up to 2 MB each: HTML, CSS, JS, JSON, Markdown, SVG, plain text and source code. A folder can hold up to 200 files and 25 MB, including WOFF2 fonts.
|
|
31
|
+
- Images, PDFs, video and other binary files are refused. Describe an image in text, or leave it out.
|
|
32
|
+
- A pad's page runs scripts in a sandbox. It can load scripts from cdnjs, jsDelivr and unpkg, but can't fetch anything or show images from elsewhere.
|
|
33
|
+
|
|
34
|
+
## Privacy
|
|
35
|
+
|
|
36
|
+
The link is public, and pads are for sharing output, so leave secrets, credentials and personal data out of them. When the content is sensitive, add `--password` or `--burn`, and keep `--ttl` short.
|
|
37
|
+
|
|
38
|
+
## Delete
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx pad.fyi delete <file, folder, or pad URL>
|
|
42
|
+
```
|
package/dist/pad.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{homedir as It}from"node:os";import{join as Ct}from"node:path";import{parseArgs as Ft}from"node:util";import{resolve as ir}from"node:path";import{lstat as gt,readdir as yt,readFile as Rr,stat as wt}from"node:fs/promises";import{basename as qr,join as mt,relative as dt,sep as xt}from"node:path";import{createRequire as Qr}from"module";var _r=Qr("/"),V,rt,tt;try{V=_r("worker_threads"),rt=V.Worker,tt=V.isMarkedAsUntransferable}catch(r){}var T=Uint8Array,I=Uint16Array,pr=Int32Array,gr=new T([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),yr=new T([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Tr=new T([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ir=function(r,t){var e=new I(31);for(var n=0;n<31;++n)e[n]=t+=1<<r[n-1];var i=new pr(e[30]);for(var n=1;n<30;++n)for(var a=e[n];a<e[n+1];++a)i[a]=a-e[n]<<5|n;return{b:e,r:i}},V=Ir(gr,2),et=V.b,hr=V.r;et[28]=258,hr[258]=28;var Cr=Ir(yr,0),{b:Bt,r:Ur}=Cr,lr=new I(32768);for(v=0;v<32768;++v)q=(v&43690)>>1|(v&21845)<<1,q=(q&52428)>>2|(q&13107)<<2,q=(q&61680)>>4|(q&3855)<<4,lr[v]=((q&65280)>>8|(q&255)<<8)>>1;var q,v,rr=function(r,t,e){var n=r.length,i=0,a=new I(t);for(;i<n;++i)if(r[i])++a[r[i]-1];var o=new I(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var f;if(e){f=new I(1<<t);var h=15-t;for(i=0;i<n;++i)if(r[i]){var u=i<<4|r[i],s=t-r[i],l=o[r[i]-1]++<<s;for(var g=l|(1<<s)-1;l<=g;++l)f[lr[l]>>h]=u}}else{f=new I(n);for(i=0;i<n;++i)if(r[i])f[i]=lr[o[r[i]-1]++]>>15-r[i]}return f},j=new T(288);for(v=0;v<144;++v)j[v]=8;var v;for(v=144;v<256;++v)j[v]=9;var v;for(v=256;v<280;++v)j[v]=7;var v;for(v=280;v<288;++v)j[v]=8;var v,tr=new T(32);for(v=0;v<32;++v)tr[v]=5;var v,nt=rr(j,9,0);var it=rr(tr,5,0);var Pr=function(r){return(r+7)/8|0},kr=function(r,t,e){if(t==null||t<0)t=0;if(e==null||e>r.length)e=r.length;return new T(r.subarray(t,e))};var at=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],er=function(r,t,e){var n=Error(t||at[r]);if(n.code=r,Error.captureStackTrace)Error.captureStackTrace(n,er);if(!e)throw n;return n};var G=function(r,t,e){e<<=t&7;var n=t/8|0;r[n]|=e,r[n+1]|=e>>8},Q=function(r,t,e){e<<=t&7;var n=t/8|0;r[n]|=e,r[n+1]|=e>>8,r[n+2]|=e>>16},ur=function(r,t){var e=[];for(var n=0;n<r.length;++n)if(r[n])e.push({s:n,f:r[n]});var i=e.length,a=e.slice();if(!i)return{t:Br,l:0};if(i==1){var o=new T(e[0].s+1);return o[e[0].s]=1,{t:o,l:1}}e.sort(function(D,M){return D.f-M.f}),e.push({s:-1,f:25001});var f=e[0],h=e[1],u=0,s=1,l=2;e[0]={s:-1,f:f.f+h.f,l:f,r:h};while(s!=i-1)f=e[e[u].f<e[l].f?u++:l++],h=e[u!=s&&e[u].f<e[l].f?u++:l++],e[s++]={s:-1,f:f.f+h.f,l:f,r:h};var g=a[0].s;for(var n=1;n<i;++n)if(a[n].s>g)g=a[n].s;var y=new I(g+1),m=vr(e[s-1],y,0);if(m>t){var n=0,w=0,U=m-t,B=1<<U;a.sort(function(M,d){return y[d.s]-y[M.s]||M.f-d.f});for(;n<i;++n){var C=a[n].s;if(y[C]>t)w+=B-(1<<m-y[C]),y[C]=t;else break}w>>=U;while(w>0){var O=a[n].s;if(y[O]<t)w-=1<<t-y[O]++-1;else++n}for(;n>=0&&w;--n){var x=a[n].s;if(y[x]==t)--y[x],++w}m=t}return{t:new T(y),l:m}},vr=function(r,t,e){return r.s==-1?Math.max(vr(r.l,t,e+1),vr(r.r,t,e+1)):t[r.s]=e},Dr=function(r){var t=r.length;while(t&&!r[--t]);var e=new I(++t),n=0,i=r[0],a=1,o=function(h){e[n++]=h};for(var f=1;f<=t;++f)if(r[f]==i&&f!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);if(a>2)o(a>10?a-11<<5|28690:a-3<<5|12305),a=0}else if(a>3){o(i),--a;for(;a>6;a-=6)o(8304);if(a>2)o(a-3<<5|8208),a=0}while(a--)o(i);a=1,i=r[f]}return{c:e.subarray(0,n),n:t}},_=function(r,t){var e=0;for(var n=0;n<t.length;++n)e+=r[n]*t[n];return e},br=function(r,t,e){var n=e.length,i=Pr(t+2);r[i]=n&255,r[i+1]=n>>8,r[i+2]=r[i]^255,r[i+3]=r[i+1]^255;for(var a=0;a<n;++a)r[i+a+4]=e[a];return(i+4+n)*8},Mr=function(r,t,e,n,i,a,o,f,h,u,s){G(t,s++,e),++i[256];var l=ur(i,15),{t:g,l:y}=l,m=ur(a,15),{t:w,l:U}=m,B=Dr(g),{c:C,n:O}=B,x=Dr(w),{c:D,n:M}=x,d=new I(19);for(var p=0;p<C.length;++p)++d[C[p]&31];for(var p=0;p<D.length;++p)++d[D[p]&31];var c=ur(d,7),{t:E,l:J}=c,F=19;for(;F>4&&!E[Tr[F-1]];--F);var W=u+5<<3,P=_(i,j)+_(a,tr)+o,k=_(i,g)+_(a,w)+o+14+3*F+_(d,E)+2*d[16]+3*d[17]+7*d[18];if(h>=0&&W<=P&&W<=k)return br(t,s,r.subarray(h,h+u));var N,z,b,L;if(G(t,s,1+(k<P)),s+=2,k<P){N=rr(g,y,0),z=g,b=rr(w,U,0),L=w;var ar=rr(E,J,0);G(t,s,O-257),G(t,s+5,M-1),G(t,s+10,F-4),s+=14;for(var p=0;p<F;++p)G(t,s+3*p,E[Tr[p]]);s+=3*F;var Z=[C,D];for(var K=0;K<2;++K){var H=Z[K];for(var p=0;p<H.length;++p){var R=H[p]&31;if(G(t,s,ar[R]),s+=E[R],R>15)G(t,s,H[p]>>5&127),s+=H[p]>>12}}}else N=nt,z=j,b=it,L=tr;for(var p=0;p<f;++p){var S=n[p];if(S>255){var R=S>>18&31;if(Q(t,s,N[R+257]),s+=z[R+257],R>7)G(t,s,S>>23&31),s+=gr[R];var X=S&31;if(Q(t,s,b[X]),s+=L[X],X>3)Q(t,s,S>>5&8191),s+=yr[X]}else Q(t,s,N[S]),s+=z[S]}return Q(t,s,N[256]),s+z[256]},ot=new pr([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Br=new T(0),st=function(r,t,e,n,i,a){var o=a.z||r.length,f=new T(n+o+5*(1+Math.ceil(o/7000))+i),h=f.subarray(n,f.length-i),u=a.l,s=(a.r||0)&7;if(t){if(s)h[0]=a.r>>3;var l=ot[t-1],g=l>>13,y=l&8191,m=(1<<e)-1,w=a.p||new I(32768),U=a.h||new I(m+1),B=Math.ceil(e/3),C=2*B,O=function(fr){return(r[fr]^r[fr+1]<<B^r[fr+2]<<C)&m},x=new pr(25000),D=new I(288),M=new I(32),d=0,p=0,c=a.i||0,E=0,J=a.w||0,F=0;for(;c+2<o;++c){var W=O(c),P=c&32767,k=U[W];if(w[P]=k,U[W]=P,J<=c){var N=o-c;if((d>7000||E>24576)&&(N>423||!u)){s=Mr(r,h,0,x,D,M,p,E,F,c-F,s),E=d=p=0,F=c;for(var z=0;z<286;++z)D[z]=0;for(var z=0;z<30;++z)M[z]=0}var b=2,L=0,ar=y,Z=P-k&32767;if(N>2&&W==O(c-Z)){var K=Math.min(g,N)-1,H=Math.min(32767,c),R=Math.min(258,N);while(Z<=H&&--ar&&P!=k){if(r[c+b]==r[c+b-Z]){var S=0;for(;S<R&&r[c+S]==r[c+S-Z];++S);if(S>b){if(b=S,L=Z,S>K)break;var X=Math.min(Z,S-2),xr=0;for(var z=0;z<X;++z){var or=c-Z+z&32767,Kr=w[or],zr=or-Kr&32767;if(zr>xr)xr=zr,k=or}}}P=k,k=w[P],Z+=P-k&32767}}if(L){x[E++]=268435456|hr[b]<<18|Ur[L];var Ar=hr[b]&31,Sr=Ur[L]&31;p+=gr[Ar]+yr[Sr],++D[257+Ar],++M[Sr],J=c+b,++d}else x[E++]=r[c],++D[r[c]]}}for(c=Math.max(c,J);c<o;++c)x[E++]=r[c],++D[r[c]];if(s=Mr(r,h,u,x,D,M,p,E,F,c-F,s),!u)a.r=s&7|h[s/8|0]<<3,s-=7,a.h=U,a.p=w,a.i=c,a.w=J}else{for(var c=a.w||0;c<o+u;c+=65535){var sr=c+65535;if(sr>=o)h[s/8|0]=u,sr=o;s=br(h,s+1,r.subarray(c,sr))}a.i=o}return kr(f,0,n+Pr(s)+i)},ft=function(){var r=new Int32Array(256);for(var t=0;t<256;++t){var e=t,n=9;while(--n)e=(e&1&&-306674912)^e>>>1;r[t]=e}return r}(),ut=function(){var r=-1;return{p:function(t){var e=r;for(var n=0;n<t.length;++n)e=ft[e&255^t[n]]^e>>>8;r=e},d:function(){return~r}}};var ht=function(r,t,e,n,i){if(!i){if(i={l:1},t.dictionary){var a=t.dictionary.subarray(-32768),o=new T(a.length+r.length);o.set(a),o.set(r,a.length),r=o,i.w=a.length}}return st(r,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):20:12+t.mem,e,n,i)},Or=function(r,t){var e={};for(var n in r)e[n]=r[n];for(var n in t)e[n]=t[n];return e};var A=function(r,t,e){for(;e;++t)r[t]=e,e>>>=8};function lt(r,t){return ht(r,t||{},0,0)}var Nr=function(r,t,e,n){for(var i in r){var a=r[i],o=t+i,f=n;if(Array.isArray(a))f=Or(n,a[1]),a=a[0];if(ArrayBuffer.isView(a))e[o]=[a,f];else e[o+="/"]=[new T(0),f],Nr(a,o,e,n)}},Er=typeof TextEncoder<"u"&&new TextEncoder,vt=typeof TextDecoder<"u"&&new TextDecoder,ct=0;try{vt.decode(Br,{stream:!0}),ct=1}catch(r){}function Fr(r,t){if(t){var e=new T(r.length);for(var n=0;n<r.length;++n)e[n]=r.charCodeAt(n);return e}if(Er)return Er.encode(r);var i=r.length,a=new T(r.length+(r.length>>1)),o=0,f=function(s){a[o++]=s};for(var n=0;n<i;++n){if(o+5>a.length){var h=new T(o+8+(i-n<<1));h.set(a),a=h}var u=r.charCodeAt(n);if(u<128||t)f(u);else if(u<2048)f(192|u>>6),f(128|u&63);else if(u>55295&&u<57344)u=65536+(u&1047552)|r.charCodeAt(++n)&1023,f(240|u>>18),f(128|u>>12&63),f(128|u>>6&63),f(128|u&63);else f(224|u>>12),f(128|u>>6&63),f(128|u&63)}return kr(a,0,o)}var cr=function(r){var t=0;if(r)for(var e in r){var n=r[e].length;if(n>65535)er(9);t+=n+4}return t},$r=function(r,t,e,n,i,a,o,f){var h=n.length,u=e.extra,s=f&&f.length,l=cr(u);if(A(r,t,o!=null?33639248:67324752),t+=4,o!=null)r[t++]=20,r[t++]=e.os;r[t]=20,t+=2,r[t++]=e.flag<<1|(a<0&&8),r[t++]=i&&8,r[t++]=e.compression&255,r[t++]=e.compression>>8;var g=new Date(e.mtime==null?Date.now():e.mtime),y=g.getFullYear()-1980;if(y<0||y>119)er(10);if(A(r,t,y<<25|g.getMonth()+1<<21|g.getDate()<<16|g.getHours()<<11|g.getMinutes()<<5|g.getSeconds()>>1),t+=4,a!=-1)A(r,t,e.crc),A(r,t+4,a<0?-a-2:a),A(r,t+8,e.size);if(A(r,t+12,h),A(r,t+14,l),t+=16,o!=null)A(r,t,s),A(r,t+6,e.attrs),A(r,t+10,o),t+=14;if(r.set(n,t),t+=h,l)for(var m in u){var w=u[m],U=w.length;A(r,t,+m),A(r,t+2,U),r.set(w,t+4),t+=4+U}if(s)r.set(f,t),t+=s;return t},pt=function(r,t,e,n,i){A(r,t,101010256),A(r,t+8,e),A(r,t+10,e),A(r,t+12,n),A(r,t+16,i)};function Zr(r,t){if(!t)t={};var e={},n=[];Nr(r,"",e,t);var i=0,a=0;for(var o in e){var f=e[o],h=f[0],u=f[1],s=u.level==0?0:8,l=Fr(o),g=l.length,y=u.comment,m=y&&Fr(y),w=m&&m.length,U=cr(u.extra);if(g>65535)er(11);var B=s?lt(h,u):h,C=B.length,O=ut();O.p(h),n.push(Or(u,{size:h.length,crc:O.d(),c:B,f:l,m,u:g!=o.length||m&&y.length!=w,o:i,compression:s})),i+=30+g+U+C,a+=76+2*(g+U)+(w||0)+C}var x=new T(a+22),D=i,M=a-i;for(var d=0;d<n.length;++d){var l=n[d];$r(x,l.o,l,l.f,l.u,l.c.length);var p=30+l.f.length+cr(l.extra);x.set(l.c,l.o+p),$r(x,i,l,l.f,l.u,l.c.length,l.o,l.m),i+=16+p+(l.m?l.m.length:0)}return pt(x,i,n.length,M,D),x}var nr=26214400,Gr=200,zt=new Set([".git","node_modules",".DS_Store"]),Lr=async(r)=>{let t=[];for(let e of await yt(r,{withFileTypes:!0})){if(zt.has(e.name))continue;let n=mt(r,e.name);if(e.isSymbolicLink())throw Error(`pad.fyi uploads no symlinks; copy the file in instead: ${n}`);if(e.isDirectory())t.push(...await Lr(n));else if(e.isFile())t.push({path:n,size:(await gt(n)).size})}return t},jr=async(r)=>{let t=await wt(r);if(!t.isDirectory()){if(t.size>nr)throw Error(`${r} is over pad.fyi's ${nr}-byte limit.`);return{body:await Rr(r),name:qr(r)}}let e=await Lr(r);if(e.length>Gr)throw Error(`A folder pad can hold up to ${Gr} files.`);if(e.reduce((i,a)=>i+a.size,0)>nr)throw Error(`A folder pad can hold up to ${nr} bytes.`);let n={};for(let i of e)n[dt(r,i.path).split(xt).join("/")]=await Rr(i.path);return{body:Zr(n),name:`${qr(r)}.zip`}};import{link as At,readFile as Jr,rename as St,rm as wr,writeFile as Wr}from"node:fs/promises";import{setTimeout as Tt}from"node:timers/promises";var Ut=async(r)=>{let t=Number(await Jr(r,"utf8").catch(()=>""));if(!Number.isInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}},Dt=async(r,t)=>{let e=`${r}.lock`;for(;;){let n=`${e}.${process.pid}`;await Wr(n,String(process.pid),{mode:384});try{return await At(n,e),e}catch(i){if(i.code!=="EEXIST")throw i;if(await Ut(e))await t(100);else await wr(e,{force:!0})}finally{await wr(n,{force:!0})}}},Mt=async(r)=>{try{return JSON.parse(await Jr(r,"utf8"))}catch(t){if(t.code!=="ENOENT")throw t;return{pads:{}}}},mr=async(r,t,e=Tt)=>{let n=await Dt(r,e);try{let i=await Mt(r),a=await t(i),o=`${r}.${process.pid}.tmp`;return await Wr(o,`${JSON.stringify(i,null,"\t")}
|
|
3
|
+
`,{mode:384}),await St(o,r),a}finally{await wr(n,{force:!0})}};class Y extends Error{status;constructor(r,t){super(r);this.status=t}}var dr=async(r,t,e)=>{let n=await r.fetch(`${r.api}${t}`,e);if(n.status===204)return;let i=await n.json().catch(()=>({}));if(!n.ok||i.success!==!0){let a=typeof i.error==="string"?i.error:`pad.fyi answered HTTP ${n.status}.`;throw new Y(a,n.status)}return i.result},Et=(r)=>String.fromCharCode(...new TextEncoder().encode(r)),Hr=async(r,t,e)=>{let n=ir(t),{body:i,name:a}=await jr(n);return mr(r.storeFile,async(o)=>{let f=e.new?void 0:o.pads[n];if(f&&Date.parse(f.expiresAt)>Date.now()){if(e.ttl||e.burn||e.views||e.password!==void 0)throw new Y(`${t} already has a pad, which keeps its settings. Add --new to make one with these.`,0);try{let s=await dr(r,`/v1/pads/${f.id}?name=${encodeURIComponent(a)}`,{body:i,headers:{Authorization:`Bearer ${f.editToken}`},method:"PUT"});return{...f,...s}}catch(s){if(!(s instanceof Y&&s.status===404))throw s}}let h=new URLSearchParams({name:a});if(e.ttl)h.set("ttl",e.ttl);if(e.views)h.set("views",e.views);if(e.burn)h.set("burn","");let u=await dr(r,`/v1/pads?${h}`,{body:i,headers:e.password===void 0?{}:{"Pad-Password":Et(e.password)},method:"POST"});return o.pads[n]={editToken:u.editToken,expiresAt:u.expiresAt,id:u.id,url:u.url},u},r.wait)},Xr=async(r,t)=>mr(r.storeFile,async(e)=>{let n=/^(?:https?:\/\/)?([0-9a-z]{10})(?:-v\d+)?(?:\.pad\.fyi)?\/?$/i.exec(t.trim())?.[1]?.toLowerCase(),i=e.pads[ir(t)]?[ir(t),e.pads[ir(t)]]:Object.entries(e.pads).find(([,f])=>f.id===n);if(!i?.[1])throw new Y(`No edit token for ${t} in ${r.storeFile}.`,0);let[a,o]=i;return await dr(r,`/v1/pads/${o.id}`,{headers:{Authorization:`Bearer ${o.editToken}`},method:"DELETE"}).catch((f)=>{if(!(f instanceof Y&&f.status===404))throw f}),delete e.pads[a],o},r.wait);var Vr=`Usage:
|
|
4
|
+
pad.fyi upload <file or folder> [--ttl 1h|1d|7d|30d] [--burn] [--views N] [--password P] [--new] [--json]
|
|
5
|
+
pad.fyi delete <file, folder, pad URL or ID> [--json]
|
|
6
|
+
|
|
7
|
+
A folder becomes a multi-file pad, served from its index.html. Uploading the same
|
|
8
|
+
path again adds a version at the same URL; --new makes a new pad instead.
|
|
9
|
+
Edit tokens are kept in ~/.pad.`,Yr=async(r,t,e=console.log,n=console.error)=>{let i;try{i=$t(r)}catch(u){return n(`${u.message}
|
|
10
|
+
|
|
11
|
+
${Vr}`),2}let{positionals:a,values:o}=i,[f,h]=a;if(o.help||h===void 0||a.length>2||f!=="upload"&&f!=="delete")return(o.help?e:n)(Vr),o.help?0:2;try{if(f==="delete"){let s=await Xr(t,h);return e(o.json?JSON.stringify({deleted:s.url}):`Deleted ${s.url}`),0}let u=await Hr(t,h,o);return e(o.json?JSON.stringify(u):`${u.url}
|
|
12
|
+
Version ${u.version}: ${u.versionUrl}
|
|
13
|
+
Expires ${u.expiresAt}`),0}catch(u){return n(u instanceof Error?u.message:String(u)),1}},$t=(r)=>Ft({allowPositionals:!0,args:r,options:{burn:{type:"boolean"},help:{short:"h",type:"boolean"},json:{type:"boolean"},new:{type:"boolean"},password:{type:"string"},ttl:{type:"string"},views:{type:"string"}}});var{PAD_API:Pt,PAD_STORE:kt}=process.env;process.exitCode=await Yr(process.argv.slice(2),{api:Pt??"https://pad.fyi",fetch,storeFile:kt??Ct(It(),".pad")});
|
package/package.json
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"bin": {
|
|
3
|
+
"pad.fyi": "dist/pad.mjs"
|
|
4
|
+
},
|
|
5
|
+
"description": "Short links for files, for developers and agents.",
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"fflate": "0.8.3"
|
|
8
|
+
},
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md",
|
|
15
|
+
"SKILL.md"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://pad.fyi",
|
|
18
|
+
"license": "UNLICENSED",
|
|
19
|
+
"name": "pad.fyi",
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"provenance": false
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/okay-e9g/pad.fyi.git"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "bun build ./src/bin.ts --target=node --format=esm --minify --outfile=dist/pad.mjs",
|
|
30
|
+
"prepublishOnly": "bun run build",
|
|
31
|
+
"typecheck": "tsc --noEmit"
|
|
32
|
+
},
|
|
33
|
+
"type": "module",
|
|
34
|
+
"version": "0.0.1"
|
|
35
|
+
}
|