vibe-code-explainer 0.2.0 → 0.3.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 +152 -55
- package/dist/{chunk-5NCRRHU7.js → chunk-JPDU5ASR.js} +9 -1
- package/dist/chunk-JPDU5ASR.js.map +1 -0
- package/dist/chunk-KS3PATTI.js +429 -0
- package/dist/chunk-KS3PATTI.js.map +1 -0
- package/dist/chunk-Y55I7ZS5.js +604 -0
- package/dist/chunk-Y55I7ZS5.js.map +1 -0
- package/dist/cli/index.js +6 -6
- package/dist/{config-H57D4GXB.js → config-74UP7RRD.js} +109 -2
- package/dist/config-74UP7RRD.js.map +1 -0
- package/dist/hooks/post-tool.js +62 -26
- package/dist/hooks/post-tool.js.map +1 -1
- package/dist/{init-KUVD2YGA.js → init-OTODBBPP.js} +19 -3
- package/dist/init-OTODBBPP.js.map +1 -0
- package/dist/ollama-PGPTPYS4.js +14 -0
- package/dist/{schema-TBXFNCIG.js → schema-TEWSY7EF.js} +4 -2
- package/dist/{tracker-HCWPUZIO.js → tracker-4ORSFJQB.js} +4 -2
- package/dist/{uninstall-CNGJWJYQ.js → uninstall-PN7724RX.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-5NCRRHU7.js.map +0 -1
- package/dist/chunk-W67RX53R.js +0 -347
- package/dist/chunk-W67RX53R.js.map +0 -1
- package/dist/chunk-YS2XIZIA.js +0 -544
- package/dist/chunk-YS2XIZIA.js.map +0 -1
- package/dist/config-H57D4GXB.js.map +0 -1
- package/dist/init-KUVD2YGA.js.map +0 -1
- package/dist/ollama-34TOVCUY.js +0 -12
- /package/dist/{ollama-34TOVCUY.js.map → ollama-PGPTPYS4.js.map} +0 -0
- /package/dist/{schema-TBXFNCIG.js.map → schema-TEWSY7EF.js.map} +0 -0
- /package/dist/{tracker-HCWPUZIO.js.map → tracker-4ORSFJQB.js.map} +0 -0
- /package/dist/{uninstall-CNGJWJYQ.js.map → uninstall-PN7724RX.js.map} +0 -0
package/README.md
CHANGED
|
@@ -16,30 +16,57 @@ No more accepting code blindly.
|
|
|
16
16
|
**Safe change (low/no risk):**
|
|
17
17
|
|
|
18
18
|
```
|
|
19
|
-
|
|
20
|
-
│
|
|
21
|
-
│
|
|
22
|
-
│
|
|
23
|
-
│
|
|
24
|
-
│
|
|
25
|
-
│
|
|
26
|
-
│
|
|
27
|
-
|
|
19
|
+
╭─ vibe-code-explainer ─────────────────────────╮
|
|
20
|
+
│ │
|
|
21
|
+
│ 📄 src/app/page.tsx │
|
|
22
|
+
│ │
|
|
23
|
+
│ ▸ Impact │
|
|
24
|
+
│ Changed page background from solid dark │
|
|
25
|
+
│ blue to a gradient. │
|
|
26
|
+
│ │
|
|
27
|
+
│ ▸ How it works │
|
|
28
|
+
│ `bg-gradient-to-br` + `from-`/`to-` Tailwind │
|
|
29
|
+
│ utilities generate a CSS linear-gradient. │
|
|
30
|
+
│ │
|
|
31
|
+
│ ▸ Why │
|
|
32
|
+
│ Tailwind: utility classes for gradients │
|
|
33
|
+
│ instead of writing custom CSS. │
|
|
34
|
+
│ │
|
|
35
|
+
│ ┄ ─ ┄ ─ ┄ ─ ┄ ─ ┄ ─ ┄ ─ ┄ ─ ┄ ─ ┄ ─ ┄ ─ ┄ │
|
|
36
|
+
│ │
|
|
37
|
+
│ ✓ Risk: None │
|
|
38
|
+
│ │
|
|
39
|
+
╰─────────────────────────────────────────────────╯
|
|
28
40
|
```
|
|
29
41
|
|
|
30
42
|
**Risky change (medium/high risk):**
|
|
31
43
|
|
|
32
44
|
```
|
|
33
|
-
|
|
34
|
-
│
|
|
35
|
-
│
|
|
36
|
-
│
|
|
37
|
-
│
|
|
38
|
-
│
|
|
39
|
-
│
|
|
40
|
-
│
|
|
41
|
-
│
|
|
42
|
-
|
|
45
|
+
╭─ vibe-code-explainer ─────────────────────────╮ ← red border
|
|
46
|
+
│ │
|
|
47
|
+
│ 📄 .env │
|
|
48
|
+
│ │
|
|
49
|
+
│ ▸ Impact │
|
|
50
|
+
│ Added a Stripe payment secret key directly │
|
|
51
|
+
│ in the environment file. │
|
|
52
|
+
│ │
|
|
53
|
+
│ ▸ How it works │
|
|
54
|
+
│ `.env` files store environment variables, │
|
|
55
|
+
│ read by your code at runtime. `sk_live_` │
|
|
56
|
+
│ is Stripe's prefix for production keys. │
|
|
57
|
+
│ │
|
|
58
|
+
│ ▸ Why │
|
|
59
|
+
│ Convention: secrets live in .env files that │
|
|
60
|
+
│ are kept out of git via .gitignore. │
|
|
61
|
+
│ │
|
|
62
|
+
│ ┄ ─ ┄ ─ ┄ ─ ┄ ─ ┄ ─ ┄ ─ ┄ ─ ┄ ─ ┄ ─ ┄ ─ ┄ │
|
|
63
|
+
│ │
|
|
64
|
+
│ 🚨 Risk: High │
|
|
65
|
+
│ A live Stripe production key is hardcoded. │
|
|
66
|
+
│ Make sure .env is in .gitignore before │
|
|
67
|
+
│ committing. │
|
|
68
|
+
│ │
|
|
69
|
+
╰─────────────────────────────────────────────────╯
|
|
43
70
|
```
|
|
44
71
|
|
|
45
72
|
---
|
|
@@ -112,9 +139,15 @@ exist, so you can set a global default and override per-project.
|
|
|
112
139
|
|
|
113
140
|
#### 3. Detail level
|
|
114
141
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
- **
|
|
142
|
+
This is also the **teacher mode** switch:
|
|
143
|
+
|
|
144
|
+
- **Minimal** — single sentence describing the impact. **No teaching.** Use
|
|
145
|
+
this if you just want to know what changed without any educational content.
|
|
146
|
+
- **Standard** — three sections per change: **Impact** (what changes for the
|
|
147
|
+
user), **How it works** (mechanical explanation of the syntax/concept),
|
|
148
|
+
**Why** (why this approach was used). Recommended.
|
|
149
|
+
- **Verbose** — same three sections, each more in-depth (2–4 sentences).
|
|
150
|
+
Plus a fourth **Deeper dive** section with related terms to look up.
|
|
118
151
|
|
|
119
152
|
#### 4. Language
|
|
120
153
|
|
|
@@ -123,10 +156,25 @@ Pick the language the explanations are written in. Supported:
|
|
|
123
156
|
English, Portuguese, Spanish, French, German, Italian, Chinese, Japanese,
|
|
124
157
|
Korean.
|
|
125
158
|
|
|
126
|
-
Only the
|
|
127
|
-
risk labels (`none` / `low` /
|
|
159
|
+
Only the natural-language fields (impact, howItWorks, why, deepDive items,
|
|
160
|
+
riskReason) are translated. JSON keys and risk labels (`none` / `low` /
|
|
161
|
+
`medium` / `high`) stay in English so parsing stays stable.
|
|
162
|
+
|
|
163
|
+
#### 5. Programming knowledge level (only when teaching is on)
|
|
164
|
+
|
|
165
|
+
If you picked Standard or Verbose, the installer asks how much you already
|
|
166
|
+
know about programming. This calibrates the depth of the teaching:
|
|
128
167
|
|
|
129
|
-
|
|
168
|
+
- **Never programmed** — explanations start from "what is a variable" when
|
|
169
|
+
needed. Uses everyday-life analogies.
|
|
170
|
+
- **Just starting out** — explains new technical terms, doesn't re-teach
|
|
171
|
+
basics like variables and functions.
|
|
172
|
+
- **Read code with difficulty** — assumes core concepts, focuses on idiomatic
|
|
173
|
+
patterns and what specific syntax accomplishes.
|
|
174
|
+
- **Code regularly** — concise. Mentions modern features, gotchas, and
|
|
175
|
+
alternatives rather than syntax basics.
|
|
176
|
+
|
|
177
|
+
#### 6. Model (Ollama only)
|
|
130
178
|
|
|
131
179
|
- If you have an NVIDIA GPU, the installer auto-detects your VRAM and picks
|
|
132
180
|
the right model.
|
|
@@ -214,27 +262,50 @@ Every explanation includes a risk rating:
|
|
|
214
262
|
|
|
215
263
|
## Configuration
|
|
216
264
|
|
|
217
|
-
Change any setting at any time by running
|
|
265
|
+
Change any setting at any time by running `config`. Which command depends on
|
|
266
|
+
how you installed it:
|
|
267
|
+
|
|
268
|
+
**If you installed globally** (the package is on your PATH):
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
vibe-code-explainer config
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
**If you installed per-project** (or want to be safe):
|
|
218
275
|
|
|
219
276
|
```bash
|
|
220
277
|
npx vibe-code-explainer config
|
|
221
278
|
```
|
|
222
279
|
|
|
223
|
-
|
|
224
|
-
|
|
280
|
+
Both commands do the same thing. Use whichever works in your shell. If you
|
|
281
|
+
see a stale version run via `npx`, force the latest with:
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
npx vibe-code-explainer@latest config
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
The menu auto-detects whether to edit the project config (`./code-explainer.config.json`)
|
|
288
|
+
or the global config (`~/.code-explainer.config.json`): project config wins
|
|
289
|
+
if both exist.
|
|
290
|
+
|
|
291
|
+
It opens an interactive menu showing your current settings. Pick what you
|
|
292
|
+
want to change, one at a time. Every change is saved immediately. When you
|
|
293
|
+
change the model, the tool checks whether Ollama already has it pulled and
|
|
294
|
+
offers to download it on the spot if not.
|
|
225
295
|
|
|
226
296
|
```
|
|
227
297
|
code-explainer config (project)
|
|
228
298
|
|
|
229
299
|
Current settings:
|
|
230
|
-
Engine:
|
|
231
|
-
Model:
|
|
232
|
-
Ollama URL:
|
|
233
|
-
Detail level:
|
|
234
|
-
Language:
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
300
|
+
Engine: Local LLM (Ollama)
|
|
301
|
+
Model: qwen3.5:4b
|
|
302
|
+
Ollama URL: http://localhost:11434
|
|
303
|
+
Detail level: standard
|
|
304
|
+
Language: English
|
|
305
|
+
Learner level: Read code with difficulty
|
|
306
|
+
Hooks: Edit ✓ Write ✓ Bash ✓
|
|
307
|
+
Excluded: *.lock, dist/**, node_modules/**
|
|
308
|
+
Skip if slow: 8s
|
|
238
309
|
|
|
239
310
|
? What would you like to change?
|
|
240
311
|
❯ Engine
|
|
@@ -242,6 +313,7 @@ Current settings:
|
|
|
242
313
|
Ollama URL
|
|
243
314
|
Detail level
|
|
244
315
|
Language
|
|
316
|
+
Learner level
|
|
245
317
|
Enable/disable hooks
|
|
246
318
|
File exclusions
|
|
247
319
|
Latency timeout
|
|
@@ -266,8 +338,12 @@ If both exist, the project config takes precedence at runtime.
|
|
|
266
338
|
- **Detail level** — minimal / standard / verbose. See
|
|
267
339
|
[Install → Detail level](#3-detail-level) for what each produces.
|
|
268
340
|
- **Language** — English, Portuguese, Spanish, French, German, Italian,
|
|
269
|
-
Chinese, Japanese, Korean. Applies to the
|
|
270
|
-
|
|
341
|
+
Chinese, Japanese, Korean. Applies to the natural-language fields (impact,
|
|
342
|
+
howItWorks, why, deepDive, riskReason); JSON keys and risk labels stay in
|
|
343
|
+
English.
|
|
344
|
+
- **Learner level** — calibrates teaching depth. Options: never programmed /
|
|
345
|
+
just starting / read code with difficulty / code regularly. See
|
|
346
|
+
[Install → step 5](#5-programming-knowledge-level-only-when-teaching-is-on).
|
|
271
347
|
- **Hooks** — turn on or off individually. If Bash explanations feel noisy,
|
|
272
348
|
disable just that hook and keep Edit + Write.
|
|
273
349
|
- **File exclusions** — glob patterns for files you never want explained.
|
|
@@ -294,6 +370,7 @@ Full config schema:
|
|
|
294
370
|
"ollamaUrl": "http://localhost:11434",
|
|
295
371
|
"detailLevel": "standard",
|
|
296
372
|
"language": "en",
|
|
373
|
+
"learnerLevel": "intermediate",
|
|
297
374
|
"hooks": {
|
|
298
375
|
"edit": true,
|
|
299
376
|
"write": true,
|
|
@@ -322,6 +399,7 @@ Field types:
|
|
|
322
399
|
| `ollamaUrl` | Any valid URL (warns on non-loopback) |
|
|
323
400
|
| `detailLevel` | `"minimal"` / `"standard"` / `"verbose"` |
|
|
324
401
|
| `language` | `"en"` / `"pt"` / `"es"` / `"fr"` / `"de"` / `"it"` / `"zh"` / `"ja"` / `"ko"` |
|
|
402
|
+
| `learnerLevel` | `"none"` / `"beginner"` / `"intermediate"` / `"regular"` |
|
|
325
403
|
| `hooks.edit` / `hooks.write` / `hooks.bash` | `true` or `false` |
|
|
326
404
|
| `exclude` | Array of glob patterns |
|
|
327
405
|
| `skipIfSlowMs` | Number in milliseconds; `0` means never skip |
|
|
@@ -332,10 +410,14 @@ Changes take effect on the next Claude Code tool call — no restart needed.
|
|
|
332
410
|
|
|
333
411
|
## Session tools
|
|
334
412
|
|
|
413
|
+
All commands below accept both forms: `vibe-code-explainer <cmd>` (if
|
|
414
|
+
globally installed, on PATH) or `npx vibe-code-explainer <cmd>` (if per-project).
|
|
415
|
+
|
|
335
416
|
### Summary of what Claude has done
|
|
336
417
|
|
|
337
418
|
```bash
|
|
338
|
-
|
|
419
|
+
vibe-code-explainer summary
|
|
420
|
+
# or: npx vibe-code-explainer summary
|
|
339
421
|
```
|
|
340
422
|
|
|
341
423
|
Prints a report of every explained change in your current Claude Code session:
|
|
@@ -344,7 +426,8 @@ total changes, files touched, risk breakdown, and flagged unrelated files.
|
|
|
344
426
|
### Clear the session
|
|
345
427
|
|
|
346
428
|
```bash
|
|
347
|
-
|
|
429
|
+
vibe-code-explainer session end
|
|
430
|
+
# or: npx vibe-code-explainer session end
|
|
348
431
|
```
|
|
349
432
|
|
|
350
433
|
Clears the session state (tracked files and cache). Run this when you start a
|
|
@@ -353,7 +436,8 @@ new task so the drift-detection summary doesn't include old edits.
|
|
|
353
436
|
### Warm up the model
|
|
354
437
|
|
|
355
438
|
```bash
|
|
356
|
-
|
|
439
|
+
vibe-code-explainer warmup
|
|
440
|
+
# or: npx vibe-code-explainer warmup
|
|
357
441
|
```
|
|
358
442
|
|
|
359
443
|
Sends a trivial diff to Ollama to pre-load the model. Useful if you closed and
|
|
@@ -365,17 +449,29 @@ slow (10–15 seconds) as the model gets loaded into VRAM.
|
|
|
365
449
|
## Uninstall
|
|
366
450
|
|
|
367
451
|
```bash
|
|
368
|
-
|
|
452
|
+
vibe-code-explainer uninstall
|
|
453
|
+
# or: npx vibe-code-explainer uninstall
|
|
369
454
|
```
|
|
370
455
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
456
|
+
The uninstaller auto-detects whether you have a project install, a global
|
|
457
|
+
install, or both. If both exist, it asks which to remove.
|
|
458
|
+
|
|
459
|
+
**Project uninstall:** removes the PostToolUse hook entries from
|
|
460
|
+
`.claude/settings.local.json` and deletes `code-explainer.config.json`. Other
|
|
461
|
+
entries (hooks from other tools, other settings) are preserved.
|
|
374
462
|
|
|
375
|
-
|
|
463
|
+
**Global uninstall:** removes the PostToolUse hooks from
|
|
464
|
+
`~/.claude/settings.json` and deletes `~/.code-explainer.config.json`. The
|
|
465
|
+
globally-installed npm package stays on disk — remove it with:
|
|
376
466
|
|
|
377
467
|
```bash
|
|
378
|
-
|
|
468
|
+
npm uninstall -g vibe-code-explainer
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
Ollama and any pulled models stay installed either way. To remove them:
|
|
472
|
+
|
|
473
|
+
```bash
|
|
474
|
+
ollama rm qwen3.5:4b
|
|
379
475
|
# or whichever model you pulled
|
|
380
476
|
```
|
|
381
477
|
|
|
@@ -395,9 +491,10 @@ Most common causes, in order:
|
|
|
395
491
|
ollama serve
|
|
396
492
|
```
|
|
397
493
|
Then try another edit.
|
|
398
|
-
3. **The engine is misconfigured.** Run `
|
|
399
|
-
check the engine and URL. Try
|
|
400
|
-
test — if that works, Ollama is
|
|
494
|
+
3. **The engine is misconfigured.** Run `vibe-code-explainer config` (or
|
|
495
|
+
`npx vibe-code-explainer config`) and check the engine and URL. Try
|
|
496
|
+
switching to the Claude Code engine as a test — if that works, Ollama is
|
|
497
|
+
the issue.
|
|
401
498
|
4. **The file is excluded.** Check your `exclude` patterns in the config.
|
|
402
499
|
|
|
403
500
|
### The explanation took too long and got skipped
|
|
@@ -405,8 +502,8 @@ Most common causes, in order:
|
|
|
405
502
|
Default timeout is 8 seconds. Cold starts with Ollama (first explanation
|
|
406
503
|
after starting the service) can be 10–15 seconds. Two fixes:
|
|
407
504
|
|
|
408
|
-
- Run `
|
|
409
|
-
- Raise the timeout to 15 seconds via `
|
|
505
|
+
- Run `vibe-code-explainer warmup` right after starting Ollama.
|
|
506
|
+
- Raise the timeout to 15 seconds via `vibe-code-explainer config →
|
|
410
507
|
Latency timeout`.
|
|
411
508
|
|
|
412
509
|
### Explanations are low-quality
|
|
@@ -416,7 +513,7 @@ business logic, security-relevant changes). If explanations feel wrong on
|
|
|
416
513
|
tricky diffs, switch to the Claude Code engine:
|
|
417
514
|
|
|
418
515
|
```bash
|
|
419
|
-
|
|
516
|
+
vibe-code-explainer config
|
|
420
517
|
# → Engine → Claude Code (native)
|
|
421
518
|
```
|
|
422
519
|
|
|
@@ -428,7 +525,7 @@ cost of API tokens per explanation.
|
|
|
428
525
|
Add a glob pattern via the config menu:
|
|
429
526
|
|
|
430
527
|
```
|
|
431
|
-
|
|
528
|
+
vibe-code-explainer config → File exclusions → Add a pattern
|
|
432
529
|
```
|
|
433
530
|
|
|
434
531
|
For example, `*.md` to skip all markdown files, or `src/generated/**` to skip
|
|
@@ -437,7 +534,7 @@ a whole directory.
|
|
|
437
534
|
### I want to turn off Bash explanations but keep Edit/Write
|
|
438
535
|
|
|
439
536
|
```
|
|
440
|
-
|
|
537
|
+
vibe-code-explainer config → Enable/disable hooks
|
|
441
538
|
```
|
|
442
539
|
|
|
443
540
|
Uncheck Bash, keep Edit and Write checked.
|
|
@@ -15,6 +15,12 @@ var LANGUAGE_NAMES = {
|
|
|
15
15
|
ja: "Japanese",
|
|
16
16
|
ko: "Korean"
|
|
17
17
|
};
|
|
18
|
+
var LEARNER_LEVEL_NAMES = {
|
|
19
|
+
none: "Never programmed",
|
|
20
|
+
beginner: "Just starting out",
|
|
21
|
+
intermediate: "Read code with difficulty",
|
|
22
|
+
regular: "Code regularly"
|
|
23
|
+
};
|
|
18
24
|
var CONFIG_FILENAME = "code-explainer.config.json";
|
|
19
25
|
function getGlobalConfigPath() {
|
|
20
26
|
return join(homedir(), ".code-explainer.config.json");
|
|
@@ -25,6 +31,7 @@ var DEFAULT_CONFIG = {
|
|
|
25
31
|
ollamaUrl: "http://localhost:11434",
|
|
26
32
|
detailLevel: "standard",
|
|
27
33
|
language: "en",
|
|
34
|
+
learnerLevel: "intermediate",
|
|
28
35
|
hooks: {
|
|
29
36
|
edit: true,
|
|
30
37
|
write: true,
|
|
@@ -81,9 +88,10 @@ function loadConfig(configPath) {
|
|
|
81
88
|
|
|
82
89
|
export {
|
|
83
90
|
LANGUAGE_NAMES,
|
|
91
|
+
LEARNER_LEVEL_NAMES,
|
|
84
92
|
CONFIG_FILENAME,
|
|
85
93
|
getGlobalConfigPath,
|
|
86
94
|
DEFAULT_CONFIG,
|
|
87
95
|
loadConfig
|
|
88
96
|
};
|
|
89
|
-
//# sourceMappingURL=chunk-
|
|
97
|
+
//# sourceMappingURL=chunk-JPDU5ASR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config/schema.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\n\nexport type Engine = \"ollama\" | \"claude\";\nexport type DetailLevel = \"minimal\" | \"standard\" | \"verbose\";\nexport type RiskLevel = \"none\" | \"low\" | \"medium\" | \"high\";\n\nexport type Language =\n | \"en\"\n | \"pt\"\n | \"es\"\n | \"fr\"\n | \"de\"\n | \"it\"\n | \"zh\"\n | \"ja\"\n | \"ko\";\n\nexport const LANGUAGE_NAMES: Record<Language, string> = {\n en: \"English\",\n pt: \"Portuguese\",\n es: \"Spanish\",\n fr: \"French\",\n de: \"German\",\n it: \"Italian\",\n zh: \"Chinese\",\n ja: \"Japanese\",\n ko: \"Korean\",\n};\n\nexport type LearnerLevel = \"none\" | \"beginner\" | \"intermediate\" | \"regular\";\n\nexport const LEARNER_LEVEL_NAMES: Record<LearnerLevel, string> = {\n none: \"Never programmed\",\n beginner: \"Just starting out\",\n intermediate: \"Read code with difficulty\",\n regular: \"Code regularly\",\n};\n\nexport interface HooksConfig {\n edit: boolean;\n write: boolean;\n bash: boolean;\n}\n\nexport interface BashFilterConfig {\n capturePatterns: string[];\n}\n\nexport interface Config {\n engine: Engine;\n ollamaModel: string;\n ollamaUrl: string;\n detailLevel: DetailLevel;\n language: Language;\n learnerLevel: LearnerLevel;\n hooks: HooksConfig;\n exclude: string[];\n skipIfSlowMs: number;\n bashFilter: BashFilterConfig;\n}\n\nexport interface DeepDiveItem {\n term: string;\n explanation: string;\n}\n\nexport interface ExplanationResult {\n impact: string;\n howItWorks: string;\n why: string;\n deepDive: DeepDiveItem[];\n isSamePattern: boolean;\n samePatternNote: string;\n risk: RiskLevel;\n riskReason: string;\n}\n\nexport interface HookPayload {\n session_id: string;\n transcript_path: string;\n cwd: string;\n permission_mode: string;\n hook_event_name: string;\n tool_name: string;\n tool_input: Record<string, unknown>;\n tool_response: string;\n}\n\nexport const CONFIG_FILENAME = \"code-explainer.config.json\";\n\nexport function getGlobalConfigPath(): string {\n return join(homedir(), \".code-explainer.config.json\");\n}\n\nexport const DEFAULT_CONFIG: Config = {\n engine: \"ollama\",\n ollamaModel: \"qwen3.5:4b\",\n ollamaUrl: \"http://localhost:11434\",\n detailLevel: \"standard\",\n language: \"en\",\n learnerLevel: \"intermediate\",\n hooks: {\n edit: true,\n write: true,\n bash: true,\n },\n exclude: [\"*.lock\", \"dist/**\", \"node_modules/**\"],\n skipIfSlowMs: 8000,\n bashFilter: {\n capturePatterns: [\n \"rm\",\n \"mv\",\n \"cp\",\n \"mkdir\",\n \"npm install\",\n \"pip install\",\n \"yarn add\",\n \"pnpm add\",\n \"chmod\",\n \"chown\",\n \"git checkout\",\n \"git reset\",\n \"git revert\",\n \"sed -i\",\n ],\n },\n};\n\nfunction mergeConfig(base: Config, overlay: Partial<Config>): Config {\n return {\n ...base,\n ...overlay,\n hooks: { ...base.hooks, ...(overlay.hooks ?? {}) },\n bashFilter: {\n ...base.bashFilter,\n ...(overlay.bashFilter ?? {}),\n },\n };\n}\n\nfunction tryReadJson(path: string): Partial<Config> | null {\n if (!existsSync(path)) return null;\n try {\n return JSON.parse(readFileSync(path, \"utf-8\")) as Partial<Config>;\n } catch {\n return null;\n }\n}\n\n/**\n * Load config with three-level resolution, most specific first:\n * 1. Project config (passed as configPath) — overrides everything\n * 2. Global user config (~/.code-explainer.config.json)\n * 3. Built-in defaults\n *\n * A project config that lacks a field falls through to the global; a global\n * that lacks a field falls through to defaults. This lets a global install\n * set everyone's defaults while still allowing per-project overrides.\n */\nexport function loadConfig(configPath: string): Config {\n const globalConfig = tryReadJson(getGlobalConfigPath());\n const projectConfig = tryReadJson(configPath);\n\n let result = DEFAULT_CONFIG;\n if (globalConfig) result = mergeConfig(result, globalConfig);\n if (projectConfig) result = mergeConfig(result, projectConfig);\n return result;\n}\n"],"mappings":";;;AAAA,SAAS,YAAY,oBAAoB;AACzC,SAAS,eAAe;AACxB,SAAS,YAAY;AAiBd,IAAM,iBAA2C;AAAA,EACtD,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAIO,IAAM,sBAAoD;AAAA,EAC/D,MAAM;AAAA,EACN,UAAU;AAAA,EACV,cAAc;AAAA,EACd,SAAS;AACX;AAoDO,IAAM,kBAAkB;AAExB,SAAS,sBAA8B;AAC5C,SAAO,KAAK,QAAQ,GAAG,6BAA6B;AACtD;AAEO,IAAM,iBAAyB;AAAA,EACpC,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,WAAW;AAAA,EACX,aAAa;AAAA,EACb,UAAU;AAAA,EACV,cAAc;AAAA,EACd,OAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA,SAAS,CAAC,UAAU,WAAW,iBAAiB;AAAA,EAChD,cAAc;AAAA,EACd,YAAY;AAAA,IACV,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,YAAY,MAAc,SAAkC;AACnE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,IACH,OAAO,EAAE,GAAG,KAAK,OAAO,GAAI,QAAQ,SAAS,CAAC,EAAG;AAAA,IACjD,YAAY;AAAA,MACV,GAAG,KAAK;AAAA,MACR,GAAI,QAAQ,cAAc,CAAC;AAAA,IAC7B;AAAA,EACF;AACF;AAEA,SAAS,YAAY,MAAsC;AACzD,MAAI,CAAC,WAAW,IAAI,EAAG,QAAO;AAC9B,MAAI;AACF,WAAO,KAAK,MAAM,aAAa,MAAM,OAAO,CAAC;AAAA,EAC/C,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAYO,SAAS,WAAW,YAA4B;AACrD,QAAM,eAAe,YAAY,oBAAoB,CAAC;AACtD,QAAM,gBAAgB,YAAY,UAAU;AAE5C,MAAI,SAAS;AACb,MAAI,aAAc,UAAS,YAAY,QAAQ,YAAY;AAC3D,MAAI,cAAe,UAAS,YAAY,QAAQ,aAAa;AAC7D,SAAO;AACT;","names":[]}
|