初始化模版工程
This commit is contained in:
38
app/api/nova-config.ts
Normal file
38
app/api/nova-config.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { readFileSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
|
||||
interface NovaAgent {
|
||||
agent_id: string
|
||||
agent_name: string
|
||||
agent_description: string
|
||||
}
|
||||
|
||||
interface NovaConfig {
|
||||
agents: NovaAgent[]
|
||||
}
|
||||
|
||||
let _config: NovaConfig | null = null
|
||||
|
||||
export function getNovaConfig(): NovaConfig {
|
||||
if (!_config) {
|
||||
const configPath = join(process.cwd(), '.nova', 'config.json')
|
||||
_config = JSON.parse(readFileSync(configPath, 'utf-8'))
|
||||
}
|
||||
return _config!
|
||||
}
|
||||
|
||||
export function getDefaultAgentId(): string {
|
||||
const config = getNovaConfig()
|
||||
if (!config.agents.length) {
|
||||
throw new Error('No agents configured in .nova/config.json')
|
||||
}
|
||||
return config.agents[0].agent_id
|
||||
}
|
||||
|
||||
export function getDefaultAgentName(): string {
|
||||
const config = getNovaConfig()
|
||||
if (!config.agents.length) {
|
||||
throw new Error('No agents configured in .nova/config.json')
|
||||
}
|
||||
return config.agents[0].agent_name
|
||||
}
|
||||
Reference in New Issue
Block a user