2026-02-17 13:39:47 -06:00
|
|
|
import { readConfig, configExists, resolveConfigPath } from "../config/store.js";
|
|
|
|
|
import type { CheckResult } from "./index.js";
|
|
|
|
|
|
|
|
|
|
export function configCheck(configPath?: string): CheckResult {
|
|
|
|
|
const filePath = resolveConfigPath(configPath);
|
|
|
|
|
|
|
|
|
|
if (!configExists(configPath)) {
|
|
|
|
|
return {
|
|
|
|
|
name: "Config file",
|
|
|
|
|
status: "fail",
|
|
|
|
|
message: `Config file not found at ${filePath}`,
|
|
|
|
|
canRepair: false,
|
2026-03-03 08:45:26 -06:00
|
|
|
repairHint: "Run `paperclipai onboard` to create one",
|
2026-02-17 13:39:47 -06:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
readConfig(configPath);
|
|
|
|
|
return {
|
|
|
|
|
name: "Config file",
|
|
|
|
|
status: "pass",
|
|
|
|
|
message: `Valid config at ${filePath}`,
|
|
|
|
|
};
|
|
|
|
|
} catch (err) {
|
|
|
|
|
return {
|
|
|
|
|
name: "Config file",
|
|
|
|
|
status: "fail",
|
|
|
|
|
message: `Invalid config: ${err instanceof Error ? err.message : String(err)}`,
|
|
|
|
|
canRepair: false,
|
2026-03-03 08:45:26 -06:00
|
|
|
repairHint: "Run `paperclipai configure --section database` (or `paperclipai onboard` to recreate)",
|
2026-02-17 13:39:47 -06:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|