@ninjaxtools/slopdex 0.3.0 → 0.8.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 +186 -24
- package/README.md +212 -83
- package/dist/cli.js +2228 -326
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +232 -7
- package/dist/index.js +1624 -224
- package/dist/index.js.map +1 -1
- package/package.json +14 -3
package/dist/index.d.ts
CHANGED
|
@@ -3,30 +3,63 @@ declare class CodeIndex {
|
|
|
3
3
|
readonly rootDir: string;
|
|
4
4
|
readonly indexPath: string;
|
|
5
5
|
readonly provider: EmbeddingProvider;
|
|
6
|
+
readonly summaryProvider: SummaryProvider;
|
|
6
7
|
constructor(options: CodeIndexOptions);
|
|
7
8
|
close(): void;
|
|
8
9
|
status(): IndexStatus;
|
|
9
10
|
allFunctions(): IndexedFunction[];
|
|
11
|
+
indexErrors(): IndexingError[];
|
|
10
12
|
updateFiles(options: UpdateFilesOptions): Promise<UpdateStats>;
|
|
13
|
+
updateFromWorkingTree(options?: UpdateFromWorkingTreeOptions): Promise<UpdateStats>;
|
|
11
14
|
updateFromGit(options?: UpdateFromGitOptions): Promise<UpdateStats>;
|
|
15
|
+
useSummaries(options?: {
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}): Promise<SummaryStats>;
|
|
18
|
+
searchSummary(options: SimilaritySearchOptions): Promise<SimilarityResult[]>;
|
|
12
19
|
similaritySearch(options: SimilaritySearchOptions): Promise<SimilarityResult[]>;
|
|
13
20
|
similarToFunction(functionId: number, options: {
|
|
21
|
+
includeSummaries?: boolean;
|
|
14
22
|
limit: number;
|
|
15
23
|
minSimilarity: number;
|
|
16
24
|
maxSimilarity?: number;
|
|
25
|
+
excludePaths?: readonly string[];
|
|
26
|
+
minLines?: number;
|
|
27
|
+
nameRegex?: string;
|
|
17
28
|
}): SimilarityResult[];
|
|
18
|
-
vectorForFunction(functionId: number): number[];
|
|
29
|
+
vectorForFunction(functionId: number, kind?: "code" | "summary"): number[];
|
|
19
30
|
searchByVector(vector: readonly number[], options: {
|
|
31
|
+
summaryVector?: readonly number[];
|
|
20
32
|
limit: number;
|
|
21
33
|
minSimilarity: number;
|
|
22
34
|
maxSimilarity?: number;
|
|
35
|
+
excludePaths?: readonly string[];
|
|
36
|
+
minLines?: number;
|
|
37
|
+
nameRegex?: string;
|
|
23
38
|
}): SimilarityResult[];
|
|
24
39
|
sourceFunctions(filter: CrossSearchSourceFilter): Promise<IndexedFunction[]>;
|
|
25
40
|
}
|
|
26
41
|
|
|
27
|
-
type SupportedLanguage = "typescript" | "tsx" | "
|
|
42
|
+
type SupportedLanguage = "python" | "javascript" | "jsx" | "typescript" | "tsx" | "rust" | "go" | "java" | "c";
|
|
28
43
|
type CallableKind = "function" | "method" | "constructor" | "generator";
|
|
29
44
|
type SourceMode = "git" | "working-tree";
|
|
45
|
+
interface IndexingIssue {
|
|
46
|
+
path: string;
|
|
47
|
+
language: SupportedLanguage | null;
|
|
48
|
+
scope: "file" | "function";
|
|
49
|
+
code: "parse-error" | "parse-failed" | "extraction-error" | "read-error" | "file-too-large";
|
|
50
|
+
message: string;
|
|
51
|
+
qualifiedName: string | null;
|
|
52
|
+
startLine: number | null;
|
|
53
|
+
startColumn: number | null;
|
|
54
|
+
endLine: number | null;
|
|
55
|
+
endColumn: number | null;
|
|
56
|
+
source: string | null;
|
|
57
|
+
}
|
|
58
|
+
interface IndexingError extends IndexingIssue {
|
|
59
|
+
id: number;
|
|
60
|
+
sourceMode: SourceMode;
|
|
61
|
+
indexedCommit: string | null;
|
|
62
|
+
}
|
|
30
63
|
interface ParsedCallable {
|
|
31
64
|
path: string;
|
|
32
65
|
language: SupportedLanguage;
|
|
@@ -39,6 +72,7 @@ interface ParsedCallable {
|
|
|
39
72
|
startColumn: number;
|
|
40
73
|
endLine: number;
|
|
41
74
|
endColumn: number;
|
|
75
|
+
lineCount: number;
|
|
42
76
|
source: string;
|
|
43
77
|
sourceHash: string;
|
|
44
78
|
embeddingInput: string;
|
|
@@ -49,6 +83,8 @@ interface IndexedFunction extends ParsedCallable {
|
|
|
49
83
|
lastSeenCommit: string | null;
|
|
50
84
|
sourceMode: SourceMode;
|
|
51
85
|
embeddingId: number;
|
|
86
|
+
summary: string | null;
|
|
87
|
+
summaryEmbeddingId: number | null;
|
|
52
88
|
}
|
|
53
89
|
interface EmbeddingProfile {
|
|
54
90
|
provider: "openai" | "jina" | string;
|
|
@@ -65,10 +101,31 @@ interface EmbeddingProvider {
|
|
|
65
101
|
signal?: AbortSignal;
|
|
66
102
|
}): Promise<number[]>;
|
|
67
103
|
}
|
|
104
|
+
interface SummaryProfile {
|
|
105
|
+
provider: string;
|
|
106
|
+
model: string;
|
|
107
|
+
strategyVersion: string;
|
|
108
|
+
}
|
|
109
|
+
interface SummaryInput {
|
|
110
|
+
repository: string;
|
|
111
|
+
callable: ParsedCallable;
|
|
112
|
+
fileSource: string;
|
|
113
|
+
}
|
|
114
|
+
interface SummaryProvider {
|
|
115
|
+
readonly profile: SummaryProfile;
|
|
116
|
+
summarize(input: SummaryInput, options?: {
|
|
117
|
+
signal?: AbortSignal;
|
|
118
|
+
}): Promise<string>;
|
|
119
|
+
}
|
|
120
|
+
interface SummaryStats {
|
|
121
|
+
summariesCreated: number;
|
|
122
|
+
summariesEnabled: boolean;
|
|
123
|
+
}
|
|
68
124
|
interface CodeIndexOptions {
|
|
69
125
|
rootDir: string;
|
|
70
126
|
indexPath?: string;
|
|
71
127
|
provider: EmbeddingProvider;
|
|
128
|
+
summaryProvider?: SummaryProvider;
|
|
72
129
|
onWarning?: (message: string) => void;
|
|
73
130
|
include?: readonly string[];
|
|
74
131
|
exclude?: readonly string[];
|
|
@@ -88,6 +145,10 @@ interface UpdateFilesOptions {
|
|
|
88
145
|
interface UpdateFromGitOptions {
|
|
89
146
|
target?: string;
|
|
90
147
|
rebuildOnDivergence?: boolean;
|
|
148
|
+
includeWorkingTree?: boolean;
|
|
149
|
+
signal?: AbortSignal;
|
|
150
|
+
}
|
|
151
|
+
interface UpdateFromWorkingTreeOptions {
|
|
91
152
|
signal?: AbortSignal;
|
|
92
153
|
}
|
|
93
154
|
interface UpdateStats {
|
|
@@ -101,22 +162,42 @@ interface UpdateStats {
|
|
|
101
162
|
}
|
|
102
163
|
interface SimilaritySearchOptions {
|
|
103
164
|
query: string;
|
|
165
|
+
/** Restrict result qualified names before ranking and limiting. */
|
|
166
|
+
nameRegex?: string;
|
|
104
167
|
limit?: number;
|
|
105
168
|
minSimilarity?: number;
|
|
106
169
|
maxSimilarity?: number;
|
|
107
170
|
signal?: AbortSignal;
|
|
108
171
|
}
|
|
109
|
-
interface
|
|
110
|
-
function: IndexedFunction;
|
|
172
|
+
interface SimilarityScores {
|
|
111
173
|
similarity: number;
|
|
174
|
+
codeSimilarity?: number;
|
|
175
|
+
summarySimilarity?: number;
|
|
176
|
+
}
|
|
177
|
+
interface AnalysisSimilarity {
|
|
178
|
+
similarityMode: "code" | "code-summary-average";
|
|
179
|
+
similarityWeights: {
|
|
180
|
+
code: number;
|
|
181
|
+
summary: number;
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
interface SimilarityResult extends SimilarityScores {
|
|
185
|
+
function: IndexedFunction;
|
|
112
186
|
}
|
|
113
|
-
type CrossSearchSourceFilter = {
|
|
187
|
+
type CrossSearchSourceFilter = ({
|
|
114
188
|
type: "all";
|
|
115
189
|
path?: string;
|
|
116
190
|
} | {
|
|
117
|
-
type: "
|
|
191
|
+
type: "changed-since";
|
|
118
192
|
commit: string;
|
|
119
193
|
path?: string;
|
|
194
|
+
uncommitted?: boolean;
|
|
195
|
+
} | {
|
|
196
|
+
type: "uncommitted";
|
|
197
|
+
path?: string;
|
|
198
|
+
}) & {
|
|
199
|
+
/** Restrict source qualified names; does not restrict target candidates. */
|
|
200
|
+
nameRegex?: string;
|
|
120
201
|
};
|
|
121
202
|
interface CrossSearchOptions {
|
|
122
203
|
source: CodeIndex;
|
|
@@ -126,6 +207,9 @@ interface CrossSearchOptions {
|
|
|
126
207
|
minSimilarity?: number;
|
|
127
208
|
maxSimilarity?: number;
|
|
128
209
|
includeSymmetricDuplicates?: boolean;
|
|
210
|
+
crossFileOnly?: boolean;
|
|
211
|
+
minLines?: number;
|
|
212
|
+
nameRegex?: string;
|
|
129
213
|
signal?: AbortSignal;
|
|
130
214
|
onProgress?: (progress: {
|
|
131
215
|
completed: number;
|
|
@@ -135,7 +219,111 @@ interface CrossSearchOptions {
|
|
|
135
219
|
interface CrossSearchResult {
|
|
136
220
|
source: IndexedFunction;
|
|
137
221
|
matches: SimilarityResult[];
|
|
222
|
+
scoring?: AnalysisSimilarity & {
|
|
223
|
+
sourceSummaryProfile: SummaryProfile | null;
|
|
224
|
+
targetSummaryProfile: SummaryProfile | null;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
type CohesionLocationCategory = "same-file" | "same-folder" | "different-folder";
|
|
228
|
+
interface CohesionLocation {
|
|
229
|
+
category: CohesionLocationCategory;
|
|
230
|
+
physicalDistance: number;
|
|
231
|
+
folderHops: number;
|
|
232
|
+
commonAncestor: string | null;
|
|
233
|
+
sourceTestPair: boolean;
|
|
234
|
+
}
|
|
235
|
+
interface CohesionFunctionReference {
|
|
236
|
+
path: string;
|
|
237
|
+
qualifiedName: string;
|
|
238
|
+
kind: CallableKind;
|
|
239
|
+
signature: string | null;
|
|
240
|
+
startLine: number;
|
|
241
|
+
startColumn: number;
|
|
242
|
+
endLine: number;
|
|
243
|
+
endColumn: number;
|
|
244
|
+
lineCount: number;
|
|
245
|
+
source?: string;
|
|
246
|
+
}
|
|
247
|
+
interface CohesionPair<FunctionValue = IndexedFunction> extends SimilarityScores {
|
|
248
|
+
rank: number;
|
|
249
|
+
left: FunctionValue;
|
|
250
|
+
right: FunctionValue;
|
|
251
|
+
reciprocal: boolean | null;
|
|
252
|
+
semanticWeight: number;
|
|
253
|
+
separationWeight: number;
|
|
254
|
+
cohesionGap: number;
|
|
255
|
+
location: CohesionLocation;
|
|
256
|
+
}
|
|
257
|
+
interface CohesionFileReport<FunctionValue = IndexedFunction> {
|
|
258
|
+
path: string;
|
|
259
|
+
functionCount: number;
|
|
260
|
+
internalAffinity: number;
|
|
261
|
+
sameFolderAffinity: number;
|
|
262
|
+
externalAffinity: number;
|
|
263
|
+
externalAffinityRatio: number;
|
|
264
|
+
strongestExternalMatch?: SimilarityScores & {
|
|
265
|
+
function: FunctionValue;
|
|
266
|
+
cohesionGap: number;
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
interface CohesionGroup<FunctionValue = IndexedFunction> {
|
|
270
|
+
rank: number;
|
|
271
|
+
memberCount: number;
|
|
272
|
+
fileCount: number;
|
|
273
|
+
minimumEdgeSimilarity: number;
|
|
274
|
+
maximumEdgeSimilarity: number;
|
|
275
|
+
maximumPhysicalDistance: number;
|
|
276
|
+
maximumCohesionGap: number;
|
|
277
|
+
members: FunctionValue[];
|
|
278
|
+
}
|
|
279
|
+
interface CohesionSummary {
|
|
280
|
+
scope: "repository" | "selected-sources";
|
|
281
|
+
functionsAnalyzed: number;
|
|
282
|
+
candidateFunctions: number;
|
|
283
|
+
semanticEdges: number;
|
|
284
|
+
sameFileRatio: number;
|
|
285
|
+
sameFolderRatio: number;
|
|
286
|
+
remoteRatio: number;
|
|
287
|
+
weightedMeanDistance: number;
|
|
288
|
+
}
|
|
289
|
+
interface CohesionAnalysisOptions {
|
|
290
|
+
source: CodeIndex;
|
|
291
|
+
sourceFilter?: CrossSearchSourceFilter;
|
|
292
|
+
neighbors?: number;
|
|
293
|
+
limit?: number;
|
|
294
|
+
minSimilarity?: number;
|
|
295
|
+
maxSimilarity?: number;
|
|
296
|
+
minLines?: number;
|
|
297
|
+
nameRegex?: string;
|
|
298
|
+
signal?: AbortSignal;
|
|
299
|
+
onProgress?: (progress: {
|
|
300
|
+
completed: number;
|
|
301
|
+
total: number;
|
|
302
|
+
}) => void;
|
|
303
|
+
}
|
|
304
|
+
interface CohesionReport<FunctionValue = IndexedFunction> {
|
|
305
|
+
schemaVersion: 1;
|
|
306
|
+
repository: {
|
|
307
|
+
generation: number;
|
|
308
|
+
gitCheckpoint: string | null;
|
|
309
|
+
embeddingProfile: Required<EmbeddingProfile>;
|
|
310
|
+
summaryProfile: SummaryProfile | null;
|
|
311
|
+
};
|
|
312
|
+
parameters: AnalysisSimilarity & {
|
|
313
|
+
neighbors: number;
|
|
314
|
+
limit: number;
|
|
315
|
+
minSimilarity: number;
|
|
316
|
+
maxSimilarity?: number;
|
|
317
|
+
minLines: number;
|
|
318
|
+
nameRegex?: string;
|
|
319
|
+
sourceFilter: CrossSearchSourceFilter;
|
|
320
|
+
};
|
|
321
|
+
summary: CohesionSummary;
|
|
322
|
+
pairs: CohesionPair<FunctionValue>[];
|
|
323
|
+
files: CohesionFileReport<FunctionValue>[];
|
|
324
|
+
groups: CohesionGroup<FunctionValue>[];
|
|
138
325
|
}
|
|
326
|
+
type CohesionJsonReport = CohesionReport<CohesionFunctionReference>;
|
|
139
327
|
interface IndexStatus {
|
|
140
328
|
rootDir: string;
|
|
141
329
|
indexPath: string;
|
|
@@ -144,8 +332,18 @@ interface IndexStatus {
|
|
|
144
332
|
generation: number;
|
|
145
333
|
gitCheckpoint: string | null;
|
|
146
334
|
embeddingProfile: Required<EmbeddingProfile>;
|
|
335
|
+
summariesEnabled: boolean;
|
|
336
|
+
summaryCount: number;
|
|
337
|
+
summaryProfile: SummaryProfile | null;
|
|
338
|
+
indexingErrorCount: number;
|
|
339
|
+
failedFileCount: number;
|
|
147
340
|
}
|
|
148
341
|
|
|
342
|
+
declare function readIndexErrors(indexPath: string): IndexingError[];
|
|
343
|
+
|
|
344
|
+
declare function analyzeCohesion(options: CohesionAnalysisOptions): Promise<CohesionReport>;
|
|
345
|
+
declare function cohesionLocation(leftPath: string, rightPath: string): CohesionLocation;
|
|
346
|
+
|
|
149
347
|
declare function crossSearch(options: CrossSearchOptions): AsyncGenerator<CrossSearchResult>;
|
|
150
348
|
|
|
151
349
|
interface OpenAIEmbeddingProviderOptions {
|
|
@@ -171,6 +369,24 @@ declare class OpenAIEmbeddingProvider implements EmbeddingProvider {
|
|
|
171
369
|
}): Promise<number[]>;
|
|
172
370
|
}
|
|
173
371
|
|
|
372
|
+
interface OpenAISummaryProviderOptions {
|
|
373
|
+
apiKey?: string;
|
|
374
|
+
model?: string;
|
|
375
|
+
baseUrl?: string;
|
|
376
|
+
}
|
|
377
|
+
declare class OpenAISummaryProvider implements SummaryProvider {
|
|
378
|
+
#private;
|
|
379
|
+
readonly profile: {
|
|
380
|
+
provider: string;
|
|
381
|
+
model: string;
|
|
382
|
+
strategyVersion: string;
|
|
383
|
+
};
|
|
384
|
+
constructor(options?: OpenAISummaryProviderOptions);
|
|
385
|
+
summarize(input: SummaryInput, options?: {
|
|
386
|
+
signal?: AbortSignal;
|
|
387
|
+
}): Promise<string>;
|
|
388
|
+
}
|
|
389
|
+
|
|
174
390
|
interface JinaEmbeddingProviderOptions {
|
|
175
391
|
apiKey?: string;
|
|
176
392
|
model?: string;
|
|
@@ -200,6 +416,9 @@ declare class CodeIndexError extends Error {
|
|
|
200
416
|
declare class GitDivergenceError extends CodeIndexError {
|
|
201
417
|
constructor(checkpoint: string, target: string);
|
|
202
418
|
}
|
|
419
|
+
declare class GitUnavailableError extends CodeIndexError {
|
|
420
|
+
constructor(message: string, options?: ErrorOptions);
|
|
421
|
+
}
|
|
203
422
|
declare class IncompatibleIndexError extends CodeIndexError {
|
|
204
423
|
constructor(message: string);
|
|
205
424
|
}
|
|
@@ -207,7 +426,13 @@ declare class IncompatibleIndexError extends CodeIndexError {
|
|
|
207
426
|
declare function openCodeIndex(options: CodeIndexOptions): CodeIndex;
|
|
208
427
|
declare function updateFiles(index: CodeIndex, options: UpdateFilesOptions): Promise<UpdateStats>;
|
|
209
428
|
declare function updateFromGit(index: CodeIndex, options?: UpdateFromGitOptions): Promise<UpdateStats>;
|
|
429
|
+
declare function updateFromWorkingTree(index: CodeIndex, options?: UpdateFromWorkingTreeOptions): Promise<UpdateStats>;
|
|
210
430
|
declare function similaritySearch(index: CodeIndex, options: SimilaritySearchOptions): Promise<SimilarityResult[]>;
|
|
431
|
+
declare function useSummaries(index: CodeIndex, options?: {
|
|
432
|
+
signal?: AbortSignal;
|
|
433
|
+
}): Promise<SummaryStats>;
|
|
434
|
+
declare function searchSummary(index: CodeIndex, options: SimilaritySearchOptions): Promise<SimilarityResult[]>;
|
|
211
435
|
declare function crossSearchFunctions(options: CrossSearchOptions): AsyncGenerator<CrossSearchResult, any, any>;
|
|
436
|
+
declare function analyzeCodeCohesion(options: CohesionAnalysisOptions): Promise<CohesionReport<IndexedFunction>>;
|
|
212
437
|
|
|
213
|
-
export { type CallableKind, CodeIndex, CodeIndexError, type CodeIndexOptions, type CrossSearchOptions, type CrossSearchResult, type CrossSearchSourceFilter, type EmbeddingProfile, type EmbeddingProvider, GitDivergenceError, IncompatibleIndexError, type IndexStatus, type IndexedFunction, JinaEmbeddingProvider, type JinaEmbeddingProviderOptions, OpenAIEmbeddingProvider, type OpenAIEmbeddingProviderOptions, type ParsedCallable, type SimilarityResult, type SimilaritySearchOptions, type SourceMode, type SupportedLanguage, type UpdateFilesOptions, type UpdateFromGitOptions, type UpdateStats, crossSearch, crossSearchFunctions, openCodeIndex, similaritySearch, updateFiles, updateFromGit };
|
|
438
|
+
export { type AnalysisSimilarity, type CallableKind, CodeIndex, CodeIndexError, type CodeIndexOptions, type CohesionAnalysisOptions, type CohesionFileReport, type CohesionFunctionReference, type CohesionGroup, type CohesionJsonReport, type CohesionLocation, type CohesionLocationCategory, type CohesionPair, type CohesionReport, type CohesionSummary, type CrossSearchOptions, type CrossSearchResult, type CrossSearchSourceFilter, type EmbeddingProfile, type EmbeddingProvider, GitDivergenceError, GitUnavailableError, IncompatibleIndexError, type IndexStatus, type IndexedFunction, type IndexingError, type IndexingIssue, JinaEmbeddingProvider, type JinaEmbeddingProviderOptions, OpenAIEmbeddingProvider, type OpenAIEmbeddingProviderOptions, OpenAISummaryProvider, type OpenAISummaryProviderOptions, type ParsedCallable, type SimilarityResult, type SimilarityScores, type SimilaritySearchOptions, type SourceMode, type SummaryInput, type SummaryProfile, type SummaryProvider, type SummaryStats, type SupportedLanguage, type UpdateFilesOptions, type UpdateFromGitOptions, type UpdateFromWorkingTreeOptions, type UpdateStats, analyzeCodeCohesion, analyzeCohesion, cohesionLocation, crossSearch, crossSearchFunctions, openCodeIndex, readIndexErrors, searchSummary, similaritySearch, updateFiles, updateFromGit, updateFromWorkingTree, useSummaries };
|