@pratik7368patil/anchor-core 0.1.26 → 0.1.28
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 +3 -0
- package/dist/index.js +23 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -716,6 +716,8 @@ type IndexPullRequestsProgress = {
|
|
|
716
716
|
type CodeIndexProgress = {
|
|
717
717
|
stage: "discovering_code_files";
|
|
718
718
|
repo: string;
|
|
719
|
+
scanned?: number;
|
|
720
|
+
total?: number;
|
|
719
721
|
} | {
|
|
720
722
|
stage: "discovered_code_files";
|
|
721
723
|
repo: string;
|
|
@@ -1133,6 +1135,7 @@ type CodeFileDiscoveryResult = {
|
|
|
1133
1135
|
declare function isHardExcludedCodePath(filePath: string): boolean;
|
|
1134
1136
|
declare function discoverCodeFiles(cwd: string, repo: string, options?: {
|
|
1135
1137
|
maxFileBytes?: number;
|
|
1138
|
+
onScan?: (scanned: number, total: number) => void;
|
|
1136
1139
|
}): CodeFileDiscoveryResult;
|
|
1137
1140
|
|
|
1138
1141
|
declare function indexCodebase(db: AnchorDatabase, options: {
|
package/dist/index.js
CHANGED
|
@@ -1694,7 +1694,7 @@ function calculateCoverage(input) {
|
|
|
1694
1694
|
}
|
|
1695
1695
|
|
|
1696
1696
|
// src/db/database.ts
|
|
1697
|
-
var CODE_WRITE_PROGRESS_INTERVAL =
|
|
1697
|
+
var CODE_WRITE_PROGRESS_INTERVAL = 150;
|
|
1698
1698
|
function shouldEmitCodeWriteProgress(current, total) {
|
|
1699
1699
|
return current === 0 || current === 1 || current === total || current % CODE_WRITE_PROGRESS_INTERVAL === 0;
|
|
1700
1700
|
}
|
|
@@ -1882,9 +1882,9 @@ function clearGraphQLFetchCheckpoint(db, repo, scope) {
|
|
|
1882
1882
|
).run((/* @__PURE__ */ new Date()).toISOString(), repo);
|
|
1883
1883
|
}
|
|
1884
1884
|
function deleteExistingPrData(db, prId) {
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1885
|
+
db.prepare(
|
|
1886
|
+
"DELETE FROM wisdom_units_fts WHERE unitId IN (SELECT id FROM wisdom_units WHERE pr_id = ?)"
|
|
1887
|
+
).run(prId);
|
|
1888
1888
|
db.prepare("DELETE FROM regression_events WHERE pr_id = ?").run(prId);
|
|
1889
1889
|
db.prepare("DELETE FROM wisdom_units WHERE pr_id = ?").run(prId);
|
|
1890
1890
|
db.prepare("DELETE FROM pr_comments WHERE pr_id = ?").run(prId);
|
|
@@ -2075,16 +2075,17 @@ function replaceCodeIndex(db, repo, codeFiles, codeChunks, skippedFiles, cwd, ar
|
|
|
2075
2075
|
});
|
|
2076
2076
|
options.onProgress?.({ stage: "writing_code_index", repo, phase: "Writing code index" });
|
|
2077
2077
|
const transaction = db.transaction(() => {
|
|
2078
|
-
const
|
|
2078
|
+
const existingChunkCount = db.prepare("SELECT COUNT(*) AS count FROM code_chunks WHERE repo_id = ?").get(repoId).count;
|
|
2079
2079
|
const existingPatternCount = db.prepare("SELECT COUNT(*) AS count FROM architecture_patterns WHERE repo_id = ?").get(repoId).count;
|
|
2080
2080
|
options.onProgress?.({
|
|
2081
2081
|
stage: "deleting_existing_code_index",
|
|
2082
2082
|
repo,
|
|
2083
|
-
chunks:
|
|
2083
|
+
chunks: existingChunkCount,
|
|
2084
2084
|
patterns: existingPatternCount
|
|
2085
2085
|
});
|
|
2086
|
-
|
|
2087
|
-
|
|
2086
|
+
db.prepare(
|
|
2087
|
+
"DELETE FROM code_chunks_fts WHERE chunkId IN (SELECT id FROM code_chunks WHERE repo_id = ?)"
|
|
2088
|
+
).run(repoId);
|
|
2088
2089
|
db.prepare("DELETE FROM code_chunks WHERE repo_id = ?").run(repoId);
|
|
2089
2090
|
db.prepare("DELETE FROM code_files WHERE repo_id = ?").run(repoId);
|
|
2090
2091
|
db.prepare("DELETE FROM test_links WHERE repo_id = ? AND reason != 'PR co-change'").run(repoId);
|
|
@@ -2222,9 +2223,9 @@ function replaceCodeIndex(db, repo, codeFiles, codeChunks, skippedFiles, cwd, ar
|
|
|
2222
2223
|
};
|
|
2223
2224
|
}
|
|
2224
2225
|
function deleteExistingArchitectureData(db, repoId) {
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2226
|
+
db.prepare(
|
|
2227
|
+
"DELETE FROM architecture_patterns_fts WHERE patternId IN (SELECT id FROM architecture_patterns WHERE repo_id = ?)"
|
|
2228
|
+
).run(repoId);
|
|
2228
2229
|
db.prepare("DELETE FROM architecture_patterns WHERE repo_id = ?").run(repoId);
|
|
2229
2230
|
db.prepare("DELETE FROM architecture_components WHERE repo_id = ?").run(repoId);
|
|
2230
2231
|
db.prepare("DELETE FROM code_imports WHERE repo_id = ?").run(repoId);
|
|
@@ -2796,7 +2797,7 @@ function chunkCodeFile(file, options = {}) {
|
|
|
2796
2797
|
import crypto2 from "crypto";
|
|
2797
2798
|
import path6 from "path";
|
|
2798
2799
|
var KNOWN_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".json"];
|
|
2799
|
-
var ARCHITECTURE_PROGRESS_INTERVAL =
|
|
2800
|
+
var ARCHITECTURE_PROGRESS_INTERVAL = 100;
|
|
2800
2801
|
function shouldEmitProgress2(current, total) {
|
|
2801
2802
|
return current === 0 || current === 1 || current === total || current % ARCHITECTURE_PROGRESS_INTERVAL === 0;
|
|
2802
2803
|
}
|
|
@@ -3243,12 +3244,19 @@ function discoverGitFiles(cwd) {
|
|
|
3243
3244
|
});
|
|
3244
3245
|
return output.split("\n").map((line) => normalizeGitPath(line.trim())).filter(Boolean);
|
|
3245
3246
|
}
|
|
3247
|
+
var DISCOVERY_SCAN_INTERVAL = 200;
|
|
3246
3248
|
function discoverCodeFiles(cwd, repo, options = {}) {
|
|
3247
3249
|
const maxFileBytes = options.maxFileBytes ?? DEFAULT_MAX_CODE_FILE_BYTES;
|
|
3248
3250
|
const rootPath = path7.resolve(cwd);
|
|
3249
3251
|
const files = [];
|
|
3250
3252
|
let skippedFiles = 0;
|
|
3251
|
-
|
|
3253
|
+
const gitFiles = discoverGitFiles(cwd);
|
|
3254
|
+
const total = gitFiles.length;
|
|
3255
|
+
for (const [scanIndex, filePath] of gitFiles.entries()) {
|
|
3256
|
+
const scanned = scanIndex + 1;
|
|
3257
|
+
if (scanned % DISCOVERY_SCAN_INTERVAL === 0 || scanned === total) {
|
|
3258
|
+
options.onScan?.(scanned, total);
|
|
3259
|
+
}
|
|
3252
3260
|
if (isHardExcludedCodePath(filePath)) {
|
|
3253
3261
|
skippedFiles += 1;
|
|
3254
3262
|
continue;
|
|
@@ -3524,7 +3532,8 @@ function refreshTestCommands(db, cwd, repo, files = [], options = {}) {
|
|
|
3524
3532
|
function indexCodebase(db, options) {
|
|
3525
3533
|
options.onProgress?.({ stage: "discovering_code_files", repo: options.repo });
|
|
3526
3534
|
const discovery = discoverCodeFiles(options.cwd, options.repo, {
|
|
3527
|
-
maxFileBytes: options.maxFileBytes
|
|
3535
|
+
maxFileBytes: options.maxFileBytes,
|
|
3536
|
+
onScan: (scanned, total) => options.onProgress?.({ stage: "discovering_code_files", repo: options.repo, scanned, total })
|
|
3528
3537
|
});
|
|
3529
3538
|
options.onProgress?.({
|
|
3530
3539
|
stage: "discovered_code_files",
|