codebase-ai 0.1.0 → 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.
@@ -67,7 +67,7 @@ Follow the complete `/vb-review` workflow across all phases:
67
67
 
68
68
  - **Phase 0** — Scope (`--pr N` or full codebase)
69
69
  - **Phase 1** — Security Review (OWASP top 10, CVEs, secrets, auth/authz)
70
- - **Phase 2** — Quality Review (CLAUDE.md conventions, dead code, lint, complexity)
70
+ - **Phase 2** — Quality Review (CLAUDE.md conventions, dead code, lint, complexity, defensive programming, minimal code)
71
71
  - **Phase 3** — Dependency Health (outdated, vulnerable, alternatives)
72
72
  - **Phase 4** — UI/Accessibility (contrast, ARIA, keyboard, responsive)
73
73
  - **Phase 5** — Consolidate & prioritize
@@ -147,4 +147,60 @@ Auto-fix: [yes | no]
147
147
  ════════════════════════════════════════════════════════
148
148
  ```
149
149
 
150
- All other behavior (security agent prompts, quality rules, CVE research, accessibility checks, test generation) follows the `/vb-review` specification exactly.
150
+ All other behavior (security agent prompts, CVE research, accessibility checks, test generation) follows the `/vb-review` specification exactly.
151
+
152
+ ---
153
+
154
+ ## Phase 2 — Quality Review (Extended Rules)
155
+
156
+ The quality agent must check the following **in addition** to the base `/vb-review` quality rules.
157
+
158
+ ### Defensive Programming
159
+
160
+ Check every function, method, and handler for:
161
+
162
+ - **Missing guard clauses** — function body has deep nesting where an early return/throw would flatten it. Flag any function with 3+ levels of nesting that could use guard clauses.
163
+ - **Missing input validation at boundaries** — functions that accept external input (API params, user input, env vars, CLI args, file reads) without validating type, range, or presence before use.
164
+ - **Unchecked null/undefined** — property access on values that could be null/undefined without a prior check (e.g. `user.name` where `user` could be null).
165
+ - **Silent failures** — empty `catch` blocks, `.catch(() => {})`, swallowed errors with no logging or rethrow. Every error boundary must either handle, log, or rethrow.
166
+ - **Missing error handling at I/O boundaries** — file reads, network calls, subprocess exec, DB queries with no error handling.
167
+ - **Optimistic assumptions** — code that assumes an array is non-empty before indexing, assumes a map key exists before accessing, or assumes an async call always resolves.
168
+ - **No fail-fast** — configuration or required env vars read lazily (mid-request) instead of validated at startup, so failures surface late and with poor context.
169
+
170
+ Severity guide:
171
+ - `high` — missing validation on external input, unchecked null on a hot path, silent catch hiding errors
172
+ - `medium` — deep nesting fixable with guard clauses, missing fail-fast for config
173
+ - `low` — optimistic array/map access in low-risk paths
174
+
175
+ ### Minimal Code
176
+
177
+ Check for over-engineering and unnecessary complexity:
178
+
179
+ - **YAGNI violations** — abstractions, interfaces, config options, or generics added for hypothetical future use that have exactly one concrete caller/case today.
180
+ - **Premature abstraction** — a helper/utility/class created for code used in only one place. Three similar lines of code is better than a one-use abstraction.
181
+ - **Over-parameterization** — functions with options objects or boolean flags that only ever receive the same values. Flags that were never flipped from their default since they were added.
182
+ - **Unnecessary indirection** — wrapper functions that do nothing but call another function with the same signature.
183
+ - **Dead feature flags** — flags/toggles that are always `true` or always `false` in all environments; can just be removed.
184
+ - **Backwards-compatibility shims for internal code** — deprecated aliases, re-exports, or `_unused` renames for code that has no external consumers.
185
+ - **Excessive comments explaining obvious code** — comments that restate what the code already says clearly (e.g. `// increment counter` above `count++`). Flag only; do not auto-fix.
186
+ - **Over-engineered error messages** — error classes with elaborate hierarchies for a project that throws 2-3 distinct error types.
187
+
188
+ Severity guide:
189
+ - `medium` — YAGNI abstractions, over-parameterization, unnecessary indirection
190
+ - `low` — dead flags, excessive comments, minor shims
191
+
192
+ ### Code Simplicity Principles
193
+
194
+ - **Flat over nested** — prefer early returns, guard clauses, and linear flow over pyramid/callback-hell structures.
195
+ - **Explicit over clever** — flag code that uses obscure language tricks, complex one-liners, or metaprogramming where a simple loop/condition would be clearer.
196
+ - **Consistent patterns** — same operation done differently in 2+ places (e.g. one place uses `?.` optional chaining, another uses explicit null check for the same pattern). Flag the inconsistency; suggest unifying to the simpler form.
197
+ - **Functions do one thing** — flag functions that mix concerns (e.g. validate + transform + persist in one function body >30 lines with no clear single responsibility).
198
+
199
+ Severity guide:
200
+ - `medium` — mixed concerns in large functions, inconsistent patterns across the codebase
201
+ - `low` — clever one-liners, minor style inconsistencies
202
+
203
+ ### Auto-fixable vs Architectural
204
+
205
+ - **Auto-fixable (`--fix`)**: guard clause refactors (simple cases), removing empty catch blocks (replace with `// TODO: handle error`), removing dead flags set to constant values, removing unused re-exports.
206
+ - **Architectural (create issue, no auto-fix)**: adding input validation that requires schema/type decisions, restructuring mixed-concern functions, replacing premature abstractions (requires understanding callers).
package/commands/setup.md CHANGED
@@ -171,10 +171,65 @@ Mark genuinely unknown sections with `[INFERRED: ...]`.
171
171
 
