edsger 0.2.0 → 0.2.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.
Files changed (178) hide show
  1. package/dist/api/features/feature-utils.d.ts +13 -0
  2. package/dist/api/features/feature-utils.js +46 -0
  3. package/dist/api/features/get-feature.d.ts +5 -0
  4. package/dist/api/features/get-feature.js +19 -0
  5. package/dist/api/features/index.d.ts +7 -0
  6. package/dist/api/features/index.js +9 -0
  7. package/dist/api/features/status-updater.d.ts +27 -0
  8. package/dist/api/features/status-updater.js +64 -0
  9. package/dist/api/features/test-cases.d.ts +21 -0
  10. package/dist/api/features/test-cases.js +63 -0
  11. package/dist/api/features/update-feature.d.ts +13 -0
  12. package/dist/api/features/update-feature.js +31 -0
  13. package/dist/api/features/user-stories.d.ts +21 -0
  14. package/dist/api/features/user-stories.js +63 -0
  15. package/dist/api/features.d.ts +100 -0
  16. package/dist/api/features.js +219 -0
  17. package/dist/api/mcp-client.d.ts +18 -0
  18. package/dist/api/mcp-client.js +58 -0
  19. package/dist/api/products.d.ts +10 -0
  20. package/dist/api/products.js +22 -0
  21. package/dist/api/test-reports.d.ts +9 -0
  22. package/dist/api/test-reports.js +25 -0
  23. package/dist/cli/commands/code-implementation-command.d.ts +2 -0
  24. package/dist/cli/commands/code-implementation-command.js +36 -0
  25. package/dist/cli/commands/code-review-command.d.ts +2 -0
  26. package/dist/cli/commands/code-review-command.js +39 -0
  27. package/dist/cli/commands/feature-analysis-command.d.ts +2 -0
  28. package/dist/cli/commands/feature-analysis-command.js +36 -0
  29. package/dist/cli/commands/functional-testing-command.d.ts +2 -0
  30. package/dist/cli/commands/functional-testing-command.js +36 -0
  31. package/dist/cli/commands/technical-design-command.d.ts +2 -0
  32. package/dist/cli/commands/technical-design-command.js +36 -0
  33. package/dist/cli/commands/workflow-command.d.ts +2 -0
  34. package/dist/cli/commands/workflow-command.js +34 -0
  35. package/dist/cli/formatters/code-implementation-formatter.d.ts +9 -0
  36. package/dist/cli/formatters/code-implementation-formatter.js +27 -0
  37. package/dist/cli/formatters/feature-analysis-formatter.d.ts +2 -0
  38. package/dist/cli/formatters/feature-analysis-formatter.js +27 -0
  39. package/dist/cli/formatters/functional-testing-formatter.d.ts +15 -0
  40. package/dist/cli/formatters/functional-testing-formatter.js +37 -0
  41. package/dist/cli/formatters/technical-design-formatter.d.ts +7 -0
  42. package/dist/cli/formatters/technical-design-formatter.js +30 -0
  43. package/dist/cli/index.d.ts +3 -0
  44. package/dist/cli/index.js +99 -0
  45. package/dist/cli/utils/validation.d.ts +25 -0
  46. package/dist/cli/utils/validation.js +58 -0
  47. package/dist/cli/utils/workflow-utils.d.ts +21 -0
  48. package/dist/cli/utils/workflow-utils.js +47 -0
  49. package/dist/cli.d.ts +1 -1
  50. package/dist/cli.js +11 -466
  51. package/dist/config.d.ts +1 -1
  52. package/dist/index.d.ts +3 -3
  53. package/dist/index.js +2 -2
  54. package/dist/{bug-fixing → phases/bug-fixing}/analyzer.d.ts +1 -1
  55. package/dist/{bug-fixing → phases/bug-fixing}/analyzer.js +1 -1
  56. package/dist/{bug-fixing → phases/bug-fixing}/context-fetcher.d.ts +4 -22
  57. package/dist/{bug-fixing → phases/bug-fixing}/context-fetcher.js +14 -58
  58. package/dist/{bug-fixing → phases/bug-fixing}/mcp-server.js +1 -30
  59. package/dist/phases/code-implementation/analyzer.d.ts +33 -0
  60. package/dist/{code-implementation → phases/code-implementation}/analyzer.js +174 -15
  61. package/dist/phases/code-implementation/context-fetcher.d.ts +17 -0
  62. package/dist/phases/code-implementation/context-fetcher.js +86 -0
  63. package/dist/{code-implementation → phases/code-implementation}/mcp-server.js +1 -30
  64. package/dist/{code-review → phases/code-review}/reviewer.d.ts +1 -1
  65. package/dist/{feature-analysis → phases/feature-analysis}/analyzer.d.ts +3 -2
  66. package/dist/{feature-analysis → phases/feature-analysis}/analyzer.js +29 -127
  67. package/dist/phases/feature-analysis/context-fetcher.d.ts +18 -0
  68. package/dist/phases/feature-analysis/context-fetcher.js +86 -0
  69. package/dist/{feature-analysis → phases/feature-analysis}/http-fallback.js +1 -1
  70. package/dist/{feature-analysis → phases/feature-analysis}/mcp-server.js +1 -24
  71. package/dist/{functional-testing → phases/functional-testing}/analyzer.d.ts +17 -2
  72. package/dist/{functional-testing → phases/functional-testing}/analyzer.js +225 -31
  73. package/dist/phases/functional-testing/context-fetcher.d.ts +16 -0
  74. package/dist/phases/functional-testing/context-fetcher.js +81 -0
  75. package/dist/{functional-testing → phases/functional-testing}/http-fallback.js +1 -1
  76. package/dist/{functional-testing → phases/functional-testing}/index.d.ts +1 -1
  77. package/dist/{functional-testing → phases/functional-testing}/index.js +1 -1
  78. package/dist/{functional-testing → phases/functional-testing}/mcp-server.js +1 -30
  79. package/dist/{functional-testing → phases/functional-testing}/test-report-creator.d.ts +26 -0
  80. package/dist/{functional-testing → phases/functional-testing}/test-report-creator.js +87 -5
  81. package/dist/phases/functional-testing/test-retry-handler.d.ts +16 -0
  82. package/dist/phases/functional-testing/test-retry-handler.js +75 -0
  83. package/dist/{pull-request → phases/pull-request}/creator.js +47 -6
  84. package/dist/phases/pull-request/handler.d.ts +16 -0
  85. package/dist/phases/pull-request/handler.js +60 -0
  86. package/dist/{technical-design → phases/technical-design}/analyzer.d.ts +7 -2
  87. package/dist/phases/technical-design/analyzer.js +418 -0
  88. package/dist/phases/technical-design/context-fetcher.d.ts +12 -0
  89. package/dist/phases/technical-design/context-fetcher.js +39 -0
  90. package/dist/{technical-design → phases/technical-design}/http-fallback.js +1 -1
  91. package/dist/{technical-design → phases/technical-design}/mcp-server.js +1 -30
  92. package/dist/prompts/bug-fixing.d.ts +2 -0
  93. package/dist/prompts/bug-fixing.js +63 -0
  94. package/dist/prompts/code-implementation.d.ts +3 -0
  95. package/dist/prompts/code-implementation.js +132 -0
  96. package/dist/prompts/feature-analysis.d.ts +3 -0
  97. package/dist/prompts/feature-analysis.js +149 -0
  98. package/dist/prompts/formatters.d.ts +29 -0
  99. package/dist/prompts/formatters.js +139 -0
  100. package/dist/prompts/functional-testing.d.ts +3 -0
  101. package/dist/prompts/functional-testing.js +126 -0
  102. package/dist/prompts/index.d.ts +6 -0
  103. package/dist/prompts/index.js +7 -0
  104. package/dist/prompts/technical-design.d.ts +3 -0
  105. package/dist/prompts/technical-design.js +130 -0
  106. package/dist/services/checklist.d.ts +99 -0
  107. package/dist/services/checklist.js +337 -0
  108. package/dist/types/features.d.ts +29 -0
  109. package/dist/types/features.js +1 -0
  110. package/dist/types/index.d.ts +112 -0
  111. package/dist/types/index.js +1 -0
  112. package/dist/types/pipeline.d.ts +25 -0
  113. package/dist/types/pipeline.js +4 -0
  114. package/dist/utils/logger.d.ts +19 -0
  115. package/dist/utils/logger.js +52 -0
  116. package/dist/utils/pipeline-logger.d.ts +8 -0
  117. package/dist/utils/pipeline-logger.js +35 -0
  118. package/dist/workflow-runner/config/phase-configs.d.ts +5 -0
  119. package/dist/workflow-runner/config/phase-configs.js +34 -0
  120. package/dist/workflow-runner/config/stage-configs.d.ts +5 -0
  121. package/dist/workflow-runner/config/stage-configs.js +34 -0
  122. package/dist/workflow-runner/core/feature-filter.d.ts +16 -0
  123. package/dist/workflow-runner/core/feature-filter.js +46 -0
  124. package/dist/workflow-runner/core/feature-filter.test.d.ts +4 -0
  125. package/dist/workflow-runner/core/feature-filter.test.js +127 -0
  126. package/dist/workflow-runner/core/index.d.ts +8 -0
  127. package/dist/workflow-runner/core/index.js +12 -0
  128. package/dist/workflow-runner/core/pipeline-evaluator.d.ts +24 -0
  129. package/dist/workflow-runner/core/pipeline-evaluator.js +32 -0
  130. package/dist/workflow-runner/core/state-manager.d.ts +24 -0
  131. package/dist/workflow-runner/core/state-manager.js +42 -0
  132. package/dist/workflow-runner/core/workflow-logger.d.ts +20 -0
  133. package/dist/workflow-runner/core/workflow-logger.js +65 -0
  134. package/dist/workflow-runner/executors/phase-executor.d.ts +8 -0
  135. package/dist/workflow-runner/executors/phase-executor.js +183 -0
  136. package/dist/workflow-runner/executors/stage-executor.d.ts +8 -0
  137. package/dist/workflow-runner/executors/stage-executor.js +49 -0
  138. package/dist/workflow-runner/feature-service.d.ts +17 -0
  139. package/dist/workflow-runner/feature-service.js +60 -0
  140. package/dist/workflow-runner/feature-workflow-runner.d.ts +26 -0
  141. package/dist/workflow-runner/feature-workflow-runner.js +113 -0
  142. package/dist/workflow-runner/index.d.ts +0 -1
  143. package/dist/workflow-runner/index.js +0 -1
  144. package/dist/workflow-runner/pipeline-runner.d.ts +9 -19
  145. package/dist/workflow-runner/pipeline-runner.js +247 -256
  146. package/dist/workflow-runner/pipeline.d.ts +18 -0
  147. package/dist/workflow-runner/pipeline.js +197 -0
  148. package/dist/workflow-runner/processor.d.ts +40 -0
  149. package/dist/workflow-runner/processor.js +191 -0
  150. package/dist/workflow-runner/types.d.ts +48 -0
  151. package/dist/workflow-runner/types.js +4 -0
  152. package/dist/workflow-runner/workflow-processor.d.ts +6 -23
  153. package/dist/workflow-runner/workflow-processor.js +38 -100
  154. package/package.json +2 -2
  155. package/dist/code-implementation/analyzer.d.ts +0 -19
  156. package/dist/code-implementation/context-fetcher.d.ts +0 -38
  157. package/dist/code-implementation/context-fetcher.js +0 -147
  158. package/dist/feature-analysis/context-fetcher.d.ts +0 -54
  159. package/dist/feature-analysis/context-fetcher.js +0 -193
  160. package/dist/functional-testing/context-fetcher.d.ts +0 -47
  161. package/dist/functional-testing/context-fetcher.js +0 -192
  162. package/dist/technical-design/analyzer.js +0 -338
  163. package/dist/technical-design/context-fetcher.d.ts +0 -42
  164. package/dist/technical-design/context-fetcher.js +0 -170
  165. /package/dist/{bug-fixing → phases/bug-fixing}/index.d.ts +0 -0
  166. /package/dist/{bug-fixing → phases/bug-fixing}/index.js +0 -0
  167. /package/dist/{bug-fixing → phases/bug-fixing}/mcp-server.d.ts +0 -0
  168. /package/dist/{code-implementation → phases/code-implementation}/mcp-server.d.ts +0 -0
  169. /package/dist/{code-review → phases/code-review}/reviewer.js +0 -0
  170. /package/dist/{feature-analysis → phases/feature-analysis}/http-fallback.d.ts +0 -0
  171. /package/dist/{feature-analysis → phases/feature-analysis}/index.d.ts +0 -0
  172. /package/dist/{feature-analysis → phases/feature-analysis}/index.js +0 -0
  173. /package/dist/{feature-analysis → phases/feature-analysis}/mcp-server.d.ts +0 -0
  174. /package/dist/{functional-testing → phases/functional-testing}/http-fallback.d.ts +0 -0
  175. /package/dist/{functional-testing → phases/functional-testing}/mcp-server.d.ts +0 -0
  176. /package/dist/{pull-request → phases/pull-request}/creator.d.ts +0 -0
  177. /package/dist/{technical-design → phases/technical-design}/http-fallback.d.ts +0 -0
  178. /package/dist/{technical-design → phases/technical-design}/mcp-server.d.ts +0 -0
