@ninjaxtools/slopdex 0.10.0 → 0.13.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.
@@ -18,26 +18,38 @@ Describe behavior rather than guessing a symbol name. `-e` is a regex that restr
18
18
 
19
19
  ### Search function purpose
20
20
 
21
- Code purpose-summary generation needs to be enabled once:
21
+ Code purpose-description generation needs to be enabled once:
22
22
 
23
23
  ```bash
24
- slopdex summaries enable # only needed once
24
+ slopdex descriptions enable # only needed once
25
25
  ```
26
26
 
27
- Then purpose-summaries can be searched:
27
+ Then purpose descriptions can be searched:
28
28
 
29
29
  ```bash
30
- slopdex search-summary "keep the repository index synchronized" --format summary --limit 10
30
+ slopdex search-description "keep the repository index synchronized" --format summary --limit 10
31
31
  ```
32
32
 
33
- Enabling needs `OPENAI_API_KEY` in the environment.
33
+ Enabling needs `OPENAI_API_KEY` by default. Select OpenCode Zen or Go with
34
+ `--description-provider opencode` or `--description-provider opencode-go` and set `OPENCODE_API_KEY`.
34
35
 
35
36
  To select another model:
36
37
 
37
38
  ```bash
38
- slopdex summaries enable --summary-model <model-id>
39
+ slopdex descriptions enable --description-model <model-id>
39
40
  ```
40
41
 
42
+ List and persist a published OpenCode model without creating an index:
43
+
44
+ ```bash
45
+ slopdex models opencode-go
46
+ slopdex config model opencode-go/gpt-5.6-luna
47
+ slopdex config descriptions enable
48
+ ```
49
+
50
+ The next index-using command applies the configured description state. A bare model ID passed to
51
+ `config model` resolves automatically only when it belongs to one of Zen or Go; qualify shared IDs.
52
+
41
53
  ### Find duplicate candidates
42
54
 
43
55
  ```bash
@@ -91,7 +103,7 @@ slopdex cross-search \
91
103
  --threshold 0.9 --format summary
92
104
  ```
93
105
 
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.
106
+ 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/description configuration. Use `--target-config <path>` for a custom target config.
95
107
 
96
108
  ### Inspect or maintain the index
97
109
 
@@ -100,6 +112,8 @@ slopdex status
100
112
  slopdex index-errors --format summary
101
113
  slopdex update-git
102
114
  slopdex update-files src/service.ts src/model.ts
115
+ slopdex reindex-files
116
+ slopdex reindex-files --callables
103
117
  slopdex delete-files src/removed.ts
104
118
  slopdex --version
105
119
  ```
@@ -108,6 +122,7 @@ slopdex --version
108
122
  - `index-errors` reads saved failures without refreshing or needing API credentials.
109
123
  - `update-git` explicitly refreshes HEAD and working-tree changes.
110
124
  - `update-files` reparses specified working-tree files after automatic refresh, even when their contents are unchanged.
125
+ - `reindex-files` regenerates stale file descriptions and embeddings. Add `--callables` to also replace callable descriptions in those files.
111
126
  - `delete-files` removes index entries after automatic refresh, not source files. Eligible files can return on later refresh.
112
127
  - `--version` prints the built package version. `--help` describes available commands/options.
113
128
 
@@ -125,7 +140,8 @@ Usage: `slopdex <command> [arguments] [options]`. Quote queries and regexes. Boo
125
140
  | `--provider <openai\|jina>` | Embedding provider; `openai`. |
126
141
  | `--model <name>` | Embedding model; OpenAI `text-embedding-3-large`, Jina `jina-embeddings-v4`. |
127
142
  | `--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. |
143
+ | `--description-provider <openai\|opencode\|opencode-go>` | Description provider; OpenAI by default. OpenCode values require `OPENCODE_API_KEY`. |
144
+ | `--description-model <name>` | Description model; `gpt-5.6-sol` for OpenAI/Zen and `gpt-5.6-luna` for Go. |
129
145
  | `--ignore-errors` | Silence saved-diagnostic warnings without deleting records. |
130
146
  | `-h`, `--help` | Usage; no refresh. |
131
147
  | `--version` | Package version; exits without refresh or saved-diagnostic warnings. |
@@ -136,7 +152,7 @@ Explicit relative config/index paths resolve from the current directory. Source
136
152
 
137
153
  | Argument | Applies to / behavior |
138
154
  | --- | --- |
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`. |
155
+ | `--limit <number>` | Positive integer. `search`/`search-description`: matches, default `10`. Cross-search: neighbors per source, default `5`. Cohesion: reported pairs and file rows, default `50`. |
140
156
  | `--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
