flypod 0.3.0 → 0.4.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 +57 -0
- package/dist/bin/deploy.js +552 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -92,6 +92,7 @@ The URL is always printed alone on stdout in pretty and quiet modes, so
|
|
|
92
92
|
|
|
93
93
|
| Variable | Description |
|
|
94
94
|
|----------|-------------|
|
|
95
|
+
| `FLYPOD_API_KEY` | Deploy as your account without `flypod login` (agents / CI). A saved session takes precedence |
|
|
95
96
|
| `DEPLOY_URL` | Override the deploy server (default: `https://flypod.dev`) |
|
|
96
97
|
| `NO_COLOR` | Disable ANSI colors |
|
|
97
98
|
| `FORCE_COLOR` | Force colors even when stderr is not a TTY |
|
|
@@ -154,6 +155,62 @@ doesn't remember it.
|
|
|
154
155
|
|
|
155
156
|
---
|
|
156
157
|
|
|
158
|
+
## Teach your coding agents
|
|
159
|
+
|
|
160
|
+
One command writes a small instruction file into your coding agents so they know
|
|
161
|
+
how to deploy with flypod — no config, no copy-paste.
|
|
162
|
+
|
|
163
|
+
```sh
|
|
164
|
+
npx flypod install skill
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Run in a terminal, it shows a checklist of the agents it found. It always writes
|
|
168
|
+
the universal [`AGENTS.md`](https://agents.md) (read by Codex, Cursor, Copilot,
|
|
169
|
+
Gemini, Zed, Jules, and ~20 more) plus a first-class **Claude Code** skill at
|
|
170
|
+
`.claude/skills/flypod/SKILL.md`, and pre-selects any other agents it detects in
|
|
171
|
+
your repo (Cursor, Windsurf, Cline, Roo, …).
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
flypod · teach your agents to deploy
|
|
175
|
+
|
|
176
|
+
Install the flypod skill into:
|
|
177
|
+
|
|
178
|
+
› ◉ AGENTS.md universal — Codex, Cursor, Copilot, Gemini, Zed, Jules, +more
|
|
179
|
+
◉ Claude Code .claude/skills/flypod/SKILL.md — loaded on demand
|
|
180
|
+
◉ Cursor .cursor/rules/flypod.mdc · detected
|
|
181
|
+
◯ Windsurf .windsurf/rules/flypod.md
|
|
182
|
+
|
|
183
|
+
↑/↓ move · space toggle · a all · enter confirm · esc cancel
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
It's idempotent — shared files (`AGENTS.md`, `copilot-instructions.md`, `GEMINI.md`)
|
|
187
|
+
get a fenced `flypod` block that re-runs replace in place, never clobbering your
|
|
188
|
+
own content. Dedicated rule files are flypod-owned and rewritten wholesale.
|
|
189
|
+
|
|
190
|
+
Non-interactive when piped or under an agent (writes the same defaults), so it
|
|
191
|
+
drops cleanly into setup scripts and CI.
|
|
192
|
+
|
|
193
|
+
```sh
|
|
194
|
+
flypod install skill --all # write files for every supported agent
|
|
195
|
+
flypod install skill --claude # just the Claude Code skill
|
|
196
|
+
flypod install skill --global # install at the user level (~/.claude + ~/.codex; add --all for ~/.gemini)
|
|
197
|
+
flypod install skill --list # show what's detected and where it would go
|
|
198
|
+
flypod install skill --dry-run # print the planned paths, write nothing
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
| Target | File written |
|
|
202
|
+
|--------|--------------|
|
|
203
|
+
| `--agents` | `AGENTS.md` (universal) |
|
|
204
|
+
| `--claude` | `.claude/skills/flypod/SKILL.md` |
|
|
205
|
+
| `--cursor` | `.cursor/rules/flypod.mdc` |
|
|
206
|
+
| `--copilot` | `.github/copilot-instructions.md` |
|
|
207
|
+
| `--windsurf` | `.windsurf/rules/flypod.md` |
|
|
208
|
+
| `--cline` | `.clinerules/flypod.md` |
|
|
209
|
+
| `--roo` | `.roo/rules/flypod.md` |
|
|
210
|
+
| `--gemini` | `GEMINI.md` |
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
157
214
|
## Library
|
|
158
215
|
|
|
159
216
|
```ts
|
package/dist/bin/deploy.js
CHANGED
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
} from "../cli-ynzcc4xy.js";
|
|
8
8
|
|
|
9
9
|
// bin/deploy.ts
|
|
10
|
-
import { readFile as
|
|
10
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
11
|
+
import { homedir as homedir3 } from "node:os";
|
|
11
12
|
import { relative } from "node:path";
|
|
12
13
|
import { fileURLToPath } from "node:url";
|
|
13
14
|
|
|
@@ -115,6 +116,12 @@ async function forgetSite(site_id, env) {
|
|
|
115
116
|
|
|
116
117
|
// src/cli/session.ts
|
|
117
118
|
import { readFile as readFile2, unlink } from "node:fs/promises";
|
|
119
|
+
async function resolveAuth(env = process.env) {
|
|
120
|
+
const session = await loadSession(env);
|
|
121
|
+
const apiKey = session?.api_key ?? env.FLYPOD_API_KEY;
|
|
122
|
+
const baseUrl = session?.base_url ?? env.DEPLOY_URL ?? "https://flypod.dev";
|
|
123
|
+
return { apiKey, baseUrl };
|
|
124
|
+
}
|
|
118
125
|
async function loadSession(env) {
|
|
119
126
|
try {
|
|
120
127
|
const path = sessionFilePath(env);
|
|
@@ -457,8 +464,463 @@ async function forget(args, io) {
|
|
|
457
464
|
return 0;
|
|
458
465
|
}
|
|
459
466
|
|
|
460
|
-
// src/
|
|
467
|
+
// src/cli/select.ts
|
|
461
468
|
var ESC = "\x1B[";
|
|
469
|
+
function canPrompt(input = process.stdin, output = process.stderr) {
|
|
470
|
+
return Boolean(input.isTTY && output.isTTY && typeof input.setRawMode === "function");
|
|
471
|
+
}
|
|
472
|
+
function multiselect(opts) {
|
|
473
|
+
const input = opts.input ?? process.stdin;
|
|
474
|
+
const output = opts.output ?? process.stderr;
|
|
475
|
+
const { style } = opts;
|
|
476
|
+
const choices = opts.choices.map((c) => ({ ...c }));
|
|
477
|
+
return new Promise((resolve) => {
|
|
478
|
+
let index = 0;
|
|
479
|
+
let printed = 0;
|
|
480
|
+
const footer = style.dim("↑/↓ move · space toggle · a all · enter confirm · esc cancel");
|
|
481
|
+
const render = () => {
|
|
482
|
+
const lines = [` ${style.bold(opts.title)}`, ""];
|
|
483
|
+
choices.forEach((c, i) => {
|
|
484
|
+
const active = i === index;
|
|
485
|
+
const pointer = active ? style.accent("›") : " ";
|
|
486
|
+
const box = c.checked ? style.ok("◉") : style.dim("◯");
|
|
487
|
+
const label = active ? style.bold(c.label) : c.label;
|
|
488
|
+
const hint = c.hint ? ` ${style.dim(c.hint)}` : "";
|
|
489
|
+
lines.push(` ${pointer} ${box} ${label}${hint}`);
|
|
490
|
+
});
|
|
491
|
+
lines.push("");
|
|
492
|
+
lines.push(` ${footer}`);
|
|
493
|
+
return lines;
|
|
494
|
+
};
|
|
495
|
+
const draw = () => {
|
|
496
|
+
if (printed > 0)
|
|
497
|
+
output.write(`${ESC}${printed}A`);
|
|
498
|
+
output.write(`${ESC}0J`);
|
|
499
|
+
const lines = render();
|
|
500
|
+
output.write(`${lines.join(`
|
|
501
|
+
`)}
|
|
502
|
+
`);
|
|
503
|
+
printed = lines.length;
|
|
504
|
+
};
|
|
505
|
+
const cleanup = () => {
|
|
506
|
+
if (printed > 0) {
|
|
507
|
+
output.write(`${ESC}${printed}A`);
|
|
508
|
+
output.write(`${ESC}0J`);
|
|
509
|
+
}
|
|
510
|
+
output.write(`${ESC}?25h`);
|
|
511
|
+
input.removeListener("data", onData);
|
|
512
|
+
if (typeof input.setRawMode === "function")
|
|
513
|
+
input.setRawMode(false);
|
|
514
|
+
input.pause();
|
|
515
|
+
};
|
|
516
|
+
const finish = (value) => {
|
|
517
|
+
cleanup();
|
|
518
|
+
resolve(value);
|
|
519
|
+
};
|
|
520
|
+
const onData = (buf) => {
|
|
521
|
+
const key = buf.toString("utf8");
|
|
522
|
+
switch (key) {
|
|
523
|
+
case "\x03":
|
|
524
|
+
case "\x1B":
|
|
525
|
+
case "q":
|
|
526
|
+
return finish(null);
|
|
527
|
+
case "\r":
|
|
528
|
+
case `
|
|
529
|
+
`:
|
|
530
|
+
return finish(choices.filter((c) => c.checked).map((c) => c.id));
|
|
531
|
+
case " ": {
|
|
532
|
+
const c = choices[index];
|
|
533
|
+
if (c)
|
|
534
|
+
c.checked = !c.checked;
|
|
535
|
+
return draw();
|
|
536
|
+
}
|
|
537
|
+
case "a": {
|
|
538
|
+
const allOn = choices.every((c) => c.checked);
|
|
539
|
+
for (const c of choices)
|
|
540
|
+
c.checked = !allOn;
|
|
541
|
+
return draw();
|
|
542
|
+
}
|
|
543
|
+
case "\x1B[A":
|
|
544
|
+
case "k":
|
|
545
|
+
index = (index - 1 + choices.length) % choices.length;
|
|
546
|
+
return draw();
|
|
547
|
+
case "\x1B[B":
|
|
548
|
+
case "j":
|
|
549
|
+
index = (index + 1) % choices.length;
|
|
550
|
+
return draw();
|
|
551
|
+
default:
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
output.write(`${ESC}?25l`);
|
|
556
|
+
if (typeof input.setRawMode === "function")
|
|
557
|
+
input.setRawMode(true);
|
|
558
|
+
input.resume();
|
|
559
|
+
input.on("data", onData);
|
|
560
|
+
draw();
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// src/cli/skill.ts
|
|
565
|
+
import { mkdir as mkdir2, readFile as readFile3, stat, writeFile as writeFile2 } from "node:fs/promises";
|
|
566
|
+
import { homedir as homedir2 } from "node:os";
|
|
567
|
+
import { dirname as dirname2, join as join2 } from "node:path";
|
|
568
|
+
var SKILL_NAME = "flypod";
|
|
569
|
+
var SKILL_DESCRIPTION = "Deploy any folder of static files to a live public URL with flypod (flypod.dev) — no account, config, or build pipeline needed. " + "Use when the user wants to deploy, publish, ship, share, or host a static site, build output, preview, or demo, or asks to put a finished build online or get a URL for it.";
|
|
570
|
+
var MARK_BEGIN = `<!-- ${SKILL_NAME}:begin -->`;
|
|
571
|
+
var MARK_END = `<!-- ${SKILL_NAME}:end -->`;
|
|
572
|
+
function renderBody(sub) {
|
|
573
|
+
return `flypod turns any folder of static files into a live, public URL with a single
|
|
574
|
+
command. No account, no config, no build step of its own — you bring the built
|
|
575
|
+
files, flypod hosts them. Reach for it the moment a build exists and the user
|
|
576
|
+
wants it online: a site, a preview, a demo, a one-off share.
|
|
577
|
+
|
|
578
|
+
${sub} The happy path
|
|
579
|
+
|
|
580
|
+
1. Make sure the site is built — there is a folder of static files to ship
|
|
581
|
+
(e.g. \`dist/\`, \`build/\`, \`out/\`). flypod ships files; it does not build them.
|
|
582
|
+
2. Deploy that folder. Prefer \`--json\` so you can read the result:
|
|
583
|
+
|
|
584
|
+
\`\`\`sh
|
|
585
|
+
npx flypod ./dist --json
|
|
586
|
+
\`\`\`
|
|
587
|
+
|
|
588
|
+
If flypod is installed globally, drop the \`npx\`: \`flypod ./dist --json\`.
|
|
589
|
+
3. Read the \`url\` field from the JSON and give it to the user. That is the live
|
|
590
|
+
site. That's the whole loop.
|
|
591
|
+
|
|
592
|
+
If you omit the path, flypod auto-detects a build folder, trying \`dist\`,
|
|
593
|
+
\`build\`, \`out\`, \`.output/public\`, \`.vercel/output/static\`, \`public\`, \`_site\`
|
|
594
|
+
(each must contain an \`index.html\`). When in doubt, pass the path explicitly.
|
|
595
|
+
|
|
596
|
+
${sub} Is flypod installed?
|
|
597
|
+
|
|
598
|
+
Run \`flypod --version\`. If it is missing, **do not install anything** — just
|
|
599
|
+
prefix commands with \`npx\`: \`npx flypod ...\` downloads and runs it on the fly.
|
|
600
|
+
To install once: \`npm install -g flypod\`.
|
|
601
|
+
|
|
602
|
+
${sub} Reading the result
|
|
603
|
+
|
|
604
|
+
\`npx flypod ./dist --json\` prints a JSON object on stdout:
|
|
605
|
+
|
|
606
|
+
\`\`\`json
|
|
607
|
+
{
|
|
608
|
+
"ok": true,
|
|
609
|
+
"url": "https://ab12cd34.flypod.dev",
|
|
610
|
+
"site_id": "ab12cd34",
|
|
611
|
+
"manage_token": "…",
|
|
612
|
+
"claim_token": "…",
|
|
613
|
+
"expires_at": 1782929906088,
|
|
614
|
+
"files": 12,
|
|
615
|
+
"bytes": 1234567,
|
|
616
|
+
"elapsed_ms": 812
|
|
617
|
+
}
|
|
618
|
+
\`\`\`
|
|
619
|
+
|
|
620
|
+
- \`url\` — the live site. Always surface this to the user.
|
|
621
|
+
- \`manage_token\` — save it; it is needed to redeploy, roll back, or delete the site.
|
|
622
|
+
- \`claim_token\` — save it; it attaches an anonymous site to an account later.
|
|
623
|
+
- \`expires_at\` — anonymous deploys are ephemeral (~14 days); \`null\` once owned.
|
|
624
|
+
|
|
625
|
+
Treat \`manage_token\` and \`claim_token\` as secrets — don't paste them into chat
|
|
626
|
+
unless the user asks. Without \`--json\`, use quiet mode to capture the URL in a
|
|
627
|
+
shell variable: \`URL=$(npx flypod ./dist -q)\` (URL on stdout, token on stderr).
|
|
628
|
+
|
|
629
|
+
${sub} Anonymous vs. signed in
|
|
630
|
+
|
|
631
|
+
- **Anonymous (default):** zero auth. The first deploy just works and the site
|
|
632
|
+
expires in ~14 days. Best for previews and throwaways.
|
|
633
|
+
- **Signed in:** deploys are attributed to an account, never expire, and show up
|
|
634
|
+
in \`flypod list\`. Sign in once (no interactive prompt):
|
|
635
|
+
|
|
636
|
+
\`\`\`sh
|
|
637
|
+
flypod login --key fk_xxxxxxxxxxxxxxxxxxxx
|
|
638
|
+
\`\`\`
|
|
639
|
+
|
|
640
|
+
For agents and CI, skip the session file entirely — set the key in the
|
|
641
|
+
environment and every deploy is attributed to the account:
|
|
642
|
+
|
|
643
|
+
\`\`\`sh
|
|
644
|
+
FLYPOD_API_KEY=fk_xxxxxxxxxxxxxxxxxxxx npx flypod ./dist --json
|
|
645
|
+
\`\`\`
|
|
646
|
+
|
|
647
|
+
Mint a key at https://flypod.dev/account, or run \`flypod keys create\` when
|
|
648
|
+
already signed in.
|
|
649
|
+
|
|
650
|
+
${sub} Other commands
|
|
651
|
+
|
|
652
|
+
\`\`\`sh
|
|
653
|
+
flypod list # sites you own (requires sign in)
|
|
654
|
+
flypod claim <site_id> <token> # attach an anonymous deploy to your account
|
|
655
|
+
flypod keys create # mint an API key for agents / CI
|
|
656
|
+
flypod logout # forget the saved key
|
|
657
|
+
flypod --help # full usage
|
|
658
|
+
\`\`\`
|
|
659
|
+
|
|
660
|
+
${sub} Rules of thumb
|
|
661
|
+
|
|
662
|
+
- Build first. Point flypod at the **output** folder, never the project root or source.
|
|
663
|
+
- Prefer \`--json\` and read \`url\`. Use \`-q\`/\`--quiet\` when you only need the URL.
|
|
664
|
+
- flypod hosts **static files only** (HTML/CSS/JS/assets). It runs no server or backend.
|
|
665
|
+
- A missing \`flypod\` binary is fine — use \`npx flypod\`; never block on installing it.`;
|
|
666
|
+
}
|
|
667
|
+
function standaloneMarkdown() {
|
|
668
|
+
return `# Deploy with flypod
|
|
669
|
+
|
|
670
|
+
${renderBody("##")}
|
|
671
|
+
`;
|
|
672
|
+
}
|
|
673
|
+
function embedSection() {
|
|
674
|
+
return `${MARK_BEGIN}
|
|
675
|
+
## Deploying with flypod
|
|
676
|
+
|
|
677
|
+
${renderBody("###")}
|
|
678
|
+
${MARK_END}`;
|
|
679
|
+
}
|
|
680
|
+
function claudeSkillFile() {
|
|
681
|
+
return `---
|
|
682
|
+
name: ${SKILL_NAME}
|
|
683
|
+
description: ${SKILL_DESCRIPTION}
|
|
684
|
+
---
|
|
685
|
+
|
|
686
|
+
${standaloneMarkdown()}`;
|
|
687
|
+
}
|
|
688
|
+
function cursorRuleFile() {
|
|
689
|
+
return `---
|
|
690
|
+
description: ${SKILL_DESCRIPTION}
|
|
691
|
+
globs:
|
|
692
|
+
alwaysApply: false
|
|
693
|
+
---
|
|
694
|
+
|
|
695
|
+
${standaloneMarkdown()}`;
|
|
696
|
+
}
|
|
697
|
+
async function exists(path) {
|
|
698
|
+
try {
|
|
699
|
+
await stat(path);
|
|
700
|
+
return true;
|
|
701
|
+
} catch {
|
|
702
|
+
return false;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
async function anyExists(root, rels) {
|
|
706
|
+
for (const rel of rels) {
|
|
707
|
+
if (await exists(join2(root, rel)))
|
|
708
|
+
return true;
|
|
709
|
+
}
|
|
710
|
+
return false;
|
|
711
|
+
}
|
|
712
|
+
var TARGETS = [
|
|
713
|
+
{
|
|
714
|
+
id: "agents",
|
|
715
|
+
label: "AGENTS.md",
|
|
716
|
+
detail: "universal — Codex, Cursor, Copilot, Gemini, Zed, Jules, +more",
|
|
717
|
+
kind: "embed",
|
|
718
|
+
alwaysDefault: true,
|
|
719
|
+
projectPath: (root) => join2(root, "AGENTS.md"),
|
|
720
|
+
globalPath: () => join2(homedir2(), ".codex", "AGENTS.md"),
|
|
721
|
+
detect: () => Promise.resolve(true),
|
|
722
|
+
render: embedSection
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
id: "claude",
|
|
726
|
+
label: "Claude Code",
|
|
727
|
+
detail: ".claude/skills/flypod/SKILL.md — loaded on demand",
|
|
728
|
+
kind: "skill",
|
|
729
|
+
alwaysDefault: true,
|
|
730
|
+
projectPath: (root) => join2(root, ".claude", "skills", SKILL_NAME, "SKILL.md"),
|
|
731
|
+
globalPath: () => join2(homedir2(), ".claude", "skills", SKILL_NAME, "SKILL.md"),
|
|
732
|
+
detect: (root) => anyExists(root, [".claude", "CLAUDE.md"]),
|
|
733
|
+
render: claudeSkillFile
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
id: "cursor",
|
|
737
|
+
label: "Cursor",
|
|
738
|
+
detail: ".cursor/rules/flypod.mdc",
|
|
739
|
+
kind: "rules",
|
|
740
|
+
alwaysDefault: false,
|
|
741
|
+
projectPath: (root) => join2(root, ".cursor", "rules", `${SKILL_NAME}.mdc`),
|
|
742
|
+
globalPath: () => null,
|
|
743
|
+
detect: (root) => anyExists(root, [".cursor", ".cursorrules"]),
|
|
744
|
+
render: cursorRuleFile
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
id: "copilot",
|
|
748
|
+
label: "GitHub Copilot",
|
|
749
|
+
detail: ".github/copilot-instructions.md",
|
|
750
|
+
kind: "embed",
|
|
751
|
+
alwaysDefault: false,
|
|
752
|
+
projectPath: (root) => join2(root, ".github", "copilot-instructions.md"),
|
|
753
|
+
globalPath: () => null,
|
|
754
|
+
detect: (root) => anyExists(root, [".github"]),
|
|
755
|
+
render: embedSection
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
id: "windsurf",
|
|
759
|
+
label: "Windsurf",
|
|
760
|
+
detail: ".windsurf/rules/flypod.md",
|
|
761
|
+
kind: "rules",
|
|
762
|
+
alwaysDefault: false,
|
|
763
|
+
projectPath: (root) => join2(root, ".windsurf", "rules", `${SKILL_NAME}.md`),
|
|
764
|
+
globalPath: () => null,
|
|
765
|
+
detect: (root) => anyExists(root, [".windsurf", ".windsurfrules"]),
|
|
766
|
+
render: standaloneMarkdown
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
id: "cline",
|
|
770
|
+
label: "Cline",
|
|
771
|
+
detail: ".clinerules/flypod.md",
|
|
772
|
+
kind: "rules",
|
|
773
|
+
alwaysDefault: false,
|
|
774
|
+
projectPath: (root) => join2(root, ".clinerules", `${SKILL_NAME}.md`),
|
|
775
|
+
globalPath: () => null,
|
|
776
|
+
detect: (root) => anyExists(root, [".clinerules"]),
|
|
777
|
+
render: standaloneMarkdown
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
id: "roo",
|
|
781
|
+
label: "Roo Code",
|
|
782
|
+
detail: ".roo/rules/flypod.md",
|
|
783
|
+
kind: "rules",
|
|
784
|
+
alwaysDefault: false,
|
|
785
|
+
projectPath: (root) => join2(root, ".roo", "rules", `${SKILL_NAME}.md`),
|
|
786
|
+
globalPath: () => null,
|
|
787
|
+
detect: (root) => anyExists(root, [".roo", ".roorules"]),
|
|
788
|
+
render: standaloneMarkdown
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
id: "gemini",
|
|
792
|
+
label: "Gemini CLI",
|
|
793
|
+
detail: "GEMINI.md",
|
|
794
|
+
kind: "embed",
|
|
795
|
+
alwaysDefault: false,
|
|
796
|
+
projectPath: (root) => join2(root, "GEMINI.md"),
|
|
797
|
+
globalPath: () => join2(homedir2(), ".gemini", "GEMINI.md"),
|
|
798
|
+
detect: (root) => anyExists(root, ["GEMINI.md", ".gemini"]),
|
|
799
|
+
render: embedSection
|
|
800
|
+
}
|
|
801
|
+
];
|
|
802
|
+
function spliceBlock(existing, section) {
|
|
803
|
+
const begin = existing.indexOf(MARK_BEGIN);
|
|
804
|
+
const end = existing.indexOf(MARK_END);
|
|
805
|
+
if (begin !== -1 && end !== -1 && end > begin) {
|
|
806
|
+
const before = existing.slice(0, begin);
|
|
807
|
+
const after = existing.slice(end + MARK_END.length);
|
|
808
|
+
return `${before}${section}${after}`;
|
|
809
|
+
}
|
|
810
|
+
const trimmed = existing.replace(/\s+$/, "");
|
|
811
|
+
return trimmed ? `${trimmed}
|
|
812
|
+
|
|
813
|
+
${section}
|
|
814
|
+
` : `${section}
|
|
815
|
+
`;
|
|
816
|
+
}
|
|
817
|
+
async function writeTarget(target, path) {
|
|
818
|
+
const had = await exists(path);
|
|
819
|
+
const current = had ? await readFile3(path, "utf8") : "";
|
|
820
|
+
let next;
|
|
821
|
+
if (target.kind === "embed") {
|
|
822
|
+
next = spliceBlock(current, target.render());
|
|
823
|
+
} else {
|
|
824
|
+
next = target.render();
|
|
825
|
+
}
|
|
826
|
+
if (had && current === next)
|
|
827
|
+
return { target, path, status: "unchanged" };
|
|
828
|
+
await mkdir2(dirname2(path), { recursive: true });
|
|
829
|
+
await writeFile2(path, next, "utf8");
|
|
830
|
+
return { target, path, status: had ? "updated" : "created" };
|
|
831
|
+
}
|
|
832
|
+
async function buildPlan(root, env, global) {
|
|
833
|
+
const entries = [];
|
|
834
|
+
for (const target of TARGETS) {
|
|
835
|
+
const path = global ? target.globalPath(env) : target.projectPath(root);
|
|
836
|
+
if (!path)
|
|
837
|
+
continue;
|
|
838
|
+
const detected = await target.detect(root, env);
|
|
839
|
+
entries.push({
|
|
840
|
+
target,
|
|
841
|
+
path,
|
|
842
|
+
detected,
|
|
843
|
+
defaultOn: target.alwaysDefault || detected
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
return entries;
|
|
847
|
+
}
|
|
848
|
+
async function installSkill(args, io) {
|
|
849
|
+
const env = io.env ?? process.env;
|
|
850
|
+
const root = args.cwd ?? process.cwd();
|
|
851
|
+
const global = Boolean(args.global);
|
|
852
|
+
const plan = await buildPlan(root, env, global);
|
|
853
|
+
if (args.list) {
|
|
854
|
+
io.err(global ? "flypod skill targets (global):" : "flypod skill targets (this project):");
|
|
855
|
+
io.err("");
|
|
856
|
+
for (const e of plan) {
|
|
857
|
+
const mark = e.defaultOn ? "●" : "○";
|
|
858
|
+
const tag = e.target.alwaysDefault ? "default" : e.detected ? "detected" : "available";
|
|
859
|
+
io.out(`${mark} ${e.target.id} ${tag} ${e.path}`);
|
|
860
|
+
}
|
|
861
|
+
io.err("");
|
|
862
|
+
io.err("● = installed by default. Run `flypod install skill` to write them.");
|
|
863
|
+
return 0;
|
|
864
|
+
}
|
|
865
|
+
let chosen;
|
|
866
|
+
if (args.all) {
|
|
867
|
+
chosen = plan.map((e) => e.target.id);
|
|
868
|
+
} else if (args.targets && args.targets.length > 0) {
|
|
869
|
+
const known = new Set(plan.map((e) => e.target.id));
|
|
870
|
+
const unknown = args.targets.filter((id) => !known.has(id));
|
|
871
|
+
if (unknown.length > 0) {
|
|
872
|
+
io.err(`flypod: unknown target(s): ${unknown.join(", ")}`);
|
|
873
|
+
io.err(`Known targets: ${TARGETS.map((t) => t.id).join(", ")}`);
|
|
874
|
+
return 2;
|
|
875
|
+
}
|
|
876
|
+
chosen = args.targets;
|
|
877
|
+
} else if (args.picker) {
|
|
878
|
+
const picked = await args.picker(plan);
|
|
879
|
+
if (picked === null) {
|
|
880
|
+
io.err("Cancelled. Nothing written.");
|
|
881
|
+
return 130;
|
|
882
|
+
}
|
|
883
|
+
chosen = picked;
|
|
884
|
+
} else {
|
|
885
|
+
chosen = plan.filter((e) => e.defaultOn).map((e) => e.target.id);
|
|
886
|
+
}
|
|
887
|
+
const selected = plan.filter((e) => chosen.includes(e.target.id));
|
|
888
|
+
if (selected.length === 0) {
|
|
889
|
+
io.err("No targets selected. Nothing written.");
|
|
890
|
+
return 0;
|
|
891
|
+
}
|
|
892
|
+
if (args.dryRun) {
|
|
893
|
+
io.err("Would write:");
|
|
894
|
+
for (const e of selected)
|
|
895
|
+
io.out(e.path);
|
|
896
|
+
return 0;
|
|
897
|
+
}
|
|
898
|
+
const results = [];
|
|
899
|
+
for (const e of selected) {
|
|
900
|
+
try {
|
|
901
|
+
results.push(await writeTarget(e.target, e.path));
|
|
902
|
+
} catch (error) {
|
|
903
|
+
io.err(`flypod: failed to write ${e.path}: ${error.message}`);
|
|
904
|
+
return 1;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
const verb = {
|
|
908
|
+
created: "created",
|
|
909
|
+
updated: "updated",
|
|
910
|
+
unchanged: "up to date"
|
|
911
|
+
};
|
|
912
|
+
for (const r of results) {
|
|
913
|
+
io.err(` ${r.status === "unchanged" ? "·" : "✓"} ${verb[r.status]} ${r.path}`);
|
|
914
|
+
io.out(r.path);
|
|
915
|
+
}
|
|
916
|
+
const changed = results.filter((r) => r.status !== "unchanged").length;
|
|
917
|
+
io.err("");
|
|
918
|
+
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.");
|
|
919
|
+
return 0;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// src/ui.ts
|
|
923
|
+
var ESC2 = "\x1B[";
|
|
462
924
|
function envBool(name) {
|
|
463
925
|
const v = process.env[name];
|
|
464
926
|
return v !== undefined && v !== "" && v !== "0" && v !== "false";
|
|
@@ -472,7 +934,7 @@ function colorsEnabled(stream = process.stderr) {
|
|
|
472
934
|
}
|
|
473
935
|
var FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
474
936
|
function paint(open, s) {
|
|
475
|
-
return `${
|
|
937
|
+
return `${ESC2}${open}m${s}${ESC2}0m`;
|
|
476
938
|
}
|
|
477
939
|
function makeStyle(enabled) {
|
|
478
940
|
if (!enabled) {
|
|
@@ -495,11 +957,11 @@ function makeSpinner(stream = process.stderr, style = makeStyle(false)) {
|
|
|
495
957
|
let label = "";
|
|
496
958
|
let started = false;
|
|
497
959
|
const writeFrame = () => {
|
|
498
|
-
stream.write(`\r${
|
|
960
|
+
stream.write(`\r${ESC2}2K ${style.accent(FRAMES[frame] ?? "·")} ${label}`);
|
|
499
961
|
};
|
|
500
962
|
const clearLine = () => {
|
|
501
963
|
if (tty)
|
|
502
|
-
stream.write(`\r${
|
|
964
|
+
stream.write(`\r${ESC2}2K`);
|
|
503
965
|
};
|
|
504
966
|
return {
|
|
505
967
|
start(text) {
|
|
@@ -571,8 +1033,20 @@ var SUBCOMMANDS = new Set([
|
|
|
571
1033
|
"logout",
|
|
572
1034
|
"list",
|
|
573
1035
|
"claim",
|
|
574
|
-
"keys"
|
|
1036
|
+
"keys",
|
|
1037
|
+
"install"
|
|
575
1038
|
]);
|
|
1039
|
+
var TARGET_FLAGS = {
|
|
1040
|
+
"--agents": "agents",
|
|
1041
|
+
"--agents-md": "agents",
|
|
1042
|
+
"--claude": "claude",
|
|
1043
|
+
"--cursor": "cursor",
|
|
1044
|
+
"--copilot": "copilot",
|
|
1045
|
+
"--windsurf": "windsurf",
|
|
1046
|
+
"--cline": "cline",
|
|
1047
|
+
"--roo": "roo",
|
|
1048
|
+
"--gemini": "gemini"
|
|
1049
|
+
};
|
|
576
1050
|
function parseArgs(argv) {
|
|
577
1051
|
const out = { json: false, quiet: false, help: false, version: false };
|
|
578
1052
|
for (const a of argv) {
|
|
@@ -672,17 +1146,81 @@ async function runSubcommand(name, argv) {
|
|
|
672
1146
|
io.err("Usage: flypod keys create");
|
|
673
1147
|
return 2;
|
|
674
1148
|
}
|
|
1149
|
+
case "install":
|
|
1150
|
+
return runInstall(argv, io);
|
|
675
1151
|
default:
|
|
676
1152
|
io.err(`flypod: unknown subcommand "${name}"`);
|
|
677
1153
|
return 2;
|
|
678
1154
|
}
|
|
679
1155
|
}
|
|
1156
|
+
function shortHome(path) {
|
|
1157
|
+
const home = homedir3();
|
|
1158
|
+
return path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
1159
|
+
}
|
|
1160
|
+
async function runInstall(argv, io) {
|
|
1161
|
+
const noun = argv.find((a) => !a.startsWith("-"));
|
|
1162
|
+
if (noun !== "skill" && noun !== "skills") {
|
|
1163
|
+
io.err("Usage: flypod install skill [targets] [--all] [--global] [--list] [--dry-run]");
|
|
1164
|
+
io.err("");
|
|
1165
|
+
io.err("Teaches your coding agents (Claude Code, Codex, Cursor, …) how to deploy");
|
|
1166
|
+
io.err("with flypod by writing a small instruction file they read automatically.");
|
|
1167
|
+
return 2;
|
|
1168
|
+
}
|
|
1169
|
+
const KNOWN_FLAGS = new Set([
|
|
1170
|
+
"--all",
|
|
1171
|
+
"--global",
|
|
1172
|
+
"--list",
|
|
1173
|
+
"--dry-run",
|
|
1174
|
+
"--print",
|
|
1175
|
+
"--yes",
|
|
1176
|
+
"-y",
|
|
1177
|
+
...Object.keys(TARGET_FLAGS)
|
|
1178
|
+
]);
|
|
1179
|
+
const unknownFlag = argv.find((a) => a.startsWith("-") && !KNOWN_FLAGS.has(a));
|
|
1180
|
+
if (unknownFlag) {
|
|
1181
|
+
io.err(`flypod: unknown flag "${unknownFlag}"`);
|
|
1182
|
+
io.err("Run `flypod install skill --list` to see available targets and flags.");
|
|
1183
|
+
return 2;
|
|
1184
|
+
}
|
|
1185
|
+
const has = (flag2) => argv.includes(flag2);
|
|
1186
|
+
const targets = [];
|
|
1187
|
+
for (const [flag2, id] of Object.entries(TARGET_FLAGS)) {
|
|
1188
|
+
if (has(flag2) && !targets.includes(id))
|
|
1189
|
+
targets.push(id);
|
|
1190
|
+
}
|
|
1191
|
+
const all = has("--all");
|
|
1192
|
+
const global = has("--global");
|
|
1193
|
+
const list2 = has("--list");
|
|
1194
|
+
const dryRun = has("--dry-run") || has("--print");
|
|
1195
|
+
const yes = has("--yes") || has("-y");
|
|
1196
|
+
const interactive = !list2 && !dryRun && !all && !yes && targets.length === 0 && canPrompt(process.stdin);
|
|
1197
|
+
const picker = interactive ? async (plan) => {
|
|
1198
|
+
const style = makeStyle(colorsEnabled(process.stderr));
|
|
1199
|
+
process.stderr.write(`
|
|
1200
|
+
${style.bold(style.accent("flypod"))} ${style.dim("· teach your agents to deploy")}
|
|
1201
|
+
|
|
1202
|
+
`);
|
|
1203
|
+
const choices = plan.map((e) => ({
|
|
1204
|
+
id: e.target.id,
|
|
1205
|
+
label: e.target.label,
|
|
1206
|
+
hint: `${e.target.detail}${e.detected && !e.target.alwaysDefault ? " · detected" : ""}`,
|
|
1207
|
+
checked: e.defaultOn
|
|
1208
|
+
}));
|
|
1209
|
+
return multiselect({ title: "Install the flypod skill into:", choices, style });
|
|
1210
|
+
} : undefined;
|
|
1211
|
+
const io2 = {
|
|
1212
|
+
out: io.out,
|
|
1213
|
+
err: (line) => io.err(shortHome(line)),
|
|
1214
|
+
env: io.env
|
|
1215
|
+
};
|
|
1216
|
+
return installSkill({ targets, all, global, list: list2, dryRun, picker }, io2);
|
|
1217
|
+
}
|
|
680
1218
|
async function readVersion() {
|
|
681
1219
|
const here = fileURLToPath(import.meta.url);
|
|
682
1220
|
for (const rel of ["../../package.json", "../package.json"]) {
|
|
683
1221
|
try {
|
|
684
1222
|
const url = new URL(rel, `file://${here}`);
|
|
685
|
-
const text = await
|
|
1223
|
+
const text = await readFile4(url, "utf8");
|
|
686
1224
|
const version = JSON.parse(text).version;
|
|
687
1225
|
if (version)
|
|
688
1226
|
return version;
|
|
@@ -731,12 +1269,17 @@ Account (optional — lets deploys live forever and be listed/owned):
|
|
|
731
1269
|
flypod keys create Mint a new API key (for agents / CI).
|
|
732
1270
|
flypod forget [--site <id>] Drop this folder's remembered site link.
|
|
733
1271
|
|
|
1272
|
+
Agents:
|
|
1273
|
+
flypod install skill Teach your coding agents (Claude Code, Codex,
|
|
1274
|
+
Cursor, …) how to deploy with flypod.
|
|
1275
|
+
|
|
734
1276
|
Output:
|
|
735
1277
|
--json Emit a stable JSON result on stdout (for agents/scripts).
|
|
736
1278
|
-q, --quiet Print only the URL.
|
|
737
1279
|
-h, --help Show this help. -v, --version Show the flypod version.
|
|
738
1280
|
|
|
739
1281
|
Environment:
|
|
1282
|
+
FLYPOD_API_KEY Deploy as your account without logging in (agents / CI)
|
|
740
1283
|
DEPLOY_URL Override the deploy server (default: https://flypod.dev)
|
|
741
1284
|
FLYPOD_CONFIG_DIR Override where the CLI keeps its session + folder memory
|
|
742
1285
|
NO_COLOR Disable ANSI colors
|
|
@@ -774,8 +1317,7 @@ async function main() {
|
|
|
774
1317
|
`);
|
|
775
1318
|
return;
|
|
776
1319
|
}
|
|
777
|
-
const
|
|
778
|
-
const baseUrl = session?.base_url ?? process.env.DEPLOY_URL ?? "https://flypod.dev";
|
|
1320
|
+
const { apiKey, baseUrl } = await resolveAuth();
|
|
779
1321
|
const useUI = !args.json && !args.quiet;
|
|
780
1322
|
const style = makeStyle(colorsEnabled(process.stderr) && useUI);
|
|
781
1323
|
if (useUI) {
|
|
@@ -837,7 +1379,7 @@ async function main() {
|
|
|
837
1379
|
const started = Date.now();
|
|
838
1380
|
let result;
|
|
839
1381
|
try {
|
|
840
|
-
result = await deploySite({ baseUrl, files, apiKey
|
|
1382
|
+
result = await deploySite({ baseUrl, files, apiKey });
|
|
841
1383
|
} catch (error) {
|
|
842
1384
|
spinner.fail("Deploy failed.");
|
|
843
1385
|
const msg = error.message;
|