@anysphere/file-service 0.0.0-d5257282 → 0.0.0-d52aaecd

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 (3) hide show
  1. package/index.d.ts +110 -26
  2. package/index.js +5 -4
  3. package/package.json +16 -10
package/index.d.ts CHANGED
@@ -12,11 +12,6 @@ export interface DiffChunk {
12
12
  diffType: DiffType
13
13
  text: string
14
14
  }
15
- export interface WalkDirConfig {
16
- maxNumFiles: number
17
- logFilePath?: string
18
- blocklistPath?: string
19
- }
20
15
  export interface CommitData {
21
16
  sha: string
22
17
  date: number
@@ -47,10 +42,70 @@ export interface VerifyData {
47
42
  fileContent: string
48
43
  filePath: string
49
44
  }
50
- export interface Candidate {
45
+ export interface IndexedFile {
51
46
  path: string
52
- locations: Array<number>
53
- weight: number
47
+ diff: Array<string>
48
+ }
49
+ export interface IndexedPullRequest {
50
+ prNumber: number
51
+ generation: number
52
+ sha: string
53
+ commitSecret: string
54
+ body: string
55
+ changedFiles: Array<IndexedFile>
56
+ trimmedTooLarge: boolean
57
+ title?: string
58
+ author?: string
59
+ date?: Date
60
+ }
61
+ export interface JsPullRequestExtractionOptions {
62
+ lastIndexedCommit?: string
63
+ lastIndexedCommitGeneration?: number
64
+ syncBitmap?: Buffer
65
+ limitCommits?: number
66
+ limitPerPr?: number
67
+ context?: number
68
+ workerThreads?: number
69
+ jsConcurrency?: number
70
+ jsChunkSize?: number
71
+ }
72
+ export interface JsPullRequestHydrationOptions {
73
+ limitPerPr?: number
74
+ context?: number
75
+ workerThreads?: number
76
+ interestingPaths?: Array<string>
77
+ }
78
+ export interface JsHandshakeData {
79
+ lastSeenCommit: string
80
+ lastSeenCommitSecret: string
81
+ origin: string
82
+ }
83
+ export interface JsRepositoryTip {
84
+ commitSha: string
85
+ commitShaSecret: string
86
+ generation: number
87
+ }
88
+ export interface ExtractResults {
89
+ repositoryTip?: JsRepositoryTip
90
+ progress: IndexedPullRequestProgress
91
+ }
92
+ export interface IndexedPullRequestProgress {
93
+ processed: number
94
+ ignored: number
95
+ failed: number
96
+ elapsed: number
97
+ }
98
+ export const MULTI_ROOT_ABSOLUTE_PATH: string
99
+ export interface WalkDirConfig {
100
+ maxNumFiles: number
101
+ logFilePath?: string
102
+ blocklistPath?: string
103
+ unifiedJsonBlocklistPath?: string
104
+ }
105
+ export interface LocalCodebaseFileInfo {
106
+ unencryptedRelativePath: string
107
+ hash: string
108
+ children?: Array<LocalCodebaseFileInfo>
54
109
  }
55
110
  export declare class DiffClient {
56
111
  constructor()
@@ -65,19 +120,6 @@ export declare class DiffClient {
65
120
  */
66
121
  diffLines(text1: string, text2: string): Array<DiffChunk>
67
122
  }
68
- export declare class MerkleClient {
69
- constructor(absoluteRootDirectory: string)
70
- build(allowIncremental: boolean, config: WalkDirConfig): Promise<void>
71
- getSubtreeHash(relativePath: string): Promise<string>
72
- getNumEmbeddableFiles(): Promise<number>
73
- getImportantPaths(k: number): Promise<Array<string>>
74
- getAllFiles(): Promise<Array<string>>
75
- getAllDirFilesToEmbed(absoluteFilePath: string): Promise<Array<string>>
76
- onDidCreate(absoluteFilePath: string): void
77
- onDidChange(absoluteFilePath: string): void
78
- onDidDelete(absoluteFilePath: string): void
79
- static enableTracing(): void
80
- }
81
123
  export declare class GitClient {
82
124
  constructor(absoluteRootDirectory: string)
83
125
  getTotalCommitCount(): Promise<number>
@@ -87,10 +129,52 @@ export declare class GitClient {
87
129
  getRepoHeadSha(): Promise<string | null>
88
130
  getCommitChain(hash: string, depth: number, getFiles: CommitChainGetFiles): Promise<Array<CommitData>>
89
131
  }
90
- export declare class GitFile {
91
- findSimilarFiles(lineno: number): Promise<Array<Candidate>>
132
+ export declare class GitGraph {
133
+ constructor(repo: string, globalCursorIgnoreLegacy?: string | undefined | null, globalCursorJsonUnifiedBlocklist?: string | undefined | null)
134
+ /**
135
+ * Get a list of all paths in this repository, up to a maximum depth of `max_depth`. The
136
+ * paths are returned breadth-first, meaning that all paths at depth 0 are returned before any
137
+ * paths at depth 1, and so on.
138
+ * The iteration takes into account `gitignore` and `cursorignore` rules.
139
+ *
140
+ * @param maxDepth - maximum depth to search for paths. A depth of 0 means only the root path
141
+ * is returned.
142
+ * @param limit - maximum number of paths to return. If `None`, all paths are returned.
143
+ */
144
+ getBfsPaths(maxDepth: number, limit?: number | undefined | null): Promise<Array<string>>
145
+ /**
146
+ * Get a sorted list of relevant paths in this repository, from most relevant to least
147
+ * relevant. The list is biased towards the current user, using a heuristic that takes into account
148
+ * the most recently opened/edited files in the editor, which must be passed in as
149
+ * `lastEditedFiles`. If no recent files are provided, the returned paths will be sorted
150
+ * based on the global popularity of the files in the repository (i.e. the number of times each
151
+ * file has been modified throughout the Git history).
152
+ *
153
+ * @param lastEditedFiles - list of files that were recently opened/edited in the editor.
154
+ * @param maxCommits - maximum number of commits to consider when calculating the relevant paths.
155
+ * @param maxPaths - number of relevant paths to return
156
+ */
157
+ getRelevantPaths(lastEditedFiles: Array<string>, maxCommits: number, maxPaths: number): Promise<Array<string>>
158
+ }
159
+ export declare class RepositoryIndexer {
160
+ constructor(repo: string, blockListLegacy?: string | undefined | null, blockListJson?: string | undefined | null)
161
+ extractPullRequests(options: JsPullRequestExtractionOptions, callback: (err: Error | null, indexed: IndexedPullRequest[], ignored: number[], progress: IndexedPullRequestProgress) => Promise<void>): Promise<ExtractResults>
162
+ hydratePullRequests(pullRequests: Array<string>, options: JsPullRequestHydrationOptions, callback: (err: Error | null, arg: IndexedPullRequest) => any): Promise<void>
163
+ getHandshakeData(): Promise<JsHandshakeData | null>
164
+ verifyCommitOwnership(secret: string, candidates: Array<string>): Promise<JsHandshakeData | null>
92
165
  }
93
- export declare class LocalGitGraph {
94
- constructor(repo: string)
95
- openFile(path: string): Promise<GitFile>
166
+ export declare class MerkleClient {
167
+ constructor(rootPathsMap: Record<string, string>)
168
+ build(allowIncremental: boolean, config: WalkDirConfig): Promise<void>
169
+ getSubtreeHash(relativePath: string): Promise<string>
170
+ getNumEmbeddableFiles(): Promise<number>
171
+ getSimhash(): Promise<Float32Array>
172
+ getImportantPaths(k: number): Promise<Array<string>>
173
+ getAllFiles(): Promise<Array<string>>
174
+ getAllDirFilesToEmbed(absoluteFilePath: string): Promise<Array<string>>
175
+ onDidCreate(absoluteFilePath: string): void
176
+ onDidChange(absoluteFilePath: string): void
177
+ onDidDelete(absoluteFilePath: string): void
178
+ getTreeStructure(): Promise<LocalCodebaseFileInfo | null>
179
+ dispose(): void
96
180
  }
package/index.js CHANGED
@@ -310,13 +310,14 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { DiffType, DiffClient, MerkleClient, GitClient, CommitFileStatus, CommitChainGetFiles, GitFile, LocalGitGraph } = nativeBinding
313
+ const { DiffType, DiffClient, GitClient, CommitFileStatus, CommitChainGetFiles, GitGraph, RepositoryIndexer, MULTI_ROOT_ABSOLUTE_PATH, MerkleClient } = nativeBinding
314
314
 
315
315
  module.exports.DiffType = DiffType
316
316
  module.exports.DiffClient = DiffClient
317
- module.exports.MerkleClient = MerkleClient
318
317
  module.exports.GitClient = GitClient
319
318
  module.exports.CommitFileStatus = CommitFileStatus
320
319
  module.exports.CommitChainGetFiles = CommitChainGetFiles
321
- module.exports.GitFile = GitFile
322
- module.exports.LocalGitGraph = LocalGitGraph
320
+ module.exports.GitGraph = GitGraph
321
+ module.exports.RepositoryIndexer = RepositoryIndexer
322
+ module.exports.MULTI_ROOT_ABSOLUTE_PATH = MULTI_ROOT_ABSOLUTE_PATH
323
+ module.exports.MerkleClient = MerkleClient
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anysphere/file-service",
3
- "version": "0.0.0-d5257282",
3
+ "version": "0.0.0-d52aaecd",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "napi": {
@@ -9,6 +9,8 @@
9
9
  "additional": [
10
10
  "aarch64-apple-darwin",
11
11
  "aarch64-pc-windows-msvc",
12
+ "aarch64-unknown-linux-musl",
13
+ "x86_64-unknown-linux-musl",
12
14
  "universal-apple-darwin",
13
15
  "aarch64-unknown-linux-gnu"
14
16
  ]
@@ -18,10 +20,12 @@
18
20
  "index.js",
19
21
  "index.d.ts"
20
22
  ],
21
- "license": "MIT",
23
+ "license": "UNLICENSED",
22
24
  "devDependencies": {
23
25
  "@napi-rs/cli": "^2.18.4",
24
- "ava": "^5.1.1"
26
+ "ava": "^6.3.0",
27
+ "sqlite": "^5.1.1",
28
+ "sqlite3": "^5.1.7"
25
29
  },
26
30
  "ava": {
27
31
  "timeout": "3m"
@@ -40,12 +44,14 @@
40
44
  "version": "napi version"
41
45
  },
42
46
  "optionalDependencies": {
43
- "@anysphere/file-service-win32-x64-msvc": "0.0.0-d5257282",
44
- "@anysphere/file-service-darwin-x64": "0.0.0-d5257282",
45
- "@anysphere/file-service-linux-x64-gnu": "0.0.0-d5257282",
46
- "@anysphere/file-service-darwin-arm64": "0.0.0-d5257282",
47
- "@anysphere/file-service-win32-arm64-msvc": "0.0.0-d5257282",
48
- "@anysphere/file-service-darwin-universal": "0.0.0-d5257282",
49
- "@anysphere/file-service-linux-arm64-gnu": "0.0.0-d5257282"
47
+ "@anysphere/file-service-win32-x64-msvc": "0.0.0-d52aaecd",
48
+ "@anysphere/file-service-darwin-x64": "0.0.0-d52aaecd",
49
+ "@anysphere/file-service-linux-x64-gnu": "0.0.0-d52aaecd",
50
+ "@anysphere/file-service-darwin-arm64": "0.0.0-d52aaecd",
51
+ "@anysphere/file-service-win32-arm64-msvc": "0.0.0-d52aaecd",
52
+ "@anysphere/file-service-linux-arm64-musl": "0.0.0-d52aaecd",
53
+ "@anysphere/file-service-linux-x64-musl": "0.0.0-d52aaecd",
54
+ "@anysphere/file-service-darwin-universal": "0.0.0-d52aaecd",
55
+ "@anysphere/file-service-linux-arm64-gnu": "0.0.0-d52aaecd"
50
56
  }
51
57
  }