157
  | `--format <json\|summary\|clusters>` | Both query searches, cross-search, cohesion, index-errors. `clusters` only supports cross-search; output defaults below. |
142
158
  | `-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. |
@@ -160,6 +176,7 @@ Explicit relative config/index paths resolve from the current directory. Source
160
176
  | `--rebuild-on-divergence` | Permit reconciliation after non-descendant history changes, such as a rebase/branch switch. |
161
177
  | `--force-reindex` | Recreate an incompatible index. Compatible indexes still use normal refresh; this is not an unconditional reparse flag. |
162
178
  | `--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. |
179
+ | `--callables` | With `reindex-files`, continue after the file description and regenerate every callable description in each stale file. |
163
180
 
164
181
  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
182
 
@@ -169,11 +186,11 @@ Use `--no-reindex` when the task calls for committed-only results or reuse of an
169
186
 
170
187
  | Command | Default | Alternatives |
171
188
  | --- | --- | --- |
172
- | `search`, `search-summary` | `summary` | JSON array; purpose search includes generated summary text |
189
+ | `search`, `search-description` | `summary` | JSON array; purpose search includes generated description text |
173
190
  | `cross-search` | `clusters` | `summary`, or `json` for JSONL with one row per matched source |
174
191
  | `cohesion` | `summary` | One JSON report |
175
192
  | `index-errors` | `summary` | JSON array |
176
- | `status`, update commands, `summaries` | JSON object | — |
193
+ | `status`, update commands, `descriptions` | JSON object | — |
177
194
 
178
195
  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
196
 
@@ -195,9 +212,9 @@ When reporting candidates, identify paths/symbols, summarize the shared behavior
195
212
 
196
213
  ### Purpose-aware scoring
197
214
 
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.
215
+ When descriptions are complete, `search`, cross-search, and cohesion average code, callable-description, and file-description similarity with equal one-third weights. `search-description` averages callable and file descriptions. Cross-repository analysis needs completeness on both sides; otherwise all scores are code-only. Stale file descriptions remain in scoring until `reindex-files` refreshes them. Description-generator models may differ even though embedding profiles must match.
199
216
 
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.
217
+ 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 description-generator profiles, threshold, neighbor count, and source/candidate filters.
201
218
 
202
219
  ### Cohesion
203
220
 
@@ -217,4 +234,4 @@ Cohesion: 184 functions analyzed, 37 semantic edges
217
234
  - **Reciprocal:** both functions selected each other as neighbors. JSON `null` means an endpoint was not evaluated because of source filtering.
218
235
  - **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
236
 
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.
237
+ 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. Cohesion metrics use all qualifying edges; pairs/files are limited, and groups use reported pairs.
package/README.md CHANGED
@@ -27,13 +27,24 @@ slopdex search "keep the repository index synchronized" --format summary --limit
27
27
  To search generated descriptions of each function's role instead:
28
28
 
29
29
  ```bash
30
- slopdex summaries enable
31
- slopdex search-summary "keep the repository index synchronized" --format summary --limit 10
30
+ slopdex descriptions enable
31
+ slopdex search-description "keep the repository index synchronized" --format summary --limit 10
32
32
  ```
33
33
 
34
- This requires `OPENAI_API_KEY` even when Jina supplies embeddings, and adds generation costs. See [summaries and scoring](#summaries-and-scoring).
34
+ 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).
35
35
 
36
- `summaries disable` turns off summary generation while retaining cached data.
36
+ `descriptions disable` turns off description generation while retaining cached data.
37
+
38
+ To choose from OpenCode's current published models and persist description settings without creating an index:
39
+
40
+ ```bash
41
+ slopdex models opencode-go
42
+ slopdex config model opencode-go/gpt-5.6-luna
43
+ slopdex config descriptions enable
44
+ ```
45
+
46
+ The next index-using command creates or refreshes the index and applies the configured description state.
47
+ You can also pass the selection separately as `slopdex config model --description-provider opencode-go --description-model gpt-5.6-luna`.
37
48
 
38
49
  ### Find duplicate-code candidates
39
50
 
@@ -70,7 +81,7 @@ slopdex cross-search \
70
81
  --threshold 0.9 --format summary
71
82
  ```
72
83
 
73
- 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 summary settings. Use `--target-config` for a non-default target config.
84
+ 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.
74
85
 
75
86
  ### Inspect index health
76
87
 
@@ -88,15 +99,19 @@ Usage: `slopdex <command> [arguments] [options]`.
88
99
 
89
100
  | Command | Purpose | Output |
90
101
  | --- | --- | --- |
102
+ | `models [opencode\|opencode-go]` | Fetch valid models from the current published Zen and/or Go catalogs. | Qualified `provider/model` lines; optional JSON array |
103
+ | `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 |
104
+ | `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 |
91
105
  | `search <query>` | Search function code by meaning. Quote multiword queries. | Summary; optional JSON array |
92
- | `summaries <enable\|disable>` | Enable or disable automatic purpose summaries. Re-enabling with unchanged inputs reuses cached summaries. | JSON statistics |
93
- | `search-summary <query>` | Search purpose summaries after enabling them. | Summary including summary text; optional JSON array |
106
+ | `descriptions <enable\|disable>` | Enable or disable automatic purpose descriptions. Re-enabling with unchanged inputs reuses cached descriptions. | JSON statistics |
107
+ | `search-description <query>` | Search purpose descriptions after enabling them. | Summary including description text; optional JSON array |
94
108
  | `cross-search` | Find neighbors for each selected function in this or another index. | `clusters` by default; optional `summary` or JSONL |
95
109
  | `cohesion` | Analyze semantic relationships versus file/folder separation. | Summary; optional JSON report |
96
110
  | `status` | Refresh and show index metadata, counts, and profiles. | JSON object |
97
111
  | `index-errors` | Read saved file/function indexing failures. | Summary; optional JSON array |
98
112
  | `update-git` | Explicitly refresh a Git snapshot, with current working-tree changes when targeting HEAD. | JSON update statistics |
99
113
  | `update-files <path...>` | After automatic refresh, explicitly reparse selected working-tree files. Paths are repository-relative or absolute within the root. | JSON update statistics |
114
+ | `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 |
100
115
  | `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 |
101
116
 
102
117
  Manual maintenance examples:
@@ -104,6 +119,8 @@ Manual maintenance examples:
104
119
  ```bash
105
120
  slopdex update-git
106
121
  slopdex update-files src/service.ts src/model.ts
122
+ slopdex reindex-files
123
+ slopdex reindex-files --callables
107
124
  slopdex delete-files src/removed.ts
108
125
  slopdex update-git --target HEAD --rebuild-on-divergence
109
126
  slopdex update-git --force-reindex
@@ -119,7 +136,8 @@ slopdex update-git --force-reindex
119
136
  | `--provider <openai\|jina>` | Embedding provider; `openai` by default. |
120
137
  | `--model <name>` | Embedding model; `text-embedding-3-large` for OpenAI, `jina-embeddings-v4` for Jina. |
121
138
  | `--dimensions <number>` | Positive embedding dimension count; OpenAI `3072`, Jina `1024`. Must be supported by the model. |
