@studiometa/forge-cli 0.2.5 → 0.3.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.
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/backups/handlers.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBpE;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCnF;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAoDtE;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BtF"}
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/backups/handlers.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBpE;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCnF;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAoDtE;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BtF"}
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/commands/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAsBvD,wBAAsB,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBrE;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBpF;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBvE"}
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/commands/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAsBvD,wBAAsB,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBrE;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBpF;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBvE"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Config command — manage forge-cli configuration
2
+ * Config command — manage forge configuration
3
3
  */
4
4
  export declare function showConfigHelp(): void;
5
5
  export declare function handleConfigCommand(subcommand: string, args: string[], options: Record<string, string | boolean | string[]>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/daemons/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBpE;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCnF;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BvF"}
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/daemons/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBpE;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCnF;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BvF"}
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/monitors/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,wBAAsB,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBrE;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCpF;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA6CvE;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BvF"}
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/monitors/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,wBAAsB,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBrE;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCpF;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA6CvE;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BvF"}
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/recipes/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIvD,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAYpE;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAanF;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BnF"}
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/recipes/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIvD,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAYpE;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAanF;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BnF"}
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/security-rules/handlers.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAsBvD,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB1E;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBzF;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB5E;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB5F"}
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/security-rules/handlers.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAsBvD,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB1E;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBzF;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB5E;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB5F"}
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/sites/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,wBAAsB,SAAS,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBlE;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAuCjF"}
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/sites/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,wBAAsB,SAAS,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBlE;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAuCjF"}
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/ssh-keys/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBpE;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BnF"}
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/ssh-keys/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBpE;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BnF"}
package/dist/config.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Config loading for forge-cli.
2
+ * Config loading for forge.
3
3
  *
4
4
  * Resolution priority (highest to lowest):
5
5
  * 1. CLI arguments (--token)
@@ -1,6 +1,6 @@
1
1
  import { HttpClient, createConfigStore, createConfigStore as createConfigStore$1, deleteToken, getToken, getToken as getToken$1, setToken } from "@studiometa/forge-api";
2
2
  /**
3
- * Error types for forge-cli.
3
+ * Error types for forge.
4
4
  *
5
5
  * Provides specific error types for different failure scenarios with
6
6
  * recovery hints for both humans and AI agents.
@@ -39,7 +39,7 @@ var ConfigError = class ConfigError extends CliError {
39
39
  return new ConfigError("API token not configured", [
40
40
  "Set via CLI flag: --token <token>",
41
41
  "Set via environment: export FORGE_API_TOKEN=<token>",
42
- "Set via config: forge-cli config set YOUR_TOKEN"
42
+ "Set via config: forge config set YOUR_TOKEN"
43
43
  ]);
44
44
  }
45
45
  };
@@ -99,7 +99,7 @@ function isCliError(error) {
99
99
  return error instanceof CliError;
100
100
  }
101
101
  /**
102
- * Config loading for forge-cli.
102
+ * Config loading for forge.
103
103
  *
104
104
  * Resolution priority (highest to lowest):
105
105
  * 1. CLI arguments (--token)
@@ -393,4 +393,4 @@ function exitWithValidationError(field, usage, formatter) {
393
393
  }
394
394
  export { ConfigError as _, createContext as a, colors as c, deleteToken as d, getConfig as f, CliError as g, ApiError as h, runCommand as i, setColorEnabled as l, setToken as m, exitWithValidationError as n, createTestContext as o, getToken$1 as p, handleError as r, OutputFormatter as s, ExitCode as t, createConfigStore$1 as u, ValidationError as v, isCliError as y };
395
395
 
396
- //# sourceMappingURL=error-handler-BahHMt6t.js.map
396
+ //# sourceMappingURL=error-handler-Byuujxh1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler-Byuujxh1.js","names":[],"sources":["../src/errors.ts","../src/config.ts","../src/utils/colors.ts","../src/output.ts","../src/context.ts","../src/error-handler.ts"],"sourcesContent":["/**\n * Error types for forge.\n *\n * Provides specific error types for different failure scenarios with\n * recovery hints for both humans and AI agents.\n */\n\n/**\n * Base error class for all CLI errors.\n */\nexport abstract class CliError extends Error {\n abstract readonly code: string;\n abstract readonly isRecoverable: boolean;\n\n constructor(\n message: string,\n public readonly hints?: string[],\n public readonly cause?: unknown,\n ) {\n super(message);\n this.name = this.constructor.name;\n\n Error.captureStackTrace?.(this, this.constructor);\n }\n\n toJSON(): Record<string, unknown> {\n return {\n error: this.code,\n name: this.name,\n message: this.message,\n isRecoverable: this.isRecoverable,\n ...(this.hints && this.hints.length > 0 ? { hints: this.hints } : {}),\n ...(this.cause instanceof Error ? { cause: { message: this.cause.message } } : {}),\n };\n }\n\n toFormattedMessage(): string {\n let msg = this.message;\n if (this.hints && this.hints.length > 0) {\n msg += \"\\n\\nHints:\\n\" + this.hints.map((h) => ` • ${h}`).join(\"\\n\");\n }\n return msg;\n }\n}\n\n// ── Config Errors ────────────────────────────────────\n\nexport class ConfigError extends CliError {\n readonly code = \"CONFIG_ERROR\";\n readonly isRecoverable = true;\n\n static missingToken(): ConfigError {\n return new ConfigError(\"API token not configured\", [\n \"Set via CLI flag: --token <token>\",\n \"Set via environment: export FORGE_API_TOKEN=<token>\",\n \"Set via config: forge config set YOUR_TOKEN\",\n ]);\n }\n}\n\n// ── Validation Errors ────────────────────────────────\n\nexport class ValidationError extends CliError {\n readonly code = \"VALIDATION_ERROR\";\n readonly isRecoverable = true;\n\n constructor(\n message: string,\n public readonly field?: string,\n hints?: string[],\n cause?: unknown,\n ) {\n super(message, hints, cause);\n }\n\n override toJSON() {\n return { ...super.toJSON(), field: this.field };\n }\n\n static required(field: string, hints?: string[]): ValidationError {\n return new ValidationError(`${field} is required`, field, hints);\n }\n}\n\n// ── API Errors ───────────────────────────────────────\n\nexport class ApiError extends CliError {\n readonly code = \"API_ERROR\";\n readonly isRecoverable: boolean;\n\n constructor(\n message: string,\n public readonly statusCode?: number,\n hints?: string[],\n cause?: unknown,\n ) {\n super(message, hints ?? getApiErrorHints(statusCode), cause);\n this.isRecoverable = statusCode === undefined || (statusCode >= 500 && statusCode < 600);\n }\n\n override toJSON() {\n return { ...super.toJSON(), statusCode: this.statusCode };\n }\n\n static fromForgeError(error: unknown): ApiError {\n if (error instanceof Error && \"statusCode\" in error) {\n const e = error as Error & { statusCode?: number };\n return new ApiError(e.message, e.statusCode, undefined, e);\n }\n if (error instanceof Error) {\n return new ApiError(error.message, undefined, undefined, error);\n }\n return new ApiError(String(error));\n }\n}\n\nfunction getApiErrorHints(statusCode?: number): string[] {\n if (statusCode === 401) {\n return [\"Check that your API token is valid\", \"Set via: export FORGE_API_TOKEN=<token>\"];\n }\n if (statusCode === 403) {\n return [\"You may not have permission to access this resource\"];\n }\n if (statusCode === 404) {\n return [\n \"The resource may not exist\",\n \"Verify the ID is correct\",\n \"Use the list command to find valid IDs\",\n ];\n }\n if (statusCode === 429) {\n return [\"Too many requests — wait before retrying\"];\n }\n if (statusCode !== undefined && statusCode >= 500) {\n return [\"Server error — try again later\"];\n }\n return [];\n}\n\n// ── Type Guards ──────────────────────────────────────\n\nexport function isCliError(error: unknown): error is CliError {\n return error instanceof CliError;\n}\n","/**\n * Config loading for forge.\n *\n * Resolution priority (highest to lowest):\n * 1. CLI arguments (--token)\n * 2. Environment variable (FORGE_API_TOKEN)\n * 3. Config file (XDG-compliant)\n */\n\nimport { createConfigStore, getToken } from \"@studiometa/forge-api\";\n\nexport interface ForgeCliConfig {\n /** Forge API token */\n apiToken: string | undefined;\n}\n\n/**\n * Resolve config from multiple sources with priority order.\n */\nexport function getConfig(\n cliOptions?: Record<string, string | boolean | string[]>,\n): ForgeCliConfig {\n // 1. CLI argument --token\n const cliToken = cliOptions?.token;\n\n // 2. Environment variable / config file (handled by getToken)\n const storedToken = getToken(createConfigStore());\n\n return {\n apiToken: typeof cliToken === \"string\" ? cliToken : (storedToken ?? undefined),\n };\n}\n\nexport { createConfigStore, getToken, setToken, deleteToken } from \"@studiometa/forge-api\";\n","/**\n * ANSI color utilities using native Node.js.\n * Provides terminal colors without external dependencies.\n */\n\n// ANSI escape codes\nconst RESET = \"\\x1b[0m\";\nconst BOLD = \"\\x1b[1m\";\nconst DIM = \"\\x1b[2m\";\n\n// Foreground colors\nconst FG_RED = \"\\x1b[31m\";\nconst FG_GREEN = \"\\x1b[32m\";\nconst FG_YELLOW = \"\\x1b[33m\";\nconst FG_CYAN = \"\\x1b[36m\";\nconst FG_GRAY = \"\\x1b[90m\";\n\n// Colors enabled by default, disabled by NO_COLOR env var\nlet colorEnabled = process.env.NO_COLOR === undefined;\n\nexport function setColorEnabled(enabled: boolean): void {\n colorEnabled = enabled;\n}\n\nexport function isColorEnabled(): boolean {\n return colorEnabled;\n}\n\nfunction colorize(text: string, code: string): string {\n if (!colorEnabled) return text;\n return `${code}${text}${RESET}`;\n}\n\nexport const colors = {\n reset: (text: string) => (colorEnabled ? `${RESET}${text}` : text),\n bold: (text: string) => colorize(text, BOLD),\n dim: (text: string) => colorize(text, DIM),\n red: (text: string) => colorize(text, FG_RED),\n green: (text: string) => colorize(text, FG_GREEN),\n yellow: (text: string) => colorize(text, FG_YELLOW),\n cyan: (text: string) => colorize(text, FG_CYAN),\n gray: (text: string) => colorize(text, FG_GRAY),\n};\n","import type { OutputFormat } from \"./types.ts\";\n\nimport { colors } from \"./utils/colors.ts\";\n\n/**\n * Output formatter for CLI commands.\n * Supports human-readable, JSON, and table formats.\n */\nexport class OutputFormatter {\n constructor(\n private format: OutputFormat = \"human\",\n private noColor: boolean = false,\n ) {}\n\n /**\n * Returns true when the current format is JSON.\n */\n isJson(): boolean {\n return this.format === \"json\";\n }\n\n /**\n * Output data in the configured format.\n * Use format='json' for AI agents and structured data.\n */\n output(data: unknown): void {\n switch (this.format) {\n case \"json\":\n console.log(JSON.stringify(data, null, 2));\n break;\n case \"table\":\n this.outputTable(data);\n break;\n case \"human\":\n default:\n console.log(data);\n break;\n }\n }\n\n /**\n * Output a list with a human-readable one-liner per item and a table for table format.\n * Falls back to JSON for json format.\n *\n * @param data - Array of items to display\n * @param columns - Ordered list of field names to include in human/table output\n * @param emptyMessage - Message shown when data is empty (human format only)\n * @param lineFormat - Optional custom line formatter for human format\n */\n outputList<T extends object>(\n data: T[],\n columns: (keyof T & string)[],\n emptyMessage: string,\n lineFormat?: (item: T) => string,\n ): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify(data, null, 2));\n return;\n }\n\n if (this.format === \"table\") {\n this.outputTable(data.map((item) => Object.fromEntries(columns.map((c) => [c, item[c]]))));\n return;\n }\n\n // human\n if (data.length === 0) {\n console.log(colors.cyan(emptyMessage));\n return;\n }\n\n if (lineFormat) {\n for (const item of data) {\n console.log(lineFormat(item));\n }\n return;\n }\n\n // Default: padded columns\n const widths = columns.map((col) =>\n Math.max(\n col.length,\n ...data.map((item) => String((item as Record<string, unknown>)[col] ?? \"\").length),\n ),\n );\n for (const item of data) {\n const row = item as Record<string, unknown>;\n const line = columns.map((col, i) => String(row[col] ?? \"\").padEnd(widths[i])).join(\" \");\n console.log(line.trimEnd());\n }\n }\n\n /**\n * Output a single resource in human-readable format.\n * For json format, uses JSON.stringify. For table format, uses a two-column key/value table.\n *\n * @param data - Object to display\n * @param fields - Ordered list of fields to display (defaults to all keys)\n */\n outputOne<T extends object>(data: T, fields?: (keyof T & string)[]): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify(data, null, 2));\n return;\n }\n\n const record = data as Record<string, unknown>;\n const keys = fields ?? (Object.keys(record) as (keyof T & string)[]);\n\n if (this.format === \"table\") {\n const rows = keys.map((k) => ({ field: k, value: String(record[k] ?? \"\") }));\n this.outputTable(rows);\n return;\n }\n\n // human: key: value pairs\n const keyWidth = Math.max(...keys.map((k) => k.length));\n for (const key of keys) {\n const value = record[key];\n const valueStr =\n value !== null && typeof value === \"object\" ? JSON.stringify(value) : String(value ?? \"\");\n console.log(`${colors.cyan(key.padEnd(keyWidth))} ${valueStr}`);\n }\n }\n\n success(message: string): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify({ status: \"success\", message }));\n } else {\n console.log(colors.green(`✓ ${message}`));\n }\n }\n\n error(message: string, details?: unknown): void {\n if (this.format === \"json\") {\n console.error(JSON.stringify({ status: \"error\", message, details }));\n } else {\n console.error(colors.red(`✗ ${message}`));\n if (details !== undefined) {\n console.error(details);\n }\n }\n }\n\n warning(message: string): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify({ status: \"warning\", message }));\n } else {\n console.log(colors.yellow(`⚠ ${message}`));\n }\n }\n\n info(message: string): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify({ status: \"info\", message }));\n } else {\n console.log(colors.cyan(message));\n }\n }\n\n private outputTable(data: unknown): void {\n if (Array.isArray(data) && data.length > 0) {\n const headers = Object.keys(data[0] as Record<string, unknown>);\n const colWidths = headers.map((h) => {\n const maxDataWidth = Math.max(\n ...data.map((row) => String((row as Record<string, unknown>)[h] ?? \"\").length),\n );\n return Math.max(h.length, maxDataWidth);\n });\n\n // Header\n const headerRow = headers.map((h, i) => h.padEnd(colWidths[i])).join(\" | \");\n console.log(headerRow);\n console.log(colWidths.map((w) => \"-\".repeat(w)).join(\"-+-\"));\n\n // Rows\n for (const row of data) {\n const rowStr = headers\n .map((h, i) => String((row as Record<string, unknown>)[h] ?? \"\").padEnd(colWidths[i]))\n .join(\" | \");\n console.log(rowStr);\n }\n }\n }\n}\nexport const x = { a: 1, b: 2 };\n","/**\n * CLI execution context with dependency injection.\n *\n * Instead of hidden dependencies in command handlers, this module provides\n * explicit dependency passing for testability and transparency.\n */\n\nimport type { HttpClient } from \"@studiometa/forge-api\";\nimport type { ExecutorContext } from \"@studiometa/forge-core\";\n\nimport type { OutputFormat } from \"./types.ts\";\n\nimport { HttpClient as ForgeHttpClient } from \"@studiometa/forge-api\";\nimport { ConfigError } from \"./errors.ts\";\nimport { createConfigStore, getToken } from \"./config.ts\";\nimport { OutputFormatter } from \"./output.ts\";\n\nexport interface CommandOptions {\n [key: string]: string | boolean | string[] | undefined;\n format?: string;\n f?: string;\n token?: string;\n \"no-color\"?: boolean;\n}\n\n/**\n * Context containing all dependencies needed by command handlers.\n */\nexport interface CommandContext {\n /** Output formatter for the current format */\n readonly formatter: OutputFormatter;\n /** Raw CLI options */\n readonly options: CommandOptions;\n /** Create an ExecutorContext from this command context */\n createExecutorContext(token: string): ExecutorContext;\n /** Resolve the API token or throw ConfigError */\n getToken(): string;\n}\n\n/**\n * Creates a command context from CLI options.\n */\nexport function createContext(options: CommandOptions = {}): CommandContext {\n const format = (options.format ?? options.f ?? \"human\") as OutputFormat;\n const noColor = options[\"no-color\"] === true;\n const formatter = new OutputFormatter(format, noColor);\n\n return {\n formatter,\n options,\n\n createExecutorContext(token: string): ExecutorContext {\n const client = new ForgeHttpClient({ token }) as unknown as HttpClient;\n return { client };\n },\n\n getToken(): string {\n // 1. CLI arg\n if (typeof options.token === \"string\" && options.token) {\n return options.token;\n }\n // 2. Env var / config file\n const stored = getToken(createConfigStore());\n if (stored) {\n return stored;\n }\n // 3. Not found — throw\n throw ConfigError.missingToken();\n },\n };\n}\n\n/**\n * Creates a test context for unit tests.\n *\n * @example\n * ```typescript\n * const ctx = createTestContext({\n * mockClient: { get: async () => ({ servers: [] }) } as never,\n * });\n * ```\n */\nexport function createTestContext(overrides: {\n options?: CommandOptions;\n formatter?: OutputFormatter;\n token?: string;\n mockClient?: HttpClient;\n}): CommandContext {\n const opts: CommandOptions = overrides.options ?? {\n format: \"json\",\n \"no-color\": true,\n };\n const format = (opts.format ?? \"json\") as OutputFormat;\n const formatter = overrides.formatter ?? new OutputFormatter(format, true);\n\n return {\n formatter,\n options: opts,\n createExecutorContext(_token: string): ExecutorContext {\n if (!overrides.mockClient) {\n throw new Error(\n \"createTestContext: provide mockClient to use createExecutorContext in tests\",\n );\n }\n return { client: overrides.mockClient };\n },\n getToken(): string {\n if (overrides.token) return overrides.token;\n if (typeof opts.token === \"string\") return opts.token;\n return \"test-token\";\n },\n };\n}\n","/**\n * Centralized error handling for forge.\n */\n\nimport type { OutputFormatter } from \"./output.ts\";\n\nimport { ApiError, CliError, ConfigError, ValidationError, isCliError } from \"./errors.ts\";\n\n/**\n * Exit codes for different error categories.\n */\nexport const ExitCode = {\n SUCCESS: 0,\n GENERAL_ERROR: 1,\n AUTHENTICATION_ERROR: 2,\n VALIDATION_ERROR: 3,\n CONFIG_ERROR: 4,\n NOT_FOUND_ERROR: 5,\n} as const;\n\nexport type ExitCode = (typeof ExitCode)[keyof typeof ExitCode];\n\n/**\n * Determine the appropriate exit code for an error.\n */\nexport function getExitCode(error: unknown): ExitCode {\n if (error instanceof ValidationError) {\n return ExitCode.VALIDATION_ERROR;\n }\n if (error instanceof ApiError) {\n if (error.statusCode === 401) return ExitCode.AUTHENTICATION_ERROR;\n if (error.statusCode === 404) return ExitCode.NOT_FOUND_ERROR;\n }\n if (isCliError(error) && error.code === \"CONFIG_ERROR\") {\n return ExitCode.CONFIG_ERROR;\n }\n return ExitCode.GENERAL_ERROR;\n}\n\n/**\n * Central error handler for all commands.\n */\nexport function handleError(\n error: unknown,\n formatter: OutputFormatter,\n options?: { exit?: boolean },\n): ExitCode {\n const shouldExit = options?.exit ?? true;\n\n let cliError: CliError;\n if (isCliError(error)) {\n cliError = error;\n } else {\n cliError = ApiError.fromForgeError(error);\n }\n\n // Output error in appropriate format\n const opts = formatter as unknown as { format?: string };\n if (opts.format === \"json\") {\n formatter.output(cliError.toJSON());\n } else {\n formatter.error(cliError.toFormattedMessage());\n }\n\n const exitCode = getExitCode(cliError);\n\n if (shouldExit) {\n process.exit(exitCode);\n }\n\n return exitCode;\n}\n\n/**\n * Wraps a command function with automatic error handling.\n */\nexport async function runCommand<T>(\n fn: () => Promise<T>,\n formatter: OutputFormatter,\n): Promise<T | undefined> {\n try {\n return await fn();\n } catch (error) {\n handleError(error, formatter);\n return undefined; // unreachable due to process.exit\n }\n}\n\n/**\n * Exits with a validation error for a missing required argument.\n */\nexport function exitWithValidationError(\n field: string,\n usage: string,\n formatter: OutputFormatter,\n): never {\n const error = ValidationError.required(field, [`Usage: ${usage}`]);\n handleError(error, formatter);\n // Unreachable in production\n throw error;\n}\n\n/**\n * Exits with a config error when token is missing.\n */\nexport function exitWithConfigError(formatter: OutputFormatter): never {\n const error = ConfigError.missingToken();\n handleError(error, formatter);\n throw error;\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAsB,WAAtB,cAAuC,MAAM;CAI3C,YACE,SACA,OACA,OACA;AACA,QAAM,QAAQ;AAHE,OAAA,QAAA;AACA,OAAA,QAAA;AAGhB,OAAK,OAAO,KAAK,YAAY;AAE7B,QAAM,oBAAoB,MAAM,KAAK,YAAY;;CAGnD,SAAkC;AAChC,SAAO;GACL,OAAO,KAAK;GACZ,MAAM,KAAK;GACX,SAAS,KAAK;GACd,eAAe,KAAK;GACpB,GAAI,KAAK,SAAS,KAAK,MAAM,SAAS,IAAI,EAAE,OAAO,KAAK,OAAO,GAAG,EAAE;GACpE,GAAI,KAAK,iBAAiB,QAAQ,EAAE,OAAO,EAAE,SAAS,KAAK,MAAM,SAAS,EAAE,GAAG,EAAE;GAClF;;CAGH,qBAA6B;EAC3B,IAAI,MAAM,KAAK;AACf,MAAI,KAAK,SAAS,KAAK,MAAM,SAAS,EACpC,QAAO,iBAAiB,KAAK,MAAM,KAAK,MAAM,OAAO,IAAI,CAAC,KAAK,KAAK;AAEtE,SAAO;;;AAMX,IAAa,cAAb,MAAa,oBAAoB,SAAS;CACxC,OAAgB;CAChB,gBAAyB;CAEzB,OAAO,eAA4B;AACjC,SAAO,IAAI,YAAY,4BAA4B;GACjD;GACA;GACA;GACD,CAAC;;;AAMN,IAAa,kBAAb,MAAa,wBAAwB,SAAS;CAC5C,OAAgB;CAChB,gBAAyB;CAEzB,YACE,SACA,OACA,OACA,OACA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;CACd,iBAAiB;CAClB;;;;AAOD,SAAgB,YAAY,OAA0B;AACpD,KAAI,iBAAiB,gBACnB,QAAO,SAAS;AAElB,KAAI,iBAAiB,UAAU;AAC7B,MAAI,MAAM,eAAe,IAAK,QAAO,SAAS;AAC9C,MAAI,MAAM,eAAe,IAAK,QAAO,SAAS;;AAEhD,KAAI,WAAW,MAAM,IAAI,MAAM,SAAS,eACtC,QAAO,SAAS;AAElB,QAAO,SAAS;;;;;AAMlB,SAAgB,YACd,OACA,WACA,SACU;CACV,MAAM,aAAa,SAAS,QAAQ;CAEpC,IAAI;AACJ,KAAI,WAAW,MAAM,CACnB,YAAW;KAEX,YAAW,SAAS,eAAe,MAAM;AAK3C,KADa,UACJ,WAAW,OAClB,WAAU,OAAO,SAAS,QAAQ,CAAC;KAEnC,WAAU,MAAM,SAAS,oBAAoB,CAAC;CAGhD,MAAM,WAAW,YAAY,SAAS;AAEtC,KAAI,WACF,SAAQ,KAAK,SAAS;AAGxB,QAAO;;;;;AAMT,eAAsB,WACpB,IACA,WACwB;AACxB,KAAI;AACF,SAAO,MAAM,IAAI;UACV,OAAO;AACd,cAAY,OAAO,UAAU;AAC7B;;;;;;AAOJ,SAAgB,wBACd,OACA,OACA,WACO;CACP,MAAM,QAAQ,gBAAgB,SAAS,OAAO,CAAC,UAAU,QAAQ,CAAC;AAClE,aAAY,OAAO,UAAU;AAE7B,OAAM"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Centralized error handling for forge-cli.
2
+ * Centralized error handling for forge.
3
3
  */
4
4
  import type { OutputFormatter } from "./output.ts";
5
5
  /**
package/dist/errors.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Error types for forge-cli.
2
+ * Error types for forge.
3
3
  *
4
4
  * Provides specific error types for different failure scenarios with
5
5
  * recovery hints for both humans and AI agents.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as ConfigError, a as createContext, f as getConfig, g as CliError, h as ApiError, i as runCommand, o as createTestContext, r as handleError, s as OutputFormatter, t as ExitCode, v as ValidationError, y as isCliError } from "./error-handler-BahHMt6t.js";
1
+ import { _ as ConfigError, a as createContext, f as getConfig, g as CliError, h as ApiError, i as runCommand, o as createTestContext, r as handleError, s as OutputFormatter, t as ExitCode, v as ValidationError, y as isCliError } from "./error-handler-Byuujxh1.js";
2
2
  export { ApiError, CliError, ConfigError, ExitCode, OutputFormatter, ValidationError, createContext, createTestContext, getConfig, handleError, isCliError, runCommand };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studiometa/forge-cli",
3
- "version": "0.2.5",
3
+ "version": "0.3.0",
4
4
  "description": "CLI tool for managing Laravel Forge servers, sites, and deployments",
5
5
  "keywords": [
6
6
  "ai-agent",
@@ -19,7 +19,7 @@
19
19
  "directory": "packages/cli"
20
20
  },
21
21
  "bin": {
22
- "forge-cli": "./dist/cli.js"
22
+ "forge": "./dist/cli.js"
23
23
  },
24
24
  "files": [
25
25
  "dist"
@@ -48,8 +48,8 @@
48
48
  "typecheck": "tsc --noEmit"
49
49
  },
50
50
  "dependencies": {
51
- "@studiometa/forge-api": "0.2.5",
52
- "@studiometa/forge-core": "0.2.5"
51
+ "@studiometa/forge-api": "0.3.0",
52
+ "@studiometa/forge-core": "0.3.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/node": "^24.0.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-handler-BahHMt6t.js","names":[],"sources":["../src/errors.ts","../src/config.ts","../src/utils/colors.ts","../src/output.ts","../src/context.ts","../src/error-handler.ts"],"sourcesContent":["/**\n * Error types for forge-cli.\n *\n * Provides specific error types for different failure scenarios with\n * recovery hints for both humans and AI agents.\n */\n\n/**\n * Base error class for all CLI errors.\n */\nexport abstract class CliError extends Error {\n abstract readonly code: string;\n abstract readonly isRecoverable: boolean;\n\n constructor(\n message: string,\n public readonly hints?: string[],\n public readonly cause?: unknown,\n ) {\n super(message);\n this.name = this.constructor.name;\n\n Error.captureStackTrace?.(this, this.constructor);\n }\n\n toJSON(): Record<string, unknown> {\n return {\n error: this.code,\n name: this.name,\n message: this.message,\n isRecoverable: this.isRecoverable,\n ...(this.hints && this.hints.length > 0 ? { hints: this.hints } : {}),\n ...(this.cause instanceof Error ? { cause: { message: this.cause.message } } : {}),\n };\n }\n\n toFormattedMessage(): string {\n let msg = this.message;\n if (this.hints && this.hints.length > 0) {\n msg += \"\\n\\nHints:\\n\" + this.hints.map((h) => ` • ${h}`).join(\"\\n\");\n }\n return msg;\n }\n}\n\n// ── Config Errors ────────────────────────────────────\n\nexport class ConfigError extends CliError {\n readonly code = \"CONFIG_ERROR\";\n readonly isRecoverable = true;\n\n static missingToken(): ConfigError {\n return new ConfigError(\"API token not configured\", [\n \"Set via CLI flag: --token <token>\",\n \"Set via environment: export FORGE_API_TOKEN=<token>\",\n \"Set via config: forge-cli config set YOUR_TOKEN\",\n ]);\n }\n}\n\n// ── Validation Errors ────────────────────────────────\n\nexport class ValidationError extends CliError {\n readonly code = \"VALIDATION_ERROR\";\n readonly isRecoverable = true;\n\n constructor(\n message: string,\n public readonly field?: string,\n hints?: string[],\n cause?: unknown,\n ) {\n super(message, hints, cause);\n }\n\n override toJSON() {\n return { ...super.toJSON(), field: this.field };\n }\n\n static required(field: string, hints?: string[]): ValidationError {\n return new ValidationError(`${field} is required`, field, hints);\n }\n}\n\n// ── API Errors ───────────────────────────────────────\n\nexport class ApiError extends CliError {\n readonly code = \"API_ERROR\";\n readonly isRecoverable: boolean;\n\n constructor(\n message: string,\n public readonly statusCode?: number,\n hints?: string[],\n cause?: unknown,\n ) {\n super(message, hints ?? getApiErrorHints(statusCode), cause);\n this.isRecoverable = statusCode === undefined || (statusCode >= 500 && statusCode < 600);\n }\n\n override toJSON() {\n return { ...super.toJSON(), statusCode: this.statusCode };\n }\n\n static fromForgeError(error: unknown): ApiError {\n if (error instanceof Error && \"statusCode\" in error) {\n const e = error as Error & { statusCode?: number };\n return new ApiError(e.message, e.statusCode, undefined, e);\n }\n if (error instanceof Error) {\n return new ApiError(error.message, undefined, undefined, error);\n }\n return new ApiError(String(error));\n }\n}\n\nfunction getApiErrorHints(statusCode?: number): string[] {\n if (statusCode === 401) {\n return [\"Check that your API token is valid\", \"Set via: export FORGE_API_TOKEN=<token>\"];\n }\n if (statusCode === 403) {\n return [\"You may not have permission to access this resource\"];\n }\n if (statusCode === 404) {\n return [\n \"The resource may not exist\",\n \"Verify the ID is correct\",\n \"Use the list command to find valid IDs\",\n ];\n }\n if (statusCode === 429) {\n return [\"Too many requests — wait before retrying\"];\n }\n if (statusCode !== undefined && statusCode >= 500) {\n return [\"Server error — try again later\"];\n }\n return [];\n}\n\n// ── Type Guards ──────────────────────────────────────\n\nexport function isCliError(error: unknown): error is CliError {\n return error instanceof CliError;\n}\n","/**\n * Config loading for forge-cli.\n *\n * Resolution priority (highest to lowest):\n * 1. CLI arguments (--token)\n * 2. Environment variable (FORGE_API_TOKEN)\n * 3. Config file (XDG-compliant)\n */\n\nimport { createConfigStore, getToken } from \"@studiometa/forge-api\";\n\nexport interface ForgeCliConfig {\n /** Forge API token */\n apiToken: string | undefined;\n}\n\n/**\n * Resolve config from multiple sources with priority order.\n */\nexport function getConfig(\n cliOptions?: Record<string, string | boolean | string[]>,\n): ForgeCliConfig {\n // 1. CLI argument --token\n const cliToken = cliOptions?.token;\n\n // 2. Environment variable / config file (handled by getToken)\n const storedToken = getToken(createConfigStore());\n\n return {\n apiToken: typeof cliToken === \"string\" ? cliToken : (storedToken ?? undefined),\n };\n}\n\nexport { createConfigStore, getToken, setToken, deleteToken } from \"@studiometa/forge-api\";\n","/**\n * ANSI color utilities using native Node.js.\n * Provides terminal colors without external dependencies.\n */\n\n// ANSI escape codes\nconst RESET = \"\\x1b[0m\";\nconst BOLD = \"\\x1b[1m\";\nconst DIM = \"\\x1b[2m\";\n\n// Foreground colors\nconst FG_RED = \"\\x1b[31m\";\nconst FG_GREEN = \"\\x1b[32m\";\nconst FG_YELLOW = \"\\x1b[33m\";\nconst FG_CYAN = \"\\x1b[36m\";\nconst FG_GRAY = \"\\x1b[90m\";\n\n// Colors enabled by default, disabled by NO_COLOR env var\nlet colorEnabled = process.env.NO_COLOR === undefined;\n\nexport function setColorEnabled(enabled: boolean): void {\n colorEnabled = enabled;\n}\n\nexport function isColorEnabled(): boolean {\n return colorEnabled;\n}\n\nfunction colorize(text: string, code: string): string {\n if (!colorEnabled) return text;\n return `${code}${text}${RESET}`;\n}\n\nexport const colors = {\n reset: (text: string) => (colorEnabled ? `${RESET}${text}` : text),\n bold: (text: string) => colorize(text, BOLD),\n dim: (text: string) => colorize(text, DIM),\n red: (text: string) => colorize(text, FG_RED),\n green: (text: string) => colorize(text, FG_GREEN),\n yellow: (text: string) => colorize(text, FG_YELLOW),\n cyan: (text: string) => colorize(text, FG_CYAN),\n gray: (text: string) => colorize(text, FG_GRAY),\n};\n","import type { OutputFormat } from \"./types.ts\";\n\nimport { colors } from \"./utils/colors.ts\";\n\n/**\n * Output formatter for CLI commands.\n * Supports human-readable, JSON, and table formats.\n */\nexport class OutputFormatter {\n constructor(\n private format: OutputFormat = \"human\",\n private noColor: boolean = false,\n ) {}\n\n /**\n * Returns true when the current format is JSON.\n */\n isJson(): boolean {\n return this.format === \"json\";\n }\n\n /**\n * Output data in the configured format.\n * Use format='json' for AI agents and structured data.\n */\n output(data: unknown): void {\n switch (this.format) {\n case \"json\":\n console.log(JSON.stringify(data, null, 2));\n break;\n case \"table\":\n this.outputTable(data);\n break;\n case \"human\":\n default:\n console.log(data);\n break;\n }\n }\n\n /**\n * Output a list with a human-readable one-liner per item and a table for table format.\n * Falls back to JSON for json format.\n *\n * @param data - Array of items to display\n * @param columns - Ordered list of field names to include in human/table output\n * @param emptyMessage - Message shown when data is empty (human format only)\n * @param lineFormat - Optional custom line formatter for human format\n */\n outputList<T extends object>(\n data: T[],\n columns: (keyof T & string)[],\n emptyMessage: string,\n lineFormat?: (item: T) => string,\n ): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify(data, null, 2));\n return;\n }\n\n if (this.format === \"table\") {\n this.outputTable(data.map((item) => Object.fromEntries(columns.map((c) => [c, item[c]]))));\n return;\n }\n\n // human\n if (data.length === 0) {\n console.log(colors.cyan(emptyMessage));\n return;\n }\n\n if (lineFormat) {\n for (const item of data) {\n console.log(lineFormat(item));\n }\n return;\n }\n\n // Default: padded columns\n const widths = columns.map((col) =>\n Math.max(\n col.length,\n ...data.map((item) => String((item as Record<string, unknown>)[col] ?? \"\").length),\n ),\n );\n for (const item of data) {\n const row = item as Record<string, unknown>;\n const line = columns.map((col, i) => String(row[col] ?? \"\").padEnd(widths[i])).join(\" \");\n console.log(line.trimEnd());\n }\n }\n\n /**\n * Output a single resource in human-readable format.\n * For json format, uses JSON.stringify. For table format, uses a two-column key/value table.\n *\n * @param data - Object to display\n * @param fields - Ordered list of fields to display (defaults to all keys)\n */\n outputOne<T extends object>(data: T, fields?: (keyof T & string)[]): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify(data, null, 2));\n return;\n }\n\n const record = data as Record<string, unknown>;\n const keys = fields ?? (Object.keys(record) as (keyof T & string)[]);\n\n if (this.format === \"table\") {\n const rows = keys.map((k) => ({ field: k, value: String(record[k] ?? \"\") }));\n this.outputTable(rows);\n return;\n }\n\n // human: key: value pairs\n const keyWidth = Math.max(...keys.map((k) => k.length));\n for (const key of keys) {\n const value = record[key];\n const valueStr =\n value !== null && typeof value === \"object\" ? JSON.stringify(value) : String(value ?? \"\");\n console.log(`${colors.cyan(key.padEnd(keyWidth))} ${valueStr}`);\n }\n }\n\n success(message: string): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify({ status: \"success\", message }));\n } else {\n console.log(colors.green(`✓ ${message}`));\n }\n }\n\n error(message: string, details?: unknown): void {\n if (this.format === \"json\") {\n console.error(JSON.stringify({ status: \"error\", message, details }));\n } else {\n console.error(colors.red(`✗ ${message}`));\n if (details !== undefined) {\n console.error(details);\n }\n }\n }\n\n warning(message: string): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify({ status: \"warning\", message }));\n } else {\n console.log(colors.yellow(`⚠ ${message}`));\n }\n }\n\n info(message: string): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify({ status: \"info\", message }));\n } else {\n console.log(colors.cyan(message));\n }\n }\n\n private outputTable(data: unknown): void {\n if (Array.isArray(data) && data.length > 0) {\n const headers = Object.keys(data[0] as Record<string, unknown>);\n const colWidths = headers.map((h) => {\n const maxDataWidth = Math.max(\n ...data.map((row) => String((row as Record<string, unknown>)[h] ?? \"\").length),\n );\n return Math.max(h.length, maxDataWidth);\n });\n\n // Header\n const headerRow = headers.map((h, i) => h.padEnd(colWidths[i])).join(\" | \");\n console.log(headerRow);\n console.log(colWidths.map((w) => \"-\".repeat(w)).join(\"-+-\"));\n\n // Rows\n for (const row of data) {\n const rowStr = headers\n .map((h, i) => String((row as Record<string, unknown>)[h] ?? \"\").padEnd(colWidths[i]))\n .join(\" | \");\n console.log(rowStr);\n }\n }\n }\n}\nexport const x = { a: 1, b: 2 };\n","/**\n * CLI execution context with dependency injection.\n *\n * Instead of hidden dependencies in command handlers, this module provides\n * explicit dependency passing for testability and transparency.\n */\n\nimport type { HttpClient } from \"@studiometa/forge-api\";\nimport type { ExecutorContext } from \"@studiometa/forge-core\";\n\nimport type { OutputFormat } from \"./types.ts\";\n\nimport { HttpClient as ForgeHttpClient } from \"@studiometa/forge-api\";\nimport { ConfigError } from \"./errors.ts\";\nimport { createConfigStore, getToken } from \"./config.ts\";\nimport { OutputFormatter } from \"./output.ts\";\n\nexport interface CommandOptions {\n [key: string]: string | boolean | string[] | undefined;\n format?: string;\n f?: string;\n token?: string;\n \"no-color\"?: boolean;\n}\n\n/**\n * Context containing all dependencies needed by command handlers.\n */\nexport interface CommandContext {\n /** Output formatter for the current format */\n readonly formatter: OutputFormatter;\n /** Raw CLI options */\n readonly options: CommandOptions;\n /** Create an ExecutorContext from this command context */\n createExecutorContext(token: string): ExecutorContext;\n /** Resolve the API token or throw ConfigError */\n getToken(): string;\n}\n\n/**\n * Creates a command context from CLI options.\n */\nexport function createContext(options: CommandOptions = {}): CommandContext {\n const format = (options.format ?? options.f ?? \"human\") as OutputFormat;\n const noColor = options[\"no-color\"] === true;\n const formatter = new OutputFormatter(format, noColor);\n\n return {\n formatter,\n options,\n\n createExecutorContext(token: string): ExecutorContext {\n const client = new ForgeHttpClient({ token }) as unknown as HttpClient;\n return { client };\n },\n\n getToken(): string {\n // 1. CLI arg\n if (typeof options.token === \"string\" && options.token) {\n return options.token;\n }\n // 2. Env var / config file\n const stored = getToken(createConfigStore());\n if (stored) {\n return stored;\n }\n // 3. Not found — throw\n throw ConfigError.missingToken();\n },\n };\n}\n\n/**\n * Creates a test context for unit tests.\n *\n * @example\n * ```typescript\n * const ctx = createTestContext({\n * mockClient: { get: async () => ({ servers: [] }) } as never,\n * });\n * ```\n */\nexport function createTestContext(overrides: {\n options?: CommandOptions;\n formatter?: OutputFormatter;\n token?: string;\n mockClient?: HttpClient;\n}): CommandContext {\n const opts: CommandOptions = overrides.options ?? {\n format: \"json\",\n \"no-color\": true,\n };\n const format = (opts.format ?? \"json\") as OutputFormat;\n const formatter = overrides.formatter ?? new OutputFormatter(format, true);\n\n return {\n formatter,\n options: opts,\n createExecutorContext(_token: string): ExecutorContext {\n if (!overrides.mockClient) {\n throw new Error(\n \"createTestContext: provide mockClient to use createExecutorContext in tests\",\n );\n }\n return { client: overrides.mockClient };\n },\n getToken(): string {\n if (overrides.token) return overrides.token;\n if (typeof opts.token === \"string\") return opts.token;\n return \"test-token\";\n },\n };\n}\n","/**\n * Centralized error handling for forge-cli.\n */\n\nimport type { OutputFormatter } from \"./output.ts\";\n\nimport { ApiError, CliError, ConfigError, ValidationError, isCliError } from \"./errors.ts\";\n\n/**\n * Exit codes for different error categories.\n */\nexport const ExitCode = {\n SUCCESS: 0,\n GENERAL_ERROR: 1,\n AUTHENTICATION_ERROR: 2,\n VALIDATION_ERROR: 3,\n CONFIG_ERROR: 4,\n NOT_FOUND_ERROR: 5,\n} as const;\n\nexport type ExitCode = (typeof ExitCode)[keyof typeof ExitCode];\n\n/**\n * Determine the appropriate exit code for an error.\n */\nexport function getExitCode(error: unknown): ExitCode {\n if (error instanceof ValidationError) {\n return ExitCode.VALIDATION_ERROR;\n }\n if (error instanceof ApiError) {\n if (error.statusCode === 401) return ExitCode.AUTHENTICATION_ERROR;\n if (error.statusCode === 404) return ExitCode.NOT_FOUND_ERROR;\n }\n if (isCliError(error) && error.code === \"CONFIG_ERROR\") {\n return ExitCode.CONFIG_ERROR;\n }\n return ExitCode.GENERAL_ERROR;\n}\n\n/**\n * Central error handler for all commands.\n */\nexport function handleError(\n error: unknown,\n formatter: OutputFormatter,\n options?: { exit?: boolean },\n): ExitCode {\n const shouldExit = options?.exit ?? true;\n\n let cliError: CliError;\n if (isCliError(error)) {\n cliError = error;\n } else {\n cliError = ApiError.fromForgeError(error);\n }\n\n // Output error in appropriate format\n const opts = formatter as unknown as { format?: string };\n if (opts.format === \"json\") {\n formatter.output(cliError.toJSON());\n } else {\n formatter.error(cliError.toFormattedMessage());\n }\n\n const exitCode = getExitCode(cliError);\n\n if (shouldExit) {\n process.exit(exitCode);\n }\n\n return exitCode;\n}\n\n/**\n * Wraps a command function with automatic error handling.\n */\nexport async function runCommand<T>(\n fn: () => Promise<T>,\n formatter: OutputFormatter,\n): Promise<T | undefined> {\n try {\n return await fn();\n } catch (error) {\n handleError(error, formatter);\n return undefined; // unreachable due to process.exit\n }\n}\n\n/**\n * Exits with a validation error for a missing required argument.\n */\nexport function exitWithValidationError(\n field: string,\n usage: string,\n formatter: OutputFormatter,\n): never {\n const error = ValidationError.required(field, [`Usage: ${usage}`]);\n handleError(error, formatter);\n // Unreachable in production\n throw error;\n}\n\n/**\n * Exits with a config error when token is missing.\n */\nexport function exitWithConfigError(formatter: OutputFormatter): never {\n const error = ConfigError.missingToken();\n handleError(error, formatter);\n throw error;\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAsB,WAAt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