@instafy/cli 0.1.1 → 0.1.3

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 CHANGED
@@ -1,68 +1,29 @@
1
- # Instafy CLI (Developer Preview)
1
+ <p align="center"><code>npm i -g @instafy/cli</code></p>
2
2
 
3
- Use this CLI to link a folder to an Instafy project and run a self-hosted runtime (desktop or server) that connects back to Instafy Studio (including tunnels).
3
+ # Instafy CLI (Preview)
4
4
 
5
- Primary commands:
5
+ Run Instafy projects locally and connect them back to Instafy Studio — from any terminal.
6
6
 
7
- - `instafy runtime:start` — launch the runtime in the current machine (foreground by default, `--detach` to background).
8
- - `instafy runtime:status` — report health of the last started runtime.
9
- - `instafy runtime:stop` — stop the last started runtime.
10
- - `instafy runtime:token` — mint a runtime access token with agent + origin scopes.
11
- - `instafy project:init` — create a project via the controller and write `.instafy/project.json` in the chosen folder.
12
- - `instafy project:list` — list projects for the orgs available to the current controller token.
13
- - `instafy org:list` — list orgs available to the current controller token.
14
-
15
- ## Quick start
16
-
17
- ```bash
18
- # From repo root (assumes runtime-agent is built): pnpm --filter @instafy/cli dev -- --help
19
- pnpm --filter @instafy/cli dev -- runtime:start \
20
- --project 00000000-0000-0000-0000-000000000000 \
21
- --controller-url http://127.0.0.1:8788 \
22
- --controller-access-token "$CONTROLLER_ACCESS_TOKEN"
23
-
24
- # Inspect status
25
- pnpm --filter @instafy/cli dev -- runtime:status
26
-
27
- # Stop
28
- pnpm --filter @instafy/cli dev -- runtime:stop
29
-
30
- # Create a project manifest for the current directory
31
- pnpm --filter @instafy/cli dev -- project:init --controller-url http://127.0.0.1:8788 --access-token "$SUPABASE_ACCESS_TOKEN"
7
+ ## Quickstart
32
8
 
33
- # List projects for your orgs
34
- pnpm --filter @instafy/cli dev -- project:list --controller-url http://127.0.0.1:8788 --access-token "$SUPABASE_ACCESS_TOKEN"
35
- ```
9
+ 1. Link a folder to a project:
10
+ - VS Code: install the Instafy extension and run `Instafy: Link Workspace to Project`, or
11
+ - Terminal: `instafy project:init`
12
+ 2. Start the runtime: `instafy runtime:start`
13
+ 3. Check status / stop:
14
+ - `instafy runtime:status`
15
+ - `instafy runtime:stop`
36
16
 
37
- ## Auth model
17
+ ## Common commands
38
18
 
39
- - The CLI mints a **runtime access token** via `/projects/:projectId/runtime/token` when a controller access token is provided (`--controller-access-token` or `CONTROLLER_ACCESS_TOKEN`).
40
- - That token is exported to the runtime as `RUNTIME_ACCESS_TOKEN` and mirrored to `ORIGIN_INTERNAL_TOKEN` for the bundled origin server.
41
- - You can supply a pre-minted token with `--runtime-token` / `RUNTIME_ACCESS_TOKEN` (also reused for origin). Legacy `--origin-token` still maps to the same value.
42
- - If you only have a Supabase session (service role or user JWT), pass it via `--supabase-access-token`, `--supabase-access-token-file`, or `SUPABASE_ACCESS_TOKEN`. The CLI uses that session to mint the controller and runtime tokens automatically so you do not need to juggle controller-issued keys locally.
43
-
44
- ## Important flags
45
-
46
- - `--project` / `PROJECT_ID` — project UUID to associate the runtime with (defaults to `.instafy/project.json` if present).
47
- - `--controller-url` / `CONTROLLER_BASE_URL` — controller base URL (defaults to `http://127.0.0.1:8788`).
48
- - `--controller-access-token` — user/controller token used to mint the runtime token if `--runtime-token` is not provided.
49
- - `--supabase-access-token` / `SUPABASE_ACCESS_TOKEN` — Supabase session token the CLI can exchange for controller and runtime tokens when you do not have a controller key handy.
50
- - `--runtime-token` / `RUNTIME_ACCESS_TOKEN` — pre-minted runtime/origin token to bypass minting.
51
- - `--origin-id` — optionally fix the origin id (otherwise auto-generated).
52
- - `--origin-endpoint` — skip tunnels entirely and publish a fixed, reachable origin URL (useful for servers with a stable public endpoint).
53
- - `--workspace` / `WORKSPACE_DIR` — workspace root for the runtime (default `./.instafy/workspace`).
54
- - `--provider` / `RUNTIME_PROVIDER` — runtime provider label (defaults to the org in `.instafy/project.json`, otherwise `self-hosted`).
55
- - `--detach` — background the runtime; pid/log state is recorded under `~/.instafy/cli-runtime-state.json`.
56
- - `--org-id` — target an existing org when running `project:init` (otherwise the CLI creates or reuses a personal org).
57
-
58
- ## Tunnels (self-hosted)
59
-
60
- Tunnels are controller-managed: the runtime-agent requests a tunnel assignment from the controller and then launches the appropriate client locally.
19
+ - `instafy runtime:start` start a local runtime (agent + origin).
20
+ - `instafy runtime:status` show health of the last started runtime.
21
+ - `instafy runtime:stop` stop the last started runtime.
22
+ - `instafy tunnel` request a tunnel and forward a local port.
23
+ - `instafy workspace:mount` — mount project files locally (SSHFS).
61
24
 
