imcp 0.1.4 → 0.1.5

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 (228) hide show
  1. package/README.md +21 -4
  2. package/dist/cli/commands/install.js.map +1 -0
  3. package/dist/cli/commands/list.js.map +1 -0
  4. package/dist/cli/commands/pull.js.map +1 -0
  5. package/dist/cli/commands/serve.js.map +1 -0
  6. package/dist/cli/commands/start.d.ts +2 -0
  7. package/dist/cli/commands/start.js +32 -0
  8. package/dist/cli/commands/start.js.map +1 -0
  9. package/dist/cli/commands/sync.d.ts +2 -0
  10. package/dist/cli/commands/sync.js +17 -0
  11. package/dist/cli/commands/sync.js.map +1 -0
  12. package/dist/cli/commands/uninstall.js.map +1 -0
  13. package/dist/cli/index.js +0 -0
  14. package/dist/cli/index.js.map +1 -0
  15. package/dist/core/ConfigurationLoader.d.ts +32 -0
  16. package/{src/core/loaders/ConfigurationLoader.ts → dist/core/ConfigurationLoader.js} +236 -298
  17. package/dist/core/ConfigurationLoader.js.map +1 -0
  18. package/dist/core/ConfigurationProvider.d.ts +35 -0
  19. package/{src/core/loaders/ConfigurationProvider.ts → dist/core/ConfigurationProvider.js} +375 -462
  20. package/dist/core/ConfigurationProvider.js.map +1 -0
  21. package/dist/core/InstallationService.d.ts +50 -0
  22. package/dist/core/InstallationService.js +350 -0
  23. package/dist/core/InstallationService.js.map +1 -0
  24. package/dist/core/MCPManager.d.ts +28 -0
  25. package/dist/core/MCPManager.js +188 -0
  26. package/dist/core/MCPManager.js.map +1 -0
  27. package/dist/core/RequirementService.d.ts +40 -0
  28. package/dist/core/RequirementService.js +110 -0
  29. package/dist/core/RequirementService.js.map +1 -0
  30. package/dist/core/ServerSchemaLoader.d.ts +11 -0
  31. package/dist/core/ServerSchemaLoader.js +43 -0
  32. package/dist/core/ServerSchemaLoader.js.map +1 -0
  33. package/dist/core/ServerSchemaProvider.d.ts +17 -0
  34. package/dist/core/ServerSchemaProvider.js +120 -0
  35. package/dist/core/ServerSchemaProvider.js.map +1 -0
  36. package/dist/core/constants.d.ts +47 -0
  37. package/dist/core/constants.js +94 -0
  38. package/dist/core/constants.js.map +1 -0
  39. package/dist/core/installers/BaseInstaller.d.ts +74 -0
  40. package/dist/core/installers/BaseInstaller.js +253 -0
  41. package/dist/core/installers/BaseInstaller.js.map +1 -0
  42. package/dist/core/installers/ClientInstaller.d.ts +23 -0
  43. package/dist/core/installers/ClientInstaller.js +564 -0
  44. package/dist/core/installers/ClientInstaller.js.map +1 -0
  45. package/dist/core/installers/CommandInstaller.d.ts +37 -0
  46. package/{src/core/installers/requirements/CommandInstaller.ts → dist/core/installers/CommandInstaller.js} +173 -231
  47. package/dist/core/installers/CommandInstaller.js.map +1 -0
  48. package/dist/core/installers/GeneralInstaller.d.ts +33 -0
  49. package/dist/core/installers/GeneralInstaller.js +85 -0
  50. package/dist/core/installers/GeneralInstaller.js.map +1 -0
  51. package/dist/core/installers/InstallerFactory.d.ts +54 -0
  52. package/{src/core/installers/requirements/InstallerFactory.ts → dist/core/installers/InstallerFactory.js} +97 -114
  53. package/dist/core/installers/InstallerFactory.js.map +1 -0
  54. package/dist/core/installers/NpmInstaller.d.ts +26 -0
  55. package/dist/core/installers/NpmInstaller.js +127 -0
  56. package/dist/core/installers/NpmInstaller.js.map +1 -0
  57. package/dist/core/installers/PipInstaller.d.ts +28 -0
  58. package/dist/core/installers/PipInstaller.js +127 -0
  59. package/dist/core/installers/PipInstaller.js.map +1 -0
  60. package/{src/core/installers/requirements/RequirementInstaller.ts → dist/core/installers/RequirementInstaller.d.ts} +33 -42
  61. package/dist/core/installers/RequirementInstaller.js +3 -0
  62. package/dist/core/installers/RequirementInstaller.js.map +1 -0
  63. package/dist/core/installers/clients/BaseClientInstaller.js.map +1 -0
  64. package/dist/core/installers/clients/ClientInstaller.js.map +1 -0
  65. package/dist/core/installers/clients/ClientInstallerFactory.js.map +1 -0
  66. package/dist/core/installers/clients/ClineInstaller.js.map +1 -0
  67. package/dist/core/installers/clients/ExtensionInstaller.js.map +1 -0
  68. package/dist/core/installers/clients/GithubCopilotInstaller.js.map +1 -0
  69. package/dist/core/installers/clients/MSRooCodeInstaller.js.map +1 -0
  70. package/dist/core/installers/index.js.map +1 -0
  71. package/dist/core/installers/requirements/BaseInstaller.js.map +1 -0
  72. package/dist/core/installers/requirements/CommandInstaller.js.map +1 -0
  73. package/dist/core/installers/requirements/GeneralInstaller.js.map +1 -0
  74. package/dist/core/installers/requirements/InstallerFactory.js.map +1 -0
  75. package/dist/core/installers/requirements/NpmInstaller.js.map +1 -0
  76. package/dist/core/installers/requirements/NugetInstaller.js.map +1 -0
  77. package/dist/core/installers/requirements/PipInstaller.js.map +1 -0
  78. package/dist/core/installers/requirements/RequirementInstaller.js.map +1 -0
  79. package/dist/core/loaders/ConfigurationLoader.js.map +1 -0
  80. package/dist/core/loaders/ConfigurationProvider.js.map +1 -0
  81. package/dist/core/loaders/InstallOperationManager.js.map +1 -0
  82. package/dist/core/loaders/ServerSchemaLoader.js.map +1 -0
  83. package/dist/core/loaders/ServerSchemaProvider.js.map +1 -0
  84. package/dist/core/loaders/SystemSettingsManager.js.map +1 -0
  85. package/dist/core/metadatas/constants.js.map +1 -0
  86. package/dist/core/metadatas/recordingConstants.js.map +1 -0
  87. package/dist/core/metadatas/types.js.map +1 -0
  88. package/dist/core/onboard/FeedOnboardService.js.map +1 -0
  89. package/dist/core/onboard/OnboardProcessor.js.map +1 -0
  90. package/dist/core/onboard/OnboardStatus.js.map +1 -0
  91. package/dist/core/onboard/OnboardStatusManager.js.map +1 -0
  92. package/dist/core/types.d.ts +166 -0
  93. package/dist/core/types.js +16 -0
  94. package/dist/core/types.js.map +1 -0
  95. package/dist/core/validators/FeedValidator.js.map +1 -0
  96. package/dist/core/validators/IServerValidator.js.map +1 -0
  97. package/dist/core/validators/SSEServerValidator.js.map +1 -0
  98. package/dist/core/validators/ServerValidatorFactory.js.map +1 -0
  99. package/dist/core/validators/StdioServerValidator.js.map +1 -0
  100. package/dist/index.js.map +1 -0
  101. package/dist/services/InstallRequestValidator.d.ts +21 -0
  102. package/dist/services/InstallRequestValidator.js +99 -0
  103. package/dist/services/InstallRequestValidator.js.map +1 -0
  104. package/dist/services/InstallationService.js.map +1 -0
  105. package/dist/services/MCPManager.js.map +1 -0
  106. package/dist/services/RequirementService.js.map +1 -0
  107. package/dist/services/ServerService.js.map +1 -0
  108. package/dist/services/TelemetryService.js.map +1 -0
  109. package/dist/utils/UpdateCheckTracker.js.map +1 -0
  110. package/dist/utils/adoUtils.js.map +1 -0
  111. package/dist/utils/clientUtils.js.map +1 -0
  112. package/dist/utils/feedUtils.js.map +1 -0
  113. package/dist/utils/githubAuth.js.map +1 -0
  114. package/dist/utils/githubUtils.js.map +1 -0
  115. package/dist/utils/logger.js.map +1 -0
  116. package/dist/utils/macroExpressionUtils.js.map +1 -0
  117. package/dist/utils/osUtils.js.map +1 -0
  118. package/dist/utils/versionUtils.js.map +1 -0
  119. package/dist/web/contract/serverContract.js.map +1 -0
  120. package/dist/web/public/index.html +1 -1
  121. package/dist/web/public/js/modal/installHandler.js +227 -0
  122. package/dist/web/public/js/modal/loadingUI.js +74 -0
  123. package/dist/web/public/js/modal/messageQueue.js +101 -45
  124. package/dist/web/public/js/modal/modalUI.js +214 -0
  125. package/{src/web/public/js/modal/versionUtils.js → dist/web/public/js/modal/version.js} +1 -1
  126. package/dist/web/public/onboard.html +4 -4
  127. package/dist/web/server.js.map +1 -0
  128. package/package.json +5 -1
  129. package/.github/ISSUE_TEMPLATE/JitAccess.yml +0 -28
  130. package/.github/acl/access.yml +0 -20
  131. package/.github/compliance/inventory.yml +0 -5
  132. package/.github/policies/jit.yml +0 -19
  133. package/.roo/rules-code/rules.md +0 -88
  134. package/dist/core/onboard/InstallOperationManager.d.ts +0 -23
  135. package/dist/core/onboard/InstallOperationManager.js +0 -144
  136. package/docs/ONBOARDING_PAGE_DESIGN.md +0 -260
  137. package/docs/Telemetry.md +0 -136
  138. package/memory-bank/activeContext.md +0 -26
  139. package/memory-bank/decisionLog.md +0 -91
  140. package/memory-bank/productContext.md +0 -41
  141. package/memory-bank/progress.md +0 -35
  142. package/memory-bank/systemPatterns.md +0 -10
  143. package/src/cli/commands/install.ts +0 -139
  144. package/src/cli/commands/list.ts +0 -113
  145. package/src/cli/commands/pull.ts +0 -16
  146. package/src/cli/commands/serve.ts +0 -39
  147. package/src/cli/commands/uninstall.ts +0 -64
  148. package/src/cli/index.ts +0 -82
  149. package/src/core/installers/clients/BaseClientInstaller.ts +0 -341
  150. package/src/core/installers/clients/ClientInstaller.ts +0 -222
  151. package/src/core/installers/clients/ClientInstallerFactory.ts +0 -43
  152. package/src/core/installers/clients/ClineInstaller.ts +0 -35
  153. package/src/core/installers/clients/ExtensionInstaller.ts +0 -165
  154. package/src/core/installers/clients/GithubCopilotInstaller.ts +0 -79
  155. package/src/core/installers/clients/MSRooCodeInstaller.ts +0 -32
  156. package/src/core/installers/index.ts +0 -11
  157. package/src/core/installers/requirements/BaseInstaller.ts +0 -85
  158. package/src/core/installers/requirements/GeneralInstaller.ts +0 -133
  159. package/src/core/installers/requirements/NpmInstaller.ts +0 -271
  160. package/src/core/installers/requirements/NugetInstaller.ts +0 -203
  161. package/src/core/installers/requirements/PipInstaller.ts +0 -207
  162. package/src/core/loaders/InstallOperationManager.ts +0 -367
  163. package/src/core/loaders/ServerSchemaLoader.ts +0 -117
  164. package/src/core/loaders/ServerSchemaProvider.ts +0 -99
  165. package/src/core/loaders/SystemSettingsManager.ts +0 -278
  166. package/src/core/metadatas/constants.ts +0 -122
  167. package/src/core/metadatas/recordingConstants.ts +0 -65
  168. package/src/core/metadatas/types.ts +0 -202
  169. package/src/core/onboard/FeedOnboardService.ts +0 -501
  170. package/src/core/onboard/OnboardProcessor.ts +0 -356
  171. package/src/core/onboard/OnboardStatus.ts +0 -60
  172. package/src/core/onboard/OnboardStatusManager.ts +0 -416
  173. package/src/core/validators/FeedValidator.ts +0 -135
  174. package/src/core/validators/IServerValidator.ts +0 -21
  175. package/src/core/validators/SSEServerValidator.ts +0 -43
  176. package/src/core/validators/ServerValidatorFactory.ts +0 -51
  177. package/src/core/validators/StdioServerValidator.ts +0 -313
  178. package/src/index.ts +0 -44
  179. package/src/services/InstallationService.ts +0 -102
  180. package/src/services/MCPManager.ts +0 -249
  181. package/src/services/RequirementService.ts +0 -627
  182. package/src/services/ServerService.ts +0 -161
  183. package/src/services/TelemetryService.ts +0 -59
  184. package/src/utils/UpdateCheckTracker.ts +0 -86
  185. package/src/utils/adoUtils.ts +0 -293
  186. package/src/utils/clientUtils.ts +0 -72
  187. package/src/utils/feedUtils.ts +0 -31
  188. package/src/utils/githubAuth.ts +0 -212
  189. package/src/utils/githubUtils.ts +0 -164
  190. package/src/utils/logger.ts +0 -195
  191. package/src/utils/macroExpressionUtils.ts +0 -104
  192. package/src/utils/osUtils.ts +0 -700
  193. package/src/utils/versionUtils.ts +0 -114
  194. package/src/web/contract/serverContract.ts +0 -74
  195. package/src/web/public/css/detailsWidget.css +0 -235
  196. package/src/web/public/css/modal.css +0 -757
  197. package/src/web/public/css/notifications.css +0 -101
  198. package/src/web/public/css/onboard.css +0 -107
  199. package/src/web/public/css/serverCategoryList.css +0 -120
  200. package/src/web/public/css/serverDetails.css +0 -139
  201. package/src/web/public/index.html +0 -359
  202. package/src/web/public/js/api.js +0 -132
  203. package/src/web/public/js/detailsWidget.js +0 -264
  204. package/src/web/public/js/flights/flights.js +0 -127
  205. package/src/web/public/js/modal/index.js +0 -52
  206. package/src/web/public/js/modal/installModal.js +0 -162
  207. package/src/web/public/js/modal/installation.js +0 -266
  208. package/src/web/public/js/modal/loadingModal.js +0 -182
  209. package/src/web/public/js/modal/modalSetup.js +0 -595
  210. package/src/web/public/js/modal/modalUtils.js +0 -37
  211. package/src/web/public/js/modal.js +0 -42
  212. package/src/web/public/js/notifications.js +0 -137
  213. package/src/web/public/js/onboard/formProcessor.js +0 -1037
  214. package/src/web/public/js/onboard/index.js +0 -374
  215. package/src/web/public/js/onboard/publishHandler.js +0 -172
  216. package/src/web/public/js/onboard/state.js +0 -76
  217. package/src/web/public/js/onboard/templates.js +0 -342
  218. package/src/web/public/js/onboard/uiHandlers.js +0 -1076
  219. package/src/web/public/js/onboard/validationHandlers.js +0 -493
  220. package/src/web/public/js/serverCategoryDetails.js +0 -364
  221. package/src/web/public/js/serverCategoryList.js +0 -241
  222. package/src/web/public/js/settings.js +0 -314
  223. package/src/web/public/modal.html +0 -84
  224. package/src/web/public/onboard.html +0 -296
  225. package/src/web/public/settings.html +0 -135
  226. package/src/web/public/styles.css +0 -277
  227. package/src/web/server.ts +0 -478
  228. package/tsconfig.json +0 -18
