@specverse/engines 4.3.5 → 5.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 (64) hide show
  1. package/assets/examples/10-api/README.md +3 -3
  2. package/assets/prompts/core/README.md +1 -1
  3. package/dist/inference/core/rule-engine.d.ts +0 -12
  4. package/dist/inference/core/rule-engine.d.ts.map +1 -1
  5. package/dist/inference/core/rule-engine.js +99 -968
  6. package/dist/inference/core/rule-engine.js.map +1 -1
  7. package/dist/inference/core/template-helpers.d.ts +56 -0
  8. package/dist/inference/core/template-helpers.d.ts.map +1 -0
  9. package/dist/inference/core/template-helpers.js +87 -0
  10. package/dist/inference/core/template-helpers.js.map +1 -0
  11. package/dist/inference/logical/generators/service-generator.d.ts.map +1 -1
  12. package/dist/inference/logical/generators/service-generator.js +0 -4
  13. package/dist/inference/logical/generators/service-generator.js.map +1 -1
  14. package/dist/libs/instance-factories/cli/templates/commander/command-generator.js +27 -5
  15. package/dist/libs/instance-factories/tools/README.md +1 -1
  16. package/dist/libs/instance-factories/tools/mcp.yaml +1 -1
  17. package/dist/libs/instance-factories/tools/templates/mcp/mcp-server-generator.js +336 -116
  18. package/dist/libs/instance-factories/tools/templates/vscode/vscode-extension-generator.js +172 -8
  19. package/dist/libs/instance-factories/tools/vscode.yaml +1 -1
  20. package/libs/instance-factories/cli/templates/commander/command-generator.ts +27 -5
  21. package/libs/instance-factories/tools/README.md +1 -1
  22. package/libs/instance-factories/tools/mcp.yaml +1 -1
  23. package/libs/instance-factories/tools/templates/mcp/mcp-server-generator.ts +386 -141
  24. package/libs/instance-factories/tools/templates/vscode/static/extension.ts +9 -2
  25. package/libs/instance-factories/tools/templates/vscode/vscode-extension-generator.ts +246 -10
  26. package/libs/instance-factories/tools/vscode.yaml +1 -1
  27. package/package.json +5 -4
  28. package/libs/instance-factories/tools/templates/mcp/static/docs/DEPLOYMENT_GUIDE.md +0 -630
  29. package/libs/instance-factories/tools/templates/mcp/static/docs/HYBRID_RESOURCE_SYSTEM.md +0 -330
  30. package/libs/instance-factories/tools/templates/mcp/static/docs/deployments/EXTENSION_DEPLOYMENT.md +0 -552
  31. package/libs/instance-factories/tools/templates/mcp/static/docs/deployments/LOCAL_DEPLOYMENT.md +0 -164
  32. package/libs/instance-factories/tools/templates/mcp/static/docs/deployments/WEB_DEPLOYMENT.md +0 -247
  33. package/libs/instance-factories/tools/templates/mcp/static/package.json +0 -94
  34. package/libs/instance-factories/tools/templates/mcp/static/scripts/build-enterprise.js +0 -284
  35. package/libs/instance-factories/tools/templates/mcp/static/scripts/build-extension.js +0 -139
  36. package/libs/instance-factories/tools/templates/mcp/static/scripts/build-local.js +0 -74
  37. package/libs/instance-factories/tools/templates/mcp/static/scripts/build-web.js +0 -156
  38. package/libs/instance-factories/tools/templates/mcp/static/scripts/copy-canonical-files.js +0 -41
  39. package/libs/instance-factories/tools/templates/mcp/static/scripts/test-deployments.js +0 -259
  40. package/libs/instance-factories/tools/templates/mcp/static/scripts/test-hybrid-resources.js +0 -231
  41. package/libs/instance-factories/tools/templates/mcp/static/scripts/test-hybrid-simple.js +0 -196
  42. package/libs/instance-factories/tools/templates/mcp/static/src/controllers/MCPServerController.ts +0 -293
  43. package/libs/instance-factories/tools/templates/mcp/static/src/events/EventEmitter.ts +0 -90
  44. package/libs/instance-factories/tools/templates/mcp/static/src/index.ts +0 -24
  45. package/libs/instance-factories/tools/templates/mcp/static/src/interfaces/ResourceProvider.ts +0 -15
  46. package/libs/instance-factories/tools/templates/mcp/static/src/models/LibrarySuggestion.ts +0 -106
  47. package/libs/instance-factories/tools/templates/mcp/static/src/models/SpecVerseResource.ts +0 -75
  48. package/libs/instance-factories/tools/templates/mcp/static/src/server/mcp-server.ts +0 -239
  49. package/libs/instance-factories/tools/templates/mcp/static/src/services/CLIProxyService.ts +0 -1501
  50. package/libs/instance-factories/tools/templates/mcp/static/src/services/EmbeddedResourcesAdapter.ts +0 -211
  51. package/libs/instance-factories/tools/templates/mcp/static/src/services/EntityModuleService.ts +0 -308
  52. package/libs/instance-factories/tools/templates/mcp/static/src/services/HybridResourcesProvider.ts +0 -210
  53. package/libs/instance-factories/tools/templates/mcp/static/src/services/LibraryToolsService.ts +0 -356
  54. package/libs/instance-factories/tools/templates/mcp/static/src/services/OrchestratorBridge.ts +0 -522
  55. package/libs/instance-factories/tools/templates/mcp/static/src/services/OrchestratorToolsService.ts +0 -530
  56. package/libs/instance-factories/tools/templates/mcp/static/src/services/PromptToolsService.ts +0 -594
  57. package/libs/instance-factories/tools/templates/mcp/static/src/services/ResourcesProviderService.ts +0 -170
  58. package/libs/instance-factories/tools/templates/mcp/static/src/tests/unit/CLIProxyService.init.test.ts +0 -544
  59. package/libs/instance-factories/tools/templates/mcp/static/src/tests/unit/CLIProxyService.test.ts +0 -189
  60. package/libs/instance-factories/tools/templates/mcp/static/src/tests/unit/ResourcesProviderService.test.ts +0 -89
  61. package/libs/instance-factories/tools/templates/mcp/static/src/types/index.ts +0 -110
  62. package/libs/instance-factories/tools/templates/mcp/static/tsconfig.json +0 -28
  63. package/libs/instance-factories/tools/templates/vscode/static/schemas/specverse-v3-schema.json +0 -4279
  64. /package/libs/instance-factories/tools/templates/vscode/static/themes/{specverse-complete-theme.json → specverse-dark-theme.json} +0 -0