172
172
  **Never hardcode example industries, roles, or countries** — infer from codebase or ask the user.
173
173
 
174
- Commit:
174
+ ---
175
+
176
+ ## Step 7 — CLAUDE.md
177
+
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.
179
+
180
+ **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
+
182
+ **If `CLAUDE.md` does not exist:** generate it from scratch.
183
+
184
+ The file must include these sections, tailored to the actual project:
185
+
186
+ ### Project Overview
187
+ One paragraph describing what the project does, who it's for, and its current state (alpha/beta/production).
188
+
189
+ ### Build & Development Commands
190
+ Exact commands from `.codebase.json` → `commands.*`. Include build, dev, test, lint, typecheck.
191
+
192
+ ### Architecture
193
+ How the codebase is structured — key directories, entry points, data flow. Infer from `structure`, `patterns`, and file scanning. Be specific, not generic.
194
+
195
+ ### Key Conventions
196
+ 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").
197
+
198
+ ### Current Status
199
+ From `.codebase.json` → `status`: open issues count, any blockers, active milestone. One short paragraph.
200
+
201
+ ### Vibekit Workflow
202
+ Always include this verbatim at the end (before the codebase injection block):
203
+
204
+ ```markdown
205
+ ## Vibekit Workflow
206
+
207
+ ```
208
+ /simulate → /build → /launch
209
+ ```
210
+
211
+ - `/simulate` — Playwright customer journeys find & fix bugs inline. Creates GitHub issues for arch problems.
212
+ - `/build` — Implements architectural issues autonomously. Runs until all `arch`+`vibekit` issues are closed.
213
+ - `/launch` — Gates on open bugs, generates GTM artifacts, creates GitHub release, merges to main.
214
+
215
+ ### Browser Automation (agent-browser)
216
+
217
+ Commands: `open <url>`, `snapshot -i` (→ `@e1`/`@e2` refs), `click @e1`, `fill @e2 "text"`, `screenshot`, `auth save/login <profile>`, `state save/load <name>`.
218
+ ```
219
+
220
+ After writing CLAUDE.md, re-run the codebase injection to ensure the context block is up to date:
221
+
222
+ ```bash
223
+ npx codebase init --quiet 2>/dev/null || true
224
+ ```
225
+
226
+ ---
227
+
228
+ ## Step 8 — Commit
229
+
175
230
  ```bash
176
231
  git checkout develop 2>/dev/null || git checkout -b develop
177
- git add docs/PRODUCT.md .vibekit/ .gitignore 2>/dev/null || true
232
+ git add docs/PRODUCT.md CLAUDE.md .vibekit/ .gitignore 2>/dev/null || true
178
233
  git diff --cached --quiet || git commit -m "chore: bootstrap codebase + vibekit setup
179
234
 
180
235
  Initialized by /setup"
@@ -182,7 +237,7 @@ Initialized by /setup"
182
237
 
183
238
  ---
184
239
 
185
- ## Step 7 — Summary
240
+ ## Step 9 — Summary
186
241
 
187
242
  ```
