flowzap-mcp 1.0.7 → 1.1.0
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/README.md +36 -1
- package/dist/index.js +36 -1
- package/dist/index.js.map +1 -1
- package/dist/tools/artifactToDiagram.d.ts +21 -0
- package/dist/tools/artifactToDiagram.d.ts.map +1 -0
- package/dist/tools/artifactToDiagram.js +485 -0
- package/dist/tools/artifactToDiagram.js.map +1 -0
- package/dist/tools/diffAndApply.d.ts +67 -0
- package/dist/tools/diffAndApply.d.ts.map +1 -0
- package/dist/tools/diffAndApply.js +474 -0
- package/dist/tools/diffAndApply.js.map +1 -0
- package/dist/tools/exportGraph.d.ts +51 -0
- package/dist/tools/exportGraph.d.ts.map +1 -0
- package/dist/tools/exportGraph.js +222 -0
- package/dist/tools/exportGraph.js.map +1 -0
- package/dist/tools/index.d.ts +12 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +9 -0
- package/dist/tools/index.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,20 +61,55 @@ Add to `~/.codeium/windsurf/mcp_config.json`:
|
|
|
61
61
|
|
|
62
62
|
## Available Tools
|
|
63
63
|
|
|
64
|
+
### Core Tools
|
|
64
65
|
| Tool | Description |
|
|
65
66
|
|------|-------------|
|
|
66
67
|
| `flowzap_validate` | Validate FlowZap Code syntax |
|
|
67
68
|
| `flowzap_create_playground` | Create a shareable diagram URL |
|
|
68
69
|
| `flowzap_get_syntax` | Get FlowZap Code syntax documentation |
|
|
69
70
|
|
|
71
|
+
### Agent-Focused Tools (v1.1.0+)
|
|
72
|
+
| Tool | Description |
|
|
73
|
+
|------|-------------|
|
|
74
|
+
| `flowzap_export_graph` | Export FlowZap Code as structured JSON graph (lanes, nodes, edges) for reasoning |
|
|
75
|
+
| `flowzap_artifact_to_diagram` | Parse HTTP logs, OpenAPI specs, or code into FlowZap diagrams |
|
|
76
|
+
| `flowzap_diff` | Compare two versions of FlowZap Code and get structured diff |
|
|
77
|
+
| `flowzap_apply_change` | Apply structured patch operations (insert/remove/update nodes/edges) |
|
|
78
|
+
|
|
70
79
|
## Usage Examples
|
|
71
80
|
|
|
81
|
+
### Basic Diagram Creation
|
|
72
82
|
Ask your AI assistant:
|
|
73
|
-
|
|
74
83
|
- "Create a workflow diagram for an order processing system"
|
|
75
84
|
- "Make a flowchart showing user registration flow"
|
|
76
85
|
- "Diagram a CI/CD pipeline with build, test, and deploy stages"
|
|
77
86
|
|
|
87
|
+
### Agent-Focused Workflows
|
|
88
|
+
|
|
89
|
+
**Parse HTTP Logs into Diagrams:**
|
|
90
|
+
```
|
|
91
|
+
"Here are my nginx access logs. Create a sequence diagram showing the request flow."
|
|
92
|
+
```
|
|
93
|
+
The agent uses `flowzap_artifact_to_diagram` with `artifactType: "http_logs"`.
|
|
94
|
+
|
|
95
|
+
**Analyze Diagram Structure:**
|
|
96
|
+
```
|
|
97
|
+
"Which steps in this workflow touch the database?"
|
|
98
|
+
```
|
|
99
|
+
The agent uses `flowzap_export_graph` to get a JSON graph, then queries it.
|
|
100
|
+
|
|
101
|
+
**Show What Changed:**
|
|
102
|
+
```
|
|
103
|
+
"I updated the workflow. What's different from the previous version?"
|
|
104
|
+
```
|
|
105
|
+
The agent uses `flowzap_diff` to compare old and new code.
|
|
106
|
+
|
|
107
|
+
**Safe Incremental Updates:**
|
|
108
|
+
```
|
|
109
|
+
"Add a logging step after the API call in this diagram."
|
|
110
|
+
```
|
|
111
|
+
The agent uses `flowzap_apply_change` with a structured patch instead of regenerating.
|
|
112
|
+
|
|
78
113
|
The assistant will:
|
|
79
114
|
1. Generate FlowZap Code based on your description
|
|
80
115
|
2. Validate the code
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
// Import new agent-focused tools
|
|
6
|
+
import { exportGraphTool, handleExportGraph, artifactToDiagramTool, handleArtifactToDiagram, diffTool, applyChangeTool, handleDiff, handleApplyChange, } from "./tools/index.js";
|
|
5
7
|
// =============================================================================
|
|
6
8
|
// SECURITY CONFIGURATION
|
|
7
9
|
// =============================================================================
|
|
@@ -148,6 +150,11 @@ const tools = [
|
|
|
148
150
|
properties: {},
|
|
149
151
|
},
|
|
150
152
|
},
|
|
153
|
+
// New agent-focused tools
|
|
154
|
+
exportGraphTool,
|
|
155
|
+
artifactToDiagramTool,
|
|
156
|
+
diffTool,
|
|
157
|
+
applyChangeTool,
|
|
151
158
|
];
|
|
152
159
|
// FlowZap Code syntax documentation
|
|
153
160
|
const FLOWZAP_SYNTAX = `
|
|
@@ -387,7 +394,15 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
387
394
|
const { name, arguments: args } = request.params;
|
|
388
395
|
securityLog("TOOL_CALL", { tool: name });
|
|
389
396
|
// Validate tool name (whitelist approach)
|
|
390
|
-
const allowedTools = [
|
|
397
|
+
const allowedTools = [
|
|
398
|
+
"flowzap_validate",
|
|
399
|
+
"flowzap_create_playground",
|
|
400
|
+
"flowzap_get_syntax",
|
|
401
|
+
"flowzap_export_graph",
|
|
402
|
+
"flowzap_artifact_to_diagram",
|
|
403
|
+
"flowzap_diff",
|
|
404
|
+
"flowzap_apply_change",
|
|
405
|
+
];
|
|
391
406
|
if (!allowedTools.includes(name)) {
|
|
392
407
|
securityLog("UNKNOWN_TOOL", { tool: name });
|
|
393
408
|
throw new Error(`Unknown tool: ${name}`);
|
|
@@ -406,6 +421,26 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
406
421
|
case "flowzap_get_syntax": {
|
|
407
422
|
return { content: [{ type: "text", text: FLOWZAP_SYNTAX }] };
|
|
408
423
|
}
|
|
424
|
+
case "flowzap_export_graph": {
|
|
425
|
+
const code = args?.code;
|
|
426
|
+
const result = handleExportGraph(code);
|
|
427
|
+
return { content: [{ type: "text", text: result }] };
|
|
428
|
+
}
|
|
429
|
+
case "flowzap_artifact_to_diagram": {
|
|
430
|
+
const { artifactType, content, view } = args;
|
|
431
|
+
const result = handleArtifactToDiagram(artifactType, content, view);
|
|
432
|
+
return { content: [{ type: "text", text: result }] };
|
|
433
|
+
}
|
|
434
|
+
case "flowzap_diff": {
|
|
435
|
+
const { oldCode, newCode } = args;
|
|
436
|
+
const result = handleDiff(oldCode, newCode);
|
|
437
|
+
return { content: [{ type: "text", text: result }] };
|
|
438
|
+
}
|
|
439
|
+
case "flowzap_apply_change": {
|
|
440
|
+
const { code, operations } = args;
|
|
441
|
+
const result = handleApplyChange(code, operations);
|
|
442
|
+
return { content: [{ type: "text", text: result }] };
|
|
443
|
+
}
|
|
409
444
|
default:
|
|
410
445
|
throw new Error(`Unknown tool: ${name}`);
|
|
411
446
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAEvB,MAAM,oCAAoC,CAAC;AAE5C,gFAAgF;AAChF,yBAAyB;AACzB,gFAAgF;AAEhF,yEAAyE;AACzE,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAC/C,MAAM,aAAa,GAAG,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;AAEzD,kEAAkE;AAClE,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,oBAAoB,GAAG,MAAM,CAAC;AACpC,MAAM,cAAc,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,E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C,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArtifactToDiagram Tool
|
|
3
|
+
*
|
|
4
|
+
* Parses real artifacts (HTTP logs, OpenAPI specs, code snippets) into FlowZap Code.
|
|
5
|
+
* Gives AI agents a capability they don't have natively: structured extraction from logs/specs.
|
|
6
|
+
*/
|
|
7
|
+
import { Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
8
|
+
export type ArtifactType = "http_logs" | "openapi" | "code" | "diff";
|
|
9
|
+
export interface ParsedArtifact {
|
|
10
|
+
code: string;
|
|
11
|
+
view: "workflow" | "sequence";
|
|
12
|
+
notes: string;
|
|
13
|
+
actors: string[];
|
|
14
|
+
stepCount: number;
|
|
15
|
+
}
|
|
16
|
+
export declare const artifactToDiagramTool: Tool;
|
|
17
|
+
/**
|
|
18
|
+
* Main handler for artifact_to_diagram tool
|
|
19
|
+
*/
|
|
20
|
+
export declare function handleArtifactToDiagram(artifactType: unknown, content: unknown, view?: unknown): string;
|
|
21
|
+
//# sourceMappingURL=artifactToDiagram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifactToDiagram.d.ts","sourceRoot":"","sources":["../../src/tools/artifactToDiagram.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE1D,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAErE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,qBAAqB,EAAE,IAwBnC,CAAC;AAqbF;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,OAAO,EACrB,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,OAAO,GACb,MAAM,CAiFR"}
|
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArtifactToDiagram Tool
|
|
3
|
+
*
|
|
4
|
+
* Parses real artifacts (HTTP logs, OpenAPI specs, code snippets) into FlowZap Code.
|
|
5
|
+
* Gives AI agents a capability they don't have natively: structured extraction from logs/specs.
|
|
6
|
+
*/
|
|
7
|
+
export const artifactToDiagramTool = {
|
|
8
|
+
name: "flowzap_artifact_to_diagram",
|
|
9
|
+
description: "Parse real artifacts (HTTP logs, OpenAPI specs, code snippets) into FlowZap Code diagrams. Use this to convert raw technical data into visual workflows that can be explained and refined.",
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: "object",
|
|
12
|
+
properties: {
|
|
13
|
+
artifactType: {
|
|
14
|
+
type: "string",
|
|
15
|
+
enum: ["http_logs", "openapi", "code"],
|
|
16
|
+
description: "Type of artifact: http_logs (request/response sequences), openapi (API specs), code (function call traces)",
|
|
17
|
+
},
|
|
18
|
+
content: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "Raw artifact content to parse",
|
|
21
|
+
},
|
|
22
|
+
view: {
|
|
23
|
+
type: "string",
|
|
24
|
+
enum: ["workflow", "sequence"],
|
|
25
|
+
description: "Preferred diagram view (default: sequence for logs, workflow for openapi)",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: ["artifactType", "content"],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Parse HTTP logs into FlowZap Code
|
|
33
|
+
*
|
|
34
|
+
* Supports formats:
|
|
35
|
+
* - Apache/Nginx combined log format
|
|
36
|
+
* - Simple request/response pairs
|
|
37
|
+
* - HAR-like JSON
|
|
38
|
+
*/
|
|
39
|
+
function parseHttpLogs(content) {
|
|
40
|
+
const lines = content.split("\n").filter((l) => l.trim());
|
|
41
|
+
const actors = new Set(["Client"]);
|
|
42
|
+
const steps = [];
|
|
43
|
+
// Try to detect format
|
|
44
|
+
let nodeId = 1;
|
|
45
|
+
// Pattern 1: Simple "METHOD URL -> STATUS" or "CLIENT -> SERVER: MESSAGE"
|
|
46
|
+
const simplePattern = /^(\w+)?\s*(?:->|→)\s*(\w+)(?:\s*:\s*(.+))?$/;
|
|
47
|
+
const httpPattern = /^(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS)\s+(\S+)(?:\s+(\d{3}))?/i;
|
|
48
|
+
const responsePattern = /^(\d{3})\s+(.+)/;
|
|
49
|
+
let currentServer = "Server";
|
|
50
|
+
for (const line of lines) {
|
|
51
|
+
const trimmed = line.trim();
|
|
52
|
+
if (!trimmed)
|
|
53
|
+
continue;
|
|
54
|
+
// Try HTTP method pattern
|
|
55
|
+
const httpMatch = trimmed.match(httpPattern);
|
|
56
|
+
if (httpMatch) {
|
|
57
|
+
const [, method, path, status] = httpMatch;
|
|
58
|
+
// Extract server from path if it's a full URL
|
|
59
|
+
try {
|
|
60
|
+
const url = new URL(path.startsWith("http") ? path : `https://example.com${path}`);
|
|
61
|
+
currentServer = url.hostname.split(".")[0] || "Server";
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Keep current server
|
|
65
|
+
}
|
|
66
|
+
actors.add(currentServer);
|
|
67
|
+
// Request
|
|
68
|
+
steps.push({
|
|
69
|
+
from: "Client",
|
|
70
|
+
to: currentServer,
|
|
71
|
+
label: `${method} ${path.length > 30 ? path.substring(0, 30) + "..." : path}`,
|
|
72
|
+
});
|
|
73
|
+
// Response if status included
|
|
74
|
+
if (status) {
|
|
75
|
+
steps.push({
|
|
76
|
+
from: currentServer,
|
|
77
|
+
to: "Client",
|
|
78
|
+
label: `${status} Response`,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
// Try simple arrow pattern
|
|
84
|
+
const simpleMatch = trimmed.match(simplePattern);
|
|
85
|
+
if (simpleMatch) {
|
|
86
|
+
const [, from = "Client", to, message = "Request"] = simpleMatch;
|
|
87
|
+
actors.add(from);
|
|
88
|
+
actors.add(to);
|
|
89
|
+
steps.push({ from, to, label: message });
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
// Try response pattern (just status code)
|
|
93
|
+
const responseMatch = trimmed.match(responsePattern);
|
|
94
|
+
if (responseMatch && steps.length > 0) {
|
|
95
|
+
const lastStep = steps[steps.length - 1];
|
|
96
|
+
steps.push({
|
|
97
|
+
from: lastStep.to,
|
|
98
|
+
to: lastStep.from,
|
|
99
|
+
label: `${responseMatch[1]} ${responseMatch[2]}`,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// If no steps parsed, create a placeholder
|
|
104
|
+
if (steps.length === 0) {
|
|
105
|
+
return {
|
|
106
|
+
code: `client {\n # Client\n n1: circle label:"No parseable requests found"\n}`,
|
|
107
|
+
view: "sequence",
|
|
108
|
+
notes: "Could not parse HTTP log format. Try a simpler format like 'GET /api/users 200' or 'Client -> Server: Request'",
|
|
109
|
+
actors: ["Client"],
|
|
110
|
+
stepCount: 0,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
// Generate FlowZap Code
|
|
114
|
+
const actorList = Array.from(actors);
|
|
115
|
+
const laneNodes = new Map();
|
|
116
|
+
const allEdges = [];
|
|
117
|
+
// Initialize lanes
|
|
118
|
+
for (const actor of actorList) {
|
|
119
|
+
laneNodes.set(actor, []);
|
|
120
|
+
}
|
|
121
|
+
// Create nodes and edges
|
|
122
|
+
for (const step of steps) {
|
|
123
|
+
const fromLane = step.from;
|
|
124
|
+
const toLane = step.to;
|
|
125
|
+
// Create source node if this is first action from this actor
|
|
126
|
+
const fromNodes = laneNodes.get(fromLane) || [];
|
|
127
|
+
let fromNodeId;
|
|
128
|
+
if (fromNodes.length === 0) {
|
|
129
|
+
fromNodeId = `n${nodeId++}`;
|
|
130
|
+
fromNodes.push(` ${fromNodeId}: rectangle label:"${escapeLabel(step.label)}"`);
|
|
131
|
+
laneNodes.set(fromLane, fromNodes);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
// Use last node as source
|
|
135
|
+
const lastNode = fromNodes[fromNodes.length - 1];
|
|
136
|
+
const match = lastNode.match(/^\s*(n\d+):/);
|
|
137
|
+
fromNodeId = match ? match[1] : `n${nodeId++}`;
|
|
138
|
+
}
|
|
139
|
+
// Create target node
|
|
140
|
+
const toNodes = laneNodes.get(toLane) || [];
|
|
141
|
+
const toNodeId = `n${nodeId++}`;
|
|
142
|
+
toNodes.push(` ${toNodeId}: rectangle label:"${escapeLabel(step.label)}"`);
|
|
143
|
+
laneNodes.set(toLane, toNodes);
|
|
144
|
+
// Create edge
|
|
145
|
+
if (fromLane === toLane) {
|
|
146
|
+
allEdges.push(` ${fromNodeId}.handle(right) -> ${toNodeId}.handle(left)`);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
allEdges.push(` ${fromNodeId}.handle(bottom) -> ${toLane.toLowerCase().replace(/\s+/g, "")}.${toNodeId}.handle(top) [label="${escapeLabel(step.label)}"]`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Build code
|
|
153
|
+
let code = "";
|
|
154
|
+
for (const [actor, nodes] of laneNodes) {
|
|
155
|
+
const laneId = actor.toLowerCase().replace(/\s+/g, "");
|
|
156
|
+
code += `${laneId} {\n # ${actor}\n`;
|
|
157
|
+
code += nodes.join("\n") + "\n";
|
|
158
|
+
// Add edges that originate from this lane
|
|
159
|
+
const laneEdges = allEdges.filter((e) => e.includes(`${laneId}.`) || e.match(new RegExp(`^\\s*n\\d+\\.handle`)));
|
|
160
|
+
if (laneEdges.length > 0) {
|
|
161
|
+
code += laneEdges.join("\n") + "\n";
|
|
162
|
+
}
|
|
163
|
+
code += "}\n\n";
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
code: code.trim(),
|
|
167
|
+
view: "sequence",
|
|
168
|
+
notes: `Inferred ${actorList.length} actors and ${steps.length} steps from HTTP logs`,
|
|
169
|
+
actors: actorList,
|
|
170
|
+
stepCount: steps.length,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Parse OpenAPI spec into FlowZap Code
|
|
175
|
+
*/
|
|
176
|
+
function parseOpenAPI(content) {
|
|
177
|
+
let spec;
|
|
178
|
+
try {
|
|
179
|
+
spec = JSON.parse(content);
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
// Try YAML-like parsing (basic)
|
|
183
|
+
try {
|
|
184
|
+
// Very basic YAML parsing for common patterns
|
|
185
|
+
const lines = content.split("\n");
|
|
186
|
+
spec = { paths: {}, info: { title: "API" } };
|
|
187
|
+
let currentPath = "";
|
|
188
|
+
let currentMethod = "";
|
|
189
|
+
for (const line of lines) {
|
|
190
|
+
const pathMatch = line.match(/^\/[\w\-\/{}]+:/);
|
|
191
|
+
if (pathMatch) {
|
|
192
|
+
currentPath = pathMatch[0].replace(":", "");
|
|
193
|
+
spec.paths[currentPath] = {};
|
|
194
|
+
}
|
|
195
|
+
const methodMatch = line.match(/^\s+(get|post|put|delete|patch):/i);
|
|
196
|
+
if (methodMatch && currentPath) {
|
|
197
|
+
currentMethod = methodMatch[1].toLowerCase();
|
|
198
|
+
spec.paths[currentPath][currentMethod] = { summary: "" };
|
|
199
|
+
}
|
|
200
|
+
const summaryMatch = line.match(/^\s+summary:\s*(.+)/);
|
|
201
|
+
if (summaryMatch && currentPath && currentMethod) {
|
|
202
|
+
spec.paths[currentPath][currentMethod].summary = summaryMatch[1].trim().replace(/^["']|["']$/g, "");
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
return {
|
|
208
|
+
code: `api {\n # API\n n1: circle label:"Could not parse OpenAPI spec"\n}`,
|
|
209
|
+
view: "workflow",
|
|
210
|
+
notes: "Failed to parse OpenAPI content. Ensure it's valid JSON or YAML.",
|
|
211
|
+
actors: ["API"],
|
|
212
|
+
stepCount: 0,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const paths = spec.paths || {};
|
|
217
|
+
const title = spec.info?.title || "API";
|
|
218
|
+
const actors = new Set(["Client", title]);
|
|
219
|
+
const steps = [];
|
|
220
|
+
// Extract endpoints
|
|
221
|
+
for (const [path, methods] of Object.entries(paths)) {
|
|
222
|
+
if (typeof methods !== "object" || methods === null)
|
|
223
|
+
continue;
|
|
224
|
+
for (const [method, details] of Object.entries(methods)) {
|
|
225
|
+
if (!["get", "post", "put", "delete", "patch"].includes(method.toLowerCase()))
|
|
226
|
+
continue;
|
|
227
|
+
const summary = details?.summary || details?.operationId || `${method.toUpperCase()} ${path}`;
|
|
228
|
+
steps.push({
|
|
229
|
+
method: method.toUpperCase(),
|
|
230
|
+
path,
|
|
231
|
+
summary: String(summary),
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (steps.length === 0) {
|
|
236
|
+
return {
|
|
237
|
+
code: `api {\n # ${title}\n n1: circle label:"No endpoints found"\n}`,
|
|
238
|
+
view: "workflow",
|
|
239
|
+
notes: "No API endpoints found in the OpenAPI spec.",
|
|
240
|
+
actors: [title],
|
|
241
|
+
stepCount: 0,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
// Generate workflow diagram
|
|
245
|
+
const apiLaneId = title.toLowerCase().replace(/\s+/g, "").replace(/[^a-z0-9]/g, "");
|
|
246
|
+
let code = `client {\n # Client\n n1: circle label:"Start"\n}\n\n`;
|
|
247
|
+
code += `${apiLaneId} {\n # ${title}\n`;
|
|
248
|
+
let nodeId = 2;
|
|
249
|
+
const nodeIds = [];
|
|
250
|
+
for (const step of steps) {
|
|
251
|
+
const label = step.summary.length > 40 ? step.summary.substring(0, 40) + "..." : step.summary;
|
|
252
|
+
code += ` n${nodeId}: rectangle label:"${escapeLabel(label)}"\n`;
|
|
253
|
+
nodeIds.push(`n${nodeId}`);
|
|
254
|
+
nodeId++;
|
|
255
|
+
}
|
|
256
|
+
// Add edges between consecutive endpoints
|
|
257
|
+
for (let i = 0; i < nodeIds.length - 1; i++) {
|
|
258
|
+
code += ` ${nodeIds[i]}.handle(right) -> ${nodeIds[i + 1]}.handle(left)\n`;
|
|
259
|
+
}
|
|
260
|
+
// Add end node
|
|
261
|
+
code += ` n${nodeId}: circle label:"End"\n`;
|
|
262
|
+
if (nodeIds.length > 0) {
|
|
263
|
+
code += ` ${nodeIds[nodeIds.length - 1]}.handle(right) -> n${nodeId}.handle(left)\n`;
|
|
264
|
+
}
|
|
265
|
+
code += "}\n";
|
|
266
|
+
// Add cross-lane edge from client to first API node
|
|
267
|
+
code = code.replace("n1: circle label:\"Start\"\n}", `n1: circle label:"Start"\n n1.handle(bottom) -> ${apiLaneId}.n2.handle(top)\n}`);
|
|
268
|
+
return {
|
|
269
|
+
code,
|
|
270
|
+
view: "workflow",
|
|
271
|
+
notes: `Extracted ${steps.length} endpoints from OpenAPI spec "${title}"`,
|
|
272
|
+
actors: Array.from(actors),
|
|
273
|
+
stepCount: steps.length,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Parse code snippets into FlowZap Code (function call trace)
|
|
278
|
+
*/
|
|
279
|
+
function parseCode(content) {
|
|
280
|
+
const lines = content.split("\n").filter((l) => l.trim());
|
|
281
|
+
const actors = new Set();
|
|
282
|
+
const calls = [];
|
|
283
|
+
// Patterns for function calls
|
|
284
|
+
const patterns = [
|
|
285
|
+
// JavaScript/TypeScript: object.method() or await object.method()
|
|
286
|
+
/(?:await\s+)?(\w+)\.(\w+)\s*\(/g,
|
|
287
|
+
// Python: object.method() or Class.method()
|
|
288
|
+
/(\w+)\.(\w+)\s*\(/g,
|
|
289
|
+
// Function definition: function name() or def name():
|
|
290
|
+
/(?:function|def|async\s+function)\s+(\w+)/g,
|
|
291
|
+
// Class method: class.method or self.method
|
|
292
|
+
/(?:this|self)\.(\w+)\s*\(/g,
|
|
293
|
+
];
|
|
294
|
+
let currentModule = "Main";
|
|
295
|
+
for (const line of lines) {
|
|
296
|
+
const trimmed = line.trim();
|
|
297
|
+
// Detect class/module definitions
|
|
298
|
+
const classMatch = trimmed.match(/^(?:class|module|namespace)\s+(\w+)/);
|
|
299
|
+
if (classMatch) {
|
|
300
|
+
currentModule = classMatch[1];
|
|
301
|
+
actors.add(currentModule);
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
// Detect function definitions
|
|
305
|
+
const funcMatch = trimmed.match(/^(?:function|def|async\s+function|async\s+def)\s+(\w+)/);
|
|
306
|
+
if (funcMatch) {
|
|
307
|
+
actors.add(currentModule);
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
// Detect method calls
|
|
311
|
+
const callMatch = trimmed.match(/(?:await\s+)?(\w+)\.(\w+)\s*\(/);
|
|
312
|
+
if (callMatch) {
|
|
313
|
+
const [, obj, method] = callMatch;
|
|
314
|
+
// Skip common non-actor objects
|
|
315
|
+
if (["console", "Math", "JSON", "Object", "Array", "String", "this", "self"].includes(obj)) {
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
actors.add(obj);
|
|
319
|
+
calls.push({
|
|
320
|
+
caller: currentModule,
|
|
321
|
+
callee: obj,
|
|
322
|
+
method,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (calls.length === 0) {
|
|
327
|
+
return {
|
|
328
|
+
code: `main {\n # Main\n n1: circle label:"No function calls detected"\n}`,
|
|
329
|
+
view: "sequence",
|
|
330
|
+
notes: "Could not detect function call patterns in the code.",
|
|
331
|
+
actors: ["Main"],
|
|
332
|
+
stepCount: 0,
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
// Generate sequence diagram
|
|
336
|
+
const actorList = Array.from(actors);
|
|
337
|
+
if (!actorList.includes("Main")) {
|
|
338
|
+
actorList.unshift("Main");
|
|
339
|
+
}
|
|
340
|
+
let code = "";
|
|
341
|
+
const laneNodes = new Map();
|
|
342
|
+
let nodeId = 1;
|
|
343
|
+
// Initialize lanes
|
|
344
|
+
for (const actor of actorList) {
|
|
345
|
+
const laneId = actor.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
346
|
+
code += `${laneId} {\n # ${actor}\n`;
|
|
347
|
+
laneNodes.set(actor, 0);
|
|
348
|
+
code += "}\n\n";
|
|
349
|
+
}
|
|
350
|
+
// We'll rebuild with nodes and edges
|
|
351
|
+
code = "";
|
|
352
|
+
const allNodes = [];
|
|
353
|
+
const allEdges = [];
|
|
354
|
+
for (const call of calls) {
|
|
355
|
+
const fromLane = call.caller.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
356
|
+
const toLane = call.callee.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
357
|
+
const fromNodeId = `n${nodeId++}`;
|
|
358
|
+
const toNodeId = `n${nodeId++}`;
|
|
359
|
+
allNodes.push({ lane: fromLane, id: fromNodeId, label: `Call ${call.method}` });
|
|
360
|
+
allNodes.push({ lane: toLane, id: toNodeId, label: call.method });
|
|
361
|
+
if (fromLane === toLane) {
|
|
362
|
+
allEdges.push({ lane: fromLane, edge: ` ${fromNodeId}.handle(right) -> ${toNodeId}.handle(left)` });
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
allEdges.push({ lane: fromLane, edge: ` ${fromNodeId}.handle(bottom) -> ${toLane}.${toNodeId}.handle(top) [label="${call.method}"]` });
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
// Group nodes by lane
|
|
369
|
+
const nodesByLane = new Map();
|
|
370
|
+
for (const node of allNodes) {
|
|
371
|
+
const existing = nodesByLane.get(node.lane) || [];
|
|
372
|
+
existing.push(node);
|
|
373
|
+
nodesByLane.set(node.lane, existing);
|
|
374
|
+
}
|
|
375
|
+
// Build code
|
|
376
|
+
for (const actor of actorList) {
|
|
377
|
+
const laneId = actor.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
378
|
+
code += `${laneId} {\n # ${actor}\n`;
|
|
379
|
+
const nodes = nodesByLane.get(laneId) || [];
|
|
380
|
+
for (const node of nodes) {
|
|
381
|
+
code += ` ${node.id}: rectangle label:"${escapeLabel(node.label)}"\n`;
|
|
382
|
+
}
|
|
383
|
+
const edges = allEdges.filter((e) => e.lane === laneId);
|
|
384
|
+
for (const e of edges) {
|
|
385
|
+
code += e.edge + "\n";
|
|
386
|
+
}
|
|
387
|
+
code += "}\n\n";
|
|
388
|
+
}
|
|
389
|
+
return {
|
|
390
|
+
code: code.trim(),
|
|
391
|
+
view: "sequence",
|
|
392
|
+
notes: `Detected ${calls.length} function calls across ${actorList.length} modules`,
|
|
393
|
+
actors: actorList,
|
|
394
|
+
stepCount: calls.length,
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Escape label text for FlowZap Code
|
|
399
|
+
*/
|
|
400
|
+
function escapeLabel(text) {
|
|
401
|
+
return text
|
|
402
|
+
.replace(/\\/g, "\\\\")
|
|
403
|
+
.replace(/"/g, '\\"')
|
|
404
|
+
.replace(/\n/g, " ")
|
|
405
|
+
.trim();
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Main handler for artifact_to_diagram tool
|
|
409
|
+
*/
|
|
410
|
+
export function handleArtifactToDiagram(artifactType, content, view) {
|
|
411
|
+
// Validate inputs
|
|
412
|
+
if (typeof artifactType !== "string") {
|
|
413
|
+
return JSON.stringify({
|
|
414
|
+
success: false,
|
|
415
|
+
error: "artifactType must be a string",
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
if (!["http_logs", "openapi", "code"].includes(artifactType)) {
|
|
419
|
+
return JSON.stringify({
|
|
420
|
+
success: false,
|
|
421
|
+
error: `Invalid artifactType "${artifactType}". Must be one of: http_logs, openapi, code`,
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
if (typeof content !== "string") {
|
|
425
|
+
return JSON.stringify({
|
|
426
|
+
success: false,
|
|
427
|
+
error: "content must be a string",
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
if (content.trim().length === 0) {
|
|
431
|
+
return JSON.stringify({
|
|
432
|
+
success: false,
|
|
433
|
+
error: "content cannot be empty",
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
if (content.length > 100000) {
|
|
437
|
+
return JSON.stringify({
|
|
438
|
+
success: false,
|
|
439
|
+
error: "content exceeds maximum length of 100,000 characters",
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
try {
|
|
443
|
+
let result;
|
|
444
|
+
switch (artifactType) {
|
|
445
|
+
case "http_logs":
|
|
446
|
+
result = parseHttpLogs(content);
|
|
447
|
+
break;
|
|
448
|
+
case "openapi":
|
|
449
|
+
result = parseOpenAPI(content);
|
|
450
|
+
break;
|
|
451
|
+
case "code":
|
|
452
|
+
result = parseCode(content);
|
|
453
|
+
break;
|
|
454
|
+
default:
|
|
455
|
+
return JSON.stringify({
|
|
456
|
+
success: false,
|
|
457
|
+
error: `Unsupported artifact type: ${artifactType}`,
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
// Override view if specified
|
|
461
|
+
if (view === "workflow" || view === "sequence") {
|
|
462
|
+
result.view = view;
|
|
463
|
+
}
|
|
464
|
+
return JSON.stringify({
|
|
465
|
+
success: true,
|
|
466
|
+
code: result.code,
|
|
467
|
+
view: result.view,
|
|
468
|
+
notes: result.notes,
|
|
469
|
+
stats: {
|
|
470
|
+
actors: result.actors,
|
|
471
|
+
stepCount: result.stepCount,
|
|
472
|
+
},
|
|
473
|
+
_next: {
|
|
474
|
+
hint: "Call flowzap_create_playground with this code to get a shareable diagram URL",
|
|
475
|
+
},
|
|
476
|
+
}, null, 2);
|
|
477
|
+
}
|
|
478
|
+
catch (error) {
|
|
479
|
+
return JSON.stringify({
|
|
480
|
+
success: false,
|
|
481
|
+
error: `Failed to parse artifact: ${error instanceof Error ? error.message : String(error)}`,
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
//# sourceMappingURL=artifactToDiagram.js.map
|