@stoneforge/quarry 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 +13 -0
- package/README.md +160 -0
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +8 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/quarry-api.d.ts +268 -0
- package/dist/api/quarry-api.d.ts.map +1 -0
- package/dist/api/quarry-api.js +3905 -0
- package/dist/api/quarry-api.js.map +1 -0
- package/dist/api/types.d.ts +1359 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +204 -0
- package/dist/api/types.js.map +1 -0
- package/dist/bin/sf.d.ts +3 -0
- package/dist/bin/sf.d.ts.map +1 -0
- package/dist/bin/sf.js +9 -0
- package/dist/bin/sf.js.map +1 -0
- package/dist/cli/commands/admin.d.ts +11 -0
- package/dist/cli/commands/admin.d.ts.map +1 -0
- package/dist/cli/commands/admin.js +465 -0
- package/dist/cli/commands/admin.js.map +1 -0
- package/dist/cli/commands/alias.d.ts +8 -0
- package/dist/cli/commands/alias.d.ts.map +1 -0
- package/dist/cli/commands/alias.js +70 -0
- package/dist/cli/commands/alias.js.map +1 -0
- package/dist/cli/commands/channel.d.ts +13 -0
- package/dist/cli/commands/channel.d.ts.map +1 -0
- package/dist/cli/commands/channel.js +680 -0
- package/dist/cli/commands/channel.js.map +1 -0
- package/dist/cli/commands/completion.d.ts +8 -0
- package/dist/cli/commands/completion.d.ts.map +1 -0
- package/dist/cli/commands/completion.js +87 -0
- package/dist/cli/commands/completion.js.map +1 -0
- package/dist/cli/commands/config.d.ts +12 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +242 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/crud.d.ts +64 -0
- package/dist/cli/commands/crud.d.ts.map +1 -0
- package/dist/cli/commands/crud.js +805 -0
- package/dist/cli/commands/crud.js.map +1 -0
- package/dist/cli/commands/dep.d.ts +16 -0
- package/dist/cli/commands/dep.d.ts.map +1 -0
- package/dist/cli/commands/dep.js +499 -0
- package/dist/cli/commands/dep.js.map +1 -0
- package/dist/cli/commands/document.d.ts +12 -0
- package/dist/cli/commands/document.d.ts.map +1 -0
- package/dist/cli/commands/document.js +1039 -0
- package/dist/cli/commands/document.js.map +1 -0
- package/dist/cli/commands/embeddings.d.ts +12 -0
- package/dist/cli/commands/embeddings.d.ts.map +1 -0
- package/dist/cli/commands/embeddings.js +273 -0
- package/dist/cli/commands/embeddings.js.map +1 -0
- package/dist/cli/commands/entity.d.ts +16 -0
- package/dist/cli/commands/entity.d.ts.map +1 -0
- package/dist/cli/commands/entity.js +522 -0
- package/dist/cli/commands/entity.js.map +1 -0
- package/dist/cli/commands/gc.d.ts +10 -0
- package/dist/cli/commands/gc.d.ts.map +1 -0
- package/dist/cli/commands/gc.js +257 -0
- package/dist/cli/commands/gc.js.map +1 -0
- package/dist/cli/commands/help.d.ts +11 -0
- package/dist/cli/commands/help.d.ts.map +1 -0
- package/dist/cli/commands/help.js +169 -0
- package/dist/cli/commands/help.js.map +1 -0
- package/dist/cli/commands/history.d.ts +9 -0
- package/dist/cli/commands/history.d.ts.map +1 -0
- package/dist/cli/commands/history.js +160 -0
- package/dist/cli/commands/history.js.map +1 -0
- package/dist/cli/commands/identity.d.ts +18 -0
- package/dist/cli/commands/identity.d.ts.map +1 -0
- package/dist/cli/commands/identity.js +698 -0
- package/dist/cli/commands/identity.js.map +1 -0
- package/dist/cli/commands/inbox.d.ts +20 -0
- package/dist/cli/commands/inbox.d.ts.map +1 -0
- package/dist/cli/commands/inbox.js +493 -0
- package/dist/cli/commands/inbox.js.map +1 -0
- package/dist/cli/commands/init.d.ts +20 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +144 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/install.d.ts +9 -0
- package/dist/cli/commands/install.d.ts.map +1 -0
- package/dist/cli/commands/install.js +200 -0
- package/dist/cli/commands/install.js.map +1 -0
- package/dist/cli/commands/library.d.ts +12 -0
- package/dist/cli/commands/library.d.ts.map +1 -0
- package/dist/cli/commands/library.js +665 -0
- package/dist/cli/commands/library.js.map +1 -0
- package/dist/cli/commands/message.d.ts +11 -0
- package/dist/cli/commands/message.d.ts.map +1 -0
- package/dist/cli/commands/message.js +608 -0
- package/dist/cli/commands/message.js.map +1 -0
- package/dist/cli/commands/plan.d.ts +17 -0
- package/dist/cli/commands/plan.d.ts.map +1 -0
- package/dist/cli/commands/plan.js +698 -0
- package/dist/cli/commands/plan.js.map +1 -0
- package/dist/cli/commands/playbook.d.ts +12 -0
- package/dist/cli/commands/playbook.d.ts.map +1 -0
- package/dist/cli/commands/playbook.js +730 -0
- package/dist/cli/commands/playbook.js.map +1 -0
- package/dist/cli/commands/reset.d.ts +12 -0
- package/dist/cli/commands/reset.d.ts.map +1 -0
- package/dist/cli/commands/reset.js +306 -0
- package/dist/cli/commands/reset.js.map +1 -0
- package/dist/cli/commands/serve.d.ts +11 -0
- package/dist/cli/commands/serve.d.ts.map +1 -0
- package/dist/cli/commands/serve.js +106 -0
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/stats.d.ts +8 -0
- package/dist/cli/commands/stats.d.ts.map +1 -0
- package/dist/cli/commands/stats.js +82 -0
- package/dist/cli/commands/stats.js.map +1 -0
- package/dist/cli/commands/sync.d.ts +14 -0
- package/dist/cli/commands/sync.d.ts.map +1 -0
- package/dist/cli/commands/sync.js +370 -0
- package/dist/cli/commands/sync.js.map +1 -0
- package/dist/cli/commands/task.d.ts +25 -0
- package/dist/cli/commands/task.d.ts.map +1 -0
- package/dist/cli/commands/task.js +1153 -0
- package/dist/cli/commands/task.js.map +1 -0
- package/dist/cli/commands/team.d.ts +13 -0
- package/dist/cli/commands/team.d.ts.map +1 -0
- package/dist/cli/commands/team.js +471 -0
- package/dist/cli/commands/team.js.map +1 -0
- package/dist/cli/commands/workflow.d.ts +16 -0
- package/dist/cli/commands/workflow.d.ts.map +1 -0
- package/dist/cli/commands/workflow.js +753 -0
- package/dist/cli/commands/workflow.js.map +1 -0
- package/dist/cli/completion.d.ts +28 -0
- package/dist/cli/completion.d.ts.map +1 -0
- package/dist/cli/completion.js +295 -0
- package/dist/cli/completion.js.map +1 -0
- package/dist/cli/db.d.ts +38 -0
- package/dist/cli/db.d.ts.map +1 -0
- package/dist/cli/db.js +90 -0
- package/dist/cli/db.js.map +1 -0
- package/dist/cli/formatter.d.ts +87 -0
- package/dist/cli/formatter.d.ts.map +1 -0
- package/dist/cli/formatter.js +464 -0
- package/dist/cli/formatter.js.map +1 -0
- package/dist/cli/index.d.ts +33 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +38 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/parser.d.ts +45 -0
- package/dist/cli/parser.d.ts.map +1 -0
- package/dist/cli/parser.js +256 -0
- package/dist/cli/parser.js.map +1 -0
- package/dist/cli/plugin-loader.d.ts +39 -0
- package/dist/cli/plugin-loader.d.ts.map +1 -0
- package/dist/cli/plugin-loader.js +165 -0
- package/dist/cli/plugin-loader.js.map +1 -0
- package/dist/cli/plugin-registry.d.ts +50 -0
- package/dist/cli/plugin-registry.d.ts.map +1 -0
- package/dist/cli/plugin-registry.js +206 -0
- package/dist/cli/plugin-registry.js.map +1 -0
- package/dist/cli/plugin-types.d.ts +106 -0
- package/dist/cli/plugin-types.d.ts.map +1 -0
- package/dist/cli/plugin-types.js +103 -0
- package/dist/cli/plugin-types.js.map +1 -0
- package/dist/cli/runner.d.ts +35 -0
- package/dist/cli/runner.d.ts.map +1 -0
- package/dist/cli/runner.js +340 -0
- package/dist/cli/runner.js.map +1 -0
- package/dist/cli/suggest.d.ts +15 -0
- package/dist/cli/suggest.d.ts.map +1 -0
- package/dist/cli/suggest.js +49 -0
- package/dist/cli/suggest.js.map +1 -0
- package/dist/cli/types.d.ts +138 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +63 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/config/config.d.ts +86 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +348 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/defaults.d.ts +66 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +114 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/duration.d.ts +75 -0
- package/dist/config/duration.d.ts.map +1 -0
- package/dist/config/duration.js +190 -0
- package/dist/config/duration.js.map +1 -0
- package/dist/config/env.d.ts +67 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/env.js +207 -0
- package/dist/config/env.js.map +1 -0
- package/dist/config/file.d.ts +97 -0
- package/dist/config/file.d.ts.map +1 -0
- package/dist/config/file.js +365 -0
- package/dist/config/file.js.map +1 -0
- package/dist/config/index.d.ts +35 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +41 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/merge.d.ts +53 -0
- package/dist/config/merge.d.ts.map +1 -0
- package/dist/config/merge.js +226 -0
- package/dist/config/merge.js.map +1 -0
- package/dist/config/types.d.ts +257 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +72 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config/validation.d.ts +55 -0
- package/dist/config/validation.d.ts.map +1 -0
- package/dist/config/validation.js +251 -0
- package/dist/config/validation.js.map +1 -0
- package/dist/http/index.d.ts +8 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +12 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/sync-handlers.d.ts +162 -0
- package/dist/http/sync-handlers.d.ts.map +1 -0
- package/dist/http/sync-handlers.js +271 -0
- package/dist/http/sync-handlers.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/dist/server/index.d.ts +34 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +3329 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/static.d.ts +18 -0
- package/dist/server/static.d.ts.map +1 -0
- package/dist/server/static.js +71 -0
- package/dist/server/static.js.map +1 -0
- package/dist/server/ws/broadcaster.d.ts +8 -0
- package/dist/server/ws/broadcaster.d.ts.map +1 -0
- package/dist/server/ws/broadcaster.js +7 -0
- package/dist/server/ws/broadcaster.js.map +1 -0
- package/dist/server/ws/handler.d.ts +55 -0
- package/dist/server/ws/handler.d.ts.map +1 -0
- package/dist/server/ws/handler.js +160 -0
- package/dist/server/ws/handler.js.map +1 -0
- package/dist/services/blocked-cache.d.ts +297 -0
- package/dist/services/blocked-cache.d.ts.map +1 -0
- package/dist/services/blocked-cache.js +755 -0
- package/dist/services/blocked-cache.js.map +1 -0
- package/dist/services/dependency.d.ts +205 -0
- package/dist/services/dependency.d.ts.map +1 -0
- package/dist/services/dependency.js +566 -0
- package/dist/services/dependency.js.map +1 -0
- package/dist/services/embeddings/fusion.d.ts +33 -0
- package/dist/services/embeddings/fusion.d.ts.map +1 -0
- package/dist/services/embeddings/fusion.js +34 -0
- package/dist/services/embeddings/fusion.js.map +1 -0
- package/dist/services/embeddings/index.d.ts +12 -0
- package/dist/services/embeddings/index.d.ts.map +1 -0
- package/dist/services/embeddings/index.js +10 -0
- package/dist/services/embeddings/index.js.map +1 -0
- package/dist/services/embeddings/local-provider.d.ts +31 -0
- package/dist/services/embeddings/local-provider.d.ts.map +1 -0
- package/dist/services/embeddings/local-provider.js +80 -0
- package/dist/services/embeddings/local-provider.js.map +1 -0
- package/dist/services/embeddings/service.d.ts +76 -0
- package/dist/services/embeddings/service.d.ts.map +1 -0
- package/dist/services/embeddings/service.js +153 -0
- package/dist/services/embeddings/service.js.map +1 -0
- package/dist/services/embeddings/types.d.ts +70 -0
- package/dist/services/embeddings/types.d.ts.map +1 -0
- package/dist/services/embeddings/types.js +8 -0
- package/dist/services/embeddings/types.js.map +1 -0
- package/dist/services/id-length-cache.d.ts +156 -0
- package/dist/services/id-length-cache.d.ts.map +1 -0
- package/dist/services/id-length-cache.js +197 -0
- package/dist/services/id-length-cache.js.map +1 -0
- package/dist/services/inbox.d.ts +147 -0
- package/dist/services/inbox.d.ts.map +1 -0
- package/dist/services/inbox.js +428 -0
- package/dist/services/inbox.js.map +1 -0
- package/dist/services/index.d.ts +10 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +10 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/priority-service.d.ts +145 -0
- package/dist/services/priority-service.d.ts.map +1 -0
- package/dist/services/priority-service.js +272 -0
- package/dist/services/priority-service.js.map +1 -0
- package/dist/services/search-utils.d.ts +47 -0
- package/dist/services/search-utils.d.ts.map +1 -0
- package/dist/services/search-utils.js +83 -0
- package/dist/services/search-utils.js.map +1 -0
- package/dist/sync/hash.d.ts +48 -0
- package/dist/sync/hash.d.ts.map +1 -0
- package/dist/sync/hash.js +136 -0
- package/dist/sync/hash.js.map +1 -0
- package/dist/sync/index.d.ts +11 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +16 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/merge.d.ts +80 -0
- package/dist/sync/merge.d.ts.map +1 -0
- package/dist/sync/merge.js +310 -0
- package/dist/sync/merge.js.map +1 -0
- package/dist/sync/serialization.d.ts +132 -0
- package/dist/sync/serialization.d.ts.map +1 -0
- package/dist/sync/serialization.js +306 -0
- package/dist/sync/serialization.js.map +1 -0
- package/dist/sync/service.d.ts +102 -0
- package/dist/sync/service.d.ts.map +1 -0
- package/dist/sync/service.js +493 -0
- package/dist/sync/service.js.map +1 -0
- package/dist/sync/types.d.ts +275 -0
- package/dist/sync/types.d.ts.map +1 -0
- package/dist/sync/types.js +76 -0
- package/dist/sync/types.js.map +1 -0
- package/dist/systems/identity.d.ts +479 -0
- package/dist/systems/identity.d.ts.map +1 -0
- package/dist/systems/identity.js +817 -0
- package/dist/systems/identity.js.map +1 -0
- package/dist/systems/index.d.ts +8 -0
- package/dist/systems/index.d.ts.map +1 -0
- package/dist/systems/index.js +29 -0
- package/dist/systems/index.js.map +1 -0
- package/package.json +121 -0
- package/web/assets/charts-vendor-D1YcbGux.js +55 -0
- package/web/assets/dnd-vendor-DmxE-_ZH.js +5 -0
- package/web/assets/editor-vendor-BxraAWts.js +279 -0
- package/web/assets/index-B77vv208.js +341 -0
- package/web/assets/index-CF_XnVLh.css +1 -0
- package/web/assets/router-vendor-BCKpRBrB.js +41 -0
- package/web/assets/ui-vendor-DUahGnbT.js +45 -0
- package/web/assets/utils-vendor-CfYKiENT.js +813 -0
- package/web/favicon.ico +0 -0
- package/web/index.html +23 -0
- package/web/logo.png +0 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Plugin Registry
|
|
3
|
+
*
|
|
4
|
+
* Handles registration of plugin commands and aliases with conflict detection.
|
|
5
|
+
* Built-in commands always take precedence over plugin commands.
|
|
6
|
+
*/
|
|
7
|
+
import { registerCommand, registerAlias, getCommand, getAllAliases } from './runner.js';
|
|
8
|
+
/**
|
|
9
|
+
* Merges subcommands from a plugin command into an existing command.
|
|
10
|
+
*
|
|
11
|
+
* @param existingCommand - The existing command to merge into
|
|
12
|
+
* @param pluginCommand - The plugin command with subcommands to merge
|
|
13
|
+
* @param pluginName - Name of the plugin (for logging)
|
|
14
|
+
* @param verbose - Whether to log verbose output
|
|
15
|
+
* @returns Result of the merge operation
|
|
16
|
+
*/
|
|
17
|
+
function mergeSubcommands(existingCommand, pluginCommand, pluginName, verbose) {
|
|
18
|
+
const merged = [];
|
|
19
|
+
const skipped = [];
|
|
20
|
+
for (const [name, subCmd] of Object.entries(pluginCommand.subcommands || {})) {
|
|
21
|
+
if (existingCommand.subcommands?.[name]) {
|
|
22
|
+
skipped.push(name);
|
|
23
|
+
if (verbose) {
|
|
24
|
+
console.error(`[plugin:${pluginName}] Skipping subcommand '${existingCommand.name} ${name}': already exists`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
existingCommand.subcommands = existingCommand.subcommands || {};
|
|
29
|
+
existingCommand.subcommands[name] = subCmd;
|
|
30
|
+
merged.push(name);
|
|
31
|
+
if (verbose) {
|
|
32
|
+
console.error(`[plugin:${pluginName}] Merged subcommand '${existingCommand.name} ${name}'`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return { merged, skipped };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Registers all commands and aliases from a single plugin.
|
|
40
|
+
*
|
|
41
|
+
* Built-in commands always take precedence - plugin commands that conflict
|
|
42
|
+
* with existing commands are skipped with a warning.
|
|
43
|
+
*
|
|
44
|
+
* @param plugin - The plugin to register
|
|
45
|
+
* @param options - Registration options
|
|
46
|
+
* @returns Registration result
|
|
47
|
+
*/
|
|
48
|
+
export function registerPluginCommands(plugin, options) {
|
|
49
|
+
const verbose = options?.verbose ?? false;
|
|
50
|
+
const registeredCommands = [];
|
|
51
|
+
const skippedCommands = [];
|
|
52
|
+
const registeredAliases = [];
|
|
53
|
+
const skippedAliases = [];
|
|
54
|
+
// Register commands
|
|
55
|
+
for (const command of plugin.commands) {
|
|
56
|
+
const existingCommand = getCommand(command.name);
|
|
57
|
+
if (existingCommand) {
|
|
58
|
+
// Check if both have subcommands - can merge
|
|
59
|
+
if (existingCommand.subcommands && command.subcommands) {
|
|
60
|
+
const mergeResult = mergeSubcommands(existingCommand, command, plugin.name, verbose);
|
|
61
|
+
if (mergeResult.merged.length > 0) {
|
|
62
|
+
registeredCommands.push(`${command.name} (subcommands: ${mergeResult.merged.join(', ')})`);
|
|
63
|
+
}
|
|
64
|
+
if (mergeResult.skipped.length > 0) {
|
|
65
|
+
skippedCommands.push({
|
|
66
|
+
commandName: command.name,
|
|
67
|
+
success: false,
|
|
68
|
+
conflictReason: `Subcommand(s) '${mergeResult.skipped.join(', ')}' already exist`,
|
|
69
|
+
subcommandsMerged: mergeResult,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
else if (mergeResult.merged.length > 0) {
|
|
73
|
+
// Track successful merge without conflicts for logging purposes
|
|
74
|
+
skippedCommands.push({
|
|
75
|
+
commandName: command.name,
|
|
76
|
+
success: true,
|
|
77
|
+
subcommandsMerged: mergeResult,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// Cannot merge - skip entirely (existing behavior)
|
|
83
|
+
const result = {
|
|
84
|
+
commandName: command.name,
|
|
85
|
+
success: false,
|
|
86
|
+
conflictReason: `Command '${command.name}' already registered`,
|
|
87
|
+
};
|
|
88
|
+
skippedCommands.push(result);
|
|
89
|
+
if (verbose) {
|
|
90
|
+
console.error(`[plugin:${plugin.name}] Skipping command '${command.name}': already registered`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
// Register the command
|
|
96
|
+
registerCommand(command);
|
|
97
|
+
registeredCommands.push(command.name);
|
|
98
|
+
if (verbose) {
|
|
99
|
+
console.error(`[plugin:${plugin.name}] Registered command '${command.name}'`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Register aliases
|
|
104
|
+
if (plugin.aliases) {
|
|
105
|
+
const existingAliases = getAllAliases();
|
|
106
|
+
for (const [alias, target] of Object.entries(plugin.aliases)) {
|
|
107
|
+
// Check if alias conflicts with existing command or alias
|
|
108
|
+
const existingCommand = getCommand(alias);
|
|
109
|
+
const existingAlias = existingAliases.get(alias);
|
|
110
|
+
if (existingCommand) {
|
|
111
|
+
skippedAliases.push(alias);
|
|
112
|
+
if (verbose) {
|
|
113
|
+
console.error(`[plugin:${plugin.name}] Skipping alias '${alias}': conflicts with existing command`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else if (existingAlias) {
|
|
117
|
+
skippedAliases.push(alias);
|
|
118
|
+
if (verbose) {
|
|
119
|
+
console.error(`[plugin:${plugin.name}] Skipping alias '${alias}': already registered as alias for '${existingAlias}'`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
registerAlias(alias, target);
|
|
124
|
+
registeredAliases.push(alias);
|
|
125
|
+
if (verbose) {
|
|
126
|
+
console.error(`[plugin:${plugin.name}] Registered alias '${alias}' -> '${target}'`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
pluginName: plugin.name,
|
|
133
|
+
registeredCommands,
|
|
134
|
+
skippedCommands,
|
|
135
|
+
registeredAliases,
|
|
136
|
+
skippedAliases,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Registers all plugins' commands and aliases.
|
|
141
|
+
*
|
|
142
|
+
* Plugins are registered in order, so earlier plugins take precedence
|
|
143
|
+
* for command names. Built-in commands always take precedence over all plugins.
|
|
144
|
+
*
|
|
145
|
+
* @param plugins - Plugins to register
|
|
146
|
+
* @param options - Registration options
|
|
147
|
+
* @returns Array of registration results
|
|
148
|
+
*/
|
|
149
|
+
export async function registerAllPlugins(plugins, options) {
|
|
150
|
+
const results = [];
|
|
151
|
+
for (const plugin of plugins) {
|
|
152
|
+
// Run plugin init if provided
|
|
153
|
+
if (plugin.init) {
|
|
154
|
+
try {
|
|
155
|
+
await plugin.init();
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
159
|
+
console.error(`[plugin:${plugin.name}] Init failed: ${message}`);
|
|
160
|
+
// Continue with registration even if init fails
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const result = registerPluginCommands(plugin, options);
|
|
164
|
+
results.push(result);
|
|
165
|
+
}
|
|
166
|
+
return results;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Logs conflict warnings from registration results.
|
|
170
|
+
*
|
|
171
|
+
* @param results - Registration results to check for conflicts
|
|
172
|
+
*/
|
|
173
|
+
export function logConflictWarnings(results) {
|
|
174
|
+
for (const result of results) {
|
|
175
|
+
// Log skipped commands
|
|
176
|
+
for (const skipped of result.skippedCommands) {
|
|
177
|
+
// Skip warning if subcommands were successfully merged (partial or full success)
|
|
178
|
+
if (skipped.subcommandsMerged?.merged.length) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (skipped.conflictReason) {
|
|
182
|
+
console.error(`[plugin:${result.pluginName}] Warning: ${skipped.conflictReason}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Log skipped aliases (only if there were any)
|
|
186
|
+
if (result.skippedAliases.length > 0) {
|
|
187
|
+
console.error(`[plugin:${result.pluginName}] Warning: Skipped ${result.skippedAliases.length} alias(es) due to conflicts`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Gets a summary of registered plugin commands for the help menu.
|
|
193
|
+
*
|
|
194
|
+
* @param results - Registration results
|
|
195
|
+
* @returns Map of plugin name to registered command names
|
|
196
|
+
*/
|
|
197
|
+
export function getPluginCommandSummary(results) {
|
|
198
|
+
const summary = new Map();
|
|
199
|
+
for (const result of results) {
|
|
200
|
+
if (result.registeredCommands.length > 0) {
|
|
201
|
+
summary.set(result.pluginName, result.registeredCommands);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return summary;
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=plugin-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-registry.js","sourceRoot":"","sources":["../../src/cli/plugin-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAexF;;;;;;;;GA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|
4
|
+
* Type definitions for the CLI plugin system.
|
|
5
|
+
* Plugins can register commands and aliases to extend the CLI.
|
|
6
|
+
*/
|
|
7
|
+
import type { Command } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* CLI Plugin interface for extending the `sf` CLI.
|
|
10
|
+
*
|
|
11
|
+
* Plugins can provide additional commands and aliases to the CLI.
|
|
12
|
+
* They are discovered via known packages or user-specified config.
|
|
13
|
+
*/
|
|
14
|
+
export interface CLIPlugin {
|
|
15
|
+
/** Plugin name (should be unique) */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Plugin version */
|
|
18
|
+
version: string;
|
|
19
|
+
/** Commands provided by this plugin */
|
|
20
|
+
commands: Command[];
|
|
21
|
+
/** Command aliases (e.g., 'agents' -> 'agent list') */
|
|
22
|
+
aliases?: Record<string, string>;
|
|
23
|
+
/** Optional initialization function called before commands are registered */
|
|
24
|
+
init?: () => Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Plugin configuration for user-specified packages
|
|
28
|
+
*/
|
|
29
|
+
export interface PluginsConfig {
|
|
30
|
+
/** Package names that export CLI plugins */
|
|
31
|
+
packages: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Result of attempting to load a single plugin
|
|
35
|
+
*/
|
|
36
|
+
export interface PluginLoadResult {
|
|
37
|
+
/** Package name that was attempted */
|
|
38
|
+
packageName: string;
|
|
39
|
+
/** Whether the plugin was successfully loaded */
|
|
40
|
+
success: boolean;
|
|
41
|
+
/** The loaded plugin (if successful) */
|
|
42
|
+
plugin?: CLIPlugin;
|
|
43
|
+
/** Error message (if failed) */
|
|
44
|
+
error?: string;
|
|
45
|
+
/** Whether the package was not found (vs load error) */
|
|
46
|
+
notFound?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Result of plugin discovery process
|
|
50
|
+
*/
|
|
51
|
+
export interface PluginDiscoveryResult {
|
|
52
|
+
/** Successfully loaded plugins */
|
|
53
|
+
plugins: CLIPlugin[];
|
|
54
|
+
/** Load results for all attempted packages */
|
|
55
|
+
results: PluginLoadResult[];
|
|
56
|
+
/** Packages that were not found (silent skip) */
|
|
57
|
+
notFoundPackages: string[];
|
|
58
|
+
/** Packages that failed to load (warning) */
|
|
59
|
+
failedPackages: string[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Result of merging subcommands from a plugin command into an existing command
|
|
63
|
+
*/
|
|
64
|
+
export interface SubcommandMergeResult {
|
|
65
|
+
/** Subcommand names that were successfully merged */
|
|
66
|
+
merged: string[];
|
|
67
|
+
/** Subcommand names that were skipped due to conflicts */
|
|
68
|
+
skipped: string[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Result of registering a command
|
|
72
|
+
*/
|
|
73
|
+
export interface CommandRegistrationResult {
|
|
74
|
+
/** Command name */
|
|
75
|
+
commandName: string;
|
|
76
|
+
/** Whether registration succeeded */
|
|
77
|
+
success: boolean;
|
|
78
|
+
/** Conflict reason if registration failed */
|
|
79
|
+
conflictReason?: string;
|
|
80
|
+
/** Result of subcommand merging (when both commands have subcommands) */
|
|
81
|
+
subcommandsMerged?: SubcommandMergeResult;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Result of registering a plugin's commands
|
|
85
|
+
*/
|
|
86
|
+
export interface PluginRegistrationResult {
|
|
87
|
+
/** Plugin name */
|
|
88
|
+
pluginName: string;
|
|
89
|
+
/** Commands that were successfully registered */
|
|
90
|
+
registeredCommands: string[];
|
|
91
|
+
/** Commands that were skipped due to conflicts */
|
|
92
|
+
skippedCommands: CommandRegistrationResult[];
|
|
93
|
+
/** Aliases that were successfully registered */
|
|
94
|
+
registeredAliases: string[];
|
|
95
|
+
/** Aliases that were skipped due to conflicts */
|
|
96
|
+
skippedAliases: string[];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Validates that an object is a valid CLIPlugin
|
|
100
|
+
*/
|
|
101
|
+
export declare function isValidCLIPlugin(obj: unknown): obj is CLIPlugin;
|
|
102
|
+
/**
|
|
103
|
+
* Validates plugin configuration
|
|
104
|
+
*/
|
|
105
|
+
export declare function isValidPluginsConfig(obj: unknown): obj is PluginsConfig;
|
|
106
|
+
//# sourceMappingURL=plugin-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-types.d.ts","sourceRoot":"","sources":["../../src/cli/plugin-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAM1C;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IAEb,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAEhB,uCAAuC;IACvC,QAAQ,EAAE,OAAO,EAAE,CAAC;IAEpB,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAMD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAMD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAC;IAEpB,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC;IAEjB,wCAAwC;IACxC,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,wDAAwD;IACxD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,kCAAkC;IAClC,OAAO,EAAE,SAAS,EAAE,CAAC;IAErB,8CAA8C;IAC9C,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAE5B,iDAAiD;IACjD,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAE3B,6CAA6C;IAC7C,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAMD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,qDAAqD;IACrD,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,mBAAmB;IACnB,WAAW,EAAE,MAAM,CAAC;IAEpB,qCAAqC;IACrC,OAAO,EAAE,OAAO,CAAC;IAEjB,6CAA6C;IAC7C,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,yEAAyE;IACzE,iBAAiB,CAAC,EAAE,qBAAqB,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,kBAAkB;IAClB,UAAU,EAAE,MAAM,CAAC;IAEnB,iDAAiD;IACjD,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAE7B,kDAAkD;IAClD,eAAe,EAAE,yBAAyB,EAAE,CAAC;IAE7C,gDAAgD;IAChD,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAE5B,iDAAiD;IACjD,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAMD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,SAAS,CA2C/D;AAyCD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,aAAa,CAkBvE"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Plugin Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the CLI plugin system.
|
|
5
|
+
* Plugins can register commands and aliases to extend the CLI.
|
|
6
|
+
*/
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Type Guards
|
|
9
|
+
// ============================================================================
|
|
10
|
+
/**
|
|
11
|
+
* Validates that an object is a valid CLIPlugin
|
|
12
|
+
*/
|
|
13
|
+
export function isValidCLIPlugin(obj) {
|
|
14
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const plugin = obj;
|
|
18
|
+
// Required fields
|
|
19
|
+
if (typeof plugin.name !== 'string' || plugin.name.length === 0) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (typeof plugin.version !== 'string' || plugin.version.length === 0) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (!Array.isArray(plugin.commands)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
// Validate commands array
|
|
29
|
+
for (const cmd of plugin.commands) {
|
|
30
|
+
if (!isValidCommand(cmd)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Optional aliases
|
|
35
|
+
if (plugin.aliases !== undefined) {
|
|
36
|
+
if (typeof plugin.aliases !== 'object' || plugin.aliases === null) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
for (const [key, value] of Object.entries(plugin.aliases)) {
|
|
40
|
+
if (typeof key !== 'string' || typeof value !== 'string') {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Optional init function
|
|
46
|
+
if (plugin.init !== undefined && typeof plugin.init !== 'function') {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Validates that an object is a valid Command
|
|
53
|
+
*/
|
|
54
|
+
function isValidCommand(obj) {
|
|
55
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
const cmd = obj;
|
|
59
|
+
// Required fields
|
|
60
|
+
if (typeof cmd.name !== 'string' || cmd.name.length === 0) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (typeof cmd.description !== 'string') {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (typeof cmd.usage !== 'string') {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (typeof cmd.handler !== 'function') {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
// Optional subcommands
|
|
73
|
+
if (cmd.subcommands !== undefined) {
|
|
74
|
+
if (typeof cmd.subcommands !== 'object' || cmd.subcommands === null) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
for (const subCmd of Object.values(cmd.subcommands)) {
|
|
78
|
+
if (!isValidCommand(subCmd)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Validates plugin configuration
|
|
87
|
+
*/
|
|
88
|
+
export function isValidPluginsConfig(obj) {
|
|
89
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
const config = obj;
|
|
93
|
+
if (!Array.isArray(config.packages)) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
for (const pkg of config.packages) {
|
|
97
|
+
if (typeof pkg !== 'string' || pkg.length === 0) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=plugin-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-types.js","sourceRoot":"","sources":["../../src/cli/plugin-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwIH,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAY;IAC3C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,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K,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC5C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,MAAM,GAAG,GAA8B,CAAC;IAE9C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAChD,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Runner
|
|
3
|
+
*
|
|
4
|
+
* Main entry point for command execution.
|
|
5
|
+
*/
|
|
6
|
+
import type { Command } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Registers a command
|
|
9
|
+
*/
|
|
10
|
+
export declare function registerCommand(command: Command): void;
|
|
11
|
+
/**
|
|
12
|
+
* Registers a command alias
|
|
13
|
+
*/
|
|
14
|
+
export declare function registerAlias(alias: string, commandName: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Gets a registered command (checking aliases first)
|
|
17
|
+
*/
|
|
18
|
+
export declare function getCommand(name: string): Command | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Gets all registered commands
|
|
21
|
+
*/
|
|
22
|
+
export declare function getAllCommands(): Command[];
|
|
23
|
+
/**
|
|
24
|
+
* Gets all registered aliases
|
|
25
|
+
*/
|
|
26
|
+
export declare function getAllAliases(): Map<string, string>;
|
|
27
|
+
/**
|
|
28
|
+
* Runs the CLI with the given arguments
|
|
29
|
+
*/
|
|
30
|
+
export declare function run(argv: string[]): Promise<number>;
|
|
31
|
+
/**
|
|
32
|
+
* Main CLI entry point
|
|
33
|
+
*/
|
|
34
|
+
export declare function main(argv?: string[]): Promise<never>;
|
|
35
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/cli/runner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAgC,MAAM,YAAY,CAAC;AAiBxE;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEtD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAEtE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAI5D;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,EAAE,CAE1C;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAEnD;AAwDD;;GAEG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAkGzD;AAgCD;;GAEG;AACH,wBAAsB,IAAI,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,KAAK,CAAC,CA+JjF"}
|