@ninjaxtools/slopdex 0.14.0 → 0.18.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.
Files changed (54) hide show
  1. package/.agents/skills/slopdex/SKILL.md +14 -11
  2. package/README.md +91 -219
  3. package/dist/chunk-6LHZCHEB.js +1112 -0
  4. package/dist/chunk-6LHZCHEB.js.map +1 -0
  5. package/dist/chunk-BXWO2KMC.js +20 -0
  6. package/dist/chunk-BXWO2KMC.js.map +1 -0
  7. package/dist/chunk-DKRB2XT5.js +33 -0
  8. package/dist/chunk-DKRB2XT5.js.map +1 -0
  9. package/dist/chunk-DTI7SXGL.js +109 -0
  10. package/dist/chunk-DTI7SXGL.js.map +1 -0
  11. package/dist/chunk-IQU3YVZ3.js +85 -0
  12. package/dist/chunk-IQU3YVZ3.js.map +1 -0
  13. package/dist/chunk-JAVPHCZH.js +24 -0
  14. package/dist/chunk-JAVPHCZH.js.map +1 -0
  15. package/dist/chunk-KQRS5P4U.js +10 -0
  16. package/dist/chunk-KQRS5P4U.js.map +1 -0
  17. package/dist/chunk-KUV6PKKL.js +425 -0
  18. package/dist/chunk-KUV6PKKL.js.map +1 -0
  19. package/dist/chunk-MKUTTXZB.js +74 -0
  20. package/dist/chunk-MKUTTXZB.js.map +1 -0
  21. package/dist/chunk-N6D66ASM.js +2217 -0
  22. package/dist/chunk-N6D66ASM.js.map +1 -0
  23. package/dist/chunk-OIKBO3NJ.js +133 -0
  24. package/dist/chunk-OIKBO3NJ.js.map +1 -0
  25. package/dist/chunk-S225GYCL.js +79 -0
  26. package/dist/chunk-S225GYCL.js.map +1 -0
  27. package/dist/chunk-TSURHRFF.js +240 -0
  28. package/dist/chunk-TSURHRFF.js.map +1 -0
  29. package/dist/chunk-VH5VGRCI.js +103 -0
  30. package/dist/chunk-VH5VGRCI.js.map +1 -0
  31. package/dist/cli.js +240 -3561
  32. package/dist/cli.js.map +1 -1
  33. package/dist/code-index-YEFTNG7E.js +14 -0
  34. package/dist/code-index-YEFTNG7E.js.map +1 -0
  35. package/dist/cross-search-FVKDMGP7.js +10 -0
  36. package/dist/cross-search-FVKDMGP7.js.map +1 -0
  37. package/dist/database-KAPV2YMP.js +14 -0
  38. package/dist/database-KAPV2YMP.js.map +1 -0
  39. package/dist/hosted-GHIUHKOU.js +13 -0
  40. package/dist/hosted-GHIUHKOU.js.map +1 -0
  41. package/dist/index.d.ts +109 -2
  42. package/dist/index.js +38 -3583
  43. package/dist/index.js.map +1 -1
  44. package/dist/jina-43RL7C6M.js +12 -0
  45. package/dist/jina-43RL7C6M.js.map +1 -0
  46. package/dist/openai-CYUPNBGB.js +12 -0
  47. package/dist/openai-CYUPNBGB.js.map +1 -0
  48. package/dist/openai-EC6THXKV.js +21 -0
  49. package/dist/openai-EC6THXKV.js.map +1 -0
  50. package/dist/openai-TCRXM66O.js +11 -0
  51. package/dist/openai-TCRXM66O.js.map +1 -0
  52. package/docs/implementation.md +10 -19
  53. package/docs/reference.md +187 -0
  54. package/package.json +4 -3
@@ -41,7 +41,8 @@ slopdex search-description "keep the repository index synchronized" --format sum
41
41
  ```
42
42
 
43
43
  Enabling needs `OPENAI_API_KEY` by default. Select OpenCode Zen or Go with
44
- `--description-provider opencode` or `--description-provider opencode-go` and set `OPENCODE_API_KEY`.
44
+ `--description-provider opencode` or `--description-provider opencode-go` and set `OPENCODE_API_KEY`
45
+ or sign in with `opencode auth login`, which stores the key in `~/.local/share/opencode/auth.json`.
45
46
 
46
47
  To select another model:
47
48
 
@@ -63,16 +64,16 @@ The next index-using command applies the configured description state. A bare mo
63
64
  ### Find duplicate candidates
64
65
 
65
66
  ```bash
