@enactprotocol/shared 1.2.11 → 2.0.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.
Files changed (134) hide show
  1. package/README.md +44 -0
  2. package/package.json +16 -58
  3. package/src/config.ts +476 -0
  4. package/src/constants.ts +36 -0
  5. package/src/execution/command.ts +314 -0
  6. package/src/execution/index.ts +73 -0
  7. package/src/execution/runtime.ts +308 -0
  8. package/src/execution/types.ts +379 -0
  9. package/src/execution/validation.ts +508 -0
  10. package/src/index.ts +237 -30
  11. package/src/manifest/index.ts +36 -0
  12. package/src/manifest/loader.ts +187 -0
  13. package/src/manifest/parser.ts +173 -0
  14. package/src/manifest/validator.ts +309 -0
  15. package/src/paths.ts +108 -0
  16. package/src/registry.ts +219 -0
  17. package/src/resolver.ts +345 -0
  18. package/src/types/index.ts +30 -0
  19. package/src/types/manifest.ts +255 -0
  20. package/src/types.ts +5 -188
  21. package/src/utils/fs.ts +281 -0
  22. package/src/utils/logger.ts +270 -59
  23. package/src/utils/version.ts +304 -36
  24. package/tests/config.test.ts +515 -0
  25. package/tests/execution/command.test.ts +317 -0
  26. package/tests/execution/validation.test.ts +384 -0
  27. package/tests/fixtures/invalid-tool.yaml +4 -0
  28. package/tests/fixtures/valid-tool.md +62 -0
  29. package/tests/fixtures/valid-tool.yaml +40 -0
  30. package/tests/index.test.ts +8 -0
  31. package/tests/manifest/loader.test.ts +291 -0
  32. package/tests/manifest/parser.test.ts +345 -0
  33. package/tests/manifest/validator.test.ts +394 -0
  34. package/tests/manifest-types.test.ts +358 -0
  35. package/tests/paths.test.ts +153 -0
  36. package/tests/registry.test.ts +231 -0
  37. package/tests/resolver.test.ts +272 -0
  38. package/tests/utils/fs.test.ts +388 -0
  39. package/tests/utils/logger.test.ts +480 -0
  40. package/tests/utils/version.test.ts +390 -0
  41. package/tsconfig.json +12 -0
  42. package/tsconfig.tsbuildinfo +1 -0
  43. package/dist/LocalToolResolver.d.ts +0 -84
  44. package/dist/LocalToolResolver.js +0 -353
  45. package/dist/api/enact-api.d.ts +0 -130
  46. package/dist/api/enact-api.js +0 -428
  47. package/dist/api/index.d.ts +0 -2
  48. package/dist/api/index.js +0 -2
  49. package/dist/api/types.d.ts +0 -103
  50. package/dist/api/types.js +0 -1
  51. package/dist/constants.d.ts +0 -7
  52. package/dist/constants.js +0 -10
  53. package/dist/core/DaggerExecutionProvider.d.ts +0 -169
  54. package/dist/core/DaggerExecutionProvider.js +0 -1029
  55. package/dist/core/DirectExecutionProvider.d.ts +0 -23
  56. package/dist/core/DirectExecutionProvider.js +0 -406
  57. package/dist/core/EnactCore.d.ts +0 -162
  58. package/dist/core/EnactCore.js +0 -597
  59. package/dist/core/NativeExecutionProvider.d.ts +0 -9
  60. package/dist/core/NativeExecutionProvider.js +0 -16
  61. package/dist/core/index.d.ts +0 -3
  62. package/dist/core/index.js +0 -3
  63. package/dist/exec/index.d.ts +0 -3
  64. package/dist/exec/index.js +0 -3
  65. package/dist/exec/logger.d.ts +0 -11
  66. package/dist/exec/logger.js +0 -57
  67. package/dist/exec/validate.d.ts +0 -5
  68. package/dist/exec/validate.js +0 -167
  69. package/dist/index.d.ts +0 -21
  70. package/dist/index.js +0 -25
  71. package/dist/lib/enact-direct.d.ts +0 -150
  72. package/dist/lib/enact-direct.js +0 -159
  73. package/dist/lib/index.d.ts +0 -1
  74. package/dist/lib/index.js +0 -1
  75. package/dist/security/index.d.ts +0 -3
  76. package/dist/security/index.js +0 -3
  77. package/dist/security/security.d.ts +0 -23
  78. package/dist/security/security.js +0 -137
  79. package/dist/security/sign.d.ts +0 -103
  80. package/dist/security/sign.js +0 -666
  81. package/dist/security/verification-enforcer.d.ts +0 -53
  82. package/dist/security/verification-enforcer.js +0 -204
  83. package/dist/services/McpCoreService.d.ts +0 -98
  84. package/dist/services/McpCoreService.js +0 -124
  85. package/dist/services/index.d.ts +0 -1
  86. package/dist/services/index.js +0 -1
  87. package/dist/types.d.ts +0 -132
  88. package/dist/types.js +0 -3
  89. package/dist/utils/config.d.ts +0 -111
  90. package/dist/utils/config.js +0 -342
  91. package/dist/utils/env-loader.d.ts +0 -54
  92. package/dist/utils/env-loader.js +0 -270
  93. package/dist/utils/help.d.ts +0 -36
  94. package/dist/utils/help.js +0 -248
  95. package/dist/utils/index.d.ts +0 -7
  96. package/dist/utils/index.js +0 -7
  97. package/dist/utils/logger.d.ts +0 -35
  98. package/dist/utils/logger.js +0 -75
  99. package/dist/utils/silent-monitor.d.ts +0 -67
  100. package/dist/utils/silent-monitor.js +0 -242
  101. package/dist/utils/timeout.d.ts +0 -5
  102. package/dist/utils/timeout.js +0 -23
  103. package/dist/utils/version.d.ts +0 -4
  104. package/dist/utils/version.js +0 -35
  105. package/dist/web/env-manager-server.d.ts +0 -29
  106. package/dist/web/env-manager-server.js +0 -367
  107. package/dist/web/index.d.ts +0 -1
  108. package/dist/web/index.js +0 -1
  109. package/src/LocalToolResolver.ts +0 -424
  110. package/src/api/enact-api.ts +0 -604
  111. package/src/api/index.ts +0 -2
  112. package/src/api/types.ts +0 -114
  113. package/src/core/DaggerExecutionProvider.ts +0 -1357
  114. package/src/core/DirectExecutionProvider.ts +0 -484
  115. package/src/core/EnactCore.ts +0 -847
  116. package/src/core/index.ts +0 -3
  117. package/src/exec/index.ts +0 -3
  118. package/src/exec/logger.ts +0 -63
  119. package/src/exec/validate.ts +0 -238
  120. package/src/lib/enact-direct.ts +0 -254
  121. package/src/lib/index.ts +0 -1
  122. package/src/services/McpCoreService.ts +0 -201
  123. package/src/services/index.ts +0 -1
  124. package/src/utils/config.ts +0 -438
  125. package/src/utils/env-loader.ts +0 -370
  126. package/src/utils/help.ts +0 -257
  127. package/src/utils/index.ts +0 -7
  128. package/src/utils/silent-monitor.ts +0 -328
  129. package/src/utils/timeout.ts +0 -26
  130. package/src/web/env-manager-server.ts +0 -465
  131. package/src/web/index.ts +0 -1
  132. package/src/web/static/app.js +0 -663
  133. package/src/web/static/index.html +0 -117
  134. package/src/web/static/style.css +0 -291
