@thinkingsage/kanon 0.8.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 (199) hide show
  1. package/CHANGELOG.md +410 -0
  2. package/LICENSE +21 -0
  3. package/README.md +168 -0
  4. package/bridge/mcp-server.cjs +14171 -0
  5. package/package.json +98 -0
  6. package/src/adapters/capabilities.ts +178 -0
  7. package/src/adapters/claude-code.ts +110 -0
  8. package/src/adapters/cline.ts +98 -0
  9. package/src/adapters/codex.ts +173 -0
  10. package/src/adapters/copilot.ts +106 -0
  11. package/src/adapters/cursor.ts +97 -0
  12. package/src/adapters/degradation.ts +95 -0
  13. package/src/adapters/index.ts +324 -0
  14. package/src/adapters/kiro-frontmatter.ts +139 -0
  15. package/src/adapters/kiro-inclusion.ts +86 -0
  16. package/src/adapters/kiro.ts +412 -0
  17. package/src/adapters/qdeveloper.ts +115 -0
  18. package/src/adapters/types.ts +81 -0
  19. package/src/adapters/windsurf.ts +96 -0
  20. package/src/admin.ts +283 -0
  21. package/src/asset-conventions.ts +118 -0
  22. package/src/attribution-backfill.ts +319 -0
  23. package/src/attribution-report.ts +95 -0
  24. package/src/attribution.ts +239 -0
  25. package/src/backends/github.ts +194 -0
  26. package/src/backends/http.ts +122 -0
  27. package/src/backends/index.ts +39 -0
  28. package/src/backends/local.ts +47 -0
  29. package/src/backends/s3.ts +157 -0
  30. package/src/backends/types.ts +59 -0
  31. package/src/base-cache.ts +270 -0
  32. package/src/browse-ui.ts +3754 -0
  33. package/src/browse.ts +1038 -0
  34. package/src/build.ts +1108 -0
  35. package/src/catalog.ts +204 -0
  36. package/src/cli-deprecated.ts +29 -0
  37. package/src/cli.ts +773 -0
  38. package/src/collection-admin.ts +287 -0
  39. package/src/collection-builder.ts +464 -0
  40. package/src/collections.ts +116 -0
  41. package/src/compatibility.ts +105 -0
  42. package/src/config.ts +743 -0
  43. package/src/eval/rubrics/kiro-progressive-steering.ts +841 -0
  44. package/src/eval.ts +1169 -0
  45. package/src/file-writer.ts +61 -0
  46. package/src/format-registry.ts +141 -0
  47. package/src/guild/auto-updater.ts +163 -0
  48. package/src/guild/backend-resolver.ts +49 -0
  49. package/src/guild/cli.ts +592 -0
  50. package/src/guild/collection-expander.ts +47 -0
  51. package/src/guild/global-cache.ts +247 -0
  52. package/src/guild/hook-generator.ts +100 -0
  53. package/src/guild/manifest.ts +154 -0
  54. package/src/guild/path-utils.ts +12 -0
  55. package/src/guild/sync.ts +622 -0
  56. package/src/guild/version-resolver.ts +42 -0
  57. package/src/help/metadata.ts +445 -0
  58. package/src/help/renderer.ts +265 -0
  59. package/src/help/typo-suggester.ts +25 -0
  60. package/src/hooks/expression.ts +493 -0
  61. package/src/hooks/pipeline.ts +141 -0
  62. package/src/import.ts +773 -0
  63. package/src/importers/claude-code.ts +134 -0
  64. package/src/importers/cline.ts +103 -0
  65. package/src/importers/codex.ts +140 -0
  66. package/src/importers/copilot.ts +103 -0
  67. package/src/importers/cursor.ts +105 -0
  68. package/src/importers/index.ts +390 -0
  69. package/src/importers/kiro.ts +110 -0
  70. package/src/importers/qdeveloper.ts +103 -0
  71. package/src/importers/types.ts +54 -0
  72. package/src/importers/windsurf.ts +104 -0
  73. package/src/install.ts +1005 -0
  74. package/src/manifest-admin.ts +306 -0
  75. package/src/mcp-bridge.ts +240 -0
  76. package/src/mutation/delta.ts +50 -0
  77. package/src/mutation/history.ts +66 -0
  78. package/src/mutation/operators.ts +524 -0
  79. package/src/mutation/runner.ts +332 -0
  80. package/src/new.ts +106 -0
  81. package/src/outcomes/collision.ts +127 -0
  82. package/src/outcomes/normalize.ts +208 -0
  83. package/src/outcomes/registry.ts +173 -0
  84. package/src/parser.ts +446 -0
  85. package/src/provenance-backfill-cli.ts +319 -0
  86. package/src/provenance-backfill.ts +520 -0
  87. package/src/publish.ts +354 -0
  88. package/src/reconcile-orchestrator.ts +502 -0
  89. package/src/reconcile-report-renderer.ts +176 -0
  90. package/src/resolve-body.ts +15 -0
  91. package/src/rosetta/builtins/compatibility-profiles.ts +297 -0
  92. package/src/rosetta/builtins/contracts.ts +1033 -0
  93. package/src/rosetta/builtins/pretty-printers/claude-code-native.ts +122 -0
  94. package/src/rosetta/builtins/pretty-printers/cline-native.ts +50 -0
  95. package/src/rosetta/builtins/pretty-printers/codex-native.ts +127 -0
  96. package/src/rosetta/builtins/pretty-printers/copilot-native.ts +50 -0
  97. package/src/rosetta/builtins/pretty-printers/cursor-native.ts +50 -0
  98. package/src/rosetta/builtins/pretty-printers/index.ts +81 -0
  99. package/src/rosetta/builtins/pretty-printers/kiro-native.ts +166 -0
  100. package/src/rosetta/builtins/pretty-printers/kiro-power.ts +108 -0
  101. package/src/rosetta/builtins/pretty-printers/kiro-skill.ts +88 -0
  102. package/src/rosetta/builtins/pretty-printers/qdeveloper-native.ts +51 -0
  103. package/src/rosetta/builtins/pretty-printers/superpowers.ts +97 -0
  104. package/src/rosetta/builtins/pretty-printers/windsurf-native.ts +50 -0
  105. package/src/rosetta/builtins/sources/claude-code-native.ts +348 -0
  106. package/src/rosetta/builtins/sources/cline-native.ts +176 -0
  107. package/src/rosetta/builtins/sources/codex-native.ts +343 -0
  108. package/src/rosetta/builtins/sources/copilot-native.ts +178 -0
  109. package/src/rosetta/builtins/sources/cursor-native.ts +176 -0
  110. package/src/rosetta/builtins/sources/index.ts +95 -0
  111. package/src/rosetta/builtins/sources/kiro-native.ts +462 -0
  112. package/src/rosetta/builtins/sources/kiro-power.ts +285 -0
  113. package/src/rosetta/builtins/sources/kiro-skill.ts +230 -0
  114. package/src/rosetta/builtins/sources/qdeveloper-native.ts +181 -0
  115. package/src/rosetta/builtins/sources/superpowers.ts +240 -0
  116. package/src/rosetta/builtins/sources/windsurf-native.ts +176 -0
  117. package/src/rosetta/builtins/targets/claude-code.ts +181 -0
  118. package/src/rosetta/builtins/targets/cline.ts +87 -0
  119. package/src/rosetta/builtins/targets/codex.ts +226 -0
  120. package/src/rosetta/builtins/targets/copilot.ts +103 -0
  121. package/src/rosetta/builtins/targets/cursor.ts +87 -0
  122. package/src/rosetta/builtins/targets/index.ts +60 -0
  123. package/src/rosetta/builtins/targets/kiro.ts +278 -0
  124. package/src/rosetta/builtins/targets/qdeveloper.ts +103 -0
  125. package/src/rosetta/builtins/targets/windsurf.ts +87 -0
  126. package/src/rosetta/canonical.ts +729 -0
  127. package/src/rosetta/compatibility.ts +432 -0
  128. package/src/rosetta/contracts.ts +329 -0
  129. package/src/rosetta/detector.ts +724 -0
  130. package/src/rosetta/diagnostics.ts +630 -0
  131. package/src/rosetta/engine-bootstrap.ts +103 -0
  132. package/src/rosetta/engine.ts +744 -0
  133. package/src/rosetta/index.ts +381 -0
  134. package/src/rosetta/inspection.ts +530 -0
  135. package/src/rosetta/plan.ts +448 -0
  136. package/src/rosetta/provenance-digest.ts +369 -0
  137. package/src/rosetta/reconcile.ts +812 -0
  138. package/src/rosetta/redaction.ts +467 -0
  139. package/src/rosetta/registry.ts +712 -0
  140. package/src/rosetta/renderers.ts +571 -0
  141. package/src/rosetta/request-guard.ts +335 -0
  142. package/src/rosetta/resolution.ts +419 -0
  143. package/src/rosetta/source-accounting.ts +233 -0
  144. package/src/rosetta/templates.ts +129 -0
  145. package/src/rosetta-cli.ts +717 -0
  146. package/src/rosetta-docs-generator.ts +793 -0
  147. package/src/rosetta-profiles-cli.ts +367 -0
  148. package/src/schemas.ts +1712 -0
  149. package/src/spec-coordination.ts +1141 -0
  150. package/src/temper.ts +747 -0
  151. package/src/template-bundle-loader.ts +312 -0
  152. package/src/template-engine.ts +53 -0
  153. package/src/translation-application-policy.ts +496 -0
  154. package/src/translation-orchestrator.ts +1013 -0
  155. package/src/translation-plan-applier.ts +473 -0
  156. package/src/tutorial.ts +305 -0
  157. package/src/validate.ts +1093 -0
  158. package/src/versioning.ts +553 -0
  159. package/src/wizard.ts +660 -0
  160. package/src/workspace.ts +237 -0
  161. package/templates/eval-contexts/claude-code.md.njk +6 -0
  162. package/templates/eval-contexts/cline.md.njk +6 -0
  163. package/templates/eval-contexts/copilot.md.njk +6 -0
  164. package/templates/eval-contexts/cursor.md.njk +6 -0
  165. package/templates/eval-contexts/kiro.md.njk +10 -0
  166. package/templates/eval-contexts/qdeveloper.md.njk +6 -0
  167. package/templates/eval-contexts/windsurf.md.njk +6 -0
  168. package/templates/harness-adapters/_base/attribution-footer.md.njk +17 -0
  169. package/templates/harness-adapters/_base/base.md.njk +16 -0
  170. package/templates/harness-adapters/claude-code/claude.md.njk +1 -0
  171. package/templates/harness-adapters/claude-code/mcp.json.njk +1 -0
  172. package/templates/harness-adapters/claude-code/settings.json.njk +1 -0
  173. package/templates/harness-adapters/claude-code/skill-library-index.md.njk +13 -0
  174. package/templates/harness-adapters/claude-code/skill.md.njk +19 -0
  175. package/templates/harness-adapters/cline/hook.sh.njk +4 -0
  176. package/templates/harness-adapters/cline/mcp.json.njk +1 -0
  177. package/templates/harness-adapters/cline/rule.md.njk +1 -0
  178. package/templates/harness-adapters/codex/agents-md.md.njk +6 -0
  179. package/templates/harness-adapters/codex/agents-pointer.md.njk +16 -0
  180. package/templates/harness-adapters/codex/skill.md.njk +27 -0
  181. package/templates/harness-adapters/copilot/agents.md.njk +1 -0
  182. package/templates/harness-adapters/copilot/instructions.md.njk +1 -0
  183. package/templates/harness-adapters/copilot/scoped.md.njk +6 -0
  184. package/templates/harness-adapters/cursor/mcp.json.njk +1 -0
  185. package/templates/harness-adapters/cursor/rule.md.njk +6 -0
  186. package/templates/harness-adapters/kiro/hook.json.njk +1 -0
  187. package/templates/harness-adapters/kiro/mcp.json.njk +1 -0
  188. package/templates/harness-adapters/kiro/power-steering.md.njk +3 -0
  189. package/templates/harness-adapters/kiro/power.md.njk +12 -0
  190. package/templates/harness-adapters/kiro/steering.md.njk +16 -0
  191. package/templates/harness-adapters/qdeveloper/agent.md.njk +1 -0
  192. package/templates/harness-adapters/qdeveloper/mcp.json.njk +1 -0
  193. package/templates/harness-adapters/qdeveloper/rule.md.njk +1 -0
  194. package/templates/harness-adapters/windsurf/mcp.json.njk +1 -0
  195. package/templates/harness-adapters/windsurf/rule.md.njk +1 -0
  196. package/templates/harness-adapters/windsurf/workflow.md.njk +1 -0
  197. package/templates/knowledge/hooks.yaml.njk +4 -0
  198. package/templates/knowledge/knowledge.md.njk +53 -0
  199. package/templates/knowledge/mcp-servers.yaml.njk +2 -0
