imcp 0.1.7 → 0.1.8-dev
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.
- package/dist/cli/commands/install.js +1 -106
- package/dist/cli/commands/install.js.map +1 -0
- package/dist/cli/commands/list.js +1 -90
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/pull.js +1 -16
- package/dist/cli/commands/pull.js.map +1 -0
- package/dist/cli/commands/serve.js +1 -33
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/uninstall.js +1 -46
- package/dist/cli/commands/uninstall.js.map +1 -0
- package/dist/cli/index.js +1 -65
- package/dist/cli/index.js.map +1 -0
- package/dist/core/installers/clients/BaseClientInstaller.js +1 -282
- package/dist/core/installers/clients/BaseClientInstaller.js.map +1 -0
- package/dist/core/installers/clients/ClientInstaller.js +1 -163
- package/dist/core/installers/clients/ClientInstaller.js.map +1 -0
- package/dist/core/installers/clients/ClientInstallerFactory.js +1 -36
- package/dist/core/installers/clients/ClientInstallerFactory.js.map +1 -0
- package/dist/core/installers/clients/ClineInstaller.js +1 -30
- package/dist/core/installers/clients/ClineInstaller.js.map +1 -0
- package/dist/core/installers/clients/ExtensionInstaller.js +1 -151
- package/dist/core/installers/clients/ExtensionInstaller.js.map +1 -0
- package/dist/core/installers/clients/GithubCopilotInstaller.js +1 -68
- package/dist/core/installers/clients/GithubCopilotInstaller.js.map +1 -0
- package/dist/core/installers/clients/MSRooCodeInstaller.js +1 -28
- package/dist/core/installers/clients/MSRooCodeInstaller.js.map +1 -0
- package/dist/core/installers/index.js +1 -8
- package/dist/core/installers/index.js.map +1 -0
- package/dist/core/installers/requirements/BaseInstaller.js +1 -56
- package/dist/core/installers/requirements/BaseInstaller.js.map +1 -0
- package/dist/core/installers/requirements/CommandInstaller.js +1 -213
- package/dist/core/installers/requirements/CommandInstaller.js.map +1 -0
- package/dist/core/installers/requirements/GeneralInstaller.js +1 -126
- package/dist/core/installers/requirements/GeneralInstaller.js.map +1 -0
- package/dist/core/installers/requirements/InstallerFactory.js +1 -99
- package/dist/core/installers/requirements/InstallerFactory.js.map +1 -0
- package/dist/core/installers/requirements/NpmInstaller.js +1 -235
- package/dist/core/installers/requirements/NpmInstaller.js.map +1 -0
- package/dist/core/installers/requirements/NugetInstaller.js +1 -188
- package/dist/core/installers/requirements/NugetInstaller.js.map +1 -0
- package/dist/core/installers/requirements/PipInstaller.js +1 -192
- package/dist/core/installers/requirements/PipInstaller.js.map +1 -0
- package/dist/core/installers/requirements/RequirementInstaller.js +1 -2
- package/dist/core/installers/requirements/RequirementInstaller.js.map +1 -0
- package/dist/core/loaders/ConfigurationLoader.js +1 -256
- package/dist/core/loaders/ConfigurationLoader.js.map +1 -0
- package/dist/core/loaders/ConfigurationProvider.js +1 -383
- package/dist/core/loaders/ConfigurationProvider.js.map +1 -0
- package/dist/core/loaders/InstallOperationManager.js +1 -310
- package/dist/core/loaders/InstallOperationManager.js.map +1 -0
- package/dist/core/loaders/ServerSchemaLoader.js +1 -108
- package/dist/core/loaders/ServerSchemaLoader.js.map +1 -0
- package/dist/core/loaders/ServerSchemaProvider.js +1 -89
- package/dist/core/loaders/ServerSchemaProvider.js.map +1 -0
- package/dist/core/loaders/SystemSettingsManager.js +1 -256
- package/dist/core/loaders/SystemSettingsManager.js.map +1 -0
- package/dist/core/metadatas/constants.js +1 -100
- package/dist/core/metadatas/constants.js.map +1 -0
- package/dist/core/metadatas/recordingConstants.js +1 -46
- package/dist/core/metadatas/recordingConstants.js.map +1 -0
- package/dist/core/metadatas/types.js +1 -15
- package/dist/core/metadatas/types.js.map +1 -0
- package/dist/core/onboard/FeedOnboardService.js +1 -422
- package/dist/core/onboard/FeedOnboardService.js.map +1 -0
- package/dist/core/onboard/OnboardProcessor.js +1 -333
- package/dist/core/onboard/OnboardProcessor.js.map +1 -0
- package/dist/core/onboard/OnboardStatus.js +1 -9
- package/dist/core/onboard/OnboardStatus.js.map +1 -0
- package/dist/core/onboard/OnboardStatusManager.js +1 -360
- package/dist/core/onboard/OnboardStatusManager.js.map +1 -0
- package/dist/core/validators/FeedValidator.js +1 -133
- package/dist/core/validators/FeedValidator.js.map +1 -0
- package/dist/core/validators/IServerValidator.js +1 -1
- package/dist/core/validators/IServerValidator.js.map +1 -0
- package/dist/core/validators/SSEServerValidator.js +1 -38
- package/dist/core/validators/SSEServerValidator.js.map +1 -0
- package/dist/core/validators/ServerValidatorFactory.js +1 -44
- package/dist/core/validators/ServerValidatorFactory.js.map +1 -0
- package/dist/core/validators/StdioServerValidator.js +1 -281
- package/dist/core/validators/StdioServerValidator.js.map +1 -0
- package/dist/index.js +1 -18
- package/dist/index.js.map +1 -0
- package/dist/services/InstallationService.js +1 -81
- package/dist/services/InstallationService.js.map +1 -0
- package/dist/services/MCPManager.js +1 -197
- package/dist/services/MCPManager.js.map +1 -0
- package/dist/services/RequirementService.js +1 -548
- package/dist/services/RequirementService.js.map +1 -0
- package/dist/services/ServerService.js +1 -127
- package/dist/services/ServerService.js.map +1 -0
- package/dist/services/TelemetryService.js +1 -53
- package/dist/services/TelemetryService.js.map +1 -0
- package/dist/utils/UpdateCheckTracker.js +1 -79
- package/dist/utils/UpdateCheckTracker.js.map +1 -0
- package/dist/utils/adoUtils.js +1 -254
- package/dist/utils/adoUtils.js.map +1 -0
- package/dist/utils/clientUtils.js +1 -65
- package/dist/utils/clientUtils.js.map +1 -0
- package/dist/utils/feedUtils.js +1 -28
- package/dist/utils/feedUtils.js.map +1 -0
- package/dist/utils/githubAuth.js +1 -177
- package/dist/utils/githubAuth.js.map +1 -0
- package/dist/utils/githubUtils.js +1 -125
- package/dist/utils/githubUtils.js.map +1 -0
- package/dist/utils/logger.js +1 -176
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/macroExpressionUtils.js +1 -93
- package/dist/utils/macroExpressionUtils.js.map +1 -0
- package/dist/utils/osUtils.js +1 -664
- package/dist/utils/osUtils.js.map +1 -0
- package/dist/utils/versionUtils.js +1 -101
- package/dist/utils/versionUtils.js.map +1 -0
- package/dist/web/contract/serverContract.js +1 -1
- package/dist/web/contract/serverContract.js.map +1 -0
- package/dist/web/public/js/api.js +2 -132
- package/dist/web/public/js/api.js.map +1 -0
- package/dist/web/public/js/detailsWidget.js +2 -264
- package/dist/web/public/js/detailsWidget.js.map +1 -0
- package/dist/web/public/js/flights/flights.js +2 -127
- package/dist/web/public/js/flights/flights.js.map +1 -0
- package/dist/web/public/js/modal/index.js +2 -52
- package/dist/web/public/js/modal/index.js.map +1 -0
- package/dist/web/public/js/modal/installModal.js +2 -162
- package/dist/web/public/js/modal/installModal.js.map +1 -0
- package/dist/web/public/js/modal/installation.js +2 -266
- package/dist/web/public/js/modal/installation.js.map +1 -0
- package/dist/web/public/js/modal/loadingModal.js +2 -182
- package/dist/web/public/js/modal/loadingModal.js.map +1 -0
- package/dist/web/public/js/modal/modalSetup.js +2 -595
- package/dist/web/public/js/modal/modalSetup.js.map +1 -0
- package/dist/web/public/js/modal/modalUtils.js +2 -37
- package/dist/web/public/js/modal/modalUtils.js.map +1 -0
- package/dist/web/public/js/modal/versionUtils.js +2 -20
- package/dist/web/public/js/modal/versionUtils.js.map +1 -0
- package/dist/web/public/js/modal.js +2 -42
- package/dist/web/public/js/modal.js.map +1 -0
- package/dist/web/public/js/notifications.js +2 -137
- package/dist/web/public/js/notifications.js.map +1 -0
- package/dist/web/public/js/onboard/formProcessor.js +2 -1037
- package/dist/web/public/js/onboard/formProcessor.js.map +1 -0
- package/dist/web/public/js/onboard/index.js +2 -374
- package/dist/web/public/js/onboard/index.js.map +1 -0
- package/dist/web/public/js/onboard/publishHandler.js +2 -172
- package/dist/web/public/js/onboard/publishHandler.js.map +1 -0
- package/dist/web/public/js/onboard/state.js +2 -76
- package/dist/web/public/js/onboard/state.js.map +1 -0
- package/dist/web/public/js/onboard/templates.js +2 -342
- package/dist/web/public/js/onboard/templates.js.map +1 -0
- package/dist/web/public/js/onboard/uiHandlers.js +2 -1076
- package/dist/web/public/js/onboard/uiHandlers.js.map +1 -0
- package/dist/web/public/js/onboard/validationHandlers.js +2 -493
- package/dist/web/public/js/onboard/validationHandlers.js.map +1 -0
- package/dist/web/public/js/serverCategoryDetails.js +2 -364
- package/dist/web/public/js/serverCategoryDetails.js.map +1 -0
- package/dist/web/public/js/serverCategoryList.js +2 -241
- package/dist/web/public/js/serverCategoryList.js.map +1 -0
- package/dist/web/public/js/settings.js +2 -314
- package/dist/web/public/js/settings.js.map +1 -0
- package/dist/web/server.js +1 -404
- package/dist/web/server.js.map +1 -0
- package/package.json +8 -2
- package/.github/ISSUE_TEMPLATE/JitAccess.yml +0 -28
- package/.github/acl/access.yml +0 -20
- package/.github/compliance/inventory.yml +0 -5
- package/.github/policies/jit.yml +0 -19
- package/.github/workflows/build.yml +0 -28
- package/.roo/rules-code/rules.md +0 -88
- package/dist/cli/commands/start.d.ts +0 -2
- package/dist/cli/commands/start.js +0 -32
- package/dist/cli/commands/sync.d.ts +0 -2
- package/dist/cli/commands/sync.js +0 -17
- package/dist/core/ConfigurationLoader.d.ts +0 -32
- package/dist/core/ConfigurationLoader.js +0 -236
- package/dist/core/ConfigurationProvider.d.ts +0 -35
- package/dist/core/ConfigurationProvider.js +0 -375
- package/dist/core/InstallationService.d.ts +0 -50
- package/dist/core/InstallationService.js +0 -350
- package/dist/core/MCPManager.d.ts +0 -28
- package/dist/core/MCPManager.js +0 -188
- package/dist/core/RequirementService.d.ts +0 -40
- package/dist/core/RequirementService.js +0 -110
- package/dist/core/ServerSchemaLoader.d.ts +0 -11
- package/dist/core/ServerSchemaLoader.js +0 -43
- package/dist/core/ServerSchemaProvider.d.ts +0 -17
- package/dist/core/ServerSchemaProvider.js +0 -120
- package/dist/core/constants.d.ts +0 -47
- package/dist/core/constants.js +0 -94
- package/dist/core/installers/BaseInstaller.d.ts +0 -74
- package/dist/core/installers/BaseInstaller.js +0 -253
- package/dist/core/installers/ClientInstaller.d.ts +0 -23
- package/dist/core/installers/ClientInstaller.js +0 -564
- package/dist/core/installers/CommandInstaller.d.ts +0 -37
- package/dist/core/installers/CommandInstaller.js +0 -173
- package/dist/core/installers/GeneralInstaller.d.ts +0 -33
- package/dist/core/installers/GeneralInstaller.js +0 -85
- package/dist/core/installers/InstallerFactory.d.ts +0 -54
- package/dist/core/installers/InstallerFactory.js +0 -97
- package/dist/core/installers/NpmInstaller.d.ts +0 -26
- package/dist/core/installers/NpmInstaller.js +0 -127
- package/dist/core/installers/PipInstaller.d.ts +0 -28
- package/dist/core/installers/PipInstaller.js +0 -127
- package/dist/core/installers/RequirementInstaller.d.ts +0 -33
- package/dist/core/installers/RequirementInstaller.js +0 -3
- package/dist/core/types.d.ts +0 -166
- package/dist/core/types.js +0 -16
- package/dist/services/InstallRequestValidator.d.ts +0 -21
- package/dist/services/InstallRequestValidator.js +0 -99
- package/dist/web/public/js/modal/installHandler.js +0 -227
- package/dist/web/public/js/modal/loadingUI.js +0 -74
- package/dist/web/public/js/modal/messageQueue.js +0 -112
- package/dist/web/public/js/modal/modalUI.js +0 -214
- package/dist/web/public/js/modal/version.js +0 -20
- package/dist/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +0 -370
- package/docs/ONBOARDING_PAGE_DESIGN.md +0 -260
- package/docs/Telemetry.md +0 -136
- package/memory-bank/activeContext.md +0 -26
- package/memory-bank/decisionLog.md +0 -91
- package/memory-bank/productContext.md +0 -41
- package/memory-bank/progress.md +0 -35
- package/memory-bank/systemPatterns.md +0 -10
- package/src/cli/commands/install.ts +0 -139
- package/src/cli/commands/list.ts +0 -113
- package/src/cli/commands/pull.ts +0 -16
- package/src/cli/commands/serve.ts +0 -39
- package/src/cli/commands/uninstall.ts +0 -64
- package/src/cli/index.ts +0 -82
- package/src/core/installers/clients/BaseClientInstaller.ts +0 -341
- package/src/core/installers/clients/ClientInstaller.ts +0 -222
- package/src/core/installers/clients/ClientInstallerFactory.ts +0 -43
- package/src/core/installers/clients/ClineInstaller.ts +0 -35
- package/src/core/installers/clients/ExtensionInstaller.ts +0 -165
- package/src/core/installers/clients/GithubCopilotInstaller.ts +0 -79
- package/src/core/installers/clients/MSRooCodeInstaller.ts +0 -32
- package/src/core/installers/index.ts +0 -11
- package/src/core/installers/requirements/BaseInstaller.ts +0 -85
- package/src/core/installers/requirements/CommandInstaller.ts +0 -231
- package/src/core/installers/requirements/GeneralInstaller.ts +0 -133
- package/src/core/installers/requirements/InstallerFactory.ts +0 -114
- package/src/core/installers/requirements/NpmInstaller.ts +0 -271
- package/src/core/installers/requirements/NugetInstaller.ts +0 -203
- package/src/core/installers/requirements/PipInstaller.ts +0 -207
- package/src/core/installers/requirements/RequirementInstaller.ts +0 -42
- package/src/core/loaders/ConfigurationLoader.ts +0 -298
- package/src/core/loaders/ConfigurationProvider.ts +0 -462
- package/src/core/loaders/InstallOperationManager.ts +0 -367
- package/src/core/loaders/ServerSchemaLoader.ts +0 -117
- package/src/core/loaders/ServerSchemaProvider.ts +0 -99
- package/src/core/loaders/SystemSettingsManager.ts +0 -278
- package/src/core/metadatas/constants.ts +0 -122
- package/src/core/metadatas/recordingConstants.ts +0 -65
- package/src/core/metadatas/types.ts +0 -202
- package/src/core/onboard/FeedOnboardService.ts +0 -501
- package/src/core/onboard/OnboardProcessor.ts +0 -356
- package/src/core/onboard/OnboardStatus.ts +0 -60
- package/src/core/onboard/OnboardStatusManager.ts +0 -416
- package/src/core/validators/FeedValidator.ts +0 -135
- package/src/core/validators/IServerValidator.ts +0 -21
- package/src/core/validators/SSEServerValidator.ts +0 -43
- package/src/core/validators/ServerValidatorFactory.ts +0 -51
- package/src/core/validators/StdioServerValidator.ts +0 -313
- package/src/index.ts +0 -44
- package/src/services/InstallationService.ts +0 -102
- package/src/services/MCPManager.ts +0 -249
- package/src/services/RequirementService.ts +0 -627
- package/src/services/ServerService.ts +0 -161
- package/src/services/TelemetryService.ts +0 -59
- package/src/utils/UpdateCheckTracker.ts +0 -86
- package/src/utils/adoUtils.ts +0 -293
- package/src/utils/clientUtils.ts +0 -72
- package/src/utils/feedUtils.ts +0 -31
- package/src/utils/githubAuth.ts +0 -212
- package/src/utils/githubUtils.ts +0 -164
- package/src/utils/logger.ts +0 -195
- package/src/utils/macroExpressionUtils.ts +0 -104
- package/src/utils/osUtils.ts +0 -700
- package/src/utils/versionUtils.ts +0 -114
- package/src/web/contract/serverContract.ts +0 -74
- package/src/web/public/css/detailsWidget.css +0 -235
- package/src/web/public/css/modal.css +0 -757
- package/src/web/public/css/notifications.css +0 -101
- package/src/web/public/css/onboard.css +0 -107
- package/src/web/public/css/serverCategoryList.css +0 -120
- package/src/web/public/css/serverDetails.css +0 -139
- package/src/web/public/index.html +0 -359
- package/src/web/public/js/api.js +0 -132
- package/src/web/public/js/detailsWidget.js +0 -264
- package/src/web/public/js/flights/flights.js +0 -127
- package/src/web/public/js/modal/index.js +0 -52
- package/src/web/public/js/modal/installModal.js +0 -162
- package/src/web/public/js/modal/installation.js +0 -266
- package/src/web/public/js/modal/loadingModal.js +0 -182
- package/src/web/public/js/modal/modalSetup.js +0 -595
- package/src/web/public/js/modal/modalUtils.js +0 -37
- package/src/web/public/js/modal/versionUtils.js +0 -20
- package/src/web/public/js/modal.js +0 -42
- package/src/web/public/js/notifications.js +0 -137
- package/src/web/public/js/onboard/formProcessor.js +0 -1037
- package/src/web/public/js/onboard/index.js +0 -374
- package/src/web/public/js/onboard/publishHandler.js +0 -172
- package/src/web/public/js/onboard/state.js +0 -76
- package/src/web/public/js/onboard/templates.js +0 -342
- package/src/web/public/js/onboard/uiHandlers.js +0 -1076
- package/src/web/public/js/onboard/validationHandlers.js +0 -493
- package/src/web/public/js/serverCategoryDetails.js +0 -364
- package/src/web/public/js/serverCategoryList.js +0 -241
- package/src/web/public/js/settings.js +0 -314
- package/src/web/public/modal.html +0 -84
- package/src/web/public/onboard.html +0 -296
- package/src/web/public/settings.html +0 -135
- package/src/web/public/styles.css +0 -277
- package/src/web/server.ts +0 -478
- package/tsconfig.json +0 -18
- package/wiki/Installation.md +0 -3
- package/wiki/Publish.md +0 -3
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
import { exec } from 'child_process';
|
|
2
|
-
import { promisify } from 'util';
|
|
3
|
-
import fs from 'fs/promises';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { GITHUB_REPO, SETTINGS_DIR } from '../metadatas/constants.js';
|
|
6
|
-
import { FeedConfiguration } from '../metadatas/types.js';
|
|
7
|
-
import { Logger } from '../../utils/logger.js';
|
|
8
|
-
|
|
9
|
-
const execAsync = promisify(exec);
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Class responsible for handling GitHub operations during the onboarding process
|
|
13
|
-
*/
|
|
14
|
-
export class OnboardProcessor {
|
|
15
|
-
/**
|
|
16
|
-
* Forks the GitHub repository specified in GITHUB_REPO constants.
|
|
17
|
-
* Uses the `gh repo fork` command.
|
|
18
|
-
* @param onboardingId The ID of the onboarding process (for logging).
|
|
19
|
-
* @param repoDir The directory of the repository (currently unused but kept for consistency).
|
|
20
|
-
* @throws An error if the forking process fails, with a 'step' property set to 'forkRepo'.
|
|
21
|
-
*/
|
|
22
|
-
public async forkRepo(onboardingId: string, repoDir: string): Promise<void> {
|
|
23
|
-
try {
|
|
24
|
-
// Using --remote=true ensures that if the fork already exists, 'origin' remote is set to it.
|
|
25
|
-
// If the fork doesn't exist, it creates it and sets 'origin' remote.
|
|
26
|
-
await execAsync(`gh repo fork ${GITHUB_REPO.repoName} --clone=false --remote=true`);
|
|
27
|
-
Logger.debug(`[${onboardingId}] Successfully ensured repository is forked and remote 'origin' is set.`);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
30
|
-
Logger.error(`[${onboardingId}] Error during forkRepo: ${errorMessage}`);
|
|
31
|
-
throw Object.assign(new Error(`Failed to fork repository: ${errorMessage}`), { step: 'forkRepo' });
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Clones the user's fork of the repository into a temporary directory.
|
|
37
|
-
* It first removes any existing repository directory for the current onboarding process.
|
|
38
|
-
* Then, it retrieves the GitHub username and constructs the repository URL to clone.
|
|
39
|
-
* @param onboardingId The ID of the onboarding process (for logging).
|
|
40
|
-
* @param tempDir The base temporary directory for the onboarding process.
|
|
41
|
-
* @param repoDir The specific directory within tempDir where the repository will be cloned.
|
|
42
|
-
* @throws An error if cloning fails, with a 'step' property set to 'cloneRepo'.
|
|
43
|
-
*/
|
|
44
|
-
public async cloneRepo(onboardingId: string, tempDir: string, repoDir: string): Promise<void> {
|
|
45
|
-
try {
|
|
46
|
-
await fs.mkdir(tempDir, { recursive: true });
|
|
47
|
-
|
|
48
|
-
let repoExistsAndIsValid = false;
|
|
49
|
-
const originalCwd = process.cwd();
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
const gitDirStat = await fs.stat(path.join(repoDir, '.git'));
|
|
53
|
-
if (gitDirStat.isDirectory()) {
|
|
54
|
-
process.chdir(repoDir);
|
|
55
|
-
const { stdout: remoteUrlStdout } = await execAsync(`git config --get remote.origin.url`);
|
|
56
|
-
const remoteUrl = remoteUrlStdout.trim();
|
|
57
|
-
process.chdir(originalCwd);
|
|
58
|
-
|
|
59
|
-
const username = await this.getGitHubUsername();
|
|
60
|
-
const expectedRepoName = GITHUB_REPO.repoName.split('/')[1];
|
|
61
|
-
|
|
62
|
-
if (remoteUrl.includes(username) && remoteUrl.includes(expectedRepoName)) {
|
|
63
|
-
Logger.debug(`[${onboardingId}] Repository directory ${repoDir} already exists, is a valid git repository, and has the correct remote origin. Skipping clone.`);
|
|
64
|
-
repoExistsAndIsValid = true;
|
|
65
|
-
} else {
|
|
66
|
-
Logger.log(`WARNING: [${onboardingId}] Repository directory ${repoDir} exists and is a git repository, but remote 'origin' URL (${remoteUrl}) does not match expected user/repo. Will re-clone.`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
} catch (checkError: any) {
|
|
70
|
-
Logger.debug(`[${onboardingId}] Repository directory ${repoDir} check failed or is not the correct repository. Proceeding with clone. Error: ${checkError.message || checkError.code}`);
|
|
71
|
-
if (process.cwd() !== originalCwd) {
|
|
72
|
-
process.chdir(originalCwd);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (!repoExistsAndIsValid) {
|
|
77
|
-
await fs.rm(repoDir, { recursive: true, force: true });
|
|
78
|
-
Logger.debug(`[${onboardingId}] Cleaned up existing directory (if any) at ${repoDir}.`);
|
|
79
|
-
|
|
80
|
-
const username = await this.getGitHubUsername();
|
|
81
|
-
const repoUrl = `https://github.com/${username}/${GITHUB_REPO.repoName.split('/')[1]}.git`;
|
|
82
|
-
|
|
83
|
-
await execAsync(`git clone ${repoUrl} ${repoDir}`);
|
|
84
|
-
Logger.debug(`[${onboardingId}] Successfully cloned repository to ${repoDir}`);
|
|
85
|
-
}
|
|
86
|
-
} catch (error) {
|
|
87
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
88
|
-
Logger.error(`[${onboardingId}] Error during cloneRepo: ${errorMessage}`);
|
|
89
|
-
throw Object.assign(new Error(`Failed to clone repository: ${errorMessage}`), { step: 'cloneRepo' });
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Retrieves the GitHub username of the authenticated user using the `gh api user` command.
|
|
95
|
-
* @returns A promise that resolves to the GitHub username as a string.
|
|
96
|
-
* @throws An error if fetching the username fails.
|
|
97
|
-
*/
|
|
98
|
-
private async getGitHubUsername(): Promise<string> {
|
|
99
|
-
try {
|
|
100
|
-
const { stdout } = await execAsync('gh api user -q .login');
|
|
101
|
-
return stdout.trim();
|
|
102
|
-
} catch (error) {
|
|
103
|
-
throw new Error(`Failed to get GitHub username: ${error instanceof Error ? error.message : String(error)}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Saves the feed configuration as a JSON file into the specified path within the cloned repository.
|
|
109
|
-
* The file will be named `config.name.json`.
|
|
110
|
-
* @param onboardingId The ID of the onboarding process.
|
|
111
|
-
* @param config The feed configuration to save.
|
|
112
|
-
* @param repoDir The root directory of the cloned repository.
|
|
113
|
-
* @param serverList The list of MCP server names to process.
|
|
114
|
-
* @returns A promise that resolves to an object containing the path to the saved feed file and the category-specific schemas directory.
|
|
115
|
-
* @throws An error if saving the configuration fails, with a 'step' property set to 'saveFeedConfigToRepo'.
|
|
116
|
-
*/
|
|
117
|
-
public async saveFeedConfigToRepo(onboardingId: string, config: FeedConfiguration, repoDir: string, serverList: string[]): Promise<{ feedFilePath: string; categorySchemasPath: string; }> {
|
|
118
|
-
try {
|
|
119
|
-
const feedsDir = path.join(repoDir, GITHUB_REPO.feedsPath);
|
|
120
|
-
await fs.mkdir(feedsDir, { recursive: true });
|
|
121
|
-
|
|
122
|
-
const categoryName = config.name; // Feed name is the category name
|
|
123
|
-
const categorySchemasPath = path.join(feedsDir, 'schemas', categoryName);
|
|
124
|
-
await fs.mkdir(categorySchemasPath, { recursive: true }); // Ensure category schema directory exists
|
|
125
|
-
|
|
126
|
-
// Process schemas for each MCP server
|
|
127
|
-
// Create a mutable copy of mcpServers to update schema paths
|
|
128
|
-
const updatedMcpServers = [];
|
|
129
|
-
for (const server of config.mcpServers) {
|
|
130
|
-
let updatedServer = { ...server }; // Shallow copy server config
|
|
131
|
-
if (serverList.includes(server.name)) {
|
|
132
|
-
if (updatedServer.schemas && typeof updatedServer.schemas === 'string' && updatedServer.schemas.trim() !== '') {
|
|
133
|
-
const originalSchemaPath = updatedServer.schemas;
|
|
134
|
-
const serverName = updatedServer.name;
|
|
135
|
-
const newSchemaFileName = `${serverName}.json`;
|
|
136
|
-
|
|
137
|
-
// Schemas are now directly under categorySchemasPath
|
|
138
|
-
const newSchemaPathInRepo = path.join(categorySchemasPath, newSchemaFileName);
|
|
139
|
-
|
|
140
|
-
try {
|
|
141
|
-
// Read content from the original schema path
|
|
142
|
-
const schemaContent = await fs.readFile(originalSchemaPath, 'utf-8');
|
|
143
|
-
// Write content to the new schema file in the repo
|
|
144
|
-
await fs.writeFile(newSchemaPathInRepo, schemaContent);
|
|
145
|
-
Logger.debug(`[${onboardingId}] Copied schema for server '${serverName}' from '${originalSchemaPath}' to '${newSchemaPathInRepo}'`);
|
|
146
|
-
|
|
147
|
-
// Update the schemas property to the new filename, as per instruction "rename schemas in McpServer as serverName].json"
|
|
148
|
-
updatedServer.schemas = newSchemaFileName;
|
|
149
|
-
} catch (schemaError) {
|
|
150
|
-
const errorMsg = `Error processing schema for server '${serverName}' (source: ${originalSchemaPath}): ${schemaError instanceof Error ? schemaError.message : String(schemaError)}`;
|
|
151
|
-
Logger.error(`[${onboardingId}] ${errorMsg}`);
|
|
152
|
-
// Propagate the error to fail the onboarding step
|
|
153
|
-
throw new Error(errorMsg);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
updatedMcpServers.push(updatedServer);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Create a new config object with the updated mcpServers
|
|
162
|
-
const processedConfig = {
|
|
163
|
-
...config,
|
|
164
|
-
mcpServers: updatedMcpServers
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
const feedFilePath = path.join(feedsDir, `${config.name}.json`);
|
|
168
|
-
await fs.writeFile(feedFilePath, JSON.stringify(processedConfig, null, 2));
|
|
169
|
-
Logger.debug(`[${onboardingId}] Saved feed configuration (with processed schemas) to ${feedFilePath}`);
|
|
170
|
-
|
|
171
|
-
return { feedFilePath, categorySchemasPath };
|
|
172
|
-
} catch (error) {
|
|
173
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
174
|
-
Logger.error(`[${onboardingId}] Error during saveFeedConfigToRepo: ${errorMessage}`);
|
|
175
|
-
throw Object.assign(new Error(`Failed to save feed configuration to repo: ${errorMessage}`), { step: 'saveFeedConfigToRepo' });
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Creates a pull request on GitHub for the newly added feed configuration.
|
|
181
|
-
* @param onboardingId The ID of the onboarding process.
|
|
182
|
-
* @param config The feed configuration, used for branch name and PR details.
|
|
183
|
-
* @param repoDir The root directory of the cloned repository.
|
|
184
|
-
* @returns A promise that resolves to an object containing the URL of the created PR and the branch name.
|
|
185
|
-
* @throws An error if any step of the PR creation process fails.
|
|
186
|
-
*/
|
|
187
|
-
/**
|
|
188
|
-
* Sets up a clean branch for the feed configuration changes.
|
|
189
|
-
* @param onboardingId The ID of the onboarding process.
|
|
190
|
-
* @param config The feed configuration.
|
|
191
|
-
* @param repoDir The root directory of the cloned repository.
|
|
192
|
-
* @returns The name of the created branch.
|
|
193
|
-
* @throws An error if branch setup fails.
|
|
194
|
-
*/
|
|
195
|
-
public async setupBranch(onboardingId: string, config: FeedConfiguration, repoDir: string): Promise<string> {
|
|
196
|
-
try {
|
|
197
|
-
process.chdir(repoDir);
|
|
198
|
-
|
|
199
|
-
try {
|
|
200
|
-
await execAsync(`git remote get-url upstream`);
|
|
201
|
-
await execAsync(`git remote set-url upstream ${GITHUB_REPO.url}`);
|
|
202
|
-
Logger.debug(`[${onboardingId}] Updated 'upstream' remote URL to ${GITHUB_REPO.url}`);
|
|
203
|
-
} catch (remoteError) {
|
|
204
|
-
await execAsync(`git remote add upstream ${GITHUB_REPO.url}`);
|
|
205
|
-
Logger.debug(`[${onboardingId}] Added 'upstream' remote with URL ${GITHUB_REPO.url}`);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
await execAsync('git fetch upstream');
|
|
209
|
-
Logger.debug(`[${onboardingId}] Fetched from upstream.`);
|
|
210
|
-
|
|
211
|
-
try {
|
|
212
|
-
await execAsync('git checkout main --force');
|
|
213
|
-
Logger.debug(`[${onboardingId}] Switched to existing local branch 'main'.`);
|
|
214
|
-
} catch (checkoutMainError: any) {
|
|
215
|
-
const errStdErr = checkoutMainError.stderr || '';
|
|
216
|
-
if (errStdErr.includes('did not match any file(s) known to git') ||
|
|
217
|
-
errStdErr.includes('is not a commit and a branch') ||
|
|
218
|
-
errStdErr.includes('pathspec \'main\' did not match any file(s) known to git')) {
|
|
219
|
-
Logger.debug(`[${onboardingId}] Local branch 'main' not found or invalid. Attempting to create it from 'upstream/main'.`);
|
|
220
|
-
try {
|
|
221
|
-
await execAsync('git checkout -b main --force upstream/main');
|
|
222
|
-
Logger.debug(`[${onboardingId}] Created and switched to local branch 'main' from 'upstream/main'.`);
|
|
223
|
-
} catch (createMainError: any) {
|
|
224
|
-
const errMsg = createMainError instanceof Error ? createMainError.message : String(createMainError);
|
|
225
|
-
Logger.error(`[${onboardingId}] Failed to create local branch 'main' from 'upstream/main': ${errMsg}. Stderr: ${createMainError.stderr}`);
|
|
226
|
-
throw Object.assign(new Error(`Failed to create local branch 'main': ${errMsg}`), { step: 'setupBranch.setupMainBranch' });
|
|
227
|
-
}
|
|
228
|
-
} else {
|
|
229
|
-
const errMsg = checkoutMainError instanceof Error ? checkoutMainError.message : String(checkoutMainError);
|
|
230
|
-
Logger.error(`[${onboardingId}] Failed to checkout local branch 'main': ${errMsg}. Stderr: ${checkoutMainError.stderr}`);
|
|
231
|
-
throw Object.assign(new Error(`Failed to checkout local branch 'main': ${errMsg}`), { step: 'setupBranch.checkoutMainBranch' });
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
await execAsync('git reset --hard upstream/main');
|
|
236
|
-
Logger.debug(`[${onboardingId}] Local 'main' branch is now hard reset to 'upstream/main'.`);
|
|
237
|
-
|
|
238
|
-
const branchName = `feed/${config.name}`;
|
|
239
|
-
try {
|
|
240
|
-
await execAsync(`git branch -D ${branchName}`);
|
|
241
|
-
Logger.debug(`[${onboardingId}] Deleted local branch '${branchName}' as it may have existed.`);
|
|
242
|
-
} catch (deleteError: any) {
|
|
243
|
-
const errStdErrDelete = deleteError.stderr || '';
|
|
244
|
-
if (errStdErrDelete.includes('not found') || errStdErrDelete.includes('not found.')) {
|
|
245
|
-
Logger.debug(`[${onboardingId}] Local branch '${branchName}' did not exist, no need to delete.`);
|
|
246
|
-
} else {
|
|
247
|
-
const errorMessage = deleteError instanceof Error ? deleteError.message : String(deleteError);
|
|
248
|
-
Logger.error(`[${onboardingId}] Failed to delete local branch '${branchName}': ${errorMessage}. Stderr: ${deleteError.stderr}`);
|
|
249
|
-
throw Object.assign(new Error(`Failed to delete local branch '${branchName}': ${errorMessage}`), { step: 'setupBranch.deleteFeatureBranch' });
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
await execAsync(`git checkout -b ${branchName} upstream/main`);
|
|
254
|
-
Logger.debug(`[${onboardingId}] Created and checked out new branch '${branchName}' from 'upstream/main'.`);
|
|
255
|
-
|
|
256
|
-
return branchName;
|
|
257
|
-
} catch (error) {
|
|
258
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
259
|
-
Logger.error(`[${onboardingId}] Error during branch setup: ${errorMessage}`);
|
|
260
|
-
throw Object.assign(new Error(`Failed to setup branch: ${errorMessage}`), { step: 'setupBranch' });
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Creates a pull request for the feed configuration changes.
|
|
266
|
-
* @param onboardingId The ID of the onboarding process.
|
|
267
|
-
* @param config The feed configuration.
|
|
268
|
-
* @param repoDir The root directory of the cloned repository.
|
|
269
|
-
* @param branchName The name of the branch to create the PR from.
|
|
270
|
-
* @returns Object containing the PR URL and branch name.
|
|
271
|
-
* @throws An error if PR creation fails.
|
|
272
|
-
*/
|
|
273
|
-
public async createPullRequest(onboardingId: string, config: FeedConfiguration, repoDir: string, branchName: string): Promise<{ url: string; branchName: string; prExists: boolean }> {
|
|
274
|
-
try {
|
|
275
|
-
process.chdir(repoDir);
|
|
276
|
-
|
|
277
|
-
// Stage and commit changes
|
|
278
|
-
await execAsync('git add .');
|
|
279
|
-
await execAsync(`git commit --allow-empty -m "Add feed configuration for ${config.name}"`);
|
|
280
|
-
Logger.debug(`[${onboardingId}] Committed changes (or allowed empty commit) for ${config.name}.`);
|
|
281
|
-
|
|
282
|
-
// Push to origin
|
|
283
|
-
await execAsync(`git push -u -f origin ${branchName}`);
|
|
284
|
-
Logger.debug(`[${onboardingId}] Pushed branch ${branchName} to origin. Verifying remote branch...`);
|
|
285
|
-
|
|
286
|
-
try {
|
|
287
|
-
const { stdout: remoteBranchCheck } = await execAsync(`git ls-remote origin refs/heads/${branchName}`);
|
|
288
|
-
if (!remoteBranchCheck.includes(`refs/heads/${branchName}`)) {
|
|
289
|
-
throw new Error(`Branch ${branchName} not found on remote 'origin' (fork) after push. Output of ls-remote: ${remoteBranchCheck}`);
|
|
290
|
-
}
|
|
291
|
-
Logger.debug(`[${onboardingId}] Branch ${branchName} confirmed on remote 'origin' (fork).`);
|
|
292
|
-
} catch (verifyError) {
|
|
293
|
-
const errorMessage = verifyError instanceof Error ? verifyError.message : String(verifyError);
|
|
294
|
-
Logger.error(`[${onboardingId}] Failed to verify branch ${branchName} on remote 'origin' (fork) after push: ${errorMessage}`);
|
|
295
|
-
throw new Error(`Verification of branch ${branchName} on remote 'origin' (fork) failed: ${errorMessage}`);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const title = `Add feed configuration for ${config.name}`;
|
|
299
|
-
const body = `Add new feed configuration:\n\n- Name: ${config.name}\n- Display Name: ${config.displayName}\n- Description: ${config.description}`;
|
|
300
|
-
const username = await this.getGitHubUsername();
|
|
301
|
-
const explicitHeadRef = `${username}:${branchName}`;
|
|
302
|
-
|
|
303
|
-
const prCheckCommand = `gh pr list --repo ${GITHUB_REPO.repoName} --head ${branchName} --author ${username} --state open --json url --limit 1`;
|
|
304
|
-
Logger.debug(`[${onboardingId}] Checking for existing PR with command: ${prCheckCommand}`);
|
|
305
|
-
const { stdout: existingPrJson } = await execAsync(prCheckCommand);
|
|
306
|
-
|
|
307
|
-
let prUrlToReturn: string;
|
|
308
|
-
|
|
309
|
-
const createPRCommand = `gh pr create --repo ${GITHUB_REPO.repoName} --base main --head ${explicitHeadRef} --title "${title}" --body "${body}"`
|
|
310
|
-
let prExists = false;
|
|
311
|
-
|
|
312
|
-
if (existingPrJson && existingPrJson.trim() !== '[]' && existingPrJson.trim() !== '') {
|
|
313
|
-
try {
|
|
314
|
-
const prs = JSON.parse(existingPrJson);
|
|
315
|
-
if (prs.length > 0 && prs[0].url) {
|
|
316
|
-
prUrlToReturn = prs[0].url;
|
|
317
|
-
prExists = true;
|
|
318
|
-
Logger.log(`[${onboardingId}] Found existing open PR for ${explicitHeadRef} on ${GITHUB_REPO.repoName}: ${prUrlToReturn}`);
|
|
319
|
-
} else {
|
|
320
|
-
Logger.debug(`[${onboardingId}] No existing PR found or unable to parse PR list JSON. Proceeding to create PR.`);
|
|
321
|
-
const { stdout: prUrl } = await execAsync(createPRCommand);
|
|
322
|
-
prUrlToReturn = prUrl.trim();
|
|
323
|
-
}
|
|
324
|
-
} catch (parseError) {
|
|
325
|
-
Logger.log(`WARNING: [${onboardingId}] Could not parse existing PR JSON: ${existingPrJson}. Proceeding to create new PR. Error: ${parseError}`);
|
|
326
|
-
const { stdout: prUrl } = await execAsync(createPRCommand);
|
|
327
|
-
prUrlToReturn = prUrl.trim();
|
|
328
|
-
}
|
|
329
|
-
} else {
|
|
330
|
-
Logger.debug(`[${onboardingId}] No existing PR found. Proceeding to create PR.`);
|
|
331
|
-
const { stdout: prUrl } = await execAsync(createPRCommand);
|
|
332
|
-
prUrlToReturn = prUrl.trim();
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
Logger.debug(`[${onboardingId}] Pull request operation completed. PR URL: ${prUrlToReturn}`);
|
|
336
|
-
return { url: prUrlToReturn, branchName: branchName, prExists: prExists };
|
|
337
|
-
} catch (error) {
|
|
338
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
339
|
-
Logger.error(`[${onboardingId}] Error during createPullRequest: ${errorMessage}`);
|
|
340
|
-
throw Object.assign(new Error(`Failed to create pull request: ${errorMessage}`), { step: 'createPullRequest' });
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Creates necessary directories for the onboarding process
|
|
346
|
-
* @param onboardingId The ID of the onboarding process
|
|
347
|
-
* @returns Object containing tempDir and repoDir paths
|
|
348
|
-
*/
|
|
349
|
-
public createDirectories(onboardingId: string): { tempDir: string; repoDir: string } {
|
|
350
|
-
const tempDir = path.join(SETTINGS_DIR, 'onboard', 'temp', onboardingId);
|
|
351
|
-
const repoDir = path.join(tempDir, 'imcp-feed');
|
|
352
|
-
return { tempDir, repoDir };
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
export const onboardProcessor = new OnboardProcessor();
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { FeedConfiguration } from "../metadatas/types.js";
|
|
2
|
-
|
|
3
|
-
export enum OnboardingProcessStatus {
|
|
4
|
-
VALIDATING = 'validating',
|
|
5
|
-
VALIDATED = 'validated',
|
|
6
|
-
PR_CREATING = 'prcreating',
|
|
7
|
-
FAILED = 'failed',
|
|
8
|
-
SUCCEEDED = 'succeeded',
|
|
9
|
-
PENDING = 'pending',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type OperationType = 'FULL_ONBOARDING' | 'VALIDATION_ONLY';
|
|
13
|
-
|
|
14
|
-
export interface ServerValidationResult {
|
|
15
|
-
serverName: string;
|
|
16
|
-
isValid: boolean;
|
|
17
|
-
message?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface OnboardStatus {
|
|
21
|
-
onboardingId: string;
|
|
22
|
-
status: OnboardingProcessStatus;
|
|
23
|
-
steps?: {
|
|
24
|
-
stepName: string;
|
|
25
|
-
timestamp: string;
|
|
26
|
-
status?: OnboardingProcessStatus; // Status of this specific step, if different from overall
|
|
27
|
-
errorMessage?: string;
|
|
28
|
-
}[];
|
|
29
|
-
validationStatus?: {
|
|
30
|
-
isValid: boolean;
|
|
31
|
-
message?: string;
|
|
32
|
-
serverResults?: ServerValidationResult[];
|
|
33
|
-
};
|
|
34
|
-
prInfo?: {
|
|
35
|
-
url?: string;
|
|
36
|
-
branchName?: string;
|
|
37
|
-
};
|
|
38
|
-
result?: any; // Can store PR URL or other relevant result data
|
|
39
|
-
errorMessage?: string;
|
|
40
|
-
lastUpdated: string;
|
|
41
|
-
feedName: string;
|
|
42
|
-
serverName?: string; // Optional, if applicable
|
|
43
|
-
operationType?: OperationType;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface OperationStatus {
|
|
47
|
-
onboardingId: string;
|
|
48
|
-
status: OnboardingProcessStatus;
|
|
49
|
-
message?: string;
|
|
50
|
-
lastQueried?: string; // ISO date string of when the status was last queried by a client
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface ValidationOperationResult {
|
|
54
|
-
validationStatus: {
|
|
55
|
-
isValid: boolean;
|
|
56
|
-
message?: string;
|
|
57
|
-
serverResults?: ServerValidationResult[];
|
|
58
|
-
};
|
|
59
|
-
feedConfiguration?: FeedConfiguration;
|
|
60
|
-
}
|