@@ -1,170 +0,0 @@
1
- /**
2
- * ResourcesProviderService
3
- * Clean implementation from extracted specification
4
- */
5
-
6
- import { readFile } from 'fs/promises';
7
- import { existsSync } from 'fs';
8
- import { join, dirname } from 'path';
9
- import { fileURLToPath } from 'url';
10
- import { parse } from 'yaml';
11
- import { SpecVerseResourceModel } from '../models/SpecVerseResource.js';
12
- import type { ResourceProvider } from '../interfaces/ResourceProvider.js';
13
- import type { SpecVerseResource, MCPToolResult } from '../types/index.js';
14
-
15
- const __filename = fileURLToPath(import.meta.url);
16
- const __dirname = dirname(__filename);
17
-
18
- export class ResourcesProviderService implements ResourceProvider {
19
- private resourceCatalog: Map<string, SpecVerseResourceModel> = new Map();
20
- private resourcesPath: string;
21
- private isInitialized = false;
22
-
23
- constructor(resourcesPath?: string) {
24
- if (resourcesPath) {
25
- this.resourcesPath = resourcesPath;
26
- } else {
27
- // Auto-detect based on directory structure
28
- // Development: src/services -> ../../resources
29
- // NPM package: dist/local/services -> ../resources
30
- const candidatePaths = [
31
- join(__dirname, '../resources'), // NPM package structure
32
- join(__dirname, '../../resources'), // Development structure
33
- ];
34
-
35
- this.resourcesPath = candidatePaths[0]; // Default to NPM structure
36
-
37
- // Check which path exists (sync check is OK here as it's only during initialization)
38
- try {
39
- for (const path of candidatePaths) {
40
- if (existsSync(path)) {
41
- this.resourcesPath = path;
42
- break;
43
- }
44
- }
45
- } catch (error) {
46
- // Fallback to first candidate if fs check fails
47
- this.resourcesPath = candidatePaths[0];
48
- }
49
- }
50
- }
51
-
52
- async initializeResources(): Promise<void> {
53
- if (this.isInitialized) {
54
- return;
55
- }
56
-
57
- // Initialize resource catalog with essential resources only
58
- // Schemas and catalogs are now provided through AI tools for better contextual guidance
59
- const resources: SpecVerseResource[] = [
60
- {
61
- uri: 'specverse://examples/chat-prompts',
62
- name: 'Chat Prompt Examples',
63
- description: 'Example prompts for terminal/chat-based AI interactions',
64
- mimeType: 'text/markdown'
65
- },
66
- {
67
- uri: 'specverse://examples/api-calls',
68
- name: 'API Integration Examples',
69
- description: 'Examples for API-based AI integrations',
70
- mimeType: 'application/javascript'
71
- }
72
- ];
73
-
74
- for (const resourceData of resources) {
75
- const resource = SpecVerseResourceModel.create(resourceData);
76
- this.resourceCatalog.set(resource.uri, resource);
77
- }
78
-
79
- this.isInitialized = true;
80
- }
81
-
82
- async listResources(): Promise<SpecVerseResource[]> {
83
- await this.initializeResources();
84
-
85
- return Array.from(this.resourceCatalog.values()).map(resource => ({
86
- uri: resource.uri,
87
- name: resource.name,
88
- description: resource.description,
89
- mimeType: resource.mimeType,
90
- content: resource.content,
91
- metadata: resource.metadata
92
- }));
93
- }
94
-
95
- async getResourceContent(uri: string): Promise<string> {
96
- await this.initializeResources();
97
-
98
- const resource = this.resourceCatalog.get(uri);
99
- if (!resource) {
100
- throw new Error(`Resource not found: ${uri}`);
101
- }
102
-
103
- if (resource.isLoaded()) {
104
- return resource.content!;
105
- }
106
-
107
- // Load content from file system
108
- const filePath = this.resolveResourcePath(uri);
109
-
110
- try {
111
- const content = await readFile(filePath, 'utf-8');
112
-
113
- // Update resource with loaded content
114
- const updatedResource = resource.withContent(content);
115
- this.resourceCatalog.set(uri, updatedResource);
116
-
117
- return content;
118
- } catch (error) {
119
- throw new Error(`Failed to load resource ${uri}: ${error instanceof Error ? error.message : String(error)}`);
120
- }
121
- }
122
-
123
- async readResource(uri: string): Promise<MCPToolResult> {
124
- try {
125
- const content = await this.getResourceContent(uri);
126
- const resource = this.resourceCatalog.get(uri)!;
127
-
128
- return {
129
- content: [{
130
- type: 'resource',
131
- resource: {
132
- uri: resource.uri,
133
- name: resource.name,
134
- description: resource.description,
135
- mimeType: resource.mimeType,
136
- content
137
- }
138
- }]
139
- };
140
- } catch (error) {
141
- return {
142
- content: [{
143
- type: 'text',
144
- text: `Error reading resource: ${error instanceof Error ? error.message : String(error)}`
145
- }],
146
- isError: true
147
- };
148
- }
149
- }
150
-
151
- private resolveResourcePath(uri: string): string {
152
- switch (uri) {
153
- // Schemas and catalogs removed - now provided through AI tools
154
- case 'specverse://examples/chat-prompts':
155
- return join(this.resourcesPath, 'examples/chat-prompts/ecommerce-store-example.md');
156
- case 'specverse://examples/api-calls':
157
- return join(this.resourcesPath, 'examples/api-calls/orchestrator-workflow-example.js');
158
- default:
159
- throw new Error(`Unknown resource URI: ${uri}`);
160
- }
161
- }
162
-
163
- isResourceAvailable(uri: string): boolean {
164
- return this.resourceCatalog.has(uri);
165
- }
166
-
167
- getCachedResourceCount(): number {
168
- return Array.from(this.resourceCatalog.values()).filter(r => r.isLoaded()).length;
169
- }
170
- }