@anaclumos/taal 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/providers/claude-code.ts +66 -0
package/package.json
CHANGED
|
@@ -1,14 +1,80 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
1
3
|
import { join } from "node:path";
|
|
2
4
|
import type { McpServer } from "../config/schema.js";
|
|
3
5
|
import { BaseProvider } from "./base.js";
|
|
6
|
+
import {
|
|
7
|
+
readConfig as readConfigUtil,
|
|
8
|
+
writeConfig as writeConfigUtil,
|
|
9
|
+
} from "./utils.js";
|
|
4
10
|
|
|
5
11
|
export class ClaudeCodeProvider extends BaseProvider {
|
|
6
12
|
name = "claude-code";
|
|
7
13
|
configPath = (home: string) => join(home, ".claude", "settings.json");
|
|
14
|
+
secondaryConfigPath = (home: string) => join(home, ".claude.json");
|
|
8
15
|
format = "json" as const;
|
|
9
16
|
mcpKey = "mcpServers";
|
|
10
17
|
skillsPath = (home: string) => join(home, ".claude", "skills");
|
|
11
18
|
|
|
19
|
+
override async isInstalled(home?: string): Promise<boolean> {
|
|
20
|
+
const homeDir = home || homedir();
|
|
21
|
+
const secondaryPath = this.secondaryConfigPath(homeDir);
|
|
22
|
+
return existsSync(join(homeDir, ".claude")) || existsSync(secondaryPath);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override async readConfig(home?: string): Promise<unknown> {
|
|
26
|
+
const homeDir = home || homedir();
|
|
27
|
+
const primaryPath = this.configPath(homeDir);
|
|
28
|
+
const secondaryPath = this.secondaryConfigPath(homeDir);
|
|
29
|
+
|
|
30
|
+
const primaryConfig = readConfigUtil(primaryPath, this.format) as Record<
|
|
31
|
+
string,
|
|
32
|
+
unknown
|
|
33
|
+
>;
|
|
34
|
+
const secondaryConfig = readConfigUtil(
|
|
35
|
+
secondaryPath,
|
|
36
|
+
this.format
|
|
37
|
+
) as Record<string, unknown>;
|
|
38
|
+
|
|
39
|
+
const primaryServers = (primaryConfig.mcpServers || {}) as Record<
|
|
40
|
+
string,
|
|
41
|
+
unknown
|
|
42
|
+
>;
|
|
43
|
+
const secondaryServers = (secondaryConfig.mcpServers || {}) as Record<
|
|
44
|
+
string,
|
|
45
|
+
unknown
|
|
46
|
+
>;
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
...primaryConfig,
|
|
50
|
+
mcpServers: {
|
|
51
|
+
...secondaryServers,
|
|
52
|
+
...primaryServers,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
override async writeConfig(config: unknown, home?: string): Promise<void> {
|
|
58
|
+
const homeDir = home || homedir();
|
|
59
|
+
const primaryPath = this.configPath(homeDir);
|
|
60
|
+
const secondaryPath = this.secondaryConfigPath(homeDir);
|
|
61
|
+
|
|
62
|
+
const configObj = config as Record<string, unknown>;
|
|
63
|
+
|
|
64
|
+
writeConfigUtil(primaryPath, this.format, configObj);
|
|
65
|
+
|
|
66
|
+
const existingSecondary = readConfigUtil(
|
|
67
|
+
secondaryPath,
|
|
68
|
+
this.format
|
|
69
|
+
) as Record<string, unknown>;
|
|
70
|
+
|
|
71
|
+
const secondaryConfig = {
|
|
72
|
+
...existingSecondary,
|
|
73
|
+
mcpServers: configObj.mcpServers,
|
|
74
|
+
};
|
|
75
|
+
writeConfigUtil(secondaryPath, this.format, secondaryConfig);
|
|
76
|
+
}
|
|
77
|
+
|
|
12
78
|
transformMcpServers(
|
|
13
79
|
servers: Record<string, McpServer>
|
|
14
80
|
): Record<string, unknown> {
|