midnight-mcp 0.2.2 → 0.2.3
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 +31 -24
- package/dist/bin.js +3 -3
- package/dist/{chunk-HOWO4K5A.js → chunk-EBFMM2DS.js} +46 -6
- package/dist/{chunk-S7G4OHA4.js → chunk-ZYCQLQEX.js} +747 -16
- package/dist/db-ILWTH42C.js +7 -0
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/db-YDGUWI5K.js +0 -7
package/README.md
CHANGED
|
@@ -8,6 +8,33 @@
|
|
|
8
8
|
|
|
9
9
|
MCP server that gives AI assistants access to Midnight blockchain—search contracts, analyze code, and explore documentation.
|
|
10
10
|
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- **Node.js 20+** (LTS recommended)
|
|
14
|
+
|
|
15
|
+
Check your version: `node --version`
|
|
16
|
+
|
|
17
|
+
<details>
|
|
18
|
+
<summary><strong>Using nvm?</strong> Click for Claude Desktop setup</summary>
|
|
19
|
+
|
|
20
|
+
If you use nvm, Claude Desktop may not see your nvm-managed Node. Use this config instead:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"mcpServers": {
|
|
25
|
+
"midnight": {
|
|
26
|
+
"command": "/bin/sh",
|
|
27
|
+
"args": [
|
|
28
|
+
"-c",
|
|
29
|
+
"source ~/.nvm/nvm.sh && nvm use 20 >/dev/null 2>&1 && npx -y midnight-mcp@latest"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
</details>
|
|
37
|
+
|
|
11
38
|
## Quick Start
|
|
12
39
|
|
|
13
40
|
### Claude Desktop
|
|
@@ -71,33 +98,13 @@ Add to `~/.codeium/windsurf/mcp_config.json`:
|
|
|
71
98
|
|
|
72
99
|
**No API keys required.** Restart your editor after adding the config.
|
|
73
100
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
Using `midnight-mcp@latest` in your config ensures you get updates automatically on restart.
|
|
77
|
-
|
|
78
|
-
**Already using an older version without `@latest`?** Update your config manually:
|
|
79
|
-
|
|
80
|
-
```diff
|
|
81
|
-
- "args": ["-y", "midnight-mcp"]
|
|
82
|
-
+ "args": ["-y", "midnight-mcp@latest"]
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
**Then clear npm cache and restart:**
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
# Clear npx cache (required to fetch new version)
|
|
89
|
-
rm -rf ~/.npm/_npx
|
|
90
|
-
|
|
91
|
-
# Restart your editor (Cmd+Q on Mac, then reopen)
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
> **Note:** AI agents cannot auto-update your config because they run in a sandboxed environment without access to your local filesystem.
|
|
101
|
+
> **Why `@latest`?** Unlike cached npx packages that never auto-update, `@latest` ensures you get new features and fixes on each restart. If upgrading from an older config without `@latest`, also clear your npx cache: `rm -rf ~/.npm/_npx`
|
|
95
102
|
|
|
96
103
|
---
|
|
97
104
|
|
|
98
105
|
## What's Included
|
|
99
106
|
|
|
100
|
-
###
|
|
107
|
+
### 27 Tools
|
|
101
108
|
|
|
102
109
|
| Category | Tools | Description |
|
|
103
110
|
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
|
|
@@ -108,7 +115,7 @@ rm -rf ~/.npm/_npx
|
|
|
108
115
|
| **AI Generation** | `generate-contract`, `review-contract`, `document-contract` | AI-powered code generation _(requires sampling)_ |
|
|
109
116
|
| **Compound** | `upgrade-check`, `get-repo-context` | Multi-step operations _(saves 50-70% tokens)_ |
|
|
110
117
|
| **Health** | `health-check`, `get-status`, `check-version` | Server status and version checking |
|
|
111
|
-
| **Discovery** | `list-tool-categories`, `list-category-tools`
|
|
118
|
+
| **Discovery** | `list-tool-categories`, `list-category-tools`, `suggest-tool` | Explore available tools and get recommendations |
|
|
112
119
|
|
|
113
120
|
All tools are prefixed with `midnight-` (e.g., `midnight-search-compact`).
|
|
114
121
|
|
|
@@ -116,7 +123,7 @@ All tools are prefixed with `midnight-` (e.g., `midnight-search-compact`).
|
|
|
116
123
|
|
|
117
124
|
| Capability | Feature |
|
|
118
125
|
| --------------- | ----------------------------------------------- |
|
|
119
|
-
| **Tools** |
|
|
126
|
+
| **Tools** | 27 tools with `listChanged` notifications |
|
|
120
127
|
| **Resources** | 9 embedded resources with subscription support |
|
|
121
128
|
| **Prompts** | 5 workflow prompts |
|
|
122
129
|
| **Logging** | Client-controllable log level |
|
package/dist/bin.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
startHttpServer,
|
|
4
4
|
startServer
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ZYCQLQEX.js";
|
|
6
6
|
import {
|
|
7
7
|
setOutputFormat
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-EBFMM2DS.js";
|
|
9
9
|
|
|
10
10
|
// src/bin.ts
|
|
11
11
|
import { config } from "dotenv";
|
|
@@ -13,7 +13,7 @@ import { resolve } from "path";
|
|
|
13
13
|
import yargs from "yargs";
|
|
14
14
|
import { hideBin } from "yargs/helpers";
|
|
15
15
|
config({ path: resolve(process.cwd(), ".env") });
|
|
16
|
-
var CURRENT_VERSION = "0.2.
|
|
16
|
+
var CURRENT_VERSION = "0.2.3";
|
|
17
17
|
process.on("uncaughtException", (error) => {
|
|
18
18
|
console.error("Uncaught exception:", error);
|
|
19
19
|
process.exit(1);
|
|
@@ -1594,7 +1594,7 @@ async function checkGitHubAPI() {
|
|
|
1594
1594
|
}
|
|
1595
1595
|
async function checkVectorStore() {
|
|
1596
1596
|
try {
|
|
1597
|
-
const { vectorStore: vectorStore2 } = await import("./db-
|
|
1597
|
+
const { vectorStore: vectorStore2 } = await import("./db-ILWTH42C.js");
|
|
1598
1598
|
if (vectorStore2) {
|
|
1599
1599
|
return {
|
|
1600
1600
|
status: "pass",
|
|
@@ -1899,6 +1899,39 @@ setInterval(pruneAllCaches, 5 * 60 * 1e3);
|
|
|
1899
1899
|
|
|
1900
1900
|
// src/utils/hosted-api.ts
|
|
1901
1901
|
var API_TIMEOUT = 1e4;
|
|
1902
|
+
function getActionableErrorMessage(status, endpoint, serverMessage) {
|
|
1903
|
+
const baseMessages = {
|
|
1904
|
+
400: `Bad request to ${endpoint}. Check your query parameters are valid.`,
|
|
1905
|
+
401: `Authentication failed. If you have an API key configured, verify it's correct.`,
|
|
1906
|
+
403: `Access denied to ${endpoint}. This resource may require authentication.`,
|
|
1907
|
+
404: `Resource not found at ${endpoint}. Use midnight-list-examples to see available resources.`,
|
|
1908
|
+
408: `Request timed out. The hosted service may be under heavy load - try again in a moment.`,
|
|
1909
|
+
429: `Rate limited. Try again in a few minutes, or set MIDNIGHT_LOCAL=true for unlimited local search (requires ChromaDB + OpenAI API key).`,
|
|
1910
|
+
500: `Server error. This is temporary - try again shortly or report at github.com/Olanetsoft/midnight-mcp/issues`,
|
|
1911
|
+
502: `Bad gateway. The hosted API may be restarting - try again in 30 seconds.`,
|
|
1912
|
+
503: `Service temporarily unavailable. The hosted API may be under maintenance - try again later or use MIDNIGHT_LOCAL=true for local mode.`,
|
|
1913
|
+
504: `Gateway timeout. The request took too long - try a simpler query or try again later.`
|
|
1914
|
+
};
|
|
1915
|
+
const actionableMessage = baseMessages[status] || `API error (${status}). Try again or report at github.com/Olanetsoft/midnight-mcp/issues`;
|
|
1916
|
+
if (serverMessage && !actionableMessage.includes(serverMessage)) {
|
|
1917
|
+
return `${actionableMessage} Server said: "${serverMessage}"`;
|
|
1918
|
+
}
|
|
1919
|
+
return actionableMessage;
|
|
1920
|
+
}
|
|
1921
|
+
async function parseApiError(response, endpoint) {
|
|
1922
|
+
let serverMessage;
|
|
1923
|
+
try {
|
|
1924
|
+
const errorData = await response.json();
|
|
1925
|
+
serverMessage = errorData.error || errorData.message;
|
|
1926
|
+
} catch {
|
|
1927
|
+
}
|
|
1928
|
+
const actionableMessage = getActionableErrorMessage(
|
|
1929
|
+
response.status,
|
|
1930
|
+
endpoint,
|
|
1931
|
+
serverMessage
|
|
1932
|
+
);
|
|
1933
|
+
return new Error(actionableMessage);
|
|
1934
|
+
}
|
|
1902
1935
|
async function apiRequest(endpoint, options = {}) {
|
|
1903
1936
|
const url = `${config.hostedApiUrl}${endpoint}`;
|
|
1904
1937
|
const controller = new AbortController();
|
|
@@ -1914,14 +1947,21 @@ async function apiRequest(endpoint, options = {}) {
|
|
|
1914
1947
|
}
|
|
1915
1948
|
});
|
|
1916
1949
|
if (!response.ok) {
|
|
1917
|
-
|
|
1918
|
-
throw new Error(errorData.error || `API error: ${response.status}`);
|
|
1950
|
+
throw await parseApiError(response, endpoint);
|
|
1919
1951
|
}
|
|
1920
1952
|
return await response.json();
|
|
1921
1953
|
} catch (error) {
|
|
1922
1954
|
if (error instanceof Error && error.name === "AbortError") {
|
|
1923
1955
|
throw new Error(
|
|
1924
|
-
|
|
1956
|
+
`Request to ${endpoint} timed out after ${API_TIMEOUT / 1e3}s. The hosted service may be unavailable. Try again or set MIDNIGHT_LOCAL=true for local search.`
|
|
1957
|
+
);
|
|
1958
|
+
}
|
|
1959
|
+
if (error instanceof Error && error.message.includes("github.com/Olanetsoft")) {
|
|
1960
|
+
throw error;
|
|
1961
|
+
}
|
|
1962
|
+
if (error instanceof Error) {
|
|
1963
|
+
throw new Error(
|
|
1964
|
+
`Failed to connect to hosted API: ${error.message}. Check your internet connection or set MIDNIGHT_LOCAL=true for local search.`
|
|
1925
1965
|
);
|
|
1926
1966
|
}
|
|
1927
1967
|
throw error;
|
|
@@ -1985,7 +2025,7 @@ function serialize(data) {
|
|
|
1985
2025
|
}
|
|
1986
2026
|
|
|
1987
2027
|
// src/utils/version.ts
|
|
1988
|
-
var CURRENT_VERSION = "0.2.
|
|
2028
|
+
var CURRENT_VERSION = "0.2.3";
|
|
1989
2029
|
|
|
1990
2030
|
// src/db/vectorStore.ts
|
|
1991
2031
|
var VectorStore = class {
|
|
@@ -2194,4 +2234,4 @@ export {
|
|
|
2194
2234
|
serialize,
|
|
2195
2235
|
CURRENT_VERSION
|
|
2196
2236
|
};
|
|
2197
|
-
//# sourceMappingURL=chunk-
|
|
2237
|
+
//# sourceMappingURL=chunk-EBFMM2DS.js.map
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
validateNumber,
|
|
26
26
|
validateQuery,
|
|
27
27
|
vectorStore
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-EBFMM2DS.js";
|
|
29
29
|
|
|
30
30
|
// src/tools/search/schemas.ts
|
|
31
31
|
import { z } from "zod";
|
|
@@ -324,7 +324,12 @@ var searchToolAnnotations = {
|
|
|
324
324
|
var searchTools = [
|
|
325
325
|
{
|
|
326
326
|
name: "midnight-search-compact",
|
|
327
|
-
description:
|
|
327
|
+
description: `Semantic search across Compact smart contract code and patterns. Use this to find circuit definitions, witness functions, ledger declarations, and best practices for Midnight smart contracts.
|
|
328
|
+
|
|
329
|
+
USAGE GUIDANCE:
|
|
330
|
+
\u2022 Call at most 2 times per question - if first search doesn't help, try different keywords
|
|
331
|
+
\u2022 For comprehensive results, combine with midnight-search-docs
|
|
332
|
+
\u2022 Use specific terms like "ledger", "circuit", "witness" for better matches`,
|
|
328
333
|
inputSchema: {
|
|
329
334
|
type: "object",
|
|
330
335
|
properties: {
|
|
@@ -356,7 +361,12 @@ var searchTools = [
|
|
|
356
361
|
},
|
|
357
362
|
{
|
|
358
363
|
name: "midnight-search-typescript",
|
|
359
|
-
description:
|
|
364
|
+
description: `Search TypeScript SDK code, types, and API implementations. Use this to find how to use the Midnight JavaScript SDK, type definitions, and integration patterns.
|
|
365
|
+
|
|
366
|
+
USAGE GUIDANCE:
|
|
367
|
+
\u2022 Call at most 2 times per question - refine keywords rather than repeating
|
|
368
|
+
\u2022 For contract code, use midnight-search-compact instead
|
|
369
|
+
\u2022 Include "type" or "interface" in query for type definitions`,
|
|
360
370
|
inputSchema: {
|
|
361
371
|
type: "object",
|
|
362
372
|
properties: {
|
|
@@ -388,7 +398,12 @@ var searchTools = [
|
|
|
388
398
|
},
|
|
389
399
|
{
|
|
390
400
|
name: "midnight-search-docs",
|
|
391
|
-
description:
|
|
401
|
+
description: `Full-text search across official Midnight documentation. Use this to find guides, API documentation, and conceptual explanations about Midnight blockchain and the Compact language.
|
|
402
|
+
|
|
403
|
+
USAGE GUIDANCE:
|
|
404
|
+
\u2022 Call at most 2 times per question - use different keywords if first search fails
|
|
405
|
+
\u2022 For code examples, combine with midnight-search-compact or midnight-search-typescript
|
|
406
|
+
\u2022 Use category filter to narrow results (guides, api, concepts)`,
|
|
392
407
|
inputSchema: {
|
|
393
408
|
type: "object",
|
|
394
409
|
properties: {
|
|
@@ -784,7 +799,17 @@ var explainCircuitOutputSchema = {
|
|
|
784
799
|
var analyzeTools = [
|
|
785
800
|
{
|
|
786
801
|
name: "midnight-analyze-contract",
|
|
787
|
-
description:
|
|
802
|
+
description: `\u26A0\uFE0F STATIC ANALYSIS ONLY - Analyze contract structure and patterns.
|
|
803
|
+
\u{1F6AB} THIS DOES NOT COMPILE THE CONTRACT. Cannot catch: sealed field rules, disclose() requirements, semantic errors.
|
|
804
|
+
\u{1F449} Use 'midnight-extract-contract-structure' for pre-compilation checks.
|
|
805
|
+
|
|
806
|
+
Use this for: understanding structure, security pattern analysis, recommendations.
|
|
807
|
+
NEVER claim a contract 'works' or 'compiles' based on this tool alone.
|
|
808
|
+
|
|
809
|
+
USAGE GUIDANCE:
|
|
810
|
+
\u2022 Call once per contract - results are deterministic
|
|
811
|
+
\u2022 For security review, also use midnight-review-contract (requires sampling)
|
|
812
|
+
\u2022 Run before making changes, not repeatedly during iteration`,
|
|
788
813
|
inputSchema: {
|
|
789
814
|
type: "object",
|
|
790
815
|
properties: {
|
|
@@ -810,7 +835,12 @@ var analyzeTools = [
|
|
|
810
835
|
},
|
|
811
836
|
{
|
|
812
837
|
name: "midnight-explain-circuit",
|
|
813
|
-
description:
|
|
838
|
+
description: `Explain what a specific Compact circuit does in plain language, including its zero-knowledge proof implications and privacy considerations.
|
|
839
|
+
|
|
840
|
+
USAGE GUIDANCE:
|
|
841
|
+
\u2022 Call once per circuit - explanations are deterministic
|
|
842
|
+
\u2022 Provide complete circuit code including parameters and body
|
|
843
|
+
\u2022 For full contract analysis, use midnight-analyze-contract first`,
|
|
814
844
|
inputSchema: {
|
|
815
845
|
type: "object",
|
|
816
846
|
properties: {
|
|
@@ -6935,7 +6965,12 @@ function getInstallCommand(repoName, version) {
|
|
|
6935
6965
|
var repositoryTools = [
|
|
6936
6966
|
{
|
|
6937
6967
|
name: "midnight-get-file",
|
|
6938
|
-
description:
|
|
6968
|
+
description: `Retrieve a specific file from Midnight repositories. Use repository aliases like 'compact', 'midnight-js', 'counter', or 'bboard' for convenience.
|
|
6969
|
+
|
|
6970
|
+
USAGE GUIDANCE:
|
|
6971
|
+
\u2022 Use midnight-list-examples first if you're unsure which file to get
|
|
6972
|
+
\u2022 For searching across files, use midnight-search-* tools instead
|
|
6973
|
+
\u2022 Use 'ref' parameter to get specific versions (branch, tag, or commit)`,
|
|
6939
6974
|
inputSchema: {
|
|
6940
6975
|
type: "object",
|
|
6941
6976
|
properties: {
|
|
@@ -8015,6 +8050,11 @@ var ListCategoryToolsInputSchema = z6.object({
|
|
|
8015
8050
|
]).describe("Category to list tools for"),
|
|
8016
8051
|
includeSchemas: z6.boolean().optional().default(false).describe("Include input/output schemas")
|
|
8017
8052
|
});
|
|
8053
|
+
var SuggestToolInputSchema = z6.object({
|
|
8054
|
+
intent: z6.string().describe(
|
|
8055
|
+
"What you want to accomplish (e.g., 'find example voting contract', 'check if my version is outdated', 'analyze my contract for security issues')"
|
|
8056
|
+
)
|
|
8057
|
+
});
|
|
8018
8058
|
var CATEGORY_INFO = {
|
|
8019
8059
|
search: {
|
|
8020
8060
|
description: "Semantic search across Midnight codebase - find code by meaning, not keywords",
|
|
@@ -8022,7 +8062,33 @@ var CATEGORY_INFO = {
|
|
|
8022
8062
|
"Find example implementations",
|
|
8023
8063
|
"Search for patterns",
|
|
8024
8064
|
"Discover relevant code"
|
|
8025
|
-
]
|
|
8065
|
+
],
|
|
8066
|
+
intentKeywords: [
|
|
8067
|
+
// Core search verbs
|
|
8068
|
+
"find",
|
|
8069
|
+
"search",
|
|
8070
|
+
"look for",
|
|
8071
|
+
"locate",
|
|
8072
|
+
"discover",
|
|
8073
|
+
"explore",
|
|
8074
|
+
// Question patterns
|
|
8075
|
+
"example",
|
|
8076
|
+
"how to",
|
|
8077
|
+
"show me",
|
|
8078
|
+
"where is",
|
|
8079
|
+
"what is",
|
|
8080
|
+
"can i see",
|
|
8081
|
+
"give me",
|
|
8082
|
+
// Code-specific
|
|
8083
|
+
"pattern",
|
|
8084
|
+
"implementation",
|
|
8085
|
+
"code for",
|
|
8086
|
+
"sample",
|
|
8087
|
+
"snippet",
|
|
8088
|
+
"reference",
|
|
8089
|
+
"similar to"
|
|
8090
|
+
],
|
|
8091
|
+
startWith: "midnight-search-compact"
|
|
8026
8092
|
},
|
|
8027
8093
|
analyze: {
|
|
8028
8094
|
description: "Static analysis of Compact contracts - security, structure, patterns",
|
|
@@ -8030,7 +8096,34 @@ var CATEGORY_INFO = {
|
|
|
8030
8096
|
"Security audit",
|
|
8031
8097
|
"Code review",
|
|
8032
8098
|
"Understand contract structure"
|
|
8033
|
-
]
|
|
8099
|
+
],
|
|
8100
|
+
intentKeywords: [
|
|
8101
|
+
// Analysis verbs
|
|
8102
|
+
"analyze",
|
|
8103
|
+
"check",
|
|
8104
|
+
"inspect",
|
|
8105
|
+
"examine",
|
|
8106
|
+
"evaluate",
|
|
8107
|
+
"assess",
|
|
8108
|
+
// Security-related
|
|
8109
|
+
"security",
|
|
8110
|
+
"audit",
|
|
8111
|
+
"vulnerability",
|
|
8112
|
+
"vulnerabilities",
|
|
8113
|
+
"safe",
|
|
8114
|
+
"secure",
|
|
8115
|
+
"risk",
|
|
8116
|
+
// Understanding
|
|
8117
|
+
"review",
|
|
8118
|
+
"structure",
|
|
8119
|
+
"explain",
|
|
8120
|
+
"understand",
|
|
8121
|
+
"what does",
|
|
8122
|
+
"breakdown",
|
|
8123
|
+
"how does",
|
|
8124
|
+
"meaning of"
|
|
8125
|
+
],
|
|
8126
|
+
startWith: "midnight-analyze-contract"
|
|
8034
8127
|
},
|
|
8035
8128
|
repository: {
|
|
8036
8129
|
description: "Access repository files, examples, and recent updates",
|
|
@@ -8038,7 +8131,32 @@ var CATEGORY_INFO = {
|
|
|
8038
8131
|
"Get specific files",
|
|
8039
8132
|
"List examples",
|
|
8040
8133
|
"Track repository changes"
|
|
8041
|
-
]
|
|
8134
|
+
],
|
|
8135
|
+
intentKeywords: [
|
|
8136
|
+
// File access
|
|
8137
|
+
"get file",
|
|
8138
|
+
"fetch",
|
|
8139
|
+
"download",
|
|
8140
|
+
"read file",
|
|
8141
|
+
"open",
|
|
8142
|
+
"source code",
|
|
8143
|
+
"raw",
|
|
8144
|
+
// Listing
|
|
8145
|
+
"list",
|
|
8146
|
+
"examples",
|
|
8147
|
+
"show examples",
|
|
8148
|
+
"available",
|
|
8149
|
+
"what examples",
|
|
8150
|
+
// Repository state
|
|
8151
|
+
"recent",
|
|
8152
|
+
"updates",
|
|
8153
|
+
"changes",
|
|
8154
|
+
"commits",
|
|
8155
|
+
"history",
|
|
8156
|
+
"modified",
|
|
8157
|
+
"new files"
|
|
8158
|
+
],
|
|
8159
|
+
startWith: "midnight-list-examples"
|
|
8042
8160
|
},
|
|
8043
8161
|
versioning: {
|
|
8044
8162
|
description: "Version management, breaking changes, and migration assistance",
|
|
@@ -8047,15 +8165,92 @@ var CATEGORY_INFO = {
|
|
|
8047
8165
|
"Plan upgrades",
|
|
8048
8166
|
"Compare versions",
|
|
8049
8167
|
"Get migration guides"
|
|
8050
|
-
]
|
|
8168
|
+
],
|
|
8169
|
+
intentKeywords: [
|
|
8170
|
+
// Version-related
|
|
8171
|
+
"version",
|
|
8172
|
+
"upgrade",
|
|
8173
|
+
"update",
|
|
8174
|
+
"migrate",
|
|
8175
|
+
"migration",
|
|
8176
|
+
// State checks
|
|
8177
|
+
"breaking",
|
|
8178
|
+
"outdated",
|
|
8179
|
+
"latest",
|
|
8180
|
+
"current",
|
|
8181
|
+
"deprecated",
|
|
8182
|
+
"old",
|
|
8183
|
+
"new version",
|
|
8184
|
+
// Comparison
|
|
8185
|
+
"compare",
|
|
8186
|
+
"diff",
|
|
8187
|
+
"difference",
|
|
8188
|
+
"changed between",
|
|
8189
|
+
"what changed",
|
|
8190
|
+
// Guidance
|
|
8191
|
+
"syntax",
|
|
8192
|
+
"correct syntax",
|
|
8193
|
+
"reference"
|
|
8194
|
+
],
|
|
8195
|
+
startWith: "midnight-upgrade-check"
|
|
8051
8196
|
},
|
|
8052
8197
|
generation: {
|
|
8053
8198
|
description: "AI-powered code generation, review, and documentation (requires sampling)",
|
|
8054
|
-
useCases: ["Generate contracts", "Review code", "Generate documentation"]
|
|
8199
|
+
useCases: ["Generate contracts", "Review code", "Generate documentation"],
|
|
8200
|
+
intentKeywords: [
|
|
8201
|
+
// Creation verbs
|
|
8202
|
+
"generate",
|
|
8203
|
+
"create",
|
|
8204
|
+
"write",
|
|
8205
|
+
"build",
|
|
8206
|
+
"make",
|
|
8207
|
+
"scaffold",
|
|
8208
|
+
"boilerplate",
|
|
8209
|
+
// AI-specific
|
|
8210
|
+
"ai",
|
|
8211
|
+
"help me write",
|
|
8212
|
+
"draft",
|
|
8213
|
+
"produce",
|
|
8214
|
+
// Documentation
|
|
8215
|
+
"document",
|
|
8216
|
+
"documentation",
|
|
8217
|
+
"explain code",
|
|
8218
|
+
"comment",
|
|
8219
|
+
// Review
|
|
8220
|
+
"improve",
|
|
8221
|
+
"suggest fix",
|
|
8222
|
+
"refactor"
|
|
8223
|
+
],
|
|
8224
|
+
startWith: "midnight-generate-contract"
|
|
8055
8225
|
},
|
|
8056
8226
|
health: {
|
|
8057
8227
|
description: "Server health checks and status monitoring",
|
|
8058
|
-
useCases: ["Check API status", "Monitor rate limits", "Debug connectivity"]
|
|
8228
|
+
useCases: ["Check API status", "Monitor rate limits", "Debug connectivity"],
|
|
8229
|
+
intentKeywords: [
|
|
8230
|
+
// Status checks
|
|
8231
|
+
"health",
|
|
8232
|
+
"status",
|
|
8233
|
+
"working",
|
|
8234
|
+
"alive",
|
|
8235
|
+
"running",
|
|
8236
|
+
"up",
|
|
8237
|
+
// Problems
|
|
8238
|
+
"rate limit",
|
|
8239
|
+
"throttle",
|
|
8240
|
+
"quota",
|
|
8241
|
+
"error",
|
|
8242
|
+
"issue",
|
|
8243
|
+
"problem",
|
|
8244
|
+
// Debugging
|
|
8245
|
+
"debug",
|
|
8246
|
+
"connection",
|
|
8247
|
+
"connectivity",
|
|
8248
|
+
"api",
|
|
8249
|
+
"server",
|
|
8250
|
+
"not working",
|
|
8251
|
+
"broken"
|
|
8252
|
+
],
|
|
8253
|
+
startWith: "midnight-health-check"
|
|
8059
8254
|
},
|
|
8060
8255
|
compound: {
|
|
8061
8256
|
description: "Multi-step operations in a single call - saves tokens and reduces latency",
|
|
@@ -8063,9 +8258,411 @@ var CATEGORY_INFO = {
|
|
|
8063
8258
|
"Full upgrade analysis",
|
|
8064
8259
|
"Get complete repo context",
|
|
8065
8260
|
"One-shot operations"
|
|
8066
|
-
]
|
|
8261
|
+
],
|
|
8262
|
+
intentKeywords: [
|
|
8263
|
+
// Completeness
|
|
8264
|
+
"everything",
|
|
8265
|
+
"all",
|
|
8266
|
+
"complete",
|
|
8267
|
+
"full",
|
|
8268
|
+
"comprehensive",
|
|
8269
|
+
"entire",
|
|
8270
|
+
"whole",
|
|
8271
|
+
// Starting points
|
|
8272
|
+
"start",
|
|
8273
|
+
"begin",
|
|
8274
|
+
"setup",
|
|
8275
|
+
"getting started",
|
|
8276
|
+
"onboard",
|
|
8277
|
+
"new project",
|
|
8278
|
+
// Efficiency
|
|
8279
|
+
"one shot",
|
|
8280
|
+
"single call",
|
|
8281
|
+
"efficient",
|
|
8282
|
+
"quick",
|
|
8283
|
+
"fast"
|
|
8284
|
+
],
|
|
8285
|
+
startWith: "midnight-get-repo-context"
|
|
8067
8286
|
}
|
|
8068
8287
|
};
|
|
8288
|
+
var INTENT_TO_TOOL = [
|
|
8289
|
+
// Examples & Getting Started
|
|
8290
|
+
{
|
|
8291
|
+
patterns: [
|
|
8292
|
+
"counter",
|
|
8293
|
+
"simple",
|
|
8294
|
+
"beginner",
|
|
8295
|
+
"start",
|
|
8296
|
+
"hello world",
|
|
8297
|
+
"basic",
|
|
8298
|
+
"first contract",
|
|
8299
|
+
"tutorial",
|
|
8300
|
+
"starter"
|
|
8301
|
+
],
|
|
8302
|
+
tool: "midnight-list-examples",
|
|
8303
|
+
reason: "Lists all example contracts including the beginner-friendly counter"
|
|
8304
|
+
},
|
|
8305
|
+
{
|
|
8306
|
+
patterns: [
|
|
8307
|
+
"getting started",
|
|
8308
|
+
"begin",
|
|
8309
|
+
"first time",
|
|
8310
|
+
"new to midnight",
|
|
8311
|
+
"learn midnight",
|
|
8312
|
+
"introduction",
|
|
8313
|
+
"overview",
|
|
8314
|
+
"onboarding",
|
|
8315
|
+
"setup project"
|
|
8316
|
+
],
|
|
8317
|
+
tool: "midnight-get-repo-context",
|
|
8318
|
+
reason: "Get everything needed to start working (compound tool)"
|
|
8319
|
+
},
|
|
8320
|
+
// Domain-specific searches
|
|
8321
|
+
{
|
|
8322
|
+
patterns: [
|
|
8323
|
+
"voting",
|
|
8324
|
+
"governance",
|
|
8325
|
+
"election",
|
|
8326
|
+
"ballot",
|
|
8327
|
+
"poll",
|
|
8328
|
+
"referendum",
|
|
8329
|
+
"proposal",
|
|
8330
|
+
"dao"
|
|
8331
|
+
],
|
|
8332
|
+
tool: "midnight-search-compact",
|
|
8333
|
+
reason: "Search for voting/governance-related patterns and examples"
|
|
8334
|
+
},
|
|
8335
|
+
{
|
|
8336
|
+
patterns: [
|
|
8337
|
+
"token",
|
|
8338
|
+
"transfer",
|
|
8339
|
+
"balance",
|
|
8340
|
+
"mint",
|
|
8341
|
+
"burn",
|
|
8342
|
+
"erc20",
|
|
8343
|
+
"fungible",
|
|
8344
|
+
"asset",
|
|
8345
|
+
"coin"
|
|
8346
|
+
],
|
|
8347
|
+
tool: "midnight-search-compact",
|
|
8348
|
+
reason: "Search for token-related implementations"
|
|
8349
|
+
},
|
|
8350
|
+
{
|
|
8351
|
+
patterns: [
|
|
8352
|
+
"nft",
|
|
8353
|
+
"non-fungible",
|
|
8354
|
+
"collectible",
|
|
8355
|
+
"unique",
|
|
8356
|
+
"ownership",
|
|
8357
|
+
"deed"
|
|
8358
|
+
],
|
|
8359
|
+
tool: "midnight-search-compact",
|
|
8360
|
+
reason: "Search for NFT and non-fungible token patterns"
|
|
8361
|
+
},
|
|
8362
|
+
{
|
|
8363
|
+
patterns: ["auction", "bid", "bidding", "marketplace", "sale", "exchange"],
|
|
8364
|
+
tool: "midnight-search-compact",
|
|
8365
|
+
reason: "Search for auction and marketplace patterns"
|
|
8366
|
+
},
|
|
8367
|
+
{
|
|
8368
|
+
patterns: [
|
|
8369
|
+
"access control",
|
|
8370
|
+
"permission",
|
|
8371
|
+
"role",
|
|
8372
|
+
"admin",
|
|
8373
|
+
"owner",
|
|
8374
|
+
"authorization",
|
|
8375
|
+
"acl"
|
|
8376
|
+
],
|
|
8377
|
+
tool: "midnight-search-compact",
|
|
8378
|
+
reason: "Search for access control and permission patterns"
|
|
8379
|
+
},
|
|
8380
|
+
// Security & Analysis
|
|
8381
|
+
{
|
|
8382
|
+
patterns: [
|
|
8383
|
+
"security",
|
|
8384
|
+
"vulnerability",
|
|
8385
|
+
"audit",
|
|
8386
|
+
"safe",
|
|
8387
|
+
"attack",
|
|
8388
|
+
"exploit",
|
|
8389
|
+
"risk",
|
|
8390
|
+
"issue",
|
|
8391
|
+
"bug"
|
|
8392
|
+
],
|
|
8393
|
+
tool: "midnight-analyze-contract",
|
|
8394
|
+
reason: "Performs security analysis on your contract code"
|
|
8395
|
+
},
|
|
8396
|
+
{
|
|
8397
|
+
patterns: [
|
|
8398
|
+
"circuit",
|
|
8399
|
+
"zk",
|
|
8400
|
+
"zero knowledge",
|
|
8401
|
+
"proof",
|
|
8402
|
+
"privacy",
|
|
8403
|
+
"private",
|
|
8404
|
+
"witness",
|
|
8405
|
+
"constraint"
|
|
8406
|
+
],
|
|
8407
|
+
tool: "midnight-explain-circuit",
|
|
8408
|
+
reason: "Explains circuit logic and ZK implications"
|
|
8409
|
+
},
|
|
8410
|
+
// Version & Upgrade
|
|
8411
|
+
{
|
|
8412
|
+
patterns: [
|
|
8413
|
+
"upgrade",
|
|
8414
|
+
"update",
|
|
8415
|
+
"outdated",
|
|
8416
|
+
"new version",
|
|
8417
|
+
"breaking",
|
|
8418
|
+
"deprecat",
|
|
8419
|
+
"migrate",
|
|
8420
|
+
"migration guide"
|
|
8421
|
+
],
|
|
8422
|
+
tool: "midnight-upgrade-check",
|
|
8423
|
+
reason: "Complete upgrade analysis in one call (compound tool)"
|
|
8424
|
+
},
|
|
8425
|
+
{
|
|
8426
|
+
patterns: [
|
|
8427
|
+
"syntax",
|
|
8428
|
+
"correct",
|
|
8429
|
+
"how to write",
|
|
8430
|
+
"format",
|
|
8431
|
+
"proper way",
|
|
8432
|
+
"right way",
|
|
8433
|
+
"convention",
|
|
8434
|
+
"best practice"
|
|
8435
|
+
],
|
|
8436
|
+
tool: "midnight-get-latest-syntax",
|
|
8437
|
+
reason: "Get authoritative syntax reference to avoid mistakes"
|
|
8438
|
+
},
|
|
8439
|
+
{
|
|
8440
|
+
patterns: [
|
|
8441
|
+
"what changed",
|
|
8442
|
+
"changelog",
|
|
8443
|
+
"release notes",
|
|
8444
|
+
"difference between",
|
|
8445
|
+
"compare versions"
|
|
8446
|
+
],
|
|
8447
|
+
tool: "midnight-compare-syntax",
|
|
8448
|
+
reason: "Compare syntax/features between versions"
|
|
8449
|
+
},
|
|
8450
|
+
// SDK & TypeScript
|
|
8451
|
+
{
|
|
8452
|
+
patterns: [
|
|
8453
|
+
"sdk",
|
|
8454
|
+
"typescript",
|
|
8455
|
+
"javascript",
|
|
8456
|
+
"api",
|
|
8457
|
+
"integration",
|
|
8458
|
+
"client",
|
|
8459
|
+
"frontend",
|
|
8460
|
+
"dapp",
|
|
8461
|
+
"web3"
|
|
8462
|
+
],
|
|
8463
|
+
tool: "midnight-search-typescript",
|
|
8464
|
+
reason: "Search TypeScript SDK code and types"
|
|
8465
|
+
},
|
|
8466
|
+
{
|
|
8467
|
+
patterns: ["type", "types", "interface", "typing", "definition"],
|
|
8468
|
+
tool: "midnight-search-typescript",
|
|
8469
|
+
reason: "Search TypeScript type definitions"
|
|
8470
|
+
},
|
|
8471
|
+
// Documentation
|
|
8472
|
+
{
|
|
8473
|
+
patterns: [
|
|
8474
|
+
"docs",
|
|
8475
|
+
"documentation",
|
|
8476
|
+
"guide",
|
|
8477
|
+
"tutorial",
|
|
8478
|
+
"learn",
|
|
8479
|
+
"concept",
|
|
8480
|
+
"explanation",
|
|
8481
|
+
"manual"
|
|
8482
|
+
],
|
|
8483
|
+
tool: "midnight-search-docs",
|
|
8484
|
+
reason: "Search official Midnight documentation"
|
|
8485
|
+
},
|
|
8486
|
+
// Code Generation
|
|
8487
|
+
{
|
|
8488
|
+
patterns: [
|
|
8489
|
+
"generate",
|
|
8490
|
+
"create contract",
|
|
8491
|
+
"write contract",
|
|
8492
|
+
"new contract",
|
|
8493
|
+
"scaffold",
|
|
8494
|
+
"template",
|
|
8495
|
+
"boilerplate"
|
|
8496
|
+
],
|
|
8497
|
+
tool: "midnight-generate-contract",
|
|
8498
|
+
reason: "AI-powered contract generation (requires sampling)"
|
|
8499
|
+
},
|
|
8500
|
+
{
|
|
8501
|
+
patterns: [
|
|
8502
|
+
"review",
|
|
8503
|
+
"check my code",
|
|
8504
|
+
"is this correct",
|
|
8505
|
+
"feedback",
|
|
8506
|
+
"improve my",
|
|
8507
|
+
"fix my"
|
|
8508
|
+
],
|
|
8509
|
+
tool: "midnight-review-contract",
|
|
8510
|
+
reason: "AI-powered code review (requires sampling)"
|
|
8511
|
+
},
|
|
8512
|
+
{
|
|
8513
|
+
patterns: [
|
|
8514
|
+
"document my",
|
|
8515
|
+
"add comments",
|
|
8516
|
+
"explain my code",
|
|
8517
|
+
"generate docs"
|
|
8518
|
+
],
|
|
8519
|
+
tool: "midnight-generate-documentation",
|
|
8520
|
+
reason: "AI-powered documentation generation (requires sampling)"
|
|
8521
|
+
},
|
|
8522
|
+
// Health & Debugging
|
|
8523
|
+
{
|
|
8524
|
+
patterns: [
|
|
8525
|
+
"not working",
|
|
8526
|
+
"error",
|
|
8527
|
+
"broken",
|
|
8528
|
+
"failing",
|
|
8529
|
+
"issue with server",
|
|
8530
|
+
"api down"
|
|
8531
|
+
],
|
|
8532
|
+
tool: "midnight-health-check",
|
|
8533
|
+
reason: "Check server status and connectivity"
|
|
8534
|
+
},
|
|
8535
|
+
{
|
|
8536
|
+
patterns: ["rate limit", "quota", "throttle", "429", "too many requests"],
|
|
8537
|
+
tool: "midnight-health-check",
|
|
8538
|
+
reason: "Check rate limit status and remaining quota"
|
|
8539
|
+
},
|
|
8540
|
+
{
|
|
8541
|
+
patterns: ["server status", "api status", "is api up", "check server"],
|
|
8542
|
+
tool: "midnight-get-status",
|
|
8543
|
+
reason: "Get detailed server and API status information"
|
|
8544
|
+
},
|
|
8545
|
+
{
|
|
8546
|
+
patterns: [
|
|
8547
|
+
"mcp version",
|
|
8548
|
+
"server version",
|
|
8549
|
+
"what version am i using",
|
|
8550
|
+
"installed version"
|
|
8551
|
+
],
|
|
8552
|
+
tool: "midnight-check-version",
|
|
8553
|
+
reason: "Check the current MCP server version"
|
|
8554
|
+
},
|
|
8555
|
+
{
|
|
8556
|
+
patterns: [
|
|
8557
|
+
"auto update",
|
|
8558
|
+
"keep updated",
|
|
8559
|
+
"automatic updates",
|
|
8560
|
+
"stay current",
|
|
8561
|
+
"update automatically"
|
|
8562
|
+
],
|
|
8563
|
+
tool: "midnight-auto-update-config",
|
|
8564
|
+
reason: "Configure automatic syntax updates"
|
|
8565
|
+
},
|
|
8566
|
+
// Repository & Files
|
|
8567
|
+
{
|
|
8568
|
+
patterns: [
|
|
8569
|
+
"recent changes",
|
|
8570
|
+
"latest commits",
|
|
8571
|
+
"what's new",
|
|
8572
|
+
"updates",
|
|
8573
|
+
"modified",
|
|
8574
|
+
"new features",
|
|
8575
|
+
"repo activity"
|
|
8576
|
+
],
|
|
8577
|
+
tool: "midnight-get-latest-updates",
|
|
8578
|
+
reason: "See recent repository activity and changes"
|
|
8579
|
+
},
|
|
8580
|
+
{
|
|
8581
|
+
patterns: ["read file", "get file", "show file", "file content", "source"],
|
|
8582
|
+
tool: "midnight-get-file",
|
|
8583
|
+
reason: "Fetch specific file content from repository"
|
|
8584
|
+
},
|
|
8585
|
+
{
|
|
8586
|
+
patterns: [
|
|
8587
|
+
"file from version",
|
|
8588
|
+
"old version of file",
|
|
8589
|
+
"file at version",
|
|
8590
|
+
"historical file",
|
|
8591
|
+
"previous version"
|
|
8592
|
+
],
|
|
8593
|
+
tool: "midnight-get-file-at-version",
|
|
8594
|
+
reason: "Get a file as it existed in a specific version"
|
|
8595
|
+
},
|
|
8596
|
+
// Version Comparison & Info
|
|
8597
|
+
{
|
|
8598
|
+
patterns: [
|
|
8599
|
+
"what version",
|
|
8600
|
+
"current version",
|
|
8601
|
+
"latest version",
|
|
8602
|
+
"version number",
|
|
8603
|
+
"compact version"
|
|
8604
|
+
],
|
|
8605
|
+
tool: "midnight-get-version-info",
|
|
8606
|
+
reason: "Get version information for Midnight components"
|
|
8607
|
+
},
|
|
8608
|
+
{
|
|
8609
|
+
patterns: [
|
|
8610
|
+
"breaking changes",
|
|
8611
|
+
"what broke",
|
|
8612
|
+
"incompatible",
|
|
8613
|
+
"api changes",
|
|
8614
|
+
"deprecations"
|
|
8615
|
+
],
|
|
8616
|
+
tool: "midnight-check-breaking-changes",
|
|
8617
|
+
reason: "Check for breaking changes between versions"
|
|
8618
|
+
},
|
|
8619
|
+
{
|
|
8620
|
+
patterns: [
|
|
8621
|
+
"how to migrate",
|
|
8622
|
+
"migration steps",
|
|
8623
|
+
"upgrade guide",
|
|
8624
|
+
"migration path",
|
|
8625
|
+
"move to new version"
|
|
8626
|
+
],
|
|
8627
|
+
tool: "midnight-get-migration-guide",
|
|
8628
|
+
reason: "Get step-by-step migration guidance"
|
|
8629
|
+
},
|
|
8630
|
+
{
|
|
8631
|
+
patterns: [
|
|
8632
|
+
"compare syntax",
|
|
8633
|
+
"syntax diff",
|
|
8634
|
+
"syntax between versions",
|
|
8635
|
+
"syntax comparison"
|
|
8636
|
+
],
|
|
8637
|
+
tool: "midnight-compare-syntax",
|
|
8638
|
+
reason: "Compare Compact syntax between two versions"
|
|
8639
|
+
},
|
|
8640
|
+
// Contract Structure
|
|
8641
|
+
{
|
|
8642
|
+
patterns: [
|
|
8643
|
+
"extract structure",
|
|
8644
|
+
"contract structure",
|
|
8645
|
+
"parse contract",
|
|
8646
|
+
"contract outline",
|
|
8647
|
+
"functions in contract",
|
|
8648
|
+
"contract anatomy"
|
|
8649
|
+
],
|
|
8650
|
+
tool: "midnight-extract-contract-structure",
|
|
8651
|
+
reason: "Extract and analyze contract structure (functions, state, etc.)"
|
|
8652
|
+
},
|
|
8653
|
+
// Meta/Discovery (fallback patterns)
|
|
8654
|
+
{
|
|
8655
|
+
patterns: [
|
|
8656
|
+
"what tools",
|
|
8657
|
+
"available tools",
|
|
8658
|
+
"list tools",
|
|
8659
|
+
"show tools",
|
|
8660
|
+
"tool list"
|
|
8661
|
+
],
|
|
8662
|
+
tool: "midnight-list-tool-categories",
|
|
8663
|
+
reason: "Browse available tool categories"
|
|
8664
|
+
}
|
|
8665
|
+
];
|
|
8069
8666
|
|
|
8070
8667
|
// src/tools/meta/handlers.ts
|
|
8071
8668
|
var _metaTools = [];
|
|
@@ -8156,6 +8753,76 @@ function generateCategorySuggestion(category) {
|
|
|
8156
8753
|
return `Use these tools for ${CATEGORY_INFO[category]?.useCases[0] || "related operations"}.`;
|
|
8157
8754
|
}
|
|
8158
8755
|
}
|
|
8756
|
+
async function suggestTool(input) {
|
|
8757
|
+
const intentLower = input.intent.toLowerCase();
|
|
8758
|
+
const matchedTools = [];
|
|
8759
|
+
for (const mapping of INTENT_TO_TOOL) {
|
|
8760
|
+
const matchCount = mapping.patterns.filter(
|
|
8761
|
+
(p) => intentLower.includes(p.toLowerCase())
|
|
8762
|
+
).length;
|
|
8763
|
+
if (matchCount > 0) {
|
|
8764
|
+
matchedTools.push({
|
|
8765
|
+
tool: mapping.tool,
|
|
8766
|
+
reason: mapping.reason,
|
|
8767
|
+
confidence: matchCount >= 2 ? "high" : "medium"
|
|
8768
|
+
});
|
|
8769
|
+
}
|
|
8770
|
+
}
|
|
8771
|
+
const matchedCategories = [];
|
|
8772
|
+
for (const [category, info] of Object.entries(CATEGORY_INFO)) {
|
|
8773
|
+
const matchCount = info.intentKeywords.filter(
|
|
8774
|
+
(k) => intentLower.includes(k.toLowerCase())
|
|
8775
|
+
).length;
|
|
8776
|
+
if (matchCount > 0 && info.startWith) {
|
|
8777
|
+
matchedCategories.push({
|
|
8778
|
+
category,
|
|
8779
|
+
startWith: info.startWith,
|
|
8780
|
+
description: info.description,
|
|
8781
|
+
confidence: matchCount >= 2 ? "medium" : "low"
|
|
8782
|
+
});
|
|
8783
|
+
}
|
|
8784
|
+
}
|
|
8785
|
+
const confidenceOrder = { high: 0, medium: 1, low: 2 };
|
|
8786
|
+
matchedTools.sort(
|
|
8787
|
+
(a, b) => confidenceOrder[a.confidence] - confidenceOrder[b.confidence]
|
|
8788
|
+
);
|
|
8789
|
+
if (matchedTools.length === 0 && matchedCategories.length === 0) {
|
|
8790
|
+
return {
|
|
8791
|
+
intent: input.intent,
|
|
8792
|
+
suggestions: [],
|
|
8793
|
+
fallback: {
|
|
8794
|
+
tool: "midnight-list-tool-categories",
|
|
8795
|
+
reason: "No specific match found. Start by exploring available tool categories."
|
|
8796
|
+
},
|
|
8797
|
+
tip: "Try rephrasing your intent with keywords like: search, analyze, generate, upgrade, version, security, example"
|
|
8798
|
+
};
|
|
8799
|
+
}
|
|
8800
|
+
const seenTools = /* @__PURE__ */ new Set();
|
|
8801
|
+
const suggestions = [];
|
|
8802
|
+
for (const match of matchedTools) {
|
|
8803
|
+
if (!seenTools.has(match.tool)) {
|
|
8804
|
+
seenTools.add(match.tool);
|
|
8805
|
+
suggestions.push(match);
|
|
8806
|
+
}
|
|
8807
|
+
}
|
|
8808
|
+
for (const match of matchedCategories) {
|
|
8809
|
+
if (!seenTools.has(match.startWith)) {
|
|
8810
|
+
seenTools.add(match.startWith);
|
|
8811
|
+
suggestions.push({
|
|
8812
|
+
tool: match.startWith,
|
|
8813
|
+
reason: `Recommended starting tool for ${match.category}: ${match.description}`,
|
|
8814
|
+
confidence: match.confidence
|
|
8815
|
+
});
|
|
8816
|
+
}
|
|
8817
|
+
}
|
|
8818
|
+
const topSuggestions = suggestions.slice(0, 3);
|
|
8819
|
+
return {
|
|
8820
|
+
intent: input.intent,
|
|
8821
|
+
suggestions: topSuggestions,
|
|
8822
|
+
primaryRecommendation: topSuggestions[0],
|
|
8823
|
+
tip: topSuggestions[0]?.confidence === "high" ? `Strong match! Use ${topSuggestions[0].tool} for this task.` : "Multiple tools may help. Consider the suggestions based on your specific needs."
|
|
8824
|
+
};
|
|
8825
|
+
}
|
|
8159
8826
|
|
|
8160
8827
|
// src/tools/meta/tools.ts
|
|
8161
8828
|
var listCategoriesOutputSchema = {
|
|
@@ -8219,10 +8886,39 @@ var listCategoryToolsOutputSchema = {
|
|
|
8219
8886
|
required: ["category", "tools"],
|
|
8220
8887
|
description: "Tools within a specific category"
|
|
8221
8888
|
};
|
|
8889
|
+
var suggestToolOutputSchema = {
|
|
8890
|
+
type: "object",
|
|
8891
|
+
properties: {
|
|
8892
|
+
intent: { type: "string", description: "The original intent" },
|
|
8893
|
+
suggestions: {
|
|
8894
|
+
type: "array",
|
|
8895
|
+
description: "Suggested tools ranked by relevance",
|
|
8896
|
+
items: {
|
|
8897
|
+
type: "object",
|
|
8898
|
+
properties: {
|
|
8899
|
+
tool: { type: "string", description: "Tool name" },
|
|
8900
|
+
reason: { type: "string", description: "Why this tool is suggested" },
|
|
8901
|
+
confidence: {
|
|
8902
|
+
type: "string",
|
|
8903
|
+
enum: ["high", "medium", "low"],
|
|
8904
|
+
description: "Match confidence"
|
|
8905
|
+
}
|
|
8906
|
+
}
|
|
8907
|
+
}
|
|
8908
|
+
},
|
|
8909
|
+
primaryRecommendation: {
|
|
8910
|
+
type: "object",
|
|
8911
|
+
description: "Top recommendation"
|
|
8912
|
+
},
|
|
8913
|
+
tip: { type: "string", description: "Helpful tip" }
|
|
8914
|
+
},
|
|
8915
|
+
required: ["intent", "suggestions"],
|
|
8916
|
+
description: "Tool suggestions based on intent"
|
|
8917
|
+
};
|
|
8222
8918
|
var metaTools = [
|
|
8223
8919
|
{
|
|
8224
8920
|
name: "midnight-list-tool-categories",
|
|
8225
|
-
description: "\u{1F4CB} DISCOVERY TOOL: List available tool categories for progressive exploration. Use this FIRST to understand what capabilities are available, then drill into specific categories with midnight-list-category-tools. Reduces cognitive load by organizing
|
|
8921
|
+
description: "\u{1F4CB} DISCOVERY TOOL: List available tool categories for progressive exploration. Use this FIRST to understand what capabilities are available, then drill into specific categories with midnight-list-category-tools. Reduces cognitive load by organizing 27 tools into 7 logical groups.",
|
|
8226
8922
|
inputSchema: {
|
|
8227
8923
|
type: "object",
|
|
8228
8924
|
properties: {
|
|
@@ -8276,6 +8972,41 @@ var metaTools = [
|
|
|
8276
8972
|
category: "health"
|
|
8277
8973
|
},
|
|
8278
8974
|
handler: listCategoryTools
|
|
8975
|
+
},
|
|
8976
|
+
{
|
|
8977
|
+
name: "midnight-suggest-tool",
|
|
8978
|
+
description: `\u{1F3AF} SMART DISCOVERY: Describe what you want to do in natural language, and get tool recommendations.
|
|
8979
|
+
|
|
8980
|
+
EXAMPLES:
|
|
8981
|
+
\u2022 "I want to find example voting contracts" \u2192 midnight-search-compact
|
|
8982
|
+
\u2022 "Check if my version is outdated" \u2192 midnight-upgrade-check
|
|
8983
|
+
\u2022 "Analyze my contract for security issues" \u2192 midnight-analyze-contract
|
|
8984
|
+
\u2022 "I'm new to Midnight and want to get started" \u2192 midnight-get-repo-context
|
|
8985
|
+
|
|
8986
|
+
This tool matches your intent against known patterns and suggests the most appropriate tools with confidence levels.
|
|
8987
|
+
|
|
8988
|
+
USAGE GUIDANCE:
|
|
8989
|
+
\u2022 Call once with your intent - no need to call repeatedly
|
|
8990
|
+
\u2022 More specific intents get better matches
|
|
8991
|
+
\u2022 Use the primaryRecommendation for the best match`,
|
|
8992
|
+
inputSchema: {
|
|
8993
|
+
type: "object",
|
|
8994
|
+
properties: {
|
|
8995
|
+
intent: {
|
|
8996
|
+
type: "string",
|
|
8997
|
+
description: "What you want to accomplish (natural language description)"
|
|
8998
|
+
}
|
|
8999
|
+
},
|
|
9000
|
+
required: ["intent"]
|
|
9001
|
+
},
|
|
9002
|
+
outputSchema: suggestToolOutputSchema,
|
|
9003
|
+
annotations: {
|
|
9004
|
+
readOnlyHint: true,
|
|
9005
|
+
idempotentHint: true,
|
|
9006
|
+
title: "\u{1F3AF} Suggest Tool",
|
|
9007
|
+
category: "health"
|
|
9008
|
+
},
|
|
9009
|
+
handler: suggestTool
|
|
8279
9010
|
}
|
|
8280
9011
|
];
|
|
8281
9012
|
setMetaTools(metaTools);
|
|
@@ -8303,4 +9034,4 @@ export {
|
|
|
8303
9034
|
startServer,
|
|
8304
9035
|
startHttpServer
|
|
8305
9036
|
};
|
|
8306
|
-
//# sourceMappingURL=chunk-
|
|
9037
|
+
//# sourceMappingURL=chunk-ZYCQLQEX.js.map
|
package/dist/index.js
CHANGED
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
promptDefinitions,
|
|
10
10
|
startHttpServer,
|
|
11
11
|
startServer
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ZYCQLQEX.js";
|
|
13
13
|
import {
|
|
14
14
|
logger
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-EBFMM2DS.js";
|
|
16
16
|
export {
|
|
17
17
|
allResources,
|
|
18
18
|
allTools,
|
package/package.json
CHANGED