* Fix an issue where CMD+K does not clear the terminal when the terminal has focus (#1671) On MacOS, ⌘+K is bound, by default, to Terminal:Clear. Without this change ⌘+K does not clear the terminal but instead iniates a chord sequence and waits for the next stroke of the chord. Co-authored-by: Rob Leidle <rleidle@tesla.com> * Change treeSitter to cache the Language objects it loads from wasm (#1672) Without this change, for a repository with 600 typescript files, the indexer would fail to finish correctly and there would be many of the following errors in the webview console log: 'Unable to load language for file ${path} RuntimeError: table index is out of bounds' The following bash will create a repo that reproduces the problem: current_path="." for ((i=1; i<=20; i++)); do new_folder="folder-$i" mkdir -p "$current_path/$new_folder" current_path="$current_path/$new_folder" for ((a=1; a<=30; a++)); do head -c 10000 /dev/urandom | base64 > "$current_path/file-$a.ts" done done Co-authored-by: Rob Leidle <rleidle@tesla.com> * acknowledge sourcemap flag in esbuild.js * don't run jetbrains-release.yaml on vscode releases * further testing for walkDir * chore: add telemetry to commands (#1673) * test: Add basic unit test to baseLLM (#1668) * update version * test: Add basic unit test to baseLLM --------- Co-authored-by: Nate Sesti <sestinj@gmail.com> Co-authored-by: inimaz <imaz@ai-verse.com> * feat: add Quick Actions CodeLens feature (#1674) * docs: add docs and schema for "OS" provider (#1536) * ignore .env * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * add voyage rerank-1 * import Handlebars * feat: open pane on install (#1564) * feat: open pane on activation * comment out testing code * chore: add telemetry for pageviews (#1576) * feat: update onboarding w/ embeddings model (#1570) * chore(gui): remove unused pages * feat: add embeddings step * feat: update styles * feat: copy button updates * fix: correct pull command for embed model * fix: remove commented code * fix: remove commented code * feat: simplify copy btn props * chore: rename onboarding selection event * feat: add provider config * fix: undo msg name * remove dead code * fix: invalid mode check * fix: remove testing logic * fix: fullscreen gui retains context when hidden, fixed fullscreen focusing (#1582) * small UI tweaks * media query * feat: add best experience onboarding * small fixes * feat: add free trial card to onboarding (#1600) * feat: add free trial card to onboarding * add import * chore: add telemetry for full screen toggle (#1618) * rerank-lite-1 * remove doccs * basic tests for VS Code extension * improved testing of VS Code extension * manually implement stop tokens for hf inference api * chore: onboarding metrics (#1626) * fix: pageview tracking * feat: add onboarding telemetry * create single `onboardingStatus` type * improved var naming * remove console logs * fix windows performance issue * rename vscodeExtension.ts * migration of onboarding variables * "stash" instead of "delete" in indexing progress * fix preview.yaml * also fix main.yaml * Update troubleshooting.md (#1637) * feat: add quick actions * Update index.d.ts * quick actions mvp * update docs * subscribe to vscode change settings * Update commands.ts * cleanup * Update quick-actions.md * Update VerticalPerLineCodeLensProvider.ts * resolve feedback --------- Co-authored-by: Nate Sesti <sestinj@gmail.com> Co-authored-by: Nate Sesti <33237525+sestinj@users.noreply.github.com> Co-authored-by: Jonah Wagner <jonahwagner231@gmail.com> * chore: add `isCommandEvent` to command telemetry (#1675) * chore: add `isCommandEvent` to command telemetry * Update commands.ts * Nate/better retrieval (#1677) * deduplicatearray tests * break out separate retrieval pipelines * IConfigHandler * tests for codebase indexer * better .continueignore for continue * indexing fixes * ignore .gitignore and .continueignore when indexing * retrieval pipeline improvements * fix formatting err in out .continueignore * add necessary filter to lance_db_cache * update package.json version * skip unused tests --------- Co-authored-by: Rob Leidle <rleidle@gmail.com> Co-authored-by: Rob Leidle <rleidle@tesla.com> Co-authored-by: Patrick Erichsen <patrick.a.erichsen@gmail.com> Co-authored-by: inimaz <49730431+inimaz@users.noreply.github.com> Co-authored-by: inimaz <imaz@ai-verse.com> Co-authored-by: Jonah Wagner <jonahwagner231@gmail.com>
174 lines
4.6 KiB
TypeScript
174 lines
4.6 KiB
TypeScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { ConfigHandler } from "../../config/ConfigHandler";
|
|
import { ContinueServerClient } from "../../continueServer/stubs/client";
|
|
import { CodebaseIndexer, PauseToken } from "../../indexing/CodebaseIndexer";
|
|
import { LanceDbIndex } from "../../indexing/LanceDbIndex";
|
|
import TransformersJsEmbeddingsProvider from "../../indexing/embeddings/TransformersJsEmbeddingsProvider";
|
|
import FileSystemIde from "../../util/filesystem";
|
|
import {
|
|
getIndexFolderPath,
|
|
getIndexSqlitePath,
|
|
getLanceDbPath,
|
|
} from "../../util/paths";
|
|
import {
|
|
addToTestDir,
|
|
setUpTestDir,
|
|
tearDownTestDir,
|
|
TEST_DIR,
|
|
} from "../testUtils/testDir";
|
|
|
|
const TEST_TS = `\
|
|
function main() {
|
|
console.log("Hello, world!");
|
|
}
|
|
|
|
class Foo {
|
|
constructor(public bar: string) {}
|
|
}
|
|
`;
|
|
|
|
const TEST_PY = `\
|
|
def main():
|
|
print("Hello, world!")
|
|
|
|
class Foo:
|
|
def __init__(self, bar: str):
|
|
self.bar = bar
|
|
`;
|
|
|
|
const TEST_RS = `\
|
|
fn main() {
|
|
println!("Hello, world!");
|
|
}
|
|
|
|
struct Foo {
|
|
bar: String,
|
|
}
|
|
`;
|
|
|
|
// These are more like integration tests, whereas we should separately test
|
|
// the individual CodebaseIndex classes
|
|
describe.skip("CodebaseIndexer", () => {
|
|
const ide = new FileSystemIde(TEST_DIR);
|
|
const ideSettingsPromise = ide.getIdeSettings();
|
|
const configHandler = new ConfigHandler(
|
|
ide,
|
|
ideSettingsPromise,
|
|
async (text) => {},
|
|
);
|
|
const pauseToken = new PauseToken(false);
|
|
const continueServerClient = new ContinueServerClient(undefined, undefined);
|
|
const codebaseIndexer = new CodebaseIndexer(
|
|
configHandler,
|
|
ide,
|
|
pauseToken,
|
|
continueServerClient,
|
|
);
|
|
const lancedbIndex = new LanceDbIndex(
|
|
new TransformersJsEmbeddingsProvider(),
|
|
ide.readFile.bind(ide),
|
|
continueServerClient,
|
|
);
|
|
|
|
beforeAll(async () => {
|
|
setUpTestDir();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
tearDownTestDir();
|
|
});
|
|
|
|
test("should index test folder without problem", async () => {
|
|
addToTestDir([
|
|
["test.ts", TEST_TS],
|
|
["py/main.py", TEST_PY],
|
|
]);
|
|
const abortController = new AbortController();
|
|
const abortSignal = abortController.signal;
|
|
|
|
const updates = [];
|
|
for await (const update of codebaseIndexer.refresh(
|
|
[TEST_DIR],
|
|
abortSignal,
|
|
)) {
|
|
updates.push(update);
|
|
}
|
|
|
|
expect(updates.length).toBeGreaterThan(0);
|
|
});
|
|
|
|
test("should have created index folder with all necessary files", async () => {
|
|
expect(fs.existsSync(getIndexFolderPath())).toBe(true);
|
|
expect(fs.existsSync(getIndexSqlitePath())).toBe(true);
|
|
expect(fs.existsSync(getLanceDbPath())).toBe(true);
|
|
});
|
|
|
|
test("should be able to query lancedb index", async () => {
|
|
const chunks = await lancedbIndex.retrieve(
|
|
"What is the main function doing?",
|
|
10,
|
|
await ide.getTags(lancedbIndex.artifactId),
|
|
undefined,
|
|
);
|
|
|
|
expect(chunks.length).toBe(2);
|
|
// Check that the main function from both files is returned
|
|
expect(chunks.some((chunk) => chunk.filepath.endsWith("test.ts"))).toBe(
|
|
true,
|
|
);
|
|
expect(chunks.some((chunk) => chunk.filepath.endsWith("main.py"))).toBe(
|
|
true,
|
|
);
|
|
});
|
|
|
|
test("should successfully re-index after adding a file", async () => {
|
|
addToTestDir([["main.rs", TEST_RS]]);
|
|
const abortController = new AbortController();
|
|
const abortSignal = abortController.signal;
|
|
const updates = [];
|
|
for await (const update of codebaseIndexer.refresh(
|
|
[TEST_DIR],
|
|
abortSignal,
|
|
)) {
|
|
updates.push(update);
|
|
}
|
|
expect(updates.length).toBeGreaterThan(0);
|
|
// Check that the new file was indexed
|
|
const chunks = await lancedbIndex.retrieve(
|
|
"What is the main function doing?",
|
|
3,
|
|
await ide.getTags(lancedbIndex.artifactId),
|
|
undefined,
|
|
);
|
|
expect(chunks.length).toBe(3);
|
|
expect(chunks.some((chunk) => chunk.filepath.endsWith("main.rs"))).toBe(
|
|
true,
|
|
);
|
|
});
|
|
|
|
test("should successfully re-index after deleting a file", async () => {
|
|
fs.rmSync(path.join(TEST_DIR, "main.rs"));
|
|
const abortController = new AbortController();
|
|
const abortSignal = abortController.signal;
|
|
const updates = [];
|
|
for await (const update of codebaseIndexer.refresh(
|
|
[TEST_DIR],
|
|
abortSignal,
|
|
)) {
|
|
updates.push(update);
|
|
}
|
|
expect(updates.length).toBeGreaterThan(0);
|
|
// Check that the deleted file was removed from the index
|
|
const chunks = await lancedbIndex.retrieve(
|
|
"What is the main function doing?",
|
|
10,
|
|
await ide.getTags(lancedbIndex.artifactId),
|
|
undefined,
|
|
);
|
|
expect(chunks.length).toBe(2);
|
|
expect(chunks.every((chunk) => !chunk.filepath.endsWith("main.rs"))).toBe(
|
|
true,
|
|
);
|
|
});
|
|
});
|