@dexto/agent-management 1.5.6 → 1.5.8

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.
Files changed (140) hide show
  1. package/dist/config/config-enrichment.cjs +72 -21
  2. package/dist/config/config-enrichment.d.ts +10 -2
  3. package/dist/config/config-enrichment.d.ts.map +1 -1
  4. package/dist/config/config-enrichment.js +76 -21
  5. package/dist/config/discover-prompts.cjs +1 -1
  6. package/dist/config/discover-prompts.d.ts +11 -11
  7. package/dist/config/discover-prompts.d.ts.map +1 -1
  8. package/dist/config/discover-prompts.js +1 -1
  9. package/dist/config/loader.cjs +31 -13
  10. package/dist/config/loader.d.ts.map +1 -1
  11. package/dist/config/loader.js +31 -13
  12. package/dist/index.cjs +76 -0
  13. package/dist/index.d.ts +5 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +78 -0
  16. package/dist/models/custom-models.cjs +2 -1
  17. package/dist/models/custom-models.d.ts +7 -6
  18. package/dist/models/custom-models.d.ts.map +1 -1
  19. package/dist/models/custom-models.js +2 -1
  20. package/dist/plugins/discover-plugins.cjs +176 -0
  21. package/dist/plugins/discover-plugins.d.ts +39 -0
  22. package/dist/plugins/discover-plugins.d.ts.map +1 -0
  23. package/dist/plugins/discover-plugins.js +140 -0
  24. package/dist/plugins/discover-skills.cjs +93 -0
  25. package/dist/plugins/discover-skills.d.ts +49 -0
  26. package/dist/plugins/discover-skills.d.ts.map +1 -0
  27. package/dist/plugins/discover-skills.js +58 -0
  28. package/dist/plugins/error-codes.cjs +47 -0
  29. package/dist/plugins/error-codes.d.ts +24 -0
  30. package/dist/plugins/error-codes.d.ts.map +1 -0
  31. package/dist/plugins/error-codes.js +23 -0
  32. package/dist/plugins/errors.cjs +197 -0
  33. package/dist/plugins/errors.d.ts +68 -0
  34. package/dist/plugins/errors.d.ts.map +1 -0
  35. package/dist/plugins/errors.js +173 -0
  36. package/dist/plugins/index.cjs +144 -0
  37. package/dist/plugins/index.d.ts +23 -0
  38. package/dist/plugins/index.d.ts.map +1 -0
  39. package/dist/plugins/index.js +115 -0
  40. package/dist/plugins/install-plugin.cjs +211 -0
  41. package/dist/plugins/install-plugin.d.ts +47 -0
  42. package/dist/plugins/install-plugin.d.ts.map +1 -0
  43. package/dist/plugins/install-plugin.js +173 -0
  44. package/dist/plugins/list-plugins.cjs +134 -0
  45. package/dist/plugins/list-plugins.d.ts +26 -0
  46. package/dist/plugins/list-plugins.d.ts.map +1 -0
  47. package/dist/plugins/list-plugins.js +99 -0
  48. package/dist/plugins/load-plugin.cjs +197 -0
  49. package/dist/plugins/load-plugin.d.ts +20 -0
  50. package/dist/plugins/load-plugin.d.ts.map +1 -0
  51. package/dist/plugins/load-plugin.js +163 -0
  52. package/dist/plugins/marketplace/error-codes.cjs +45 -0
  53. package/dist/plugins/marketplace/error-codes.d.ts +21 -0
  54. package/dist/plugins/marketplace/error-codes.d.ts.map +1 -0
  55. package/dist/plugins/marketplace/error-codes.js +21 -0
  56. package/dist/plugins/marketplace/errors.cjs +188 -0
  57. package/dist/plugins/marketplace/errors.d.ts +64 -0
  58. package/dist/plugins/marketplace/errors.d.ts.map +1 -0
  59. package/dist/plugins/marketplace/errors.js +164 -0
  60. package/dist/plugins/marketplace/index.cjs +95 -0
  61. package/dist/plugins/marketplace/index.d.ts +14 -0
  62. package/dist/plugins/marketplace/index.d.ts.map +1 -0
  63. package/dist/plugins/marketplace/index.js +74 -0
  64. package/dist/plugins/marketplace/install-from-marketplace.cjs +152 -0
  65. package/dist/plugins/marketplace/install-from-marketplace.d.ts +25 -0
  66. package/dist/plugins/marketplace/install-from-marketplace.d.ts.map +1 -0
  67. package/dist/plugins/marketplace/install-from-marketplace.js +120 -0
  68. package/dist/plugins/marketplace/operations.cjs +374 -0
  69. package/dist/plugins/marketplace/operations.d.ts +43 -0
  70. package/dist/plugins/marketplace/operations.d.ts.map +1 -0
  71. package/dist/plugins/marketplace/operations.js +339 -0
  72. package/dist/plugins/marketplace/registry.cjs +166 -0
  73. package/dist/plugins/marketplace/registry.d.ts +72 -0
  74. package/dist/plugins/marketplace/registry.d.ts.map +1 -0
  75. package/dist/plugins/marketplace/registry.js +119 -0
  76. package/dist/plugins/marketplace/schemas.cjs +79 -0
  77. package/dist/plugins/marketplace/schemas.d.ts +260 -0
  78. package/dist/plugins/marketplace/schemas.d.ts.map +1 -0
  79. package/dist/plugins/marketplace/schemas.js +49 -0
  80. package/dist/plugins/marketplace/types.cjs +16 -0
  81. package/dist/plugins/marketplace/types.d.ts +156 -0
  82. package/dist/plugins/marketplace/types.d.ts.map +1 -0
  83. package/dist/plugins/marketplace/types.js +0 -0
  84. package/dist/plugins/schemas.cjs +74 -0
  85. package/dist/plugins/schemas.d.ts +262 -0
  86. package/dist/plugins/schemas.d.ts.map +1 -0
  87. package/dist/plugins/schemas.js +46 -0
  88. package/dist/plugins/types.cjs +16 -0
  89. package/dist/plugins/types.d.ts +186 -0
  90. package/dist/plugins/types.d.ts.map +1 -0
  91. package/dist/plugins/types.js +0 -0
  92. package/dist/plugins/uninstall-plugin.cjs +133 -0
  93. package/dist/plugins/uninstall-plugin.d.ts +24 -0
  94. package/dist/plugins/uninstall-plugin.d.ts.map +1 -0
  95. package/dist/plugins/uninstall-plugin.js +99 -0
  96. package/dist/plugins/validate-plugin.cjs +180 -0
  97. package/dist/plugins/validate-plugin.d.ts +53 -0
  98. package/dist/plugins/validate-plugin.d.ts.map +1 -0
  99. package/dist/plugins/validate-plugin.js +145 -0
  100. package/dist/preferences/errors.cjs +11 -0
  101. package/dist/preferences/errors.d.ts +1 -0
  102. package/dist/preferences/errors.d.ts.map +1 -1
  103. package/dist/preferences/errors.js +11 -0
  104. package/dist/preferences/loader.cjs +119 -6
  105. package/dist/preferences/loader.d.ts +21 -1
  106. package/dist/preferences/loader.d.ts.map +1 -1
  107. package/dist/preferences/loader.js +102 -1
  108. package/dist/preferences/schemas.cjs +12 -0
  109. package/dist/preferences/schemas.d.ts +38 -12
  110. package/dist/preferences/schemas.d.ts.map +1 -1
  111. package/dist/preferences/schemas.js +10 -0
  112. package/dist/runtime/AgentRuntime.cjs +1 -2
  113. package/dist/runtime/AgentRuntime.d.ts.map +1 -1
  114. package/dist/runtime/AgentRuntime.js +1 -2
  115. package/dist/tool-provider/llm-resolution.cjs +74 -0
  116. package/dist/tool-provider/llm-resolution.d.ts +51 -0
  117. package/dist/tool-provider/llm-resolution.d.ts.map +1 -0
  118. package/dist/tool-provider/llm-resolution.js +50 -0
  119. package/dist/tool-provider/runtime-service.cjs +246 -34
  120. package/dist/tool-provider/runtime-service.d.ts +34 -2
  121. package/dist/tool-provider/runtime-service.d.ts.map +1 -1
  122. package/dist/tool-provider/runtime-service.js +236 -34
  123. package/dist/tool-provider/tool-provider.cjs +154 -1
  124. package/dist/tool-provider/tool-provider.d.ts +7 -1
  125. package/dist/tool-provider/tool-provider.d.ts.map +1 -1
  126. package/dist/tool-provider/tool-provider.js +161 -1
  127. package/dist/tool-provider/types.d.ts +2 -0
  128. package/dist/tool-provider/types.d.ts.map +1 -1
  129. package/dist/utils/api-key-resolver.cjs +5 -2
  130. package/dist/utils/api-key-resolver.d.ts.map +1 -1
  131. package/dist/utils/api-key-resolver.js +5 -2
  132. package/dist/utils/dexto-auth.cjs +83 -0
  133. package/dist/utils/dexto-auth.d.ts +23 -0
  134. package/dist/utils/dexto-auth.d.ts.map +1 -0
  135. package/dist/utils/dexto-auth.js +57 -0
  136. package/dist/utils/feature-flags.cjs +32 -0
  137. package/dist/utils/feature-flags.d.ts +21 -0
  138. package/dist/utils/feature-flags.d.ts.map +1 -0
  139. package/dist/utils/feature-flags.js +8 -0
  140. package/package.json +3 -2
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Plugin Listing
3
+ *
4
+ * Lists all installed plugins managed by Dexto:
5
+ * 1. Dexto's installed_plugins.json (~/.dexto/plugins/installed_plugins.json)
6
+ * 2. Directory scanning of Dexto plugin directories (project and user)
7
+ *
8
+ * Deduplicates by plugin name (first found wins).
9
+ */
10
+ import type { ListedPlugin } from './types.js';
11
+ /**
12
+ * Path to Dexto's installed_plugins.json
13
+ */
14
+ export declare function getDextoInstalledPluginsPath(): string;
15
+ /**
16
+ * Lists all installed plugins managed by Dexto.
17
+ *
18
+ * Discovery sources:
19
+ * 1. ~/.dexto/plugins/installed_plugins.json (tracked installations)
20
+ * 2. Directory scanning of .dexto/plugins (project and user)
21
+ *
22
+ * @param projectPath Optional project path for filtering project-scoped plugins
23
+ * @returns Array of listed plugins, deduplicated by name (first found wins)
24
+ */
25
+ export declare function listInstalledPlugins(projectPath?: string): ListedPlugin[];
26
+ //# sourceMappingURL=list-plugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-plugins.d.ts","sourceRoot":"","sources":["../../src/plugins/list-plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAsB,MAAM,YAAY,CAAC;AAEnE;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,MAAM,CAErD;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,YAAY,EAAE,CA8DzE"}
@@ -0,0 +1,99 @@
1
+ import * as path from "path";
2
+ import { existsSync, readFileSync, readdirSync } from "fs";
3
+ import { getDextoGlobalPath } from "../utils/path.js";
4
+ import { InstalledPluginsFileSchema } from "./schemas.js";
5
+ import { tryLoadManifest } from "./validate-plugin.js";
6
+ function getDextoInstalledPluginsPath() {
7
+ return getDextoGlobalPath("plugins", "installed_plugins.json");
8
+ }
9
+ function listInstalledPlugins(projectPath) {
10
+ const plugins = [];
11
+ const seenNames = /* @__PURE__ */ new Set();
12
+ const cwd = projectPath || process.cwd();
13
+ const addPlugin = (plugin) => {
14
+ const normalizedName = plugin.name.toLowerCase();
15
+ if (seenNames.has(normalizedName)) {
16
+ return false;
17
+ }
18
+ seenNames.add(normalizedName);
19
+ plugins.push(plugin);
20
+ return true;
21
+ };
22
+ const { plugins: dextoPlugins } = readDextoInstalledPlugins(cwd);
23
+ for (const plugin of dextoPlugins) {
24
+ addPlugin(plugin);
25
+ }
26
+ const scanPluginsDir = (dir) => {
27
+ if (!existsSync(dir)) return;
28
+ try {
29
+ const entries = readdirSync(dir, { withFileTypes: true });
30
+ for (const entry of entries) {
31
+ if (!entry.isDirectory()) continue;
32
+ if (entry.name === "cache" || entry.name === "marketplaces") continue;
33
+ const pluginPath = path.join(dir, entry.name);
34
+ const manifest = tryLoadManifest(pluginPath);
35
+ if (manifest) {
36
+ addPlugin({
37
+ name: manifest.name,
38
+ description: manifest.description,
39
+ version: manifest.version,
40
+ path: pluginPath,
41
+ source: "dexto"
42
+ });
43
+ }
44
+ }
45
+ } catch {
46
+ }
47
+ };
48
+ scanPluginsDir(path.join(cwd, ".dexto", "plugins"));
49
+ scanPluginsDir(getDextoGlobalPath("plugins"));
50
+ return plugins;
51
+ }
52
+ function readDextoInstalledPlugins(currentProjectPath) {
53
+ const plugins = [];
54
+ const filePath = getDextoInstalledPluginsPath();
55
+ if (!existsSync(filePath)) {
56
+ return { plugins };
57
+ }
58
+ try {
59
+ const content = readFileSync(filePath, "utf-8");
60
+ const parsed = JSON.parse(content);
61
+ const result = InstalledPluginsFileSchema.safeParse(parsed);
62
+ if (!result.success) {
63
+ return { plugins };
64
+ }
65
+ for (const [_pluginId, installations] of Object.entries(result.data.plugins)) {
66
+ for (const installation of installations) {
67
+ const { scope, installPath, version, installedAt, projectPath } = installation;
68
+ if (!existsSync(installPath)) {
69
+ continue;
70
+ }
71
+ const manifest = tryLoadManifest(installPath);
72
+ if (manifest) {
73
+ if ((scope === "project" || scope === "local") && projectPath) {
74
+ const normalizedProjectPath = path.resolve(projectPath).toLowerCase();
75
+ const normalizedCurrentPath = path.resolve(currentProjectPath).toLowerCase();
76
+ if (normalizedProjectPath !== normalizedCurrentPath) {
77
+ continue;
78
+ }
79
+ }
80
+ plugins.push({
81
+ name: manifest.name,
82
+ description: manifest.description,
83
+ version: version || manifest.version,
84
+ path: installPath,
85
+ source: "dexto",
86
+ scope,
87
+ installedAt
88
+ });
89
+ }
90
+ }
91
+ }
92
+ } catch {
93
+ }
94
+ return { plugins };
95
+ }
96
+ export {
97
+ getDextoInstalledPluginsPath,
98
+ listInstalledPlugins
99
+ };
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var load_plugin_exports = {};
30
+ __export(load_plugin_exports, {
31
+ loadClaudeCodePlugin: () => loadClaudeCodePlugin
32
+ });
33
+ module.exports = __toCommonJS(load_plugin_exports);
34
+ var path = __toESM(require("path"), 1);
35
+ var import_fs = require("fs");
36
+ var import_schemas = require("./schemas.js");
37
+ function isDextoManifest(manifest) {
38
+ return typeof manifest === "object" && manifest !== null && "customToolProviders" in manifest && Array.isArray(manifest.customToolProviders);
39
+ }
40
+ function loadClaudeCodePlugin(plugin) {
41
+ const warnings = [];
42
+ const commands = [];
43
+ const pluginName = plugin.manifest.name;
44
+ const pluginPath = plugin.path;
45
+ const format = plugin.format;
46
+ const commandsDir = path.join(pluginPath, "commands");
47
+ if ((0, import_fs.existsSync)(commandsDir)) {
48
+ const commandFiles = scanMarkdownFiles(commandsDir);
49
+ for (const file of commandFiles) {
50
+ const content = readFileSafe(file);
51
+ if (!content) {
52
+ warnings.push(
53
+ `[${pluginName}] Command '${path.basename(file)}' could not be read and will be skipped`
54
+ );
55
+ continue;
56
+ }
57
+ commands.push({
58
+ file,
59
+ namespace: pluginName,
60
+ isSkill: false
61
+ });
62
+ }
63
+ }
64
+ const skillsDir = path.join(pluginPath, "skills");
65
+ if ((0, import_fs.existsSync)(skillsDir)) {
66
+ try {
67
+ const entries = (0, import_fs.readdirSync)(skillsDir, { withFileTypes: true });
68
+ for (const entry of entries) {
69
+ if (!entry.isDirectory()) continue;
70
+ const skillFile = path.join(skillsDir, entry.name, "SKILL.md");
71
+ if ((0, import_fs.existsSync)(skillFile)) {
72
+ const content = readFileSafe(skillFile);
73
+ if (!content) {
74
+ warnings.push(
75
+ `[${pluginName}] Skill '${entry.name}' could not be read and will be skipped`
76
+ );
77
+ continue;
78
+ }
79
+ commands.push({
80
+ file: skillFile,
81
+ namespace: pluginName,
82
+ isSkill: true
83
+ });
84
+ }
85
+ }
86
+ } catch {
87
+ }
88
+ }
89
+ const mcpConfig = loadMcpConfig(pluginPath, pluginName, warnings);
90
+ checkUnsupportedFeatures(pluginPath, pluginName, warnings);
91
+ const customToolProviders = [];
92
+ if (format === "dexto" && isDextoManifest(plugin.manifest)) {
93
+ const providers = plugin.manifest.customToolProviders;
94
+ if (providers && providers.length > 0) {
95
+ customToolProviders.push(...providers);
96
+ }
97
+ }
98
+ return {
99
+ manifest: plugin.manifest,
100
+ format,
101
+ commands,
102
+ mcpConfig,
103
+ customToolProviders,
104
+ warnings
105
+ };
106
+ }
107
+ function scanMarkdownFiles(dir) {
108
+ const files = [];
109
+ try {
110
+ const entries = (0, import_fs.readdirSync)(dir, { withFileTypes: true });
111
+ for (const entry of entries) {
112
+ if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
113
+ files.push(path.join(dir, entry.name));
114
+ }
115
+ }
116
+ } catch {
117
+ }
118
+ return files;
119
+ }
120
+ function readFileSafe(filePath) {
121
+ try {
122
+ return (0, import_fs.readFileSync)(filePath, "utf-8");
123
+ } catch {
124
+ return null;
125
+ }
126
+ }
127
+ function loadMcpConfig(pluginPath, pluginName, warnings) {
128
+ const mcpPath = path.join(pluginPath, ".mcp.json");
129
+ if (!(0, import_fs.existsSync)(mcpPath)) {
130
+ return void 0;
131
+ }
132
+ try {
133
+ const content = (0, import_fs.readFileSync)(mcpPath, "utf-8");
134
+ const parsed = JSON.parse(content);
135
+ if (!parsed.mcpServers && typeof parsed === "object" && parsed !== null) {
136
+ const hasServerConfig = Object.values(parsed).some(
137
+ (val) => typeof val === "object" && val !== null && ("type" in val || "command" in val || "url" in val)
138
+ );
139
+ if (hasServerConfig) {
140
+ const normalized = {};
141
+ for (const [serverName, serverConfig] of Object.entries(parsed)) {
142
+ if (typeof serverConfig === "object" && serverConfig !== null && !Array.isArray(serverConfig)) {
143
+ const config = serverConfig;
144
+ if ("type" in config) {
145
+ normalized[serverName] = config;
146
+ } else if ("command" in config) {
147
+ normalized[serverName] = {
148
+ type: "stdio",
149
+ ...config
150
+ };
151
+ } else if ("url" in config) {
152
+ const url = String(config.url || "");
153
+ const inferredType = url.includes("/sse") ? "sse" : "http";
154
+ normalized[serverName] = {
155
+ type: inferredType,
156
+ ...config
157
+ };
158
+ } else {
159
+ normalized[serverName] = config;
160
+ }
161
+ }
162
+ }
163
+ return { mcpServers: normalized };
164
+ }
165
+ }
166
+ const result = import_schemas.PluginMCPConfigSchema.safeParse(parsed);
167
+ if (!result.success) {
168
+ const issues = result.error.issues.map((i) => i.message).join(", ");
169
+ warnings.push(`[${pluginName}] Invalid .mcp.json: ${issues}`);
170
+ return void 0;
171
+ }
172
+ return result.data;
173
+ } catch (error) {
174
+ if (error instanceof SyntaxError) {
175
+ warnings.push(`[${pluginName}] Failed to parse .mcp.json: invalid JSON`);
176
+ } else {
177
+ warnings.push(`[${pluginName}] Failed to load .mcp.json: ${String(error)}`);
178
+ }
179
+ return void 0;
180
+ }
181
+ }
182
+ function checkUnsupportedFeatures(pluginPath, pluginName, warnings) {
183
+ const hooksPath = path.join(pluginPath, "hooks", "hooks.json");
184
+ if ((0, import_fs.existsSync)(hooksPath)) {
185
+ warnings.push(
186
+ `[${pluginName}] hooks/hooks.json detected but not supported (security risk)`
187
+ );
188
+ }
189
+ const lspPath = path.join(pluginPath, ".lsp.json");
190
+ if ((0, import_fs.existsSync)(lspPath)) {
191
+ warnings.push(`[${pluginName}] .lsp.json detected but not supported (LSP integration)`);
192
+ }
193
+ }
194
+ // Annotate the CommonJS export names for ESM import in node:
195
+ 0 && (module.exports = {
196
+ loadClaudeCodePlugin
197
+ });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Plugin Loader
3
+ *
4
+ * Loads plugin contents including commands, skills, MCP configuration,
5
+ * and custom tool providers (Dexto-native plugins).
6
+ * Detects and warns about unsupported features (hooks, LSP).
7
+ *
8
+ * Supports two plugin formats:
9
+ * - .claude-plugin: Claude Code compatible format
10
+ * - .dexto-plugin: Dexto-native format with extended features (customToolProviders)
11
+ */
12
+ import type { DiscoveredPlugin, LoadedPlugin } from './types.js';
13
+ /**
14
+ * Loads a discovered plugin's contents.
15
+ *
16
+ * @param plugin The discovered plugin to load
17
+ * @returns Loaded plugin with commands, MCP config, custom tool providers, and warnings
18
+ */
19
+ export declare function loadClaudeCodePlugin(plugin: DiscoveredPlugin): LoadedPlugin;
20
+ //# sourceMappingURL=load-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/load-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EACR,gBAAgB,EAChB,YAAY,EAIf,MAAM,YAAY,CAAC;AAcpB;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,GAAG,YAAY,CAiF3E"}
@@ -0,0 +1,163 @@
1
+ import * as path from "path";
2
+ import { existsSync, readdirSync, readFileSync } from "fs";
3
+ import { PluginMCPConfigSchema } from "./schemas.js";
4
+ function isDextoManifest(manifest) {
5
+ return typeof manifest === "object" && manifest !== null && "customToolProviders" in manifest && Array.isArray(manifest.customToolProviders);
6
+ }
7
+ function loadClaudeCodePlugin(plugin) {
8
+ const warnings = [];
9
+ const commands = [];
10
+ const pluginName = plugin.manifest.name;
11
+ const pluginPath = plugin.path;
12
+ const format = plugin.format;
13
+ const commandsDir = path.join(pluginPath, "commands");
14
+ if (existsSync(commandsDir)) {
15
+ const commandFiles = scanMarkdownFiles(commandsDir);
16
+ for (const file of commandFiles) {
17
+ const content = readFileSafe(file);
18
+ if (!content) {
19
+ warnings.push(
20
+ `[${pluginName}] Command '${path.basename(file)}' could not be read and will be skipped`
21
+ );
22
+ continue;
23
+ }
24
+ commands.push({
25
+ file,
26
+ namespace: pluginName,
27
+ isSkill: false
28
+ });
29
+ }
30
+ }
31
+ const skillsDir = path.join(pluginPath, "skills");
32
+ if (existsSync(skillsDir)) {
33
+ try {
34
+ const entries = readdirSync(skillsDir, { withFileTypes: true });
35
+ for (const entry of entries) {
36
+ if (!entry.isDirectory()) continue;
37
+ const skillFile = path.join(skillsDir, entry.name, "SKILL.md");
38
+ if (existsSync(skillFile)) {
39
+ const content = readFileSafe(skillFile);
40
+ if (!content) {
41
+ warnings.push(
42
+ `[${pluginName}] Skill '${entry.name}' could not be read and will be skipped`
43
+ );
44
+ continue;
45
+ }
46
+ commands.push({
47
+ file: skillFile,
48
+ namespace: pluginName,
49
+ isSkill: true
50
+ });
51
+ }
52
+ }
53
+ } catch {
54
+ }
55
+ }
56
+ const mcpConfig = loadMcpConfig(pluginPath, pluginName, warnings);
57
+ checkUnsupportedFeatures(pluginPath, pluginName, warnings);
58
+ const customToolProviders = [];
59
+ if (format === "dexto" && isDextoManifest(plugin.manifest)) {
60
+ const providers = plugin.manifest.customToolProviders;
61
+ if (providers && providers.length > 0) {
62
+ customToolProviders.push(...providers);
63
+ }
64
+ }
65
+ return {
66
+ manifest: plugin.manifest,
67
+ format,
68
+ commands,
69
+ mcpConfig,
70
+ customToolProviders,
71
+ warnings
72
+ };
73
+ }
74
+ function scanMarkdownFiles(dir) {
75
+ const files = [];
76
+ try {
77
+ const entries = readdirSync(dir, { withFileTypes: true });
78
+ for (const entry of entries) {
79
+ if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
80
+ files.push(path.join(dir, entry.name));
81
+ }
82
+ }
83
+ } catch {
84
+ }
85
+ return files;
86
+ }
87
+ function readFileSafe(filePath) {
88
+ try {
89
+ return readFileSync(filePath, "utf-8");
90
+ } catch {
91
+ return null;
92
+ }
93
+ }
94
+ function loadMcpConfig(pluginPath, pluginName, warnings) {
95
+ const mcpPath = path.join(pluginPath, ".mcp.json");
96
+ if (!existsSync(mcpPath)) {
97
+ return void 0;
98
+ }
99
+ try {
100
+ const content = readFileSync(mcpPath, "utf-8");
101
+ const parsed = JSON.parse(content);
102
+ if (!parsed.mcpServers && typeof parsed === "object" && parsed !== null) {
103
+ const hasServerConfig = Object.values(parsed).some(
104
+ (val) => typeof val === "object" && val !== null && ("type" in val || "command" in val || "url" in val)
105
+ );
106
+ if (hasServerConfig) {
107
+ const normalized = {};
108
+ for (const [serverName, serverConfig] of Object.entries(parsed)) {
109
+ if (typeof serverConfig === "object" && serverConfig !== null && !Array.isArray(serverConfig)) {
110
+ const config = serverConfig;
111
+ if ("type" in config) {
112
+ normalized[serverName] = config;
113
+ } else if ("command" in config) {
114
+ normalized[serverName] = {
115
+ type: "stdio",
116
+ ...config
117
+ };
118
+ } else if ("url" in config) {
119
+ const url = String(config.url || "");
120
+ const inferredType = url.includes("/sse") ? "sse" : "http";
121
+ normalized[serverName] = {
122
+ type: inferredType,
123
+ ...config
124
+ };
125
+ } else {
126
+ normalized[serverName] = config;
127
+ }
128
+ }
129
+ }
130
+ return { mcpServers: normalized };
131
+ }
132
+ }
133
+ const result = PluginMCPConfigSchema.safeParse(parsed);
134
+ if (!result.success) {
135
+ const issues = result.error.issues.map((i) => i.message).join(", ");
136
+ warnings.push(`[${pluginName}] Invalid .mcp.json: ${issues}`);
137
+ return void 0;
138
+ }
139
+ return result.data;
140
+ } catch (error) {
141
+ if (error instanceof SyntaxError) {
142
+ warnings.push(`[${pluginName}] Failed to parse .mcp.json: invalid JSON`);
143
+ } else {
144
+ warnings.push(`[${pluginName}] Failed to load .mcp.json: ${String(error)}`);
145
+ }
146
+ return void 0;
147
+ }
148
+ }
149
+ function checkUnsupportedFeatures(pluginPath, pluginName, warnings) {
150
+ const hooksPath = path.join(pluginPath, "hooks", "hooks.json");
151
+ if (existsSync(hooksPath)) {
152
+ warnings.push(
153
+ `[${pluginName}] hooks/hooks.json detected but not supported (security risk)`
154
+ );
155
+ }
156
+ const lspPath = path.join(pluginPath, ".lsp.json");
157
+ if (existsSync(lspPath)) {
158
+ warnings.push(`[${pluginName}] .lsp.json detected but not supported (LSP integration)`);
159
+ }
160
+ }
161
+ export {
162
+ loadClaudeCodePlugin
163
+ };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var error_codes_exports = {};
20
+ __export(error_codes_exports, {
21
+ MarketplaceErrorCode: () => MarketplaceErrorCode
22
+ });
23
+ module.exports = __toCommonJS(error_codes_exports);
24
+ var MarketplaceErrorCode = /* @__PURE__ */ ((MarketplaceErrorCode2) => {
25
+ MarketplaceErrorCode2["REGISTRY_READ_FAILED"] = "marketplace_registry_read_failed";
26
+ MarketplaceErrorCode2["REGISTRY_WRITE_FAILED"] = "marketplace_registry_write_failed";
27
+ MarketplaceErrorCode2["ADD_ALREADY_EXISTS"] = "marketplace_add_already_exists";
28
+ MarketplaceErrorCode2["ADD_CLONE_FAILED"] = "marketplace_add_clone_failed";
29
+ MarketplaceErrorCode2["ADD_INVALID_SOURCE"] = "marketplace_add_invalid_source";
30
+ MarketplaceErrorCode2["ADD_LOCAL_NOT_FOUND"] = "marketplace_add_local_not_found";
31
+ MarketplaceErrorCode2["REMOVE_NOT_FOUND"] = "marketplace_remove_not_found";
32
+ MarketplaceErrorCode2["REMOVE_DELETE_FAILED"] = "marketplace_remove_delete_failed";
33
+ MarketplaceErrorCode2["UPDATE_NOT_FOUND"] = "marketplace_update_not_found";
34
+ MarketplaceErrorCode2["UPDATE_PULL_FAILED"] = "marketplace_update_pull_failed";
35
+ MarketplaceErrorCode2["UPDATE_LOCAL_NOT_SUPPORTED"] = "marketplace_update_local_not_supported";
36
+ MarketplaceErrorCode2["INSTALL_MARKETPLACE_NOT_FOUND"] = "marketplace_install_marketplace_not_found";
37
+ MarketplaceErrorCode2["INSTALL_PLUGIN_NOT_FOUND"] = "marketplace_install_plugin_not_found";
38
+ MarketplaceErrorCode2["INSTALL_COPY_FAILED"] = "marketplace_install_copy_failed";
39
+ MarketplaceErrorCode2["SCAN_FAILED"] = "marketplace_scan_failed";
40
+ return MarketplaceErrorCode2;
41
+ })(MarketplaceErrorCode || {});
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ MarketplaceErrorCode
45
+ });
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Plugin Marketplace Error Codes
3
+ */
4
+ export declare enum MarketplaceErrorCode {
5
+ REGISTRY_READ_FAILED = "marketplace_registry_read_failed",
6
+ REGISTRY_WRITE_FAILED = "marketplace_registry_write_failed",
7
+ ADD_ALREADY_EXISTS = "marketplace_add_already_exists",
8
+ ADD_CLONE_FAILED = "marketplace_add_clone_failed",
9
+ ADD_INVALID_SOURCE = "marketplace_add_invalid_source",
10
+ ADD_LOCAL_NOT_FOUND = "marketplace_add_local_not_found",
11
+ REMOVE_NOT_FOUND = "marketplace_remove_not_found",
12
+ REMOVE_DELETE_FAILED = "marketplace_remove_delete_failed",
13
+ UPDATE_NOT_FOUND = "marketplace_update_not_found",
14
+ UPDATE_PULL_FAILED = "marketplace_update_pull_failed",
15
+ UPDATE_LOCAL_NOT_SUPPORTED = "marketplace_update_local_not_supported",
16
+ INSTALL_MARKETPLACE_NOT_FOUND = "marketplace_install_marketplace_not_found",
17
+ INSTALL_PLUGIN_NOT_FOUND = "marketplace_install_plugin_not_found",
18
+ INSTALL_COPY_FAILED = "marketplace_install_copy_failed",
19
+ SCAN_FAILED = "marketplace_scan_failed"
20
+ }
21
+ //# sourceMappingURL=error-codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../../../src/plugins/marketplace/error-codes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oBAAY,oBAAoB;IAE5B,oBAAoB,qCAAqC;IACzD,qBAAqB,sCAAsC;IAG3D,kBAAkB,mCAAmC;IACrD,gBAAgB,iCAAiC;IACjD,kBAAkB,mCAAmC;IACrD,mBAAmB,oCAAoC;IAGvD,gBAAgB,iCAAiC;IACjD,oBAAoB,qCAAqC;IAGzD,gBAAgB,iCAAiC;IACjD,kBAAkB,mCAAmC;IACrD,0BAA0B,2CAA2C;IAGrE,6BAA6B,8CAA8C;IAC3E,wBAAwB,yCAAyC;IACjE,mBAAmB,oCAAoC;IAGvD,WAAW,4BAA4B;CAC1C"}
@@ -0,0 +1,21 @@
1
+ var MarketplaceErrorCode = /* @__PURE__ */ ((MarketplaceErrorCode2) => {
2
+ MarketplaceErrorCode2["REGISTRY_READ_FAILED"] = "marketplace_registry_read_failed";
3
+ MarketplaceErrorCode2["REGISTRY_WRITE_FAILED"] = "marketplace_registry_write_failed";
4
+ MarketplaceErrorCode2["ADD_ALREADY_EXISTS"] = "marketplace_add_already_exists";
5
+ MarketplaceErrorCode2["ADD_CLONE_FAILED"] = "marketplace_add_clone_failed";
6
+ MarketplaceErrorCode2["ADD_INVALID_SOURCE"] = "marketplace_add_invalid_source";
7
+ MarketplaceErrorCode2["ADD_LOCAL_NOT_FOUND"] = "marketplace_add_local_not_found";
8
+ MarketplaceErrorCode2["REMOVE_NOT_FOUND"] = "marketplace_remove_not_found";
9
+ MarketplaceErrorCode2["REMOVE_DELETE_FAILED"] = "marketplace_remove_delete_failed";
10
+ MarketplaceErrorCode2["UPDATE_NOT_FOUND"] = "marketplace_update_not_found";
11
+ MarketplaceErrorCode2["UPDATE_PULL_FAILED"] = "marketplace_update_pull_failed";
12
+ MarketplaceErrorCode2["UPDATE_LOCAL_NOT_SUPPORTED"] = "marketplace_update_local_not_supported";
13
+ MarketplaceErrorCode2["INSTALL_MARKETPLACE_NOT_FOUND"] = "marketplace_install_marketplace_not_found";
14
+ MarketplaceErrorCode2["INSTALL_PLUGIN_NOT_FOUND"] = "marketplace_install_plugin_not_found";
15
+ MarketplaceErrorCode2["INSTALL_COPY_FAILED"] = "marketplace_install_copy_failed";
16
+ MarketplaceErrorCode2["SCAN_FAILED"] = "marketplace_scan_failed";
17
+ return MarketplaceErrorCode2;
18
+ })(MarketplaceErrorCode || {});
19
+ export {
20
+ MarketplaceErrorCode
21
+ };