* 🎨 refactor out react context * 🎨 refactor local storage * 🎨 refactor IdeMessenger * 🔥 removing unused files * 🚚 move scripts * ✅ setup VSCode integration testing * 🎨 fix test-related stuff * 🚧 testing * 🎨 tweak terminal cmd+L * 🧑💻 install biome in core * 🎨 run biome check on core * 🎨 run biome check in vscode * 🎨 run biome check in binary * 🧑💻 global biome config * 🎨 run biome check on core * 🎨 run biome check in vscode * 🎨 fix a few biome warnings * 🚧 WIP on protocols * 🚧 progress, organizing, about to remove webviewCore protocol * 🚧 now running * 🚧 move indexing code to core * 🚧 WIP on JetBrains indexing implementation * 🎨 finish listDir * 🚧 gui fixes * 🏷️ update IMessenger.on return type * 🐛 fix jetbrains types + IDE detection * 🧑💻 set up debugging for binary with TcpMessenger * 👷 fix prepackage.js * 🧑💻 turn off debug mode for intellij * 🐛 merge fixes * 🐛 fixes after refactor * 🐛 merge fixes * 💄 increase font size in JB * 🔀 merge changes * 🩹 small fixes * 🐛 fix jetbrains build * 🩹 more jetbrains fixes * 🎨 jetbrains improvements * 🐛 fix lancedb prob in jetbrains build * 👷 update jetbrains build process * ✨ intellij problems context provider * 👷 add script utils file * 💚 fix jetbrains build regression * 🎨 dynamic import transformers.js * 🩹 small jetbrains updates * ✨ folder context provider in jetbrains * 🎨 many more jetbrains improvements * 🔀 merge fixes * ⚡️ small improvements * 🎨 tell users transformers.js not supported * 🎨 trial updates * 📝 update jetbrains readmej * ⚡️ only use smaller context for local autocomplete models * ⚡️ improve bracket filter * ✨ global .continue/.prompts folder * 💄 improved model setup process * 🥅 display VSCode req errs
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import fs from "node:fs";
|
|
import { getGlobalContextFilePath } from "./paths";
|
|
|
|
export type GlobalContextType = {
|
|
indexingPaused: boolean;
|
|
};
|
|
|
|
/**
|
|
* A way to persist global state
|
|
*/
|
|
export class GlobalContext {
|
|
update<T extends keyof GlobalContextType>(
|
|
key: T,
|
|
value: GlobalContextType[T],
|
|
) {
|
|
if (!fs.existsSync(getGlobalContextFilePath())) {
|
|
fs.writeFileSync(
|
|
getGlobalContextFilePath(),
|
|
JSON.stringify(
|
|
{
|
|
[key]: value,
|
|
},
|
|
null,
|
|
2,
|
|
),
|
|
);
|
|
} else {
|
|
const data = fs.readFileSync(getGlobalContextFilePath(), "utf-8");
|
|
const parsed = JSON.parse(data);
|
|
parsed[key] = value;
|
|
fs.writeFileSync(
|
|
getGlobalContextFilePath(),
|
|
JSON.stringify(parsed, null, 2),
|
|
);
|
|
}
|
|
}
|
|
|
|
get<T extends keyof GlobalContextType>(
|
|
key: T,
|
|
): GlobalContextType[T] | undefined {
|
|
if (!fs.existsSync(getGlobalContextFilePath())) {
|
|
return undefined;
|
|
}
|
|
|
|
const data = fs.readFileSync(getGlobalContextFilePath(), "utf-8");
|
|
const parsed = JSON.parse(data);
|
|
return parsed[key];
|
|
}
|
|
}
|