122
- | `--summary-model <name>` | OpenAI summary model; `gpt-5.6-sol` initially, then the persisted model unless overridden. |
139
+ | `--description-provider <openai\|opencode\|opencode-go>` | Description provider; OpenAI by default. OpenCode values use Zen or Go with `OPENCODE_API_KEY`. |
140
+ | `--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. |
123
141
  | `--ignore-errors` | Silence warnings about saved indexing errors; records remain available. |
124
142
  | `-h`, `--help` | Show CLI usage without refreshing. |
125
143
  | `--version` | Print the package version and exit. |
@@ -200,19 +218,25 @@ Cohesion: 184 functions analyzed, 37 semantic edges
200
218
  | `sourceTestPair` | A source/test relationship inferred from paths; separation may be intentional. |
201
219
  | `externalAffinityRatio` | In JSON file reports, the share of observed affinity outside that file's folder. |
202
220
 
203
- The example suggests reviewing separated authentication responsibilities. It does not establish that they belong in one module. There is no universal cohesion pass threshold. Filtered reports describe selected sources, not the entire repository. Summary metrics cover all qualifying edges; reported pairs/files are limited, and groups are built from reported pairs.
221
+ The example suggests reviewing separated authentication responsibilities. It does not establish that they belong in one module. There is no universal cohesion pass threshold. Filtered reports describe selected sources, not the entire repository. Cohesion metrics cover all qualifying edges; reported pairs/files are limited, and groups are built from reported pairs.
204
222
 
205
- For automation, pass `--format json`: query searches and diagnostics return JSON arrays; cross-search returns **JSONL**, one row per matched source; cohesion returns one JSON object containing `repository`, `parameters`, `summary`, `pairs`, `files`, and `groups`. Results go to stdout; notices and warnings go to stderr.
223
+ For automation, pass `--format json`: query searches and diagnostics return JSON arrays; cross-search returns **JSONL**, one row per matched source; cohesion returns one JSON object containing `repository`, `parameters`, `metrics`, `pairs`, `files`, and `groups`. Results go to stdout; notices and warnings go to stderr.
206
224
 
207
225
  ## System behavior
208
226
 
209
- ### Summaries and scoring
227
+ ### Descriptions and scoring
228
+
229
+ 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.
230
+
231
+ 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.
232
+
233
+ 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.
210
234
 
211
- Summaries are optional and disabled initially. `summaries enable` persists the selected summary model and keeps summaries current on later updates, including file-context and path changes. Use `slopdex summaries enable --summary-model <model-id>` to change it, or `slopdex summaries disable` to stop automatic updates and summary-based searching/scoring while retaining cached summaries. `status` exposes `summariesEnabled`, `summaryCount`, and `summaryProfile`.
235
+ 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.
212
236
 
213
- `search` always searches code; `search-summary` always searches purpose summaries. When all callables have enabled summaries, cross-search and cohesion automatically use **50% code similarity + 50% summary similarity**. Cross-repository analysis needs complete summaries on both sides; otherwise the entire analysis uses code-only scores. Thresholds and neighbor limits apply to the selected score.
237
+ With complete descriptions, `search`, cross-search, and cohesion 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 neighbor limits apply to the selected score.
214
238
 
215
- Text output labels combined scores. JSON exposes `codeSimilarity`, `summarySimilarity`, and scoring mode/weights (`scoring` for cross-search, `parameters` for cohesion). Compare runs only with matching scoring mode, weights, embedding and summary-generator profiles, threshold, neighbor count, and source/candidate filters.
239
+ Text output labels combined scores. JSON exposes `codeSimilarity`, `descriptionSimilarity`, `fileDescriptionSimilarity`, and scoring mode/weights (`scoring` for cross-search, `parameters` for cohesion). Compare runs only with matching scoring mode, weights, embedding and description-generator profiles, threshold, neighbor count, and source/candidate filters.
216
240
 
217
241
  ### Exclusions
218
242
 
@@ -226,17 +250,18 @@ Parse, extraction, read, and file-size failures are saved while healthy callable
226
250
 
227
251
  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.
228
252
 
229
- Use the recovery flag named in the error: `--rebuild-on-divergence` for Git history changes, `--force-reindex` for incompatible indexes. For provider/authentication failures, fix the reported configuration. 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
+ Use the recovery flag named in the error: `--rebuild-on-divergence` for Git history changes, `--force-reindex` for incompatible indexes. Schema versions before 5 require `--force-reindex`; schema-5 rebuilds preserve 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).
230
254
 
231
255
  ## Configuration
232
256
 
233
- Optional file: `<root>/.slopdex/config.json`. Example using Jina (requires `JINA_API_KEY`):
257
+ Optional file: `<root>/.slopdex/config.json`. Example using Jina embeddings and OpenCode Go descriptions (requires `JINA_API_KEY`, plus `OPENCODE_API_KEY` when descriptions are enabled):
234
258
 
235
259
  ```json
236
260
  {
237
261
  "provider": "jina",
238
262
  "model": "jina-embeddings-v4",
239
263
  "dimensions": 1024,
264
+ "descriptionProvider": "opencode-go",
240
265
  "exclude": ["**/fixtures/**"]
241
266
  }
242
267
  ```
@@ -244,14 +269,16 @@ Optional file: `<root>/.slopdex/config.json`. Example using Jina (requires `JINA
244
269
  | Property | Purpose / default |
245
270
  | --- | --- |
246
271
  | `provider`, `model`, `dimensions` | Embedding settings; defaults are listed in the CLI table. |
247
- | `summaryModel` | Summary model; initially `gpt-5.6-sol`. |
272
+ | `descriptionProvider` | Description provider: `openai`, `opencode` (Zen), or `opencode-go`; defaults to `openai`. |
273
+ | `descriptionModel` | Description model; provider default unless explicitly set. |
274
+ | `descriptionsEnabled` | When true or false, the next index-using command applies that enabled state during its normal refresh. Unset leaves persisted index state unchanged. |
248
275
  | `indexPath` | Index location; `<root>/.slopdex/index.sqlite`. |
249
276
  | `include` | Repository-relative glob array; empty/unset includes all supported eligible files. |
250
277
  | `exclude` | Additional repository-relative exclusion globs. |
251
278
  | `maxFileSize` | Maximum source-file size in bytes; positive integer, default `1048576`. |
252
279
  | `embeddingBatchSize` | Embedding inputs per batch; positive integer, default `32`. |
253
280
 
254
- Keep keys in the environment (`OPENAI_API_KEY`, `JINA_API_KEY`). Changing the embedding profile requires rebuilding with `--force-reindex`.
281
+ Keep keys in the environment (`OPENAI_API_KEY`, `JINA_API_KEY`, `OPENCODE_API_KEY`). Changing the embedding profile requires rebuilding with `--force-reindex`.
255
282
 
256
283
  ## Development
257
284