@ninjaxtools/slopdex 0.28.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -52,31 +52,47 @@ Vector search requires an embedding-provider API key from OpenAI or Jina.
52
52
 
53
53
  ```console
54
54
  $ export OPENAI_API_KEY="your-api-key"
55
+ $ slopdex update
55
56
  $ slopdex search "validate an authenticated session"
56
57
  ...
57
58
  ```
58
59
 
59
- The index tracks the current Git commit and is created or updated on every command that uses it. Index data is stored in the current user's cache folder and project settings are stored in `.slopdex/config.json` (add `.slopdex` to `.gitignore`). See also [cache configuration](docs/reference.md#shared-provider-artifacts).
60
+ The index is created with the `update` command and tracks the current Git commit and is refreshed with the latest changes before it is used. Index data is stored in the current user's global cache folder and project settings are stored in `.slopdex/config.json` (add `.slopdex` to `.gitignore`). See also [cache configuration](docs/reference.md#shared-provider-artifacts).
60
61
 
61
62
  ### Code map/skeleton
62
63
 
63
- `slopdex map` doesn't use vector search and works locally without a provider or API key.
64
+ `slopdex map` works locally without a provider or API key.
64
65
 
65
66
  ```console
66
67
  $ slopdex map src docs
67
68
  $ slopdex map src -g '*.rs' -k fns -e 'refresh|search'
68
69
  $ slopdex map src --private
69
70
  $ slopdex map -g '*.md' -e '^Guide\.Setup' -i --format json
71
+ $ slopdex map docs --detail expanded
70
72
  $ slopdex map --no-reindex
73
+ $ slopdex map src -q 'validate session' -q 'authenticate user' -k fns
74
+ $ slopdex map docs -q 'installation' --symbol-threshold 0.6 --detail expanded
71
75
  ```
72
76
 
73
77
  The `map` command can be used to generate a source code skeleton that strips most of the code implementation but retains structurally useful information that can act as an index into the source code, which improves context usage.
74
78
 
