mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 04:01:56 +00:00
refactor(coding-agent): improve settings storage semantics and error handling
This commit is contained in:
parent
5133697bc4
commit
de2736bad0
7 changed files with 386 additions and 152 deletions
|
|
@ -55,6 +55,16 @@ async function readPipedStdin(): Promise<string | undefined> {
|
|||
});
|
||||
}
|
||||
|
||||
function reportSettingsErrors(settingsManager: SettingsManager, context: string): void {
|
||||
const errors = settingsManager.drainErrors();
|
||||
for (const { scope, error } of errors) {
|
||||
console.error(chalk.yellow(`Warning (${context}, ${scope} settings): ${error.message}`));
|
||||
if (error.stack) {
|
||||
console.error(chalk.dim(error.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type PackageCommand = "install" | "remove" | "update" | "list";
|
||||
|
||||
interface PackageCommandOptions {
|
||||
|
|
@ -200,6 +210,7 @@ async function handlePackageCommand(args: string[]): Promise<boolean> {
|
|||
const cwd = process.cwd();
|
||||
const agentDir = getAgentDir();
|
||||
const settingsManager = SettingsManager.create(cwd, agentDir);
|
||||
reportSettingsErrors(settingsManager, "package command");
|
||||
const packageManager = new DefaultPackageManager({ cwd, agentDir, settingsManager });
|
||||
|
||||
packageManager.setProgressCallback((event) => {
|
||||
|
|
@ -508,6 +519,7 @@ async function handleConfigCommand(args: string[]): Promise<boolean> {
|
|||
const cwd = process.cwd();
|
||||
const agentDir = getAgentDir();
|
||||
const settingsManager = SettingsManager.create(cwd, agentDir);
|
||||
reportSettingsErrors(settingsManager, "config command");
|
||||
const packageManager = new DefaultPackageManager({ cwd, agentDir, settingsManager });
|
||||
|
||||
const resolvedPaths = await packageManager.resolve();
|
||||
|
|
@ -541,6 +553,7 @@ export async function main(args: string[]) {
|
|||
const cwd = process.cwd();
|
||||
const agentDir = getAgentDir();
|
||||
const settingsManager = SettingsManager.create(cwd, agentDir);
|
||||
reportSettingsErrors(settingsManager, "startup");
|
||||
const authStorage = new AuthStorage();
|
||||
const modelRegistry = new ModelRegistry(authStorage, getModelsPath());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue