clawfire 0.2.0 → 0.3.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 CHANGED
@@ -13,8 +13,11 @@ Clawfire lets you build Firebase apps by talking to AI. Define your API contract
13
13
 
14
14
  - **Contract-based API** — Define input/output with Zod schemas. Runtime validation, type safety, and docs come for free.
15
15
  - **File-based Routing** — `app/routes/todos/create.ts` becomes `POST /api/todos/create`. No configuration.
16
+ - **Page Routing** — `app/pages/about.html` becomes `/about`. Layouts, components, and SPA navigation built in.
17
+ - **Layouts & Components** — `_layout.html` wraps pages via `<slot />`. `<c-nav />` inserts `app/components/nav.html`.
18
+ - **SPA Navigation** — Internal links swap page content without full reload. Tailwind CSS via CDN.
16
19
  - **Two-Port Dev Server** — Frontend app on port 3000, API + Playground on port 3456. One command.
17
- - **Hot Reload** — API route changes reload instantly. CSS changes apply without page reload.
20
+ - **Hot Reload** — API, page, and CSS changes reload instantly. No manual refresh needed.
18
21
  - **API Playground** — Interactive API explorer auto-generated from your route definitions.
19
22
  - **Auto Client Generation** — Type-safe `api.todos.create({ title })` client generated from your contracts.
20
23
  - **Firebase-Native** — Firestore, Auth, Functions, Hosting. Fully integrated, no alternatives needed.
@@ -48,6 +51,7 @@ This starts **two servers** in a single process:
48
51
  App : http://localhost:3000
49
52
  API : http://localhost:3456/api/...
50
53
  Playground : http://localhost:3456
54
+ Pages : ON (app/pages/)
51
55
 
52
56
  Routes (5):
53
57
  POST /api/health [public] Health check endpoint
@@ -57,7 +61,7 @@ This starts **two servers** in a single process:
57
61
  POST /api/todos/update [public] Update a todo
58
62
 
59
63
  Hot Reload : ON
60
- Watching: app/routes/, app/schemas/, public/
64
+ Watching: app/routes/, app/schemas/, app/pages/, app/components/, public/
61
65
  ```
62
66
 
63
67
  ### 3. Open in Your Browser
@@ -87,12 +91,14 @@ curl -s -X POST http://localhost:3000/api/todos/create \
87
91
  Clawfire runs a **two-port dev server** in a single process:
88
92
 
89
93
  ```
90
- DevServer
94
+ DevServer (single process)
95
+ ├─ PageCompiler (compiles app/pages/ + app/components/ → HTML)
91
96
  ├─ Frontend Server (port 3000)
92
- │ ├─ Serves public/ directory
97
+ │ ├─ Serves compiled pages (app/pages/ → routes)
98
+ │ ├─ Serves public/ directory (static assets)
93
99
  │ ├─ Auto-injects HMR script into HTML
