codebase-ai 0.2.0 → 0.3.1

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
@@ -99,7 +99,7 @@ One command. Zero manual steps.
99
99
 
100
100
  ### Level 1 — Give Claude memory of your project
101
101
 
102
- Only requires Node.js 18+.
102
+ Only requires Node.js 20+.
103
103
 
104
104
  ```bash
105
105
  cd your-project
@@ -241,8 +241,11 @@ codebase fix # auto-repairs everything doctor flags
241
241
 
242
242
  ```bash
243
243
  # Setup
244
- npx codebase # full setup run once per project
245
- codebase setup # re-run wiring (updates commands, hooks, tools)
244
+ # Use `npx codebase` / `codebase init` the first time: scans your project AND wires AI tools + hooks.
245
+ # Use `codebase setup` to re-wire AI tools and hooks only — it does NOT re-scan. Run it when you
246
+ # add a new AI tool or need to reinstall hooks on an existing project.
247
+ npx codebase # full setup — scan + wire AI tools + hooks (run once per project)
248
+ codebase setup # re-wire AI tools and hooks only (no scan)
246
249
 
247
250
  # AI interface (what AI tools call)
248
251
  codebase brief # full project briefing
@@ -300,7 +303,7 @@ npx codebase-ai # try without installing
300
303
  pnpm add -g codebase-ai
301
304
  ```
302
305
 
303
- Zero runtime dependencies. Node.js 18+ only.
306
+ Zero runtime dependencies. Node.js 20+ only.
304
307
 
305
308
  ---
306
309
 
package/commands/setup.md CHANGED
@@ -73,6 +73,120 @@ Print: `codebase manifest: generated`
73
73
 
74
74
  ---
75
75
 
76
+ ## Step 2b — Project Structure Standardisation
77
+
78
+ Scaffold the standard project structure. **Never overwrite existing files or directories.**
79
+
80
+ For each path, only create if it does not already exist:
81
+
82
+ ```bash
83
+ # Directories
84
+ mkdir -p docs src/core src/modules src/interfaces tests scripts
85
+
86
+ # README.md — only if missing
87
+ [ -f README.md ] || cat > README.md << 'EOF'
88
+ # [Project Name]
89
+
90
+ [What this project does — 1-2 sentences.]
91
+
92
+ ## Getting Started
93
+
94
+ ```bash
95
+ # install dependencies
96
+ # run the project
97
+ ```
98
+
99
+ ## Development
100
+
101
+ ```bash
102
+ # build
103
+ # test
104
+ # lint
105
+ ```
106
+ EOF
107
+
108
+ # .env.example — only if missing and no .env exists
109
+ [ -f .env.example ] || [ -f .env ] || cat > .env.example << 'EOF'
110
+ # Required environment variables
111
+ # Copy to .env and fill in values
112
+
113
+ # APP_PORT=3000
114
+ # DATABASE_URL=
115
+ # SECRET_KEY=
116
+ EOF
117
+
118
+ # docs/ARCHITECTURE.md — only if missing
119
+ [ -f docs/ARCHITECTURE.md ] || cat > docs/ARCHITECTURE.md << 'EOF'
120
+ # Architecture
121
+
122
+ ## System Overview
123
+
124
+ [High-level description of how the system works.]
125
+
126
+ ## Key Components
127
+
128
+ | Component | Purpose |
129
+ |---|---|
130
+ | `src/core/` | Business logic |
131
+ | `src/modules/` | Feature modules |
132
+ | `src/interfaces/` | Contracts, APIs, types |
133
+
134
+ ## Data Flow
135
+
136
+ [Describe the main request/data flow through the system.]
137
+
138
+ ## Key Design Decisions
139
+
140
+ [Document architectural decisions and their rationale here.]
141
+ EOF
142
+
143
+ # docs/IMPLEMENTATION.md — only if missing
144
+ [ -f docs/IMPLEMENTATION.md ] || cat > docs/IMPLEMENTATION.md << 'EOF'
145
+ # Implementation Guide
146
+
147
+ ## Code Organisation
148
+
149
+ [How the source code is structured and why.]
150
+
151
+ ## Patterns & Conventions
152
+
153
+ [Coding patterns, naming conventions, module rules.]
154
+
155
+ ## Adding Features
156
+
157
+ [Step-by-step guide for contributing new functionality.]
158
+
159
+ ## Common Tasks
160
+
161
+ [Runbook for frequent development tasks.]
162
+ EOF
163
+ ```
164
+
165
+ Print a structure report:
166
+ ```
167
+ PROJECT STRUCTURE
168
+ ══════════════════════════════════════
169
+ docs/ [created | exists]
170
+ ARCHITECTURE.md [created | exists]
171
+ IMPLEMENTATION.md [created | exists]
172
+ PRODUCT.md [pending — Step 6]
173
+ src/core/ [created | exists]
174
+ src/modules/ [created | exists]
175
+ src/interfaces/ [created | exists]
176
+ tests/ [created | exists]
177
+ scripts/ [created | exists]
178
+ README.md [created | exists]
179
+ .env.example [created | exists | skipped — .env present]
180
+ ══════════════════════════════════════
181
+ ```
182
+
183
+ **Rules:**
184
+ - Never delete or overwrite anything that already exists
185
+ - If the project has a non-standard structure (e.g. `app/` instead of `src/`), adapt the report but do not force-rename existing dirs
186
+ - Add any newly created paths to the Step 8 commit
187
+
188
+ ---
189
+
76
190
  ## Step 3 — GitHub labels
77
191
 
78
192
  ```bash
