@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,115 @@
1
+ import {
2
+ PluginManifestSchema,
3
+ DextoPluginManifestSchema,
4
+ PluginMCPConfigSchema,
5
+ InstalledPluginEntrySchema,
6
+ InstalledPluginsFileSchema
7
+ } from "./schemas.js";
8
+ import { PluginErrorCode } from "./error-codes.js";
9
+ import { PluginError } from "./errors.js";
10
+ import {
11
+ discoverClaudeCodePlugins,
12
+ getPluginSearchPaths,
13
+ getInstalledPluginsPath
14
+ } from "./discover-plugins.js";
15
+ import { discoverStandaloneSkills, getSkillSearchPaths } from "./discover-skills.js";
16
+ import { loadClaudeCodePlugin } from "./load-plugin.js";
17
+ import { validatePluginDirectory, tryLoadManifest } from "./validate-plugin.js";
18
+ import { listInstalledPlugins, getDextoInstalledPluginsPath } from "./list-plugins.js";
19
+ import {
20
+ installPluginFromPath,
21
+ loadDextoInstalledPlugins,
22
+ saveDextoInstalledPlugins,
23
+ isPluginInstalled
24
+ } from "./install-plugin.js";
25
+ import { uninstallPlugin } from "./uninstall-plugin.js";
26
+ import {
27
+ MarketplaceSourceSchema,
28
+ MarketplaceEntrySchema,
29
+ KnownMarketplacesFileSchema,
30
+ MarketplaceManifestSchema,
31
+ MarketplacePluginEntrySchema,
32
+ MarketplaceAddCommandSchema,
33
+ MarketplaceInstallCommandSchema,
34
+ MarketplaceErrorCode,
35
+ MarketplaceError,
36
+ DEFAULT_MARKETPLACES,
37
+ getMarketplacesRegistryPath,
38
+ getMarketplacesDir,
39
+ getMarketplaceCacheDir,
40
+ loadKnownMarketplaces,
41
+ saveKnownMarketplaces,
42
+ getMarketplaceEntry,
43
+ marketplaceExists,
44
+ getAllMarketplaces,
45
+ getUninstalledDefaults,
46
+ isDefaultMarketplace,
47
+ parseMarketplaceSource,
48
+ deriveMarketplaceName,
49
+ addMarketplace,
50
+ removeMarketplace,
51
+ updateMarketplace,
52
+ listMarketplaces,
53
+ scanMarketplacePlugins,
54
+ listAllMarketplacePlugins,
55
+ findPluginInMarketplaces,
56
+ parsePluginSpec,
57
+ installPluginFromMarketplace,
58
+ searchMarketplacePlugins
59
+ } from "./marketplace/index.js";
60
+ export {
61
+ DEFAULT_MARKETPLACES,
62
+ DextoPluginManifestSchema,
63
+ InstalledPluginEntrySchema,
64
+ InstalledPluginsFileSchema,
65
+ KnownMarketplacesFileSchema,
66
+ MarketplaceAddCommandSchema,
67
+ MarketplaceEntrySchema,
68
+ MarketplaceError,
69
+ MarketplaceErrorCode,
70
+ MarketplaceInstallCommandSchema,
71
+ MarketplaceManifestSchema,
72
+ MarketplacePluginEntrySchema,
73
+ MarketplaceSourceSchema,
74
+ PluginError,
75
+ PluginErrorCode,
76
+ PluginMCPConfigSchema,
77
+ PluginManifestSchema,
78
+ addMarketplace,
79
+ deriveMarketplaceName,
80
+ discoverClaudeCodePlugins,
81
+ discoverStandaloneSkills,
82
+ findPluginInMarketplaces,
83
+ getAllMarketplaces,
84
+ getDextoInstalledPluginsPath,
85
+ getInstalledPluginsPath,
86
+ getMarketplaceCacheDir,
87
+ getMarketplaceEntry,
88
+ getMarketplacesDir,
89
+ getMarketplacesRegistryPath,
90
+ getPluginSearchPaths,
91
+ getSkillSearchPaths,
92
+ getUninstalledDefaults,
93
+ installPluginFromMarketplace,
94
+ installPluginFromPath,
95
+ isDefaultMarketplace,
96
+ isPluginInstalled,
97
+ listAllMarketplacePlugins,
98
+ listInstalledPlugins,
99
+ listMarketplaces,
100
+ loadClaudeCodePlugin,
101
+ loadDextoInstalledPlugins,
102
+ loadKnownMarketplaces,
103
+ marketplaceExists,
104
+ parseMarketplaceSource,
105
+ parsePluginSpec,
106
+ removeMarketplace,
107
+ saveDextoInstalledPlugins,
108
+ saveKnownMarketplaces,
109
+ scanMarketplacePlugins,
110
+ searchMarketplacePlugins,
111
+ tryLoadManifest,
112
+ uninstallPlugin,
113
+ updateMarketplace,
114
+ validatePluginDirectory
115
+ };
@@ -0,0 +1,211 @@
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 install_plugin_exports = {};
30
+ __export(install_plugin_exports, {
31
+ getDextoInstalledPluginsPath: () => getDextoInstalledPluginsPath,
32
+ installPluginFromPath: () => installPluginFromPath,
33
+ isPluginInstalled: () => isPluginInstalled,
34
+ loadDextoInstalledPlugins: () => loadDextoInstalledPlugins,
35
+ saveDextoInstalledPlugins: () => saveDextoInstalledPlugins
36
+ });
37
+ module.exports = __toCommonJS(install_plugin_exports);
38
+ var path = __toESM(require("path"), 1);
39
+ var import_fs = require("fs");
40
+ var import_path = require("../utils/path.js");
41
+ var import_validate_plugin = require("./validate-plugin.js");
42
+ var import_errors = require("./errors.js");
43
+ var import_schemas = require("./schemas.js");
44
+ function getDextoInstalledPluginsPath() {
45
+ return (0, import_path.getDextoGlobalPath)("plugins", "installed_plugins.json");
46
+ }
47
+ function loadDextoInstalledPlugins() {
48
+ const filePath = getDextoInstalledPluginsPath();
49
+ if (!(0, import_fs.existsSync)(filePath)) {
50
+ return { version: 1, plugins: {} };
51
+ }
52
+ try {
53
+ const content = (0, import_fs.readFileSync)(filePath, "utf-8");
54
+ const parsed = JSON.parse(content);
55
+ const result = import_schemas.InstalledPluginsFileSchema.safeParse(parsed);
56
+ if (!result.success) {
57
+ return { version: 1, plugins: {} };
58
+ }
59
+ return result.data;
60
+ } catch {
61
+ return { version: 1, plugins: {} };
62
+ }
63
+ }
64
+ function saveDextoInstalledPlugins(data) {
65
+ const filePath = getDextoInstalledPluginsPath();
66
+ const dirPath = path.dirname(filePath);
67
+ if (!(0, import_fs.existsSync)(dirPath)) {
68
+ (0, import_fs.mkdirSync)(dirPath, { recursive: true });
69
+ }
70
+ try {
71
+ (0, import_fs.writeFileSync)(filePath, JSON.stringify(data, null, 2), "utf-8");
72
+ } catch (error) {
73
+ throw import_errors.PluginError.installManifestWriteFailed(
74
+ filePath,
75
+ error instanceof Error ? error.message : String(error)
76
+ );
77
+ }
78
+ }
79
+ function isPluginInstalled(pluginName, projectPath) {
80
+ const installed = loadDextoInstalledPlugins();
81
+ const normalizedName = pluginName.toLowerCase();
82
+ for (const [_id, installations] of Object.entries(installed.plugins)) {
83
+ for (const installation of installations) {
84
+ const manifestPath = path.join(
85
+ installation.installPath,
86
+ ".claude-plugin",
87
+ "plugin.json"
88
+ );
89
+ if (!(0, import_fs.existsSync)(manifestPath)) continue;
90
+ try {
91
+ const content = (0, import_fs.readFileSync)(manifestPath, "utf-8");
92
+ const manifest = JSON.parse(content);
93
+ if (manifest.name?.toLowerCase() === normalizedName) {
94
+ if ((installation.scope === "project" || installation.scope === "local") && installation.projectPath) {
95
+ if (projectPath) {
96
+ const normalizedInstallProject = path.resolve(installation.projectPath).toLowerCase();
97
+ const normalizedCurrentProject = path.resolve(projectPath).toLowerCase();
98
+ if (normalizedInstallProject === normalizedCurrentProject) {
99
+ return installation;
100
+ }
101
+ }
102
+ continue;
103
+ }
104
+ return installation;
105
+ }
106
+ } catch {
107
+ continue;
108
+ }
109
+ }
110
+ }
111
+ return null;
112
+ }
113
+ async function installPluginFromPath(sourcePath, options) {
114
+ const { scope, projectPath, force = false } = options;
115
+ const warnings = [];
116
+ const absoluteSourcePath = path.isAbsolute(sourcePath) ? sourcePath : path.resolve(sourcePath);
117
+ const validation = (0, import_validate_plugin.validatePluginDirectory)(absoluteSourcePath);
118
+ if (!validation.valid) {
119
+ throw import_errors.PluginError.installSourceNotFound(absoluteSourcePath);
120
+ }
121
+ if (!validation.manifest) {
122
+ throw import_errors.PluginError.installSourceNotFound(absoluteSourcePath);
123
+ }
124
+ warnings.push(...validation.warnings);
125
+ const pluginName = validation.manifest.name;
126
+ const currentProjectPath = projectPath || process.cwd();
127
+ const existingInstall = isPluginInstalled(pluginName, currentProjectPath);
128
+ if (existingInstall && !force) {
129
+ throw import_errors.PluginError.installAlreadyExists(pluginName, existingInstall.installPath);
130
+ }
131
+ let installPath;
132
+ let isLocal = false;
133
+ switch (scope) {
134
+ case "user":
135
+ installPath = path.join((0, import_path.getDextoGlobalPath)("plugins"), pluginName);
136
+ break;
137
+ case "project":
138
+ installPath = path.join(currentProjectPath, ".dexto", "plugins", pluginName);
139
+ break;
140
+ case "local":
141
+ installPath = absoluteSourcePath;
142
+ isLocal = true;
143
+ break;
144
+ default:
145
+ throw import_errors.PluginError.invalidScope(scope);
146
+ }
147
+ if (!isLocal) {
148
+ if (existingInstall && force) {
149
+ try {
150
+ (0, import_fs.rmSync)(existingInstall.installPath, { recursive: true, force: true });
151
+ } catch (error) {
152
+ throw import_errors.PluginError.installCopyFailed(
153
+ absoluteSourcePath,
154
+ installPath,
155
+ `Failed to remove existing: ${error instanceof Error ? error.message : String(error)}`
156
+ );
157
+ }
158
+ }
159
+ const parentDir = path.dirname(installPath);
160
+ if (!(0, import_fs.existsSync)(parentDir)) {
161
+ (0, import_fs.mkdirSync)(parentDir, { recursive: true });
162
+ }
163
+ try {
164
+ await (0, import_path.copyDirectory)(absoluteSourcePath, installPath);
165
+ } catch (error) {
166
+ throw import_errors.PluginError.installCopyFailed(
167
+ absoluteSourcePath,
168
+ installPath,
169
+ error instanceof Error ? error.message : String(error)
170
+ );
171
+ }
172
+ }
173
+ const installed = loadDextoInstalledPlugins();
174
+ const now = (/* @__PURE__ */ new Date()).toISOString();
175
+ const entry = {
176
+ scope,
177
+ installPath,
178
+ version: validation.manifest.version,
179
+ installedAt: now,
180
+ lastUpdated: now,
181
+ ...scope !== "user" && { projectPath: currentProjectPath },
182
+ ...isLocal && { isLocal: true }
183
+ };
184
+ if (!installed.plugins[pluginName]) {
185
+ installed.plugins[pluginName] = [];
186
+ }
187
+ installed.plugins[pluginName] = installed.plugins[pluginName].filter((e) => {
188
+ if (e.scope !== scope) return true;
189
+ if (scope === "user") return false;
190
+ if (e.projectPath && currentProjectPath) {
191
+ return path.resolve(e.projectPath).toLowerCase() !== path.resolve(currentProjectPath).toLowerCase();
192
+ }
193
+ return true;
194
+ });
195
+ installed.plugins[pluginName].push(entry);
196
+ saveDextoInstalledPlugins(installed);
197
+ return {
198
+ success: true,
199
+ pluginName,
200
+ installPath,
201
+ warnings
202
+ };
203
+ }
204
+ // Annotate the CommonJS export names for ESM import in node:
205
+ 0 && (module.exports = {
206
+ getDextoInstalledPluginsPath,
207
+ installPluginFromPath,
208
+ isPluginInstalled,
209
+ loadDextoInstalledPlugins,
210
+ saveDextoInstalledPlugins
211
+ });
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Plugin Installation
3
+ *
4
+ * Installs plugins from local directories to Dexto's plugin directory.
5
+ * Manages Dexto's own installed_plugins.json for tracking installations.
6
+ */
7
+ import type { PluginInstallScope, PluginInstallResult, InstalledPluginsFile, InstalledPluginEntry } from './types.js';
8
+ /**
9
+ * Options for plugin installation
10
+ */
11
+ export interface InstallPluginOptions {
12
+ /** Installation scope: 'user', 'project', or 'local' */
13
+ scope: PluginInstallScope;
14
+ /** Project path for project-scoped plugins */
15
+ projectPath?: string;
16
+ /** Force overwrite if plugin already exists */
17
+ force?: boolean;
18
+ }
19
+ /**
20
+ * Path to Dexto's installed_plugins.json
21
+ */
22
+ export declare function getDextoInstalledPluginsPath(): string;
23
+ /**
24
+ * Loads Dexto's installed_plugins.json
25
+ */
26
+ export declare function loadDextoInstalledPlugins(): InstalledPluginsFile;
27
+ /**
28
+ * Saves Dexto's installed_plugins.json
29
+ */
30
+ export declare function saveDextoInstalledPlugins(data: InstalledPluginsFile): void;
31
+ /**
32
+ * Checks if a plugin is already installed.
33
+ *
34
+ * @param pluginName Plugin name to check
35
+ * @param projectPath Optional project path for project-scoped check
36
+ * @returns Installation entry if found, null otherwise
37
+ */
38
+ export declare function isPluginInstalled(pluginName: string, projectPath?: string): InstalledPluginEntry | null;
39
+ /**
40
+ * Installs a plugin from a local directory.
41
+ *
42
+ * @param sourcePath Absolute or relative path to the plugin source directory
43
+ * @param options Installation options
44
+ * @returns Installation result with success status and warnings
45
+ */
46
+ export declare function installPluginFromPath(sourcePath: string, options: InstallPluginOptions): Promise<PluginInstallResult>;
47
+ //# sourceMappingURL=install-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/install-plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EACR,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACvB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,wDAAwD;IACxD,KAAK,EAAE,kBAAkB,CAAC;IAC1B,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,MAAM,CAErD;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,oBAAoB,CAsBhE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAiB1E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC7B,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,GACrB,oBAAoB,GAAG,IAAI,CA+C7B;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,GAC9B,OAAO,CAAC,mBAAmB,CAAC,CA6H9B"}
@@ -0,0 +1,173 @@
1
+ import * as path from "path";
2
+ import { existsSync, readFileSync, writeFileSync, mkdirSync, rmSync } from "fs";
3
+ import { getDextoGlobalPath, copyDirectory } from "../utils/path.js";
4
+ import { validatePluginDirectory } from "./validate-plugin.js";
5
+ import { PluginError } from "./errors.js";
6
+ import { InstalledPluginsFileSchema } from "./schemas.js";
7
+ function getDextoInstalledPluginsPath() {
8
+ return getDextoGlobalPath("plugins", "installed_plugins.json");
9
+ }
10
+ function loadDextoInstalledPlugins() {
11
+ const filePath = getDextoInstalledPluginsPath();
12
+ if (!existsSync(filePath)) {
13
+ return { version: 1, plugins: {} };
14
+ }
15
+ try {
16
+ const content = readFileSync(filePath, "utf-8");
17
+ const parsed = JSON.parse(content);
18
+ const result = InstalledPluginsFileSchema.safeParse(parsed);
19
+ if (!result.success) {
20
+ return { version: 1, plugins: {} };
21
+ }
22
+ return result.data;
23
+ } catch {
24
+ return { version: 1, plugins: {} };
25
+ }
26
+ }
27
+ function saveDextoInstalledPlugins(data) {
28
+ const filePath = getDextoInstalledPluginsPath();
29
+ const dirPath = path.dirname(filePath);
30
+ if (!existsSync(dirPath)) {
31
+ mkdirSync(dirPath, { recursive: true });
32
+ }
33
+ try {
34
+ writeFileSync(filePath, JSON.stringify(data, null, 2), "utf-8");
35
+ } catch (error) {
36
+ throw PluginError.installManifestWriteFailed(
37
+ filePath,
38
+ error instanceof Error ? error.message : String(error)
39
+ );
40
+ }
41
+ }
42
+ function isPluginInstalled(pluginName, projectPath) {
43
+ const installed = loadDextoInstalledPlugins();
44
+ const normalizedName = pluginName.toLowerCase();
45
+ for (const [_id, installations] of Object.entries(installed.plugins)) {
46
+ for (const installation of installations) {
47
+ const manifestPath = path.join(
48
+ installation.installPath,
49
+ ".claude-plugin",
50
+ "plugin.json"
51
+ );
52
+ if (!existsSync(manifestPath)) continue;
53
+ try {
54
+ const content = readFileSync(manifestPath, "utf-8");
55
+ const manifest = JSON.parse(content);
56
+ if (manifest.name?.toLowerCase() === normalizedName) {
57
+ if ((installation.scope === "project" || installation.scope === "local") && installation.projectPath) {
58
+ if (projectPath) {
59
+ const normalizedInstallProject = path.resolve(installation.projectPath).toLowerCase();
60
+ const normalizedCurrentProject = path.resolve(projectPath).toLowerCase();
61
+ if (normalizedInstallProject === normalizedCurrentProject) {
62
+ return installation;
63
+ }
64
+ }
65
+ continue;
66
+ }
67
+ return installation;
68
+ }
69
+ } catch {
70
+ continue;
71
+ }
72
+ }
73
+ }
74
+ return null;
75
+ }
76
+ async function installPluginFromPath(sourcePath, options) {
77
+ const { scope, projectPath, force = false } = options;
78
+ const warnings = [];
79
+ const absoluteSourcePath = path.isAbsolute(sourcePath) ? sourcePath : path.resolve(sourcePath);
80
+ const validation = validatePluginDirectory(absoluteSourcePath);
81
+ if (!validation.valid) {
82
+ throw PluginError.installSourceNotFound(absoluteSourcePath);
83
+ }
84
+ if (!validation.manifest) {
85
+ throw PluginError.installSourceNotFound(absoluteSourcePath);
86
+ }
87
+ warnings.push(...validation.warnings);
88
+ const pluginName = validation.manifest.name;
89
+ const currentProjectPath = projectPath || process.cwd();
90
+ const existingInstall = isPluginInstalled(pluginName, currentProjectPath);
91
+ if (existingInstall && !force) {
92
+ throw PluginError.installAlreadyExists(pluginName, existingInstall.installPath);
93
+ }
94
+ let installPath;
95
+ let isLocal = false;
96
+ switch (scope) {
97
+ case "user":
98
+ installPath = path.join(getDextoGlobalPath("plugins"), pluginName);
99
+ break;
100
+ case "project":
101
+ installPath = path.join(currentProjectPath, ".dexto", "plugins", pluginName);
102
+ break;
103
+ case "local":
104
+ installPath = absoluteSourcePath;
105
+ isLocal = true;
106
+ break;
107
+ default:
108
+ throw PluginError.invalidScope(scope);
109
+ }
110
+ if (!isLocal) {
111
+ if (existingInstall && force) {
112
+ try {
113
+ rmSync(existingInstall.installPath, { recursive: true, force: true });
114
+ } catch (error) {
115
+ throw PluginError.installCopyFailed(
116
+ absoluteSourcePath,
117
+ installPath,
118
+ `Failed to remove existing: ${error instanceof Error ? error.message : String(error)}`
119
+ );
120
+ }
121
+ }
122
+ const parentDir = path.dirname(installPath);
123
+ if (!existsSync(parentDir)) {
124
+ mkdirSync(parentDir, { recursive: true });
125
+ }
126
+ try {
127
+ await copyDirectory(absoluteSourcePath, installPath);
128
+ } catch (error) {
129
+ throw PluginError.installCopyFailed(
130
+ absoluteSourcePath,
131
+ installPath,
132
+ error instanceof Error ? error.message : String(error)
133
+ );
134
+ }
135
+ }
136
+ const installed = loadDextoInstalledPlugins();
137
+ const now = (/* @__PURE__ */ new Date()).toISOString();
138
+ const entry = {
139
+ scope,
140
+ installPath,
141
+ version: validation.manifest.version,
142
+ installedAt: now,
143
+ lastUpdated: now,
144
+ ...scope !== "user" && { projectPath: currentProjectPath },
145
+ ...isLocal && { isLocal: true }
146
+ };
147
+ if (!installed.plugins[pluginName]) {
148
+ installed.plugins[pluginName] = [];
149
+ }
150
+ installed.plugins[pluginName] = installed.plugins[pluginName].filter((e) => {
151
+ if (e.scope !== scope) return true;
152
+ if (scope === "user") return false;
153
+ if (e.projectPath && currentProjectPath) {
154
+ return path.resolve(e.projectPath).toLowerCase() !== path.resolve(currentProjectPath).toLowerCase();
155
+ }
156
+ return true;
157
+ });
158
+ installed.plugins[pluginName].push(entry);
159
+ saveDextoInstalledPlugins(installed);
160
+ return {
161
+ success: true,
162
+ pluginName,
163
+ installPath,
164
+ warnings
165
+ };
166
+ }
167
+ export {
168
+ getDextoInstalledPluginsPath,
169
+ installPluginFromPath,
170
+ isPluginInstalled,
171
+ loadDextoInstalledPlugins,
172
+ saveDextoInstalledPlugins
173
+ };
@@ -0,0 +1,134 @@
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 list_plugins_exports = {};
30
+ __export(list_plugins_exports, {
31
+ getDextoInstalledPluginsPath: () => getDextoInstalledPluginsPath,
32
+ listInstalledPlugins: () => listInstalledPlugins
33
+ });
34
+ module.exports = __toCommonJS(list_plugins_exports);
35
+ var path = __toESM(require("path"), 1);
36
+ var import_fs = require("fs");
37
+ var import_path = require("../utils/path.js");
38
+ var import_schemas = require("./schemas.js");
39
+ var import_validate_plugin = require("./validate-plugin.js");
40
+ function getDextoInstalledPluginsPath() {
41
+ return (0, import_path.getDextoGlobalPath)("plugins", "installed_plugins.json");
42
+ }
43
+ function listInstalledPlugins(projectPath) {
44
+ const plugins = [];
45
+ const seenNames = /* @__PURE__ */ new Set();
46
+ const cwd = projectPath || process.cwd();
47
+ const addPlugin = (plugin) => {
48
+ const normalizedName = plugin.name.toLowerCase();
49
+ if (seenNames.has(normalizedName)) {
50
+ return false;
51
+ }
52
+ seenNames.add(normalizedName);
53
+ plugins.push(plugin);
54
+ return true;
55
+ };
56
+ const { plugins: dextoPlugins } = readDextoInstalledPlugins(cwd);
57
+ for (const plugin of dextoPlugins) {
58
+ addPlugin(plugin);
59
+ }
60
+ const scanPluginsDir = (dir) => {
61
+ if (!(0, import_fs.existsSync)(dir)) return;
62
+ try {
63
+ const entries = (0, import_fs.readdirSync)(dir, { withFileTypes: true });
64
+ for (const entry of entries) {
65
+ if (!entry.isDirectory()) continue;
66
+ if (entry.name === "cache" || entry.name === "marketplaces") continue;
67
+ const pluginPath = path.join(dir, entry.name);
68
+ const manifest = (0, import_validate_plugin.tryLoadManifest)(pluginPath);
69
+ if (manifest) {
70
+ addPlugin({
71
+ name: manifest.name,
72
+ description: manifest.description,
73
+ version: manifest.version,
74
+ path: pluginPath,
75
+ source: "dexto"
76
+ });
77
+ }
78
+ }
79
+ } catch {
80
+ }
81
+ };
82
+ scanPluginsDir(path.join(cwd, ".dexto", "plugins"));
83
+ scanPluginsDir((0, import_path.getDextoGlobalPath)("plugins"));
84
+ return plugins;
85
+ }
86
+ function readDextoInstalledPlugins(currentProjectPath) {
87
+ const plugins = [];
88
+ const filePath = getDextoInstalledPluginsPath();
89
+ if (!(0, import_fs.existsSync)(filePath)) {
90
+ return { plugins };
91
+ }
92
+ try {
93
+ const content = (0, import_fs.readFileSync)(filePath, "utf-8");
94
+ const parsed = JSON.parse(content);
95
+ const result = import_schemas.InstalledPluginsFileSchema.safeParse(parsed);
96
+ if (!result.success) {
97
+ return { plugins };
98
+ }
99
+ for (const [_pluginId, installations] of Object.entries(result.data.plugins)) {
100
+ for (const installation of installations) {
101
+ const { scope, installPath, version, installedAt, projectPath } = installation;
102
+ if (!(0, import_fs.existsSync)(installPath)) {
103
+ continue;
104
+ }
105
+ const manifest = (0, import_validate_plugin.tryLoadManifest)(installPath);
106
+ if (manifest) {
107
+ if ((scope === "project" || scope === "local") && projectPath) {
108
+ const normalizedProjectPath = path.resolve(projectPath).toLowerCase();
109
+ const normalizedCurrentPath = path.resolve(currentProjectPath).toLowerCase();
110
+ if (normalizedProjectPath !== normalizedCurrentPath) {
111
+ continue;
112
+ }
113
+ }
114
+ plugins.push({
115
+ name: manifest.name,
116
+ description: manifest.description,
117
+ version: version || manifest.version,
118
+ path: installPath,
119
+ source: "dexto",
120
+ scope,
121
+ installedAt
122
+ });
123
+ }
124
+ }
125
+ }
126
+ } catch {
127
+ }
128
+ return { plugins };
129
+ }
130
+ // Annotate the CommonJS export names for ESM import in node:
131
+ 0 && (module.exports = {
132
+ getDextoInstalledPluginsPath,
133
+ listInstalledPlugins
134
+ });