codebase-ai 0.3.2 → 0.3.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 ZySec-AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,215 +1,156 @@
1
- # CodeBase
1
+ <p align="center">
2
+ <img src="assets/logo.svg" alt="codebase" width="800"/>
3
+ </p>
2
4
 
3
5
  <p align="center">
4
6
  <img src="https://img.shields.io/npm/v/codebase-ai" alt="npm version" />
5
7
  <img src="https://img.shields.io/npm/dm/codebase-ai" alt="npm downloads" />
6
8
  <img src="https://img.shields.io/github/license/ZySec-AI/codebase" alt="license" />
7
9
  <a href="https://github.com/ZySec-AI/codebase/stargazers"><img src="https://img.shields.io/github/stars/ZySec-AI/codebase?style=social" alt="GitHub stars"></a>
8
- </p>
9
-
10
- <p align="center">
11
- <b>One command. Your AI understands your project, finds bugs, fixes them, and ships.</b>
10
+ <a href="https://github.com/ZySec-AI/codebase/actions/workflows/ci.yml"><img src="https://github.com/ZySec-AI/codebase/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
11
+ <a href="https://securityscorecards.dev/viewer/?uri=github.com/ZySec-AI/codebase"><img src="https://api.securityscorecards.dev/projects/github.com/ZySec-AI/codebase/badge" alt="OpenSSF Scorecard" /></a>
12
12
  </p>
13
13
 
14
14
  ---
15
15
 
16
- ## The idea in plain English
17
-
18
- Imagine hiring an engineer who reads your entire project in seconds and works through your bug list on demand. That's what `codebase` does — it gives AI the context and the tools to work *on* your project, not just *for* you.
19
-
20
- **Without codebase:** Every time you open Claude Code, it starts from zero. You re-explain your project, paste in files, describe what's broken. You're the coordinator. Claude is the cursor.
21
-
22
- **With codebase:** Claude reads a single compact file that captures everything about your project — your stack, your commands, your open issues. It knows where things are. It knows what needs doing. It can act.
23
-
24
- **Two things happen:**
25
-
26
- **1 — Claude gets permanent memory of your project**
27
- One command scans your project and writes a small snapshot file (`.codebase.json`). Claude reads this automatically on every session via `CLAUDE.md`. You never re-explain your project again.
28
-
29
- **2 — AI gets the ability to act**
30
- Seven slash commands give AI a complete workflow: simulate real users in a browser, work through your bug backlog, run tests, commit fixes, and ship releases. Not prompts — real, repeatable actions.
16
+ > **~95% fewer tokens.** Claude reads one 500-token snapshot instead of exploring thousands of files. Instant context, every session.
31
17
 
32
18
  ---
33
19
 
34
- ## The three commands that matter
35
-
36
- Once set up, your entire development loop is:
20
+ ## Install
37
21
 
22
+ ```bash
23
+ npm install -g codebase-ai
38
24
  ```
39
- /simulate → /build → /launch
40
- ```
41
-
42
- That's it. Here's what each one actually does:
43
25
 
44
- ---
45
-
46
- ### `/simulate` — AI becomes your user
26
+ Then in your project:
47
27
 
48
- Claude opens your app in a real browser (agent-browser) and acts like a real customer. It tries to sign up, log in, complete purchases, hit edge cases. When something breaks or feels wrong, it:
28
+ ```bash
29
+ npx codebase-ai
30
+ ```
49
31
 
50
- 1. Fixes the bug directly in your code
51
- 2. Commits the fix with a proper message
52
- 3. Opens a GitHub Issue if the bug is too complex to fix inline
53
- 4. Records UX problems (confusing copy, broken flows, accessibility issues) as issues
32
+ That's it. Every Claude session now starts with instant project context.
54
33
 
55
- After `/simulate`, your repo has real user-found bugs tracked and many already fixed.
34
+ > Requires Node.js 20+. For the autonomous loop, also install [Claude Code](https://www.npmjs.com/package/@anthropic-ai/claude-code) and run `gh auth login`.
56
35
 
57
36
  ---
58
37
 
59
- ### `/build` AI works through your issue backlog
38
+ ## What it does
60
39
 
61
- Claude reads your open GitHub Issues (prioritized by label), picks the most important one, and implements the fix. It:
40
+ `codebase` is a vibecoding loop built around three ideas:
62
41
 
63
- 1. Reads `codebase brief` to understand your project
64
- 2. Picks the top issue labeled `vibekit`, `critical`, `high`, or `bug`
65
- 3. Writes the fix
66
- 4. Runs your test suite
67
- 5. Commits if tests pass — or opens a new issue if it gets stuck
68
- 6. Closes the original issue with a summary of what was done
69
- 7. Moves to the next issue
70
- 8. Repeats until the backlog is clear or you stop it
42
+ - **Codebase = brain.** One scan writes a compact snapshot (`.codebase.json`) your stack, commands, open issues, recent decisions. AI reads this instead of exploring files. ~95% fewer tokens, instant context.
43
+ - **GitHub = memory.** Issues, PRs, and labels are the persistent state. The loop can restart anytime and pick up where it left off.
44
+ - **Claude = execution.** Slash commands give AI a complete workflow: simulate real users, fix bugs, run tests, commit, ship.
71
45
 
72
- This runs in a loop. You can run `/build` once or keep it running until the backlog is clear.
46
+ Multiple developers can jump into the same loop. Commit `.codebase.json` and `.claude/commands/` everyone gets the same context and commands.
73
47
 
74
48
  ---
75
49
 
76
- ### `/launch` — AI ships your release
50
+ ## The loop
77
51
 
78
- Before merging to `main`, Claude checks four quality gates:
52
+ <p align="center">
53
+ <img src="assets/loop.svg" alt="codebase loop animation" width="800"/>
54
+ </p>
55
+
56
+ Or run the entire loop hands-free with one command:
79
57
 
80
- | Gate | What it checks |
81
- |------|---------------|
82
- | **Bugs** | No open critical or high severity issues |
83
- | **Tests** | Your full test suite passes |
84
- | **UX score** | World-class score ≥ 7.0 (from `/simulate` cycles) |
85
- | **Branch** | No uncommitted changes, branch is clean |
58
+ ```
59
+ /vibeloop
60
+ ```
86
61
 
87
- If all gates pass, it:
88
- - Auto-increments your version
89
- - Tags the release
90
- - Merges `develop main` with a proper merge commit
91
- - Creates a GitHub Release with auto-generated release notes
92
- - Rotates the milestone
62
+ | Command | What it does |
63
+ |---------|-------------|
64
+ | `/simulate` | Opens your app in a real browser. Acts like real users. Fixes bugs inline, tracks complex ones as GitHub Issues. |
65
+ | `/build` | Reads open issues, picks the highest priority, implements the fix, tests it, commits, closes the issue. Repeats. |
66
+ | `/launch` | Checks quality gates (open bugs, test suite, UX score). If all pass: bumps version, tags release, merges to main, publishes GitHub Release. |
67
+ | `/vibeloop` | **Runs everything.** Continuous `/simulate → /build → /launch` loop. Zero intervention. |
93
68
 
94
- One command. Zero manual steps.
69
+ First time? Run `/setup` in Claude Code to create `docs/PRODUCT.md` and your first milestone.
95
70
 
96
71
  ---
97
72
 
98
73
  ## Quick start
99
74
 
100
- ### Level 1 — Give Claude memory of your project
101
-
102
- Only requires Node.js 20+.
75
+ **Level 1 — Give Claude memory of your project** (Node.js only)
103
76
 
104
77
  ```bash
105
78
  cd your-project
106
79
  npx codebase-ai
107
80
  ```
108
81
 
109
- This scans your project and wires everything automatically:
110
- - Writes `.codebase.json` — a compact snapshot of your stack, commands, and structure
111
- - Injects smart instructions into `CLAUDE.md`
112
- - Configures the MCP server so Claude can query project context natively
113
- - Installs git hooks so the manifest stays fresh on every commit
114
- - Updates `.gitignore`
115
-
116
- That's it. Every Claude session now starts with instant project context — no re-explaining, no file pasting.
117
-
118
- ---
119
-
120
- ### Level 2 — Autonomous dev loop
82
+ Scans your project and wires everything: `.codebase.json`, `CLAUDE.md`, MCP server, git hooks, `.gitignore`.
121
83
 
122
- > **Requires:** Claude Code (`npm install -g @anthropic-ai/claude-code`) and GitHub CLI (`gh auth login`)
84
+ **Level 2 Autonomous dev loop**
123
85
 
124
- Open Claude Code in your project and run `/setup` — this creates `docs/PRODUCT.md` and sets up your first GitHub milestone.
125
-
126
- Then run the loop:
127
86
  ```bash
