mcp-spec-cli 1.0.9

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 (111) hide show
  1. package/README.md +49 -0
  2. package/api/spec-workflow.openapi.yaml +1305 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +151 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/features/check/analyzeStage.d.ts +20 -0
  8. package/dist/features/check/analyzeStage.d.ts.map +1 -0
  9. package/dist/features/check/analyzeStage.js +114 -0
  10. package/dist/features/check/analyzeStage.js.map +1 -0
  11. package/dist/features/check/checkWorkflow.d.ts +10 -0
  12. package/dist/features/check/checkWorkflow.d.ts.map +1 -0
  13. package/dist/features/check/checkWorkflow.js +92 -0
  14. package/dist/features/check/checkWorkflow.js.map +1 -0
  15. package/dist/features/check/generateNextDocument.d.ts +14 -0
  16. package/dist/features/check/generateNextDocument.d.ts.map +1 -0
  17. package/dist/features/check/generateNextDocument.js +64 -0
  18. package/dist/features/check/generateNextDocument.js.map +1 -0
  19. package/dist/features/confirm/confirmStage.d.ts +9 -0
  20. package/dist/features/confirm/confirmStage.d.ts.map +1 -0
  21. package/dist/features/confirm/confirmStage.js +101 -0
  22. package/dist/features/confirm/confirmStage.js.map +1 -0
  23. package/dist/features/executeWorkflow.d.ts +15 -0
  24. package/dist/features/executeWorkflow.d.ts.map +1 -0
  25. package/dist/features/executeWorkflow.js +97 -0
  26. package/dist/features/executeWorkflow.js.map +1 -0
  27. package/dist/features/init/createRequirementsDoc.d.ts +11 -0
  28. package/dist/features/init/createRequirementsDoc.d.ts.map +1 -0
  29. package/dist/features/init/createRequirementsDoc.js +36 -0
  30. package/dist/features/init/createRequirementsDoc.js.map +1 -0
  31. package/dist/features/init/initWorkflow.d.ts +12 -0
  32. package/dist/features/init/initWorkflow.d.ts.map +1 -0
  33. package/dist/features/init/initWorkflow.js +103 -0
  34. package/dist/features/init/initWorkflow.js.map +1 -0
  35. package/dist/features/shared/SpecManager.d.ts +33 -0
  36. package/dist/features/shared/SpecManager.d.ts.map +1 -0
  37. package/dist/features/shared/SpecManager.js +103 -0
  38. package/dist/features/shared/SpecManager.js.map +1 -0
  39. package/dist/features/shared/confirmationStatus.d.ts +24 -0
  40. package/dist/features/shared/confirmationStatus.d.ts.map +1 -0
  41. package/dist/features/shared/confirmationStatus.js +69 -0
  42. package/dist/features/shared/confirmationStatus.js.map +1 -0
  43. package/dist/features/shared/documentAnalyzer.d.ts +18 -0
  44. package/dist/features/shared/documentAnalyzer.d.ts.map +1 -0
  45. package/dist/features/shared/documentAnalyzer.js +34 -0
  46. package/dist/features/shared/documentAnalyzer.js.map +1 -0
  47. package/dist/features/shared/documentStatus.d.ts +18 -0
  48. package/dist/features/shared/documentStatus.d.ts.map +1 -0
  49. package/dist/features/shared/documentStatus.js +66 -0
  50. package/dist/features/shared/documentStatus.js.map +1 -0
  51. package/dist/features/shared/documentTemplates.d.ts +8 -0
  52. package/dist/features/shared/documentTemplates.d.ts.map +1 -0
  53. package/dist/features/shared/documentTemplates.js +89 -0
  54. package/dist/features/shared/documentTemplates.js.map +1 -0
  55. package/dist/features/shared/documentUtils.d.ts +9 -0
  56. package/dist/features/shared/documentUtils.d.ts.map +1 -0
  57. package/dist/features/shared/documentUtils.js +38 -0
  58. package/dist/features/shared/documentUtils.js.map +1 -0
  59. package/dist/features/shared/mcpTypes.d.ts +83 -0
  60. package/dist/features/shared/mcpTypes.d.ts.map +1 -0
  61. package/dist/features/shared/mcpTypes.js +41 -0
  62. package/dist/features/shared/mcpTypes.js.map +1 -0
  63. package/dist/features/shared/openApiLoader.d.ts +88 -0
  64. package/dist/features/shared/openApiLoader.d.ts.map +1 -0
  65. package/dist/features/shared/openApiLoader.js +166 -0
  66. package/dist/features/shared/openApiLoader.js.map +1 -0
  67. package/dist/features/shared/openApiTypes.d.ts +101 -0
  68. package/dist/features/shared/openApiTypes.d.ts.map +1 -0
  69. package/dist/features/shared/openApiTypes.js +4 -0
  70. package/dist/features/shared/openApiTypes.js.map +1 -0
  71. package/dist/features/shared/progressCalculator.d.ts +22 -0
  72. package/dist/features/shared/progressCalculator.d.ts.map +1 -0
  73. package/dist/features/shared/progressCalculator.js +45 -0
  74. package/dist/features/shared/progressCalculator.js.map +1 -0
  75. package/dist/features/shared/responseBuilder.d.ts +13 -0
  76. package/dist/features/shared/responseBuilder.d.ts.map +1 -0
  77. package/dist/features/shared/responseBuilder.js +303 -0
  78. package/dist/features/shared/responseBuilder.js.map +1 -0
  79. package/dist/features/shared/taskGuidanceTemplate.d.ts +22 -0
  80. package/dist/features/shared/taskGuidanceTemplate.d.ts.map +1 -0
  81. package/dist/features/shared/taskGuidanceTemplate.js +145 -0
  82. package/dist/features/shared/taskGuidanceTemplate.js.map +1 -0
  83. package/dist/features/shared/taskParser.d.ts +17 -0
  84. package/dist/features/shared/taskParser.d.ts.map +1 -0
  85. package/dist/features/shared/taskParser.js +259 -0
  86. package/dist/features/shared/taskParser.js.map +1 -0
  87. package/dist/features/shared/typeGuards.d.ts +54 -0
  88. package/dist/features/shared/typeGuards.d.ts.map +1 -0
  89. package/dist/features/shared/typeGuards.js +96 -0
  90. package/dist/features/shared/typeGuards.js.map +1 -0
  91. package/dist/features/skip/skipStage.d.ts +9 -0
  92. package/dist/features/skip/skipStage.d.ts.map +1 -0
  93. package/dist/features/skip/skipStage.js +122 -0
  94. package/dist/features/skip/skipStage.js.map +1 -0
  95. package/dist/features/task/completeTask.d.ts +13 -0
  96. package/dist/features/task/completeTask.d.ts.map +1 -0
  97. package/dist/features/task/completeTask.js +362 -0
  98. package/dist/features/task/completeTask.js.map +1 -0
  99. package/dist/index.d.ts +7 -0
  100. package/dist/index.d.ts.map +1 -0
  101. package/dist/index.js +51 -0
  102. package/dist/index.js.map +1 -0
  103. package/dist/logger.d.ts +6 -0
  104. package/dist/logger.d.ts.map +1 -0
  105. package/dist/logger.js +23 -0
  106. package/dist/logger.js.map +1 -0
  107. package/dist/tools/specTools.d.ts +3 -0
  108. package/dist/tools/specTools.d.ts.map +1 -0
  109. package/dist/tools/specTools.js +107 -0
  110. package/dist/tools/specTools.js.map +1 -0
  111. package/package.json +44 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentStatus.d.ts","sourceRoot":"","sources":["../../../src/features/shared/documentStatus.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,cAAc,CAAC;IAC7B,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,cAAc,CAAC;CACvB;AAED,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,QAAQ,GAAG,OAAO,GAAG,WAAW,CAAC;AAE9E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAM9D;AAQD,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CA0BpF;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAIhE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQlD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOtD"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Document status management related functions
