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.
Files changed (192) hide show
  1. package/LICENSE +4 -0
  2. package/README.md +66 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +4 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/commands/add.d.ts +2 -0
  7. package/dist/commands/add.js +134 -0
  8. package/dist/commands/add.js.map +1 -0
  9. package/dist/commands/index.d.ts +3 -0
  10. package/dist/commands/index.js +41 -0
  11. package/dist/commands/index.js.map +1 -0
  12. package/dist/commands/init.d.ts +2 -0
  13. package/dist/commands/init.js +17 -0
  14. package/dist/commands/init.js.map +1 -0
  15. package/dist/commands/mcp.d.ts +2 -0
  16. package/dist/commands/mcp.js +17 -0
  17. package/dist/commands/mcp.js.map +1 -0
  18. package/dist/commands/migrate.d.ts +2 -0
  19. package/dist/commands/migrate.js +73 -0
  20. package/dist/commands/migrate.js.map +1 -0
  21. package/dist/commands/output.d.ts +6 -0
  22. package/dist/commands/output.js +49 -0
  23. package/dist/commands/output.js.map +1 -0
  24. package/dist/commands/search.d.ts +2 -0
  25. package/dist/commands/search.js +57 -0
  26. package/dist/commands/search.js.map +1 -0
  27. package/dist/core/compatibility-matcher.d.ts +17 -0
  28. package/dist/core/compatibility-matcher.js +146 -0
  29. package/dist/core/compatibility-matcher.js.map +1 -0
  30. package/dist/core/dedup.d.ts +22 -0
  31. package/dist/core/dedup.js +54 -0
  32. package/dist/core/dedup.js.map +1 -0
  33. package/dist/core/error-signature.d.ts +15 -0
  34. package/dist/core/error-signature.js +59 -0
  35. package/dist/core/error-signature.js.map +1 -0
  36. package/dist/core/facets.d.ts +9 -0
  37. package/dist/core/facets.js +46 -0
  38. package/dist/core/facets.js.map +1 -0
  39. package/dist/core/index.d.ts +30 -0
  40. package/dist/core/index.js +16 -0
  41. package/dist/core/index.js.map +1 -0
  42. package/dist/core/lesson-importer.d.ts +22 -0
  43. package/dist/core/lesson-importer.js +94 -0
  44. package/dist/core/lesson-importer.js.map +1 -0
  45. package/dist/core/paths.d.ts +5 -0
  46. package/dist/core/paths.js +11 -0
  47. package/dist/core/paths.js.map +1 -0
  48. package/dist/core/project-environment-detector.d.ts +43 -0
  49. package/dist/core/project-environment-detector.js +464 -0
  50. package/dist/core/project-environment-detector.js.map +1 -0
  51. package/dist/core/ranker.d.ts +3 -0
  52. package/dist/core/ranker.js +47 -0
  53. package/dist/core/ranker.js.map +1 -0
  54. package/dist/core/redaction.d.ts +35 -0
  55. package/dist/core/redaction.js +149 -0
  56. package/dist/core/redaction.js.map +1 -0
  57. package/dist/core/rule-compatibility.d.ts +66 -0
  58. package/dist/core/rule-compatibility.js +53 -0
  59. package/dist/core/rule-compatibility.js.map +1 -0
  60. package/dist/core/rule-parser.d.ts +25 -0
  61. package/dist/core/rule-parser.js +81 -0
  62. package/dist/core/rule-parser.js.map +1 -0
  63. package/dist/core/rule-schema.d.ts +231 -0
  64. package/dist/core/rule-schema.js +184 -0
  65. package/dist/core/rule-schema.js.map +1 -0
  66. package/dist/core/rule-writer.d.ts +35 -0
  67. package/dist/core/rule-writer.js +63 -0
  68. package/dist/core/rule-writer.js.map +1 -0
  69. package/dist/core/search-types.d.ts +51 -0
  70. package/dist/core/search-types.js +2 -0
  71. package/dist/core/search-types.js.map +1 -0
  72. package/dist/core/slug.d.ts +13 -0
  73. package/dist/core/slug.js +42 -0
  74. package/dist/core/slug.js.map +1 -0
  75. package/dist/core/stack-detector.d.ts +56 -0
  76. package/dist/core/stack-detector.js +358 -0
  77. package/dist/core/stack-detector.js.map +1 -0
  78. package/dist/index.d.ts +5 -0
  79. package/dist/index.js +4 -0
  80. package/dist/index.js.map +1 -0
  81. package/dist/mcp/index.d.ts +7 -0
  82. package/dist/mcp/index.js +5 -0
  83. package/dist/mcp/index.js.map +1 -0
  84. package/dist/mcp/lesson-capture.d.ts +30 -0
  85. package/dist/mcp/lesson-capture.js +146 -0
  86. package/dist/mcp/lesson-capture.js.map +1 -0
  87. package/dist/mcp/rules-add-lesson-tool.d.ts +4 -0
  88. package/dist/mcp/rules-add-lesson-tool.js +73 -0
  89. package/dist/mcp/rules-add-lesson-tool.js.map +1 -0
  90. package/dist/mcp/rules-dedup-lesson-tool.d.ts +4 -0
  91. package/dist/mcp/rules-dedup-lesson-tool.js +69 -0
  92. package/dist/mcp/rules-dedup-lesson-tool.js.map +1 -0
  93. package/dist/mcp/rules-list-facets-tool.d.ts +3 -0
  94. package/dist/mcp/rules-list-facets-tool.js +31 -0
  95. package/dist/mcp/rules-list-facets-tool.js.map +1 -0
  96. package/dist/mcp/rules-prepare-lesson-tool.d.ts +4 -0
  97. package/dist/mcp/rules-prepare-lesson-tool.js +7 -0
  98. package/dist/mcp/rules-prepare-lesson-tool.js.map +1 -0
  99. package/dist/mcp/rules-search-error-tool.d.ts +4 -0
  100. package/dist/mcp/rules-search-error-tool.js +99 -0
  101. package/dist/mcp/rules-search-error-tool.js.map +1 -0
  102. package/dist/mcp/rules-search-for-project-tool.d.ts +4 -0
  103. package/dist/mcp/rules-search-for-project-tool.js +103 -0
  104. package/dist/mcp/rules-search-for-project-tool.js.map +1 -0
  105. package/dist/mcp/rules-search-tool.d.ts +7 -0
  106. package/dist/mcp/rules-search-tool.js +65 -0
  107. package/dist/mcp/rules-search-tool.js.map +1 -0
  108. package/dist/mcp/schemas.d.ts +222 -0
  109. package/dist/mcp/schemas.js +99 -0
  110. package/dist/mcp/schemas.js.map +1 -0
  111. package/dist/mcp/server.d.ts +5 -0
  112. package/dist/mcp/server.js +29 -0
  113. package/dist/mcp/server.js.map +1 -0
  114. package/dist/mcp/tool-output.d.ts +32 -0
  115. package/dist/mcp/tool-output.js +74 -0
  116. package/dist/mcp/tool-output.js.map +1 -0
  117. package/dist/mcp/tools.d.ts +300 -0
  118. package/dist/mcp/tools.js +123 -0
  119. package/dist/mcp/tools.js.map +1 -0
  120. package/dist/migration/adapters/fenced-lessons.d.ts +2 -0
  121. package/dist/migration/adapters/fenced-lessons.js +55 -0
  122. package/dist/migration/adapters/fenced-lessons.js.map +1 -0
  123. package/dist/migration/adapters/global-rules.d.ts +2 -0
  124. package/dist/migration/adapters/global-rules.js +72 -0
  125. package/dist/migration/adapters/global-rules.js.map +1 -0
  126. package/dist/migration/adapters/index.d.ts +2 -0
  127. package/dist/migration/adapters/index.js +13 -0
  128. package/dist/migration/adapters/index.js.map +1 -0
  129. package/dist/migration/adapters/markdown-lessons.d.ts +2 -0
  130. package/dist/migration/adapters/markdown-lessons.js +36 -0
  131. package/dist/migration/adapters/markdown-lessons.js.map +1 -0
  132. package/dist/migration/adapters/structured-lessons.d.ts +2 -0
  133. package/dist/migration/adapters/structured-lessons.js +8 -0
  134. package/dist/migration/adapters/structured-lessons.js.map +1 -0
  135. package/dist/migration/adapters/structured-shared.d.ts +3 -0
  136. package/dist/migration/adapters/structured-shared.js +97 -0
  137. package/dist/migration/adapters/structured-shared.js.map +1 -0
  138. package/dist/migration/applier.d.ts +32 -0
  139. package/dist/migration/applier.js +469 -0
  140. package/dist/migration/applier.js.map +1 -0
  141. package/dist/migration/index.d.ts +11 -0
  142. package/dist/migration/index.js +7 -0
  143. package/dist/migration/index.js.map +1 -0
  144. package/dist/migration/manifest.d.ts +262 -0
  145. package/dist/migration/manifest.js +89 -0
  146. package/dist/migration/manifest.js.map +1 -0
  147. package/dist/migration/migration-report.d.ts +147 -0
  148. package/dist/migration/migration-report.js +81 -0
  149. package/dist/migration/migration-report.js.map +1 -0
  150. package/dist/migration/scanner.d.ts +2 -0
  151. package/dist/migration/scanner.js +314 -0
  152. package/dist/migration/scanner.js.map +1 -0
  153. package/dist/migration/source-adapter.d.ts +37 -0
  154. package/dist/migration/source-adapter.js +2 -0
  155. package/dist/migration/source-adapter.js.map +1 -0
  156. package/dist/migration/verifier.d.ts +5 -0
  157. package/dist/migration/verifier.js +217 -0
  158. package/dist/migration/verifier.js.map +1 -0
  159. package/dist/program.d.ts +2 -0
  160. package/dist/program.js +21 -0
  161. package/dist/program.js.map +1 -0
  162. package/dist/storage/index-check.d.ts +19 -0
  163. package/dist/storage/index-check.js +114 -0
  164. package/dist/storage/index-check.js.map +1 -0
  165. package/dist/storage/index.d.ts +15 -0
  166. package/dist/storage/index.js +9 -0
  167. package/dist/storage/index.js.map +1 -0
  168. package/dist/storage/indexer.d.ts +19 -0
  169. package/dist/storage/indexer.js +354 -0
  170. package/dist/storage/indexer.js.map +1 -0
  171. package/dist/storage/migrations.d.ts +3 -0
  172. package/dist/storage/migrations.js +110 -0
  173. package/dist/storage/migrations.js.map +1 -0
  174. package/dist/storage/rule-discovery.d.ts +4 -0
  175. package/dist/storage/rule-discovery.js +34 -0
  176. package/dist/storage/rule-discovery.js.map +1 -0
  177. package/dist/storage/rule-store.d.ts +10 -0
  178. package/dist/storage/rule-store.js +12 -0
  179. package/dist/storage/rule-store.js.map +1 -0
  180. package/dist/storage/rulebook-home.d.ts +21 -0
  181. package/dist/storage/rulebook-home.js +75 -0
  182. package/dist/storage/rulebook-home.js.map +1 -0
  183. package/dist/storage/search-service.d.ts +17 -0
  184. package/dist/storage/search-service.js +252 -0
  185. package/dist/storage/search-service.js.map +1 -0
  186. package/dist/storage/sqlite-errors.d.ts +26 -0
  187. package/dist/storage/sqlite-errors.js +55 -0
  188. package/dist/storage/sqlite-errors.js.map +1 -0
  189. package/dist/storage/sqlite.d.ts +13 -0
  190. package/dist/storage/sqlite.js +34 -0
  191. package/dist/storage/sqlite.js.map +1 -0
  192. package/package.json +62 -0
