@ninjaxtools/slopdex 0.8.0 → 0.10.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/.agents/skills/slopdex/SKILL.md +150 -270
- package/README.md +159 -211
- package/dist/cli.js +79 -38
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +33 -7
- package/dist/index.js.map +1 -1
- package/docs/implementation.md +163 -0
- package/package.json +2 -1
|
@@ -1,340 +1,220 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: slopdex
|
|
3
|
-
description:
|
|
3
|
+
description: Semantic code search, find duplicate-function candidates, analyze physical code cohesion
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Slopdex
|
|
6
|
+
# Slopdex operator guide for agents
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Slopdex does semantic code search, finds similar-code candidates, and identifies related functions stored far apart.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Run the command that satisfies the user's request immediately. Do not begin with `slopdex status`, `slopdex --help`, executable lookup, API-key probes, or version probes. Slopdex performs its own validation and reports missing credentials or incompatible state.
|
|
13
|
-
|
|
14
|
-
- For semantic search, run `slopdex search "<query>" --format summary --limit 10`.
|
|
15
|
-
- For duplicate-code clusters, run `slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.9 --limit 5`.
|
|
16
|
-
- For related functions that are physically separated, run `slopdex cohesion --format summary --threshold 0.8 --neighbors 20 --limit 50`.
|
|
17
|
-
- For an explicit request to refresh the current index, run `slopdex update-git`.
|
|
18
|
-
- Use `slopdex status` only when the user asks for index metadata or checkpoint information.
|
|
19
|
-
|
|
20
|
-
Every command refreshes its index from committed `HEAD`, then overlays working-tree changes. A missing index is created automatically; let the requested command perform the refresh rather than initializing separately. Without Git or a Git repository, every command warns on stderr and fully re-indexes the working tree. Use `--no-reindex` only when explicitly asked to skip Git working-tree overlays or reuse an existing non-empty index without Git.
|
|
21
|
-
|
|
22
|
-
## Prerequisites
|
|
23
|
-
|
|
24
|
-
- Run commands from the repository root or pass `--root <path>`.
|
|
25
|
-
- Set `OPENAI_API_KEY` or `JINA_API_KEY` for the configured embedding provider.
|
|
26
|
-
- Use Node.js 24 or newer.
|
|
27
|
-
- Store optional configuration in `.slopdex/config.json`:
|
|
28
|
-
|
|
29
|
-
```json
|
|
30
|
-
{
|
|
31
|
-
"provider": "jina",
|
|
32
|
-
"model": "jina-embeddings-v4",
|
|
33
|
-
"dimensions": 1024,
|
|
34
|
-
"exclude": ["**/fixtures/**"]
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Do not expose API keys in commands, output, configuration files, or commits.
|
|
39
|
-
|
|
40
|
-
## Indexing
|
|
41
|
-
|
|
42
|
-
Root and nested `.gitignore` files restrict indexing, including tracked files. Working-tree updates use current ignore files; historical or committed-only Git updates use ignore files from the selected commit. A normal refresh removes newly ignored files from the index. Explicit updates reject ignored paths.
|
|
43
|
-
|
|
44
|
-
Indexing records parse, callable-extraction, file-read, and file-size failures in SQLite while retaining healthy callables. Commands warn on stderr when unresolved diagnostics remain. Inspect them with `slopdex index-errors --format summary` (or JSON by default); this reads saved errors without refreshing the index or calling providers. Records include paths, source locations, recoverable function names, messages, and available source text. `status` reports `indexingErrorCount` and `failedFileCount`. Failed files are retried during updates; fixes, deletions, and exclusions clear their diagnostics. `--ignore-errors` silences diagnostic warnings without discarding the records.
|
|
45
|
-
|
|
46
|
-
If a CLI command cannot find its source index, Slopdex prints a notice to stderr and automatically creates and populates it from committed `HEAD`, then overlays working-tree changes. Missing cross-search target indexes are initialized from the target repository's `HEAD` and working tree as well.
|
|
47
|
-
|
|
48
|
-
Index the current committed snapshot and working-tree overlay:
|
|
10
|
+
### Find code by meaning
|
|
49
11
|
|
|
50
12
|
```bash
|
|
51
|
-
slopdex
|
|
13
|
+
slopdex search "validate an authenticated session" --format summary --limit 10
|
|
14
|
+
slopdex search "persist user data" -e 'save|persist' --format summary --limit 5
|
|
52
15
|
```
|
|
53
16
|
|
|
54
|
-
|
|
17
|
+
Describe behavior rather than guessing a symbol name. `-e` is a regex that restricts which symbols (functions) are searched.
|
|
55
18
|
|
|
56
|
-
|
|
57
|
-
slopdex update-files src/service.ts src/model.ts
|
|
58
|
-
```
|
|
19
|
+
### Search function purpose
|
|
59
20
|
|
|
60
|
-
|
|
21
|
+
Code purpose-summary generation needs to be enabled once:
|
|
61
22
|
|
|
62
23
|
```bash
|
|
63
|
-
slopdex
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Index another commit or recover after changing to a divergent branch:
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
slopdex update-git --target HEAD
|
|
70
|
-
slopdex update-git --target HEAD --rebuild-on-divergence
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Rebuild automatically when an existing index is incompatible with the current provider, model, dimensions, strategy, schema, or repository:
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
slopdex update-git --force-rebuild
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
This removes the incompatible index and prints a warning before rebuilding it.
|
|
80
|
-
|
|
81
|
-
Skip the otherwise mandatory full working-tree refresh when Git is unavailable and a non-empty index already exists:
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
slopdex search "query" --no-reindex
|
|
24
|
+
slopdex summaries enable # only needed once
|
|
85
25
|
```
|
|
86
26
|
|
|
87
|
-
|
|
27
|
+
Then purpose-summaries can be searched:
|
|
88
28
|
|
|
89
29
|
```bash
|
|
90
|
-
slopdex
|
|
30
|
+
slopdex search-summary "keep the repository index synchronized" --format summary --limit 10
|
|
91
31
|
```
|
|
92
32
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
## Failure Handling
|
|
33
|
+
Enabling needs `OPENAI_API_KEY` in the environment.
|
|
96
34
|
|
|
97
|
-
|
|
98
|
-
- Provider authentication and configuration failures are actionable as printed. Never display key values, and do not probe whether keys are set unless the error specifically indicates missing credentials and the user asks for diagnosis.
|
|
99
|
-
- A bare system error such as `Invalid argument` is a Slopdex/runtime failure, not evidence that a different indexing command is needed. Stop retrying, report the command and error, and recommend diagnosing or updating Slopdex.
|
|
100
|
-
- `slopdex --help` is the supported capability reference. There is no `slopdex --version` option; never invoke it.
|
|
101
|
-
|
|
102
|
-
## Analysis Examples
|
|
103
|
-
|
|
104
|
-
### Duplicate Analysis
|
|
35
|
+
To select another model:
|
|
105
36
|
|
|
106
37
|
```bash
|
|
107
|
-
slopdex
|
|
108
|
-
--cross-file-only \
|
|
109
|
-
--min-lines 4 \
|
|
110
|
-
--threshold 0.9 \
|
|
111
|
-
--limit 5
|
|
38
|
+
slopdex summaries enable --summary-model <model-id>
|
|
112
39
|
```
|
|
113
40
|
|
|
114
|
-
|
|
115
|
-
Cluster 1 (3 functions, similarity 0.9124-0.9568)
|
|
116
|
-
src/auth/session.ts:18:1 :: validateSession
|
|
117
|
-
src/http/middleware.ts:42:1 :: authenticate
|
|
118
|
-
src/users/user-service.ts:27:3 :: UserService.authenticate
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
This result found three substantial authentication functions in three files with very high similarity. Review them for repeated validation or session-handling logic that could move into one shared implementation. The middleware and service locations may represent intentional architectural layers, so treat the result as evidence to inspect rather than proof that the functions should be merged. The range describes observed links in a connected component; transitive clustering means every function is not necessarily directly similar to every other function.
|
|
122
|
-
|
|
123
|
-
### Cohesion Analysis
|
|
41
|
+
### Find duplicate candidates
|
|
124
42
|
|
|
125
43
|
```bash
|
|
126
|
-
slopdex
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
```text
|
|
130
|
-
Cohesion: 184 functions analyzed, 37 semantic edges
|
|
131
|
-
same file 35.1% same folder 29.7% remote 35.2% mean distance 1.84
|
|
132
|
-
|
|
133
|
-
1. gap 0.6053 similarity 0.9400 distance 4 reciprocal
|
|
134
|
-
src/auth/session.ts:18:1 :: validateSession
|
|
135
|
-
packages/http/middleware.ts:42:1 :: authenticate
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
There is no universal pass/fail cutoff for cohesion, but this example has several warning signs. More than a third of weighted semantic affinity crosses folder boundaries, and the mean distance of 1.84 is above the same-folder distance of one. The top pair is strongly related at 0.94 similarity yet four distance units apart, producing a relatively high gap of 0.6053; the reciprocal match strengthens that signal. A more cohesive result under the same settings would concentrate affinity in the same-file and same-folder percentages, have a lower mean distance, and contain few high-gap remote pairs. Inspect whether shared authentication behavior belongs in one module, while accounting for the possibility that session and middleware responsibilities are intentionally separated. Compare modules or repository history rather than treating one percentage as a fixed quality threshold.
|
|
139
|
-
|
|
140
|
-
## Reading Analysis Output
|
|
141
|
-
|
|
142
|
-
Interpret values only within the same embedding profile and similar command settings. Changing the model, threshold, neighbor count, source scope, or minimum line count changes the candidate graph and makes direct comparisons unreliable.
|
|
143
|
-
|
|
144
|
-
### Duplicate Clusters
|
|
145
|
-
|
|
146
|
-
For `Cluster 1 (3 functions, similarity 0.9124-0.9568)`:
|
|
147
|
-
|
|
148
|
-
- `Cluster 1` is the display identifier. Clusters are ordered by function count and then name, not severity, so a lower number is not inherently worse.
|
|
149
|
-
- `3 functions` counts unique callables connected by observed edges. Higher can indicate a larger duplicate family, but may also result from generic helpers or transitive links.
|
|
150
|
-
- `similarity 0.9124-0.9568` is the weakest-to-strongest raw cosine similarity among observed edges. Higher means greater semantic resemblance according to the configured model. A high minimum means every observed link is strong; a wide range can identify a weaker bridge.
|
|
151
|
-
- Callable lines use `path:line:column :: qualifiedFunctionName`. Location is contextual rather than scored; inspect architectural roles before consolidating code.
|
|
152
|
-
|
|
153
|
-
### Cohesion Summary
|
|
154
|
-
|
|
155
|
-
For `Cohesion: 184 functions analyzed, 37 semantic edges`:
|
|
156
|
-
|
|
157
|
-
- `functions analyzed` is coverage after filters, not a quality value.
|
|
158
|
-
- `semantic edges` counts unique top-neighbor pairs meeting the threshold before output limiting. Higher can reflect more overlapping responsibilities, but also increases with more neighbors or a lower threshold.
|
|
159
|
-
|
|
160
|
-
For `same file 35.1% same folder 29.7% remote 35.2% mean distance 1.84`:
|
|
161
|
-
|
|
162
|
-
- Higher `same file` generally means stronger co-location, though very high values can indicate oversized files.
|
|
163
|
-
- Higher `same folder` means related code is split into nearby modules but remains locally grouped.
|
|
164
|
-
- Higher `remote` means more semantic affinity crosses folder boundaries and indicates weaker physical cohesion.
|
|
165
|
-
- Lower `mean distance` generally means stronger physical cohesion. Zero is entirely within files, one reaches only other files in the same folder, and larger values indicate greater dispersion.
|
|
166
|
-
|
|
167
|
-
### Cohesion Findings
|
|
168
|
-
|
|
169
|
-
For `1. gap 0.6053 similarity 0.9400 distance 4 reciprocal`:
|
|
170
|
-
|
|
171
|
-
- A lower rank number is a higher review priority.
|
|
172
|
-
- Higher `gap` means stronger semantic affinity combined with greater physical separation; same-file pairs have zero gap.
|
|
173
|
-
- Higher `similarity` means stronger model-assessed resemblance, but does not prove duplication and is not comparable across embedding profiles.
|
|
174
|
-
- Higher `distance` means more file and directory-tree separation: zero is the same file and one is different files in the same folder.
|
|
175
|
-
- `reciprocal` strengthens confidence because both functions rank each other as neighbors. Its absence means one-directional or unevaluated under a source filter.
|
|
176
|
-
|
|
177
|
-
In JSON, higher `semanticWeight` means similarity lies farther above the threshold, and higher `separationWeight` means greater path distance. `sourceTestPair: true` flags an often-intentional source/test relationship. Higher file `externalAffinityRatio` means more observed related-function affinity lies outside that file's folder; lower means relationships are primarily internal or local.
|
|
178
|
-
|
|
179
|
-
## Semantic Search
|
|
180
|
-
|
|
181
|
-
Search indexed functions by intent:
|
|
182
|
-
|
|
183
|
-
```bash
|
|
184
|
-
slopdex search "validate an authenticated session" --limit 10
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
Use compact human-readable output and filter weak results:
|
|
188
|
-
|
|
189
|
-
```bash
|
|
190
|
-
slopdex search "validate an authenticated session" \
|
|
191
|
-
--format summary \
|
|
192
|
-
--threshold 0.8 \
|
|
193
|
-
--limit 10
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
`--threshold` is the minimum raw cosine similarity. Use a half-open range such as `--threshold 0.85-0.95` to include the left bound and exclude the right bound.
|
|
197
|
-
|
|
198
|
-
## Duplicate Discovery
|
|
199
|
-
|
|
200
|
-
Cross-search defaults to connected clusters. Treat each cluster as a source-review candidate rather than proof of duplication. Lower `--threshold` to broaden discovery, or lower `--min-lines` when short wrappers are relevant.
|
|
201
|
-
|
|
202
|
-
Summary output can instead group matches beneath each source:
|
|
203
|
-
|
|
204
|
-
```text
|
|
205
|
-
src/users.ts :: Users.authenticate
|
|
206
|
-
0.9321 src/session.ts :: validateSession
|
|
207
|
-
0.8475 src/auth.ts :: authenticate
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
Interpret high similarity as a candidate requiring source review, not proof of duplication. Public facade methods, API wrappers, interface implementations, and test doubles often score highly while serving distinct roles.
|
|
211
|
-
|
|
212
|
-
Cross-search excludes one-line callables by default. Raise `--min-lines` for more substantial duplicate candidates, or use `--min-lines 1` when short wrappers are relevant:
|
|
213
|
-
|
|
214
|
-
```bash
|
|
215
|
-
slopdex cross-search --min-lines 4 --threshold 0.9
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
Filter source symbols by qualified callable name while searching the whole eligible index:
|
|
219
|
-
|
|
220
|
-
```bash
|
|
221
|
-
slopdex cross-search -e '^(User|Session)\.' --source-path src --threshold 0.9
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
`-e` / `--regexp` uses a case-sensitive JavaScript regex. In cross-search and cohesion, it restricts sources only. Combine it with `--source-path`, `--changed-since`, `--uncommitted`, and other analysis options. When both Git filters are present, sources must have changed since the commit and belong to an uncommitted file. In `search` and `search-summary`, `-e` filters result names before applying `--limit`.
|
|
225
|
-
|
|
226
|
-
To filter both source and matching candidates, use `--regex`:
|
|
227
|
-
|
|
228
|
-
```bash
|
|
229
|
-
slopdex cross-search --regex '^(User|Session)\.' --threshold 0.9
|
|
44
|
+
slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.9 --limit 5
|
|
230
45
|
```
|
|
231
46
|
|
|
232
|
-
|
|
47
|
+
The default output is connected clusters. This excludes same-file matches and short functions. For source-by-source matches, add `--format summary`.
|
|
233
48
|
|
|
234
|
-
|
|
49
|
+
Broaden discovery through adjacent score bands when needed:
|
|
235
50
|
|
|
236
51
|
```bash
|
|
237
|
-
slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.9 --limit 5
|
|
238
52
|
slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.85-0.9 --limit 5
|
|
239
53
|
slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.8-0.85 --limit 5
|
|
240
54
|
```
|
|
241
55
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
Same-index search reports each unordered pair once by default. Include both `A -> B` and `B -> A` only when explicitly needed:
|
|
245
|
-
|
|
246
|
-
```bash
|
|
247
|
-
slopdex cross-search --include-symmetric-duplicates
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
Exclude candidates from the source function's file when looking for duplication across files:
|
|
251
|
-
|
|
252
|
-
```bash
|
|
253
|
-
slopdex cross-search --cross-file-only --format summary --threshold 0.9
|
|
254
|
-
```
|
|
56
|
+
Ranges include the lower bound and exclude the upper bound. Use `--min-lines 1` when one-line wrappers are relevant.
|
|
255
57
|
|
|
256
|
-
|
|
58
|
+
### Review changes or a module
|
|
257
59
|
|
|
258
60
|
```bash
|
|
259
|
-
slopdex cross-search --
|
|
61
|
+
slopdex cross-search --uncommitted --cross-file-only --min-lines 4 --threshold 0.9
|
|
62
|
+
slopdex cross-search --changed-since origin/main --format summary --threshold 0.9
|
|
63
|
+
slopdex cross-search --source-path src/services -e '^UserService\.' --format summary --threshold 0.9
|
|
260
64
|
```
|
|
261
65
|
|
|
262
|
-
|
|
66
|
+
These restrict sources while searching the full eligible index. The same filters work with `cohesion`. All supplied restrictions intersect:
|
|
263
67
|
|
|
264
68
|
```bash
|
|
265
|
-
slopdex cross-search --source-path src
|
|
69
|
+
slopdex cross-search --source-path src -e 'validate' \
|
|
70
|
+
--changed-since origin/main --uncommitted \
|
|
71
|
+
--cross-file-only --min-lines 4 --threshold 0.9
|
|
266
72
|
```
|
|
267
73
|
|
|
268
|
-
|
|
74
|
+
Here a source must have changed since the commit and belong to an uncommitted file, within the selected path/name scope. `--regex` is an alias for `-e/--regexp`.
|
|
269
75
|
|
|
270
|
-
|
|
76
|
+
### Review physical cohesion
|
|
271
77
|
|
|
272
78
|
```bash
|
|
273
|
-
slopdex
|
|
79
|
+
slopdex cohesion --threshold 0.8 --neighbors 20 --limit 50 --format summary
|
|
80
|
+
slopdex cohesion --source-path src/services --threshold 0.8 --format summary
|
|
274
81
|
```
|
|
275
82
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
```bash
|
|
279
|
-
slopdex cross-search --uncommitted --format summary --threshold 0.9
|
|
280
|
-
```
|
|
83
|
+
Ranks related functions by semantic affinity and file/folder separation. add `--include-source` only when full callable bodies are needed.
|
|
281
84
|
|
|
282
|
-
|
|
85
|
+
### Compare repositories
|
|
283
86
|
|
|
284
87
|
```bash
|
|
285
88
|
slopdex cross-search \
|
|
286
|
-
--target-root /path/to/other/
|
|
287
|
-
--target-index /path/to/other/
|
|
288
|
-
--format summary
|
|
289
|
-
--threshold 0.8
|
|
89
|
+
--target-root /path/to/other/repo \
|
|
90
|
+
--target-index /path/to/other/repo/.slopdex/index.sqlite \
|
|
91
|
+
--threshold 0.9 --format summary
|
|
290
92
|
```
|
|
291
93
|
|
|
292
|
-
|
|
293
|
-
Use `--target-config <path>` when the target repository does not use `.slopdex/config.json`.
|
|
94
|
+
Both target options are required. Both indexes refresh and must have identical embedding profiles. The target refresh uses the source command's embedding provider and the target's file-selection/summary configuration. Use `--target-config <path>` for a custom target config.
|
|
294
95
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
Use JSON when passing the report to another tool or an LLM:
|
|
96
|
+
### Inspect or maintain the index
|
|
298
97
|
|
|
299
98
|
```bash
|
|
300
|
-
slopdex
|
|
99
|
+
slopdex status
|
|
100
|
+
slopdex index-errors --format summary
|
|
101
|
+
slopdex update-git
|
|
102
|
+
slopdex update-files src/service.ts src/model.ts
|
|
103
|
+
slopdex delete-files src/removed.ts
|
|
104
|
+
slopdex --version
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
- `status` refreshes, then reports coverage, checkpoint, profiles, and error counts; use when metadata is requested.
|
|
108
|
+
- `index-errors` reads saved failures without refreshing or needing API credentials.
|
|
109
|
+
- `update-git` explicitly refreshes HEAD and working-tree changes.
|
|
110
|
+
- `update-files` reparses specified working-tree files after automatic refresh, even when their contents are unchanged.
|
|
111
|
+
- `delete-files` removes index entries after automatic refresh, not source files. Eligible files can return on later refresh.
|
|
112
|
+
- `--version` prints the built package version. `--help` describes available commands/options.
|
|
113
|
+
|
|
114
|
+
## Command-line reference
|
|
115
|
+
|
|
116
|
+
Usage: `slopdex <command> [arguments] [options]`. Quote queries and regexes. Boolean flags default to off. Use options only with their applicable commands.
|
|
117
|
+
|
|
118
|
+
### General settings
|
|
119
|
+
|
|
120
|
+
| Argument | Meaning / default |
|
|
121
|
+
| --- | --- |
|
|
122
|
+
| `--root <path>` | Repository root; current directory by default. |
|
|
123
|
+
| `--config <path>` | Config; `<root>/.slopdex/config.json`. |
|
|
124
|
+
| `--index <path>` | Index; `<root>/.slopdex/index.sqlite`. Overrides config `indexPath`. |
|
|
125
|
+
| `--provider <openai\|jina>` | Embedding provider; `openai`. |
|
|
126
|
+
| `--model <name>` | Embedding model; OpenAI `text-embedding-3-large`, Jina `jina-embeddings-v4`. |
|
|
127
|
+
| `--dimensions <number>` | Positive dimensions supported by the model; OpenAI `3072`, Jina `1024`. |
|
|
128
|
+
| `--summary-model <name>` | OpenAI summary model; initially `gpt-5.6-sol`, then the persisted selection. |
|
|
129
|
+
| `--ignore-errors` | Silence saved-diagnostic warnings without deleting records. |
|
|
130
|
+
| `-h`, `--help` | Usage; no refresh. |
|
|
131
|
+
| `--version` | Package version; exits without refresh or saved-diagnostic warnings. |
|
|
132
|
+
|
|
133
|
+
Explicit relative config/index paths resolve from the current directory. Source paths and explicit file arguments resolve within `--root`. Prefer absolute paths when operating across repositories. CLI settings override config.
|
|
134
|
+
|
|
135
|
+
### Query and analysis options
|
|
136
|
+
|
|
137
|
+
| Argument | Applies to / behavior |
|
|
138
|
+
| --- | --- |
|
|
139
|
+
| `--limit <number>` | Positive integer. `search`/`search-summary`: matches, default `10`. Cross-search: neighbors per source, default `5`. Cohesion: reported pairs and file rows, default `50`. |
|
|
140
|
+
| `--threshold <number\|min-max>` | Both query searches and analyses. Inclusive minimum or half-open range. Default `-1` for query/cross-search; `0.8` for cohesion. Cohesion minimum must be in `[-1, 1)`. |
|
|
141
|
+
| `--format <json\|summary\|clusters>` | Both query searches, cross-search, cohesion, index-errors. `clusters` only supports cross-search; output defaults below. |
|
|
142
|
+
| `-e <regex>`, `--regexp <regex>`, `--regex <regex>` | Equivalent case-sensitive JavaScript regex options on qualified names. Query searches filter results before limiting; cross-search/cohesion filter sources only. |
|
|
143
|
+
| `--min-lines <number>` | Cross-search/cohesion: positive source/candidate length minimum, default `2`. |
|
|
144
|
+
| `--source-path <path>` | Cross-search/cohesion: source file or recursive directory within the root. |
|
|
145
|
+
| `--changed-since <commit>` | Cross-search/cohesion: added, modified, or moved functions since an ancestor of the indexed Git checkpoint, including working-tree changes. Requires Git. |
|
|
146
|
+
| `--uncommitted` | Cross-search/cohesion: functions indexed from working-tree files; in Git these are staged, unstaged, or untracked changes. Without Git this selects all working-tree functions. |
|
|
147
|
+
| `--cross-file-only` | Cross-search: exclude same-physical-file matches. |
|
|
148
|
+
| `--include-symmetric-duplicates` | Cross-search: allow both directions of same-index matches; otherwise each unordered pair appears once. |
|
|
149
|
+
| `--neighbors <number>` | Cohesion: positive neighbor count per source, default `20`; changes analysis scope. |
|
|
150
|
+
| `--include-source` | Cohesion JSON: include callable bodies; omitted by default. |
|
|
151
|
+
| `--target-root <path>` | Cross-search: second repository; requires `--target-index`. |
|
|
152
|
+
| `--target-index <path>` | Cross-search: second index file; requires `--target-root`. |
|
|
153
|
+
| `--target-config <path>` | Cross-search: target config, default `<target-root>/.slopdex/config.json`; requires both target options. |
|
|
154
|
+
|
|
155
|
+
### Refresh and recovery options
|
|
156
|
+
|
|
157
|
+
| Argument | Behavior |
|
|
158
|
+
| --- | --- |
|
|
159
|
+
| `--target <ref>` | `update-git` snapshot, default `HEAD`. Non-HEAD targets are committed-only; later commands normally return to HEAD. |
|
|
160
|
+
| `--rebuild-on-divergence` | Permit reconciliation after non-descendant history changes, such as a rebase/branch switch. |
|
|
161
|
+
| `--force-reindex` | Recreate an incompatible index. Compatible indexes still use normal refresh; this is not an unconditional reparse flag. |
|
|
162
|
+
| `--no-reindex` | With Git, reconcile the committed snapshot but omit working-tree overlays. Without Git, reuse a non-empty index; missing/empty indexes still populate. Not an offline mode. |
|
|
163
|
+
|
|
164
|
+
Use `--no-reindex` when the task calls for committed-only results or reuse of an existing non-Git index, rather than silently weakening freshness.
|
|
165
|
+
|
|
166
|
+
## Interpret and report results
|
|
167
|
+
|
|
168
|
+
### Output formats
|
|
169
|
+
|
|
170
|
+
| Command | Default | Alternatives |
|
|
171
|
+
| --- | --- | --- |
|
|
172
|
+
| `search`, `search-summary` | `summary` | JSON array; purpose search includes generated summary text |
|
|
173
|
+
| `cross-search` | `clusters` | `summary`, or `json` for JSONL with one row per matched source |
|
|
174
|
+
| `cohesion` | `summary` | One JSON report |
|
|
175
|
+
| `index-errors` | `summary` | JSON array |
|
|
176
|
+
| `status`, update commands, `summaries` | JSON object | — |
|
|
177
|
+
|
|
178
|
+
Prefer summary output for compact source review, clusters for duplicate families, and JSON/JSONL for structured processing. Stdout carries results; stderr carries notices and warnings. Cross-search omits sources without emitted matches. Empty output means no findings under the chosen coverage/filters, not proof that no similar code exists.
|
|
179
|
+
|
|
180
|
+
### Similarity and clusters
|
|
181
|
+
|
|
182
|
+
```text
|
|
183
|
+
Cluster 1 (3 functions, similarity 0.9124-0.9568)
|
|
184
|
+
src/auth/session.ts:18:1 :: validateSession
|
|
185
|
+
src/http/middleware.ts:42:1 :: authenticate
|
|
186
|
+
src/users/user-service.ts:27:3 :: UserService.authenticate
|
|
301
187
|
```
|
|
302
188
|
|
|
303
|
-
|
|
189
|
+
- Similarity is a model-dependent resemblance score, not a duplication probability.
|
|
190
|
+
- The range describes observed links. Members can be connected transitively; not all pairs necessarily match.
|
|
191
|
+
- Cluster numbers reflect ordering by member count and name, not severity.
|
|
192
|
+
- Inspect listed locations and callers. Tests, facades, adapters, and intentional layers can resemble each other without being redundant.
|
|
304
193
|
|
|
305
|
-
|
|
194
|
+
When reporting candidates, identify paths/symbols, summarize the shared behavior you verified, and explain whether consolidation is appropriate. Do not infer equivalence from the score alone.
|
|
306
195
|
|
|
307
|
-
|
|
196
|
+
### Purpose-aware scoring
|
|
308
197
|
|
|
309
|
-
|
|
310
|
-
- `--format clusters` groups overlapping pairs and lists each function once with its source line.
|
|
311
|
-
- The default `search` output is formatted JSON.
|
|
312
|
-
- The default `cross-search` output is connected clusters. Use `--format json` for JSONL with one object per source function.
|
|
313
|
-
- The default `cohesion` output is one compact JSON report. Use `--format summary` for ranked pairs.
|
|
314
|
-
- Functions with no matches after threshold filtering are omitted from cross-search output.
|
|
198
|
+
`search` uses code only; `search-summary` uses purpose summaries only. Cross-search and cohesion automatically use **50% code + 50% summary similarity** when summaries are enabled and complete. Cross-repository analysis needs completeness on both sides; otherwise all scores are code-only. Summary-generator models may differ even though embedding profiles must match.
|
|
315
199
|
|
|
316
|
-
|
|
200
|
+
Thresholds and limits apply to the selected score. Text labels combined scoring; JSON includes component scores and mode/weights (`scoring` in cross-search, `parameters` in cohesion). Compare runs only with matching scoring mode, weights, embedding and summary-generator profiles, threshold, neighbor count, and source/candidate filters.
|
|
317
201
|
|
|
318
|
-
|
|
202
|
+
### Cohesion
|
|
319
203
|
|
|
320
204
|
```text
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
--force-rebuild Rebuild an incompatible existing index
|
|
328
|
-
--limit <number> Result limit
|
|
329
|
-
--neighbors <number> Semantic neighbors per function for cohesion
|
|
330
|
-
--threshold <number|range> Similarity threshold or half-open range
|
|
331
|
-
--format <json|summary|clusters> Output format
|
|
332
|
-
--include-source Include callable source in cohesion JSON
|
|
333
|
-
--cross-file-only Exclude matches from the source file
|
|
334
|
-
--min-lines <number> Minimum cross-search callable length
|
|
335
|
-
-e, --regexp <regex> Match qualified symbols (analysis: sources only)
|
|
336
|
-
--regex <regex> Match both analysis source and candidate names
|
|
337
|
-
--target-config <path> Target repository configuration file
|
|
205
|
+
Cohesion: 184 functions analyzed, 37 semantic edges
|
|
206
|
+
same file 35.1% same folder 29.7% remote 35.2% mean distance 1.84
|
|
207
|
+
|
|
208
|
+
1. gap 0.6053 similarity 0.9400 distance 4 reciprocal
|
|
209
|
+
src/auth/session.ts:18:1 :: validateSession
|
|
210
|
+
packages/http/middleware.ts:42:1 :: authenticate
|
|
338
211
|
```
|
|
339
212
|
|
|
340
|
-
|
|
213
|
+
- **Functions analyzed / edges:** selected-source coverage and unique qualifying neighbor pairs before report limiting, not quality grades.
|
|
214
|
+
- **Same file / same folder / remote:** shares of weighted semantic affinity. More remote affinity means more related code crosses folder boundaries.
|
|
215
|
+
- **Mean distance:** weighted physical separation; `0` is same file, `1` is different files in one folder, larger means farther apart.
|
|
216
|
+
- **Gap / rank:** a `0–1` review score combining similarity above the threshold with separation. Higher gap ranks earlier; same-file pairs have zero gap.
|
|
217
|
+
- **Reciprocal:** both functions selected each other as neighbors. JSON `null` means an endpoint was not evaluated because of source filtering.
|
|
218
|
+
- **JSON details:** `semanticWeight` reflects similarity above threshold; `separationWeight` reflects distance; `sourceTestPair` flags a path-inferred source/test relationship; file `externalAffinityRatio` measures affinity outside that file's folder.
|
|
219
|
+
|
|
220
|
+
The example merits reviewing separated authentication responsibilities, while accounting for intentional layering. There is no universal pass/fail threshold. Use comparable runs to evaluate changes. Filtered reports describe selected sources, not the full repository. Summary metrics use all qualifying edges; pairs/files are limited, and groups use reported pairs.
|