dsh-codebase-chat 0.16.3 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,58 +1,89 @@
1
1
  <p align="center">
2
- <img src="https://raw.githubusercontent.com/shinzarou-eng/dsh-codebase-chat/main/docs/assets/logo.svg" width="120" height="120" alt="dsh-codebase-chat logo">
2
+ <img src="https://raw.githubusercontent.com/shinzarou-eng/dsh-codebase-chat/main/docs/assets/logo.png" width="110" height="110" alt="dsh-codebase-chat logo">
3
3
  </p>
4
4
 
5
5
  <h1 align="center">dsh-codebase-chat</h1>
6
6
 
7
7
  <p align="center">
8
- <strong>Multi-language codebase intelligence for DeepSeek Harness and any MCP IDE.</strong><br>
9
- Chat, search, explain, refactor, audit, and generate board-ready reports from local code.
8
+ <strong>Local-first codebase intelligence chat, audit, refactor, and report on any repository.</strong><br>
9
+ DeepSeek Harness plugin &nbsp;·&nbsp; standalone MCP server &nbsp;·&nbsp; CLI
10
10
  </p>
11
11
 
12
12
  <p align="center">
13
- <a href="https://www.npmjs.com/package/dsh-codebase-chat"><img src="https://img.shields.io/npm/v/dsh-codebase-chat?logo=npm&color=blue" alt="npm"></a>
14
- <a href="https://www.npmjs.com/package/dsh-codebase-chat-mcp"><img src="https://img.shields.io/npm/v/dsh-codebase-chat-mcp?logo=npm&color=purple" alt="npm mcp"></a>
15
- <a href="https://github.com/shinzarou-eng/dsh-codebase-chat/releases"><img src="https://img.shields.io/github/v/release/shinzarou-eng/dsh-codebase-chat?logo=github" alt="release"></a>
16
- <a href="./LICENSE"><img src="https://img.shields.io/github/license/shinzarou-eng/dsh-codebase-chat?color=blue" alt="license"></a>
17
- <a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen?logo=nodedotjs" alt="node"></a>
18
- <a href="https://modelcontextprotocol.io"><img src="https://img.shields.io/badge/MCP-Compatible-purple" alt="mcp"></a>
13
+ <a href="https://www.npmjs.com/package/dsh-codebase-chat"><img src="https://img.shields.io/npm/v/dsh-codebase-chat?logo=npm&label=plugin&color=7cc7ff" alt="npm plugin"></a>
14
+ <a href="https://www.npmjs.com/package/dsh-codebase-chat-mcp"><img src="https://img.shields.io/npm/v/dsh-codebase-chat-mcp?logo=npm&label=mcp&color=b08cff" alt="npm mcp"></a>
15
+ <a href="https://github.com/shinzarou-eng/dsh-codebase-chat/blob/main/LICENSE"><img src="https://img.shields.io/github/license/shinzarou-eng/dsh-codebase-chat?color=97a3b0" alt="license"></a>
16
+ <a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D20-5fed83?logo=nodedotjs" alt="node >= 20"></a>
17
+ <a href="https://modelcontextprotocol.io"><img src="https://img.shields.io/badge/MCP-compatible-39c5cf" alt="MCP compatible"></a>
18
+ <a href="https://github.com/shinzarou-eng/dsh-codebase-chat/stargazers"><img src="https://img.shields.io/github/stars/shinzarou-eng/dsh-codebase-chat?style=social" alt="stars"></a>
19
19
  </p>
20
20
 
21
21
  <p align="center">
