edict-lang 1.6.0 → 1.7.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 +4 -4
- package/dist/mcp/create-server.d.ts.map +1 -1
- package/dist/mcp/create-server.js +36 -283
- package/dist/mcp/create-server.js.map +1 -1
- package/dist/mcp/prompt-defs/add-contracts.d.ts +3 -0
- package/dist/mcp/prompt-defs/add-contracts.d.ts.map +1 -0
- package/dist/mcp/prompt-defs/add-contracts.js +11 -0
- package/dist/mcp/prompt-defs/add-contracts.js.map +1 -0
- package/dist/mcp/prompt-defs/fix-error.d.ts +3 -0
- package/dist/mcp/prompt-defs/fix-error.d.ts.map +1 -0
- package/dist/mcp/prompt-defs/fix-error.js +11 -0
- package/dist/mcp/prompt-defs/fix-error.js.map +1 -0
- package/dist/mcp/prompt-defs/index.d.ts +4 -0
- package/dist/mcp/prompt-defs/index.d.ts.map +1 -0
- package/dist/mcp/prompt-defs/index.js +15 -0
- package/dist/mcp/prompt-defs/index.js.map +1 -0
- package/dist/mcp/prompt-defs/review-ast.d.ts +3 -0
- package/dist/mcp/prompt-defs/review-ast.d.ts.map +1 -0
- package/dist/mcp/prompt-defs/review-ast.js +11 -0
- package/dist/mcp/prompt-defs/review-ast.js.map +1 -0
- package/dist/mcp/prompt-defs/write-program.d.ts +3 -0
- package/dist/mcp/prompt-defs/write-program.d.ts.map +1 -0
- package/dist/mcp/prompt-defs/write-program.js +11 -0
- package/dist/mcp/prompt-defs/write-program.js.map +1 -0
- package/dist/mcp/resources/errors.d.ts +3 -0
- package/dist/mcp/resources/errors.d.ts.map +1 -0
- package/dist/mcp/resources/errors.js +20 -0
- package/dist/mcp/resources/errors.js.map +1 -0
- package/dist/mcp/resources/examples.d.ts +3 -0
- package/dist/mcp/resources/examples.d.ts.map +1 -0
- package/dist/mcp/resources/examples.js +20 -0
- package/dist/mcp/resources/examples.js.map +1 -0
- package/dist/mcp/resources/index.d.ts +4 -0
- package/dist/mcp/resources/index.d.ts.map +1 -0
- package/dist/mcp/resources/index.js +17 -0
- package/dist/mcp/resources/index.js.map +1 -0
- package/dist/mcp/resources/schema-minimal.d.ts +3 -0
- package/dist/mcp/resources/schema-minimal.d.ts.map +1 -0
- package/dist/mcp/resources/schema-minimal.js +20 -0
- package/dist/mcp/resources/schema-minimal.js.map +1 -0
- package/dist/mcp/resources/schema-patch.d.ts +3 -0
- package/dist/mcp/resources/schema-patch.d.ts.map +1 -0
- package/dist/mcp/resources/schema-patch.js +20 -0
- package/dist/mcp/resources/schema-patch.js.map +1 -0
- package/dist/mcp/resources/schema.d.ts +3 -0
- package/dist/mcp/resources/schema.d.ts.map +1 -0
- package/dist/mcp/resources/schema.js +20 -0
- package/dist/mcp/resources/schema.js.map +1 -0
- package/dist/mcp/tool-types.d.ts +24 -0
- package/dist/mcp/tool-types.d.ts.map +1 -0
- package/dist/mcp/tool-types.js +8 -0
- package/dist/mcp/tool-types.js.map +1 -0
- package/dist/mcp/tools/check.d.ts +3 -0
- package/dist/mcp/tools/check.d.ts.map +1 -0
- package/dist/mcp/tools/check.js +24 -0
- package/dist/mcp/tools/check.js.map +1 -0
- package/dist/mcp/tools/compile.d.ts +3 -0
- package/dist/mcp/tools/compile.d.ts.map +1 -0
- package/dist/mcp/tools/compile.js +35 -0
- package/dist/mcp/tools/compile.js.map +1 -0
- package/dist/mcp/tools/errors.d.ts +3 -0
- package/dist/mcp/tools/errors.d.ts.map +1 -0
- package/dist/mcp/tools/errors.js +17 -0
- package/dist/mcp/tools/errors.js.map +1 -0
- package/dist/mcp/tools/examples.d.ts +3 -0
- package/dist/mcp/tools/examples.d.ts.map +1 -0
- package/dist/mcp/tools/examples.js +12 -0
- package/dist/mcp/tools/examples.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +4 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +27 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/lint.d.ts +3 -0
- package/dist/mcp/tools/lint.d.ts.map +1 -0
- package/dist/mcp/tools/lint.js +29 -0
- package/dist/mcp/tools/lint.js.map +1 -0
- package/dist/mcp/tools/patch.d.ts +3 -0
- package/dist/mcp/tools/patch.d.ts.map +1 -0
- package/dist/mcp/tools/patch.js +37 -0
- package/dist/mcp/tools/patch.js.map +1 -0
- package/dist/mcp/tools/run.d.ts +3 -0
- package/dist/mcp/tools/run.d.ts.map +1 -0
- package/dist/mcp/tools/run.js +33 -0
- package/dist/mcp/tools/run.js.map +1 -0
- package/dist/mcp/tools/schema.d.ts +3 -0
- package/dist/mcp/tools/schema.d.ts.map +1 -0
- package/dist/mcp/tools/schema.js +21 -0
- package/dist/mcp/tools/schema.js.map +1 -0
- package/dist/mcp/tools/validate.d.ts +3 -0
- package/dist/mcp/tools/validate.d.ts.map +1 -0
- package/dist/mcp/tools/validate.js +24 -0
- package/dist/mcp/tools/validate.js.map +1 -0
- package/dist/mcp/tools/version.d.ts +3 -0
- package/dist/mcp/tools/version.d.ts.map +1 -0
- package/dist/mcp/tools/version.js +17 -0
- package/dist/mcp/tools/version.js.map +1 -0
- package/package.json +10 -5
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ Host capabilities available through adapters: filesystem (sandboxed), HTTP, cryp
|
|
|
51
51
|
|
|
52
52
|
```bash
|
|
53
53
|
npm install
|
|
54
|
-
npm test #
|
|
54
|
+
npm test # 1194 tests across 69 files
|
|
55
55
|
npm run mcp # start MCP server (stdio transport)
|
|
56
56
|
```
|
|
57
57
|
|
|
@@ -61,7 +61,7 @@ npm run mcp # start MCP server (stdio transport)
|
|
|
61
61
|
|---|---|
|
|
62
62
|
| `edict_schema` | Returns the full AST JSON Schema — the spec for how to write programs |
|
|
63
63
|
| `edict_version` | Returns compiler version and capability info |
|
|
64
|
-
| `edict_examples` | Returns
|
|
64
|
+
| `edict_examples` | Returns 19 example programs as JSON ASTs |
|
|
65
65
|
| `edict_validate` | Validates AST structure (field names, types, node kinds) |
|
|
66
66
|
| `edict_check` | Full pipeline: validate → resolve names → type check → effect check → verify contracts |
|
|
67
67
|
| `edict_compile` | Compiles a checked AST to WASM (returns base64-encoded binary) |
|
|
@@ -167,8 +167,8 @@ src/
|
|
|
167
167
|
├── mcp/ # MCP server (tools + resources + prompts)
|
|
168
168
|
└── errors/ # Structured error types
|
|
169
169
|
|
|
170
|
-
tests/ #
|
|
171
|
-
examples/ #
|
|
170
|
+
tests/ # 1194 tests across 69 files
|
|
171
|
+
examples/ # 19 example programs (⭐→⭐⭐⭐ difficulty in README)
|
|
172
172
|
schema/ # Auto-generated JSON Schema
|
|
173
173
|
```
|
|
174
174
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-server.d.ts","sourceRoot":"","sources":["../../src/mcp/create-server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-server.d.ts","sourceRoot":"","sources":["../../src/mcp/create-server.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAUpE,wBAAgB,iBAAiB,IAAI,SAAS,CAyC7C"}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// MCP Server — declarative tool/resource/prompt registration
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// Each tool, resource, and prompt is defined as a declarative object in its
|
|
5
|
+
// own file. This module imports them via barrel exports and registers them
|
|
6
|
+
// with the MCP SDK. To add a new tool, create a file in tools/ and add it
|
|
7
|
+
// to tools/index.ts — no changes to this file needed.
|
|
1
8
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
9
|
+
import { ALL_TOOLS } from "./tools/index.js";
|
|
10
|
+
import { ALL_RESOURCES } from "./resources/index.js";
|
|
11
|
+
import { ALL_PROMPTS } from "./prompt-defs/index.js";
|
|
5
12
|
// =============================================================================
|
|
6
13
|
// Server setup
|
|
7
14
|
// =============================================================================
|
|
@@ -10,288 +17,34 @@ export function createEdictServer() {
|
|
|
10
17
|
name: "edict-compiler",
|
|
11
18
|
version: "0.1.0",
|
|
12
19
|
});
|
|
13
|
-
//
|
|
14
|
-
// Tools
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const result = handleSchema(format);
|
|
21
|
-
return {
|
|
22
|
-
content: [
|
|
23
|
-
{
|
|
24
|
-
type: "text",
|
|
25
|
-
text: JSON.stringify({ schema: result.schema, format: result.format, tokenEstimate: result.tokenEstimate }),
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
};
|
|
29
|
-
});
|
|
30
|
-
// edict_version — Return capability info
|
|
31
|
-
server.tool("edict_version", {}, async () => {
|
|
32
|
-
const result = handleVersion();
|
|
33
|
-
return {
|
|
34
|
-
content: [
|
|
35
|
-
{
|
|
36
|
-
type: "text",
|
|
37
|
-
text: JSON.stringify(result, null, 2),
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
// edict_examples — Return all example programs
|
|
43
|
-
server.tool("edict_examples", {}, async () => {
|
|
44
|
-
const result = handleExamples();
|
|
45
|
-
return {
|
|
46
|
-
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
47
|
-
};
|
|
48
|
-
});
|
|
49
|
-
// edict_validate — Validate an AST against the JSON schema
|
|
50
|
-
server.tool("edict_validate", "Validate an Edict AST against the compiler's JSON schema without typing or compiling. Use this as a first pass.", {
|
|
51
|
-
ast: z.any().describe("The Edict JSON AST to validate"),
|
|
52
|
-
}, async ({ ast }) => {
|
|
53
|
-
const result = handleValidate(ast);
|
|
54
|
-
if (result.ok) {
|
|
55
|
-
return { content: [{ type: "text", text: "AST is schema-valid." }] };
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
return {
|
|
59
|
-
content: [
|
|
60
|
-
{ type: "text", text: JSON.stringify({ errors: result.errors }, null, 2) },
|
|
61
|
-
],
|
|
62
|
-
isError: true,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
// edict_check — Type check, effect check, and verify contracts
|
|
67
|
-
server.tool("edict_check", "Run the full semantic checker (name resolution, type checking, effect checking, contract verification) on an AST.", {
|
|
68
|
-
ast: z.any().describe("The Edict JSON AST to check"),
|
|
69
|
-
}, async ({ ast }) => {
|
|
70
|
-
const result = await handleCheck(ast);
|
|
71
|
-
if (result.ok) {
|
|
72
|
-
return { content: [{ type: "text", text: "AST passed all semantic checks." }] };
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
return {
|
|
76
|
-
content: [
|
|
77
|
-
{ type: "text", text: JSON.stringify({ errors: result.errors }, null, 2) },
|
|
78
|
-
],
|
|
79
|
-
isError: true,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
// edict_compile — Compile a checked AST to a base64 encoded WASM module
|
|
84
|
-
server.tool("edict_compile", "Compile a semantically valid Edict AST into a WebAssembly module. Returns the WASM binary encoded as a base64 string.", {
|
|
85
|
-
ast: z.any().describe("The Edict JSON AST to compile"),
|
|
86
|
-
}, async ({ ast }) => {
|
|
87
|
-
const result = await handleCompile(ast);
|
|
88
|
-
if (result.ok && result.wasm) {
|
|
89
|
-
return {
|
|
90
|
-
content: [
|
|
91
|
-
{
|
|
92
|
-
type: "text",
|
|
93
|
-
text: JSON.stringify({
|
|
94
|
-
message: "Compilation successful.",
|
|
95
|
-
wasm: result.wasm,
|
|
96
|
-
binarySize: result.wasm.length, // rough estimate
|
|
97
|
-
}, null, 2),
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
return {
|
|
104
|
-
content: [
|
|
105
|
-
{ type: "text", text: JSON.stringify({ errors: result.errors }, null, 2) },
|
|
106
|
-
],
|
|
107
|
-
isError: true,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
// edict_run — Run a base64 encoded WASM module and return its output
|
|
112
|
-
server.tool("edict_run", "Execute a compiled WebAssembly module (provided as base64) using the Edict runtime host. Returns standard output, exit code, and any sandbox limit errors. Supports optional execution limits (timeout, memory).", {
|
|
113
|
-
wasmBase64: z.string().describe("The base64 encoded WebAssembly module to execute"),
|
|
114
|
-
limits: z.object({
|
|
115
|
-
timeoutMs: z.number().optional().describe("Max execution time in milliseconds (default: 15000, min: 100)"),
|
|
116
|
-
maxMemoryMb: z.number().optional().describe("Max WASM memory in MB (compile-time limit, default: 1)"),
|
|
117
|
-
}).optional().describe("Optional execution sandbox limits"),
|
|
118
|
-
}, async ({ wasmBase64, limits }) => {
|
|
119
|
-
try {
|
|
120
|
-
const result = await handleRun(wasmBase64, limits);
|
|
121
|
-
return {
|
|
122
|
-
content: [
|
|
123
|
-
{
|
|
124
|
-
type: "text",
|
|
125
|
-
text: JSON.stringify(result, null, 2),
|
|
126
|
-
},
|
|
127
|
-
],
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
catch (err) {
|
|
131
|
-
return {
|
|
132
|
-
content: [{ type: "text", text: String(err) }],
|
|
133
|
-
isError: true,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
// edict_patch — Apply targeted AST patches by nodeId and re-check
|
|
138
|
-
server.tool("edict_patch", "Apply surgical patches to an Edict AST by nodeId, then run the full check pipeline. Use this to fix errors without resubmitting the entire AST. Each patch specifies a nodeId, an operation (replace/delete/insert), and the relevant field/value.", {
|
|
139
|
-
ast: z.any().describe("The base Edict JSON AST to patch"),
|
|
140
|
-
patches: z.array(z.object({
|
|
141
|
-
nodeId: z.string().describe("ID of the target AST node"),
|
|
142
|
-
op: z.enum(["replace", "delete", "insert"]).describe("Operation: replace a field, delete a node, or insert into an array"),
|
|
143
|
-
field: z.string().optional().describe("Field name (required for replace/insert)"),
|
|
144
|
-
value: z.any().optional().describe("New value (required for replace/insert)"),
|
|
145
|
-
index: z.number().optional().describe("Array index for insert (defaults to end)"),
|
|
146
|
-
})).describe("Array of patches to apply"),
|
|
147
|
-
returnAst: z.boolean().optional().default(false).describe("Include the patched AST in the response (costs tokens, off by default)"),
|
|
148
|
-
}, async ({ ast, patches, returnAst }) => {
|
|
149
|
-
const result = await handlePatch(ast, patches, returnAst);
|
|
150
|
-
if (result.ok) {
|
|
151
|
-
const response = { ok: true };
|
|
152
|
-
if (result.patchedAst)
|
|
153
|
-
response.patchedAst = result.patchedAst;
|
|
154
|
-
return {
|
|
155
|
-
content: [{ type: "text", text: JSON.stringify(response, null, 2) }],
|
|
156
|
-
};
|
|
20
|
+
// -------------------------------------------------------------------------
|
|
21
|
+
// Tools — auto-register from declarative definitions
|
|
22
|
+
// -------------------------------------------------------------------------
|
|
23
|
+
for (const tool of ALL_TOOLS) {
|
|
24
|
+
if (tool.description) {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
server.tool(tool.name, tool.description, tool.schema, tool.handler);
|
|
157
27
|
}
|
|
158
28
|
else {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
});
|
|
179
|
-
// edict_lint — Run non-blocking quality analysis and return warnings
|
|
180
|
-
server.tool("edict_lint", "Run non-blocking lint analysis on an Edict AST. Returns quality warnings (unused variables, missing contracts, oversized functions, redundant effects, etc.) without blocking compilation. Warnings use the same structured format as errors but with severity: 'warning'.", {
|
|
181
|
-
ast: z.any().describe("The Edict JSON AST to lint"),
|
|
182
|
-
}, async ({ ast }) => {
|
|
183
|
-
const result = handleLint(ast);
|
|
184
|
-
if (!result.ok) {
|
|
185
|
-
return {
|
|
186
|
-
content: [
|
|
187
|
-
{ type: "text", text: JSON.stringify({ errors: result.errors }, null, 2) },
|
|
188
|
-
],
|
|
189
|
-
isError: true,
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
return {
|
|
193
|
-
content: [
|
|
194
|
-
{
|
|
195
|
-
type: "text",
|
|
196
|
-
text: JSON.stringify({ warnings: result.warnings, count: result.warnings?.length ?? 0 }, null, 2),
|
|
197
|
-
},
|
|
198
|
-
],
|
|
199
|
-
};
|
|
200
|
-
});
|
|
201
|
-
// =============================================================================
|
|
202
|
-
// Resources
|
|
203
|
-
// =============================================================================
|
|
204
|
-
server.resource("schema", "edict://schema", {
|
|
205
|
-
description: "The full JSON Schema defining valid Edict AST programs",
|
|
206
|
-
mimeType: "application/json",
|
|
207
|
-
}, async () => {
|
|
208
|
-
const result = handleSchema("full");
|
|
209
|
-
return {
|
|
210
|
-
contents: [
|
|
211
|
-
{
|
|
212
|
-
uri: "edict://schema",
|
|
213
|
-
mimeType: "application/json",
|
|
214
|
-
text: JSON.stringify(result.schema, null, 2),
|
|
215
|
-
},
|
|
216
|
-
],
|
|
217
|
-
};
|
|
218
|
-
});
|
|
219
|
-
server.resource("schema-minimal", "edict://schema/minimal", {
|
|
220
|
-
description: "Token-optimized JSON Schema (descriptions stripped) for minimal context window usage",
|
|
221
|
-
mimeType: "application/json",
|
|
222
|
-
}, async () => {
|
|
223
|
-
const result = handleSchema("minimal");
|
|
224
|
-
return {
|
|
225
|
-
contents: [
|
|
226
|
-
{
|
|
227
|
-
uri: "edict://schema/minimal",
|
|
228
|
-
mimeType: "application/json",
|
|
229
|
-
text: JSON.stringify(result.schema, null, 2),
|
|
230
|
-
},
|
|
231
|
-
],
|
|
232
|
-
};
|
|
233
|
-
});
|
|
234
|
-
server.resource("examples", "edict://examples", { description: "10 example Edict programs as JSON ASTs", mimeType: "application/json" }, async () => {
|
|
235
|
-
const result = handleExamples();
|
|
236
|
-
return {
|
|
237
|
-
contents: [
|
|
238
|
-
{
|
|
239
|
-
uri: "edict://examples",
|
|
240
|
-
mimeType: "application/json",
|
|
241
|
-
text: JSON.stringify(result, null, 2),
|
|
242
|
-
},
|
|
243
|
-
],
|
|
244
|
-
};
|
|
245
|
-
});
|
|
246
|
-
server.resource("errors", "edict://errors", {
|
|
247
|
-
description: "Machine-readable catalog of all structured error types with fields, pipeline stages, and example cause/fix ASTs",
|
|
248
|
-
mimeType: "application/json",
|
|
249
|
-
}, async () => {
|
|
250
|
-
const result = handleErrorCatalog();
|
|
251
|
-
return {
|
|
252
|
-
contents: [
|
|
253
|
-
{
|
|
254
|
-
uri: "edict://errors",
|
|
255
|
-
mimeType: "application/json",
|
|
256
|
-
text: JSON.stringify(result, null, 2),
|
|
257
|
-
},
|
|
258
|
-
],
|
|
259
|
-
};
|
|
260
|
-
});
|
|
261
|
-
server.resource("schema-patch", "edict://schema/patch", {
|
|
262
|
-
description: "JSON Schema defining the AST diff/patch protocol for the edict_patch tool (replace, insert, delete operations)",
|
|
263
|
-
mimeType: "application/json",
|
|
264
|
-
}, async () => {
|
|
265
|
-
const schema = handlePatchSchema();
|
|
266
|
-
return {
|
|
267
|
-
contents: [
|
|
268
|
-
{
|
|
269
|
-
uri: "edict://schema/patch",
|
|
270
|
-
mimeType: "application/json",
|
|
271
|
-
text: JSON.stringify(schema, null, 2),
|
|
272
|
-
},
|
|
273
|
-
],
|
|
274
|
-
};
|
|
275
|
-
});
|
|
276
|
-
// =============================================================================
|
|
277
|
-
// Prompts
|
|
278
|
-
// =============================================================================
|
|
279
|
-
server.prompt("write_program", "System prompt for writing a new Edict program from a task description. Includes minimal schema, example, and builtin list.", { task: z.string().describe("Description of what the program should do") }, async ({ task }, _extra) => {
|
|
280
|
-
const result = promptWriteProgram(task);
|
|
281
|
-
return result;
|
|
282
|
-
});
|
|
283
|
-
server.prompt("fix_error", "Prompt for fixing a structured Edict compiler error. Includes error taxonomy and fix strategy.", { error: z.string().describe("The structured error JSON from the compiler") }, async ({ error }, _extra) => {
|
|
284
|
-
const result = promptFixError(error);
|
|
285
|
-
return result;
|
|
286
|
-
});
|
|
287
|
-
server.prompt("add_contracts", "Prompt for adding pre/postcondition contracts to existing Edict functions for Z3 formal verification.", { ast: z.string().describe("The Edict JSON AST to add contracts to") }, async ({ ast }, _extra) => {
|
|
288
|
-
const result = promptAddContracts(ast);
|
|
289
|
-
return result;
|
|
290
|
-
});
|
|
291
|
-
server.prompt("review_ast", "Prompt for reviewing an Edict AST for quality issues (unused variables, missing effects, dead code, etc.).", { ast: z.string().describe("The Edict JSON AST to review") }, async ({ ast }, _extra) => {
|
|
292
|
-
const result = promptReviewAst(ast);
|
|
293
|
-
return result;
|
|
294
|
-
});
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
server.tool(tool.name, tool.schema, tool.handler);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// -------------------------------------------------------------------------
|
|
34
|
+
// Resources — auto-register from declarative definitions
|
|
35
|
+
// -------------------------------------------------------------------------
|
|
36
|
+
for (const resource of ALL_RESOURCES) {
|
|
37
|
+
server.resource(resource.name, resource.uri, { description: resource.description, mimeType: resource.mimeType },
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
resource.handler);
|
|
40
|
+
}
|
|
41
|
+
// -------------------------------------------------------------------------
|
|
42
|
+
// Prompts — auto-register from declarative definitions
|
|
43
|
+
// -------------------------------------------------------------------------
|
|
44
|
+
for (const prompt of ALL_PROMPTS) {
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
|
+
server.prompt(prompt.name, prompt.description, prompt.schema, prompt.handler);
|
|
47
|
+
}
|
|
295
48
|
return server;
|
|
296
49
|
}
|
|
297
50
|
//# sourceMappingURL=create-server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-server.js","sourceRoot":"","sources":["../../src/mcp/create-server.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"create-server.js","sourceRoot":"","sources":["../../src/mcp/create-server.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,6DAA6D;AAC7D,gFAAgF;AAChF,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,sDAAsD;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,gFAAgF;AAChF,eAAe;AACf,gFAAgF;AAEhF,MAAM,UAAU,iBAAiB;IAC7B,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QACzB,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,OAAO;KACnB,CAAC,CAAC;IAEH,4EAA4E;IAC5E,qDAAqD;IACrD,4EAA4E;IAC5E,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,8DAA8D;YAC9D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAc,CAAC,CAAC;QAC/E,CAAC;aAAM,CAAC;YACJ,8DAA8D;YAC9D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAc,CAAC,CAAC;QAC7D,CAAC;IACL,CAAC;IAED,4EAA4E;IAC5E,yDAAyD;IACzD,4EAA4E;IAC5E,KAAK,MAAM,QAAQ,IAAI,aAAa,EAAE,CAAC;QACnC,MAAM,CAAC,QAAQ,CACX,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,GAAG,EACZ,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE;QAClE,8DAA8D;QAC9D,QAAQ,CAAC,OAAc,CAC1B,CAAC;IACN,CAAC;IAED,4EAA4E;IAC5E,uDAAuD;IACvD,4EAA4E;IAC5E,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE,CAAC;QAC/B,8DAA8D;QAC9D,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAc,CAAC,CAAC;IACzF,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-contracts.d.ts","sourceRoot":"","sources":["../../../src/mcp/prompt-defs/add-contracts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGvD,eAAO,MAAM,kBAAkB,EAAE,cAOhC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { promptAddContracts } from "../prompts.js";
|
|
3
|
+
export const addContractsPrompt = {
|
|
4
|
+
name: "add_contracts",
|
|
5
|
+
description: "Prompt for adding pre/postcondition contracts to existing Edict functions for Z3 formal verification.",
|
|
6
|
+
schema: { ast: z.string().describe("The Edict JSON AST to add contracts to") },
|
|
7
|
+
handler: async ({ ast }) => {
|
|
8
|
+
return promptAddContracts(ast);
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=add-contracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-contracts.js","sourceRoot":"","sources":["../../../src/mcp/prompt-defs/add-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,CAAC,MAAM,kBAAkB,GAAmB;IAC9C,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,uGAAuG;IACpH,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC,EAAE;IAC9E,OAAO,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;QACvB,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-error.d.ts","sourceRoot":"","sources":["../../../src/mcp/prompt-defs/fix-error.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGvD,eAAO,MAAM,cAAc,EAAE,cAO5B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { promptFixError } from "../prompts.js";
|
|
3
|
+
export const fixErrorPrompt = {
|
|
4
|
+
name: "fix_error",
|
|
5
|
+
description: "Prompt for fixing a structured Edict compiler error. Includes error taxonomy and fix strategy.",
|
|
6
|
+
schema: { error: z.string().describe("The structured error JSON from the compiler") },
|
|
7
|
+
handler: async ({ error }) => {
|
|
8
|
+
return promptFixError(error);
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=fix-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-error.js","sourceRoot":"","sources":["../../../src/mcp/prompt-defs/fix-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC1C,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,gGAAgG;IAC7G,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC,EAAE;IACrF,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QACzB,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/prompt-defs/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAMvD,+FAA+F;AAC/F,eAAO,MAAM,WAAW,EAAE,cAAc,EAKvC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// Prompt barrel export — all declarative MCP prompt definitions
|
|
3
|
+
// =============================================================================
|
|
4
|
+
import { writeProgramPrompt } from "./write-program.js";
|
|
5
|
+
import { fixErrorPrompt } from "./fix-error.js";
|
|
6
|
+
import { addContractsPrompt } from "./add-contracts.js";
|
|
7
|
+
import { reviewAstPrompt } from "./review-ast.js";
|
|
8
|
+
/** All registered MCP prompts. Add new prompts by creating a file and adding to this array. */
|
|
9
|
+
export const ALL_PROMPTS = [
|
|
10
|
+
writeProgramPrompt,
|
|
11
|
+
fixErrorPrompt,
|
|
12
|
+
addContractsPrompt,
|
|
13
|
+
reviewAstPrompt,
|
|
14
|
+
];
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/prompt-defs/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,gEAAgE;AAChE,gFAAgF;AAGhF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,+FAA+F;AAC/F,MAAM,CAAC,MAAM,WAAW,GAAqB;IACzC,kBAAkB;IAClB,cAAc;IACd,kBAAkB;IAClB,eAAe;CAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review-ast.d.ts","sourceRoot":"","sources":["../../../src/mcp/prompt-defs/review-ast.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGvD,eAAO,MAAM,eAAe,EAAE,cAO7B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { promptReviewAst } from "../prompts.js";
|
|
3
|
+
export const reviewAstPrompt = {
|
|
4
|
+
name: "review_ast",
|
|
5
|
+
description: "Prompt for reviewing an Edict AST for quality issues (unused variables, missing effects, dead code, etc.).",
|
|
6
|
+
schema: { ast: z.string().describe("The Edict JSON AST to review") },
|
|
7
|
+
handler: async ({ ast }) => {
|
|
8
|
+
return promptReviewAst(ast);
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=review-ast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review-ast.js","sourceRoot":"","sources":["../../../src/mcp/prompt-defs/review-ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC3C,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,4GAA4G;IACzH,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC,EAAE;IACpE,OAAO,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;QACvB,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-program.d.ts","sourceRoot":"","sources":["../../../src/mcp/prompt-defs/write-program.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGvD,eAAO,MAAM,kBAAkB,EAAE,cAOhC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { promptWriteProgram } from "../prompts.js";
|
|
3
|
+
export const writeProgramPrompt = {
|
|
4
|
+
name: "write_program",
|
|
5
|
+
description: "System prompt for writing a new Edict program from a task description. Includes minimal schema, example, and builtin list.",
|
|
6
|
+
schema: { task: z.string().describe("Description of what the program should do") },
|
|
7
|
+
handler: async ({ task }) => {
|
|
8
|
+
return promptWriteProgram(task);
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=write-program.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-program.js","sourceRoot":"","sources":["../../../src/mcp/prompt-defs/write-program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,CAAC,MAAM,kBAAkB,GAAmB;IAC9C,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,4HAA4H;IACzI,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC,EAAE;IAClF,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QACxB,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/mcp/resources/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,eAAO,MAAM,cAAc,EAAE,gBAiB5B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { handleErrorCatalog } from "../handlers.js";
|
|
2
|
+
export const errorsResource = {
|
|
3
|
+
name: "errors",
|
|
4
|
+
uri: "edict://errors",
|
|
5
|
+
description: "Machine-readable catalog of all structured error types with fields, pipeline stages, and example cause/fix ASTs",
|
|
6
|
+
mimeType: "application/json",
|
|
7
|
+
handler: async () => {
|
|
8
|
+
const result = handleErrorCatalog();
|
|
9
|
+
return {
|
|
10
|
+
contents: [
|
|
11
|
+
{
|
|
12
|
+
uri: "edict://errors",
|
|
13
|
+
mimeType: "application/json",
|
|
14
|
+
text: JSON.stringify(result, null, 2),
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/mcp/resources/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,CAAC,MAAM,cAAc,GAAqB;IAC5C,IAAI,EAAE,QAAQ;IACd,GAAG,EAAE,gBAAgB;IACrB,WAAW,EAAE,iHAAiH;IAC9H,QAAQ,EAAE,kBAAkB;IAC5B,OAAO,EAAE,KAAK,IAAI,EAAE;QAChB,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;QACpC,OAAO;YACH,QAAQ,EAAE;gBACN;oBACI,GAAG,EAAE,gBAAgB;oBACrB,QAAQ,EAAE,kBAAkB;oBAC5B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;iBACxC;aACJ;SACJ,CAAC;IACN,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"examples.d.ts","sourceRoot":"","sources":["../../../src/mcp/resources/examples.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,eAAO,MAAM,gBAAgB,EAAE,gBAiB9B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { handleExamples } from "../handlers.js";
|
|
2
|
+
export const examplesResource = {
|
|
3
|
+
name: "examples",
|
|
4
|
+
uri: "edict://examples",
|
|
5
|
+
description: "10 example Edict programs as JSON ASTs",
|
|
6
|
+
mimeType: "application/json",
|
|
7
|
+
handler: async () => {
|
|
8
|
+
const result = handleExamples();
|
|
9
|
+
return {
|
|
10
|
+
contents: [
|
|
11
|
+
{
|
|
12
|
+
uri: "edict://examples",
|
|
13
|
+
mimeType: "application/json",
|
|
14
|
+
text: JSON.stringify(result, null, 2),
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=examples.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"examples.js","sourceRoot":"","sources":["../../../src/mcp/resources/examples.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,CAAC,MAAM,gBAAgB,GAAqB;IAC9C,IAAI,EAAE,UAAU;IAChB,GAAG,EAAE,kBAAkB;IACvB,WAAW,EAAE,wCAAwC;IACrD,QAAQ,EAAE,kBAAkB;IAC5B,OAAO,EAAE,KAAK,IAAI,EAAE;QAChB,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;QAChC,OAAO;YACH,QAAQ,EAAE;gBACN;oBACI,GAAG,EAAE,kBAAkB;oBACvB,QAAQ,EAAE,kBAAkB;oBAC5B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;iBACxC;aACJ;SACJ,CAAC;IACN,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/resources/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAOzD,mGAAmG;AACnG,eAAO,MAAM,aAAa,EAAE,gBAAgB,EAM3C,CAAC"}
|