@@ -1,270 +0,0 @@
1
- // src/utils/env-loader.ts - Environment variable loader for Enact tools with package namespace support
2
- import { join } from "path";
3
- import { homedir } from "os";
4
- import { existsSync } from "fs";
5
- import { readFile } from "fs/promises";
6
- import { config as loadDotenv } from "dotenv";
7
- // Configuration paths
8
- const CONFIG_DIR = join(homedir(), ".enact");
9
- /**
10
- * Extract package namespace from tool name (excluding tool name)
11
- * e.g., "kgroves88/dagger/social/bluesky-poster" -> "kgroves88/dagger/social"
12
- */
13
- function extractPackageNamespace(toolName) {
14
- const parts = toolName.split("/");
15
- if (parts.length < 2) {
16
- throw new Error('Tool name must be in format "org/package" or "org/package/tool"');
17
- }
18
- // Use all path parts except the last one (tool name)
19
- // For tools like "kgroves88/dagger/social/bluesky-poster",
20
- // we want the package path "kgroves88/dagger/social"
21
- if (parts.length >= 2) {
22
- return parts.slice(0, -1).join("/");
23
- }
24
- return parts[0]; // fallback for edge cases
25
- }
26
- /**
27
- * Get the environment file path for a package namespace
28
- */
29
- function getPackageEnvPath(packageNamespace) {
30
- return join(CONFIG_DIR, "env", packageNamespace, ".env");
31
- }
32
- /**
33
- * Simple decryption for encrypted values
34
- */
35
- function decryptValue(encryptedValue) {
36
- try {
37
- return Buffer.from(encryptedValue, "base64").toString("utf8");
38
- }
39
- catch {
40
- return encryptedValue; // Return as-is if decryption fails
41
- }
42
- }
43
- /**
44
- * Read environment configuration for a package namespace
45
- */
46
- async function readPackageEnvConfig(packageNamespace) {
47
- const envFile = getPackageEnvPath(packageNamespace);
48
- if (!existsSync(envFile)) {
49
- return { variables: {} };
50
- }
51
- try {
52
- const data = await readFile(envFile, "utf8");
53
- // Check if it's a simple .env file (KEY=value format) or JSON
54
- if (data.trim().startsWith("{")) {
55
- // It's JSON format (legacy package-managed variables)
56
- return JSON.parse(data);
57
- }
58
- else {
59
- // It's simple .env format (project mode), return empty since these are handled separately
60
- return { variables: {} };
61
- }
62
- }
63
- catch (error) {
64
- // Only warn if it's not a simple .env file parsing issue
65
- if (!error.message.includes("Unexpected token")) {
66
- console.warn(`Failed to read env config from ${envFile}: ${error.message}`);
67
- }
68
- return { variables: {} };
69
- }
70
- }
71
- /**
72
- * Load environment variables from Enact configuration for a specific package namespace
73
- */
74
- export async function loadPackageEnvironmentVariables(packageNamespace) {
75
- const config = await readPackageEnvConfig(packageNamespace);
76
- const envVars = {};
77
- // Load variables from the package namespace
78
- for (const [name, envVar] of Object.entries(config.variables)) {
79
- const value = envVar.encrypted ? decryptValue(envVar.value) : envVar.value;
80
- envVars[name] = value;
81
- }
82
- return envVars;
83
- }
84
- /**
85
- * Load environment variables from a package-based .env file
86
- */
87
- function loadPackageEnvFile(toolName) {
88
- if (!toolName) {
89
- return {};
90
- }
91
- try {
92
- const packageNamespace = extractPackageNamespace(toolName);
93
- const packageEnvPath = getPackageEnvPath(packageNamespace);
94
- if (!existsSync(packageEnvPath)) {
95
- return {};
96
- }
97
- // Load .env file and return the parsed variables
98
- const result = loadDotenv({ path: packageEnvPath });
99
- return result.parsed || {};
100
- }
101
- catch (error) {
102
- console.warn(`Warning: Failed to load package .env file: ${error.message}`);
103
- return {};
104
- }
105
- }
106
- /**
107
- * Resolve environment variables for a tool definition with package namespace support
108
- * Combines system environment, Enact package configuration, and tool-specific requirements
109
- * Following the Enact protocol format:
110
- * env:
111
- * VARIABLE_NAME:
112
- * description: string
113
- * source: string
114
- * required: boolean
115
- * default: string (optional)
116
- */
117
- export async function resolveToolEnvironmentVariables(toolName, toolEnvConfig) {
118
- // Start with system environment variables
119
- const resolved = { ...process.env };
120
- // Load package .env file (if it exists) - priority 2
121
- const packageEnvVars = loadPackageEnvFile(toolName);
122
- Object.assign(resolved, packageEnvVars);
123
- // Load package-specific environment variables if we have a tool name - priority 3 (highest)
124
- if (toolName) {
125
- try {
126
- const packageNamespace = extractPackageNamespace(toolName);
127
- const packageJsonEnvVars = await loadPackageEnvironmentVariables(packageNamespace);
128
- // Override with package-managed JSON variables (highest priority)
129
- Object.assign(resolved, packageJsonEnvVars);
130
- }
131
- catch (error) {
132
- // If we can't extract package namespace, continue without package env vars
133
- console.warn(`Warning: Could not load package environment variables: ${error.message}`);
134
- }
135
- }
136
- const missing = [];
137
- // Check tool-specific environment requirements following Enact protocol
138
- if (toolEnvConfig) {
139
- for (const [varName, config] of Object.entries(toolEnvConfig)) {
140
- if (typeof config === "object" && config !== null) {
141
- // Enact protocol: each env var has description, source, required, and optional default
142
- const isRequired = config.required === true;
143
- const defaultValue = config.default;
144
- const source = config.source;
145
- // Check if variable is already resolved
146
- if (!(varName in resolved) || resolved[varName] === "") {
147
- if (defaultValue !== undefined) {
148
- resolved[varName] = String(defaultValue);
149
- }
150
- else if (isRequired) {
151
- missing.push(varName);
152
- }
153
- }
154
- // Handle different sources as specified in the Enact protocol
155
- if (source && resolved[varName]) {
156
- // The source field tells us where the value should come from
157
- // For now, we'll just ensure the variable is available
158
- // In the future, this could be extended to support different sources
159
- // like "user", "system", "config", etc.
160
- }
161
- }
162
- }
163
- }
164
- // Generate and show configuration link if there are missing variables
165
- let configLink;
166
- if (missing.length > 0) {
167
- configLink = generateConfigLink(missing, toolName) || undefined;
168
- if (configLink) {
169
- console.log(`\n🔧 Missing environment variables: ${missing.join(", ")}`);
170
- console.log(`📋 Configure them here: ${configLink}\n`);
171
- }
172
- else {
173
- console.log(`\nâš ī¸ Missing required environment variables: ${missing.join(", ")}`);
174
- console.log(`💡 Set them using the 'enact env set' command or your system environment\n`);
175
- }
176
- }
177
- return { resolved, missing, configLink };
178
- }
179
- /**
180
- * Get available environment variables for a package namespace
181
- */
182
- export async function getPackageEnvironmentVariables(packageNamespace) {
183
- const packageConfig = await readPackageEnvConfig(packageNamespace);
184
- const packageVars = {};
185
- // Process package variables
186
- for (const [name, envVar] of Object.entries(packageConfig.variables)) {
187
- packageVars[name] = {
188
- value: envVar.encrypted ? "[encrypted]" : envVar.value,
189
- encrypted: envVar.encrypted || false,
190
- description: envVar.description,
191
- };
192
- }
193
- // System environment variables (filtered to avoid exposing sensitive data)
194
- const system = Object.fromEntries(Object.entries(process.env)
195
- .filter(([key]) =>
196
- // Only include environment variables that look like they might be relevant for tools
197
- key.includes("API") ||
198
- key.includes("TOKEN") ||
199
- key.includes("KEY") ||
200
- key.includes("URL") ||
201
- key.includes("HOST") ||
202
- key.includes("PORT") ||
203
- key.startsWith("ENACT_") ||
204
- key.startsWith("NODE_") ||
205
- key.startsWith("NPM_"))
206
- .map(([key, value]) => [key, value || ""]));
207
- return { package: packageVars, system };
208
- }
209
- /**
210
- * Validate that all required environment variables are available
211
- * Following the Enact protocol format for environment variables
212
- */
213
- export function validateRequiredEnvironmentVariables(toolEnvConfig, availableVars) {
214
- const missing = [];
215
- const errors = [];
216
- if (!toolEnvConfig) {
217
- return { valid: true, missing, errors };
218
- }
219
- for (const [varName, config] of Object.entries(toolEnvConfig)) {
220
- if (typeof config === "object" && config !== null) {
221
- // Enact protocol: description, source, required are all required fields
222
- // default is optional
223
- const isRequired = config.required === true;
224
- const hasDefault = config.default !== undefined;
225
- const description = config.description || "";
226
- const source = config.source || "";
227
- if (isRequired &&
228
- !hasDefault &&
229
- (!(varName in availableVars) || availableVars[varName] === "")) {
230
- missing.push(varName);
231
- const errorMsg = `Required environment variable '${varName}' is not set`;
232
- const detailMsg = description ? ` - ${description}` : "";
233
- const sourceMsg = source ? ` (source: ${source})` : "";
234
- errors.push(`${errorMsg}${detailMsg}${sourceMsg}`);
235
- }
236
- }
237
- }
238
- return {
239
- valid: missing.length === 0,
240
- missing,
241
- errors,
242
- };
243
- }
244
- // Export the package namespace extraction function for use in other modules
245
- export { extractPackageNamespace };
246
- // Load .env file if it exists
247
- loadDotenv();
248
- /**
249
- * Get the web server URL if it's running
250
- */
251
- export function getWebServerUrl() {
252
- // For now, default to localhost:5555 as that's the standard port
253
- // When running via MCP (npx -p @enactprotocol/cli enact-mcp), the web server is automatically started
254
- // TODO: In the future, we could check if the server is actually responding or get the port dynamically
255
- return "http://localhost:5555";
256
- }
257
- /**
258
- * Generate a configuration link for missing environment variables
259
- */
260
- export function generateConfigLink(missingVars, toolName) {
261
- const webUrl = getWebServerUrl();
262
- if (!webUrl) {
263
- return null;
264
- }
265
- // Extract package namespace from tool name (exclude tool name itself)
266
- const packageNamespace = extractPackageNamespace(toolName);
267
- const encodedVars = encodeURIComponent(JSON.stringify(missingVars));
268
- const encodedPackage = encodeURIComponent(packageNamespace);
269
- return `${webUrl}/?vars=${encodedVars}&package=${encodedPackage}`;
270
- }
@@ -1,36 +0,0 @@
1
- /**
2
- * Show the main help message
3
- */
4
- export declare function showHelp(): void;
5
- /**
6
- * Show version information
7
- */
8
- export declare function showVersion(): void;
9
- /**
10
- * Show help for the auth command
11
- */
12
- export declare function showAuthHelp(): void;
13
- /**
14
- * Show help for the init command
15
- */
16
- export declare function showInitHelp(): void;
17
- /**
18
- * Show help for the publish command
19
- */
20
- export declare function showPublishHelp(): void;
21
- /**
22
- * Show help for the search command
23
- */
24
- export declare function showSearchHelp(): void;
25
- /**
26
- * Show help for the remote command
27
- */
28
- export declare function showRemoteHelp(): void;
29
- /**
30
- * Show help for the user command
31
- */
32
- export declare function showUserHelp(): void;
33
- /**
34
- * Show help for the env command
35
- */
36
- export declare function showEnvHelp(): void;
@@ -1,248 +0,0 @@
1
- // src/utils/help.ts
2
- import pc from "picocolors";
3
- import { readFileSync } from "fs";
4
- import { join } from "path";
5
- /**
6
- * Get the package version from package.json
7
- */
8
- function getVersion() {
9
- try {
10
- const packageJsonPath = join(__dirname, "../../package.json");
11
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
12
- return packageJson.version || "0.1.0";
13
- }
14
- catch (error) {
15
- // Fallback version if package.json can't be read
16
- return "0.1.0";
17
- }
18
- }
19
- /**
20
- * Show the main help message
21
- */
22
- export function showHelp() {
23
- const version = getVersion();
24
- console.error(`
25
- ${pc.bold("Enact CLI")} ${pc.dim(`v${version}`)}
26
- ${pc.dim("A CLI tool for managing and publishing Enact tools")}
27
-
28
- ${pc.bold("Usage:")}
29
- ${pc.cyan("enact")} ${pc.green("<command>")} [options]
30
-
31
- ${pc.bold("Commands:")}
32
- ${pc.green("auth")} Manage authentication (login, logout, status, token)
33
- ${pc.green("env")} Manage environment variables (set, get, list, delete)
34
- ${pc.green("exec")} Execute a tool by fetching and running it
35
- ${pc.green("init")} Create a new tool definition
36
- ${pc.green("mcp")} MCP client integration (install, list, status)
37
- ${pc.green("publish")} Publish a tool to the registry
38
- ${pc.green("search")} Search for tools in the registry
39
- ${pc.green("sign")} Sign and verify tools with cryptographic signatures
40
- ${pc.green("remote")} Manage remote servers (add, list, remove)
41
- ${pc.green("user")} User operations (get public key)
42
-
43
- ${pc.bold("Global Options:")}
44
- ${pc.yellow("--help, -h")} Show help message
45
- ${pc.yellow("--version, -v")} Show version information
46
-
47
- ${pc.bold("Examples:")}
48
- ${pc.cyan("enact")} ${pc.dim("# Interactive mode")}
49
- ${pc.cyan("enact")} ${pc.green("search")} ${pc.yellow("--tags")} web,api ${pc.dim("# Search tools by tags")}
50
- ${pc.cyan("enact")} ${pc.green("exec")} enact/text/slugify ${pc.dim("# Execute a tool")}
51
- ${pc.cyan("enact")} ${pc.green("mcp")} install ${pc.yellow("--client")} claude-desktop ${pc.dim("# Install MCP server")}
52
- ${pc.cyan("enact")} ${pc.green("mcp")} install ${pc.yellow("--client")} goose ${pc.dim("# Install for Goose AI")}
53
- ${pc.cyan("enact")} ${pc.green("env")} set API_KEY --encrypt ${pc.dim("# Set encrypted env var")}
54
- ${pc.cyan("enact")} ${pc.green("sign")} verify my-tool.yaml ${pc.dim("# Verify tool signatures")}
55
- ${pc.cyan("enact")} ${pc.green("publish")} my-tool.yaml ${pc.dim("# Publish a tool")}
56
- ${pc.cyan("enact")} ${pc.green("auth")} login ${pc.dim("# Login with OAuth")}
57
- ${pc.cyan("enact")} ${pc.green("init")} ${pc.yellow("--minimal")} ${pc.dim("# Create minimal tool template")}
58
-
59
- ${pc.bold("More Help:")}
60
- ${pc.cyan("enact")} ${pc.green("<command>")} ${pc.yellow("--help")} ${pc.dim("# Show command-specific help")}
61
- `);
62
- }
63
- /**
64
- * Show version information
65
- */
66
- export function showVersion() {
67
- const version = getVersion();
68
- console.error(`@enactprotocol/cli v${version}`);
69
- }
70
- /**
71
- * Show help for the auth command
72
- */
73
- export function showAuthHelp() {
74
- console.error(`
75
- ${pc.bold("Usage:")} ${pc.cyan("enact")} ${pc.green("auth")} ${pc.blue("<subcommand>")} [options]
76
-
77
- ${pc.bold("Manage authentication for Enact registry")}
78
-
79
- ${pc.bold("Subcommands:")}
80
- ${pc.blue("login")} Login using OAuth
81
- ${pc.blue("logout")} Logout and clear stored credentials
82
- ${pc.blue("status")} Check authentication status
83
- ${pc.blue("token")} Display current authentication token
84
-
85
- ${pc.bold("Options:")}
86
- ${pc.yellow("--help, -h")} Show this help message
87
- ${pc.yellow("--server, -s")} Specify server URL
88
- ${pc.yellow("--port, -p")} Specify port for OAuth callback
89
-
90
- ${pc.bold("Examples:")}
91
- ${pc.cyan("enact")} ${pc.green("auth")} ${pc.blue("login")}
92
- ${pc.cyan("enact")} ${pc.green("auth")} ${pc.blue("status")}
93
- ${pc.cyan("enact")} ${pc.green("auth")} ${pc.blue("login")} ${pc.yellow("--server")} https://api.example.com
94
- `);
95
- }
96
- /**
97
- * Show help for the init command
98
- */
99
- export function showInitHelp() {
100
- console.error(`
101
- ${pc.bold("Usage:")} ${pc.cyan("enact")} ${pc.green("init")} [options] [name]
102
-
103
- ${pc.bold("Create a new tool definition file")}
104
-
105
- ${pc.bold("Arguments:")}
106
- ${pc.blue("name")} Name for the new tool (optional)
107
-
108
- ${pc.bold("Options:")}
109
- ${pc.yellow("--help, -h")} Show this help message
110
- ${pc.yellow("--minimal, -m")} Create a minimal tool template
111
-
112
- ${pc.bold("Examples:")}
113
- ${pc.cyan("enact")} ${pc.green("init")}
114
- ${pc.cyan("enact")} ${pc.green("init")} my-awesome-tool
115
- ${pc.cyan("enact")} ${pc.green("init")} ${pc.yellow("--minimal")} simple-tool
116
- `);
117
- }
118
- /**
119
- * Show help for the publish command
120
- */
121
- export function showPublishHelp() {
122
- console.error(`
123
- ${pc.bold("Usage:")} ${pc.cyan("enact")} ${pc.green("publish")} [options] [file]
124
-
125
- ${pc.bold("Publish a tool to the Enact registry")}
126
-
127
- ${pc.bold("Arguments:")}
128
- ${pc.blue("file")} The tool definition file to publish (YAML format)
129
-
130
- ${pc.bold("Options:")}
131
- ${pc.yellow("--help, -h")} Show this help message
132
- ${pc.yellow("--url")} Specify the registry URL
133
- ${pc.yellow("--token, -t")} Specify authentication token
134
-
135
- ${pc.bold("Examples:")}
136
- ${pc.cyan("enact")} ${pc.green("publish")} my-tool.yaml
137
- ${pc.cyan("enact")} ${pc.green("publish")} ${pc.yellow("--url")} https://registry.example.com my-tool.yaml
138
- ${pc.cyan("enact")} ${pc.green("publish")} ${pc.yellow("--token")} abc123 my-tool.yaml
139
- `);
140
- }
141
- /**
142
- * Show help for the search command
143
- */
144
- export function showSearchHelp() {
145
- console.error(`
146
- ${pc.bold("Usage:")} ${pc.cyan("enact")} ${pc.green("search")} [options] [query]
147
-
148
- ${pc.bold("Search for tools in the Enact registry")}
149
-
150
- ${pc.bold("Arguments:")}
151
- ${pc.blue("query")} Search query (optional)
152
-
153
- ${pc.bold("Options:")}
154
- ${pc.yellow("--help, -h")} Show this help message
155
- ${pc.yellow("--limit, -l")} Limit number of results (default: 20)
156
- ${pc.yellow("--tags")} Filter by tags (comma-separated)
157
- ${pc.yellow("--author, -a")} Filter by author
158
- ${pc.yellow("--format, -f")} Output format (table, json, minimal)
159
-
160
- ${pc.bold("Examples:")}
161
- ${pc.cyan("enact")} ${pc.green("search")}
162
- ${pc.cyan("enact")} ${pc.green("search")} "web scraper"
163
- ${pc.cyan("enact")} ${pc.green("search")} ${pc.yellow("--tags")} web,api ${pc.yellow("--limit")} 10
164
- ${pc.cyan("enact")} ${pc.green("search")} ${pc.yellow("--author")} johndoe ${pc.yellow("--format")} json
165
- `);
166
- }
167
- /**
168
- * Show help for the remote command
169
- */
170
- export function showRemoteHelp() {
171
- console.error(`
172
- ${pc.bold("Usage:")} ${pc.cyan("enact")} ${pc.green("remote")} ${pc.blue("<subcommand>")} [options]
173
-
174
- ${pc.bold("Manage remote Enact registry servers")}
175
-
176
- ${pc.bold("Subcommands:")}
177
- ${pc.blue("add")} Add a new remote server
178
- ${pc.blue("list")} List all configured remote servers
179
- ${pc.blue("remove")} Remove a remote server
180
-
181
- ${pc.bold("Options:")}
182
- ${pc.yellow("--help, -h")} Show this help message
183
-
184
- ${pc.bold("Examples:")}
185
- ${pc.cyan("enact")} ${pc.green("remote")} ${pc.blue("add")}
186
- ${pc.cyan("enact")} ${pc.green("remote")} ${pc.blue("list")}
187
- ${pc.cyan("enact")} ${pc.green("remote")} ${pc.blue("remove")} origin
188
- `);
189
- }
190
- /**
191
- * Show help for the user command
192
- */
193
- export function showUserHelp() {
194
- console.error(`
195
- ${pc.bold("Usage:")} ${pc.cyan("enact")} ${pc.green("user")} ${pc.blue("<subcommand>")} [options]
196
-
197
- ${pc.bold("User operations for Enact registry")}
198
-
199
- ${pc.bold("Subcommands:")}
200
- ${pc.blue("public-key")} Get user's public key
201
-
202
- ${pc.bold("Options:")}
203
- ${pc.yellow("--help, -h")} Show this help message
204
- ${pc.yellow("--server, -s")} Specify server URL
205
- ${pc.yellow("--token, -t")} Specify authentication token
206
- ${pc.yellow("--format, -f")} Output format (default, json)
207
-
208
- ${pc.bold("Examples:")}
209
- ${pc.cyan("enact")} ${pc.green("user")} ${pc.blue("public-key")}
210
- ${pc.cyan("enact")} ${pc.green("user")} ${pc.blue("public-key")} ${pc.yellow("--format")} json
211
- ${pc.cyan("enact")} ${pc.green("user")} ${pc.blue("public-key")} ${pc.yellow("--server")} https://api.example.com
212
- `);
213
- }
214
- /**
215
- * Show help for the env command
216
- */
217
- export function showEnvHelp() {
218
- console.error(`
219
- ${pc.bold("Usage:")} ${pc.cyan("enact")} ${pc.green("env")} ${pc.blue("<subcommand>")} [options]
220
-
221
- ${pc.bold("Environment variable management for Enact CLI")}
222
-
223
- ${pc.bold("Subcommands:")}
224
- ${pc.blue("set")} ${pc.magenta("<name>")} [value] Set an environment variable
225
- ${pc.blue("get")} ${pc.magenta("<name>")} Get an environment variable
226
- ${pc.blue("list")} List all environment variables
227
- ${pc.blue("delete")} ${pc.magenta("<name>")} Delete an environment variable
228
- ${pc.blue("copy")} ${pc.magenta("<from>")} ${pc.magenta("<to>")} Copy variables between scopes
229
- ${pc.blue("export")} [format] Export variables (env|json|yaml)
230
- ${pc.blue("clear")} Clear all environment variables
231
-
232
- ${pc.bold("Options:")}
233
- ${pc.yellow("--help, -h")} Show this help message
234
- ${pc.yellow("--global")} Use global scope (default)
235
- ${pc.yellow("--project")} Use project scope
236
- ${pc.yellow("--encrypt")} Encrypt sensitive values
237
- ${pc.yellow("--format")} Output format (table|json)
238
- ${pc.yellow("--show")} Show actual values (default: hidden)
239
-
240
- ${pc.bold("Examples:")}
241
- ${pc.cyan("enact")} ${pc.green("env")} ${pc.blue("set")} OPENAI_API_KEY ${pc.yellow("--encrypt")}
242
- ${pc.cyan("enact")} ${pc.green("env")} ${pc.blue("set")} DATABASE_URL postgres://... ${pc.yellow("--project")}
243
- ${pc.cyan("enact")} ${pc.green("env")} ${pc.blue("get")} OPENAI_API_KEY ${pc.yellow("--show")}
244
- ${pc.cyan("enact")} ${pc.green("env")} ${pc.blue("list")} ${pc.yellow("--project")} ${pc.yellow("--format")} json
245
- ${pc.cyan("enact")} ${pc.green("env")} ${pc.blue("copy")} global project
246
- ${pc.cyan("enact")} ${pc.green("env")} ${pc.blue("export")} env > .env
247
- `);
248
- }
@@ -1,7 +0,0 @@
1
- export * from './config';
2
- export * from './env-loader';
3
- export { showHelp } from './help';
4
- export * from './logger';
5
- export * from './silent-monitor';
6
- export * from './timeout';
7
- export { showVersion } from './version';
@@ -1,7 +0,0 @@
1
- export * from './config';
2
- export * from './env-loader';
3
- export { showHelp } from './help';
4
- export * from './logger';
5
- export * from './silent-monitor';
6
- export * from './timeout';
7
- export { showVersion } from './version';
@@ -1,35 +0,0 @@
1
- export declare enum LogLevel {
2
- DEBUG = 0,
3
- INFO = 1,
4
- SUCCESS = 2,
5
- WARN = 3,
6
- ERROR = 4
7
- }
8
- /**
9
- * Sets the current log level
10
- */
11
- export declare function setLogLevel(level: LogLevel): void;
12
- /**
13
- * Debug log - only shown when log level is DEBUG
14
- */
15
- export declare function debug(message: string): void;
16
- /**
17
- * Info log - general information
18
- */
19
- export declare function info(message: string): void;
20
- /**
21
- * Success log - operation completed successfully
22
- */
23
- export declare function success(message: string): void;
24
- /**
25
- * Warning log - non-critical issues
26
- */
27
- export declare function warn(message: string): void;
28
- /**
29
- * Error log - critical issues
30
- */
31
- export declare function error(message: string, details?: any): void;
32
- /**
33
- * Table log - display tabular data
34
- */
35
- export declare function table(data: any[], columns?: string[]): void;
@@ -1,75 +0,0 @@
1
- // src/utils/logger.ts
2
- import pc from "picocolors";
3
- export var LogLevel;
4
- (function (LogLevel) {
5
- LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
6
- LogLevel[LogLevel["INFO"] = 1] = "INFO";
7
- LogLevel[LogLevel["SUCCESS"] = 2] = "SUCCESS";
8
- LogLevel[LogLevel["WARN"] = 3] = "WARN";
9
- LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
10
- })(LogLevel || (LogLevel = {}));
11
- // Default log level
12
- let currentLogLevel = LogLevel.INFO;
13
- /**
14
- * Sets the current log level
15
- */
16
- export function setLogLevel(level) {
17
- currentLogLevel = level;
18
- }
19
- /**
20
- * Debug log - only shown when log level is DEBUG
21
- */
22
- export function debug(message) {
23
- if (currentLogLevel <= LogLevel.DEBUG) {
24
- console.error(pc.dim(`🔍 ${message}`));
25
- }
26
- }
27
- /**
28
- * Info log - general information
29
- */
30
- export function info(message) {
31
- if (currentLogLevel <= LogLevel.INFO) {
32
- console.error(pc.blue(`â„šī¸ ${message}`));
33
- }
34
- }
35
- /**
36
- * Success log - operation completed successfully
37
- */
38
- export function success(message) {
39
- if (currentLogLevel <= LogLevel.SUCCESS) {
40
- console.error(pc.green(`✓ ${message}`));
41
- }
42
- }
43
- /**
44
- * Warning log - non-critical issues
45
- */
46
- export function warn(message) {
47
- if (currentLogLevel <= LogLevel.WARN) {
48
- console.error(pc.yellow(`âš ī¸ ${message}`));
49
- }
50
- }
51
- /**
52
- * Error log - critical issues
53
- */
54
- export function error(message, details) {
55
- if (currentLogLevel <= LogLevel.ERROR) {
56
- console.error(pc.red(`✗ Error: ${message}`));
57
- if (details && currentLogLevel === LogLevel.DEBUG) {
58
- console.error(pc.dim("Details:"));
59
- console.error(details);
60
- }
61
- }
62
- }
63
- /**
64
- * Table log - display tabular data
65
- */
66
- export function table(data, columns) {
67
- if (currentLogLevel <= LogLevel.INFO) {
68
- if (columns) {
69
- console.table(data, columns);
70
- }
71
- else {
72
- console.table(data);
73
- }
74
- }
75
- }