glost-registry 0.5.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 GLOST Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,283 @@
1
+ # glost-registry
2
+
3
+ Enhanced plugin registry with discovery, metadata, validation, and conflict detection for GLOST.
4
+
5
+ ## Overview
6
+
7
+ `glost-registry` provides a comprehensive plugin registry system for managing GLOST plugins with:
8
+
9
+ - Plugin discovery and search
10
+ - Metadata management
11
+ - Conflict detection
12
+ - Dependency resolution
13
+ - Validation
14
+ - Statistics
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install glost-registry
20
+ # or
21
+ pnpm add glost-registry
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ### Registering Plugins
27
+
28
+ ```typescript
29
+ import { pluginRegistry } from "glost-registry";
30
+ import { myExtension } from "./my-plugin";
31
+
32
+ pluginRegistry.register(myExtension, {
33
+ version: "1.0.0",
34
+ description: "Adds transcription support for Thai",
35
+ category: "enhancer",
36
+ tags: ["transcription", "thai", "ipa"],
37
+ author: "Your Name",
38
+ repository: "https://github.com/yourusername/my-plugin",
39
+ supports: {
40
+ languages: ["th"],
41
+ async: true,
42
+ parallel: false
43
+ },
44
+ requires: {
45
+ plugins: ["frequency"],
46
+ glostVersion: ">=0.4.0"
47
+ }
48
+ });
49
+ ```
50
+
51
+ ### Searching for Plugins
52
+
53
+ ```typescript
54
+ // Search by keyword
55
+ const results = pluginRegistry.search({ keyword: "transcription" });
56
+
57
+ // Filter by category
58
+ const enhancers = pluginRegistry.search({ category: "enhancer" });
59
+
60
+ // Filter by language
61
+ const thaiPlugins = pluginRegistry.search({ language: "th" });
62
+
63
+ // Multiple filters
64
+ const results = pluginRegistry.search({
65
+ category: "enhancer",
66
+ language: "th",
67
+ tags: ["transcription"]
68
+ });
69
+ ```
70
+
71
+ ### Get Plugin Metadata
72
+
73
+ ```typescript
74
+ const metadata = pluginRegistry.getMetadata("my-plugin");
75
+ console.log(metadata.version);
76
+ console.log(metadata.category);
77
+ console.log(metadata.supports.languages);
78
+ ```
79
+
80
+ ### Check for Conflicts
81
+
82
+ ```typescript
83
+ const report = pluginRegistry.checkConflicts([
84
+ "plugin1",
85
+ "plugin2",
86
+ "plugin3"
87
+ ]);
88
+
89
+ if (report.hasConflicts) {
90
+ for (const conflict of report.conflicts) {
91
+ console.error(`Conflict: ${conflict.plugin1} <-> ${conflict.plugin2}`);
92
+ console.error(`Reason: ${conflict.reason}`);
93
+ console.error(`Severity: ${conflict.severity}`);
94
+ }
95
+ }
96
+ ```
97
+
98
+ ### Resolve Dependencies
99
+
100
+ ```typescript
101
+ const orderedPlugins = pluginRegistry.resolveDependencies([
102
+ "plugin-c", // depends on plugin-a
103
+ "plugin-a",
104
+ "plugin-b" // depends on plugin-a
105
+ ]);
106
+ // Returns: ["plugin-a", "plugin-c", "plugin-b"]
107
+ ```
108
+
109
+ ### Validate Plugins
110
+
111
+ ```typescript
112
+ const result = pluginRegistry.validate("my-plugin", {
113
+ scheme: "ipa",
114
+ target: "en"
115
+ });
116
+
117
+ if (!result.valid) {
118
+ console.error("Validation errors:", result.errors);
119
+ }
120
+
121
+ if (result.warnings.length > 0) {
122
+ console.warn("Validation warnings:", result.warnings);
123
+ }
124
+ ```
125
+
126
+ ### Get Registry Statistics
127
+
128
+ ```typescript
129
+ const stats = pluginRegistry.getStatistics();
130
+ console.log(`Total plugins: ${stats.total}`);
131
+ console.log(`By category:`, stats.byCategory);
132
+ console.log(`By language:`, stats.byLanguage);
133
+ console.log(`Top tags:`, stats.topTags);
134
+ ```
135
+
136
+ ## Advanced Usage
137
+
138
+ ### Plugin Discovery
139
+
140
+ ```typescript
141
+ import { PluginDiscovery, pluginRegistry } from "glost-registry";
142
+
143
+ // Find related plugins
144
+ const related = PluginDiscovery.findRelated(
145
+ pluginRegistry.list(),
146
+ "my-plugin"
147
+ );
148
+
149
+ // Suggest plugins based on current selection
150
+ const suggestions = PluginDiscovery.suggestPlugins(
151
+ currentPlugins,
152
+ pluginRegistry.list()
153
+ );
154
+ ```
155
+
156
+ ### Filtering and Sorting
157
+
158
+ ```typescript
159
+ import { PluginFilter, PluginSorter } from "glost-registry";
160
+
161
+ let plugins = pluginRegistry.list();
162
+
163
+ // Filter
164
+ plugins = PluginFilter.byLanguage(plugins, "th");
165
+ plugins = PluginFilter.asyncOnly(plugins);
166
+
167
+ // Sort
168
+ plugins = PluginSorter.byName(plugins);
169
+ plugins = PluginSorter.byCategory(plugins);
170
+ plugins = PluginSorter.byDate(plugins, false); // newest first
171
+ ```
172
+
173
+ ### Custom Validation
174
+
175
+ ```typescript
176
+ import { PluginValidator } from "glost-registry";
177
+
178
+ const metadata = pluginRegistry.getMetadata("my-plugin");
179
+
180
+ // Validate metadata
181
+ const metaResult = PluginValidator.validateMetadata(metadata);
182
+
183
+ // Validate compatibility
184
+ const compResult = PluginValidator.validateCompatibility(
185
+ metadata,
186
+ "0.4.0", // GLOST version
187
+ "20.0.0" // Node.js version
188
+ );
189
+
190
+ // Validate dependencies
191
+ const depResult = PluginValidator.validateDependencies(
192
+ metadata,
193
+ new Set(["plugin-a", "plugin-b"])
194
+ );
195
+ ```
196
+
197
+ ## Plugin Metadata Schema
198
+
199
+ ```typescript
200
+ interface PluginMetadata {
201
+ // Required
202
+ id: string;
203
+ name: string;
204
+ version: string;
205
+ description: string;
206
+ category: "transformer" | "enhancer" | "generator" | "analyzer" | "utility";
207
+ tags: string[];
208
+ supports: {
209
+ languages?: string[];
210
+ nodeTypes?: string[];
211
+ async: boolean;
212
+ parallel?: boolean;
213
+ };
214
+
215
+ // Optional
216
+ author?: string;
217
+ repository?: string;
218
+ homepage?: string;
219
+ requires?: {
220
+ plugins?: string[];
221
+ glostVersion?: string;
222
+ nodeVersion?: string;
223
+ };
224
+ conflicts?: string[];
225
+ options?: PluginOptionsSchema;
226
+ examples?: PluginExample[];
227
+ }
228
+ ```
229
+
230
+ ## API
231
+
232
+ ### PluginRegistry
233
+
234
+ - `register(extension, metadata)` - Register a plugin
235
+ - `getMetadata(id)` - Get plugin metadata
236
+ - `getExtension(id)` - Get plugin extension
237
+ - `list()` - List all plugins
238
+ - `search(query)` - Search for plugins
239
+ - `getByCategory(category)` - Get plugins by category
240
+ - `getLanguageSupport(language)` - Get plugins supporting a language
241
+ - `isLanguageSupported(id, language)` - Check language support
242
+ - `isCompatible(id, version)` - Check version compatibility
243
+ - `checkConflicts(ids)` - Check for conflicts
244
+ - `resolveDependencies(ids)` - Resolve dependencies
245
+ - `validate(id, options)` - Validate plugin configuration
246
+ - `getStatistics()` - Get registry statistics
247
+ - `has(id)` - Check if plugin exists
248
+ - `unregister(id)` - Unregister a plugin
249
+ - `clear()` - Clear all plugins
250
+
251
+ ### PluginFilter
252
+
253
+ - `byKeyword(plugins, keyword)` - Filter by keyword
254
+ - `byCategory(plugins, category)` - Filter by category
255
+ - `byLanguage(plugins, language)` - Filter by language
256
+ - `byTags(plugins, tags)` - Filter by tags
257
+ - `byAuthor(plugins, author)` - Filter by author
258
+ - `asyncOnly(plugins)` - Filter async plugins
259
+ - `parallelOnly(plugins)` - Filter parallel plugins
260
+ - `apply(plugins, query)` - Apply multiple filters
261
+
262
+ ### PluginSorter
263
+
264
+ - `byName(plugins, ascending)` - Sort by name
265
+ - `byDate(plugins, ascending)` - Sort by date
266
+ - `byCategory(plugins)` - Sort by category
267
+
268
+ ### PluginDiscovery
269
+
270
+ - `findRelated(plugins, id)` - Find related plugins
271
+ - `findDependents(plugins, extensions, id)` - Find dependent plugins
272
+ - `findMissingDependencies(plugins, extensions)` - Find missing deps
273
+ - `suggestPlugins(current, all)` - Suggest plugins
274
+
275
+ ### PluginValidator
276
+
277
+ - `validateMetadata(metadata)` - Validate metadata
278
+ - `validateCompatibility(metadata, glost, node)` - Validate compatibility
279
+ - `validateDependencies(metadata, available)` - Validate dependencies
280
+
281
+ ## License
282
+
283
+ MIT
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Plugin Discovery
3
+ *
4
+ * Utilities for discovering and filtering plugins.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ import type { PluginMetadata, PluginQuery, PluginCategory } from "./types.js";
9
+ /**
10
+ * Filter plugins by various criteria
11
+ */
12
+ export declare class PluginFilter {
13
+ /**
14
+ * Filter plugins by keyword
15
+ *
16
+ * @param plugins - Plugins to filter
17
+ * @param keyword - Keyword to search for
18
+ * @returns Filtered plugins
19
+ */
20
+ static byKeyword(plugins: PluginMetadata[], keyword: string): PluginMetadata[];
21
+ /**
22
+ * Filter plugins by category
23
+ *
24
+ * @param plugins - Plugins to filter
25
+ * @param category - Category to filter by
26
+ * @returns Filtered plugins
27
+ */
28
+ static byCategory(plugins: PluginMetadata[], category: PluginCategory): PluginMetadata[];
29
+ /**
30
+ * Filter plugins by language support
31
+ *
32
+ * @param plugins - Plugins to filter
33
+ * @param language - Language code
34
+ * @returns Filtered plugins
35
+ */
36
+ static byLanguage(plugins: PluginMetadata[], language: string): PluginMetadata[];
37
+ /**
38
+ * Filter plugins by tags
39
+ *
40
+ * @param plugins - Plugins to filter
41
+ * @param tags - Tags to match (any)
42
+ * @returns Filtered plugins
43
+ */
44
+ static byTags(plugins: PluginMetadata[], tags: string[]): PluginMetadata[];
45
+ /**
46
+ * Filter plugins by author
47
+ *
48
+ * @param plugins - Plugins to filter
49
+ * @param author - Author name
50
+ * @returns Filtered plugins
51
+ */
52
+ static byAuthor(plugins: PluginMetadata[], author: string): PluginMetadata[];
53
+ /**
54
+ * Filter plugins that support async
55
+ *
56
+ * @param plugins - Plugins to filter
57
+ * @returns Filtered plugins
58
+ */
59
+ static asyncOnly(plugins: PluginMetadata[]): PluginMetadata[];
60
+ /**
61
+ * Filter plugins that support parallel execution
62
+ *
63
+ * @param plugins - Plugins to filter
64
+ * @returns Filtered plugins
65
+ */
66
+ static parallelOnly(plugins: PluginMetadata[]): PluginMetadata[];
67
+ /**
68
+ * Apply multiple filters
69
+ *
70
+ * @param plugins - Plugins to filter
71
+ * @param query - Filter query
72
+ * @returns Filtered plugins
73
+ */
74
+ static apply(plugins: PluginMetadata[], query: PluginQuery): PluginMetadata[];
75
+ }
76
+ /**
77
+ * Sort plugins by various criteria
78
+ */
79
+ export declare class PluginSorter {
80
+ /**
81
+ * Sort plugins by name
82
+ *
83
+ * @param plugins - Plugins to sort
84
+ * @param ascending - Sort order
85
+ * @returns Sorted plugins
86
+ */
87
+ static byName(plugins: PluginMetadata[], ascending?: boolean): PluginMetadata[];
88
+ /**
89
+ * Sort plugins by registration date
90
+ *
91
+ * @param plugins - Plugins to sort
92
+ * @param ascending - Sort order
93
+ * @returns Sorted plugins
94
+ */
95
+ static byDate(plugins: PluginMetadata[], ascending?: boolean): PluginMetadata[];
96
+ /**
97
+ * Sort plugins by category
98
+ *
99
+ * @param plugins - Plugins to sort
100
+ * @returns Sorted plugins
101
+ */
102
+ static byCategory(plugins: PluginMetadata[]): PluginMetadata[];
103
+ }
104
+ /**
105
+ * Plugin discovery helpers
106
+ */
107
+ export declare class PluginDiscovery {
108
+ /**
109
+ * Find plugins related to a given plugin
110
+ *
111
+ * @param plugins - All plugins
112
+ * @param pluginId - Plugin to find related plugins for
113
+ * @returns Related plugins
114
+ */
115
+ static findRelated(plugins: PluginMetadata[], pluginId: string): PluginMetadata[];
116
+ /**
117
+ * Find plugins that depend on a given plugin
118
+ *
119
+ * @param plugins - All plugins
120
+ * @param allExtensions - Map of extensions (for dependency info)
121
+ * @param pluginId - Plugin to find dependents for
122
+ * @returns Dependent plugins
123
+ */
124
+ static findDependents(plugins: PluginMetadata[], allExtensions: Map<string, {
125
+ dependencies?: string[];
126
+ }>, pluginId: string): PluginMetadata[];
127
+ /**
128
+ * Find missing dependencies for plugins
129
+ *
130
+ * @param plugins - Plugins to check
131
+ * @param allExtensions - Map of all extensions
132
+ * @returns Map of plugin ID to missing dependencies
133
+ */
134
+ static findMissingDependencies(plugins: PluginMetadata[], allExtensions: Map<string, {
135
+ dependencies?: string[];
136
+ }>): Map<string, string[]>;
137
+ /**
138
+ * Suggest plugins based on a user's current plugins
139
+ *
140
+ * @param currentPlugins - Currently used plugins
141
+ * @param allPlugins - All available plugins
142
+ * @returns Suggested plugins
143
+ */
144
+ static suggestPlugins(currentPlugins: PluginMetadata[], allPlugins: PluginMetadata[]): PluginMetadata[];
145
+ }
146
+ //# sourceMappingURL=discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE9E;;GAEG;AACH,qBAAa,YAAY;IACvB;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,EAA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