add sub-bar usage widget extension with opencode-go support

This commit is contained in:
2026-03-12 12:30:09 +00:00
parent 9ad10a016c
commit 5179fc6471
70 changed files with 14775 additions and 6 deletions
@@ -0,0 +1,61 @@
/**
* Storage abstraction for settings persistence.
*/
import * as fs from "node:fs";
import * as path from "node:path";
export interface StorageAdapter {
readFile(path: string): string | undefined;
writeFile(path: string, contents: string): void;
writeFileExclusive(path: string, contents: string): boolean;
exists(path: string): boolean;
removeFile(path: string): void;
ensureDir(path: string): void;
}
export function createFsStorage(): StorageAdapter {
return {
readFile(filePath: string): string | undefined {
try {
return fs.readFileSync(filePath, "utf-8");
} catch {
return undefined;
}
},
writeFile(filePath: string, contents: string): void {
fs.writeFileSync(filePath, contents, "utf-8");
},
writeFileExclusive(filePath: string, contents: string): boolean {
try {
fs.writeFileSync(filePath, contents, { flag: "wx" });
return true;
} catch {
return false;
}
},
exists(filePath: string): boolean {
return fs.existsSync(filePath);
},
removeFile(filePath: string): void {
try {
fs.unlinkSync(filePath);
} catch {
// Ignore remove errors
}
},
ensureDir(dirPath: string): void {
fs.mkdirSync(path.resolve(dirPath), { recursive: true });
},
};
}
let activeStorage: StorageAdapter = createFsStorage();
export function getStorage(): StorageAdapter {
return activeStorage;
}
export function setStorage(storage: StorageAdapter): void {
activeStorage = storage;
}