22
- <a href="https://shinzarou-eng.github.io/dsh-codebase-chat">Website</a> ·
23
- <a href="https://github.com/shinzarou-eng/dsh-codebase-chat/releases">Releases</a> ·
24
- <a href="#install">Install</a> ·
25
- <a href="#mcp">MCP</a> ·
26
- <a href="#commands">Commands</a> ·
27
- <a href="#faq">FAQ</a>
22
+ <a href="https://shinzarou-eng.github.io/dsh-codebase-chat"><strong>Website</strong></a> ·
23
+ <a href="#quick-start">Quick start</a> ·
24
+ <a href="#tool-suite">Tools</a> ·
25
+ <a href="ROADMAP.md">Roadmap</a> ·
26
+ <a href="CHANGELOG.md">Changelog</a> ·
27
+ <a href="CONTRIBUTING.md">Contributing</a>
28
+ </p>
29
+
30
+ <br>
31
+
32
+ <p align="center">
33
+ <img src="docs/assets/demo.gif" alt="dsh-codebase-chat CLI demo" width="820"><br>
34
+ <em>Real terminal output — <a href="docs/assets/demo-mcp.gif">MCP session</a> · <a href="docs/assets/demo-fr.gif">French mode</a></em>
28
35
  </p>
29
36
 
30
37
  ---
31
38
 
32
- ## Why dsh-codebase-chat?
39
+ ## In plain words
33
40
 
34
- Most codebase assistants are **slow, paywalled, or force you to upload source code to the cloud**. **dsh-codebase-chat** runs **locally**, reads only the files you point at, and turns raw code into structured intelligence with **source citations, confidence scores, and severity labels**.
41
+ > **New here?** Point it at a folder of code on your computer. Ask questions in plain
42
+ > language — *"How does login work?"*, *"Is there a hardcoded password?"*, *"What should
43
+ > I fix first?"* — in French or English. Every answer cites the exact file and line it
44
+ > came from, so you can verify it in seconds. Nothing is uploaded anywhere.
35
45
 
36
- | Capability | What it gives you |
46
+ | Term | Meaning |
37
47
  | --- | --- |
38
- | **Chat** | Ask anything about the project in plain language. |
39
- | **Search** | Find symbols, terms, and usages with line references. |
40
- | **Explain** | Understand a file or function with real code excerpts. |
41
- | **Refactor** | Get production-ready code changes with diff rationale. |
42
- | **Intelligence Pro** | CTO-level audit: architecture, tech radar, debt, security, competitors, roadmap. |
43
- | **Audit** | Dedicated non-conformity and tech-debt scan with fixes. |
44
- | **Strategic Report** | Board-ready SWOT, score cards, 90-day roadmap, marketing angle. |
45
- | **Tasks** | Auto-generate `TASKS.md` with sprints, Before/After blocks, and patch application. |
46
- | **Player Brief** | UX / playthrough analysis from a real user perspective. |
47
- | **Crea** | Slogans, taglines, and feature ideas inspired by the code. |
48
+ | **MCP server** | A plug format that lets AI assistants (Claude, Cursor…) use extra tools. Install once, your IDE can "see" your code. |
49
+ | **Index** | Like the index at the back of a book — a map of every function and file, so answers are instant. |
50
+ | **Prompt-only mode** | The tool prepares the context; your existing AI writes the answer. No extra API key, no extra cost. |
51
+ | **Deterministic analysis** | Checks computed directly from your code same input, same result, every time. No guessing. |
52
+
53
+ <details>
54
+ <summary><strong>🇫🇷 En termes simples</strong></summary>
55
+
56
+ <br>
57
+
58
+ Pointez-le vers un dossier de code sur votre ordinateur. Posez des questions en langage
59
+ clair — *« Comment fonctionne la connexion ? », « Y a-t-il un mot de passe codé en dur ? »,
60
+ « Que devrais-je réparer en premier ? »* — en français ou en anglais. Chaque réponse cite
61
+ exactement le fichier et la ligne d'où elle vient, donc vous pouvez vérifier en quelques
62
+ secondes. Rien n'est envoyé sur internet.
63
+
64
+ </details>
65
+
66
+ ---
67
+
68
+ ## Why dsh-codebase-chat?
69
+
70
+ Most codebase assistants are slow, paywalled, or require uploading your source to the cloud.
71
+ **dsh-codebase-chat** runs entirely on your machine: it indexes your repository, retrieves the
72
+ chunks that matter, and assembles a **sourced prompt** — every answer comes back with
73
+ `[source: file:line]` citations, confidence scores, and severity labels.
74
+
75
+ - **Local-first** — indexing, retrieval, and prompt building never leave your machine.
76
+ - **Bilingual** — every prompt, report, and UI string in French and English.
77
+ - **Everywhere** — DeepSeek Harness plugin, standalone MCP server (Cursor, Claude, Windsurf…), and a plain CLI.
78
+ - **Decision-grade output** — not just answers: CTO briefs, audits, TASKS.md plans, board reports.
48
79
 
