@webhouse/cms-cli 0.1.1 → 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,30 +1,169 @@
1
1
  # @webhouse/cms-cli
2
2
 
3
- CLI for `@webhouse/cms` — scaffold, develop, build, and manage AI-native CMS sites.
3
+ CLI for [@webhouse/cms](https://github.com/webhousecode/cms) — scaffold projects, run the dev server, build static sites, and generate content with AI.
4
4
 
5
- ## Installation
5
+ ## Quick start
6
6
 
7
7
  ```bash
8
- npm install -g @webhouse/cms-cli
8
+ # 1. Create a new project
9
+ npm create @webhouse/cms my-site
10
+ cd my-site
11
+ npm install
12
+
13
+ # 2. Add your AI key (optional, for AI content generation)
14
+ echo "ANTHROPIC_API_KEY=sk-ant-..." >> .env
15
+
16
+ # 3. Start developing
17
+ npx cms dev
9
18
  ```
10
19
 
11
- Or use directly with npx:
20
+ Your site is running at `http://localhost:3000` with a full REST API.
21
+
22
+ ## The full workflow
23
+
24
+ Here's what a typical workflow looks like — from zero to published site:
25
+
26
+ <p align="center">
27
+ <img src="../../docs/workflow.svg" alt="WebHouse CMS workflow" width="720" />
28
+ </p>
29
+
30
+ ### Step 1: Scaffold
12
31
 
13
32
  ```bash
14
- npx @webhouse/cms init
33
+ npm create @webhouse/cms my-site
34
+ cd my-site && npm install
35
+ ```
36
+
37
+ This creates `cms.config.ts` with a `posts` collection, an example post, and a `.env` file for your API keys.
38
+
39
+ ### Step 2: Define your schema
40
+
41
+ Edit `cms.config.ts` to add collections:
42
+
43
+ ```typescript
44
+ import { defineConfig, defineCollection } from '@webhouse/cms';
45
+
46
+ export default defineConfig({
47
+ collections: [
48
+ defineCollection({
49
+ name: 'posts',
50
+ label: 'Blog Posts',
51
+ fields: [
52
+ { name: 'title', type: 'text', label: 'Title', required: true },
53
+ { name: 'excerpt', type: 'textarea', label: 'Excerpt' },
54
+ { name: 'content', type: 'richtext', label: 'Content' },
55
+ { name: 'date', type: 'date', label: 'Publish Date' },
56
+ ],
57
+ }),
58
+ defineCollection({
59
+ name: 'pages',
60
+ label: 'Pages',
61
+ fields: [
62
+ { name: 'title', type: 'text', label: 'Title', required: true },
63
+ { name: 'body', type: 'richtext', label: 'Body' },
64
+ { name: 'slug', type: 'text', label: 'URL Slug', required: true },
65
+ ],
66
+ }),
67
+ ],
68
+ });
69
+ ```
70
+
71
+ ### Step 3: Create content
72
+
73
+ You have three ways to create content:
74
+
75
+ **A) Via the REST API** (programmatic)
76
+ ```bash
77
+ curl -X POST http://localhost:3000/api/content/posts \
78
+ -H "Content-Type: application/json" \
79
+ -d '{"slug":"my-post","status":"published","data":{"title":"My Post","content":"# Hello"}}'
80
+ ```
81
+
82
+ **B) Via AI generation** (from terminal)
83
+ ```bash
84
+ npx cms ai generate posts "Write a blog post about TypeScript best practices"
85
+ ```
86
+
87
+ **C) Via Claude Code** (AI-assisted development)
88
+ ```
89
+ > Build a website with 2 collections (posts, pages). Create a post about
90
+ why SQLite is great for content management.
91
+ ```
92
+
93
+ Claude Code will edit `cms.config.ts`, call the API to create content, and verify the build.
94
+
95
+ ### Step 4: Build & deploy
96
+
97
+ ```bash
98
+ npx cms build # Generates static HTML, sitemap, llms.txt
99
+ ```
100
+
101
+ Output goes to `dist/` — deploy anywhere (Fly.io, Vercel, Cloudflare Pages, etc.)
102
+
103
+ ## Using with Claude Code
104
+
105
+ WebHouse CMS is designed to work seamlessly with AI coding assistants. Here's a real-world session:
106
+
107
+ ```
108
+ You: Build a website around @webhouse/cms with 2 collections: posts and pages
109
+
110
+ Claude: I'll set up the project for you.
111
+ [edits cms.config.ts — adds posts and pages collections]
112
+ [starts dev server]
113
+ [creates an "About" page via the API]
114
+ ✓ Site running at http://localhost:3000
115
+
116
+ You: Create a blog post about AI-native CMS
117
+
118
+ Claude: I'll use the AI content generator.
119
+ [runs: npx cms ai generate posts "Write about AI-native CMS"]
120
+ ✓ Created: why-ai-native-cms-is-the-future
121
+ Cost: $0.0096 | Tokens: 195 in / 602 out
122
+
123
+ You: Build it
124
+
125
+ Claude: [runs: npx cms build]
126
+ ✓ Build complete — 6 pages in dist/
15
127
  ```