79
+ Symbols can be filtered by using `-e <regex>` or `-q <symbol>` (OR). The `-q` filter uses vector search
80
+ and will be ignored if an index doesn't exist.
81
+
82
+ Use `--detail expanded` to to show full code or markdown of matched symbols.
83
+
75
84
  See the [selector reference](docs/reference.md#shared-selectors).
76
85
 
86
+ > [!NOTE]
87
+ > Add this to your `AGENTS.md` to let the agent use the map command to explore the codebase:
88
+ >
89
+ > ```text
90
+ > - Start discovery with one scoped `slopdex map -g "<glob>" -i -e "<term|term>" -q "<short symbol concept>" --private --callers 2 --callees 2 <paths...>`. Use known paths or `.`. Immediately read plausible implementation ranges and follow calls in source; grep for usages or missing links. Map again only for unknown declaration locations. Batch reads; skip repeated inventories and setup/help.
91
+ > ```
92
+
77
93
  ### Search
78
94
 
79
- By default all available indexes are searched and ranked together.
95
+ By default code/docs and generated descriptions, are searched and ranked together.
80
96
 
81
97
  ```console
82
98
  $ slopdex search "keep the repository index synchronized"
@@ -97,9 +113,20 @@ To search code/docs individually:
97
113
  ```console
98
114
  $ slopdex search-code "configure the embedding provider"
99
115
  $ slopdex search-md "configure the embedding provider"
116
+ $ slopdex search-code 'reject expired credentials' -q 'validate session' --symbol-threshold 0.6
117
+ ```
118
+
119
+ Symbol index is searched with either `search-symbols` or `--symbols`:
120
+
121
+ ```console
122
+ $ slopdex search-symbols 'validate session' --threshold 0.6 --limit 20
123
+ $ slopdex search 'installation' --symbols -g '*.md' --detail expanded
124
+ $ slopdex search 'validate session' --code --symbols
125
+ $ slopdex search-symbols 'read settings' -q 'configuration' --symbol-threshold 0.7
100
126
  ```
101
127
 
102
- 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.
128
+ You can also enable optional description generation which will automatically generate file and
129
+ function descriptions with a configured LLM provider and include them in the search.
103
130
 
104
131
  I use OpenCode Go usually with DeepSeek or Muse Spark, which are fairly good low-cost models. If you
105
132
  sign up for OpenCode Go through [this link](https://opencode.ai/go?ref=RAR3Z744DZ), we both receive
@@ -129,6 +156,13 @@ The fallback-model is used if the main model reports an error, and if the fallba
129
156
 
130
157
  File and function descriptions are cached by source and description context, so renaming a file can reuse its descriptions. Function changes or a changed file-description context can require new callable descriptions. File descriptions after edits can be refreshed explicitly with `index reindex-files`.
131
158
 
159
+ > [!NOTE]
160
+ > Add this to your `AGENTS.md` to use semantic code search with your agent:
161
+ >
162
+ > ```text
163
+ > - use semantic code search to find code with: `slopdex search "<query>" --threshold 0.3 --limit 20`; vary the search query if you get no results
164
+ > ```
165
+
132
166
  ### Interactive Config
133
167
 
134
168
  To configure all configurable settings interactively run:
@@ -145,7 +179,7 @@ The intention of the `describe` command is to use a low-cost model to summarise
145
179
  $ slopdex describe "I want to implement a new rpc endpoint"
146
180
  ```
147
181
 
148
- The LLM receives expanded text search results with indexed code from callers and callees up to two edges away by default; it does not receive whole-file source.
182
+ First a `search` is performed with `--detail expanded` and `--expanded-callers 2` and `--expanded-callees 2` which expands generated descriptions and function implementations in the result, which is then given to an LLM which is asked to interpret the result, and the final output will be the result of the LLM interpretation as well as the `compact` results from the earlier search. This provides a tailored description for the specific query based on the `expanded` search results as well as the `compact` version of those results.
149
183
 
150
184
  ### Find duplicate code
151
185
 
@@ -153,29 +187,15 @@ Compare functions across files, exclude short wrappers, and group matches into c
153
187
 
154
188
  ```console
155
189
  $ slopdex cross-search --cross-file-only --lines 4 --threshold 0.9
156
- Cluster 1 · 3 functions · similarity 0.9124-0.9568
157
-
158
- *** src/auth/session.ts
159
- @@ 18-29 @@
160
- export function validateSession(token: string): Session
161
-
162
- *** src/http/middleware.ts
163
- @@ 42-57 @@
164
- export function authenticate(req: Request): Session
165
-
166
- *** src/users/user-service.ts
167
- @@ 27-48 @@ UserService.authenticate
168
- authenticate(token: string): Session
190
+ *** Cluster 1 · 3 symbols · similarity 0.91-0.96
191
+ src/auth/session.ts:18-29:validateSession
192
+ src/http/middleware.ts:42-57:authenticate
193
+ src/users/user-service.ts:27-48:UserService.authenticate
169
194
  ...
170
195
  ```
171
196
 
172
197
  Using `--cross-file-only` is useful to exclude similar code in the same file.
173
198
 
174
- Cross-search defaults to `--threshold 0.8` (query search defaults to `0.3`).
175
- Clusters join matches transitively, so a low threshold can connect many groups
176
- into one large cluster. Use `0.9` for stricter duplicate detection, or explicitly
177
- pass `--threshold 0.3` for the pre-rewrite default.
178
-
179
199
  You can use threshold and line-count ranges as well. Range starts are inclusive
180
200
  and ends are exclusive, so `--lines 4-20` selects functions with 4 through 19
181
201
  lines:
@@ -184,6 +204,12 @@ lines:
184
204
  $ slopdex cross-search --cross-file-only --lines 4 --threshold 0.9
185
205
  $ slopdex cross-search --cross-file-only --lines 4-20 --threshold 0.85-0.9
186
206
  ```
207
+ > [!NOTE]
208
+ > Add this to your `AGENTS.md` to detect and refactor duplicate code before it is committed:
209
+ >
210
+ > ```text
211
+ > - when reviewing uncommitted determine if similar code elsewhere warrants a refactor: `slopdex cross-search --uncommitted --cross-file-only --threshold 0.8`
212
+ > ```
187
213
 
188
214
  ### Restrict functions used in the cross-search
189
215
 
@@ -212,16 +238,6 @@ When code is similar but not actually duplicated, then `--cohesion` can help fin
212
238
  ```console
213
239
  $ slopdex cross-search --cross-file-only --cohesion --threshold 0.8
214
240
  ```
215
- ### Use with agents
216
-
217
- Just put this in your `AGENTS.md` file and adjust as desired, no skill necessary:
218
-
219
- ```
220
- - use `slopdex map -g "<glob>" -i -e "<regex>" <files or directories...>` to obtain a compact structural code skeleton, and then perform targeted reads using the line numbers for implementation details. To filter for specific symbols, use `-e`. To only include specific kinds of symbols use `-k` with `imports`, `fns`, `consts`, `types`, or `classes`.
221
- - use semantic code search to find code with: `slopdex search "<query>" --threshold 0.5`; vary the search query if you get no results
222
- - when reviewing uncommitted code avoid introducing duplicates by looking for related matches: `slopdex cross-search --uncommitted --cross-file-only --threshold 0.8`
223
- - when tasked to do advanced codebase analysis, use `slopdex --help` first to see all options
224
- ```
225
241
 
226
242
  ### Reranking
227
243
 
@@ -19,7 +19,7 @@
19
19
  "hasInstallScript": true,
20
20
  "license": "MIT",
21
21
  "name": "@ninjaxtools/slopdex",
22
- "version": "0.28.0"
22
+ "version": "0.30.0"
23
23
  },
24
24
  "node_modules/detect-libc": {
25
25
  "engines": {
@@ -48,5 +48,5 @@
48
48
  }
49
49
  },
50
50
  "requires": true,
51
- "version": "0.28.0"
51
+ "version": "0.30.0"
52
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "artifactDownloadUrls": [
3
- "https://github.com/ninjaxtools/slopdex/releases/download/v0.28.0"
3
+ "https://github.com/ninjaxtools/slopdex/releases/download/v0.30.0"
4
4
  ],
5
5
  "bin": {
6
6
  "slopdex": "run-slopdex.js"
@@ -80,7 +80,7 @@
80
80
  "zipExt": ".tar.xz"
81
81
  }
82
82
  },
83
- "version": "0.28.0",
83
+ "version": "0.30.0",
84
84
  "volta": {
85
85
  "node": "18.14.1",
86
86
  "npm": "9.5.0"