3
+ */
4
+ import { existsSync } from 'fs';
5
+ import { join } from 'path';
6
+ import { isStageSkipped, isStageConfirmed } from './confirmationStatus.js';
7
+ export function getWorkflowStatus(path) {
8
+ return {
9
+ requirements: getDocumentStatus(path, 'requirements.md'),
10
+ design: getDocumentStatus(path, 'design.md'),
11
+ tasks: getDocumentStatus(path, 'tasks.md')
12
+ };
13
+ }
14
+ function getDocumentStatus(path, fileName) {
15
+ const filePath = join(path, fileName);
16
+ return { exists: existsSync(filePath) };
17
+ }
18
+ export function getCurrentStage(status, path) {
19
+ if (!path) {
20
+ // Backward compatibility: if no path, return the first existing document stage
21
+ if (status.requirements.exists)
22
+ return 'requirements';
23
+ if (status.design.exists)
24
+ return 'design';
25
+ if (status.tasks.exists)
26
+ return 'tasks';
27
+ return 'completed';
28
+ }
29
+ // Determine current stage based on confirmations
30
+ // If requirements stage is not confirmed and not skipped, current stage is requirements
31
+ if (!isStageConfirmed(path, 'requirements') && !isStageSkipped(path, 'requirements')) {
32
+ return 'requirements';
33
+ }
34
+ // If design stage is not confirmed and not skipped, current stage is design
35
+ if (!isStageConfirmed(path, 'design') && !isStageSkipped(path, 'design')) {
36
+ return 'design';
37
+ }
38
+ // If tasks stage is not confirmed and not skipped, current stage is tasks
39
+ if (!isStageConfirmed(path, 'tasks') && !isStageSkipped(path, 'tasks')) {
40
+ return 'tasks';
41
+ }
42
+ return 'completed';
43
+ }
44
+ export function getNextStage(stage) {
45
+ const stages = ['requirements', 'design', 'tasks', 'completed'];
46
+ const index = stages.indexOf(stage);
47
+ return stages[Math.min(index + 1, stages.length - 1)];
48
+ }
49
+ export function getStageName(stage) {
50
+ const names = {
51
+ requirements: 'Requirements Document',
52
+ design: 'Design Document',
53
+ tasks: 'Task List',
54
+ completed: 'Completed'
55
+ };
56
+ return names[stage] || stage;
57
+ }
58
+ export function getStageFileName(stage) {
59
+ const fileNames = {
60
+ requirements: 'requirements.md',
61
+ design: 'design.md',
62
+ tasks: 'tasks.md'
63
+ };
64
+ return fileNames[stage] || '';
65
+ }
66
+ //# sourceMappingURL=documentStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentStatus.js","sourceRoot":"","sources":["../../../src/features/shared/documentStatus.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC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I,EAAE,OAAO,CAAC,EAAE,CAAC;QACvE,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAoB;IAC/C,MAAM,MAAM,GAAoB,CAAC,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IACjF,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,MAAM,KAAK,GAA2B;QACpC,YAAY,EAAE,uBAAuB;QACrC,MAAM,EAAE,iBAAiB;QACzB,KAAK,EAAE,WAAW;QAClB,SAAS,EAAE,WAAW;KACvB,CAAC;IACF,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,MAAM,SAAS,GAA2B;QACxC,YAAY,EAAE,iBAAiB;QAC/B,MAAM,EAAE,WAAW;QACnB,KAAK,EAAE,UAAU;KAClB,CAAC;IACF,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;AAChC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Document templates - using OpenAPI as single source of truth
3
+ */
4
+ export declare function getRequirementsTemplate(featureName: string, introduction: string): string;
5
+ export declare function getDesignTemplate(featureName: string): string;
6
+ export declare function getTasksTemplate(featureName: string): string;
7
+ export declare function getSkippedTemplate(featureName: string, stageName: string): string;
8
+ //# sourceMappingURL=documentTemplates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentTemplates.d.ts","sourceRoot":"","sources":["../../../src/features/shared/documentTemplates.ts"],"names":[],"mappings":"AAAA;;GAEG;AAuDH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CASzF;AAGD,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAS7D;AAGD,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAS5D;AAGD,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CASjF"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Document templates - using OpenAPI as single source of truth
3
+ */
4
+ import { openApiLoader } from './openApiLoader.js';
5
+ import { isObject, isArray } from './typeGuards.js';
6
+ // Format template, replace variables
7
+ function formatTemplate(template, values) {
8
+ const lines = [];
9
+ if (!isObject(template)) {
10
+ throw new Error('Invalid template format');
11
+ }
12
+ const title = template.title;
13
+ if (typeof title === 'string') {
14
+ lines.push(`# ${interpolate(title, values)}`);
15
+ lines.push('');
16
+ }
17
+ const sections = template.sections;
18
+ if (isArray(sections)) {
19
+ for (const section of sections) {
20
+ if (isObject(section)) {
21
+ if (typeof section.content === 'string') {
22
+ lines.push(interpolate(section.content, values));
23
+ }
24
+ else if (typeof section.placeholder === 'string') {
25
+ lines.push(section.placeholder);
26
+ }
27
+ lines.push('');
28
+ }
29
+ }
30
+ }
31
+ return lines.join('\n');
32
+ }
33
+ // Variable interpolation
34
+ function interpolate(template, values) {
35
+ return template.replace(/\${([^}]+)}/g, (match, key) => {
36
+ const keys = key.split('.');
37
+ let value = values;
38
+ for (const k of keys) {
39
+ if (isObject(value) && k in value) {
40
+ value = value[k];
41
+ }
42
+ else {
43
+ return match;
44
+ }
45
+ }
46
+ return String(value);
47
+ });
48
+ }
49
+ // Get requirements document template
50
+ export function getRequirementsTemplate(featureName, introduction) {
51
+ // Ensure spec is loaded
52
+ openApiLoader.loadSpec();
53
+ const template = openApiLoader.getDocumentTemplate('requirements');
54
+ if (!template) {
55
+ throw new Error('Requirements template not found in OpenAPI specification');
56
+ }
57
+ return formatTemplate(template, { featureName, introduction });
58
+ }
59
+ // Get design document template
60
+ export function getDesignTemplate(featureName) {
61
+ // Ensure spec is loaded
62
+ openApiLoader.loadSpec();
63
+ const template = openApiLoader.getDocumentTemplate('design');
64
+ if (!template) {
65
+ throw new Error('Design template not found in OpenAPI specification');
66
+ }
67
+ return formatTemplate(template, { featureName });
68
+ }
69
+ // Get tasks list template
70
+ export function getTasksTemplate(featureName) {
71
+ // Ensure spec is loaded
72
+ openApiLoader.loadSpec();
73
+ const template = openApiLoader.getDocumentTemplate('tasks');
74
+ if (!template) {
75
+ throw new Error('Tasks template not found in OpenAPI specification');
76
+ }
77
+ return formatTemplate(template, { featureName });
78
+ }
79
+ // Get skipped marker template
80
+ export function getSkippedTemplate(featureName, stageName) {
81
+ // Ensure spec is loaded
82
+ openApiLoader.loadSpec();
83
+ const template = openApiLoader.getDocumentTemplate('skipped');
84
+ if (!template) {
85
+ throw new Error('Skipped template not found in OpenAPI specification');
86
+ }
87
+ return formatTemplate(template, { featureName, stageName });
88
+ }
89
+ //# sourceMappingURL=documentTemplates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentTemplates.js","sourceRoot":"","sources":["../../../src/features/shared/documentTemplates.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAEpD,qCAAqC;AACrC,SAAS,cAAc,CAAC,QAAiB,EAAE,MAAkC;IAC3E,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC7B,IAAI,OAAO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E,CAAC,CAAC;AACnD,CAAC;AAED,8BAA8B;AAC9B,MAAM,UAAU,kBAAkB,CAAC,WAAmB,EAAE,SAAiB;IACvE,wBAAwB;IACxB,aAAa,CAAC,QAAQ,EAAE,CAAC;IACzB,MAAM,QAAQ,GAAG,aAAa,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC9D,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,cAAc,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shared utilities for document processing
3
+ */
4
+ export interface DocumentInfo {
5
+ featureName: string;
6
+ introduction: string;
7
+ }
8
+ export declare function extractDocumentInfo(requirementsPath: string): DocumentInfo;
9
+ //# sourceMappingURL=documentUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentUtils.d.ts","sourceRoot":"","sources":["../../../src/features/shared/documentUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,mBAAmB,CAAC,gBAAgB,EAAE,MAAM,GAAG,YAAY,CAkC1E"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Shared utilities for document processing
3
+ */
4
+ import { readFileSync } from 'fs';
5
+ export function extractDocumentInfo(requirementsPath) {
6
+ try {
7
+ const content = readFileSync(requirementsPath, 'utf-8');
8
+ const lines = content.split('\n');
9
+ // Extract feature name
10
+ const titleLine = lines.find(line => line.startsWith('# '));
11
+ const featureName = titleLine
12
+ ? titleLine.replace('# ', '').replace(' - Requirements Document', '').trim()
13
+ : 'Unnamed Feature';
14
+ // Extract project background
15
+ const backgroundIndex = lines.findIndex(line => line.includes('## Project Background'));
16
+ let introduction = '';
17
+ if (backgroundIndex !== -1) {
18
+ for (let i = backgroundIndex + 1; i < lines.length; i++) {
19
+ if (lines[i].startsWith('##'))
20
+ break;
21
+ if (lines[i].trim()) {
22
+ introduction += lines[i] + '\n';
23
+ }
24
+ }
25
+ }
26
+ return {
27
+ featureName,
28
+ introduction: introduction.trim() || 'No description'
29
+ };
30
+ }
31
+ catch {
32
+ return {
33
+ featureName: 'Unnamed Feature',
34
+ introduction: 'No description'
35
+ };
36
+ }
37
+ }
38
+ //# sourceMappingURL=documentUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentUtils.js","sourceRoot":"","sources":["../../../src/features/shared/documentUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAOlC,MAAM,UAAU,mBAAmB,CAAC,gBAAwB;IAC1D,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QACxD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAElC,uBAAuB;QACvB,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5D,MAAM,WAAW,GAAG,SAAS;YAC3B,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,0BAA0B,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE;YAC5E,CAAC,CAAC,iBAAiB,CAAC;QAEtB,6BAA6B;QAC7B,MAAM,eAAe,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC,CAAC;QACxF,IAAI,YAAY,GAAG,EAAE,CAAC;QAEtB,IAAI,eAAe,KAAK,CAAC,CAAC,EAAE,CAAC;YAC3B,KAAK,IAAI,CAAC,GAAG,eAAe,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACxD,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;oBAAE,MAAM;gBACrC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;oBACpB,YAAY,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;gBAClC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO;YACL,WAAW;YACX,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE,IAAI,gBAAgB;SACtD,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,WAAW,EAAE,iBAAiB;YAC9B,YAAY,EAAE,gBAAgB;SAC/B,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * MCP (Model Context Protocol) compatible type definitions
3
+ * Standard interfaces conforming to MCP specification
4
+ */
5
+ /**
6
+ * MCP text content
7
+ */
8
+ export interface McpTextContent {
9
+ type: "text";
10
+ text: string;
11
+ }
12
+ /**
13
+ * MCP image content
14
+ */
15
+ export interface McpImageContent {
16
+ type: "image";
17
+ data: string;
18
+ mimeType: string;
19
+ }
20
+ /**
21
+ * MCP audio content
22
+ */
23
+ export interface McpAudioContent {
24
+ type: "audio";
25
+ data: string;
26
+ mimeType: string;
27
+ }
28
+ /**
29
+ * MCP resource content
30
+ */
31
+ export interface McpResourceContent {
32
+ type: "resource";
33
+ resource: {
34
+ uri: string;
35
+ title?: string;
36
+ mimeType: string;
37
+ text?: string;
38
+ };
39
+ }
40
+ /**
41
+ * MCP content type union
42
+ */
43
+ export type McpContent = McpTextContent | McpImageContent | McpAudioContent | McpResourceContent;
44
+ /**
45
+ * MCP tool call result
46
+ * This is the standard format that must be returned after tool execution
47
+ */
48
+ export interface McpCallToolResult {
49
+ content: McpContent[];
50
+ isError?: boolean;
51
+ structuredContent?: unknown;
52
+ }
53
+ /**
54
+ * Internally used workflow result
55
+ * Used to pass data between functional modules
56
+ */
57
+ export interface WorkflowResult {
58
+ displayText: string;
59
+ data: {
60
+ success?: boolean;
61
+ error?: string;
62
+ [key: string]: unknown;
63
+ };
64
+ resources?: Array<{
65
+ uri: string;
66
+ title?: string;
67
+ mimeType: string;
68
+ text?: string;
69
+ }>;
70
+ }
71
+ /**
72
+ * Create text content
73
+ */
74
+ export declare function createTextContent(text: string): McpTextContent;
75
+ /**
76
+ * Create resource content
77
+ */
78
+ export declare function createResourceContent(resource: McpResourceContent['resource']): McpResourceContent;
79
+ /**
80
+ * Convert internal workflow result to MCP format
81
+ */
82
+ export declare function toMcpResult(result: WorkflowResult): McpCallToolResult;
83
+ //# sourceMappingURL=mcpTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpTypes.d.ts","sourceRoot":"","sources":["../../../src/features/shared/mcpTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,cAAc,GACd,eAAe,GACf,eAAe,GACf,kBAAkB,CAAC;AAEvB;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE;QACJ,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,SAAS,CAAC,EAAE,KAAK,CAAC;QAChB,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;CACJ;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAK9D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,kBAAkB,CAAC,UAAU,CAAC,GAAG,kBAAkB,CAKlG;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,iBAAiB,CAgBrE"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * MCP (Model Context Protocol) compatible type definitions
3
+ * Standard interfaces conforming to MCP specification
4
+ */
5
+ /**
6
+ * Create text content
7
+ */
8
+ export function createTextContent(text) {
9
+ return {
10
+ type: "text",
11
+ text
12
+ };
13
+ }
14
+ /**
15
+ * Create resource content
16
+ */
17
+ export function createResourceContent(resource) {
18
+ return {
19
+ type: "resource",
20
+ resource
21
+ };
22
+ }
23
+ /**
24
+ * Convert internal workflow result to MCP format
25
+ */
26
+ export function toMcpResult(result) {
27
+ const content = [
28
+ createTextContent(result.displayText)
29
+ ];
30
+ // Resources are now embedded in displayText, no need to add them separately
31
+ // This avoids duplicate display in clients that support resource content type
32
+ return {
33
+ content,
34
+ isError: result.data.success === false,
35
+ // Add structured content, return response object conforming to OpenAPI specification
36
+ structuredContent: result.data && typeof result.data === 'object' && 'displayText' in result.data
37
+ ? result.data // If data is already a complete response object
38
+ : undefined // Otherwise don't return structuredContent
39
+ };
40
+ }
41
+ //# sourceMappingURL=mcpTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpTypes.js","sourceRoot":"","sources":["../../../src/features/shared/mcpTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+EH;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,IAAI;KACL,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAwC;IAC5E,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,MAAsB;IAChD,MAAM,OAAO,GAAiB;QAC5B,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC;KACtC,CAAC;IAEF,4EAA4E;IAC5E,8EAA8E;IAE9E,OAAO;QACL,OAAO;QACP,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,KAAK,KAAK;QACtC,qFAAqF;QACrF,iBAAiB,EAAE,MAAM,CAAC,IAAI,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,aAAa,IAAI,MAAM,CAAC,IAAI;YAC/F,CAAC,CAAC,MAAM,CAAC,IAAI,CAAE,gDAAgD;YAC/D,CAAC,CAAC,SAAS,CAAI,2CAA2C;KAC7D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,88 @@
1
+ export interface OpenApiSpec {
2
+ paths: {
3
+ '/spec': {
4
+ post: {
5
+ responses: {
6
+ '200': {
7
+ content: {
8
+ 'application/json': {
9
+ schema: {
10
+ $ref: string;
11
+ };
12
+ };
13
+ };
14
+ };
15
+ };
16
+ };
17
+ };
18
+ };
19
+ components: {
20
+ schemas: Record<string, unknown>;
21
+ };
22
+ 'x-error-responses': Record<string, {
23
+ displayText: string;
24
+ }>;
25
+ 'x-shared-resources': Record<string, {
26
+ uri: string;
27
+ title?: string;
28
+ mimeType: string;
29
+ text?: string;
30
+ }>;
31
+ 'x-global-config': unknown;
32
+ 'x-document-templates': Record<string, unknown>;
33
+ 'x-task-guidance-template'?: {
34
+ separator: string;
35
+ header: string;
36
+ instructions: {
37
+ prefix: string;
38
+ taskFocus: string;
39
+ progressTracking: string;
40
+ workflow: string;
41
+ };
42
+ prompts: {
43
+ firstTask: string;
44
+ nextTask: string;
45
+ continueTask: string;
46
+ batchContinue: string;
47
+ };
48
+ completionMessages: {
49
+ taskCompleted: string;
50
+ allCompleted: string;
51
+ alreadyCompleted: string;
52
+ batchSucceeded: string;
53
+ batchCompleted: string;
54
+ };
55
+ };
56
+ }
57
+ export declare class OpenApiLoader {
58
+ private static instance;
59
+ private spec;
60
+ private examples;
61
+ private constructor();
62
+ static getInstance(): OpenApiLoader;
63
+ loadSpec(): OpenApiSpec;
64
+ private cacheExamples;
65
+ getResponseExample(responseType: string, criteria?: Record<string, unknown>): unknown;
66
+ getErrorResponse(errorType: string): string | null;
67
+ getProgressRules(): unknown;
68
+ private getNestedValue;
69
+ static replaceVariables(template: string, variables: Record<string, unknown>): string;
70
+ getSharedResource(resourceId: string): {
71
+ uri: string;
72
+ title?: string;
73
+ mimeType: string;
74
+ text?: string;
75
+ } | null;
76
+ getGlobalConfig(): unknown;
77
+ getDocumentTemplate(templateType: string): unknown;
78
+ resolveResources(resources?: Array<unknown>): Array<{
79
+ uri: string;
80
+ title?: string;
81
+ mimeType: string;
82
+ text?: string;
83
+ }> | undefined;
84
+ getTaskGuidanceTemplate(): OpenApiSpec['x-task-guidance-template'] | null;
85
+ getExamplesCount(responseType: string): number;
86
+ }
87
+ export declare const openApiLoader: OpenApiLoader;
88
+ //# sourceMappingURL=openApiLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openApiLoader.d.ts","sourceRoot":"","sources":["../../../src/features/shared/openApiLoader.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE;QACL,OAAO,EAAE;YACP,IAAI,EAAE;gBACJ,SAAS,EAAE;oBACT,KAAK,EAAE;wBACL,OAAO,EAAE;4BACP,kBAAkB,EAAE;gCAClB,MAAM,EAAE;oCACN,IAAI,EAAE,MAAM,CAAC;iCACd,CAAC;6BACH,CAAC;yBACH,CAAC;qBACH,CAAC;iBACH,CAAC;aACH,CAAC;SACH,CAAC;KACH,CAAC;IACF,UAAU,EAAE;QACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC,CAAC;IACF,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE;QAClC,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;IACH,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE;QACnC,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;IACH,iBAAiB,EAAE,OAAO,CAAC;IAC3B,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChD,0BAA0B,CAAC,EAAE;QAC3B,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,EAAE;YACZ,MAAM,EAAE,MAAM,CAAC;YACf,SAAS,EAAE,MAAM,CAAC;YAClB,gBAAgB,EAAE,MAAM,CAAC;YACzB,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AG,OAAO;IAMlD,gBAAgB,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,SAAS;IAqBjI,uBAAuB,IAAI,WAAW,CAAC,0BAA0B,CAAC,GAAG,IAAI;IAMzE,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;CAG/C;AAED,eAAO,MAAM,aAAa,eAA8B,CAAC"}
@@ -0,0 +1,166 @@
1
+ import * as yaml from 'js-yaml';
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ import { dirname } from 'path';
6
+ import { isObject } from './typeGuards.js';
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+ // Singleton pattern for loading OpenAPI specification
10
+ export class OpenApiLoader {
11
+ static instance;
12
+ spec = null;
13
+ examples = new Map();
14
+ constructor() { }
15
+ static getInstance() {
16
+ if (!OpenApiLoader.instance) {
17
+ OpenApiLoader.instance = new OpenApiLoader();
18
+ }
19
+ return OpenApiLoader.instance;
20
+ }
21
+ // Load OpenAPI specification
22
+ loadSpec() {
23
+ if (this.spec) {
24
+ return this.spec;
25
+ }
26
+ const specPath = path.join(__dirname, '../../../api/spec-workflow.openapi.yaml');
27
+ const specContent = fs.readFileSync(specPath, 'utf8');
28
+ this.spec = yaml.load(specContent);
29
+ // Parse and cache all examples
30
+ this.cacheExamples();
31
+ return this.spec;
32
+ }
33
+ // Cache all response examples
34
+ cacheExamples() {
35
+ if (!this.spec)
36
+ return;
37
+ const schemas = this.spec.components.schemas;
38
+ for (const [schemaName, schema] of Object.entries(schemas)) {
39
+ if (!isObject(schema))
40
+ continue;
41
+ // Support standard OpenAPI 3.1.0 examples field
42
+ if ('examples' in schema && Array.isArray(schema.examples)) {
43
+ this.examples.set(schemaName, schema.examples);
44
+ }
45
+ // Maintain backward compatibility with custom x-examples field
46
+ else if ('x-examples' in schema && Array.isArray(schema['x-examples'])) {
47
+ this.examples.set(schemaName, schema['x-examples']);
48
+ }
49
+ }
50
+ }
51
+ // Get response example
52
+ getResponseExample(responseType, criteria) {
53
+ const examples = this.examples.get(responseType);
54
+ if (!examples || examples.length === 0) {
55
+ return null;
56
+ }
57
+ // If no filter criteria, return the first example
58
+ if (!criteria) {
59
+ return examples[0];
60
+ }
61
+ // Filter examples by criteria
62
+ for (const example of examples) {
63
+ let matches = true;
64
+ for (const [key, value] of Object.entries(criteria)) {
65
+ if (this.getNestedValue(example, key) !== value) {
66
+ matches = false;
67
+ break;
68
+ }
69
+ }
70
+ if (matches) {
71
+ return example;
72
+ }
73
+ }
74
+ // No match found, return the first one
75
+ return examples[0];
76
+ }
77
+ // Get error response template
78
+ getErrorResponse(errorType) {
79
+ if (!this.spec || !this.spec['x-error-responses']) {
80
+ return null;
81
+ }
82
+ const errorResponse = this.spec['x-error-responses'][errorType];
83
+ return errorResponse?.displayText || null;
84
+ }
85
+ // Get progress calculation rules
86
+ getProgressRules() {
87
+ if (!this.spec)
88
+ return null;
89
+ const progressSchema = this.spec.components.schemas.Progress;
90
+ if (isObject(progressSchema) && 'x-progress-rules' in progressSchema) {
91
+ return progressSchema['x-progress-rules'];
92
+ }
93
+ return null;
94
+ }
95
+ // Utility function: get nested object value
96
+ getNestedValue(obj, path) {
97
+ const keys = path.split('.');
98
+ let current = obj;
99
+ for (const key of keys) {
100
+ if (isObject(current) && key in current) {
101
+ current = current[key];
102
+ }
103
+ else {
104
+ return undefined;
105
+ }
106
+ }
107
+ return current;
108
+ }
109
+ // Replace template variables
110
+ static replaceVariables(template, variables) {
111
+ let result = template;
112
+ for (const [key, value] of Object.entries(variables)) {
113
+ const regex = new RegExp(`\\$\\{${key}\\}`, 'g');
114
+ result = result.replace(regex, String(value));
115
+ }
116
+ return result;
117
+ }
118
+ // Get shared resource - directly return MCP format
119
+ getSharedResource(resourceId) {
120
+ if (!this.spec || !this.spec['x-shared-resources']) {
121
+ return null;
122
+ }
123
+ return this.spec['x-shared-resources'][resourceId] || null;
124
+ }
125
+ // Get global configuration
126
+ getGlobalConfig() {
127
+ if (!this.spec)
128
+ return {};
129
+ return this.spec['x-global-config'] || {};
130
+ }
131
+ // Get document template
132
+ getDocumentTemplate(templateType) {
133
+ if (!this.spec)
134
+ return null;
135
+ return this.spec['x-document-templates']?.[templateType] || null;
136
+ }
137
+ // Resolve resource list - no conversion needed, use MCP format directly
138
+ resolveResources(resources) {
139
+ if (!resources || resources.length === 0) {
140
+ return undefined;
141
+ }
142
+ const resolved = [];
143
+ for (const resource of resources) {
144
+ if (isObject(resource) && 'ref' in resource && typeof resource.ref === 'string') {
145
+ // Get from shared resources - already in MCP format
146
+ const sharedResource = this.getSharedResource(resource.ref);
147
+ if (sharedResource) {
148
+ resolved.push(sharedResource);
149
+ }
150
+ }
151
+ }
152
+ return resolved.length > 0 ? resolved : undefined;
153
+ }
154
+ // Get task guidance template
155
+ getTaskGuidanceTemplate() {
156
+ if (!this.spec)
157
+ return null;
158
+ return this.spec['x-task-guidance-template'] || null;
159
+ }
160
+ // Debug method: get cached examples count
161
+ getExamplesCount(responseType) {
162
+ return this.examples.get(responseType)?.length || 0;
163
+ }
164
+ }
165
+ export const openApiLoader = OpenApiLoader.getInstance();
166
+ //# sourceMappingURL=openApiLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openApiLoader.js","sourceRoot":"","sources":["../../../src/features/shared/openApiLoader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAA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