* Warn this MCP client once for each selected project whose persisted * extraction version predates the running engine. The state belongs to the * client session, never this shared handler: one daemon serves many clients.
(
result: ToolResult,
projectPath: string | undefined,
state: IndexVersionWarningState | undefined,
)
| 3020 | * client session, never this shared handler: one daemon serves many clients. |
| 3021 | */ |
| 3022 | private withIndexVersionNotice( |
| 3023 | result: ToolResult, |
| 3024 | projectPath: string | undefined, |
| 3025 | state: IndexVersionWarningState | undefined, |
| 3026 | ): ToolResult { |
| 3027 | if (!state || result.isError) return result; |
| 3028 | const [first, ...rest] = result.content; |
| 3029 | if (!first || first.type !== 'text') return result; |
| 3030 | |
| 3031 | let cg: CodeGraph; |
| 3032 | let root: string; |
| 3033 | try { |
| 3034 | cg = this.getCodeGraph(projectPath); |
| 3035 | if (!cg.isIndexStale()) return result; |
| 3036 | root = cg.getProjectRoot(); |
| 3037 | } catch { |
| 3038 | // No initialized project (or a project that cannot be opened) has no |
| 3039 | // trustworthy build metadata to report and must not consume a warning. |
| 3040 | return result; |
| 3041 | } |
| 3042 | if (!state.claim(root)) return result; |
| 3043 | |
| 3044 | const warning = formatIndexVersionWarning(cg.getIndexBuildInfo()); |
| 3045 | return { |
| 3046 | ...result, |
| 3047 | content: [{ type: 'text', text: `${warning}\n\n${first.text}` }, ...rest], |
| 3048 | }; |
| 3049 | } |
| 3050 | |
| 3051 | /** |
| 3052 | * Execute a tool by name. |
no test coverage detected