repomap-ai 0.1.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 ADDED
@@ -0,0 +1,91 @@
1
+ # repomap-ai
2
+
3
+ > Token-efficient repository mapping tool for AI IDEs — npm wrapper for the [repomap](https://pypi.org/project/repomap/) Python package.
4
+
5
+ RepoMap parses source code with tree-sitter, builds function-level dependency graphs, and outputs compact maps that fit within LLM token budgets. Works with Cursor, VS Code, and any MCP-compatible AI IDE.
6
+
7
+ ## Requirements
8
+
9
+ - **Node.js** >= 16
10
+ - **Python** >= 3.11 (with pip)
11
+
12
+ ## Usage
13
+
14
+ ### One-time use (no install)
15
+
16
+ ```bash
17
+ npx repomap-ai generate .
18
+ ```
19
+
20
+ ### Global install
21
+
22
+ ```bash
23
+ npm install -g repomap-ai
24
+ repomap generate .
25
+ ```
26
+
27
+ ### Or install via pip directly
28
+
29
+ ```bash
30
+ pip install repomap
31
+ repomap generate .
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ```bash
37
+ # Generate a map of any repository
38
+ npx repomap-ai generate /path/to/your/repo
39
+
40
+ # Or if you're already inside the repo
41
+ cd /path/to/your/repo
42
+ npx repomap-ai generate .
43
+
44
+ # With a larger token budget, JSON format
45
+ npx repomap-ai generate . --max-tokens 4000 --format json
46
+
47
+ # Set up MCP integration for Cursor / VS Code
48
+ npx repomap-ai init .
49
+ ```
50
+
51
+ ## Commands
52
+
53
+ | Command | Description |
54
+ |---|---|
55
+ | `repomap generate .` | Generate a token-budgeted map of the repository |
56
+ | `repomap visual . -o map.html` | Interactive HTML dependency graph |
57
+ | `repomap stats .` | Symbol and edge statistics |
58
+ | `repomap watch .` | Incremental file watcher |
59
+ | `repomap serve . --transport stdio` | Start MCP server for IDE integration |
60
+ | `repomap init .` | Generate `.cursor/mcp.json` and `.vscode/mcp.json` |
61
+
62
+ ## MCP Integration (Cursor / VS Code)
63
+
64
+ Run `repomap init .` in your repo root to auto-generate config files, then restart your IDE.
65
+
66
+ Or add manually to `.cursor/mcp.json`:
67
+
68
+ ```json
69
+ {
70
+ "mcpServers": {
71
+ "repomap": {
72
+ "command": "repomap",
73
+ "args": ["serve", ".", "--transport", "stdio"]
74
+ }
75
+ }
76
+ }
77
+ ```
78
+
79
+ ## How It Works
80
+
81
+ This npm package is a thin wrapper. When you run `npx repomap-ai`, it:
82
+
83
+ 1. Checks if the `repomap` Python CLI is installed
84
+ 2. If not, runs `pip install repomap` automatically
85
+ 3. Delegates all commands to the Python CLI
86
+
87
+ The actual implementation lives in the [`repomap` PyPI package](https://pypi.org/project/repomap/).
88
+
89
+ ## License
90
+
91
+ MIT
package/bin/repomap.js ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const { spawnSync } = require('child_process');
5
+
6
+ // Forward every argument after "node bin/repomap.js" to the Python CLI
7
+ const args = process.argv.slice(2);
8
+
9
+ const result = spawnSync('repomap', args, {
10
+ stdio: 'inherit',
11
+ // On Windows, spawn via shell so PATH is resolved correctly
12
+ shell: process.platform === 'win32',
13
+ });
14
+
15
+ if (result.error) {
16
+ if (result.error.code === 'ENOENT') {
17
+ process.stderr.write(
18
+ '[repomap-ai] Could not find the "repomap" Python CLI.\n' +
19
+ ' Try reinstalling: npm install -g repomap-ai\n' +
20
+ ' Or install directly: pip install repomap\n'
21
+ );
22
+ process.exit(1);
23
+ }
24
+ throw result.error;
25
+ }
26
+
27
+ process.exit(result.status ?? 0);
package/install.js ADDED
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const { execSync, spawnSync } = require('child_process');
5
+
6
+ const PYPI_PACKAGE = 'repomap';
7
+ const MIN_PYTHON_VERSION = [3, 11];
8
+
9
+ // ─── Helpers ────────────────────────────────────────────────────────────────
10
+
11
+ function log(msg) {
12
+ process.stdout.write('[repomap-ai] ' + msg + '\n');
13
+ }
14
+
15
+ function err(msg) {
16
+ process.stderr.write('[repomap-ai] ERROR: ' + msg + '\n');
17
+ }
18
+
19
+ /** Try running a command; return stdout on success, null on failure. */
20
+ function tryExec(cmd) {
21
+ try {
22
+ return execSync(cmd, { stdio: ['ignore', 'pipe', 'ignore'] })
23
+ .toString()
24
+ .trim();
25
+ } catch {
26
+ return null;
27
+ }
28
+ }
29
+
30
+ // ─── Check if repomap CLI is already on PATH ─────────────────────────────────
31
+
32
+ const alreadyInstalled = tryExec('repomap --version');
33
+ if (alreadyInstalled !== null) {
34
+ log('repomap is already installed (' + alreadyInstalled + '). Nothing to do.');
35
+ process.exit(0);
36
+ }
37
+
38
+ // ─── Detect Python ───────────────────────────────────────────────────────────
39
+
40
+ function detectPython() {
41
+ for (const bin of ['python3', 'python']) {
42
+ const version = tryExec(bin + ' --version');
43
+ if (!version) continue;
44
+
45
+ // version looks like "Python 3.12.0"
46
+ const match = version.match(/Python (\d+)\.(\d+)/);
47
+ if (!match) continue;
48
+
49
+ const major = parseInt(match[1], 10);
50
+ const minor = parseInt(match[2], 10);
51
+ if (
52
+ major > MIN_PYTHON_VERSION[0] ||
53
+ (major === MIN_PYTHON_VERSION[0] && minor >= MIN_PYTHON_VERSION[1])
54
+ ) {
55
+ return bin;
56
+ }
57
+ }
58
+ return null;
59
+ }
60
+
61
+ const python = detectPython();
62
+ if (!python) {
63
+ err(
64
+ 'Python 3.11 or later is required but was not found on your PATH.\n' +
65
+ ' Install Python from https://python.org/downloads/ and then re-run:\n' +
66
+ ' npm install -g repomap-ai'
67
+ );
68
+ process.exit(1);
69
+ }
70
+
71
+ log('Found ' + tryExec(python + ' --version') + '. Installing repomap from PyPI…');
72
+
73
+ // ─── Detect pip ──────────────────────────────────────────────────────────────
74
+
75
+ function detectPip(pythonBin) {
76
+ // Prefer running pip as a Python module to guarantee it matches the right interpreter
77
+ if (tryExec(pythonBin + ' -m pip --version') !== null) {
78
+ return pythonBin + ' -m pip';
79
+ }
80
+ for (const bin of ['pip3', 'pip']) {
81
+ if (tryExec(bin + ' --version') !== null) return bin;
82
+ }
83
+ return null;
84
+ }
85
+
86
+ const pip = detectPip(python);
87
+ if (!pip) {
88
+ err(
89
+ 'pip was not found. Install pip by running:\n' +
90
+ ' ' + python + ' -m ensurepip --upgrade\n' +
91
+ ' then re-run:\n' +
92
+ ' npm install -g repomap-ai'
93
+ );
94
+ process.exit(1);
95
+ }
96
+
97
+ // ─── Install repomap ─────────────────────────────────────────────────────────
98
+
99
+ const result = spawnSync(
100
+ pip.split(' ')[0],
101
+ [...pip.split(' ').slice(1), 'install', '--upgrade', PYPI_PACKAGE],
102
+ { stdio: 'inherit' }
103
+ );
104
+
105
+ if (result.status !== 0) {
106
+ err(
107
+ 'pip install failed. You can install manually with:\n' +
108
+ ' pip install repomap\n' +
109
+ ' then re-run your command.'
110
+ );
111
+ process.exit(result.status || 1);
112
+ }
113
+
114
+ log('repomap installed successfully! Run: repomap generate .');
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "repomap-ai",
3
+ "version": "0.1.0",
4
+ "description": "Token-efficient repository mapping tool for AI IDEs. Thin npm wrapper around the Python repomap package.",
5
+ "keywords": [
6
+ "repomap",
7
+ "ai",
8
+ "llm",
9
+ "mcp",
10
+ "code-analysis",
11
+ "tree-sitter",
12
+ "context",
13
+ "cursor",
14
+ "vscode"
15
+ ],
16
+ "author": "tushar22",
17
+ "license": "MIT",
18
+ "homepage": "https://github.com/tushar22/repomap#readme",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/tushar22/repomap.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/tushar22/repomap/issues"
25
+ },
26
+ "bin": {
27
+ "repomap": "bin/repomap.js"
28
+ },
29
+ "scripts": {
30
+ "postinstall": "node install.js"
31
+ },
32
+ "engines": {
33
+ "node": ">=16"
34
+ },
35
+ "files": [
36
+ "bin/",
37
+ "install.js",
38
+ "README.md"
39
+ ]
40
+ }