scip-cli 1.1.0__tar.gz → 1.3.0__tar.gz

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 (62) hide show
  1. scip_cli-1.3.0/PKG-INFO +281 -0
  2. scip_cli-1.3.0/README.md +257 -0
  3. {scip_cli-1.1.0 → scip_cli-1.3.0}/pyproject.toml +3 -0
  4. scip_cli-1.3.0/scip_cli/SKILL.md +108 -0
  5. {scip_cli-1.1.0 → scip_cli-1.3.0}/scip_cli/__init__.py +1 -1
  6. {scip_cli-1.1.0 → scip_cli-1.3.0}/scip_cli/__main__.py +40 -4
  7. scip_cli-1.3.0/scip_cli/cache.py +70 -0
  8. scip_cli-1.3.0/scip_cli/cli_args.py +33 -0
  9. scip_cli-1.3.0/scip_cli/commands/def_cmd.py +57 -0
  10. {scip_cli-1.1.0 → scip_cli-1.3.0}/scip_cli/commands/members.py +21 -13
  11. {scip_cli-1.1.0 → scip_cli-1.3.0}/scip_cli/commands/rdeps.py +11 -12
  12. {scip_cli-1.1.0 → scip_cli-1.3.0}/scip_cli/commands/refs.py +35 -15
  13. scip_cli-1.3.0/scip_cli/commands/reindex.py +55 -0
  14. scip_cli-1.3.0/scip_cli/commands/search.py +212 -0
  15. {scip_cli-1.1.0 → scip_cli-1.3.0}/scip_cli/commands/symbols.py +11 -14
  16. scip_cli-1.3.0/scip_cli/config.py +67 -0
  17. scip_cli-1.3.0/scip_cli/constants.py +14 -0
  18. scip_cli-1.3.0/scip_cli/discover.py +128 -0
  19. scip_cli-1.3.0/scip_cli/indexing.py +370 -0
  20. scip_cli-1.3.0/scip_cli/lib.py +64 -0
  21. scip_cli-1.3.0/scip_cli/merge.py +175 -0
  22. scip_cli-1.3.0/scip_cli/output.py +112 -0
  23. scip_cli-1.3.0/scip_cli/paths.py +48 -0
  24. scip_cli-1.3.0/scip_cli/project.py +29 -0
  25. scip_cli-1.3.0/scip_cli/queries.py +320 -0
  26. scip_cli-1.3.0/scip_cli/scip_tool.py +150 -0
  27. scip_cli-1.3.0/scip_cli/scope.py +74 -0
  28. scip_cli-1.3.0/scip_cli/session.py +46 -0
  29. scip_cli-1.3.0/scip_cli/source.py +65 -0
  30. scip_cli-1.3.0/scip_cli/sql.py +24 -0
  31. scip_cli-1.3.0/scip_cli/symbols.py +133 -0
  32. scip_cli-1.3.0/scip_cli.egg-info/PKG-INFO +281 -0
  33. scip_cli-1.3.0/scip_cli.egg-info/SOURCES.txt +51 -0
  34. scip_cli-1.3.0/tests/test_cache.py +54 -0
  35. scip_cli-1.3.0/tests/test_composability.py +181 -0
  36. scip_cli-1.3.0/tests/test_config.py +56 -0
  37. scip_cli-1.3.0/tests/test_discover.py +118 -0
  38. scip_cli-1.3.0/tests/test_indexer_env.py +36 -0
  39. scip_cli-1.3.0/tests/test_merge.py +208 -0
  40. {scip_cli-1.1.0 → scip_cli-1.3.0}/tests/test_pure_functions.py +179 -26
  41. scip_cli-1.3.0/tests/test_scip_tool.py +17 -0
  42. scip_cli-1.3.0/tests/test_scope.py +61 -0
  43. scip_cli-1.3.0/tests/test_smoke_cli.py +157 -0
  44. scip_cli-1.3.0/tests/test_typescript_projects.py +53 -0
  45. scip_cli-1.1.0/PKG-INFO +0 -191
  46. scip_cli-1.1.0/README.md +0 -167
  47. scip_cli-1.1.0/scip_cli/SKILL.md +0 -85
  48. scip_cli-1.1.0/scip_cli/commands/def_cmd.py +0 -47
  49. scip_cli-1.1.0/scip_cli/commands/reindex.py +0 -26
  50. scip_cli-1.1.0/scip_cli/commands/search.py +0 -138
  51. scip_cli-1.1.0/scip_cli/lib.py +0 -505
  52. scip_cli-1.1.0/scip_cli.egg-info/PKG-INFO +0 -191
  53. scip_cli-1.1.0/scip_cli.egg-info/SOURCES.txt +0 -24
  54. {scip_cli-1.1.0 → scip_cli-1.3.0}/LICENSE +0 -0
  55. {scip_cli-1.1.0 → scip_cli-1.3.0}/MANIFEST.in +0 -0
  56. {scip_cli-1.1.0 → scip_cli-1.3.0}/scip_cli/commands/__init__.py +0 -0
  57. {scip_cli-1.1.0 → scip_cli-1.3.0}/scip_cli/commands/skill.py +0 -0
  58. {scip_cli-1.1.0 → scip_cli-1.3.0}/scip_cli.egg-info/dependency_links.txt +0 -0
  59. {scip_cli-1.1.0 → scip_cli-1.3.0}/scip_cli.egg-info/entry_points.txt +0 -0
  60. {scip_cli-1.1.0 → scip_cli-1.3.0}/scip_cli.egg-info/top_level.txt +0 -0
  61. {scip_cli-1.1.0 → scip_cli-1.3.0}/setup.cfg +0 -0
  62. {scip_cli-1.1.0 → scip_cli-1.3.0}/setup.py +0 -0
