refactor: drop skill file, rework client

This commit was merged in pull request #3.
This commit is contained in:
2026-07-11 08:52:55 +00:00
parent 990a8d09b6
commit a6a288103c
21 changed files with 679 additions and 645 deletions
+51
View File
@@ -0,0 +1,51 @@
import fs from "node:fs";
import { configFilePath, initDataDir } from "./data.ts";
// Re-export for backward compatibility
export { initDataDir };
export interface LoginConfig {
serverUrl: string;
email: string;
username: string;
domain?: string;
}
let inMemoryPassword: string | null = null;
export function setPassword(password: string): void {
inMemoryPassword = password;
}
export function getPassword(): string | null {
return inMemoryPassword;
}
export function hasPassword(): boolean {
return inMemoryPassword !== null;
}
export function clearPassword(): void {
inMemoryPassword = null;
}
export function loadConfig(): LoginConfig {
const filePath = configFilePath();
if (!fs.existsSync(filePath)) {
throw new Error("Not logged in. Use the login tool first.");
}
return JSON.parse(fs.readFileSync(filePath, "utf-8")) as LoginConfig;
}
export function saveConfig(config: LoginConfig): void {
const filePath = configFilePath();
fs.writeFileSync(filePath, JSON.stringify(config, null, 2), "utf-8");
}
export function clearConfig(): void {
const filePath = configFilePath();
if (fs.existsSync(filePath)) {
fs.unlinkSync(filePath);
}
clearPassword();
}