@ninjaxtools/slopdex 0.3.0 → 0.6.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/dist/index.d.ts CHANGED
@@ -8,18 +8,25 @@ declare class CodeIndex {
8
8
  status(): IndexStatus;
9
9
  allFunctions(): IndexedFunction[];
10
10
  updateFiles(options: UpdateFilesOptions): Promise<UpdateStats>;
11
+ updateFromWorkingTree(options?: UpdateFromWorkingTreeOptions): Promise<UpdateStats>;
11
12
  updateFromGit(options?: UpdateFromGitOptions): Promise<UpdateStats>;
12
13
  similaritySearch(options: SimilaritySearchOptions): Promise<SimilarityResult[]>;
13
14
  similarToFunction(functionId: number, options: {
14
15
  limit: number;
15
16
  minSimilarity: number;
16
17
  maxSimilarity?: number;
18
+ excludePaths?: readonly string[];
19
+ minLines?: number;
20
+ nameRegex?: string;
17
21
  }): SimilarityResult[];
18
22
  vectorForFunction(functionId: number): number[];
19
23
  searchByVector(vector: readonly number[], options: {
20
24
  limit: number;
21
25
  minSimilarity: number;
22
26
  maxSimilarity?: number;
27
+ excludePaths?: readonly string[];
28
+ minLines?: number;
29
+ nameRegex?: string;
23
30
  }): SimilarityResult[];
24
31
  sourceFunctions(filter: CrossSearchSourceFilter): Promise<IndexedFunction[]>;
25
32
  }