49
80
  ---
50
81
 
51
82
  ## Quick start
52
83
 
53
- ### 1. DeepSeek Harness plugin
84
+ ### Option A — DeepSeek Harness plugin
54
85
 
55
- ```powershell
86
+ ```bash
56
87
  pnpm add dsh-codebase-chat
57
88
  # or
58
89
  npm install dsh-codebase-chat
@@ -60,75 +91,85 @@ npm install dsh-codebase-chat
60
91
 
61
92
  Then open `http://127.0.0.1:3080` and click the **Codebase Pro** button in the sidebar.
62
93
 
63
- ### 2. Standalone MCP server
94
+ ### Option B MCP server (Cursor, Claude, Windsurf…)
64
95
 
65
96
  ```bash
66
- # Install globally
67
- npm install -g dsh-codebase-chat-mcp
68
-
69
- # Or run without installing
70
97
  npx dsh-codebase-chat-mcp
71
98
  ```
72
99
 
73
- Configure Windsurf / Cursor / Claude:
74
-
75
100
  ```json
76
101
  {
77
102
  "mcpServers": {
78
103
  "dsh-codebase-chat": {
79
104
  "command": "npx",
80
- "args": ["dsh-codebase-chat-mcp"],
81
- "env": {
82
- "DEEPSEEK_API_KEY": "sk-...",
83
- "CODEBASE_MODEL": "deepseek-chat"
84
- }
105
+ "args": ["dsh-codebase-chat-mcp"]
85
106
  }
86
107
  }
87
108
  }
88
109
  ```
89
110
 
90
- See [`mcp/README.md`](mcp/README.md) for the full config.
111
+ > **No API key needed.** Without `DEEPSEEK_API_KEY` / `OPENAI_API_KEY`, the server runs in
112
+ > `promptOnly` mode and hands the assembled context to your host model. See
113
+ > [`mcp/README.md`](mcp/README.md) for direct-LLM configuration.
114
+
115
+ ### Option C — CLI
116
+
117
+ ```bash
118
+ npx dsh-codebase-chat --project C:\my-app --ask "how is auth handled?"
119
+ npx dsh-codebase-chat --project C:\my-app --search "rate limiting"
120
+ npx dsh-codebase-chat --project C:\my-app --file src/auth.ts
121
+ npx dsh-codebase-chat --project C:\my-app --stats
122
+ npx dsh-codebase-chat --project C:\my-app --health # deterministic static analysis, no LLM
123
+ ```
124
+
125
+ `--health` runs entirely offline: circular dependencies, unused files/exports, duplicated
126
+ blocks, complexity hotspots, and a health score — handy as a quick quality gate.
91
127
 
92
- ### 3. From source
128
+ The first run builds a cached index under `CODEBASE_CACHE_DIR`; subsequent runs are incremental.
129
+
130
+ ### From source
93
131
 
94
132
  ```bash
95
133
  git clone https://github.com/shinzarou-eng/dsh-codebase-chat.git
96
134
  cd dsh-codebase-chat
97
- pnpm install
135
+ pnpm install && pnpm build
98
136
  ```
99
137
 
100
138
  ---
101
139
 