66
- slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.9 --limit 5
67
+ slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.9 --matches 5 --limit 5
67
68
  ```
68
69
 
69
- The default output is connected clusters. This excludes same-file matches and short functions. For source-by-source matches, add `--format summary`.
70
+ The default output is connected clusters. This excludes same-file matches and short functions, keeps 5 matches per source, and emits at most 5 clusters. For source-by-source matches, add `--format summary`. `--limit` caps emitted clusters/sources (unlimited by default); `--matches` caps matches per source (default 5).
70
71
 
71
72
  Broaden discovery through adjacent score bands when needed:
72
73
 
73
74
  ```bash
74
- slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.85-0.9 --limit 5
75
- slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.8-0.85 --limit 5
75
+ slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.85-0.9 --matches 5
76
+ slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.8-0.85 --matches 5
76
77
  ```
77
78
 
78
79
  Ranges include the lower bound and exclude the upper bound. Use `--min-lines 1` when one-line wrappers are relevant.
@@ -98,7 +99,7 @@ Here a source must have changed since the commit and belong to an uncommitted fi
98
99
  ### Review physical cohesion
99
100
 
100
101
  ```bash
101
- slopdex cross-search --cohesion --threshold 0.8 --limit 20 --format summary
102
+ slopdex cross-search --cohesion --threshold 0.8 --matches 20 --format summary
102
103
  slopdex cross-search --cohesion --source-path src/services --threshold 0.8 --format summary
103
104
  ```
104
105
 
@@ -150,10 +151,11 @@ Usage: `slopdex <command> [arguments] [options]`. Quote queries and regexes. Boo
150
151
  | `--provider <openai\|jina>` | Embedding provider; `openai`. |
151
152
  | `--model <name>` | Embedding model; OpenAI `text-embedding-3-large`, Jina `jina-embeddings-v4`. |
152
153
  | `--dimensions <number>` | Positive dimensions supported by the model; OpenAI `3072`, Jina `1024`. |
153
- | `--description-provider <openai\|opencode\|opencode-go>` | Description provider; OpenAI by default. OpenCode values require `OPENCODE_API_KEY`. |
154
- | `--description-model <name>` | Description model; `gpt-5.6-sol` for OpenAI/Zen and `gpt-5.6-luna` for Go. |
154
+ | `--description-provider <openai\|opencode\|opencode-go>` | Description provider; OpenAI by default. OpenCode values use `OPENCODE_API_KEY` or `~/.local/share/opencode/auth.json`. |
155
+ | `--description-model <name>` | Description model; `gpt-5.6-luna` for OpenAI and `muse-spark-1.3-contributor` for Zen/Go. |
155
156
  | `--reranker-candidates <number>` | With `config reranker openai`, embedding-ranked functions sent to the LLM; range `1`-`100`, default `10`. |
156
157
  | `--ignore-errors` | Silence saved-diagnostic warnings without deleting records. |
158
+ | `--verbose` | Report every external model request on stderr instead of once per call kind/provider/model. Config `"verbose": true` has the same effect. |
157
159
  | `-h`, `--help` | Usage; no refresh. |
158
160
  | `--version` | Package version; exits without refresh or saved-diagnostic warnings. |
159
161
 
@@ -163,8 +165,9 @@ Explicit relative config/index paths resolve from the current directory. Source
163
165
 
164
166
  | Argument | Applies to / behavior |
165
167
  | --- | --- |
166
- | `--limit <number>` | Positive integer. `search`/`search-description`: matches, default `10`. Cross-search: neighbors per source, default `5`. |
167
- | `--threshold <number\|min-max>` | Both query searches and cross-search. Inclusive minimum or half-open range; default `-1`. |
168
+ | `--limit <number>` | Positive integer output limit; unlimited unless passed. Query matches, or cross-search clusters (`clusters`) / matched sources (`summary`/JSONL). Threshold filters results. |
169
+ | `--matches <number>` | Cross-search only: matches kept per source function; default `5`. |
170
+ | `--threshold <number\|min-max>` | Both query searches and cross-search. Inclusive minimum or half-open range; default `0.3`. |
168
171
  | `--format <json\|summary\|clusters>` | Both query searches, cross-search, and index-errors. Cohesion-ranked cross-search supports summary or JSONL, not clusters. |
169
172
  | `-e <regex>`, `--regexp <regex>`, `--regex <regex>` | Equivalent case-sensitive JavaScript regex options on qualified names. Query searches filter results before limiting; cross-search filters sources only. |
170
173
  | `--min-lines <number>` | Cross-search: positive source/candidate length minimum, default `2`. |
@@ -201,7 +204,7 @@ Use `--no-reindex` when the task calls for committed-only results or reuse of an
201
204
  | `index-errors` | `summary` | JSON array |
202
205
  | `status`, update commands, `descriptions` | JSON object | — |
203
206
 
204
- 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.
207
+ 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. External vector, description, and reranking requests identify their provider and model once per combination, or for every request with `--verbose`. Cross-search omits sources without emitted matches. Empty output means no findings under the chosen coverage/filters, not proof that no similar code exists.
205
208
 
206
209
  With reranking enabled, query summaries display both reranker relevance and embedding similarity. Similarity thresholds filter candidates before reranking; limits apply to the reranked output. LLM candidate documents include descriptions when available and function metadata/source code.
207
210
 
package/README.md CHANGED
@@ -1,292 +1,164 @@
1
+ This repository employs the use of LLMs for [automatic programming](https://antirez.com/news/159).
2
+
3
+ This readme is written by a human.
4
+
1
5
  # slopdex
2
6
 
3
- Search functions by meaning, find duplicate-code candidates, and locate related functions spread across a codebase.
7
+ <img src="sloppy-dexter.png" width="280" align="right" alt="Dexter, the sloppy slime" />
8
+
9
+ Slopdex helps with doing analysis on codebases that contain a lot of AI generated code.
4
10
 
5
- ## Start here
11
+ The main supported functions are
6
12
 
7
- Requires an embedding-provider API key. Install, set your key, and run commands from the repository you want to analyze (or pass `--root /path/to/repo`):
13
+ - `slopdex search <query>`
14
+ <br/>which finds code similar to the query
15
+ - `slopdex cross-search`
16
+ <br/>which finds clusters of similar code
8
17
 
9
- Coding agents should start with the bundled [Slopdex agent skill](.agents/skills/slopdex/SKILL.md).
18
+ `cross-search` helps with finding duplicated code, and with `--cohesion` helps with identifying similar code that is not necessarily duplicated but spread out across the codebase, which could indicate that a refactoring could make it more cohesive.
19
+
20
+ ## Getting started
21
+
22
+ An embedding-provider API key is required. You can use either OpenAI or Jina.
10
23
 
11
24
  ```bash
