@seedcli/core 0.1.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/LICENSE +21 -0
- package/dist/command/help.d.ts +59 -0
- package/dist/command/help.d.ts.map +1 -0
- package/dist/command/help.js +216 -0
- package/dist/command/help.js.map +1 -0
- package/dist/command/parser.d.ts +27 -0
- package/dist/command/parser.d.ts.map +1 -0
- package/dist/command/parser.js +259 -0
- package/dist/command/parser.js.map +1 -0
- package/dist/command/router.d.ts +34 -0
- package/dist/command/router.d.ts.map +1 -0
- package/dist/command/router.js +90 -0
- package/dist/command/router.js.map +1 -0
- package/dist/discovery/auto-discover.d.ts +26 -0
- package/dist/discovery/auto-discover.d.ts.map +1 -0
- package/dist/discovery/auto-discover.js +138 -0
- package/dist/discovery/auto-discover.js.map +1 -0
- package/dist/discovery/index.d.ts +3 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +2 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin/errors.d.ts +23 -0
- package/dist/plugin/errors.d.ts.map +1 -0
- package/dist/plugin/errors.js +45 -0
- package/dist/plugin/errors.js.map +1 -0
- package/dist/plugin/index.d.ts +6 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +6 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/loader.d.ts +12 -0
- package/dist/plugin/loader.d.ts.map +1 -0
- package/dist/plugin/loader.js +33 -0
- package/dist/plugin/loader.js.map +1 -0
- package/dist/plugin/registry.d.ts +32 -0
- package/dist/plugin/registry.d.ts.map +1 -0
- package/dist/plugin/registry.js +101 -0
- package/dist/plugin/registry.js.map +1 -0
- package/dist/plugin/topo-sort.d.ts +8 -0
- package/dist/plugin/topo-sort.d.ts.map +1 -0
- package/dist/plugin/topo-sort.js +60 -0
- package/dist/plugin/topo-sort.js.map +1 -0
- package/dist/plugin/validator.d.ts +17 -0
- package/dist/plugin/validator.d.ts.map +1 -0
- package/dist/plugin/validator.js +58 -0
- package/dist/plugin/validator.js.map +1 -0
- package/dist/runtime/builder.d.ts +70 -0
- package/dist/runtime/builder.d.ts.map +1 -0
- package/dist/runtime/builder.js +108 -0
- package/dist/runtime/builder.js.map +1 -0
- package/dist/runtime/runtime.d.ts +53 -0
- package/dist/runtime/runtime.d.ts.map +1 -0
- package/dist/runtime/runtime.js +424 -0
- package/dist/runtime/runtime.js.map +1 -0
- package/dist/types/args.d.ts +93 -0
- package/dist/types/args.d.ts.map +1 -0
- package/dist/types/args.js +9 -0
- package/dist/types/args.js.map +1 -0
- package/dist/types/command.d.ts +60 -0
- package/dist/types/command.d.ts.map +1 -0
- package/dist/types/command.js +26 -0
- package/dist/types/command.js.map +1 -0
- package/dist/types/config.d.ts +61 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +17 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/extension.d.ts +30 -0
- package/dist/types/extension.d.ts.map +1 -0
- package/dist/types/extension.js +16 -0
- package/dist/types/extension.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/modules.d.ts +47 -0
- package/dist/types/modules.d.ts.map +1 -0
- package/dist/types/modules.js +5 -0
- package/dist/types/modules.js.map +1 -0
- package/dist/types/plugin.d.ts +40 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +17 -0
- package/dist/types/plugin.js.map +1 -0
- package/dist/types/toolbox.d.ts +54 -0
- package/dist/types/toolbox.d.ts.map +1 -0
- package/dist/types/toolbox.js +2 -0
- package/dist/types/toolbox.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { levenshtein } from "./parser.js";
|
|
2
|
+
// ─── Router ───
|
|
3
|
+
/**
|
|
4
|
+
* Route argv to a registered command.
|
|
5
|
+
*
|
|
6
|
+
* Algorithm:
|
|
7
|
+
* 1. Split argv into tokens
|
|
8
|
+
* 2. Try exact match (including aliases)
|
|
9
|
+
* 3. Try subcommand matching (e.g., ["db", "migrate"] → db.subcommands.migrate)
|
|
10
|
+
* 4. If no match, compute fuzzy suggestions
|
|
11
|
+
* 5. Return { command, argv, suggestions }
|
|
12
|
+
*/
|
|
13
|
+
export function route(argv, commands) {
|
|
14
|
+
if (argv.length === 0) {
|
|
15
|
+
return { command: null, argv: [], suggestions: [] };
|
|
16
|
+
}
|
|
17
|
+
const token = argv[0];
|
|
18
|
+
// 1. Exact match by name or alias
|
|
19
|
+
const matched = findCommand(token, commands);
|
|
20
|
+
if (matched) {
|
|
21
|
+
const remaining = argv.slice(1);
|
|
22
|
+
// 2. Try subcommand resolution
|
|
23
|
+
if (matched.subcommands && matched.subcommands.length > 0 && remaining.length > 0) {
|
|
24
|
+
const subResult = route(remaining, matched.subcommands);
|
|
25
|
+
if (subResult.command) {
|
|
26
|
+
return subResult;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return { command: matched, argv: remaining, suggestions: [] };
|
|
30
|
+
}
|
|
31
|
+
// 3. No match — compute suggestions
|
|
32
|
+
const suggestions = getSuggestions(token, commands);
|
|
33
|
+
return { command: null, argv, suggestions };
|
|
34
|
+
}
|
|
35
|
+
// ─── Helpers ───
|
|
36
|
+
/**
|
|
37
|
+
* Find a command by exact name or alias match.
|
|
38
|
+
*/
|
|
39
|
+
function findCommand(name, commands) {
|
|
40
|
+
for (const cmd of commands) {
|
|
41
|
+
if (cmd.name === name)
|
|
42
|
+
return cmd;
|
|
43
|
+
if (cmd.alias?.includes(name))
|
|
44
|
+
return cmd;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get fuzzy suggestions for an unrecognized command name.
|
|
50
|
+
*
|
|
51
|
+
* Returns commands sorted by Levenshtein distance, filtered to:
|
|
52
|
+
* - distance ≤ 3, or
|
|
53
|
+
* - input is a prefix of the command name
|
|
54
|
+
*/
|
|
55
|
+
function getSuggestions(input, commands) {
|
|
56
|
+
const suggestions = [];
|
|
57
|
+
const lowerInput = input.toLowerCase();
|
|
58
|
+
for (const cmd of commands) {
|
|
59
|
+
if (cmd.hidden)
|
|
60
|
+
continue;
|
|
61
|
+
const distance = levenshtein(lowerInput, cmd.name.toLowerCase());
|
|
62
|
+
// Include if close enough or if input is a prefix
|
|
63
|
+
if (distance <= 3 || cmd.name.toLowerCase().startsWith(lowerInput)) {
|
|
64
|
+
suggestions.push({
|
|
65
|
+
name: cmd.name,
|
|
66
|
+
description: cmd.description,
|
|
67
|
+
distance,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Sort by distance (closest first)
|
|
72
|
+
suggestions.sort((a, b) => a.distance - b.distance);
|
|
73
|
+
return suggestions;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Flatten all commands (including subcommands) into a flat list.
|
|
77
|
+
* Useful for help generation.
|
|
78
|
+
*/
|
|
79
|
+
export function flattenCommands(commands, prefix = "") {
|
|
80
|
+
const result = [];
|
|
81
|
+
for (const cmd of commands) {
|
|
82
|
+
const fullName = prefix ? `${prefix} ${cmd.name}` : cmd.name;
|
|
83
|
+
result.push({ fullName, command: cmd });
|
|
84
|
+
if (cmd.subcommands) {
|
|
85
|
+
result.push(...flattenCommands(cmd.subcommands, fullName));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/command/router.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAmB1C,iBAAiB;AAEjB;;;;;;;;;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AC7D,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;QAExC,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC5D,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Command } from "../types/command.js";
|
|
2
|
+
import type { ExtensionConfig } from "../types/extension.js";
|
|
3
|
+
export interface AutoDiscoveryResult {
|
|
4
|
+
commands: Command[];
|
|
5
|
+
extensions: ExtensionConfig[];
|
|
6
|
+
}
|
|
7
|
+
export declare class DiscoveryError extends Error {
|
|
8
|
+
readonly filePath: string;
|
|
9
|
+
constructor(message: string, filePath: string);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Discover commands from a directory.
|
|
13
|
+
* Files become commands, nested directories become subcommands.
|
|
14
|
+
* An `index.ts` in a subdirectory provides the parent command config.
|
|
15
|
+
*/
|
|
16
|
+
export declare function discoverCommands(baseDir: string): Promise<Command[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Discover extensions from a directory.
|
|
19
|
+
* Each `.ts` file is imported and expected to export an ExtensionConfig.
|
|
20
|
+
*/
|
|
21
|
+
export declare function discoverExtensions(baseDir: string): Promise<ExtensionConfig[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Discover both commands and extensions from a source directory.
|
|
24
|
+
*/
|
|
25
|
+
export declare function discover(srcDir: string): Promise<AutoDiscoveryResult>;
|
|
26
|
+
//# sourceMappingURL=auto-discover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-discover.d.ts","sourceRoot":"","sources":["../../src/discovery/auto-discover.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,mBAAmB;IACnC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,UAAU,EAAE,eAAe,EAAE,CAAC;CAC9B;AAED,qBAAa,cAAe,SAAQ,KAAK;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAK7C;AA6BD;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAsE1E;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAqBpF;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAO3E"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { stat } from "node:fs/promises";
|
|
2
|
+
import { basename, join } from "node:path";
|
|
3
|
+
export class DiscoveryError extends Error {
|
|
4
|
+
filePath;
|
|
5
|
+
constructor(message, filePath) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "DiscoveryError";
|
|
8
|
+
this.filePath = filePath;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
async function isDir(path) {
|
|
12
|
+
try {
|
|
13
|
+
const s = await stat(path);
|
|
14
|
+
return s.isDirectory();
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function importModule(filePath) {
|
|
21
|
+
try {
|
|
22
|
+
const mod = await import(filePath);
|
|
23
|
+
return mod.default ?? mod;
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
27
|
+
throw new DiscoveryError(`Failed to import "${filePath}": ${message}`, filePath);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function shouldSkip(filename) {
|
|
31
|
+
return filename.startsWith("_") || filename.startsWith(".");
|
|
32
|
+
}
|
|
33
|
+
function assignName(obj, name) {
|
|
34
|
+
if (!obj.name)
|
|
35
|
+
obj.name = name;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Discover commands from a directory.
|
|
39
|
+
* Files become commands, nested directories become subcommands.
|
|
40
|
+
* An `index.ts` in a subdirectory provides the parent command config.
|
|
41
|
+
*/
|
|
42
|
+
export async function discoverCommands(baseDir) {
|
|
43
|
+
const commandsDir = join(baseDir, "commands");
|
|
44
|
+
if (!(await isDir(commandsDir)))
|
|
45
|
+
return [];
|
|
46
|
+
const glob = new Bun.Glob("**/*.ts");
|
|
47
|
+
const files = [];
|
|
48
|
+
for await (const match of glob.scan({ cwd: commandsDir, onlyFiles: true })) {
|
|
49
|
+
// Normalize to forward slashes (glob may return backslashes on Windows)
|
|
50
|
+
const normalized = match.replaceAll("\\", "/");
|
|
51
|
+
const parts = normalized.split("/");
|
|
52
|
+
if (parts.some(shouldSkip))
|
|
53
|
+
continue;
|
|
54
|
+
files.push(normalized);
|
|
55
|
+
}
|
|
56
|
+
files.sort();
|
|
57
|
+
// Group files by their directory path
|
|
58
|
+
const tree = new Map();
|
|
59
|
+
for (const file of files) {
|
|
60
|
+
const fullPath = join(commandsDir, file);
|
|
61
|
+
const mod = await importModule(fullPath);
|
|
62
|
+
const cmd = mod;
|
|
63
|
+
const record = cmd;
|
|
64
|
+
const segments = file.replace(/\.ts$/, "").split("/");
|
|
65
|
+
if (segments.length === 1) {
|
|
66
|
+
// Top-level command
|
|
67
|
+
const name = segments[0];
|
|
68
|
+
if (name === "index")
|
|
69
|
+
continue; // Skip root index
|
|
70
|
+
assignName(record, name);
|
|
71
|
+
tree.set(name, cmd);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// Nested: first segment is parent dir, rest form the path
|
|
75
|
+
const parentName = segments[0];
|
|
76
|
+
const childName = segments[segments.length - 1];
|
|
77
|
+
const isIndex = childName === "index";
|
|
78
|
+
if (isIndex) {
|
|
79
|
+
// index.ts defines the parent command
|
|
80
|
+
assignName(record, parentName);
|
|
81
|
+
const existing = tree.get(parentName);
|
|
82
|
+
if (existing) {
|
|
83
|
+
// Merge: keep existing subcommands
|
|
84
|
+
const subs = existing.subcommands ?? [];
|
|
85
|
+
Object.assign(cmd, { subcommands: [...(cmd.subcommands ?? []), ...subs] });
|
|
86
|
+
}
|
|
87
|
+
tree.set(parentName, cmd);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// Regular file becomes a subcommand
|
|
91
|
+
assignName(record, childName);
|
|
92
|
+
let parent = tree.get(parentName);
|
|
93
|
+
if (!parent) {
|
|
94
|
+
// Auto-create minimal parent
|
|
95
|
+
parent = { name: parentName };
|
|
96
|
+
tree.set(parentName, parent);
|
|
97
|
+
}
|
|
98
|
+
const subs = (parent.subcommands ?? []);
|
|
99
|
+
subs.push(cmd);
|
|
100
|
+
parent.subcommands = subs;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return Array.from(tree.values());
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Discover extensions from a directory.
|
|
108
|
+
* Each `.ts` file is imported and expected to export an ExtensionConfig.
|
|
109
|
+
*/
|
|
110
|
+
export async function discoverExtensions(baseDir) {
|
|
111
|
+
const extensionsDir = join(baseDir, "extensions");
|
|
112
|
+
if (!(await isDir(extensionsDir)))
|
|
113
|
+
return [];
|
|
114
|
+
const glob = new Bun.Glob("*.ts");
|
|
115
|
+
const extensions = [];
|
|
116
|
+
for await (const match of glob.scan({ cwd: extensionsDir, onlyFiles: true })) {
|
|
117
|
+
if (shouldSkip(match))
|
|
118
|
+
continue;
|
|
119
|
+
const fullPath = join(extensionsDir, match);
|
|
120
|
+
const mod = await importModule(fullPath);
|
|
121
|
+
const ext = mod;
|
|
122
|
+
const name = basename(match, ".ts");
|
|
123
|
+
assignName(ext, name);
|
|
124
|
+
extensions.push(ext);
|
|
125
|
+
}
|
|
126
|
+
return extensions;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Discover both commands and extensions from a source directory.
|
|
130
|
+
*/
|
|
131
|
+
export async function discover(srcDir) {
|
|
132
|
+
const [commands, extensions] = await Promise.all([
|
|
133
|
+
discoverCommands(srcDir),
|
|
134
|
+
discoverExtensions(srcDir),
|
|
135
|
+
]);
|
|
136
|
+
return { commands, extensions };
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=auto-discover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-discover.js","sourceRoot":"","sources":["../../src/discovery/auto-discover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAS3C,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC/B,QAAQ,CAAS;IAE1B,YAAY,OAAe,EAAE,QAAgB;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;CACD;AAED,KAAK,UAAU,KAAK,CAAC,IAAY;IAChC,IAAI,CAAC;QACJ,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,QAAgB;IAC3C,IAAI,CAAC;QACJ,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnC,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version":3,"file":"index.js","sourceRoot":"","sources":["../../src/discovery/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @seedcli/core — Core runtime for Seed CLI framework.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { command, arg, flag, definePlugin, defineExtension, defineConfig } from "@seedcli/core";
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export type { HelpOptions } from "./command/help.js";
|
|
10
|
+
export { renderCommandHelp, renderGlobalHelp } from "./command/help.js";
|
|
11
|
+
export type { ParseResult } from "./command/parser.js";
|
|
12
|
+
export { ParseError, parse } from "./command/parser.js";
|
|
13
|
+
export type { CommandSuggestion, RouteResult } from "./command/router.js";
|
|
14
|
+
export { flattenCommands, route } from "./command/router.js";
|
|
15
|
+
export type { AutoDiscoveryResult } from "./discovery/auto-discover.js";
|
|
16
|
+
export { DiscoveryError, discover, discoverCommands, discoverExtensions, } from "./discovery/auto-discover.js";
|
|
17
|
+
export { ExtensionCycleError, ExtensionSetupError, PluginDependencyError, PluginError, PluginLoadError, PluginValidationError, } from "./plugin/errors.js";
|
|
18
|
+
export { loadPlugin, loadPlugins } from "./plugin/loader.js";
|
|
19
|
+
export { PluginRegistry } from "./plugin/registry.js";
|
|
20
|
+
export { topoSort } from "./plugin/topo-sort.js";
|
|
21
|
+
export { validatePeerDependencies, validatePlugin, validateSeedcliVersion, } from "./plugin/validator.js";
|
|
22
|
+
export type { BuilderConfig, ConfigOptions, PluginScanOptions } from "./runtime/builder.js";
|
|
23
|
+
export { build } from "./runtime/builder.js";
|
|
24
|
+
export type { RunConfig } from "./runtime/runtime.js";
|
|
25
|
+
export { Runtime, run } from "./runtime/runtime.js";
|
|
26
|
+
export { arg, flag } from "./types/args.js";
|
|
27
|
+
export { command } from "./types/command.js";
|
|
28
|
+
export { defineConfig } from "./types/config.js";
|
|
29
|
+
export { defineExtension } from "./types/extension.js";
|
|
30
|
+
export type { ArgDef, ArgType, Command, CommandConfig, ExtensionConfig, FlagDef, FlagType, InferArgs, InferFlags, Middleware, PluginConfig, PrintModule, ResolveArgType, ResolveFlagType, SeedConfig, StringsModule, Toolbox, ToolboxExtensions, } from "./types/index.js";
|
|
31
|
+
export { definePlugin } from "./types/plugin.js";
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACxE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE,OAAO,EACN,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,GAClB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,qBAAqB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EACN,wBAAwB,EACxB,cAAc,EACd,sBAAsB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE5F,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,YAAY,EACX,MAAM,EAEN,OAAO,EAEP,OAAO,EACP,aAAa,EAEb,eAAe,EACf,OAAO,EACP,QAAQ,EACR,SAAS,EACT,UAAU,EACV,UAAU,EAEV,YAAY,EAEZ,WAAW,EACX,cAAc,EACd,eAAe,EAEf,UAAU,EACV,aAAa,EAEb,OAAO,EACP,iBAAiB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @seedcli/core — Core runtime for Seed CLI framework.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { command, arg, flag, definePlugin, defineExtension, defineConfig } from "@seedcli/core";
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export { renderCommandHelp, renderGlobalHelp } from "./command/help.js";
|
|
10
|
+
// ─── Command System ───
|
|
11
|
+
export { ParseError, parse } from "./command/parser.js";
|
|
12
|
+
export { flattenCommands, route } from "./command/router.js";
|
|
13
|
+
// ─── Auto-Discovery ───
|
|
14
|
+
export { DiscoveryError, discover, discoverCommands, discoverExtensions, } from "./discovery/auto-discover.js";
|
|
15
|
+
// ─── Plugin System ───
|
|
16
|
+
export { ExtensionCycleError, ExtensionSetupError, PluginDependencyError, PluginError, PluginLoadError, PluginValidationError, } from "./plugin/errors.js";
|
|
17
|
+
export { loadPlugin, loadPlugins } from "./plugin/loader.js";
|
|
18
|
+
export { PluginRegistry } from "./plugin/registry.js";
|
|
19
|
+
export { topoSort } from "./plugin/topo-sort.js";
|
|
20
|
+
export { validatePeerDependencies, validatePlugin, validateSeedcliVersion, } from "./plugin/validator.js";
|
|
21
|
+
// ─── Runtime ───
|
|
22
|
+
export { build } from "./runtime/builder.js";
|
|
23
|
+
export { Runtime, run } from "./runtime/runtime.js";
|
|
24
|
+
// ─── Factory Functions ───
|
|
25
|
+
export { arg, flag } from "./types/args.js";
|
|
26
|
+
export { command } from "./types/command.js";
|
|
27
|
+
export { defineConfig } from "./types/config.js";
|
|
28
|
+
export { defineExtension } from "./types/extension.js";
|
|
29
|
+
export { definePlugin } from "./types/plugin.js";
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAExE,yBAAyB;AACzB,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE7D,yBAAyB;AACzB,OAAO,EACN,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,GAClB,MAAM,8BAA8B,CAAC;AACtC,wBAAwB;AACxB,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,qBAAqB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EACN,wBAAwB,EACxB,cAAc,EACd,sBAAsB,GACtB,MAAM,uBAAuB,CAAC;AAE/B,kBAAkB;AAClB,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AACpD,4BAA4B;AAC5B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA6BvD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare class PluginError extends Error {
|
|
2
|
+
readonly pluginName: string;
|
|
3
|
+
constructor(message: string, pluginName: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class PluginValidationError extends PluginError {
|
|
6
|
+
constructor(message: string, pluginName: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class PluginLoadError extends PluginError {
|
|
9
|
+
constructor(message: string, pluginName: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class PluginDependencyError extends PluginError {
|
|
12
|
+
readonly dependency: string;
|
|
13
|
+
constructor(message: string, pluginName: string, dependency: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class ExtensionCycleError extends Error {
|
|
16
|
+
readonly extensions: string[];
|
|
17
|
+
constructor(extensions: string[]);
|
|
18
|
+
}
|
|
19
|
+
export declare class ExtensionSetupError extends Error {
|
|
20
|
+
readonly extensionName: string;
|
|
21
|
+
constructor(message: string, extensionName: string);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/plugin/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAChB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAK/C;AAED,qBAAa,qBAAsB,SAAQ,WAAW;gBACzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAI/C;AAED,qBAAa,eAAgB,SAAQ,WAAW;gBACnC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAI/C;AAED,qBAAa,qBAAsB,SAAQ,WAAW;IACrD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAChB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAKnE;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;gBAClB,UAAU,EAAE,MAAM,EAAE;CAKhC;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;gBACnB,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;CAKlD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export class PluginError extends Error {
|
|
2
|
+
pluginName;
|
|
3
|
+
constructor(message, pluginName) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "PluginError";
|
|
6
|
+
this.pluginName = pluginName;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class PluginValidationError extends PluginError {
|
|
10
|
+
constructor(message, pluginName) {
|
|
11
|
+
super(message, pluginName);
|
|
12
|
+
this.name = "PluginValidationError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class PluginLoadError extends PluginError {
|
|
16
|
+
constructor(message, pluginName) {
|
|
17
|
+
super(message, pluginName);
|
|
18
|
+
this.name = "PluginLoadError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class PluginDependencyError extends PluginError {
|
|
22
|
+
dependency;
|
|
23
|
+
constructor(message, pluginName, dependency) {
|
|
24
|
+
super(message, pluginName);
|
|
25
|
+
this.name = "PluginDependencyError";
|
|
26
|
+
this.dependency = dependency;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export class ExtensionCycleError extends Error {
|
|
30
|
+
extensions;
|
|
31
|
+
constructor(extensions) {
|
|
32
|
+
super(`Circular dependency detected among extensions: ${extensions.join(", ")}`);
|
|
33
|
+
this.name = "ExtensionCycleError";
|
|
34
|
+
this.extensions = extensions;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class ExtensionSetupError extends Error {
|
|
38
|
+
extensionName;
|
|
39
|
+
constructor(message, extensionName) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.name = "ExtensionSetupError";
|
|
42
|
+
this.extensionName = extensionName;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/plugin/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC5B,UAAU,CAAS;IAC5B,YAAY,OAAe,EAAE,UAAkB;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;CACD;AAED,MAAM,OAAO,qBAAsB,SAAQ,WAAW;IACrD,YAAY,OAAe,EAAE,UAAkB;QAC9C,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACrC,CAAC;CACD;AAED,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC/C,YAAY,OAAe,EAAE,UAAkB;QAC9C,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAC/B,CAAC;CACD;AAED,MAAM,OAAO,qBAAsB,SAAQ,WAAW;IAC5C,UAAU,CAAS;IAC5B,YAAY,OAAe,EAAE,UAAkB,EAAE,UAAkB;QAClE,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;CACD;AAED,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACpC,UAAU,CAAW;IAC9B,YAAY,UAAoB;QAC/B,KAAK,CAAC,kDAAkD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjF,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;CACD;AAED,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACpC,aAAa,CAAS;IAC/B,YAAY,OAAe,EAAE,aAAqB;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACpC,CAAC;CACD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ExtensionCycleError, ExtensionSetupError, PluginDependencyError, PluginError, PluginLoadError, PluginValidationError, } from "./errors.js";
|
|
2
|
+
export { loadPlugin, loadPlugins } from "./loader.js";
|
|
3
|
+
export { PluginRegistry } from "./registry.js";
|
|
4
|
+
export { topoSort } from "./topo-sort.js";
|
|
5
|
+
export { validatePeerDependencies, validatePlugin } from "./validator.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,qBAAqB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ExtensionCycleError, ExtensionSetupError, PluginDependencyError, PluginError, PluginLoadError, PluginValidationError, } from "./errors.js";
|
|
2
|
+
export { loadPlugin, loadPlugins } from "./loader.js";
|
|
3
|
+
export { PluginRegistry } from "./registry.js";
|
|
4
|
+
export { topoSort } from "./topo-sort.js";
|
|
5
|
+
export { validatePeerDependencies, validatePlugin } from "./validator.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,qBAAqB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PluginConfig } from "../types/plugin.js";
|
|
2
|
+
/**
|
|
3
|
+
* Load a single plugin from a source.
|
|
4
|
+
* If source is a string, dynamic-imports it (expects default export).
|
|
5
|
+
* If source is an object, uses it directly.
|
|
6
|
+
*/
|
|
7
|
+
export declare function loadPlugin(source: string | PluginConfig): Promise<PluginConfig>;
|
|
8
|
+
/**
|
|
9
|
+
* Load multiple plugins in parallel.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadPlugins(sources: Array<string | PluginConfig>): Promise<PluginConfig[]>;
|
|
12
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/plugin/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CA2BrF;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,GAAG,YAAY,CAAC,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAEhG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { PluginLoadError } from "./errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* Load a single plugin from a source.
|
|
4
|
+
* If source is a string, dynamic-imports it (expects default export).
|
|
5
|
+
* If source is an object, uses it directly.
|
|
6
|
+
*/
|
|
7
|
+
export async function loadPlugin(source) {
|
|
8
|
+
if (typeof source !== "string") {
|
|
9
|
+
return source;
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const mod = await import(source);
|
|
13
|
+
const config = mod.default ?? mod;
|
|
14
|
+
if (!config || typeof config !== "object") {
|
|
15
|
+
throw new PluginLoadError(`Plugin "${source}" has an invalid export.\n\n The default export is not a valid plugin definition.\n\n A valid plugin must export a definePlugin() result:\n\n export default definePlugin({\n name: "my-plugin",\n commands: [...],\n });`, source);
|
|
16
|
+
}
|
|
17
|
+
return config;
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
if (err instanceof PluginLoadError) {
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
24
|
+
throw new PluginLoadError(`Plugin "${source}" not found.\n\n Could not resolve the module "${source}".\n\n Make sure it's installed:\n bun add ${source}\n\n Original error: ${message}`, source);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Load multiple plugins in parallel.
|
|
29
|
+
*/
|
|
30
|
+
export async function loadPlugins(sources) {
|
|
31
|
+
return Promise.all(sources.map(loadPlugin));
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/plugin/loader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAA6B;IAC7D,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,MAAM,CAAC;IACf,CAAC;IAED,IAAI,CAAC;QACJ,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;QACjC,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC;QAElC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC3C,MAAM,IAAI,eAAe,CACxB,WAAW,MAAM,6OAA6O,EAC9P,MAAM,CACN,CAAC;QACH,CAAC;QAED,OAAO,MAAsB,CAAC;IAC/B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,IAAI,GAAG,YAAY,eAAe,EAAE,CAAC;YACpC,MAAM,GAAG,CAAC;QACX,CAAC;QACD,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,MAAM,IAAI,eAAe,CACxB,WAAW,MAAM,mDAAmD,MAAM,kDAAkD,MAAM,yBAAyB,OAAO,EAAE,EACpK,MAAM,CACN,CAAC;IACH,CAAC;AACF,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAqC;IACtE,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Command } from "../types/command.js";
|
|
2
|
+
import type { ExtensionConfig } from "../types/extension.js";
|
|
3
|
+
import type { PluginConfig } from "../types/plugin.js";
|
|
4
|
+
/**
|
|
5
|
+
* In-memory registry for loaded and validated plugins.
|
|
6
|
+
*/
|
|
7
|
+
export declare class PluginRegistry {
|
|
8
|
+
private plugins;
|
|
9
|
+
/**
|
|
10
|
+
* Register a plugin after validation.
|
|
11
|
+
* Silently deduplicates if a plugin with the same name is already registered.
|
|
12
|
+
* Validates command and extension name conflicts across all plugins.
|
|
13
|
+
*/
|
|
14
|
+
register(plugin: PluginConfig): void;
|
|
15
|
+
/** Get a plugin by name. */
|
|
16
|
+
get(name: string): PluginConfig | undefined;
|
|
17
|
+
/** Check if a plugin is registered. */
|
|
18
|
+
has(name: string): boolean;
|
|
19
|
+
/** Get all registered plugins. */
|
|
20
|
+
all(): PluginConfig[];
|
|
21
|
+
/** Aggregate all commands from all registered plugins. */
|
|
22
|
+
commands(): Command[];
|
|
23
|
+
/** Aggregate all extensions from all registered plugins. */
|
|
24
|
+
extensions(): ExtensionConfig[];
|
|
25
|
+
/** Validate peer dependencies across all registered plugins. */
|
|
26
|
+
validateAll(): void;
|
|
27
|
+
/** Find which plugin registered a given command name. */
|
|
28
|
+
private findPluginByCommand;
|
|
29
|
+
/** Find which plugin registered a given extension name. */
|
|
30
|
+
private findPluginByExtension;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/plugin/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD;;GAEG;AACH,qBAAa,cAAc;IAC1B,OAAO,CAAC,OAAO,CAAmC;IAElD;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IA6CpC,4BAA4B;IAC5B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI3C,uCAAuC;IACvC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,kCAAkC;IAClC,GAAG,IAAI,YAAY,EAAE;IAIrB,0DAA0D;IAC1D,QAAQ,IAAI,OAAO,EAAE;IAUrB,4DAA4D;IAC5D,UAAU,IAAI,eAAe,EAAE;IAU/B,gEAAgE;IAChE,WAAW,IAAI,IAAI;IAMnB,yDAAyD;IACzD,OAAO,CAAC,mBAAmB;IAS3B,2DAA2D;IAC3D,OAAO,CAAC,qBAAqB;CAQ7B"}
|