@teambit/cli-mcp-server 0.0.91 → 0.0.93

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.
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getRemoteComponentWithDetails = getRemoteComponentWithDetails;
7
+ function _componentId() {
8
+ const data = require("@teambit/component-id");
9
+ _componentId = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _legacy() {
15
+ const data = require("@teambit/legacy.consumer");
16
+ _legacy = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _scope() {
22
+ const data = require("@teambit/scope.remotes");
23
+ _scope = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _pkgModules() {
29
+ const data = require("@teambit/pkg.modules.component-package-name");
30
+ _pkgModules = function () {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
35
+ function _componentModules() {
36
+ const data = require("@teambit/component.modules.component-url");
37
+ _componentModules = function () {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
42
+ /**
43
+ * Fetches and processes remote component details for MCP server.
44
+ *
45
+ * This function is specifically needed for consumer-project mode where there is no local
46
+ * workspace or scope available. It uses ConsumerComponent instances fetched from remote
47
+ * to provide rich component information including extensions data, which enables access
48
+ * to docs, compositions, environment details, and full dependency information.
49
+ */
50
+ async function getRemoteComponentWithDetails(componentName) {
51
+ const componentId = _componentId().ComponentID.fromString(componentName);
52
+ const consumer = await (0, _legacy().loadConsumerIfExist)();
53
+ const remote = await (0, _scope().getRemoteByName)(componentId.scope, consumer);
54
+ const consumerComponent = await remote.show(componentId);
55
+ if (!consumerComponent) {
56
+ throw new Error(`Component ${componentName} not found in remote`);
57
+ }
58
+
59
+ // Build result in the same format as getCompDetails from api-for-ide.ts
60
+ const result = {};
61
+
62
+ // ID as string (to match workspace format)
63
+ result.id = consumerComponent.id.toString();
64
+
65
+ // Package name using componentIdToPackageName utility
66
+ const packageName = (0, _pkgModules().componentIdToPackageName)(consumerComponent);
67
+ result['package name'] = packageName;
68
+
69
+ // Files
70
+ const mainFiles = [];
71
+ const devFiles = {
72
+ config: [] // Add config entry like workspace version
73
+ };
74
+ consumerComponent.files.forEach(file => {
75
+ const relativePath = file.relative;
76
+
77
+ // Categorize files similar to how getCompDetails does it
78
+ if (relativePath.includes('.docs.') || relativePath.includes('.doc.') || relativePath.endsWith('.mdx')) {
79
+ if (!devFiles['teambit.docs/docs']) devFiles['teambit.docs/docs'] = [];
80
+ devFiles['teambit.docs/docs'].push(relativePath);
81
+ } else if (relativePath.includes('.composition.') || relativePath.includes('.comp.')) {
82
+ if (!devFiles['teambit.compositions/compositions']) devFiles['teambit.compositions/compositions'] = [];
83
+ devFiles['teambit.compositions/compositions'].push(relativePath);
84
+ } else if (relativePath.includes('.spec.') || relativePath.includes('.test.')) {
85
+ if (!devFiles['teambit.defender/tester']) devFiles['teambit.defender/tester'] = [];
86
+ devFiles['teambit.defender/tester'].push(relativePath);
87
+ } else {
88
+ mainFiles.push(relativePath);
89
+ }
90
+ });
91
+ result.files = mainFiles;
92
+ result['dev files'] = devFiles;
93
+
94
+ // Extract docs content from files
95
+ const docsFiles = devFiles['teambit.docs/docs'];
96
+ if (docsFiles && docsFiles.length > 0) {
97
+ result.docs = {};
98
+ docsFiles.forEach(filePath => {
99
+ const file = consumerComponent.files.find(f => f.relative === filePath);
100
+ if (file && file.contents) {
101
+ result.docs[filePath] = file.contents.toString();
102
+ }
103
+ });
104
+ }
105
+
106
+ // Extract composition content
107
+ const compositionFiles = devFiles['teambit.compositions/compositions'];
108
+ if (compositionFiles && compositionFiles.length > 0) {
109
+ result.usageExamples = {};
110
+ compositionFiles.forEach(filePath => {
111
+ const file = consumerComponent.files.find(f => f.relative === filePath);
112
+ if (file && file.contents) {
113
+ result.usageExamples[filePath] = file.contents.toString();
114
+ }
115
+ });
116
+ }
117
+
118
+ // Extract environment from extensions
119
+ if (consumerComponent.extensions) {
120
+ const envsExtension = consumerComponent.extensions.findExtension('teambit.envs/envs');
121
+ if (envsExtension && envsExtension.data && envsExtension.data.id) {
122
+ result.env = envsExtension.data.id;
123
+ }
124
+
125
+ // Extract dependencies from dependency resolver extension
126
+ const depResolverExtension = consumerComponent.extensions.findExtension('teambit.dependencies/dependency-resolver');
127
+ if (depResolverExtension && depResolverExtension.data && depResolverExtension.data.dependencies) {
128
+ result.dependencies = depResolverExtension.data.dependencies.map(dep => {
129
+ const {
130
+ packageName: depPackageName,
131
+ id,
132
+ version,
133
+ lifecycle,
134
+ __type: type,
135
+ source
136
+ } = dep;
137
+ const pkg = depPackageName || id;
138
+ const versionStr = version ? `@${version}` : '';
139
+ const compIdStr = type === 'component' && id ? `, component-id: ${id}` : '';
140
+ return `${pkg}${versionStr} (lifecycle: ${lifecycle || 'runtime'}, type: ${type || 'component'}, source: ${source || 'auto'}${compIdStr})`;
141
+ });
142
+ }
143
+ }
144
+
145
+ // Add URL using ComponentUrl utility
146
+ result.url = _componentModules().ComponentUrl.toUrl(componentId, {
147
+ includeVersion: false
148
+ });
149
+
150
+ // Component location (since it's remote)
151
+ result.componentLocation = 'a remote component';
152
+ return result;
153
+ }
154
+
155
+ //# sourceMappingURL=remote-component-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_componentId","data","require","_legacy","_scope","_pkgModules","_componentModules","getRemoteComponentWithDetails","componentName","componentId","ComponentID","fromString","consumer","loadConsumerIfExist","remote","getRemoteByName","scope","consumerComponent","show","Error","result","id","toString","packageName","componentIdToPackageName","mainFiles","devFiles","config","files","forEach","file","relativePath","relative","includes","endsWith","push","docsFiles","length","docs","filePath","find","f","contents","compositionFiles","usageExamples","extensions","envsExtension","findExtension","env","depResolverExtension","dependencies","map","dep","depPackageName","version","lifecycle","__type","type","source","pkg","versionStr","compIdStr","url","ComponentUrl","toUrl","includeVersion","componentLocation"],"sources":["remote-component-utils.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\nimport { loadConsumerIfExist } from '@teambit/legacy.consumer';\nimport { getRemoteByName } from '@teambit/scope.remotes';\nimport { componentIdToPackageName } from '@teambit/pkg.modules.component-package-name';\nimport { ComponentUrl } from '@teambit/component.modules.component-url';\n\n/**\n * Fetches and processes remote component details for MCP server.\n * \n * This function is specifically needed for consumer-project mode where there is no local \n * workspace or scope available. It uses ConsumerComponent instances fetched from remote\n * to provide rich component information including extensions data, which enables access\n * to docs, compositions, environment details, and full dependency information.\n */\nexport async function getRemoteComponentWithDetails(componentName: string): Promise<any> {\n const componentId = ComponentID.fromString(componentName);\n const consumer = await loadConsumerIfExist();\n const remote = await getRemoteByName(componentId.scope as string, consumer);\n\n const consumerComponent = await remote.show(componentId);\n\n if (!consumerComponent) {\n throw new Error(`Component ${componentName} not found in remote`);\n }\n\n // Build result in the same format as getCompDetails from api-for-ide.ts\n const result: any = {};\n\n // ID as string (to match workspace format)\n result.id = consumerComponent.id.toString();\n\n // Package name using componentIdToPackageName utility\n const packageName = componentIdToPackageName(consumerComponent);\n result['package name'] = packageName;\n\n // Files\n const mainFiles: string[] = [];\n const devFiles: any = {\n config: [], // Add config entry like workspace version\n };\n\n consumerComponent.files.forEach((file: any) => {\n const relativePath = file.relative;\n\n // Categorize files similar to how getCompDetails does it\n if (relativePath.includes('.docs.') || relativePath.includes('.doc.') || relativePath.endsWith('.mdx')) {\n if (!devFiles['teambit.docs/docs']) devFiles['teambit.docs/docs'] = [];\n devFiles['teambit.docs/docs'].push(relativePath);\n } else if (relativePath.includes('.composition.') || relativePath.includes('.comp.')) {\n if (!devFiles['teambit.compositions/compositions']) devFiles['teambit.compositions/compositions'] = [];\n devFiles['teambit.compositions/compositions'].push(relativePath);\n } else if (relativePath.includes('.spec.') || relativePath.includes('.test.')) {\n if (!devFiles['teambit.defender/tester']) devFiles['teambit.defender/tester'] = [];\n devFiles['teambit.defender/tester'].push(relativePath);\n } else {\n mainFiles.push(relativePath);\n }\n });\n\n result.files = mainFiles;\n result['dev files'] = devFiles;\n\n // Extract docs content from files\n const docsFiles = devFiles['teambit.docs/docs'];\n if (docsFiles && docsFiles.length > 0) {\n result.docs = {};\n docsFiles.forEach((filePath: string) => {\n const file = consumerComponent.files.find((f: any) => f.relative === filePath);\n if (file && file.contents) {\n result.docs[filePath] = file.contents.toString();\n }\n });\n }\n\n // Extract composition content\n const compositionFiles = devFiles['teambit.compositions/compositions'];\n if (compositionFiles && compositionFiles.length > 0) {\n result.usageExamples = {};\n compositionFiles.forEach((filePath: string) => {\n const file = consumerComponent.files.find((f: any) => f.relative === filePath);\n if (file && file.contents) {\n result.usageExamples[filePath] = file.contents.toString();\n }\n });\n }\n\n // Extract environment from extensions\n if (consumerComponent.extensions) {\n const envsExtension = consumerComponent.extensions.findExtension('teambit.envs/envs');\n if (envsExtension && envsExtension.data && envsExtension.data.id) {\n result.env = envsExtension.data.id;\n }\n\n // Extract dependencies from dependency resolver extension\n const depResolverExtension = consumerComponent.extensions.findExtension('teambit.dependencies/dependency-resolver');\n if (depResolverExtension && depResolverExtension.data && depResolverExtension.data.dependencies) {\n result.dependencies = depResolverExtension.data.dependencies.map((dep: any) => {\n const { packageName: depPackageName, id, version, lifecycle, __type: type, source } = dep;\n const pkg = depPackageName || id;\n const versionStr = version ? `@${version}` : '';\n const compIdStr = type === 'component' && id ? `, component-id: ${id}` : '';\n return `${pkg}${versionStr} (lifecycle: ${lifecycle || 'runtime'}, type: ${type || 'component'}, source: ${source || 'auto'}${compIdStr})`;\n });\n }\n }\n\n // Add URL using ComponentUrl utility\n result.url = ComponentUrl.toUrl(componentId, { includeVersion: false });\n\n // Component location (since it's remote)\n result.componentLocation = 'a remote component';\n\n return result;\n}"],"mappings":";;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAAAF,IAAA,G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  "homepage": "https://bit.cloud/teambit/mcp/cli-mcp-server",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.mcp",
8
8
  "name": "cli-mcp-server",
9
- "version": "0.0.91"
9
+ "version": "0.0.93"
10
10
  },
11
11
  "dependencies": {
12
12
  "comment-json": "4.2.5",
@@ -18,20 +18,25 @@
18
18
  "lodash": "4.17.21",
19
19
  "chalk": "4.1.2",
20
20
  "@teambit/harmony": "0.4.7",
21
- "@teambit/cli": "0.0.1268",
22
21
  "@teambit/legacy.constants": "0.0.15",
23
- "@teambit/logger": "0.0.1361",
24
- "@teambit/scope.network": "0.0.69",
25
- "@teambit/mcp.mcp-config-writer": "0.0.5"
22
+ "@teambit/mcp.mcp-config-writer": "0.0.5",
23
+ "@teambit/component-id": "1.2.4",
24
+ "@teambit/component.modules.component-url": "0.0.179",
25
+ "@teambit/cli": "0.0.1269",
26
+ "@teambit/logger": "0.0.1362",
27
+ "@teambit/scope.network": "0.0.70",
28
+ "@teambit/legacy.consumer": "0.0.70",
29
+ "@teambit/pkg.modules.component-package-name": "0.0.77",
30
+ "@teambit/scope.remotes": "0.0.70"
26
31
  },
27
32
  "devDependencies": {
28
33
  "@types/fs-extra": "9.0.7",
29
34
  "@types/node-fetch": "2.5.12",
30
35
  "@types/lodash": "4.14.165",
31
- "@teambit/component.testing.mock-components": "0.0.333",
32
- "@teambit/harmony.testing.load-aspect": "0.0.328",
33
- "@teambit/workspace.testing.mock-workspace": "0.0.116",
34
- "@teambit/harmony.envs.core-aspect-env": "0.0.78"
36
+ "@teambit/harmony.envs.core-aspect-env": "0.0.78",
37
+ "@teambit/component.testing.mock-components": "0.0.334",
38
+ "@teambit/harmony.testing.load-aspect": "0.0.329",
39
+ "@teambit/workspace.testing.mock-workspace": "0.0.117"
35
40
  },
36
41
  "peerDependencies": {
37
42
  "chai": "5.2.1",