midnight-mcp 0.1.41 → 0.2.1
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 +32 -1
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +10764 -0
- package/dist/index.d.ts +205 -3
- package/dist/index.js +10722 -15
- package/package.json +16 -6
- package/dist/config/compact-version.d.ts +0 -183
- package/dist/config/compact-version.js +0 -423
- package/dist/db/index.d.ts +0 -3
- package/dist/db/index.js +0 -2
- package/dist/db/vectorStore.d.ts +0 -69
- package/dist/db/vectorStore.js +0 -196
- package/dist/pipeline/embeddings.d.ts +0 -25
- package/dist/pipeline/embeddings.js +0 -103
- package/dist/pipeline/github.d.ts +0 -84
- package/dist/pipeline/github.js +0 -399
- package/dist/pipeline/index.d.ts +0 -11
- package/dist/pipeline/index.js +0 -6
- package/dist/pipeline/indexer.d.ts +0 -41
- package/dist/pipeline/indexer.js +0 -254
- package/dist/pipeline/parser.d.ts +0 -46
- package/dist/pipeline/parser.js +0 -436
- package/dist/pipeline/releases.d.ts +0 -112
- package/dist/pipeline/releases.js +0 -298
- package/dist/pipeline/repository.d.ts +0 -372
- package/dist/pipeline/repository.js +0 -520
- package/dist/prompts/index.d.ts +0 -3
- package/dist/prompts/index.js +0 -2
- package/dist/prompts/templates.d.ts +0 -26
- package/dist/prompts/templates.js +0 -443
- package/dist/resources/code.d.ts +0 -15
- package/dist/resources/code.js +0 -122
- package/dist/resources/content/code-content.d.ts +0 -6
- package/dist/resources/content/code-content.js +0 -802
- package/dist/resources/content/docs-content.d.ts +0 -14
- package/dist/resources/content/docs-content.js +0 -1202
- package/dist/resources/content/index.d.ts +0 -6
- package/dist/resources/content/index.js +0 -6
- package/dist/resources/docs.d.ts +0 -15
- package/dist/resources/docs.js +0 -98
- package/dist/resources/index.d.ts +0 -6
- package/dist/resources/index.js +0 -13
- package/dist/resources/schemas.d.ts +0 -16
- package/dist/resources/schemas.js +0 -407
- package/dist/scripts/index-repos.d.ts +0 -12
- package/dist/scripts/index-repos.js +0 -53
- package/dist/server.d.ts +0 -43
- package/dist/server.js +0 -696
- package/dist/services/index.d.ts +0 -6
- package/dist/services/index.js +0 -6
- package/dist/services/sampling.d.ts +0 -62
- package/dist/services/sampling.js +0 -277
- package/dist/tools/analyze.d.ts +0 -106
- package/dist/tools/analyze.js +0 -431
- package/dist/tools/generation.d.ts +0 -9
- package/dist/tools/generation.js +0 -285
- package/dist/tools/health.d.ts +0 -120
- package/dist/tools/health.js +0 -365
- package/dist/tools/index.d.ts +0 -14
- package/dist/tools/index.js +0 -22
- package/dist/tools/meta.d.ts +0 -61
- package/dist/tools/meta.js +0 -282
- package/dist/tools/repository/constants.d.ts +0 -19
- package/dist/tools/repository/constants.js +0 -324
- package/dist/tools/repository/handlers.d.ts +0 -373
- package/dist/tools/repository/handlers.js +0 -724
- package/dist/tools/repository/index.d.ts +0 -9
- package/dist/tools/repository/index.js +0 -13
- package/dist/tools/repository/schemas.d.ts +0 -153
- package/dist/tools/repository/schemas.js +0 -106
- package/dist/tools/repository/tools.d.ts +0 -7
- package/dist/tools/repository/tools.js +0 -484
- package/dist/tools/repository/validation.d.ts +0 -106
- package/dist/tools/repository/validation.js +0 -820
- package/dist/tools/repository.d.ts +0 -6
- package/dist/tools/repository.js +0 -7
- package/dist/tools/search.d.ts +0 -76
- package/dist/tools/search.js +0 -423
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.js +0 -2
- package/dist/types/mcp.d.ts +0 -187
- package/dist/types/mcp.js +0 -6
- package/dist/utils/cache.d.ts +0 -77
- package/dist/utils/cache.js +0 -172
- package/dist/utils/config.d.ts +0 -70
- package/dist/utils/config.js +0 -294
- package/dist/utils/errors.d.ts +0 -111
- package/dist/utils/errors.js +0 -165
- package/dist/utils/health.d.ts +0 -29
- package/dist/utils/health.js +0 -132
- package/dist/utils/hosted-api.d.ts +0 -67
- package/dist/utils/hosted-api.js +0 -119
- package/dist/utils/index.d.ts +0 -16
- package/dist/utils/index.js +0 -15
- package/dist/utils/logger.d.ts +0 -48
- package/dist/utils/logger.js +0 -124
- package/dist/utils/rate-limit.d.ts +0 -61
- package/dist/utils/rate-limit.js +0 -148
- package/dist/utils/validation.d.ts +0 -52
- package/dist/utils/validation.js +0 -255
|
@@ -1,443 +0,0 @@
|
|
|
1
|
-
// Prompt definitions
|
|
2
|
-
export const promptDefinitions = [
|
|
3
|
-
{
|
|
4
|
-
name: "midnight:create-contract",
|
|
5
|
-
description: "Guided prompt for creating new Compact contracts with privacy considerations",
|
|
6
|
-
arguments: [
|
|
7
|
-
{
|
|
8
|
-
name: "contractType",
|
|
9
|
-
description: "Type of contract (token, voting, credential, custom)",
|
|
10
|
-
required: true,
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
name: "privacyLevel",
|
|
14
|
-
description: "Required privacy features (full, partial, public)",
|
|
15
|
-
required: false,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
name: "complexity",
|
|
19
|
-
description: "Expected complexity level (beginner, intermediate, advanced)",
|
|
20
|
-
required: false,
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: "midnight:review-contract",
|
|
26
|
-
description: "Security and best practices review prompt for existing contracts",
|
|
27
|
-
arguments: [
|
|
28
|
-
{
|
|
29
|
-
name: "contractCode",
|
|
30
|
-
description: "The Compact contract code to review",
|
|
31
|
-
required: true,
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: "focusAreas",
|
|
35
|
-
description: "Specific areas to emphasize (security, performance, privacy, readability)",
|
|
36
|
-
required: false,
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: "midnight:explain-concept",
|
|
42
|
-
description: "Educational prompt for explaining Midnight concepts at various levels",
|
|
43
|
-
arguments: [
|
|
44
|
-
{
|
|
45
|
-
name: "concept",
|
|
46
|
-
description: "The concept to explain (zk-proofs, circuits, witnesses, ledger, etc.)",
|
|
47
|
-
required: true,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: "level",
|
|
51
|
-
description: "Expertise level (beginner, intermediate, advanced)",
|
|
52
|
-
required: false,
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: "midnight:compare-approaches",
|
|
58
|
-
description: "Compare different implementation approaches for a given problem",
|
|
59
|
-
arguments: [
|
|
60
|
-
{
|
|
61
|
-
name: "problem",
|
|
62
|
-
description: "The problem to solve",
|
|
63
|
-
required: true,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: "approaches",
|
|
67
|
-
description: "Specific approaches to compare (comma-separated)",
|
|
68
|
-
required: false,
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: "midnight:debug-contract",
|
|
74
|
-
description: "Help debug issues with a Compact contract",
|
|
75
|
-
arguments: [
|
|
76
|
-
{
|
|
77
|
-
name: "contractCode",
|
|
78
|
-
description: "The contract code with issues",
|
|
79
|
-
required: true,
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: "errorMessage",
|
|
83
|
-
description: "Error message or description of the issue",
|
|
84
|
-
required: false,
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
];
|
|
89
|
-
/**
|
|
90
|
-
* Generate prompt messages based on template and arguments
|
|
91
|
-
*/
|
|
92
|
-
export function generatePrompt(name, args) {
|
|
93
|
-
switch (name) {
|
|
94
|
-
case "midnight:create-contract":
|
|
95
|
-
return generateCreateContractPrompt(args);
|
|
96
|
-
case "midnight:review-contract":
|
|
97
|
-
return generateReviewContractPrompt(args);
|
|
98
|
-
case "midnight:explain-concept":
|
|
99
|
-
return generateExplainConceptPrompt(args);
|
|
100
|
-
case "midnight:compare-approaches":
|
|
101
|
-
return generateCompareApproachesPrompt(args);
|
|
102
|
-
case "midnight:debug-contract":
|
|
103
|
-
return generateDebugContractPrompt(args);
|
|
104
|
-
default:
|
|
105
|
-
return [
|
|
106
|
-
{
|
|
107
|
-
role: "user",
|
|
108
|
-
content: {
|
|
109
|
-
type: "text",
|
|
110
|
-
text: `Unknown prompt: ${name}`,
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
];
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function generateCreateContractPrompt(args) {
|
|
117
|
-
const contractType = args.contractType || "custom";
|
|
118
|
-
const privacyLevel = args.privacyLevel || "partial";
|
|
119
|
-
const complexity = args.complexity || "intermediate";
|
|
120
|
-
return [
|
|
121
|
-
{
|
|
122
|
-
role: "user",
|
|
123
|
-
content: {
|
|
124
|
-
type: "text",
|
|
125
|
-
text: `I want to create a new Midnight Compact smart contract with the following requirements:
|
|
126
|
-
|
|
127
|
-
**Contract Type:** ${contractType}
|
|
128
|
-
**Privacy Level:** ${privacyLevel}
|
|
129
|
-
**Complexity:** ${complexity}
|
|
130
|
-
|
|
131
|
-
## ⚠️ MANDATORY WORKFLOW - Follow these steps IN ORDER:
|
|
132
|
-
|
|
133
|
-
### Step 1: Get Current Syntax
|
|
134
|
-
Call \`midnight-get-latest-syntax\` FIRST to get:
|
|
135
|
-
- The \`quickStartTemplate\` (use as your base)
|
|
136
|
-
- The \`commonMistakes\` array (avoid these errors)
|
|
137
|
-
- Current pragma format: \`pragma language_version >= 0.16 && <= 0.18;\`
|
|
138
|
-
|
|
139
|
-
### Step 2: Generate Contract
|
|
140
|
-
Based on syntax reference, generate the contract using:
|
|
141
|
-
- Individual ledger declarations: \`export ledger field: Type;\` (NOT \`ledger { }\` blocks)
|
|
142
|
-
- Empty tuple return: \`circuit fn(): []\` (NOT \`Void\`)
|
|
143
|
-
- Export enums: \`export enum State { ... }\`
|
|
144
|
-
- Wrap witness conditionals: \`if (disclose(witness == value))\`
|
|
145
|
-
- Disclose circuit params that touch ledger: \`const d = disclose(param); ledger.insert(d, v);\`
|
|
146
|
-
- Cast arithmetic results: \`(a + b) as Uint<64>\`
|
|
147
|
-
- Uint to Bytes needs two casts: \`(amount as Field) as Bytes<32>\`
|
|
148
|
-
|
|
149
|
-
### IMPORTANT: Compact is NOT TypeScript!
|
|
150
|
-
- Map.lookup() and Set.member() ARE available in circuits
|
|
151
|
-
- No 'function' keyword - use 'circuit' or 'pure circuit'
|
|
152
|
-
- No 'void' - use '[]'
|
|
153
|
-
- Enum access: \`Choice.rock\` NOT \`Choice::rock\`
|
|
154
|
-
|
|
155
|
-
### Step 3: Validate Before Returning
|
|
156
|
-
Call \`midnight-extract-contract-structure\` with your generated code to check for:
|
|
157
|
-
- deprecated_ledger_block
|
|
158
|
-
- invalid_void_type
|
|
159
|
-
- invalid_pragma_format
|
|
160
|
-
- unexported_enum
|
|
161
|
-
- deprecated_cell_wrapper
|
|
162
|
-
|
|
163
|
-
If ANY errors are found, fix them before returning the code to the user.
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
## Contract Requirements
|
|
168
|
-
|
|
169
|
-
Please help me design and implement this contract. Consider:
|
|
170
|
-
|
|
171
|
-
1. **State Design**
|
|
172
|
-
- What should be public vs private (shielded)?
|
|
173
|
-
- What data structures are needed?
|
|
174
|
-
- How should state transitions work?
|
|
175
|
-
|
|
176
|
-
2. **Circuit Design**
|
|
177
|
-
- What circuits (functions) are needed?
|
|
178
|
-
- What inputs/outputs should they have?
|
|
179
|
-
- What constraints and assertions are required?
|
|
180
|
-
|
|
181
|
-
3. **Witness Functions**
|
|
182
|
-
- What off-chain data is needed?
|
|
183
|
-
- How should private state be accessed?
|
|
184
|
-
|
|
185
|
-
4. **Privacy Considerations**
|
|
186
|
-
- How to protect user privacy?
|
|
187
|
-
- When to use disclose() vs commit()?
|
|
188
|
-
- How to prevent information leakage?
|
|
189
|
-
|
|
190
|
-
5. **Security**
|
|
191
|
-
- Access control mechanisms
|
|
192
|
-
- Input validation
|
|
193
|
-
- Protection against common vulnerabilities
|
|
194
|
-
|
|
195
|
-
Please provide:
|
|
196
|
-
- A complete contract implementation
|
|
197
|
-
- Explanation of design decisions
|
|
198
|
-
- Example usage scenarios
|
|
199
|
-
- Any security considerations`,
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
];
|
|
203
|
-
}
|
|
204
|
-
function generateReviewContractPrompt(args) {
|
|
205
|
-
const contractCode = args.contractCode || "// No code provided";
|
|
206
|
-
const focusAreas = args.focusAreas || "security, privacy, best practices";
|
|
207
|
-
return [
|
|
208
|
-
{
|
|
209
|
-
role: "user",
|
|
210
|
-
content: {
|
|
211
|
-
type: "text",
|
|
212
|
-
text: `Please review this Midnight Compact smart contract:
|
|
213
|
-
|
|
214
|
-
\`\`\`compact
|
|
215
|
-
${contractCode}
|
|
216
|
-
\`\`\`
|
|
217
|
-
|
|
218
|
-
**Focus Areas:** ${focusAreas}
|
|
219
|
-
|
|
220
|
-
## ⚠️ MANDATORY WORKFLOW:
|
|
221
|
-
|
|
222
|
-
### Step 1: Validate Syntax
|
|
223
|
-
Call \`midnight-extract-contract-structure\` with the contract code to check for:
|
|
224
|
-
- deprecated_ledger_block (should use \`export ledger field: Type;\`)
|
|
225
|
-
- invalid_void_type (should use \`[]\` not \`Void\`)
|
|
226
|
-
- invalid_pragma_format (should use \`>= 0.16 && <= 0.18\`)
|
|
227
|
-
- unexported_enum (enums need \`export\`)
|
|
228
|
-
- deprecated_cell_wrapper
|
|
229
|
-
|
|
230
|
-
Report ALL static analysis findings first.
|
|
231
|
-
|
|
232
|
-
### Step 2: Get Latest Syntax Reference
|
|
233
|
-
If syntax errors are found, call \`midnight-get-latest-syntax\` to get:
|
|
234
|
-
- The \`commonMistakes\` array showing correct patterns
|
|
235
|
-
- Current syntax reference
|
|
236
|
-
|
|
237
|
-
---
|
|
238
|
-
|
|
239
|
-
Please analyze:
|
|
240
|
-
|
|
241
|
-
1. **Static Analysis Results** (from midnight-extract-contract-structure)
|
|
242
|
-
- Syntax errors found
|
|
243
|
-
- Deprecated patterns detected
|
|
244
|
-
- Required fixes
|
|
245
|
-
|
|
246
|
-
2. **Security Analysis**
|
|
247
|
-
- Input validation
|
|
248
|
-
- Access control
|
|
249
|
-
- State manipulation vulnerabilities
|
|
250
|
-
- Assertion coverage
|
|
251
|
-
|
|
252
|
-
3. **Privacy Assessment**
|
|
253
|
-
- Proper use of @private state
|
|
254
|
-
- Information leakage risks
|
|
255
|
-
- Correct use of disclose() and commit()
|
|
256
|
-
- Privacy guarantees provided
|
|
257
|
-
|
|
258
|
-
4. **Best Practices**
|
|
259
|
-
- Code organization
|
|
260
|
-
- Naming conventions
|
|
261
|
-
- Documentation
|
|
262
|
-
- Error messages
|
|
263
|
-
|
|
264
|
-
5. **Performance**
|
|
265
|
-
- Circuit complexity
|
|
266
|
-
- State access patterns
|
|
267
|
-
- Optimization opportunities
|
|
268
|
-
|
|
269
|
-
6. **Recommendations**
|
|
270
|
-
- Critical issues to fix (start with P0 syntax errors)
|
|
271
|
-
- Improvements to consider
|
|
272
|
-
- Alternative approaches
|
|
273
|
-
|
|
274
|
-
Please provide specific line references and code suggestions where applicable.`,
|
|
275
|
-
},
|
|
276
|
-
},
|
|
277
|
-
];
|
|
278
|
-
}
|
|
279
|
-
function generateExplainConceptPrompt(args) {
|
|
280
|
-
const concept = args.concept || "zero-knowledge proofs";
|
|
281
|
-
const level = args.level || "intermediate";
|
|
282
|
-
const levelDescriptions = {
|
|
283
|
-
beginner: "Explain like I'm new to blockchain and cryptography. Use analogies and avoid jargon.",
|
|
284
|
-
intermediate: "I understand blockchain basics and some cryptography. Focus on practical applications.",
|
|
285
|
-
advanced: "I have deep technical knowledge. Include implementation details and edge cases.",
|
|
286
|
-
};
|
|
287
|
-
return [
|
|
288
|
-
{
|
|
289
|
-
role: "user",
|
|
290
|
-
content: {
|
|
291
|
-
type: "text",
|
|
292
|
-
text: `Please explain the concept of **${concept}** in the context of Midnight blockchain.
|
|
293
|
-
|
|
294
|
-
**My Level:** ${level}
|
|
295
|
-
${levelDescriptions[level] || levelDescriptions.intermediate}
|
|
296
|
-
|
|
297
|
-
Please cover:
|
|
298
|
-
|
|
299
|
-
1. **What it is**
|
|
300
|
-
- Clear definition
|
|
301
|
-
- How it works in Midnight
|
|
302
|
-
|
|
303
|
-
2. **Why it matters**
|
|
304
|
-
- Benefits and use cases
|
|
305
|
-
- Real-world applications
|
|
306
|
-
|
|
307
|
-
3. **How to use it**
|
|
308
|
-
- Code examples in Compact
|
|
309
|
-
- Best practices
|
|
310
|
-
|
|
311
|
-
4. **Common pitfalls**
|
|
312
|
-
- Mistakes to avoid
|
|
313
|
-
- Debugging tips
|
|
314
|
-
|
|
315
|
-
5. **Further learning**
|
|
316
|
-
- Related concepts
|
|
317
|
-
- Resources for deeper understanding`,
|
|
318
|
-
},
|
|
319
|
-
},
|
|
320
|
-
];
|
|
321
|
-
}
|
|
322
|
-
function generateCompareApproachesPrompt(args) {
|
|
323
|
-
const problem = args.problem || "implementing a token contract";
|
|
324
|
-
const approaches = args.approaches || "";
|
|
325
|
-
return [
|
|
326
|
-
{
|
|
327
|
-
role: "user",
|
|
328
|
-
content: {
|
|
329
|
-
type: "text",
|
|
330
|
-
text: `I need to solve the following problem in Midnight:
|
|
331
|
-
|
|
332
|
-
**Problem:** ${problem}
|
|
333
|
-
|
|
334
|
-
${approaches ? `**Approaches to compare:** ${approaches}` : "Please suggest different implementation approaches."}
|
|
335
|
-
|
|
336
|
-
Please compare:
|
|
337
|
-
|
|
338
|
-
1. **Approach Overview**
|
|
339
|
-
- Brief description of each approach
|
|
340
|
-
- Key differences
|
|
341
|
-
|
|
342
|
-
2. **Privacy Implications**
|
|
343
|
-
- What data is exposed?
|
|
344
|
-
- Privacy guarantees
|
|
345
|
-
|
|
346
|
-
3. **Performance**
|
|
347
|
-
- Proof generation time
|
|
348
|
-
- State storage requirements
|
|
349
|
-
- Transaction costs
|
|
350
|
-
|
|
351
|
-
4. **Security**
|
|
352
|
-
- Attack surface
|
|
353
|
-
- Trust assumptions
|
|
354
|
-
|
|
355
|
-
5. **Code Complexity**
|
|
356
|
-
- Implementation difficulty
|
|
357
|
-
- Maintenance burden
|
|
358
|
-
|
|
359
|
-
6. **Recommendation**
|
|
360
|
-
- Best approach for different scenarios
|
|
361
|
-
- Trade-offs to consider
|
|
362
|
-
|
|
363
|
-
Please include code examples for each approach.`,
|
|
364
|
-
},
|
|
365
|
-
},
|
|
366
|
-
];
|
|
367
|
-
}
|
|
368
|
-
function generateDebugContractPrompt(args) {
|
|
369
|
-
const contractCode = args.contractCode || "// No code provided";
|
|
370
|
-
const errorMessage = args.errorMessage || "Not specified";
|
|
371
|
-
return [
|
|
372
|
-
{
|
|
373
|
-
role: "user",
|
|
374
|
-
content: {
|
|
375
|
-
type: "text",
|
|
376
|
-
text: `I'm having issues with this Midnight Compact contract:
|
|
377
|
-
|
|
378
|
-
\`\`\`compact
|
|
379
|
-
${contractCode}
|
|
380
|
-
\`\`\`
|
|
381
|
-
|
|
382
|
-
**Error/Issue:** ${errorMessage}
|
|
383
|
-
|
|
384
|
-
## ⚠️ MANDATORY WORKFLOW:
|
|
385
|
-
|
|
386
|
-
### Step 1: Run Static Analysis
|
|
387
|
-
Call \`midnight-extract-contract-structure\` FIRST to check for common syntax errors:
|
|
388
|
-
- deprecated_ledger_block → should use \`export ledger field: Type;\`
|
|
389
|
-
- invalid_void_type → should use \`[]\` not \`Void\`
|
|
390
|
-
- invalid_pragma_format → should use \`>= 0.16 && <= 0.18\`
|
|
391
|
-
- unexported_enum → enums need \`export\` keyword
|
|
392
|
-
|
|
393
|
-
### Step 2: Get Correct Syntax
|
|
394
|
-
If syntax errors found, call \`midnight-get-latest-syntax\` to get:
|
|
395
|
-
- The \`commonMistakes\` array with correct patterns
|
|
396
|
-
- Current \`quickStartTemplate\` for reference
|
|
397
|
-
|
|
398
|
-
### Step 3: Check for Common Compiler Errors
|
|
399
|
-
Match error message against known fixes:
|
|
400
|
-
- "cannot cast from type Uint<64> to type Bytes<32>" → Use \`(amount as Field) as Bytes<32>\`
|
|
401
|
-
- "expected type Uint<64> but received Uint<0..N>" → Cast arithmetic: \`(a + b) as Uint<64>\`
|
|
402
|
-
- "potential witness-value disclosure must be declared" → Disclose params: \`const d = disclose(param);\`
|
|
403
|
-
- Map.lookup() and Set.member() ARE available in circuits (ignore old advice saying they aren't)
|
|
404
|
-
|
|
405
|
-
---
|
|
406
|
-
|
|
407
|
-
Please help me debug by:
|
|
408
|
-
|
|
409
|
-
1. **Static Analysis Results**
|
|
410
|
-
- Run midnight-extract-contract-structure
|
|
411
|
-
- List all P0 syntax errors found
|
|
412
|
-
- Show the correct syntax for each error
|
|
413
|
-
|
|
414
|
-
2. **Identifying the Problem**
|
|
415
|
-
- What's causing the error?
|
|
416
|
-
- Which line(s) are problematic?
|
|
417
|
-
|
|
418
|
-
3. **Explaining Why**
|
|
419
|
-
- Root cause analysis
|
|
420
|
-
- How Compact/ZK constraints work
|
|
421
|
-
|
|
422
|
-
4. **Providing a Fix**
|
|
423
|
-
- Corrected code (validated against static analysis)
|
|
424
|
-
- Explanation of changes
|
|
425
|
-
|
|
426
|
-
5. **Preventing Future Issues**
|
|
427
|
-
- Related pitfalls to watch for
|
|
428
|
-
- Testing strategies
|
|
429
|
-
|
|
430
|
-
6. **Additional Improvements**
|
|
431
|
-
- Code quality suggestions
|
|
432
|
-
- Best practices`,
|
|
433
|
-
},
|
|
434
|
-
},
|
|
435
|
-
];
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* List all available prompts
|
|
439
|
-
*/
|
|
440
|
-
export function listPrompts() {
|
|
441
|
-
return promptDefinitions;
|
|
442
|
-
}
|
|
443
|
-
//# sourceMappingURL=templates.js.map
|
package/dist/resources/code.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Code resources
|
|
3
|
-
* Provides access to Midnight code examples via MCP resources
|
|
4
|
-
*/
|
|
5
|
-
import type { ResourceDefinition } from "./schemas.js";
|
|
6
|
-
export declare const codeResources: ResourceDefinition[];
|
|
7
|
-
/**
|
|
8
|
-
* Get code content by URI
|
|
9
|
-
*/
|
|
10
|
-
export declare function getCode(uri: string): Promise<string | null>;
|
|
11
|
-
/**
|
|
12
|
-
* List all available code resources
|
|
13
|
-
*/
|
|
14
|
-
export declare function listCodeResources(): ResourceDefinition[];
|
|
15
|
-
//# sourceMappingURL=code.d.ts.map
|
package/dist/resources/code.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Code resources
|
|
3
|
-
* Provides access to Midnight code examples via MCP resources
|
|
4
|
-
*/
|
|
5
|
-
import { githubClient } from "../pipeline/index.js";
|
|
6
|
-
import { logger } from "../utils/index.js";
|
|
7
|
-
import { EMBEDDED_CODE } from "./content/index.js";
|
|
8
|
-
// Code example resources
|
|
9
|
-
export const codeResources = [
|
|
10
|
-
{
|
|
11
|
-
uri: "midnight://code/examples/counter",
|
|
12
|
-
name: "Counter Example",
|
|
13
|
-
description: "Simple counter contract demonstrating basic Compact concepts",
|
|
14
|
-
mimeType: "text/x-compact",
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
uri: "midnight://code/examples/bboard",
|
|
18
|
-
name: "Bulletin Board Example",
|
|
19
|
-
description: "Full DApp example with private messaging",
|
|
20
|
-
mimeType: "text/x-compact",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
uri: "midnight://code/patterns/state-management",
|
|
24
|
-
name: "State Management Pattern",
|
|
25
|
-
description: "Best practices for managing public and private state",
|
|
26
|
-
mimeType: "text/x-compact",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
uri: "midnight://code/patterns/access-control",
|
|
30
|
-
name: "Access Control Pattern",
|
|
31
|
-
description: "Implementing access control in Compact contracts",
|
|
32
|
-
mimeType: "text/x-compact",
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
uri: "midnight://code/patterns/privacy-preserving",
|
|
36
|
-
name: "Privacy-Preserving Pattern",
|
|
37
|
-
description: "Patterns for maintaining privacy in smart contracts",
|
|
38
|
-
mimeType: "text/x-compact",
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
uri: "midnight://code/templates/token",
|
|
42
|
-
name: "Token Template",
|
|
43
|
-
description: "Starter template for privacy-preserving token contracts",
|
|
44
|
-
mimeType: "text/x-compact",
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
uri: "midnight://code/templates/voting",
|
|
48
|
-
name: "Voting Template",
|
|
49
|
-
description: "Starter template for private voting contracts",
|
|
50
|
-
mimeType: "text/x-compact",
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
uri: "midnight://code/examples/nullifier",
|
|
54
|
-
name: "Nullifier Pattern",
|
|
55
|
-
description: "How to create and use nullifiers to prevent double-spending and replay attacks",
|
|
56
|
-
mimeType: "text/x-compact",
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
uri: "midnight://code/examples/hash",
|
|
60
|
-
name: "Hash Functions",
|
|
61
|
-
description: "Using hash functions for commitments, nullifiers, and data integrity",
|
|
62
|
-
mimeType: "text/x-compact",
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
uri: "midnight://code/examples/simple-counter",
|
|
66
|
-
name: "Simple Counter",
|
|
67
|
-
description: "Minimal counter contract for beginners learning Compact",
|
|
68
|
-
mimeType: "text/x-compact",
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
uri: "midnight://code/templates/basic",
|
|
72
|
-
name: "Basic Contract Template",
|
|
73
|
-
description: "Starting template with initialization, access control, and state management",
|
|
74
|
-
mimeType: "text/x-compact",
|
|
75
|
-
},
|
|
76
|
-
];
|
|
77
|
-
/**
|
|
78
|
-
* Get code content by URI
|
|
79
|
-
*/
|
|
80
|
-
export async function getCode(uri) {
|
|
81
|
-
// Check embedded code first
|
|
82
|
-
if (EMBEDDED_CODE[uri]) {
|
|
83
|
-
return EMBEDDED_CODE[uri];
|
|
84
|
-
}
|
|
85
|
-
// Try to fetch from GitHub for example paths
|
|
86
|
-
if (uri.startsWith("midnight://code/examples/")) {
|
|
87
|
-
const exampleName = uri.replace("midnight://code/examples/", "");
|
|
88
|
-
try {
|
|
89
|
-
// Map example names to repositories
|
|
90
|
-
const repoMap = {
|
|
91
|
-
counter: {
|
|
92
|
-
owner: "midnightntwrk",
|
|
93
|
-
repo: "example-counter",
|
|
94
|
-
path: "contract/src/counter.compact",
|
|
95
|
-
},
|
|
96
|
-
bboard: {
|
|
97
|
-
owner: "midnightntwrk",
|
|
98
|
-
repo: "example-bboard",
|
|
99
|
-
path: "contract/src/bboard.compact",
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
const mapping = repoMap[exampleName];
|
|
103
|
-
if (mapping) {
|
|
104
|
-
const file = await githubClient.getFileContent(mapping.owner, mapping.repo, mapping.path);
|
|
105
|
-
if (file) {
|
|
106
|
-
return file.content;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
logger.warn(`Could not fetch code from GitHub: ${uri}`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* List all available code resources
|
|
118
|
-
*/
|
|
119
|
-
export function listCodeResources() {
|
|
120
|
-
return codeResources;
|
|
121
|
-
}
|
|
122
|
-
//# sourceMappingURL=code.js.map
|