@a1st/aix 0.6.0 → 0.8.0
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 +13 -7
- package/bin/aixd.mjs +8 -6
- package/dist/cli.js +3 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/add/agent.d.ts +29 -0
- package/dist/commands/add/agent.d.ts.map +1 -0
- package/dist/commands/add/agent.js +212 -0
- package/dist/commands/add/agent.js.map +1 -0
- package/dist/commands/add/hook.d.ts +45 -0
- package/dist/commands/add/hook.d.ts.map +1 -0
- package/dist/commands/add/hook.js +238 -0
- package/dist/commands/add/hook.js.map +1 -0
- package/dist/commands/add/index.d.ts +1 -0
- package/dist/commands/add/index.d.ts.map +1 -1
- package/dist/commands/add/index.js +3 -1
- package/dist/commands/add/index.js.map +1 -1
- package/dist/commands/add/marketplace.d.ts +25 -0
- package/dist/commands/add/marketplace.d.ts.map +1 -0
- package/dist/commands/add/marketplace.js +187 -0
- package/dist/commands/add/marketplace.js.map +1 -0
- package/dist/commands/add/mcp.d.ts +1 -0
- package/dist/commands/add/mcp.d.ts.map +1 -1
- package/dist/commands/add/mcp.js +5 -2
- package/dist/commands/add/mcp.js.map +1 -1
- package/dist/commands/add/plugin.d.ts +25 -0
- package/dist/commands/add/plugin.d.ts.map +1 -0
- package/dist/commands/add/plugin.js +190 -0
- package/dist/commands/add/plugin.js.map +1 -0
- package/dist/commands/add/prompt.d.ts +1 -0
- package/dist/commands/add/prompt.d.ts.map +1 -1
- package/dist/commands/add/prompt.js +5 -2
- package/dist/commands/add/prompt.js.map +1 -1
- package/dist/commands/add/rule.d.ts +1 -0
- package/dist/commands/add/rule.d.ts.map +1 -1
- package/dist/commands/add/rule.js +5 -2
- package/dist/commands/add/rule.js.map +1 -1
- package/dist/commands/add/skill.d.ts +1 -0
- package/dist/commands/add/skill.d.ts.map +1 -1
- package/dist/commands/add/skill.js +5 -2
- package/dist/commands/add/skill.js.map +1 -1
- package/dist/commands/backups.d.ts.map +1 -1
- package/dist/commands/backups.js +62 -39
- package/dist/commands/backups.js.map +1 -1
- package/dist/commands/cache/index.d.ts +1 -0
- package/dist/commands/cache/index.d.ts.map +1 -1
- package/dist/commands/cache/index.js +2 -0
- package/dist/commands/cache/index.js.map +1 -1
- package/dist/commands/config/get.d.ts.map +1 -1
- package/dist/commands/config/get.js +4 -1
- package/dist/commands/config/get.js.map +1 -1
- package/dist/commands/config/index.d.ts +1 -0
- package/dist/commands/config/index.d.ts.map +1 -1
- package/dist/commands/config/index.js +2 -0
- package/dist/commands/config/index.js.map +1 -1
- package/dist/commands/config/set.d.ts.map +1 -1
- package/dist/commands/config/set.js +8 -1
- package/dist/commands/config/set.js.map +1 -1
- package/dist/commands/install.d.ts +3 -0
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +63 -10
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/list/agents.d.ts +6 -0
- package/dist/commands/list/agents.d.ts.map +1 -0
- package/dist/commands/list/agents.js +6 -0
- package/dist/commands/list/agents.js.map +1 -0
- package/dist/commands/list/editors.d.ts +3 -4
- package/dist/commands/list/editors.d.ts.map +1 -1
- package/dist/commands/list/editors.js +4 -34
- package/dist/commands/list/editors.js.map +1 -1
- package/dist/commands/list/hooks.d.ts +6 -0
- package/dist/commands/list/hooks.d.ts.map +1 -0
- package/dist/commands/list/hooks.js +6 -0
- package/dist/commands/list/hooks.js.map +1 -0
- package/dist/commands/list/index.d.ts +8 -3
- package/dist/commands/list/index.d.ts.map +1 -1
- package/dist/commands/list/index.js +292 -67
- package/dist/commands/list/index.js.map +1 -1
- package/dist/commands/list/marketplaces.d.ts +6 -0
- package/dist/commands/list/marketplaces.d.ts.map +1 -0
- package/dist/commands/list/marketplaces.js +6 -0
- package/dist/commands/list/marketplaces.js.map +1 -0
- package/dist/commands/list/mcp.d.ts +3 -4
- package/dist/commands/list/mcp.d.ts.map +1 -1
- package/dist/commands/list/mcp.js +4 -42
- package/dist/commands/list/mcp.js.map +1 -1
- package/dist/commands/list/plugins.d.ts +6 -0
- package/dist/commands/list/plugins.d.ts.map +1 -0
- package/dist/commands/list/plugins.js +6 -0
- package/dist/commands/list/plugins.js.map +1 -0
- package/dist/commands/list/prompts.d.ts +3 -4
- package/dist/commands/list/prompts.d.ts.map +1 -1
- package/dist/commands/list/prompts.js +4 -56
- package/dist/commands/list/prompts.js.map +1 -1
- package/dist/commands/list/rules.d.ts +3 -4
- package/dist/commands/list/rules.d.ts.map +1 -1
- package/dist/commands/list/rules.js +4 -57
- package/dist/commands/list/rules.js.map +1 -1
- package/dist/commands/list/skills.d.ts +3 -4
- package/dist/commands/list/skills.d.ts.map +1 -1
- package/dist/commands/list/skills.js +4 -32
- package/dist/commands/list/skills.js.map +1 -1
- package/dist/commands/remove/agent.d.ts +22 -0
- package/dist/commands/remove/agent.d.ts.map +1 -0
- package/dist/commands/remove/agent.js +145 -0
- package/dist/commands/remove/agent.js.map +1 -0
- package/dist/commands/remove/hook.d.ts +24 -0
- package/dist/commands/remove/hook.d.ts.map +1 -0
- package/dist/commands/remove/hook.js +145 -0
- package/dist/commands/remove/hook.js.map +1 -0
- package/dist/commands/remove/index.d.ts +1 -0
- package/dist/commands/remove/index.d.ts.map +1 -1
- package/dist/commands/remove/index.js +3 -1
- package/dist/commands/remove/index.js.map +1 -1
- package/dist/commands/remove/marketplace.d.ts +23 -0
- package/dist/commands/remove/marketplace.d.ts.map +1 -0
- package/dist/commands/remove/marketplace.js +139 -0
- package/dist/commands/remove/marketplace.js.map +1 -0
- package/dist/commands/remove/mcp.d.ts +3 -0
- package/dist/commands/remove/mcp.d.ts.map +1 -1
- package/dist/commands/remove/mcp.js +29 -26
- package/dist/commands/remove/mcp.js.map +1 -1
- package/dist/commands/remove/plugin.d.ts +23 -0
- package/dist/commands/remove/plugin.d.ts.map +1 -0
- package/dist/commands/remove/plugin.js +139 -0
- package/dist/commands/remove/plugin.js.map +1 -0
- package/dist/commands/remove/prompt.d.ts +22 -0
- package/dist/commands/remove/prompt.d.ts.map +1 -0
- package/dist/commands/remove/prompt.js +145 -0
- package/dist/commands/remove/prompt.js.map +1 -0
- package/dist/commands/remove/rule.d.ts +22 -0
- package/dist/commands/remove/rule.d.ts.map +1 -0
- package/dist/commands/remove/rule.js +145 -0
- package/dist/commands/remove/rule.js.map +1 -0
- package/dist/commands/remove/skill.d.ts +3 -0
- package/dist/commands/remove/skill.d.ts.map +1 -1
- package/dist/commands/remove/skill.js +28 -20
- package/dist/commands/remove/skill.js.map +1 -1
- package/dist/commands/sync.d.ts +0 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +31 -18
- package/dist/commands/sync.js.map +1 -1
- package/dist/flags/save.d.ts +4 -0
- package/dist/flags/save.d.ts.map +1 -0
- package/dist/flags/save.js +9 -0
- package/dist/flags/save.js.map +1 -0
- package/dist/flags/scope.d.ts +17 -2
- package/dist/flags/scope.d.ts.map +1 -1
- package/dist/flags/scope.js +24 -2
- package/dist/flags/scope.js.map +1 -1
- package/dist/lib/add-command-helper.d.ts +3 -1
- package/dist/lib/add-command-helper.d.ts.map +1 -1
- package/dist/lib/add-command-helper.js +26 -22
- package/dist/lib/add-command-helper.js.map +1 -1
- package/dist/lib/apply-result-reporter.d.ts +13 -1
- package/dist/lib/apply-result-reporter.d.ts.map +1 -1
- package/dist/lib/apply-result-reporter.js +69 -13
- package/dist/lib/apply-result-reporter.js.map +1 -1
- package/dist/lib/delete-helper.d.ts +10 -1
- package/dist/lib/delete-helper.d.ts.map +1 -1
- package/dist/lib/delete-helper.js +92 -2
- package/dist/lib/delete-helper.js.map +1 -1
- package/dist/lib/install-helper.d.ts +24 -1
- package/dist/lib/install-helper.d.ts.map +1 -1
- package/dist/lib/install-helper.js +99 -15
- package/dist/lib/install-helper.js.map +1 -1
- package/dist/lib/lockfile-helper.d.ts +4 -1
- package/dist/lib/lockfile-helper.d.ts.map +1 -1
- package/dist/lib/lockfile-helper.js +28 -3
- package/dist/lib/lockfile-helper.js.map +1 -1
- package/dist/lib/resolve-removal-editors.d.ts +25 -0
- package/dist/lib/resolve-removal-editors.d.ts.map +1 -0
- package/dist/lib/resolve-removal-editors.js +42 -0
- package/dist/lib/resolve-removal-editors.js.map +1 -0
- package/dist/lib/search/registry.d.ts.map +1 -1
- package/dist/lib/search/registry.js +3 -2
- package/dist/lib/search/registry.js.map +1 -1
- package/oclif.manifest.json +3185 -495
- package/package.json +6 -6
|
@@ -1,64 +1,69 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { BaseCommand } from '../../base-command.js';
|
|
4
|
-
import { onlyFlag, parseSections, includesSection, configScopeFlags,
|
|
5
|
-
import { readState, importFromEditor, getAvailableEditors, getAcceptedEditorNames, isEditorInputName, normalizeEditorName, } from '@a1st/aix-core';
|
|
4
|
+
import { onlyFlag, parseSections, includesSection, configScopeFlags, resolveListScope, } from '../../flags/scope.js';
|
|
5
|
+
import { readState, importFromEditor, getAvailableEditors, getAcceptedEditorNames, isEditorInputName, normalizeEditorName, isDisabledConfigValue, } from '@a1st/aix-core';
|
|
6
6
|
import { resolveScope } from '@a1st/aix-schema';
|
|
7
|
-
const STATE_SECTIONS = [
|
|
7
|
+
const STATE_SECTIONS = [
|
|
8
|
+
'mcp',
|
|
9
|
+
'skills',
|
|
10
|
+
'rules',
|
|
11
|
+
'prompts',
|
|
12
|
+
'agents',
|
|
13
|
+
'hooks',
|
|
14
|
+
'plugins',
|
|
15
|
+
'marketplaces',
|
|
16
|
+
];
|
|
8
17
|
const CANONICAL_EDITORS = getAvailableEditors();
|
|
9
18
|
const VALID_EDITORS = getAcceptedEditorNames();
|
|
10
19
|
export default class List extends BaseCommand {
|
|
11
20
|
static aliases = ['ls'];
|
|
12
|
-
static description = 'List
|
|
21
|
+
static description = 'List native editor configuration';
|
|
13
22
|
static examples = [
|
|
14
23
|
'<%= config.bin %> <%= command.id %>',
|
|
15
24
|
'<%= config.bin %> <%= command.id %> --only skills',
|
|
16
25
|
'<%= config.bin %> <%= command.id %> --only rules --only mcp',
|
|
26
|
+
'<%= config.bin %> <%= command.id %> --only hooks',
|
|
17
27
|
'<%= config.bin %> <%= command.id %> --scope user',
|
|
18
28
|
'<%= config.bin %> <%= command.id %> --project',
|
|
19
29
|
'<%= config.bin %> <%= command.id %> --all',
|
|
20
|
-
'<%= config.bin %> <%= command.id %> --all --
|
|
21
|
-
'<%= config.bin %> <%= command.id %> --all --
|
|
22
|
-
'<%= config.bin %> <%= command.id %> --all --scope user --only mcp',
|
|
30
|
+
'<%= config.bin %> <%= command.id %> --all --target codex',
|
|
31
|
+
'<%= config.bin %> <%= command.id %> --all --target codex --target zed',
|
|
23
32
|
];
|
|
24
33
|
static flags = {
|
|
25
34
|
...onlyFlag,
|
|
26
35
|
...configScopeFlags,
|
|
27
36
|
all: Flags.boolean({
|
|
28
|
-
description: 'List
|
|
37
|
+
description: 'List user and project config from detected editors',
|
|
29
38
|
default: false,
|
|
39
|
+
exclusive: ['project', 'scope', 'user'],
|
|
30
40
|
}),
|
|
31
|
-
|
|
32
|
-
char: '
|
|
41
|
+
target: Flags.string({
|
|
42
|
+
char: 't',
|
|
43
|
+
aliases: ['editor'],
|
|
44
|
+
charAliases: ['e'],
|
|
33
45
|
description: 'Only show config from a specific editor (repeatable, case-insensitive)',
|
|
34
46
|
multiple: true,
|
|
35
47
|
}),
|
|
36
48
|
};
|
|
49
|
+
sectionsOverride;
|
|
37
50
|
async run() {
|
|
38
|
-
const sections = parseSections(this.flags),
|
|
39
|
-
|
|
40
|
-
// `-u` lists all items present in every editor's global config — never the project's
|
|
41
|
-
// ai.json/state. It always uses discovery: scan actual editor config directories to give
|
|
42
|
-
// a complete, accurate view of what is installed in those editors, including
|
|
43
|
-
// non-aix-managed items and items installed without an ai.json.
|
|
44
|
-
if (isUserScope) {
|
|
45
|
-
await this.listAllEditorConfig(sections, scopeFilter, editorFilter);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
// Editors explicitly requested via --all or -e also trigger direct config-file discovery.
|
|
49
|
-
if (showAll || editorFilter !== undefined) {
|
|
50
|
-
await this.listAllEditorConfig(sections, scopeFilter, editorFilter);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (this.flags.json) {
|
|
54
|
-
await this.listProjectConfigJson(sections, scopeFilter);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
await this.listProjectConfig(sections, scopeFilter);
|
|
51
|
+
const sections = this.sectionsOverride ? [...this.sectionsOverride] : parseSections(this.flags), scope = resolveListScope(this.flags), editorFilter = this.resolveEditorFilter();
|
|
52
|
+
await this.listAllEditorConfig(sections, scope === 'all' ? undefined : scope, editorFilter);
|
|
58
53
|
}
|
|
59
54
|
getConfigSections(config, sections) {
|
|
60
55
|
const result = {};
|
|
61
|
-
for (const section of [
|
|
56
|
+
for (const section of [
|
|
57
|
+
'skills',
|
|
58
|
+
'mcp',
|
|
59
|
+
'rules',
|
|
60
|
+
'prompts',
|
|
61
|
+
'agents',
|
|
62
|
+
'hooks',
|
|
63
|
+
'plugins',
|
|
64
|
+
'marketplaces',
|
|
65
|
+
'editors',
|
|
66
|
+
]) {
|
|
62
67
|
if (includesSection(sections, section)) {
|
|
63
68
|
result[section] = config[section] ?? {};
|
|
64
69
|
}
|
|
@@ -87,7 +92,17 @@ export default class List extends BaseCommand {
|
|
|
87
92
|
return result;
|
|
88
93
|
}
|
|
89
94
|
printConfigSections(config, sections) {
|
|
90
|
-
for (const section of [
|
|
95
|
+
for (const section of [
|
|
96
|
+
'skills',
|
|
97
|
+
'mcp',
|
|
98
|
+
'rules',
|
|
99
|
+
'prompts',
|
|
100
|
+
'agents',
|
|
101
|
+
'hooks',
|
|
102
|
+
'plugins',
|
|
103
|
+
'marketplaces',
|
|
104
|
+
'editors',
|
|
105
|
+
]) {
|
|
91
106
|
if (!includesSection(sections, section)) {
|
|
92
107
|
continue;
|
|
93
108
|
}
|
|
@@ -143,7 +158,7 @@ export default class List extends BaseCommand {
|
|
|
143
158
|
return STATE_SECTIONS.some((s) => Object.values(state.installed[s]).some((meta) => meta.editors.some((e) => editorSet.has(e))));
|
|
144
159
|
}
|
|
145
160
|
resolveEditorFilter() {
|
|
146
|
-
const editors = this.flags.
|
|
161
|
+
const editors = this.flags.target;
|
|
147
162
|
if (!editors || editors.length === 0) {
|
|
148
163
|
return undefined;
|
|
149
164
|
}
|
|
@@ -162,6 +177,9 @@ export default class List extends BaseCommand {
|
|
|
162
177
|
rules: 'Rules',
|
|
163
178
|
prompts: 'Prompts',
|
|
164
179
|
agents: 'Agents',
|
|
180
|
+
hooks: 'Hooks',
|
|
181
|
+
plugins: 'Plugins',
|
|
182
|
+
marketplaces: 'Marketplaces',
|
|
165
183
|
editors: 'Editors',
|
|
166
184
|
};
|
|
167
185
|
return names[section] ?? section;
|
|
@@ -170,17 +188,18 @@ export default class List extends BaseCommand {
|
|
|
170
188
|
* Scan editors' actual config directories and collect any discovered items.
|
|
171
189
|
*/
|
|
172
190
|
async collectEditorConfig(editors, scope) {
|
|
173
|
-
const projectRoot = process.cwd(), projectState = await readState('project', projectRoot), userState = await readState('user'),
|
|
174
|
-
for (const editor of editors) {
|
|
191
|
+
const projectRoot = process.cwd(), projectState = await readState('project', projectRoot), userState = await readState('user'), imported = await Promise.all(editors.map(async (editor) => {
|
|
175
192
|
try {
|
|
176
|
-
// eslint-disable-next-line no-await-in-loop -- Sequential for consistency
|
|
177
193
|
const result = await importFromEditor(editor, { projectRoot, scope });
|
|
178
|
-
|
|
179
|
-
results.push({ editor, result });
|
|
180
|
-
}
|
|
194
|
+
return { editor, result };
|
|
181
195
|
}
|
|
182
196
|
catch {
|
|
183
|
-
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
})), results = [];
|
|
200
|
+
for (const entry of imported) {
|
|
201
|
+
if (entry && (this.hasEditorItems(entry.result) || entry.result.warnings.length > 0)) {
|
|
202
|
+
results.push(entry);
|
|
184
203
|
}
|
|
185
204
|
}
|
|
186
205
|
return { results, projectState, userState };
|
|
@@ -190,22 +209,64 @@ export default class List extends BaseCommand {
|
|
|
190
209
|
* Scans actual editor config directories to discover what's installed.
|
|
191
210
|
*/
|
|
192
211
|
async listAllEditorConfig(sections, scopeFilter, editorFilter) {
|
|
193
|
-
const editors = editorFilter ?? CANONICAL_EDITORS, scope = scopeFilter ?? 'all', { results, projectState, userState } = await this.collectEditorConfig(editors, scope), context = { sections, scopeFilter, projectState, userState };
|
|
194
|
-
if (
|
|
195
|
-
|
|
212
|
+
const editors = editorFilter ?? CANONICAL_EDITORS, scope = scopeFilter ?? 'all', { results, projectState, userState } = await this.collectEditorConfig(editors, scope), context = { sections, scopeFilter, projectState, userState }, isEditorsOnly = sections.length === 1 && sections[0] === 'editors';
|
|
213
|
+
if (isEditorsOnly) {
|
|
214
|
+
const detectedEditors = results.map(({ editor }) => editor);
|
|
215
|
+
if (this.flags.json) {
|
|
216
|
+
this.output.json({
|
|
217
|
+
version: 1,
|
|
218
|
+
scope: scopeFilter ?? 'all',
|
|
219
|
+
targets: editors,
|
|
220
|
+
editors: detectedEditors,
|
|
221
|
+
items: [],
|
|
222
|
+
warnings: results.flatMap(({ editor, result }) => {
|
|
223
|
+
return result.warnings.map((warning) => ({ editor, warning }));
|
|
224
|
+
}),
|
|
225
|
+
});
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (detectedEditors.length === 0) {
|
|
229
|
+
this.output.info('No editors with AI configuration found.');
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
for (const editor of detectedEditors) {
|
|
233
|
+
this.output.log(editor);
|
|
234
|
+
}
|
|
196
235
|
return;
|
|
197
236
|
}
|
|
198
237
|
if (this.flags.json) {
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
238
|
+
const items = results.flatMap(({ editor, result }) => {
|
|
239
|
+
return this.getEditorItemRows(editor, result, context).map((row) => ({
|
|
240
|
+
editor,
|
|
241
|
+
type: row.type,
|
|
242
|
+
name: row.name,
|
|
243
|
+
source: row.source,
|
|
244
|
+
status: row.status,
|
|
245
|
+
scope: row.scope,
|
|
246
|
+
path: row.path,
|
|
247
|
+
}));
|
|
248
|
+
});
|
|
249
|
+
this.output.json({
|
|
250
|
+
version: 1,
|
|
251
|
+
scope: scopeFilter ?? 'all',
|
|
252
|
+
targets: editors,
|
|
253
|
+
items,
|
|
254
|
+
warnings: results.flatMap(({ editor, result }) => {
|
|
255
|
+
return result.warnings.map((warning) => ({ editor, warning }));
|
|
256
|
+
}),
|
|
257
|
+
});
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
if (results.length === 0) {
|
|
261
|
+
this.output.info('No AI configuration found in any editor.');
|
|
204
262
|
return;
|
|
205
263
|
}
|
|
206
264
|
let printed = 0;
|
|
207
265
|
for (const { editor, result } of results) {
|
|
208
266
|
const didPrint = this.printEditorConfig(editor, result, context, printed > 0);
|
|
267
|
+
for (const warning of result.warnings) {
|
|
268
|
+
this.output.warn(`${editor}: ${warning}`);
|
|
269
|
+
}
|
|
209
270
|
if (didPrint) {
|
|
210
271
|
printed++;
|
|
211
272
|
}
|
|
@@ -265,7 +326,7 @@ export default class List extends BaseCommand {
|
|
|
265
326
|
}
|
|
266
327
|
const editors = {};
|
|
267
328
|
for (const { editor, result: editorResult } of results) {
|
|
268
|
-
editors[editor] = this.buildEditorJson(editorResult, context);
|
|
329
|
+
editors[editor] = this.buildEditorJson(editor, editorResult, context);
|
|
269
330
|
}
|
|
270
331
|
if (Object.keys(editors).length > 0) {
|
|
271
332
|
result.editors = editors;
|
|
@@ -283,15 +344,18 @@ export default class List extends BaseCommand {
|
|
|
283
344
|
result.rules.length > 0 ||
|
|
284
345
|
Object.keys(result.skills).length > 0 ||
|
|
285
346
|
Object.keys(result.prompts).length > 0 ||
|
|
286
|
-
Object.keys(result.agents).length > 0
|
|
347
|
+
Object.keys(result.agents).length > 0 ||
|
|
348
|
+
Object.keys(result.hooks).length > 0 ||
|
|
349
|
+
Object.keys(result.plugins).length > 0 ||
|
|
350
|
+
Object.keys(result.marketplaces).length > 0);
|
|
287
351
|
}
|
|
288
|
-
buildEditorJson(result, context) {
|
|
352
|
+
buildEditorJson(editor, result, context) {
|
|
289
353
|
const out = {};
|
|
290
354
|
const { sections, scopeFilter, projectState, userState } = context;
|
|
291
355
|
if (includesSection(sections, 'mcp') && Object.keys(result.mcp).length > 0) {
|
|
292
356
|
const items = {};
|
|
293
357
|
for (const [name] of Object.entries(result.mcp)) {
|
|
294
|
-
const managed = this.isAixManaged(name, 'mcp', projectState, userState);
|
|
358
|
+
const managed = this.isAixManaged({ editor, name, section: 'mcp', projectState, userState });
|
|
295
359
|
const scope = managed?.scope ?? result.scopes.mcp[name];
|
|
296
360
|
if (scopeFilter && scope !== scopeFilter) {
|
|
297
361
|
continue;
|
|
@@ -309,7 +373,7 @@ export default class List extends BaseCommand {
|
|
|
309
373
|
if (includesSection(sections, 'rules') && result.rules.length > 0) {
|
|
310
374
|
const items = {};
|
|
311
375
|
for (const rule of result.rules) {
|
|
312
|
-
const managed = this.isAixManaged(rule.name, 'rules', projectState, userState);
|
|
376
|
+
const managed = this.isAixManaged({ editor, name: rule.name, section: 'rules', projectState, userState });
|
|
313
377
|
const scope = rule.scope ?? result.scopes.rules[rule.name] ?? managed?.scope;
|
|
314
378
|
if (scopeFilter && scope !== scopeFilter) {
|
|
315
379
|
continue;
|
|
@@ -327,7 +391,7 @@ export default class List extends BaseCommand {
|
|
|
327
391
|
if (includesSection(sections, 'skills') && Object.keys(result.skills).length > 0) {
|
|
328
392
|
const items = {};
|
|
329
393
|
for (const [name] of Object.entries(result.skills)) {
|
|
330
|
-
const managed = this.isAixManaged(name, 'skills', projectState, userState);
|
|
394
|
+
const managed = this.isAixManaged({ editor, name, section: 'skills', projectState, userState });
|
|
331
395
|
const scope = managed?.scope ?? result.scopes.skills[name];
|
|
332
396
|
if (scopeFilter && scope !== scopeFilter) {
|
|
333
397
|
continue;
|
|
@@ -345,7 +409,7 @@ export default class List extends BaseCommand {
|
|
|
345
409
|
if (includesSection(sections, 'prompts') && Object.keys(result.prompts).length > 0) {
|
|
346
410
|
const items = {};
|
|
347
411
|
for (const [name] of Object.entries(result.prompts)) {
|
|
348
|
-
const managed = this.isAixManaged(name, 'prompts', projectState, userState);
|
|
412
|
+
const managed = this.isAixManaged({ editor, name, section: 'prompts', projectState, userState });
|
|
349
413
|
const scope = managed?.scope ?? result.scopes.prompts[name];
|
|
350
414
|
if (scopeFilter && scope !== scopeFilter) {
|
|
351
415
|
continue;
|
|
@@ -363,7 +427,7 @@ export default class List extends BaseCommand {
|
|
|
363
427
|
if (includesSection(sections, 'agents') && Object.keys(result.agents).length > 0) {
|
|
364
428
|
const items = {};
|
|
365
429
|
for (const [name] of Object.entries(result.agents)) {
|
|
366
|
-
const managed = this.isAixManaged(name, 'agents', projectState, userState);
|
|
430
|
+
const managed = this.isAixManaged({ editor, name, section: 'agents', projectState, userState });
|
|
367
431
|
const scope = managed?.scope ?? result.scopes.agents[name];
|
|
368
432
|
if (scopeFilter && scope !== scopeFilter) {
|
|
369
433
|
continue;
|
|
@@ -378,10 +442,63 @@ export default class List extends BaseCommand {
|
|
|
378
442
|
out.agents = items;
|
|
379
443
|
}
|
|
380
444
|
}
|
|
445
|
+
if (includesSection(sections, 'hooks') && Object.keys(result.hooks).length > 0) {
|
|
446
|
+
const items = {};
|
|
447
|
+
for (const [event, matchers] of Object.entries(result.hooks)) {
|
|
448
|
+
const managed = this.isAixManaged({ editor, name: event, section: 'hooks', projectState, userState }), scope = managed?.scope ?? result.scopes.hooks[event];
|
|
449
|
+
if (scopeFilter && scope !== scopeFilter) {
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
const hookItems = this.flattenHookItems(event, matchers);
|
|
453
|
+
for (const hookItem of hookItems) {
|
|
454
|
+
items[hookItem.name] = {
|
|
455
|
+
source: managed ? 'aix' : 'external',
|
|
456
|
+
scope,
|
|
457
|
+
path: result.paths.hooks[event],
|
|
458
|
+
event,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
if (Object.keys(items).length > 0) {
|
|
463
|
+
out.hooks = items;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
if (includesSection(sections, 'plugins') && Object.keys(result.plugins).length > 0) {
|
|
467
|
+
const items = {};
|
|
468
|
+
for (const name of Object.keys(result.plugins)) {
|
|
469
|
+
const managed = this.isAixManaged({ editor, name, section: 'plugins', projectState, userState }), scope = managed?.scope ?? result.scopes.plugins[name];
|
|
470
|
+
if (!scopeFilter || scope === scopeFilter) {
|
|
471
|
+
items[name] = {
|
|
472
|
+
source: managed ? 'aix' : 'external',
|
|
473
|
+
scope,
|
|
474
|
+
path: result.paths.plugins[name],
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
if (Object.keys(items).length > 0) {
|
|
479
|
+
out.plugins = items;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (includesSection(sections, 'marketplaces') && Object.keys(result.marketplaces).length > 0) {
|
|
483
|
+
const items = {};
|
|
484
|
+
for (const name of Object.keys(result.marketplaces)) {
|
|
485
|
+
const managed = this.isAixManaged({ editor, name, section: 'marketplaces', projectState, userState }), scope = managed?.scope ?? result.scopes.marketplaces[name];
|
|
486
|
+
if (!scopeFilter || scope === scopeFilter) {
|
|
487
|
+
items[name] = {
|
|
488
|
+
source: managed ? 'aix' : 'external',
|
|
489
|
+
scope,
|
|
490
|
+
path: result.paths.marketplaces[name],
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
if (Object.keys(items).length > 0) {
|
|
495
|
+
out.marketplaces = items;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
381
498
|
return out;
|
|
382
499
|
}
|
|
383
500
|
printEditorConfig(editor, result, context, addLeadingBlankLine) {
|
|
384
|
-
const rows = this.getEditorItemRows(result, context);
|
|
501
|
+
const rows = this.getEditorItemRows(editor, result, context);
|
|
385
502
|
if (rows.length === 0) {
|
|
386
503
|
return false;
|
|
387
504
|
}
|
|
@@ -392,11 +509,12 @@ export default class List extends BaseCommand {
|
|
|
392
509
|
this.printEditorRows(rows);
|
|
393
510
|
return true;
|
|
394
511
|
}
|
|
395
|
-
getEditorItemRows(result, context) {
|
|
512
|
+
getEditorItemRows(editor, result, context) {
|
|
396
513
|
const rows = [];
|
|
397
514
|
const { sections } = context;
|
|
398
515
|
if (includesSection(sections, 'mcp')) {
|
|
399
516
|
rows.push(...Object.keys(result.mcp).flatMap((name) => this.toEditorItemRow({
|
|
517
|
+
editor,
|
|
400
518
|
type: 'mcp',
|
|
401
519
|
name,
|
|
402
520
|
section: 'mcp',
|
|
@@ -406,6 +524,7 @@ export default class List extends BaseCommand {
|
|
|
406
524
|
}
|
|
407
525
|
if (includesSection(sections, 'rules')) {
|
|
408
526
|
rows.push(...result.rules.flatMap((rule) => this.toEditorItemRow({
|
|
527
|
+
editor,
|
|
409
528
|
type: 'rule',
|
|
410
529
|
name: rule.name,
|
|
411
530
|
section: 'rules',
|
|
@@ -415,6 +534,7 @@ export default class List extends BaseCommand {
|
|
|
415
534
|
}
|
|
416
535
|
if (includesSection(sections, 'skills')) {
|
|
417
536
|
rows.push(...Object.keys(result.skills).flatMap((name) => this.toEditorItemRow({
|
|
537
|
+
editor,
|
|
418
538
|
type: 'skill',
|
|
419
539
|
name,
|
|
420
540
|
section: 'skills',
|
|
@@ -424,6 +544,7 @@ export default class List extends BaseCommand {
|
|
|
424
544
|
}
|
|
425
545
|
if (includesSection(sections, 'prompts')) {
|
|
426
546
|
rows.push(...Object.keys(result.prompts).flatMap((name) => this.toEditorItemRow({
|
|
547
|
+
editor,
|
|
427
548
|
type: 'prompt',
|
|
428
549
|
name,
|
|
429
550
|
section: 'prompts',
|
|
@@ -433,6 +554,7 @@ export default class List extends BaseCommand {
|
|
|
433
554
|
}
|
|
434
555
|
if (includesSection(sections, 'agents')) {
|
|
435
556
|
rows.push(...Object.keys(result.agents).flatMap((name) => this.toEditorItemRow({
|
|
557
|
+
editor,
|
|
436
558
|
type: 'agent',
|
|
437
559
|
name,
|
|
438
560
|
section: 'agents',
|
|
@@ -440,11 +562,112 @@ export default class List extends BaseCommand {
|
|
|
440
562
|
detectedScope: result.scopes.agents[name],
|
|
441
563
|
}, context)));
|
|
442
564
|
}
|
|
565
|
+
if (includesSection(sections, 'hooks')) {
|
|
566
|
+
for (const [event, matchers] of Object.entries(result.hooks)) {
|
|
567
|
+
const hookItems = this.flattenHookItems(event, matchers);
|
|
568
|
+
for (const hookItem of hookItems) {
|
|
569
|
+
rows.push(...this.toEditorItemRow({
|
|
570
|
+
editor,
|
|
571
|
+
type: 'hook',
|
|
572
|
+
name: hookItem.name,
|
|
573
|
+
section: 'hooks',
|
|
574
|
+
path: result.paths.hooks[event],
|
|
575
|
+
detectedScope: result.scopes.hooks[event],
|
|
576
|
+
managedKey: event,
|
|
577
|
+
}, context));
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
if (includesSection(sections, 'plugins')) {
|
|
582
|
+
rows.push(...Object.keys(result.plugins).flatMap((name) => this.toEditorItemRow({
|
|
583
|
+
editor,
|
|
584
|
+
type: 'plugin',
|
|
585
|
+
name,
|
|
586
|
+
section: 'plugins',
|
|
587
|
+
path: result.paths.plugins[name],
|
|
588
|
+
detectedScope: result.scopes.plugins[name],
|
|
589
|
+
status: isDisabledConfigValue(result.plugins[name]) ? 'disabled' : 'enabled',
|
|
590
|
+
}, context)));
|
|
591
|
+
}
|
|
592
|
+
if (includesSection(sections, 'marketplaces')) {
|
|
593
|
+
rows.push(...Object.keys(result.marketplaces).flatMap((name) => this.toEditorItemRow({
|
|
594
|
+
editor,
|
|
595
|
+
type: 'marketplace',
|
|
596
|
+
name,
|
|
597
|
+
section: 'marketplaces',
|
|
598
|
+
path: result.paths.marketplaces[name],
|
|
599
|
+
detectedScope: result.scopes.marketplaces[name],
|
|
600
|
+
status: isDisabledConfigValue(result.marketplaces[name]) ? 'disabled' : 'enabled',
|
|
601
|
+
}, context)));
|
|
602
|
+
}
|
|
603
|
+
rows.sort((left, right) => {
|
|
604
|
+
const leftKey = `${left.type}\0${left.scope ?? ''}\0${left.name}\0${left.path ?? ''}`, rightKey = `${right.type}\0${right.scope ?? ''}\0${right.name}\0${right.path ?? ''}`;
|
|
605
|
+
return leftKey.localeCompare(rightKey);
|
|
606
|
+
});
|
|
443
607
|
return rows;
|
|
444
608
|
}
|
|
609
|
+
formatHookActionTarget(action) {
|
|
610
|
+
const rawCommand = action.command ?? action.bash ?? action.powershell, command = rawCommand?.replace(/\s+/g, ' ').trim();
|
|
611
|
+
if (action.name && command) {
|
|
612
|
+
return `${action.name}: ${command}`;
|
|
613
|
+
}
|
|
614
|
+
if (action.name && action.url) {
|
|
615
|
+
return `${action.name}: ${action.url}`;
|
|
616
|
+
}
|
|
617
|
+
if (action.name && action.prompt) {
|
|
618
|
+
const prompt = action.prompt.replace(/\s+/g, ' ').trim(), displayPrompt = prompt.length > 60 ? `${prompt.slice(0, 57)}...` : prompt;
|
|
619
|
+
return `${action.name}: prompt "${displayPrompt}"`;
|
|
620
|
+
}
|
|
621
|
+
if (action.name && action.mcp_tool) {
|
|
622
|
+
const server = action.mcp_server ? `${action.mcp_server}/` : '';
|
|
623
|
+
return `${action.name}: mcp ${server}${action.mcp_tool}`;
|
|
624
|
+
}
|
|
625
|
+
if (action.name) {
|
|
626
|
+
return action.name;
|
|
627
|
+
}
|
|
628
|
+
if (command) {
|
|
629
|
+
return command;
|
|
630
|
+
}
|
|
631
|
+
if (action.url) {
|
|
632
|
+
return `http ${action.url}`;
|
|
633
|
+
}
|
|
634
|
+
if (action.prompt) {
|
|
635
|
+
const prompt = action.prompt.replace(/\s+/g, ' ').trim(), displayPrompt = prompt.length > 60 ? `${prompt.slice(0, 57)}...` : prompt;
|
|
636
|
+
return `prompt "${displayPrompt}"`;
|
|
637
|
+
}
|
|
638
|
+
if (action.mcp_tool) {
|
|
639
|
+
const server = action.mcp_server ? `${action.mcp_server}/` : '';
|
|
640
|
+
return `mcp ${server}${action.mcp_tool}`;
|
|
641
|
+
}
|
|
642
|
+
return action.description ?? 'hook';
|
|
643
|
+
}
|
|
644
|
+
formatHookItemName(event, matcher, action) {
|
|
645
|
+
const matcherPart = matcher ? ` [${matcher}]` : '';
|
|
646
|
+
if (!action) {
|
|
647
|
+
return `${event}${matcherPart}`;
|
|
648
|
+
}
|
|
649
|
+
const target = this.formatHookActionTarget(action);
|
|
650
|
+
return `${event}${matcherPart} -> ${target}`;
|
|
651
|
+
}
|
|
652
|
+
flattenHookItems(event, matchers) {
|
|
653
|
+
if (!matchers || matchers.length === 0) {
|
|
654
|
+
return [{ name: event }];
|
|
655
|
+
}
|
|
656
|
+
const items = [];
|
|
657
|
+
for (const matcher of matchers) {
|
|
658
|
+
const hooks = matcher.hooks ?? [];
|
|
659
|
+
if (hooks.length === 0) {
|
|
660
|
+
items.push({ name: this.formatHookItemName(event, matcher.matcher) });
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
for (const action of hooks) {
|
|
664
|
+
items.push({ name: this.formatHookItemName(event, matcher.matcher, action) });
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return items.length > 0 ? items : [{ name: event }];
|
|
668
|
+
}
|
|
445
669
|
toEditorItemRow(input, context) {
|
|
446
|
-
const { type, name, section, path, detectedScope } = input, { scopeFilter, projectState, userState } = context;
|
|
447
|
-
const managed = this.isAixManaged(name, section, projectState, userState), scope = detectedScope ?? managed?.scope;
|
|
670
|
+
const { editor, type, name, section, path, detectedScope, status = 'enabled', managedKey } = input, { scopeFilter, projectState, userState } = context, managed = this.isAixManaged({ editor, name: managedKey ?? name, section, projectState, userState }), scope = detectedScope ?? managed?.scope;
|
|
448
671
|
if (scopeFilter && scope !== scopeFilter) {
|
|
449
672
|
return [];
|
|
450
673
|
}
|
|
@@ -453,26 +676,28 @@ export default class List extends BaseCommand {
|
|
|
453
676
|
type,
|
|
454
677
|
name,
|
|
455
678
|
source: managed ? 'aix' : 'external',
|
|
679
|
+
status,
|
|
456
680
|
scope,
|
|
457
681
|
path,
|
|
458
682
|
},
|
|
459
683
|
];
|
|
460
684
|
}
|
|
461
685
|
printEditorRows(rows) {
|
|
462
|
-
const typeWidth = Math.max('type'.length, ...rows.map((row) => row.type.length)), scopeWidth = Math.max('scope'.length, ...rows.map((row) => (row.scope ?? 'unknown').length)), sourceWidth = Math.max('source'.length, ...rows.map((row) => row.source.length)), nameWidth = Math.max('name'.length, ...rows.map((row) => row.name.length));
|
|
463
|
-
const header = ` ${'type'.padEnd(typeWidth)} ${'scope'.padEnd(scopeWidth)} ${'source'.padEnd(sourceWidth)} ${'name'.padEnd(nameWidth)} path`;
|
|
686
|
+
const typeWidth = Math.max('type'.length, ...rows.map((row) => row.type.length)), scopeWidth = Math.max('scope'.length, ...rows.map((row) => (row.scope ?? 'unknown').length)), sourceWidth = Math.max('source'.length, ...rows.map((row) => row.source.length)), statusWidth = Math.max('status'.length, ...rows.map((row) => row.status.length)), nameWidth = Math.max('name'.length, ...rows.map((row) => row.name.length));
|
|
687
|
+
const header = ` ${'type'.padEnd(typeWidth)} ${'scope'.padEnd(scopeWidth)} ${'source'.padEnd(sourceWidth)} ${'status'.padEnd(statusWidth)} ${'name'.padEnd(nameWidth)} path`;
|
|
464
688
|
this.output.log(chalk.dim(header));
|
|
465
689
|
this.output.log(chalk.dim(` ${'-'.repeat(header.length - 2)}`));
|
|
466
690
|
for (const row of rows) {
|
|
467
|
-
const type = row.type.padEnd(typeWidth), scope = (row.scope ?? 'unknown').padEnd(scopeWidth), source = row.source.padEnd(sourceWidth), name = row.name.padEnd(nameWidth), sourceColor = row.source === 'aix' ? chalk.green : chalk.dim;
|
|
468
|
-
this.output.log(` ${chalk.magenta(type)} ${chalk.dim(scope)} ${sourceColor(source)} ${this.output.cyan(name)} ${chalk.dim(row.path ?? '')}`);
|
|
691
|
+
const type = row.type.padEnd(typeWidth), scope = (row.scope ?? 'unknown').padEnd(scopeWidth), source = row.source.padEnd(sourceWidth), status = row.status.padEnd(statusWidth), name = row.name.padEnd(nameWidth), sourceColor = row.source === 'aix' ? chalk.green : chalk.blue, statusColor = row.status === 'disabled' ? chalk.yellow : chalk.dim;
|
|
692
|
+
this.output.log(` ${chalk.magenta(type)} ${chalk.dim(scope)} ${sourceColor(source)} ${statusColor(status)} ${this.output.cyan(name)} ${chalk.dim(row.path ?? '')}`);
|
|
469
693
|
}
|
|
470
694
|
}
|
|
471
|
-
isAixManaged(
|
|
472
|
-
|
|
695
|
+
isAixManaged(options) {
|
|
696
|
+
const { editor, name, section, projectState, userState } = options;
|
|
697
|
+
if (projectState.installed[section][name]?.editors.includes(editor)) {
|
|
473
698
|
return { scope: 'project' };
|
|
474
699
|
}
|
|
475
|
-
if (userState.installed[section][name]) {
|
|
700
|
+
if (userState.installed[section][name]?.editors.includes(editor)) {
|
|
476
701
|
return { scope: 'user' };
|
|
477
702
|
}
|
|
478
703
|
return undefined;
|