@@ -150,7 +264,7 @@ fi
150
264
 
151
265
  ---
152
266
 
153
- ## Step 6 — PRODUCT.md
267
+ ## Step 6 — Docs (PRODUCT.md, ARCHITECTURE.md, IMPLEMENTATION.md)
154
268
 
155
269
  Use `codebase brief` as the primary source of project intelligence:
156
270
 
@@ -160,7 +274,7 @@ npx codebase brief 2>/dev/null > /tmp/cb-brief.json || true
160
274
 
161
275
  Read the brief. If `docs/PRODUCT.md` exists and `--refresh` not passed: show diff of stale sections, ask user to confirm updates.
162
276
 
163
- Otherwise generate `docs/PRODUCT.md` from:
277
+ Otherwise generate `docs/PRODUCT.md` from (note: filename is all-caps `PRODUCT.md`):
164
278
  - `project.name`, `project.description` → Summary
165
279
  - `stack.languages`, `stack.frameworks`, `commands.*` → Tech Stack (auto-filled)
166
280
  - `patterns.architecture`, `patterns.api_style` → Context
@@ -173,9 +287,9 @@ Mark genuinely unknown sections with `[INFERRED: ...]`.
173
287
 
174
288
  ---
175
289
 
176
- ## Step 7 — CLAUDE.md
290
+ ## Step 7 — CLAUDE.md (last — reads everything set up above)
177
291
 
178
- Write (or update) `CLAUDE.md` for this specific project. Read `.codebase.json` and the codebase structure to produce a file that is genuinely useful to an AI starting a fresh session on this project.
292
+ Write (or update) `CLAUDE.md` for this specific project. At this point all other setup steps are complete — read `.codebase.json`, `docs/PRODUCT.md`, `docs/ARCHITECTURE.md`, `docs/IMPLEMENTATION.md`, and the full project structure before writing, so CLAUDE.md accurately reflects the final state of the project.
179
293
 
180
294
  **If `CLAUDE.md` already exists:** read it first. Preserve any existing sections. Only update the `<!-- codebase:start -->...<!-- codebase:end -->` block and add missing sections without removing human-authored content.
181
295
 
@@ -190,7 +304,7 @@ One paragraph describing what the project does, who it's for, and its current st
190
304
  Exact commands from `.codebase.json` → `commands.*`. Include build, dev, test, lint, typecheck.
191
305
 
192
306
  ### Architecture
193
- How the codebase is structured — key directories, entry points, data flow. Infer from `structure`, `patterns`, and file scanning. Be specific, not generic.
307
+ How the codebase is structured — key directories, entry points, data flow. Pull from `docs/ARCHITECTURE.md` if it was populated, otherwise infer from `structure`, `patterns`, and file scanning. Be specific, not generic.
194
308
 
195
309
  ### Key Conventions
196
310
  Language/framework conventions detected. Coding patterns observed. Things an AI must know to not break the codebase (e.g. "zero runtime dependencies", "no cross-module state", "all DB calls go through /lib/db").
@@ -229,7 +343,7 @@ npx codebase init --quiet 2>/dev/null || true
229
343
 
230
344
  ```bash
231
345
  git checkout develop 2>/dev/null || git checkout -b develop
232
- git add docs/PRODUCT.md CLAUDE.md .vibekit/ .gitignore 2>/dev/null || true
346
+ git add docs/PRODUCT.md docs/ARCHITECTURE.md docs/IMPLEMENTATION.md CLAUDE.md README.md .env.example .vibekit/ .gitignore src/ tests/ scripts/ 2>/dev/null || true
233
347
  git diff --cached --quiet || git commit -m "chore: bootstrap codebase + vibekit setup
234
348
 
235
349
  Initialized by /setup"