@@ -0,0 +1,281 @@
1
+ Metadata-Version: 2.4
2
+ Name: scip-cli
3
+ Version: 1.3.0
4
+ Summary: Fast code intelligence via SCIP indexes
5
+ Home-page: https://github.com/flesler/scip-cli
6
+ Author: Ariel Flesler
7
+ License: MIT
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Topic :: Software Development :: Code Generators
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: author
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: license
21
+ Dynamic: license-file
22
+ Dynamic: requires-python
23
+ Dynamic: summary
24
+
25
+ # scip-cli
26
+
27
+ [![PyPI version](https://badge.fury.io/py/scip-cli.svg)](https://badge.fury.io/py/scip-cli)
28
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
29
+
30
+ Fast code intelligence CLI for TypeScript/JavaScript and Python projects. Query SCIP indexes directly via SQLite for instant results.
31
+
32
+ ## Features
33
+
34
+ - **Fast**: Direct SQLite queries, eliminating skippable overhead
35
+ - **Simple**: Single binary with subcommands
36
+ - **Auto-indexing**: Automatically indexes projects on first query
37
+ - **Token-efficient**: Clean, minimal output optimized for AI consumption
38
+
39
+ ## For AI Agents
40
+
41
+ If you're an AI agent, run this to see the quick reference:
42
+
43
+ ```bash
44
+ scip-cli skill
45
+ ```
46
+
47
+ Or install it to your skills folder:
48
+
49
+ ```bash
50
+ scip-cli skill ~/.claude/skills/scip-cli/SKILL.md
51
+ ```
52
+
53
+ This enables commands like `def`, `refs`, `search`, `symbols`, `rdeps`, and `members` - just ask "where is X?" or "find references to X".
54
+
55
+ ## Installation
56
+
57
+ ### 1. Install scip-cli
58
+
59
+ **From PyPI:**
60
+
61
+ ```bash
62
+ pip install scip-cli
63
+ ```
64
+
65
+ **From source (local development):**
66
+
67
+ ```bash
68
+ git clone https://github.com/flesler/scip-cli.git
69
+ cd scip-cli
70
+ pip install .
71
+ ```
72
+
73
+ For editable development (where `pip install -e .` fails due to permissions):
74
+
75
+ ```bash
76
+ export PYTHONPATH=/path/to/scip-cli:$PYTHONPATH
77
+ python -m scip_cli --help
78
+ ```
79
+
80
+ ### 2. Install prerequisites (optional)
81
+
82
+ On **first index**, scip-cli runs language indexers and builds a SQLite cache. You can let it fetch tools on demand, or install them globally ahead of time so the first run does not download via `npx`:
83
+
84
+ **Option A: Zero extra setup (recommended)**
85
+
86
+ Install `scip-cli` and run it. On first index, scip-cli will:
87
+
88
+ - Download `scip-typescript` / `scip-python` via `npx` when not already on PATH
89
+ - Download the `scip` converter binary from [GitHub releases](https://github.com/scip-code/scip/releases) into `~/.cache/scip-cli/bin/` when not already on PATH
90
+ - Walk the repo for `tsconfig*.json` project roots (TypeScript monorepos), run `scip-typescript` per project (parallel by default), convert each partial index, then merge into one `index.db`
91
+
92
+ No `.scip-cli.json` required for discovery. Subsequent queries read the cached database only.
93
+
94
+ **Option B: Install indexers globally ahead of time**
95
+
96
+ Same indexing steps as Option A; this only avoids `npx` download on the first run:
97
+
98
+ ```bash
99
+ # TypeScript/JavaScript indexer (also handles plain JS via --infer-tsconfig)
100
+ npm install -g @sourcegraph/scip-typescript
101
+
102
+ # Python indexer
103
+ npm install -g @sourcegraph/scip-python
104
+
105
+ # SCIP CLI for index conversion (GitHub release — not on npm)
106
+ # https://github.com/scip-code/scip/releases (v0.8.1+ recommended)
107
+ ```
108
+
109
+ **Verify installation:**
110
+
111
+ ```bash
112
+ scip-cli --help
113
+ scip-typescript --version # Only if you chose Option B
114
+ scip --version # Install from GitHub releases; v0.8.1+ recommended
115
+ ```
116
+
117
+ ## Usage
118
+
119
+ All commands are subcommands of `scip-cli`:
120
+
121
+ ```bash
122
+ scip-cli <command> [arguments]
123
+ ```
124
+
125
+ ### Commands
126
+
127
+ - `refs <symbol>` - Find all references to a symbol (`--path` to scope)
128
+ - `def <symbol>` - Find symbol definition with source code (`--path`, `--max-lines`)
129
+ - `search <pattern>` - Search symbols by name pattern (`--path`)
130
+ - `symbols <file>` - List all symbols in a file (`--path`; bare filename OK)
131
+ - `rdeps <file>` - Find files that depend on a file (`--path`)
132
+ - `members <symbol>` - List members of a class/interface (`--path`)
133
+ - `reindex` - Force re-indexing of the current project (`--path` to limit scope; repeatable)
134
+ - `skill [path]` - Install or dump the SKILL.md
135
+
136
+ ### Examples
137
+
138
+ ```bash
139
+ # Find where greet is used
140
+ scip-cli refs greet
141
+
142
+ # Get definition of greet
143
+ scip-cli def greet
144
+
145
+ # Search for symbols matching "Widget"
146
+ scip-cli search Widget
147
+
148
+ # Scope to a subdirectory
149
+ scip-cli def greet --path packages/api
150
+
151
+ # List symbols by bare filename
152
+ scip-cli symbols helper.ts
153
+
154
+ # Find files that import from a module
155
+ scip-cli rdeps src/helper.ts
156
+
157
+ # List members of a class
158
+ scip-cli members Widget
159
+
160
+ # Install skill file
161
+ scip-cli skill ~/.claude/skills/scip-cli/SKILL.md
162
+ ```
163
+
164
+ ### Pipelines
165
+
166
+ Stdout is one record per line; stderr carries warnings and ambiguity notices. Kinds are lowercase (`function`, `class`, `method`, `property`, `variable`). Pipe-friendly flags: `refs --paths-only`, `search --names-only` / `--paths-only`, `members --names-only`. `rdeps` already prints bare file paths.
167
+
168
+ ```bash
169
+ # What do importers of this file export?
170
+ scip-cli rdeps src/helper.ts | xargs -I{} scip-cli symbols {}
171
+
172
+ # Which files reference a symbol?
173
+ scip-cli refs greet --paths-only
174
+
175
+ # Classes matching a name → list their members
176
+ scip-cli search Handler --kind class --names-only | xargs -I{} scip-cli members {}
177
+
178
+ # Walk class members to their definitions
179
+ scip-cli members Widget --names-only | xargs -I{} scip-cli def Widget.{}
180
+ ```
181
+
182
+ ## How It Works
183
+
184
+ 1. On first query, automatically detects project language from `package.json` (TS/JS) or `pyproject.toml`/`setup.py` (Python)
185
+ 2. For TypeScript monorepos, walks the repository for `tsconfig*.json` project roots (nested ancestors deduped; root included only when its `include` is broad)
186
+ 3. Runs `scip-typescript` per project (in parallel when there are multiple projects; set `SCIP_CLI_INDEX_WORKERS=1` to force serial), or `scip-python` for Python
187
+ 4. Converts each SCIP output to SQLite with `scip expt-convert`, then merges partial databases when needed
188
+ 5. Caches the result in `~/.cache/scip-cli/projects/<dirname>-<hash>/index.db` (e.g. `my-monorepo-1a3f7a`)
189
+ 6. Subsequent queries are SQLite lookups against that cache (not re-indexing)
190
+
191
+ ## Configuration
192
+
193
+ Optional `.scip-cli.json` in the project root:
194
+
195
+ ```json
196
+ {
197
+ "maxHeapMb": 8192,
198
+ "indexRoots": ["packages/core", "apps/worker"],
199
+ "onlyIndexRoots": false
200
+ }
201
+ ```
202
+
203
+ - `maxHeapMb` — Node heap for `scip-typescript` / `scip-python` (default **8192 MB** when omitted). Overridden by `SCIP_CLI_MAX_HEAP_MB`. This is the V8 heap cap, not total RAM usage.
204
+ - `indexRoots` — extra TypeScript project directories to include on **first index**, merged with auto-discovered projects.
205
+ - `onlyIndexRoots` — skip auto-discovery and index **only** `indexRoots` (smaller initial index when you only care about part of a monorepo).
206
+
207
+ `SCIP_CLI_INDEX_WORKERS` controls parallel `scip-typescript` runs during first index (default: up to 8). Merge into one database is always serial.
208
+
209
+ Scoped indexing without editing `.scip-cli.json`:
210
+
211
+ ```bash
212
+ scip-cli reindex --path entrypoints/server
213
+ scip-cli reindex --path packages/api --path packages/worker
214
+ ```
215
+
216
+ `--path` limits which discovered tsconfig projects are indexed (prefix match, same idea as query `--path`). The scope is saved as `index-scope.json` next to `index.db` and reused until you run a full `scip-cli reindex` with no `--path`.
217
+
218
+ Run `scip-cli reindex` after changing scope, `.scip-cli.json` index settings, or when you want a fresh index.
219
+
220
+ This is separate from `.scipquery.json`, which belongs to [scip-query](https://github.com/PlunderStruck/scip-query) and configures its analyzers, watch mode, and diff-gate — not read by scip-cli.
221
+
222
+ ## Performance
223
+
224
+ Inspired by [scip-query](https://github.com/PlunderStruck/scip-query), scip-cli is a lightweight Python reimplementation optimized for speed. Compared to the original bash wrapper scripts:
225
+
226
+ - `refs`: 6.4s → 0.03s (213x faster)
227
+ - `def`: 2.8s → 0.05s (56x faster)
228
+ - `search`: 2.6s → 0.03s (87x faster)
229
+ - `symbols`: 0.3s → 0.02s (15x faster)
230
+ - `rdeps`: 0.2s → 0.02s (10x faster)
231
+ - `members`: 3.1s → 0.03s (103x faster)
232
+
233
+ The speedup comes from direct SQLite queries instead of shell command chains, eliminating subprocess overhead.
234
+
235
+ ## Architecture
236
+
237
+ ```
238
+ scip_cli/
239
+ ├── __init__.py
240
+ ├── __main__.py # CLI entry point
241
+ ├── cli_args.py # Shared argparse helpers
242
+ ├── config.py # .scip-cli.json loader
243
+ ├── discover.py # TypeScript project discovery
244
+ ├── merge.py # SQLite index merging
245
+ ├── scip_tool.py # scip binary download
246
+ ├── constants.py # Shared constants
247
+ ├── sql.py # SQLite helpers
248
+ ├── paths.py # --path scope filtering
249
+ ├── project.py # Project root + language detection
250
+ ├── cache.py # Index cache paths
251
+ ├── indexing.py # SCIP index build + get_db
252
+ ├── symbols.py # Symbol parsing and kinds
253
+ ├── queries.py # Symbol/file SQL queries
254
+ ├── source.py # Filesystem source reads
255
+ ├── output.py # CLI formatting helpers
256
+ ├── session.py # setup() and single-match resolution
257
+ └── commands/ # Subcommand implementations
258
+ ```
259
+
260
+ ## Development
261
+
262
+ ```bash
263
+ pip install -e .
264
+ pytest tests/ -q
265
+ pytest tests/ -m integration -q # indexes tests/fixtures/sample-project (needs scip-typescript)
266
+ ```
267
+
268
+ ### Debug Logging
269
+
270
+ Set `SCIP_CLI_DEBUG=1` to enable SQL query logging to stderr:
271
+
272
+ ```bash
273
+ SCIP_CLI_DEBUG=1 scip-cli refs MyFunction
274
+ # Shows: SQL: SELECT ... | params: (...)
275
+ ```
276
+
277
+ This is useful for testing and debugging SQL queries without exposing a `--debug` flag to users.
278
+
279
+ ## License
280
+
281
+ MIT
@@ -0,0 +1,257 @@
1
+ # scip-cli
2
+
3
+ [![PyPI version](https://badge.fury.io/py/scip-cli.svg)](https://badge.fury.io/py/scip-cli)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Fast code intelligence CLI for TypeScript/JavaScript and Python projects. Query SCIP indexes directly via SQLite for instant results.
7
+
8
+ ## Features
9
+
10
+ - **Fast**: Direct SQLite queries, eliminating skippable overhead
11
+ - **Simple**: Single binary with subcommands
12
+ - **Auto-indexing**: Automatically indexes projects on first query
13
+ - **Token-efficient**: Clean, minimal output optimized for AI consumption
14
+
15
+ ## For AI Agents
16
+
17
+ If you're an AI agent, run this to see the quick reference:
18
+
19
+ ```bash
20
+ scip-cli skill
21
+ ```
22
+
23
+ Or install it to your skills folder:
24
+
25
+ ```bash
26
+ scip-cli skill ~/.claude/skills/scip-cli/SKILL.md
27
+ ```
28
+
29
+ This enables commands like `def`, `refs`, `search`, `symbols`, `rdeps`, and `members` - just ask "where is X?" or "find references to X".
30
+
31
+ ## Installation
32
+
33
+ ### 1. Install scip-cli
34
+
35
+ **From PyPI:**
36
+
37
+ ```bash
38
+ pip install scip-cli
39
+ ```
40
+
41
+ **From source (local development):**
42
+
43
+ ```bash
44
+ git clone https://github.com/flesler/scip-cli.git
45
+ cd scip-cli
46
+ pip install .
47
+ ```
48
+
49
+ For editable development (where `pip install -e .` fails due to permissions):
50
+
51
+ ```bash
52
+ export PYTHONPATH=/path/to/scip-cli:$PYTHONPATH
53
+ python -m scip_cli --help
54
+ ```
55
+
56
+ ### 2. Install prerequisites (optional)
57
+
58
+ On **first index**, scip-cli runs language indexers and builds a SQLite cache. You can let it fetch tools on demand, or install them globally ahead of time so the first run does not download via `npx`:
59
+
60
+ **Option A: Zero extra setup (recommended)**
61
+
62
+ Install `scip-cli` and run it. On first index, scip-cli will:
63
+
64
+ - Download `scip-typescript` / `scip-python` via `npx` when not already on PATH
65
+ - Download the `scip` converter binary from [GitHub releases](https://github.com/scip-code/scip/releases) into `~/.cache/scip-cli/bin/` when not already on PATH
66
+ - Walk the repo for `tsconfig*.json` project roots (TypeScript monorepos), run `scip-typescript` per project (parallel by default), convert each partial index, then merge into one `index.db`
67
+
68
+ No `.scip-cli.json` required for discovery. Subsequent queries read the cached database only.
69
+
70
+ **Option B: Install indexers globally ahead of time**
71
+
72
+ Same indexing steps as Option A; this only avoids `npx` download on the first run:
73
+
74
+ ```bash
75
+ # TypeScript/JavaScript indexer (also handles plain JS via --infer-tsconfig)
76
+ npm install -g @sourcegraph/scip-typescript
77
+
78
+ # Python indexer
79
+ npm install -g @sourcegraph/scip-python
80
+
81
+ # SCIP CLI for index conversion (GitHub release — not on npm)
82
+ # https://github.com/scip-code/scip/releases (v0.8.1+ recommended)
83
+ ```
84
+
85
+ **Verify installation:**
86
+
87
+ ```bash
88
+ scip-cli --help
89
+ scip-typescript --version # Only if you chose Option B
90
+ scip --version # Install from GitHub releases; v0.8.1+ recommended
91
+ ```
92
+
93
+ ## Usage
94
+
95
+ All commands are subcommands of `scip-cli`:
96
+
97
+ ```bash
98
+ scip-cli <command> [arguments]
99
+ ```
100
+
101
+ ### Commands
102
+
103
+ - `refs <symbol>` - Find all references to a symbol (`--path` to scope)
104
+ - `def <symbol>` - Find symbol definition with source code (`--path`, `--max-lines`)
105
+ - `search <pattern>` - Search symbols by name pattern (`--path`)
106
+ - `symbols <file>` - List all symbols in a file (`--path`; bare filename OK)
107
+ - `rdeps <file>` - Find files that depend on a file (`--path`)
108
+ - `members <symbol>` - List members of a class/interface (`--path`)
109
+ - `reindex` - Force re-indexing of the current project (`--path` to limit scope; repeatable)
110
+ - `skill [path]` - Install or dump the SKILL.md
111
+
112
+ ### Examples
113
+
114
+ ```bash
115
+ # Find where greet is used
116
+ scip-cli refs greet
117
+
118
+ # Get definition of greet
119
+ scip-cli def greet
120
+
121
+ # Search for symbols matching "Widget"
122
+ scip-cli search Widget
123
+
124
+ # Scope to a subdirectory
125
+ scip-cli def greet --path packages/api
126
+
127
+ # List symbols by bare filename
128
+ scip-cli symbols helper.ts
129
+
130
+ # Find files that import from a module
131
+ scip-cli rdeps src/helper.ts
132
+
133
+ # List members of a class
134
+ scip-cli members Widget
135
+
136
+ # Install skill file
137
+ scip-cli skill ~/.claude/skills/scip-cli/SKILL.md
138
+ ```
139
+
140
+ ### Pipelines
141
+
142
+ Stdout is one record per line; stderr carries warnings and ambiguity notices. Kinds are lowercase (`function`, `class`, `method`, `property`, `variable`). Pipe-friendly flags: `refs --paths-only`, `search --names-only` / `--paths-only`, `members --names-only`. `rdeps` already prints bare file paths.
143
+
144
+ ```bash
145
+ # What do importers of this file export?
146
+ scip-cli rdeps src/helper.ts | xargs -I{} scip-cli symbols {}
147
+
148
+ # Which files reference a symbol?
149
+ scip-cli refs greet --paths-only
150
+
151
+ # Classes matching a name → list their members
152
+ scip-cli search Handler --kind class --names-only | xargs -I{} scip-cli members {}
153
+
154
+ # Walk class members to their definitions
155
+ scip-cli members Widget --names-only | xargs -I{} scip-cli def Widget.{}
156
+ ```
157
+
158
+ ## How It Works
159
+
160
+ 1. On first query, automatically detects project language from `package.json` (TS/JS) or `pyproject.toml`/`setup.py` (Python)
161
+ 2. For TypeScript monorepos, walks the repository for `tsconfig*.json` project roots (nested ancestors deduped; root included only when its `include` is broad)
162
+ 3. Runs `scip-typescript` per project (in parallel when there are multiple projects; set `SCIP_CLI_INDEX_WORKERS=1` to force serial), or `scip-python` for Python
163
+ 4. Converts each SCIP output to SQLite with `scip expt-convert`, then merges partial databases when needed
164
+ 5. Caches the result in `~/.cache/scip-cli/projects/<dirname>-<hash>/index.db` (e.g. `my-monorepo-1a3f7a`)
165
+ 6. Subsequent queries are SQLite lookups against that cache (not re-indexing)
166
+
167
+ ## Configuration
168
+
169
+ Optional `.scip-cli.json` in the project root:
170
+
171
+ ```json
172
+ {
173
+ "maxHeapMb": 8192,
174
+ "indexRoots": ["packages/core", "apps/worker"],
175
+ "onlyIndexRoots": false
176
+ }
177
+ ```
178
+
179
+ - `maxHeapMb` — Node heap for `scip-typescript` / `scip-python` (default **8192 MB** when omitted). Overridden by `SCIP_CLI_MAX_HEAP_MB`. This is the V8 heap cap, not total RAM usage.
180
+ - `indexRoots` — extra TypeScript project directories to include on **first index**, merged with auto-discovered projects.
181
+ - `onlyIndexRoots` — skip auto-discovery and index **only** `indexRoots` (smaller initial index when you only care about part of a monorepo).
182
+
183
+ `SCIP_CLI_INDEX_WORKERS` controls parallel `scip-typescript` runs during first index (default: up to 8). Merge into one database is always serial.
184
+
185
+ Scoped indexing without editing `.scip-cli.json`:
186
+
187
+ ```bash
188
+ scip-cli reindex --path entrypoints/server
189
+ scip-cli reindex --path packages/api --path packages/worker
190
+ ```
191
+
192
+ `--path` limits which discovered tsconfig projects are indexed (prefix match, same idea as query `--path`). The scope is saved as `index-scope.json` next to `index.db` and reused until you run a full `scip-cli reindex` with no `--path`.
193
+
194
+ Run `scip-cli reindex` after changing scope, `.scip-cli.json` index settings, or when you want a fresh index.
195
+
196
+ This is separate from `.scipquery.json`, which belongs to [scip-query](https://github.com/PlunderStruck/scip-query) and configures its analyzers, watch mode, and diff-gate — not read by scip-cli.
197
+
198
+ ## Performance
199
+
200
+ Inspired by [scip-query](https://github.com/PlunderStruck/scip-query), scip-cli is a lightweight Python reimplementation optimized for speed. Compared to the original bash wrapper scripts:
201
+
202
+ - `refs`: 6.4s → 0.03s (213x faster)
203
+ - `def`: 2.8s → 0.05s (56x faster)
204
+ - `search`: 2.6s → 0.03s (87x faster)
205
+ - `symbols`: 0.3s → 0.02s (15x faster)
206
+ - `rdeps`: 0.2s → 0.02s (10x faster)
207
+ - `members`: 3.1s → 0.03s (103x faster)
208
+
209
+ The speedup comes from direct SQLite queries instead of shell command chains, eliminating subprocess overhead.
210
+
211
+ ## Architecture
212
+
213
+ ```
214
+ scip_cli/
215
+ ├── __init__.py
216
+ ├── __main__.py # CLI entry point
217
+ ├── cli_args.py # Shared argparse helpers
218
+ ├── config.py # .scip-cli.json loader
219
+ ├── discover.py # TypeScript project discovery
220
+ ├── merge.py # SQLite index merging
221
+ ├── scip_tool.py # scip binary download
222
+ ├── constants.py # Shared constants
223
+ ├── sql.py # SQLite helpers
224
+ ├── paths.py # --path scope filtering
225
+ ├── project.py # Project root + language detection
226
+ ├── cache.py # Index cache paths
227
+ ├── indexing.py # SCIP index build + get_db
228
+ ├── symbols.py # Symbol parsing and kinds
229
+ ├── queries.py # Symbol/file SQL queries
230
+ ├── source.py # Filesystem source reads
231
+ ├── output.py # CLI formatting helpers
232
+ ├── session.py # setup() and single-match resolution
233
+ └── commands/ # Subcommand implementations
234
+ ```
235
+
236
+ ## Development
237
+
238
+ ```bash
239
+ pip install -e .
240
+ pytest tests/ -q
241
+ pytest tests/ -m integration -q # indexes tests/fixtures/sample-project (needs scip-typescript)
242
+ ```
243
+
244
+ ### Debug Logging
245
+
246
+ Set `SCIP_CLI_DEBUG=1` to enable SQL query logging to stderr:
247
+
248
+ ```bash
249
+ SCIP_CLI_DEBUG=1 scip-cli refs MyFunction
250
+ # Shows: SQL: SELECT ... | params: (...)
251
+ ```
252
+
253
+ This is useful for testing and debugging SQL queries without exposing a `--debug` flag to users.
254
+
255
+ ## License
256
+
257
+ MIT
@@ -8,3 +8,6 @@ python_files = ["test_*.py"]
8
8
  python_classes = ["Test*"]
9
9
  python_functions = ["test_*"]
10
10
  addopts = "-v"
11
+ markers = [
12
+ "integration: indexes the bundled sample project (requires scip-typescript)",
13
+ ]
@@ -0,0 +1,108 @@
1
+ ---
2
+ name: scip-cli
3
+ description: Read when needing to find symbols, definitions, references, or members in TypeScript/JavaScript or Python code
4
+ ---
5
+
6
+ TypeScript/JavaScript (.ts, .tsx, .js, .jsx) and Python (.py) — not GraphQL, CSS, or other files.
7
+
8
+ All commands are sub-commands of `scip-cli`. Run from the project root.
9
+
10
+ ## Quick Decision Guide
11
+
12
+ | Question | Use | What you get |
13
+ | ----------------------------------------- | ------------------- | ----------------------------------------------------------------------------------------- |
14
+ | "Where is X defined and what does it do?" | `def X` | Definition snippet (capped at 80 lines by default). Use `members Class` for large classes |
15
+ | "Where is X used/called?" | `refs X` | All file:line locations. Shows refs for all matching symbols. Use `--limit` to cap |
16
+ | "What's in this file?" | `symbols file` | All symbols — bare filename works (`helper.ts`, `widget.ts`) |
17
+ | "Find symbols by name" | `search name` | Functions, types, interfaces, classes. Use `--kind variable` for consts |
18
+ | "What files depend on this file?" | `rdeps file` | Importers — bare name works |
19
+ | "What methods does this class have?" | `members ClassName` | All methods/fields with line ranges |
20
+
21
+ ## Gotchas
22
+
23
+ - **Bare names** resolve functions, types (aliases + interfaces), and classes. Use dotted qualifiers to disambiguate members: `def Widget.run`, `refs Foo.setBar`, `search MyClass.myMethod`, `members pkg.MyClass`. Consts/variables need `def --kind variable X` or `search --kind variable X`. Class methods need `members ClassName`, not bare `def methodName`.
24
+ - **Ambiguous types** (e.g. `Opts` in multiple hooks) — `def` returns all matches; `refs` returns refs for all matching symbols. Use `--limit N` to cap results, or use `search` with a more specific pattern to disambiguate.
25
+ - **First run** in a project may auto-index (one-time wait; large monorepos with many `tsconfig.json` files take longer). Projects index in parallel by default (`SCIP_CLI_INDEX_WORKERS`; merge is serial). JS-only projects (no `tsconfig.json`) are supported automatically.
26
+ - **Monorepos** are indexed by walking for `tsconfig*.json` under the repo (skips `node_modules`, `.git`, etc.). Nested parent/child projects are deduped. Add extra roots or limit indexing with `.scip-cli.json` (see README). Use `--path packages/api` (or any file/dir) to scope queries.
27
+ - **Prerequisites**: Node.js (for `npx` indexers). The `scip` converter auto-downloads on first use if missing; `scip-typescript` / `scip-python` download via `npx`. Optional `.scip-cli.json` for extra index roots or heap tuning. `brew install scip` installs an unrelated optimization solver — scip-cli ignores it and downloads the real binary.
28
+
29
+ ## Details
30
+
31
+ ### def
32
+
33
+ ```bash
34
+ def [--kind <kind>] [--limit N] [--max-lines N] [--path PATH] <symbol>
35
+ ```
36
+
37
+ Kinds: `function`, `method`, `class`, `property`, `variable` — use `--kind` when the bare name isn't in the default set above.
38
+
39
+ `--limit` caps how many matching symbols are shown (default 10). `--max-lines` caps source lines **per definition body** (default 80) so huge functions/classes do not flood context. Use `--max-lines 0` for the full body. Override default via `SCIP_CLI_MAX_DEF_LINES`.
40
+
41
+ For large classes, prefer `members ClassName` first, then `def Class.method` for one member.
42
+
43
+ ### refs
44
+
45
+ ```bash
46
+ refs [--limit N] [--path PATH] [--paths-only] <symbol>
47
+ ```
48
+
49
+ Returns `file:line` for each reference. Reads source files to find exact line numbers.
50
+
51
+ Default `--limit` is 10. When multiple symbols match, refs are grouped by symbol with `# <leaf-name>` headers on **stderr** (stdout stays pipe-clean). Use `--paths-only` for unique file paths (pipe-friendly).
52
+
53
+ ### Pipelines
54
+
55
+ Commands emit one record per line on stdout; warnings and progress go to stderr. Use `--paths-only` / `--names-only` when piping into another `scip-cli` command.
56
+
57
+ | Goal | Pipeline |
58
+ | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
59
+ | Blast radius of a file | `scip-cli rdeps file.ts \| xargs -I{} scip-cli symbols {}` |
60
+ | Files that import a symbol | `scip-cli refs Foo --paths-only` |
61
+ | Symbols in referencing files | `scip-cli refs Foo --paths-only \| xargs -I{} scip-cli symbols {}` (barrel files may have no symbols; prefer `search Foo --paths-only` for definition files) |
62
+ | Find classes, list members | `scip-cli search Handler --kind class --names-only \| xargs -I{} scip-cli members {}` |
63
+ | Members → definitions | `scip-cli members Widget --names-only \| xargs -I{} scip-cli def Widget.{}` |
64
+ | Find functions, show callers | `scip-cli search Publish --kind function --names-only \| xargs -I{} scip-cli refs {} --paths-only` |
65
+ | Files touching a topic | `scip-cli search Dynamo --paths-only` |
66
+ | Count importers | `scip-cli rdeps file.ts \| wc -l` |
67
+
68
+ `rdeps` already prints bare paths. `refs` defaults to `path:line`; add `--paths-only` to dedupe files. `search` / `members` need `--names-only` or `--paths-only` instead of `awk`.
69
+
70
+ Each `xargs` invocation reopens the index (fast on cache hit). Use `--limit` on the first command to cap fan-out.
71
+
72
+ ### search
73
+
74
+ ```bash
75
+ search [--kind <kind>] [--limit N] [--path PATH] [--names-only] [--paths-only] <pattern>
76
+ ```
77
+
78
+ Returns `file:line kind symbolName` (kinds are lowercase: `function`, `class`, etc.). Filters noisy symbols (file-level, parameters, type literals).
79
+
80
+ Default `--limit` is 10.
81
+
82
+ ### symbols
83
+
84
+ ```bash
85
+ symbols [--limit N] [--path PATH] <file>
86
+ ```
87
+
88
+ Returns `startLine-endLine kind name` for each symbol in the file.
89
+
90
+ Default `--limit` is 10.
91
+
92
+ ### rdeps
93
+
94
+ ```bash
95
+ rdeps [--limit N] [--path PATH] <file>
96
+ ```
97
+
98
+ Returns list of files that import from this file.
99
+
100
+ Default `--limit` is 10.
101
+
102
+ ### members
103
+
104
+ ```bash
105
+ members [--limit N] [--path PATH] [--names-only] <symbol>
106
+ ```
107
+
108
+ Returns `startLine:endLine kind name` for each member. Note: limited by database coverage — `enclosing_symbol` data is sparse for many indexers.
@@ -1,2 +1,2 @@
1
1
  """scip-cli: Fast code intelligence via SCIP indexes."""
2
- __version__ = "1.1.0"
2
+ __version__ = "1.3.0"