@nomad-e/bluma-cli 0.9.2 → 0.11.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.
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: factorai-sh
3
+ description: >
4
+ Use for FactorAI.sh / Severino Next.js hosting in sandbox: scaffold, first deploy,
5
+ edit live apps, rebuild (Vercel-like). Triggers: "deploy next", "factorai.sh",
6
+ "criar app nextjs", "portfolio online", "rebuild", "atualizar app deployada",
7
+ "apply_app_changes", "redeploy", "factor-sh-url-app".
8
+ license: Proprietary
9
+ ---
10
+
11
+ # FactorAI.sh — Next.js deploy & incremental rebuild
12
+
13
+ ## Prerequisites
14
+
15
+ - Sandbox: `BLUMA_SANDBOX=true`
16
+ - `FACTORAI_BASE_URL` and `SEVERINO_URL` are set in your environment — tools call those bases automatically
17
+ - Do **not** invent API hosts or guess prod vs dev; use env + `factorai.sh.json` only
18
+ - Optional: `FACTORAI_API_KEY` / `SEVERINO_API_KEY` when the server requires auth
19
+
20
+ ## Manifest
21
+
22
+ Always read `factorai.sh.json` in the project root before editing a deployed app:
23
+
24
+ - `appContext.appId` — UUID for all FactorAI API tools
25
+ - `appContext.appUrl` — path or URL for the live app → use for `factor-sh-url-app` (resolve to absolute URL via manifest + `SEVERINO_URL` when path-only)
26
+
27
+ ## Session scope
28
+
29
+ - Each `session_id` has its own sandbox workspace. Manifest and project files exist **only** there.
30
+ - Do not use `appId` from another session. If `factorai.sh.json` is missing in cwd, create/deploy the app in **this** session first.
31
+
32
+ ## Flow A — New app
33
+
34
+ ```text
35
+ 1. factorai.sh.create_next_app({ name: "my-app", template: "full" })
36
+ 2. edit_tool / file_write under ./my-app/ (especially app/**)
37
+ 3. Avoid npm run build before deploy (.next inflates ZIP); optional npx tsc --noEmit
38
+ 4. factorai.sh.deploy_app({ projectDir: "./my-app", name: "my-app" })
39
+ 5. Poll get_app_status until ready (see Polling)
40
+ 6. message(result) with factor-sh-url-app from manifest after ready
41
+ ```
42
+
43
+ ## Flow B — App already online in this session (like Vercel)
44
+
45
+ ```text
46
+ 1. Read factorai.sh.json in cwd → appId
47
+ 2. edit_tool / file_write locally, then read_file_lines the FULL changed file(s)
48
+ 3. factorai.sh.apply_app_changes({
49
+ appId: "<uuid from this session manifest>",
50
+ files: [
51
+ { path: "app/page.tsx", content: "<ENTIRE file contents after edit>" },
52
+ ],
53
+ deploy: true,
54
+ })
55
+ 4. Poll until building → ready
56
+ 5. message(result) with factor-sh-url-app from manifest after ready
57
+ ```
58
+
59
+ **Wrong patterns:**
60
+
61
+ - `files[].content` with only a footer/section snippet → server replaces whole file → broken page
62
+ - `file_write` only without `apply_app_changes` → running app unchanged
63
+ - `deploy_app` again for a one-line JSX change → slow, wasteful
64
+ - ZIP with `node_modules` → fails or exceeds size limit
65
+ - Hardcoding deploy/API hosts instead of using configured env
66
+
67
+ ## Polling checklist
68
+
69
+ 1. Call `factorai.sh.get_app_status({ appId })` every 5–10s
70
+ 2. Require seeing `building` after apply/deploy before trusting `ready`
71
+ 3. Verify the live route from `appContext.appUrl` (absolute URL); reject `Service Unavailable` JSON as "not live yet"
72
+ 4. Typical rebuild: 30–90 seconds
73
+
74
+ ## Tool reference
75
+
76
+ | Tool | Purpose |
77
+ |------|---------|
78
+ | `factorai.sh.create_next_app` | Scaffold Next 14 + App Router + Tailwind (+ shadcn in `full`) |
79
+ | `factorai.sh.deploy_app` | First deploy: ZIP source → deploy API on `SEVERINO_URL` |
80
+ | `factorai.sh.apply_app_changes` | Patch files on server + `next build` + restart |
81
+ | `factorai.sh.get_app_status` | Status + contract |
82
+ | `factorai.sh.redeploy_app` | Rebuild without uploading new file contents |
83
+
84
+ ## Troubleshooting
85
+
86
+ | Symptom | Action |
87
+ |---------|--------|
88
+ | `Couldn't find app directory` | Scaffold missing `app/` — use `template: "full"` or fix `create_next_app` |
89
+ | `Cannot find name 'Slot'` | Broken shadcn template — use fixed scaffold or simplify `components/ui/button.tsx` |
90
+ | ZIP too large | Ensure `node_modules` not in ZIP; `deploy_app` excludes it |
91
+ | `ready` but 503/JSON error | Keep polling; rebuild still running |
92
+ | curl deploy fails on headers | Use tools, not manual curl |
93
+
94
+ ## End of task
95
+
96
+ - `message({ message_type: "result", content: "...", "factor-sh-url-app": "<absolute live url from manifest>" })` — **required** for Severino; auto-filled from `factorai.sh.json` if omitted
97
+ - `attachments[]` — only for files under `.bluma/artifacts/`, not the app URL