@liendev/lien 0.21.0 → 0.23.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.js +102 -77
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3984,98 +3984,123 @@ function getModelLoadingMessage() {
|
|
|
3984
3984
|
}
|
|
3985
3985
|
|
|
3986
3986
|
// src/cli/index-cmd.ts
|
|
3987
|
+
async function clearExistingIndex() {
|
|
3988
|
+
const { VectorDB: VectorDB2 } = await import("@liendev/core");
|
|
3989
|
+
const { ManifestManager: ManifestManager2 } = await import("@liendev/core");
|
|
3990
|
+
console.log(chalk4.yellow("Clearing existing index and manifest..."));
|
|
3991
|
+
const vectorDB = new VectorDB2(process.cwd());
|
|
3992
|
+
await vectorDB.initialize();
|
|
3993
|
+
await vectorDB.clear();
|
|
3994
|
+
const manifest = new ManifestManager2(vectorDB.dbPath);
|
|
3995
|
+
await manifest.clear();
|
|
3996
|
+
console.log(chalk4.green("\u2713 Index and manifest cleared\n"));
|
|
3997
|
+
}
|
|
3998
|
+
function createProgressTracker() {
|
|
3999
|
+
return {
|
|
4000
|
+
current: {
|
|
4001
|
+
phase: "initializing",
|
|
4002
|
+
message: "Starting...",
|
|
4003
|
+
filesTotal: 0,
|
|
4004
|
+
filesProcessed: 0
|
|
4005
|
+
},
|
|
4006
|
+
wittyMessage: getIndexingMessage(),
|
|
4007
|
+
lastUpdateTime: 0,
|
|
4008
|
+
updateCount: 0,
|
|
4009
|
+
completedViaProgress: false
|
|
4010
|
+
};
|
|
4011
|
+
}
|
|
4012
|
+
function updateSpinner(spinner, tracker, forceUpdate = false) {
|
|
4013
|
+
const now = Date.now();
|
|
4014
|
+
tracker.updateCount++;
|
|
4015
|
+
const shouldThrottle = tracker.updateCount > 20;
|
|
4016
|
+
const throttleMs = 50;
|
|
4017
|
+
if (!forceUpdate && shouldThrottle && now - tracker.lastUpdateTime < throttleMs) {
|
|
4018
|
+
return;
|
|
4019
|
+
}
|
|
4020
|
+
tracker.lastUpdateTime = now;
|
|
4021
|
+
const { current, wittyMessage } = tracker;
|
|
4022
|
+
const text = current.filesTotal && current.filesProcessed !== void 0 ? `${current.filesProcessed}/${current.filesTotal} files | ${wittyMessage}` : wittyMessage;
|
|
4023
|
+
spinner.text = text;
|
|
4024
|
+
setImmediate(() => spinner.render());
|
|
4025
|
+
}
|
|
4026
|
+
function updateWittyMessage(tracker) {
|
|
4027
|
+
const { current } = tracker;
|
|
4028
|
+
if (current.phase === "embedding" || current.phase === "indexing") {
|
|
4029
|
+
tracker.wittyMessage = getIndexingMessage();
|
|
4030
|
+
} else if (current.phase === "initializing") {
|
|
4031
|
+
tracker.wittyMessage = getModelLoadingMessage();
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
function startMessageRotation(spinner, tracker) {
|
|
4035
|
+
tracker.messageRotationInterval = setInterval(() => {
|
|
4036
|
+
updateWittyMessage(tracker);
|
|
4037
|
+
updateSpinner(spinner, tracker, true);
|
|
4038
|
+
}, 8e3);
|
|
4039
|
+
}
|
|
4040
|
+
function stopMessageRotation(tracker) {
|
|
4041
|
+
if (tracker.messageRotationInterval) {
|
|
4042
|
+
clearInterval(tracker.messageRotationInterval);
|
|
4043
|
+
tracker.messageRotationInterval = void 0;
|
|
4044
|
+
}
|
|
4045
|
+
}
|
|
4046
|
+
function createProgressCallback(spinner, tracker) {
|
|
4047
|
+
return (progress) => {
|
|
4048
|
+
tracker.current = progress;
|
|
4049
|
+
if (progress.phase === "initializing" && !tracker.messageRotationInterval) {
|
|
4050
|
+
tracker.wittyMessage = getModelLoadingMessage();
|
|
4051
|
+
} else if (progress.phase === "embedding") {
|
|
4052
|
+
tracker.wittyMessage = getEmbeddingMessage();
|
|
4053
|
+
} else if (progress.phase === "indexing") {
|
|
4054
|
+
tracker.wittyMessage = getIndexingMessage();
|
|
4055
|
+
}
|
|
4056
|
+
if (progress.phase === "complete") {
|
|
4057
|
+
tracker.completedViaProgress = true;
|
|
4058
|
+
stopMessageRotation(tracker);
|
|
4059
|
+
let message = progress.message;
|
|
4060
|
+
if (progress.filesTotal && progress.filesProcessed !== void 0) {
|
|
4061
|
+
message = `${message} (${progress.filesProcessed}/${progress.filesTotal})`;
|
|
4062
|
+
}
|
|
4063
|
+
spinner.succeed(chalk4.green(message));
|
|
4064
|
+
} else {
|
|
4065
|
+
updateSpinner(spinner, tracker);
|
|
4066
|
+
}
|
|
4067
|
+
};
|
|
4068
|
+
}
|
|
4069
|
+
function displayFinalResult(spinner, tracker, result) {
|
|
4070
|
+
if (!tracker.completedViaProgress) {
|
|
4071
|
+
if (result.filesIndexed === 0) {
|
|
4072
|
+
spinner.succeed(chalk4.green("Index is up to date - no changes detected"));
|
|
4073
|
+
} else {
|
|
4074
|
+
spinner.succeed(chalk4.green(`Indexed ${result.filesIndexed} files, ${result.chunksCreated} chunks`));
|
|
4075
|
+
}
|
|
4076
|
+
}
|
|
4077
|
+
}
|
|
3987
4078
|
async function indexCommand(options) {
|
|
3988
4079
|
showCompactBanner();
|
|
3989
4080
|
try {
|
|
3990
4081
|
if (options.force) {
|
|
3991
|
-
|
|
3992
|
-
const { ManifestManager: ManifestManager2 } = await import("@liendev/core");
|
|
3993
|
-
console.log(chalk4.yellow("Clearing existing index and manifest..."));
|
|
3994
|
-
const vectorDB = new VectorDB2(process.cwd());
|
|
3995
|
-
await vectorDB.initialize();
|
|
3996
|
-
await vectorDB.clear();
|
|
3997
|
-
const manifest = new ManifestManager2(vectorDB.dbPath);
|
|
3998
|
-
await manifest.clear();
|
|
3999
|
-
console.log(chalk4.green("\u2713 Index and manifest cleared\n"));
|
|
4082
|
+
await clearExistingIndex();
|
|
4000
4083
|
}
|
|
4001
4084
|
const spinner = ora({
|
|
4002
4085
|
text: "Starting indexing...",
|
|
4003
4086
|
interval: 30
|
|
4004
4087
|
// Faster refresh rate for smoother progress
|
|
4005
4088
|
}).start();
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
let messageRotationInterval;
|
|
4009
|
-
let lastUpdateTime = 0;
|
|
4010
|
-
let updateCount = 0;
|
|
4011
|
-
let currentProgress = {
|
|
4012
|
-
phase: "initializing",
|
|
4013
|
-
message: "Starting...",
|
|
4014
|
-
filesTotal: 0,
|
|
4015
|
-
filesProcessed: 0
|
|
4016
|
-
};
|
|
4017
|
-
const updateSpinner = (forceUpdate = false) => {
|
|
4018
|
-
const now = Date.now();
|
|
4019
|
-
updateCount++;
|
|
4020
|
-
const shouldThrottle = updateCount > 20;
|
|
4021
|
-
const throttleMs = 50;
|
|
4022
|
-
if (!forceUpdate && shouldThrottle && now - lastUpdateTime < throttleMs) {
|
|
4023
|
-
return;
|
|
4024
|
-
}
|
|
4025
|
-
lastUpdateTime = now;
|
|
4026
|
-
let text = "";
|
|
4027
|
-
if (currentProgress.filesTotal && currentProgress.filesProcessed !== void 0) {
|
|
4028
|
-
text = `${currentProgress.filesProcessed}/${currentProgress.filesTotal} files | ${wittyMessage}`;
|
|
4029
|
-
} else {
|
|
4030
|
-
text = wittyMessage;
|
|
4031
|
-
}
|
|
4032
|
-
spinner.text = text;
|
|
4033
|
-
setImmediate(() => {
|
|
4034
|
-
spinner.render();
|
|
4035
|
-
});
|
|
4036
|
-
};
|
|
4037
|
-
messageRotationInterval = setInterval(() => {
|
|
4038
|
-
if (currentProgress.phase === "embedding" || currentProgress.phase === "indexing") {
|
|
4039
|
-
wittyMessage = getIndexingMessage();
|
|
4040
|
-
} else if (currentProgress.phase === "initializing") {
|
|
4041
|
-
wittyMessage = getModelLoadingMessage();
|
|
4042
|
-
}
|
|
4043
|
-
updateSpinner(true);
|
|
4044
|
-
}, 8e3);
|
|
4089
|
+
const tracker = createProgressTracker();
|
|
4090
|
+
startMessageRotation(spinner, tracker);
|
|
4045
4091
|
const result = await indexCodebase({
|
|
4046
4092
|
rootDir: process.cwd(),
|
|
4047
4093
|
verbose: options.verbose || false,
|
|
4048
4094
|
force: options.force || false,
|
|
4049
|
-
onProgress: (
|
|
4050
|
-
currentProgress = progress;
|
|
4051
|
-
if (progress.phase === "initializing" && !messageRotationInterval) {
|
|
4052
|
-
wittyMessage = getModelLoadingMessage();
|
|
4053
|
-
} else if (progress.phase === "embedding") {
|
|
4054
|
-
wittyMessage = getEmbeddingMessage();
|
|
4055
|
-
} else if (progress.phase === "indexing") {
|
|
4056
|
-
wittyMessage = getIndexingMessage();
|
|
4057
|
-
}
|
|
4058
|
-
if (progress.phase === "complete") {
|
|
4059
|
-
completedViaProgress = true;
|
|
4060
|
-
if (messageRotationInterval) clearInterval(messageRotationInterval);
|
|
4061
|
-
let message = progress.message;
|
|
4062
|
-
if (progress.filesTotal && progress.filesProcessed !== void 0) {
|
|
4063
|
-
message = `${message} (${progress.filesProcessed}/${progress.filesTotal})`;
|
|
4064
|
-
}
|
|
4065
|
-
spinner.succeed(chalk4.green(message));
|
|
4066
|
-
} else {
|
|
4067
|
-
updateSpinner();
|
|
4068
|
-
}
|
|
4069
|
-
}
|
|
4095
|
+
onProgress: createProgressCallback(spinner, tracker)
|
|
4070
4096
|
});
|
|
4071
|
-
|
|
4072
|
-
if (!
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
spinner.succeed(chalk4.green(`Indexed ${result.filesIndexed} files, ${result.chunksCreated} chunks`));
|
|
4077
|
-
}
|
|
4097
|
+
stopMessageRotation(tracker);
|
|
4098
|
+
if (!result.success && result.error) {
|
|
4099
|
+
spinner.fail(chalk4.red("Indexing failed"));
|
|
4100
|
+
console.error(chalk4.red("\n" + result.error));
|
|
4101
|
+
process.exit(1);
|
|
4078
4102
|
}
|
|
4103
|
+
displayFinalResult(spinner, tracker, result);
|
|
4079
4104
|
if (options.watch) {
|
|
4080
4105
|
console.log(chalk4.yellow("\n\u26A0\uFE0F Watch mode not yet implemented"));
|
|
4081
4106
|
}
|
|
@@ -8656,7 +8681,7 @@ async function handleSemanticSearch(args, ctx) {
|
|
|
8656
8681
|
const queryEmbedding = await embeddings.embed(query);
|
|
8657
8682
|
let results;
|
|
8658
8683
|
if (crossRepo && vectorDB instanceof QdrantDB) {
|
|
8659
|
-
results = await vectorDB.searchCrossRepo(queryEmbedding, limit, repoIds);
|
|
8684
|
+
results = await vectorDB.searchCrossRepo(queryEmbedding, limit, { repoIds });
|
|
8660
8685
|
log(`Found ${results.length} results across ${Object.keys(groupResultsByRepo(results)).length} repos`);
|
|
8661
8686
|
} else {
|
|
8662
8687
|
if (crossRepo) {
|