agent-rulebook 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -0
- package/README.md +66 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/add.d.ts +2 -0
- package/dist/commands/add.js +134 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.js +41 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +17 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mcp.d.ts +2 -0
- package/dist/commands/mcp.js +17 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/migrate.d.ts +2 -0
- package/dist/commands/migrate.js +73 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/output.d.ts +6 -0
- package/dist/commands/output.js +49 -0
- package/dist/commands/output.js.map +1 -0
- package/dist/commands/search.d.ts +2 -0
- package/dist/commands/search.js +57 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/core/compatibility-matcher.d.ts +17 -0
- package/dist/core/compatibility-matcher.js +146 -0
- package/dist/core/compatibility-matcher.js.map +1 -0
- package/dist/core/dedup.d.ts +22 -0
- package/dist/core/dedup.js +54 -0
- package/dist/core/dedup.js.map +1 -0
- package/dist/core/error-signature.d.ts +15 -0
- package/dist/core/error-signature.js +59 -0
- package/dist/core/error-signature.js.map +1 -0
- package/dist/core/facets.d.ts +9 -0
- package/dist/core/facets.js +46 -0
- package/dist/core/facets.js.map +1 -0
- package/dist/core/index.d.ts +30 -0
- package/dist/core/index.js +16 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/lesson-importer.d.ts +22 -0
- package/dist/core/lesson-importer.js +94 -0
- package/dist/core/lesson-importer.js.map +1 -0
- package/dist/core/paths.d.ts +5 -0
- package/dist/core/paths.js +11 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/project-environment-detector.d.ts +43 -0
- package/dist/core/project-environment-detector.js +464 -0
- package/dist/core/project-environment-detector.js.map +1 -0
- package/dist/core/ranker.d.ts +3 -0
- package/dist/core/ranker.js +47 -0
- package/dist/core/ranker.js.map +1 -0
- package/dist/core/redaction.d.ts +35 -0
- package/dist/core/redaction.js +149 -0
- package/dist/core/redaction.js.map +1 -0
- package/dist/core/rule-compatibility.d.ts +66 -0
- package/dist/core/rule-compatibility.js +53 -0
- package/dist/core/rule-compatibility.js.map +1 -0
- package/dist/core/rule-parser.d.ts +25 -0
- package/dist/core/rule-parser.js +81 -0
- package/dist/core/rule-parser.js.map +1 -0
- package/dist/core/rule-schema.d.ts +231 -0
- package/dist/core/rule-schema.js +184 -0
- package/dist/core/rule-schema.js.map +1 -0
- package/dist/core/rule-writer.d.ts +35 -0
- package/dist/core/rule-writer.js +63 -0
- package/dist/core/rule-writer.js.map +1 -0
- package/dist/core/search-types.d.ts +51 -0
- package/dist/core/search-types.js +2 -0
- package/dist/core/search-types.js.map +1 -0
- package/dist/core/slug.d.ts +13 -0
- package/dist/core/slug.js +42 -0
- package/dist/core/slug.js.map +1 -0
- package/dist/core/stack-detector.d.ts +56 -0
- package/dist/core/stack-detector.js +358 -0
- package/dist/core/stack-detector.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.d.ts +7 -0
- package/dist/mcp/index.js +5 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/lesson-capture.d.ts +30 -0
- package/dist/mcp/lesson-capture.js +146 -0
- package/dist/mcp/lesson-capture.js.map +1 -0
- package/dist/mcp/rules-add-lesson-tool.d.ts +4 -0
- package/dist/mcp/rules-add-lesson-tool.js +73 -0
- package/dist/mcp/rules-add-lesson-tool.js.map +1 -0
- package/dist/mcp/rules-dedup-lesson-tool.d.ts +4 -0
- package/dist/mcp/rules-dedup-lesson-tool.js +69 -0
- package/dist/mcp/rules-dedup-lesson-tool.js.map +1 -0
- package/dist/mcp/rules-list-facets-tool.d.ts +3 -0
- package/dist/mcp/rules-list-facets-tool.js +31 -0
- package/dist/mcp/rules-list-facets-tool.js.map +1 -0
- package/dist/mcp/rules-prepare-lesson-tool.d.ts +4 -0
- package/dist/mcp/rules-prepare-lesson-tool.js +7 -0
- package/dist/mcp/rules-prepare-lesson-tool.js.map +1 -0
- package/dist/mcp/rules-search-error-tool.d.ts +4 -0
- package/dist/mcp/rules-search-error-tool.js +99 -0
- package/dist/mcp/rules-search-error-tool.js.map +1 -0
- package/dist/mcp/rules-search-for-project-tool.d.ts +4 -0
- package/dist/mcp/rules-search-for-project-tool.js +103 -0
- package/dist/mcp/rules-search-for-project-tool.js.map +1 -0
- package/dist/mcp/rules-search-tool.d.ts +7 -0
- package/dist/mcp/rules-search-tool.js +65 -0
- package/dist/mcp/rules-search-tool.js.map +1 -0
- package/dist/mcp/schemas.d.ts +222 -0
- package/dist/mcp/schemas.js +99 -0
- package/dist/mcp/schemas.js.map +1 -0
- package/dist/mcp/server.d.ts +5 -0
- package/dist/mcp/server.js +29 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tool-output.d.ts +32 -0
- package/dist/mcp/tool-output.js +74 -0
- package/dist/mcp/tool-output.js.map +1 -0
- package/dist/mcp/tools.d.ts +300 -0
- package/dist/mcp/tools.js +123 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/migration/adapters/fenced-lessons.d.ts +2 -0
- package/dist/migration/adapters/fenced-lessons.js +55 -0
- package/dist/migration/adapters/fenced-lessons.js.map +1 -0
- package/dist/migration/adapters/global-rules.d.ts +2 -0
- package/dist/migration/adapters/global-rules.js +72 -0
- package/dist/migration/adapters/global-rules.js.map +1 -0
- package/dist/migration/adapters/index.d.ts +2 -0
- package/dist/migration/adapters/index.js +13 -0
- package/dist/migration/adapters/index.js.map +1 -0
- package/dist/migration/adapters/markdown-lessons.d.ts +2 -0
- package/dist/migration/adapters/markdown-lessons.js +36 -0
- package/dist/migration/adapters/markdown-lessons.js.map +1 -0
- package/dist/migration/adapters/structured-lessons.d.ts +2 -0
- package/dist/migration/adapters/structured-lessons.js +8 -0
- package/dist/migration/adapters/structured-lessons.js.map +1 -0
- package/dist/migration/adapters/structured-shared.d.ts +3 -0
- package/dist/migration/adapters/structured-shared.js +97 -0
- package/dist/migration/adapters/structured-shared.js.map +1 -0
- package/dist/migration/applier.d.ts +32 -0
- package/dist/migration/applier.js +469 -0
- package/dist/migration/applier.js.map +1 -0
- package/dist/migration/index.d.ts +11 -0
- package/dist/migration/index.js +7 -0
- package/dist/migration/index.js.map +1 -0
- package/dist/migration/manifest.d.ts +262 -0
- package/dist/migration/manifest.js +89 -0
- package/dist/migration/manifest.js.map +1 -0
- package/dist/migration/migration-report.d.ts +147 -0
- package/dist/migration/migration-report.js +81 -0
- package/dist/migration/migration-report.js.map +1 -0
- package/dist/migration/scanner.d.ts +2 -0
- package/dist/migration/scanner.js +314 -0
- package/dist/migration/scanner.js.map +1 -0
- package/dist/migration/source-adapter.d.ts +37 -0
- package/dist/migration/source-adapter.js +2 -0
- package/dist/migration/source-adapter.js.map +1 -0
- package/dist/migration/verifier.d.ts +5 -0
- package/dist/migration/verifier.js +217 -0
- package/dist/migration/verifier.js.map +1 -0
- package/dist/program.d.ts +2 -0
- package/dist/program.js +21 -0
- package/dist/program.js.map +1 -0
- package/dist/storage/index-check.d.ts +19 -0
- package/dist/storage/index-check.js +114 -0
- package/dist/storage/index-check.js.map +1 -0
- package/dist/storage/index.d.ts +15 -0
- package/dist/storage/index.js +9 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/indexer.d.ts +19 -0
- package/dist/storage/indexer.js +354 -0
- package/dist/storage/indexer.js.map +1 -0
- package/dist/storage/migrations.d.ts +3 -0
- package/dist/storage/migrations.js +110 -0
- package/dist/storage/migrations.js.map +1 -0
- package/dist/storage/rule-discovery.d.ts +4 -0
- package/dist/storage/rule-discovery.js +34 -0
- package/dist/storage/rule-discovery.js.map +1 -0
- package/dist/storage/rule-store.d.ts +10 -0
- package/dist/storage/rule-store.js +12 -0
- package/dist/storage/rule-store.js.map +1 -0
- package/dist/storage/rulebook-home.d.ts +21 -0
- package/dist/storage/rulebook-home.js +75 -0
- package/dist/storage/rulebook-home.js.map +1 -0
- package/dist/storage/search-service.d.ts +17 -0
- package/dist/storage/search-service.js +252 -0
- package/dist/storage/search-service.js.map +1 -0
- package/dist/storage/sqlite-errors.d.ts +26 -0
- package/dist/storage/sqlite-errors.js +55 -0
- package/dist/storage/sqlite-errors.js.map +1 -0
- package/dist/storage/sqlite.d.ts +13 -0
- package/dist/storage/sqlite.js +34 -0
- package/dist/storage/sqlite.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
export declare const MCP_DEFAULT_SEARCH_LIMIT = 5;
|
|
3
|
+
export declare const MCP_MAX_SEARCH_LIMIT = 10;
|
|
4
|
+
export declare const McpRuleLanguageSchema: z.ZodEnum<{
|
|
5
|
+
typescript: "typescript";
|
|
6
|
+
swift: "swift";
|
|
7
|
+
kotlin: "kotlin";
|
|
8
|
+
javascript: "javascript";
|
|
9
|
+
python: "python";
|
|
10
|
+
mcp: "mcp";
|
|
11
|
+
other: "other";
|
|
12
|
+
}>;
|
|
13
|
+
export declare const McpSearchFiltersSchema: z.ZodObject<{
|
|
14
|
+
language: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
typescript: "typescript";
|
|
16
|
+
swift: "swift";
|
|
17
|
+
kotlin: "kotlin";
|
|
18
|
+
javascript: "javascript";
|
|
19
|
+
python: "python";
|
|
20
|
+
mcp: "mcp";
|
|
21
|
+
other: "other";
|
|
22
|
+
}>>;
|
|
23
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
24
|
+
categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
25
|
+
platforms: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
26
|
+
}, z.core.$strict>;
|
|
27
|
+
export declare const McpSearchInputSchema: z.ZodObject<{
|
|
28
|
+
query: z.ZodString;
|
|
29
|
+
filters: z.ZodOptional<z.ZodObject<{
|
|
30
|
+
language: z.ZodOptional<z.ZodEnum<{
|
|
31
|
+
typescript: "typescript";
|
|
32
|
+
swift: "swift";
|
|
33
|
+
kotlin: "kotlin";
|
|
34
|
+
javascript: "javascript";
|
|
35
|
+
python: "python";
|
|
36
|
+
mcp: "mcp";
|
|
37
|
+
other: "other";
|
|
38
|
+
}>>;
|
|
39
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
40
|
+
categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
41
|
+
platforms: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
+
}, z.core.$strict>>;
|
|
43
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
}, z.core.$strict>;
|
|
45
|
+
export declare const McpSearchForProjectInputSchema: z.ZodObject<{
|
|
46
|
+
project_path: z.ZodString;
|
|
47
|
+
task: z.ZodString;
|
|
48
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
}, z.core.$strict>;
|
|
50
|
+
export declare const McpSearchErrorInputSchema: z.ZodObject<{
|
|
51
|
+
error_log: z.ZodString;
|
|
52
|
+
project_path: z.ZodOptional<z.ZodString>;
|
|
53
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
}, z.core.$strict>;
|
|
55
|
+
export declare const McpDedupLessonInputSchema: z.ZodObject<{
|
|
56
|
+
title: z.ZodString;
|
|
57
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
58
|
+
language: z.ZodEnum<{
|
|
59
|
+
typescript: "typescript";
|
|
60
|
+
swift: "swift";
|
|
61
|
+
kotlin: "kotlin";
|
|
62
|
+
javascript: "javascript";
|
|
63
|
+
python: "python";
|
|
64
|
+
mcp: "mcp";
|
|
65
|
+
other: "other";
|
|
66
|
+
}>;
|
|
67
|
+
platforms: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
68
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
|
+
categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
70
|
+
mistake: z.ZodString;
|
|
71
|
+
fix: z.ZodString;
|
|
72
|
+
source_project: z.ZodOptional<z.ZodString>;
|
|
73
|
+
}, z.core.$strict>;
|
|
74
|
+
export declare const McpPrepareLessonInputSchema: z.ZodObject<{
|
|
75
|
+
title: z.ZodString;
|
|
76
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
77
|
+
language: z.ZodEnum<{
|
|
78
|
+
typescript: "typescript";
|
|
79
|
+
swift: "swift";
|
|
80
|
+
kotlin: "kotlin";
|
|
81
|
+
javascript: "javascript";
|
|
82
|
+
python: "python";
|
|
83
|
+
mcp: "mcp";
|
|
84
|
+
other: "other";
|
|
85
|
+
}>;
|
|
86
|
+
platforms: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
87
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
88
|
+
categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
89
|
+
mistake: z.ZodString;
|
|
90
|
+
fix: z.ZodString;
|
|
91
|
+
source_project: z.ZodOptional<z.ZodString>;
|
|
92
|
+
rule_scope: z.ZodEnum<{
|
|
93
|
+
shared: "shared";
|
|
94
|
+
project: "project";
|
|
95
|
+
}>;
|
|
96
|
+
project_key: z.ZodOptional<z.ZodString>;
|
|
97
|
+
compatibility: z.ZodObject<{
|
|
98
|
+
scope: z.ZodEnum<{
|
|
99
|
+
unknown: "unknown";
|
|
100
|
+
version_agnostic: "version_agnostic";
|
|
101
|
+
constrained: "constrained";
|
|
102
|
+
}>;
|
|
103
|
+
constraints: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
104
|
+
kind: z.ZodEnum<{
|
|
105
|
+
language: "language";
|
|
106
|
+
sdk: "sdk";
|
|
107
|
+
toolchain: "toolchain";
|
|
108
|
+
framework: "framework";
|
|
109
|
+
runtime: "runtime";
|
|
110
|
+
build_tool: "build_tool";
|
|
111
|
+
platform: "platform";
|
|
112
|
+
}>;
|
|
113
|
+
component: z.ZodString;
|
|
114
|
+
range: z.ZodString;
|
|
115
|
+
}, z.core.$strict>>>;
|
|
116
|
+
verified_with: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
117
|
+
component: z.ZodString;
|
|
118
|
+
version: z.ZodString;
|
|
119
|
+
}, z.core.$strict>>>;
|
|
120
|
+
}, z.core.$strict>;
|
|
121
|
+
criteria: z.ZodObject<{
|
|
122
|
+
debugging_cost: z.ZodEnum<{
|
|
123
|
+
low: "low";
|
|
124
|
+
high: "high";
|
|
125
|
+
}>;
|
|
126
|
+
token_cost: z.ZodEnum<{
|
|
127
|
+
low: "low";
|
|
128
|
+
high: "high";
|
|
129
|
+
}>;
|
|
130
|
+
recurrence_risk: z.ZodEnum<{
|
|
131
|
+
low: "low";
|
|
132
|
+
high: "high";
|
|
133
|
+
}>;
|
|
134
|
+
}, z.core.$strict>;
|
|
135
|
+
verification: z.ZodObject<{
|
|
136
|
+
kind: z.ZodEnum<{
|
|
137
|
+
focused_test: "focused_test";
|
|
138
|
+
integration_test: "integration_test";
|
|
139
|
+
manual_verification: "manual_verification";
|
|
140
|
+
}>;
|
|
141
|
+
evidence: z.ZodString;
|
|
142
|
+
}, z.core.$strict>;
|
|
143
|
+
}, z.core.$strict>;
|
|
144
|
+
export declare const McpAddLessonInputSchema: z.ZodObject<{
|
|
145
|
+
title: z.ZodString;
|
|
146
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
147
|
+
language: z.ZodEnum<{
|
|
148
|
+
typescript: "typescript";
|
|
149
|
+
swift: "swift";
|
|
150
|
+
kotlin: "kotlin";
|
|
151
|
+
javascript: "javascript";
|
|
152
|
+
python: "python";
|
|
153
|
+
mcp: "mcp";
|
|
154
|
+
other: "other";
|
|
155
|
+
}>;
|
|
156
|
+
platforms: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
157
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
158
|
+
categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
159
|
+
mistake: z.ZodString;
|
|
160
|
+
fix: z.ZodString;
|
|
161
|
+
source_project: z.ZodOptional<z.ZodString>;
|
|
162
|
+
rule_scope: z.ZodEnum<{
|
|
163
|
+
shared: "shared";
|
|
164
|
+
project: "project";
|
|
165
|
+
}>;
|
|
166
|
+
project_key: z.ZodOptional<z.ZodString>;
|
|
167
|
+
compatibility: z.ZodObject<{
|
|
168
|
+
scope: z.ZodEnum<{
|
|
169
|
+
unknown: "unknown";
|
|
170
|
+
version_agnostic: "version_agnostic";
|
|
171
|
+
constrained: "constrained";
|
|
172
|
+
}>;
|
|
173
|
+
constraints: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
174
|
+
kind: z.ZodEnum<{
|
|
175
|
+
language: "language";
|
|
176
|
+
sdk: "sdk";
|
|
177
|
+
toolchain: "toolchain";
|
|
178
|
+
framework: "framework";
|
|
179
|
+
runtime: "runtime";
|
|
180
|
+
build_tool: "build_tool";
|
|
181
|
+
platform: "platform";
|
|
182
|
+
}>;
|
|
183
|
+
component: z.ZodString;
|
|
184
|
+
range: z.ZodString;
|
|
185
|
+
}, z.core.$strict>>>;
|
|
186
|
+
verified_with: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
187
|
+
component: z.ZodString;
|
|
188
|
+
version: z.ZodString;
|
|
189
|
+
}, z.core.$strict>>>;
|
|
190
|
+
}, z.core.$strict>;
|
|
191
|
+
criteria: z.ZodObject<{
|
|
192
|
+
debugging_cost: z.ZodEnum<{
|
|
193
|
+
low: "low";
|
|
194
|
+
high: "high";
|
|
195
|
+
}>;
|
|
196
|
+
token_cost: z.ZodEnum<{
|
|
197
|
+
low: "low";
|
|
198
|
+
high: "high";
|
|
199
|
+
}>;
|
|
200
|
+
recurrence_risk: z.ZodEnum<{
|
|
201
|
+
low: "low";
|
|
202
|
+
high: "high";
|
|
203
|
+
}>;
|
|
204
|
+
}, z.core.$strict>;
|
|
205
|
+
verification: z.ZodObject<{
|
|
206
|
+
kind: z.ZodEnum<{
|
|
207
|
+
focused_test: "focused_test";
|
|
208
|
+
integration_test: "integration_test";
|
|
209
|
+
manual_verification: "manual_verification";
|
|
210
|
+
}>;
|
|
211
|
+
evidence: z.ZodString;
|
|
212
|
+
}, z.core.$strict>;
|
|
213
|
+
payload_hash: z.ZodString;
|
|
214
|
+
}, z.core.$strict>;
|
|
215
|
+
export declare const McpListFacetsInputSchema: z.ZodObject<{}, z.core.$strict>;
|
|
216
|
+
export type McpSearchInput = z.infer<typeof McpSearchInputSchema>;
|
|
217
|
+
export type McpSearchForProjectInput = z.infer<typeof McpSearchForProjectInputSchema>;
|
|
218
|
+
export type McpSearchErrorInput = z.infer<typeof McpSearchErrorInputSchema>;
|
|
219
|
+
export type McpPrepareLessonInput = z.infer<typeof McpPrepareLessonInputSchema>;
|
|
220
|
+
export type McpAddLessonInput = z.infer<typeof McpAddLessonInputSchema>;
|
|
221
|
+
export type McpListFacetsInput = z.infer<typeof McpListFacetsInputSchema>;
|
|
222
|
+
export type McpDedupLessonInput = z.infer<typeof McpDedupLessonInputSchema>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
export const MCP_DEFAULT_SEARCH_LIMIT = 5;
|
|
3
|
+
export const MCP_MAX_SEARCH_LIMIT = 10;
|
|
4
|
+
export const McpRuleLanguageSchema = z.enum([
|
|
5
|
+
'swift',
|
|
6
|
+
'kotlin',
|
|
7
|
+
'typescript',
|
|
8
|
+
'javascript',
|
|
9
|
+
'python',
|
|
10
|
+
'mcp',
|
|
11
|
+
'other',
|
|
12
|
+
]);
|
|
13
|
+
export const McpSearchFiltersSchema = z
|
|
14
|
+
.object({
|
|
15
|
+
language: McpRuleLanguageSchema.optional(),
|
|
16
|
+
tools: z.array(z.string().min(1)).optional(),
|
|
17
|
+
categories: z.array(z.string().min(1)).optional(),
|
|
18
|
+
platforms: z.array(z.string().min(1)).optional(),
|
|
19
|
+
})
|
|
20
|
+
.strict();
|
|
21
|
+
const McpLimitSchema = z.number().int().min(1).max(MCP_MAX_SEARCH_LIMIT).optional();
|
|
22
|
+
export const McpSearchInputSchema = z
|
|
23
|
+
.object({
|
|
24
|
+
query: z.string().trim().min(1),
|
|
25
|
+
filters: McpSearchFiltersSchema.optional(),
|
|
26
|
+
limit: McpLimitSchema,
|
|
27
|
+
})
|
|
28
|
+
.strict();
|
|
29
|
+
export const McpSearchForProjectInputSchema = z
|
|
30
|
+
.object({
|
|
31
|
+
project_path: z.string().trim().min(1),
|
|
32
|
+
task: z.string().trim().min(1),
|
|
33
|
+
limit: McpLimitSchema,
|
|
34
|
+
})
|
|
35
|
+
.strict();
|
|
36
|
+
export const McpSearchErrorInputSchema = z
|
|
37
|
+
.object({
|
|
38
|
+
error_log: z.string().trim().min(1),
|
|
39
|
+
project_path: z.string().trim().min(1).optional(),
|
|
40
|
+
limit: McpLimitSchema,
|
|
41
|
+
})
|
|
42
|
+
.strict();
|
|
43
|
+
const McpLessonBaseInputSchema = z
|
|
44
|
+
.object({
|
|
45
|
+
title: z.string().trim().min(1),
|
|
46
|
+
summary: z.string().trim().min(1).optional(),
|
|
47
|
+
language: McpRuleLanguageSchema,
|
|
48
|
+
platforms: z.array(z.string().min(1)).optional(),
|
|
49
|
+
tools: z.array(z.string().min(1)).optional(),
|
|
50
|
+
categories: z.array(z.string().min(1)).optional(),
|
|
51
|
+
mistake: z.string().trim().min(1),
|
|
52
|
+
fix: z.string().trim().min(1),
|
|
53
|
+
source_project: z.string().trim().min(1).optional(),
|
|
54
|
+
})
|
|
55
|
+
.strict();
|
|
56
|
+
export const McpDedupLessonInputSchema = McpLessonBaseInputSchema;
|
|
57
|
+
const McpCaptureCriteriaSchema = z.object({
|
|
58
|
+
debugging_cost: z.enum(['low', 'high']),
|
|
59
|
+
token_cost: z.enum(['low', 'high']),
|
|
60
|
+
recurrence_risk: z.enum(['low', 'high']),
|
|
61
|
+
}).strict();
|
|
62
|
+
const McpVerificationSchema = z.object({
|
|
63
|
+
kind: z.enum(['focused_test', 'integration_test', 'manual_verification']),
|
|
64
|
+
evidence: z.string().trim().min(1),
|
|
65
|
+
}).strict();
|
|
66
|
+
const McpCompatibilitySchema = z.object({
|
|
67
|
+
scope: z.enum(['version_agnostic', 'constrained', 'unknown']),
|
|
68
|
+
constraints: z.array(z.object({
|
|
69
|
+
kind: z.enum(['language', 'sdk', 'toolchain', 'framework', 'runtime', 'build_tool', 'platform']),
|
|
70
|
+
component: z.string().trim().min(1),
|
|
71
|
+
range: z.string().trim().min(1),
|
|
72
|
+
}).strict()).default([]),
|
|
73
|
+
verified_with: z.array(z.object({
|
|
74
|
+
component: z.string().trim().min(1),
|
|
75
|
+
version: z.string().trim().min(1),
|
|
76
|
+
}).strict()).default([]),
|
|
77
|
+
}).strict();
|
|
78
|
+
export const McpPrepareLessonInputSchema = McpLessonBaseInputSchema.extend({
|
|
79
|
+
rule_scope: z.enum(['shared', 'project']),
|
|
80
|
+
project_key: z.string().trim().regex(/^[a-z0-9][a-z0-9._-]*$/).optional(),
|
|
81
|
+
compatibility: McpCompatibilitySchema,
|
|
82
|
+
criteria: McpCaptureCriteriaSchema,
|
|
83
|
+
verification: McpVerificationSchema,
|
|
84
|
+
}).strict().superRefine((input, context) => {
|
|
85
|
+
if (input.rule_scope === 'project' && input.project_key === undefined) {
|
|
86
|
+
context.addIssue({ code: 'custom', path: ['project_key'], message: 'Project scope requires project_key' });
|
|
87
|
+
}
|
|
88
|
+
if (input.rule_scope === 'shared' && input.project_key !== undefined) {
|
|
89
|
+
context.addIssue({ code: 'custom', path: ['project_key'], message: 'Shared scope cannot include project_key' });
|
|
90
|
+
}
|
|
91
|
+
if (input.compatibility.scope === 'constrained' && input.compatibility.constraints.length === 0) {
|
|
92
|
+
context.addIssue({ code: 'custom', path: ['compatibility', 'constraints'], message: 'Constrained compatibility requires constraints' });
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
export const McpAddLessonInputSchema = McpPrepareLessonInputSchema.safeExtend({
|
|
96
|
+
payload_hash: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
97
|
+
});
|
|
98
|
+
export const McpListFacetsInputSchema = z.object({}).strict();
|
|
99
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/mcp/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAC1C,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEvC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC1C,OAAO;IACP,QAAQ;IACR,YAAY;IACZ,YAAY;IACZ,QAAQ;IACR,KAAK;IACL,OAAO;CACR,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC;KACpC,MAAM,CAAC;IACN,QAAQ,EAAE,qBAAqB,CAAC,QAAQ,EAAE;IAC1C,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC5C,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACjD,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACjD,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,cAAc,GAAG,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BAAuB,CAAC;CACxD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { AGENT_RULEBOOK_MCP_TOOLS, } from './tools.js';
|
|
3
|
+
import { toolErrorResult } from './tool-output.js';
|
|
4
|
+
export function createAgentRulebookMcpServer(options) {
|
|
5
|
+
const server = new McpServer({
|
|
6
|
+
name: 'agent-rulebook',
|
|
7
|
+
version: '0.0.0',
|
|
8
|
+
});
|
|
9
|
+
const context = {
|
|
10
|
+
rulebookHome: options.rulebookHome,
|
|
11
|
+
};
|
|
12
|
+
for (const tool of AGENT_RULEBOOK_MCP_TOOLS) {
|
|
13
|
+
server.registerTool(tool.name, {
|
|
14
|
+
title: tool.title,
|
|
15
|
+
description: tool.description,
|
|
16
|
+
inputSchema: tool.inputSchema,
|
|
17
|
+
annotations: tool.annotations,
|
|
18
|
+
}, async (args) => {
|
|
19
|
+
try {
|
|
20
|
+
return await tool.handler(args, context);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
return toolErrorResult(error);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return server;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EACL,wBAAwB,GAEzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMnD,MAAM,UAAU,4BAA4B,CAC1C,OAA4C;IAE5C,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;IACH,MAAM,OAAO,GAA6B;QACxC,YAAY,EAAE,OAAO,CAAC,YAAY;KACnC,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,wBAAwB,EAAE,CAAC;QAC5C,MAAM,CAAC,YAAY,CACjB,IAAI,CAAC,IAAI,EACT;YACE,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,EACD,KAAK,EAAE,IAAa,EAAE,EAAE;YACtB,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAa,EAAE,OAAO,CAAC,CAAC;YACpD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import type { SearchFilters, SearchResult } from '../core/index.js';
|
|
3
|
+
export type ToolOutputWarning = {
|
|
4
|
+
code: string;
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
export type CompactRuleOutput = {
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
summary: string;
|
|
11
|
+
fix: string;
|
|
12
|
+
path: string;
|
|
13
|
+
confidence: SearchResult['confidence'];
|
|
14
|
+
status: SearchResult['status'];
|
|
15
|
+
applicability: SearchResult['applicability'];
|
|
16
|
+
compatibility_evidence: string[];
|
|
17
|
+
reason: string;
|
|
18
|
+
warnings: ToolOutputWarning[];
|
|
19
|
+
};
|
|
20
|
+
export declare function jsonToolResult(payload: Record<string, unknown>, isError?: boolean): CallToolResult;
|
|
21
|
+
export declare function toolErrorResult(error: unknown): CallToolResult;
|
|
22
|
+
export declare function toCompactRuleOutputs(results: SearchResult[], queryText: string): CompactRuleOutput[];
|
|
23
|
+
export declare function noResultsWarning(hint: string | undefined): ToolOutputWarning;
|
|
24
|
+
export type IndexMissingToolResultOptions = {
|
|
25
|
+
indexPath: string;
|
|
26
|
+
queryText: string;
|
|
27
|
+
filters: SearchFilters;
|
|
28
|
+
stackHints: string[];
|
|
29
|
+
limit: number;
|
|
30
|
+
projectPath?: string;
|
|
31
|
+
};
|
|
32
|
+
export declare function indexMissingToolResult(options: IndexMissingToolResultOptions): CallToolResult;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export function jsonToolResult(payload, isError = false) {
|
|
2
|
+
return {
|
|
3
|
+
content: [
|
|
4
|
+
{
|
|
5
|
+
type: 'text',
|
|
6
|
+
text: JSON.stringify(payload),
|
|
7
|
+
},
|
|
8
|
+
],
|
|
9
|
+
isError,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function toolErrorResult(error) {
|
|
13
|
+
const candidate = error;
|
|
14
|
+
const message = typeof candidate.message === 'string' ? candidate.message : 'MCP tool failed.';
|
|
15
|
+
const code = candidate.name === 'RulebookIndexLockTimeoutError' ? 'index_lock_timeout'
|
|
16
|
+
: candidate.name === 'RulebookIndexMigrationError' ? 'index_migration_failed'
|
|
17
|
+
: candidate.name === 'RulebookIndexCorruptError' ? 'index_corrupt'
|
|
18
|
+
: /fts5/i.test(message) ? 'fts5_unavailable'
|
|
19
|
+
: candidate.code === 'EEXIST' ? 'rule_already_exists'
|
|
20
|
+
: 'service_error';
|
|
21
|
+
return jsonToolResult({ status: 'error', code, message }, true);
|
|
22
|
+
}
|
|
23
|
+
export function toCompactRuleOutputs(results, queryText) {
|
|
24
|
+
return results.map((result) => ({
|
|
25
|
+
id: result.id,
|
|
26
|
+
title: result.title,
|
|
27
|
+
summary: result.summary,
|
|
28
|
+
fix: result.fix,
|
|
29
|
+
path: result.path,
|
|
30
|
+
confidence: result.confidence,
|
|
31
|
+
status: result.status,
|
|
32
|
+
applicability: result.applicability,
|
|
33
|
+
compatibility_evidence: result.compatibilityEvidence,
|
|
34
|
+
reason: `Matched search query: ${queryText}; applicability: ${result.applicabilityReason}`,
|
|
35
|
+
warnings: result.warnings,
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
export function noResultsWarning(hint) {
|
|
39
|
+
return {
|
|
40
|
+
code: 'no_results',
|
|
41
|
+
message: hint ?? 'No results. Try removing filters or broadening the query.',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export function indexMissingToolResult(options) {
|
|
45
|
+
const message = `Rulebook index is missing at ${options.indexPath}. Run agent-rulebook index rebuild first.`;
|
|
46
|
+
const payload = {
|
|
47
|
+
status: 'error',
|
|
48
|
+
code: 'index_missing',
|
|
49
|
+
message,
|
|
50
|
+
rules: [],
|
|
51
|
+
query_used: {
|
|
52
|
+
text: options.queryText,
|
|
53
|
+
filters: options.filters,
|
|
54
|
+
},
|
|
55
|
+
applied: {
|
|
56
|
+
status: ['active'],
|
|
57
|
+
scope: options.projectPath === undefined ? 'shared_and_project' : 'project_context',
|
|
58
|
+
environment: [],
|
|
59
|
+
},
|
|
60
|
+
stack_hints: options.stackHints,
|
|
61
|
+
warnings: [
|
|
62
|
+
{
|
|
63
|
+
code: 'index_missing',
|
|
64
|
+
message: `Rulebook index is missing at ${options.indexPath}.`,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
limit: options.limit,
|
|
68
|
+
};
|
|
69
|
+
if (options.projectPath !== undefined) {
|
|
70
|
+
payload.project_path = options.projectPath;
|
|
71
|
+
}
|
|
72
|
+
return jsonToolResult(payload, true);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=tool-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-output.js","sourceRoot":"","sources":["../../src/mc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