* Write the merged graph to a standalone JSON file for external consumers (e.g., MCP server).
(graph: WorkflowGraph | null)
| 211 | * Write the merged graph to a standalone JSON file for external consumers (e.g., MCP server). |
| 212 | */ |
| 213 | private async writeGraphFile(graph: WorkflowGraph | null): Promise<void> { |
| 214 | if (!this.graphPath) return; |
| 215 | try { |
| 216 | if (graph) { |
| 217 | const content = JSON.stringify(graph, null, 2); |
| 218 | await vscode.workspace.fs.writeFile(this.graphPath, Buffer.from(content, 'utf8')); |
| 219 | } else { |
| 220 | try { await vscode.workspace.fs.delete(this.graphPath); } catch { /* may not exist */ } |
| 221 | } |
| 222 | } catch (error) { |
| 223 | console.error('Failed to write graph file:', error); |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | /** |
| 228 | * Force immediate save of any pending changes. |
no test coverage detected