agent-switchboard 0.1.3 → 0.1.4
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 +43 -10
- package/dist/commands/distribution.d.ts +2 -1
- package/dist/commands/distribution.js +3 -2
- package/dist/commands/distribution.js.map +1 -1
- package/dist/commands/inventory.d.ts +2 -1
- package/dist/commands/inventory.js +2 -2
- package/dist/commands/inventory.js.map +1 -1
- package/dist/config/layered-config.d.ts +27 -0
- package/dist/config/layered-config.js +132 -0
- package/dist/config/layered-config.js.map +1 -0
- package/dist/config/paths.d.ts +9 -4
- package/dist/config/paths.js +17 -6
- package/dist/config/paths.js.map +1 -1
- package/dist/config/schemas.d.ts +225 -23
- package/dist/config/schemas.js +41 -8
- package/dist/config/schemas.js.map +1 -1
- package/dist/config/scope.d.ts +6 -0
- package/dist/config/scope.js +17 -0
- package/dist/config/scope.js.map +1 -0
- package/dist/config/switchboard-config.d.ts +9 -1
- package/dist/config/switchboard-config.js +7 -22
- package/dist/config/switchboard-config.js.map +1 -1
- package/dist/index.js +215 -42
- package/dist/index.js.map +1 -1
- package/dist/library/distribute.d.ts +2 -0
- package/dist/library/distribute.js +2 -2
- package/dist/library/distribute.js.map +1 -1
- package/dist/library/state.d.ts +4 -3
- package/dist/library/state.js +40 -43
- package/dist/library/state.js.map +1 -1
- package/dist/rules/composer.d.ts +2 -1
- package/dist/rules/composer.js +9 -3
- package/dist/rules/composer.js.map +1 -1
- package/dist/rules/distribution.d.ts +2 -1
- package/dist/rules/distribution.js +4 -4
- package/dist/rules/distribution.js.map +1 -1
- package/dist/rules/inventory.d.ts +2 -1
- package/dist/rules/inventory.js +2 -2
- package/dist/rules/inventory.js.map +1 -1
- package/dist/rules/state.d.ts +4 -3
- package/dist/rules/state.js +39 -44
- package/dist/rules/state.js.map +1 -1
- package/dist/subagents/distribution.d.ts +2 -1
- package/dist/subagents/distribution.js +3 -2
- package/dist/subagents/distribution.js.map +1 -1
- package/dist/subagents/inventory.d.ts +2 -1
- package/dist/subagents/inventory.js +2 -2
- package/dist/subagents/inventory.js.map +1 -1
- package/dist/ui/command-ui.d.ts +2 -1
- package/dist/ui/command-ui.js +2 -1
- package/dist/ui/command-ui.js.map +1 -1
- package/dist/ui/fuzzy-multi-select.d.ts +18 -0
- package/dist/ui/fuzzy-multi-select.js +276 -0
- package/dist/ui/fuzzy-multi-select.js.map +1 -0
- package/dist/ui/library-selector.d.ts +2 -0
- package/dist/ui/library-selector.js +46 -30
- package/dist/ui/library-selector.js.map +1 -1
- package/dist/ui/rule-ui.d.ts +2 -1
- package/dist/ui/rule-ui.js +66 -54
- package/dist/ui/rule-ui.js.map +1 -1
- package/dist/ui/subagent-ui.d.ts +2 -1
- package/dist/ui/subagent-ui.js +2 -1
- package/dist/ui/subagent-ui.js.map +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -60,6 +60,29 @@ Toggle `rules.includeDelimiters` to `true` if you want each snippet surrounded b
|
|
|
60
60
|
|
|
61
61
|
Run `agent-switchboard mcp` again after updating the list.
|
|
62
62
|
|
|
63
|
+
### Layered configuration & scope
|
|
64
|
+
|
|
65
|
+
Agent Switchboard merges configuration from three TOML layers (higher priority wins):
|
|
66
|
+
|
|
67
|
+
- **User default**: `<ASB_HOME>/config.toml`
|
|
68
|
+
- **Profile**: `<ASB_HOME>/<profile>.toml`
|
|
69
|
+
- **Project**: `<project>/.asb.toml`
|
|
70
|
+
|
|
71
|
+
Every layer can define `[commands]`, `[subagents]`, and `[rules]` `active` lists. Use profiles to share team presets and project files to override per repository. The CLI honors these layers via scope flags:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Profile only
|
|
75
|
+
agent-switchboard command -p team
|
|
76
|
+
|
|
77
|
+
# Project only
|
|
78
|
+
agent-switchboard rule --project /path/to/repo
|
|
79
|
+
|
|
80
|
+
# Merge profile + project
|
|
81
|
+
agent-switchboard subagent -p team --project /path/to/repo
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`ASB_HOME` still defaults to `~/.agent-switchboard` but can be overridden through the environment variable.
|
|
85
|
+
|
|
63
86
|
## Rule Library
|
|
64
87
|
|
|
65
88
|
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:
|
|
@@ -77,13 +100,13 @@ Keep commit messages scoped to the change.
|
|
|
77
100
|
|
|
78
101
|
### Selecting and Ordering Rules
|
|
79
102
|
|
|
80
|
-
Use the interactive selector to choose the active snippets and adjust their order:
|
|
103
|
+
Use the interactive selector (arrow keys, `Space` to toggle, just start typing to fuzzy filter) to choose the active snippets and adjust their order:
|
|
81
104
|
|
|
82
105
|
```bash
|
|
83
|
-
agent-switchboard rule
|
|
106
|
+
agent-switchboard rule [-p <profile>] [--project <path>]
|
|
84
107
|
```
|
|
85
108
|
|
|
86
|
-
Once confirmed, Agent Switchboard composes the merged Markdown, stores the active order, and writes the document to:
|
|
109
|
+
The selected order is saved back to the highest-priority layer (project, profile, then user) before distribution. Once confirmed, Agent Switchboard composes the merged Markdown, stores the active order, and writes the document to:
|
|
87
110
|
- `~/.claude/CLAUDE.md`
|
|
88
111
|
- `~/.codex/AGENTS.md`
|
|
89
112
|
- `~/.gemini/AGENTS.md`
|
|
@@ -96,7 +119,7 @@ Unsupportive agents such as Claude Desktop and Cursor are reported and left unto
|
|
|
96
119
|
See the full inventory, activation state, and per-agent sync timestamps:
|
|
97
120
|
|
|
98
121
|
```bash
|
|
99
|
-
agent-switchboard rule list
|
|
122
|
+
agent-switchboard rule list [-p <profile>] [--project <path>]
|
|
100
123
|
```
|
|
101
124
|
|
|
102
125
|
## Command Library
|
|
@@ -121,10 +144,10 @@ agent-switchboard command load <platform> [path] [-r]
|
|
|
121
144
|
### Select and Distribute
|
|
122
145
|
|
|
123
146
|
```bash
|
|
124
|
-
agent-switchboard command
|
|
147
|
+
agent-switchboard command [-p <profile>] [--project <path>]
|
|
125
148
|
```
|
|
126
149
|
|
|
127
|
-
|
|
150
|
+
The selector supports fuzzy filtering—type any part of a title, ID, or model name to narrow the list. Confirming selections saves them back into the highest-priority configuration layer before distribution. Adapters then write each selected command to the corresponding platform output in your user home (platform defaults), using the file format that platform expects. The frontmatter consists of the global `description` (if present) plus `extras.<platform>` written as-is.
|
|
128
151
|
|
|
129
152
|
Files are only rewritten when content changes.
|
|
130
153
|
|
|
@@ -132,7 +155,7 @@ Files are only rewritten when content changes.
|
|
|
132
155
|
|
|
133
156
|
```bash
|
|
134
157
|
# Inventory
|
|
135
|
-
agent-switchboard command list
|
|
158
|
+
agent-switchboard command list [-p <profile>] [--project <path>]
|
|
136
159
|
```
|
|
137
160
|
|
|
138
161
|
## Subagent Library
|
|
@@ -153,17 +176,27 @@ agent-switchboard subagent load <platform> [path] [-r]
|
|
|
153
176
|
### Select and Distribute
|
|
154
177
|
|
|
155
178
|
```bash
|
|
156
|
-
agent-switchboard subagent
|
|
179
|
+
agent-switchboard subagent [-p <profile>] [--project <path>]
|
|
157
180
|
```
|
|
158
181
|
|
|
159
|
-
|
|
182
|
+
Type to fuzzy filter the list, then confirm to persist the selection into the active configuration layer. Adapters write each selected subagent to the corresponding platform output in your user home (platform defaults), using the file format that platform expects. The frontmatter consists of the global `description` (if present) plus `extras.<platform>` written as-is. Platforms that do not accept subagent files are skipped with a hint.
|
|
160
183
|
|
|
161
184
|
### Inventory
|
|
162
185
|
|
|
163
186
|
```bash
|
|
164
|
-
agent-switchboard subagent list
|
|
187
|
+
agent-switchboard subagent list [-p <profile>] [--project <path>]
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Sync
|
|
191
|
+
|
|
192
|
+
After curating your `active` lists in the selectors, run the unified sync command to push rules, commands, and subagents to every supported agent directory:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
agent-switchboard sync [-p <profile>] [--project <path>]
|
|
165
196
|
```
|
|
166
197
|
|
|
198
|
+
The command merges the layered configuration, prints a warning that files will be overwritten without diffs, and rewrites the target files for each platform in place. Use profiles or project scopes to preview changes before applying them globally.
|
|
199
|
+
|
|
167
200
|
## Environment
|
|
168
201
|
|
|
169
202
|
- `ASB_HOME`: overrides `~/.agent-switchboard` for library/state files.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ConfigScope } from '../config/scope.js';
|
|
1
2
|
import { type DistributeOutcome } from '../library/distribute.js';
|
|
2
3
|
export type CommandPlatform = 'claude-code' | 'codex' | 'gemini' | 'opencode';
|
|
3
4
|
export interface CommandDistributionResult {
|
|
@@ -9,4 +10,4 @@ export interface CommandDistributionResult {
|
|
|
9
10
|
}
|
|
10
11
|
export type CommandDistributionOutcome = DistributeOutcome<CommandPlatform>;
|
|
11
12
|
export declare function resolveCommandFilePath(platform: CommandPlatform, id: string): string;
|
|
12
|
-
export declare function distributeCommands(): CommandDistributionOutcome;
|
|
13
|
+
export declare function distributeCommands(scope?: ConfigScope): CommandDistributionOutcome;
|
|
@@ -73,9 +73,9 @@ function renderForPlatform(platform, entry) {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
export function distributeCommands() {
|
|
76
|
+
export function distributeCommands(scope) {
|
|
77
77
|
const entries = loadCommandLibrary();
|
|
78
|
-
const state = loadLibraryStateSection('commands');
|
|
78
|
+
const state = loadLibraryStateSection('commands', scope);
|
|
79
79
|
const activeIds = state.active;
|
|
80
80
|
const byId = new Map(entries.map((e) => [e.id, e]));
|
|
81
81
|
const selected = [];
|
|
@@ -91,6 +91,7 @@ export function distributeCommands() {
|
|
|
91
91
|
platforms,
|
|
92
92
|
resolveFilePath: (p, e) => resolveCommandFilePath(p, e.id),
|
|
93
93
|
render: (p, e) => renderForPlatform(p, e),
|
|
94
|
+
scope,
|
|
94
95
|
});
|
|
95
96
|
}
|
|
96
97
|
//# sourceMappingURL=distribution.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distribution.js","sourceRoot":"","sources":["../../src/commands/distribution.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"distribution.js","sourceRoot":"","sources":["../../src/commands/distribution.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE9F,OAAO,EAGL,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAqB,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAcrE,MAAM,UAAU,sBAAsB,CAAC,QAAyB,EAAE,EAAU;IAC1E,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,aAAa;YAChB,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QAC3D,KAAK,OAAO;YACV,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QACzD,KAAK,QAAQ;YACX,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAC7D,KAAK,UAAU;YACb,OAAO,eAAe,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;AACH,CAAC;AAED,SA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,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAmB;IACpD,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IACrC,MAAM,KAAK,GAAG,uBAAuB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACzD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAmB,EAAE,CAAC;IACpC,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACvB,IAAI,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,SAAS,GAAsB,CAAC,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IAEpF,OAAO,iBAAiB,CAAgC;QACtD,OAAO,EAAE,UAAU;QACnB,QAAQ;QACR,SAAS;QACT,eAAe,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QAC1D,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC;QACzC,KAAK;KACN,CAAuD,CAAC;AAC3D,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ConfigScope } from '../config/scope.js';
|
|
1
2
|
import { type SectionState } from '../library/state.js';
|
|
2
3
|
export interface CommandInventoryRow {
|
|
3
4
|
id: string;
|
|
@@ -13,4 +14,4 @@ export interface CommandInventory {
|
|
|
13
14
|
entries: CommandInventoryRow[];
|
|
14
15
|
state: SectionState;
|
|
15
16
|
}
|
|
16
|
-
export declare function buildCommandInventory(): CommandInventory;
|
|
17
|
+
export declare function buildCommandInventory(scope?: ConfigScope): CommandInventory;
|
|
@@ -11,9 +11,9 @@ function sortInactive(entries) {
|
|
|
11
11
|
return aLabel.localeCompare(bLabel);
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
-
export function buildCommandInventory() {
|
|
14
|
+
export function buildCommandInventory(scope) {
|
|
15
15
|
const entries = loadCommandLibrary();
|
|
16
|
-
const state = loadLibraryStateSection('commands');
|
|
16
|
+
const state = loadLibraryStateSection('commands', scope);
|
|
17
17
|
const byId = new Map(entries.map((e) => [e.id, e]));
|
|
18
18
|
const rows = [];
|
|
19
19
|
const seen = new Set();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inventory.js","sourceRoot":"","sources":["../../src/commands/inventory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inventory.js","sourceRoot":"","sources":["../../src/commands/inventory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAqB,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAqB,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAkBrE,SAAS,YAAY,CAAC,OAAuB;IAC3C,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAChC,MAAM,KAAK,GAAG,CAAC,CAAC,QAAmC,CAAC;QACpD,MAAM,KAAK,GAAG,CAAC,CAAC,QAAmC,CAAC;QACpD,MAAM,MAAM,GAAG,KAAK,CAAC,KAAgB,CAAC;QACtC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAgB,CAAC;QACtC,MAAM,MAAM,GAAG,CACb,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,EAA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
path: string;
|
|
4
|
+
exists: boolean;
|
|
5
|
+
config: SwitchboardConfigLayer;
|
|
6
|
+
}
|
|
7
|
+
export interface LoadConfigLayersOptions {
|
|
8
|
+
profile?: string | null;
|
|
9
|
+
projectPath?: string | null;
|
|
10
|
+
}
|
|
11
|
+
export interface ConfigLayers {
|
|
12
|
+
user: ConfigLayerLoadResult;
|
|
13
|
+
profile?: ConfigLayerLoadResult;
|
|
14
|
+
project?: ConfigLayerLoadResult;
|
|
15
|
+
}
|
|
16
|
+
export type ConfigLayerKind = 'user' | 'profile' | 'project';
|
|
17
|
+
export declare function loadConfigLayers(options?: LoadConfigLayersOptions): ConfigLayers;
|
|
18
|
+
export declare function mergeConfigLayers(layers: ConfigLayers): Record<string, unknown>;
|
|
19
|
+
export declare function buildMergedSwitchboardConfig(layers: ConfigLayers): SwitchboardConfig;
|
|
20
|
+
export declare function loadMergedSwitchboardConfig(options?: LoadConfigLayersOptions): {
|
|
21
|
+
layers: ConfigLayers;
|
|
22
|
+
config: SwitchboardConfig;
|
|
23
|
+
};
|
|
24
|
+
export interface UpdateConfigLayerOptions extends LoadConfigLayersOptions {
|
|
25
|
+
target?: ConfigLayerKind;
|
|
26
|
+
}
|
|
27
|
+
export declare function updateConfigLayer(mutator: (layer: SwitchboardConfigLayer) => SwitchboardConfigLayer, options?: UpdateConfigLayerOptions): ConfigLayerLoadResult;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { parse, stringify } from '@iarna/toml';
|
|
4
|
+
import { getProfileConfigPath, getProjectConfigPath, getSwitchboardConfigPath } from './paths.js';
|
|
5
|
+
import { switchboardConfigLayerSchema, switchboardConfigSchema, } from './schemas.js';
|
|
6
|
+
function isPlainObject(value) {
|
|
7
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
function readLayerFile(filePath) {
|
|
10
|
+
if (!fs.existsSync(filePath)) {
|
|
11
|
+
return { path: filePath, exists: false, config: {} };
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
15
|
+
const parsed = content.trim().length === 0 ? {} : parse(content);
|
|
16
|
+
const validated = switchboardConfigLayerSchema.parse(parsed && typeof parsed === 'object' ? parsed : {});
|
|
17
|
+
return { path: filePath, exists: true, config: validated };
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error instanceof Error) {
|
|
21
|
+
throw new Error(`Failed to load configuration from ${filePath}: ${error.message}`);
|
|
22
|
+
}
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function loadConfigLayers(options) {
|
|
27
|
+
const userPath = getSwitchboardConfigPath();
|
|
28
|
+
const user = readLayerFile(userPath);
|
|
29
|
+
let profile;
|
|
30
|
+
const profileName = options?.profile?.trim();
|
|
31
|
+
if (profileName) {
|
|
32
|
+
const profilePath = getProfileConfigPath(profileName);
|
|
33
|
+
profile = readLayerFile(profilePath);
|
|
34
|
+
}
|
|
35
|
+
let project;
|
|
36
|
+
const projectRoot = options?.projectPath?.trim();
|
|
37
|
+
if (projectRoot) {
|
|
38
|
+
const projectPath = getProjectConfigPath(projectRoot);
|
|
39
|
+
project = readLayerFile(projectPath);
|
|
40
|
+
}
|
|
41
|
+
return { user, profile, project };
|
|
42
|
+
}
|
|
43
|
+
function mergeDeep(target, source) {
|
|
44
|
+
for (const [key, value] of Object.entries(source)) {
|
|
45
|
+
if (typeof value === 'undefined')
|
|
46
|
+
continue;
|
|
47
|
+
if (Array.isArray(value)) {
|
|
48
|
+
target[key] = [...value];
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (isPlainObject(value)) {
|
|
52
|
+
const current = target[key];
|
|
53
|
+
const base = isPlainObject(current) ? current : {};
|
|
54
|
+
const clone = { ...base };
|
|
55
|
+
mergeDeep(clone, value);
|
|
56
|
+
target[key] = clone;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
target[key] = value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export function mergeConfigLayers(layers) {
|
|
63
|
+
const merged = {};
|
|
64
|
+
mergeDeep(merged, layers.user.config);
|
|
65
|
+
if (layers.profile) {
|
|
66
|
+
mergeDeep(merged, layers.profile.config);
|
|
67
|
+
}
|
|
68
|
+
if (layers.project) {
|
|
69
|
+
mergeDeep(merged, layers.project.config);
|
|
70
|
+
}
|
|
71
|
+
return merged;
|
|
72
|
+
}
|
|
73
|
+
export function buildMergedSwitchboardConfig(layers) {
|
|
74
|
+
const merged = mergeConfigLayers(layers);
|
|
75
|
+
return switchboardConfigSchema.parse(merged);
|
|
76
|
+
}
|
|
77
|
+
export function loadMergedSwitchboardConfig(options) {
|
|
78
|
+
const layers = loadConfigLayers(options);
|
|
79
|
+
const config = buildMergedSwitchboardConfig(layers);
|
|
80
|
+
return { layers, config };
|
|
81
|
+
}
|
|
82
|
+
function defaultWritableLayer(options) {
|
|
83
|
+
const project = options?.projectPath?.trim();
|
|
84
|
+
if (project && project.length > 0)
|
|
85
|
+
return 'project';
|
|
86
|
+
const profile = options?.profile?.trim();
|
|
87
|
+
if (profile && profile.length > 0)
|
|
88
|
+
return 'profile';
|
|
89
|
+
return 'user';
|
|
90
|
+
}
|
|
91
|
+
function resolveLayerPath(kind, options) {
|
|
92
|
+
switch (kind) {
|
|
93
|
+
case 'user':
|
|
94
|
+
return getSwitchboardConfigPath();
|
|
95
|
+
case 'profile': {
|
|
96
|
+
const profile = options?.profile?.trim();
|
|
97
|
+
if (!profile) {
|
|
98
|
+
throw new Error('Profile name is required to write profile configuration.');
|
|
99
|
+
}
|
|
100
|
+
return getProfileConfigPath(profile);
|
|
101
|
+
}
|
|
102
|
+
case 'project': {
|
|
103
|
+
const project = options?.projectPath?.trim();
|
|
104
|
+
if (!project) {
|
|
105
|
+
throw new Error('Project path is required to write project configuration.');
|
|
106
|
+
}
|
|
107
|
+
return getProjectConfigPath(project);
|
|
108
|
+
}
|
|
109
|
+
default:
|
|
110
|
+
return getSwitchboardConfigPath();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function writeLayerFile(filePath, config) {
|
|
114
|
+
const dir = path.dirname(filePath);
|
|
115
|
+
if (!fs.existsSync(dir)) {
|
|
116
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
117
|
+
}
|
|
118
|
+
const portable = JSON.parse(JSON.stringify(config));
|
|
119
|
+
// biome-ignore lint/suspicious/noExplicitAny: TOML stringify requires JsonMap typing
|
|
120
|
+
const content = stringify(portable);
|
|
121
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
122
|
+
}
|
|
123
|
+
export function updateConfigLayer(mutator, options) {
|
|
124
|
+
const targetKind = options?.target ?? defaultWritableLayer(options);
|
|
125
|
+
const filePath = resolveLayerPath(targetKind, options);
|
|
126
|
+
const current = readLayerFile(filePath);
|
|
127
|
+
const draft = JSON.parse(JSON.stringify(current.config));
|
|
128
|
+
const next = switchboardConfigLayerSchema.parse(mutator(draft));
|
|
129
|
+
writeLayerFile(filePath, next);
|
|
130
|
+
return readLayerFile(filePath);
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=layered-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layered-config.js","sourceRoot":"","sources":["../../src/config/layered-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAClG,OAAO,EAGL,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAqBtB,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,KAAK,IAAI,IAAI,O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C/B,OAAkE,EAClE,OAAkC;IAElC,MAAM,UAAU,GAAG,OAAO,EAAE,MAAM,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACpE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IACxC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAA2B,CAAC;IACnF,MAAM,IAAI,GAAG,4BAA4B,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAChE,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC/B,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC"}
|
package/dist/config/paths.d.ts
CHANGED
|
@@ -27,13 +27,18 @@ export declare function getMcpConfigPath(): string;
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function getSwitchboardConfigPath(): string;
|
|
29
29
|
/**
|
|
30
|
-
* Returns the absolute path to
|
|
30
|
+
* Returns the absolute path to a profile-specific configuration file located under ASB_HOME.
|
|
31
|
+
* Example: ~/.agent-switchboard/team.toml
|
|
31
32
|
*/
|
|
32
|
-
export declare function
|
|
33
|
+
export declare function getProfileConfigPath(profileName: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the absolute path to a project-scoped configuration file (.asb.toml).
|
|
36
|
+
*/
|
|
37
|
+
export declare function getProjectConfigPath(projectRoot: string): string;
|
|
33
38
|
/**
|
|
34
|
-
* Returns the absolute path to the rule
|
|
39
|
+
* Returns the absolute path to the rule snippets directory
|
|
35
40
|
*/
|
|
36
|
-
export declare function
|
|
41
|
+
export declare function getRulesDir(): string;
|
|
37
42
|
/**
|
|
38
43
|
* Returns the absolute path to the commands library directory
|
|
39
44
|
*/
|
package/dist/config/paths.js
CHANGED
|
@@ -41,16 +41,27 @@ export function getSwitchboardConfigPath() {
|
|
|
41
41
|
return path.join(getConfigDir(), 'config.toml');
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* Returns the absolute path to
|
|
44
|
+
* Returns the absolute path to a profile-specific configuration file located under ASB_HOME.
|
|
45
|
+
* Example: ~/.agent-switchboard/team.toml
|
|
45
46
|
*/
|
|
46
|
-
export function
|
|
47
|
-
|
|
47
|
+
export function getProfileConfigPath(profileName) {
|
|
48
|
+
const trimmed = profileName.trim();
|
|
49
|
+
if (trimmed.length === 0) {
|
|
50
|
+
throw new Error('Profile name must be a non-empty string.');
|
|
51
|
+
}
|
|
52
|
+
return path.join(getConfigDir(), `${trimmed}.toml`);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns the absolute path to a project-scoped configuration file (.asb.toml).
|
|
56
|
+
*/
|
|
57
|
+
export function getProjectConfigPath(projectRoot) {
|
|
58
|
+
return path.join(path.resolve(projectRoot), '.asb.toml');
|
|
48
59
|
}
|
|
49
60
|
/**
|
|
50
|
-
* Returns the absolute path to the rule
|
|
61
|
+
* Returns the absolute path to the rule snippets directory
|
|
51
62
|
*/
|
|
52
|
-
export function
|
|
53
|
-
return path.join(getConfigDir(), '
|
|
63
|
+
export function getRulesDir() {
|
|
64
|
+
return path.join(getConfigDir(), 'rules');
|
|
54
65
|
}
|
|
55
66
|
/**
|
|
56
67
|
* Returns the absolute path to the commands library directory
|
package/dist/config/paths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/config/paths.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY;IAC1B,wBAAwB;IACxB,2GAA2G;IAC3G,2DAA2D;IAC3D,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,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