@feltdb/feltkit 0.3.9 → 0.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/app.d.ts +6 -0
  2. package/dist/app.js +22 -2
  3. package/dist/app.js.map +1 -1
  4. package/dist/appboundry/build.js +32 -5
  5. package/dist/appboundry/build.js.map +1 -1
  6. package/dist/appboundry/guest.js +37 -1
  7. package/dist/appboundry/guest.js.map +1 -1
  8. package/dist/appboundry/host.d.ts +25 -0
  9. package/dist/appboundry/host.js +363 -0
  10. package/dist/appboundry/host.js.map +1 -0
  11. package/dist/cli/deploy.d.ts +3 -3
  12. package/dist/cli/deploy.js +56 -6
  13. package/dist/cli/deploy.js.map +1 -1
  14. package/dist/cli/fly.d.ts +20 -0
  15. package/dist/cli/fly.js +120 -0
  16. package/dist/cli/fly.js.map +1 -0
  17. package/dist/cli/main.js +101 -6
  18. package/dist/cli/main.js.map +1 -1
  19. package/dist/cli/skills.d.ts +8 -0
  20. package/dist/cli/skills.js +37 -0
  21. package/dist/cli/skills.js.map +1 -1
  22. package/dist/cli/vercel.d.ts +1 -1
  23. package/dist/cli/vercel.js +3 -3
  24. package/dist/cli/vercel.js.map +1 -1
  25. package/dist/errors.d.ts +7 -1
  26. package/dist/errors.js +1 -0
  27. package/dist/errors.js.map +1 -1
  28. package/dist/index.d.ts +1 -1
  29. package/dist/runtime/capabilities.d.ts +1 -1
  30. package/dist/runtime/capabilities.js +19 -2
  31. package/dist/runtime/capabilities.js.map +1 -1
  32. package/dist/runtime/context.d.ts +7 -0
  33. package/dist/runtime/contract.js +4 -1
  34. package/dist/runtime/contract.js.map +1 -1
  35. package/dist/runtime/data.d.ts +24 -0
  36. package/dist/runtime/data.js +43 -1
  37. package/dist/runtime/data.js.map +1 -1
  38. package/dist/runtime/deployment.d.ts +3 -3
  39. package/dist/runtime/deployment.js +16 -4
  40. package/dist/runtime/deployment.js.map +1 -1
  41. package/dist/runtime/outbox.d.ts +83 -0
  42. package/dist/runtime/outbox.js +92 -0
  43. package/dist/runtime/outbox.js.map +1 -0
  44. package/dist/runtime/runtime.d.ts +7 -1
  45. package/dist/runtime/runtime.js +144 -15
  46. package/dist/runtime/runtime.js.map +1 -1
  47. package/dist/runtime/services.d.ts +8 -0
  48. package/dist/runtime/services.js +47 -1
  49. package/dist/runtime/services.js.map +1 -1
  50. package/dist/runtime/targets.d.ts +9 -5
  51. package/dist/runtime/targets.js +55 -3
  52. package/dist/runtime/targets.js.map +1 -1
  53. package/dist/schema.d.ts +30 -2
  54. package/dist/schema.js +39 -2
  55. package/dist/schema.js.map +1 -1
  56. package/dist/testing/index.d.ts +21 -0
  57. package/dist/testing/index.js +29 -0
  58. package/dist/testing/index.js.map +1 -1
  59. package/package.json +4 -4
  60. package/skills/.claude-plugin/marketplace.json +1 -1
  61. package/skills/.claude-plugin/plugin.json +1 -1
  62. package/skills/feltkit-agent/SKILL.md +1 -1
  63. package/skills/feltkit-build/SKILL.md +29 -1
  64. package/skills/feltkit-data/SKILL.md +1 -1
  65. package/skills/feltkit-operations/SKILL.md +4 -3
  66. package/skills/feltkit-services/SKILL.md +20 -2