102
- ## Commands
103
-
104
- ```powershell
105
- # Ask a question
106
- dsh --profile headless '/codebase "how is auth handled?"'
140
+ ## Tool suite
107
141
 
108
- # Ask with explicit project
109
- dsh --profile headless '/codebase "how is auth handled?" --project C:\my-app'
142
+ Every capability is exposed as a DSH tool, a slash command, and an MCP tool.
110
143
 
111
- # Append a creative idea
112
- dsh --profile headless '/codebase "how does storage work?" --project C:\my-app --crea --crea-theme "slogan"'
144
+ | Tool | What it does |
145
+ | --- | --- |
146
+ | `codebase_chat` | Q&amp;A on your project with cited sources |
147
+ | `codebase_search` | Find symbols, terms, and usages across the repo |
148
+ | `codebase_explain` | Explain a file or symbol — fallback symbol search included |
149
+ | `codebase_refactor` | Propose a concrete refactor with Before/After diff |
150
+ | `codebase_intelligence` | Full CTO brief: architecture, debt, security, roadmap |
151
+ | `codebase_audit` | Tech-debt and non-conformity scan with severity |
152
+ | `codebase_report` | Strategic board report — SWOT, risks, opportunities |
153
+ | `codebase_ceo` | One-page executive brief |
154
+ | `codebase_tasks` | Generate a sprinted `TASKS.md` action plan |
155
+ | `codebase_player` | UX / playthrough brief from a user's point of view |
156
+ | `codebase_crea` | Creative and marketing angles extracted from the code |
157
+ | `codebase_health` | **Deterministic** static analysis — circular deps, dead code, duplication, complexity, health score. No LLM needed |
158
+
159
+ Common parameters: `projectPath`, `lang` (`fr`/`en`), `embed` (local semantic embeddings),
160
+ `promptOnly` (MCP), `style` (reports).
161
+
162
+ ### Slash commands (DeepSeek Harness)
113
163
 
114
- # Search, explain, refactor
164
+ ```powershell
165
+ dsh --profile headless '/codebase "how is auth handled?" --project C:\my-app'
115
166
  dsh --profile headless '/codebase-search "usePetStore" --project C:\my-app'
116
167
  dsh --profile headless '/codebase-explain "storage.ts" --project C:\my-app'
117
168
  dsh --profile headless '/codebase-refactor "split this hook" --file storage.ts --project C:\my-app'
118
-
119
- # Professional briefs
120
169
  dsh --profile headless '/codebase-intel --project C:\my-app'
121
- dsh --profile headless '/codebase-audit --project C:\my-app'
122
- dsh --profile headless '/codebase-report --project C:\my-app'
123
- dsh --profile headless '/codebase-ceo --project C:\my-app'
124
- dsh --profile headless '/codebase-player --project C:\my-app'
125
-
126
- # Tasks & apply
170
+ dsh --profile headless '/codebase-audit --project C:\my-app --lang en'
127
171
  dsh --profile headless '/codebase-tasks --project C:\my-app'
128
- dsh --profile headless '/codebase-tasks-raw --project C:\my-app'
129
172
  dsh --profile headless '/codebase-apply-tasks --project C:\my-app'
130
-
131
- # Build & git
132
173
  dsh --profile headless '/codebase-build --project C:\my-app'
133
174
  dsh --profile headless '/codebase-git --project C:\my-app'
134
175
  ```
@@ -139,123 +180,119 @@ dsh --profile headless '/codebase-git --project C:\my-app'
139
180
 
140
181
  ```mermaid
141
182
  graph LR
