claude-ex 1.2.0 → 1.4.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 +175 -31
- package/dist/claude/claudemd.js +94 -33
- package/dist/claude/claudemd.js.map +1 -1
- package/dist/claude/mcp.js +162 -139
- package/dist/claude/mcp.js.map +1 -1
- package/dist/db/schema.js +64 -13
- package/dist/db/schema.js.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/indexer/index.js +39 -24
- package/dist/indexer/index.js.map +1 -1
- package/dist/query/engine.d.ts +2 -0
- package/dist/query/engine.js +740 -137
- package/dist/query/engine.js.map +1 -1
- package/dist/watcher/daemon.js +19 -12
- package/dist/watcher/daemon.js.map +1 -1
- package/package.json +36 -18
package/README.md
CHANGED
|
@@ -21,7 +21,140 @@ That's it. Open Claude Code — the MCP server starts automatically and gives Cl
|
|
|
21
21
|
2. **Computes PageRank** to identify structurally important symbols
|
|
22
22
|
3. **Runs as MCP server** with the SQLite database held open in memory — every query answers in <5ms
|
|
23
23
|
4. **Watches files** for changes and reindexes in <15ms
|
|
24
|
-
5. **
|
|
24
|
+
5. **Generates CLAUDE.md** with a development cycle that Claude follows automatically
|
|
25
|
+
|
|
26
|
+
## What's New in 1.4.0
|
|
27
|
+
|
|
28
|
+
### Performance Overhaul
|
|
29
|
+
|
|
30
|
+
Every query is now faster. The entire engine was rewritten for speed:
|
|
31
|
+
|
|
32
|
+
- **Prepared statement cache** — SQL is compiled once per db connection, not per call. Every MCP tool invocation skips recompilation.
|
|
33
|
+
- **N+1 query elimination** — `getStats` (4 queries → 1), `getModules` (N+1 → 2), `getFileMap` / `getFileMapCompact` (N+1 → 1 via GROUP_CONCAT)
|
|
34
|
+
- **5 new indexes** — `files(path)`, `symbols(file_id, line_start)`, `file_deps(to_file, from_file)`, `symbols(exported, kind)`, `rankings(pagerank DESC)` — eliminates full table scans in hot-path queries
|
|
35
|
+
- **PageRank O(n) per iteration** — dangling node mass is pre-computed instead of O(n^2) inner loop
|
|
36
|
+
- **Import resolution** — uses pre-computed file set (0 `fs.existsSync` calls) instead of 11 syscalls per import
|
|
37
|
+
- **`transparentReview`** — 80 queries → 25 (lightweight code fetch instead of full `getContext` per caller)
|
|
38
|
+
- **Compact JSON** — MCP responses use `JSON.stringify(result)` instead of pretty-printed (30-50% smaller, 2x faster serialization)
|
|
39
|
+
- **Pre-warm on startup** — statement cache + SQLite page cache are warm before the first tool call
|
|
40
|
+
|
|
41
|
+
### Trigram Search
|
|
42
|
+
|
|
43
|
+
Substring and fuzzy matching, similar to Cursor's Instant Grep approach:
|
|
44
|
+
|
|
45
|
+
- New `symbols_trigram` FTS5 table with `tokenize='trigram'` for substring matches on symbol names, qualified names, and signatures
|
|
46
|
+
- **Two-pass search** — FTS5 word-level search first (fast, ranked), trigram fallback if results are sparse
|
|
47
|
+
- **FTS5 prefix index** (`prefix='2 4'`) — 80% faster prefix/autocomplete queries
|
|
48
|
+
- **NEAR phrase queries** — multi-token searches like `"get user"` use `NEAR` operator for better relevance, falling back to `OR` for partial matches
|
|
49
|
+
|
|
50
|
+
### Development Cycle in CLAUDE.md
|
|
51
|
+
|
|
52
|
+
The generated CLAUDE.md now includes a mandatory development cycle that Claude follows for every code change:
|
|
53
|
+
|
|
54
|
+
1. **Understand** — `search_code` → `get_symbol` → `get_callers` → `get_dependents` before touching anything
|
|
55
|
+
2. **Plan** — identify all affected files/symbols, state the plan if >3 files
|
|
56
|
+
3. **Implement** — edit code, update all callers, `reindex_file` after major changes
|
|
57
|
+
4. **Verify** — re-check callers/dependents, run tests and build
|
|
58
|
+
5. **Review** — `review_diff` for graph-aware risk assessment
|
|
59
|
+
|
|
60
|
+
Each step has a gate condition and a quick-reference table mapping steps to tools. Claude won't skip steps.
|
|
61
|
+
|
|
62
|
+
### CLAUDE.md Generator Improvements
|
|
63
|
+
|
|
64
|
+
- **Skip-if-unchanged** — won't rewrite the file if the generated section is identical (no more spurious git diffs)
|
|
65
|
+
- **Marker-safe** — only replaces content between `<!-- claude-ex:start -->` and `<!-- claude-ex:end -->`, preserving all user content before and after
|
|
66
|
+
- **Directive-style MCP docs** — decision guide table tells Claude exactly when to use each tool vs grep
|
|
67
|
+
- **Development cycle** — enforced process section (see above)
|
|
68
|
+
|
|
69
|
+
### Test Suite
|
|
70
|
+
|
|
71
|
+
93 tests across 5 files, runnable via `npm test`:
|
|
72
|
+
|
|
73
|
+
- **`tests/schema.test.ts`** (17) — database creation, tables, indexes, FTS, CRUD operations
|
|
74
|
+
- **`tests/engine.test.ts`** (25) — search, callers, context, impact, stats, file map, type hierarchy, dead exports, package usages
|
|
75
|
+
- **`tests/indexer.test.ts`** (10) — full index, file dependencies, PageRank, re-index, parser integration
|
|
76
|
+
- **`tests/claudemd.test.ts`** (11) — markers, user content preservation, skip-if-unchanged, development cycle
|
|
77
|
+
- **`tests/perf.test.ts`** (18) — performance gates (<50ms per query), data integrity (PageRank sum, no orphans, FTS sync)
|
|
78
|
+
|
|
79
|
+
### Other Improvements
|
|
80
|
+
|
|
81
|
+
- **Batch watcher debounce** — burst of file saves → single reindex batch (300ms window)
|
|
82
|
+
- **Memoized tool list** — MCP `ListTools` response allocated once, not per request
|
|
83
|
+
- **Cached insert statements** — `insertSymbol`, `insertEdge`, `insertPkgDep`, etc. use WeakMap-cached prepared statements
|
|
84
|
+
|
|
85
|
+
## Transparent Review (`transparent_review`)
|
|
86
|
+
|
|
87
|
+
Zero-black-box code review. Instead of dumping JSON metadata, it produces a **readable English narrative** that shows you exactly what changed and why it matters — no interpretation required.
|
|
88
|
+
|
|
89
|
+
### Usage
|
|
90
|
+
|
|
91
|
+
In Claude Code, use the `transparent_review` MCP tool, or from the CLI:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
claude-ex transparent-review Review the last commit
|
|
95
|
+
claude-ex transparent-review staged Review staged changes
|
|
96
|
+
claude-ex transparent-review branch Review current branch vs main (PR review)
|
|
97
|
+
claude-ex transparent-review abc1234 Review a specific commit
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### What you get
|
|
101
|
+
|
|
102
|
+
For every changed symbol, the review shows:
|
|
103
|
+
|
|
104
|
+
1. **Exact before/after code** — the old version is found by name in git history, not by shifted line numbers
|
|
105
|
+
2. **Plain-English description** — "Partially modified. 2 lines added. Added error handling (try/catch). 1 new conditional branch."
|
|
106
|
+
3. **Per-symbol diff snippets** — the actual `+`/`-` lines scoped to that symbol
|
|
107
|
+
4. **Caller impact stories** — which functions in other files call the changed code, their source, and whether they'll break or just see behavior changes
|
|
108
|
+
5. **Blast radius by depth** — direct importers vs 2-3 levels deep, with symbol counts
|
|
109
|
+
6. **Risk assessment** — PageRank importance, cascade risk for widely-used exports, API signature changes, broken imports from deleted files
|
|
110
|
+
|
|
111
|
+
### Example output
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
## What Changed (file by file)
|
|
115
|
+
|
|
116
|
+
### `src/auth/session.ts` — modified
|
|
117
|
+
+12 / -3 lines
|
|
118
|
+
|
|
119
|
+
#### `validateToken` — function (exported)
|
|
120
|
+
|
|
121
|
+
What changed: Partially modified. Signature changed. 1 new parameter(s) added.
|
|
122
|
+
Added error handling (try/catch). 1 new conditional branch.
|
|
123
|
+
|
|
124
|
+
[Before/After code shown inline]
|
|
125
|
+
[Diff snippet for this symbol]
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
## Who Gets Affected
|
|
129
|
+
|
|
130
|
+
2 caller(s) in other files use the changed exports:
|
|
131
|
+
|
|
132
|
+
- **handleRequest** in `src/routes/api.ts`
|
|
133
|
+
calls validateToken. Signature changed, so this caller may need updating.
|
|
134
|
+
[Caller code shown]
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
## Blast Radius
|
|
138
|
+
|
|
139
|
+
3 file(s) could be transitively affected:
|
|
140
|
+
|
|
141
|
+
Direct importers (2 files):
|
|
142
|
+
- `src/routes/api.ts` (8 symbols)
|
|
143
|
+
- `src/middleware/auth.ts` (3 symbols)
|
|
144
|
+
|
|
145
|
+
2 levels deep (1 file):
|
|
146
|
+
- `src/app.ts` (12 symbols)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### How it differs from `review_diff`
|
|
150
|
+
|
|
151
|
+
| `review_diff` | `transparent_review` |
|
|
152
|
+
|---|---|
|
|
153
|
+
| Returns structured JSON | Returns readable markdown narrative |
|
|
154
|
+
| Lists changed symbol names | Shows actual before/after code |
|
|
155
|
+
| Lists affected dependents | Explains *how* each caller is affected |
|
|
156
|
+
| Risk flags as strings | Risk assessment with context and reasoning |
|
|
157
|
+
| You need to interpret the data | You read it and understand what happened |
|
|
25
158
|
|
|
26
159
|
## Code Review (`/review`)
|
|
27
160
|
|
|
@@ -51,44 +184,55 @@ In Claude Code, type:
|
|
|
51
184
|
- Cross-file concerns
|
|
52
185
|
- Verdict + action items
|
|
53
186
|
|
|
54
|
-
### When it helps most
|
|
55
|
-
|
|
56
|
-
- Multi-file refactors — catches "you changed X but 12 callers need updates"
|
|
57
|
-
- Exported API changes — flags widely-used exports that were modified
|
|
58
|
-
- Large PRs — risk signals help prioritize what to look at
|
|
59
|
-
- Deleted files — warns if something still imports from them
|
|
60
|
-
|
|
61
187
|
## MCP Tools
|
|
62
188
|
|
|
63
189
|
| Tool | What it does | Speed |
|
|
64
190
|
|------|-------------|-------|
|
|
65
|
-
| `search_code` | Hybrid FTS5 + PageRank search |
|
|
66
|
-
| `get_symbol` | Full context for a symbol |
|
|
67
|
-
| `get_callers` | Who calls this function |
|
|
68
|
-
| `get_dependents` | What breaks if a file changes |
|
|
69
|
-
| `get_dependencies` | What a symbol depends on |
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
191
|
+
| `search_code` | Hybrid FTS5 + trigram + PageRank search | <3ms |
|
|
192
|
+
| `get_symbol` | Full context for a symbol | <4ms |
|
|
193
|
+
| `get_callers` | Who calls this function | <3ms |
|
|
194
|
+
| `get_dependents` | What breaks if a file changes | <5ms |
|
|
195
|
+
| `get_dependencies` | What a symbol depends on | <3ms |
|
|
196
|
+
| `get_file_map` | Every file and its exports | <5ms |
|
|
197
|
+
| `get_file_symbols` | All symbols in a file | <3ms |
|
|
198
|
+
| `find_files` | Find files by glob pattern | <3ms |
|
|
199
|
+
| `find_by_kind` | All classes, interfaces, enums, etc. | <5ms |
|
|
200
|
+
| `get_type_hierarchy` | Subclasses/implementors | <3ms |
|
|
201
|
+
| `find_dead_exports` | Exported symbols nothing imports | <10ms |
|
|
202
|
+
| `get_pkg_usages` | Files importing a given package | <3ms |
|
|
203
|
+
| `get_architecture` | Project overview | <5ms |
|
|
204
|
+
| `reindex_file` | Re-index after edits | <15ms |
|
|
205
|
+
| `review_diff` | Graph-aware diff review (structured JSON) | 10-50ms |
|
|
206
|
+
| `transparent_review` | Zero-black-box review narrative (readable English) | 15-80ms |
|
|
72
207
|
|
|
73
208
|
## CLI Commands
|
|
74
209
|
|
|
75
210
|
```
|
|
76
|
-
claude-ex init [path]
|
|
77
|
-
claude-ex review [target]
|
|
78
|
-
claude-ex
|
|
79
|
-
claude-ex
|
|
80
|
-
claude-ex
|
|
81
|
-
claude-ex
|
|
82
|
-
claude-ex
|
|
83
|
-
claude-ex
|
|
84
|
-
claude-ex
|
|
85
|
-
claude-ex
|
|
86
|
-
claude-ex
|
|
87
|
-
claude-ex
|
|
88
|
-
claude-ex
|
|
89
|
-
claude-ex
|
|
90
|
-
claude-ex
|
|
91
|
-
claude-ex
|
|
211
|
+
claude-ex init [path] Index + install config + generate docs
|
|
212
|
+
claude-ex transparent-review [target] Zero-black-box review (before/after code, English, blast radius)
|
|
213
|
+
claude-ex review [target] Graph-aware diff review (structured JSON)
|
|
214
|
+
claude-ex search <query> Search symbols
|
|
215
|
+
claude-ex callers <symbol> Find callers
|
|
216
|
+
claude-ex context <symbol> Full symbol context
|
|
217
|
+
claude-ex impact <file> Impact analysis
|
|
218
|
+
claude-ex deps <symbol> Dependencies
|
|
219
|
+
claude-ex rank Top symbols by PageRank
|
|
220
|
+
claude-ex modules Module map
|
|
221
|
+
claude-ex stats Index statistics
|
|
222
|
+
claude-ex brief Project summary (SessionStart hook)
|
|
223
|
+
claude-ex pre-edit <file> Pre-edit context (PreToolUse hook)
|
|
224
|
+
claude-ex post-edit <file> Post-edit reindex (PostToolUse hook)
|
|
225
|
+
claude-ex generate-docs Regenerate CLAUDE.md
|
|
226
|
+
claude-ex mcp Run as MCP server
|
|
227
|
+
claude-ex uninstall Remove all config
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Testing
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
npm test Run all 93 tests
|
|
234
|
+
npm run test:watch Watch mode
|
|
235
|
+
npm run prepush Build + test (pre-push validation)
|
|
92
236
|
```
|
|
93
237
|
|
|
94
238
|
## Supported Languages
|
package/dist/claude/claudemd.js
CHANGED
|
@@ -88,35 +88,89 @@ function generateClaudeMd(rootDir, db) {
|
|
|
88
88
|
lines.push(fileMap);
|
|
89
89
|
lines.push('');
|
|
90
90
|
}
|
|
91
|
+
// MCP tool guidance — directive style so Claude actually uses them
|
|
91
92
|
lines.push('## Codex MCP Tools — USE THESE');
|
|
92
93
|
lines.push('');
|
|
93
94
|
lines.push('This project has a live code index via MCP. **Always prefer these over grep/ripgrep for structural queries.** They are faster, rank-aware, and understand code relationships.');
|
|
94
95
|
lines.push('');
|
|
95
|
-
lines.push('
|
|
96
|
-
lines.push('
|
|
97
|
-
lines.push('
|
|
98
|
-
lines.push('
|
|
99
|
-
lines.push('
|
|
100
|
-
lines.push('
|
|
101
|
-
lines.push('
|
|
102
|
-
lines.push('
|
|
103
|
-
lines.push('
|
|
104
|
-
lines.push('
|
|
105
|
-
lines.push('
|
|
106
|
-
lines.push('
|
|
107
|
-
lines.push('
|
|
108
|
-
lines.push('
|
|
109
|
-
lines.push('
|
|
110
|
-
lines.push('
|
|
111
|
-
lines.push('
|
|
112
|
-
lines.push('');
|
|
113
|
-
lines.push('
|
|
114
|
-
lines.push('
|
|
115
|
-
lines.push('
|
|
116
|
-
lines.push('-
|
|
117
|
-
lines.push('-
|
|
118
|
-
lines.push('-
|
|
119
|
-
lines.push('
|
|
96
|
+
lines.push('### When to use which tool');
|
|
97
|
+
lines.push('');
|
|
98
|
+
lines.push('**Finding code** — use instead of Grep/Glob:');
|
|
99
|
+
lines.push('- `search_code` — find symbols by name or description (PageRank-ranked). Use this FIRST for any "where is X" or "find X" query.');
|
|
100
|
+
lines.push('- `find_files` — find files by glob pattern (e.g. `**/*.test.ts`). Use instead of shell find/ls.');
|
|
101
|
+
lines.push('- `get_file_map` — full project map with every file and its exports. Use to orient yourself in an unfamiliar codebase.');
|
|
102
|
+
lines.push('');
|
|
103
|
+
lines.push('**Before modifying code** — always check impact:');
|
|
104
|
+
lines.push('- `get_symbol` — full context for a symbol (code, deps, dependents, co-located symbols). Read this before editing any function/class.');
|
|
105
|
+
lines.push('- `get_callers` — all callers of a function. Check before renaming, changing signatures, or deleting.');
|
|
106
|
+
lines.push('- `get_dependents` — all files transitively affected if a file changes. Check before refactoring exports.');
|
|
107
|
+
lines.push('- `get_dependencies` — what a symbol imports/uses.');
|
|
108
|
+
lines.push('');
|
|
109
|
+
lines.push('**Understanding structure:**');
|
|
110
|
+
lines.push('- `get_file_symbols` — all symbols in a file (not just exports).');
|
|
111
|
+
lines.push('- `find_by_kind` — find all classes, interfaces, enums, etc. across the project.');
|
|
112
|
+
lines.push('- `get_type_hierarchy` — subclasses/implementors of a class or interface.');
|
|
113
|
+
lines.push('- `get_pkg_usages` — files that import a given npm package (use before swapping libraries).');
|
|
114
|
+
lines.push('- `get_architecture` — project overview with top symbols and module dependency map.');
|
|
115
|
+
lines.push('');
|
|
116
|
+
lines.push('**Maintenance:**');
|
|
117
|
+
lines.push('- `find_dead_exports` — exported symbols nothing imports (dead code candidates).');
|
|
118
|
+
lines.push('- `reindex_file` — re-index a file after major edits to keep results fresh.');
|
|
119
|
+
lines.push('- `review_diff` — graph-aware diff review: changed symbols, callers, blast radius, risks.');
|
|
120
|
+
lines.push('');
|
|
121
|
+
lines.push('### Decision guide');
|
|
122
|
+
lines.push('');
|
|
123
|
+
lines.push('| You want to... | Use this | Not this |');
|
|
124
|
+
lines.push('|---|---|---|');
|
|
125
|
+
lines.push('| Find a function/class | `search_code` | Grep/ripgrep |');
|
|
126
|
+
lines.push('| Find files by name | `find_files` | shell find/ls/Glob |');
|
|
127
|
+
lines.push('| See what a file exports | `get_file_symbols` | Read entire file |');
|
|
128
|
+
lines.push('| Check who calls X | `get_callers` | Grep for function name |');
|
|
129
|
+
lines.push('| Understand blast radius | `get_dependents` | Manual file tracing |');
|
|
130
|
+
lines.push('| Find a literal string/regex | Grep (built-in) | — |');
|
|
131
|
+
lines.push('');
|
|
132
|
+
// Development cycle — enforce process automatically
|
|
133
|
+
lines.push('## Development Cycle — FOLLOW THIS');
|
|
134
|
+
lines.push('');
|
|
135
|
+
lines.push('For every code change, follow this cycle. Do not skip steps.');
|
|
136
|
+
lines.push('');
|
|
137
|
+
lines.push('### 1. Understand (before touching anything)');
|
|
138
|
+
lines.push('- Run `search_code` or `get_file_map` to locate the relevant code.');
|
|
139
|
+
lines.push('- Run `get_symbol` on every function/class you plan to modify — read its full context, dependencies, and dependents.');
|
|
140
|
+
lines.push('- Run `get_callers` on any function whose signature, behavior, or name will change. Know who depends on it.');
|
|
141
|
+
lines.push('- Run `get_dependents` on any file whose exports will change. Know the blast radius.');
|
|
142
|
+
lines.push('- If unfamiliar with the area, run `get_architecture` to see how modules connect.');
|
|
143
|
+
lines.push('');
|
|
144
|
+
lines.push('### 2. Plan (decide what to change)');
|
|
145
|
+
lines.push('- From step 1, you now know: what the code does, who calls it, and what breaks if it changes.');
|
|
146
|
+
lines.push('- Identify all files and symbols that need updating (not just the primary target — include callers/dependents that must adapt).');
|
|
147
|
+
lines.push('- If the change affects >3 files or an exported API, state the plan before writing code.');
|
|
148
|
+
lines.push('');
|
|
149
|
+
lines.push('### 3. Implement (make the change)');
|
|
150
|
+
lines.push('- Edit the code. Prefer minimal, targeted changes.');
|
|
151
|
+
lines.push('- Update all callers/dependents identified in step 2 — do not leave broken references.');
|
|
152
|
+
lines.push('- After major edits to a file, run `reindex_file` so subsequent queries reflect your changes.');
|
|
153
|
+
lines.push('');
|
|
154
|
+
lines.push('### 4. Verify (confirm nothing broke)');
|
|
155
|
+
lines.push('- Run `get_callers` again on modified symbols — verify every caller still works with the new signature/behavior.');
|
|
156
|
+
lines.push('- Run `get_dependents` on modified files — verify no import is left broken.');
|
|
157
|
+
lines.push('- Run tests if they exist (`npm test`, `pytest`, etc.).');
|
|
158
|
+
lines.push('- If the project has a build step, run it (`npm run build`, `tsc --noEmit`, etc.).');
|
|
159
|
+
lines.push('');
|
|
160
|
+
lines.push('### 5. Review (before committing)');
|
|
161
|
+
lines.push('- Run `review_diff` with target "staged" or "last_commit" to get a graph-aware review of your changes.');
|
|
162
|
+
lines.push('- Check the risk assessment: high-importance symbols modified, cascade risks, broken imports.');
|
|
163
|
+
lines.push('- If risks are flagged, go back to step 4 and address them.');
|
|
164
|
+
lines.push('');
|
|
165
|
+
lines.push('### Quick reference');
|
|
166
|
+
lines.push('');
|
|
167
|
+
lines.push('| Step | Tools | Gate |');
|
|
168
|
+
lines.push('|---|---|---|');
|
|
169
|
+
lines.push('| Understand | `search_code`, `get_symbol`, `get_callers`, `get_dependents` | Know the blast radius |');
|
|
170
|
+
lines.push('| Plan | (your reasoning) | All affected files identified |');
|
|
171
|
+
lines.push('| Implement | Edit + `reindex_file` | Code written |');
|
|
172
|
+
lines.push('| Verify | `get_callers`, `get_dependents`, tests, build | No broken refs, tests pass |');
|
|
173
|
+
lines.push('| Review | `review_diff` | No unaddressed risks |');
|
|
120
174
|
lines.push('');
|
|
121
175
|
lines.push('*Auto-generated by claude-ex. Run `claude-ex generate-docs` to regenerate.*');
|
|
122
176
|
lines.push(MARKER_END);
|
|
@@ -130,21 +184,28 @@ function generateClaudeMd(rootDir, db) {
|
|
|
130
184
|
function writeClaudeMd(rootDir, db) {
|
|
131
185
|
const content = generateClaudeMd(rootDir, db);
|
|
132
186
|
const claudeMdPath = path.join(rootDir, 'CLAUDE.md');
|
|
187
|
+
let updated;
|
|
133
188
|
if (fs.existsSync(claudeMdPath)) {
|
|
134
189
|
const existing = fs.readFileSync(claudeMdPath, 'utf-8');
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
190
|
+
const startIdx = existing.indexOf(MARKER_START);
|
|
191
|
+
const endIdx = existing.indexOf(MARKER_END);
|
|
192
|
+
if (startIdx !== -1 && endIdx !== -1) {
|
|
193
|
+
// Replace only the generated section, preserve everything before/after
|
|
194
|
+
const before = existing.slice(0, startIdx);
|
|
195
|
+
const after = existing.slice(endIdx + MARKER_END.length);
|
|
196
|
+
updated = before + content + after;
|
|
140
197
|
}
|
|
141
198
|
else {
|
|
142
|
-
//
|
|
143
|
-
|
|
199
|
+
// No markers yet — append with a blank line separator
|
|
200
|
+
updated = existing.trimEnd() + '\n\n' + content + '\n';
|
|
144
201
|
}
|
|
202
|
+
// Skip write if nothing changed
|
|
203
|
+
if (updated === existing)
|
|
204
|
+
return;
|
|
145
205
|
}
|
|
146
206
|
else {
|
|
147
|
-
|
|
207
|
+
updated = content + '\n';
|
|
148
208
|
}
|
|
209
|
+
fs.writeFileSync(claudeMdPath, updated);
|
|
149
210
|
}
|
|
150
211
|
//# sourceMappingURL=claudemd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudemd.js","sourceRoot":"","sources":["../../src/claude/claudemd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,
|
|
1
|
+
{"version":3,"file":"claudemd.js","sourceRoot":"","sources":["../../src/claude/claudemd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,4CAiJC;AAED,sCA6BC;AAzLD,uCAAyB;AACzB,2CAA6B;AAE7B,yCAA4C;AAC5C,4CAAmF;A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