@@ -0,0 +1,20 @@
1
+ import type { VercelEnvPlan } from "./vercel.js";
2
+ /** The app name and region the artifact's fly.toml names. */
3
+ export declare function flyConfig(artifact: string): {
4
+ app: string;
5
+ region: string;
6
+ volume: string | null;
7
+ };
8
+ /** Signed in to Fly, or signs in (interactively); a CI run sets FLY_API_TOKEN instead. */
9
+ export declare function ensureFlyAuth(artifact: string, interactive: boolean, report: (line: string) => void): Promise<string>;
10
+ /** Create the app the first time. An existing app of yours is used as it is. */
11
+ export declare function ensureFlyApp(artifact: string, app: string, org: string | undefined, report: (line: string) => void): Promise<boolean>;
12
+ /** The volume a `--data volume` deployment keeps its state on, created once in the app's region. */
13
+ export declare function ensureFlyVolume(artifact: string, app: string, volume: string, region: string, report: (line: string) => void): Promise<boolean>;
14
+ /** `fly secrets import`: NAME=value lines on stdin. `stage`: applied by the next deploy, not by a restart now. */
15
+ export declare function setFlySecrets(plan: VercelEnvPlan, app: string, stage: boolean): Promise<void>;
16
+ /** `fly deploy --remote-only` (Fly's builders build the image); one machine for a volume deployment. */
17
+ export declare function flyDeploy(plan: VercelEnvPlan, app: string, volume: boolean): Promise<{
18
+ code: number;
19
+ url: string;
20
+ }>;
@@ -0,0 +1,120 @@
1
+ /**
2
+ * `feltkit fly env` and `feltkit fly deploy`: deploy an artifact built with
3
+ * `feltkit deploy --target fly` to Fly.io with flyctl.
4
+ *
5
+ * `deploy` signs you in to Fly when flyctl is not (interactively), creates the app named in
6
+ * fly.toml the first time (and, for `--data volume`, its volume in fly.toml's primary_region),
7
+ * stages the secrets (`fly secrets import --stage`, values on stdin, never in argv or printed),
8
+ * then `fly deploy --remote-only`: Fly's builders build the image, so no local Docker is needed.
9
+ * A volume deployment runs one machine (`--ha=false`): a volume belongs to one machine.
10
+ *
11
+ * What is uploaded is exactly what `feltkit vercel env` would upload for the same contract
12
+ * (planPlatformEnv): a volume deployment needs no FeltDB settings, and FELTDB_* is never sent.
13
+ */
14
+ import { spawn } from "node:child_process";
15
+ import { readFileSync } from "node:fs";
16
+ import { join } from "node:path";
17
+ import { FeltKitError } from "../errors.js";
18
+ /** flyctl: FELTKIT_FLY_CLI (a path), else `fly`. */
19
+ function flyCommand() {
20
+ return process.env.FELTKIT_FLY_CLI ?? "fly";
21
+ }
22
+ function run(args, options) {
23
+ const command = flyCommand();
24
+ return new Promise((done, fail) => {
25
+ const child = spawn(command, args, { cwd: options.cwd, stdio: options.inherit ? "inherit" : [options.input === undefined ? "ignore" : "pipe", "pipe", "pipe"] });
26
+ let output = "";
27
+ const take = (chunk) => {
28
+ output += chunk;
29
+ options.show?.(String(chunk));
30
+ };
31
+ child.stdout?.on("data", take);
32
+ child.stderr?.on("data", take);
33
+ child.once("error", (error) => fail(new FeltKitError("UNAVAILABLE", `Could not run flyctl (${command}): ${error.message}`, { hint: "Install it: https://fly.io/docs/flyctl/install/ (or set FELTKIT_FLY_CLI to its path)." })));
34
+ child.once("exit", (code) => done({ code: code ?? 1, output }));
35
+ if (options.input !== undefined)
36
+ child.stdin.end(options.input);
37
+ });
38
+ }
39
+ const tail = (text) => text.trim().split("\n").slice(-4).join("\n");
40
+ /** The app name and region the artifact's fly.toml names. */
41
+ export function flyConfig(artifact) {
42
+ const toml = readFileSync(join(artifact, "fly.toml"), "utf8");
43
+ const app = /^app\s*=\s*"([^"]+)"/m.exec(toml)?.[1];
44
+ if (!app)
45
+ throw new FeltKitError("CONFIGURATION", `${join(artifact, "fly.toml")} names no app.`);
46
+ return { app, region: /^primary_region\s*=\s*"([^"]+)"/m.exec(toml)?.[1] ?? "iad", volume: /^\s*source\s*=\s*"([^"]+)"/m.exec(toml)?.[1] ?? null };
47
+ }
48
+ /** Signed in to Fly, or signs in (interactively); a CI run sets FLY_API_TOKEN instead. */
49
+ export async function ensureFlyAuth(artifact, interactive, report) {
50
+ const who = await run(["auth", "whoami"], { cwd: artifact });
51
+ if (who.code === 0)
52
+ return who.output.trim().split("\n").pop().trim();
53
+ if (!interactive)
54
+ throw new FeltKitError("UNAUTHORIZED", "flyctl is not signed in to Fly.io; nothing was uploaded.", { hint: "Run `fly auth login`, or set FLY_API_TOKEN (fly tokens create deploy) in CI." });
55
+ report("Signing you in to Fly.io (a browser opens)…");
56
+ const login = await run(["auth", "login"], { cwd: artifact, inherit: true });
57
+ if (login.code !== 0)
58
+ throw new FeltKitError("UNAUTHORIZED", "Fly.io sign-in did not complete; nothing was uploaded.");
59
+ return (await run(["auth", "whoami"], { cwd: artifact })).output.trim().split("\n").pop().trim();
60
+ }
61
+ /** Create the app the first time. An existing app of yours is used as it is. */
62
+ export async function ensureFlyApp(artifact, app, org, report) {
63
+ const status = await run(["status", "--app", app, "--json"], { cwd: artifact });
64
+ if (status.code === 0)
65
+ return false;
66
+ report(`Creating the Fly app ${app}…`);
67
+ const created = await run(["apps", "create", app, ...(org ? ["--org", org] : [])], { cwd: artifact });
68
+ if (created.code !== 0) {
69
+ const taken = /taken|already exists/i.test(created.output);
70
+ throw new FeltKitError("CONFIGURATION", taken ? `The Fly app name "${app}" belongs to someone else.` : `fly apps create ${app} failed (exit ${created.code}).`, {
71
+ hint: taken ? "Choose another name: edit app = \"…\" in the artifact's fly.toml (it is regenerated from your app's name by `feltkit deploy`), then run this again." : tail(created.output),
72
+ });
73
+ }
74
+ return true;
75
+ }
76
+ /** The volume a `--data volume` deployment keeps its state on, created once in the app's region. */
77
+ export async function ensureFlyVolume(artifact, app, volume, region, report) {
78
+ const listed = await run(["volumes", "list", "--app", app, "--json"], { cwd: artifact });
79
+ if (listed.code !== 0)
80
+ throw new FeltKitError("UNAVAILABLE", `fly volumes list failed (exit ${listed.code}).`, { hint: tail(listed.output) });
81
+ let volumes = [];
82
+ try {
83
+ volumes = JSON.parse(listed.output.slice(listed.output.indexOf("[")));
84
+ }
85
+ catch {
86
+ volumes = [];
87
+ }
88
+ if (volumes.some((v) => (v.name ?? v.Name) === volume))
89
+ return false;
90
+ report(`Creating the volume ${volume} (1 GB, ${region}) for the app's data…`);
91
+ const created = await run(["volumes", "create", volume, "--app", app, "--region", region, "--size", "1", "--yes"], { cwd: artifact });
92
+ if (created.code !== 0)
93
+ throw new FeltKitError("UNAVAILABLE", `fly volumes create failed (exit ${created.code}).`, { hint: tail(created.output) });
94
+ return true;
95
+ }
96
+ /** Scrubs every planned value out of text before it is shown. */
97
+ function scrub(text, plan) {
98
+ let out = text;
99
+ for (const value of Object.values(plan.values))
100
+ if (value.length >= 4)
101
+ out = out.split(value).join("…");
102
+ return out;
103
+ }
104
+ /** `fly secrets import`: NAME=value lines on stdin. `stage`: applied by the next deploy, not by a restart now. */
105
+ export async function setFlySecrets(plan, app, stage) {
106
+ for (const [name, value] of Object.entries(plan.values)) {
107
+ if (/[\r\n]/.test(value))
108
+ throw new FeltKitError("INVALID_ARGUMENT", `${name} spans several lines; Fly secrets are set one line per variable. Nothing was uploaded.`);
109
+ }
110
+ const input = Object.entries(plan.values).map(([name, value]) => `${name}=${value}`).join("\n") + "\n";
111
+ const result = await run(["secrets", "import", "--app", app, ...(stage ? ["--stage"] : [])], { cwd: plan.artifact, input });
112
+ if (result.code !== 0)
113
+ throw new FeltKitError("UNAVAILABLE", `fly secrets import failed (exit ${result.code}).`, { hint: scrub(tail(result.output), plan) });
114
+ }
115
+ /** `fly deploy --remote-only` (Fly's builders build the image); one machine for a volume deployment. */
116
+ export async function flyDeploy(plan, app, volume) {
117
+ const result = await run(["deploy", "--app", app, "--remote-only", ...(volume ? ["--ha=false"] : [])], { cwd: plan.artifact, show: (text) => process.stderr.write(scrub(text, plan)) });
118
+ return { code: result.code, url: `https://${app}.fly.dev` };
119
+ }
120
+ //# sourceMappingURL=fly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fly.js","sourceRoot":"","sources":["../../src/cli/fly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,oDAAoD;AACpD,SAAS,UAAU;IACjB,OAAO,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,KAAK,CAAC;AAC9C,CAAC;AAED,SAAS,GAAG,CAAC,IAAc,EAAE,OAA0F;IACrH,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,OAAO,IAAI,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QAChC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,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CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACvG,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5H,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC;QAAE,MAAM,IAAI,YAAY,CAAC,aAAa,EAAE,mCAAmC,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;AAC/J,CAAC;AAED,wGAAwG;AACxG,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAmB,EAAE,GAAW,EAAE,MAAe;IAC/E,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IACxL,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,GAAG,UAAU,EAAE,CAAC;AAC9D,CAAC"}
package/dist/cli/main.js CHANGED
@@ -63,9 +63,10 @@ ${c.bold("Commands")}
63
63
  start Run the production build (environment: production)