@@ -0,0 +1,1033 @@
1
+ /**
2
+ * Rosetta Stone — Built-in Format Contracts
3
+ *
4
+ * Static declarations of all built-in format contracts and selection aliases.
5
+ * Each contract satisfies FormatContractSchema from `../../schemas`.
6
+ *
7
+ * CONSTRAINTS:
8
+ * - NO filesystem, process, clock, random, Git, or network imports
9
+ * - Pure data only — no side effects
10
+ *
11
+ * Requirements: 2.4, 2.9, 6.3, 7.9, 14.3, 14.5, 15.7
12
+ */
13
+
14
+ import type {
15
+ FormatContract,
16
+ FormatIdentifier,
17
+ RosettaCompatibilityProfile,
18
+ } from "../../schemas";
19
+ import {
20
+ CLAUDE_CODE_PROFILE,
21
+ CLINE_PROFILE,
22
+ CODEX_PROFILE,
23
+ COPILOT_PROFILE,
24
+ CURSOR_PROFILE,
25
+ KIRO_STEERING_PROFILE,
26
+ QDEVELOPER_PROFILE,
27
+ WINDSURF_PROFILE,
28
+ } from "./compatibility-profiles";
29
+
30
+ // ═══════════════════════════════════════════════════════════════════════════════
31
+ // Selection Alias Metadata
32
+ // ═══════════════════════════════════════════════════════════════════════════════
33
+
34
+ /**
35
+ * Metadata for a deprecated selection alias. Selection aliases occupy a
36
+ * separate namespace from format aliases and resolve to detection-based
37
+ * selection rather than a specific format contract.
38
+ */
39
+ export interface SelectionAliasMetadata {
40
+ readonly id: string;
41
+ readonly status: "deprecated";
42
+ readonly description: string;
43
+ readonly replacement: string;
44
+ readonly introducedIn: string;
45
+ readonly deprecatedIn: string;
46
+ readonly removalPolicy: string;
47
+ }
48
+
49
+ /**
50
+ * `auto` is represented as a deprecated selection alias, not a format contract.
51
+ * It resolves to "no explicit format; run detection."
52
+ */
53
+ export const SELECTION_ALIASES: Readonly<
54
+ Record<string, SelectionAliasMetadata>
55
+ > = {
56
+ auto: {
57
+ id: "auto",
58
+ status: "deprecated",
59
+ description:
60
+ "Legacy selection alias that defers to format detection. Not a representation contract.",
61
+ replacement: "Omit format selection to trigger detection automatically.",
62
+ introducedIn: "0.1.0",
63
+ deprecatedIn: "1.0.0",
64
+ removalPolicy:
65
+ "Will be removed in 2.0.0. Migrate by omitting the format field entirely.",
66
+ },
67
+ };
68
+
69
+ // ═══════════════════════════════════════════════════════════════════════════════
70
+ // Compatibility Profile Helpers
71
+ // ═══════════════════════════════════════════════════════════════════════════════
72
+
73
+ /** All canonical capabilities required in every profile */
74
+ const ALL_CAPABILITIES = [
75
+ "frontmatter",
76
+ "body",
77
+ "hooks",
78
+ "mcp-servers",
79
+ "workflows",
80
+ "body-overrides",
81
+ "extra-fields",
82
+ "path-scoping",
83
+ "toggleable-rules",
84
+ "file-match-inclusion",
85
+ "system-prompt-merging",
86
+ "skill",
87
+ "power",
88
+ "rule",
89
+ "workflow",
90
+ "agent",
91
+ "prompt",
92
+ "template",
93
+ "reference-pack",
94
+ ] as const;
95
+
96
+ /** Profile where every capability is fully supported */
97
+ function fullProfile(): RosettaCompatibilityProfile {
98
+ const profile: Record<string, { support: "full" }> = {};
99
+ for (const cap of ALL_CAPABILITIES) {
100
+ profile[cap] = { support: "full" };
101
+ }
102
+ return profile as unknown as RosettaCompatibilityProfile;
103
+ }
104
+
105
+ // ═══════════════════════════════════════════════════════════════════════════════
106
+ // Built-in Format Contracts
107
+ // ═══════════════════════════════════════════════════════════════════════════════
108
+
109
+ /**
110
+ * Canonical artifact directory format — the native source representation.
111
+ */
112
+ export const KANON_CANONICAL_CONTRACT: FormatContract = {
113
+ id: "kanon-canonical" as FormatIdentifier,
114
+ contractVersion: "1.0",
115
+ direction: "bidirectional",
116
+ harness: null,
117
+ aliases: ["canonical" as FormatIdentifier],
118
+ lifecycle: { status: "active", introducedIn: "1.0.0" },
119
+ canonicalVersions: { minInclusive: "1.0.0", maxExclusive: "2.0.0" },
120
+ schemaReference: {
121
+ type: "zod",
122
+ location: "src/schemas.ts#KnowledgeArtifactSchema",
123
+ description: "Zod schema for canonical knowledge artifacts",
124
+ },
125
+ pathConventions: [
126
+ {
127
+ pattern: "knowledge.md",
128
+ required: true,
129
+ description: "Main artifact file with YAML frontmatter and Markdown body",
130
+ },
131
+ {
132
+ pattern: "hooks.yaml",
133
+ required: false,
134
+ description: "Canonical lifecycle hooks",
135
+ },
136
+ {
137
+ pattern: "mcp-servers.yaml",
138
+ required: false,
139
+ description: "MCP server declarations",
140
+ },
141
+ {
142
+ pattern: "workflows/*.md",
143
+ required: false,
144
+ description: "Workflow phase files",
145
+ },
146
+ ],
147
+ detection: {
148
+ threshold: 0.6,
149
+ rules: [
150
+ {
151
+ id: "knowledge-md",
152
+ kind: "basename",
153
+ pattern: "knowledge.md",
154
+ weight: 50,
155
+ required: true,
156
+ evidenceLabel: "knowledge.md present",
157
+ },
158
+ {
159
+ id: "frontmatter-name",
160
+ kind: "frontmatter-key",
161
+ pattern: "name",
162
+ weight: 20,
163
+ required: false,
164
+ evidenceLabel: "Frontmatter 'name' key",
165
+ },
166
+ {
167
+ id: "frontmatter-type",
168
+ kind: "frontmatter-key",
169
+ pattern: "type",
170
+ weight: 20,
171
+ required: false,
172
+ evidenceLabel: "Frontmatter 'type' key",
173
+ },
174
+ {
175
+ id: "hooks-yaml",
176
+ kind: "basename",
177
+ pattern: "hooks.yaml",
178
+ weight: 10,
179
+ required: false,
180
+ evidenceLabel: "hooks.yaml companion",
181
+ },
182
+ ],
183
+ },
184
+ variants: {},
185
+ optionDefinitions: {},
186
+ defaults: {},
187
+ normalizationRules: [
188
+ {
189
+ id: "nfc-paths",
190
+ description: "Normalize all relative paths to NFC",
191
+ scope: "both",
192
+ },
193
+ {
194
+ id: "trim-body",
195
+ description: "Trim trailing whitespace from body content",
196
+ scope: "source",
197
+ },
198
+ ],
199
+ compatibility: fullProfile(),
200
+ security: {
201
+ sensitiveValuePolicy: "reference-only",
202
+ allowedReferencePatterns: ["\\$\\{[A-Z_]+\\}"],
203
+ },
204
+ };
205
+
206
+ /**
207
+ * Kiro harness format — steering files, skills, hooks, and MCP config.
208
+ */
209
+ export const KIRO_CONTRACT: FormatContract = {
210
+ id: "kiro" as FormatIdentifier,
211
+ contractVersion: "1.0",
212
+ direction: "bidirectional",
213
+ harness: "kiro",
214
+ aliases: [],
215
+ lifecycle: { status: "active", introducedIn: "1.0.0" },
216
+ canonicalVersions: { minInclusive: "1.0.0", maxExclusive: "2.0.0" },
217
+ schemaReference: {
218
+ type: "none",
219
+ description: "Kiro steering/skill file conventions",
220
+ },
221
+ pathConventions: [
222
+ {
223
+ pattern: ".kiro/steering/*.md",
224
+ required: false,
225
+ description: "Steering files",
226
+ },
227
+ {
228
+ pattern: ".kiro/skills/*/SKILL.md",
229
+ required: false,
230
+ description: "Skill definition files",
231
+ },
232
+ { pattern: ".kiro/hooks/*.md", required: false, description: "Hook files" },
233
+ ],
234
+ detection: {
235
+ threshold: 0.5,
236
+ rules: [
237
+ {
238
+ id: "kiro-dir",
239
+ kind: "path-glob",
240
+ pattern: ".kiro/**",
241
+ weight: 40,
242
+ required: false,
243
+ evidenceLabel: ".kiro directory structure",
244
+ },
245
+ {
246
+ id: "steering-md",
247
+ kind: "path-glob",
248
+ pattern: ".kiro/steering/*.md",
249
+ weight: 30,
250
+ required: false,
251
+ evidenceLabel: "Kiro steering file",
252
+ },
253
+ {
254
+ id: "skill-md",
255
+ kind: "basename",
256
+ pattern: "SKILL.md",
257
+ weight: 20,
258
+ required: false,
259
+ evidenceLabel: "SKILL.md marker",
260
+ },
261
+ ],
262
+ },
263
+ variants: {
264
+ steering: {
265
+ id: "steering" as FormatIdentifier,
266
+ description: "Kiro steering file format",
267
+ pathConventions: [{ pattern: ".kiro/steering/*.md", required: true }],
268
+ defaults: {},
269
+ optionOverrides: {},
270
+ },
271
+ power: {
272
+ id: "power" as FormatIdentifier,
273
+ description: "Kiro power format",
274
+ pathConventions: [{ pattern: ".kiro/skills/*/SKILL.md", required: true }],
275
+ defaults: {},
276
+ optionOverrides: {},
277
+ },
278
+ },
279
+ defaultVariant: "steering" as FormatIdentifier,
280
+ optionDefinitions: {},
281
+ defaults: {},
282
+ normalizationRules: [
283
+ {
284
+ id: "frontmatter-yaml",
285
+ description: "Normalize YAML frontmatter to standard key order",
286
+ scope: "source",
287
+ },
288
+ ],
289
+ compatibility: KIRO_STEERING_PROFILE,
290
+ security: {
291
+ sensitiveValuePolicy: "reference-only",
292
+ allowedReferencePatterns: ["\\$\\{[A-Z_]+\\}"],
293
+ },
294
+ };
295
+
296
+ /**
297
+ * Claude Code harness format — CLAUDE.md and settings.
298
+ */
299
+ export const CLAUDE_CODE_CONTRACT: FormatContract = {
300
+ id: "claude-code" as FormatIdentifier,
301
+ contractVersion: "1.0",
302
+ direction: "bidirectional",
303
+ harness: "claude-code",
304
+ aliases: ["claude" as FormatIdentifier],
305
+ lifecycle: { status: "active", introducedIn: "1.0.0" },
306
+ canonicalVersions: { minInclusive: "1.0.0", maxExclusive: "2.0.0" },
307
+ schemaReference: {
308
+ type: "none",
309
+ description: "Claude Code CLAUDE.md conventions",
310
+ },
311
+ pathConventions: [
312
+ {
313
+ pattern: "CLAUDE.md",
314
+ required: false,
315
+ description: "Root Claude instructions",
316
+ },
317
+ {
318
+ pattern: ".claude/settings.json",
319
+ required: false,
320
+ description: "Claude settings",
321
+ },
322
+ ],
323
+ detection: {
324
+ threshold: 0.5,
325
+ rules: [
326
+ {
327
+ id: "claude-md",
328
+ kind: "basename",
329
+ pattern: "CLAUDE.md",
330
+ weight: 50,
331
+ required: false,
332
+ evidenceLabel: "CLAUDE.md present",
333
+ },
334
+ {
335
+ id: "claude-settings",
336
+ kind: "path-glob",
337
+ pattern: ".claude/settings.json",
338
+ weight: 30,
339
+ required: false,
340
+ evidenceLabel: "Claude settings directory",
341
+ },
342
+ ],
343
+ },
344
+ variants: {
345
+ "claude-md": {
346
+ id: "claude-md" as FormatIdentifier,
347
+ description: "CLAUDE.md Markdown format",
348
+ pathConventions: [{ pattern: "CLAUDE.md", required: true }],
349
+ defaults: {},
350
+ optionOverrides: {},
351
+ },
352
+ },
353
+ defaultVariant: "claude-md" as FormatIdentifier,
354
+ optionDefinitions: {},
355
+ defaults: {},
356
+ normalizationRules: [
357
+ {
358
+ id: "merge-sections",
359
+ description: "Merge duplicate heading sections",
360
+ scope: "source",
361
+ },
362
+ ],
363
+ compatibility: CLAUDE_CODE_PROFILE,
364
+ security: { sensitiveValuePolicy: "reject", allowedReferencePatterns: [] },
365
+ };
366
+
367
+ /**
368
+ * Codex harness format — AGENTS.md, skills, and TOML MCP config.
369
+ */
370
+ export const CODEX_CONTRACT: FormatContract = {
371
+ id: "codex" as FormatIdentifier,
372
+ contractVersion: "1.0",
373
+ direction: "bidirectional",
374
+ harness: "codex",
375
+ aliases: [],
376
+ lifecycle: { status: "active", introducedIn: "1.0.0" },
377
+ canonicalVersions: { minInclusive: "1.0.0", maxExclusive: "2.0.0" },
378
+ schemaReference: {
379
+ type: "none",
380
+ description: "Codex AGENTS.md and skill conventions",
381
+ },
382
+ pathConventions: [
383
+ {
384
+ pattern: "AGENTS.md",
385
+ required: false,
386
+ description: "Root Codex instructions",
387
+ },
388
+ {
389
+ pattern: ".codex-plugin/plugin.json",
390
+ required: false,
391
+ description: "Codex plugin manifest",
392
+ },
393
+ ],
394
+ detection: {
395
+ threshold: 0.5,
396
+ rules: [
397
+ {
398
+ id: "agents-md",
399
+ kind: "basename",
400
+ pattern: "AGENTS.md",
401
+ weight: 50,
402
+ required: false,
403
+ evidenceLabel: "AGENTS.md present",
404
+ },
405
+ {
406
+ id: "codex-plugin",
407
+ kind: "path-glob",
408
+ pattern: ".codex-plugin/**",
409
+ weight: 30,
410
+ required: false,
411
+ evidenceLabel: "Codex plugin directory",
412
+ },
413
+ ],
414
+ },
415
+ variants: {
416
+ "agents-md": {
417
+ id: "agents-md" as FormatIdentifier,
418
+ description: "AGENTS.md Markdown format",
419
+ pathConventions: [{ pattern: "AGENTS.md", required: true }],
420
+ defaults: {},
421
+ optionOverrides: {},
422
+ },
423
+ skill: {
424
+ id: "skill" as FormatIdentifier,
425
+ description: "Codex skill format with references",
426
+ pathConventions: [{ pattern: "references/*.md", required: false }],
427
+ defaults: {},
428
+ optionOverrides: {},
429
+ },
430
+ },
431
+ defaultVariant: "agents-md" as FormatIdentifier,
432
+ optionDefinitions: {},
433
+ defaults: {},
434
+ normalizationRules: [
435
+ {
436
+ id: "toml-mcp-normalize",
437
+ description: "Normalize TOML MCP server configuration",
438
+ scope: "source",
439
+ },
440
+ ],
441
+ compatibility: CODEX_PROFILE,
442
+ security: {
443
+ sensitiveValuePolicy: "reference-only",
444
+ allowedReferencePatterns: ["\\$\\{[A-Z_]+\\}"],
445
+ },
446
+ };
447
+
448
+ /**
449
+ * GitHub Copilot harness format — instruction files and agent definitions.
450
+ */
451
+ export const COPILOT_CONTRACT: FormatContract = {
452
+ id: "copilot" as FormatIdentifier,
453
+ contractVersion: "1.0",
454
+ direction: "bidirectional",
455
+ harness: "copilot",
456
+ aliases: ["github-copilot" as FormatIdentifier],
457
+ lifecycle: { status: "active", introducedIn: "1.0.0" },
458
+ canonicalVersions: { minInclusive: "1.0.0", maxExclusive: "2.0.0" },
459
+ schemaReference: {
460
+ type: "none",
461
+ description: "Copilot instruction and agent file conventions",
462
+ },
463
+ pathConventions: [
464
+ {
465
+ pattern: ".github/copilot-instructions.md",
466
+ required: false,
467
+ description: "Global Copilot instructions",
468
+ },
469
+ {
470
+ pattern: ".github/copilot/*.md",
471
+ required: false,
472
+ description: "Copilot agent files",
473
+ },
474
+ ],
475
+ detection: {
476
+ threshold: 0.5,
477
+ rules: [
478
+ {
479
+ id: "copilot-instructions",
480
+ kind: "path-glob",
481
+ pattern: ".github/copilot-instructions.md",
482
+ weight: 50,
483
+ required: false,
484
+ evidenceLabel: "Copilot instructions file",
485
+ },
486
+ {
487
+ id: "copilot-agents",
488
+ kind: "path-glob",
489
+ pattern: ".github/copilot/*.md",
490
+ weight: 30,
491
+ required: false,
492
+ evidenceLabel: "Copilot agent files",
493
+ },
494
+ ],
495
+ },
496
+ variants: {
497
+ instructions: {
498
+ id: "instructions" as FormatIdentifier,
499
+ description: "Copilot instructions format",
500
+ pathConventions: [
501
+ { pattern: ".github/copilot-instructions.md", required: true },
502
+ ],
503
+ defaults: {},
504
+ optionOverrides: {},
505
+ },
506
+ agent: {
507
+ id: "agent" as FormatIdentifier,
508
+ description: "Copilot agent format",
509
+ pathConventions: [{ pattern: ".github/copilot/*.md", required: true }],
510
+ defaults: {},
511
+ optionOverrides: {},
512
+ },
513
+ },
514
+ defaultVariant: "instructions" as FormatIdentifier,
515
+ optionDefinitions: {},
516
+ defaults: {},
517
+ normalizationRules: [
518
+ {
519
+ id: "instruction-frontmatter",
520
+ description: "Normalize YAML frontmatter in instruction files",
521
+ scope: "source",
522
+ },
523
+ ],
524
+ compatibility: COPILOT_PROFILE,
525
+ security: { sensitiveValuePolicy: "reject", allowedReferencePatterns: [] },
526
+ };
527
+
528
+ /**
529
+ * Cursor harness format — rule files.
530
+ */
531
+ export const CURSOR_CONTRACT: FormatContract = {
532
+ id: "cursor" as FormatIdentifier,
533
+ contractVersion: "1.0",
534
+ direction: "bidirectional",
535
+ harness: "cursor",
536
+ aliases: [],
537
+ lifecycle: { status: "active", introducedIn: "1.0.0" },
538
+ canonicalVersions: { minInclusive: "1.0.0", maxExclusive: "2.0.0" },
539
+ schemaReference: {
540
+ type: "none",
541
+ description: "Cursor rule file conventions",
542
+ },
543
+ pathConventions: [
544
+ {
545
+ pattern: ".cursor/rules/*.mdc",
546
+ required: false,
547
+ description: "Cursor rule files",
548
+ },
549
+ ],
550
+ detection: {
551
+ threshold: 0.5,
552
+ rules: [
553
+ {
554
+ id: "cursor-rules",
555
+ kind: "path-glob",
556
+ pattern: ".cursor/rules/*.mdc",
557
+ weight: 50,
558
+ required: false,
559
+ evidenceLabel: "Cursor rules directory",
560
+ },
561
+ {
562
+ id: "cursorrules",
563
+ kind: "basename",
564
+ pattern: ".cursorrules",
565
+ weight: 30,
566
+ required: false,
567
+ evidenceLabel: "Legacy .cursorrules file",
568
+ },
569
+ ],
570
+ },
571
+ variants: {
572
+ rule: {
573
+ id: "rule" as FormatIdentifier,
574
+ description: "Cursor rule format",
575
+ pathConventions: [{ pattern: ".cursor/rules/*.mdc", required: true }],
576
+ defaults: {},
577
+ optionOverrides: {},
578
+ },
579
+ },
580
+ defaultVariant: "rule" as FormatIdentifier,
581
+ optionDefinitions: {},
582
+ defaults: {},
583
+ normalizationRules: [
584
+ {
585
+ id: "mdc-frontmatter",
586
+ description: "Normalize MDC frontmatter format",
587
+ scope: "source",
588
+ },
589
+ ],
590
+ compatibility: CURSOR_PROFILE,
591
+ security: { sensitiveValuePolicy: "reject", allowedReferencePatterns: [] },
592
+ };
593
+
594
+ /**
595
+ * Windsurf harness format — rule files.
596
+ */
597
+ export const WINDSURF_CONTRACT: FormatContract = {
598
+ id: "windsurf" as FormatIdentifier,
599
+ contractVersion: "1.0",
600
+ direction: "bidirectional",
601
+ harness: "windsurf",
602
+ aliases: [],
603
+ lifecycle: { status: "active", introducedIn: "1.0.0" },
604
+ canonicalVersions: { minInclusive: "1.0.0", maxExclusive: "2.0.0" },
605
+ schemaReference: {
606
+ type: "none",
607
+ description: "Windsurf rule file conventions",
608
+ },
609
+ pathConventions: [
610
+ {
611
+ pattern: ".windsurf/rules/*.md",
612
+ required: false,
613
+ description: "Windsurf rule files",
614
+ },
615
+ ],
616
+ detection: {
617
+ threshold: 0.5,
618
+ rules: [
619
+ {
620
+ id: "windsurf-rules",
621
+ kind: "path-glob",
622
+ pattern: ".windsurf/rules/*.md",
623
+ weight: 50,
624
+ required: false,
625
+ evidenceLabel: "Windsurf rules directory",
626
+ },
627
+ {
628
+ id: "windsurfrules",
629
+ kind: "basename",
630
+ pattern: ".windsurfrules",
631
+ weight: 30,
632
+ required: false,
633
+ evidenceLabel: "Legacy .windsurfrules file",
634
+ },
635
+ ],
636
+ },
637
+ variants: {
638
+ rule: {
639
+ id: "rule" as FormatIdentifier,
640
+ description: "Windsurf rule format",
641
+ pathConventions: [{ pattern: ".windsurf/rules/*.md", required: true }],
642
+ defaults: {},
643
+ optionOverrides: {},
644
+ },
645
+ },
646
+ defaultVariant: "rule" as FormatIdentifier,
647
+ optionDefinitions: {},
648
+ defaults: {},
649
+ normalizationRules: [
650
+ {
651
+ id: "rule-frontmatter",
652
+ description: "Normalize Markdown frontmatter in rule files",
653
+ scope: "source",
654
+ },
655
+ ],
656
+ compatibility: WINDSURF_PROFILE,
657
+ security: { sensitiveValuePolicy: "reject", allowedReferencePatterns: [] },
658
+ };
659
+
660
+ /**
661
+ * Cline harness format — rule files.
662
+ */
663
+ export const CLINE_CONTRACT: FormatContract = {
664
+ id: "cline" as FormatIdentifier,
665
+ contractVersion: "1.0",
666
+ direction: "bidirectional",
667
+ harness: "cline",
668
+ aliases: [],
669
+ lifecycle: { status: "active", introducedIn: "1.0.0" },
670
+ canonicalVersions: { minInclusive: "1.0.0", maxExclusive: "2.0.0" },
671
+ schemaReference: { type: "none", description: "Cline rule file conventions" },
672
+ pathConventions: [
673
+ {
674
+ pattern: ".cline/rules/*.md",
675
+ required: false,
676
+ description: "Cline rule files",
677
+ },
678
+ {
679
+ pattern: ".clinerules",
680
+ required: false,
681
+ description: "Legacy Cline rules file",
682
+ },
683
+ ],
684
+ detection: {
685
+ threshold: 0.5,
686
+ rules: [
687
+ {
688
+ id: "cline-rules",
689
+ kind: "path-glob",
690
+ pattern: ".cline/rules/*.md",
691
+ weight: 50,
692
+ required: false,
693
+ evidenceLabel: "Cline rules directory",
694
+ },
695
+ {
696
+ id: "clinerules",
697
+ kind: "basename",
698
+ pattern: ".clinerules",
699
+ weight: 30,
700
+ required: false,
701
+ evidenceLabel: "Legacy .clinerules file",
702
+ },
703
+ ],
704
+ },
705
+ variants: {
706
+ rule: {
707
+ id: "rule" as FormatIdentifier,
708
+ description: "Cline rule format",
709
+ pathConventions: [{ pattern: ".cline/rules/*.md", required: true }],
710
+ defaults: {},
711
+ optionOverrides: {},
712
+ },
713
+ },
714
+ defaultVariant: "rule" as FormatIdentifier,
715
+ optionDefinitions: {},
716
+ defaults: {},
717
+ normalizationRules: [
718
+ {
719
+ id: "rule-frontmatter",
720
+ description: "Normalize Markdown frontmatter in rule files",
721
+ scope: "source",
722
+ },
723
+ ],
724
+ compatibility: CLINE_PROFILE,
725
+ security: { sensitiveValuePolicy: "reject", allowedReferencePatterns: [] },
726
+ };
727
+
728
+ /**
729
+ * Amazon Q Developer harness format — rule and agent files.
730
+ */
731
+ export const QDEVELOPER_CONTRACT: FormatContract = {
732
+ id: "qdeveloper" as FormatIdentifier,
733
+ contractVersion: "1.0",
734
+ direction: "bidirectional",
735
+ harness: "qdeveloper",
736
+ aliases: ["q-developer" as FormatIdentifier, "amazon-q" as FormatIdentifier],
737
+ lifecycle: { status: "active", introducedIn: "1.0.0" },
738
+ canonicalVersions: { minInclusive: "1.0.0", maxExclusive: "2.0.0" },
739
+ schemaReference: {
740
+ type: "none",
741
+ description: "Amazon Q Developer rule and agent file conventions",
742
+ },
743
+ pathConventions: [
744
+ {
745
+ pattern: ".amazonq/rules/*.md",
746
+ required: false,
747
+ description: "Q Developer rule files",
748
+ },
749
+ {
750
+ pattern: ".amazonq/agents/*.md",
751
+ required: false,
752
+ description: "Q Developer agent files",
753
+ },
754
+ ],
755
+ detection: {
756
+ threshold: 0.5,
757
+ rules: [
758
+ {
759
+ id: "amazonq-rules",
760
+ kind: "path-glob",
761
+ pattern: ".amazonq/rules/*.md",
762
+ weight: 50,
763
+ required: false,
764
+ evidenceLabel: "Amazon Q rules directory",
765
+ },
766
+ {
767
+ id: "amazonq-agents",
768
+ kind: "path-glob",
769
+ pattern: ".amazonq/agents/*.md",
770
+ weight: 20,
771
+ required: false,
772
+ evidenceLabel: "Amazon Q agents directory",
773
+ },
774
+ ],
775
+ },
776
+ variants: {
777
+ rule: {
778
+ id: "rule" as FormatIdentifier,
779
+ description: "Q Developer rule format",
780
+ pathConventions: [{ pattern: ".amazonq/rules/*.md", required: true }],
781
+ defaults: {},
782
+ optionOverrides: {},
783
+ },
784
+ agent: {
785
+ id: "agent" as FormatIdentifier,
786
+ description: "Q Developer agent format",
787
+ pathConventions: [{ pattern: ".amazonq/agents/*.md", required: true }],
788
+ defaults: {},
789
+ optionOverrides: {},
790
+ },
791
+ },
792
+ defaultVariant: "rule" as FormatIdentifier,
793
+ optionDefinitions: {},
794
+ defaults: {},
795
+ normalizationRules: [
796
+ {
797
+ id: "rule-frontmatter",
798
+ description: "Normalize Markdown frontmatter in rule files",
799
+ scope: "source",
800
+ },
801
+ ],
802
+ compatibility: QDEVELOPER_PROFILE,
803
+ security: { sensitiveValuePolicy: "reject", allowedReferencePatterns: [] },
804
+ };
805
+
806
+ /**
807
+ * Kiro Power format — source-only, path-based POWER.md plus steering/.
808
+ */
809
+ export const KIRO_POWER_CONTRACT: FormatContract = {
810
+ id: "kiro-power" as FormatIdentifier,
811
+ contractVersion: "1.0",
812
+ direction: "source",
813
+ harness: "kiro",
814
+ aliases: [],
815
+ lifecycle: {
816
+ status: "active",
817
+ introducedIn: "0.1.0",
818
+ },
819
+ canonicalVersions: { minInclusive: "1.0.0", maxExclusive: "2.0.0" },
820
+ schemaReference: {
821
+ type: "none",
822
+ description: "Kiro Power POWER.md structure",
823
+ },
824
+ pathConventions: [
825
+ {
826
+ pattern: "POWER.md",
827
+ required: true,
828
+ description: "Power definition file",
829
+ },
830
+ {
831
+ pattern: "steering/*.md",
832
+ required: false,
833
+ description: "Power steering files",
834
+ },
835
+ ],
836
+ detection: {
837
+ threshold: 0.5,
838
+ rules: [
839
+ {
840
+ id: "power-md",
841
+ kind: "basename",
842
+ pattern: "POWER.md",
843
+ weight: 60,
844
+ required: true,
845
+ evidenceLabel: "POWER.md present",
846
+ },
847
+ {
848
+ id: "steering-dir",
849
+ kind: "path-glob",
850
+ pattern: "steering/*.md",
851
+ weight: 20,
852
+ required: false,
853
+ evidenceLabel: "Steering directory",
854
+ },
855
+ ],
856
+ },
857
+ variants: {},
858
+ optionDefinitions: {},
859
+ defaults: {},
860
+ normalizationRules: [
861
+ {
862
+ id: "power-frontmatter",
863
+ description: "Normalize POWER.md frontmatter",
864
+ scope: "source",
865
+ },
866
+ ],
867
+ compatibility: fullProfile(),
868
+ security: {
869
+ sensitiveValuePolicy: "reference-only",
870
+ allowedReferencePatterns: ["\\$\\{[A-Z_]+\\}"],
871
+ },
872
+ };
873
+
874
+ /**
875
+ * Kiro Skill format — source-only, path-based SKILL.md plus references/.
876
+ */
877
+ export const KIRO_SKILL_CONTRACT: FormatContract = {
878
+ id: "kiro-skill" as FormatIdentifier,
879
+ contractVersion: "1.0",
880
+ direction: "source",
881
+ harness: "kiro",
882
+ aliases: [],
883
+ lifecycle: {
884
+ status: "active",
885
+ introducedIn: "0.1.0",
886
+ },
887
+ canonicalVersions: { minInclusive: "1.0.0", maxExclusive: "2.0.0" },
888
+ schemaReference: {
889
+ type: "none",
890
+ description: "Kiro Skill SKILL.md structure",
891
+ },
892
+ pathConventions: [
893
+ {
894
+ pattern: "SKILL.md",
895
+ required: true,
896
+ description: "Skill definition file",
897
+ },
898
+ {
899
+ pattern: "references/*.md",
900
+ required: false,
901
+ description: "Skill reference files",
902
+ },
903
+ ],
904
+ detection: {
905
+ threshold: 0.5,
906
+ rules: [
907
+ {
908
+ id: "skill-md",
909
+ kind: "basename",
910
+ pattern: "SKILL.md",
911
+ weight: 60,
912
+ required: true,
913
+ evidenceLabel: "SKILL.md present",
914
+ },
915
+ {
916
+ id: "references-dir",
917
+ kind: "path-glob",
918
+ pattern: "references/*.md",
919
+ weight: 20,
920
+ required: false,
921
+ evidenceLabel: "References directory",
922
+ },
923
+ ],
924
+ },
925
+ variants: {},
926
+ optionDefinitions: {},
927
+ defaults: {},
928
+ normalizationRules: [
929
+ {
930
+ id: "skill-frontmatter",
931
+ description: "Normalize SKILL.md frontmatter",
932
+ scope: "source",
933
+ },
934
+ ],
935
+ compatibility: fullProfile(),
936
+ security: {
937
+ sensitiveValuePolicy: "reference-only",
938
+ allowedReferencePatterns: ["\\$\\{[A-Z_]+\\}"],
939
+ },
940
+ };
941
+
942
+ /**
943
+ * Superpowers format — source-only, SKILL.md plus companion Markdown.
944
+ */
945
+ export const SUPERPOWERS_CONTRACT: FormatContract = {
946
+ id: "superpowers" as FormatIdentifier,
947
+ contractVersion: "1.0",
948
+ direction: "source",
949
+ harness: null,
950
+ aliases: [],
951
+ lifecycle: {
952
+ status: "deprecated",
953
+ introducedIn: "0.1.0",
954
+ deprecatedIn: "1.0.0",
955
+ replacement: undefined,
956
+ },
957
+ canonicalVersions: { minInclusive: "1.0.0", maxExclusive: "2.0.0" },
958
+ schemaReference: {
959
+ type: "none",
960
+ description: "Superpowers SKILL.md plus companion Markdown structure",
961
+ },
962
+ pathConventions: [
963
+ {
964
+ pattern: "SKILL.md",
965
+ required: true,
966
+ description: "Superpowers skill definition",
967
+ },
968
+ {
969
+ pattern: "*.md",
970
+ required: false,
971
+ description: "Companion Markdown files",
972
+ },
973
+ ],
974
+ detection: {
975
+ threshold: 0.5,
976
+ rules: [
977
+ {
978
+ id: "superpowers-skill",
979
+ kind: "basename",
980
+ pattern: "SKILL.md",
981
+ weight: 40,
982
+ required: true,
983
+ evidenceLabel: "SKILL.md present",
984
+ },
985
+ {
986
+ id: "superpowers-dir",
987
+ kind: "path-glob",
988
+ pattern: ".superpowers/**",
989
+ weight: 40,
990
+ required: false,
991
+ evidenceLabel: ".superpowers directory",
992
+ },
993
+ ],
994
+ },
995
+ variants: {},
996
+ optionDefinitions: {},
997
+ defaults: {},
998
+ normalizationRules: [
999
+ {
1000
+ id: "companion-normalize",
1001
+ description: "Normalize companion Markdown filenames to kebab-case",
1002
+ scope: "source",
1003
+ },
1004
+ ],
1005
+ compatibility: fullProfile(),
1006
+ security: {
1007
+ sensitiveValuePolicy: "reference-only",
1008
+ allowedReferencePatterns: ["\\$\\{[A-Z_]+\\}"],
1009
+ },
1010
+ };
1011
+
1012
+ // ═══════════════════════════════════════════════════════════════════════════════
1013
+ // Aggregate Export
1014
+ // ═══════════════════════════════════════════════════════════════════════════════
1015
+
1016
+ /**
1017
+ * All built-in format contracts in registration order.
1018
+ * Order: kanon-canonical first, then harness-native alphabetically, then source-only.
1019
+ */
1020
+ export const BUILTIN_FORMAT_CONTRACTS: readonly FormatContract[] = [
1021
+ KANON_CANONICAL_CONTRACT,
1022
+ CLAUDE_CODE_CONTRACT,
1023
+ CLINE_CONTRACT,
1024
+ CODEX_CONTRACT,
1025
+ COPILOT_CONTRACT,
1026
+ CURSOR_CONTRACT,
1027
+ KIRO_CONTRACT,
1028
+ QDEVELOPER_CONTRACT,
1029
+ WINDSURF_CONTRACT,
1030
+ KIRO_POWER_CONTRACT,
1031
+ KIRO_SKILL_CONTRACT,
1032
+ SUPERPOWERS_CONTRACT,
1033
+ ];