()
| 3717 | } |
| 3718 | |
| 3719 | private async getSystemPrompt(): Promise<string> { |
| 3720 | const { mcpEnabled } = (await this.providerRef.deref()?.getState()) ?? {} |
| 3721 | let mcpHub: McpHub | undefined |
| 3722 | if (mcpEnabled ?? true) { |
| 3723 | const provider = this.providerRef.deref() |
| 3724 | |
| 3725 | if (!provider) { |
| 3726 | throw new Error("Provider reference lost during view transition") |
| 3727 | } |
| 3728 | |
| 3729 | // Wait for MCP hub initialization through McpServerManager |
| 3730 | mcpHub = await McpServerManager.getInstance(provider.context, provider) |
| 3731 | |
| 3732 | if (!mcpHub) { |
| 3733 | throw new Error("Failed to get MCP hub from server manager") |
| 3734 | } |
| 3735 | |
| 3736 | // Wait for MCP servers to be connected before generating system prompt |
| 3737 | await pWaitFor(() => !mcpHub!.isConnecting, { timeout: 10_000 }).catch(() => { |
| 3738 | console.error("MCP servers failed to connect in time") |
| 3739 | }) |
| 3740 | } |
| 3741 | |
| 3742 | const rooIgnoreInstructions = this.rooIgnoreController?.getInstructions() |
| 3743 | |
| 3744 | const state = await this.providerRef.deref()?.getState() |
| 3745 | |
| 3746 | const { |
| 3747 | mode, |
| 3748 | customModes, |
| 3749 | customModePrompts, |
| 3750 | customInstructions, |
| 3751 | experiments, |
| 3752 | language, |
| 3753 | apiConfiguration, |
| 3754 | enableSubfolderRules, |
| 3755 | } = state ?? {} |
| 3756 | |
| 3757 | return await (async () => { |
| 3758 | const provider = this.providerRef.deref() |
| 3759 | |
| 3760 | if (!provider) { |
| 3761 | throw new Error("Provider not available") |
| 3762 | } |
| 3763 | |
| 3764 | const modelInfo = this.api.getModel().info |
| 3765 | |
| 3766 | return SYSTEM_PROMPT( |
| 3767 | provider.context, |
| 3768 | this.cwd, |
| 3769 | false, |
| 3770 | mcpHub, |
| 3771 | this.diffStrategy, |
| 3772 | mode ?? defaultModeSlug, |
| 3773 | customModePrompts, |
| 3774 | customModes, |
| 3775 | customInstructions, |
| 3776 | experiments, |
no test coverage detected