64
64
  test Run the project's tests against an isolated test environment
65
65
  inspect Show what the application is, where its state lives, and what it's doing
66
- deploy Build a verified deployment: one container, an app container + FeltDB, or Vercel
66
+ deploy Build a verified deployment: one container, an app container + FeltDB, Vercel, Cloudflare, or Fly.io
67
67
  vercel <action> Set a Vercel project's environment from FeltDB's values, deploy, and sign you in
68
68
  cloudflare <action> Set a Cloudflare Worker's secrets from FeltDB's values, deploy, and sign you in
69
+ fly <action> Create the Fly.io app (and volume), set its secrets, deploy, and sign you in
69
70
  manage Open production Studio for the deployed app (a one-time sign-in link)
70
71
  session <action> Create, list, or revoke sessions (agents, service accounts)
71
72
  operator grant Sign a one-time production Studio sign-in for an operator
@@ -88,7 +89,7 @@ Docs: https://github.com/rkendel1/concave#readme`;
88
89
  const COMMAND_HELP = {
89
90
  create: "feltkit create <dir> [--name <app-name>] [--template tasks|managed]\n Copies a starter into <dir>: tasks (default; local FeltDB) or managed (Managed FeltDB, --managed).\n Refuses to write into a non-empty directory.",
90
91
  dev: "feltkit dev [--port 3000] [--host 127.0.0.1] [--no-frontend]\n Development environment: state in .feltkit/development/state.",
91
- build: "feltkit build [--target appboundry] [--out <dir>]\n Writes .feltkit/build/functions.mjs and dist/client, then loads the bundle to verify it.\n --target appboundry also compiles <name>.app: manifest.json, module.wasm (imports nothing) and the\n frontend, which `appboundry run <name>.app` runs without this project, Node tooling, or FeltKit.",
92
+ build: "feltkit build [--target appboundry] [--out <dir>]\n Writes .feltkit/build/functions.mjs and dist/client, then loads the bundle to verify it.\n --target appboundry also compiles <name>.app: manifest.json, module.wasm (imports nothing) and the\n frontend, which AppBoundry runs without this project, Node tooling, or FeltKit. Test the artifact itself\n with createArtifactTestApp(<name>.app) from @feltdb/feltkit/testing. Without --target, lists what would\n block the AppBoundry target.",
92
93
  start: "feltkit start [--port $PORT] [--host 0.0.0.0] [--env production]\n Uses FELTDB_URL + FELTDB_TOKEN when set, else FELTKIT_STATE_DIR or .feltkit/production/state.",
93
94
  test: "feltkit test [files…]\n Runs node --test on tests/**/*.test.ts with FELTKIT_ENV=test.",
94
95
  inspect: "feltkit inspect [--json] [--env development]\n Reads from the running server when there is one; otherwise opens the environment directly.",
@@ -96,7 +97,7 @@ const COMMAND_HELP = {
96
97
  " Writes the FeltDB application contract: this application's collections, FeltKit's own records, and FeltDB's\n" +
97
98
  " agent state. Managed FeltDB stores only what the promoted contract declares; publish it with\n" +
98
99
  " `feltdb publish --contract feltdb.contract.json`. --check exits 1 when the file is out of date.",
99
- deploy: "feltkit deploy [--target container|hosted|self-hosted|vercel|cloudflare] [--data managed|self-hosted] [--instances <n>] [--out <dir>] [--yes]\n" +
100
+ deploy: "feltkit deploy [--target container|hosted|self-hosted|vercel|cloudflare|fly] [--data volume|managed|self-hosted] [--instances <n>] [--out <dir>] [--yes]\n" +
100
101
  " Builds, verifies the build boots, and writes .feltkit/deploy for how you run it:\n" +
101
102
  " container everything in one container: the app and its FeltDB state on a volume (default)\n" +
102
103
  " hosted a separate app container; data in Managed FeltDB (with feltdb.contract.json)\n" +
@@ -104,6 +105,8 @@ const COMMAND_HELP = {
104
105
  " vercel Vercel's container runtime; data in Managed FeltDB (--data self-hosted: your FeltDB server)\n" +
105
106
  " cloudflare Cloudflare Containers behind a Worker; data in Managed FeltDB (--data self-hosted: your FeltDB server);\n" +
106
107
  " --instances <n> spreads requests over n containers (default 1)\n" +
108
+ " fly Fly.io Machines; data on a Fly volume beside the app, one machine (default; --data managed:\n" +
109
+ " Managed FeltDB, --data self-hosted: your FeltDB server; any number of machines)\n" +
107
110
  " Each has a Dockerfile, docker-compose.yml, fly.toml, .env.example and DEPLOY.md. Asks which in a terminal.",
108
111
  vercel: "feltkit vercel env [--from <file>[,<file>]] [--environment production|preview|development] [--dry-run]\n" +
109
112
  " For an artifact built with `feltkit deploy --target vercel`: uploads the variables it needs to the linked\n" +
@@ -127,6 +130,15 @@ const COMMAND_HELP = {
127
130
  " it with a one-time Studio link, exactly as `feltkit vercel deploy` does.\n" +
128
131
  "feltkit cloudflare env [same options]\n" +
129
132
  " Sets the secrets of a Worker that is already deployed (`wrangler secret bulk`, values on stdin).",
133
+ fly: "feltkit fly deploy [--from <file>[,<file>]] [--org <fly org>] [--dry-run] [--no-studio] [--owner <id>] [--role <role>[,<role>]] [--sign-in|--no-sign-in]\n" +
134
+ " For an artifact built with `feltkit deploy --target fly`: signs you in to Fly when flyctl is not, creates the app\n" +
135
+ " named in its fly.toml the first time (and, for --data volume, its volume in fly.toml's primary_region), stages\n" +
136
+ " exactly the settings it needs as Fly secrets (values on stdin, never printed), then `fly deploy --remote-only`\n" +
137
+ " (Fly builds the image; no local Docker). Production Studio is on by default. Records https://<app>.fly.dev and\n" +
138
+ " prints a one-time Studio link; with data in FeltDB it also creates your session, as `feltkit vercel deploy` does.\n" +
139
+ " Needs flyctl (FELTKIT_FLY_CLI overrides its path); CI sets FLY_API_TOKEN.\n" +
140
+ "feltkit fly env [same options]\n" +
141
+ " Sets the app's secrets now (Fly restarts its machines to apply them).",
130
142
  manage: "feltkit manage [--id <you>] [--role <role>[,<role>]] [--ttl <minutes>] [--json]\n" +
131
143
  " A one-time sign-in link to production Studio (https://<your app>/_feltkit/), signed with the deployment's\n" +
132
144
  " operator key from .env.local. Default id: your user name; default roles: all the app declares.",
@@ -263,6 +275,12 @@ async function finishProductionDeploy(o) {
263
275
  line(`\n${c.bold("Open the app and create your account")}: ${url}`);
264
276
  line(c.dim(` ${accounts.signUp === false ? "Sign-up is closed (auth.accounts.signUp: false): accounts that exist sign in there." : `Anyone with the link can sign up; a new account gets ${accounts.roles.join(", ")}.`} Studio's Data page lists accounts.`));
265
277
  }
278
+ else if (signIn && o.stateOnPlatform) {
279
+ // The state is on the platform's volume, which only the running app opens: sign in to Studio
280
+ // (below) and manage the app there; end users sign in with auth.accounts or auth.authenticate.
281
+ line(`\n${c.bold("Sign in")}: the app's state is on its volume, so sessions are issued by the running app.`);
282
+ line(c.dim(" Use the production Studio link below. For your users, add built-in accounts (auth: { accounts: { roles: [...] } }) or auth.authenticate."));
283
+ }
266
284
  else if (signIn) {
267
285
  try {
268
286
  const session = await issueProductionSession(projectDir, { id: owner, type: "user", ...(role ? { roles: role } : {}) }, { env, label: `first sign-in, created by feltkit ${platform} deploy`, ...(deps.issueSession ? { issue: deps.issueSession } : {}) });
@@ -329,7 +347,7 @@ export async function main(argv = process.argv.slice(2), deps = {}) {
329
347
  line(` cd ${dir}\n npm install\n npm run dev\n`);
330
348
  line(c.dim("The dev server prints your app URL and a dashboard link. State lives in .feltkit/development/state."));
331
349
  }
332
- line(c.dim("Using a coding agent? `npx feltkit skills install` (after npm install) adds the FeltKit skills for Claude Code."));
350
+ line(c.dim("Using a coding agent? `npx feltkit skills install` (after npm install) adds the FeltKit skills for Claude Code; restart the Claude Code session afterwards to load them."));
333
351
  return 0;
334
352
  }
335
353
  case "contract": {
@@ -420,9 +438,20 @@ export async function main(argv = process.argv.slice(2), deps = {}) {
420
438
  line(` ${c.bold("Host access")} collections ${m.permissions.collections.read.join(", ") || "none"}; services ${m.permissions.services.join(", ") || "none"}; network none; filesystem none`);
421
439
  for (const note of artifact.omitted)
422
440
  line(` ${symbols.info} ${c.dim(`Not in the artifact: ${note}`)}`);
423
- line(c.dim(`\nRun it with AppBoundry: appboundry run ${artifact.path.replace(projectDir + "/", "")}`));
441
+ const relativeArtifact = artifact.path.replace(projectDir + "/", "");
442
+ line(c.dim(`\nTest it: createArtifactTestApp("${relativeArtifact}") from @feltdb/feltkit/testing runs your calls against the artifact.`));
443
+ line(c.dim(`Serve it with AppBoundry (built from github.com/rkendel1/appboundry; no npm release reads appboundry.app/1 yet): appboundry run ${relativeArtifact}`));
424
444
  return 0;
425
445
  }
446
+ // Not an error: a FeltKit server runs all of it. Said now so a team learns before relying on the artifact target.
447
+ const { unsupportedUses } = await import("../appboundry/build.js");
448
+ const { loadBundle } = await import("../runtime/loader.js");
449
+ const blockers = unsupportedUses(projectDir, (await loadBundle(result.bundle)).app);
450
+ if (blockers.length) {
451
+ line(`${symbols.info} ${c.dim(`Not portable to --target appboundry (${blockers.length}):`)}`);
452
+ for (const blocker of blockers)
453
+ line(` ${c.dim(blocker)}`);
454
+ }
426
455
  line(c.dim("\nRun it with `feltkit start`, or package it with `feltkit deploy`."));
427
456
  return 0;
428
457
  }
@@ -516,6 +545,20 @@ export async function main(argv = process.argv.slice(2), deps = {}) {
516
545
  line(c.dim(" Uploads only what this deployment needs, from .env.local (never the control key), as Worker secrets with the code,"));
517
546
  line(c.dim(" then prints the app's URL, your session token, and a one-time link to production Studio. Preview: npx feltkit cloudflare deploy --dry-run"));
518
547
  }
548
+ else if (result.target === "fly") {
549
+ const volume = result.storage === "local";
550
+ if (!volume) {
551
+ const managed = result.storage === "managed";
552
+ line(`\n${c.bold(`1. ${managed ? "Create the app in Managed FeltDB, and its runtime key" : "Give the app a key for its namespace on your FeltDB server"}`)}`);
553
+ line(managed
554
+ ? ` npx feltdb init-managed --contract ${join(at, "feltdb.contract.json")} --runtime-scopes minimal`
555
+ : ` feltdb-server keys create --keys <keys.json> --name ${result.application} --namespace ${result.application} --scope state:read,state:write`);
556
+ }
557
+ line(`\n${c.bold(`${volume ? "" : "2. "}Deploy, and sign in`)} ${c.dim("(needs flyctl; signs you in to Fly the first time)")}`);
558
+ line(" npx feltkit fly deploy");
559
+ line(c.dim(` Creates the Fly app${volume ? " and its volume" : ""} the first time, sets only the secrets this deployment needs, deploys with Fly's builders,`));
560
+ line(c.dim(" and prints the app's URL and a one-time link to production Studio. Region and machine size: fly.toml. Preview: npx feltkit fly deploy --dry-run"));
561
+ }
519
562
  else if (result.target === "self-hosted") {
520
563
  line(`\n${c.bold("1. Give the app a key for its namespace on your FeltDB server")}`);
521
564
  line(` feltdb-server keys create --keys <keys.json> --name ${result.application} --namespace ${result.application} --scope state:read,state:write`);
@@ -532,7 +575,7 @@ export async function main(argv = process.argv.slice(2), deps = {}) {
532
575
  line(" npm ci --omit=dev");
533
576
  line(" npm start");
534
577
  }
535
- line(c.dim(result.target === "vercel" || result.target === "cloudflare"
578
+ line(c.dim(result.target === "vercel" || result.target === "cloudflare" || result.target === "fly"
536
579
  ? `\nLater: \`npx feltkit manage\` opens production Studio again. The whole setup, the target's contract (state, recovery, upgrades), and its limits: ${join(at, "DEPLOY.md")}.`
537
580
  : `\nThen open http://localhost:3000. The target's contract (state, recovery, upgrades), Fly.io and other hosts: ${join(at, "DEPLOY.md")}.`));
538
581
  line(c.dim(`Other ways to run it: ${Object.keys(DEPLOY_TARGETS).filter((id) => id !== result.target).map((id) => `npx feltkit deploy --target ${id}`).join(" | ")}`));
@@ -638,6 +681,56 @@ export async function main(argv = process.argv.slice(2), deps = {}) {
638
681
  line(c.dim("After the very first deploy, Cloudflare can take several minutes before the container answers."));
639
682
  return finishProductionDeploy({ projectDir, platform: "cloudflare", url: deployed.url, values: plan.values, flags, deps });
640
683
  }
684
+ case "fly": {
685
+ const action = positional[0];
686
+ if (action !== "env" && action !== "deploy")
687
+ throw new FeltKitError("INVALID_ARGUMENT", "Usage: feltkit fly env|deploy [--from <file>] [--org <fly org>] [--dry-run] [--no-studio] [--owner <id>] [--role <role>]");
688
+ const { platformArtifact, planPlatformEnv } = await import("./vercel.js");
689
+ const { ensureFlyApp, ensureFlyAuth, ensureFlyVolume, flyConfig, flyDeploy, setFlySecrets } = await import("./fly.js");
690
+ const from = typeof flags.from === "string" ? flags.from.split(",").map((f) => f.trim()).filter(Boolean) : [];
691
+ const dryRun = flags["dry-run"] === true;
692
+ const dir = typeof flags.dir === "string" ? flags.dir : undefined;
693
+ const artifact = platformArtifact(projectDir, "fly", dir);
694
+ const fly = flyConfig(artifact);
695
+ const plan = planPlatformEnv({ platform: "fly", projectDir, ...(dir ? { dir } : {}), from, generate: !dryRun, ...(typeof flags.studio === "boolean" ? { studio: flags.studio } : {}) });
696
+ const at = relative(process.cwd(), plan.artifact) || ".";
697
+ if (json && dryRun) {
698
+ line(JSON.stringify({ artifact: plan.artifact, app: fly.app, region: fly.region, volume: fly.volume, variables: plan.variables.map((v) => ({ ...v, type: "secret" })), skipped: plan.skipped }, null, 2));
699
+ return 0;
700
+ }
701
+ line(`${c.bold(dryRun ? "Would set" : "Setting")} ${plan.variables.length} Fly secrets on ${c.bold(fly.app)} for the artifact in ${at}:`);
702
+ if (dryRun)
703
+ for (const v of plan.variables)
704
+ line(` ${v.name} ${c.dim(`secret (${v.source})`)}`);
705
+ if (plan.generated.length)
706
+ line(c.dim(` Generated ${plan.generated.join(", ")} and saved ${plan.generated.length > 1 ? "them" : "it"} to ${relative(process.cwd(), plan.savedTo)}: keep ${plan.generated.length > 1 ? "them" : "it"}; running this again reuses ${plan.generated.length > 1 ? "them" : "it"}.`));
707
+ if (plan.skipped.length)
708
+ line(c.dim(` Not uploaded (not part of this deployment): ${plan.skipped.join(", ")}`));
709
+ if (dryRun) {
710
+ if (fly.volume)
711
+ line(c.dim(` Data on the volume ${fly.volume} (${fly.region}), one machine.`));
712
+ return 0;
713
+ }
714
+ const report = (text) => line(c.dim(text));
715
+ const who = await ensureFlyAuth(artifact, Boolean(process.stdin.isTTY), report);
716
+ line(c.dim(`Fly.io: signed in as ${who}.`));
717
+ await ensureFlyApp(artifact, fly.app, typeof flags.org === "string" ? flags.org : undefined, report);
718
+ if (fly.volume)
719
+ await ensureFlyVolume(artifact, fly.app, fly.volume, fly.region, report);
720
+ if (action === "env") {
721
+ await setFlySecrets(plan, fly.app, false);
722
+ line(`${symbols.ok} ${plan.variables.length} Fly secrets set on ${fly.app}. Values were never printed.`);
723
+ line(c.dim("Fly restarts the app's machines to apply them. Deploy with: npx feltkit fly deploy"));
724
+ return 0;
725
+ }
726
+ await setFlySecrets(plan, fly.app, true);
727
+ line(`${symbols.ok} ${plan.variables.length} Fly secrets staged for the deploy. Values were never printed.`);
728
+ line(c.bold("\nDeploying to Fly.io (Fly's builders build the image)…"));
729
+ const deployed = await flyDeploy(plan, fly.app, Boolean(fly.volume));
730
+ if (deployed.code !== 0)
731
+ return 1;
732
+ return finishProductionDeploy({ projectDir, platform: "fly", url: deployed.url, values: plan.values, flags, deps, stateOnPlatform: Boolean(fly.volume) });
733
+ }
641
734
  case "manage": {
642
735
  const deployment = readDeployment(projectDir);
643
736
  if (deployment && !deployment.studio) {
@@ -919,6 +1012,8 @@ export async function main(argv = process.argv.slice(2), deps = {}) {
919
1012
  for (const skip of result.skipped)
920
1013
  line(`${symbols.fail} ${skip.skill}: ${skip.reason}`);
921
1014
  line(c.dim("\nGuidance for coding agents; they grant no permission. Check with `feltkit skills check`."));
1015
+ if (result.installed.length)
1016
+ line(`${symbols.info} Restart your Claude Code session to load them: a session already running does not pick up skills installed after it started (until then, read ${relative(projectDir, target) || target}/<skill>/SKILL.md).`);
922
1017
  }
923
1018
  return result.skipped.length ? 1 : 0;
924
1019
  }