flypod 0.6.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +425 -187
- package/dist/bin/deploy.js +499 -1038
- package/dist/cli-g2wb2hxm.js +1435 -0
- package/dist/src/cli/client.d.ts +99 -0
- package/dist/src/cli/commands.d.ts +68 -0
- package/dist/src/cli/paths.d.ts +17 -0
- package/dist/src/cli/projects.d.ts +35 -0
- package/dist/src/cli/session.d.ts +11 -0
- package/dist/src/cli/skill.d.ts +135 -0
- package/dist/src/cli/source.d.ts +7 -0
- package/dist/src/cli.d.ts +72 -0
- package/dist/src/cli.js +1 -1
- package/dist/src/deploy-source.d.ts +20 -0
- package/package.json +14 -16
- package/dist/cli-ynzcc4xy.js +0 -709
|
@@ -0,0 +1,1435 @@
|
|
|
1
|
+
// src/cli.ts
|
|
2
|
+
import { readdir, readFile as readFile3, stat as stat2 } from "node:fs/promises";
|
|
3
|
+
import { join as join3, relative } from "node:path";
|
|
4
|
+
|
|
5
|
+
// ../../node_modules/.bun/fflate@0.8.3/node_modules/fflate/esm/index.mjs
|
|
6
|
+
import { createRequire } from "module";
|
|
7
|
+
var require2 = createRequire("/");
|
|
8
|
+
var _a;
|
|
9
|
+
var Worker;
|
|
10
|
+
var isMarkedAsUntransferable;
|
|
11
|
+
try {
|
|
12
|
+
_a = require2("worker_threads"), Worker = _a.Worker, isMarkedAsUntransferable = _a.isMarkedAsUntransferable;
|
|
13
|
+
} catch (e) {}
|
|
14
|
+
var u8 = Uint8Array;
|
|
15
|
+
var u16 = Uint16Array;
|
|
16
|
+
var i32 = Int32Array;
|
|
17
|
+
var fleb = new u8([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]);
|
|
18
|
+
var fdeb = new u8([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]);
|
|
19
|
+
var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
|
|
20
|
+
var freb = function(eb, start) {
|
|
21
|
+
var b = new u16(31);
|
|
22
|
+
for (var i = 0;i < 31; ++i) {
|
|
23
|
+
b[i] = start += 1 << eb[i - 1];
|
|
24
|
+
}
|
|
25
|
+
var r = new i32(b[30]);
|
|
26
|
+
for (var i = 1;i < 30; ++i) {
|
|
27
|
+
for (var j = b[i];j < b[i + 1]; ++j) {
|
|
28
|
+
r[j] = j - b[i] << 5 | i;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return { b, r };
|
|
32
|
+
};
|
|
33
|
+
var _a = freb(fleb, 2);
|
|
34
|
+
var fl = _a.b;
|
|
35
|
+
var revfl = _a.r;
|
|
36
|
+
fl[28] = 258, revfl[258] = 28;
|
|
37
|
+
var _b = freb(fdeb, 0);
|
|
38
|
+
var fd = _b.b;
|
|
39
|
+
var revfd = _b.r;
|
|
40
|
+
var rev = new u16(32768);
|
|
41
|
+
for (i = 0;i < 32768; ++i) {
|
|
42
|
+
x = (i & 43690) >> 1 | (i & 21845) << 1;
|
|
43
|
+
x = (x & 52428) >> 2 | (x & 13107) << 2;
|
|
44
|
+
x = (x & 61680) >> 4 | (x & 3855) << 4;
|
|
45
|
+
rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
|
|
46
|
+
}
|
|
47
|
+
var x;
|
|
48
|
+
var i;
|
|
49
|
+
var hMap = function(cd, mb, r) {
|
|
50
|
+
var s = cd.length;
|
|
51
|
+
var i2 = 0;
|
|
52
|
+
var l = new u16(mb);
|
|
53
|
+
for (;i2 < s; ++i2) {
|
|
54
|
+
if (cd[i2])
|
|
55
|
+
++l[cd[i2] - 1];
|
|
56
|
+
}
|
|
57
|
+
var le = new u16(mb);
|
|
58
|
+
for (i2 = 1;i2 < mb; ++i2) {
|
|
59
|
+
le[i2] = le[i2 - 1] + l[i2 - 1] << 1;
|
|
60
|
+
}
|
|
61
|
+
var co;
|
|
62
|
+
if (r) {
|
|
63
|
+
co = new u16(1 << mb);
|
|
64
|
+
var rvb = 15 - mb;
|
|
65
|
+
for (i2 = 0;i2 < s; ++i2) {
|
|
66
|
+
if (cd[i2]) {
|
|
67
|
+
var sv = i2 << 4 | cd[i2];
|
|
68
|
+
var r_1 = mb - cd[i2];
|
|
69
|
+
var v = le[cd[i2] - 1]++ << r_1;
|
|
70
|
+
for (var m = v | (1 << r_1) - 1;v <= m; ++v) {
|
|
71
|
+
co[rev[v] >> rvb] = sv;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
co = new u16(s);
|
|
77
|
+
for (i2 = 0;i2 < s; ++i2) {
|
|
78
|
+
if (cd[i2]) {
|
|
79
|
+
co[i2] = rev[le[cd[i2] - 1]++] >> 15 - cd[i2];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return co;
|
|
84
|
+
};
|
|
85
|
+
var flt = new u8(288);
|
|
86
|
+
for (i = 0;i < 144; ++i)
|
|
87
|
+
flt[i] = 8;
|
|
88
|
+
var i;
|
|
89
|
+
for (i = 144;i < 256; ++i)
|
|
90
|
+
flt[i] = 9;
|
|
91
|
+
var i;
|
|
92
|
+
for (i = 256;i < 280; ++i)
|
|
93
|
+
flt[i] = 7;
|
|
94
|
+
var i;
|
|
95
|
+
for (i = 280;i < 288; ++i)
|
|
96
|
+
flt[i] = 8;
|
|
97
|
+
var i;
|
|
98
|
+
var fdt = new u8(32);
|
|
99
|
+
for (i = 0;i < 32; ++i)
|
|
100
|
+
fdt[i] = 5;
|
|
101
|
+
var i;
|
|
102
|
+
var flm = /* @__PURE__ */ hMap(flt, 9, 0);
|
|
103
|
+
var fdm = /* @__PURE__ */ hMap(fdt, 5, 0);
|
|
104
|
+
var shft = function(p) {
|
|
105
|
+
return (p + 7) / 8 | 0;
|
|
106
|
+
};
|
|
107
|
+
var slc = function(v, s, e) {
|
|
108
|
+
if (s == null || s < 0)
|
|
109
|
+
s = 0;
|
|
110
|
+
if (e == null || e > v.length)
|
|
111
|
+
e = v.length;
|
|
112
|
+
return new u8(v.subarray(s, e));
|
|
113
|
+
};
|
|
114
|
+
var ec = [
|
|
115
|
+
"unexpected EOF",
|
|
116
|
+
"invalid block type",
|
|
117
|
+
"invalid length/literal",
|
|
118
|
+
"invalid distance",
|
|
119
|
+
"stream finished",
|
|
120
|
+
"no stream handler",
|
|
121
|
+
,
|
|
122
|
+
"no callback",
|
|
123
|
+
"invalid UTF-8 data",
|
|
124
|
+
"extra field too long",
|
|
125
|
+
"date not in range 1980-2099",
|
|
126
|
+
"filename too long",
|
|
127
|
+
"stream finishing",
|
|
128
|
+
"invalid zip data"
|
|
129
|
+
];
|
|
130
|
+
var err = function(ind, msg, nt) {
|
|
131
|
+
var e = new Error(msg || ec[ind]);
|
|
132
|
+
e.code = ind;
|
|
133
|
+
if (Error.captureStackTrace)
|
|
134
|
+
Error.captureStackTrace(e, err);
|
|
135
|
+
if (!nt)
|
|
136
|
+
throw e;
|
|
137
|
+
return e;
|
|
138
|
+
};
|
|
139
|
+
var wbits = function(d, p, v) {
|
|
140
|
+
v <<= p & 7;
|
|
141
|
+
var o = p / 8 | 0;
|
|
142
|
+
d[o] |= v;
|
|
143
|
+
d[o + 1] |= v >> 8;
|
|
144
|
+
};
|
|
145
|
+
var wbits16 = function(d, p, v) {
|
|
146
|
+
v <<= p & 7;
|
|
147
|
+
var o = p / 8 | 0;
|
|
148
|
+
d[o] |= v;
|
|
149
|
+
d[o + 1] |= v >> 8;
|
|
150
|
+
d[o + 2] |= v >> 16;
|
|
151
|
+
};
|
|
152
|
+
var hTree = function(d, mb) {
|
|
153
|
+
var t = [];
|
|
154
|
+
for (var i2 = 0;i2 < d.length; ++i2) {
|
|
155
|
+
if (d[i2])
|
|
156
|
+
t.push({ s: i2, f: d[i2] });
|
|
157
|
+
}
|
|
158
|
+
var s = t.length;
|
|
159
|
+
var t2 = t.slice();
|
|
160
|
+
if (!s)
|
|
161
|
+
return { t: et, l: 0 };
|
|
162
|
+
if (s == 1) {
|
|
163
|
+
var v = new u8(t[0].s + 1);
|
|
164
|
+
v[t[0].s] = 1;
|
|
165
|
+
return { t: v, l: 1 };
|
|
166
|
+
}
|
|
167
|
+
t.sort(function(a, b) {
|
|
168
|
+
return a.f - b.f;
|
|
169
|
+
});
|
|
170
|
+
t.push({ s: -1, f: 25001 });
|
|
171
|
+
var l = t[0], r = t[1], i0 = 0, i1 = 1, i22 = 2;
|
|
172
|
+
t[0] = { s: -1, f: l.f + r.f, l, r };
|
|
173
|
+
while (i1 != s - 1) {
|
|
174
|
+
l = t[t[i0].f < t[i22].f ? i0++ : i22++];
|
|
175
|
+
r = t[i0 != i1 && t[i0].f < t[i22].f ? i0++ : i22++];
|
|
176
|
+
t[i1++] = { s: -1, f: l.f + r.f, l, r };
|
|
177
|
+
}
|
|
178
|
+
var maxSym = t2[0].s;
|
|
179
|
+
for (var i2 = 1;i2 < s; ++i2) {
|
|
180
|
+
if (t2[i2].s > maxSym)
|
|
181
|
+
maxSym = t2[i2].s;
|
|
182
|
+
}
|
|
183
|
+
var tr = new u16(maxSym + 1);
|
|
184
|
+
var mbt = ln(t[i1 - 1], tr, 0);
|
|
185
|
+
if (mbt > mb) {
|
|
186
|
+
var i2 = 0, dt = 0;
|
|
187
|
+
var lft = mbt - mb, cst = 1 << lft;
|
|
188
|
+
t2.sort(function(a, b) {
|
|
189
|
+
return tr[b.s] - tr[a.s] || a.f - b.f;
|
|
190
|
+
});
|
|
191
|
+
for (;i2 < s; ++i2) {
|
|
192
|
+
var i2_1 = t2[i2].s;
|
|
193
|
+
if (tr[i2_1] > mb) {
|
|
194
|
+
dt += cst - (1 << mbt - tr[i2_1]);
|
|
195
|
+
tr[i2_1] = mb;
|
|
196
|
+
} else
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
dt >>= lft;
|
|
200
|
+
while (dt > 0) {
|
|
201
|
+
var i2_2 = t2[i2].s;
|
|
202
|
+
if (tr[i2_2] < mb)
|
|
203
|
+
dt -= 1 << mb - tr[i2_2]++ - 1;
|
|
204
|
+
else
|
|
205
|
+
++i2;
|
|
206
|
+
}
|
|
207
|
+
for (;i2 >= 0 && dt; --i2) {
|
|
208
|
+
var i2_3 = t2[i2].s;
|
|
209
|
+
if (tr[i2_3] == mb) {
|
|
210
|
+
--tr[i2_3];
|
|
211
|
+
++dt;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
mbt = mb;
|
|
215
|
+
}
|
|
216
|
+
return { t: new u8(tr), l: mbt };
|
|
217
|
+
};
|
|
218
|
+
var ln = function(n, l, d) {
|
|
219
|
+
return n.s == -1 ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1)) : l[n.s] = d;
|
|
220
|
+
};
|
|
221
|
+
var lc = function(c) {
|
|
222
|
+
var s = c.length;
|
|
223
|
+
while (s && !c[--s])
|
|
224
|
+
;
|
|
225
|
+
var cl = new u16(++s);
|
|
226
|
+
var cli = 0, cln = c[0], cls = 1;
|
|
227
|
+
var w = function(v) {
|
|
228
|
+
cl[cli++] = v;
|
|
229
|
+
};
|
|
230
|
+
for (var i2 = 1;i2 <= s; ++i2) {
|
|
231
|
+
if (c[i2] == cln && i2 != s)
|
|
232
|
+
++cls;
|
|
233
|
+
else {
|
|
234
|
+
if (!cln && cls > 2) {
|
|
235
|
+
for (;cls > 138; cls -= 138)
|
|
236
|
+
w(32754);
|
|
237
|
+
if (cls > 2) {
|
|
238
|
+
w(cls > 10 ? cls - 11 << 5 | 28690 : cls - 3 << 5 | 12305);
|
|
239
|
+
cls = 0;
|
|
240
|
+
}
|
|
241
|
+
} else if (cls > 3) {
|
|
242
|
+
w(cln), --cls;
|
|
243
|
+
for (;cls > 6; cls -= 6)
|
|
244
|
+
w(8304);
|
|
245
|
+
if (cls > 2)
|
|
246
|
+
w(cls - 3 << 5 | 8208), cls = 0;
|
|
247
|
+
}
|
|
248
|
+
while (cls--)
|
|
249
|
+
w(cln);
|
|
250
|
+
cls = 1;
|
|
251
|
+
cln = c[i2];
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return { c: cl.subarray(0, cli), n: s };
|
|
255
|
+
};
|
|
256
|
+
var clen = function(cf, cl) {
|
|
257
|
+
var l = 0;
|
|
258
|
+
for (var i2 = 0;i2 < cl.length; ++i2)
|
|
259
|
+
l += cf[i2] * cl[i2];
|
|
260
|
+
return l;
|
|
261
|
+
};
|
|
262
|
+
var wfblk = function(out, pos, dat) {
|
|
263
|
+
var s = dat.length;
|
|
264
|
+
var o = shft(pos + 2);
|
|
265
|
+
out[o] = s & 255;
|
|
266
|
+
out[o + 1] = s >> 8;
|
|
267
|
+
out[o + 2] = out[o] ^ 255;
|
|
268
|
+
out[o + 3] = out[o + 1] ^ 255;
|
|
269
|
+
for (var i2 = 0;i2 < s; ++i2)
|
|
270
|
+
out[o + i2 + 4] = dat[i2];
|
|
271
|
+
return (o + 4 + s) * 8;
|
|
272
|
+
};
|
|
273
|
+
var wblk = function(dat, out, final, syms, lf, df, eb, li, bs, bl, p) {
|
|
274
|
+
wbits(out, p++, final);
|
|
275
|
+
++lf[256];
|
|
276
|
+
var _a2 = hTree(lf, 15), dlt = _a2.t, mlb = _a2.l;
|
|
277
|
+
var _b2 = hTree(df, 15), ddt = _b2.t, mdb = _b2.l;
|
|
278
|
+
var _c = lc(dlt), lclt = _c.c, nlc = _c.n;
|
|
279
|
+
var _d = lc(ddt), lcdt = _d.c, ndc = _d.n;
|
|
280
|
+
var lcfreq = new u16(19);
|
|
281
|
+
for (var i2 = 0;i2 < lclt.length; ++i2)
|
|
282
|
+
++lcfreq[lclt[i2] & 31];
|
|
283
|
+
for (var i2 = 0;i2 < lcdt.length; ++i2)
|
|
284
|
+
++lcfreq[lcdt[i2] & 31];
|
|
285
|
+
var _e = hTree(lcfreq, 7), lct = _e.t, mlcb = _e.l;
|
|
286
|
+
var nlcc = 19;
|
|
287
|
+
for (;nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)
|
|
288
|
+
;
|
|
289
|
+
var flen = bl + 5 << 3;
|
|
290
|
+
var ftlen = clen(lf, flt) + clen(df, fdt) + eb;
|
|
291
|
+
var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];
|
|
292
|
+
if (bs >= 0 && flen <= ftlen && flen <= dtlen)
|
|
293
|
+
return wfblk(out, p, dat.subarray(bs, bs + bl));
|
|
294
|
+
var lm, ll, dm, dl;
|
|
295
|
+
wbits(out, p, 1 + (dtlen < ftlen)), p += 2;
|
|
296
|
+
if (dtlen < ftlen) {
|
|
297
|
+
lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;
|
|
298
|
+
var llm = hMap(lct, mlcb, 0);
|
|
299
|
+
wbits(out, p, nlc - 257);
|
|
300
|
+
wbits(out, p + 5, ndc - 1);
|
|
301
|
+
wbits(out, p + 10, nlcc - 4);
|
|
302
|
+
p += 14;
|
|
303
|
+
for (var i2 = 0;i2 < nlcc; ++i2)
|
|
304
|
+
wbits(out, p + 3 * i2, lct[clim[i2]]);
|
|
305
|
+
p += 3 * nlcc;
|
|
306
|
+
var lcts = [lclt, lcdt];
|
|
307
|
+
for (var it = 0;it < 2; ++it) {
|
|
308
|
+
var clct = lcts[it];
|
|
309
|
+
for (var i2 = 0;i2 < clct.length; ++i2) {
|
|
310
|
+
var len = clct[i2] & 31;
|
|
311
|
+
wbits(out, p, llm[len]), p += lct[len];
|
|
312
|
+
if (len > 15)
|
|
313
|
+
wbits(out, p, clct[i2] >> 5 & 127), p += clct[i2] >> 12;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
} else {
|
|
317
|
+
lm = flm, ll = flt, dm = fdm, dl = fdt;
|
|
318
|
+
}
|
|
319
|
+
for (var i2 = 0;i2 < li; ++i2) {
|
|
320
|
+
var sym = syms[i2];
|
|
321
|
+
if (sym > 255) {
|
|
322
|
+
var len = sym >> 18 & 31;
|
|
323
|
+
wbits16(out, p, lm[len + 257]), p += ll[len + 257];
|
|
324
|
+
if (len > 7)
|
|
325
|
+
wbits(out, p, sym >> 23 & 31), p += fleb[len];
|
|
326
|
+
var dst = sym & 31;
|
|
327
|
+
wbits16(out, p, dm[dst]), p += dl[dst];
|
|
328
|
+
if (dst > 3)
|
|
329
|
+
wbits16(out, p, sym >> 5 & 8191), p += fdeb[dst];
|
|
330
|
+
} else {
|
|
331
|
+
wbits16(out, p, lm[sym]), p += ll[sym];
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
wbits16(out, p, lm[256]);
|
|
335
|
+
return p + ll[256];
|
|
336
|
+
};
|
|
337
|
+
var deo = /* @__PURE__ */ new i32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);
|
|
338
|
+
var et = /* @__PURE__ */ new u8(0);
|
|
339
|
+
var dflt = function(dat, lvl, plvl, pre, post, st) {
|
|
340
|
+
var s = st.z || dat.length;
|
|
341
|
+
var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7000)) + post);
|
|
342
|
+
var w = o.subarray(pre, o.length - post);
|
|
343
|
+
var lst = st.l;
|
|
344
|
+
var pos = (st.r || 0) & 7;
|
|
345
|
+
if (lvl) {
|
|
346
|
+
if (pos)
|
|
347
|
+
w[0] = st.r >> 3;
|
|
348
|
+
var opt = deo[lvl - 1];
|
|
349
|
+
var n = opt >> 13, c = opt & 8191;
|
|
350
|
+
var msk_1 = (1 << plvl) - 1;
|
|
351
|
+
var prev = st.p || new u16(32768), head = st.h || new u16(msk_1 + 1);
|
|
352
|
+
var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;
|
|
353
|
+
var hsh = function(i3) {
|
|
354
|
+
return (dat[i3] ^ dat[i3 + 1] << bs1_1 ^ dat[i3 + 2] << bs2_1) & msk_1;
|
|
355
|
+
};
|
|
356
|
+
var syms = new i32(25000);
|
|
357
|
+
var lf = new u16(288), df = new u16(32);
|
|
358
|
+
var lc_1 = 0, eb = 0, i2 = st.i || 0, li = 0, wi = st.w || 0, bs = 0;
|
|
359
|
+
for (;i2 + 2 < s; ++i2) {
|
|
360
|
+
var hv = hsh(i2);
|
|
361
|
+
var imod = i2 & 32767, pimod = head[hv];
|
|
362
|
+
prev[imod] = pimod;
|
|
363
|
+
head[hv] = imod;
|
|
364
|
+
if (wi <= i2) {
|
|
365
|
+
var rem = s - i2;
|
|
366
|
+
if ((lc_1 > 7000 || li > 24576) && (rem > 423 || !lst)) {
|
|
367
|
+
pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i2 - bs, pos);
|
|
368
|
+
li = lc_1 = eb = 0, bs = i2;
|
|
369
|
+
for (var j = 0;j < 286; ++j)
|
|
370
|
+
lf[j] = 0;
|
|
371
|
+
for (var j = 0;j < 30; ++j)
|
|
372
|
+
df[j] = 0;
|
|
373
|
+
}
|
|
374
|
+
var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;
|
|
375
|
+
if (rem > 2 && hv == hsh(i2 - dif)) {
|
|
376
|
+
var maxn = Math.min(n, rem) - 1;
|
|
377
|
+
var maxd = Math.min(32767, i2);
|
|
378
|
+
var ml = Math.min(258, rem);
|
|
379
|
+
while (dif <= maxd && --ch_1 && imod != pimod) {
|
|
380
|
+
if (dat[i2 + l] == dat[i2 + l - dif]) {
|
|
381
|
+
var nl = 0;
|
|
382
|
+
for (;nl < ml && dat[i2 + nl] == dat[i2 + nl - dif]; ++nl)
|
|
383
|
+
;
|
|
384
|
+
if (nl > l) {
|
|
385
|
+
l = nl, d = dif;
|
|
386
|
+
if (nl > maxn)
|
|
387
|
+
break;
|
|
388
|
+
var mmd = Math.min(dif, nl - 2);
|
|
389
|
+
var md = 0;
|
|
390
|
+
for (var j = 0;j < mmd; ++j) {
|
|
391
|
+
var ti = i2 - dif + j & 32767;
|
|
392
|
+
var pti = prev[ti];
|
|
393
|
+
var cd = ti - pti & 32767;
|
|
394
|
+
if (cd > md)
|
|
395
|
+
md = cd, pimod = ti;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
imod = pimod, pimod = prev[imod];
|
|
400
|
+
dif += imod - pimod & 32767;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
if (d) {
|
|
404
|
+
syms[li++] = 268435456 | revfl[l] << 18 | revfd[d];
|
|
405
|
+
var lin = revfl[l] & 31, din = revfd[d] & 31;
|
|
406
|
+
eb += fleb[lin] + fdeb[din];
|
|
407
|
+
++lf[257 + lin];
|
|
408
|
+
++df[din];
|
|
409
|
+
wi = i2 + l;
|
|
410
|
+
++lc_1;
|
|
411
|
+
} else {
|
|
412
|
+
syms[li++] = dat[i2];
|
|
413
|
+
++lf[dat[i2]];
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
for (i2 = Math.max(i2, wi);i2 < s; ++i2) {
|
|
418
|
+
syms[li++] = dat[i2];
|
|
419
|
+
++lf[dat[i2]];
|
|
420
|
+
}
|
|
421
|
+
pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i2 - bs, pos);
|
|
422
|
+
if (!lst) {
|
|
423
|
+
st.r = pos & 7 | w[pos / 8 | 0] << 3;
|
|
424
|
+
pos -= 7;
|
|
425
|
+
st.h = head, st.p = prev, st.i = i2, st.w = wi;
|
|
426
|
+
}
|
|
427
|
+
} else {
|
|
428
|
+
for (var i2 = st.w || 0;i2 < s + lst; i2 += 65535) {
|
|
429
|
+
var e = i2 + 65535;
|
|
430
|
+
if (e >= s) {
|
|
431
|
+
w[pos / 8 | 0] = lst;
|
|
432
|
+
e = s;
|
|
433
|
+
}
|
|
434
|
+
pos = wfblk(w, pos + 1, dat.subarray(i2, e));
|
|
435
|
+
}
|
|
436
|
+
st.i = s;
|
|
437
|
+
}
|
|
438
|
+
return slc(o, 0, pre + shft(pos) + post);
|
|
439
|
+
};
|
|
440
|
+
var crct = /* @__PURE__ */ function() {
|
|
441
|
+
var t = new Int32Array(256);
|
|
442
|
+
for (var i2 = 0;i2 < 256; ++i2) {
|
|
443
|
+
var c = i2, k = 9;
|
|
444
|
+
while (--k)
|
|
445
|
+
c = (c & 1 && -306674912) ^ c >>> 1;
|
|
446
|
+
t[i2] = c;
|
|
447
|
+
}
|
|
448
|
+
return t;
|
|
449
|
+
}();
|
|
450
|
+
var crc = function() {
|
|
451
|
+
var c = -1;
|
|
452
|
+
return {
|
|
453
|
+
p: function(d) {
|
|
454
|
+
var cr = c;
|
|
455
|
+
for (var i2 = 0;i2 < d.length; ++i2)
|
|
456
|
+
cr = crct[cr & 255 ^ d[i2]] ^ cr >>> 8;
|
|
457
|
+
c = cr;
|
|
458
|
+
},
|
|
459
|
+
d: function() {
|
|
460
|
+
return ~c;
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
};
|
|
464
|
+
var dopt = function(dat, opt, pre, post, st) {
|
|
465
|
+
if (!st) {
|
|
466
|
+
st = { l: 1 };
|
|
467
|
+
if (opt.dictionary) {
|
|
468
|
+
var dict = opt.dictionary.subarray(-32768);
|
|
469
|
+
var newDat = new u8(dict.length + dat.length);
|
|
470
|
+
newDat.set(dict);
|
|
471
|
+
newDat.set(dat, dict.length);
|
|
472
|
+
dat = newDat;
|
|
473
|
+
st.w = dict.length;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20 : 12 + opt.mem, pre, post, st);
|
|
477
|
+
};
|
|
478
|
+
var mrg = function(a, b) {
|
|
479
|
+
var o = {};
|
|
480
|
+
for (var k in a)
|
|
481
|
+
o[k] = a[k];
|
|
482
|
+
for (var k in b)
|
|
483
|
+
o[k] = b[k];
|
|
484
|
+
return o;
|
|
485
|
+
};
|
|
486
|
+
var wbytes = function(d, b, v) {
|
|
487
|
+
for (;v; ++b)
|
|
488
|
+
d[b] = v, v >>>= 8;
|
|
489
|
+
};
|
|
490
|
+
function deflateSync(data, opts) {
|
|
491
|
+
return dopt(data, opts || {}, 0, 0);
|
|
492
|
+
}
|
|
493
|
+
var fltn = function(d, p, t, o) {
|
|
494
|
+
for (var k in d) {
|
|
495
|
+
var val = d[k], n = p + k, op = o;
|
|
496
|
+
if (Array.isArray(val))
|
|
497
|
+
op = mrg(o, val[1]), val = val[0];
|
|
498
|
+
if (ArrayBuffer.isView(val))
|
|
499
|
+
t[n] = [val, op];
|
|
500
|
+
else {
|
|
501
|
+
t[n += "/"] = [new u8(0), op];
|
|
502
|
+
fltn(val, n, t, o);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
var te = typeof TextEncoder != "undefined" && /* @__PURE__ */ new TextEncoder;
|
|
507
|
+
var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder;
|
|
508
|
+
var tds = 0;
|
|
509
|
+
try {
|
|
510
|
+
td.decode(et, { stream: true });
|
|
511
|
+
tds = 1;
|
|
512
|
+
} catch (e) {}
|
|
513
|
+
function strToU8(str, latin1) {
|
|
514
|
+
if (latin1) {
|
|
515
|
+
var ar_1 = new u8(str.length);
|
|
516
|
+
for (var i2 = 0;i2 < str.length; ++i2)
|
|
517
|
+
ar_1[i2] = str.charCodeAt(i2);
|
|
518
|
+
return ar_1;
|
|
519
|
+
}
|
|
520
|
+
if (te)
|
|
521
|
+
return te.encode(str);
|
|
522
|
+
var l = str.length;
|
|
523
|
+
var ar = new u8(str.length + (str.length >> 1));
|
|
524
|
+
var ai = 0;
|
|
525
|
+
var w = function(v) {
|
|
526
|
+
ar[ai++] = v;
|
|
527
|
+
};
|
|
528
|
+
for (var i2 = 0;i2 < l; ++i2) {
|
|
529
|
+
if (ai + 5 > ar.length) {
|
|
530
|
+
var n = new u8(ai + 8 + (l - i2 << 1));
|
|
531
|
+
n.set(ar);
|
|
532
|
+
ar = n;
|
|
533
|
+
}
|
|
534
|
+
var c = str.charCodeAt(i2);
|
|
535
|
+
if (c < 128 || latin1)
|
|
536
|
+
w(c);
|
|
537
|
+
else if (c < 2048)
|
|
538
|
+
w(192 | c >> 6), w(128 | c & 63);
|
|
539
|
+
else if (c > 55295 && c < 57344)
|
|
540
|
+
c = 65536 + (c & 1023 << 10) | str.charCodeAt(++i2) & 1023, w(240 | c >> 18), w(128 | c >> 12 & 63), w(128 | c >> 6 & 63), w(128 | c & 63);
|
|
541
|
+
else
|
|
542
|
+
w(224 | c >> 12), w(128 | c >> 6 & 63), w(128 | c & 63);
|
|
543
|
+
}
|
|
544
|
+
return slc(ar, 0, ai);
|
|
545
|
+
}
|
|
546
|
+
var exfl = function(ex) {
|
|
547
|
+
var le = 0;
|
|
548
|
+
if (ex) {
|
|
549
|
+
for (var k in ex) {
|
|
550
|
+
var l = ex[k].length;
|
|
551
|
+
if (l > 65535)
|
|
552
|
+
err(9);
|
|
553
|
+
le += l + 4;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return le;
|
|
557
|
+
};
|
|
558
|
+
var wzh = function(d, b, f, fn, u, c, ce, co) {
|
|
559
|
+
var fl2 = fn.length, ex = f.extra, col = co && co.length;
|
|
560
|
+
var exl = exfl(ex);
|
|
561
|
+
wbytes(d, b, ce != null ? 33639248 : 67324752), b += 4;
|
|
562
|
+
if (ce != null)
|
|
563
|
+
d[b++] = 20, d[b++] = f.os;
|
|
564
|
+
d[b] = 20, b += 2;
|
|
565
|
+
d[b++] = f.flag << 1 | (c < 0 && 8), d[b++] = u && 8;
|
|
566
|
+
d[b++] = f.compression & 255, d[b++] = f.compression >> 8;
|
|
567
|
+
var dt = new Date(f.mtime == null ? Date.now() : f.mtime), y = dt.getFullYear() - 1980;
|
|
568
|
+
if (y < 0 || y > 119)
|
|
569
|
+
err(10);
|
|
570
|
+
wbytes(d, b, y << 25 | dt.getMonth() + 1 << 21 | dt.getDate() << 16 | dt.getHours() << 11 | dt.getMinutes() << 5 | dt.getSeconds() >> 1), b += 4;
|
|
571
|
+
if (c != -1) {
|
|
572
|
+
wbytes(d, b, f.crc);
|
|
573
|
+
wbytes(d, b + 4, c < 0 ? -c - 2 : c);
|
|
574
|
+
wbytes(d, b + 8, f.size);
|
|
575
|
+
}
|
|
576
|
+
wbytes(d, b + 12, fl2);
|
|
577
|
+
wbytes(d, b + 14, exl), b += 16;
|
|
578
|
+
if (ce != null) {
|
|
579
|
+
wbytes(d, b, col);
|
|
580
|
+
wbytes(d, b + 6, f.attrs);
|
|
581
|
+
wbytes(d, b + 10, ce), b += 14;
|
|
582
|
+
}
|
|
583
|
+
d.set(fn, b);
|
|
584
|
+
b += fl2;
|
|
585
|
+
if (exl) {
|
|
586
|
+
for (var k in ex) {
|
|
587
|
+
var exf = ex[k], l = exf.length;
|
|
588
|
+
wbytes(d, b, +k);
|
|
589
|
+
wbytes(d, b + 2, l);
|
|
590
|
+
d.set(exf, b + 4), b += 4 + l;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
if (col)
|
|
594
|
+
d.set(co, b), b += col;
|
|
595
|
+
return b;
|
|
596
|
+
};
|
|
597
|
+
var wzf = function(o, b, c, d, e) {
|
|
598
|
+
wbytes(o, b, 101010256);
|
|
599
|
+
wbytes(o, b + 8, c);
|
|
600
|
+
wbytes(o, b + 10, c);
|
|
601
|
+
wbytes(o, b + 12, d);
|
|
602
|
+
wbytes(o, b + 16, e);
|
|
603
|
+
};
|
|
604
|
+
function zipSync(data, opts) {
|
|
605
|
+
if (!opts)
|
|
606
|
+
opts = {};
|
|
607
|
+
var r = {};
|
|
608
|
+
var files = [];
|
|
609
|
+
fltn(data, "", r, opts);
|
|
610
|
+
var o = 0;
|
|
611
|
+
var tot = 0;
|
|
612
|
+
for (var fn in r) {
|
|
613
|
+
var _a2 = r[fn], file = _a2[0], p = _a2[1];
|
|
614
|
+
var compression = p.level == 0 ? 0 : 8;
|
|
615
|
+
var f = strToU8(fn), s = f.length;
|
|
616
|
+
var com = p.comment, m = com && strToU8(com), ms = m && m.length;
|
|
617
|
+
var exl = exfl(p.extra);
|
|
618
|
+
if (s > 65535)
|
|
619
|
+
err(11);
|
|
620
|
+
var d = compression ? deflateSync(file, p) : file, l = d.length;
|
|
621
|
+
var c = crc();
|
|
622
|
+
c.p(file);
|
|
623
|
+
files.push(mrg(p, {
|
|
624
|
+
size: file.length,
|
|
625
|
+
crc: c.d(),
|
|
626
|
+
c: d,
|
|
627
|
+
f,
|
|
628
|
+
m,
|
|
629
|
+
u: s != fn.length || m && com.length != ms,
|
|
630
|
+
o,
|
|
631
|
+
compression
|
|
632
|
+
}));
|
|
633
|
+
o += 30 + s + exl + l;
|
|
634
|
+
tot += 76 + 2 * (s + exl) + (ms || 0) + l;
|
|
635
|
+
}
|
|
636
|
+
var out = new u8(tot + 22), oe = o, cdl = tot - o;
|
|
637
|
+
for (var i2 = 0;i2 < files.length; ++i2) {
|
|
638
|
+
var f = files[i2];
|
|
639
|
+
wzh(out, f.o, f, f.f, f.u, f.c.length);
|
|
640
|
+
var badd = 30 + f.f.length + exfl(f.extra);
|
|
641
|
+
out.set(f.c, f.o + badd);
|
|
642
|
+
wzh(out, o, f, f.f, f.u, f.c.length, f.o, f.m), o += 16 + badd + (f.m ? f.m.length : 0);
|
|
643
|
+
}
|
|
644
|
+
wzf(out, o, files.length, cdl, oe);
|
|
645
|
+
return out;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// src/deploy-source.ts
|
|
649
|
+
var SOURCE_HEADER = "x-flypod-source";
|
|
650
|
+
var DEPLOY_SOURCES = ["cli", "browser", "library", "skill", "unknown"];
|
|
651
|
+
function coerceSource(value) {
|
|
652
|
+
const normalized = (value ?? "").trim().toLowerCase();
|
|
653
|
+
return DEPLOY_SOURCES.includes(normalized) ? normalized : "unknown";
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// src/cli/session.ts
|
|
657
|
+
import { readFile, unlink } from "node:fs/promises";
|
|
658
|
+
|
|
659
|
+
// src/cli/paths.ts
|
|
660
|
+
import { mkdir, rename, writeFile } from "node:fs/promises";
|
|
661
|
+
import { homedir, platform } from "node:os";
|
|
662
|
+
import { dirname, join } from "node:path";
|
|
663
|
+
function configDir(env = process.env) {
|
|
664
|
+
if (env.FLYPOD_CONFIG_DIR)
|
|
665
|
+
return env.FLYPOD_CONFIG_DIR;
|
|
666
|
+
const os = platform();
|
|
667
|
+
if (os === "darwin") {
|
|
668
|
+
return join(homedir(), "Library", "Application Support", "flypod");
|
|
669
|
+
}
|
|
670
|
+
if (os === "win32") {
|
|
671
|
+
const appData = env.APPDATA ?? join(homedir(), "AppData", "Roaming");
|
|
672
|
+
return join(appData, "flypod");
|
|
673
|
+
}
|
|
674
|
+
const xdg = env.XDG_CONFIG_HOME ?? join(homedir(), ".config");
|
|
675
|
+
return join(xdg, "flypod");
|
|
676
|
+
}
|
|
677
|
+
function sessionFilePath(env = process.env) {
|
|
678
|
+
return join(configDir(env), "session.json");
|
|
679
|
+
}
|
|
680
|
+
function projectsFilePath(env = process.env) {
|
|
681
|
+
return join(configDir(env), "projects.json");
|
|
682
|
+
}
|
|
683
|
+
async function atomicWriteFile(path, content) {
|
|
684
|
+
await mkdir(dirname(path), { recursive: true });
|
|
685
|
+
const tmp = `${path}.tmp`;
|
|
686
|
+
await writeFile(tmp, content, { mode: 384 });
|
|
687
|
+
await rename(tmp, path);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
// src/cli/session.ts
|
|
691
|
+
async function loadSession(env) {
|
|
692
|
+
try {
|
|
693
|
+
const path = sessionFilePath(env);
|
|
694
|
+
const text = await readFile(path, "utf8");
|
|
695
|
+
const parsed = JSON.parse(text);
|
|
696
|
+
if (typeof parsed?.session_token === "string" && typeof parsed?.base_url === "string" && typeof parsed?.created_at === "number") {
|
|
697
|
+
return parsed;
|
|
698
|
+
}
|
|
699
|
+
return null;
|
|
700
|
+
} catch {
|
|
701
|
+
return null;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
async function saveSession(session, env) {
|
|
705
|
+
const path = sessionFilePath(env);
|
|
706
|
+
await atomicWriteFile(path, `${JSON.stringify(session, null, 2)}
|
|
707
|
+
`);
|
|
708
|
+
return path;
|
|
709
|
+
}
|
|
710
|
+
async function clearSession(env) {
|
|
711
|
+
try {
|
|
712
|
+
await unlink(sessionFilePath(env));
|
|
713
|
+
return true;
|
|
714
|
+
} catch {
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// src/cli/skill.ts
|
|
720
|
+
import { mkdir as mkdir2, readFile as readFile2, stat, writeFile as writeFile2 } from "node:fs/promises";
|
|
721
|
+
import { homedir as homedir2 } from "node:os";
|
|
722
|
+
import { dirname as dirname2, join as join2 } from "node:path";
|
|
723
|
+
var SKILL_NAME = "flypod";
|
|
724
|
+
var SKILL_DESCRIPTION = "Deploy a folder of static files or Markdown to a live, public URL anyone can open — no account, no config. " + "Use it when the user asks to deploy, publish, or share something built; " + "when a build has just finished and someone else needs to look at it; " + "when a report, research write-up, or set of Markdown notes should become a browsable site instead of a file; " + "or when a screenshot or a local dev server will not do because the recipient must open it themselves. " + "Static output only — flypod serves files, and does not run a server or build them.";
|
|
725
|
+
function yamlScalar(value) {
|
|
726
|
+
return `'${value.replaceAll("'", "''")}'`;
|
|
727
|
+
}
|
|
728
|
+
var versionsReference = {
|
|
729
|
+
file: "reference/updates-and-versions.md",
|
|
730
|
+
when: "shipping a change without forking the site, or listing and rolling back versions",
|
|
731
|
+
body: () => `# Updates, versions, and rollback
|
|
732
|
+
|
|
733
|
+
Every command here acts on a site that already exists, so none of them forks it.
|
|
734
|
+
All take \`--json\`.
|
|
735
|
+
|
|
736
|
+
\`\`\`sh
|
|
737
|
+
flypod update # ship this folder as a new version
|
|
738
|
+
flypod update ./dist # same, with an explicit path
|
|
739
|
+
flypod versions # every version, newest first, live one marked
|
|
740
|
+
flypod rollback # put the previous version back
|
|
741
|
+
flypod rollback <version> # roll back to a version id, or a prefix of one
|
|
742
|
+
\`\`\`
|
|
743
|
+
|
|
744
|
+
## How flypod knows which site
|
|
745
|
+
|
|
746
|
+
flypod remembers which folder maps to which site, in its own config directory
|
|
747
|
+
under your home — never in the repo, so there is nothing to \`.gitignore\` and
|
|
748
|
+
nothing to commit. From the folder you deployed, these need no id and no flags.
|
|
749
|
+
|
|
750
|
+
\`FLYPOD_CONFIG_DIR\` relocates that memory, which is how you isolate CI runs.
|
|
751
|
+
|
|
752
|
+
## When the folder memory isn't there
|
|
753
|
+
|
|
754
|
+
Stateless, in a different directory, or holding a \`site_id\` from an earlier
|
|
755
|
+
deploy? Target the site:
|
|
756
|
+
|
|
757
|
+
\`\`\`sh
|
|
758
|
+
flypod update --site <site_id> ./dist
|
|
759
|
+
flypod versions --site <site_id>
|
|
760
|
+
flypod rollback --site <site_id> <version_id>
|
|
761
|
+
flypod forget [--site <site_id>] # drop the folder→site memory
|
|
762
|
+
\`\`\`
|
|
763
|
+
|
|
764
|
+
Sites you own authorize with your login. A **temporary** site acted on from a
|
|
765
|
+
machine that does not remember it authorizes with its manage token:
|
|
766
|
+
|
|
767
|
+
\`\`\`sh
|
|
768
|
+
flypod update --site <site_id> --token <manage_token> ./dist
|
|
769
|
+
\`\`\`
|
|
770
|
+
|
|
771
|
+
\`flypod token [--site <id>]\` prints that token on stdout for a site this machine
|
|
772
|
+
remembers — the one case that needs the plaintext. Treat it like a password: it
|
|
773
|
+
authorizes updates, rollbacks, and claims, and it cannot be rotated.
|
|
774
|
+
|
|
775
|
+
## Versions are content-addressed
|
|
776
|
+
|
|
777
|
+
A version id is a hash of the files, so deploying byte-identical content again
|
|
778
|
+
is a no-op: same hash, same version, no new entry in the history. A redundant
|
|
779
|
+
\`flypod update\` is free, and needs no guard.
|
|
780
|
+
|
|
781
|
+
## Typical loop
|
|
782
|
+
|
|
783
|
+
\`\`\`sh
|
|
784
|
+
npm run build && npx flypod ./dist --json # first deploy, note the url
|
|
785
|
+
# … edit, rebuild …
|
|
786
|
+
npm run build && npx flypod update --json # same url, new content
|
|
787
|
+
npx flypod versions --json # confirm what's live
|
|
788
|
+
npx flypod rollback # undo a bad ship
|
|
789
|
+
\`\`\`
|
|
790
|
+
`
|
|
791
|
+
};
|
|
792
|
+
var markdownReference = {
|
|
793
|
+
file: "reference/publishing-markdown.md",
|
|
794
|
+
when: "publishing Markdown — a report, research notes, a changelog, docs",
|
|
795
|
+
body: () => `# Publishing Markdown with flypod
|
|
796
|
+
|
|
797
|
+
flypod renders Markdown into a styled, browsable site. You do not need a static
|
|
798
|
+
site generator, a theme, or a build step — deploy the \`.md\` files themselves.
|
|
799
|
+
|
|
800
|
+
This is the fastest path from "I wrote a report" to "here is a link."
|
|
801
|
+
|
|
802
|
+
\`\`\`sh
|
|
803
|
+
npx flypod ./report.md --json # one document
|
|
804
|
+
npx flypod ./notes --json # a folder of documents
|
|
805
|
+
\`\`\`
|
|
806
|
+
|
|
807
|
+
## When it triggers
|
|
808
|
+
|
|
809
|
+
Markdown rendering kicks in when **both** are true of the files you deploy:
|
|
810
|
+
|
|
811
|
+
1. There is **no \`index.html\`** at the root of the deploy, and
|
|
812
|
+
2. at least one file ends in \`.md\`, \`.markdown\`, or \`.mdx\`.
|
|
813
|
+
|
|
814
|
+
That condition is deliberate: a real static site that happens to ship a stray
|
|
815
|
+
\`README.md\` is never hijacked. If you want files served untouched instead,
|
|
816
|
+
include an \`index.html\`.
|
|
817
|
+
|
|
818
|
+
## What you get
|
|
819
|
+
|
|
820
|
+
- **One HTML page per document.** \`guide.md\` is served at \`/guide.html\`.
|
|
821
|
+
- **A home page.** \`README.md\` or \`index.md\` becomes \`/\`. If you deploy exactly
|
|
822
|
+
one document, that document becomes the home page whatever it is called.
|
|
823
|
+
- **Navigation** across every document, with the home doc first and the rest
|
|
824
|
+
alphabetical.
|
|
825
|
+
- **A title per page,** taken from the first \`#\` heading, falling back to a
|
|
826
|
+
title-cased version of the filename.
|
|
827
|
+
- **Light and dark themes,** applied before first paint so there is no flash.
|
|
828
|
+
- **Sanitized HTML.** Inline \`<script>\` tags, \`on*\` event attributes, and
|
|
829
|
+
\`javascript:\` links are stripped from the rendered output. Interactive content
|
|
830
|
+
belongs in a built static site, deployed as HTML.
|
|
831
|
+
|
|
832
|
+
## Agents get the Markdown back
|
|
833
|
+
|
|
834
|
+
The original \`.md\` sources are preserved and served through HTTP content
|
|
835
|
+
negotiation on the *same* URL. A browser gets the styled HTML; a client that
|
|
836
|
+
asks for Markdown gets the source:
|
|
837
|
+
|
|
838
|
+
\`\`\`sh
|
|
839
|
+
curl -H 'Accept: text/markdown' https://ab12cd34.flypod.dev/guide.html
|
|
840
|
+
\`\`\`
|
|
841
|
+
|
|
842
|
+
Known agent and crawler user-agents also get Markdown when they express no media
|
|
843
|
+
preference. An explicit preference for HTML always wins, so a real browser is
|
|
844
|
+
never handed raw Markdown.
|
|
845
|
+
|
|
846
|
+
This matters when you are the one reading the site back later: fetch it with
|
|
847
|
+
\`Accept: text/markdown\` and you get clean source instead of parsing HTML.
|
|
848
|
+
|
|
849
|
+
## Good uses
|
|
850
|
+
|
|
851
|
+
- A research write-up or analysis the user asked for, published instead of pasted.
|
|
852
|
+
- A changelog, migration guide, or RFC that needs review from someone without a
|
|
853
|
+
checkout.
|
|
854
|
+
- Meeting notes or a status report that should have a URL rather than an attachment.
|
|
855
|
+
- Documentation for a small project, without adopting a docs framework.
|
|
856
|
+
|
|
857
|
+
Pair it with comments (\`reference/comments.md\`) when the reader should be able
|
|
858
|
+
to respond in place.
|
|
859
|
+
`
|
|
860
|
+
};
|
|
861
|
+
var commentsReference = {
|
|
862
|
+
file: "reference/comments.md",
|
|
863
|
+
when: "collecting feedback on a preview, or reading reviewer comments back",
|
|
864
|
+
body: () => `# Comments — feedback on a deployed site
|
|
865
|
+
|
|
866
|
+
flypod can attach a commenting layer to a site, so a reviewer opens the URL and
|
|
867
|
+
leaves comments anchored to the page. You can then read those comments back as
|
|
868
|
+
JSON and act on them. That closes the loop: ship a preview, collect feedback,
|
|
869
|
+
fix, re-ship — without leaving the terminal.
|
|
870
|
+
|
|
871
|
+
## Turning comments on
|
|
872
|
+
|
|
873
|
+
At deploy time:
|
|
874
|
+
|
|
875
|
+
\`\`\`sh
|
|
876
|
+
npx flypod ./dist --comments --json # mode: anonymous
|
|
877
|
+
npx flypod ./dist --comments --mode approved --json
|
|
878
|
+
\`\`\`
|
|
879
|
+
|
|
880
|
+
On a site that already exists:
|
|
881
|
+
|
|
882
|
+
\`\`\`sh
|
|
883
|
+
flypod comments enable --site <site_id> [--mode <mode>]
|
|
884
|
+
flypod comments mode <mode> --site <site_id> [--passcode <s>]
|
|
885
|
+
flypod comments off --site <site_id> # disable; existing data is preserved
|
|
886
|
+
\`\`\`
|
|
887
|
+
|
|
888
|
+
## Modes
|
|
889
|
+
|
|
890
|
+
| Mode | Who can comment |
|
|
891
|
+
| --- | --- |
|
|
892
|
+
| \`anonymous\` | anyone with the link, no sign-in — best for quick previews |
|
|
893
|
+
| \`passcode\` | anyone holding the passcode you set with \`--passcode\` |
|
|
894
|
+
| \`approved\` | only people you have approved — best for anything semi-public |
|
|
895
|
+
|
|
896
|
+
Default when you pass \`--comments\` with no mode: \`anonymous\`.
|
|
897
|
+
|
|
898
|
+
## Reading feedback
|
|
899
|
+
|
|
900
|
+
\`\`\`sh
|
|
901
|
+
flypod comments list <site_id> --json # ND-JSON: one thread per line
|
|
902
|
+
flypod comments list <site_id> --open --json # only unresolved threads
|
|
903
|
+
flypod comments list <site_id> --page /pricing.html # threads on one page
|
|
904
|
+
flypod comments show <site_id> <thread_id> # one thread with its replies
|
|
905
|
+
\`\`\`
|
|
906
|
+
|
|
907
|
+
\`list\` writes one JSON object per line, so it streams and pipes. \`--json\` only
|
|
908
|
+
suppresses the human-readable count on stderr; the thread objects go to stdout
|
|
909
|
+
either way.
|
|
910
|
+
|
|
911
|
+
## Replying and closing out
|
|
912
|
+
|
|
913
|
+
\`\`\`sh
|
|
914
|
+
flypod comments post <site_id> --page <path> --target <json> --body <text>
|
|
915
|
+
flypod comments resolve <site_id> <thread_id>
|
|
916
|
+
flypod comments reopen <site_id> <thread_id>
|
|
917
|
+
\`\`\`
|
|
918
|
+
|
|
919
|
+
## Authorization
|
|
920
|
+
|
|
921
|
+
Read verbs follow the site's own policy. **Write verbs — \`post\`, \`resolve\`,
|
|
922
|
+
\`reopen\`, and the \`enable\`/\`mode\`/\`off\` verbs — need an account session or an
|
|
923
|
+
agent token.** Run \`flypod login\`, or set \`FLYPOD_TOKEN\`. A deploy-only key (one
|
|
924
|
+
starting \`fk_\`) is rejected up front with exit code 3; it authorizes deploys and
|
|
925
|
+
nothing else. \`reference/troubleshooting.md\` has the full exit-code table.
|
|
926
|
+
|
|
927
|
+
## The review loop
|
|
928
|
+
|
|
929
|
+
\`\`\`sh
|
|
930
|
+
npx flypod ./dist --comments --json # ship a preview, share the url
|
|
931
|
+
flypod comments list <site_id> --open --json # collect what came back
|
|
932
|
+
# … make the fixes …
|
|
933
|
+
npx flypod update ./dist # same url, updated content
|
|
934
|
+
flypod comments resolve <site_id> <thread_id>
|
|
935
|
+
\`\`\`
|
|
936
|
+
`
|
|
937
|
+
};
|
|
938
|
+
var troubleshootingReference = {
|
|
939
|
+
file: "reference/troubleshooting.md",
|
|
940
|
+
when: "a deploy failed or the site looks wrong, or you need exit codes, CI setup, env vars",
|
|
941
|
+
body: () => `# Troubleshooting and environment
|
|
942
|
+
|
|
943
|
+
## Exit codes
|
|
944
|
+
|
|
945
|
+
| Code | Meaning |
|
|
946
|
+
| --- | --- |
|
|
947
|
+
| \`0\` | success |
|
|
948
|
+
| \`1\` | runtime error — no build folder, network failure, deploy rejected |
|
|
949
|
+
| \`2\` | usage error — unknown flag or bad arguments |
|
|
950
|
+
| \`3\` | \`flypod comments\` only: not signed in, or the token cannot write comments |
|
|
951
|
+
| \`4\` | \`flypod comments\` only: server error (5xx), so a retry is reasonable |
|
|
952
|
+
|
|
953
|
+
With \`--json\`, failures print \`{"ok": false, "error": "…"}\` on stdout, so you can
|
|
954
|
+
branch on the payload instead of scraping stderr.
|
|
955
|
+
|
|
956
|
+
## "No build output folder found"
|
|
957
|
+
|
|
958
|
+
flypod looked for \`dist\`, \`build\`, \`out\`, \`.output/public\`,
|
|
959
|
+
\`.vercel/output/static\`, \`public\`, \`_site\` — each of which must contain an
|
|
960
|
+
\`index.html\` — and found none. Either the project has not been built yet, or the
|
|
961
|
+
output lives somewhere else. Build it, then pass the path explicitly:
|
|
962
|
+
|
|
963
|
+
\`\`\`sh
|
|
964
|
+
npm run build && npx flypod ./path/to/output --json
|
|
965
|
+
\`\`\`
|
|
966
|
+
|
|
967
|
+
## The deploy succeeded but the site looks wrong
|
|
968
|
+
|
|
969
|
+
Check the \`warnings\` array in the \`--json\` output before you report success.
|
|
970
|
+
Each warning has a \`code\` and a \`fix_recipe\` naming the change to make.
|
|
971
|
+
|
|
972
|
+
- \`missing-index\` — nothing is served at \`/\`. Name the entry file \`index.html\`.
|
|
973
|
+
- \`not-spa\` — the page ships scripts but also has visible body content, so
|
|
974
|
+
client-side routing fallback stays off and deep links will 404 on refresh.
|
|
975
|
+
|
|
976
|
+
\`healed\` lists what flypod fixed on your behalf. \`spa-fallback\` there means it
|
|
977
|
+
recognised a single-page app, so unknown paths serve \`index.html\` and
|
|
978
|
+
client-side routing works without configuration.
|
|
979
|
+
|
|
980
|
+
## Blank page, broken assets
|
|
981
|
+
|
|
982
|
+
Almost always absolute paths that assume a domain root, or a build configured
|
|
983
|
+
for a subpath. Rebuild with relative asset paths, then \`flypod update\`.
|
|
984
|
+
|
|
985
|
+
## Agents and CI
|
|
986
|
+
|
|
987
|
+
Set a session token in the environment and every deploy is attributed to the
|
|
988
|
+
account, with no browser and no interactive login:
|
|
989
|
+
|
|
990
|
+
\`\`\`sh
|
|
991
|
+
URL=$(FLYPOD_TOKEN=$TOKEN npx flypod ./dist -q)
|
|
992
|
+
\`\`\`
|
|
993
|
+
|
|
994
|
+
\`-q\` prints the URL and nothing else, which keeps the token out of the build log
|
|
995
|
+
it would otherwise outlive.
|
|
996
|
+
|
|
997
|
+
| Variable | Effect |
|
|
998
|
+
| --- | --- |
|
|
999
|
+
| \`FLYPOD_TOKEN\` | Deploy as your account without logging in (agents / CI) |
|
|
1000
|
+
| \`DEPLOY_URL\` | Point at a different flypod server (default \`https://flypod.dev\`) |
|
|
1001
|
+
| \`FLYPOD_CONFIG_DIR\` | Relocate the session + folder→site memory |
|
|
1002
|
+
|
|
1003
|
+
## Getting the full command surface
|
|
1004
|
+
|
|
1005
|
+
\`flypod --help\` is authoritative and current; so is \`--help\` on any subcommand
|
|
1006
|
+
(\`update\`, \`versions\`, \`rollback\`, \`forget\`, \`token\`, \`login\`). Read it rather
|
|
1007
|
+
than guessing at a flag.
|
|
1008
|
+
`
|
|
1009
|
+
};
|
|
1010
|
+
var REFERENCES = [
|
|
1011
|
+
versionsReference,
|
|
1012
|
+
markdownReference,
|
|
1013
|
+
commentsReference,
|
|
1014
|
+
troubleshootingReference
|
|
1015
|
+
];
|
|
1016
|
+
function entryBody() {
|
|
1017
|
+
return `flypod turns a folder into a live, public URL with one command. You bring the
|
|
1018
|
+
files; flypod serves them.
|
|
1019
|
+
|
|
1020
|
+
## Deploy
|
|
1021
|
+
|
|
1022
|
+
1. Build first, if the project has a build — flypod serves files, it does not
|
|
1023
|
+
make them. You want a folder whose contents *are* the finished site.
|
|
1024
|
+
2. Deploy it:
|
|
1025
|
+
|
|
1026
|
+
\`\`\`sh
|
|
1027
|
+
npx flypod ./dist --json
|
|
1028
|
+
\`\`\`
|
|
1029
|
+
|
|
1030
|
+
3. Read \`url\` from the JSON and give it to the user.
|
|
1031
|
+
|
|
1032
|
+
**Done when** the user has the URL, and \`warnings\` is empty or you have told
|
|
1033
|
+
them what is in it.
|
|
1034
|
+
|
|
1035
|
+
Omit the path and flypod auto-detects a build folder, trying \`dist\`, \`build\`,
|
|
1036
|
+
\`out\`, \`.output/public\`, \`.vercel/output/static\`, \`public\`, \`_site\` — each of
|
|
1037
|
+
which must hold an \`index.html\`. Pass the path whenever you know it.
|
|
1038
|
+
|
|
1039
|
+
A single file deploys too: \`flypod report.html\`. For several, deploy the folder.
|
|
1040
|
+
|
|
1041
|
+
No \`flypod\` binary? \`npx flypod ...\` downloads and runs it on the fly, and that
|
|
1042
|
+
is the normal path rather than a fallback. To install once: \`npm install -g flypod\`.
|
|
1043
|
+
|
|
1044
|
+
## The result
|
|
1045
|
+
|
|
1046
|
+
\`\`\`json
|
|
1047
|
+
{
|
|
1048
|
+
"ok": true,
|
|
1049
|
+
"url": "https://ab12cd34.flypod.dev",
|
|
1050
|
+
"site_id": "ab12cd34",
|
|
1051
|
+
"version_id": "…",
|
|
1052
|
+
"expires_at": 1782929906088,
|
|
1053
|
+
"files": 12,
|
|
1054
|
+
"bytes": 1234567,
|
|
1055
|
+
"elapsed_ms": 812,
|
|
1056
|
+
"healed": ["spa-fallback"],
|
|
1057
|
+
"warnings": []
|
|
1058
|
+
}
|
|
1059
|
+
\`\`\`
|
|
1060
|
+
|
|
1061
|
+
- \`url\` — the live site. Give it to the user.
|
|
1062
|
+
- \`warnings\` — problems that survived the deploy, each with a \`code\` and a
|
|
1063
|
+
\`fix_recipe\` naming the change to make. A deploy exits 0 and still serves a
|
|
1064
|
+
broken site; this array is how you find out before the user does.
|
|
1065
|
+
- \`healed\` — problems flypod fixed for you, e.g. \`spa-fallback\`.
|
|
1066
|
+
- \`site_id\` — names the site for \`--site <id>\` from any other folder.
|
|
1067
|
+
- \`expires_at\` — epoch **milliseconds** while the site is temporary, \`null\` once
|
|
1068
|
+
it belongs to an account.
|
|
1069
|
+
- \`manage_token\` / \`claim_token\` — secrets, on a first temporary deploy. The CLI
|
|
1070
|
+
has already saved what it needs, keyed by the folder you deployed from, so
|
|
1071
|
+
these want no action from you. Keep them out of chat, commits, logs, and PR
|
|
1072
|
+
descriptions.
|
|
1073
|
+
|
|
1074
|
+
\`-q\` prints the URL alone, for a shell variable: \`URL=$(npx flypod ./dist -q)\`.
|
|
1075
|
+
|
|
1076
|
+
## Temporary, then yours
|
|
1077
|
+
|
|
1078
|
+
A deploy with no account is **temporary** and expires in **14 days** — right for
|
|
1079
|
+
previews, demos, and throwaways. \`flypod login\` makes every temporary site this
|
|
1080
|
+
machine deployed **yours**: no expiry, listed by \`flypod list\`.
|
|
1081
|
+
|
|
1082
|
+
Because login claims them all at once and not just the last one, the honest
|
|
1083
|
+
advice is "deploy now, log in whenever you want to keep these." Raise it when
|
|
1084
|
+
the user will still want the site next week, and let it go otherwise. \`flypod
|
|
1085
|
+
login\` is how a site is kept — the tokens above are never the answer.
|
|
1086
|
+
|
|
1087
|
+
For agents and CI, set a session token and every deploy is attributed to the
|
|
1088
|
+
account from the start, with no browser:
|
|
1089
|
+
|
|
1090
|
+
\`\`\`sh
|
|
1091
|
+
FLYPOD_TOKEN=<session-token> npx flypod ./dist --json
|
|
1092
|
+
\`\`\`
|
|
1093
|
+
|
|
1094
|
+
## Shipping a change
|
|
1095
|
+
|
|
1096
|
+
A second \`flypod\` **forks** the site: a new site on a new URL, while the link
|
|
1097
|
+
you already gave the user quietly goes stale. \`flypod update\` adds a version to
|
|
1098
|
+
the site you already made, and the URL holds.
|
|
1099
|
+
|
|
1100
|
+
\`\`\`sh
|
|
1101
|
+
flypod update ./dist
|
|
1102
|
+
\`\`\`
|
|
1103
|
+
|
|
1104
|
+
## What flypod serves
|
|
1105
|
+
|
|
1106
|
+
Static files: HTML, CSS, browser JavaScript, assets, Markdown. An app that needs
|
|
1107
|
+
a server at request time — API routes, server-side rendering, a database call —
|
|
1108
|
+
belongs somewhere else, and saying so beats shipping a build that breaks on
|
|
1109
|
+
arrival. Most frameworks have a static export that deploys fine.
|
|
1110
|
+
|
|
1111
|
+
## Deeper reference
|
|
1112
|
+
|
|
1113
|
+
Open these when the task calls for them.
|
|
1114
|
+
|
|
1115
|
+
| File | Read it when |
|
|
1116
|
+
| --- | --- |
|
|
1117
|
+
${REFERENCES.map((r) => `| \`${r.file}\` | ${r.when} |`).join(`
|
|
1118
|
+
`)}`;
|
|
1119
|
+
}
|
|
1120
|
+
function skillEntryFile() {
|
|
1121
|
+
return `---
|
|
1122
|
+
name: ${SKILL_NAME}
|
|
1123
|
+
description: ${yamlScalar(SKILL_DESCRIPTION)}
|
|
1124
|
+
---
|
|
1125
|
+
|
|
1126
|
+
# Deploy with flypod
|
|
1127
|
+
|
|
1128
|
+
${entryBody()}
|
|
1129
|
+
`;
|
|
1130
|
+
}
|
|
1131
|
+
function skillFiles() {
|
|
1132
|
+
const files = { "SKILL.md": skillEntryFile() };
|
|
1133
|
+
for (const ref of REFERENCES)
|
|
1134
|
+
files[ref.file] = ref.body();
|
|
1135
|
+
return files;
|
|
1136
|
+
}
|
|
1137
|
+
function home(env) {
|
|
1138
|
+
return env.HOME ?? homedir2();
|
|
1139
|
+
}
|
|
1140
|
+
var TARGETS = [
|
|
1141
|
+
{
|
|
1142
|
+
id: "claude",
|
|
1143
|
+
label: "Claude Code",
|
|
1144
|
+
detail: ".claude/skills/flypod/ — loaded on demand",
|
|
1145
|
+
projectDir: (root) => join2(root, ".claude", "skills", SKILL_NAME),
|
|
1146
|
+
globalDir: (env) => join2(home(env), ".claude", "skills", SKILL_NAME)
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
id: "agents",
|
|
1150
|
+
label: "Agent Skills (shared)",
|
|
1151
|
+
detail: ".agents/skills/flypod/ — Codex, Cursor, Gemini CLI, Copilot",
|
|
1152
|
+
projectDir: (root) => join2(root, ".agents", "skills", SKILL_NAME),
|
|
1153
|
+
globalDir: (env) => join2(home(env), ".agents", "skills", SKILL_NAME)
|
|
1154
|
+
}
|
|
1155
|
+
];
|
|
1156
|
+
var LEGACY_PATHS = [
|
|
1157
|
+
"AGENTS.md",
|
|
1158
|
+
"GEMINI.md",
|
|
1159
|
+
join2(".github", "copilot-instructions.md"),
|
|
1160
|
+
join2(".cursor", "rules", `${SKILL_NAME}.mdc`),
|
|
1161
|
+
join2(".windsurf", "rules", `${SKILL_NAME}.md`),
|
|
1162
|
+
join2(".clinerules", `${SKILL_NAME}.md`),
|
|
1163
|
+
join2(".roo", "rules", `${SKILL_NAME}.md`)
|
|
1164
|
+
];
|
|
1165
|
+
var LEGACY_SHARED = new Set([
|
|
1166
|
+
"AGENTS.md",
|
|
1167
|
+
"GEMINI.md",
|
|
1168
|
+
join2(".github", "copilot-instructions.md")
|
|
1169
|
+
]);
|
|
1170
|
+
var LEGACY_MARK = `<!-- ${SKILL_NAME}:begin -->`;
|
|
1171
|
+
async function exists(path) {
|
|
1172
|
+
try {
|
|
1173
|
+
await stat(path);
|
|
1174
|
+
return true;
|
|
1175
|
+
} catch {
|
|
1176
|
+
return false;
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
async function legacyArtifacts(root) {
|
|
1180
|
+
const found = [];
|
|
1181
|
+
for (const rel of LEGACY_PATHS) {
|
|
1182
|
+
const path = join2(root, rel);
|
|
1183
|
+
if (!await exists(path))
|
|
1184
|
+
continue;
|
|
1185
|
+
if (!LEGACY_SHARED.has(rel)) {
|
|
1186
|
+
found.push(rel);
|
|
1187
|
+
continue;
|
|
1188
|
+
}
|
|
1189
|
+
try {
|
|
1190
|
+
if ((await readFile2(path, "utf8")).includes(LEGACY_MARK))
|
|
1191
|
+
found.push(rel);
|
|
1192
|
+
} catch {}
|
|
1193
|
+
}
|
|
1194
|
+
return found;
|
|
1195
|
+
}
|
|
1196
|
+
async function skillInstalledIn(root) {
|
|
1197
|
+
for (const target of TARGETS) {
|
|
1198
|
+
if (await exists(join2(target.projectDir(root), "SKILL.md")))
|
|
1199
|
+
return true;
|
|
1200
|
+
}
|
|
1201
|
+
return (await legacyArtifacts(root)).length > 0;
|
|
1202
|
+
}
|
|
1203
|
+
async function writeTarget(target, dir) {
|
|
1204
|
+
const results = [];
|
|
1205
|
+
for (const [rel, content] of Object.entries(skillFiles())) {
|
|
1206
|
+
const path = join2(dir, rel);
|
|
1207
|
+
const had = await exists(path);
|
|
1208
|
+
if (had && await readFile2(path, "utf8") === content) {
|
|
1209
|
+
results.push({ target, path, status: "unchanged" });
|
|
1210
|
+
continue;
|
|
1211
|
+
}
|
|
1212
|
+
await mkdir2(dirname2(path), { recursive: true });
|
|
1213
|
+
await writeFile2(path, content, "utf8");
|
|
1214
|
+
results.push({ target, path, status: had ? "updated" : "created" });
|
|
1215
|
+
}
|
|
1216
|
+
return results;
|
|
1217
|
+
}
|
|
1218
|
+
async function buildPlan(root, env, global) {
|
|
1219
|
+
return TARGETS.map((target) => ({
|
|
1220
|
+
target,
|
|
1221
|
+
dir: global ? target.globalDir(env) : target.projectDir(root)
|
|
1222
|
+
}));
|
|
1223
|
+
}
|
|
1224
|
+
async function installSkill(args, io) {
|
|
1225
|
+
const env = io.env ?? process.env;
|
|
1226
|
+
const root = args.cwd ?? process.cwd();
|
|
1227
|
+
const global = Boolean(args.global);
|
|
1228
|
+
const plan = await buildPlan(root, env, global);
|
|
1229
|
+
if (args.list) {
|
|
1230
|
+
io.err(global ? "flypod skill targets (global):" : "flypod skill targets (this project):");
|
|
1231
|
+
io.err("");
|
|
1232
|
+
for (const e of plan)
|
|
1233
|
+
io.out(`● ${e.target.id} ${e.target.detail} ${e.dir}`);
|
|
1234
|
+
io.err("");
|
|
1235
|
+
io.err("Run `flypod install skill` to write them.");
|
|
1236
|
+
return 0;
|
|
1237
|
+
}
|
|
1238
|
+
let chosen;
|
|
1239
|
+
if (args.targets && args.targets.length > 0) {
|
|
1240
|
+
const known = new Set(plan.map((e) => e.target.id));
|
|
1241
|
+
const unknown = args.targets.filter((id) => !known.has(id));
|
|
1242
|
+
if (unknown.length > 0) {
|
|
1243
|
+
io.err(`flypod: unknown target(s): ${unknown.join(", ")}`);
|
|
1244
|
+
io.err(`Known targets: ${TARGETS.map((t) => t.id).join(", ")}`);
|
|
1245
|
+
return 2;
|
|
1246
|
+
}
|
|
1247
|
+
chosen = args.targets;
|
|
1248
|
+
} else if (args.picker && !args.all) {
|
|
1249
|
+
const picked = await args.picker(plan);
|
|
1250
|
+
if (picked === null) {
|
|
1251
|
+
io.err("Cancelled. Nothing written.");
|
|
1252
|
+
return 130;
|
|
1253
|
+
}
|
|
1254
|
+
chosen = picked;
|
|
1255
|
+
} else {
|
|
1256
|
+
chosen = plan.map((e) => e.target.id);
|
|
1257
|
+
}
|
|
1258
|
+
const selected = plan.filter((e) => chosen.includes(e.target.id));
|
|
1259
|
+
if (selected.length === 0) {
|
|
1260
|
+
io.err("No targets selected. Nothing written.");
|
|
1261
|
+
return 0;
|
|
1262
|
+
}
|
|
1263
|
+
if (args.dryRun) {
|
|
1264
|
+
io.err("Would write:");
|
|
1265
|
+
for (const e of selected) {
|
|
1266
|
+
for (const rel of Object.keys(skillFiles()))
|
|
1267
|
+
io.out(join2(e.dir, rel));
|
|
1268
|
+
}
|
|
1269
|
+
return 0;
|
|
1270
|
+
}
|
|
1271
|
+
const results = [];
|
|
1272
|
+
for (const e of selected) {
|
|
1273
|
+
try {
|
|
1274
|
+
results.push(...await writeTarget(e.target, e.dir));
|
|
1275
|
+
} catch (error) {
|
|
1276
|
+
io.err(`flypod: failed to write ${e.dir}: ${error.message}`);
|
|
1277
|
+
return 1;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
for (const e of selected) {
|
|
1281
|
+
const mine = results.filter((r) => r.target.id === e.target.id);
|
|
1282
|
+
const changed2 = mine.filter((r) => r.status !== "unchanged").length;
|
|
1283
|
+
io.err(changed2 > 0 ? ` ✓ wrote ${e.dir}/ (${mine.length} files)` : ` · up to date ${e.dir}/`);
|
|
1284
|
+
}
|
|
1285
|
+
for (const r of results)
|
|
1286
|
+
io.out(r.path);
|
|
1287
|
+
const changed = results.filter((r) => r.status !== "unchanged").length;
|
|
1288
|
+
io.err("");
|
|
1289
|
+
io.err(changed > 0 ? `Your agents now know how to deploy with flypod. Try asking one to "deploy this with flypod".` : "Everything was already up to date.");
|
|
1290
|
+
if (!global) {
|
|
1291
|
+
const legacy = await legacyArtifacts(root);
|
|
1292
|
+
if (legacy.length > 0) {
|
|
1293
|
+
io.err("");
|
|
1294
|
+
io.err("These older flypod instruction files are still in the project:");
|
|
1295
|
+
for (const rel of legacy)
|
|
1296
|
+
io.err(` ${rel}`);
|
|
1297
|
+
io.err("They now duplicate the skill, and their content is out of date.");
|
|
1298
|
+
io.err("Removing the flypod parts is safe — the skill above replaces them.");
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
return 0;
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
// src/cli/source.ts
|
|
1305
|
+
async function resolveCliSource(env, cwd) {
|
|
1306
|
+
const explicit = env.FLYPOD_SOURCE;
|
|
1307
|
+
if (explicit)
|
|
1308
|
+
return coerceSource(explicit);
|
|
1309
|
+
try {
|
|
1310
|
+
return await skillInstalledIn(cwd) ? "skill" : "cli";
|
|
1311
|
+
} catch {
|
|
1312
|
+
return "cli";
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
// src/cli/client.ts
|
|
1317
|
+
var DEVICE_CLIENT_ID = "flypod-cli";
|
|
1318
|
+
var DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
1319
|
+
function resolveCredentials(env, session, overrides) {
|
|
1320
|
+
const token = overrides?.token ?? overrides?.manageToken ?? env.FLYPOD_TOKEN ?? session?.session_token ?? env.FLYPOD_API_KEY;
|
|
1321
|
+
const baseUrl = overrides?.baseUrl ?? session?.base_url ?? env.DEPLOY_URL ?? "https://flypod.dev";
|
|
1322
|
+
return { token, baseUrl };
|
|
1323
|
+
}
|
|
1324
|
+
function buildClient(token, baseUrl, fetchImpl, source = "library") {
|
|
1325
|
+
async function request(method, path, init = {}) {
|
|
1326
|
+
const url = new URL(path, baseUrl);
|
|
1327
|
+
if (init.query) {
|
|
1328
|
+
for (const [key, value] of Object.entries(init.query)) {
|
|
1329
|
+
if (value !== undefined)
|
|
1330
|
+
url.searchParams.set(key, value);
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
const headers = { [SOURCE_HEADER]: source };
|
|
1334
|
+
if (token)
|
|
1335
|
+
headers.authorization = `Bearer ${token}`;
|
|
1336
|
+
if (init.json !== undefined)
|
|
1337
|
+
headers["content-type"] = "application/json";
|
|
1338
|
+
else if (init.zip !== undefined)
|
|
1339
|
+
headers["content-type"] = "application/zip";
|
|
1340
|
+
const body = init.json !== undefined ? JSON.stringify(init.json) : init.zip;
|
|
1341
|
+
return fetchImpl(url.toString(), { method, headers, body });
|
|
1342
|
+
}
|
|
1343
|
+
return {
|
|
1344
|
+
baseUrl,
|
|
1345
|
+
token,
|
|
1346
|
+
source,
|
|
1347
|
+
request,
|
|
1348
|
+
deviceCode: () => request("POST", "/api/auth/device/code", { json: { client_id: DEVICE_CLIENT_ID } }),
|
|
1349
|
+
deviceToken: (deviceCode) => request("POST", "/api/auth/device/token", {
|
|
1350
|
+
json: {
|
|
1351
|
+
grant_type: DEVICE_GRANT_TYPE,
|
|
1352
|
+
device_code: deviceCode,
|
|
1353
|
+
client_id: DEVICE_CLIENT_ID
|
|
1354
|
+
}
|
|
1355
|
+
}),
|
|
1356
|
+
listSites: () => request("GET", "/account/sites"),
|
|
1357
|
+
claimSite: (siteId, claimToken) => request("POST", `/sites/${siteId}/claim`, { json: { claim_token: claimToken } }),
|
|
1358
|
+
bulkAttach: (sites) => request("POST", "/account/bulk-attach", { json: { sites } }),
|
|
1359
|
+
getSite: (siteId) => request("GET", `/sites/${siteId}`),
|
|
1360
|
+
createSite: (zip) => request("POST", "/sites", { zip }),
|
|
1361
|
+
redeploy: (siteId, zip) => request("POST", `/sites/${siteId}/deploys`, { zip }),
|
|
1362
|
+
rollback: (siteId, versionId) => request("POST", `/sites/${siteId}/rollback`, { json: { version_id: versionId } }),
|
|
1363
|
+
setCommentsMode: (siteId, body) => request("POST", `/api/sites/${siteId}/comments-mode`, { json: body }),
|
|
1364
|
+
listComments: (siteId, query) => request("GET", `/api/sites/${siteId}/comments`, { query }),
|
|
1365
|
+
getThread: (siteId, threadId) => request("GET", `/api/sites/${siteId}/comments/${threadId}`),
|
|
1366
|
+
postComment: (siteId, body) => request("POST", `/api/sites/${siteId}/comments`, { json: body }),
|
|
1367
|
+
setThreadStatus: (siteId, threadId, status) => request("POST", `/api/sites/${siteId}/comments/${threadId}/${status}`)
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
async function createClient(opts) {
|
|
1371
|
+
const env = opts.env ?? process.env;
|
|
1372
|
+
const fetchImpl = opts.fetch ?? fetch;
|
|
1373
|
+
const session = await loadSession(env);
|
|
1374
|
+
const { token, baseUrl } = resolveCredentials(env, session, opts.overrides);
|
|
1375
|
+
const source = await resolveCliSource(env, opts.cwd ?? process.cwd());
|
|
1376
|
+
return buildClient(token, baseUrl, fetchImpl, source);
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
// src/cli.ts
|
|
1380
|
+
var BUILD_DIR_CANDIDATES = [
|
|
1381
|
+
"dist",
|
|
1382
|
+
"build",
|
|
1383
|
+
"out",
|
|
1384
|
+
".output/public",
|
|
1385
|
+
".vercel/output/static",
|
|
1386
|
+
"public",
|
|
1387
|
+
"_site"
|
|
1388
|
+
];
|
|
1389
|
+
async function resolveDeployDir(opts = {}) {
|
|
1390
|
+
if (opts.explicit)
|
|
1391
|
+
return opts.explicit;
|
|
1392
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
1393
|
+
for (const candidate of BUILD_DIR_CANDIDATES) {
|
|
1394
|
+
const dir = join3(cwd, candidate);
|
|
1395
|
+
try {
|
|
1396
|
+
if (!(await stat2(dir)).isDirectory())
|
|
1397
|
+
continue;
|
|
1398
|
+
if ((await stat2(join3(dir, "index.html"))).isFile())
|
|
1399
|
+
return dir;
|
|
1400
|
+
} catch {}
|
|
1401
|
+
}
|
|
1402
|
+
throw new Error(`No build output folder found. Looked for ${BUILD_DIR_CANDIDATES.join(", ")} ` + `(each must contain an index.html). Pass the folder explicitly, e.g. \`npx flypod ./dist\`.`);
|
|
1403
|
+
}
|
|
1404
|
+
async function collectDist(path) {
|
|
1405
|
+
const info = await stat2(path);
|
|
1406
|
+
if (info.isFile()) {
|
|
1407
|
+
const name = path.split("/").pop() ?? "index.html";
|
|
1408
|
+
return { [name]: await readFile3(path) };
|
|
1409
|
+
}
|
|
1410
|
+
const files = {};
|
|
1411
|
+
async function walk(current) {
|
|
1412
|
+
for (const entry of await readdir(current, { withFileTypes: true })) {
|
|
1413
|
+
const full = join3(current, entry.name);
|
|
1414
|
+
if (entry.isDirectory())
|
|
1415
|
+
await walk(full);
|
|
1416
|
+
else
|
|
1417
|
+
files[relative(path, full).split("\\").join("/")] = await readFile3(full);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
await walk(path);
|
|
1421
|
+
return files;
|
|
1422
|
+
}
|
|
1423
|
+
async function deploySite(opts) {
|
|
1424
|
+
const handle = opts.handle ?? ((request) => fetch(request));
|
|
1425
|
+
const baseUrl = opts.baseUrl ?? "https://flypod.dev";
|
|
1426
|
+
const zip = zipSync(opts.files);
|
|
1427
|
+
const bridgeFetch = async (input, init) => handle(new Request(typeof input === "string" ? input : input.url, init));
|
|
1428
|
+
const client = buildClient(opts.apiKey, baseUrl, bridgeFetch, opts.source ?? "library");
|
|
1429
|
+
const res = await client.createSite(zip);
|
|
1430
|
+
if (!res.ok)
|
|
1431
|
+
throw new Error(`deploy failed: ${res.status}`);
|
|
1432
|
+
return await res.json();
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
export { zipSync, projectsFilePath, atomicWriteFile, saveSession, clearSession, installSkill, resolveCredentials, createClient, BUILD_DIR_CANDIDATES, resolveDeployDir, collectDist, deploySite };
|