@@ -0,0 +1,149 @@
1
+ import { homedir } from 'node:os';
2
+ const SECRET_PATTERNS = [
3
+ { name: 'openai_api_key', regex: /\bsk-[A-Za-z0-9_-]{8,}\b/g },
4
+ { name: 'github_token', regex: /\bghp_[A-Za-z0-9_]{20,}\b/g },
5
+ { name: 'slack_token', regex: /\bxoxb-[A-Za-z0-9-]{10,}\b/g },
6
+ { name: 'bearer_token', regex: /\bBearer\s+[A-Za-z0-9._~+/=-]{10,}\b/g },
7
+ { name: 'aws_access_key_id', regex: /\bAWS_ACCESS_KEY_ID(?:\s*=\s*[A-Z0-9]{16,})?\b/g },
8
+ { name: 'private_key', regex: /-----BEGIN [A-Z ]*PRIVATE KEY-----/g },
9
+ ];
10
+ export function redactSecretText(value) {
11
+ return SECRET_PATTERNS.reduce((redacted, pattern) => redacted.replace(pattern.regex, '[REDACTED:secret]'), value);
12
+ }
13
+ export function redactSensitiveText(value, options = {}) {
14
+ const secretRedacted = redactSecretText(value);
15
+ const pathMatches = findPathMatches(secretRedacted, options.homeDir ?? homedir()).sort((left, right) => right.match.length - left.match.length);
16
+ return pathMatches.reduce((redacted, match) => redacted.replaceAll(match.match, '[REDACTED:path]'), secretRedacted);
17
+ }
18
+ const POSIX_ABSOLUTE_PATH_PATTERN = /(?:^|[\s"'(])((?:\/[A-Za-z0-9._ -]+){2,})(?=$|[\s"',).])/g;
19
+ const WINDOWS_ABSOLUTE_PATH_PATTERN = /(?:^|[\s"'(])([A-Za-z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*)(?=$|[\s"',).])/g;
20
+ const LONG_LOG_LINE_THRESHOLD = 240;
21
+ const LONG_CODE_BLOCK_LINE_THRESHOLD = 30;
22
+ export function scanRuleDraftForRedactions(input, options = {}) {
23
+ const warnings = [];
24
+ const suggested_redactions = [];
25
+ for (const item of collectFieldText(input)) {
26
+ for (const match of findSecretMatches(item.value)) {
27
+ warnings.push({
28
+ kind: 'secret',
29
+ field: item.field,
30
+ pattern: match.pattern,
31
+ sample: maskSample(match.match),
32
+ blocks_save: true,
33
+ });
34
+ suggested_redactions.push({
35
+ field: item.field,
36
+ replacement: '[REDACTED:secret]',
37
+ reason: match.pattern,
38
+ });
39
+ }
40
+ for (const match of findPathMatches(item.value, options.homeDir ?? homedir())) {
41
+ warnings.push({
42
+ kind: 'path',
43
+ field: item.field,
44
+ pattern: match.pattern,
45
+ sample: maskSample(match.match),
46
+ blocks_save: false,
47
+ });
48
+ suggested_redactions.push({
49
+ field: item.field,
50
+ replacement: '[REDACTED:path]',
51
+ reason: match.pattern,
52
+ });
53
+ }
54
+ for (const match of findLongContentMatches(item.value)) {
55
+ warnings.push({
56
+ kind: 'long_content',
57
+ field: item.field,
58
+ pattern: match.pattern,
59
+ sample: maskSample(match.match),
60
+ blocks_save: false,
61
+ });
62
+ suggested_redactions.push({
63
+ field: item.field,
64
+ replacement: '[TRIMMED]',
65
+ reason: match.pattern,
66
+ });
67
+ }
68
+ }
69
+ return {
70
+ requires_confirmation: warnings.length > 0,
71
+ can_save: warnings.every((warning) => !warning.blocks_save),
72
+ warnings,
73
+ suggested_redactions,
74
+ };
75
+ }
76
+ function collectFieldText(input) {
77
+ const fields = [];
78
+ for (const [field, value] of Object.entries(input)) {
79
+ if (typeof value === 'string' && value.length > 0) {
80
+ fields.push({ field, value });
81
+ }
82
+ else if (Array.isArray(value)) {
83
+ for (const item of value) {
84
+ if (typeof item === 'string' && item.length > 0) {
85
+ fields.push({ field, value: item });
86
+ }
87
+ }
88
+ }
89
+ }
90
+ return fields;
91
+ }
92
+ function findSecretMatches(value) {
93
+ const matches = [];
94
+ for (const pattern of SECRET_PATTERNS) {
95
+ for (const match of value.matchAll(pattern.regex)) {
96
+ if (match[0] !== undefined) {
97
+ matches.push({ pattern: pattern.name, match: match[0] });
98
+ }
99
+ }
100
+ }
101
+ return matches;
102
+ }
103
+ function findPathMatches(value, homeDir) {
104
+ const matches = [];
105
+ const normalizedHome = normalizePathForMatch(homeDir);
106
+ const normalizedValue = normalizePathForMatch(value);
107
+ if (normalizedHome.length > 1 &&
108
+ normalizedValue.includes(normalizedHome.endsWith('/') ? normalizedHome : `${normalizedHome}/`)) {
109
+ matches.push({ pattern: 'home_path', match: homeDir });
110
+ }
111
+ for (const match of value.matchAll(POSIX_ABSOLUTE_PATH_PATTERN)) {
112
+ const matchedPath = match[1];
113
+ if (matchedPath !== undefined) {
114
+ matches.push({ pattern: 'posix_absolute_path', match: matchedPath });
115
+ }
116
+ }
117
+ for (const match of value.matchAll(WINDOWS_ABSOLUTE_PATH_PATTERN)) {
118
+ const matchedPath = match[1];
119
+ if (matchedPath !== undefined) {
120
+ matches.push({ pattern: 'windows_absolute_path', match: matchedPath });
121
+ }
122
+ }
123
+ return matches;
124
+ }
125
+ function findLongContentMatches(value) {
126
+ const matches = [];
127
+ for (const match of value.matchAll(/```[\s\S]*?```/g)) {
128
+ const block = match[0];
129
+ if (block.split('\n').length > LONG_CODE_BLOCK_LINE_THRESHOLD) {
130
+ matches.push({ pattern: 'long_code_block', match: block });
131
+ }
132
+ }
133
+ for (const line of value.split(/\r?\n/)) {
134
+ if (line.length > LONG_LOG_LINE_THRESHOLD) {
135
+ matches.push({ pattern: 'long_log_line', match: line });
136
+ }
137
+ }
138
+ return matches;
139
+ }
140
+ function normalizePathForMatch(value) {
141
+ return value.replaceAll('\\', '/');
142
+ }
143
+ function maskSample(value) {
144
+ if (value.length <= 8) {
145
+ return '[REDACTED]';
146
+ }
147
+ return `${value.slice(0, 3)}...[REDACTED]...${value.slice(-3)}`;
148
+ }
149
+ //# sourceMappingURL=redaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction.js","sourceRoot":"","sources":["../../src/core/redaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAkDlC,MAAM,eAAe,GAGhB;IACH,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,2BAA2B,EAAE;IAC9D,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,4BAA4B,EAAE;IAC7D,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,6BAA6B,EAAE;IAC7D,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,uCAAuC,EAAE;IACxE,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,iDAAiD,EAAE;IACvF,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EA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AAC,CAAC,CAAC,EAAE,CAAC;AAClE,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { z } from 'zod';
2
+ export declare const CompatibilityScopeSchema: z.ZodEnum<{
3
+ unknown: "unknown";
4
+ version_agnostic: "version_agnostic";
5
+ constrained: "constrained";
6
+ }>;
7
+ export declare const CompatibilityComponentKindSchema: z.ZodEnum<{
8
+ language: "language";
9
+ sdk: "sdk";
10
+ toolchain: "toolchain";
11
+ framework: "framework";
12
+ runtime: "runtime";
13
+ build_tool: "build_tool";
14
+ platform: "platform";
15
+ }>;
16
+ export declare const CompatibilityConstraintSchema: z.ZodObject<{
17
+ kind: z.ZodEnum<{
18
+ language: "language";
19
+ sdk: "sdk";
20
+ toolchain: "toolchain";
21
+ framework: "framework";
22
+ runtime: "runtime";
23
+ build_tool: "build_tool";
24
+ platform: "platform";
25
+ }>;
26
+ component: z.ZodPreprocess<z.ZodString>;
27
+ range: z.ZodString;
28
+ }, z.core.$strip>;
29
+ export declare const VerifiedComponentSchema: z.ZodObject<{
30
+ component: z.ZodPreprocess<z.ZodString>;
31
+ version: z.ZodString;
32
+ }, z.core.$strip>;
33
+ export declare const RuleCompatibilitySchema: z.ZodObject<{
34
+ scope: z.ZodEnum<{
35
+ unknown: "unknown";
36
+ version_agnostic: "version_agnostic";
37
+ constrained: "constrained";
38
+ }>;
39
+ constraints: z.ZodDefault<z.ZodArray<z.ZodObject<{
40
+ kind: z.ZodEnum<{
41
+ language: "language";
42
+ sdk: "sdk";
43
+ toolchain: "toolchain";
44
+ framework: "framework";
45
+ runtime: "runtime";
46
+ build_tool: "build_tool";
47
+ platform: "platform";
48
+ }>;
49
+ component: z.ZodPreprocess<z.ZodString>;
50
+ range: z.ZodString;
51
+ }, z.core.$strip>>>;
52
+ verified_with: z.ZodDefault<z.ZodArray<z.ZodObject<{
53
+ component: z.ZodPreprocess<z.ZodString>;
54
+ version: z.ZodString;
55
+ }, z.core.$strip>>>;
56
+ }, z.core.$strip>;
57
+ export declare const LegacyCompatibility: {
58
+ readonly scope: "unknown";
59
+ readonly constraints: readonly [];
60
+ readonly verified_with: readonly [];
61
+ };
62
+ export type CompatibilityScope = z.infer<typeof CompatibilityScopeSchema>;
63
+ export type CompatibilityComponentKind = z.infer<typeof CompatibilityComponentKindSchema>;
64
+ export type CompatibilityConstraint = z.infer<typeof CompatibilityConstraintSchema>;
65
+ export type VerifiedComponent = z.infer<typeof VerifiedComponentSchema>;
66
+ export type RuleCompatibility = z.infer<typeof RuleCompatibilitySchema>;
@@ -0,0 +1,53 @@
1
+ import { z } from 'zod';
2
+ const facetValueSchema = z.preprocess((value) => (typeof value === 'string' ? value.trim().toLowerCase() : value), z.string().min(1));
3
+ export const CompatibilityScopeSchema = z.enum([
4
+ 'version_agnostic',
5
+ 'constrained',
6
+ 'unknown',
7
+ ]);
8
+ export const CompatibilityComponentKindSchema = z.enum([
9
+ 'language',
10
+ 'sdk',
11
+ 'toolchain',
12
+ 'framework',
13
+ 'runtime',
14
+ 'build_tool',
15
+ 'platform',
16
+ ]);
17
+ export const CompatibilityConstraintSchema = z.object({
18
+ kind: CompatibilityComponentKindSchema,
19
+ component: facetValueSchema,
20
+ range: z.string().trim().min(1),
21
+ });
22
+ export const VerifiedComponentSchema = z.object({
23
+ component: facetValueSchema,
24
+ version: z.string().trim().min(1),
25
+ });
26
+ export const RuleCompatibilitySchema = z
27
+ .object({
28
+ scope: CompatibilityScopeSchema,
29
+ constraints: z.array(CompatibilityConstraintSchema).default([]),
30
+ verified_with: z.array(VerifiedComponentSchema).default([]),
31
+ })
32
+ .superRefine((compatibility, context) => {
33
+ if (compatibility.scope === 'constrained' && compatibility.constraints.length === 0) {
34
+ context.addIssue({
35
+ code: 'custom',
36
+ path: ['constraints'],
37
+ message: 'Constrained compatibility requires at least one component constraint',
38
+ });
39
+ }
40
+ if (compatibility.scope !== 'constrained' && compatibility.constraints.length > 0) {
41
+ context.addIssue({
42
+ code: 'custom',
43
+ path: ['constraints'],
44
+ message: `${compatibility.scope} compatibility cannot include component constraints`,
45
+ });
46
+ }
47
+ });
48
+ export const LegacyCompatibility = {
49
+ scope: 'unknown',
50
+ constraints: [],
51
+ verified_with: [],
52
+ };
53
+ //# sourceMappingURL=rule-compatibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-compatibility.js","sourceRoot":"","sources":["../../src/core/rule-compatibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,gBAAgB,GAAG,CAAC,CAAC,UAAU,CACnC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAC3E,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC7C,kBAAkB;IAClB,aAAa;IACb,SAAS;CACV,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,IAAI,CAAC;IACrD,UAAU;IACV,KAAK;IACL,WAAW;IACX,WAAW;IACX,SAAS;IACT,YAAY;IACZ,UAAU;CACX,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC;IACpD,IAAI,EAAE,gCAAgC;IACtC,SAAS,EAAE,gBAAgB;IAC3B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAChC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,SAAS,EAAE,gBAAgB;IAC3B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAClC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC;KACrC,MAAM,CAAC;IACN,KAAK,EAAE,wBAAwB;IAC/B,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/D,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CAC5D,CAAC;KACD,WAAW,CAAC,CAAC,aAAa,EAAE,OAAO,EAAE,EAAE;IACtC,IAAI,aAAa,CAAC,KAAK,KAAK,aAAa,IAAI,aAAa,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpF,OAAO,CAAC,QAAQ,CAAC;YACf,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,aAAa,CAAC;YACrB,OAAO,EAAE,sEAAsE;SAChF,CAAC,CAAC;IACL,CAAC;IAED,IAAI,aAAa,CAAC,KAAK,KAAK,aAAa,IAAI,aAAa,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClF,OAAO,CAAC,QAAQ,CAAC;YACf,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,aAAa,CAAC;YACrB,OAAO,EAAE,GAAG,aAAa,CAAC,KAAK,qDAAqD;SACrF,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,KAAK,EAAE,SAAS;IAChB,WAAW,EAAE,EAAE;IACf,aAAa,EAAE,EAAE;CACT,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { type LoadedRule, type RuleFacetWarning } from './rule-schema.js';
2
+ export type RuleValidationIssue = {
3
+ path: string;
4
+ message: string;
5
+ };
6
+ export type RuleParseError = {
7
+ kind: 'yaml_parse' | 'validation' | 'unsupported_schema_version';
8
+ filePath: string;
9
+ message: string;
10
+ issues: RuleValidationIssue[];
11
+ schemaVersion?: unknown;
12
+ };
13
+ export type RuleParseResult = {
14
+ success: true;
15
+ rule: LoadedRule;
16
+ warnings: RuleFacetWarning[];
17
+ } | {
18
+ success: false;
19
+ error: RuleParseError;
20
+ };
21
+ export type RuleParseOptions = {
22
+ filePath: string;
23
+ };
24
+ export declare function parseRuleYaml(source: string, options: RuleParseOptions): RuleParseResult;
25
+ export declare function validateRuleInput(input: unknown, options: RuleParseOptions): RuleParseResult;
@@ -0,0 +1,81 @@
1
+ import { parse as parseYaml } from 'yaml';
2
+ import { collectUnknownFacetWarnings, LegacyRuleSchema, RuleSchema, toLegacyRuleCandidate, } from './rule-schema.js';
3
+ export function parseRuleYaml(source, options) {
4
+ try {
5
+ const parsed = parseYaml(source);
6
+ return validateRuleInput(parsed, options);
7
+ }
8
+ catch (error) {
9
+ return {
10
+ success: false,
11
+ error: {
12
+ kind: 'yaml_parse',
13
+ filePath: options.filePath,
14
+ message: error instanceof Error ? error.message : 'Unable to parse YAML rule',
15
+ issues: [],
16
+ },
17
+ };
18
+ }
19
+ }
20
+ export function validateRuleInput(input, options) {
21
+ const schemaVersion = readSchemaVersion(input);
22
+ if (schemaVersion !== undefined && schemaVersion !== 1 && schemaVersion !== 2) {
23
+ return {
24
+ success: false,
25
+ error: {
26
+ kind: 'unsupported_schema_version',
27
+ filePath: options.filePath,
28
+ message: `Unsupported rule schema version: ${String(schemaVersion)}`,
29
+ issues: [],
30
+ schemaVersion,
31
+ },
32
+ };
33
+ }
34
+ if (schemaVersion === 2) {
35
+ return validationResult(RuleSchema.safeParse(input), options);
36
+ }
37
+ const legacyResult = LegacyRuleSchema.safeParse(input);
38
+ if (!legacyResult.success) {
39
+ return validationFailure(legacyResult.error, options);
40
+ }
41
+ const rule = toLegacyRuleCandidate(legacyResult.data);
42
+ return {
43
+ success: true,
44
+ rule,
45
+ warnings: collectUnknownFacetWarnings(rule),
46
+ };
47
+ }
48
+ function readSchemaVersion(input) {
49
+ if (typeof input !== 'object' || input === null || Array.isArray(input)) {
50
+ return undefined;
51
+ }
52
+ return Reflect.get(input, 'schema_version');
53
+ }
54
+ function validationResult(result, options) {
55
+ if (!result.success) {
56
+ return validationFailure(result.error, options);
57
+ }
58
+ return {
59
+ success: true,
60
+ rule: result.data,
61
+ warnings: collectUnknownFacetWarnings(result.data),
62
+ };
63
+ }
64
+ function validationFailure(error, options) {
65
+ return {
66
+ success: false,
67
+ error: {
68
+ kind: 'validation',
69
+ filePath: options.filePath,
70
+ message: `Rule validation failed for ${options.filePath}`,
71
+ issues: toValidationIssues(error),
72
+ },
73
+ };
74
+ }
75
+ function toValidationIssues(error) {
76
+ return error.issues.map((issue) => ({
77
+ path: issue.path.join('.'),
78
+ message: issue.message,
79
+ }));
80
+ }
81
+ //# sourceMappingURL=rule-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-parser.js","sourceRoot":"","sources":["../../src/core/rule-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,EAGhB,UAAU,EACV,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AA8B1B,MAAM,UAAU,aAAa,CAAC,MAAc,EAAE,OAAyB;IACrE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;QACjC,OAAO,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE;gBACL,IAAI,EAAE,YAAY;gBAClB,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,2BAA2B;gBAC7E,MAAM,EAAE,EAAE;aACX;SACF,CAA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CAAC;AAC9C,CAAC;AAED,SAAS,gBAAgB,CACvB,MAA+C,EAC/C,OAAyB;IAEzB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,iBAAiB,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,QAAQ,EAAE,2BAA2B,CAAC,MAAM,CAAC,IAAI,CAAC;KACnD,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAe,EAAE,OAAyB;IACnE,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACL,IAAI,EAAE,YAAY;YAClB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,OAAO,EAAE,8BAA8B,OAAO,CAAC,QAAQ,EAAE;YACzD,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC;SAClC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAe;IACzC,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,231 @@
1
+ import { z } from 'zod';
2
+ export declare const RuleStatusSchema: z.ZodEnum<{
3
+ draft: "draft";
4
+ active: "active";
5
+ deprecated: "deprecated";
6
+ superseded: "superseded";
7
+ }>;
8
+ export declare const RuleConfidenceSchema: z.ZodEnum<{
9
+ low: "low";
10
+ medium: "medium";
11
+ high: "high";
12
+ }>;
13
+ export declare const RuleLanguageSchema: z.ZodPreprocess<z.ZodEnum<{
14
+ typescript: "typescript";
15
+ swift: "swift";
16
+ kotlin: "kotlin";
17
+ javascript: "javascript";
18
+ python: "python";
19
+ mcp: "mcp";
20
+ other: "other";
21
+ }>>;
22
+ export declare const RuleScopeSchema: z.ZodEnum<{
23
+ shared: "shared";
24
+ project: "project";
25
+ }>;
26
+ export declare const RuleProvenanceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
27
+ imported: z.ZodLiteral<true>;
28
+ source_kind: z.ZodEnum<{
29
+ project_markdown: "project_markdown";
30
+ skill_lessons: "skill_lessons";
31
+ codex_rules: "codex_rules";
32
+ legacy_yaml: "legacy_yaml";
33
+ }>;
34
+ source_project: z.ZodOptional<z.ZodString>;
35
+ source_ref: z.ZodString;
36
+ source_checksum: z.ZodString;
37
+ }, z.core.$strip>, z.ZodObject<{
38
+ imported: z.ZodLiteral<false>;
39
+ }, z.core.$strip>], "imported">;
40
+ export declare const RuleActivationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
41
+ basis: z.ZodLiteral<"legacy_curated">;
42
+ capture_mode: z.ZodLiteral<"migration">;
43
+ }, z.core.$strip>, z.ZodObject<{
44
+ basis: z.ZodLiteral<"tdd_verified">;
45
+ capture_mode: z.ZodLiteral<"tdd_auto">;
46
+ criteria: z.ZodObject<{
47
+ debugging_cost: z.ZodLiteral<"high">;
48
+ token_cost: z.ZodLiteral<"high">;
49
+ recurrence_risk: z.ZodLiteral<"high">;
50
+ }, z.core.$strip>;
51
+ dedup_result: z.ZodLiteral<"new">;
52
+ verification: z.ZodObject<{
53
+ kind: z.ZodEnum<{
54
+ focused_test: "focused_test";
55
+ integration_test: "integration_test";
56
+ manual_verification: "manual_verification";
57
+ }>;
58
+ evidence: z.ZodString;
59
+ }, z.core.$strip>;
60
+ }, z.core.$strip>, z.ZodObject<{
61
+ basis: z.ZodLiteral<"manual_review">;
62
+ capture_mode: z.ZodLiteral<"manual">;
63
+ }, z.core.$strip>], "basis">;
64
+ export declare const LegacyRuleSchema: z.ZodObject<{
65
+ id: z.ZodString;
66
+ title: z.ZodString;
67
+ summary: z.ZodString;
68
+ mistake: z.ZodString;
69
+ fix: z.ZodString;
70
+ confidence: z.ZodEnum<{
71
+ low: "low";
72
+ medium: "medium";
73
+ high: "high";
74
+ }>;
75
+ status: z.ZodEnum<{
76
+ draft: "draft";
77
+ active: "active";
78
+ deprecated: "deprecated";
79
+ superseded: "superseded";
80
+ }>;
81
+ created_at: z.ZodString;
82
+ language: z.ZodOptional<z.ZodPreprocess<z.ZodEnum<{
83
+ typescript: "typescript";
84
+ swift: "swift";
85
+ kotlin: "kotlin";
86
+ javascript: "javascript";
87
+ python: "python";
88
+ mcp: "mcp";
89
+ other: "other";
90
+ }>>>;
91
+ platforms: z.ZodPreprocess<z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>>>;
92
+ tools: z.ZodPreprocess<z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>>>;
93
+ categories: z.ZodPreprocess<z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>>>;
94
+ trigger: z.ZodPreprocess<z.ZodDefault<z.ZodArray<z.ZodString>>>;
95
+ anti_conditions: z.ZodPreprocess<z.ZodDefault<z.ZodArray<z.ZodString>>>;
96
+ error_signature: z.ZodOptional<z.ZodString>;
97
+ source_project: z.ZodOptional<z.ZodString>;
98
+ verified_at: z.ZodOptional<z.ZodString>;
99
+ updated_at: z.ZodOptional<z.ZodString>;
100
+ superseded_by: z.ZodOptional<z.ZodNullable<z.ZodString>>;
101
+ schema_version: z.ZodOptional<z.ZodLiteral<1>>;
102
+ }, z.core.$strip>;
103
+ export declare const RuleSchema: z.ZodObject<{
104
+ id: z.ZodString;
105
+ title: z.ZodString;
106
+ summary: z.ZodString;
107
+ mistake: z.ZodString;
108
+ fix: z.ZodString;
109
+ confidence: z.ZodEnum<{
110
+ low: "low";
111
+ medium: "medium";
112
+ high: "high";
113
+ }>;
114
+ status: z.ZodEnum<{
115
+ draft: "draft";
116
+ active: "active";
117
+ deprecated: "deprecated";
118
+ superseded: "superseded";
119
+ }>;
120
+ created_at: z.ZodString;
121
+ language: z.ZodOptional<z.ZodPreprocess<z.ZodEnum<{
122
+ typescript: "typescript";
123
+ swift: "swift";
124
+ kotlin: "kotlin";
125
+ javascript: "javascript";
126
+ python: "python";
127
+ mcp: "mcp";
128
+ other: "other";
129
+ }>>>;
130
+ platforms: z.ZodPreprocess<z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>>>;
131
+ tools: z.ZodPreprocess<z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>>>;
132
+ categories: z.ZodPreprocess<z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>>>;
133
+ trigger: z.ZodPreprocess<z.ZodDefault<z.ZodArray<z.ZodString>>>;
134
+ anti_conditions: z.ZodPreprocess<z.ZodDefault<z.ZodArray<z.ZodString>>>;
135
+ error_signature: z.ZodOptional<z.ZodString>;
136
+ source_project: z.ZodOptional<z.ZodString>;
137
+ verified_at: z.ZodOptional<z.ZodString>;
138
+ updated_at: z.ZodOptional<z.ZodString>;
139
+ superseded_by: z.ZodOptional<z.ZodNullable<z.ZodString>>;
140
+ schema_version: z.ZodLiteral<2>;
141
+ rule_scope: z.ZodEnum<{
142
+ shared: "shared";
143
+ project: "project";
144
+ }>;
145
+ project_key: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
146
+ compatibility: z.ZodObject<{
147
+ scope: z.ZodEnum<{
148
+ unknown: "unknown";
149
+ version_agnostic: "version_agnostic";
150
+ constrained: "constrained";
151
+ }>;
152
+ constraints: z.ZodDefault<z.ZodArray<z.ZodObject<{
153
+ kind: z.ZodEnum<{
154
+ language: "language";
155
+ sdk: "sdk";
156
+ toolchain: "toolchain";
157
+ framework: "framework";
158
+ runtime: "runtime";
159
+ build_tool: "build_tool";
160
+ platform: "platform";
161
+ }>;
162
+ component: z.ZodPreprocess<z.ZodString>;
163
+ range: z.ZodString;
164
+ }, z.core.$strip>>>;
165
+ verified_with: z.ZodDefault<z.ZodArray<z.ZodObject<{
166
+ component: z.ZodPreprocess<z.ZodString>;
167
+ version: z.ZodString;
168
+ }, z.core.$strip>>>;
169
+ }, z.core.$strip>;
170
+ provenance: z.ZodDiscriminatedUnion<[z.ZodObject<{
171
+ imported: z.ZodLiteral<true>;
172
+ source_kind: z.ZodEnum<{
173
+ project_markdown: "project_markdown";
174
+ skill_lessons: "skill_lessons";
175
+ codex_rules: "codex_rules";
176
+ legacy_yaml: "legacy_yaml";
177
+ }>;
178
+ source_project: z.ZodOptional<z.ZodString>;
179
+ source_ref: z.ZodString;
180
+ source_checksum: z.ZodString;
181
+ }, z.core.$strip>, z.ZodObject<{
182
+ imported: z.ZodLiteral<false>;
183
+ }, z.core.$strip>], "imported">;
184
+ activation: z.ZodDiscriminatedUnion<[z.ZodObject<{
185
+ basis: z.ZodLiteral<"legacy_curated">;
186
+ capture_mode: z.ZodLiteral<"migration">;
187
+ }, z.core.$strip>, z.ZodObject<{
188
+ basis: z.ZodLiteral<"tdd_verified">;
189
+ capture_mode: z.ZodLiteral<"tdd_auto">;
190
+ criteria: z.ZodObject<{
191
+ debugging_cost: z.ZodLiteral<"high">;
192
+ token_cost: z.ZodLiteral<"high">;
193
+ recurrence_risk: z.ZodLiteral<"high">;
194
+ }, z.core.$strip>;
195
+ dedup_result: z.ZodLiteral<"new">;
196
+ verification: z.ZodObject<{
197
+ kind: z.ZodEnum<{
198
+ focused_test: "focused_test";
199
+ integration_test: "integration_test";
200
+ manual_verification: "manual_verification";
201
+ }>;
202
+ evidence: z.ZodString;
203
+ }, z.core.$strip>;
204
+ }, z.core.$strip>, z.ZodObject<{
205
+ basis: z.ZodLiteral<"manual_review">;
206
+ capture_mode: z.ZodLiteral<"manual">;
207
+ }, z.core.$strip>], "basis">;
208
+ }, z.core.$strip>;
209
+ export declare const LegacyRuleMarkerSchema: z.ZodObject<{
210
+ source_schema_version: z.ZodLiteral<1>;
211
+ }, z.core.$strip>;
212
+ export type RuleStatus = z.infer<typeof RuleStatusSchema>;
213
+ export type RuleConfidence = z.infer<typeof RuleConfidenceSchema>;
214
+ export type RuleLanguage = z.infer<typeof RuleLanguageSchema>;
215
+ export type RuleScope = z.infer<typeof RuleScopeSchema>;
216
+ export type RuleProvenance = z.infer<typeof RuleProvenanceSchema>;
217
+ export type RuleActivation = z.infer<typeof RuleActivationSchema>;
218
+ export type RuleV2 = z.infer<typeof RuleSchema>;
219
+ export type LegacyRuleDocument = z.infer<typeof LegacyRuleSchema>;
220
+ export type LoadedRule = RuleV2 & {
221
+ legacy?: z.infer<typeof LegacyRuleMarkerSchema>;
222
+ };
223
+ export type Rule = LegacyRuleDocument | LoadedRule;
224
+ export declare function toLegacyRuleCandidate(input: LegacyRuleDocument): LoadedRule;
225
+ export type RuleFacetWarning = {
226
+ kind: 'unknown_facet';
227
+ facet: 'platforms' | 'tools' | 'categories';
228
+ value: string;
229
+ };
230
+ export declare function collectUnknownFacetWarnings(rule: LoadedRule): RuleFacetWarning[];
231
+ export { isKnownFacetValue } from './facets.js';