142
- A[User query] --> B[Codebase Pro UI / MCP / CLI]
143
- B --> C[Context collector]
144
- C --> D[Project files]
145
- C --> E[Module graph / debt / tests]
146
- C --> F[Prompt builder]
147
- F --> G[LLM]
148
- G --> H[Structured response with citations]
183
+ A[Query] --> B[Index]
184
+ B --> C[Retrieve]
185
+ C --> D[Prompt]
186
+ D --> E[LLM]
187
+ E --> F[Cited answer]
149
188
  ```
150
189
 
151
- 1. **Context collector** reads `package.json`, source files, tests, config, git, build output.
152
- 2. **Module graph** maps who calls who.
153
- 3. **Debt scanner** flags `TODO` / `FIXME` / `HACK` / `console.log` / `any` / `debugger`.
154
- 4. **Prompt builder** assembles a language-aware, evidence-based prompt.
155
- 5. **LLM** returns a response that includes source citations, confidence scores, and severity badges.
156
-
157
- ---
158
-
159
- ## Evidence & scoring
160
-
161
- Every technical claim, risk, and opportunity is marked with:
190
+ 1. **Index** AST + regex extraction builds a symbol-level index, cached on disk and refreshed incrementally (mtime/size based — no full re-reads).
191
+ 2. **Retrieve** lexical scoring plus optional local multilingual embeddings (`Xenova/paraphrase-multilingual-MiniLM-L12-v2`) select the most relevant chunks inside a token budget.
192
+ 3. **Prompt** a language-aware prompt is assembled with module graphs, metrics, debt signals, and file excerpts.
193
+ 4. **Answer** the model responds with `[source: file:line]` citations, `[Confidence: X%]`, and `[Severity: …]` labels.
162
194
 
163
- - `[source: relative/path/file.ts:line]`
164
- - `[Confidence: X%]`
165
- - `[Severity: Critical/High/Medium/Low]`
195
+ ### Safe apply pipeline
166
196
 
167
- No fabricated citations, no hand-waving.
197
+ `/codebase-apply` and `/codebase-apply-tasks` support dry-run, create `.dsh-backups/` copies
198
+ before overwriting, enforce protected paths, and never write outside the selected project.
168
199
 
169
200
  ---
170
201
 
171
- ## Multi-language
172
-
173
- The plugin detects the user's language and generates the entire prompt in that language.
174
-
175
- - `fr` — French
176
- - `en` — English
202
+ ## Configuration
177
203
 
178
- More languages can be added by extending the `build*Prompt` functions.
204
+ | Variable | Default | Purpose |
205
+ | --- | --- | --- |
206
+ | `CODEBASE_CACHE_DIR` | OS cache dir | Where the index cache lives |
207
+ | `DSH_PROJECT_ALIASES` | — | Extra `name=path` project aliases (`;`-separated) |
208
+ | `DSH_DAKO_PROJECT` | — | Override the built-in `dako` alias target |
209
+ | `DSH_PROTECTED_PATHS` | built-in list | Extra paths that can never be patched |
210
+ | `DEEPSEEK_API_KEY` / `OPENAI_API_KEY` | — | MCP direct-LLM mode only |
211
+ | `DEEPSEEK_BASE_URL` / `OPENAI_BASE_URL` | `https://api.deepseek.com/v1` | Custom endpoint |
212
+ | `CODEBASE_MODEL` | `deepseek-chat` | Model for direct-LLM mode |
179
213
 
180
214
  ---
181
215
 
182
- ## Web UI
216
+ ## Project layout
183
217
 
184
- When installed in the **web** profile, the plugin adds a **Codebase Pro** button in the sidebar footer:
185
-
186
- <p align="center">
187
- <img src="https://raw.githubusercontent.com/shinzarou-eng/dsh-codebase-chat/main/docs/assets/codebase-pro-button.svg" alt="Codebase Pro button" width="240">
188
- </p>
189
-
190
- One click opens the brief selector and launches the chosen mode in the user's language.
191
-
192
- ---
218
+ ```
219
+ ├── lib/ DeepSeek Harness plugin (index.js) + Codebase Pro UI (client.js)
220
+ ├── src/ TypeScript engine — indexer, extractor, retriever, tokenizer, context, CLI
221
+ ├── mcp/ Standalone MCP server package (dsh-codebase-chat-mcp)
222
+ ├── test/ Vitest suites (extractor, retriever, tasks pipeline)
223
+ ├── docs/ Landing page (GitHub Pages) + assets
224
+ └── dist/ Build output (tsup)
225
+ ```
193
226
 
194
- ## Install as a DSH plugin
227
+ ### Development
195
228
 