16
128
 
17
129
  ## Commands
18
130
 
19
131
  | Command | Description |
20
132
  | --- | --- |
21
- | `cms init` | Scaffold a new CMS project |
22
- | `cms dev` | Start dev server with hot reload |
23
- | `cms build` | Build static site output |
24
- | `cms serve` | Serve built site locally |
25
- | `cms ai generate` | Generate content with AI |
26
- | `cms ai rewrite` | Rewrite existing content |
27
- | `cms mcp keygen` | Generate MCP API keys |
133
+ | `cms init [name]` | Scaffold a new project |
134
+ | `cms dev [--port 3000]` | Start dev server with hot reload |
135
+ | `cms build [--outDir dist]` | Build static site (HTML, sitemap, llms.txt) |
136
+ | `cms serve [--port 5000]` | Serve built site locally |
137
+ | `cms ai generate <collection> <prompt>` | Generate content with AI |
138
+ | `cms ai rewrite <collection/slug> <instruction>` | Rewrite existing content |
139
+ | `cms ai seo` | Run SEO optimization on all documents |
140
+ | `cms mcp keygen` | Generate MCP API key |
141
+ | `cms mcp test` | Test MCP server connection |
142
+ | `cms mcp status` | Check MCP server status |
143
+
144
+ ## Environment variables
145
+
146
+ The CLI automatically loads `.env` from the current directory.
147
+
148
+ | Variable | Required | Description |
149
+ | --- | --- | --- |
150
+ | `ANTHROPIC_API_KEY` | For AI features | Anthropic Claude API key |
151
+ | `OPENAI_API_KEY` | For AI features | OpenAI API key (alternative to Anthropic) |
152
+
153
+ At least one AI key is required for `cms ai` commands. Anthropic is used by default when both are set.
154
+
155
+ ## Installation
156
+
157
+ ```bash
158
+ # Global install
159
+ npm install -g @webhouse/cms-cli
160
+
161
+ # Or use npx (no install needed)
162
+ npx @webhouse/cms-cli dev
163
+
164
+ # Or add to your project
165
+ npm install @webhouse/cms-cli
166
+ ```
28
167
 
29
168
  ## Documentation
30
169
 
package/dist/index.js CHANGED
@@ -862,6 +862,10 @@ var require_picocolors = __commonJS({
862
862
  }
863
863
  });
864
864
 
865
+ // src/index.ts
866
+ import { existsSync as existsSync4, readFileSync } from "fs";
867
+ import { resolve as resolve3 } from "path";
868
+
865
869
  // ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/core.mjs
866
870
  var LogLevels = {
867
871
  silent: Number.NEGATIVE_INFINITY,
@@ -2904,6 +2908,20 @@ async function mcpStatusCommand(args) {
2904
2908
  }
2905
2909
 
2906
2910
  // src/index.ts
2911
+ var envPath = resolve3(process.cwd(), ".env");
2912
+ if (existsSync4(envPath)) {
2913
+ for (const line of readFileSync(envPath, "utf-8").split("\n")) {
2914
+ const trimmed = line.trim();
2915
+ if (!trimmed || trimmed.startsWith("#")) continue;
2916
+ const eqIdx = trimmed.indexOf("=");
2917
+ if (eqIdx === -1) continue;
2918
+ const key = trimmed.slice(0, eqIdx).trim();
2919
+ const value = trimmed.slice(eqIdx + 1).trim();
2920
+ if (!process.env[key]) {
2921
+ process.env[key] = value;
2922
+ }
2923
+ }
2924
+ }
2907
2925
  var init2 = defineCommand({
2908
2926
  meta: { name: "init", description: "Initialize a new CMS project" },
2909
2927
  args: {
@@ -3020,7 +3038,7 @@ var main = defineCommand({
3020
3038
  meta: {
3021
3039
  name: "cms",
3022
3040
  description: "@webhouse/cms \u2014 AI-native CMS engine",
3023
- version: "0.1.0"
3041
+ version: "0.1.1"
3024
3042
  },
3025
3043
  subCommands: { init: init2, dev, build, serve, ai, mcp }
3026
3044
  });