@enactprotocol/cli 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/auth/index.d.ts +12 -0
- package/dist/commands/auth/index.d.ts.map +1 -0
- package/dist/commands/auth/index.js +743 -0
- package/dist/commands/auth/index.js.map +1 -0
- package/dist/commands/cache/index.d.ts +11 -0
- package/dist/commands/cache/index.d.ts.map +1 -0
- package/dist/commands/cache/index.js +304 -0
- package/dist/commands/cache/index.js.map +1 -0
- package/dist/commands/config/index.d.ts +11 -0
- package/dist/commands/config/index.d.ts.map +1 -0
- package/dist/commands/config/index.js +138 -0
- package/dist/commands/config/index.js.map +1 -0
- package/dist/commands/env/index.d.ts +11 -0
- package/dist/commands/env/index.d.ts.map +1 -0
- package/dist/commands/env/index.js +303 -0
- package/dist/commands/env/index.js.map +1 -0
- package/dist/commands/exec/index.d.ts +12 -0
- package/dist/commands/exec/index.d.ts.map +1 -0
- package/dist/commands/exec/index.js +154 -0
- package/dist/commands/exec/index.js.map +1 -0
- package/dist/commands/get/index.d.ts +11 -0
- package/dist/commands/get/index.d.ts.map +1 -0
- package/dist/commands/get/index.js +151 -0
- package/dist/commands/get/index.js.map +1 -0
- package/dist/commands/index.d.ts +25 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +28 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init/index.d.ts +11 -0
- package/dist/commands/init/index.d.ts.map +1 -0
- package/dist/commands/init/index.js +192 -0
- package/dist/commands/init/index.js.map +1 -0
- package/dist/commands/inspect/index.d.ts +13 -0
- package/dist/commands/inspect/index.d.ts.map +1 -0
- package/dist/commands/inspect/index.js +199 -0
- package/dist/commands/inspect/index.js.map +1 -0
- package/dist/commands/install/index.d.ts +16 -0
- package/dist/commands/install/index.d.ts.map +1 -0
- package/dist/commands/install/index.js +520 -0
- package/dist/commands/install/index.js.map +1 -0
- package/dist/commands/list/index.d.ts +15 -0
- package/dist/commands/list/index.d.ts.map +1 -0
- package/dist/commands/list/index.js +103 -0
- package/dist/commands/list/index.js.map +1 -0
- package/dist/commands/publish/index.d.ts +11 -0
- package/dist/commands/publish/index.d.ts.map +1 -0
- package/dist/commands/publish/index.js +274 -0
- package/dist/commands/publish/index.js.map +1 -0
- package/dist/commands/report/index.d.ts +12 -0
- package/dist/commands/report/index.d.ts.map +1 -0
- package/dist/commands/report/index.js +279 -0
- package/dist/commands/report/index.js.map +1 -0
- package/dist/commands/run/index.d.ts +16 -0
- package/dist/commands/run/index.d.ts.map +1 -0
- package/dist/commands/run/index.js +525 -0
- package/dist/commands/run/index.js.map +1 -0
- package/dist/commands/search/index.d.ts +12 -0
- package/dist/commands/search/index.d.ts.map +1 -0
- package/dist/commands/search/index.js +275 -0
- package/dist/commands/search/index.js.map +1 -0
- package/dist/commands/setup/index.d.ts +11 -0
- package/dist/commands/setup/index.d.ts.map +1 -0
- package/dist/commands/setup/index.js +241 -0
- package/dist/commands/setup/index.js.map +1 -0
- package/dist/commands/sign/index.d.ts +17 -0
- package/dist/commands/sign/index.d.ts.map +1 -0
- package/dist/commands/sign/index.js +507 -0
- package/dist/commands/sign/index.js.map +1 -0
- package/dist/commands/trust/index.d.ts +13 -0
- package/dist/commands/trust/index.d.ts.map +1 -0
- package/dist/commands/trust/index.js +366 -0
- package/dist/commands/trust/index.js.map +1 -0
- package/dist/commands/unyank/index.d.ts +11 -0
- package/dist/commands/unyank/index.d.ts.map +1 -0
- package/dist/commands/unyank/index.js +87 -0
- package/dist/commands/unyank/index.js.map +1 -0
- package/dist/commands/yank/index.d.ts +13 -0
- package/dist/commands/yank/index.d.ts.map +1 -0
- package/dist/commands/yank/index.js +109 -0
- package/dist/commands/yank/index.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +69 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/errors.d.ts +159 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +321 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/exit-codes.d.ts +83 -0
- package/dist/utils/exit-codes.d.ts.map +1 -0
- package/dist/utils/exit-codes.js +126 -0
- package/dist/utils/exit-codes.js.map +1 -0
- package/dist/utils/ignore.d.ts +25 -0
- package/dist/utils/ignore.d.ts.map +1 -0
- package/dist/utils/ignore.js +123 -0
- package/dist/utils/ignore.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/output.d.ts +103 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +201 -0
- package/dist/utils/output.js.map +1 -0
- package/dist/utils/spinner.d.ts +83 -0
- package/dist/utils/spinner.d.ts.map +1 -0
- package/dist/utils/spinner.js +162 -0
- package/dist/utils/spinner.js.map +1 -0
- package/package.json +5 -5
- package/src/commands/index.ts +1 -0
- package/src/commands/init/index.ts +231 -0
- package/src/index.ts +7 -1
- package/tests/index.test.ts +1 -1
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
package/dist/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* @enactprotocol/cli
|
|
4
|
+
*
|
|
5
|
+
* Command-line interface for Enact.
|
|
6
|
+
* User-facing commands for tool execution, discovery, and management.
|
|
7
|
+
*/
|
|
8
|
+
import { ensureGlobalSetup } from "@enactprotocol/shared";
|
|
9
|
+
import { Command } from "commander";
|
|
10
|
+
import { configureAuthCommand, configureCacheCommand, configureConfigCommand, configureEnvCommand, configureExecCommand, configureGetCommand, configureInitCommand, configureInspectCommand, configureInstallCommand, configureListCommand, configurePublishCommand, configureReportCommand, configureRunCommand, configureSearchCommand, configureSetupCommand, configureSignCommand, configureTrustCommand, configureUnyankCommand, configureYankCommand, } from "./commands";
|
|
11
|
+
import { error, formatError } from "./utils";
|
|
12
|
+
export const version = "2.0.2";
|
|
13
|
+
// Main CLI entry point
|
|
14
|
+
async function main() {
|
|
15
|
+
// Ensure global setup is complete on first run
|
|
16
|
+
ensureGlobalSetup();
|
|
17
|
+
const program = new Command();
|
|
18
|
+
program
|
|
19
|
+
.name("enact")
|
|
20
|
+
.description("Enact - Verified, portable protocol for AI-executable tools")
|
|
21
|
+
.version(version)
|
|
22
|
+
.option("--json", "Output as JSON")
|
|
23
|
+
.option("-v, --verbose", "Enable verbose output");
|
|
24
|
+
// Configure all commands
|
|
25
|
+
configureSetupCommand(program);
|
|
26
|
+
configureInitCommand(program);
|
|
27
|
+
configureRunCommand(program);
|
|
28
|
+
configureExecCommand(program);
|
|
29
|
+
configureInstallCommand(program);
|
|
30
|
+
configureListCommand(program);
|
|
31
|
+
configureEnvCommand(program);
|
|
32
|
+
configureTrustCommand(program);
|
|
33
|
+
configureConfigCommand(program);
|
|
34
|
+
// Registry commands (Phase 8)
|
|
35
|
+
configureSearchCommand(program);
|
|
36
|
+
configureGetCommand(program);
|
|
37
|
+
configurePublishCommand(program);
|
|
38
|
+
configureAuthCommand(program);
|
|
39
|
+
configureCacheCommand(program);
|
|
40
|
+
// CLI solidification commands (Phase 9)
|
|
41
|
+
configureSignCommand(program);
|
|
42
|
+
configureReportCommand(program);
|
|
43
|
+
configureInspectCommand(program);
|
|
44
|
+
// API v2 migration commands
|
|
45
|
+
configureYankCommand(program);
|
|
46
|
+
configureUnyankCommand(program);
|
|
47
|
+
// Global error handler
|
|
48
|
+
program.exitOverride((err) => {
|
|
49
|
+
if (err.code === "commander.help" || err.code === "commander.version") {
|
|
50
|
+
process.exit(0);
|
|
51
|
+
}
|
|
52
|
+
throw err;
|
|
53
|
+
});
|
|
54
|
+
try {
|
|
55
|
+
await program.parseAsync(process.argv);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
error(formatError(err));
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (import.meta.main) {
|
|
63
|
+
main().catch((err) => {
|
|
64
|
+
error(formatError(err));
|
|
65
|
+
process.exit(1);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAK/B,uBAAuB;AACvB,KAAK,UAAU,IAAI;IACjB,+CAA+C;IAC/C,iBAAiB,EAAE,CAAC;IAEpB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,OAAO,CAAC;SACb,WAAW,CAAC,6DAA6D,CAAC;SAC1E,OAAO,CAAC,OAAO,CAAC;SAChB,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAAC;IAEpD,yBAA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AAC,CAAC,CAAC;QACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACnB,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;QACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Types
|
|
3
|
+
*/
|
|
4
|
+
import type { Command } from "commander";
|
|
5
|
+
/**
|
|
6
|
+
* Global CLI options available to all commands
|
|
7
|
+
*/
|
|
8
|
+
export interface GlobalOptions {
|
|
9
|
+
/** Enable verbose output */
|
|
10
|
+
verbose?: boolean;
|
|
11
|
+
/** Output as JSON */
|
|
12
|
+
json?: boolean;
|
|
13
|
+
/** Suppress all output except errors */
|
|
14
|
+
quiet?: boolean;
|
|
15
|
+
/** Run without making changes (preview mode) */
|
|
16
|
+
dryRun?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Context passed to command handlers
|
|
20
|
+
*/
|
|
21
|
+
export interface CommandContext {
|
|
22
|
+
/** Current working directory */
|
|
23
|
+
cwd: string;
|
|
24
|
+
/** Global options */
|
|
25
|
+
options: GlobalOptions;
|
|
26
|
+
/** Whether running in CI environment */
|
|
27
|
+
isCI: boolean;
|
|
28
|
+
/** Whether running interactively (TTY) */
|
|
29
|
+
isInteractive: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Command handler function signature
|
|
33
|
+
*/
|
|
34
|
+
export type CommandHandler<T = Record<string, unknown>> = (args: T, context: CommandContext) => Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Command definition for registration
|
|
37
|
+
*/
|
|
38
|
+
export interface CommandDefinition {
|
|
39
|
+
/** Command name */
|
|
40
|
+
name: string;
|
|
41
|
+
/** Command description */
|
|
42
|
+
description: string;
|
|
43
|
+
/** Command aliases */
|
|
44
|
+
aliases?: string[];
|
|
45
|
+
/** Configure the command (add options, arguments, subcommands) */
|
|
46
|
+
configure: (cmd: Command) => void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Result from a command execution
|
|
50
|
+
*/
|
|
51
|
+
export interface CommandResult {
|
|
52
|
+
success: boolean;
|
|
53
|
+
message?: string;
|
|
54
|
+
data?: unknown;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Exit codes
|
|
58
|
+
*/
|
|
59
|
+
export declare const ExitCode: {
|
|
60
|
+
readonly Success: 0;
|
|
61
|
+
readonly Error: 1;
|
|
62
|
+
readonly InvalidArgs: 2;
|
|
63
|
+
readonly NotFound: 3;
|
|
64
|
+
readonly PermissionDenied: 4;
|
|
65
|
+
readonly Cancelled: 130;
|
|
66
|
+
};
|
|
67
|
+
export type ExitCode = (typeof ExitCode)[keyof typeof ExitCode];
|
|
68
|
+
export type CLIConfig = Record<string, unknown>;
|
|
69
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,4BAA4B;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qBAAqB;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,wCAAwC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gDAAgD;IAChD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,gCAAgC;IAChC,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EAAE,CAAC;IACX,gBAAgB,EAAE,CAAC;IACnB,SAAS,EAAE,GAAG,EAAE,sBAAsB;CAC9B,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handling utilities for CLI
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent error handling with helpful suggestions
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Base CLI error with exit code
|
|
8
|
+
*/
|
|
9
|
+
export declare class CliError extends Error {
|
|
10
|
+
readonly exitCode: number;
|
|
11
|
+
readonly suggestion?: string | undefined;
|
|
12
|
+
constructor(message: string, exitCode?: number, suggestion?: string | undefined);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Tool not found error
|
|
16
|
+
*/
|
|
17
|
+
export declare class ToolNotFoundError extends CliError {
|
|
18
|
+
constructor(toolName: string);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Manifest error
|
|
22
|
+
*/
|
|
23
|
+
export declare class ManifestError extends CliError {
|
|
24
|
+
constructor(message: string, path?: string);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validation error
|
|
28
|
+
*/
|
|
29
|
+
export declare class ValidationError extends CliError {
|
|
30
|
+
constructor(message: string, field?: string);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Authentication error
|
|
34
|
+
*/
|
|
35
|
+
export declare class AuthError extends CliError {
|
|
36
|
+
constructor(message: string);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Network error
|
|
40
|
+
*/
|
|
41
|
+
export declare class NetworkError extends CliError {
|
|
42
|
+
constructor(message: string);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Registry error
|
|
46
|
+
*/
|
|
47
|
+
export declare class RegistryError extends CliError {
|
|
48
|
+
constructor(message: string);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Trust verification error
|
|
52
|
+
*/
|
|
53
|
+
export declare class TrustError extends CliError {
|
|
54
|
+
constructor(message: string);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Timeout error
|
|
58
|
+
*/
|
|
59
|
+
export declare class TimeoutError extends CliError {
|
|
60
|
+
constructor(operation: string, timeoutMs: number);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Execution error
|
|
64
|
+
*/
|
|
65
|
+
export declare class ExecutionError extends CliError {
|
|
66
|
+
readonly stderr?: string | undefined;
|
|
67
|
+
constructor(message: string, stderr?: string | undefined);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Container error
|
|
71
|
+
*/
|
|
72
|
+
export declare class ContainerError extends CliError {
|
|
73
|
+
constructor(message: string);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* File not found error
|
|
77
|
+
*/
|
|
78
|
+
export declare class FileNotFoundError extends CliError {
|
|
79
|
+
constructor(path: string);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Permission error
|
|
83
|
+
*/
|
|
84
|
+
export declare class PermissionError extends CliError {
|
|
85
|
+
constructor(path: string);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Configuration error
|
|
89
|
+
*/
|
|
90
|
+
export declare class ConfigError extends CliError {
|
|
91
|
+
constructor(message: string);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Usage error (invalid arguments)
|
|
95
|
+
*/
|
|
96
|
+
export declare class UsageError extends CliError {
|
|
97
|
+
constructor(message: string);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Handle an error and exit with appropriate code
|
|
101
|
+
*/
|
|
102
|
+
export declare function handleError(err: unknown, options?: {
|
|
103
|
+
verbose: boolean;
|
|
104
|
+
}): never;
|
|
105
|
+
/**
|
|
106
|
+
* Wrap an async function with error handling
|
|
107
|
+
*/
|
|
108
|
+
export declare function withErrorHandling<T extends unknown[]>(fn: (...args: T) => Promise<void>, options?: {
|
|
109
|
+
verbose: boolean;
|
|
110
|
+
}): (...args: T) => Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Categorize an error and return appropriate CliError
|
|
113
|
+
*/
|
|
114
|
+
export declare function categorizeError(err: unknown): CliError;
|
|
115
|
+
/**
|
|
116
|
+
* Common error messages with actionable suggestions
|
|
117
|
+
*/
|
|
118
|
+
export declare const ErrorMessages: {
|
|
119
|
+
toolNotFound: (name: string) => {
|
|
120
|
+
message: string;
|
|
121
|
+
suggestions: string[];
|
|
122
|
+
};
|
|
123
|
+
notAuthenticated: () => {
|
|
124
|
+
message: string;
|
|
125
|
+
suggestions: string[];
|
|
126
|
+
};
|
|
127
|
+
manifestNotFound: (dir: string) => {
|
|
128
|
+
message: string;
|
|
129
|
+
suggestions: string[];
|
|
130
|
+
};
|
|
131
|
+
invalidManifest: (errors: string[]) => {
|
|
132
|
+
message: string;
|
|
133
|
+
suggestions: string[];
|
|
134
|
+
};
|
|
135
|
+
registryUnavailable: () => {
|
|
136
|
+
message: string;
|
|
137
|
+
suggestions: string[];
|
|
138
|
+
};
|
|
139
|
+
containerRuntimeNotFound: () => {
|
|
140
|
+
message: string;
|
|
141
|
+
suggestions: string[];
|
|
142
|
+
};
|
|
143
|
+
trustVerificationFailed: (tool: string) => {
|
|
144
|
+
message: string;
|
|
145
|
+
suggestions: string[];
|
|
146
|
+
};
|
|
147
|
+
executionFailed: (tool: string, exitCode: number) => {
|
|
148
|
+
message: string;
|
|
149
|
+
suggestions: string[];
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Print an error with actionable suggestions
|
|
154
|
+
*/
|
|
155
|
+
export declare function printErrorWithSuggestions(errorInfo: {
|
|
156
|
+
message: string;
|
|
157
|
+
suggestions: string[];
|
|
158
|
+
}): void;
|
|
159
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts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G, EXIT_CONTAINER_ERROR, EXIT_EXECUTION_ERROR, EXIT_FAILURE, EXIT_MANIFEST_ERROR, EXIT_NETWORK_ERROR, EXIT_NOINPUT, EXIT_NOPERM, EXIT_REGISTRY_ERROR, EXIT_TIMEOUT, EXIT_TOOL_NOT_FOUND, EXIT_TRUST_ERROR, EXIT_USAGE, EXIT_VALIDATION_ERROR, } from "./exit-codes";
|
|
7
|
+
import { colors, dim, newline, error as printError, suggest } from "./output";
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Error Classes
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Base CLI error with exit code
|
|
13
|
+
*/
|
|
14
|
+
export class CliError extends Error {
|
|
15
|
+
exitCode;
|
|
16
|
+
suggestion;
|
|
17
|
+
constructor(message, exitCode = EXIT_FAILURE, suggestion) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.exitCode = exitCode;
|
|
20
|
+
this.suggestion = suggestion;
|
|
21
|
+
this.name = "CliError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Tool not found error
|
|
26
|
+
*/
|
|
27
|
+
export class ToolNotFoundError extends CliError {
|
|
28
|
+
constructor(toolName) {
|
|
29
|
+
super(`Tool not found: ${toolName}`, EXIT_TOOL_NOT_FOUND, "Check the tool name or provide a path to a local tool.\nFor registry tools, use the format: owner/namespace/tool[@version]");
|
|
30
|
+
this.name = "ToolNotFoundError";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Manifest error
|
|
35
|
+
*/
|
|
36
|
+
export class ManifestError extends CliError {
|
|
37
|
+
constructor(message, path) {
|
|
38
|
+
const fullMessage = path ? `${message} in ${path}` : message;
|
|
39
|
+
super(fullMessage, EXIT_MANIFEST_ERROR, "Ensure the directory contains a valid enact.yaml or enact.md file.");
|
|
40
|
+
this.name = "ManifestError";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Validation error
|
|
45
|
+
*/
|
|
46
|
+
export class ValidationError extends CliError {
|
|
47
|
+
constructor(message, field) {
|
|
48
|
+
const fullMessage = field ? `Invalid ${field}: ${message}` : message;
|
|
49
|
+
super(fullMessage, EXIT_VALIDATION_ERROR);
|
|
50
|
+
this.name = "ValidationError";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Authentication error
|
|
55
|
+
*/
|
|
56
|
+
export class AuthError extends CliError {
|
|
57
|
+
constructor(message) {
|
|
58
|
+
super(message, EXIT_AUTH_ERROR, "Run 'enact auth login' to authenticate.");
|
|
59
|
+
this.name = "AuthError";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Network error
|
|
64
|
+
*/
|
|
65
|
+
export class NetworkError extends CliError {
|
|
66
|
+
constructor(message) {
|
|
67
|
+
super(message, EXIT_NETWORK_ERROR, "Check your network connection and try again.");
|
|
68
|
+
this.name = "NetworkError";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Registry error
|
|
73
|
+
*/
|
|
74
|
+
export class RegistryError extends CliError {
|
|
75
|
+
constructor(message) {
|
|
76
|
+
super(message, EXIT_REGISTRY_ERROR, "The registry may be temporarily unavailable. Try again later.");
|
|
77
|
+
this.name = "RegistryError";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Trust verification error
|
|
82
|
+
*/
|
|
83
|
+
export class TrustError extends CliError {
|
|
84
|
+
constructor(message) {
|
|
85
|
+
super(message, EXIT_TRUST_ERROR, "Verify the tool's attestations with 'enact trust check <tool>'");
|
|
86
|
+
this.name = "TrustError";
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Timeout error
|
|
91
|
+
*/
|
|
92
|
+
export class TimeoutError extends CliError {
|
|
93
|
+
constructor(operation, timeoutMs) {
|
|
94
|
+
const timeoutSec = Math.round(timeoutMs / 1000);
|
|
95
|
+
super(`${operation} timed out after ${timeoutSec}s`, EXIT_TIMEOUT, "Try increasing the timeout with --timeout option.");
|
|
96
|
+
this.name = "TimeoutError";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Execution error
|
|
101
|
+
*/
|
|
102
|
+
export class ExecutionError extends CliError {
|
|
103
|
+
stderr;
|
|
104
|
+
constructor(message, stderr) {
|
|
105
|
+
super(message, EXIT_EXECUTION_ERROR);
|
|
106
|
+
this.stderr = stderr;
|
|
107
|
+
this.name = "ExecutionError";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Container error
|
|
112
|
+
*/
|
|
113
|
+
export class ContainerError extends CliError {
|
|
114
|
+
constructor(message) {
|
|
115
|
+
super(message, EXIT_CONTAINER_ERROR, "Ensure Docker or another container runtime is running.");
|
|
116
|
+
this.name = "ContainerError";
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* File not found error
|
|
121
|
+
*/
|
|
122
|
+
export class FileNotFoundError extends CliError {
|
|
123
|
+
constructor(path) {
|
|
124
|
+
super(`File not found: ${path}`, EXIT_NOINPUT);
|
|
125
|
+
this.name = "FileNotFoundError";
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Permission error
|
|
130
|
+
*/
|
|
131
|
+
export class PermissionError extends CliError {
|
|
132
|
+
constructor(path) {
|
|
133
|
+
super(`Permission denied: ${path}`, EXIT_NOPERM);
|
|
134
|
+
this.name = "PermissionError";
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Configuration error
|
|
139
|
+
*/
|
|
140
|
+
export class ConfigError extends CliError {
|
|
141
|
+
constructor(message) {
|
|
142
|
+
super(message, EXIT_CONFIG, "Check your configuration with 'enact config list'.");
|
|
143
|
+
this.name = "ConfigError";
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Usage error (invalid arguments)
|
|
148
|
+
*/
|
|
149
|
+
export class UsageError extends CliError {
|
|
150
|
+
constructor(message) {
|
|
151
|
+
super(message, EXIT_USAGE);
|
|
152
|
+
this.name = "UsageError";
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// ============================================================================
|
|
156
|
+
// Error Handling
|
|
157
|
+
// ============================================================================
|
|
158
|
+
/**
|
|
159
|
+
* Handle an error and exit with appropriate code
|
|
160
|
+
*/
|
|
161
|
+
export function handleError(err, options) {
|
|
162
|
+
if (err instanceof CliError) {
|
|
163
|
+
printError(err.message);
|
|
164
|
+
if (err.suggestion) {
|
|
165
|
+
suggest(err.suggestion);
|
|
166
|
+
}
|
|
167
|
+
if (options?.verbose && err.stack) {
|
|
168
|
+
newline();
|
|
169
|
+
dim(err.stack);
|
|
170
|
+
}
|
|
171
|
+
process.exit(err.exitCode);
|
|
172
|
+
}
|
|
173
|
+
// Handle standard errors
|
|
174
|
+
if (err instanceof Error) {
|
|
175
|
+
printError(err.message);
|
|
176
|
+
if (options?.verbose && err.stack) {
|
|
177
|
+
newline();
|
|
178
|
+
dim(err.stack);
|
|
179
|
+
}
|
|
180
|
+
process.exit(EXIT_FAILURE);
|
|
181
|
+
}
|
|
182
|
+
// Handle unknown errors
|
|
183
|
+
printError(String(err));
|
|
184
|
+
process.exit(EXIT_FAILURE);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Wrap an async function with error handling
|
|
188
|
+
*/
|
|
189
|
+
export function withErrorHandling(fn, options) {
|
|
190
|
+
return async (...args) => {
|
|
191
|
+
try {
|
|
192
|
+
await fn(...args);
|
|
193
|
+
}
|
|
194
|
+
catch (err) {
|
|
195
|
+
handleError(err, options);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Categorize an error and return appropriate CliError
|
|
201
|
+
*/
|
|
202
|
+
export function categorizeError(err) {
|
|
203
|
+
if (err instanceof CliError) {
|
|
204
|
+
return err;
|
|
205
|
+
}
|
|
206
|
+
if (err instanceof Error) {
|
|
207
|
+
const message = err.message.toLowerCase();
|
|
208
|
+
// Network errors
|
|
209
|
+
if (message.includes("network") ||
|
|
210
|
+
message.includes("econnrefused") ||
|
|
211
|
+
message.includes("enotfound") ||
|
|
212
|
+
message.includes("etimedout") ||
|
|
213
|
+
message.includes("fetch failed")) {
|
|
214
|
+
return new NetworkError(err.message);
|
|
215
|
+
}
|
|
216
|
+
// Permission errors
|
|
217
|
+
if (message.includes("eacces") ||
|
|
218
|
+
message.includes("permission denied") ||
|
|
219
|
+
message.includes("eperm")) {
|
|
220
|
+
return new PermissionError(err.message);
|
|
221
|
+
}
|
|
222
|
+
// File not found
|
|
223
|
+
if (message.includes("enoent") || message.includes("no such file")) {
|
|
224
|
+
return new FileNotFoundError(err.message);
|
|
225
|
+
}
|
|
226
|
+
// Timeout
|
|
227
|
+
if (message.includes("timeout") || message.includes("timed out")) {
|
|
228
|
+
return new TimeoutError("Operation", 30000);
|
|
229
|
+
}
|
|
230
|
+
// Authentication
|
|
231
|
+
if (message.includes("unauthorized") ||
|
|
232
|
+
message.includes("401") ||
|
|
233
|
+
message.includes("authentication")) {
|
|
234
|
+
return new AuthError(err.message);
|
|
235
|
+
}
|
|
236
|
+
// Return generic CliError
|
|
237
|
+
return new CliError(err.message);
|
|
238
|
+
}
|
|
239
|
+
return new CliError(String(err));
|
|
240
|
+
}
|
|
241
|
+
// ============================================================================
|
|
242
|
+
// Error Messages with Actions
|
|
243
|
+
// ============================================================================
|
|
244
|
+
/**
|
|
245
|
+
* Common error messages with actionable suggestions
|
|
246
|
+
*/
|
|
247
|
+
export const ErrorMessages = {
|
|
248
|
+
toolNotFound: (name) => ({
|
|
249
|
+
message: `Tool "${name}" not found`,
|
|
250
|
+
suggestions: [
|
|
251
|
+
"Check the tool name spelling",
|
|
252
|
+
`Search for tools: ${colors.command("enact search <query>")}`,
|
|
253
|
+
`Install from path: ${colors.command("enact install ./path/to/tool")}`,
|
|
254
|
+
],
|
|
255
|
+
}),
|
|
256
|
+
notAuthenticated: () => ({
|
|
257
|
+
message: "You are not authenticated",
|
|
258
|
+
suggestions: [
|
|
259
|
+
`Log in: ${colors.command("enact auth login")}`,
|
|
260
|
+
`Check status: ${colors.command("enact auth status")}`,
|
|
261
|
+
],
|
|
262
|
+
}),
|
|
263
|
+
manifestNotFound: (dir) => ({
|
|
264
|
+
message: `No manifest found in ${dir}`,
|
|
265
|
+
suggestions: [
|
|
266
|
+
`Create a manifest: ${colors.command("enact init")}`,
|
|
267
|
+
"Ensure the directory contains enact.yaml or enact.md",
|
|
268
|
+
],
|
|
269
|
+
}),
|
|
270
|
+
invalidManifest: (errors) => ({
|
|
271
|
+
message: "Invalid manifest",
|
|
272
|
+
suggestions: [
|
|
273
|
+
"Fix the following errors:",
|
|
274
|
+
...errors.map((e) => ` ${colors.error("•")} ${e}`),
|
|
275
|
+
`Validate manifest: ${colors.command("enact validate")}`,
|
|
276
|
+
],
|
|
277
|
+
}),
|
|
278
|
+
registryUnavailable: () => ({
|
|
279
|
+
message: "Registry is unavailable",
|
|
280
|
+
suggestions: [
|
|
281
|
+
"Check your internet connection",
|
|
282
|
+
`Verify registry URL: ${colors.command("enact config get registry.url")}`,
|
|
283
|
+
"Try again later",
|
|
284
|
+
],
|
|
285
|
+
}),
|
|
286
|
+
containerRuntimeNotFound: () => ({
|
|
287
|
+
message: "No container runtime found",
|
|
288
|
+
suggestions: [
|
|
289
|
+
"Install Docker: https://docs.docker.com/get-docker/",
|
|
290
|
+
"Or install Podman: https://podman.io/getting-started/installation",
|
|
291
|
+
"Ensure the runtime is running",
|
|
292
|
+
],
|
|
293
|
+
}),
|
|
294
|
+
trustVerificationFailed: (tool) => ({
|
|
295
|
+
message: `Trust verification failed for "${tool}"`,
|
|
296
|
+
suggestions: [
|
|
297
|
+
"The tool has no valid attestations",
|
|
298
|
+
`Add a trusted publisher: ${colors.command("enact trust add <identity>")}`,
|
|
299
|
+
`Check attestations: ${colors.command(`enact trust check ${tool}`)}`,
|
|
300
|
+
],
|
|
301
|
+
}),
|
|
302
|
+
executionFailed: (tool, exitCode) => ({
|
|
303
|
+
message: `Tool "${tool}" failed with exit code ${exitCode}`,
|
|
304
|
+
suggestions: [
|
|
305
|
+
"Check tool logs for details",
|
|
306
|
+
"Verify input parameters",
|
|
307
|
+
`Run with verbose output: ${colors.command("enact run --verbose")}`,
|
|
308
|
+
],
|
|
309
|
+
}),
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Print an error with actionable suggestions
|
|
313
|
+
*/
|
|
314
|
+
export function printErrorWithSuggestions(errorInfo) {
|
|
315
|
+
printError(errorInfo.message);
|
|
316
|
+
newline();
|
|
317
|
+
for (const suggestion of errorInfo.suggestions) {
|
|
318
|
+
console.log(` ${colors.dim("•")} ${suggestion}`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAE9E,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IAGf;IACA;IAHlB,YACE,OAAe,EACC,WAAmB,YAAY,EAC/B,UAAmB;QAEnC,KAAK,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