Skip to content

Commit f2f5bf8

Browse files
committed
chore: simplify config loading
1 parent 5409fd8 commit f2f5bf8

File tree

3 files changed

+4
-37
lines changed

3 files changed

+4
-37
lines changed

bun.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"@modelcontextprotocol/sdk": "^1.18.2",
99
"cors": "^2.8.5",
1010
"cosmiconfig": "^9.0.0",
11-
"cosmiconfig-typescript-loader": "^6.1.0",
1211
"easy-peasy": "^6.1.0",
1312
"express": "^5.1.0",
1413
"ink": "^6.3.1",
@@ -170,8 +169,6 @@
170169

171170
"cosmiconfig": ["[email protected]", "", { "dependencies": { "env-paths": "^2.2.1", "import-fresh": "^3.3.0", "js-yaml": "^4.1.0", "parse-json": "^5.2.0" }, "peerDependencies": { "typescript": ">=4.9.5" }, "optionalPeers": ["typescript"] }, "sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg=="],
172171

173-
"cosmiconfig-typescript-loader": ["[email protected]", "", { "dependencies": { "jiti": "^2.4.1" }, "peerDependencies": { "@types/node": "*", "cosmiconfig": ">=9", "typescript": ">=5" } }, "sha512-tJ1w35ZRUiM5FeTzT7DtYWAFFv37ZLqSRkGi2oeCK1gPhvaWjkAtfXvLmvE1pRfxxp9aQo6ba/Pvg1dKj05D4g=="],
174-
175172
"cross-spawn": ["[email protected]", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="],
176173

177174
"csstype": ["[email protected]", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
@@ -282,8 +279,6 @@
282279

283280
"isexe": ["[email protected]", "", {}, "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="],
284281

285-
"jiti": ["[email protected]", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ=="],
286-
287282
"js-tokens": ["[email protected]", "", {}, "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="],
288283

289284
"js-yaml": ["[email protected]", "", { "dependencies": { "argparse": "^2.0.1" }, "bin": { "js-yaml": "bin/js-yaml.js" } }, "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA=="],

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"@modelcontextprotocol/sdk": "^1.18.2",
3333
"cors": "^2.8.5",
3434
"cosmiconfig": "^9.0.0",
35-
"cosmiconfig-typescript-loader": "^6.1.0",
3635
"easy-peasy": "^6.1.0",
3736
"express": "^5.1.0",
3837
"ink": "^6.3.1",

src/utils/loadConfig.ts

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,12 @@
11
import { cosmiconfig } from "cosmiconfig"
2-
import { TypeScriptLoader } from "cosmiconfig-typescript-loader"
3-
import type { McpServerConfig } from "@anthropic-ai/claude-agent-sdk"
4-
5-
type McpServerConfigWithPrompt = McpServerConfig & {
6-
prompt?: string
7-
}
8-
9-
interface AgentChatConfig {
10-
stream?: boolean
11-
connectionTimeout?: number
12-
maxRetries?: number
13-
retryDelay?: number
14-
mcpServers: Record<string, McpServerConfigWithPrompt>
15-
}
2+
import type { AgentChatConfig } from "store"
163

174
export const loadConfig = async (): Promise<AgentChatConfig> => {
18-
const explorer = cosmiconfig("agent-chat-cli", {
19-
searchPlaces: [
20-
"agent-chat-cli.config.ts",
21-
"agent-chat-cli.config.js",
22-
".agent-chat-clirc",
23-
".agent-chat-clirc.json",
24-
".agent-chat-clirc.js",
25-
".agent-chat-clirc.ts",
26-
],
27-
loaders: {
28-
".ts": TypeScriptLoader(),
29-
},
30-
})
31-
32-
const result = await explorer.search()
5+
const result = await cosmiconfig("agent-chat-cli").search()
336

347
if (!result || result.isEmpty) {
35-
throw new Error("No configuration file found")
8+
throw new Error("[agent-chat-cli] No configuration file found")
369
}
3710

38-
return result.config as AgentChatConfig
11+
return result.config
3912
}

0 commit comments

Comments
 (0)