62
- - **Self-hosted tunnels (recommended)**: controller is configured with `TUNNEL_BROKER_BASE_URL` / `TUNNEL_BROKER_TOKEN` and returns `provider=self_hosted`. The runtime-agent launches `rathole` (outbound-only). The CLI will try to resolve `RATHOLE_BIN` (PATH or cached download). On macOS arm64, it falls back to `cargo install rathole` when no prebuilt is available.
25
+ Run `instafy --help` for the full command list and options.
63
26
 
64
- ## Notes
27
+ ## Docs
65
28
 
66
- - The CLI reuses the locally built `runtime-agent` binary from `target/{debug,release}`. Run `cargo build -p runtime-agent` first or set `INSTAFY_RUNTIME_AGENT_BIN` to an explicit path.
67
- - Runtime/origin tokens require the controller to be configured with the Ed25519 signing pair (`RUNTIME_SIGNING_PRIVATE_KEY` / `RUNTIME_SIGNING_PUBLIC_KEY`).
68
- - Logs for detached runs are written to `~/.instafy/cli-runtime-logs/*`.
29
+ - CLI reference & troubleshooting: https://github.com/instafy-dev/instafy/blob/main/docs/CLI.md
package/bin/instafy.js CHANGED
@@ -1,5 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import('../dist/index.js').catch((err) => {
2
+ import { runCli } from "../dist/index.js";
3
+
4
+ try {
5
+ await runCli(process.argv);
6
+ } catch (err) {
3
7
  console.error(err);
4
8
  process.exit(1);
5
- });
9
+ }
package/dist/index.js CHANGED
@@ -1,14 +1,17 @@
1
1
  import { Command } from "commander";
2
2
  import { pathToFileURL } from "node:url";
3
+ import { createRequire } from "node:module";
3
4
  import kleur from "kleur";
4
5
  import { runtimeStart, runtimeStatus, runtimeStop, runtimeToken, mountWorkspace, } from "./runtime.js";
5
6
  import { projectInit } from "./project.js";
6
7
  import { runTunnelCommand } from "./tunnel.js";
7
- const program = new Command();
8
+ export const program = new Command();
9
+ const require = createRequire(import.meta.url);
10
+ const pkg = require("../package.json");
8
11
  program
9
12
  .name("instafy")
10
13
  .description("Instafy CLI — manage local/self-hosted runtimes")
11
- .version("0.1.0");
14
+ .version(pkg.version ?? "0.1.0");
12
15
  program
13
16
  .command("runtime:start")
14
17
  .description("Start a local Instafy runtime (agent + origin)")
@@ -238,8 +241,15 @@ program
238
241
  process.exit(1);
239
242
  }
240
243
  });
244
+ export async function runCli(argv = process.argv) {
245
+ if (argv.length <= 2) {
246
+ program.outputHelp();
247
+ return;
248
+ }
249
+ await program.parseAsync(argv);
250
+ }
241
251
  if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {
242
- program.parseAsync(process.argv);
252
+ void runCli(process.argv);
243
253
  }
244
254
  // Re-export programmatic APIs for embedders (e.g., VS Code extension).
245
255
  export { runtimeStart as startRuntime, runtimeStatus as getRuntimeStatus, runtimeStop as stopRuntime, runtimeToken as mintRuntimeToken, mintRuntimeAccessToken, findProjectManifest, mountWorkspace, } from "./runtime.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@instafy/cli",
3
- "version": "0.1.1",
4
- "description": "CLI for connecting local folders to Instafy projects and running self-hosted runtimes (including tunnels).",
3
+ "version": "0.1.3",
4
+ "description": "Run Instafy projects locally, link folders to Studio, and share previews/webhooks via tunnels.",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "access": "public"