agent-switchboard 0.1.0 → 0.1.2
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/README.md +58 -11
- package/dist/agents/adapter.d.ts +4 -4
- package/dist/agents/claude-code.d.ts +3 -3
- package/dist/agents/claude-code.js +6 -6
- package/dist/agents/claude-code.js.map +1 -1
- package/dist/agents/claude-desktop.d.ts +3 -3
- package/dist/agents/claude-desktop.js +11 -11
- package/dist/agents/claude-desktop.js.map +1 -1
- package/dist/agents/codex.d.ts +5 -5
- package/dist/agents/codex.js +23 -27
- package/dist/agents/codex.js.map +1 -1
- package/dist/agents/cursor.d.ts +3 -3
- package/dist/agents/cursor.js +6 -6
- package/dist/agents/cursor.js.map +1 -1
- package/dist/agents/gemini.d.ts +3 -3
- package/dist/agents/gemini.js +6 -6
- package/dist/agents/gemini.js.map +1 -1
- package/dist/agents/json-utils.js +7 -4
- package/dist/agents/json-utils.js.map +1 -1
- package/dist/agents/opencode.d.ts +13 -0
- package/dist/agents/opencode.js +82 -0
- package/dist/agents/opencode.js.map +1 -0
- package/dist/agents/registry.d.ts +1 -1
- package/dist/agents/registry.js +8 -6
- package/dist/agents/registry.js.map +1 -1
- package/dist/config/mcp-config.d.ts +5 -5
- package/dist/config/mcp-config.js +38 -18
- package/dist/config/mcp-config.js.map +1 -1
- package/dist/config/paths.d.ts +9 -1
- package/dist/config/paths.js +18 -6
- package/dist/config/paths.js.map +1 -1
- package/dist/config/schemas.d.ts +40 -9
- package/dist/config/schemas.js +10 -2
- package/dist/config/schemas.js.map +1 -1
- package/dist/config/switchboard-config.d.ts +1 -1
- package/dist/config/switchboard-config.js +10 -8
- package/dist/config/switchboard-config.js.map +1 -1
- package/dist/index.js +210 -29
- package/dist/index.js.map +1 -1
- package/dist/rules/agents.d.ts +3 -0
- package/dist/rules/agents.js +3 -0
- package/dist/rules/agents.js.map +1 -0
- package/dist/rules/composer.d.ts +17 -0
- package/dist/rules/composer.js +71 -0
- package/dist/rules/composer.js.map +1 -0
- package/dist/rules/distribution.d.ts +21 -0
- package/dist/rules/distribution.js +127 -0
- package/dist/rules/distribution.js.map +1 -0
- package/dist/rules/index.d.ts +7 -0
- package/dist/rules/index.js +8 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/inventory.d.ts +17 -0
- package/dist/rules/inventory.js +66 -0
- package/dist/rules/inventory.js.map +1 -0
- package/dist/rules/library.d.ts +9 -0
- package/dist/rules/library.js +49 -0
- package/dist/rules/library.js.map +1 -0
- package/dist/rules/parser.d.ts +6 -0
- package/dist/rules/parser.js +49 -0
- package/dist/rules/parser.js.map +1 -0
- package/dist/rules/schema.d.ts +56 -0
- package/dist/rules/schema.js +22 -0
- package/dist/rules/schema.js.map +1 -0
- package/dist/rules/state.d.ts +5 -0
- package/dist/rules/state.js +71 -0
- package/dist/rules/state.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/ui/mcp-ui.d.ts +1 -1
- package/dist/ui/mcp-ui.js +14 -14
- package/dist/ui/mcp-ui.js.map +1 -1
- package/dist/ui/rule-ui.d.ts +5 -0
- package/dist/ui/rule-ui.js +154 -0
- package/dist/ui/rule-ui.js.map +1 -0
- package/package.json +16 -7
- package/dist/config/abs-config.d.ts +0 -21
- package/dist/config/abs-config.js +0 -67
- package/dist/config/abs-config.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
# Agent Switchboard
|
|
1
|
+
# Agent Switchboard
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Manage MCP servers in one place and apply them to local agents (Codex, Claude Code/Desktop, Gemini) and opencode.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
Requirements: Node.js >= 16
|
|
8
|
-
|
|
9
7
|
Global install:
|
|
10
8
|
|
|
11
9
|
```bash
|
|
@@ -25,8 +23,6 @@ npx agent-switchboard@latest mcp
|
|
|
25
23
|
|
|
26
24
|
```bash
|
|
27
25
|
agent-switchboard mcp
|
|
28
|
-
# or
|
|
29
|
-
asb mcp
|
|
30
26
|
```
|
|
31
27
|
|
|
32
28
|
That’s it. The tool updates `~/.agent-switchboard/mcp.json` and writes agent configs.
|
|
@@ -40,17 +36,68 @@ Create the file if it does not exist:
|
|
|
40
36
|
```toml
|
|
41
37
|
# ~/.agent-switchboard/config.toml
|
|
42
38
|
agents = ["codex", "cursor"]
|
|
39
|
+
|
|
40
|
+
[rules]
|
|
41
|
+
includeDelimiters = false
|
|
43
42
|
```
|
|
44
43
|
|
|
45
44
|
Supported agent IDs:
|
|
46
|
-
- `codex` — Codex CLI
|
|
47
|
-
- `cursor` — Cursor IDE
|
|
48
|
-
- `claude-code` — Claude Code CLI
|
|
49
|
-
- `claude-desktop` — Claude Desktop app
|
|
50
|
-
- `gemini` — Gemini CLI
|
|
45
|
+
- `codex` — Codex CLI
|
|
46
|
+
- `cursor` — Cursor IDE
|
|
47
|
+
- `claude-code` — Claude Code CLI
|
|
48
|
+
- `claude-desktop` — Claude Desktop app
|
|
49
|
+
- `gemini` — Gemini CLI
|
|
50
|
+
- `opencode` — opencode global config
|
|
51
|
+
|
|
52
|
+
Toggle `rules.includeDelimiters` to `true` if you want each snippet surrounded by markers such as:
|
|
53
|
+
```
|
|
54
|
+
<!-- your-rule-name:start -->
|
|
55
|
+
…
|
|
56
|
+
<!-- your-rule-name:end -->
|
|
57
|
+
```
|
|
51
58
|
|
|
52
59
|
Run `agent-switchboard mcp` again after updating the list.
|
|
53
60
|
|
|
61
|
+
## Rule Library (v0.1.2)
|
|
62
|
+
|
|
63
|
+
Rule snippets live in `~/.agent-switchboard/rules/` (respects `ASB_HOME`). Each snippet is a Markdown file and can include YAML frontmatter with `title`, `description`, `tags`, and `requires` fields. Example:
|
|
64
|
+
|
|
65
|
+
```markdown
|
|
66
|
+
---
|
|
67
|
+
title: Prompt Hygiene
|
|
68
|
+
tags:
|
|
69
|
+
- hygiene
|
|
70
|
+
requires:
|
|
71
|
+
- claude-code
|
|
72
|
+
---
|
|
73
|
+
Keep commit messages scoped to the change.
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Selecting and Ordering Rules
|
|
77
|
+
|
|
78
|
+
Use the interactive selector to choose the active snippets and adjust their order:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
agent-switchboard rule
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Once confirmed, Agent Switchboard composes the merged Markdown, stores the active order, and writes the document to:
|
|
85
|
+
- `~/.claude/CLAUDE.md`
|
|
86
|
+
- `~/.codex/AGENTS.md`
|
|
87
|
+
- `~/.gemini/AGENTS.md`
|
|
88
|
+
- `~/.config/opencode/AGENTS.md` (or `%APPDATA%/opencode/AGENTS.md` on Windows)
|
|
89
|
+
|
|
90
|
+
Unsupportive agents such as Claude Desktop and Cursor are reported and left untouched. Existing files are backed up to `<name>.bak` before overwriting. If you rerun the selector without changing the order, the tool still refreshes the destination files to overwrite any manual edits.
|
|
91
|
+
|
|
92
|
+
### Auditing Rules
|
|
93
|
+
|
|
94
|
+
See the full inventory, activation state, and per-agent sync timestamps:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
agent-switchboard rule list
|
|
98
|
+
agent-switchboard rule list --json
|
|
99
|
+
```
|
|
100
|
+
|
|
54
101
|
## License
|
|
55
102
|
|
|
56
103
|
MIT
|
package/dist/agents/adapter.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Agent adapter interface
|
|
3
3
|
* Implements the strategy pattern for different agent config formats
|
|
4
4
|
*/
|
|
5
|
-
import type { McpServer } from
|
|
5
|
+
import type { McpServer } from '../config/schemas.js';
|
|
6
6
|
/**
|
|
7
7
|
* Agent adapter interface
|
|
8
8
|
* Each agent (Claude Code, Codex, Cursor, etc.) implements this interface
|
|
@@ -23,10 +23,10 @@ export interface AgentAdapter {
|
|
|
23
23
|
/**
|
|
24
24
|
* Applies MCP config to the agent's config file
|
|
25
25
|
* - Merges with existing config (preserves unknown fields)
|
|
26
|
-
* - The '
|
|
27
|
-
* @param config - MCP servers to apply (without '
|
|
26
|
+
* - The 'enabled' field is excluded from the input
|
|
27
|
+
* @param config - MCP servers to apply (without 'enabled')
|
|
28
28
|
*/
|
|
29
29
|
applyConfig(config: {
|
|
30
|
-
mcpServers: Record<string, Omit<McpServer,
|
|
30
|
+
mcpServers: Record<string, Omit<McpServer, 'enabled'>>;
|
|
31
31
|
}): void;
|
|
32
32
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Claude Code agent adapter
|
|
3
3
|
* Manages MCP server configuration for Claude Code CLI
|
|
4
4
|
*/
|
|
5
|
-
import type { McpServer } from
|
|
6
|
-
import type { AgentAdapter } from
|
|
5
|
+
import type { McpServer } from '../config/schemas.js';
|
|
6
|
+
import type { AgentAdapter } from './adapter.js';
|
|
7
7
|
/**
|
|
8
8
|
* Claude Code agent adapter
|
|
9
9
|
* Config location: ~/.claude.json
|
|
@@ -12,6 +12,6 @@ export declare class ClaudeCodeAgent implements AgentAdapter {
|
|
|
12
12
|
readonly id: "claude-code";
|
|
13
13
|
configPath(): string;
|
|
14
14
|
applyConfig(config: {
|
|
15
|
-
mcpServers: Record<string, Omit<McpServer,
|
|
15
|
+
mcpServers: Record<string, Omit<McpServer, 'enabled'>>;
|
|
16
16
|
}): void;
|
|
17
17
|
}
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
* Claude Code agent adapter
|
|
3
3
|
* Manages MCP server configuration for Claude Code CLI
|
|
4
4
|
*/
|
|
5
|
-
import os from
|
|
6
|
-
import path from
|
|
7
|
-
import { loadJsonFile, saveJsonFile,
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { loadJsonFile, mergeMcpIntoAgent, saveJsonFile, } from './json-utils.js';
|
|
8
8
|
/**
|
|
9
9
|
* Claude Code agent adapter
|
|
10
10
|
* Config location: ~/.claude.json
|
|
11
11
|
*/
|
|
12
12
|
export class ClaudeCodeAgent {
|
|
13
|
-
id =
|
|
13
|
+
id = 'claude-code';
|
|
14
14
|
configPath() {
|
|
15
|
-
const base =
|
|
15
|
+
const base = process.env.ASB_AGENTS_HOME && process.env.ASB_AGENTS_HOME.trim().length > 0
|
|
16
16
|
? process.env.ASB_AGENTS_HOME
|
|
17
17
|
: os.homedir();
|
|
18
|
-
return path.join(base,
|
|
18
|
+
return path.join(base, '.claude.json');
|
|
19
19
|
}
|
|
20
20
|
applyConfig(config) {
|
|
21
21
|
const path = this.configPath();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../../src/agents/claude-code.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,
|
|
1
|
+
{"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../../src/agents/claude-code.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAEL,YAAY,EACZ,iBAAiB,EACjB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB;;;GAGG;AACH,MAAM,OAAO,eAAe;IACjB,EAAE,GAAG,aAAsB,CAAC;IAErC,UAAU;QACR,MAAM,IAAI,GACR,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;YAC1E,CAAC,CAAE,OAAO,CAAC,GAAG,CAAC,eAA0B;YACzC,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IACzC,CAAC;IAED,WAAW,CAAC,MAAkE;QAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAC/B,MAAM,WAAW,GAAG,YAAY,CAAkB,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5E,MAAM,MAAM,GAAG,iBAAiB,CAAC,WAAW,EAAE,MAAM,CAAC,UAAoC,CAAC,CAAC;QAC3F,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Claude Desktop agent adapter
|
|
3
3
|
* Manages MCP server configuration for Claude Desktop app
|
|
4
4
|
*/
|
|
5
|
-
import type { McpServer } from
|
|
6
|
-
import type { AgentAdapter } from
|
|
5
|
+
import type { McpServer } from '../config/schemas.js';
|
|
6
|
+
import type { AgentAdapter } from './adapter.js';
|
|
7
7
|
/**
|
|
8
8
|
* Claude Desktop config file structure
|
|
9
9
|
*/
|
|
@@ -18,6 +18,6 @@ export declare class ClaudeDesktopAgent implements AgentAdapter {
|
|
|
18
18
|
readonly id: "claude-desktop";
|
|
19
19
|
configPath(): string;
|
|
20
20
|
applyConfig(config: {
|
|
21
|
-
mcpServers: Record<string, Omit<McpServer,
|
|
21
|
+
mcpServers: Record<string, Omit<McpServer, 'enabled'>>;
|
|
22
22
|
}): void;
|
|
23
23
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Claude Desktop agent adapter
|
|
3
3
|
* Manages MCP server configuration for Claude Desktop app
|
|
4
4
|
*/
|
|
5
|
-
import os from
|
|
6
|
-
import path from
|
|
7
|
-
import { loadJsonFile, saveJsonFile,
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { loadJsonFile, mergeMcpIntoAgent, saveJsonFile, } from './json-utils.js';
|
|
8
8
|
/**
|
|
9
9
|
* Claude Desktop config file structure
|
|
10
10
|
*/
|
|
@@ -17,19 +17,19 @@ import { loadJsonFile, saveJsonFile, mergeMcpIntoAgent } from "./json-utils.js";
|
|
|
17
17
|
* - Windows: %APPDATA%\Claude\claude_desktop_config.json
|
|
18
18
|
*/
|
|
19
19
|
export class ClaudeDesktopAgent {
|
|
20
|
-
id =
|
|
20
|
+
id = 'claude-desktop';
|
|
21
21
|
configPath() {
|
|
22
22
|
const platform = os.platform();
|
|
23
|
-
const home =
|
|
23
|
+
const home = process.env.ASB_AGENTS_HOME && process.env.ASB_AGENTS_HOME.trim().length > 0
|
|
24
24
|
? process.env.ASB_AGENTS_HOME
|
|
25
25
|
: os.homedir();
|
|
26
26
|
switch (platform) {
|
|
27
|
-
case
|
|
28
|
-
return path.join(home,
|
|
29
|
-
case
|
|
30
|
-
return path.join(home,
|
|
31
|
-
case
|
|
32
|
-
return path.join(home,
|
|
27
|
+
case 'darwin': // macOS
|
|
28
|
+
return path.join(home, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
|
|
29
|
+
case 'win32': // Windows
|
|
30
|
+
return path.join(home, 'AppData', 'Roaming', 'Claude', 'claude_desktop_config.json');
|
|
31
|
+
case 'linux': // Linux
|
|
32
|
+
return path.join(home, '.config', 'Claude', 'claude_desktop_config.json');
|
|
33
33
|
default:
|
|
34
34
|
throw new Error(`Unsupported platform: ${platform}`);
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-desktop.js","sourceRoot":"","sources":["../../src/agents/claude-desktop.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"claude-desktop.js","sourceRoot":"","sources":["../../src/agents/claude-desktop.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAEL,YAAY,EACZ,iBAAiB,EACjB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,8BAA8B;AAE9B;;;;;;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.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Codex CLI Agent Adapter
|
|
3
3
|
* Handles TOML-based configuration with canonical section output
|
|
4
4
|
*/
|
|
5
|
-
import type { McpServer } from
|
|
6
|
-
import type { AgentAdapter } from
|
|
5
|
+
import type { McpServer } from '../config/schemas.js';
|
|
6
|
+
import type { AgentAdapter } from './adapter.js';
|
|
7
7
|
/**
|
|
8
8
|
* Codex CLI agent adapter
|
|
9
9
|
* Config: ~/.codex/config.toml (TOML format)
|
|
@@ -12,7 +12,7 @@ export declare class CodexAgent implements AgentAdapter {
|
|
|
12
12
|
readonly id: "codex";
|
|
13
13
|
configPath(): string;
|
|
14
14
|
applyConfig(config: {
|
|
15
|
-
mcpServers: Record<string, Omit<McpServer,
|
|
15
|
+
mcpServers: Record<string, Omit<McpServer, 'enabled'>>;
|
|
16
16
|
}): void;
|
|
17
17
|
private _loadConfig;
|
|
18
18
|
private _saveConfig;
|
|
@@ -21,7 +21,7 @@ export declare class CodexAgent implements AgentAdapter {
|
|
|
21
21
|
* Merge MCP server config into TOML content
|
|
22
22
|
* Preserves unrelated top-level tables/keys; rewrites mcp_servers in canonical form
|
|
23
23
|
*/
|
|
24
|
-
export declare function mergeConfig(content: string, mcpServers: Record<string, Omit<McpServer,
|
|
24
|
+
export declare function mergeConfig(content: string, mcpServers: Record<string, Omit<McpServer, 'enabled'>>): string;
|
|
25
25
|
/**
|
|
26
26
|
* Minimal shape for a Codex MCP server entry used by the renderer
|
|
27
27
|
*/
|
|
@@ -39,4 +39,4 @@ export type McpServerLike = Record<string, unknown> & {
|
|
|
39
39
|
* Key order per server: command, args, url, type, env_file, env.* (alpha), unknown (alpha)
|
|
40
40
|
* Exactly one blank line between server tables; final newline added by caller
|
|
41
41
|
*/
|
|
42
|
-
export declare function buildNestedToml(mcpServers: Record<string, Omit<McpServerLike,
|
|
42
|
+
export declare function buildNestedToml(mcpServers: Record<string, Omit<McpServerLike, 'enabled'>>): string;
|
package/dist/agents/codex.js
CHANGED
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
* Codex CLI Agent Adapter
|
|
3
3
|
* Handles TOML-based configuration with canonical section output
|
|
4
4
|
*/
|
|
5
|
-
import fs from
|
|
6
|
-
import os from
|
|
7
|
-
import path from
|
|
8
|
-
import { parse as parseToml, stringify as tomlStringify } from
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { parse as parseToml, stringify as tomlStringify } from '@iarna/toml';
|
|
9
9
|
/**
|
|
10
10
|
* Codex CLI agent adapter
|
|
11
11
|
* Config: ~/.codex/config.toml (TOML format)
|
|
12
12
|
*/
|
|
13
13
|
export class CodexAgent {
|
|
14
|
-
id =
|
|
14
|
+
id = 'codex';
|
|
15
15
|
configPath() {
|
|
16
|
-
const base =
|
|
16
|
+
const base = process.env.ASB_AGENTS_HOME && process.env.ASB_AGENTS_HOME.trim().length > 0
|
|
17
17
|
? process.env.ASB_AGENTS_HOME
|
|
18
18
|
: os.homedir();
|
|
19
|
-
return path.join(base,
|
|
19
|
+
return path.join(base, '.codex', 'config.toml');
|
|
20
20
|
}
|
|
21
21
|
applyConfig(config) {
|
|
22
22
|
const content = this._loadConfig();
|
|
@@ -26,9 +26,9 @@ export class CodexAgent {
|
|
|
26
26
|
_loadConfig() {
|
|
27
27
|
const configPath = this.configPath();
|
|
28
28
|
if (!fs.existsSync(configPath)) {
|
|
29
|
-
return
|
|
29
|
+
return '';
|
|
30
30
|
}
|
|
31
|
-
return fs.readFileSync(configPath,
|
|
31
|
+
return fs.readFileSync(configPath, 'utf-8');
|
|
32
32
|
}
|
|
33
33
|
_saveConfig(content) {
|
|
34
34
|
const configPath = this.configPath();
|
|
@@ -36,7 +36,7 @@ export class CodexAgent {
|
|
|
36
36
|
if (!fs.existsSync(dirPath)) {
|
|
37
37
|
fs.mkdirSync(dirPath, { recursive: true });
|
|
38
38
|
}
|
|
39
|
-
fs.writeFileSync(configPath, content,
|
|
39
|
+
fs.writeFileSync(configPath, content, 'utf-8');
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
@@ -61,21 +61,22 @@ export function mergeConfig(content, mcpServers) {
|
|
|
61
61
|
// Build canonical mcp_servers TOML from provided config
|
|
62
62
|
const mcpToml = buildNestedToml(mcpServers);
|
|
63
63
|
// Stringify other top-level tables/keys via iarna/toml
|
|
64
|
-
let otherToml =
|
|
64
|
+
let otherToml = '';
|
|
65
65
|
try {
|
|
66
66
|
if (Object.keys(otherTopLevel).length > 0) {
|
|
67
|
+
// Cast to JsonMap type expected by tomlStringify
|
|
67
68
|
otherToml = tomlStringify(otherTopLevel);
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
catch {
|
|
71
|
-
otherToml =
|
|
72
|
+
otherToml = '';
|
|
72
73
|
}
|
|
73
74
|
const parts = [];
|
|
74
75
|
if (otherToml.trim().length > 0)
|
|
75
76
|
parts.push(otherToml.trimEnd());
|
|
76
77
|
if (mcpToml.trim().length > 0)
|
|
77
78
|
parts.push(mcpToml.trimEnd());
|
|
78
|
-
return parts.join(
|
|
79
|
+
return `${parts.join('\n\n')}\n`;
|
|
79
80
|
}
|
|
80
81
|
/**
|
|
81
82
|
* Build canonical TOML: one table per server [mcp_servers.<name>]
|
|
@@ -90,46 +91,41 @@ export function buildNestedToml(mcpServers) {
|
|
|
90
91
|
const name = serverNames[idx];
|
|
91
92
|
const server = (mcpServers[name] ?? {});
|
|
92
93
|
lines.push(`[mcp_servers.${name}]`);
|
|
93
|
-
const KNOWN_ORDER = [
|
|
94
|
-
"command",
|
|
95
|
-
"args",
|
|
96
|
-
"url",
|
|
97
|
-
"type",
|
|
98
|
-
"env_file",
|
|
99
|
-
];
|
|
94
|
+
const KNOWN_ORDER = ['command', 'args', 'url', 'type', 'env_file'];
|
|
100
95
|
const emit = (k, v) => {
|
|
101
96
|
if (v === undefined || v === null)
|
|
102
97
|
return;
|
|
103
98
|
// Only allow primitives and primitive arrays
|
|
104
|
-
const isPrim = (x) => typeof x ===
|
|
99
|
+
const isPrim = (x) => typeof x === 'string' || typeof x === 'number' || typeof x === 'boolean';
|
|
105
100
|
const isPrimArr = (x) => Array.isArray(x) && x.every(isPrim);
|
|
106
101
|
if (!isPrim(v) && !isPrimArr(v))
|
|
107
102
|
return;
|
|
108
103
|
// @iarna/toml value formatting for RHS
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
const rhs = 'value' in tomlStringify
|
|
105
|
+
? tomlStringify.value(v)
|
|
106
|
+
: JSON.stringify(v);
|
|
111
107
|
lines.push(`${k} = ${rhs}`);
|
|
112
108
|
};
|
|
113
109
|
// Known keys
|
|
114
110
|
for (const k of KNOWN_ORDER)
|
|
115
111
|
emit(k, server[k]);
|
|
116
112
|
// env dotted keys (alphabetical)
|
|
117
|
-
if (server.env && typeof server.env ===
|
|
113
|
+
if (server.env && typeof server.env === 'object') {
|
|
118
114
|
const envEntries = Object.entries(server.env).filter(([_, v]) => v !== undefined && v !== null);
|
|
119
115
|
envEntries.sort(([a], [b]) => a.localeCompare(b));
|
|
120
116
|
for (const [ek, ev] of envEntries)
|
|
121
117
|
emit(`env.${ek}`, String(ev));
|
|
122
118
|
}
|
|
123
119
|
// Unknown keys (exclude known + env)
|
|
124
|
-
const knownSet = new Set([...KNOWN_ORDER.map(String),
|
|
120
|
+
const knownSet = new Set([...KNOWN_ORDER.map(String), 'env']);
|
|
125
121
|
const unknownKeys = Object.keys(server)
|
|
126
122
|
.filter((k) => !knownSet.has(k))
|
|
127
123
|
.sort((a, b) => a.localeCompare(b));
|
|
128
124
|
for (const uk of unknownKeys)
|
|
129
125
|
emit(uk, server[uk]);
|
|
130
126
|
if (idx !== serverNames.length - 1)
|
|
131
|
-
lines.push(
|
|
127
|
+
lines.push(''); // blank line between servers
|
|
132
128
|
}
|
|
133
|
-
return lines.join(
|
|
129
|
+
return lines.join('\n');
|
|
134
130
|
}
|
|
135
131
|
//# sourceMappingURL=codex.js.map
|
package/dist/agents/codex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/agents/codex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,aAAa,CAAC;AAI7E;;;GAGG;AACH,MAAM,OAAO,UAAU;
|
|
1
|
+
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/agents/codex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,aAAa,CAAC;AAI7E;;;GAGG;AACH,MAAM,OAAO,UAAU;IACZ,EAAE,GAAG,OAAgB,CAAC;IAE/B,UAAU;QACR,MAAM,IAAI,GACR,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;YAC1E,CAAC,CAAE,OAAO,CAAC,GAAG,CAAC,eAA0B;YACzC,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;IAClD,CAAC;IAED,WAAW,CAAC,MAAkE;QAC5E,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;QACxD,IAAI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CAAC,KAAK,IAAI,CAC1C,CAAC;YACF,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;YAClD,KAAK,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,UAAU;gBAAE,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QACnE,CAAC;QAED,qCAAqC;QACrC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAS,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;QACtE,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;aACpC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;aAC/B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QACtC,KAAK,MAAM,EAAE,IAAI,WAAW;YAAE,IAAI,CAAC,EAAE,EAAG,MAAkC,CAAC,EAAE,CAAC,CAAC,CAAC;QAEhF,IAAI,GAAG,KAAK,WAAW,CAAC,MAAM,GAAG,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,6BAA6B;IACnF,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/agents/cursor.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Cursor agent adapter
|
|
3
3
|
* Manages MCP server configuration for Cursor IDE
|
|
4
4
|
*/
|
|
5
|
-
import type { McpServer } from
|
|
6
|
-
import type { AgentAdapter } from
|
|
5
|
+
import type { McpServer } from '../config/schemas.js';
|
|
6
|
+
import type { AgentAdapter } from './adapter.js';
|
|
7
7
|
/**
|
|
8
8
|
* Cursor config file structure
|
|
9
9
|
*/
|
|
@@ -15,6 +15,6 @@ export declare class CursorAgent implements AgentAdapter {
|
|
|
15
15
|
readonly id: "cursor";
|
|
16
16
|
configPath(): string;
|
|
17
17
|
applyConfig(config: {
|
|
18
|
-
mcpServers: Record<string, Omit<McpServer,
|
|
18
|
+
mcpServers: Record<string, Omit<McpServer, 'enabled'>>;
|
|
19
19
|
}): void;
|
|
20
20
|
}
|
package/dist/agents/cursor.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Cursor agent adapter
|
|
3
3
|
* Manages MCP server configuration for Cursor IDE
|
|
4
4
|
*/
|
|
5
|
-
import os from
|
|
6
|
-
import path from
|
|
7
|
-
import { loadJsonFile, saveJsonFile,
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { loadJsonFile, mergeMcpIntoAgent, saveJsonFile, } from './json-utils.js';
|
|
8
8
|
/**
|
|
9
9
|
* Cursor config file structure
|
|
10
10
|
*/
|
|
@@ -14,12 +14,12 @@ import { loadJsonFile, saveJsonFile, mergeMcpIntoAgent } from "./json-utils.js";
|
|
|
14
14
|
* Config location: ~/.cursor/mcp.json
|
|
15
15
|
*/
|
|
16
16
|
export class CursorAgent {
|
|
17
|
-
id =
|
|
17
|
+
id = 'cursor';
|
|
18
18
|
configPath() {
|
|
19
|
-
const base =
|
|
19
|
+
const base = process.env.ASB_AGENTS_HOME && process.env.ASB_AGENTS_HOME.trim().length > 0
|
|
20
20
|
? process.env.ASB_AGENTS_HOME
|
|
21
21
|
: os.homedir();
|
|
22
|
-
return path.join(base,
|
|
22
|
+
return path.join(base, '.cursor', 'mcp.json');
|
|
23
23
|
}
|
|
24
24
|
applyConfig(config) {
|
|
25
25
|
const path = this.configPath();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursor.js","sourceRoot":"","sources":["../../src/agents/cursor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"cursor.js","sourceRoot":"","sources":["../../src/agents/cursor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAEL,YAAY,EACZ,iBAAiB,EACjB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,8BAA8B;AAE9B;;;GAGG;AACH,MAAM,OAAO,WAAW;IACb,EAAE,GAAG,QAAiB,CAAC;IAEhC,UAAU;QACR,MAAM,IAAI,GACR,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;YAC1E,CAAC,CAAE,OAAO,CAAC,GAAG,CAAC,eAA0B;YACzC,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC;IAED,WAAW,CAAC,MAAkE;QAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAC/B,MAAM,WAAW,GAAG,YAAY,CAAkB,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5E,MAAM,MAAM,GAAG,iBAAiB,CAAC,WAAW,EAAE,MAAM,CAAC,UAAoC,CAAC,CAAC;QAC3F,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
package/dist/agents/gemini.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Gemini CLI agent adapter
|
|
3
3
|
* Manages MCP server configuration for Gemini CLI
|
|
4
4
|
*/
|
|
5
|
-
import type { McpServer } from
|
|
6
|
-
import type { AgentAdapter } from
|
|
5
|
+
import type { McpServer } from '../config/schemas.js';
|
|
6
|
+
import type { AgentAdapter } from './adapter.js';
|
|
7
7
|
/**
|
|
8
8
|
* Gemini CLI config file structure
|
|
9
9
|
*/
|
|
@@ -15,6 +15,6 @@ export declare class GeminiAgent implements AgentAdapter {
|
|
|
15
15
|
readonly id: "gemini";
|
|
16
16
|
configPath(): string;
|
|
17
17
|
applyConfig(config: {
|
|
18
|
-
mcpServers: Record<string, Omit<McpServer,
|
|
18
|
+
mcpServers: Record<string, Omit<McpServer, 'enabled'>>;
|
|
19
19
|
}): void;
|
|
20
20
|
}
|
package/dist/agents/gemini.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Gemini CLI agent adapter
|
|
3
3
|
* Manages MCP server configuration for Gemini CLI
|
|
4
4
|
*/
|
|
5
|
-
import os from
|
|
6
|
-
import path from
|
|
7
|
-
import { loadJsonFile, saveJsonFile,
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { loadJsonFile, mergeMcpIntoAgent, saveJsonFile, } from './json-utils.js';
|
|
8
8
|
/**
|
|
9
9
|
* Gemini CLI config file structure
|
|
10
10
|
*/
|
|
@@ -14,12 +14,12 @@ import { loadJsonFile, saveJsonFile, mergeMcpIntoAgent } from "./json-utils.js";
|
|
|
14
14
|
* Config location: ~/.gemini/settings.json
|
|
15
15
|
*/
|
|
16
16
|
export class GeminiAgent {
|
|
17
|
-
id =
|
|
17
|
+
id = 'gemini';
|
|
18
18
|
configPath() {
|
|
19
|
-
const base =
|
|
19
|
+
const base = process.env.ASB_AGENTS_HOME && process.env.ASB_AGENTS_HOME.trim().length > 0
|
|
20
20
|
? process.env.ASB_AGENTS_HOME
|
|
21
21
|
: os.homedir();
|
|
22
|
-
return path.join(base,
|
|
22
|
+
return path.join(base, '.gemini', 'settings.json');
|
|
23
23
|
}
|
|
24
24
|
applyConfig(config) {
|
|
25
25
|
const path = this.configPath();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../src/agents/gemini.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../src/agents/gemini.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAEL,YAAY,EACZ,iBAAiB,EACjB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,8BAA8B;AAE9B;;;GAGG;AACH,MAAM,OAAO,WAAW;IACb,EAAE,GAAG,QAAiB,CAAC;IAEhC,UAAU;QACR,MAAM,IAAI,GACR,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;YAC1E,CAAC,CAAE,OAAO,CAAC,GAAG,CAAC,eAA0B;YACzC,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;IACrD,CAAC;IAED,WAAW,CAAC,MAAkE;QAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAC/B,MAAM,WAAW,GAAG,YAAY,CAAkB,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5E,MAAM,MAAM,GAAG,iBAAiB,CAAC,WAAW,EAAE,MAAM,CAAC,UAAoC,CAAC,CAAC;QAC3F,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared JSON file helpers for agent adapters
|
|
3
3
|
*/
|
|
4
|
-
import fs from
|
|
4
|
+
import fs from 'node:fs';
|
|
5
5
|
export function loadJsonFile(filePath, fallback) {
|
|
6
6
|
if (!fs.existsSync(filePath))
|
|
7
7
|
return fallback;
|
|
8
|
-
const content = fs.readFileSync(filePath,
|
|
8
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
9
9
|
return JSON.parse(content);
|
|
10
10
|
}
|
|
11
11
|
export function saveJsonFile(filePath, data) {
|
|
12
12
|
const json = `${JSON.stringify(data, null, 2)}\n`;
|
|
13
|
-
fs.writeFileSync(filePath, json,
|
|
13
|
+
fs.writeFileSync(filePath, json, 'utf-8');
|
|
14
14
|
}
|
|
15
15
|
export function mergeMcpIntoAgent(agentConfig, mcpServers) {
|
|
16
16
|
if (Object.keys(mcpServers).length === 0)
|
|
17
17
|
return agentConfig;
|
|
18
18
|
const merged = { ...agentConfig };
|
|
19
|
-
|
|
19
|
+
if (!merged.mcpServers) {
|
|
20
|
+
merged.mcpServers = {};
|
|
21
|
+
}
|
|
22
|
+
const target = merged.mcpServers;
|
|
20
23
|
for (const [name, server] of Object.entries(mcpServers)) {
|
|
21
24
|
const existing = target[name] ?? {};
|
|
22
25
|
target[name] = { ...existing, ...server };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-utils.js","sourceRoot":"","sources":["../../src/agents/json-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AAIzB,MAAM,UAAU,YAAY,CAAmB,QAAgB,EAAE,QAAW;IAC1E,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC9C,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAA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,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,WAAW,CAAC;IAE7D,MAAM,MAAM,GAAoB,EAAE,GAAG,WAAW,EAAE,CAAC;IACnD,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACvB,MAAM,CAAC,UAAU,GAAG,EAAE,CAAC;IACzB,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC;IAEjC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACxD,MAAM,QAAQ,GAAI,MAAM,CAAC,IAAI,CAA6B,IAAI,EAAE,CAAC;QACjE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC;IAC5C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* opencode agent adapter
|
|
3
|
+
* Synchronizes MCP servers into ~/.config/opencode/opencode.json
|
|
4
|
+
*/
|
|
5
|
+
import type { McpServer } from '../config/schemas.js';
|
|
6
|
+
import type { AgentAdapter } from './adapter.js';
|
|
7
|
+
export declare class OpencodeAgent implements AgentAdapter {
|
|
8
|
+
readonly id: "opencode";
|
|
9
|
+
configPath(): string;
|
|
10
|
+
applyConfig(config: {
|
|
11
|
+
mcpServers: Record<string, Omit<McpServer, 'enabled'>>;
|
|
12
|
+
}): void;
|
|
13
|
+
}
|