196
- ```powershell
197
- dsh plugin --profile headless add dsh-codebase-chat
198
- dsh plugin --profile web add dsh-codebase-chat
229
+ ```bash
230
+ pnpm install # install workspace deps
231
+ pnpm build # tsup dist/
232
+ pnpm test # vitest run
233
+ pnpm typecheck # tsc --noEmit
199
234
  ```
200
235
 
201
- For a local development build, use the `file:` path to your clone.
202
-
203
236
  ---
204
237
 
205
238
  ## FAQ
206
239
 
207
- **Does it send my code to the cloud?**
208
- No. All context collection and prompt building run on your machine. Only the final prompt is sent to the LLM you configure.
209
-
210
- **Can I use it with Claude, Cursor, or Windsurf?**
211
- Yes. Install `dsh-codebase-chat-mcp` and add it to your MCP server config.
212
-
213
- **Does it work without DeepSeek Harness?**
214
- Yes. The `dsh-codebase-chat-mcp` package is fully standalone.
215
-
216
- **Which languages are supported?**
217
- French and English out of the box. The prompt builders are designed to be extended.
218
-
219
- ---
220
-
221
- ## Troubleshooting
222
-
223
- ### `EADDRINUSE` — port 3080 already in use
240
+ <details>
241
+ <summary><strong>Does it send my code to the cloud?</strong></summary>
242
+ <br>
243
+ No. Indexing, retrieval, and prompt building run on your machine. In MCP prompt-only mode, nothing leaves your machine at all — the host model reads the assembled context directly.
244
+ </details>
245
+
246
+ <details>
247
+ <summary><strong>Do I need an API key?</strong></summary>
248
+ <br>
249
+ Not for the MCP server — without a key it returns the built prompt to the host model. A <code>DEEPSEEK_API_KEY</code> or <code>OPENAI_API_KEY</code> is only needed for direct LLM calls. Inside DeepSeek Harness, the plugin uses your configured model.
250
+ </details>
251
+
252
+ <details>
253
+ <summary><strong>Which languages are supported?</strong></summary>
254
+ <br>
255
+ French and English out of the box via the <code>lang</code> parameter on every tool and command. The prompt builders are designed to be extended.
256
+ </details>
257
+
258
+ <details>
259
+ <summary><strong>Is applying patches safe?</strong></summary>
260
+ <br>
261
+ Yes. Apply workflows support dry-run, create backups before overwriting, enforce protected paths, and keep all writes inside the selected project.
262
+ </details>
263
+
264
+ <details>
265
+ <summary><strong>Troubleshooting: EADDRINUSE on port 3080</strong></summary>
266
+ <br>
224
267
 
225
268
  ```powershell
226
269
  Get-NetTCPConnection -LocalPort 3080 | ForEach-Object { Stop-Process -Id $_.OwningProcess -Force }
227
270
  ```
228
271
 
229
- Then restart `dsh --profile web`.
272
+ Then restart <code>dsh --profile web</code>.
273
+ </details>
230
274
 
231
275
  ---
232
276
 
233
277
  ## Roadmap
234
278
 
235
- - [ ] More language packs
236
- - [ ] VS Code extension
237
- - [ ] Indexed project cache for huge repos
238
- - [ ] Interactive diff viewer in DSH UI
279
+ Highlights — see [ROADMAP.md](ROADMAP.md) for the full plan:
280
+
281
+ - **Next**: tree-sitter parsing (Python, Go, Rust, Java), watch mode, GitHub Issues export
282
+ - **Planned**: VS Code extension, HTTP/SSE transport, PR review mode, report export (HTML/PDF)
283
+ - **Exploring**: multi-repo workspaces, shared team index cache, CI bot
239
284
 
240
285
  ---
241
286
 
242
287
  ## Contributing
243
288
 
244
- 1. Fork the repository
245
- 2. Create a feature branch
246
- 3. Run `node --check lib/index.js` before committing
247
- 4. Open a PR against `main`
248
-
249
- See [CONTRIBUTING.md](https://github.com/shinzarou-eng/dsh-codebase-chat/blob/main/CONTRIBUTING.md) for details.
250
-
251
- ---
289
+ Contributions are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md). Run `pnpm typecheck && pnpm test` before opening a PR.
252
290
 
253
291
  ## Support
254
292
 
255
- Open an issue on [GitHub](https://github.com/shinzarou-eng/dsh-codebase-chat/issues).
256
-
257
- ---
293
+ - [Open an issue](https://github.com/shinzarou-eng/dsh-codebase-chat/issues)
294
+ - [SUPPORT.md](SUPPORT.md)
258
295
 
259
296
  ## License
260
297
 
261
- [MIT](https://github.com/shinzarou-eng/dsh-codebase-chat/blob/main/LICENSE) — Built and maintained by [shinzarou-eng](https://github.com/shinzarou-eng).
298
+ [MIT](LICENSE) — Built and maintained by [shinzarou-eng](https://github.com/shinzarou-eng).
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node