12
25
  npm install -g @ninjaxtools/slopdex
26
+
13
27
  export OPENAI_API_KEY="your-api-key"
14
- slopdex search "validate an authenticated session" --format summary --limit 10
15
- ```
28
+ # Or
29
+ # export JINA_API_KEY="your-api-key" # and pass --provider jina
16
30
 
17
- The first command creates the index automatically. Later commands refresh it before searching.
31
+ slopdex search "validate an authenticated session"
32
+ ```
18
33
 
19
- Add `.slopdex/` to your repository's `.gitignore`.
34
+ The index tracks the current git commit and is created or updated on every command and stored in `.slopdex/index.sqlite`. Add `.slopdex/` to your repository's `.gitignore` to prevent it from being committed.
20
35
 
21
36
  ### Search code
22
37
 
23
- ```bash
24
- slopdex search "keep the repository index synchronized" --format summary --limit 10
25
- ```
26
-
27
- Optionally enable a hosted second-stage reranker for `search` and `search-description`:
38
+ By default only vector embeddings of code is used for search.
28
39
 
29
40
  ```bash
30
- export COHERE_API_KEY="your-api-key"
31
- slopdex config reranker cohere
32
- # Or: export JINA_API_KEY="your-api-key" && slopdex config reranker jina
33
- # Or use an LLM: export OPENAI_API_KEY="your-api-key" && slopdex config reranker openai
41
+ $ slopdex search "keep the repository index synchronized"
42
+ 0.4284 tests/languages.test.ts :: refresh
43
+ 0.4200 src/cli.ts :: refreshIndex
44
+ 0.4113 src/code-index.ts :: CodeIndex.updateFromGit
45
+ ...
34
46
  ```
35
47
 
36
- The config command is the only CLI switch for reranking. Use `slopdex config reranker disable` to return to embedding-only ordering. An optional final argument selects a model, for example `slopdex config reranker cohere rerank-v4.0-fast`. OpenAI LLM reranking defaults to `gpt-5.6-luna` with high reasoning and receives the top 10 embedding results; change the pool with `--reranker-candidates`, for example `slopdex config reranker openai gpt-5.6-luna --reranker-candidates 20`.
48
+ You can also enable optional description generation which will automatically generate file and function descriptions with a configured LLM provider and include them in the search.
37
49
 