@@ -0,0 +1,27 @@
1
+ export const logFeatureAnalysisResults = (result, verbose) => {
2
+ console.log('\n' + '='.repeat(60));
3
+ console.log('🎯 Feature Analysis Results');
4
+ console.log('='.repeat(60));
5
+ console.log(`\n📋 Feature ID: ${result.featureId}`);
6
+ console.log(`📊 Status: ${result.status === 'success' ? '✅ Success' : '❌ Failed'}`);
7
+ if (result.summary) {
8
+ console.log(`\n📝 Summary:\n${result.summary}`);
9
+ }
10
+ if (result.createdUserStories && result.createdUserStories.length > 0) {
11
+ console.log(`\n✨ Created ${result.createdUserStories.length} user stories`);
12
+ if (verbose) {
13
+ result.createdUserStories.forEach((story, index) => {
14
+ console.log(` ${index + 1}. ${story.title}`);
15
+ });
16
+ }
17
+ }
18
+ if (result.createdTestCases && result.createdTestCases.length > 0) {
19
+ console.log(`\n🧪 Created ${result.createdTestCases.length} test cases`);
20
+ if (verbose) {
21
+ result.createdTestCases.forEach((testCase, index) => {
22
+ console.log(` ${index + 1}. ${testCase.name} ${testCase.is_critical ? '[CRITICAL]' : ''}`);
23
+ });
24
+ }
25
+ }
26
+ console.log('\n' + '='.repeat(60));
27
+ };
@@ -0,0 +1,15 @@
1
+ export declare const logFunctionalTestingResults: (result: {
2
+ featureId: string;
3
+ testStatus: "testing_passed" | "testing_failed";
4
+ structuredTestResult: {
5
+ status: "testing_passed" | "testing_failed";
6
+ title: string;
7
+ summary: string;
8
+ total_test_cases: number;
9
+ passed_test_cases: number;
10
+ failed_test_cases: number;
11
+ execution_details?: string;
12
+ } | null;
13
+ status: "success" | "error";
14
+ message: string;
15
+ }, verbose?: boolean) => void;
@@ -0,0 +1,37 @@
1
+ export const logFunctionalTestingResults = (result, verbose) => {
2
+ console.log('\n' + '='.repeat(60));
3
+ console.log('🎭 Functional Testing Results');
4
+ console.log('='.repeat(60));
5
+ console.log(`\n📋 Feature ID: ${result.featureId}`);
6
+ console.log(`📊 Status: ${result.status === 'success' ? '✅ Success' : '❌ Failed'}`);
7
+ console.log(`🧪 Test Status: ${result.testStatus === 'testing_passed' ? '✅ Passed' : '❌ Failed'}`);
8
+ if (result.message) {
9
+ console.log(`\n📝 Message: ${result.message}`);
10
+ }
11
+ if (result.structuredTestResult && verbose) {
12
+ console.log(`\n🔍 Test Results:`);
13
+ console.log('─'.repeat(40));
14
+ console.log(` Title: ${result.structuredTestResult.title}`);
15
+ console.log(` Summary: ${result.structuredTestResult.summary}`);
16
+ console.log(` Total Tests: ${result.structuredTestResult.total_test_cases}`);
17
+ console.log(` Passed: ${result.structuredTestResult.passed_test_cases}`);
18
+ console.log(` Failed: ${result.structuredTestResult.failed_test_cases}`);
19
+ if (result.structuredTestResult.execution_details) {
20
+ console.log(`\n Execution Details:`);
21
+ const lines = result.structuredTestResult.execution_details.split('\n');
22
+ const previewLines = lines.slice(0, 20);
23
+ previewLines.forEach((line) => {
24
+ console.log(` ${line}`);
25
+ });
26
+ if (lines.length > 20) {
27
+ console.log(` ... (${lines.length - 20} more lines)`);
28
+ }
29
+ console.log('─'.repeat(40));
30
+ }
31
+ }
32
+ else if (result.structuredTestResult &&
33
+ result.structuredTestResult.execution_details) {
34
+ console.log(`\n🔍 Test Results: Available (${result.structuredTestResult.execution_details.length} characters)`);
35
+ }
36
+ console.log('\n' + '='.repeat(60));
37
+ };
@@ -0,0 +1,7 @@
1
+ export declare const logTechnicalDesignResults: (result: {
2
+ featureId: string;
3
+ technicalDesign: string | null;
4
+ status: "success" | "error";
5
+ summary: string;
6
+ savedViaHttp?: boolean;
7
+ }, verbose?: boolean) => void;
@@ -0,0 +1,30 @@
1
+ export const logTechnicalDesignResults = (result, verbose) => {
2
+ console.log('\n' + '='.repeat(60));
3
+ console.log('🎨 Technical Design Results');
4
+ console.log('='.repeat(60));
5
+ console.log(`\n📋 Feature ID: ${result.featureId}`);
6
+ console.log(`📊 Status: ${result.status === 'success' ? '✅ Success' : '❌ Failed'}`);
7
+ if (result.summary) {
8
+ console.log(`\n📝 Summary:\n${result.summary}`);
9
+ }
10
+ if (result.savedViaHttp) {
11
+ console.log(`\n🔄 Saved via HTTP fallback`);
12
+ }
13
+ if (result.technicalDesign && verbose) {
14
+ console.log(`\n🏗️ Technical Design:`);
15
+ console.log('─'.repeat(40));
16
+ const lines = result.technicalDesign.split('\n');
17
+ const previewLines = lines.slice(0, 10);
18
+ previewLines.forEach((line) => {
19
+ console.log(` ${line}`);
20
+ });
21
+ if (lines.length > 10) {
22
+ console.log(` ... (${lines.length - 10} more lines)`);
23
+ }
24
+ console.log('─'.repeat(40));
25
+ }
26
+ else if (result.technicalDesign) {
27
+ console.log(`\n🏗️ Technical Design: Generated (${result.technicalDesign.length} characters)`);
28
+ }
29
+ console.log('\n' + '='.repeat(60));
30
+ };
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { CliOptions } from '../types/index.js';
3
+ export declare const runEdsger: (options: CliOptions) => Promise<void>;
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import { readFileSync } from 'fs';
4
+ import { join, dirname } from 'path';
5
+ import { fileURLToPath } from 'url';
6
+ import { config as dotenvConfig } from 'dotenv';
7
+ import { logError } from '../utils/logger.js';
8
+ import { runWorkflow } from './commands/workflow-command.js';
9
+ import { runFeatureAnalysis } from './commands/feature-analysis-command.js';
10
+ import { runTechnicalDesign } from './commands/technical-design-command.js';
11
+ import { runCodeImplementation } from './commands/code-implementation-command.js';
12
+ import { runFunctionalTestingCommand } from './commands/functional-testing-command.js';
13
+ import { runCodeReview } from './commands/code-review-command.js';
14
+ // Get package.json version dynamically
15
+ const __filename = fileURLToPath(import.meta.url);
16
+ const __dirname = dirname(__filename);
17
+ const packageJson = JSON.parse(readFileSync(join(__dirname, '../../package.json'), 'utf-8'));
18
+ const version = packageJson.version;
19
+ // Load environment variables from .env file
20
+ // Load from current working directory (where the command is run)
21
+ dotenvConfig({ path: join(process.cwd(), '.env') });
22
+ const program = new Command();
23
+ program
24
+ .name('edsger')
25
+ .description('AI-powered code review CLI tool using Claude Code SDK')
26
+ .version(version);
27
+ program
28
+ .option('-r, --review', 'Review code changes')
29
+ .option('-s, --staged', 'Review only staged changes')
30
+ .option('-f, --files <patterns...>', 'Review specific file patterns')
31
+ .option('--feature-analysis <featureId>', 'Analyze feature and generate user stories/test cases')
32
+ .option('--technical-design <featureId>', 'Generate technical design for a feature')
33
+ .option('--implement <featureId>', 'Implement code for a feature based on its specifications')
34
+ .option('--test <featureId>', 'Run functional tests for a feature using Playwright')
35
+ .option('--workflow', 'Run continuous workflow processor to handle ready_for_dev features')
36
+ .option('-c, --config <path>', 'Path to config file')
37
+ .option('-v, --verbose', 'Verbose output');
38
+ program.action(async (options) => {
39
+ try {
40
+ await runEdsger(options);
41
+ }
42
+ catch (error) {
43
+ logError(error instanceof Error ? error.message : String(error));
44
+ process.exit(1);
45
+ }
46
+ });
47
+ export const runEdsger = async (options) => {
48
+ // Handle workflow mode
49
+ if (options.workflow) {
50
+ await runWorkflow(options);
51
+ return;
52
+ }
53
+ // Handle feature analysis mode
54
+ if (options.featureAnalysis) {
55
+ await runFeatureAnalysis(options);
56
+ return;
57
+ }
58
+ // Handle technical design mode
59
+ if (options.technicalDesign) {
60
+ await runTechnicalDesign(options);
61
+ return;
62
+ }
63
+ // Handle code implementation mode
64
+ if (options.implement) {
65
+ await runCodeImplementation(options);
66
+ return;
67
+ }
68
+ // Handle functional testing mode
69
+ if (options.test) {
70
+ await runFunctionalTestingCommand(options);
71
+ return;
72
+ }
73
+ // Handle code review mode (explicit --review flag or as fallback)
74
+ if (options.review || options.staged || options.files) {
75
+ await runCodeReview(options);
76
+ return;
77
+ }
78
+ // Default to workflow mode if environment is configured, otherwise code review
79
+ const productId = process.env.EDSGER_PRODUCT_ID;
80
+ const mcpToken = process.env.EDSGER_MCP_TOKEN;
81
+ if (productId && mcpToken) {
82
+ // Environment is configured for workflow, use that as default
83
+ options.workflow = true;
84
+ await runWorkflow(options);
85
+ }
86
+ else {
87
+ // Default to code review mode
88
+ await runCodeReview(options);
89
+ }
90
+ };
91
+ // Only parse when this file is run directly (not imported as module)
92
+ // Check if this is the main module being executed
93
+ const isMainModule = import.meta.url === `file://${process.argv[1]}` ||
94
+ process.argv[1]?.endsWith('/edsger') ||
95
+ process.argv[1]?.endsWith('\\edsger') ||
96
+ process.argv[1]?.endsWith('cli.js');
97
+ if (isMainModule) {
98
+ program.parse();
99
+ }
@@ -0,0 +1,25 @@
1
+ import { CliOptions } from '../../types/index.js';
2
+ export interface ValidationResult {
3
+ config: any;
4
+ mcpServerUrl: string;
5
+ mcpToken: string;
6
+ }
7
+ /**
8
+ * Common configuration validation for all CLI commands
9
+ */
10
+ export declare const validateConfiguration: (options: CliOptions) => any;
11
+ /**
12
+ * Validate MCP environment variables and URL format
13
+ */
14
+ export declare const validateMCPEnvironment: () => {
15
+ mcpServerUrl: string;
16
+ mcpToken: string;
17
+ };
18
+ /**
19
+ * Combined validation for commands that need both config and MCP setup
20
+ */
21
+ export declare const validateCommandEnvironment: (options: CliOptions) => ValidationResult;
22
+ /**
23
+ * Check if required dependencies are installed
24
+ */
25
+ export declare const validateRequirements: (checkFunction: () => Promise<boolean>, errorMessage: string) => Promise<void>;
@@ -0,0 +1,58 @@
1
+ import { loadConfig, validateConfig } from '../../config.js';
2
+ import { logInfo } from '../../utils/logger.js';
3
+ /**
4
+ * Common configuration validation for all CLI commands
5
+ */
6
+ export const validateConfiguration = (options) => {
7
+ const config = loadConfig(options.config);
8
+ const configErrors = validateConfig(config);
9
+ if (configErrors.length > 0) {
10
+ throw new Error(`Configuration errors:\n${configErrors.map((e) => ` - ${e}`).join('\n')}`);
11
+ }
12
+ if (options.verbose) {
13
+ logInfo('Configuration loaded successfully');
14
+ }
15
+ return config;
16
+ };
17
+ /**
18
+ * Validate MCP environment variables and URL format
19
+ */
20
+ export const validateMCPEnvironment = () => {
21
+ const mcpServerUrl = process.env.EDSGER_MCP_SERVER_URL;
22
+ const mcpToken = process.env.EDSGER_MCP_TOKEN;
23
+ if (!mcpServerUrl) {
24
+ throw new Error('MCP server URL is required. Set EDSGER_MCP_SERVER_URL environment variable.');
25
+ }
26
+ if (!mcpToken) {
27
+ throw new Error('MCP token is required. Set EDSGER_MCP_TOKEN environment variable.');
28
+ }
29
+ // Validate MCP server URL format
30
+ try {
31
+ new URL(mcpServerUrl);
32
+ }
33
+ catch {
34
+ throw new Error('Invalid MCP server URL format. Use http:// or https://');
35
+ }
36
+ return { mcpServerUrl, mcpToken };
37
+ };
38
+ /**
39
+ * Combined validation for commands that need both config and MCP setup
40
+ */
41
+ export const validateCommandEnvironment = (options) => {
42
+ const config = validateConfiguration(options);
43
+ const { mcpServerUrl, mcpToken } = validateMCPEnvironment();
44
+ return {
45
+ config,
46
+ mcpServerUrl,
47
+ mcpToken,
48
+ };
49
+ };
50
+ /**
51
+ * Check if required dependencies are installed
52
+ */
53
+ export const validateRequirements = async (checkFunction, errorMessage) => {
54
+ const hasRequirements = await checkFunction();
55
+ if (!hasRequirements) {
56
+ throw new Error(errorMessage);
57
+ }
58
+ };
@@ -0,0 +1,21 @@
1
+ import { CliOptions } from '../../types/index.js';
2
+ /**
3
+ * Validate workflow-specific environment variables
4
+ */
5
+ export declare const validateWorkflowEnvironment: () => {
6
+ productId: string;
7
+ mcpServerUrl: string;
8
+ mcpToken: string;
9
+ };
10
+ /**
11
+ * Setup workflow processor parameters
12
+ */
13
+ export declare const setupWorkflowProcessor: (options: CliOptions) => {
14
+ config: any;
15
+ params: {
16
+ productId: string;
17
+ mcpServerUrl: string;
18
+ mcpToken: string;
19
+ verbose?: boolean;
20
+ };
21
+ };
@@ -0,0 +1,47 @@
1
+ import { validateConfiguration } from './validation.js';
2
+ import { logInfo } from '../../utils/logger.js';
3
+ /**
4
+ * Validate workflow-specific environment variables
5
+ */
6
+ export const validateWorkflowEnvironment = () => {
7
+ const productId = process.env.EDSGER_PRODUCT_ID;
8
+ const mcpServerUrl = process.env.EDSGER_MCP_SERVER_URL;
9
+ const mcpToken = process.env.EDSGER_MCP_TOKEN;
10
+ if (!productId) {
11
+ throw new Error('Product ID is required. Set EDSGER_PRODUCT_ID environment variable.');
12
+ }
13
+ if (!mcpServerUrl) {
14
+ throw new Error('MCP server URL is required. Set EDSGER_MCP_SERVER_URL environment variable.');
15
+ }
16
+ if (!mcpToken) {
17
+ throw new Error('MCP token is required. Set EDSGER_MCP_TOKEN environment variable.');
18
+ }
19
+ // Validate MCP server URL format
20
+ try {
21
+ new URL(mcpServerUrl);
22
+ }
23
+ catch {
24
+ throw new Error('Invalid MCP server URL format. Use http:// or https://');
25
+ }
26
+ return { productId, mcpServerUrl, mcpToken };
27
+ };
28
+ /**
29
+ * Setup workflow processor parameters
30
+ */
31
+ export const setupWorkflowProcessor = (options) => {
32
+ const config = validateConfiguration(options);
33
+ if (options.verbose) {
34
+ logInfo('Starting workflow processor mode...');
35
+ }
36
+ const { productId, mcpServerUrl, mcpToken } = validateWorkflowEnvironment();
37
+ logInfo('🚀 Starting workflow processor...');
38
+ return {
39
+ config,
40
+ params: {
41
+ productId,
42
+ mcpServerUrl,
43
+ mcpToken,
44
+ verbose: options.verbose,
45
+ },
46
+ };
47
+ };
package/dist/cli.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { CliOptions } from './types.js';
2
+ import { CliOptions } from './types/index.js';
3
3
  export declare const runEdsger: (options: CliOptions) => Promise<void>;