@webhouse/cms-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,30 +1,181 @@
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
+ # 1. Install the CLI globally
8
9
  npm install -g @webhouse/cms-cli
10
+
11
+ # 2. Create a new project
12
+ npm create @webhouse/cms my-site
13
+ cd my-site
14
+ npm install
15
+
16
+ # 3. Add your AI key (optional, for AI content generation)
17
+ echo "ANTHROPIC_API_KEY=sk-ant-..." >> .env
18
+
19
+ # 4. Start developing
20
+ cms dev
9
21
  ```
10
22
 
11
- Or use directly with npx:
23
+ Your site is running at `http://localhost:3000` with a full REST API.
24
+
25
+ ## The full workflow
26
+
27
+ Here's what a typical workflow looks like — from zero to published site:
28
+
29
+ <p align="center">
30
+ <img src="../../docs/workflow.svg" alt="WebHouse CMS workflow" width="720" />
31
+ </p>
32
+
33
+ ### Step 1: Scaffold
12
34
 
13
35
  ```bash
14
- npx @webhouse/cms init
36
+ npm create @webhouse/cms my-site
37
+ cd my-site && npm install
38
+ ```
39
+
40
+ This creates `cms.config.ts` with a `posts` collection, an example post, and a `.env` file for your API keys.
41
+
42
+ ### Step 2: Define your schema
43
+
44
+ Edit `cms.config.ts` to add collections:
45
+
46
+ ```typescript
47
+ import { defineConfig, defineCollection } from '@webhouse/cms';
48
+
49
+ export default defineConfig({
50
+ collections: [
51
+ defineCollection({
52
+ name: 'posts',
53
+ label: 'Blog Posts',
54
+ fields: [
55
+ { name: 'title', type: 'text', label: 'Title', required: true },
56
+ { name: 'excerpt', type: 'textarea', label: 'Excerpt' },
57
+ { name: 'content', type: 'richtext', label: 'Content' },
58
+ { name: 'date', type: 'date', label: 'Publish Date' },
59
+ ],
60
+ }),
61
+ defineCollection({
62
+ name: 'pages',
63
+ label: 'Pages',
64
+ fields: [
65
+ { name: 'title', type: 'text', label: 'Title', required: true },
66
+ { name: 'body', type: 'richtext', label: 'Body' },
67
+ { name: 'slug', type: 'text', label: 'URL Slug', required: true },
68
+ ],
69
+ }),
70
+ ],
71
+ });
72
+ ```
73
+
74
+ ### Step 3: Create content
75
+
76
+ You have three ways to create content:
77
+
78
+ **A) Via the REST API** (programmatic)
79
+ ```bash
80
+ curl -X POST http://localhost:3000/api/content/posts \
81
+ -H "Content-Type: application/json" \
82
+ -d '{"slug":"my-post","status":"published","data":{"title":"My Post","content":"# Hello"}}'
83
+ ```
84
+
85
+ **B) Via AI generation** (from terminal)
86
+ ```bash
87
+ cms ai generate posts "Write a blog post about TypeScript best practices"
88
+ ```
89
+
90
+ **C) Via Claude Code** (AI-assisted development)
91
+ ```
92
+ > Build a website with 2 collections (posts, pages). Create a post about
93
+ why SQLite is great for content management.
94
+ ```
95
+
96
+ Claude Code will edit `cms.config.ts`, call the API to create content, and verify the build.
97
+
98
+ ### Step 4: Build & deploy
99
+
100
+ ```bash
101
+ cms build # Generates static HTML, sitemap, llms.txt
102
+ ```
103
+
104
+ Output goes to `dist/` — deploy anywhere (Fly.io, Vercel, Cloudflare Pages, etc.)
105
+
106
+ ## Using with Claude Code
107
+
108
+ WebHouse CMS is designed to work seamlessly with AI coding assistants. Here's a real-world session:
109
+
110
+ ```
111
+ You: Build a website around @webhouse/cms with 2 collections: posts and pages
112
+
113
+ Claude: I'll set up the project for you.
114
+ [edits cms.config.ts — adds posts and pages collections]
115
+ [starts dev server]
116
+ [creates an "About" page via the API]
117
+ ✓ Site running at http://localhost:3000
118
+
119
+ You: Create a blog post about AI-native CMS
120
+
121
+ Claude: I'll use the AI content generator.
122
+ [runs: cms ai generate posts "Write about AI-native CMS"]
123
+ ✓ Created: why-ai-native-cms-is-the-future
124
+ Cost: $0.0096 | Tokens: 195 in / 602 out
125
+
126
+ You: Build it
127
+
128
+ Claude: [runs: cms build]
129
+ ✓ Build complete — 6 pages in dist/
15
130
  ```
16
131
 
17
132
  ## Commands
18
133
 
19
134
  | Command | Description |
20
135
  | --- | --- |
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 |
136
+ | `cms init [name]` | Scaffold a new project |
137
+ | `cms dev [--port 3000]` | Start dev server with hot reload |
138
+ | `cms build [--outDir dist]` | Build static site (HTML, sitemap, llms.txt) |
139
+ | `cms serve [--port 5000]` | Serve built site locally |
140
+ | `cms ai generate <collection> <prompt>` | Generate content with AI |
141
+ | `cms ai rewrite <collection/slug> <instruction>` | Rewrite existing content |
142
+ | `cms ai seo` | Run SEO optimization on all documents |
143
+ | `cms mcp keygen` | Generate MCP API key |
144
+ | `cms mcp test` | Test MCP server connection |
145
+ | `cms mcp status` | Check MCP server status |
146
+
147
+ ## Environment variables
148
+
149
+ The CLI automatically loads `.env` from the current directory.
150
+
151
+ | Variable | Required | Description |
152
+ | --- | --- | --- |
153
+ | `ANTHROPIC_API_KEY` | For AI features | Anthropic Claude API key |
154
+ | `OPENAI_API_KEY` | For AI features | OpenAI API key (alternative to Anthropic) |
155
+
156
+ At least one AI key is required for `cms ai` commands. Anthropic is used by default when both are set.
157
+
158
+ ## Installation
159
+
160
+ ```bash
161
+ # Global install (recommended) — gives you the `cms` command directly
162
+ npm install -g @webhouse/cms-cli
163
+
164
+ cms --version
165
+ cms dev
166
+ cms ai generate posts "..."
167
+ ```
168
+
169
+ > **Note:** Do not use `npx cms` — npm will resolve it to an unrelated package called `cms`.
170
+ > Use `npx @webhouse/cms-cli` if you prefer not to install globally, or install as a project dependency.
171
+
172
+ ```bash
173
+ # As a project dependency (added automatically by `npm create @webhouse/cms`)
174
+ npm install @webhouse/cms-cli
175
+
176
+ # Then use via npx within the project
177
+ npx @webhouse/cms-cli dev
178
+ ```
28
179
 
29
180
  ## Documentation
30
181
 
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
  });