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,300 @@
|
|
|
1
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { McpAddLessonInputSchema, McpDedupLessonInputSchema, McpListFacetsInputSchema, McpPrepareLessonInputSchema, McpSearchErrorInputSchema, McpSearchForProjectInputSchema, McpSearchInputSchema, type McpAddLessonInput, type McpDedupLessonInput, type McpListFacetsInput, type McpPrepareLessonInput, type McpSearchErrorInput, type McpSearchForProjectInput, type McpSearchInput } from './schemas.js';
|
|
3
|
+
export declare const MCP_SEARCH_LIMIT_POLICY: {
|
|
4
|
+
readonly defaultLimit: 5;
|
|
5
|
+
readonly maxLimit: 10;
|
|
6
|
+
};
|
|
7
|
+
export declare const AGENT_RULEBOOK_MCP_TOOL_NAMES: readonly ["rules.search", "rules.search_for_project", "rules.search_error", "rules.list_facets", "rules.dedup_lesson", "rules.prepare_lesson", "rules.add_lesson"];
|
|
8
|
+
export type AgentRulebookMcpToolName = (typeof AGENT_RULEBOOK_MCP_TOOL_NAMES)[number];
|
|
9
|
+
export type AgentRulebookToolContext = {
|
|
10
|
+
rulebookHome: string;
|
|
11
|
+
};
|
|
12
|
+
export type AgentRulebookToolDefinition = {
|
|
13
|
+
name: AgentRulebookMcpToolName;
|
|
14
|
+
title: string;
|
|
15
|
+
description: string;
|
|
16
|
+
inputSchema: typeof McpSearchInputSchema | typeof McpSearchForProjectInputSchema | typeof McpSearchErrorInputSchema | typeof McpDedupLessonInputSchema | typeof McpListFacetsInputSchema | typeof McpPrepareLessonInputSchema | typeof McpAddLessonInputSchema;
|
|
17
|
+
annotations: {
|
|
18
|
+
readOnlyHint: boolean;
|
|
19
|
+
destructiveHint: boolean;
|
|
20
|
+
idempotentHint: boolean;
|
|
21
|
+
openWorldHint: boolean;
|
|
22
|
+
};
|
|
23
|
+
handler: (args: never, context: AgentRulebookToolContext) => Promise<CallToolResult>;
|
|
24
|
+
};
|
|
25
|
+
export declare const AGENT_RULEBOOK_MCP_TOOLS: ({
|
|
26
|
+
name: "rules.search";
|
|
27
|
+
title: string;
|
|
28
|
+
description: string;
|
|
29
|
+
inputSchema: import("zod").ZodObject<{
|
|
30
|
+
query: import("zod").ZodString;
|
|
31
|
+
filters: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
32
|
+
language: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
33
|
+
typescript: "typescript";
|
|
34
|
+
swift: "swift";
|
|
35
|
+
kotlin: "kotlin";
|
|
36
|
+
javascript: "javascript";
|
|
37
|
+
python: "python";
|
|
38
|
+
mcp: "mcp";
|
|
39
|
+
other: "other";
|
|
40
|
+
}>>;
|
|
41
|
+
tools: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
42
|
+
categories: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
43
|
+
platforms: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
44
|
+
}, import("zod/v4/core").$strict>>;
|
|
45
|
+
limit: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
46
|
+
}, import("zod/v4/core").$strict>;
|
|
47
|
+
annotations: {
|
|
48
|
+
readonly readOnlyHint: true;
|
|
49
|
+
readonly destructiveHint: false;
|
|
50
|
+
readonly idempotentHint: true;
|
|
51
|
+
readonly openWorldHint: false;
|
|
52
|
+
};
|
|
53
|
+
handler: typeof handleSearch;
|
|
54
|
+
} | {
|
|
55
|
+
name: "rules.search_for_project";
|
|
56
|
+
title: string;
|
|
57
|
+
description: string;
|
|
58
|
+
inputSchema: import("zod").ZodObject<{
|
|
59
|
+
project_path: import("zod").ZodString;
|
|
60
|
+
task: import("zod").ZodString;
|
|
61
|
+
limit: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
62
|
+
}, import("zod/v4/core").$strict>;
|
|
63
|
+
annotations: {
|
|
64
|
+
readonly readOnlyHint: true;
|
|
65
|
+
readonly destructiveHint: false;
|
|
66
|
+
readonly idempotentHint: true;
|
|
67
|
+
readonly openWorldHint: false;
|
|
68
|
+
};
|
|
69
|
+
handler: typeof handleSearchForProject;
|
|
70
|
+
} | {
|
|
71
|
+
name: "rules.search_error";
|
|
72
|
+
title: string;
|
|
73
|
+
description: string;
|
|
74
|
+
inputSchema: import("zod").ZodObject<{
|
|
75
|
+
error_log: import("zod").ZodString;
|
|
76
|
+
project_path: import("zod").ZodOptional<import("zod").ZodString>;
|
|
77
|
+
limit: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
78
|
+
}, import("zod/v4/core").$strict>;
|
|
79
|
+
annotations: {
|
|
80
|
+
readonly readOnlyHint: true;
|
|
81
|
+
readonly destructiveHint: false;
|
|
82
|
+
readonly idempotentHint: true;
|
|
83
|
+
readonly openWorldHint: false;
|
|
84
|
+
};
|
|
85
|
+
handler: typeof handleSearchError;
|
|
86
|
+
} | {
|
|
87
|
+
name: "rules.list_facets";
|
|
88
|
+
title: string;
|
|
89
|
+
description: string;
|
|
90
|
+
inputSchema: import("zod").ZodObject<{}, import("zod/v4/core").$strict>;
|
|
91
|
+
annotations: {
|
|
92
|
+
readonly readOnlyHint: true;
|
|
93
|
+
readonly destructiveHint: false;
|
|
94
|
+
readonly idempotentHint: true;
|
|
95
|
+
readonly openWorldHint: false;
|
|
96
|
+
};
|
|
97
|
+
handler: typeof handleListFacets;
|
|
98
|
+
} | {
|
|
99
|
+
name: "rules.dedup_lesson";
|
|
100
|
+
title: string;
|
|
101
|
+
description: string;
|
|
102
|
+
inputSchema: import("zod").ZodObject<{
|
|
103
|
+
title: import("zod").ZodString;
|
|
104
|
+
summary: import("zod").ZodOptional<import("zod").ZodString>;
|
|
105
|
+
language: import("zod").ZodEnum<{
|
|
106
|
+
typescript: "typescript";
|
|
107
|
+
swift: "swift";
|
|
108
|
+
kotlin: "kotlin";
|
|
109
|
+
javascript: "javascript";
|
|
110
|
+
python: "python";
|
|
111
|
+
mcp: "mcp";
|
|
112
|
+
other: "other";
|
|
113
|
+
}>;
|
|
114
|
+
platforms: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
115
|
+
tools: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
116
|
+
categories: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
117
|
+
mistake: import("zod").ZodString;
|
|
118
|
+
fix: import("zod").ZodString;
|
|
119
|
+
source_project: import("zod").ZodOptional<import("zod").ZodString>;
|
|
120
|
+
}, import("zod/v4/core").$strict>;
|
|
121
|
+
annotations: {
|
|
122
|
+
readonly readOnlyHint: true;
|
|
123
|
+
readonly destructiveHint: false;
|
|
124
|
+
readonly idempotentHint: true;
|
|
125
|
+
readonly openWorldHint: false;
|
|
126
|
+
};
|
|
127
|
+
handler: typeof handleDedupLesson;
|
|
128
|
+
} | {
|
|
129
|
+
name: "rules.prepare_lesson";
|
|
130
|
+
title: string;
|
|
131
|
+
description: string;
|
|
132
|
+
inputSchema: import("zod").ZodObject<{
|
|
133
|
+
title: import("zod").ZodString;
|
|
134
|
+
summary: import("zod").ZodOptional<import("zod").ZodString>;
|
|
135
|
+
language: import("zod").ZodEnum<{
|
|
136
|
+
typescript: "typescript";
|
|
137
|
+
swift: "swift";
|
|
138
|
+
kotlin: "kotlin";
|
|
139
|
+
javascript: "javascript";
|
|
140
|
+
python: "python";
|
|
141
|
+
mcp: "mcp";
|
|
142
|
+
other: "other";
|
|
143
|
+
}>;
|
|
144
|
+
platforms: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
145
|
+
tools: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
146
|
+
categories: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
147
|
+
mistake: import("zod").ZodString;
|
|
148
|
+
fix: import("zod").ZodString;
|
|
149
|
+
source_project: import("zod").ZodOptional<import("zod").ZodString>;
|
|
150
|
+
rule_scope: import("zod").ZodEnum<{
|
|
151
|
+
shared: "shared";
|
|
152
|
+
project: "project";
|
|
153
|
+
}>;
|
|
154
|
+
project_key: import("zod").ZodOptional<import("zod").ZodString>;
|
|
155
|
+
compatibility: import("zod").ZodObject<{
|
|
156
|
+
scope: import("zod").ZodEnum<{
|
|
157
|
+
unknown: "unknown";
|
|
158
|
+
version_agnostic: "version_agnostic";
|
|
159
|
+
constrained: "constrained";
|
|
160
|
+
}>;
|
|
161
|
+
constraints: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodObject<{
|
|
162
|
+
kind: import("zod").ZodEnum<{
|
|
163
|
+
language: "language";
|
|
164
|
+
sdk: "sdk";
|
|
165
|
+
toolchain: "toolchain";
|
|
166
|
+
framework: "framework";
|
|
167
|
+
runtime: "runtime";
|
|
168
|
+
build_tool: "build_tool";
|
|
169
|
+
platform: "platform";
|
|
170
|
+
}>;
|
|
171
|
+
component: import("zod").ZodString;
|
|
172
|
+
range: import("zod").ZodString;
|
|
173
|
+
}, import("zod/v4/core").$strict>>>;
|
|
174
|
+
verified_with: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodObject<{
|
|
175
|
+
component: import("zod").ZodString;
|
|
176
|
+
version: import("zod").ZodString;
|
|
177
|
+
}, import("zod/v4/core").$strict>>>;
|
|
178
|
+
}, import("zod/v4/core").$strict>;
|
|
179
|
+
criteria: import("zod").ZodObject<{
|
|
180
|
+
debugging_cost: import("zod").ZodEnum<{
|
|
181
|
+
low: "low";
|
|
182
|
+
high: "high";
|
|
183
|
+
}>;
|
|
184
|
+
token_cost: import("zod").ZodEnum<{
|
|
185
|
+
low: "low";
|
|
186
|
+
high: "high";
|
|
187
|
+
}>;
|
|
188
|
+
recurrence_risk: import("zod").ZodEnum<{
|
|
189
|
+
low: "low";
|
|
190
|
+
high: "high";
|
|
191
|
+
}>;
|
|
192
|
+
}, import("zod/v4/core").$strict>;
|
|
193
|
+
verification: import("zod").ZodObject<{
|
|
194
|
+
kind: import("zod").ZodEnum<{
|
|
195
|
+
focused_test: "focused_test";
|
|
196
|
+
integration_test: "integration_test";
|
|
197
|
+
manual_verification: "manual_verification";
|
|
198
|
+
}>;
|
|
199
|
+
evidence: import("zod").ZodString;
|
|
200
|
+
}, import("zod/v4/core").$strict>;
|
|
201
|
+
}, import("zod/v4/core").$strict>;
|
|
202
|
+
annotations: {
|
|
203
|
+
readonly readOnlyHint: true;
|
|
204
|
+
readonly destructiveHint: false;
|
|
205
|
+
readonly idempotentHint: true;
|
|
206
|
+
readonly openWorldHint: false;
|
|
207
|
+
};
|
|
208
|
+
handler: typeof handlePrepareLesson;
|
|
209
|
+
} | {
|
|
210
|
+
name: "rules.add_lesson";
|
|
211
|
+
title: string;
|
|
212
|
+
description: string;
|
|
213
|
+
inputSchema: import("zod").ZodObject<{
|
|
214
|
+
title: import("zod").ZodString;
|
|
215
|
+
summary: import("zod").ZodOptional<import("zod").ZodString>;
|
|
216
|
+
language: import("zod").ZodEnum<{
|
|
217
|
+
typescript: "typescript";
|
|
218
|
+
swift: "swift";
|
|
219
|
+
kotlin: "kotlin";
|
|
220
|
+
javascript: "javascript";
|
|
221
|
+
python: "python";
|
|
222
|
+
mcp: "mcp";
|
|
223
|
+
other: "other";
|
|
224
|
+
}>;
|
|
225
|
+
platforms: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
226
|
+
tools: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
227
|
+
categories: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
228
|
+
mistake: import("zod").ZodString;
|
|
229
|
+
fix: import("zod").ZodString;
|
|
230
|
+
source_project: import("zod").ZodOptional<import("zod").ZodString>;
|
|
231
|
+
rule_scope: import("zod").ZodEnum<{
|
|
232
|
+
shared: "shared";
|
|
233
|
+
project: "project";
|
|
234
|
+
}>;
|
|
235
|
+
project_key: import("zod").ZodOptional<import("zod").ZodString>;
|
|
236
|
+
compatibility: import("zod").ZodObject<{
|
|
237
|
+
scope: import("zod").ZodEnum<{
|
|
238
|
+
unknown: "unknown";
|
|
239
|
+
version_agnostic: "version_agnostic";
|
|
240
|
+
constrained: "constrained";
|
|
241
|
+
}>;
|
|
242
|
+
constraints: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodObject<{
|
|
243
|
+
kind: import("zod").ZodEnum<{
|
|
244
|
+
language: "language";
|
|
245
|
+
sdk: "sdk";
|
|
246
|
+
toolchain: "toolchain";
|
|
247
|
+
framework: "framework";
|
|
248
|
+
runtime: "runtime";
|
|
249
|
+
build_tool: "build_tool";
|
|
250
|
+
platform: "platform";
|
|
251
|
+
}>;
|
|
252
|
+
component: import("zod").ZodString;
|
|
253
|
+
range: import("zod").ZodString;
|
|
254
|
+
}, import("zod/v4/core").$strict>>>;
|
|
255
|
+
verified_with: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodObject<{
|
|
256
|
+
component: import("zod").ZodString;
|
|
257
|
+
version: import("zod").ZodString;
|
|
258
|
+
}, import("zod/v4/core").$strict>>>;
|
|
259
|
+
}, import("zod/v4/core").$strict>;
|
|
260
|
+
criteria: import("zod").ZodObject<{
|
|
261
|
+
debugging_cost: import("zod").ZodEnum<{
|
|
262
|
+
low: "low";
|
|
263
|
+
high: "high";
|
|
264
|
+
}>;
|
|
265
|
+
token_cost: import("zod").ZodEnum<{
|
|
266
|
+
low: "low";
|
|
267
|
+
high: "high";
|
|
268
|
+
}>;
|
|
269
|
+
recurrence_risk: import("zod").ZodEnum<{
|
|
270
|
+
low: "low";
|
|
271
|
+
high: "high";
|
|
272
|
+
}>;
|
|
273
|
+
}, import("zod/v4/core").$strict>;
|
|
274
|
+
verification: import("zod").ZodObject<{
|
|
275
|
+
kind: import("zod").ZodEnum<{
|
|
276
|
+
focused_test: "focused_test";
|
|
277
|
+
integration_test: "integration_test";
|
|
278
|
+
manual_verification: "manual_verification";
|
|
279
|
+
}>;
|
|
280
|
+
evidence: import("zod").ZodString;
|
|
281
|
+
}, import("zod/v4/core").$strict>;
|
|
282
|
+
payload_hash: import("zod").ZodString;
|
|
283
|
+
}, import("zod/v4/core").$strict>;
|
|
284
|
+
annotations: {
|
|
285
|
+
readOnlyHint: false;
|
|
286
|
+
destructiveHint: false;
|
|
287
|
+
idempotentHint: false;
|
|
288
|
+
openWorldHint: false;
|
|
289
|
+
};
|
|
290
|
+
handler: typeof handleAddLesson;
|
|
291
|
+
})[];
|
|
292
|
+
declare function handleSearch(args: McpSearchInput, context: AgentRulebookToolContext): Promise<CallToolResult>;
|
|
293
|
+
declare function handleSearchForProject(args: McpSearchForProjectInput, context: AgentRulebookToolContext): Promise<CallToolResult>;
|
|
294
|
+
declare function handleSearchError(args: McpSearchErrorInput, context: AgentRulebookToolContext): Promise<CallToolResult>;
|
|
295
|
+
declare function handleDedupLesson(args: McpDedupLessonInput, context: AgentRulebookToolContext): Promise<CallToolResult>;
|
|
296
|
+
declare function handleListFacets(args: McpListFacetsInput, context: AgentRulebookToolContext): Promise<CallToolResult>;
|
|
297
|
+
declare function handlePrepareLesson(args: McpPrepareLessonInput, context: AgentRulebookToolContext): Promise<CallToolResult>;
|
|
298
|
+
declare function handleAddLesson(args: McpAddLessonInput, context: AgentRulebookToolContext): Promise<CallToolResult>;
|
|
299
|
+
export declare function notImplementedToolResult(tool: AgentRulebookMcpToolName): CallToolResult;
|
|
300
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { MCP_DEFAULT_SEARCH_LIMIT, MCP_MAX_SEARCH_LIMIT, McpAddLessonInputSchema, McpDedupLessonInputSchema, McpListFacetsInputSchema, McpPrepareLessonInputSchema, McpSearchErrorInputSchema, McpSearchForProjectInputSchema, McpSearchInputSchema, } from './schemas.js';
|
|
2
|
+
import { handleRulesAddLesson } from './rules-add-lesson-tool.js';
|
|
3
|
+
import { handleRulesDedupLesson } from './rules-dedup-lesson-tool.js';
|
|
4
|
+
import { handleRulesListFacets } from './rules-list-facets-tool.js';
|
|
5
|
+
import { handleRulesPrepareLesson } from './rules-prepare-lesson-tool.js';
|
|
6
|
+
import { handleRulesSearchError } from './rules-search-error-tool.js';
|
|
7
|
+
import { handleRulesSearchForProject } from './rules-search-for-project-tool.js';
|
|
8
|
+
import { handleRulesSearch } from './rules-search-tool.js';
|
|
9
|
+
import { jsonToolResult } from './tool-output.js';
|
|
10
|
+
export const MCP_SEARCH_LIMIT_POLICY = {
|
|
11
|
+
defaultLimit: MCP_DEFAULT_SEARCH_LIMIT,
|
|
12
|
+
maxLimit: MCP_MAX_SEARCH_LIMIT,
|
|
13
|
+
};
|
|
14
|
+
export const AGENT_RULEBOOK_MCP_TOOL_NAMES = [
|
|
15
|
+
'rules.search',
|
|
16
|
+
'rules.search_for_project',
|
|
17
|
+
'rules.search_error',
|
|
18
|
+
'rules.list_facets',
|
|
19
|
+
'rules.dedup_lesson',
|
|
20
|
+
'rules.prepare_lesson',
|
|
21
|
+
'rules.add_lesson',
|
|
22
|
+
];
|
|
23
|
+
export const AGENT_RULEBOOK_MCP_TOOLS = [
|
|
24
|
+
{
|
|
25
|
+
name: 'rules.search',
|
|
26
|
+
title: 'Search rules',
|
|
27
|
+
description: 'Search Agent Rulebook rules by natural-language query and optional filters.',
|
|
28
|
+
inputSchema: McpSearchInputSchema,
|
|
29
|
+
annotations: readOnlyAnnotations(),
|
|
30
|
+
handler: handleSearch,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'rules.search_for_project',
|
|
34
|
+
title: 'Search rules for project',
|
|
35
|
+
description: 'Search rules using a project path and task description.',
|
|
36
|
+
inputSchema: McpSearchForProjectInputSchema,
|
|
37
|
+
annotations: readOnlyAnnotations(),
|
|
38
|
+
handler: handleSearchForProject,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'rules.search_error',
|
|
42
|
+
title: 'Search rules for error log',
|
|
43
|
+
description: 'Search rules using a build or test error log.',
|
|
44
|
+
inputSchema: McpSearchErrorInputSchema,
|
|
45
|
+
annotations: readOnlyAnnotations(),
|
|
46
|
+
handler: handleSearchError,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'rules.list_facets',
|
|
50
|
+
title: 'List rule facets',
|
|
51
|
+
description: 'List canonical rule facets, aliases, and indexed counts.',
|
|
52
|
+
inputSchema: McpListFacetsInputSchema,
|
|
53
|
+
annotations: readOnlyAnnotations(),
|
|
54
|
+
handler: handleListFacets,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'rules.dedup_lesson',
|
|
58
|
+
title: 'Deduplicate lesson',
|
|
59
|
+
description: 'Classify a lesson candidate as duplicate, related, or new.',
|
|
60
|
+
inputSchema: McpDedupLessonInputSchema,
|
|
61
|
+
annotations: readOnlyAnnotations(),
|
|
62
|
+
handler: handleDedupLesson,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'rules.prepare_lesson',
|
|
66
|
+
title: 'Prepare lesson rule',
|
|
67
|
+
description: 'Validate, redact, scope, deduplicate, and hash a lesson without writing.',
|
|
68
|
+
inputSchema: McpPrepareLessonInputSchema,
|
|
69
|
+
annotations: readOnlyAnnotations(),
|
|
70
|
+
handler: handlePrepareLesson,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'rules.add_lesson',
|
|
74
|
+
title: 'Append lesson rule',
|
|
75
|
+
description: 'Append an eligible prepared lesson as a new active rule and rebuild the index.',
|
|
76
|
+
inputSchema: McpAddLessonInputSchema,
|
|
77
|
+
annotations: {
|
|
78
|
+
readOnlyHint: false,
|
|
79
|
+
destructiveHint: false,
|
|
80
|
+
idempotentHint: false,
|
|
81
|
+
openWorldHint: false,
|
|
82
|
+
},
|
|
83
|
+
handler: handleAddLesson,
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
async function handleSearch(args, context) {
|
|
87
|
+
return handleRulesSearch(args, context);
|
|
88
|
+
}
|
|
89
|
+
async function handleSearchForProject(args, context) {
|
|
90
|
+
return handleRulesSearchForProject(args, context);
|
|
91
|
+
}
|
|
92
|
+
async function handleSearchError(args, context) {
|
|
93
|
+
return handleRulesSearchError(args, context);
|
|
94
|
+
}
|
|
95
|
+
async function handleDedupLesson(args, context) {
|
|
96
|
+
return handleRulesDedupLesson(args, context);
|
|
97
|
+
}
|
|
98
|
+
async function handleListFacets(args, context) {
|
|
99
|
+
return handleRulesListFacets(args, context);
|
|
100
|
+
}
|
|
101
|
+
async function handlePrepareLesson(args, context) {
|
|
102
|
+
return handleRulesPrepareLesson(args, context);
|
|
103
|
+
}
|
|
104
|
+
async function handleAddLesson(args, context) {
|
|
105
|
+
return handleRulesAddLesson(args, context);
|
|
106
|
+
}
|
|
107
|
+
function readOnlyAnnotations() {
|
|
108
|
+
return {
|
|
109
|
+
readOnlyHint: true,
|
|
110
|
+
destructiveHint: false,
|
|
111
|
+
idempotentHint: true,
|
|
112
|
+
openWorldHint: false,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export function notImplementedToolResult(tool) {
|
|
116
|
+
return jsonToolResult({
|
|
117
|
+
status: 'error',
|
|
118
|
+
code: 'not_implemented',
|
|
119
|
+
tool,
|
|
120
|
+
message: `${tool} is registered but not implemented in this step.`,
|
|
121
|
+
}, true);
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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2BAA2B,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC;AAED,KAAK,UAAU,iBAAiB,CAC9B,IAAyB,EACzB,OAAiC;IAEjC,OAAO,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED,KAAK,UAAU,iBAAiB,CAC9B,IAAyB,EACzB,OAAiC;IAEjC,OAAO,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED,KAAK,UAAU,gBAAgB,CAC7B,IAAwB,EACxB,OAAiC;IAEjC,OAAO,qBAAqB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,KAAK,UAAU,mBAAmB,CAChC,IAA2B,EAC3B,OAAiC;IAEjC,OAAO,wBAAwB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAED,KAAK,UAAU,eAAe,CAC5B,IAAuB,EACvB,OAAiC;IAEjC,OAAO,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,mBAAmB;IAC1B,OAAO;QACL,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,KAAK;KACZ,CAAC;AACb,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,IAA8B;IACrE,OAAO,cAAc,CACnB;QACE,MAAM,EAAE,OAAO;QACf,IAAI,EAAE,iBAAiB;QACvB,IAAI;QACJ,OAAO,EAAE,GAAG,IAAI,kDAAkD;KACnE,EACD,IAAI,CACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { extractLessonCandidatesFromMarkdown } from '../../core/lesson-importer.js';
|
|
2
|
+
import { parseStructuredItems } from './structured-shared.js';
|
|
3
|
+
export const fencedLessonsAdapter = {
|
|
4
|
+
id: 'fenced_lessons_yaml',
|
|
5
|
+
sourceKind: 'project_markdown',
|
|
6
|
+
supports: ({ relativePath, content }) => relativePath.toLowerCase().endsWith('.md') && /^lessons:\s*$/m.test(content),
|
|
7
|
+
parse: ({ content }) => {
|
|
8
|
+
const result = extractLessonCandidatesFromMarkdown(content);
|
|
9
|
+
const enriched = parseStructuredItems(extractLessonsBlock(content), 'lessons');
|
|
10
|
+
const enrichedByLocator = new Map(enriched.candidates.map((candidate) => [candidate.locator, candidate]));
|
|
11
|
+
const skippedIndexes = new Set(result.skipped.map((item) => item.index));
|
|
12
|
+
const sourceItemCount = result.candidates.length + result.skipped.length;
|
|
13
|
+
const candidateIndexes = Array.from({ length: sourceItemCount }, (_, index) => index).filter((index) => !skippedIndexes.has(index));
|
|
14
|
+
return {
|
|
15
|
+
candidates: result.candidates.map((candidate, index) => {
|
|
16
|
+
const locator = `lessons[${candidateIndexes[index] ?? index}]`;
|
|
17
|
+
const metadata = enrichedByLocator.get(locator);
|
|
18
|
+
return {
|
|
19
|
+
locator,
|
|
20
|
+
...candidate,
|
|
21
|
+
...(metadata?.status === undefined ? {} : { status: metadata.status }),
|
|
22
|
+
...(metadata?.superseded_by === undefined
|
|
23
|
+
? {}
|
|
24
|
+
: { superseded_by: metadata.superseded_by }),
|
|
25
|
+
...(metadata?.compatibility === undefined
|
|
26
|
+
? {}
|
|
27
|
+
: { compatibility: metadata.compatibility }),
|
|
28
|
+
};
|
|
29
|
+
}),
|
|
30
|
+
skipped: result.skipped.map((item) => ({
|
|
31
|
+
locator: `lessons[${item.index}]`,
|
|
32
|
+
disposition: 'review_required',
|
|
33
|
+
reason: 'missing_required_fields',
|
|
34
|
+
})),
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
function extractLessonsBlock(source) {
|
|
39
|
+
const lines = source.split(/\r?\n/);
|
|
40
|
+
const startIndex = lines.findIndex((line) => /^lessons:\s*$/.test(line));
|
|
41
|
+
if (startIndex < 0) {
|
|
42
|
+
return '';
|
|
43
|
+
}
|
|
44
|
+
const selected = [lines[startIndex]];
|
|
45
|
+
for (const line of lines.slice(startIndex + 1)) {
|
|
46
|
+
if (line.trim() === '' || /^\s/.test(line)) {
|
|
47
|
+
selected.push(line);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return selected.join('\n');
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=fenced-lessons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fenced-lessons.js","sourceRoot":"","sources":["../../../src/migration/adapters/fenced-lessons.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mCAAmC,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,CAAC,MAAM,oBAAoB,GAAkB;IACjD,EAAE,EAAE,qBAAqB;IACzB,UAAU,EAAE,kBAAkB;IAC9B,QAAQ,EAAE,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,EAAE,CACtC,YAAY,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC;IAC9E,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;QACrB,MAAM,MAAM,GAAG,mCAAmC,CAAC,OAAO,CAAC,CAAC;QAC5D,MAAM,QAAQ,GAAG,oBAAoB,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;QAC/E,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAC/B,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CACvE,CAAC;QACF,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAA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AC,CAAC;gBACrC,OAAO,EAAE,WAAW,IAAI,CAAC,KAAK,GAAG;gBACjC,WAAW,EAAE,iBAA0B;gBACvC,MAAM,EAAE,yBAAyB;aAClC,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,SAAS,mBAAmB,CAAC,MAAc;IACzC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACzE,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,QAAQ,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACrC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC;QAC/C,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3C,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,MAAM;QACR,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { parseStructuredItems, readTopLevelInstructions } from './structured-shared.js';
|
|
2
|
+
export const globalRulesAdapter = {
|
|
3
|
+
id: 'global_rule_pack',
|
|
4
|
+
sourceKind: 'global_rule_pack',
|
|
5
|
+
supports: ({ sourcePath }) => /(?:^|\/)\.codex\/rules(?:\/|$)/.test(sourcePath),
|
|
6
|
+
parse: ({ relativePath, content }) => {
|
|
7
|
+
if (/\.ya?ml$/i.test(relativePath)) {
|
|
8
|
+
const result = parseStructuredItems(content, 'rules');
|
|
9
|
+
return {
|
|
10
|
+
...result,
|
|
11
|
+
skipped: [...result.skipped, ...readTopLevelInstructions(content)],
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
return parseExplicitMarkdownRules(content);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
function parseExplicitMarkdownRules(content) {
|
|
18
|
+
const lines = content.split(/\r?\n/);
|
|
19
|
+
const candidates = [];
|
|
20
|
+
const skipped = [];
|
|
21
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
22
|
+
const heading = /^#{2,6}\s+Rule:\s*(.+)$/i.exec(lines[index] ?? '');
|
|
23
|
+
if (heading !== null) {
|
|
24
|
+
const nextHeadingOffset = lines
|
|
25
|
+
.slice(index + 1)
|
|
26
|
+
.findIndex((line) => /^#{1,6}\s+/.test(line));
|
|
27
|
+
const endIndex = nextHeadingOffset < 0 ? lines.length : index + 1 + nextHeadingOffset;
|
|
28
|
+
const block = lines.slice(index + 1, endIndex);
|
|
29
|
+
const mistake = block.map((line) => /^Mistake:\s*(.+)$/i.exec(line)).find(Boolean)?.[1];
|
|
30
|
+
const fix = block.map((line) => /^Fix:\s*(.+)$/i.exec(line)).find(Boolean)?.[1];
|
|
31
|
+
if (mistake !== undefined && fix !== undefined) {
|
|
32
|
+
candidates.push({
|
|
33
|
+
locator: `lines:${index + 1}-${endIndex}`,
|
|
34
|
+
title: heading[1].trim(),
|
|
35
|
+
categories: ['workflow'],
|
|
36
|
+
mistake: mistake.trim(),
|
|
37
|
+
fix: fix.trim(),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
skipped.push({
|
|
42
|
+
locator: `line:${index + 1}`,
|
|
43
|
+
disposition: 'review_required',
|
|
44
|
+
reason: 'missing_required_fields',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
block.forEach((line, blockIndex) => {
|
|
48
|
+
if (/^\s*-\s+\S/.test(line)) {
|
|
49
|
+
skipped.push({
|
|
50
|
+
locator: `line:${index + blockIndex + 2}`,
|
|
51
|
+
disposition: 'skipped',
|
|
52
|
+
reason: 'non_rule_instruction',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
index = endIndex - 1;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (/^\s*-\s+\S/.test(lines[index] ?? '')) {
|
|
60
|
+
skipped.push({
|
|
61
|
+
locator: `line:${index + 1}`,
|
|
62
|
+
disposition: 'skipped',
|
|
63
|
+
reason: 'non_rule_instruction',
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (candidates.length === 0 && skipped.length === 0) {
|
|
68
|
+
skipped.push({ locator: '$', disposition: 'skipped', reason: 'non_rule_instruction' });
|
|
69
|
+
}
|
|
70
|
+
return { candidates, skipped };
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=global-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-rules.js","sourceRoot":"","sources":["../../../src/migration/adapters/global-rules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAExF,MAAM,CAAC,MAAM,kBAAkB,GAAkB;IAC/C,EAAE,EAAE,kBAAkB;IACtB,UAAU,EAAE,kBAAkB;IAC9B,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,gCAAgC,CAAC,IAAI,CAAC,UAAU,CAAC;IAC/E,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,EAAE;QACnC,IAAI,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;YACnC,MAAM,MAAM,GAAG,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACtD,OAAO;gBACL,GAAG,MAAM;gBACT,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,OAA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,EAAE,SAAkB;gBAC/B,MAAM,EAAE,sBAAsB;aAC/B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,SAAkB,EAAE,MAAM,EAAE,sBAAsB,EAAE,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { fencedLessonsAdapter } from './fenced-lessons.js';
|
|
2
|
+
import { globalRulesAdapter } from './global-rules.js';
|
|
3
|
+
import { markdownLessonsAdapter } from './markdown-lessons.js';
|
|
4
|
+
import { structuredLessonsAdapter } from './structured-lessons.js';
|
|
5
|
+
export function createDefaultSourceAdapters() {
|
|
6
|
+
return [
|
|
7
|
+
globalRulesAdapter,
|
|
8
|
+
fencedLessonsAdapter,
|
|
9
|
+
markdownLessonsAdapter,
|
|
10
|
+
structuredLessonsAdapter,
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/migration/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAGnE,MAAM,UAAU,2BAA2B;IACzC,OAAO;QACL,kBAAkB;QAClB,oBAAoB;QACpB,sBAAsB;QACtB,wBAAwB;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const markdownLessonsAdapter = {
|
|
2
|
+
id: 'dated_markdown_lessons',
|
|
3
|
+
sourceKind: 'project_markdown',
|
|
4
|
+
supports: ({ relativePath }) => relativePath.toLowerCase().endsWith('.md'),
|
|
5
|
+
parse: ({ content }) => {
|
|
6
|
+
const lines = content.split(/\r?\n/);
|
|
7
|
+
const candidates = [];
|
|
8
|
+
const skipped = [];
|
|
9
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
10
|
+
const mistake = /^\s*-\s+\*\*Mistake\*\*:\s*(.+)$/i.exec(lines[index] ?? '');
|
|
11
|
+
if (mistake !== null) {
|
|
12
|
+
const fix = /^\s*-\s+\*\*Fix\*\*:\s*(.+)$/i.exec(lines[index + 1] ?? '');
|
|
13
|
+
if (fix !== null) {
|
|
14
|
+
candidates.push({
|
|
15
|
+
locator: `lines:${index + 1}-${index + 2}`,
|
|
16
|
+
title: mistake[1],
|
|
17
|
+
categories: [],
|
|
18
|
+
mistake: mistake[1],
|
|
19
|
+
fix: fix[1],
|
|
20
|
+
});
|
|
21
|
+
index += 1;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (/^\s*-\s+\S/.test(lines[index] ?? '')) {
|
|
26
|
+
skipped.push({
|
|
27
|
+
locator: `line:${index + 1}`,
|
|
28
|
+
disposition: 'review_required',
|
|
29
|
+
reason: 'ambiguous_prose',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return { candidates, skipped };
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=markdown-lessons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-lessons.js","sourceRoot":"","sources":["../../../src/migration/adapters/markdown-lessons.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,sBAAsB,GAAkB;IACnD,EAAE,EAAE,wBAAwB;IAC5B,UAAU,EAAE,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