@@ -1,117 +0,0 @@
1
- import fs from 'fs/promises';
2
- import path from 'path';
3
- import { LOCAL_FEEDS_SCHEMA_DIR } from '../metadatas/constants.js';
4
- import { Logger } from '../../utils/logger.js';
5
- import { ServerSchema } from './ServerSchemaProvider.js';
6
-
7
- export class ServerSchemaLoader {
8
-
9
- /**
10
- * Loads a single schema file.
11
- * @param filePath The absolute path to the schema file.
12
- * @returns A Promise that resolves to the ServerSchema or undefined if not found or error.
13
- */
14
- public static async loadSchema(filePath: string): Promise<ServerSchema | undefined> {
15
- try {
16
- const content = await fs.readFile(filePath, 'utf8');
17
- const schema = JSON.parse(content);
18
-
19
- return {
20
- schema: schema
21
- };
22
- } catch (error) {
23
- if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
24
- Logger.debug(`No schema file found at ${filePath}`);
25
- return undefined;
26
- }
27
- Logger.error(`Error loading schema from ${filePath}:`, error);
28
- // Optionally rethrow or return undefined based on desired error handling
29
- return undefined;
30
- }
31
- }
32
-
33
- /**
34
- * Loads all schemas from the default feeds directory.
35
- * @param defaultFeedsDir The path to the default feeds directory.
36
- * @param schemaMap The map to populate with loaded schemas.
37
- */
38
- public static async loadAllDefaultSchemas(defaultFeedsDir: string, schemaMap: Map<string, Map<string, ServerSchema>>): Promise<void> {
39
- schemaMap.clear(); // Clear map for initial load from default directory
40
-
41
- try {
42
- const categoryDirs = await fs.readdir(defaultFeedsDir, { withFileTypes: true });
43
-
44
- for (const categoryDir of categoryDirs) {
45
- if (categoryDir.isDirectory()) {
46
- const categoryName = categoryDir.name;
47
- const categoryPath = path.join(defaultFeedsDir, categoryName);
48
- const serverFiles = await fs.readdir(categoryPath);
49
- const serverSchemas = new Map<string, ServerSchema>();
50
-
51
- for (const file of serverFiles) {
52
- if (file.endsWith('.json')) {
53
- try {
54
- const schemaFilePath = path.join(categoryPath, file);
55
- const schema = await this.loadSchema(schemaFilePath);
56
- if (schema) {
57
- serverSchemas.set(file, schema); // file is serverName
58
- Logger.debug(`Loaded schema '${file}' for category '${categoryName}' from default directory`);
59
- }
60
- } catch (error) { // Error already logged in loadSchema
61
- Logger.error(`Skipping schema file ${file} in category ${categoryName} due to loading error.`);
62
- }
63
- }
64
- }
65
- if (serverSchemas.size > 0) {
66
- schemaMap.set(categoryName, serverSchemas);
67
- }
68
- }
69
- }
70
- } catch (error) {
71
- Logger.error(`Error reading schemas from default directory ${defaultFeedsDir}:`, error);
72
- }
73
- }
74
-
75
- /**
76
- * Loads schemas from an adhoc directory for a specific category.
77
- * @param adhocSchemasDir The path to the adhoc schemas directory.
78
- * @param categoryName The name of the category for these adhoc schemas.
79
- * @param schemaMap The map to update with loaded adhoc schemas.
80
- */
81
- public static async loadAdhocSchemas(adhocSchemasDir: string, categoryName: string, schemaMap: Map<string, Map<string, ServerSchema>>): Promise<void> {
82
- try {
83
- const serverFiles = await fs.readdir(adhocSchemasDir);
84
-
85
- if (schemaMap.has(categoryName)) {
86
- Logger.warn(`\x1b[33mAdhoc schema category '${categoryName}' (from dir: ${adhocSchemasDir}) conflicts with an existing category. Adhoc schemas in this category will override existing ones.\x1b[0m`);
87
- }
88
-
89
- let serverSchemas = schemaMap.get(categoryName);
90
- if (!serverSchemas) {
91
- serverSchemas = new Map<string, ServerSchema>();
92
- }
93
-
94
- for (const file of serverFiles) {
95
- if (file.endsWith('.json')) {
96
- try {
97
- const schemaFilePath = path.join(adhocSchemasDir, file);
98
- const schema = await this.loadSchema(schemaFilePath);
99
- if (schema) {
100
- serverSchemas.set(file, schema); // file is serverName
101
- Logger.debug(`Loaded adhoc schema '${file}' for category '${categoryName}'`);
102
- }
103
- } catch (error) { // Error already logged in loadSchema
104
- Logger.error(`Skipping adhoc schema file ${file} in category ${categoryName} due to loading error.`);
105
- }
106
- }
107
- }
108
-
109
- if (serverSchemas.size > 0) {
110
- schemaMap.set(categoryName, serverSchemas);
111
- }
112
- } catch (error) {
113
- // This case should ideally be caught by the fs.access check in ServerSchemaProvider.initialize
114
- Logger.error(`Error reading adhoc schemas from directory ${adhocSchemasDir} for category ${categoryName}:`, error);
115
- }
116
- }
117
- }
@@ -1,99 +0,0 @@
1
- import fs from 'fs/promises';
2
- import path from 'path';
3
- import { LOCAL_FEEDS_SCHEMA_DIR } from '../metadatas/constants.js';
4
- import { Logger } from '../../utils/logger.js';
5
- import { ServerSchemaLoader } from './ServerSchemaLoader.js';
6
-
7
- export interface ServerSchema {
8
- schema: Record<string, any>;
9
- }
10
-
11
- export class ServerSchemaProvider {
12
- private static instance: ServerSchemaProvider;
13
- private schemaMap: Map<string, Map<string, ServerSchema>>;
14
- private schemaLock: Promise<void> = Promise.resolve();
15
-
16
- private constructor() {
17
- this.schemaMap = new Map();
18
- }
19
-
20
- public static getInstance(): ServerSchemaProvider {
21
- if (!ServerSchemaProvider.instance) {
22
- ServerSchemaProvider.instance = new ServerSchemaProvider();
23
- // Initialize is now called with optional adhocSchemasDir,
24
- // but getInstance is often called without it initially.
25
- // The actual loading with adhoc dir will happen when MCPManager calls initialize.
26
- }
27
- return ServerSchemaProvider.instance;
28
- }
29
-
30
- private async withLock<T>(operation: () => Promise<T>): Promise<T> {
31
- const current = this.schemaLock;
32
- let resolve: () => void;
33
- this.schemaLock = new Promise<void>(r => resolve = r);
34
- try {
35
- await current;
36
- return await operation();
37
- } finally {
38
- resolve!();
39
- }
40
- }
41
-
42
- async initialize(adhocSchemasDir?: string): Promise<void> {
43
- await this.withLock(async () => {
44
- try {
45
- // Create default feeds directory if it doesn't exist
46
- await fs.mkdir(LOCAL_FEEDS_SCHEMA_DIR, { recursive: true });
47
-
48
- // Load all schemas from the default feeds directory
49
- await ServerSchemaLoader.loadAllDefaultSchemas(LOCAL_FEEDS_SCHEMA_DIR, this.schemaMap);
50
-
51
- // Load schemas from adhoc directory if provided
52
- if (adhocSchemasDir) {
53
- try {
54
- await fs.access(adhocSchemasDir); // Check if directory exists
55
- const adhocCategoryName = path.basename(adhocSchemasDir);
56
- Logger.info(`Loading adhoc schemas from: ${adhocSchemasDir} for category: ${adhocCategoryName}`);
57
- await ServerSchemaLoader.loadAdhocSchemas(adhocSchemasDir, adhocCategoryName, this.schemaMap);
58
- } catch (error) {
59
- if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
60
- Logger.warn(`Adhoc schemas directory not found: ${adhocSchemasDir}`);
61
- } else {
62
- Logger.error(`Error accessing adhoc schemas directory ${adhocSchemasDir}:`, error);
63
- }
64
- }
65
- }
66
- } catch (error) {
67
- Logger.error('Error during schema initialization:', error);
68
- throw error;
69
- }
70
- });
71
- }
72
-
73
- // The actual loading methods (loadSchema, loadAllSchemas, loadAdhocSchemas) have been moved to ServerSchemaLoader.
74
- // ServerSchemaProvider now delegates to ServerSchemaLoader for these operations.
75
-
76
- async getSchema(categoryName: string, schemaFileName: string): Promise<ServerSchema | undefined> {
77
- return await this.withLock(async () => {
78
- const categorySchemas = this.schemaMap.get(categoryName);
79
- if (!categorySchemas) {
80
- Logger.debug(`No schemas found for category ${categoryName}`);
81
- return undefined;
82
- }
83
- const schema = categorySchemas.get(schemaFileName);
84
- if (!schema) {
85
- Logger.debug(`Schema ${schemaFileName} not found in category ${categoryName}`);
86
- }
87
- return schema;
88
- });
89
- }
90
-
91
- async reloadSchemas(): Promise<void> {
92
- return await this.withLock(async () => {
93
- // Reloading should re-evaluate both default and any configured adhoc directory
94
- // For simplicity, we assume initialize would be called again if adhoc path changes.
95
- // This reload will just reload from the paths known during the last full initialize.
96
- await this.initialize(); // This will re-load default and adhoc if adhocSchemasDir was set
97
- });
98
- }
99
- }
@@ -1,278 +0,0 @@
1
- import fs from 'fs/promises';
2
- import path from 'path';
3
- import { SETTINGS_DIR } from '../metadatas/constants.js';
4
- import { SystemSettings } from '../metadatas/types.js';
5
- import { Logger } from '../../utils/logger.js';
6
- import { getSystemPythonExecutablePath, getNpmExecutablePath, getBrowserPath } from '../../utils/osUtils.js';
7
-
8
- const SETTINGS_FILE_NAME = 'system_settings.json';
9
- const SETTINGS_FILE_PATH = path.join(SETTINGS_DIR, 'settings', SETTINGS_FILE_NAME);
10
-
11
- export class SystemSettingsManager {
12
- private static instance: SystemSettingsManager;
13
- private settings: SystemSettings;
14
- private settingsFilePath: string;
15
- private settingsLock: Promise<void> = Promise.resolve();
16
-
17
- private constructor() {
18
- this.settingsFilePath = SETTINGS_FILE_PATH;
19
- this.settings = {};
20
- // No await here, initialization is best-effort. Lock will protect subsequent calls.
21
- this.loadSettings().catch(error => {
22
- Logger.error('Failed to initialize SystemSettingsManager during construction:', error);
23
- // Initialize with empty settings if load fails, defaults will be applied on first access
24
- this.settings = {};
25
- });
26
- }
27
-
28
- public static getInstance(): SystemSettingsManager {
29
- if (!SystemSettingsManager.instance) {
30
- SystemSettingsManager.instance = new SystemSettingsManager();
31
- }
32
- return SystemSettingsManager.instance;
33
- }
34
-
35
- private async withLock<T>(operation: () => Promise<T>): Promise<T> {
36
- const currentLock = this.settingsLock;
37
- let releaseLock: () => void;
38
- this.settingsLock = new Promise<void>(resolve => releaseLock = resolve);
39
- try {
40
- await currentLock;
41
- return await operation();
42
- } finally {
43
- releaseLock!();
44
- }
45
- }
46
-
47
- // Internal method without lock
48
- private async _loadSettingsInternal(): Promise<void> {
49
- try {
50
- await fs.mkdir(path.dirname(this.settingsFilePath), { recursive: true });
51
- const data = await fs.readFile(this.settingsFilePath, 'utf-8');
52
- this.settings = JSON.parse(data);
53
- await this._applyDefaultsIfNeededInternal(); // Call internal version
54
- } catch (error) {
55
- if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
56
- Logger.info(`Settings file not found at ${this.settingsFilePath}. Initializing with defaults.`);
57
- this.settings = {};
58
- await this._applyDefaultsIfNeededInternal(); // Call internal version
59
- } else {
60
- Logger.error(`Error loading settings from ${this.settingsFilePath}:`, error);
61
- this.settings = {};
62
- await this._applyDefaultsIfNeededInternal(); // Call internal version
63
- }
64
- }
65
- }
66
-
67
- /**
68
- * Loads settings from the file. This operation is atomic.
69
- * If the settings file doesn't exist, it initializes with defaults and creates the file.
70
- * @returns A promise that resolves when settings are loaded.
71
- */
72
- public async loadSettings(): Promise<void> {
73
- return this.withLock(() => this._loadSettingsInternal());
74
- }
75
-
76
- // Internal method without lock
77
- private async _applyDefaultsIfNeededInternal(): Promise<void> {
78
- let updated = false;
79
- const normalizePath = (p?: string) => p ? p.replace(/\\/g, '/') : undefined;
80
-
81
- if (!this.settings.pythonEnvs) {
82
- this.settings.pythonEnvs = {};
83
- updated = true;
84
- }
85
-
86
- if (!this.settings.pythonEnvs["system"]) {
87
- try {
88
- const pythonPath = normalizePath(await getSystemPythonExecutablePath() || undefined);
89
- if (pythonPath) {
90
- this.settings.pythonEnvs["system"] = pythonPath;
91
- updated = true;
92
- }
93
- } catch (e) {
94
- Logger.warn(`Could not get default pythonEnv: ${e}`);
95
- }
96
- }
97
-
98
- if (!this.settings.nodePath) {
99
- try {
100
- const npmExecDir = await getNpmExecutablePath();
101
- let nodeExecutable = process.platform === 'win32' ? 'node.exe' : 'node';
102
- const platformNodePath = process.platform === 'win32'
103
- ? path.join(npmExecDir || '', nodeExecutable)
104
- : path.join(npmExecDir || '', 'bin', nodeExecutable);
105
- this.settings.nodePath = npmExecDir ? normalizePath(platformNodePath) : undefined;
106
- if (this.settings.nodePath) updated = true;
107
- } catch (e) {
108
- Logger.warn(`Could not get default nodePath: ${e}`);
109
- }
110
- } else {
111
- this.settings.nodePath = normalizePath(this.settings.nodePath);
112
- }
113
-
114
- if (!this.settings.browserPath) {
115
- try {
116
- this.settings.browserPath = normalizePath(await getBrowserPath() || undefined);
117
- if (this.settings.browserPath) updated = true;
118
- } catch (e) {
119
- Logger.warn(`Could not get default browserPath: ${e}`);
120
- }
121
- } else {
122
- this.settings.browserPath = normalizePath(this.settings.browserPath);
123
- }
124
-
125
- if (!this.settings.systemEnvironments) {
126
- this.settings.systemEnvironments = { ...process.env } as Record<string, string>;
127
- updated = true;
128
- }
129
- if (this.settings.userConfigurations === undefined) {
130
- this.settings.userConfigurations = {};
131
- updated = true;
132
- }
133
-
134
- if (updated) {
135
- await this._saveSettingsInternal();
136
- }
137
- }
138
-
139
- /**
140
- * Applies default values to settings if they are not already set.
141
- * This operation is atomic and saves settings if defaults are applied.
142
- * @returns A promise that resolves when defaults are applied and saved if necessary.
143
- */
144
- public async applyDefaultsIfNeeded(): Promise<void> {
145
- return this.withLock(() => this._applyDefaultsIfNeededInternal());
146
- }
147
-
148
- /**
149
- * Retrieves the current system settings.
150
- * If settings haven't been loaded or are empty, it attempts to load them.
151
- * Paths within the settings are normalized (e.g., backslashes to forward slashes).
152
- * @returns A promise that resolves to the `SystemSettings` object.
153
- */
154
- public async getSystemSettings(): Promise<SystemSettings> {
155
- // Ensure settings are loaded if they are empty.
156
- if (Object.keys(this.settings).length === 0) {
157
- // Use the public, locked version of loadSettings here
158
- await this.loadSettings();
159
- }
160
- // Return a deep copy to prevent external modification of the internal state.
161
- // Ensure this.settings is used, not a potentially stale local copy.
162
- const settingsToReturn = JSON.parse(JSON.stringify(this.settings));
163
-
164
- // Ensure paths are normalized when retrieved
165
- const normalizedSettings = { ...settingsToReturn };
166
-
167
- // Normalize paths in pythonEnvs
168
- if (normalizedSettings.pythonEnvs) {
169
- const normalizedPythonEnvs: Record<string, string> = {};
170
- Object.keys(normalizedSettings.pythonEnvs).forEach(key => {
171
- normalizedPythonEnvs[key] = normalizedSettings.pythonEnvs?.[key]?.replace(/\\/g, '/') || '';
172
- });
173
- normalizedSettings.pythonEnvs = normalizedPythonEnvs;
174
- }
175
-
176
- normalizedSettings.nodePath = normalizedSettings.nodePath?.replace(/\\/g, '/');
177
- normalizedSettings.browserPath = normalizedSettings.browserPath?.replace(/\\/g, '/');
178
- return normalizedSettings;
179
- }
180
-
181
- /**
182
- * Creates or updates system settings with the provided partial settings.
183
- * This operation is atomic and protected by a lock.
184
- * It loads existing settings if not already loaded, merges the new settings,
185
- * applies any necessary defaults, and then saves the updated settings.
186
- * @param newSettings A `Partial<SystemSettings>` object containing the settings to update.
187
- * @returns A promise that resolves to the fully updated and normalized `SystemSettings`.
188
- */
189
- public async createOrUpdateSystemSettings(newSettings: Partial<SystemSettings>): Promise<SystemSettings> {
190
- return this.withLock(async () => {
191
- // Ensure current settings are loaded before modification by calling the internal, non-locking version
192
- if (Object.keys(this.settings).length === 0) {
193
- await this._loadSettingsInternal();
194
- }
195
-
196
- const normalizePath = (p?: string) => p ? p.replace(/\\/g, '/') : undefined;
197
-
198
- // Initialize pythonEnvs if it doesn't exist on the current settings
199
- if (!this.settings.pythonEnvs) {
200
- this.settings.pythonEnvs = {};
201
- }
202
-
203
- // Create a new settings object by merging current and new settings.
204
- const updatedSettings: SystemSettings = {
205
- ...this.settings, // Start with current settings
206
- ...newSettings, // Override with new settings
207
- // Explicitly handle potentially undefined paths from newSettings
208
- nodePath: normalizePath(newSettings.nodePath !== undefined ? newSettings.nodePath : this.settings.nodePath),
209
- browserPath: normalizePath(newSettings.browserPath !== undefined ? newSettings.browserPath : this.settings.browserPath),
210
- // Ensure systemEnvironments and userConfigurations are properly merged or taken from newSettings
211
- systemEnvironments: newSettings.systemEnvironments !== undefined
212
- ? newSettings.systemEnvironments
213
- : this.settings.systemEnvironments, // Keep existing if not in newSettings
214
- userConfigurations: newSettings.userConfigurations !== undefined
215
- ? newSettings.userConfigurations
216
- : this.settings.userConfigurations || {}, // Keep existing or default to empty
217
- };
218
-
219
- this.settings = updatedSettings;
220
-
221
- // Call the internal, non-locking version of applyDefaultsIfNeeded
222
- await this._applyDefaultsIfNeededInternal();
223
-
224
- // _applyDefaultsIfNeededInternal will call _saveSettingsInternal if it makes changes.
225
- // However, if newSettings were provided that didn't trigger a change in _applyDefaultsIfNeededInternal
226
- // (e.g., just updating an existing path), we still need to save.
227
- // So, always call _saveSettingsInternal to persist all merged changes.
228
- await this._saveSettingsInternal();
229
-
230
- Logger.info('System settings updated.');
231
- // getSystemSettings will handle its own locking if it needs to load.
232
- return this.getSystemSettings();
233
- });
234
- }
235
-
236
- /**
237
- * Internal method to save settings to the file without acquiring a lock.
238
- * Assumes the lock is already held by the calling public method.
239
- * Normalizes paths before saving.
240
- * @returns A promise that resolves when settings are written to disk.
241
- */
242
- private async _saveSettingsInternal(): Promise<void> {
243
- try {
244
- // Normalize paths before saving
245
- const settingsToSave = { ...this.settings };
246
- settingsToSave.nodePath = settingsToSave.nodePath?.replace(/\\/g, '/');
247
- settingsToSave.browserPath = settingsToSave.browserPath?.replace(/\\/g, '/');
248
-
249
- if (settingsToSave.pythonEnvs) {
250
- const normalizedPythonEnvs: Record<string, string> = {};
251
- Object.keys(settingsToSave.pythonEnvs).forEach(key => {
252
- normalizedPythonEnvs[key] = settingsToSave.pythonEnvs?.[key]?.replace(/\\/g, '/') || '';
253
- });
254
- settingsToSave.pythonEnvs = normalizedPythonEnvs;
255
- }
256
-
257
- await fs.mkdir(path.dirname(this.settingsFilePath), { recursive: true });
258
- await fs.writeFile(this.settingsFilePath, JSON.stringify(settingsToSave, null, 2));
259
- Logger.info(`System settings saved to ${this.settingsFilePath}`);
260
- } catch (error) {
261
- Logger.error(`Error saving settings to ${this.settingsFilePath}:`, error);
262
- throw error; // Re-throw to indicate failure
263
- }
264
- }
265
-
266
- /**
267
- * Saves the current settings to the file. This operation is atomic and protected by a lock.
268
- * Paths are normalized before saving.
269
- * @returns A promise that resolves when the settings are saved.
270
- */
271
- public async saveSettings(): Promise<void> {
272
- await this.withLock(async () => {
273
- await this._saveSettingsInternal();
274
- });
275
- }
276
- }
277
-
278
- export const systemSettingsManager = SystemSettingsManager.getInstance();
@@ -1,122 +0,0 @@
1
- import os from 'os';
2
- import path from 'path';
3
-
4
- /**
5
- * Defines constants used across the application.
6
- */
7
-
8
- /**
9
- * GitHub repository configuration for feeds
10
- */
11
- export const GITHUB_REPO = {
12
- url: 'https://github.com/ai-microsoft/imcp-feed.git',
13
- repoName: 'ai-microsoft/imcp-feed',
14
- feedsPath: 'feeds',
15
- feedAssetsName: 'imcp-feeds-${latest}.zip',
16
- };
17
-
18
- /**
19
- * Local settings directory path based on OS
20
- */
21
- export const SETTINGS_DIR = (() => {
22
- switch (process.platform) {
23
- case 'win32':
24
- return path.join(os.homedir(), '.imcp');
25
- default: // linux, darwin (macOS), etc.
26
- return path.join(os.homedir(), '.imcp');
27
- }
28
- })();
29
-
30
- /**
31
- * Local feeds directory path
32
- */
33
- export const LOCAL_FEEDS_DIR = path.join(SETTINGS_DIR, 'feeds');
34
-
35
- /**
36
- * Path to the user information file
37
- */
38
- export const USER_INFO_PATH = path.join(SETTINGS_DIR, 'settings', 'user_info.json');
39
-
40
- /**
41
- * Path to the local feeds schema directory
42
- */
43
- export const LOCAL_FEEDS_SCHEMA_DIR = path.join(LOCAL_FEEDS_DIR, 'schemas');
44
-
45
- const CODE_STRORAGE_DIR = (() => {
46
- switch (process.platform) {
47
- case 'win32':
48
- return path.join(os.homedir(), 'AppData', 'Roaming', 'Code', 'User');
49
- case 'darwin': // macOS
50
- return path.join(os.homedir(), 'Library', 'Application Support', 'Code', 'User');
51
- default: // linux
52
- return path.join(os.homedir(), '.config', 'Code', 'User');
53
- }
54
- })();
55
-
56
- const CODE_INSIDER_STRORAGE_DIR = (() => {
57
- switch (process.platform) {
58
- case 'win32':
59
- return path.join(os.homedir(), 'AppData', 'Roaming', 'Code - Insiders', 'User');
60
- case 'darwin': // macOS
61
- return path.join(os.homedir(), 'Library', 'Application Support', 'Code - Insiders', 'User');
62
- default: // linux
63
- return path.join(os.homedir(), '.config', 'Code - Insiders', 'User');
64
- }
65
- })();
66
-
67
- /**
68
- * Supported client configurations.
69
- * Key: Client name (e.g., 'vscode')
70
- * Value: Client-specific settings or configuration details.
71
- * TODO: Define actual client settings structure.
72
- */
73
- export const SUPPORTED_CLIENTS: Record<string, {
74
- extension: {
75
- extensionId: string;
76
- leastVersion?: string;
77
- repository?: string;
78
- assetName?: string;
79
- private?: boolean;
80
- };
81
- codeSettingPath: string;
82
- codeInsiderSettingPath: string;
83
- }> = {
84
- 'MSRooCode': {
85
-
86
- extension: {
87
- extensionId: 'microsoftai.ms-roo-cline',
88
- leastVersion: '0.0.8',
89
- repository: 'ai-microsoft/roo-cline',
90
- assetName: 'ms-roo-cline-${version}.vsix',
91
- private: true
92
- },
93
- codeSettingPath: path.join(CODE_STRORAGE_DIR, 'globalStorage', 'microsoftai.ms-roo-cline', 'settings', 'cline_mcp_settings.json'),
94
- codeInsiderSettingPath: path.join(CODE_INSIDER_STRORAGE_DIR, 'globalStorage', 'microsoftai.ms-roo-cline', 'settings', 'cline_mcp_settings.json'),
95
- },
96
- 'Cline': { /* VS Code specific settings */
97
- extension: {
98
- extensionId: 'saoudrizwan.claude-dev',
99
- },
100
- codeSettingPath: path.join(CODE_STRORAGE_DIR, 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json'),
101
- codeInsiderSettingPath: path.join(CODE_INSIDER_STRORAGE_DIR, 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json'),
102
- },
103
- 'GithubCopilot': { /* GitHub Copilot specific settings */
104
- extension: {
105
- extensionId: 'github.copilot',
106
- },
107
- codeSettingPath: path.join(CODE_STRORAGE_DIR, 'settings.json'),
108
- codeInsiderSettingPath: path.join(CODE_INSIDER_STRORAGE_DIR, 'settings.json'),
109
- },
110
- // Add other supported clients here
111
- };
112
-
113
- /**
114
- * List of supported client names.
115
- */
116
- export const SUPPORTED_CLIENT_NAMES = Object.keys(SUPPORTED_CLIENTS);
117
-
118
- /**
119
- * Minimum time between requirement update checks (in milliseconds)
120
- * 10 minutes = 10 * 60 * 1000 = 600000 ms
121
- */
122
- export const UPDATE_CHECK_INTERVAL_MS = 10 * 60 * 1000; // 10 minutes
@@ -1,65 +0,0 @@
1
- /**
2
- * Step name constants for InstallOperationManager and step recording.
3
- *
4
- * This file defines all static step names and documents dynamic step name patterns
5
- * used throughout the installation and onboarding process.
6
- *
7
- * Dynamic step names are documented as template string patterns.
8
- */
9
-
10
- /** Step for processing all requirement updates in a batch operation. */
11
- export const STEP_PROCESS_REQUIREMENT_UPDATES = 'Processing all requirement updates';
12
-
13
- /** Step for checking the status of a specific requirement. */
14
- export const STEP_CHECKING_REQUIREMENT_STATUS = 'Checking the status of requirement';
15
-
16
- /** Step for installing requirements in the background process. */
17
- export const STEP_INSTALLING_REQUIREMENTS_IN_BACKGROUND = 'Installing requirements in the background';
18
-
19
- /** Step for running the install logic in the NugetInstaller. */
20
- export const STEP_NUGET_INSTALLER_INSTALL = 'Running install in NugetInstaller';
21
-
22
- /** Step for checking and installing all requirements as needed. */
23
- export const STEP_CHECK_AND_INSTALL_REQUIREMENTS = 'Checking and installing all requirements';
24
-
25
- /** Step for running the install logic in the CommandInstaller. */
26
- export const STEP_COMMAND_INSTALLER_INSTALL = 'Running install in CommandInstaller';
27
-
28
- /** Step for running the install logic in the GeneralInstaller. */
29
- export const STEP_GENERAL_INSTALLER_INSTALL = 'Running install in GeneralInstaller';
30
-
31
- /** Step for executing the actual installation command (npm, pip, etc.). */
32
- export const STEP_INSTALLATION_COMMAND_EXECUTION = 'Executing installation command for requirement';
33
-
34
- /** Step for running the install logic in the PipInstaller. */
35
- export const STEP_PIP_INSTALLER_INSTALL = 'Running install in PipInstaller';
36
-
37
- /** Step for processing requirement updates in the RequirementService. */
38
- export const STEP_PROCESS_REQUIREMENT_UPDATES_SERVICE = 'Processing requirement updates in RequirementService';
39
-
40
- /** Step for checking if the server is ready after installation. */
41
- export const STEP_CHECK_SERVER_READINESS = 'Checking server readiness after installation';
42
-
43
- /** Step for running the install logic in the NpmInstaller. */
44
- export const STEP_NPM_INSTALLER_INSTALL = 'Running install in NpmInstaller';
45
-
46
- /** Prefix for steps that update a specific requirement. */
47
- export const STEP_INSTALL_REQUIREMENT_PREFIX = 'Updating requirement:';
48
-
49
- /** Prefix for steps that execute an installation command for a requirement. */
50
- export const STEP_INSTALL_COMMAND_PREFIX = 'Executing installation command for:';
51
-
52
- /** Step for checking and installing the VS Code extension for the client. */
53
- export const STEP_CHECK_VSCODE_AND_INSTALL_EXTENSION = 'Checking and installing VS Code extension for client';
54
-
55
- /** Step for setting up the installation configuration (env, args, etc.). */
56
- export const STEP_SETUP_INSTALLATION_CONFIG = 'Setting up installation configuration';
57
-
58
- /** Step for updating VS Code settings for the client/server. */
59
- export const STEP_UPDATE_VSCODE_SETTINGS = 'Updating VS Code settings for client/server';
60
-
61
- /** Step for the overall installation process of a client or server. */
62
- export const STEP_INSTALLATION = 'Running overall installation process';
63
-
64
- /** Step for marking the initiation of an onboarding or installation process. */
65
- export const STEP_INITIATED = 'Initiating onboarding or installation process';