94
100
  │ ├─ Proxies /api/* → API server (no CORS)
95
- │ └─ SPA fallback index.html
101
+ │ └─ SPA fallback with partial page loading
96
102
 
97
103
  └─ API Server (port 3456)
98
104
  ├─ API routes at /api/*
@@ -131,6 +137,16 @@ dev: {
131
137
  my-app/
132
138
  app/
133
139
  store.ts In-memory data store (works without Firebase)
140
+ pages/ File-based page routing (frontend)
141
+ _layout.html Root layout (wraps all pages via <slot />)
142
+ _404.html 404 error page
143
+ index.html Home page (/)
144
+ about.html /about page
145
+ todos/
146
+ index.html /todos page
147
+ components/ Reusable HTML components
148
+ nav.html <c-nav /> navigation bar
149
+ footer.html <c-footer /> page footer
134
150
  routes/ API route handlers (file-based routing)
135
151
  health.ts → POST /api/health
136
152
  todos/
@@ -140,8 +156,7 @@ my-app/
140
156
  delete.ts → POST /api/todos/delete
141
157
  schemas/ Firestore model definitions
142
158
  todo.ts
143
- public/
144
- index.html Frontend app (vanilla JS, no build step)
159
+ public/ Static assets (CSS, images, fonts)
145
160
  generated/ Auto-generated files (DO NOT EDIT)
146
161
  api-client.ts Typed API client
147
162
  manifest.json API manifest
@@ -393,7 +408,7 @@ When using [Claude Code](https://claude.ai/claude-code), these slash commands ar
393
408
  | `clawfire/admin` | `generateFirestoreRules`, `generateFirestoreIndexes`, `setUserRole` |
394
409
  | `clawfire/codegen` | `generateClientCode`, `discoverRoutes`, `generateRouteImports` |
395
410
  | `clawfire/playground` | `generatePlaygroundHtml` |
396
- | `clawfire/dev` | `DevServer`, `startDevServer`, `FileWatcher` |
411
+ | `clawfire/dev` | `DevServer`, `startDevServer`, `FileWatcher`, `PageCompiler` |
397
412
 
398
413
  ---
399
414
 
package/dist/cli.js CHANGED
@@ -117,6 +117,8 @@ async function initProject() {
117
117
  const dirs = [
118
118
  "app/routes",
119
119
  "app/schemas",
120
+ "app/pages",
121
+ "app/components",
120
122
  "generated",
121
123
  "public",
122
124
  "functions"
@@ -184,13 +186,21 @@ export const api = functions.https.onRequest((req, res) => {
184
186
  console.log(" Created functions/index.ts");
185
187
  }
186
188
  console.log("\n \x1B[32m\u2713\x1B[0m Clawfire project initialized!\n");
189
+ console.log(" Project structure:");
190
+ console.log(" \x1B[36mapp/pages/\x1B[0m \u2192 File-based page routing (Tailwind + layouts)");
191
+ console.log(" \x1B[36mapp/components/\x1B[0m \u2192 Reusable HTML components (<c-name />)");
192
+ console.log(" \x1B[36mapp/routes/\x1B[0m \u2192 API endpoints (POST, Zod validation)");
193
+ console.log(" \x1B[36mapp/schemas/\x1B[0m \u2192 Firestore model definitions");
194
+ console.log(" \x1B[36mpublic/\x1B[0m \u2192 Static assets (CSS, images, fonts)");
195
+ console.log("");
187
196
  console.log(" Next steps:");
188
197
  console.log(" \x1B[36m1.\x1B[0m npm install");
189
198
  console.log(" \x1B[36m2.\x1B[0m npm run dev");
190
- console.log(" \x1B[36m3.\x1B[0m Open \x1B[1mhttp://localhost:3000\x1B[0m in your browser");
199
+ console.log(" \x1B[36m3.\x1B[0m Open \x1B[1mhttp://localhost:3000\x1B[0m");
200
+ console.log("");
201
+ console.log(" Your app is ready with a Todo demo, page routing, and API playground.");
191
202
  console.log("");
192
- console.log(" Your Todo app is ready! Try adding, completing, and deleting todos.");
193
- console.log(" Edit files in \x1B[1mapp/routes/\x1B[0m and see changes instantly.\n");
203
+ console.log(" npm: \x1B[4mhttps://www.npmjs.com/package/clawfire\x1B[0m\n");
194
204
  }
195
205
  async function runDevServer() {
196
206
  const projectDir = process.cwd();
@@ -199,7 +209,7 @@ async function runDevServer() {
199
209
  const port = portArg ? parseInt(portArg.split("=")[1], 10) : 3e3;
200
210
  const apiPort = apiPortArg ? parseInt(apiPortArg.split("=")[1], 10) : 3456;
201
211
  const noHotReload = args.includes("--no-hot-reload");
202
- const { startDevServer } = await import("./dev-server-QTNE5N7I.js");
212
+ const { startDevServer } = await import("./dev-server-TGEKP4YE.js");
203
213
  await startDevServer({
204
214
  projectDir,
205
215
  port,