188
243
  /setup COMPLETE
@@ -192,6 +247,7 @@ GitHub labels: 13 ready
192
247
  Milestone: v0.1 (#N)
193
248
  Highlights Index: #N
194
249
  docs/PRODUCT.md: [generated | updated]
250
+ CLAUDE.md: [generated | updated]
195
251
  Branch: develop
196
252
  Claude hooks: git-guard + git-post active
197
253
 
package/dist/index.js CHANGED
@@ -174,6 +174,17 @@ Returns: project identity, tech stack, commands, structure, current status, next
174
174
  - **Check \`next\` before starting work** \u2014 don't duplicate in-progress tasks
175
175
  - **Create issues for bugs/TODOs you find** \u2014 keep the project brain alive
176
176
  - **Close issues when you fix them** \u2014 with a reason so the team knows why
177
+
178
+ ### Vibekit Workflow
179
+ \`\`\`
180
+ /simulate \u2192 /build \u2192 /launch
181
+ \`\`\`
182
+ - \`/simulate\` \u2014 Playwright customer journeys find & fix bugs inline. Creates GitHub issues for arch problems.
183
+ - \`/build\` \u2014 Implements architectural issues autonomously. Runs until all \`arch\`+\`vibekit\` issues are closed.
184
+ - \`/launch\` \u2014 Gates on open bugs, generates GTM artifacts, creates GitHub release, merges to main.
185
+
186
+ ### Browser Automation (agent-browser)
187
+ Commands: \`open <url>\`, \`snapshot -i\` (\u2192 \`@e1\`/\`@e2\` refs), \`click @e1\`, \`fill @e2 "text"\`, \`screenshot\`, \`auth save/login <profile>\`, \`state save/load <name>\`.
177
188
  ${ie}`}function bs(e,t){return rt(Le(e,t))}function ys(e,t){let s=Le(e,t),n=rt(s)?ot(s,"utf-8"):"";if(n.includes(be)){let i=n.indexOf(be),o=n.indexOf(ie);i!==-1&&o!==-1&&(n=n.slice(0,i)+n.slice(o+ie.length),n=n.replace(/\n{3,}/g,`
178
189
 
179
190
  `).trimEnd())}hs(s,n.trimEnd()+`
@@ -208,6 +219,17 @@ Returns: project identity, tech stack, commands, structure, current status, next
208
219
  - **Check \`next\` before starting work** \u2014 don't duplicate in-progress tasks
209
220
  - **Create issues for bugs/TODOs you find** \u2014 keep the project brain alive
210
221
  - **Close issues when you fix them** \u2014 with a reason so the team knows why
222
+
223
+ ### Vibekit Workflow
224
+ \`\`\`
225
+ /simulate \u2192 /build \u2192 /launch
226
+ \`\`\`
227
+ - \`/simulate\` \u2014 Playwright customer journeys find & fix bugs inline. Creates GitHub issues for arch problems.
228
+ - \`/build\` \u2014 Implements architectural issues autonomously. Runs until all \`arch\`+\`vibekit\` issues are closed.
229
+ - \`/launch\` \u2014 Gates on open bugs, generates GTM artifacts, creates GitHub release, merges to main.
230
+
231
+ ### Browser Automation (agent-browser)
232
+ Commands: \`open <url>\`, \`snapshot -i\` (\u2192 \`@e1\`/\`@e2\` refs), \`click @e1\`, \`fill @e2 "text"\`, \`screenshot\`, \`auth save/login <profile>\`, \`state save/load <name>\`.
211
233
  ${ie}`,ac=`
212
234
  ${fo}
213
235
  # Project Context (auto-generated by codebase)
@@ -258,7 +280,7 @@ ${s}
258
280
  ${ke}
259
281
  ${s}
260
282
  `,"utf-8");Cs(i,493)}var ke,js,He=$(()=>{"use strict";ke="# codebase-auto-update";js="# codebase-pre-commit"});var dt={};yt(dt,{installClaudeCommandsForFix:()=>Eo,installClaudeHooksForFix:()=>So,runSetup:()=>ut});import{resolve as xo,dirname as $o,join as A}from"path";import{writeFileSync as Q,existsSync as J,mkdirSync as Ge,readFileSync as ue,chmodSync as lt,readdirSync as Co,copyFileSync as Es}from"fs";import{execFile as le}from"child_process";async function ut(e){let t=xo(e.path);await Me({...e,sync:!0}),j("Claude Code Integration"),J(A(t,"CLAUDE.md"))||Q(A(t,"CLAUDE.md"),`# Project Rules
261
- `,"utf-8"),V.inject(t),h("CLAUDE.md - added .codebase.json reference"),j("Git Hooks"),ce(t,!1)?(h("post-commit hook (auto-updates .codebase.json)"),h("pre-commit hook (runs typecheck + lint before every commit)"),Ro(t),h("commit-msg hook (blocks direct commits to main/master)")):y("Not a git repository - skipping hooks"),j("Claude Code Hooks"),Rs(t),j("Browser Automation"),await Po(),j("Claude Commands"),await Do()?Ss(t):(S("Claude Code CLI not detected \u2014 skipping slash commands"),S("Install Claude Code then re-run: codebase setup")),oe(t),_o(t,[".vibekit/daemon.lock",".vibekit/daemon.log",".vibekit/build.lock"]),h(".gitignore updated"),j("Vibekit Bootstrap");let i=A(t,".vibekit");J(i)?y(".vibekit/ already exists"):(Ge(i,{recursive:!0}),h(".vibekit/ directory created")),j("GitHub Labels"),await Oo()?(await Ao(t),await Io(t)):(S("gh CLI not authenticated \u2014 skipping label/issue setup"),S("Run: gh auth login then codebase setup")),j("Product Brief");let r=A(t,"docs");J(r)||Ge(r,{recursive:!0});let a=A(r,"PRODUCT.md");J(a)?y("docs/PRODUCT.md already exists \u2014 skipping (delete to regenerate)"):(No(t,a),h("docs/PRODUCT.md generated \u2014 review and fill in [INFERRED] sections")),l(`
283
+ `,"utf-8"),V.inject(t),h("CLAUDE.md - added .codebase.json reference"),j("Git Hooks"),ce(t,!1)?(h("post-commit hook (auto-updates .codebase.json)"),h("pre-commit hook (runs typecheck + lint before every commit)"),Ro(t),h("commit-msg hook (blocks direct commits to main/master)")):y("Not a git repository - skipping hooks"),j("Claude Code Hooks"),Rs(t),j("Browser Automation"),await Po(),j("Claude Commands"),await Do()?Ss(t):(S("Claude Code CLI not detected \u2014 skipping slash commands"),S("Install Claude Code then re-run: codebase setup")),oe(t),_o(t,[".vibekit/daemon.lock",".vibekit/daemon.log",".vibekit/build.lock",".vibekit/milestone.env",".mcp.json"]),h(".gitignore updated"),j("Vibekit Bootstrap");let i=A(t,".vibekit");J(i)?y(".vibekit/ already exists"):(Ge(i,{recursive:!0}),h(".vibekit/ directory created")),j("GitHub Labels"),await Oo()?(await Ao(t),await Io(t)):(S("gh CLI not authenticated \u2014 skipping label/issue setup"),S("Run: gh auth login then codebase setup")),j("Product Brief");let r=A(t,"docs");J(r)||Ge(r,{recursive:!0});let a=A(r,"PRODUCT.md");J(a)?y("docs/PRODUCT.md already exists \u2014 skipping (delete to regenerate)"):(No(t,a),h("docs/PRODUCT.md generated \u2014 review and fill in [INFERRED] sections")),l(`
262
284
  Done! Your project is wired for AI + autonomous loop.`),l(`
263
285
  1. Review docs/PRODUCT.md and fill in any [INFERRED] sections`),l(" 2. /simulate \u2014 AI customer journeys find & fix bugs"),l(" 3. /build \u2014 implement architectural issues autonomously"),l(" 4. /launch \u2014 gate check, release, merge to main")}function Eo(e){Ss(e)}function Ss(e){let t=A($o(new URL(import.meta.url).pathname),"..","commands");if(!J(t)){S("Claude commands not found in package \u2014 skipping");return}let s=A(e,".claude","commands");Ge(s,{recursive:!0});let n=Co(t).filter(c=>c.endsWith(".md")),i=0,o=0,r=0;for(let c of n){let u=A(t,c),g=A(s,c);if(J(g)){let f=ue(u,"utf-8"),p=ue(g,"utf-8");f!==p?(Es(u,g),o++):r++}else Es(u,g),i++}let a=[];i>0&&a.push(`${i} new`),o>0&&a.push(`${o} updated`),r>0&&a.push(`${r} unchanged`),i>0||o>0?(h(`Claude commands installed \u2192 .claude/commands/ (${a.join(", ")})`),y("Available: /setup /simulate /build /launch /review"),y("Tip: commit .claude/commands/ to share these with your team")):y(`All ${r} Claude commands up to date`)}function So(e){Rs(e)}function Rs(e){let t=A(e,".claude","hooks");Ge(t,{recursive:!0});let s=A(t,"git-guard.sh");Q(s,`#!/bin/bash
264
286
  # codebase git-guard \u2014 PreToolUse hook
@@ -495,7 +517,7 @@ ${v("SEE ALSO")}
495
517
  `:""}${v("MORE HELP")}
496
518
  ${k("codebase --help")} Show all commands
497
519
  ${_e("https://github.com/your-repo/codebase/docs","Full documentation")}
498
- `)}var sa={E_NO_GIT:{message:"Not a git repository",suggestion:"Initialize git first: "+k("git init")},E_NO_PACKAGE_JSON:{message:"No package.json found",suggestion:"Initialize project: "+k("npm init")+" or "+k("pnpm init")},E_GH_NOT_AUTHENTICATED:{message:"GitHub CLI not authenticated",suggestion:"Run: "+k("gh auth login")},E_MANIFEST_NOT_FOUND:{message:".codebase.json not found",suggestion:"Run: "+k("codebase init")+" to generate it"},E_INVALID_PATH:{message:"Invalid directory path",suggestion:"Use absolute path or path relative to current directory"},E_PERMISSION_DENIED:{message:"Permission denied",suggestion:"Check file permissions or run with appropriate access"}};var rn={command:"scan",subcommand:"",positionals:[],path:process.cwd(),format:"text",depth:4,categories:[],incremental:!1,quiet:!1,raw:!1,verbose:!1,port:7432,tools:[],dryRun:!1,since:"",sync:!1,message:"",reason:"",examples:!1,helpCommand:!1},xt=new Set(["scan","setup","query","mcp","issue","status","init","scan-only","brief","next","doctor","fix","release"]);function $t(e){let t={...rn},s=[];for(let n=0;n<e.length;n++){let i=e[n];if(!i.startsWith("-")&&xt.has(i)){if(t.command=i,e[n+1]==="--help"||e[n+1]==="-h")return t.helpCommand=!0,t;break}}for(let n=0;n<e.length;n++){let i=e[n];if((i==="--help"||i==="-h")&&!t.command&&(vt(),process.exit(0)),(i==="--version"||i==="-v")&&(console.log("codebase 0.1.0"),process.exit(0)),i.startsWith("--")){let o=i.slice(2);if(o==="quiet"||o==="q"){t.quiet=!0;continue}if(o==="raw"){t.raw=!0;continue}if(o==="verbose"||o==="V"){t.verbose=!0;continue}if(o==="incremental"){t.incremental=!0;continue}if(o==="dry-run"){t.dryRun=!0;continue}if(o==="sync"){t.sync=!0;continue}if(o==="examples"){t.examples=!0;continue}if(o==="mine"){s.push("mine");continue}let r=e[n+1];if(!r||r.startsWith("--"))continue;n++,o==="path"?t.path=r:o==="format"?t.format=r:o==="depth"?t.depth=parseInt(r,10)||4:o==="categories"?t.categories=r.split(",").map(a=>a.trim()):o==="port"?t.port=parseInt(r,10)||7432:o==="tools"?t.tools=r.split(",").map(a=>a.trim()):o==="since"?t.since=r:o==="message"||o==="m"?t.message=r:o==="reason"&&(t.reason=r);continue}s.push(i)}if(s.length>0&&xt.has(s[0])&&(t.command=s.shift()),s.length>0){let n=s[0];["install","uninstall","create","close","comment","list","map"].includes(n)&&(t.subcommand=s.shift())}return t.positionals=s,s.length>0&&/^[\/\.~]/.test(s[0])&&(t.path=s[0]),process.env.CODEBASE_OUTPUT&&(t.path=process.env.CODEBASE_OUTPUT),process.env.CODEBASE_PORT&&(t.port=parseInt(process.env.CODEBASE_PORT,10)||7432),process.env.CODEBASE_DEPTH&&(t.depth=parseInt(process.env.CODEBASE_DEPTH,10)||4),process.env.CODEBASE_QUIET==="true"&&(t.quiet=!0),t}function Ct(e){jt(e),process.exit(0)}I();it();Ue();he();import{resolve as qo,join as Je}from"path";import{existsSync as Ds,writeFileSync as Os,readFileSync as Mo}from"fs";import{execFile as Ps}from"child_process";import{writeFile as Lo}from"fs/promises";import{homedir as To}from"os";ye();var Fo=[V];function _s(e){return Fo.filter(t=>t.detect(e))}ye();Te();He();I();async function pt(e){U(e.quiet);let t=qo(e.path);j(`codebase \u2014 activating project intelligence
520
+ `)}var sa={E_NO_GIT:{message:"Not a git repository",suggestion:"Initialize git first: "+k("git init")},E_NO_PACKAGE_JSON:{message:"No package.json found",suggestion:"Initialize project: "+k("npm init")+" or "+k("pnpm init")},E_GH_NOT_AUTHENTICATED:{message:"GitHub CLI not authenticated",suggestion:"Run: "+k("gh auth login")},E_MANIFEST_NOT_FOUND:{message:".codebase.json not found",suggestion:"Run: "+k("codebase init")+" to generate it"},E_INVALID_PATH:{message:"Invalid directory path",suggestion:"Use absolute path or path relative to current directory"},E_PERMISSION_DENIED:{message:"Permission denied",suggestion:"Check file permissions or run with appropriate access"}};var rn={command:"scan",subcommand:"",positionals:[],path:process.cwd(),format:"text",depth:4,categories:[],incremental:!1,quiet:!1,raw:!1,verbose:!1,port:7432,tools:[],dryRun:!1,since:"",sync:!1,message:"",reason:"",examples:!1,helpCommand:!1},xt=new Set(["scan","setup","query","mcp","issue","status","init","scan-only","brief","next","doctor","fix","release"]);function $t(e){let t={...rn},s=[];for(let n=0;n<e.length;n++){let i=e[n];if(!i.startsWith("-")&&xt.has(i)){if(t.command=i,e[n+1]==="--help"||e[n+1]==="-h")return t.helpCommand=!0,t;break}}for(let n=0;n<e.length;n++){let i=e[n];if((i==="--help"||i==="-h")&&!t.command&&(vt(),process.exit(0)),(i==="--version"||i==="-v")&&(console.log("codebase 0.1.2"),process.exit(0)),i.startsWith("--")){let o=i.slice(2);if(o==="quiet"||o==="q"){t.quiet=!0;continue}if(o==="raw"){t.raw=!0;continue}if(o==="verbose"||o==="V"){t.verbose=!0;continue}if(o==="incremental"){t.incremental=!0;continue}if(o==="dry-run"){t.dryRun=!0;continue}if(o==="sync"){t.sync=!0;continue}if(o==="examples"){t.examples=!0;continue}if(o==="mine"){s.push("mine");continue}let r=e[n+1];if(!r||r.startsWith("--"))continue;n++,o==="path"?t.path=r:o==="format"?t.format=r:o==="depth"?t.depth=parseInt(r,10)||4:o==="categories"?t.categories=r.split(",").map(a=>a.trim()):o==="port"?t.port=parseInt(r,10)||7432:o==="tools"?t.tools=r.split(",").map(a=>a.trim()):o==="since"?t.since=r:o==="message"||o==="m"?t.message=r:o==="reason"&&(t.reason=r);continue}s.push(i)}if(s.length>0&&xt.has(s[0])&&(t.command=s.shift()),s.length>0){let n=s[0];["install","uninstall","create","close","comment","list","map"].includes(n)&&(t.subcommand=s.shift())}return t.positionals=s,s.length>0&&/^[\/\.~]/.test(s[0])&&(t.path=s[0]),process.env.CODEBASE_OUTPUT&&(t.path=process.env.CODEBASE_OUTPUT),process.env.CODEBASE_PORT&&(t.port=parseInt(process.env.CODEBASE_PORT,10)||7432),process.env.CODEBASE_DEPTH&&(t.depth=parseInt(process.env.CODEBASE_DEPTH,10)||4),process.env.CODEBASE_QUIET==="true"&&(t.quiet=!0),t}function Ct(e){jt(e),process.exit(0)}I();it();Ue();he();import{resolve as qo,join as Je}from"path";import{existsSync as Ds,writeFileSync as Os,readFileSync as Mo}from"fs";import{execFile as Ps}from"child_process";import{writeFile as Lo}from"fs/promises";import{homedir as To}from"os";ye();var Fo=[V];function _s(e){return Fo.filter(t=>t.detect(e))}ye();Te();He();I();async function pt(e){U(e.quiet);let t=qo(e.path);j(`codebase \u2014 activating project intelligence
499
521
  `);let s=await ve();s==="authenticated"?h("GitHub CLI \u2014 authenticated"):s==="not-authenticated"?(S("GitHub CLI installed but not logged in"),y("Run: gh auth login"),y("After login, re-run `npx codebase` for full GitHub integration\n")):(y("GitHub CLI not found \u2014 GitHub features disabled"),y(`To enable: brew install gh && gh auth login
500
522
  `));let n=s==="authenticated";l(`Scanning ${t}...`);let i=await z(t,{depth:e.depth,categories:e.categories.length?e.categories:void 0,quiet:e.quiet,sync:n});for(let[d,m]of Object.entries(i))d==="version"||d==="generated_at"||typeof m!="object"||m===null||h(`${Ho(d)} (${qe(d,m)})`);let o=Je(t,".codebase.json"),r=JSON.stringify(i,null,2);await Lo(o,r,"utf-8");let a=(Buffer.byteLength(r)/1024).toFixed(1);l(`
501
523
  Written: .codebase.json (${a} KB)`),j("AI Tool Integration");let c=_s(t),u=Go(),g=new Set(c.map(d=>d.name));for(let d of u)g.has(d.name)||(c.push(d),g.add(d.name));c.length===0?(y("No AI tool detected in project or system configs"),y("Creating CLAUDE.md as default (works with Claude Code, and readable by all tools)"),Os(Je(t,"CLAUDE.md"),`# Project Rules
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-ai",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "One command. Every AI tool understands your project instantly.",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/ZySec-AI/codebase",