fix: require a model, default to empty value during onboarding

and add a WORKSPACE_PATH constant to make tracking that path easier
This commit is contained in:
Joe Fleming
2026-03-13 20:42:00 -06:00
parent 14aa1c1e7f
commit b6df31fcbf
4 changed files with 13 additions and 11 deletions

View File

@@ -3,6 +3,7 @@ import { join } from 'node:path';
import { Command } from 'commander';
import pc from 'picocolors';
import { ConfigSchema, type Config } from '../config/types.ts';
import { WORKSPACE_PATH } from '../config/constants.ts'
import { ensureWorkspace, resolvePath, checkWorkspaceEmpty, syncTemplates } from './utils.ts';
function logCreated(item: string) {
@@ -15,9 +16,14 @@ export function onboardCommand(program: Command): void {
.description('Initialize a new nanobot workspace with config and templates')
.action(async (rawPath?: string) => {
try {
const defaultConfig: Config = ConfigSchema.parse({});
const defaultConfig: Config = ConfigSchema.parse({
agent: {
provider: '',
model: '',
}
});
const targetPath = resolvePath(rawPath ?? defaultConfig.agent.workspacePath);
const targetPath = resolvePath(rawPath ?? WORKSPACE_PATH);
const configPath = join(targetPath, 'config.json');
console.info(pc.blue('Initializing nanobot workspace...'));

1
src/config/constants.ts Normal file
View File

@@ -0,0 +1 @@
export const WORKSPACE_PATH = '~/.config/nanobot'

View File

@@ -3,6 +3,7 @@ import { homedir } from 'node:os';
import { dirname, resolve } from 'node:path';
import pc from 'picocolors'
import { type Config, ConfigSchema } from './types.ts';
import { WORKSPACE_PATH } from './constants.ts'
const DEFAULT_CONFIG_PATH = resolve(homedir(), '.config', 'nanobot', 'config.json');

View File

@@ -1,4 +1,5 @@
import { z } from 'zod';
import { WORKSPACE_PATH } from './constants.ts'
// ---------------------------------------------------------------------------
// Mattermost
@@ -41,7 +42,7 @@ export type ChannelsConfig = z.infer<typeof ChannelsConfigSchema>;
export const AgentConfigSchema = z.object({
model: z.string().default('anthropic/claude-sonnet-4-5'),
workspacePath: z.string().default('~/.config/nanobot'),
workspacePath: z.string().default(WORKSPACE_PATH),
maxTokens: z.number().int().default(4096),
contextWindowTokens: z.number().int().default(65536),
temperature: z.number().default(0.7),
@@ -113,14 +114,7 @@ export type HeartbeatConfig = z.infer<typeof HeartbeatConfigSchema>;
export const ConfigSchema = z.object({
providers: ProvidersConfigSchema.default(() => ({})),
agent: AgentConfigSchema.default(() => ({
model: 'anthropic/claude-sonnet-4-5',
workspacePath: '~/.config/nanobot',
maxTokens: 4096,
contextWindowTokens: 65536,
temperature: 0.7,
maxToolIterations: 40,
})),
agent: AgentConfigSchema,
heartbeat: HeartbeatConfigSchema.default(() => ({ enabled: false, intervalMinutes: 30 })),
channels: ChannelsConfigSchema.default(() => ({ sendProgress: true, sendToolHints: true })),
tools: ToolsConfigSchema.default(() => ({