128
- /simulate # find and fix bugs as a real user would
129
- /build # clear the issue backlog
130
- /launch # ship the release
87
+ npm install -g @anthropic-ai/claude-code
88
+ gh auth login
131
89
  ```
132
90
 
133
- ---
134
-
135
- ## Why does Claude actually understand my project?
136
-
137
- Without codebase, Claude starts every session knowing nothing:
91
+ Open Claude Code in your project, then:
138
92
 
139
93
  ```
140
- Session start → reads package.json → reads src/ reads tests/ → reads configs...
141
- 30 seconds + ~10,000 tokens later: "ok so you're using Next.js..."
94
+ /setup ← run once
95
+ /simulate ← find & fix bugs
96
+ /build ← clear the backlog
97
+ /launch ← ship
142
98
  ```
143
99
 
144
- With codebase, every session starts instantly:
100
+ Or just:
145
101
 
146
102
  ```
147
- Session start reads .codebase.json (~500 tokens)
148
- "I can see: Next.js 14, Prisma, Vitest, dev server on port 3000,
149
- 3 open critical bugs, last commit 2 hours ago, milestone v1.2 is 60% done"
103
+ /vibeloop ← does all of the above, continuously
150
104
  ```
151
105
 
152
- **~95% fewer tokens. Instant context. Every session.**
153
-
154
- The autonomous commands (`/simulate`, `/build`, `/launch`) all read the same manifest. That's why they work without human guidance. They know your stack, your commands, your open issues, your product brief. They're not guessing.
155
-
156
106
  ---
157
107
 
158
- ## All seven slash commands
108
+ ## `/vibeloop` zero intervention mode
159
109
 
160
- These live in `.claude/commands/` in your project. Commit this folder to share them with your team.
110
+ ```
111
+ /vibeloop # full autonomous run: simulate → build → launch
112
+ /vibeloop --skip-launch # simulate → build only, stop before release
113
+ /vibeloop --dry-run # full run without committing to main or publishing
114
+ /vibeloop --max-rounds 5 # cap the build loop at 5 rounds (default: 20)
115
+ /vibeloop --sim-count 5 # number of simulated users per cycle (default: 3)
116
+ /vibeloop --version 1.2.0 # pin the release version tag
117
+ ```
161
118
 
162
- | Command | Plain English |
163
- |---------|--------------|
164
- | `/setup` | First-time setup. Creates GitHub labels, your first milestone, and `docs/PRODUCT.md`. Run once per project. |
165
- | `/simulate` | Opens your app in a real browser. Acts like multiple types of users. Finds bugs, UX problems, and accessibility issues. Fixes what it can, tracks the rest as GitHub Issues. |
166
- | `/build` | Reads your open GitHub Issues. Picks the most important one. Implements the fix. Tests it. Commits it. Closes the issue. Moves to the next. Repeats. |
167
- | `/launch` | Checks quality gates (bugs, tests, UX score). If everything passes: bumps version, tags release, merges to main, publishes GitHub Release. |
168
- | `/review` | Deep code audit. Checks for security vulnerabilities, code quality problems, outdated/vulnerable dependencies, and accessibility issues. Everything goes to GitHub Issues. |
119
+ Invoke once. Come back to a shipped, tested, tagged release.
169
120
 
170
121
  ---
171
122
 
172
- ## How the git workflow works
173
-
174
- codebase enforces a simple convention that makes autonomous commits safe:
175
-
176
- - **All work happens on `develop`** — the AI commits here
177
- - **`main` is protected** — direct commits are blocked by a git hook
178
- - **Releases merge `develop → main`** — only via `codebase release`, with a proper merge commit
179
- - **One commit per verified fix** — the AI never batches unrelated changes
123
+ ## All CLI commands
180
124
 
181
- This means you can safely let the AI commit to `develop`. Nothing reaches `main` until you run `/launch` and the quality gates pass.
125
+ ```bash
126
+ # First run
127
+ npx codebase-ai # scan + wire AI tools + hooks
182
128
 
183
- ---
129
+ # Re-wire after adding a new AI tool
130
+ codebase setup
184
131
 
185
- ## What gets captured in `.codebase.json`
132
+ # AI interface
133
+ codebase brief # full project briefing
134
+ codebase next # highest-priority open issue
135
+ codebase status # kanban board + milestones
136
+ codebase query <path> # e.g. stack.languages or commands.test
186
137
 
187
- | Category | Examples |
188
- |----------|---------|
189
- | **Stack** | TypeScript, Next.js, Prisma, PostgreSQL, Vitest |
190
- | **Commands** | `npm run dev`, `npm test`, `npm run build` |
191
- | **Structure** | Where `src/` is, entry points, build output |
192
- | **Dependencies** | What's installed, what's outdated, what's notable |
193
- | **Config** | Which env vars exist, feature flags, CI setup |
194
- | **Git** | Recent commits, active branches, uncommitted changes |
195
- | **Quality** | Test framework, linter, formatter, pre-commit hooks |
196
- | **GitHub** | Open issues by priority, PRs, milestones, releases |
197
- | **Patterns** | Architecture style, API patterns, state management |
138
+ # Issues
139
+ codebase issue create "title"
140
+ codebase issue close <n> --reason "why"
141
+ codebase issue comment <n> --message "text"
198
142
 
199
- 30+ languages and 100+ frameworks detected automatically.
143
+ # Maintenance
144
+ codebase scan # refresh .codebase.json
145
+ codebase doctor # health check
146
+ codebase fix # auto-repair
147
+ codebase mcp # start MCP server
148
+ ```
200
149
 
201
150
  ---
202
151
 
203
152
  ## MCP Server
204
153
 
205
- For AI tools that support Model Context Protocol:
206
-
207
- ```bash
208
- codebase mcp # start stdio MCP server
209
- ```
210
-
211
- Add to your Claude Code MCP config (`.mcp.json` in project root):
212
-
213
154
  ```json
214
155
  {
215
156
  "mcpServers": {
@@ -221,92 +162,51 @@ Add to your Claude Code MCP config (`.mcp.json` in project root):
221
162
  }
222
163
  ```
223
164
 
224
- Tools available: `project_brief`, `get_codebase`, `query_codebase`, `get_next_task`, `get_blockers`, `create_issue`, `close_issue`, `rescan_project`, `list_commands`.
165
+ Add to `.mcp.json` in your project root. Tools: `project_brief`, `get_codebase`, `query_codebase`, `get_next_task`, `get_blockers`, `create_issue`, `close_issue`, `rescan_project`, `list_commands`.
225
166
 
226
167
  ---
227
168
 
169
+ ## Team usage
228
170
 
229
- ## Diagnostics
230
-
231
- ```bash
232
- codebase doctor # shows exactly what's broken and why
233
- codebase fix # auto-repairs everything doctor flags
234
- ```
235
-
236
- `doctor` checks: manifest freshness, AI tool injection, MCP config, git hooks, commit-msg hook, `.claude/commands/`, and `.gitignore`.
237
-
238
- ---
239
-
240
- ## All CLI commands
241
-
242
- ```bash
243
- # Setup
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)
249
-
250
- # AI interface (what AI tools call)
251
- codebase brief # full project briefing
252
- codebase next # highest-priority open issue
253
- codebase status # kanban board + milestones
254
- codebase query <path> # any field, e.g. stack.languages or commands.test
255
-
256
- # Issues
257
- codebase issue create "title" # create GitHub issue
258
- codebase issue close <n> --reason "why" # close with reason
259
- codebase issue comment <n> --message "text" # add comment (audit trail)
260
-
261
- # Maintenance
262
- codebase scan # refresh .codebase.json
263
- codebase release # quality gates → tag → develop→main → GitHub release
264
- codebase doctor # health check
265
- codebase fix # auto-repair
266
-
267
- # Integrations
268
- codebase mcp # start MCP server
269
- ```
171
+ Commit `.codebase.json` and `.claude/commands/`. Every teammate with Claude Code gets the same context and slash commands. The loop is resumable — restart anytime, GitHub tracks state.
270
172
 
271
173
  ---
272
174
 
273
175
  ## FAQ
274
176
 
275
- **Do I need Claude Code for this to work?**
276
- Yes. `codebase` is built for Claude Code. The MCP server, slash commands, and autonomous loop all require Claude Code.
277
-
278
- **What does "autonomous" actually mean — will it break my code?**
279
- All AI commits go to `develop`. Nothing reaches `main` until you run `/launch` and quality gates pass. You're always in control of what ships. The AI runs tests before committing and opens issues rather than guessing when it's stuck.
280
-
281
177
  **Does it send my code to anyone?**
282
- No. Everything runs locally. The only external calls are to GitHub (via `gh` CLI) and to Anthropic's API (only when you run Claude commands).
283
-
284
- **Will the git hooks slow down my commits?**
285
- No. The scan runs in ~200ms on most projects.
178
+ No. Everything runs locally. External calls go only to GitHub (via `gh` CLI) and Anthropic's API (only when you run Claude commands).
286
179
 
287
180
  **What if I don't use GitHub?**
288
- The manifest and AI tool wiring work without GitHub. You lose issues, PRs, releases, and labels — but the core context injection still works.
181
+ Manifest and AI tool wiring work without GitHub. You lose issues, PRs, releases, and labels — core context injection still works.
289
182
 
290
183
  **My project isn't JavaScript — does it work?**
291
- Yes. Detectors cover Python, Go, Rust, Ruby, Java, PHP, Swift, C#, and more. The slash commands use `codebase brief` to detect your stack and adapt automatically.
184
+ Yes. 30+ languages, 100+ frameworks detected automatically.
292
185
 
293
- **Can my whole team use this?**
294
- Yes. Commit `.codebase.json` and `.claude/commands/`. Every team member with Claude Code gets the same context and the same slash commands.
186
+ **Will the git hooks slow down my commits?**
187
+ No. Scan runs in ~200ms.
188
+
189
+ **What does "autonomous" mean — will it break my code?**
190
+ All AI commits go to `develop`. Nothing reaches `main` until `/launch` passes quality gates.
191
+
192
+ → [Full how-it-works docs](docs/HOW-IT-WORKS.md)
295
193
 
296
194
  ---
297
195
 
298
- ## Install
196
+ ## Contributing
299
197
 
300
- ```bash
301
- npm install -g codebase-ai # global (recommended)
302
- npx codebase-ai # try without installing
303
- pnpm add -g codebase-ai
304
- ```
198
+ We welcome contributions! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to get started, our commit conventions, and the PR process.
305
199
 
306
- Zero runtime dependencies. Node.js 20+ only.
200
+ Found a security issue? See [SECURITY.md](SECURITY.md) do not open a public issue.
307
201
 
308
- ---
202
+ ## Changelog
203
+
204
+ See [CHANGELOG.md](CHANGELOG.md) for a full version history.
205
+
206
+ ## Code of Conduct
207
+
208
+ This project follows a [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you agree to uphold it.
309
209
 
310
210
  ## License
311
211
 
312
- MIT
212
+ MIT — see [LICENSE](LICENSE) for details.
package/dist/index.js CHANGED
@@ -314,7 +314,7 @@ ${s}
314
314
  `,"utf-8");cn(i,493)}var Je,on,ft=D(()=>{"use strict";Je="# codebase-auto-update";on="# codebase-pre-commit"});var ht={};Vt(ht,{installClaudeCommandsForFix:()=>Gr,installClaudeHooksForFix:()=>Br,installClaudeSkillsForFix:()=>Ur,runSetup:()=>Tt});import{resolve as Hr,dirname as ln,join as N}from"path";import{writeFileSync as ce,existsSync as K,mkdirSync as Ke,readFileSync as le,chmodSync as Mt,readdirSync as un,copyFileSync as mt}from"fs";import{execFile as Pe}from"child_process";async function Tt(e){let t=Hr(e.path);await Ge({...e,sync:!0}),S("Claude Code Integration"),K(N(t,"CLAUDE.md"))||ce(N(t,"CLAUDE.md"),`# Project Rules
315
315
  `,"utf-8"),ae.inject(t),g("CLAUDE.md - added .codebase.json reference"),S("Git Hooks"),Re(t,!1)?(g("post-commit hook (auto-updates .codebase.json)"),g("pre-commit hook (runs typecheck + lint before every commit)"),Jr(t),g("commit-msg hook (blocks direct commits to main/master)")):h("Not a git repository - skipping hooks"),S("Claude Code Hooks"),fn(t),S("Browser Automation"),await Kr(),S("Claude Commands"),dn(t),S("Claude Skills"),pn(t),Ce(t),Wr(t,[".vibekit/daemon.lock",".vibekit/daemon.log",".vibekit/build.lock",".vibekit/milestone.env",".mcp.json"]),g(".gitignore updated"),S("Vibekit Bootstrap");let n=N(t,".vibekit");K(n)?h(".vibekit/ already exists"):(Ke(n,{recursive:!0}),g(".vibekit/ directory created")),S("GitHub Labels"),await zr()?(await Vr(t),await Qr(t)):(R("gh CLI not authenticated \u2014 skipping label/issue setup"),R("Run: gh auth login then codebase setup")),S("Product Brief");let o=N(t,"docs");K(o)||Ke(o,{recursive:!0});let r=N(o,"PRODUCT.md");K(r)?h("docs/PRODUCT.md already exists \u2014 skipping (delete to regenerate)"):(Yr(t,r),g("docs/PRODUCT.md generated \u2014 review and fill in [INFERRED] sections")),u(`
316
316
  Done! Your project is wired for AI + autonomous loop.`),u(`
317
- 0. codebase brief \u2014 load project context (AI agents: call this first)`),u(" 1. Review docs/PRODUCT.md and fill in any [INFERRED] sections"),u(" 2. /simulate \u2014 AI customer journeys find & fix bugs"),u(" 3. /build \u2014 implement architectural issues autonomously"),u(" 4. /launch \u2014 gate check, release, merge to main")}function Gr(e){dn(e)}function dn(e){let t=N(ln(new URL(import.meta.url).pathname),"..","commands");if(!K(t)){R("Claude commands not found in package \u2014 skipping");return}let s=un(t).filter(r=>r.endsWith(".md")),n=[{dir:N(e,".claude","commands"),label:".claude/commands/"},{dir:N(process.env.HOME??"~",".claude","commands"),label:"~/.claude/commands/"}],i=0,o=0;for(let{dir:r,label:a}of n){Ke(r,{recursive:!0});let c=0,l=0,p=0;for(let m of s){let y=N(t,m),b=N(r,m);if(K(b)){let x=le(y,"utf-8"),j=le(b,"utf-8");x!==j?(mt(y,b),l++):p++}else mt(y,b),c++}let d=[];c>0&&d.push(`${c} new`),l>0&&d.push(`${l} updated`),p>0&&d.push(`${p} unchanged`),c>0||l>0?g(`Claude commands \u2192 ${a} (${d.join(", ")})`):h(`Claude commands up to date \u2192 ${a}`),i+=c,o+=l}(i>0||o>0)&&(h("Available: /setup /simulate /build /launch /review /vibeloop"),h("Tip: commit .claude/commands/ to share these with your team"))}function Ur(e){pn(e)}function pn(e){let t=N(ln(new URL(import.meta.url).pathname),"..","skills");if(!K(t)){R("Skills not found in package \u2014 skipping");return}let s=un(t).filter(a=>a.endsWith(".skill"));if(s.length===0){h("No skill files found in package");return}let n=[{dir:N(e,".claude","skills"),label:".claude/skills/"},{dir:N(process.env.HOME??"~",".claude","skills"),label:"~/.claude/skills/"}],i=0,o=0;for(let{dir:a,label:c}of n){Ke(a,{recursive:!0});let l=0,p=0,d=0;for(let y of s){let b=N(t,y),x=N(a,y);if(K(x)){let j=le(b),E=le(x);j.equals(E)?d++:(mt(b,x),p++)}else mt(b,x),l++}let m=[];l>0&&m.push(`${l} new`),p>0&&m.push(`${p} updated`),d>0&&m.push(`${d} unchanged`),l>0||p>0?g(`Skills \u2192 ${c} (${m.join(", ")})`):h(`Skills up to date \u2192 ${c}`),i+=l,o+=p}let r=s.map(a=>a.replace(/\.skill$/,"")).join(", ");i>0||o>0?(h(`Available: ${r}`),h("Tip: commit .claude/skills/ to share these with your team")):h(`Available: ${r}`)}function Br(e){fn(e)}function fn(e){let t=N(e,".claude","hooks");Ke(t,{recursive:!0});let s=N(t,"git-guard.sh");ce(s,`#!/bin/bash
317
+ 0. codebase brief \u2014 load project context (AI agents: call this first)`),u(" 1. Review docs/PRODUCT.md and fill in any [INFERRED] sections"),u(" 2. /simulate \u2014 AI customer journeys find & fix bugs"),u(" 3. /build \u2014 implement architectural issues autonomously"),u(" 4. /launch \u2014 gate check, release, merge to main")}function Gr(e){dn(e)}function dn(e){let t=N(ln(new URL(import.meta.url).pathname),"..","commands");if(!K(t)){R("Claude commands not found in package \u2014 skipping");return}let s=un(t).filter(r=>r.endsWith(".md")),n=[{dir:N(e,".claude","commands"),label:".claude/commands/"},{dir:N(process.env.HOME??"~",".claude","commands"),label:"~/.claude/commands/"}],i=0,o=0;for(let{dir:r,label:a}of n){Ke(r,{recursive:!0});let c=0,l=0,p=0;for(let m of s){let y=N(t,m),b=N(r,m);if(K(b)){let x=le(y,"utf-8"),j=le(b,"utf-8");x!==j?(mt(y,b),l++):p++}else mt(y,b),c++}let d=[];c>0&&d.push(`${c} new`),l>0&&d.push(`${l} updated`),p>0&&d.push(`${p} unchanged`),c>0||l>0?g(`Claude commands \u2192 ${a} (${d.join(", ")})`):h(`Claude commands up to date \u2192 ${a}`),i+=c,o+=l}(i>0||o>0)&&(h("Available: /setup /simulate /build /launch /review /vibeloop"),h("Tip: commit .claude/commands/ to share these with your team"))}function Ur(e){pn(e)}function pn(e){let t=N(ln(new URL(import.meta.url).pathname),"../..","skills");if(!K(t)){R("Skills not found in package \u2014 skipping");return}let s=un(t).filter(a=>a.endsWith(".skill"));if(s.length===0){h("No skill files found in package");return}let n=[{dir:N(e,".claude","skills"),label:".claude/skills/"},{dir:N(process.env.HOME??"~",".claude","skills"),label:"~/.claude/skills/"}],i=0,o=0;for(let{dir:a,label:c}of n){Ke(a,{recursive:!0});let l=0,p=0,d=0;for(let y of s){let b=N(t,y),x=N(a,y);if(K(x)){let j=le(b),E=le(x);j.equals(E)?d++:(mt(b,x),p++)}else mt(b,x),l++}let m=[];l>0&&m.push(`${l} new`),p>0&&m.push(`${p} updated`),d>0&&m.push(`${d} unchanged`),l>0||p>0?g(`Skills \u2192 ${c} (${m.join(", ")})`):h(`Skills up to date \u2192 ${c}`),i+=l,o+=p}let r=s.map(a=>a.replace(/\.skill$/,"")).join(", ");i>0||o>0?(h(`Available: ${r}`),h("Tip: commit .claude/skills/ to share these with your team")):h(`Available: ${r}`)}function Br(e){fn(e)}function fn(e){let t=N(e,".claude","hooks");Ke(t,{recursive:!0});let s=N(t,"git-guard.sh");ce(s,`#!/bin/bash
318
318
  # codebase git-guard \u2014 PreToolUse hook
319
319
  # Reads Claude tool input JSON from stdin, enforces git safety rules.
320
320
 
@@ -469,7 +469,7 @@ ${o}
469
469
 
470
470
  ## Dev Credentials
471
471
 
472
- - **Default seed creds:** \`{role}@dev.local\` / \`dev123456\`
472
+ - **Default seed creds:** \`{role}@dev.local\` / \`<your-seed-password>\`
473
473
  - **Dev login path:** [INFERRED: e.g. /dev-login or /auth/login]
474
474
 
475
475
  ## Known Constraints
@@ -552,7 +552,7 @@ ${w("SEE ALSO")}
552
552
  `:""}${w("MORE HELP")}
553
553
  ${$("codebase --help")} Show all commands
554
554
  ${tt("https://github.com/ZySec-AI/codebase/docs","Full documentation")}
555
- `)}var Nc={E_NO_GIT:{message:"Not a git repository",suggestion:"Initialize git first: "+$("git init")},E_NO_PACKAGE_JSON:{message:"No package.json found",suggestion:"Initialize project: "+$("npm init")+" or "+$("pnpm init")},E_GH_NOT_AUTHENTICATED:{message:"GitHub CLI not authenticated",suggestion:"Run: "+$("gh auth login")},E_MANIFEST_NOT_FOUND:{message:".codebase.json not found",suggestion:"Run: "+$("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 oi={command:"init",subcommand:"",positionals:[],path:process.cwd(),format:"text",depth:4,categories:[],incremental:!1,quiet:!1,force:!1,verbose:!1,port:7432,tools:[],dryRun:!1,since:"",sync:!1,message:"",reason:"",examples:!1,helpCommand:!1},Zt=new Set(["scan","setup","query","mcp","issue","status","init","scan-only","brief","next","doctor","fix","release","plan","skills","serve"]);function es(e){let t={...oi},s=[];for(let n=0;n<e.length;n++){let i=e[n];if(!i.startsWith("-")&&Zt.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&&(Yt(),process.exit(0)),(i==="--version"||i==="-v")&&(console.log("codebase 0.3.2"),process.exit(0)),i.startsWith("--")){let o=i.slice(2);if(o==="quiet"||o==="q"){t.quiet=!0;continue}if(o==="force"){t.force=!0;continue}if(o==="raw"){console.error("Warning: --raw is deprecated, use --force instead"),t.force=!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&&Zt.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 ts(e){Xt(e),process.exit(0)}M();import{get as ri}from"https";import{readFileSync as jt,writeFileSync as ai,mkdirSync as ci}from"fs";import{homedir as li}from"os";import{join as ss}from"path";import{execSync as st,spawnSync as ui}from"child_process";var ns=ss(li(),".codebase"),is=ss(ns,"update-check.json"),di=1440*60*1e3,me="codebase-ai",ke=!!process.env.NO_COLOR,C={yellow:ke?"":"\x1B[33m",cyan:ke?"":"\x1B[36m",green:ke?"":"\x1B[32m",bold:ke?"":"\x1B[1m",dim:ke?"":"\x1B[2m",reset:ke?"":"\x1B[0m"};function pi(){return"0.3.2"}function fi(e,t){let s=l=>l.replace(/^v/,"").split(".").map(Number),[n,i,o]=s(e),[r,a,c]=s(t);return n!==r?n>r:i!==a?i>a:o>c}function mi(){try{return JSON.parse(jt(is,"utf8"))}catch{return null}}function gi(e){try{ci(ns,{recursive:!0}),ai(is,JSON.stringify({version:e,checkedAt:Date.now()}))}catch{}}function hi(){return new Promise((e,t)=>{let s=ri(`https://registry.npmjs.org/${me}/latest`,{headers:{accept:"application/json"}},n=>{let i="";n.on("data",o=>i+=o.toString()),n.on("end",()=>{try{e(JSON.parse(i).version)}catch{t(new Error("parse error"))}})});s.on("error",t),s.setTimeout(3e3,()=>{s.destroy(),t(new Error("timeout"))})})}function bi(){try{let e=st("npm root -g 2>/dev/null",{encoding:"utf8"}).trim();if(e&&jt(`${e}/${me}/package.json`,"utf8"))return`npm install -g ${me}@latest`}catch{}try{st("pnpm --version 2>/dev/null",{encoding:"utf8"});let e=st("pnpm root -g 2>/dev/null",{encoding:"utf8"}).trim();if(e&&jt(`${e}/${me}/package.json`,"utf8"))return`pnpm add -g ${me}@latest`}catch{}try{return st("yarn --version 2>/dev/null",{encoding:"utf8"}),`yarn global add ${me}@latest`}catch{}return`npm install -g ${me}@latest`}function yi(e){let[t,...s]=e.split(" ");return ui(t,s,{stdio:"inherit"}).status===0}function ki(){return new Promise(e=>{let t=process.stdin,s=t.isTTY;s&&t.setRawMode(!0),t.resume(),t.setEncoding("utf8");let n=i=>{s&&t.setRawMode(!1),t.pause(),t.removeListener("data",n),e(i)};t.on("data",n),setTimeout(()=>{s&&t.setRawMode(!1),t.pause(),t.removeListener("data",n),e("n")},1e4)})}async function os(){if(process.env.CI||process.env.NO_UPDATE_CHECK||process.env.CODEBASE_NO_UPDATE_CHECK||!process.stdout.isTTY||!process.stdin.isTTY)return;let e=pi(),t=mi(),s;if(t&&Date.now()-t.checkedAt<di)s=t.version;else try{s=await hi(),gi(s)}catch{return}if(!fi(s,e))return;let n=bi();console.log(`
555
+ `)}var Nc={E_NO_GIT:{message:"Not a git repository",suggestion:"Initialize git first: "+$("git init")},E_NO_PACKAGE_JSON:{message:"No package.json found",suggestion:"Initialize project: "+$("npm init")+" or "+$("pnpm init")},E_GH_NOT_AUTHENTICATED:{message:"GitHub CLI not authenticated",suggestion:"Run: "+$("gh auth login")},E_MANIFEST_NOT_FOUND:{message:".codebase.json not found",suggestion:"Run: "+$("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 oi={command:"init",subcommand:"",positionals:[],path:process.cwd(),format:"text",depth:4,categories:[],incremental:!1,quiet:!1,force:!1,verbose:!1,port:7432,tools:[],dryRun:!1,since:"",sync:!1,message:"",reason:"",examples:!1,helpCommand:!1},Zt=new Set(["scan","setup","query","mcp","issue","status","init","scan-only","brief","next","doctor","fix","release","plan","skills","serve"]);function es(e){let t={...oi},s=[];for(let n=0;n<e.length;n++){let i=e[n];if(!i.startsWith("-")&&Zt.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&&(Yt(),process.exit(0)),(i==="--version"||i==="-v")&&(console.log("codebase 0.3.4"),process.exit(0)),i.startsWith("--")){let o=i.slice(2);if(o==="quiet"||o==="q"){t.quiet=!0;continue}if(o==="force"){t.force=!0;continue}if(o==="raw"){console.error("Warning: --raw is deprecated, use --force instead"),t.force=!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&&Zt.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 ts(e){Xt(e),process.exit(0)}M();import{get as ri}from"https";import{readFileSync as jt,writeFileSync as ai,mkdirSync as ci}from"fs";import{homedir as li}from"os";import{join as ss}from"path";import{execSync as st,spawnSync as ui}from"child_process";var ns=ss(li(),".codebase"),is=ss(ns,"update-check.json"),di=1440*60*1e3,me="codebase-ai",ke=!!process.env.NO_COLOR,C={yellow:ke?"":"\x1B[33m",cyan:ke?"":"\x1B[36m",green:ke?"":"\x1B[32m",bold:ke?"":"\x1B[1m",dim:ke?"":"\x1B[2m",reset:ke?"":"\x1B[0m"};function pi(){return"0.3.4"}function fi(e,t){let s=l=>l.replace(/^v/,"").split(".").map(Number),[n,i,o]=s(e),[r,a,c]=s(t);return n!==r?n>r:i!==a?i>a:o>c}function mi(){try{return JSON.parse(jt(is,"utf8"))}catch{return null}}function gi(e){try{ci(ns,{recursive:!0}),ai(is,JSON.stringify({version:e,checkedAt:Date.now()}))}catch{}}function hi(){return new Promise((e,t)=>{let s=ri(`https://registry.npmjs.org/${me}/latest`,{headers:{accept:"application/json"}},n=>{let i="";n.on("data",o=>i+=o.toString()),n.on("end",()=>{try{e(JSON.parse(i).version)}catch{t(new Error("parse error"))}})});s.on("error",t),s.setTimeout(3e3,()=>{s.destroy(),t(new Error("timeout"))})})}function bi(){try{let e=st("npm root -g 2>/dev/null",{encoding:"utf8"}).trim();if(e&&jt(`${e}/${me}/package.json`,"utf8"))return`npm install -g ${me}@latest`}catch{}try{st("pnpm --version 2>/dev/null",{encoding:"utf8"});let e=st("pnpm root -g 2>/dev/null",{encoding:"utf8"}).trim();if(e&&jt(`${e}/${me}/package.json`,"utf8"))return`pnpm add -g ${me}@latest`}catch{}try{return st("yarn --version 2>/dev/null",{encoding:"utf8"}),`yarn global add ${me}@latest`}catch{}return`npm install -g ${me}@latest`}function yi(e){let[t,...s]=e.split(" ");return ui(t,s,{stdio:"inherit"}).status===0}function ki(){return new Promise(e=>{let t=process.stdin,s=t.isTTY;s&&t.setRawMode(!0),t.resume(),t.setEncoding("utf8");let n=i=>{s&&t.setRawMode(!1),t.pause(),t.removeListener("data",n),e(i)};t.on("data",n),setTimeout(()=>{s&&t.setRawMode(!1),t.pause(),t.removeListener("data",n),e("n")},1e4)})}async function os(){if(process.env.CI||process.env.NO_UPDATE_CHECK||process.env.CODEBASE_NO_UPDATE_CHECK||!process.stdout.isTTY||!process.stdin.isTTY)return;let e=pi(),t=mi(),s;if(t&&Date.now()-t.checkedAt<di)s=t.version;else try{s=await hi(),gi(s)}catch{return}if(!fi(s,e))return;let n=bi();console.log(`
556
556
  ${C.yellow}\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510${C.reset}`),console.log(` ${C.yellow}\u2502${C.reset} ${C.bold}Update available${C.reset} ${C.dim}${e}${C.reset} ${C.yellow}\u2192${C.reset} ${C.bold}${C.cyan}${s}${C.reset}`),console.log(` ${C.yellow}\u2502${C.reset} Press ${C.bold}Y${C.reset} to update now, any other key to skip`),console.log(` ${C.yellow}\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518${C.reset}`),process.stdout.write(`
557
557
  > `);let o=(await ki()).toLowerCase()==="y";if(console.log(o?"Updating\u2026":`Skipped.
558
558
  `),!o)return;console.log(`
@@ -621,7 +621,7 @@ ${w("BACKLOG")} (${t.backlog.length})`);for(let n of t.backlog.slice(0,10))u(`
621
621
  ${w("IN PROGRESS")} (${t.in_progress.length})`);for(let n of t.in_progress.slice(0,10)){let i=n.assignee?` @${n.assignee}`:"";u(` #${n.number} ${n.title}${i}`)}t.in_progress.length>10&&te(` \u2026 and ${t.in_progress.length-10} more`);let s=t.needs_verify??[];if(s.length>0){u(`
622
622
  ${w("NEEDS VERIFY")} (${s.length})`);for(let n of s.slice(0,10))u(` #${n.number} ${n.title}`);s.length>10&&te(` \u2026 and ${s.length-10} more`)}u(`
623
623
  ${w("DONE")} (${t.done.length} recent)`);for(let n of t.done.slice(0,5))u(` #${n.number} ${n.title}`);t.done.length>5&&te(` \u2026 and ${t.done.length-5} more`)}function _a(e){S("Priority Queue");for(let t of e.priorities.slice(0,15)){let s=t.labels.length?` [${t.labels.join(", ")}]`:"",n=t.assignee?` \u2192 @${t.assignee}`:"";u(` #${t.number} ${t.title}${s}${n}`)}}function Ra(e){S("Milestones");for(let t of e.milestones){let s=Da(t.progress.percent),n=t.due_date?` (due: ${t.due_date.split("T")[0]})`:"";u(`
624
- ${w(t.title)} ${s} ${t.progress.percent}%${n}`),u(` ${t.progress.closed}/${t.progress.open+t.progress.closed} issues closed`)}}function Pa(e){S("Decisions");let t=[...e.from_prs.map(s=>({...s,type:"PR"})),...e.from_adrs.map(s=>({...s,type:"ADR"})),...e.manual.map(s=>({...s,type:"Manual"}))].sort((s,n)=>(n.date||"").localeCompare(s.date||""));for(let s of t.slice(0,15))u(` [${s.type}] ${s.title}`),s.summary&&u(` ${s.summary.slice(0,100)}`)}function Da(e){let t=Math.round(e/5),s=20-t;return`[${"\u2588".repeat(t)}${"\u2591".repeat(s)}]`}import{resolve as Ga}from"path";import{createInterface as Aa}from"readline";import{readFile as Qe,writeFile as wt,rename as vt}from"fs/promises";import{existsSync as kt,readdirSync as Pn}from"fs";import{join as Y,resolve as Dn}from"path";import{homedir as An}from"os";import{execFile as In}from"child_process";je();He();var Oa=[{name:"project_brief",description:"CALL THIS FIRST at the start of every session. Returns a complete project briefing: what the project is, tech stack, current priorities, open issues, blockers, what to work on next, and recent decisions. This is your single source of truth \u2014 call it before doing anything else.",inputSchema:{type:"object",properties:{}}},{name:"get_codebase",description:"Get codebase data by category with optional sparse field selection. Use the 'fields' array to request only specific fields (e.g. fields: ['languages', 'frameworks'] from category: 'stack'). For single dot-path lookups use query_codebase instead.",inputSchema:{type:"object",properties:{category:{type:"string",description:"Section to retrieve: repo, structure, stack, commands, dependencies, config, git, quality, patterns, status, roadmap, decisions"},fields:{type:"array",items:{type:"string"},description:"Optional. When category is specified, return only these keys from that section. E.g. ['languages', 'frameworks'] for stack."}}}},{name:"query_codebase",description:"Query a specific field using dot-path notation. Handles both targeted dot-path queries (e.g. 'stack.languages') and full category reads (e.g. 'stack'). Examples: 'stack.languages', 'commands.test', 'status.kanban.in_progress', 'roadmap.milestones'.",inputSchema:{type:"object",properties:{path:{type:"string",description:"Dot-path query, e.g. 'stack.languages', 'commands.test', 'status.priorities'"},fields:{type:"array",items:{type:"string"},description:"Optional: return only these fields from the result object"}},required:["path"]}},{name:"get_next_task",description:"Get the highest-priority task you should work on next. Returns the top open issue ranked by priority labels (P0 > P1 > bugs > features), including mapped files so you know where to start coding.",inputSchema:{type:"object",properties:{}}},{name:"get_blockers",description:"Get all current blockers \u2014 issues labeled as blocked, PRs waiting for review, PRs with failing CI checks, PRs with merge conflicts, and uncommitted changes. Shows what's preventing progress.",inputSchema:{type:"object",properties:{}}},{name:"create_issue",description:"Create a new GitHub issue. Use this when you discover a bug, identify needed work, or the user asks to track something. Returns the issue URL.",inputSchema:{type:"object",properties:{title:{type:"string",description:"Issue title"},body:{type:"string",description:"Issue body/description (markdown)"},labels:{type:"array",items:{type:"string"},description:"Labels to apply: bug, feature, enhancement, P0, P1, P2, etc."}},required:["title"]}},{name:"close_issue",description:"Close a GitHub issue after fixing it. Add a comment explaining what was done.",inputSchema:{type:"object",properties:{number:{type:"number",description:"Issue number to close"},comment:{type:"string",description:"Comment explaining resolution"}},required:["number"]}},{name:"update_issue",description:"Update a GitHub issue \u2014 add/remove labels, set assignee. Use this to advance issues through the pipeline (e.g., add 'status:in-progress', remove 'status:backlog').",inputSchema:{type:"object",properties:{number:{type:"number",description:"Issue number"},add_labels:{type:"array",items:{type:"string"},description:"Labels to add"},remove_labels:{type:"array",items:{type:"string"},description:"Labels to remove"},assignee:{type:"string",description:"GitHub username to assign (or empty string to unassign)"}},required:["number"]}},{name:"list_commands",description:"List installed Claude Code slash commands in this project. Returns names of available commands (e.g. /vibeloop, /setup, /simulate, /build, /launch, /review).",inputSchema:{type:"object",properties:{}}},{name:"list_skills",description:"List installed Claude Code skills with their names and descriptions. Skills extend /review and other commands with stack-specific analysis.",inputSchema:{type:"object",properties:{}}},{name:"get_plan",description:"Read the project's PLAN.md \u2014 Claude's persistent working memory across sessions. Contains current sprint goals, in-flight work, decisions log, and blockers. Call this after project_brief to restore loop context.",inputSchema:{type:"object",properties:{}}},{name:"update_plan",description:"Append a status update to PLAN.md. Use this at the end of each build or simulate cycle to record what was done, decisions made, and what's next. Creates PLAN.md if it doesn't exist.",inputSchema:{type:"object",properties:{message:{type:"string",description:"Status update text to append to PLAN.md Update Log section"}},required:["message"]}},{name:"get_issue",description:"Get full details of a specific GitHub issue by number, including body, comments, and linked PRs. Use this when working on an issue and need its complete specification.",inputSchema:{type:"object",properties:{number:{type:"number",description:"Issue number"}},required:["number"]}},{name:"get_pr",description:"Get full details of a specific pull request by number, including body, review status, checks, and diff stats.",inputSchema:{type:"object",properties:{number:{type:"number",description:"PR number"}},required:["number"]}},{name:"rescan_project",description:"Rescan the project to refresh the manifest after making changes. Call this after major refactors, dependency updates, or when your cached data feels stale.",inputSchema:{type:"object",properties:{sync:{type:"boolean",description:"Also refresh GitHub data (issues, PRs, milestones). Default: true."},incremental:{type:"boolean",description:"Only re-scan changed areas (faster). Default: false."}}}},{name:"refresh_status",description:"Refresh only GitHub data (issues, PRs, milestones) without re-scanning the filesystem. Much faster than rescan_project. Call this after creating/closing issues to get fresh priority data.",inputSchema:{type:"object",properties:{}}}];async function Nn(e){let t=Aa({input:process.stdin,terminal:!1});for await(let s of t){if(!s.trim())continue;let n;try{n=JSON.parse(s)}catch{On({jsonrpc:"2.0",id:0,error:{code:-32700,message:"Parse error"}});continue}let i=await Ia(n,e);i&&On(i)}}async function Ia(e,t){switch(e.method){case"initialize":return O(e.id,{protocolVersion:"2024-11-05",serverInfo:{name:"codebase",version:"0.3.2"},capabilities:{tools:{}}});case"notifications/initialized":return null;case"tools/list":return O(e.id,{tools:Oa});case"tools/call":return Na(e,t);default:return{jsonrpc:"2.0",id:e.id,error:{code:-32601,message:`Method not found: ${e.method}`}}}}async function Na(e,t){let s=e.params||{},n=s.name,i=s.arguments||{};try{switch(n){case"project_brief":{let o=await Ve(t,!0),r=yt(o);return O(e.id,{content:[{type:"text",text:r}]})}case"get_codebase":{let o=await Ve(t),r=i.category,a=i.fields;if(r){let c=o[r];if(a?.length&&c&&typeof c=="object"&&c!==null){let l={};for(let p of a)l[p]=c[p];return O(e.id,{content:[{type:"text",text:JSON.stringify(l,null,2)}]})}return O(e.id,{content:[{type:"text",text:JSON.stringify(c??null,null,2)}]})}return O(e.id,{content:[{type:"text",text:JSON.stringify(o,null,2)}]})}case"query_codebase":{let o=await Ve(t),r=i.path,a=i.fields,c=Ae(o,r);if(a?.length&&c!==null&&c!==void 0&&typeof c=="object"&&!Array.isArray(c)){let l={};for(let p of a)l[p]=c[p];c=l}return O(e.id,{content:[{type:"text",text:JSON.stringify(c??null,null,2)}]})}case"get_next_task":{let o=await Ve(t,!0),r=Fa(o);return O(e.id,{content:[{type:"text",text:JSON.stringify(r,null,2)}]})}case"get_blockers":{let o=await Ve(t,!0),r=Ma(o);return O(e.id,{content:[{type:"text",text:JSON.stringify(r,null,2)}]})}case"create_issue":{let o=await Ta(t,i);return await Bt(t),O(e.id,{content:[{type:"text",text:o}]})}case"close_issue":{let o=await qa(t,i);return await Bt(t),O(e.id,{content:[{type:"text",text:o}]})}case"update_issue":{let o=await Ha(t,i);return await Bt(t),O(e.id,{content:[{type:"text",text:o}]})}case"list_commands":{let o=Y(t,".claude","commands"),r=Y(An(),".claude","commands"),a=new Set,c=[];for(let p of[o,r])if(kt(p))for(let d of Pn(p))d.endsWith(".md")&&!a.has(d)&&(a.add(d),c.push(d));if(c.length===0)return O(e.id,{content:[{type:"text",text:"No slash commands installed. Run: codebase setup"}]});let l=c.map(p=>"/"+p.replace(/\.md$/,"")).join(", ");return O(e.id,{content:[{type:"text",text:`Installed commands (${c.length}): ${l}
624
+ ${w(t.title)} ${s} ${t.progress.percent}%${n}`),u(` ${t.progress.closed}/${t.progress.open+t.progress.closed} issues closed`)}}function Pa(e){S("Decisions");let t=[...e.from_prs.map(s=>({...s,type:"PR"})),...e.from_adrs.map(s=>({...s,type:"ADR"})),...e.manual.map(s=>({...s,type:"Manual"}))].sort((s,n)=>(n.date||"").localeCompare(s.date||""));for(let s of t.slice(0,15))u(` [${s.type}] ${s.title}`),s.summary&&u(` ${s.summary.slice(0,100)}`)}function Da(e){let t=Math.round(e/5),s=20-t;return`[${"\u2588".repeat(t)}${"\u2591".repeat(s)}]`}import{resolve as Ga}from"path";import{createInterface as Aa}from"readline";import{readFile as Qe,writeFile as wt,rename as vt}from"fs/promises";import{existsSync as kt,readdirSync as Pn}from"fs";import{join as Y,resolve as Dn}from"path";import{homedir as An}from"os";import{execFile as In}from"child_process";je();He();var Oa=[{name:"project_brief",description:"CALL THIS FIRST at the start of every session. Returns a complete project briefing: what the project is, tech stack, current priorities, open issues, blockers, what to work on next, and recent decisions. This is your single source of truth \u2014 call it before doing anything else.",inputSchema:{type:"object",properties:{}}},{name:"get_codebase",description:"Get codebase data by category with optional sparse field selection. Use the 'fields' array to request only specific fields (e.g. fields: ['languages', 'frameworks'] from category: 'stack'). For single dot-path lookups use query_codebase instead.",inputSchema:{type:"object",properties:{category:{type:"string",description:"Section to retrieve: repo, structure, stack, commands, dependencies, config, git, quality, patterns, status, roadmap, decisions"},fields:{type:"array",items:{type:"string"},description:"Optional. When category is specified, return only these keys from that section. E.g. ['languages', 'frameworks'] for stack."}}}},{name:"query_codebase",description:"Query a specific field using dot-path notation. Handles both targeted dot-path queries (e.g. 'stack.languages') and full category reads (e.g. 'stack'). Examples: 'stack.languages', 'commands.test', 'status.kanban.in_progress', 'roadmap.milestones'.",inputSchema:{type:"object",properties:{path:{type:"string",description:"Dot-path query, e.g. 'stack.languages', 'commands.test', 'status.priorities'"},fields:{type:"array",items:{type:"string"},description:"Optional: return only these fields from the result object"}},required:["path"]}},{name:"get_next_task",description:"Get the highest-priority task you should work on next. Returns the top open issue ranked by priority labels (P0 > P1 > bugs > features), including mapped files so you know where to start coding.",inputSchema:{type:"object",properties:{}}},{name:"get_blockers",description:"Get all current blockers \u2014 issues labeled as blocked, PRs waiting for review, PRs with failing CI checks, PRs with merge conflicts, and uncommitted changes. Shows what's preventing progress.",inputSchema:{type:"object",properties:{}}},{name:"create_issue",description:"Create a new GitHub issue. Use this when you discover a bug, identify needed work, or the user asks to track something. Returns the issue URL.",inputSchema:{type:"object",properties:{title:{type:"string",description:"Issue title"},body:{type:"string",description:"Issue body/description (markdown)"},labels:{type:"array",items:{type:"string"},description:"Labels to apply: bug, feature, enhancement, P0, P1, P2, etc."}},required:["title"]}},{name:"close_issue",description:"Close a GitHub issue after fixing it. Add a comment explaining what was done.",inputSchema:{type:"object",properties:{number:{type:"number",description:"Issue number to close"},comment:{type:"string",description:"Comment explaining resolution"}},required:["number"]}},{name:"update_issue",description:"Update a GitHub issue \u2014 add/remove labels, set assignee. Use this to advance issues through the pipeline (e.g., add 'status:in-progress', remove 'status:backlog').",inputSchema:{type:"object",properties:{number:{type:"number",description:"Issue number"},add_labels:{type:"array",items:{type:"string"},description:"Labels to add"},remove_labels:{type:"array",items:{type:"string"},description:"Labels to remove"},assignee:{type:"string",description:"GitHub username to assign (or empty string to unassign)"}},required:["number"]}},{name:"list_commands",description:"List installed Claude Code slash commands in this project. Returns names of available commands (e.g. /vibeloop, /setup, /simulate, /build, /launch, /review).",inputSchema:{type:"object",properties:{}}},{name:"list_skills",description:"List installed Claude Code skills with their names and descriptions. Skills extend /review and other commands with stack-specific analysis.",inputSchema:{type:"object",properties:{}}},{name:"get_plan",description:"Read the project's PLAN.md \u2014 Claude's persistent working memory across sessions. Contains current sprint goals, in-flight work, decisions log, and blockers. Call this after project_brief to restore loop context.",inputSchema:{type:"object",properties:{}}},{name:"update_plan",description:"Append a status update to PLAN.md. Use this at the end of each build or simulate cycle to record what was done, decisions made, and what's next. Creates PLAN.md if it doesn't exist.",inputSchema:{type:"object",properties:{message:{type:"string",description:"Status update text to append to PLAN.md Update Log section"}},required:["message"]}},{name:"get_issue",description:"Get full details of a specific GitHub issue by number, including body, comments, and linked PRs. Use this when working on an issue and need its complete specification.",inputSchema:{type:"object",properties:{number:{type:"number",description:"Issue number"}},required:["number"]}},{name:"get_pr",description:"Get full details of a specific pull request by number, including body, review status, checks, and diff stats.",inputSchema:{type:"object",properties:{number:{type:"number",description:"PR number"}},required:["number"]}},{name:"rescan_project",description:"Rescan the project to refresh the manifest after making changes. Call this after major refactors, dependency updates, or when your cached data feels stale.",inputSchema:{type:"object",properties:{sync:{type:"boolean",description:"Also refresh GitHub data (issues, PRs, milestones). Default: true."},incremental:{type:"boolean",description:"Only re-scan changed areas (faster). Default: false."}}}},{name:"refresh_status",description:"Refresh only GitHub data (issues, PRs, milestones) without re-scanning the filesystem. Much faster than rescan_project. Call this after creating/closing issues to get fresh priority data.",inputSchema:{type:"object",properties:{}}}];async function Nn(e){let t=Aa({input:process.stdin,terminal:!1});for await(let s of t){if(!s.trim())continue;let n;try{n=JSON.parse(s)}catch{On({jsonrpc:"2.0",id:0,error:{code:-32700,message:"Parse error"}});continue}let i=await Ia(n,e);i&&On(i)}}async function Ia(e,t){switch(e.method){case"initialize":return O(e.id,{protocolVersion:"2024-11-05",serverInfo:{name:"codebase",version:"0.3.4"},capabilities:{tools:{}}});case"notifications/initialized":return null;case"tools/list":return O(e.id,{tools:Oa});case"tools/call":return Na(e,t);default:return{jsonrpc:"2.0",id:e.id,error:{code:-32601,message:`Method not found: ${e.method}`}}}}async function Na(e,t){let s=e.params||{},n=s.name,i=s.arguments||{};try{switch(n){case"project_brief":{let o=await Ve(t,!0),r=yt(o);return O(e.id,{content:[{type:"text",text:r}]})}case"get_codebase":{let o=await Ve(t),r=i.category,a=i.fields;if(r){let c=o[r];if(a?.length&&c&&typeof c=="object"&&c!==null){let l={};for(let p of a)l[p]=c[p];return O(e.id,{content:[{type:"text",text:JSON.stringify(l,null,2)}]})}return O(e.id,{content:[{type:"text",text:JSON.stringify(c??null,null,2)}]})}return O(e.id,{content:[{type:"text",text:JSON.stringify(o,null,2)}]})}case"query_codebase":{let o=await Ve(t),r=i.path,a=i.fields,c=Ae(o,r);if(a?.length&&c!==null&&c!==void 0&&typeof c=="object"&&!Array.isArray(c)){let l={};for(let p of a)l[p]=c[p];c=l}return O(e.id,{content:[{type:"text",text:JSON.stringify(c??null,null,2)}]})}case"get_next_task":{let o=await Ve(t,!0),r=Fa(o);return O(e.id,{content:[{type:"text",text:JSON.stringify(r,null,2)}]})}case"get_blockers":{let o=await Ve(t,!0),r=Ma(o);return O(e.id,{content:[{type:"text",text:JSON.stringify(r,null,2)}]})}case"create_issue":{let o=await Ta(t,i);return await Bt(t),O(e.id,{content:[{type:"text",text:o}]})}case"close_issue":{let o=await qa(t,i);return await Bt(t),O(e.id,{content:[{type:"text",text:o}]})}case"update_issue":{let o=await Ha(t,i);return await Bt(t),O(e.id,{content:[{type:"text",text:o}]})}case"list_commands":{let o=Y(t,".claude","commands"),r=Y(An(),".claude","commands"),a=new Set,c=[];for(let p of[o,r])if(kt(p))for(let d of Pn(p))d.endsWith(".md")&&!a.has(d)&&(a.add(d),c.push(d));if(c.length===0)return O(e.id,{content:[{type:"text",text:"No slash commands installed. Run: codebase setup"}]});let l=c.map(p=>"/"+p.replace(/\.md$/,"")).join(", ");return O(e.id,{content:[{type:"text",text:`Installed commands (${c.length}): ${l}
625
625
 
626
626
  Loop: /simulate \u2192 /build \u2192 /launch`}]})}case"list_skills":{let o=Y(An(),".claude","skills"),r=Y(t,".claude","skills"),a=new Set,c=[];for(let p of[r,o])if(kt(p))for(let d of Pn(p))d.endsWith(".skill")&&!a.has(d)&&(a.add(d),c.push({file:d,dir:p}));if(c.length===0)return O(e.id,{content:[{type:"text",text:"No skills installed in ~/.claude/skills/ or <project>/.claude/skills/. Run: codebase setup"}]});let l=[];return await Promise.all(c.map(({file:p,dir:d})=>new Promise(m=>{let y=Y(d,p);In("unzip",["-p",y,"*/SKILL.md"],{timeout:1e4},(b,x)=>{if(b||!x.trim()){m();return}let j=x.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!j){m();return}let E=j[1],f=E.match(/^name:\s*(.+)$/m),P=E.match(/^description:\s*(.+)$/m),A=f?f[1].trim():p.replace(/\.skill$/,""),G=P?P[1].trim():"";l.push({name:A,description:G,file:p}),m()})}))),O(e.id,{content:[{type:"text",text:JSON.stringify(l,null,2)}]})}case"get_plan":{let o=Y(Dn(t),"PLAN.md");if(!kt(o))return O(e.id,{content:[{type:"text",text:"No PLAN.md found. Use update_plan to create one."}]});let r=await Qe(o,"utf-8");return O(e.id,{content:[{type:"text",text:r}]})}case"update_plan":{let o=Y(Dn(t),"PLAN.md"),r=i.message,c=`
627
627
  <!-- updated: ${new Date().toISOString().split("T")[0]} -->
@@ -704,6 +704,6 @@ ${n}`;await Jn(e,o,"utf-8"),u(`${w("Created")} PLAN.md`);return}let i=await Wn(e
704
704
  ## Update Log
705
705
  ${n}`,await Jn(e,i,"utf-8"),u(`${w("Updated")} PLAN.md`)}M();import{join as Kt,resolve as vc}from"path";import{existsSync as $c,readdirSync as xc}from"fs";import{execFile as jc}from"child_process";function Sc(e){return new Promise((t,s)=>{jc("unzip",["-p",e,"*/SKILL.md"],(n,i)=>{n&&!i?s(n):t(i??"")})})}function Cc(e){let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!t)return{};let s={};for(let n of t[1].split(`
706
706
  `)){let i=n.indexOf(":");if(i===-1)continue;let o=n.slice(0,i).trim(),r=n.slice(i+1).trim().replace(/^['"]|['"]$/g,"");o&&(s[o]=r)}return s}async function Vn(e){let t=Kt(process.env.HOME??"~",".claude","skills"),s=Kt(vc(e.path??"."),".claude","skills"),n=new Set,i=[];for(let d of[s,t])if($c(d))for(let m of xc(d))m.endsWith(".skill")&&!n.has(m)&&(n.add(m),i.push({file:m,dir:d}));if(i.length===0){u("No skills installed. Run: codebase setup");return}let o=[];for(let{file:d,dir:m}of i){let y=Kt(m,d),b=d.replace(/\.skill$/,""),x="";try{let j=await Sc(y),E=Cc(j);E.name&&(b=E.name),E.description&&(x=E.description)}catch{}o.push({name:b,description:x,file:d})}if(o.length===0){u("No skills installed. Run: codebase setup");return}let r=Math.max(4,...o.map(d=>d.name.length)),a=Math.max(11,...o.map(d=>d.description.length)),c=Math.max(4,...o.map(d=>d.file.length)),l=(d,m)=>d.padEnd(m),p=` ${"\u2500".repeat(r)} ${"\u2500".repeat(a)} ${"\u2500".repeat(c)}`;h(`
707
- ${l("Name",r)} ${l("Description",a)} File`),u(p);for(let d of o)u(` ${l(d.name,r)} ${l(d.description,a)} ${d.file}`);u("")}import{createServer as Rc}from"http";je();import{readFile as Ec,writeFile as _c}from"fs/promises";import{join as Qn}from"path";async function Yn(e,t,s){let n=new URL(e,"http://localhost"),i=n.pathname;if(i==="/health")return{status:200,body:{status:"ok",version:"0.3.2"}};if(i==="/codebase/query"&&t==="GET"){let o=n.searchParams.get("path");if(!o)return{status:400,body:{error:"Missing 'path' query parameter"}};let r=await zt(s);return r?{status:200,body:Ae(r,o)??null}:{status:404,body:{error:"No manifest. POST /codebase/scan first."}}}if(i==="/codebase/scan"&&t==="POST"){let o=await W(s,{quiet:!0});return await _c(Qn(s,".codebase.json"),JSON.stringify(o,null,2),"utf-8"),{status:200,body:o}}if(i==="/codebase"&&t==="GET"){let o=await zt(s);return o?{status:200,body:o}:{status:404,body:{error:"No manifest. POST /codebase/scan first."}}}if(i.startsWith("/codebase/")&&t==="GET"){let o=i.split("/")[2],r=await zt(s);if(!r)return{status:404,body:{error:"No manifest."}};let a=r[o];return a===void 0?{status:404,body:{error:`Category '${o}' not found.`}}:{status:200,body:a}}return{status:404,body:{error:"Not found"}}}async function zt(e){try{let t=await Ec(Qn(e,".codebase.json"),"utf-8");return JSON.parse(t)}catch{return null}}function Xn(e,t){let s=Rc(async(n,i)=>{if(i.setHeader("Access-Control-Allow-Origin","*"),i.setHeader("Access-Control-Allow-Methods","GET, POST, OPTIONS"),i.setHeader("Access-Control-Allow-Headers","Content-Type"),i.setHeader("Content-Type","application/json"),n.method==="OPTIONS"){i.writeHead(200),i.end();return}try{let o=await Yn(n.url||"/",n.method||"GET",e);i.writeHead(o.status),i.end(JSON.stringify(o.body,null,2))}catch{i.writeHead(500),i.end(JSON.stringify({error:"Internal server error"}))}});s.listen(t,()=>{console.log(`codebase server running on http://localhost:${t}`),console.log(`
707
+ ${l("Name",r)} ${l("Description",a)} File`),u(p);for(let d of o)u(` ${l(d.name,r)} ${l(d.description,a)} ${d.file}`);u("")}import{createServer as Rc}from"http";je();import{readFile as Ec,writeFile as _c}from"fs/promises";import{join as Qn}from"path";async function Yn(e,t,s){let n=new URL(e,"http://localhost"),i=n.pathname;if(i==="/health")return{status:200,body:{status:"ok",version:"0.3.4"}};if(i==="/codebase/query"&&t==="GET"){let o=n.searchParams.get("path");if(!o)return{status:400,body:{error:"Missing 'path' query parameter"}};let r=await zt(s);return r?{status:200,body:Ae(r,o)??null}:{status:404,body:{error:"No manifest. POST /codebase/scan first."}}}if(i==="/codebase/scan"&&t==="POST"){let o=await W(s,{quiet:!0});return await _c(Qn(s,".codebase.json"),JSON.stringify(o,null,2),"utf-8"),{status:200,body:o}}if(i==="/codebase"&&t==="GET"){let o=await zt(s);return o?{status:200,body:o}:{status:404,body:{error:"No manifest. POST /codebase/scan first."}}}if(i.startsWith("/codebase/")&&t==="GET"){let o=i.split("/")[2],r=await zt(s);if(!r)return{status:404,body:{error:"No manifest."}};let a=r[o];return a===void 0?{status:404,body:{error:`Category '${o}' not found.`}}:{status:200,body:a}}return{status:404,body:{error:"Not found"}}}async function zt(e){try{let t=await Ec(Qn(e,".codebase.json"),"utf-8");return JSON.parse(t)}catch{return null}}function Xn(e,t){let s=Rc(async(n,i)=>{if(i.setHeader("Access-Control-Allow-Origin","*"),i.setHeader("Access-Control-Allow-Methods","GET, POST, OPTIONS"),i.setHeader("Access-Control-Allow-Headers","Content-Type"),i.setHeader("Content-Type","application/json"),n.method==="OPTIONS"){i.writeHead(200),i.end();return}try{let o=await Yn(n.url||"/",n.method||"GET",e);i.writeHead(o.status),i.end(JSON.stringify(o.body,null,2))}catch{i.writeHead(500),i.end(JSON.stringify({error:"Internal server error"}))}});s.listen(t,()=>{console.log(`codebase server running on http://localhost:${t}`),console.log(`
708
708
  Endpoints:`),console.log(" GET /health Health check"),console.log(" GET /codebase Full manifest"),console.log(" GET /codebase/:category Single category"),console.log(" GET /codebase/query?path=stack.languages"),console.log(" POST /codebase/scan Trigger re-scan")}),process.on("SIGINT",()=>{s.close(),process.exit(0)}),process.on("SIGTERM",()=>{s.close(),process.exit(0)})}var pe=es(process.argv.slice(2));ee(pe.quiet);Qt(pe.verbose);pe.helpCommand&&pe.command&&ts(pe.command);var Pc={scan:Ge,init:bn,brief:yn,next:wn,setup:Tt,query:vn,issue:En,status:Rn,mcp:Ln,doctor:qn,fix:Un,release:Bn,plan:zn,skills:Vn,serve:e=>(Xn(e.path,e.port??3e3),Promise.resolve()),"scan-only":Ge};os().catch(()=>{});var[Dc]=process.versions.node.split(".").map(Number);Dc<20&&(console.error(`Error: Node.js 20 or higher is required. You are running v${process.versions.node}.`),console.error("Upgrade: https://nodejs.org"),process.exit(1));var Zn=Pc[pe.command];Zn||(v(`Unknown command: ${pe.command}`),h(`Run ${w("codebase --help")} to see all commands.`),process.exit(1));Zn(pe).catch(e=>{v(`Error: ${e.message}`);let t=e.message.toLowerCase();t.includes("not a git repository")?h(`Initialize git first: ${w("git init")}`):t.includes("permission denied")?h("Check file permissions or run with appropriate access"):t.includes("enoent")&&t.includes("gh")?h(`GitHub CLI (gh) is not installed. Install it: ${w("brew install gh && gh auth login")}`):t.includes("no such file")?h("Check that the path is correct"):t.includes("github")&&(h(`Ensure GitHub CLI is installed: ${w("gh --version")}`),h(`Authenticate: ${w("gh auth login")}`)),process.exit(1)});
709
709
  //# sourceMappingURL=index.js.map