@instafy/cli 0.1.0 → 0.1.2

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,66 +1,29 @@
1
- # Instafy CLI (developer preview)
1
+ <p align="center"><code>npm i -g @instafy/cli</code></p>
2
2
 
3
- Local helper for running the Instafy runtime (agent + origin) on desktop or self-hosted servers. Primary commands:
3
+ # Instafy CLI (Preview)
4
4
 
5
- - `instafy runtime:start` launch the runtime in the current machine (foreground by default, `--detach` to background).
6
- - `instafy runtime:status` — report health of the last started runtime.
7
- - `instafy runtime:stop` — stop the last started runtime.
8
- - `instafy runtime:token` — mint a runtime access token with agent + origin scopes.
9
- - `instafy project:init` — create a project via the controller and write `.instafy/project.json` in the chosen folder.
10
- - `instafy project:list` — list projects for the orgs available to the current controller token.
11
- - `instafy org:list` — list orgs available to the current controller token.
12
-
13
- ## Quick start
14
-
15
- ```bash
16
- # From repo root (assumes runtime-agent is built): pnpm --filter @instafy/cli dev -- --help
17
- pnpm --filter @instafy/cli dev -- runtime:start \
18
- --project 00000000-0000-0000-0000-000000000000 \
19
- --controller-url http://127.0.0.1:8788 \
20
- --controller-access-token "$CONTROLLER_ACCESS_TOKEN"
21
-
22
- # Inspect status
23
- pnpm --filter @instafy/cli dev -- runtime:status
24
-
25
- # Stop
26
- pnpm --filter @instafy/cli dev -- runtime:stop
5
+ Run Instafy projects locally and connect them back to Instafy Studio from any terminal.
27
6
 
28
- # Create a project manifest for the current directory
29
- pnpm --filter @instafy/cli dev -- project:init --controller-url http://127.0.0.1:8788 --access-token "$SUPABASE_ACCESS_TOKEN"
7
+ ## Quickstart
30
8
 
31
- # List projects for your orgs
32
- pnpm --filter @instafy/cli dev -- project:list --controller-url http://127.0.0.1:8788 --access-token "$SUPABASE_ACCESS_TOKEN"
33
- ```
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`
34
16
 
35
- ## Auth model
17
+ ## Common commands
36
18
 
37
- - 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`).
38
- - That token is exported to the runtime as `RUNTIME_ACCESS_TOKEN` and mirrored to `ORIGIN_INTERNAL_TOKEN` for the bundled origin server.
39
- - 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.
40
- - 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.
41
-
42
- ## Important flags
43
-
44
- - `--project` / `PROJECT_ID` — project UUID to associate the runtime with (defaults to `.instafy/project.json` if present).
45
- - `--controller-url` / `CONTROLLER_BASE_URL` — controller base URL (defaults to `http://127.0.0.1:8788`).
46
- - `--controller-access-token` — user/controller token used to mint the runtime token if `--runtime-token` is not provided.
47
- - `--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.
48
- - `--runtime-token` / `RUNTIME_ACCESS_TOKEN` — pre-minted runtime/origin token to bypass minting.
49
- - `--origin-id` — optionally fix the origin id (otherwise auto-generated).
50
- - `--origin-endpoint` — skip tunnels entirely and publish a fixed, reachable origin URL (useful for servers with a stable public endpoint).
51
- - `--workspace` / `WORKSPACE_DIR` — workspace root for the runtime (default `./.instafy/workspace`).
52
- - `--provider` / `RUNTIME_PROVIDER` — runtime provider label (defaults to the org in `.instafy/project.json`, otherwise `self-hosted`).
53
- - `--detach` — background the runtime; pid/log state is recorded under `~/.instafy/cli-runtime-state.json`.
54
- - `--org-id` — target an existing org when running `project:init` (otherwise the CLI creates or reuses a personal org).
55
-
56
- ## Tunnels (self-hosted)
57
-
58
- 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).
59
24
 
60
- - **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.
61
26
 
62
- ## Notes
27
+ ## Docs
63
28
 
64
- - 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.
65
- - Runtime/origin tokens require the controller to be configured with the Ed25519 signing pair (`RUNTIME_SIGNING_PRIVATE_KEY` / `RUNTIME_SIGNING_PUBLIC_KEY`).
66
- - 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,11 @@ program
238
241
  process.exit(1);
239
242
  }
240
243
  });
244
+ export async function runCli(argv = process.argv) {
245
+ await program.parseAsync(argv);
246
+ }
241
247
  if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {
242
- program.parseAsync(process.argv);
248
+ void runCli(process.argv);
243
249
  }
244
250
  // Re-export programmatic APIs for embedders (e.g., VS Code extension).
245
251
  export { runtimeStart as startRuntime, runtimeStatus as getRuntimeStatus, runtimeStop as stopRuntime, runtimeToken as mintRuntimeToken, mintRuntimeAccessToken, findProjectManifest, mountWorkspace, } from "./runtime.js";
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@instafy/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
+ "description": "Run Instafy projects locally, link folders to Studio, and share previews/webhooks via tunnels.",
4
5
  "private": false,
5
6
  "publishConfig": {
6
7
  "access": "public"