@ulpi/codemap 0.3.13 → 0.3.14

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.
Files changed (3) hide show
  1. package/README.md +18 -1
  2. package/dist/index.js +49 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -183,6 +183,22 @@ codemap cycles
183
183
  codemap cycles --json
184
184
  ```
185
185
 
186
+ ### `codemap read <file>`
187
+
188
+ Read and return the full source of a file, or a specific line range.
189
+
190
+ ```bash
191
+ codemap read src/routes/auth.ts
192
+ codemap read src/index.ts --from 10 --to 50
193
+ codemap read src/index.ts --json
194
+ ```
195
+
196
+ | Option | Description |
197
+ |--------|-------------|
198
+ | `--from <line>` | Start line (1-based, inclusive) |
199
+ | `--to <line>` | End line (1-based, inclusive) |
200
+ | `--json` | Output as JSON (includes filePath, totalLines, from, to, content) |
201
+
186
202
  ### `codemap summary <file>`
187
203
 
188
204
  Show file overview with symbols and size.
@@ -424,7 +440,7 @@ Add to `.mcp.json` in your project root:
424
440
  }
425
441
  ```
426
442
 
427
- `"codemap"` serves the current project automatically. `"codemap-frontend"` serves a different codebase via `--cwd`. Add as many as you need — each gets its own set of 12 tools (`search_code`, `get_dependencies`, etc.) scoped to that project.
443
+ `"codemap"` serves the current project automatically. `"codemap-frontend"` serves a different codebase via `--cwd`. Add as many as you need — each gets its own set of 13 tools (`search_code`, `read_file`, `get_dependencies`, etc.) scoped to that project.
428
444
 
429
445
  #### Other Editors
430
446
 
