@dinakars777/create-nexus 1.0.0 → 1.1.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
@@ -1,40 +1,55 @@
1
- # 🧠 create-nexus
1
+ # create-nexus 🧠
2
2
 
3
- > **The Ultimate Agent-Native Boilerplate Generator.**
3
+ [![npm version](https://img.shields.io/npm/v/@dinakars777/create-nexus.svg?style=flat-square)](https://www.npmjs.com/package/@dinakars777/create-nexus)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@dinakars777/create-nexus.svg?style=flat-square)](https://www.npmjs.com/package/@dinakars777/create-nexus)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
4
6
 
5
- Most Next.js boilerplates are optimized for human readability.
6
- **Project Nexus** is optimized to be perfectly indexed, mutated, and scaled by AI Coding Agents (Cursor, Claude, Devin) with *zero hallucinations*.
7
+ > The Ultimate Agent-Native Boilerplate Generator.
8
+
9
+ Most Next.js boilerplates are optimized for human readability. **create-nexus** is optimized to be perfectly indexed, mutated, and scaled by AI coding agents (Cursor, Claude, Devin) with zero hallucinations.
7
10
 
8
11
  ## The Problem
9
- When you ask an AI Agent to "build a feature" in a standard Next.js codebase, it hallucinates. It mixes Pages Router with App Router, it writes raw SQL instead of using your ORM, or it bypasses your API layer entirely to write Server Actions in the UI.
10
12
 
11
- ## The Solution
12
- `create-nexus` generates a fortress. It scaffolds a high-density, strictly-typed environment (Next.js, Hono, Drizzle, Zod) that includes a built-in **Context Control Plane** explicitly designed to govern AI behavior.
13
+ When you ask an AI agent to "build a feature" in a standard Next.js codebase, it hallucinates. It mixes Pages Router with App Router, writes raw SQL instead of using your ORM, or bypasses your API layer entirely. **create-nexus** generates a fortress that governs AI behavior by design.
13
14
 
14
- ### 📦 The Tech Stack
15
- * **Frontend:** Next.js (App Router) + Tailwind CSS
16
- * **API:** Hono RPC (End-to-End Type Safety)
17
- * **Database:** Drizzle ORM + Postgres
18
- * **Validation:** Strict Zod Boundaries
15
+ ## Quick Start
19
16
 
20
- ### 🤖 The Agent-Native Architecture
21
- When you run the generator, you aren't just getting React components. You get:
17
+ ```bash
18
+ npx @dinakars777/create-nexus
19
+ ```
22
20
 
23
- 1. **The `.agent/` Control Directory**: Contains global `rules.md`, an architectural `project-map.json`, and a `scratchpad.md` for the agent to "think" out loud.
24
- 2. **The Twin-File System**: Every major directory (`src/app`, `src/db`) contains a `CONCEPTS.md`. This defines the Business Logic vs. Implementation boundaries so the agent understands the "why" and doesn't guess context.
25
- 3. **Strict Type-Safety Walls**: Absolute zero `any` types. Every API route uses `zValidator`. If an agent hallucinates an API shape, the Typescript compiler crashes, forcing the agent to read the error and fix itself.
26
- 4. **Verification Hooks**: Pre-configured Husky pre-commit hooks run `tsc --noEmit`. If the agent breaks the build, the Git commit natively fails, forcing it to loop until structurally sound.
27
- 5. **MCP Stub**: An integrated Model Context Protocol server stub (`server/mcp`) allowing local agents to securely query database schemas without reading thousands of lines of code.
21
+ Follow the interactive prompts. The CLI handles directory scaffolding, Git initialization, and dependency installation.
28
22
 
29
- ## Quickstart
23
+ ## What You Get
30
24
 
31
- Instantly generate your Agent-Native workspace:
25
+ | Feature | Description |
26
+ |---|---|
27
+ | `.agent/` Control Directory | `rules.md`, `project-map.json`, and `scratchpad.md` for agent context |
28
+ | Twin-File System | `CONCEPTS.md` in every major directory defining business logic boundaries |
29
+ | Strict Type-Safety | Zero `any` types, Zod-validated API routes — compiler crashes on hallucinations |
30
+ | Verification Hooks | Husky pre-commit hooks run `tsc --noEmit` — broken builds can't be committed |
31
+ | MCP Stub | Integrated Model Context Protocol server for secure local DB schema queries |
32
32
 
33
- ```bash
34
- npx @dinakars777/create-nexus
35
- ```
33
+ ## Tech Stack
34
+
35
+ | Layer | Technology |
36
+ |---|---|
37
+ | Frontend | Next.js (App Router) + Tailwind CSS |
38
+ | API | Hono RPC (end-to-end type safety) |
39
+ | Database | Drizzle ORM + Postgres |
40
+ | Validation | Zod |
41
+
42
+ ## Templates
36
43
 
37
- Follow the interactive prompts to name your project. The CLI will handle directory scaffolding, Git initialization, and NPM dependency installations.
44
+ The generator supports multiple project types:
45
+
46
+ | Template | Description |
47
+ |---|---|
48
+ | `stack` | Full-stack Next.js + Hono + Drizzle |
49
+ | `agent` | AI agent scaffold with `.agent/` control plane |
50
+ | `mcp` | Model Context Protocol server stub |
51
+ | `twin` | Twin-file system with `CONCEPTS.md` structure |
38
52
 
39
53
  ## License
54
+
40
55
  MIT
package/dist/index.js CHANGED
@@ -252,6 +252,7 @@ async function generateBoilerplate(projectName) {
252
252
  "lint": "next lint",
253
253
  "check": "tsc --noEmit",
254
254
  "db:push": "drizzle-kit push",
255
+ "db:studio": "drizzle-kit studio",
255
256
  "prepare": "husky install"
256
257
  },
257
258
  dependencies: {
@@ -317,6 +318,140 @@ npx lint-staged
317
318
  npm run check
318
319
  `;
319
320
  await fs.writeFile(path.join(targetDir, ".husky/pre-commit"), huskyPreCommit);
321
+ const envExample = `# Database
322
+ DATABASE_URL="postgres://localhost:5432/nexus"
323
+
324
+ # Next.js
325
+ NEXT_PUBLIC_API_URL="http://localhost:3000"
326
+ `;
327
+ await fs.writeFile(path.join(targetDir, ".env.example"), envExample);
328
+ const cursorrules = `# Agent Rules for ${projectName}
329
+
330
+ ## Architecture
331
+ - **Frontend**: Next.js App Router (React Server Components)
332
+ - **API**: Hono RPC with end-to-end type safety
333
+ - **Database**: Drizzle ORM + PostgreSQL
334
+ - **Validation**: Zod schemas for all inputs
335
+
336
+ ## Critical Rules
337
+ 1. **Verify Before Commit**: Always run \`npm run check\` before committing. Never commit failing code.
338
+ 2. **Strict Typing**: Never use \`any\`. Use Zod for all validations.
339
+ 3. **Twin-Files**: If you create a new directory, create a \`CONCEPTS.md\` explaining its business logic and boundaries.
340
+ 4. **Architecture Limits**:
341
+ - Do not import UI components into the API layer
342
+ - Do not import Drizzle directly into Next.js React UI layer
343
+ - Use the Hono RPC client (\`hc\`) for all frontend-to-backend communication
344
+ 5. **Think First**: Before making massive destructive changes, write your plan in \`.agent/scratchpad.md\`
345
+
346
+ ## Directory Structure
347
+ - \`src/app/\` - Next.js routing and React UI pages (read \`src/app/CONCEPTS.md\`)
348
+ - \`src/server/\` - Hono API backend and RPC routes (read \`src/server/CONCEPTS.md\`)
349
+ - \`src/db/\` - Drizzle schema operations (read \`src/db/CONCEPTS.md\`)
350
+ - \`server/mcp/\` - Model Context Protocol stubs for agent querying
351
+ - \`.agent/\` - Agent control plane (rules, project map, scratchpad)
352
+
353
+ ## Workflow
354
+ 1. Read the relevant \`CONCEPTS.md\` file before modifying a directory
355
+ 2. Use \`npm run db:studio\` to visualize the database schema
356
+ 3. Run \`npm run check\` to verify TypeScript compilation
357
+ 4. Check \`.agent/scratchpad.md\` for any ongoing work or notes
358
+ `;
359
+ await fs.writeFile(path.join(targetDir, ".cursorrules"), cursorrules);
360
+ const readme = `# ${projectName}
361
+
362
+ > Agent-Native Next.js boilerplate generated with [create-nexus](https://github.com/dinakars777/create-nexus)
363
+
364
+ ## Stack
365
+
366
+ - **Frontend**: Next.js 14 (App Router)
367
+ - **API**: Hono RPC (end-to-end type safety)
368
+ - **Database**: Drizzle ORM + PostgreSQL
369
+ - **Validation**: Zod
370
+ - **AI Integration**: Built-in \`.agent/\` control plane + MCP server
371
+
372
+ ## Getting Started
373
+
374
+ 1. **Install dependencies**:
375
+ \`\`\`bash
376
+ npm install
377
+ \`\`\`
378
+
379
+ 2. **Set up environment variables**:
380
+ \`\`\`bash
381
+ cp .env.example .env
382
+ # Edit .env with your DATABASE_URL
383
+ \`\`\`
384
+
385
+ 3. **Push database schema**:
386
+ \`\`\`bash
387
+ npm run db:push
388
+ \`\`\`
389
+
390
+ 4. **Start development server**:
391
+ \`\`\`bash
392
+ npm run dev
393
+ \`\`\`
394
+
395
+ 5. **Open Drizzle Studio** (optional):
396
+ \`\`\`bash
397
+ npm run db:studio
398
+ \`\`\`
399
+
400
+ ## Architecture
401
+
402
+ This project follows the **Agent-Native Architecture** pattern:
403
+
404
+ ### The \`.agent/\` Control Plane
405
+ - \`rules.md\` - Global rules for AI agents working on this codebase
406
+ - \`project-map.json\` - High-level architecture overview
407
+ - \`scratchpad.md\` - Temporary workspace for planning complex changes
408
+
409
+ ### The Twin-File System
410
+ Each major directory contains a \`CONCEPTS.md\` file that defines:
411
+ - Business logic boundaries
412
+ - What the directory is responsible for
413
+ - What it should NOT do
414
+
415
+ This prevents AI agents from hallucinating incorrect architectures.
416
+
417
+ ### Directory Structure
418
+
419
+ \`\`\`
420
+ ${projectName}/
421
+ \u251C\u2500\u2500 .agent/ # Agent control plane
422
+ \u251C\u2500\u2500 src/
423
+ \u2502 \u251C\u2500\u2500 app/ # Next.js pages (read CONCEPTS.md)
424
+ \u2502 \u251C\u2500\u2500 server/ # Hono API routes (read CONCEPTS.md)
425
+ \u2502 \u2514\u2500\u2500 db/ # Drizzle schema (read CONCEPTS.md)
426
+ \u251C\u2500\u2500 server/
427
+ \u2502 \u2514\u2500\u2500 mcp/ # Model Context Protocol server
428
+ \u251C\u2500\u2500 .cursorrules # AI IDE integration (Cursor, Cline)
429
+ \u2514\u2500\u2500 .husky/ # Git hooks (pre-commit type checking)
430
+ \`\`\`
431
+
432
+ ## Available Scripts
433
+
434
+ - \`npm run dev\` - Start Next.js development server
435
+ - \`npm run build\` - Build for production
436
+ - \`npm run start\` - Start production server
437
+ - \`npm run check\` - Run TypeScript type checking
438
+ - \`npm run db:push\` - Push schema changes to database
439
+ - \`npm run db:studio\` - Open Drizzle Studio (database GUI)
440
+
441
+ ## Working with AI Agents
442
+
443
+ This project is optimized for AI coding agents (Cursor, Cline, Claude, etc.):
444
+
445
+ 1. **Read \`.cursorrules\`** - Contains all architectural rules
446
+ 2. **Check \`CONCEPTS.md\`** - Before modifying any directory
447
+ 3. **Use \`.agent/scratchpad.md\`** - For planning complex changes
448
+ 4. **Run \`npm run check\`** - Before committing (enforced by Husky)
449
+
450
+ ## License
451
+
452
+ MIT
453
+ `;
454
+ await fs.writeFile(path.join(targetDir, "README.md"), readme);
320
455
  }
321
456
 
322
457
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dinakars777/create-nexus",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Scaffold the ultimate Agent-Native Boilerplate. Next.js, Hono, Drizzle, Zod, with built-in .agent control plane.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/src/generator.ts CHANGED
@@ -58,6 +58,7 @@ export async function generateBoilerplate(projectName: string) {
58
58
  "lint": "next lint",
59
59
  "check": "tsc --noEmit",
60
60
  "db:push": "drizzle-kit push",
61
+ "db:studio": "drizzle-kit studio",
61
62
  "prepare": "husky install"
62
63
  },
63
64
  dependencies: {
@@ -128,6 +129,145 @@ npx lint-staged
128
129
  npm run check
129
130
  `;
130
131
  await fs.writeFile(path.join(targetDir, '.husky/pre-commit'), huskyPreCommit);
131
- // Ensure the hook is executable (not natively supported by fs.writeFile easily cross-platform, but good enough for a generated boilerplate before install)
132
+
133
+ // 7. Generate .env.example
134
+ const envExample = `# Database
135
+ DATABASE_URL="postgres://localhost:5432/nexus"
136
+
137
+ # Next.js
138
+ NEXT_PUBLIC_API_URL="http://localhost:3000"
139
+ `;
140
+ await fs.writeFile(path.join(targetDir, '.env.example'), envExample);
141
+
142
+ // 8. Generate .cursorrules for AI IDE integration
143
+ const cursorrules = `# Agent Rules for ${projectName}
144
+
145
+ ## Architecture
146
+ - **Frontend**: Next.js App Router (React Server Components)
147
+ - **API**: Hono RPC with end-to-end type safety
148
+ - **Database**: Drizzle ORM + PostgreSQL
149
+ - **Validation**: Zod schemas for all inputs
150
+
151
+ ## Critical Rules
152
+ 1. **Verify Before Commit**: Always run \`npm run check\` before committing. Never commit failing code.
153
+ 2. **Strict Typing**: Never use \`any\`. Use Zod for all validations.
154
+ 3. **Twin-Files**: If you create a new directory, create a \`CONCEPTS.md\` explaining its business logic and boundaries.
155
+ 4. **Architecture Limits**:
156
+ - Do not import UI components into the API layer
157
+ - Do not import Drizzle directly into Next.js React UI layer
158
+ - Use the Hono RPC client (\`hc\`) for all frontend-to-backend communication
159
+ 5. **Think First**: Before making massive destructive changes, write your plan in \`.agent/scratchpad.md\`
160
+
161
+ ## Directory Structure
162
+ - \`src/app/\` - Next.js routing and React UI pages (read \`src/app/CONCEPTS.md\`)
163
+ - \`src/server/\` - Hono API backend and RPC routes (read \`src/server/CONCEPTS.md\`)
164
+ - \`src/db/\` - Drizzle schema operations (read \`src/db/CONCEPTS.md\`)
165
+ - \`server/mcp/\` - Model Context Protocol stubs for agent querying
166
+ - \`.agent/\` - Agent control plane (rules, project map, scratchpad)
167
+
168
+ ## Workflow
169
+ 1. Read the relevant \`CONCEPTS.md\` file before modifying a directory
170
+ 2. Use \`npm run db:studio\` to visualize the database schema
171
+ 3. Run \`npm run check\` to verify TypeScript compilation
172
+ 4. Check \`.agent/scratchpad.md\` for any ongoing work or notes
173
+ `;
174
+ await fs.writeFile(path.join(targetDir, '.cursorrules'), cursorrules);
175
+
176
+ // 9. Generate README.md
177
+ const readme = `# ${projectName}
178
+
179
+ > Agent-Native Next.js boilerplate generated with [create-nexus](https://github.com/dinakars777/create-nexus)
180
+
181
+ ## Stack
182
+
183
+ - **Frontend**: Next.js 14 (App Router)
184
+ - **API**: Hono RPC (end-to-end type safety)
185
+ - **Database**: Drizzle ORM + PostgreSQL
186
+ - **Validation**: Zod
187
+ - **AI Integration**: Built-in \`.agent/\` control plane + MCP server
188
+
189
+ ## Getting Started
190
+
191
+ 1. **Install dependencies**:
192
+ \`\`\`bash
193
+ npm install
194
+ \`\`\`
195
+
196
+ 2. **Set up environment variables**:
197
+ \`\`\`bash
198
+ cp .env.example .env
199
+ # Edit .env with your DATABASE_URL
200
+ \`\`\`
201
+
202
+ 3. **Push database schema**:
203
+ \`\`\`bash
204
+ npm run db:push
205
+ \`\`\`
206
+
207
+ 4. **Start development server**:
208
+ \`\`\`bash
209
+ npm run dev
210
+ \`\`\`
211
+
212
+ 5. **Open Drizzle Studio** (optional):
213
+ \`\`\`bash
214
+ npm run db:studio
215
+ \`\`\`
216
+
217
+ ## Architecture
218
+
219
+ This project follows the **Agent-Native Architecture** pattern:
220
+
221
+ ### The \`.agent/\` Control Plane
222
+ - \`rules.md\` - Global rules for AI agents working on this codebase
223
+ - \`project-map.json\` - High-level architecture overview
224
+ - \`scratchpad.md\` - Temporary workspace for planning complex changes
225
+
226
+ ### The Twin-File System
227
+ Each major directory contains a \`CONCEPTS.md\` file that defines:
228
+ - Business logic boundaries
229
+ - What the directory is responsible for
230
+ - What it should NOT do
231
+
232
+ This prevents AI agents from hallucinating incorrect architectures.
233
+
234
+ ### Directory Structure
235
+
236
+ \`\`\`
237
+ ${projectName}/
238
+ ├── .agent/ # Agent control plane
239
+ ├── src/
240
+ │ ├── app/ # Next.js pages (read CONCEPTS.md)
241
+ │ ├── server/ # Hono API routes (read CONCEPTS.md)
242
+ │ └── db/ # Drizzle schema (read CONCEPTS.md)
243
+ ├── server/
244
+ │ └── mcp/ # Model Context Protocol server
245
+ ├── .cursorrules # AI IDE integration (Cursor, Cline)
246
+ └── .husky/ # Git hooks (pre-commit type checking)
247
+ \`\`\`
248
+
249
+ ## Available Scripts
250
+
251
+ - \`npm run dev\` - Start Next.js development server
252
+ - \`npm run build\` - Build for production
253
+ - \`npm run start\` - Start production server
254
+ - \`npm run check\` - Run TypeScript type checking
255
+ - \`npm run db:push\` - Push schema changes to database
256
+ - \`npm run db:studio\` - Open Drizzle Studio (database GUI)
257
+
258
+ ## Working with AI Agents
259
+
260
+ This project is optimized for AI coding agents (Cursor, Cline, Claude, etc.):
261
+
262
+ 1. **Read \`.cursorrules\`** - Contains all architectural rules
263
+ 2. **Check \`CONCEPTS.md\`** - Before modifying any directory
264
+ 3. **Use \`.agent/scratchpad.md\`** - For planning complex changes
265
+ 4. **Run \`npm run check\`** - Before committing (enforced by Husky)
266
+
267
+ ## License
268
+
269
+ MIT
270
+ `;
271
+ await fs.writeFile(path.join(targetDir, 'README.md'), readme);
132
272
 
133
273
  }