@trikhub/mcp 0.2.0 → 0.3.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 +21 -30
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +371 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/analyze.d.ts +9 -0
- package/dist/tools/analyze.d.ts.map +1 -0
- package/dist/tools/analyze.js +173 -0
- package/dist/tools/analyze.js.map +1 -0
- package/dist/tools/design.d.ts +36 -0
- package/dist/tools/design.d.ts.map +1 -0
- package/dist/tools/design.js +188 -0
- package/dist/tools/design.js.map +1 -0
- package/dist/tools/diagnose.d.ts +9 -0
- package/dist/tools/diagnose.d.ts.map +1 -0
- package/dist/tools/diagnose.js +186 -0
- package/dist/tools/diagnose.js.map +1 -0
- package/dist/tools/index.d.ts +7 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +7 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/scaffold.d.ts +42 -0
- package/dist/tools/scaffold.d.ts.map +1 -0
- package/dist/tools/scaffold.js +416 -0
- package/dist/tools/scaffold.js.map +1 -0
- package/dist/tools/types.d.ts +69 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +5 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/validate.d.ts +9 -0
- package/dist/tools/validate.d.ts.map +1 -0
- package/dist/tools/validate.js +179 -0
- package/dist/tools/validate.js.map +1 -0
- package/package.json +2 -3
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* validate_manifest — v2 implementation.
|
|
3
|
+
*
|
|
4
|
+
* Validates a v2 manifest using the @trikhub/manifest validator,
|
|
5
|
+
* reports errors with fix suggestions, and returns quality score.
|
|
6
|
+
*/
|
|
7
|
+
import { validateManifest } from '@trikhub/manifest';
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Error-to-fix mapping
|
|
10
|
+
// ============================================================================
|
|
11
|
+
const FIX_MAP = [
|
|
12
|
+
{
|
|
13
|
+
pattern: /schemaVersion/i,
|
|
14
|
+
fix: 'Set "schemaVersion": 2 at the top level of your manifest.',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
pattern: /agent.*required|required.*agent/i,
|
|
18
|
+
fix: 'Add an "agent" object with "mode" and "domain" fields. Add "handoffDescription" if using conversational mode.',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
pattern: /handoffDescription.*minLength|handoffDescription.*short/i,
|
|
22
|
+
fix: 'Make handoffDescription at least 10 characters. Describe what your trik does clearly for handoff routing.',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
pattern: /handoffDescription.*maxLength|handoffDescription.*long/i,
|
|
26
|
+
fix: 'Keep handoffDescription under 500 characters. Be concise but descriptive.',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
pattern: /mode.*enum/i,
|
|
30
|
+
fix: 'Set agent.mode to "conversational" (for LLM agents) or "tool" (to export native tools).',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
pattern: /domain.*minItems/i,
|
|
34
|
+
fix: 'Add at least one domain tag in agent.domain. Example: ["content curation", "article generation"].',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
pattern: /systemPrompt.*mutually exclusive|systemPromptFile.*mutually exclusive/i,
|
|
38
|
+
fix: 'Use either agent.systemPrompt (inline) or agent.systemPromptFile (path to .md), not both.',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
pattern: /conversational.*requires.*systemPrompt/i,
|
|
42
|
+
fix: 'Conversational mode requires a system prompt. Add agent.systemPrompt or agent.systemPromptFile.',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
pattern: /unconstrained.*string|logSchema.*unconstrained/i,
|
|
46
|
+
fix: 'Add constraints to string fields in logSchema: use enum, format, pattern, or maxLength.',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
pattern: /placeholder.*logSchema|logSchema.*placeholder/i,
|
|
50
|
+
fix: 'Add a logSchema entry for each {{placeholder}} in your logTemplate.',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
pattern: /tool.*mode.*requires.*tools|tools.*required.*tool.*mode/i,
|
|
54
|
+
fix: 'Tool-mode triks must have a "tools" block with inputSchema and outputSchema for each tool.',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
pattern: /inputSchema.*required|outputSchema.*required/i,
|
|
58
|
+
fix: 'Tool-mode tools need both "inputSchema" and "outputSchema". Define the JSON Schema for input and output.',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
pattern: /outputSchema.*unconstrained/i,
|
|
62
|
+
fix: 'Output schema strings must be agent-safe: use enum, pattern, or format. maxLength alone is not sufficient for outputSchema.',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
pattern: /outputTemplate.*required|required.*outputTemplate/i,
|
|
66
|
+
fix: 'Tool-mode tools need an "outputTemplate" with {{placeholders}} for each outputSchema field. Example: "{{status}} ({{resultId}})".',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
pattern: /agent-safe|not agent-safe|maxLength.*not.*agent/i,
|
|
70
|
+
fix: 'outputSchema strings must use enum, format, or pattern — maxLength alone is not agent-safe. If your tool returns free-form text, use conversational mode instead.',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
pattern: /outputTemplate.*placeholder.*outputSchema|placeholder.*not.*outputSchema/i,
|
|
74
|
+
fix: 'Every {{placeholder}} in outputTemplate must match a property in outputSchema. Check for typos.',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
pattern: /entry.*required|entry.*module/i,
|
|
78
|
+
fix: 'Add an "entry" object with "module" (path to compiled file) and "export" (export name).',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
pattern: /id.*pattern/i,
|
|
82
|
+
fix: 'Trik ID must be lowercase alphanumeric with dashes, starting with a letter. Example: "my-trik".',
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
function findFix(message) {
|
|
86
|
+
for (const { pattern, fix } of FIX_MAP) {
|
|
87
|
+
if (pattern.test(message)) {
|
|
88
|
+
return fix;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return 'Check the TrikHub documentation for the correct manifest format.';
|
|
92
|
+
}
|
|
93
|
+
function extractPath(message) {
|
|
94
|
+
// Try to extract a JSON path from the error message
|
|
95
|
+
const pathMatch = message.match(/^([\w./[\]]+):/);
|
|
96
|
+
if (pathMatch) {
|
|
97
|
+
return pathMatch[1];
|
|
98
|
+
}
|
|
99
|
+
// Try to extract from "tools.NAME.logSchema" patterns
|
|
100
|
+
const toolMatch = message.match(/(tools\.\w+(?:\.\w+)*)/);
|
|
101
|
+
if (toolMatch) {
|
|
102
|
+
return toolMatch[1];
|
|
103
|
+
}
|
|
104
|
+
// Try to extract "agent.xxx" patterns
|
|
105
|
+
const agentMatch = message.match(/(agent(?:\.\w+)*)/);
|
|
106
|
+
if (agentMatch) {
|
|
107
|
+
return agentMatch[1];
|
|
108
|
+
}
|
|
109
|
+
return 'manifest';
|
|
110
|
+
}
|
|
111
|
+
// ============================================================================
|
|
112
|
+
// Public API
|
|
113
|
+
// ============================================================================
|
|
114
|
+
export function validateTrikManifest(manifestJson, strict) {
|
|
115
|
+
// 1. Parse JSON
|
|
116
|
+
let manifest;
|
|
117
|
+
try {
|
|
118
|
+
manifest = JSON.parse(manifestJson);
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
return {
|
|
122
|
+
valid: false,
|
|
123
|
+
errors: [
|
|
124
|
+
{
|
|
125
|
+
path: 'manifest.json',
|
|
126
|
+
message: `Invalid JSON: ${e instanceof Error ? e.message : 'parse error'}`,
|
|
127
|
+
fix: 'Fix the JSON syntax. Use a JSON validator or your IDE to find the error.',
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
warnings: [],
|
|
131
|
+
qualityScore: 0,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
// 2. Run v2 validator
|
|
135
|
+
const result = validateManifest(manifest);
|
|
136
|
+
// 3. Convert to MCP tool output format
|
|
137
|
+
const errors = (result.errors || []).map((msg) => ({
|
|
138
|
+
path: extractPath(msg),
|
|
139
|
+
message: msg,
|
|
140
|
+
fix: findFix(msg),
|
|
141
|
+
}));
|
|
142
|
+
const warnings = (result.warnings || []).map((msg) => ({
|
|
143
|
+
path: extractPath(msg),
|
|
144
|
+
message: msg,
|
|
145
|
+
suggestion: findFix(msg),
|
|
146
|
+
}));
|
|
147
|
+
// 4. Add strict-mode warnings
|
|
148
|
+
if (strict && result.valid) {
|
|
149
|
+
const m = manifest;
|
|
150
|
+
if (!m.author) {
|
|
151
|
+
warnings.push({
|
|
152
|
+
path: 'author',
|
|
153
|
+
message: 'Missing optional "author" field.',
|
|
154
|
+
suggestion: 'Add an "author" field with your name or organization.',
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (!m.repository) {
|
|
158
|
+
warnings.push({
|
|
159
|
+
path: 'repository',
|
|
160
|
+
message: 'Missing optional "repository" field.',
|
|
161
|
+
suggestion: 'Add a "repository" field with your git repository URL.',
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
if (!m.license) {
|
|
165
|
+
warnings.push({
|
|
166
|
+
path: 'license',
|
|
167
|
+
message: 'Missing optional "license" field.',
|
|
168
|
+
suggestion: 'Add a "license" field (e.g., "MIT", "Apache-2.0").',
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
valid: result.valid,
|
|
174
|
+
errors,
|
|
175
|
+
warnings,
|
|
176
|
+
qualityScore: result.qualityScore ?? 0,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/tools/validate.ts"],"names":[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C/C,UAAU,EAAE,wDAAwD;aACrE,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YACf,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,mCAAmC;gBAC5C,UAAU,EAAE,oDAAoD;aACjE,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM;QACN,QAAQ;QACR,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,CAAC;KACvC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trikhub/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "MCP server for AI-assisted trik authoring",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -49,8 +49,7 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
51
51
|
"zod": "^3.25.0",
|
|
52
|
-
"@trikhub/manifest": "0.
|
|
53
|
-
"@trikhub/linter": "0.11.0"
|
|
52
|
+
"@trikhub/manifest": "0.12.0"
|
|
54
53
|
},
|
|
55
54
|
"devDependencies": {
|
|
56
55
|
"tsx": "^4.19.0"
|