@@ -39,6 +46,7 @@ interface ParsedCallable {
39
46
  startColumn: number;
40
47
  endLine: number;
41
48
  endColumn: number;
49
+ lineCount: number;
42
50
  source: string;
43
51
  sourceHash: string;
44
52
  embeddingInput: string;
@@ -88,6 +96,10 @@ interface UpdateFilesOptions {
88
96
  interface UpdateFromGitOptions {
89
97
  target?: string;
90
98
  rebuildOnDivergence?: boolean;
99
+ includeWorkingTree?: boolean;
100
+ signal?: AbortSignal;
101
+ }
102
+ interface UpdateFromWorkingTreeOptions {
91
103
  signal?: AbortSignal;
92
104
  }
93
105
  interface UpdateStats {
@@ -114,9 +126,12 @@ type CrossSearchSourceFilter = {
114
126
  type: "all";
115
127
  path?: string;
116
128
  } | {
117
- type: "added-since";
129
+ type: "changed-since";
118
130
  commit: string;
119
131
  path?: string;
132
+ } | {
133
+ type: "uncommitted";
134
+ path?: string;
120
135
  };
121
136
  interface CrossSearchOptions {
122
137
  source: CodeIndex;
@@ -126,6 +141,9 @@ interface CrossSearchOptions {
126
141
  minSimilarity?: number;
127
142
  maxSimilarity?: number;
128
143
  includeSymmetricDuplicates?: boolean;
144
+ crossFileOnly?: boolean;
145
+ minLines?: number;
146
+ nameRegex?: string;
129
147
  signal?: AbortSignal;
130
148
  onProgress?: (progress: {
131
149
  completed: number;
@@ -136,6 +154,107 @@ interface CrossSearchResult {
136
154
  source: IndexedFunction;
137
155
  matches: SimilarityResult[];
138
156
  }
157
+ type CohesionLocationCategory = "same-file" | "same-folder" | "different-folder";
158
+ interface CohesionLocation {
159
+ category: CohesionLocationCategory;
160
+ physicalDistance: number;
161
+ folderHops: number;
162
+ commonAncestor: string | null;
163
+ sourceTestPair: boolean;
164
+ }
165
+ interface CohesionFunctionReference {
166
+ path: string;
167
+ qualifiedName: string;
168
+ kind: CallableKind;
169
+ signature: string | null;
170
+ startLine: number;
171
+ startColumn: number;
172
+ endLine: number;
173
+ endColumn: number;
174
+ lineCount: number;
175
+ source?: string;
176
+ }
177
+ interface CohesionPair<FunctionValue = IndexedFunction> {
178
+ rank: number;
179
+ left: FunctionValue;
180
+ right: FunctionValue;
181
+ similarity: number;
182
+ reciprocal: boolean | null;
183
+ semanticWeight: number;
184
+ separationWeight: number;
185
+ cohesionGap: number;
186
+ location: CohesionLocation;
187
+ }
188
+ interface CohesionFileReport<FunctionValue = IndexedFunction> {
189
+ path: string;
190
+ functionCount: number;
191
+ internalAffinity: number;
192
+ sameFolderAffinity: number;
193
+ externalAffinity: number;
194
+ externalAffinityRatio: number;
195
+ strongestExternalMatch?: {
196
+ function: FunctionValue;
197
+ similarity: number;
198
+ cohesionGap: number;
199
+ };
200
+ }
201
+ interface CohesionGroup<FunctionValue = IndexedFunction> {
202
+ rank: number;
203
+ memberCount: number;
204
+ fileCount: number;
205
+ minimumEdgeSimilarity: number;
206
+ maximumEdgeSimilarity: number;
207
+ maximumPhysicalDistance: number;
208
+ maximumCohesionGap: number;
209
+ members: FunctionValue[];
210
+ }
211
+ interface CohesionSummary {
212
+ scope: "repository" | "selected-sources";
213
+ functionsAnalyzed: number;
214
+ candidateFunctions: number;
215
+ semanticEdges: number;
216
+ sameFileRatio: number;
217
+ sameFolderRatio: number;
218
+ remoteRatio: number;
219
+ weightedMeanDistance: number;
220
+ }
221
+ interface CohesionAnalysisOptions {
222
+ source: CodeIndex;
223
+ sourceFilter?: CrossSearchSourceFilter;
224
+ neighbors?: number;
225
+ limit?: number;
226
+ minSimilarity?: number;
227
+ maxSimilarity?: number;
228
+ minLines?: number;
229
+ nameRegex?: string;
230
+ signal?: AbortSignal;
231
+ onProgress?: (progress: {
232
+ completed: number;
233
+ total: number;
234
+ }) => void;
235
+ }
236
+ interface CohesionReport<FunctionValue = IndexedFunction> {
237
+ schemaVersion: 1;
238
+ repository: {
239
+ generation: number;
240
+ gitCheckpoint: string | null;
241
+ embeddingProfile: Required<EmbeddingProfile>;
242
+ };
243
+ parameters: {
244
+ neighbors: number;
245
+ limit: number;
246
+ minSimilarity: number;
247
+ maxSimilarity?: number;
248
+ minLines: number;
249
+ nameRegex?: string;
250
+ sourceFilter: CrossSearchSourceFilter;
251
+ };
252
+ summary: CohesionSummary;
253
+ pairs: CohesionPair<FunctionValue>[];
254
+ files: CohesionFileReport<FunctionValue>[];
255
+ groups: CohesionGroup<FunctionValue>[];
256
+ }
257
+ type CohesionJsonReport = CohesionReport<CohesionFunctionReference>;
139
258
  interface IndexStatus {
140
259
  rootDir: string;
141
260
  indexPath: string;
@@ -146,6 +265,9 @@ interface IndexStatus {
146
265
  embeddingProfile: Required<EmbeddingProfile>;
147
266
  }
148
267
 
268
+ declare function analyzeCohesion(options: CohesionAnalysisOptions): Promise<CohesionReport>;
269
+ declare function cohesionLocation(leftPath: string, rightPath: string): CohesionLocation;
270
+
149
271
  declare function crossSearch(options: CrossSearchOptions): AsyncGenerator<CrossSearchResult>;
150
272
 
151
273
  interface OpenAIEmbeddingProviderOptions {
@@ -200,6 +322,9 @@ declare class CodeIndexError extends Error {
200
322
  declare class GitDivergenceError extends CodeIndexError {
201
323
  constructor(checkpoint: string, target: string);
202
324
  }
325
+ declare class GitUnavailableError extends CodeIndexError {
326
+ constructor(message: string, options?: ErrorOptions);
327
+ }
203
328
  declare class IncompatibleIndexError extends CodeIndexError {
204
329
  constructor(message: string);
205
330
  }
@@ -207,7 +332,9 @@ declare class IncompatibleIndexError extends CodeIndexError {
207
332
  declare function openCodeIndex(options: CodeIndexOptions): CodeIndex;
208
333
  declare function updateFiles(index: CodeIndex, options: UpdateFilesOptions): Promise<UpdateStats>;
209
334
  declare function updateFromGit(index: CodeIndex, options?: UpdateFromGitOptions): Promise<UpdateStats>;
335
+ declare function updateFromWorkingTree(index: CodeIndex, options?: UpdateFromWorkingTreeOptions): Promise<UpdateStats>;
210
336
  declare function similaritySearch(index: CodeIndex, options: SimilaritySearchOptions): Promise<SimilarityResult[]>;
211
337
  declare function crossSearchFunctions(options: CrossSearchOptions): AsyncGenerator<CrossSearchResult, any, any>;
338
+ declare function analyzeCodeCohesion(options: CohesionAnalysisOptions): Promise<CohesionReport<IndexedFunction>>;
212
339
 
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 };
340
+ export { 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, JinaEmbeddingProvider, type JinaEmbeddingProviderOptions, OpenAIEmbeddingProvider, type OpenAIEmbeddingProviderOptions, type ParsedCallable, type SimilarityResult, type SimilaritySearchOptions, type SourceMode, type SupportedLanguage, type UpdateFilesOptions, type UpdateFromGitOptions, type UpdateFromWorkingTreeOptions, type UpdateStats, analyzeCodeCohesion, analyzeCohesion, cohesionLocation, crossSearch, crossSearchFunctions, openCodeIndex, similaritySearch, updateFiles, updateFromGit, updateFromWorkingTree };