@@ -436,6 +452,7 @@ Your AI agent will then have access to tools like `search_code`, `get_dependenci
436
452
 
437
453
  | Tool | Description |
438
454
  |------|-------------|
455
+ | `read_file` | Read full source or a line range (supports `from`/`to` params) |
439
456
  | `search_code` | Search code using hybrid vector + BM25 |
440
457
  | `search_symbols` | Find functions, classes, and types by name |
441
458
  | `get_file_summary` | Get file overview with symbols and size |
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import "./chunk-WR342MP3.js";
5
5
  import "./chunk-2OBAJYRP.js";
6
6
 
7
7
  // src/index.ts
8
- import path14 from "path";
8
+ import path15 from "path";
9
9
  import { fileURLToPath } from "url";
10
10
 
11
11
  // ../../packages/intelligence/codemap-engine/dist/index.js
@@ -5939,6 +5939,7 @@ symbol lookup, dependency analysis, and PageRank file ranking.
5939
5939
  |------|-------------|
5940
5940
  | \`mcp__codemap__search_code\` | Hybrid vector + BM25 semantic code search |
5941
5941
  | \`mcp__codemap__search_symbols\` | Find functions, classes, types by name |
5942
+ | \`mcp__codemap__read_file\` | Read full source or a line range (\`from\`/\`to\` params) |
5942
5943
  | \`mcp__codemap__get_file_summary\` | File overview with symbols and line count |
5943
5944
  | \`mcp__codemap__get_index_stats\` | Index statistics (files, chunks, size) |
5944
5945
  | \`mcp__codemap__get_dependencies\` | Files this file imports (outgoing) |
@@ -5956,6 +5957,7 @@ symbol lookup, dependency analysis, and PageRank file ranking.
5956
5957
  |---------|-------------|
5957
5958
  | \`codemap search <query>\` | Hybrid vector + BM25 semantic code search |
5958
5959
  | \`codemap symbols <query>\` | Find functions, classes, types by name |
5960
+ | \`codemap read <file>\` | Read full source or line range (\`--from N --to M\`) |
5959
5961
  | \`codemap summary <file>\` | File overview with symbols and line count |
5960
5962
  | \`codemap status\` | Index statistics (files, chunks, size) |
5961
5963
  | \`codemap deps <file>\` | Files this file imports (outgoing) |
@@ -5969,6 +5971,7 @@ symbol lookup, dependency analysis, and PageRank file ranking.
5969
5971
 
5970
5972
  ### When to Use
5971
5973
 
5974
+ - **Reading files**: \`read_file\` to read full source or a line range (e.g. lines 10\u201350) \u2014 works across all connected projects
5972
5975
  - **Before editing**: \`search_code\` or \`search_symbols\` to find relevant files
5973
5976
  - **Understanding impact**: \`get_dependents\` to see what breaks if you change a file
5974
5977
  - **Architecture review**: \`get_coupling_metrics\` and \`find_cycles\` for code health
@@ -7243,8 +7246,11 @@ if [ -f "$mcp_file" ]; then
7243
7246
  for (const [name, config] of Object.entries(servers)) {
7244
7247
  if (config.command !== 'codemap') continue;
7245
7248
  const args = config.args || [];
7249
+ const env = config.env || {};
7246
7250
  const cwdIdx = args.indexOf('--cwd');
7247
- const cwd = cwdIdx >= 0 && cwdIdx + 1 < args.length ? args[cwdIdx + 1] : '';
7251
+ const cwd = cwdIdx >= 0 && cwdIdx + 1 < args.length
7252
+ ? args[cwdIdx + 1]
7253
+ : (env.CODEMAP_PROJECT_DIR || '');
7248
7254
  console.log(name + '|' + cwd);
7249
7255
  }
7250
7256
  } catch {}
@@ -7392,9 +7398,47 @@ function uninstall() {
7392
7398
  console.log(chalk17.dim("Restart Claude Code for changes to take effect."));
7393
7399
  }
7394
7400
 
7401
+ // src/commands/read.ts
7402
+ import chalk18 from "chalk";
7403
+ import fs19 from "fs";
7404
+ import path14 from "path";
7405
+ function registerRead(program2) {
7406
+ program2.command("read <file>").description("Read and return the full source of a file (or a line range)").option("--json", "Output as JSON").option("--from <line>", "Start line (1-based)", parseInt).option("--to <line>", "End line (inclusive)", parseInt).action(async (file, opts) => {
7407
+ const projectDir = program2.opts().cwd || process.cwd();
7408
+ const fullPath = path14.resolve(projectDir, file);
7409
+ if (!fs19.existsSync(fullPath)) {
7410
+ console.error(chalk18.red(`File not found: ${file}`));
7411
+ process.exit(1);
7412
+ return;
7413
+ }
7414
+ const raw = fs19.readFileSync(fullPath, "utf-8");
7415
+ const allLines = raw.split("\n");
7416
+ const totalLines = allLines.length;
7417
+ const from = opts.from ?? 1;
7418
+ const to = opts.to ?? totalLines;
7419
+ const startIdx = Math.max(0, from - 1);
7420
+ const endIdx = Math.min(totalLines, to);
7421
+ const lines = allLines.slice(startIdx, endIdx);
7422
+ const content = lines.join("\n");
7423
+ if (opts.json) {
7424
+ console.log(JSON.stringify({
7425
+ filePath: file,
7426
+ totalLines,
7427
+ from,
7428
+ to: endIdx,
7429
+ lineCount: lines.length,
7430
+ sizeBytes: Buffer.byteLength(content, "utf-8"),
7431
+ content
7432
+ }, null, 2));
7433
+ return;
7434
+ }
7435
+ console.log(content);
7436
+ });
7437
+ }
7438
+
7395
7439
  // src/index.ts
7396
- var __dirname = path14.dirname(fileURLToPath(import.meta.url));
7397
- var grammarsDir = path14.join(__dirname, "grammars");
7440
+ var __dirname = path15.dirname(fileURLToPath(import.meta.url));
7441
+ var grammarsDir = path15.join(__dirname, "grammars");
7398
7442
  setGrammarDir(grammarsDir);
7399
7443
  var program = new Command();
7400
7444
  program.name("codemap").description("Code intelligence CLI \u2014 hybrid search, dependency analysis, PageRank").version("0.3.5").option("--cwd <dir>", "Project directory (default: cwd)");
@@ -7416,4 +7460,5 @@ registerCoupling(program);
7416
7460
  registerGraphStats(program);
7417
7461
  registerRebuild(program);
7418
7462
  registerStatusline(program);
7463
+ registerRead(program);
7419
7464
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulpi/codemap",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
4
4
  "type": "module",
5
5
  "description": "Standalone code intelligence CLI — hybrid vector + BM25 search, dependency analysis, PageRank",
6
6
  "bin": {