trinity-method-sdk 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 (191) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/LICENSE +21 -0
  3. package/README.md +555 -0
  4. package/dist/cli/commands/deploy/agents.d.ts +14 -0
  5. package/dist/cli/commands/deploy/agents.js +59 -0
  6. package/dist/cli/commands/deploy/ci-cd.d.ts +13 -0
  7. package/dist/cli/commands/deploy/ci-cd.js +50 -0
  8. package/dist/cli/commands/deploy/claude-setup.d.ts +17 -0
  9. package/dist/cli/commands/deploy/claude-setup.js +91 -0
  10. package/dist/cli/commands/deploy/configuration.d.ts +13 -0
  11. package/dist/cli/commands/deploy/configuration.js +215 -0
  12. package/dist/cli/commands/deploy/directories.d.ts +12 -0
  13. package/dist/cli/commands/deploy/directories.js +38 -0
  14. package/dist/cli/commands/deploy/gitignore.d.ts +12 -0
  15. package/dist/cli/commands/deploy/gitignore.js +53 -0
  16. package/dist/cli/commands/deploy/index.d.ts +38 -0
  17. package/dist/cli/commands/deploy/index.js +156 -0
  18. package/dist/cli/commands/deploy/knowledge-base.d.ts +16 -0
  19. package/dist/cli/commands/deploy/knowledge-base.js +75 -0
  20. package/dist/cli/commands/deploy/linting.d.ts +18 -0
  21. package/dist/cli/commands/deploy/linting.js +51 -0
  22. package/dist/cli/commands/deploy/metrics.d.ts +13 -0
  23. package/dist/cli/commands/deploy/metrics.js +34 -0
  24. package/dist/cli/commands/deploy/pre-flight.d.ts +13 -0
  25. package/dist/cli/commands/deploy/pre-flight.js +29 -0
  26. package/dist/cli/commands/deploy/root-files.d.ts +16 -0
  27. package/dist/cli/commands/deploy/root-files.js +178 -0
  28. package/dist/cli/commands/deploy/sdk-install.d.ts +12 -0
  29. package/dist/cli/commands/deploy/sdk-install.js +57 -0
  30. package/dist/cli/commands/deploy/summary.d.ts +14 -0
  31. package/dist/cli/commands/deploy/summary.js +130 -0
  32. package/dist/cli/commands/deploy/templates.d.ts +14 -0
  33. package/dist/cli/commands/deploy/templates.js +84 -0
  34. package/dist/cli/commands/deploy/types.d.ts +39 -0
  35. package/dist/cli/commands/deploy/types.js +5 -0
  36. package/dist/cli/commands/update/agents.d.ts +14 -0
  37. package/dist/cli/commands/update/agents.js +31 -0
  38. package/dist/cli/commands/update/backup.d.ts +31 -0
  39. package/dist/cli/commands/update/backup.js +97 -0
  40. package/dist/cli/commands/update/commands.d.ts +14 -0
  41. package/dist/cli/commands/update/commands.js +75 -0
  42. package/dist/cli/commands/update/index.d.ts +15 -0
  43. package/dist/cli/commands/update/index.js +118 -0
  44. package/dist/cli/commands/update/knowledge-base.d.ts +14 -0
  45. package/dist/cli/commands/update/knowledge-base.js +38 -0
  46. package/dist/cli/commands/update/pre-flight.d.ts +13 -0
  47. package/dist/cli/commands/update/pre-flight.js +37 -0
  48. package/dist/cli/commands/update/summary.d.ts +20 -0
  49. package/dist/cli/commands/update/summary.js +47 -0
  50. package/dist/cli/commands/update/templates.d.ts +14 -0
  51. package/dist/cli/commands/update/templates.js +25 -0
  52. package/dist/cli/commands/update/types.d.ts +13 -0
  53. package/dist/cli/commands/update/types.js +7 -0
  54. package/dist/cli/commands/update/utils.d.ts +11 -0
  55. package/dist/cli/commands/update/utils.js +19 -0
  56. package/dist/cli/commands/update/verification.d.ts +20 -0
  57. package/dist/cli/commands/update/verification.js +54 -0
  58. package/dist/cli/commands/update/version.d.ts +18 -0
  59. package/dist/cli/commands/update/version.js +36 -0
  60. package/dist/cli/commands/update.d.ts +7 -0
  61. package/dist/cli/commands/update.js +7 -0
  62. package/dist/cli/index.d.ts +3 -0
  63. package/dist/cli/index.js +36 -0
  64. package/dist/cli/types.d.ts +77 -0
  65. package/dist/cli/types.js +5 -0
  66. package/dist/cli/utils/deploy-ci.d.ts +22 -0
  67. package/dist/cli/utils/deploy-ci.js +138 -0
  68. package/dist/cli/utils/deploy-linting.d.ts +3 -0
  69. package/dist/cli/utils/deploy-linting.js +136 -0
  70. package/dist/cli/utils/detect-stack.d.ts +3 -0
  71. package/dist/cli/utils/detect-stack.js +270 -0
  72. package/dist/cli/utils/error-classes.d.ts +63 -0
  73. package/dist/cli/utils/error-classes.js +84 -0
  74. package/dist/cli/utils/error-handler.d.ts +59 -0
  75. package/dist/cli/utils/error-handler.js +127 -0
  76. package/dist/cli/utils/errors.d.ts +52 -0
  77. package/dist/cli/utils/errors.js +102 -0
  78. package/dist/cli/utils/get-sdk-path.d.ts +18 -0
  79. package/dist/cli/utils/get-sdk-path.js +31 -0
  80. package/dist/cli/utils/inject-dependencies.d.ts +2 -0
  81. package/dist/cli/utils/inject-dependencies.js +55 -0
  82. package/dist/cli/utils/linting-tools.d.ts +8 -0
  83. package/dist/cli/utils/linting-tools.js +206 -0
  84. package/dist/cli/utils/metrics/code-quality.d.ts +32 -0
  85. package/dist/cli/utils/metrics/code-quality.js +122 -0
  86. package/dist/cli/utils/metrics/dependency-parser.d.ts +21 -0
  87. package/dist/cli/utils/metrics/dependency-parser.js +153 -0
  88. package/dist/cli/utils/metrics/file-complexity.d.ts +26 -0
  89. package/dist/cli/utils/metrics/file-complexity.js +77 -0
  90. package/dist/cli/utils/metrics/framework-detector.d.ts +17 -0
  91. package/dist/cli/utils/metrics/framework-detector.js +120 -0
  92. package/dist/cli/utils/metrics/git-metrics.d.ts +30 -0
  93. package/dist/cli/utils/metrics/git-metrics.js +83 -0
  94. package/dist/cli/utils/metrics/index.d.ts +28 -0
  95. package/dist/cli/utils/metrics/index.js +100 -0
  96. package/dist/cli/utils/template-processor.d.ts +10 -0
  97. package/dist/cli/utils/template-processor.js +188 -0
  98. package/dist/cli/utils/validate-path.d.ts +80 -0
  99. package/dist/cli/utils/validate-path.js +180 -0
  100. package/dist/index.d.ts +6 -0
  101. package/dist/index.js +8 -0
  102. package/dist/templates/agents/aj-team/apo-documentation-specialist.md.template +572 -0
  103. package/dist/templates/agents/aj-team/bas-quality-gate.md.template +906 -0
  104. package/dist/templates/agents/aj-team/bon-dependency-manager.md.template +636 -0
  105. package/dist/templates/agents/aj-team/cap-configuration-specialist.md.template +670 -0
  106. package/dist/templates/agents/aj-team/dra-code-reviewer.md.template +768 -0
  107. package/dist/templates/agents/aj-team/kil-task-executor.md.template +764 -0
  108. package/dist/templates/agents/aj-team/uro-refactoring-specialist.md.template +759 -0
  109. package/dist/templates/agents/audit/juno-auditor.md.template +447 -0
  110. package/dist/templates/agents/deployment/ein-cicd.md.template +694 -0
  111. package/dist/templates/agents/deployment/ino-context.md.template +733 -0
  112. package/dist/templates/agents/deployment/tan-structure.md.template +661 -0
  113. package/dist/templates/agents/deployment/zen-knowledge.md.template +451 -0
  114. package/dist/templates/agents/leadership/aj-cc.md.template +462 -0
  115. package/dist/templates/agents/leadership/aj-maestro.md.template +943 -0
  116. package/dist/templates/agents/leadership/aly-cto.md.template +407 -0
  117. package/dist/templates/agents/planning/eus-decomposer.md.template +496 -0
  118. package/dist/templates/agents/planning/mon-requirements.md.template +323 -0
  119. package/dist/templates/agents/planning/ror-design.md.template +465 -0
  120. package/dist/templates/agents/planning/tra-planner.md.template +432 -0
  121. package/dist/templates/ci/cd.yml.template +175 -0
  122. package/dist/templates/ci/ci.yml.template +196 -0
  123. package/dist/templates/ci/generic-ci.yml +115 -0
  124. package/dist/templates/ci/github-actions.yml +86 -0
  125. package/dist/templates/ci/gitlab-ci.yml +103 -0
  126. package/dist/templates/claude/EMPLOYEE-DIRECTORY.md.template +545 -0
  127. package/dist/templates/documentation/ROOT-README.md.template +307 -0
  128. package/dist/templates/documentation/SUBDIRECTORY-README.md.template +261 -0
  129. package/dist/templates/investigations/bug.md.template +484 -0
  130. package/dist/templates/investigations/feature.md.template +564 -0
  131. package/dist/templates/investigations/performance.md.template +625 -0
  132. package/dist/templates/investigations/security.md.template +714 -0
  133. package/dist/templates/investigations/technical.md.template +433 -0
  134. package/dist/templates/knowledge-base/AI-DEVELOPMENT-GUIDE.md.template +957 -0
  135. package/dist/templates/knowledge-base/ARCHITECTURE.md.template +452 -0
  136. package/dist/templates/knowledge-base/CODING-PRINCIPLES.md.template +750 -0
  137. package/dist/templates/knowledge-base/DOCUMENTATION-CRITERIA.md.template +1118 -0
  138. package/dist/templates/knowledge-base/ISSUES.md.template +539 -0
  139. package/dist/templates/knowledge-base/TESTING-PRINCIPLES.md.template +894 -0
  140. package/dist/templates/knowledge-base/Technical-Debt.md.template +640 -0
  141. package/dist/templates/knowledge-base/To-do.md.template +407 -0
  142. package/dist/templates/knowledge-base/Trinity.md.template +464 -0
  143. package/dist/templates/linting/flutter/.pre-commit-config.yaml.template +27 -0
  144. package/dist/templates/linting/flutter/analysis_options.yaml.template +26 -0
  145. package/dist/templates/linting/nodejs/.eslintrc-commonjs.json.template +19 -0
  146. package/dist/templates/linting/nodejs/.eslintrc-esm.json.template +19 -0
  147. package/dist/templates/linting/nodejs/.eslintrc-typescript.json.template +22 -0
  148. package/dist/templates/linting/nodejs/.pre-commit-config.yaml.template +51 -0
  149. package/dist/templates/linting/nodejs/.prettierrc.json.template +10 -0
  150. package/dist/templates/linting/python/.flake8.template +16 -0
  151. package/dist/templates/linting/python/.pre-commit-config.yaml.template +30 -0
  152. package/dist/templates/linting/python/pyproject.toml.template +38 -0
  153. package/dist/templates/linting/rust/.pre-commit-config.yaml.template +28 -0
  154. package/dist/templates/linting/rust/clippy.toml.template +14 -0
  155. package/dist/templates/linting/rust/rustfmt.toml.template +12 -0
  156. package/dist/templates/root/CLAUDE.md.template +65 -0
  157. package/dist/templates/root/TRINITY.md.template +52 -0
  158. package/dist/templates/shared/claude-commands/trinity-agents.md.template +168 -0
  159. package/dist/templates/shared/claude-commands/trinity-audit.md.template +646 -0
  160. package/dist/templates/shared/claude-commands/trinity-changelog.md.template +624 -0
  161. package/dist/templates/shared/claude-commands/trinity-continue.md.template +549 -0
  162. package/dist/templates/shared/claude-commands/trinity-create-investigation.md.template +232 -0
  163. package/dist/templates/shared/claude-commands/trinity-decompose.md.template +181 -0
  164. package/dist/templates/shared/claude-commands/trinity-design.md.template +347 -0
  165. package/dist/templates/shared/claude-commands/trinity-docs.md.template +2093 -0
  166. package/dist/templates/shared/claude-commands/trinity-end.md.template +397 -0
  167. package/dist/templates/shared/claude-commands/trinity-init.md.template +606 -0
  168. package/dist/templates/shared/claude-commands/trinity-investigate-templates.md.template +725 -0
  169. package/dist/templates/shared/claude-commands/trinity-orchestrate.md.template +1061 -0
  170. package/dist/templates/shared/claude-commands/trinity-plan-investigation.md.template +135 -0
  171. package/dist/templates/shared/claude-commands/trinity-plan.md.template +201 -0
  172. package/dist/templates/shared/claude-commands/trinity-readme.md.template +1971 -0
  173. package/dist/templates/shared/claude-commands/trinity-requirements.md.template +148 -0
  174. package/dist/templates/shared/claude-commands/trinity-start.md.template +268 -0
  175. package/dist/templates/shared/claude-commands/trinity-verify.md.template +453 -0
  176. package/dist/templates/shared/claude-commands/trinity-workorder.md.template +249 -0
  177. package/dist/templates/source/base-CLAUDE.md.template +310 -0
  178. package/dist/templates/source/flutter-CLAUDE.md.template +593 -0
  179. package/dist/templates/source/nodejs-CLAUDE.md.template +531 -0
  180. package/dist/templates/source/python-CLAUDE.md.template +510 -0
  181. package/dist/templates/source/react-CLAUDE.md.template +513 -0
  182. package/dist/templates/source/rust-CLAUDE.md.template +653 -0
  183. package/dist/templates/source/tests-CLAUDE.md.template +432 -0
  184. package/dist/templates/trinity/CLAUDE.md.template +372 -0
  185. package/dist/templates/work-orders/ANALYSIS-TEMPLATE.md.template +276 -0
  186. package/dist/templates/work-orders/AUDIT-TEMPLATE.md.template +262 -0
  187. package/dist/templates/work-orders/IMPLEMENTATION-TEMPLATE.md.template +260 -0
  188. package/dist/templates/work-orders/INVESTIGATION-TEMPLATE.md.template +206 -0
  189. package/dist/templates/work-orders/PATTERN-TEMPLATE.md.template +320 -0
  190. package/dist/templates/work-orders/VERIFICATION-TEMPLATE.md.template +273 -0
  191. package/package.json +94 -0
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Custom error classes for Trinity CLI
3
+ * Provides domain-specific error types with codes and context
4
+ * @module cli/utils/error-classes
5
+ */
6
+ /**
7
+ * Base error class for Trinity CLI
8
+ * All custom errors extend this class
9
+ */
10
+ export class TrinityCLIError extends Error {
11
+ /**
12
+ * Create a Trinity CLI error
13
+ * @param message - Human-readable error message
14
+ * @param code - Error code for categorization (e.g., 'DEPLOYMENT_ERROR')
15
+ * @param exitCode - Process exit code (default: 1)
16
+ * @param context - Additional context for debugging
17
+ */
18
+ constructor(message, code, exitCode = 1, context) {
19
+ super(message);
20
+ this.code = code;
21
+ this.exitCode = exitCode;
22
+ this.context = context;
23
+ this.name = this.constructor.name;
24
+ // Fix prototype chain for instanceof checks in Node.js 22+
25
+ Object.setPrototypeOf(this, new.target.prototype);
26
+ // Capture stack trace
27
+ if (Error.captureStackTrace) {
28
+ Error.captureStackTrace(this, this.constructor);
29
+ }
30
+ }
31
+ /**
32
+ * Format error for user display
33
+ * @returns Formatted error message with code
34
+ */
35
+ format() {
36
+ return `Error ${this.code}: ${this.message}`;
37
+ }
38
+ }
39
+ /**
40
+ * User input validation errors
41
+ * Used when user provides invalid input or options
42
+ */
43
+ export class ValidationError extends TrinityCLIError {
44
+ constructor(message, context) {
45
+ super(message, 'VALIDATION_ERROR', 1, context);
46
+ }
47
+ }
48
+ /**
49
+ * Filesystem operation errors
50
+ * Used when file/directory operations fail
51
+ */
52
+ export class FilesystemError extends TrinityCLIError {
53
+ constructor(message, context) {
54
+ super(message, 'FILESYSTEM_ERROR', 1, context);
55
+ }
56
+ }
57
+ /**
58
+ * Deployment errors
59
+ * Used when Trinity deployment fails
60
+ */
61
+ export class DeploymentError extends TrinityCLIError {
62
+ constructor(message, context) {
63
+ super(message, 'DEPLOYMENT_ERROR', 1, context);
64
+ }
65
+ }
66
+ /**
67
+ * Update errors
68
+ * Used when Trinity update fails
69
+ */
70
+ export class UpdateError extends TrinityCLIError {
71
+ constructor(message, context) {
72
+ super(message, 'UPDATE_ERROR', 1, context);
73
+ }
74
+ }
75
+ /**
76
+ * Configuration errors
77
+ * Used when configuration is invalid or missing
78
+ */
79
+ export class ConfigurationError extends TrinityCLIError {
80
+ constructor(message, context) {
81
+ super(message, 'CONFIG_ERROR', 1, context);
82
+ }
83
+ }
84
+ //# sourceMappingURL=error-classes.js.map
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Centralized error handler with cleanup mechanisms
3
+ * Provides graceful error handling and resource cleanup
4
+ * @module cli/utils/error-handler
5
+ */
6
+ /**
7
+ * Centralized error handler for Trinity CLI
8
+ * Manages cleanup tasks and provides graceful error handling
9
+ */
10
+ declare class ErrorHandler {
11
+ private cleanupTasks;
12
+ /**
13
+ * Check if debug mode is enabled
14
+ * Reads from DEBUG environment variable at runtime
15
+ */
16
+ private get debugMode();
17
+ /**
18
+ * Register a cleanup task to run before process exit
19
+ * Cleanup tasks are executed in registration order
20
+ * @param name - Human-readable name for logging
21
+ * @param handler - Cleanup function (sync or async)
22
+ */
23
+ registerCleanup(name: string, handler: () => Promise<void> | void): void;
24
+ /**
25
+ * Run all registered cleanup tasks
26
+ * Failures in cleanup tasks are logged but don't stop other tasks
27
+ * @private
28
+ */
29
+ private runCleanup;
30
+ /**
31
+ * Handle error and exit gracefully
32
+ * Runs cleanup tasks, displays error, and exits with appropriate code
33
+ * @param error - Error to handle (any type)
34
+ * @returns Never returns (process exits)
35
+ */
36
+ handle(error: unknown): Promise<never>;
37
+ /**
38
+ * Wrap async function with error handling
39
+ * Catches errors and passes them to the error handler
40
+ * @param fn - Async function to wrap
41
+ * @returns Wrapped function with error handling
42
+ */
43
+ wrap<T extends unknown[], R>(fn: (...args: T) => Promise<R>): (...args: T) => Promise<R>;
44
+ /**
45
+ * Clear all registered cleanup tasks
46
+ * Useful for testing or when cleanup is handled externally
47
+ */
48
+ clearCleanup(): void;
49
+ }
50
+ export declare const errorHandler: ErrorHandler;
51
+ /**
52
+ * Handle error and exit gracefully
53
+ * Convenience function that calls errorHandler.handle()
54
+ * @param error - Error to handle
55
+ * @returns Never returns (process exits)
56
+ */
57
+ export declare function handleError(error: unknown): Promise<never>;
58
+ export {};
59
+ //# sourceMappingURL=error-handler.d.ts.map
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Centralized error handler with cleanup mechanisms
3
+ * Provides graceful error handling and resource cleanup
4
+ * @module cli/utils/error-handler
5
+ */
6
+ import chalk from 'chalk';
7
+ import { displayError, displayInfo, getErrorMessage } from './errors.js';
8
+ import { TrinityCLIError } from './error-classes.js';
9
+ /**
10
+ * Centralized error handler for Trinity CLI
11
+ * Manages cleanup tasks and provides graceful error handling
12
+ */
13
+ class ErrorHandler {
14
+ constructor() {
15
+ this.cleanupTasks = [];
16
+ }
17
+ /**
18
+ * Check if debug mode is enabled
19
+ * Reads from DEBUG environment variable at runtime
20
+ */
21
+ get debugMode() {
22
+ return process.env.DEBUG === 'true';
23
+ }
24
+ /**
25
+ * Register a cleanup task to run before process exit
26
+ * Cleanup tasks are executed in registration order
27
+ * @param name - Human-readable name for logging
28
+ * @param handler - Cleanup function (sync or async)
29
+ */
30
+ registerCleanup(name, handler) {
31
+ this.cleanupTasks.push({ name, handler });
32
+ }
33
+ /**
34
+ * Run all registered cleanup tasks
35
+ * Failures in cleanup tasks are logged but don't stop other tasks
36
+ * @private
37
+ */
38
+ async runCleanup() {
39
+ if (this.cleanupTasks.length === 0)
40
+ return;
41
+ console.log(chalk.blue('\nCleaning up...'));
42
+ for (const task of this.cleanupTasks) {
43
+ try {
44
+ await task.handler();
45
+ console.log(chalk.gray(` ✓ ${task.name}`));
46
+ }
47
+ catch {
48
+ displayInfo(`Failed to cleanup: ${task.name}`);
49
+ }
50
+ }
51
+ this.cleanupTasks = [];
52
+ }
53
+ /**
54
+ * Handle error and exit gracefully
55
+ * Runs cleanup tasks, displays error, and exits with appropriate code
56
+ * @param error - Error to handle (any type)
57
+ * @returns Never returns (process exits)
58
+ */
59
+ async handle(error) {
60
+ // Run cleanup tasks first
61
+ await this.runCleanup();
62
+ // Handle Trinity CLI errors
63
+ if (error instanceof TrinityCLIError) {
64
+ displayError(error.format());
65
+ if (error.context && this.debugMode) {
66
+ console.error(chalk.gray('Context:'));
67
+ console.error(chalk.gray(JSON.stringify(error.context, null, 2)));
68
+ }
69
+ if (this.debugMode && error.stack) {
70
+ console.error(chalk.gray('\nStack trace:'));
71
+ console.error(chalk.gray(error.stack));
72
+ }
73
+ process.exit(error.exitCode);
74
+ }
75
+ // Handle standard Error instances
76
+ if (error instanceof Error) {
77
+ displayError(getErrorMessage(error));
78
+ if (this.debugMode && error.stack) {
79
+ console.error(chalk.gray('\nStack trace:'));
80
+ console.error(chalk.gray(error.stack));
81
+ }
82
+ process.exit(1);
83
+ }
84
+ // Handle unknown error types
85
+ displayError('Unknown error occurred');
86
+ console.error(chalk.gray(String(error)));
87
+ process.exit(1);
88
+ }
89
+ /**
90
+ * Wrap async function with error handling
91
+ * Catches errors and passes them to the error handler
92
+ * @param fn - Async function to wrap
93
+ * @returns Wrapped function with error handling
94
+ */
95
+ wrap(fn) {
96
+ return async (...args) => {
97
+ try {
98
+ return await fn(...args);
99
+ }
100
+ catch (error) {
101
+ await this.handle(error);
102
+ // TypeScript doesn't know handle() never returns (calls process.exit)
103
+ // This line is unreachable but satisfies the compiler
104
+ throw error;
105
+ }
106
+ };
107
+ }
108
+ /**
109
+ * Clear all registered cleanup tasks
110
+ * Useful for testing or when cleanup is handled externally
111
+ */
112
+ clearCleanup() {
113
+ this.cleanupTasks = [];
114
+ }
115
+ }
116
+ // Export singleton instance
117
+ export const errorHandler = new ErrorHandler();
118
+ /**
119
+ * Handle error and exit gracefully
120
+ * Convenience function that calls errorHandler.handle()
121
+ * @param error - Error to handle
122
+ * @returns Never returns (process exits)
123
+ */
124
+ export async function handleError(error) {
125
+ return errorHandler.handle(error);
126
+ }
127
+ //# sourceMappingURL=error-handler.js.map
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Error handling utilities for type-safe error management
3
+ * @module cli/utils/errors
4
+ */
5
+ /**
6
+ * Error severity levels for display formatting
7
+ */
8
+ export declare enum ErrorSeverity {
9
+ ERROR = "error",
10
+ WARNING = "warning",
11
+ INFO = "info"
12
+ }
13
+ /**
14
+ * Options for error display customization
15
+ */
16
+ export interface ErrorDisplayOptions {
17
+ severity?: ErrorSeverity;
18
+ prefix?: string;
19
+ showStack?: boolean;
20
+ }
21
+ /**
22
+ * Type guard to check if an unknown value is an Error instance
23
+ */
24
+ export declare function isError(error: unknown): error is Error;
25
+ /**
26
+ * Safely extract error message from unknown error value
27
+ */
28
+ export declare function getErrorMessage(error: unknown): string;
29
+ /**
30
+ * Safely extract error stack from unknown error value
31
+ */
32
+ export declare function getErrorStack(error: unknown): string | undefined;
33
+ /**
34
+ * Display error with consistent formatting and colors
35
+ *
36
+ * @param error - Error to display (Error instance, string, or unknown)
37
+ * @param options - Display customization options
38
+ */
39
+ export declare function displayError(error: unknown, options?: ErrorDisplayOptions): void;
40
+ /**
41
+ * Display warning message with yellow color and emoji
42
+ *
43
+ * @param message - Warning message to display
44
+ */
45
+ export declare function displayWarning(message: string): void;
46
+ /**
47
+ * Display informational message with blue color and emoji
48
+ *
49
+ * @param message - Info message to display
50
+ */
51
+ export declare function displayInfo(message: string): void;
52
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Error handling utilities for type-safe error management
3
+ * @module cli/utils/errors
4
+ */
5
+ import chalk from 'chalk';
6
+ /**
7
+ * Error severity levels for display formatting
8
+ */
9
+ export var ErrorSeverity;
10
+ (function (ErrorSeverity) {
11
+ ErrorSeverity["ERROR"] = "error";
12
+ ErrorSeverity["WARNING"] = "warning";
13
+ ErrorSeverity["INFO"] = "info";
14
+ })(ErrorSeverity || (ErrorSeverity = {}));
15
+ /**
16
+ * Type guard to check if an unknown value is an Error instance
17
+ */
18
+ export function isError(error) {
19
+ return error instanceof Error;
20
+ }
21
+ /**
22
+ * Safely extract error message from unknown error value
23
+ */
24
+ export function getErrorMessage(error) {
25
+ if (isError(error)) {
26
+ return error.message;
27
+ }
28
+ if (typeof error === 'string') {
29
+ return error;
30
+ }
31
+ if (error && typeof error === 'object' && 'message' in error) {
32
+ return String(error.message);
33
+ }
34
+ return String(error);
35
+ }
36
+ /**
37
+ * Safely extract error stack from unknown error value
38
+ */
39
+ export function getErrorStack(error) {
40
+ if (isError(error)) {
41
+ return error.stack;
42
+ }
43
+ return undefined;
44
+ }
45
+ /**
46
+ * Display error with consistent formatting and colors
47
+ *
48
+ * @param error - Error to display (Error instance, string, or unknown)
49
+ * @param options - Display customization options
50
+ */
51
+ export function displayError(error, options = {}) {
52
+ const { severity = ErrorSeverity.ERROR, prefix, showStack = false } = options;
53
+ const message = getErrorMessage(error);
54
+ // Select emoji and color based on severity
55
+ let emoji;
56
+ let color;
57
+ switch (severity) {
58
+ case ErrorSeverity.ERROR:
59
+ emoji = '❌';
60
+ color = chalk.red;
61
+ break;
62
+ case ErrorSeverity.WARNING:
63
+ emoji = '⚠️';
64
+ color = chalk.yellow;
65
+ break;
66
+ case ErrorSeverity.INFO:
67
+ emoji = 'ℹ️';
68
+ color = chalk.blue;
69
+ break;
70
+ }
71
+ // Build output message
72
+ const parts = [emoji];
73
+ if (prefix) {
74
+ parts.push(prefix);
75
+ }
76
+ parts.push(message);
77
+ console.error(color(parts.join(' ')));
78
+ // Optionally display stack trace
79
+ if (showStack) {
80
+ const stack = getErrorStack(error);
81
+ if (stack) {
82
+ console.error(chalk.gray(stack));
83
+ }
84
+ }
85
+ }
86
+ /**
87
+ * Display warning message with yellow color and emoji
88
+ *
89
+ * @param message - Warning message to display
90
+ */
91
+ export function displayWarning(message) {
92
+ displayError(message, { severity: ErrorSeverity.WARNING });
93
+ }
94
+ /**
95
+ * Display informational message with blue color and emoji
96
+ *
97
+ * @param message - Info message to display
98
+ */
99
+ export function displayInfo(message) {
100
+ displayError(message, { severity: ErrorSeverity.INFO });
101
+ }
102
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Utility to get SDK path - works in both ESM runtime and CommonJS tests
3
+ * Automatically detects whether running from SDK root (dev/test) or installed package
4
+ */
5
+ /**
6
+ * Get the SDK root directory path
7
+ * Auto-detects: SDK root (tests/dev) or node_modules/@trinity-method/sdk (production)
8
+ */
9
+ export declare function getSDKPath(): Promise<string>;
10
+ /**
11
+ * Get the templates directory path
12
+ */
13
+ export declare function getTemplatesPath(): Promise<string>;
14
+ /**
15
+ * Get the package.json path
16
+ */
17
+ export declare function getPackageJsonPath(): Promise<string>;
18
+ //# sourceMappingURL=get-sdk-path.d.ts.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Utility to get SDK path - works in both ESM runtime and CommonJS tests
3
+ * Automatically detects whether running from SDK root (dev/test) or installed package
4
+ */
5
+ import path from 'path';
6
+ import fs from 'fs-extra';
7
+ /**
8
+ * Get the SDK root directory path
9
+ * Auto-detects: SDK root (tests/dev) or node_modules/@trinity-method/sdk (production)
10
+ */
11
+ export async function getSDKPath() {
12
+ // Check if dist/templates exists in current directory (running from SDK root)
13
+ if (await fs.pathExists(path.join(process.cwd(), 'dist/templates'))) {
14
+ return process.cwd();
15
+ }
16
+ // Otherwise assume installed as npm package
17
+ return path.join(process.cwd(), 'node_modules', '@trinity-method', 'sdk');
18
+ }
19
+ /**
20
+ * Get the templates directory path
21
+ */
22
+ export async function getTemplatesPath() {
23
+ return path.join(await getSDKPath(), 'dist/templates');
24
+ }
25
+ /**
26
+ * Get the package.json path
27
+ */
28
+ export async function getPackageJsonPath() {
29
+ return path.join(await getSDKPath(), 'package.json');
30
+ }
31
+ //# sourceMappingURL=get-sdk-path.js.map
@@ -0,0 +1,2 @@
1
+ export declare function injectLintingDependencies(dependencies: string[], scripts: Record<string, string>, framework: string): Promise<void>;
2
+ //# sourceMappingURL=inject-dependencies.d.ts.map
@@ -0,0 +1,55 @@
1
+ import fs from 'fs-extra';
2
+ import chalk from 'chalk';
3
+ import { validatePath } from './validate-path.js';
4
+ export async function injectLintingDependencies(dependencies, scripts, framework) {
5
+ if (framework === 'Node.js' || framework === 'React' || framework === 'Next.js') {
6
+ await injectNodeDependencies(dependencies, scripts);
7
+ }
8
+ else if (framework === 'Python') {
9
+ await injectPythonDependencies(dependencies);
10
+ }
11
+ // Rust and Flutter have built-in tools, no injection needed
12
+ }
13
+ async function injectNodeDependencies(dependencies, scripts) {
14
+ const packageJsonPath = 'package.json';
15
+ if (!(await fs.pathExists(packageJsonPath))) {
16
+ console.warn(chalk.yellow(' Warning: package.json not found, skipping dependency injection'));
17
+ return;
18
+ }
19
+ const packageJson = await fs.readJson(packageJsonPath);
20
+ // Add devDependencies
21
+ packageJson.devDependencies = packageJson.devDependencies || {};
22
+ dependencies.forEach((dep) => {
23
+ // Handle scoped packages like @typescript-eslint/parser@^6.7.0
24
+ const lastAtIndex = dep.lastIndexOf('@');
25
+ const name = dep.substring(0, lastAtIndex);
26
+ const version = dep.substring(lastAtIndex + 1);
27
+ packageJson.devDependencies[name] = version;
28
+ });
29
+ // Add Scripts
30
+ packageJson.scripts = packageJson.scripts || {};
31
+ Object.entries(scripts).forEach(([name, command]) => {
32
+ if (!packageJson.scripts[name]) {
33
+ packageJson.scripts[name] = command;
34
+ }
35
+ });
36
+ // Write back with formatting
37
+ await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
38
+ }
39
+ async function injectPythonDependencies(dependencies) {
40
+ const requirementsPath = 'requirements-dev.txt';
41
+ // Create or append to requirements-dev.txt
42
+ let content = '';
43
+ if (await fs.pathExists(requirementsPath)) {
44
+ content = await fs.readFile(requirementsPath, 'utf8');
45
+ }
46
+ dependencies.forEach((dep) => {
47
+ if (!content.includes(dep.split('>=')[0])) {
48
+ content += `${dep}\n`;
49
+ }
50
+ });
51
+ // Validate destination path for security
52
+ const validatedPath = validatePath(requirementsPath);
53
+ await fs.writeFile(validatedPath, content);
54
+ }
55
+ //# sourceMappingURL=inject-dependencies.js.map
@@ -0,0 +1,8 @@
1
+ import { LintingTool, PostInstallInstruction } from '../types.js';
2
+ export declare const lintingTools: Record<string, LintingTool[]>;
3
+ export declare function getToolsForFramework(framework: string, language: string): LintingTool[];
4
+ export declare function getRecommendedTools(framework: string, language: string): LintingTool[];
5
+ export declare function getDependenciesForTools(selectedTools: LintingTool[]): string[];
6
+ export declare function getScriptsForTools(selectedTools: LintingTool[]): Record<string, string>;
7
+ export declare function getPostInstallInstructions(selectedTools: LintingTool[], _framework: string): PostInstallInstruction[];
8
+ //# sourceMappingURL=linting-tools.d.ts.map