38
- To search generated descriptions of each function's role instead:
50
+ I use OpenCode Go usually with DeepSeek or Muse Spark, which are fairly good low-cost models. If you
51
+ sign up for OpenCode Go through [this link](https://opencode.ai/go?ref=RAR3Z744DZ), we both receive
52
+ $5 in credit.
39
53
 
40
54
  ```bash
55
+ export OPENAI_API_KEY="your-api-key"
56
+ # Or
57
+ # export OPENCODE_API_KEY="your-api-key" # for OpenCode Zen/Go descriptions
58
+ # Or
59
+ # opencode auth login # use stored credentials instead of env variables
60
+
41
61
  slopdex descriptions enable
42
- slopdex search-description "keep the repository index synchronized" --format summary --limit 10
62
+ slopdex search-description "keep the repository index synchronized"
43
63
  ```
44
64
 
45
- The default description provider requires `OPENAI_API_KEY` even when Jina supplies embeddings. OpenCode Zen and Go use `OPENCODE_API_KEY`. Description generation can add provider costs; see [descriptions and scoring](#descriptions-and-scoring).
46
-
47
- `descriptions disable` turns off description generation while retaining cached data.
48
-
49
- To choose from OpenCode's current published models and persist description settings without creating an index:
65
+ You can list and configure one of OpenCode's models like this:
50
66
 
51
67
  ```bash
52
68
  slopdex models opencode-go
53
69
  slopdex config model opencode-go/gpt-5.6-luna
54
- slopdex config descriptions enable
55
70
  ```
56
71
 
57
- The next index-using command creates or refreshes the index and applies the configured description state.
58
- You can also pass the selection separately as `slopdex config model --description-provider opencode-go --description-model gpt-5.6-luna`.
72
+ ### Find duplicate-code
59
73
 
60
- ### Find duplicate-code candidates
74
+ Compare functions across files, exclude short wrappers, and group matches into clusters:
61
75
 
62
76
  ```bash
63
- slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.9 --limit 5
77
+ $ slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.9
78
+ Cluster 1 (3 functions, similarity 0.9124-0.9568)
79
+ src/auth/session.ts:18:1 :: validateSession
80
+ src/http/middleware.ts:42:1 :: authenticate
81
+ src/users/user-service.ts:27:3 :: UserService.authenticate
82
+ ...
64
83
  ```
65
84
 
66
- Compare functions across files, exclude short wrappers, and group strong matches into clusters. `--limit 5` selects up to five neighbors **per source function**, not five clusters.
85
+ Using `--cross-file-only` is useful to exclude similar code in the same file.
67
86
 
68
- ### Review changed code or one module
87
+ Review adjacent bands with threshold ranges:
69
88
 
70
89
  ```bash
71
- slopdex cross-search --uncommitted --cross-file-only --min-lines 4 --threshold 0.9
72
- slopdex cross-search --changed-since origin/main --format summary --threshold 0.9
73
- slopdex cross-search --source-path src/services -e '^UserService\.' --format summary --threshold 0.9
90
+ slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.9
91
+ slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.85-0.9
74
92
  ```
75
93
 
76
- These select source functions while keeping the full eligible index available for matches.
94
+ ### Restrict functions used in the cross-search
77
95
 
78
- ### Find related code stored far apart
96
+ Only use uncommitted working-tree functions as sources:
79
97
 
80
98
  ```bash
81
- slopdex cross-search --cohesion --threshold 0.8 --limit 20 --format summary
99
+ slopdex cross-search --uncommitted --cross-file-only --min-lines 4 --threshold 0.9
82
100
  ```
83
101
 
84
- `--cohesion` keeps the semantic matches selected by cross-search, annotates them with physical distance, and orders each source's matches from farthest to nearest. Similarity breaks distance ties.
85
-
86
- ### Compare repositories
102
+ Only use functions changed since origin/main as sources:
87
103
 
88
104
  ```bash
89
- slopdex cross-search \
90
- --target-root /path/to/other/repo \
91
- --target-index /path/to/other/repo/.slopdex/index.sqlite \
92
- --threshold 0.9 --format summary
105
+ slopdex cross-search --changed-since origin/main --threshold 0.9
93
106
  ```
94
107
 
95
- Both indexes refresh automatically and must use identical embedding profiles. The target is refreshed with the source command's embedding provider; target configuration supplies file-selection and description settings. Use `--target-config` for a non-default target config.
96
-
97
- ### Inspect index health
108
+ Only use matching symbols under src/services as sources:
98
109
 
99
110
  ```bash
100
- slopdex status
101
- slopdex index-errors --format summary
102
- slopdex --version
111
+ slopdex cross-search --source-path src/services -e '^UserService\.' --threshold 0.9
103
112
  ```
104
113
 
105
- `status` refreshes the index and reports coverage, profiles, checkpoint, and error counts. `index-errors` reads saved failures without refreshing or requiring credentials. `--version` prints the built package version.
106
-
107
- ## Commands
114
+ ### Find related code stored far apart
108
115
 
109
- Usage: `slopdex <command> [arguments] [options]`.
110
-
111
- | Command | Purpose | Output |
112
- | --- | --- | --- |
113
- | `models [opencode\|opencode-go]` | Fetch valid models from the current published Zen and/or Go catalogs. | Qualified `provider/model` lines; optional JSON array |
114
- | `config model <model\|provider/model>` | Validate a published OpenCode model and persist its provider/model selection without opening an index. Bare IDs auto-resolve only when unambiguous. | Updated setting summary; optional JSON |
115
- | `config descriptions <enable\|disable>` | Persist whether the next index-using command should enable or disable descriptions. Does not open an index. | Updated setting summary; optional JSON |
116
- | `config reranker <cohere\|jina\|openai\|disable> [model]` | Enable a hosted or OpenAI LLM query reranker, optionally selecting a model, or disable it. OpenAI accepts `--reranker-candidates <number>` from 1 to 100 and defaults to 10. Does not open an index. | Updated setting summary; optional JSON |
117
- | `search <query>` | Search function code by meaning. Quote multiword queries. | Summary; optional JSON array |
118
- | `descriptions <enable\|disable>` | Enable or disable automatic purpose descriptions. Re-enabling with unchanged inputs reuses cached descriptions. | JSON statistics |
119
- | `search-description <query>` | Search purpose descriptions after enabling them. | Summary including description text; optional JSON array |
120
- | `cross-search` | Find neighbors for each selected function in this or another index. | `clusters` by default; optional `summary` or JSONL |
121
- | `status` | Refresh and show index metadata, counts, and profiles. | JSON object |
122
- | `index-errors` | Read saved file/function indexing failures. | Summary; optional JSON array |
123
- | `update-git` | Explicitly refresh a Git snapshot, with current working-tree changes when targeting HEAD. | JSON update statistics |
124
- | `update-files <path...>` | After automatic refresh, explicitly reparse selected working-tree files. Paths are repository-relative or absolute within the root. | JSON update statistics |
125
- | `reindex-files [--callables]` | Regenerate descriptions for files changed since their stored file description. By default stops after each file description; `--callables` also regenerates its callable descriptions. | JSON description statistics |
126
- | `delete-files <path...>` | After automatic refresh, remove paths from the index; source files are not deleted. A later refresh can restore eligible files. | JSON update statistics |
127
-
128
- Manual maintenance examples:
116
+ When code is similar but not actually duplicated, then `--cohesion` can help find similar code that exists far apart in the filesystem tree, which could potentially by elminated through the use of an abstraction, by ordering matches from farthest to nearest.
129
117
 
130
118
  ```bash
131
- slopdex update-git
132
- slopdex update-files src/service.ts src/model.ts
133
- slopdex reindex-files
134
- slopdex reindex-files --callables
135
- slopdex delete-files src/removed.ts
136
- slopdex update-git --target HEAD --rebuild-on-divergence
137
- slopdex update-git --force-reindex
119
+ slopdex cross-search --cross-file-only --cohesion --threshold 0.8
138
120
  ```
121
+ ### Use with agents
139
122
 
140
- ### Location, providers, and diagnostics
141
-
142
- | Argument | Meaning / default |
143
- | --- | --- |
144
- | `--root <path>` | Repository root; current directory by default. |
145
- | `--config <path>` | Config file; `<root>/.slopdex/config.json` by default. |
146
- | `--index <path>` | Index file; `<root>/.slopdex/index.sqlite` by default. Overrides `indexPath` in config. |
147
- | `--provider <openai\|jina>` | Embedding provider; `openai` by default. |
148
- | `--model <name>` | Embedding model; `text-embedding-3-large` for OpenAI, `jina-embeddings-v4` for Jina. |
149
- | `--dimensions <number>` | Positive embedding dimension count; OpenAI `3072`, Jina `1024`. Must be supported by the model. |
150
- | `--description-provider <openai\|opencode\|opencode-go>` | Description provider; OpenAI by default. OpenCode values use Zen or Go with `OPENCODE_API_KEY`. |
151
- | `--description-model <name>` | Description model; `gpt-5.6-sol` for OpenAI/Zen and `gpt-5.6-luna` for Go, then the persisted model unless overridden. Published OpenCode models use their documented protocol. |
152
- | `--ignore-errors` | Silence warnings about saved indexing errors; records remain available. |
153
- | `-h`, `--help` | Show CLI usage without refreshing. |
154
- | `--version` | Print the package version and exit. |
155
-
156
- Explicit relative config and index paths resolve from the current directory, not `--root`.
157
-
158
- ### Search and analysis
159
-
160
- | Argument | Applies to | Meaning / default |
161
- | --- | --- | --- |
162
- | `--limit <number>` | Both query searches, cross-search | Positive integer. Query matches: `10`; cross-search neighbors per source: `5`. |
163
- | `--threshold <number\|min-max>` | Both query searches, cross-search | Minimum similarity, or range with inclusive minimum and exclusive maximum. Default `-1`. |
164
- | `--format <json\|summary\|clusters>` | Both query searches, cross-search, index-errors | Output format; see the commands table. `clusters` is only for ordinary cross-search. |
165
- | `-e <regex>`, `--regexp <regex>`, `--regex <regex>` | Both query searches, cross-search | Equivalent case-sensitive JavaScript regex options over qualified names. Query searches filter results before limiting; cross-search filters sources only. |
166
- | `--min-lines <number>` | Cross-search | Minimum source and candidate callable length; positive integer, default `2`. Use `1` to include one-line wrappers. |
167
- | `--source-path <path>` | Cross-search | Select sources in a file or recursive directory, relative to the repository root (or absolute within it). |
168
- | `--changed-since <commit>` | Cross-search | Select added, modified, or moved functions relative to an ancestor of the indexed Git checkpoint, including working-tree changes. Requires Git. |
169
- | `--uncommitted` | Cross-search | Select functions indexed from working-tree files: staged, unstaged, or untracked changes in Git; all working-tree functions without Git. |
170
- | `--cross-file-only` | Cross-search | Exclude matches from the same physical file. |
171
- | `--include-symmetric-duplicates` | Cross-search | Allow both directions of same-index matches; otherwise each unordered pair is emitted once. |
172
- | `--cohesion` | Cross-search | Add `physicalDistance` and re-rank each source's matches by descending distance, with similarity as the tie-breaker. Defaults to summary output; incompatible with clusters. |
173
- | `--target-root <path>` | Cross-search | Second repository root; requires `--target-index`. |
174
- | `--target-index <path>` | Cross-search | Second index file; requires `--target-root`. |
175
- | `--target-config <path>` | Cross-search | Target config; defaults to `<target-root>/.slopdex/config.json`. Requires both target options. |
176
-
177
- Review adjacent similarity bands without repeating boundary matches:
123
+ Just put this in your `AGENTS.md` file, no skill required:
178
124
 
179
- ```bash
180
- slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.9 --limit 5
181
- slopdex cross-search --cross-file-only --min-lines 4 --threshold 0.85-0.9 --limit 5
125
+ ```
126
+ - use semantic code search to find code with: `slopdex search "..." --threshold 0.5`
127
+ - when reviewing uncommitted code avoid introducing duplicates by looking for related matches: `slopdex cross-search --uncommitted --threshold 0.8`
182
128
  ```
183
129
 
184
- ### Refresh and recovery
185
-
186
- | Argument | Meaning |
187
- | --- | --- |
188
- | `--target <ref>` | Git snapshot for `update-git`; default `HEAD`. Non-HEAD targets exclude working-tree changes. Later commands normally refresh back to HEAD. |
189
- | `--rebuild-on-divergence` | Allow reconciliation when the saved checkpoint is not an ancestor of the target, such as after a rebase or branch switch. |
190
- | `--force-reindex` | Recreate an **incompatible** index (repository, provider, model, dimensions, strategy, or schema mismatch). A compatible index still follows normal refresh behavior. |
191
- | `--no-reindex` | With Git, still reconcile the committed snapshot but skip working-tree overlays. Without Git, reuse a non-empty index; missing/empty indexes are still populated. Not a general offline switch. |
192
-
193
- ## Reading results
194
-
195
- ### Similarity and duplicate clusters
130
+ Any other use, like doing a full `cross-search` is probably better done interactively with the agent, in which case you can just ask the agent to run `slopdex --help` to get usage information.
196
131
 
197
- Similarity is a model-dependent score, not a probability of duplication. Higher scores mean greater semantic resemblance. Query summaries show `score path :: qualifiedName`; cross-search summaries group those lines beneath each source. Functions without matches are omitted from cross-search output.
132
+ ### Reranking
198
133
 
199
- With reranking enabled, query summaries show `rerankScore rerank (similarity similarity)`. JSON retains `similarity` and adds `rerankScore`. The similarity threshold first filters embedding candidates. Cohere and Jina receive up to five times the requested limit. The OpenAI LLM receives the configured number of top embedding results, 10 by default, or the requested result limit when it is larger. Candidates include function descriptions when available and function metadata/source code. Cross-search and cohesion analysis are not sent to rerankers.
134
+ Optionally a second-stage reranker can be enabled for `search` and `search-description`:
200
135
 
201
- ```text
202
- Cluster 1 (3 functions, similarity 0.9124-0.9568)
203
- src/auth/session.ts:18:1 :: validateSession
204
- src/http/middleware.ts:42:1 :: authenticate
205
- src/users/user-service.ts:27:3 :: UserService.authenticate
136
+ ```bash
137
+ export COHERE_API_KEY="your-api-key"
138
+ slopdex config reranker cohere
139
+ # Or: export JINA_API_KEY="your-api-key" && slopdex config reranker jina
140
+ # Or use an LLM: export OPENAI_API_KEY="your-api-key" && slopdex config reranker openai
206
141
  ```
207
142
 
208
- - A cluster groups functions connected by matches. Its range covers observed links; not every pair necessarily matches directly.
209
- - Clusters sort by member count, then name. Cluster number is not severity.
210
- - Locations identify where to inspect behavior, callers, and architectural roles. Wrappers, adapters, tests, and separate interface implementations can legitimately resemble one another.
211
-
212
- ### Physical cohesion
143
+ ### Compare repositories
213
144
 
214
- ```text
215
- src/auth/session.ts :: validateSession
216
- 0.9400 packages/http/middleware.ts :: authenticate [distance 4]
217
- 0.9300 src/auth/token.ts :: validateToken [distance 1]
145
+ ```bash
146
+ slopdex cross-search \
147
+ --target-root /path/to/other/repo \
148
+ --target-index /path/to/other/repo/.slopdex/index.sqlite \
149
+ --threshold 0.9
218
150
  ```
219
151
 
220
- Run cross-search with `--cohesion` to put physically distant matches first. Distance is `0` within one file, `1` between files in one folder, and `1` plus directory-tree hops across folders. The option only changes the order of each source's selected semantic matches; it does not change similarity scores or establish that distant code belongs together.
221
-
222
- For automation, pass `--format json`: query searches and diagnostics return JSON arrays; cross-search returns **JSONL**, one row per matched source. With `--cohesion`, each match includes `physicalDistance`. Results go to stdout; notices and warnings go to stderr.
223
-
224
- ## System behavior
225
-
226
- ### Descriptions and scoring
227
-
228
- Descriptions are optional and disabled initially. `descriptions enable` persists the selected provider and model and keeps callable descriptions current on later updates. Use `slopdex descriptions enable --description-provider opencode-go` for OpenCode Go, or combine `--description-provider` and `--description-model` to change both. `slopdex descriptions disable` stops automatic updates and description-based searching/scoring while retaining cached descriptions. `status` exposes callable/file description counts, stale file-description count, enabled state, and profile.
229
-
230
- Descriptions are generated in source order through one conversation per file. Instructions and complete file source form a stable prefix; Slopdex asks for the overall file description first, then each callable request and answer extends that conversation. This allows supported providers to reuse their prompt cache instead of receiving a separate duplicated file context for every callable.
231
-
232
- Ordinary updates preserve an existing file description even when its source changes, while still refreshing callable descriptions. `slopdex reindex-files` explicitly regenerates stale file descriptions and their embeddings; add `--callables` to continue through and replace every callable description in those files.
233
-
234
- Tree-sitter extraction, generated descriptions, and document/query vectors are content-addressed in the same SQLite database. Each validated result is committed immediately, independently of the final logical index update. If indexing is interrupted or a later provider call fails, rerunning reuses every completed result whose profile, operation, input, and source context hash still match.
235
-
236
- With complete descriptions, `search` and cross-search average **one-third code similarity + one-third callable-description similarity + one-third file-description similarity**. `search-description` averages callable and file descriptions without code. Cross-repository analysis needs complete descriptions on both sides; otherwise the entire analysis uses code-only scores. Stale file descriptions remain searchable until explicitly reindexed. Thresholds and limits apply to the selected score.
237
-
238
- Text output labels combined scores. JSON exposes `codeSimilarity`, `descriptionSimilarity`, `fileDescriptionSimilarity`, and cross-search scoring mode/weights. Compare runs only with matching scoring mode, weights, embedding and description-generator profiles, threshold, and source/candidate filters.
239
-
240
- ### Exclusions
241
-
242
- Root and nested `.gitignore` rules apply even to tracked files and without Git. Working-tree refreshes use current rules; committed-only snapshots use the target commit's rules. Refresh removes newly excluded files and discovers newly eligible ones. Explicit `update-files` rejects ignored files.
243
-
244
- Built-in exclusions: `.git`, `.slopdex`, `node_modules`, `dist`, `build`, `coverage`, `vendor`, `generated`, `.venv`, `venv`, `__pycache__`, `.tox`, `.mypy_cache`, `.pytest_cache`, and `target`. Config `include`/`exclude` globs narrow coverage; they cannot override built-in exclusions. Ignore exceptions cannot re-include files beneath an excluded parent directory. Files over 1 MiB are skipped unless `maxFileSize` is raised.
245
-
246
- ### Failures and recovery
247
-
248
- Parse, extraction, read, and file-size failures are saved while healthy callables remain searchable. Inspect them with `slopdex index-errors --format summary`. JSON includes paths, locations, recoverable names, messages, available source, and snapshot provenance. `status` reports `indexingErrorCount` and `failedFileCount`; `functionCount` counts searchable callables.
249
-
250
- Saved failures trigger stderr warnings, including on cached runs, help, and cross-search targets. `--ignore-errors` silences warnings without clearing records. Updates retry failed files; successful indexing, deletion, or exclusion clears their diagnostics. Version output bypasses diagnostics.
251
-
252
- Use the recovery flag named in the error: `--rebuild-on-divergence` for Git history changes, `--force-reindex` for incompatible indexes. Schema versions 6 and 7 migrate in place; earlier schemas require `--force-reindex`, with compatible rebuilds preserving reusable artifact caches. For provider/authentication failures, fix the reported configuration and rerun. For source-change-during-indexing errors, rerun after edits settle. Exit status is `0` on success, `2` for argument/domain errors, and `1` for other failures (or invocation without a command).
253
-
254
- ## Configuration
152
+ ### Inspect index health
255
153
 
256
- Optional file: `<root>/.slopdex/config.json`. Example using Jina embeddings, OpenAI LLM reranking, and OpenCode Go descriptions (requires `JINA_API_KEY`, `OPENAI_API_KEY` for query searches, plus `OPENCODE_API_KEY` when descriptions are enabled):
154
+ If some functions can't be indexed a warning is printed. Index errors can be investigated and fixed with the `index-errors` command to ensure the index is complete.
257
155
 
258
- ```json
259
- {
260
- "provider": "jina",
261
- "model": "jina-embeddings-v4",
262
- "dimensions": 1024,
263
- "rerankingEnabled": true,
264
- "rerankerProvider": "openai",
265
- "rerankerModel": "gpt-5.6-luna",
266
- "rerankerCandidates": 10,
267
- "descriptionProvider": "opencode-go",
268
- "exclude": ["**/fixtures/**"]
269
- }
156
+ ```bash
157
+ slopdex status
158
+ slopdex index-errors --format summary
159
+ slopdex --version
270
160
  ```
271
161
 
272
- | Property | Purpose / default |
273
- | --- | --- |
274
- | `provider`, `model`, `dimensions` | Embedding settings; defaults are listed in the CLI table. |
275
- | `descriptionProvider` | Description provider: `openai`, `opencode` (Zen), or `opencode-go`; defaults to `openai`. |
276
- | `descriptionModel` | Description model; provider default unless explicitly set. |
277
- | `descriptionsEnabled` | When true or false, the next index-using command applies that enabled state during its normal refresh. Unset leaves persisted index state unchanged. |
278
- | `rerankingEnabled` | Enables second-stage ranking for `search` and `search-description`; disabled/unset by default. Prefer changing it through `config reranker`. |
279
- | `rerankerProvider` | Reranker: `cohere`, `jina`, or `openai`. OpenAI uses an LLM rather than a dedicated reranking endpoint. |
280
- | `rerankerModel` | Provider model; defaults to Cohere `rerank-v4.0-pro`, Jina `jina-reranker-v3.5`, or OpenAI `gpt-5.6-luna`. |
281
- | `rerankerCandidates` | Embedding-ranked candidates sent to the OpenAI LLM; integer from `1` to `100`, default `10`. The requested result limit takes precedence when larger, up to 100. |
282
- | `indexPath` | Index location; `<root>/.slopdex/index.sqlite`. |
283
- | `include` | Repository-relative glob array; empty/unset includes all supported eligible files. |
284
- | `exclude` | Additional repository-relative exclusion globs. |
285
- | `maxFileSize` | Maximum source-file size in bytes; positive integer, default `1048576`. |
286
- | `embeddingBatchSize` | Embedding inputs per batch; positive integer, default `32`. |
287
-
288
- Keep keys in the environment (`OPENAI_API_KEY`, `JINA_API_KEY`, `COHERE_API_KEY`, `OPENCODE_API_KEY`). Reranker settings do not change the stored index and do not require a rebuild. Changing the embedding profile requires rebuilding with `--force-reindex`.
289
-
290
- ## Development
291
-
292
- - [Implementation and library API](docs/implementation.md)
162
+ ## Commands
163
+
164
+ See [Command reference](docs/reference.md).