agent-switchboard 0.1.2 → 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 +110 -7
- package/dist/agents/claude-code.js +2 -6
- package/dist/agents/claude-code.js.map +1 -1
- package/dist/agents/claude-desktop.js +2 -16
- package/dist/agents/claude-desktop.js.map +1 -1
- package/dist/agents/codex.js +2 -5
- package/dist/agents/codex.js.map +1 -1
- package/dist/agents/gemini.js +2 -6
- package/dist/agents/gemini.js.map +1 -1
- package/dist/agents/opencode.js +2 -8
- package/dist/agents/opencode.js.map +1 -1
- package/dist/commands/distribution.d.ts +13 -0
- package/dist/commands/distribution.js +97 -0
- package/dist/commands/distribution.js.map +1 -0
- package/dist/commands/importer.d.ts +6 -0
- package/dist/commands/importer.js +66 -0
- package/dist/commands/importer.js.map +1 -0
- package/dist/commands/inventory.d.ts +17 -0
- package/dist/commands/inventory.js +78 -0
- package/dist/commands/inventory.js.map +1 -0
- package/dist/commands/library.d.ts +9 -0
- package/dist/commands/library.js +49 -0
- package/dist/commands/library.js.map +1 -0
- package/dist/commands/template.d.ts +1 -0
- package/dist/commands/template.js +9 -0
- package/dist/commands/template.js.map +1 -0
- 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 +31 -2
- package/dist/config/paths.js +78 -3
- 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 +620 -49
- package/dist/index.js.map +1 -1
- package/dist/library/distribute.d.ts +25 -0
- package/dist/library/distribute.js +66 -0
- package/dist/library/distribute.js.map +1 -0
- package/dist/library/fs.d.ts +14 -0
- package/dist/library/fs.js +55 -0
- package/dist/library/fs.js.map +1 -0
- package/dist/library/parser.d.ts +7 -0
- package/dist/library/parser.js +11 -0
- package/dist/library/parser.js.map +1 -0
- package/dist/library/schema.d.ts +18 -0
- package/dist/library/schema.js +14 -0
- package/dist/library/schema.js.map +1 -0
- package/dist/library/state.d.ts +44 -0
- package/dist/library/state.js +61 -0
- package/dist/library/state.js.map +1 -0
- 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 +10 -34
- 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 +13 -0
- package/dist/subagents/distribution.js +72 -0
- package/dist/subagents/distribution.js.map +1 -0
- package/dist/subagents/importer.d.ts +6 -0
- package/dist/subagents/importer.js +42 -0
- package/dist/subagents/importer.js.map +1 -0
- package/dist/subagents/inventory.d.ts +18 -0
- package/dist/subagents/inventory.js +111 -0
- package/dist/subagents/inventory.js.map +1 -0
- package/dist/subagents/library.d.ts +9 -0
- package/dist/subagents/library.js +49 -0
- package/dist/subagents/library.js.map +1 -0
- package/dist/subagents/template.d.ts +1 -0
- package/dist/subagents/template.js +9 -0
- package/dist/subagents/template.js.map +1 -0
- package/dist/ui/command-ui.d.ts +4 -0
- package/dist/ui/command-ui.js +24 -0
- package/dist/ui/command-ui.js.map +1 -0
- 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 +16 -0
- package/dist/ui/library-selector.js +152 -0
- package/dist/ui/library-selector.js.map +1 -0
- 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 +4 -0
- package/dist/ui/subagent-ui.js +30 -0
- package/dist/ui/subagent-ui.js.map +1 -0
- package/dist/util/cli.d.ts +6 -0
- package/dist/util/cli.js +24 -0
- package/dist/util/cli.js.map +1 -0
- package/dist/util/extras.d.ts +4 -0
- package/dist/util/extras.js +25 -0
- package/dist/util/extras.js.map +1 -0
- package/dist/util/frontmatter.d.ts +1 -0
- package/dist/util/frontmatter.js +7 -0
- package/dist/util/frontmatter.js.map +1 -0
- package/dist/util/markdown.d.ts +24 -0
- package/dist/util/markdown.js +70 -0
- package/dist/util/markdown.js.map +1 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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
|
+
You can run with either `agent-switchboard` or the shorter alias `asb`.
|
|
6
|
+
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
Global install:
|
|
@@ -58,7 +60,30 @@ Toggle `rules.includeDelimiters` to `true` if you want each snippet surrounded b
|
|
|
58
60
|
|
|
59
61
|
Run `agent-switchboard mcp` again after updating the list.
|
|
60
62
|
|
|
61
|
-
|
|
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
|
+
|
|
86
|
+
## Rule Library
|
|
62
87
|
|
|
63
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:
|
|
64
89
|
|
|
@@ -75,29 +100,107 @@ Keep commit messages scoped to the change.
|
|
|
75
100
|
|
|
76
101
|
### Selecting and Ordering Rules
|
|
77
102
|
|
|
78
|
-
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:
|
|
79
104
|
|
|
80
105
|
```bash
|
|
81
|
-
agent-switchboard rule
|
|
106
|
+
agent-switchboard rule [-p <profile>] [--project <path>]
|
|
82
107
|
```
|
|
83
108
|
|
|
84
|
-
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:
|
|
85
110
|
- `~/.claude/CLAUDE.md`
|
|
86
111
|
- `~/.codex/AGENTS.md`
|
|
87
112
|
- `~/.gemini/AGENTS.md`
|
|
88
113
|
- `~/.config/opencode/AGENTS.md` (or `%APPDATA%/opencode/AGENTS.md` on Windows)
|
|
89
114
|
|
|
90
|
-
Unsupportive agents such as Claude Desktop and Cursor are reported and left untouched.
|
|
115
|
+
Unsupportive agents such as Claude Desktop and Cursor are reported and left untouched. If you rerun the selector without changing the order, the tool refreshes the destination files to overwrite any manual edits.
|
|
91
116
|
|
|
92
117
|
### Auditing Rules
|
|
93
118
|
|
|
94
119
|
See the full inventory, activation state, and per-agent sync timestamps:
|
|
95
120
|
|
|
96
121
|
```bash
|
|
97
|
-
agent-switchboard rule list
|
|
98
|
-
|
|
122
|
+
agent-switchboard rule list [-p <profile>] [--project <path>]
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Command Library
|
|
126
|
+
|
|
127
|
+
- Location: `~/.agent-switchboard/commands/<slug>.md` (respects `ASB_HOME`).
|
|
128
|
+
- Frontmatter: only global `description` (optional). Any platform-native options must live under `extras.<platform>` and are written through verbatim. No parsing, no key renaming, no documentation of platform keys here.
|
|
129
|
+
|
|
130
|
+
### Import
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Import an existing platform file or directory into the library
|
|
134
|
+
# Use -r/--recursive to traverse subdirectories when <path> is a directory
|
|
135
|
+
agent-switchboard command load <platform> [path] [-r]
|
|
136
|
+
# <platform>: claude-code | codex | gemini | opencode
|
|
137
|
+
# If [path] is omitted, defaults by platform:
|
|
138
|
+
# claude-code → ~/.claude/commands
|
|
139
|
+
# codex → ~/.codex/prompts
|
|
140
|
+
# gemini → ~/.gemini/commands
|
|
141
|
+
# opencode → ~/.config/opencode/command (Windows: %APPDATA%/opencode/command)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Select and Distribute
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
agent-switchboard command [-p <profile>] [--project <path>]
|
|
148
|
+
```
|
|
149
|
+
|
|
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.
|
|
151
|
+
|
|
152
|
+
Files are only rewritten when content changes.
|
|
153
|
+
|
|
154
|
+
### Inventory
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# Inventory
|
|
158
|
+
agent-switchboard command list [-p <profile>] [--project <path>]
|
|
99
159
|
```
|
|
100
160
|
|
|
161
|
+
## Subagent Library
|
|
162
|
+
|
|
163
|
+
- Location: `~/.agent-switchboard/subagents/<slug>.md` (respects `ASB_HOME`).
|
|
164
|
+
- Frontmatter: only global `description` (optional). Any platform-native options must live under `extras.<platform>` and are written through verbatim. We do not parse, validate, or showcase platform key names in this README. Platforms that do not support subagent files are skipped.
|
|
165
|
+
|
|
166
|
+
### Import
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
agent-switchboard subagent load <platform> [path] [-r]
|
|
170
|
+
# <platform>: claude-code | opencode
|
|
171
|
+
# If [path] is omitted, defaults by platform:
|
|
172
|
+
# claude-code → ~/.claude/agents
|
|
173
|
+
# opencode → ~/.config/opencode/agent (Windows: %APPDATA%/opencode/agent)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Select and Distribute
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
agent-switchboard subagent [-p <profile>] [--project <path>]
|
|
180
|
+
```
|
|
181
|
+
|
|
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.
|
|
183
|
+
|
|
184
|
+
### Inventory
|
|
185
|
+
|
|
186
|
+
```bash
|
|
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>]
|
|
196
|
+
```
|
|
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
|
+
|
|
200
|
+
## Environment
|
|
201
|
+
|
|
202
|
+
- `ASB_HOME`: overrides `~/.agent-switchboard` for library/state files.
|
|
203
|
+
|
|
101
204
|
## License
|
|
102
205
|
|
|
103
206
|
MIT
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Claude Code agent adapter
|
|
3
3
|
* Manages MCP server configuration for Claude Code CLI
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
6
|
-
import path from 'node:path';
|
|
5
|
+
import { getClaudeJsonPath } from '../config/paths.js';
|
|
7
6
|
import { loadJsonFile, mergeMcpIntoAgent, saveJsonFile, } from './json-utils.js';
|
|
8
7
|
/**
|
|
9
8
|
* Claude Code agent adapter
|
|
@@ -12,10 +11,7 @@ import { loadJsonFile, mergeMcpIntoAgent, saveJsonFile, } from './json-utils.js'
|
|
|
12
11
|
export class ClaudeCodeAgent {
|
|
13
12
|
id = 'claude-code';
|
|
14
13
|
configPath() {
|
|
15
|
-
|
|
16
|
-
? process.env.ASB_AGENTS_HOME
|
|
17
|
-
: os.homedir();
|
|
18
|
-
return path.join(base, '.claude.json');
|
|
14
|
+
return getClaudeJsonPath();
|
|
19
15
|
}
|
|
20
16
|
applyConfig(config) {
|
|
21
17
|
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,
|
|
1
|
+
{"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../../src/agents/claude-code.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAIvD,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,OAAO,iBAAiB,EAAE,CAAC;IAC7B,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,7 @@
|
|
|
2
2
|
* Claude Desktop agent adapter
|
|
3
3
|
* Manages MCP server configuration for Claude Desktop app
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
6
|
-
import path from 'node:path';
|
|
5
|
+
import { getClaudeDesktopConfigPath } from '../config/paths.js';
|
|
7
6
|
import { loadJsonFile, mergeMcpIntoAgent, saveJsonFile, } from './json-utils.js';
|
|
8
7
|
/**
|
|
9
8
|
* Claude Desktop config file structure
|
|
@@ -19,20 +18,7 @@ import { loadJsonFile, mergeMcpIntoAgent, saveJsonFile, } from './json-utils.js'
|
|
|
19
18
|
export class ClaudeDesktopAgent {
|
|
20
19
|
id = 'claude-desktop';
|
|
21
20
|
configPath() {
|
|
22
|
-
|
|
23
|
-
const home = process.env.ASB_AGENTS_HOME && process.env.ASB_AGENTS_HOME.trim().length > 0
|
|
24
|
-
? process.env.ASB_AGENTS_HOME
|
|
25
|
-
: os.homedir();
|
|
26
|
-
switch (platform) {
|
|
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
|
-
default:
|
|
34
|
-
throw new Error(`Unsupported platform: ${platform}`);
|
|
35
|
-
}
|
|
21
|
+
return getClaudeDesktopConfigPath();
|
|
36
22
|
}
|
|
37
23
|
applyConfig(config) {
|
|
38
24
|
const path = this.configPath();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-desktop.js","sourceRoot":"","sources":["../../src/agents/claude-desktop.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"claude-desktop.js","sourceRoot":"","sources":["../../src/agents/claude-desktop.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAGhE,OAAO,EAEL,YAAY,EACZ,iBAAiB,EACjB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,8BAA8B;AAE9B;;;;;;GAMG;AACH,MAAM,OAAO,kBAAkB;IACpB,EAAE,GAAG,gBAAyB,CAAC;IAExC,UAAU;QACR,OAAO,0BAA0B,EAAE,CAAC;IACtC,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/codex.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Handles TOML-based configuration with canonical section output
|
|
4
4
|
*/
|
|
5
5
|
import fs from 'node:fs';
|
|
6
|
-
import os from 'node:os';
|
|
7
6
|
import path from 'node:path';
|
|
8
7
|
import { parse as parseToml, stringify as tomlStringify } from '@iarna/toml';
|
|
8
|
+
import { getCodexConfigPath } from '../config/paths.js';
|
|
9
9
|
/**
|
|
10
10
|
* Codex CLI agent adapter
|
|
11
11
|
* Config: ~/.codex/config.toml (TOML format)
|
|
@@ -13,10 +13,7 @@ import { parse as parseToml, stringify as tomlStringify } from '@iarna/toml';
|
|
|
13
13
|
export class CodexAgent {
|
|
14
14
|
id = 'codex';
|
|
15
15
|
configPath() {
|
|
16
|
-
|
|
17
|
-
? process.env.ASB_AGENTS_HOME
|
|
18
|
-
: os.homedir();
|
|
19
|
-
return path.join(base, '.codex', 'config.toml');
|
|
16
|
+
return getCodexConfigPath();
|
|
20
17
|
}
|
|
21
18
|
applyConfig(config) {
|
|
22
19
|
const content = this._loadConfig();
|
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,
|
|
1
|
+
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/agents/codex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,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;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAIxD;;;GAGG;AACH,MAAM,OAAO,UAAU;IACZ,EAAE,GAAG,OAAgB,CAAC;IAE/B,UAAU;QACR,OAAO,kBAAkB,EAAE,CAAC;IAC9B,CAAC;IAED,WAAW,CAAC,MAAkE;QAC5E,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,OAA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/
|
|
5
|
-
import
|
|
6
|
-
import path from 'node:path';
|
|
5
|
+
import { getGeminiSettingsPath } from '../config/paths.js';
|
|
7
6
|
import { loadJsonFile, mergeMcpIntoAgent, saveJsonFile, } from './json-utils.js';
|
|
8
7
|
/**
|
|
9
8
|
* Gemini CLI config file structure
|
|
@@ -16,10 +15,7 @@ import { loadJsonFile, mergeMcpIntoAgent, saveJsonFile, } from './json-utils.js'
|
|
|
16
15
|
export class GeminiAgent {
|
|
17
16
|
id = 'gemini';
|
|
18
17
|
configPath() {
|
|
19
|
-
|
|
20
|
-
? process.env.ASB_AGENTS_HOME
|
|
21
|
-
: os.homedir();
|
|
22
|
-
return path.join(base, '.gemini', 'settings.json');
|
|
18
|
+
return getGeminiSettingsPath();
|
|
23
19
|
}
|
|
24
20
|
applyConfig(config) {
|
|
25
21
|
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,
|
|
1
|
+
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../src/agents/gemini.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,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,OAAO,qBAAqB,EAAE,CAAC;IACjC,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/opencode.js
CHANGED
|
@@ -3,18 +3,12 @@
|
|
|
3
3
|
* Synchronizes MCP servers into ~/.config/opencode/opencode.json
|
|
4
4
|
*/
|
|
5
5
|
import fs from 'node:fs';
|
|
6
|
-
import os from 'node:os';
|
|
7
6
|
import path from 'node:path';
|
|
7
|
+
import { getOpencodePath } from '../config/paths.js';
|
|
8
8
|
export class OpencodeAgent {
|
|
9
9
|
id = 'opencode';
|
|
10
10
|
configPath() {
|
|
11
|
-
|
|
12
|
-
? process.env.ASB_AGENTS_HOME
|
|
13
|
-
: os.homedir();
|
|
14
|
-
if (process.platform === 'win32') {
|
|
15
|
-
return path.join(home, 'AppData', 'Roaming', 'opencode', 'opencode.json');
|
|
16
|
-
}
|
|
17
|
-
return path.join(home, '.config', 'opencode', 'opencode.json');
|
|
11
|
+
return getOpencodePath('opencode.json');
|
|
18
12
|
}
|
|
19
13
|
applyConfig(config) {
|
|
20
14
|
const filePath = this.configPath();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opencode.js","sourceRoot":"","sources":["../../src/agents/opencode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,
|
|
1
|
+
{"version":3,"file":"opencode.js","sourceRoot":"","sources":["../../src/agents/opencode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAcrD,MAAM,OAAO,aAAa;IACf,EAAE,GAAG,UAAmB,CAAC;IAElC,UAAU;QACR,OAAO,eAAe,CAAC,eAAe,CAAC,CAAC;IAC1C,CAAC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AAU,CAAC,GAAG,CAAC;YAAE,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAEhE,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;QACjD,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ConfigScope } from '../config/scope.js';
|
|
2
|
+
import { type DistributeOutcome } from '../library/distribute.js';
|
|
3
|
+
export type CommandPlatform = 'claude-code' | 'codex' | 'gemini' | 'opencode';
|
|
4
|
+
export interface CommandDistributionResult {
|
|
5
|
+
platform: CommandPlatform;
|
|
6
|
+
filePath: string;
|
|
7
|
+
status: 'written' | 'skipped' | 'error';
|
|
8
|
+
reason?: string;
|
|
9
|
+
error?: string;
|
|
10
|
+
}
|
|
11
|
+
export type CommandDistributionOutcome = DistributeOutcome<CommandPlatform>;
|
|
12
|
+
export declare function resolveCommandFilePath(platform: CommandPlatform, id: string): string;
|
|
13
|
+
export declare function distributeCommands(scope?: ConfigScope): CommandDistributionOutcome;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { stringify as toToml } from '@iarna/toml';
|
|
3
|
+
import { getClaudeDir, getCodexDir, getGeminiDir, getOpencodePath } from '../config/paths.js';
|
|
4
|
+
import { distributeLibrary, } from '../library/distribute.js';
|
|
5
|
+
import { loadLibraryStateSection } from '../library/state.js';
|
|
6
|
+
import { wrapFrontmatter } from '../util/frontmatter.js';
|
|
7
|
+
import { loadCommandLibrary } from './library.js';
|
|
8
|
+
export function resolveCommandFilePath(platform, id) {
|
|
9
|
+
switch (platform) {
|
|
10
|
+
case 'claude-code':
|
|
11
|
+
return path.join(getClaudeDir(), 'commands', `${id}.md`);
|
|
12
|
+
case 'codex':
|
|
13
|
+
return path.join(getCodexDir(), 'prompts', `${id}.md`);
|
|
14
|
+
case 'gemini':
|
|
15
|
+
return path.join(getGeminiDir(), 'commands', `${id}.toml`);
|
|
16
|
+
case 'opencode':
|
|
17
|
+
return getOpencodePath('command', `${id}.md`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function buildFrontmatterForClaude(entry) {
|
|
21
|
+
const base = {};
|
|
22
|
+
if (entry.metadata.description)
|
|
23
|
+
base.description = entry.metadata.description;
|
|
24
|
+
const extras = entry.metadata.extras;
|
|
25
|
+
const cc = extras?.['claude-code'] ?? undefined;
|
|
26
|
+
if (cc && typeof cc === 'object') {
|
|
27
|
+
for (const [k, v] of Object.entries(cc))
|
|
28
|
+
base[k] = v;
|
|
29
|
+
}
|
|
30
|
+
return base;
|
|
31
|
+
}
|
|
32
|
+
function buildFrontmatterForOpencode(entry) {
|
|
33
|
+
const extras = entry.metadata.extras;
|
|
34
|
+
const opencode = extras?.opencode ?? undefined;
|
|
35
|
+
const base = {};
|
|
36
|
+
if (entry.metadata.description)
|
|
37
|
+
base.description = entry.metadata.description;
|
|
38
|
+
if (opencode && typeof opencode === 'object') {
|
|
39
|
+
for (const [k, v] of Object.entries(opencode))
|
|
40
|
+
base[k] = v;
|
|
41
|
+
}
|
|
42
|
+
return base;
|
|
43
|
+
}
|
|
44
|
+
function renderForPlatform(platform, entry) {
|
|
45
|
+
switch (platform) {
|
|
46
|
+
case 'claude-code': {
|
|
47
|
+
const fm = buildFrontmatterForClaude(entry);
|
|
48
|
+
return wrapFrontmatter(fm, entry.content);
|
|
49
|
+
}
|
|
50
|
+
case 'codex': {
|
|
51
|
+
const desc = entry.metadata.description?.trim();
|
|
52
|
+
const header = desc && desc.length > 0 ? `<!-- ${desc} -->\n\n` : '';
|
|
53
|
+
return `${header}${entry.content.trimStart()}`;
|
|
54
|
+
}
|
|
55
|
+
case 'gemini': {
|
|
56
|
+
const extras = entry.metadata.extras;
|
|
57
|
+
const g = extras?.gemini ?? undefined;
|
|
58
|
+
const obj = {
|
|
59
|
+
prompt: entry.content.trimStart(),
|
|
60
|
+
};
|
|
61
|
+
if (entry.metadata.description)
|
|
62
|
+
obj.description = entry.metadata.description;
|
|
63
|
+
if (g && typeof g === 'object') {
|
|
64
|
+
for (const [k, v] of Object.entries(g))
|
|
65
|
+
obj[k] = v;
|
|
66
|
+
}
|
|
67
|
+
// biome-ignore lint/suspicious/noExplicitAny: TOML stringify expects JSON-like values; cast is safe here
|
|
68
|
+
return toToml(obj);
|
|
69
|
+
}
|
|
70
|
+
case 'opencode': {
|
|
71
|
+
const fm = buildFrontmatterForOpencode(entry);
|
|
72
|
+
return wrapFrontmatter(fm, entry.content);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export function distributeCommands(scope) {
|
|
77
|
+
const entries = loadCommandLibrary();
|
|
78
|
+
const state = loadLibraryStateSection('commands', scope);
|
|
79
|
+
const activeIds = state.active;
|
|
80
|
+
const byId = new Map(entries.map((e) => [e.id, e]));
|
|
81
|
+
const selected = [];
|
|
82
|
+
for (const id of activeIds) {
|
|
83
|
+
const e = byId.get(id);
|
|
84
|
+
if (e)
|
|
85
|
+
selected.push(e);
|
|
86
|
+
}
|
|
87
|
+
const platforms = ['claude-code', 'codex', 'gemini', 'opencode'];
|
|
88
|
+
return distributeLibrary({
|
|
89
|
+
section: 'commands',
|
|
90
|
+
selected,
|
|
91
|
+
platforms,
|
|
92
|
+
resolveFilePath: (p, e) => resolveCommandFilePath(p, e.id),
|
|
93
|
+
render: (p, e) => renderForPlatform(p, e),
|
|
94
|
+
scope,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=distribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distribution.js","sourceRoot":"","sources":["../../src/commands/distribution.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAA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AAC,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"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { wrapFrontmatter } from '../util/frontmatter.js';
|
|
4
|
+
import { FRONTMATTER_PATTERN, slugify, stripYamlFrontmatter } from '../util/markdown.js';
|
|
5
|
+
function parseTomlString(content, key) {
|
|
6
|
+
// Naive TOML key = "value" or key = """multiline"""
|
|
7
|
+
const triple = new RegExp(`^\\s*${key}\\s*=\\s*"""([\\s\\S]*?)"""`, 'm');
|
|
8
|
+
const single = new RegExp(`^\\s*${key}\\s*=\\s*"([\\s\\S]*?)"`, 'm');
|
|
9
|
+
const m3 = content.match(triple);
|
|
10
|
+
if (m3)
|
|
11
|
+
return m3[1] ?? '';
|
|
12
|
+
const m1 = content.match(single);
|
|
13
|
+
if (m1)
|
|
14
|
+
return m1[1] ?? '';
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
// Using shared stripYamlFrontmatter from util/markdown
|
|
18
|
+
export function importCommandFromFile(platform, filePath) {
|
|
19
|
+
if (!fs.existsSync(filePath)) {
|
|
20
|
+
throw new Error(`Source file not found: ${filePath}`);
|
|
21
|
+
}
|
|
22
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
23
|
+
const baseSlug = slugify(path.basename(filePath, path.extname(filePath)));
|
|
24
|
+
switch (platform) {
|
|
25
|
+
case 'claude-code':
|
|
26
|
+
case 'opencode': {
|
|
27
|
+
// Strip any existing frontmatter and wrap into library schema (description + extras.<platform>)
|
|
28
|
+
const extracted = stripYamlFrontmatter(raw);
|
|
29
|
+
let body = extracted.body;
|
|
30
|
+
let meta = extracted.meta ?? {};
|
|
31
|
+
if (!meta || typeof meta !== 'object')
|
|
32
|
+
meta = {};
|
|
33
|
+
// Attempt to strip accidental second frontmatter at body start
|
|
34
|
+
const second = body.match(FRONTMATTER_PATTERN);
|
|
35
|
+
if (second && second.index === 0) {
|
|
36
|
+
const stripped = stripYamlFrontmatter(body);
|
|
37
|
+
meta = { ...meta, ...(stripped.meta ?? {}) };
|
|
38
|
+
body = stripped.body;
|
|
39
|
+
}
|
|
40
|
+
const metaRecord = meta;
|
|
41
|
+
const description = typeof metaRecord.description === 'string' ? metaRecord.description : '';
|
|
42
|
+
const rest = Object.fromEntries(Object.entries(metaRecord).filter(([k]) => k !== 'description'));
|
|
43
|
+
const fm = { description, extras: { [platform]: rest } };
|
|
44
|
+
const bodyNoFrontmatter = body.replace(/^\s*---\s*[\s\S]*?\r?\n---\s*\r?\n?/, '');
|
|
45
|
+
return { slug: baseSlug, content: wrapFrontmatter(fm, bodyNoFrontmatter) };
|
|
46
|
+
}
|
|
47
|
+
case 'codex': {
|
|
48
|
+
// Pure Markdown body; keep content and add minimal frontmatter
|
|
49
|
+
const fm = { description: '', extras: { codex: {} } };
|
|
50
|
+
return { slug: baseSlug, content: wrapFrontmatter(fm, raw) };
|
|
51
|
+
}
|
|
52
|
+
case 'gemini': {
|
|
53
|
+
// Minimal parse: extract prompt and description; do not infer/rename other keys
|
|
54
|
+
const prompt = parseTomlString(raw, 'prompt') ?? '';
|
|
55
|
+
const description = parseTomlString(raw, 'description') ?? '';
|
|
56
|
+
const fm = { description, extras: { gemini: {} } };
|
|
57
|
+
return { slug: baseSlug, content: wrapFrontmatter(fm, prompt) };
|
|
58
|
+
}
|
|
59
|
+
default: {
|
|
60
|
+
// biome-ignore lint/suspicious/noExplicitAny: exhaustive check fallback
|
|
61
|
+
const never = platform;
|
|
62
|
+
throw new Error(`Unsupported platform: ${never}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=importer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importer.js","sourceRoot":"","sources":["../../src/commands/importer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAIzF,SAAS,eAAe,CAAC,OAAe,EAAE,GAAW;IACnD,oDAAoD;IACpD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,QAAQ,GAAG,6BAA6B,EAAE,GAAG,CAAC,CAAC;IACzE,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,QAAQ,GAAG,yBAAyB,EAAE,GAAG,CAAC,CAAC;IACrE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI,EAAE;QAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3B,MAAM,EA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,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC;YACnD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC;QAClE,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,wEAAwE;YACxE,MAAM,KAAK,GAAQ,QAAQ,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,EAAE,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ConfigScope } from '../config/scope.js';
|
|
2
|
+
import { type SectionState } from '../library/state.js';
|
|
3
|
+
export interface CommandInventoryRow {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string | null;
|
|
6
|
+
description: string | null;
|
|
7
|
+
model: string | null;
|
|
8
|
+
extrasKeys: string[];
|
|
9
|
+
active: boolean;
|
|
10
|
+
order: number | null;
|
|
11
|
+
filePath: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface CommandInventory {
|
|
14
|
+
entries: CommandInventoryRow[];
|
|
15
|
+
state: SectionState;
|
|
16
|
+
}
|
|
17
|
+
export declare function buildCommandInventory(scope?: ConfigScope): CommandInventory;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { loadLibraryStateSection } from '../library/state.js';
|
|
2
|
+
import { loadCommandLibrary } from './library.js';
|
|
3
|
+
function sortInactive(entries) {
|
|
4
|
+
return [...entries].sort((a, b) => {
|
|
5
|
+
const aMeta = a.metadata;
|
|
6
|
+
const bMeta = b.metadata;
|
|
7
|
+
const aTitle = aMeta.title;
|
|
8
|
+
const bTitle = bMeta.title;
|
|
9
|
+
const aLabel = (typeof aTitle === 'string' && aTitle.trim().length > 0 ? aTitle : a.id).toLowerCase();
|
|
10
|
+
const bLabel = (typeof bTitle === 'string' && bTitle.trim().length > 0 ? bTitle : b.id).toLowerCase();
|
|
11
|
+
return aLabel.localeCompare(bLabel);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function buildCommandInventory(scope) {
|
|
15
|
+
const entries = loadCommandLibrary();
|
|
16
|
+
const state = loadLibraryStateSection('commands', scope);
|
|
17
|
+
const byId = new Map(entries.map((e) => [e.id, e]));
|
|
18
|
+
const rows = [];
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
state.active.forEach((id) => {
|
|
21
|
+
const e = byId.get(id);
|
|
22
|
+
if (!e) {
|
|
23
|
+
rows.push({
|
|
24
|
+
id,
|
|
25
|
+
title: null,
|
|
26
|
+
description: null,
|
|
27
|
+
model: null,
|
|
28
|
+
extrasKeys: [],
|
|
29
|
+
active: true,
|
|
30
|
+
order: null,
|
|
31
|
+
filePath: null,
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
seen.add(id);
|
|
36
|
+
rows.push({
|
|
37
|
+
id,
|
|
38
|
+
title: (() => {
|
|
39
|
+
const t = e.metadata.title;
|
|
40
|
+
return typeof t === 'string' ? t : null;
|
|
41
|
+
})(),
|
|
42
|
+
description: e.metadata.description ?? null,
|
|
43
|
+
model: (() => {
|
|
44
|
+
const extras = e.metadata.extras;
|
|
45
|
+
const cc = extras?.['claude-code'] ?? undefined;
|
|
46
|
+
const m = cc?.model;
|
|
47
|
+
return typeof m === 'string' && m.trim().length > 0 ? m : null;
|
|
48
|
+
})(),
|
|
49
|
+
extrasKeys: e.metadata.extras ? Object.keys(e.metadata.extras) : [],
|
|
50
|
+
active: true,
|
|
51
|
+
order: null,
|
|
52
|
+
filePath: e.filePath,
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
const inactive = sortInactive(entries.filter((e) => !seen.has(e.id)));
|
|
56
|
+
inactive.forEach((e) => {
|
|
57
|
+
rows.push({
|
|
58
|
+
id: e.id,
|
|
59
|
+
title: (() => {
|
|
60
|
+
const t = e.metadata.title;
|
|
61
|
+
return typeof t === 'string' ? t : null;
|
|
62
|
+
})(),
|
|
63
|
+
description: e.metadata.description ?? null,
|
|
64
|
+
model: (() => {
|
|
65
|
+
const extras = e.metadata.extras;
|
|
66
|
+
const cc = extras?.['claude-code'] ?? undefined;
|
|
67
|
+
const m = cc?.model;
|
|
68
|
+
return typeof m === 'string' && m.trim().length > 0 ? m : null;
|
|
69
|
+
})(),
|
|
70
|
+
extrasKeys: e.metadata.extras ? Object.keys(e.metadata.extras) : [],
|
|
71
|
+
active: false,
|
|
72
|
+
order: null,
|
|
73
|
+
filePath: e.filePath,
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
return { entries: rows, state };
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=inventory.js.map
|